<?
function ctrc_form()
{
global  $fslct, $citdrdwn, $adrghtcol, $cspvar2 ;

 
$ctrc_mss=$fslct['country'];

echo "
<p>
<a href='admconf.php'><b>Top:</b></a><br>
<form action='admconf.php?mdopt=savectrc' method='post'>

<table width='100%'    border='0' cellspacing='1' cellpadding='0'> 
<tr><td  class='frmft1'>
 &nbsp; Setting Countries/Cities: 
</td></tr></table>

$cspvar2

<table width='600' cellspacing='10' cellpadding='10'>
<tr><td> 

Countries/Cities List:<br>
";

$str_ctrc="";
foreach ($ctrc_mss as $key => $value )
{

$str_ctrc=$str_ctrc."
".$key.":
";

$cit_mss=$value;

foreach ($cit_mss as $val_ct) {
$str_ctrc=$str_ctrc.opt_qt($val_ct)."
";
}
}

echo " 
<textarea rows='20' cols='40' name='str_ctrc' wrap=off class=formst>".$str_ctrc."</textarea>
</td><td valign='top' width='200'>
Countries/Cities format:
<p>
Country 1:<br>
City 1<br> 
City 2<br> 
City 3<br> 
City 4<br> 
........<br>
City N<p>

Country 2:<br>
City 1<br> 
City 2<br> 
City 3<br> 
City 4<br> 
........<br>
City N<p>
........
 
</td></tr></table>

<table width='100%' cellspacing='10' cellpadding='10'>
<tr><td>
<p>
Set up drop down menu for cities list on the top page instead the list with links:<br>
<select name='citdrdwn' class='formst'>
<option>".opt_qt($citdrdwn)."<checked><option>yes<option>no</select>
  
<p>

HTML code for right column on the top page before country was selected:<br>
<textarea rows='20' cols='80' name='adrghtcol' wrap=off class=formst>".$adrghtcol."</textarea>

";

echo "
<p>
<input type='submit' value='Save Options' class='formst1'>
</form>
</td></tr></table>
";

}
 
function savectrc()
{
global $opt_post, $conf_dir, $opt_header, $opt_footer;

$cfgstr=save_ctlst();
$cfgstr=$cfgstr.save_opt("citdrdwn"); 
$cfgstr=$cfgstr.save_opt("adrghtcol"); 
$cfgstr="<?
$cfgstr
?>";

savecfl($cfgstr, "conf_ctr.php");
echo "
<p>&nbsp;<p><font class='fntmsg1'>Countires/Cities list  has been saved successfully !</font>
<p>
 
";
}

function save_ctlst()
{
global $opt_post;

$ctc_str=$opt_post['str_ctrc'];
 

$dlvl="
";

$ctc_ms=split($dlvl, $ctc_str);

$res="$"."fslct['country']=array(";

$key1=0; $key2=0;
foreach($ctc_ms as $value){
$value = preg_replace ("/\r/", "", $value);
$ctc_val=check_opt($value);
if ($value!=""){
$key1++;

preg_match("/(.*):$/U", $ctc_val, $matches);
$cit_ms=split(":",$ctc_val); 
if($matches[1]!=""){
$key2++; 
if (($key2==1) and ($key1!=1)) {

echo "<p>&nbsp;<p><font class='fntmsg2'>Incorrect format for countries/cities list</font>";
echo $opt_footer;
exit;
}

if ($key2>1){ $res = preg_replace ("/,\s+$/", "", $res); $res=$res." ),";} 
$res=$res."
\"".$cit_ms[0]."\" => array (";
}
else{
 $res=$res."\"$value\", ";} 
}
}
$res = preg_replace ("/,\s+$/", "", $res);
$res=$res." )
);

";

return $res;

}

?>