
<?php
   //foreach($_POST as $key => $value)
   //  Print $key." - ".$value."<br>";
   include('../pollconfig.inc');
   if(!empty($_POST['SaveSettings']))
   {
     //инициализируем переменные
     if($_POST['ShowTips'] == 'on')
       $ShowTips = 'yes'; else $ShowTips = 'no';
     if($_POST['cookie'] == 'on')
       $ProtCookie = 'yes'; else $ProtCookie = 'no';
     if($_POST['session'] == 'on')
       $ProtSession = 'yes'; else $ProtSession = 'no';
     if($_POST['ip'] == 'on')
       $ProtIp = 'yes'; else $ProtIp = 'no';
     if($_POST['ShowResultsOnFirst'] == 'on')
       $ShowResultsOnFirst = 'yes'; else $ShowResultsOnFirst = 'no';
     if($_POST['changeformperm'] == 'on')
       $ChangeFormPerm = 'yes'; else $ChangeFormPerm = 'no';
     $Language = $_POST['language'];
     $ShowResForm = $_POST['showresform'];
     //время сохранения cookie
     $KeepCookieTmp = $_POST['keepcookie'];
     if(empty($KeepCookieTmp))
       $Errors[] = $Err_NoKeepCookieTime;
     elseif(!preg_match("|^[\d]+$|i", $KeepCookieTmp))
       $Errors[] = $Err_IncorrKeepCookieTime;
     elseif(((int)$KeepCookieTmp > 371) || ((int)$KeepCookieTmp < 1))
       $Errors[] = $Err_IncorrKeepCookieTime;
     //Время хранения IP
     $KeepIpTmp = $_POST['keepip'];
     if(empty($KeepIpTmp))
       $Errors[] = $Err_NoKeepIpTime;
     elseif(!preg_match("|^[\d]+$|i", $KeepIpTmp))
       $Errors[] = $Err_IncorrKeepIpTime;
     elseif(((int)$KeepIpTmp > 60) || ((int)$KeepIpTmp < 1))
       $Errors[] = $Err_IncorrKeepIpTime;
     //постраничная навигация - база участников
     $PollUsers_ItemPerPage = $_POST['pollusers_itemperpage'];
     if(empty($PollUsers_ItemPerPage))
       $Errors[] = $Cpt_NoNav_Pollusers;
     elseif(!preg_match("|^[\d]+$|i", $PollUsers_ItemPerPage))
       $Errors[] = $Cpt_IncorrNav_Pollusers;
     elseif(((int)$PollUsers_ItemPerPage > 100) || ((int)$PollUsers_ItemPerPage < 1))
       $Errors[] = $Cpt_IncorrNav_Pollusers;
     //постраничная навигация - один пароль для всех
     $OnePassw_ItemPerPage = $_POST['onepassw_itemperpage'];
     if(empty($OnePassw_ItemPerPage))
       $Errors[] = $Cpt_NoNav_OnePassw;
     elseif(!preg_match("|^[\d]+$|i", $OnePassw_ItemPerPage))
       $Errors[] = $Cpt_IncorrNav_OnePassw;
     elseif(((int)$OnePassw_ItemPerPage > 100) || ((int)$OnePassw_ItemPerPage < 1))
       $Errors[] = $Cpt_IncorrNav_OnePassw;
     //постраничная навигация - логин и пароль для каждого
     $EachPassw_ItemPerPage = $_POST['eachpassw_itemperpage'];
     if(empty($EachPassw_ItemPerPage))
       $Errors[] = $Cpt_NoNav_LogAndPassw;
     elseif(!preg_match("|^[\d]+$|i", $EachPassw_ItemPerPage))
       $Errors[] = $Cpt_IncorrNav_LogAndPassw;
     elseif(((int)$EachPassw_ItemPerPage > 100) || ((int)$EachPassw_ItemPerPage < 1))
       $Errors[] = $Cpt_IncorrNav_LogAndPassw;
     if(empty($Errors))
     {
       $Str = "<?php\n\$Lng='{$Language}';\n\$ShowResForm='{$ShowResForm}';\n\$ChangeFormPerm='{$ChangeFormPerm}';\n\$ShowTips='{$ShowTips}';\n\$ShowResultsOnFirst='{$ShowResultsOnFirst}';\n\$ProtSession='{$ProtSession}';\n\$ProtCookie='{$ProtCookie}';\n\$ProtIp='{$ProtIp}';\n\$KeepCookieTmp={$KeepCookieTmp};\n\$KeepIpTmp={$KeepIpTmp};\n\$PollUsers_ItemPerPage={$PollUsers_ItemPerPage};\n\$OnePassw_ItemPerPage={$OnePassw_ItemPerPage};\n\$EachPassw_ItemPerPage={$EachPassw_ItemPerPage};\n?>";
       SaveStringInFile('../pollconfig.inc', $Str, 'w');
       Refresh('settings');
     }
   }
   if($ChangeFormPerm == 'yes')
     $ChangeFormPermChecked = 'checked'; else $ChangeFormPermChecked = '';
   if($ShowTips == 'yes')
     $ShowTipsChecked = 'checked'; else $ShowTipsChecked = '';
   if($ProtSession == 'yes')
     $SessionChecked = 'checked'; else $SessionChecked = '';
   if($ProtCookie == 'yes')
     $CookieChecked = 'checked'; else $CookieChecked = '';
   if($ProtIp == 'yes')
     $IpChecked = 'checked'; else $IpChecked = '';
   if($ShowResultsOnFirst == 'yes')
     $ShowResultsOnFirstChecked = 'checked'; else $ShowResultsOnFirstChecked = '';
   print "<form action='' method=post>";
   print "<h4>{$Heading_Options}</h4>";
   ShowErrors($Errors, '90%', 'MiniField');
   print "<fieldset class=MiniField align=center>";

   print "<table class=General align=center border=0 cellspacing=0 cellpadding=0 width=90%>";
     print "<tr><td colspan=2><b>$Heading_GenOpt</b></td></tr>";
     print "<tr>";
       print "<td width=230>{$Cpt_ShowTips}</td>";
       print "<td><input type='checkbox' name='ShowTips' {$ShowTipsChecked}></td>";
     print "</tr>";
     print "<tr>";
       print "<td width=230>{$Cpt_ShowResultsOnFirstPage}</td>";
       print "<td><input type='checkbox' name='ShowResultsOnFirst' {$ShowResultsOnFirstChecked}></td>";
     print "</tr>";
     print "<tr>";
       print "<td width=230>{$Cpt_Language}</td>";
       print "<td>";
         print "<select name=language>";
         if($Lng == 'rus')
           print "<option value=rus selected>{$Opt_Russian}";
         else
           print "<option value=rus>{$Opt_Russian}";
         if($Lng == 'fre')
           print "<option value=fre selected>{$Opt_French}";
         else
           print "<option value=fre>{$Opt_French}";
         print "</select>";
       print "</td>";
     print "</tr>";

     //print "<tr><td colspan=2><b></b></td></tr>";
     print "<tr>";
       print "<td width=230>{$Cpt_PollResultsForm}</td>";
       print "<td>";
         print "<select name=showresform>";
           //линейчатые диаграммы
           if($ShowResForm == 'horhistogrammes')
             print "<option value=horhistogrammes selected>{$Opt_HorHistogrammes}";
           else
             print "<option value=horhistogrammes>{$Opt_HorHistogrammes}";
           //гистограмма 1
           if($ShowResForm == 'jpgraph_bar1')
             print "<option value=jpgraph_bar1 selected>{$Opt_Bar1}";
           else
             print "<option value=jpgraph_bar1>{$Opt_Bar1}";
           //гистограмма 2
           if($ShowResForm == 'jpgraph_bar2')
             print "<option value=jpgraph_bar2 selected>{$Opt_Bar2}";
           else
             print "<option value=jpgraph_bar2>{$Opt_Bar2}";

           //круговая диаграмма
           if($ShowResForm == 'pie')
             print "<option value=pie selected>{$Opt_Pie}";
           else
             print "<option value=pie>{$Opt_Pie}";
           //гистограмма 3
           if($ShowResForm == 'scatterplot')
             print "<option value=scatterplot selected>{$Opt_ScatterPlot}";
           else
             print "<option value=scatterplot>{$Opt_ScatterPlot}";
           //таблицы
           if($ShowResForm == 'tables')
             print "<option value=tables selected>{$Opt_Tables}";
           else
             print "<option value=tables>{$Opt_Tables}";
           //гистограмма (обычная)
           if($ShowResForm == 'verthistogrammes')
             print "<option value=verthistogrammes selected>{$Opt_VertHistogrammes}";
           else
             print "<option value=verthistogrammes>{$Opt_VertHistogrammes}";
         print "</select";
       print "</td>";
     print "</tr>";
     print "<tr>";
       print "<td>{$Cpt_ChangePollResultsFormPerm} (<a href=index.php?page=graphic_access>{$Cpt_Set}</a>)</td>";
       print "<td><input type='checkbox' name='changeformperm' {$ChangeFormPermChecked}></td>";
     print "</tr>";

     print "<tr><td colspan=2><b>{$Heading_StandProtect}</b></td></tr>";
     print "<tr>";
       print "<td width=230>{$Cpt_Cookie}</td>";
       print "<td><input type='checkbox' name='cookie' {$CookieChecked}></td>";
     print "</tr>";
     print "<tr>";
       print "<td>{$Cpt_Sessions}</td>";
       print "<td><input type='checkbox' name='session' {$SessionChecked}></td>";
     print "</tr>";
     print "<tr>";
       print "<td>{$Cpt_Ip}</td>";
       print "<td><input type='checkbox' name='ip' {$IpChecked}></td>";
     print "</tr>";
     print "<tr>";
       print "<td>{$Cpt_KeepCookieTime}</td>";
       print "<td><input type='text' name='keepcookie' value='{$KeepCookieTmp}' size=3></td>";
     print "</tr>";
     print "<tr>";
       print "<td>{$Cpt_KeepIpTime}</td>";
       print "<td><input type='text' name='keepip' value='{$KeepIpTmp}' size=3></td>";
     print "</tr>";

     print "<tr><td colspan=2><b>$Heading_Navigation</b></td></tr>";
     print "<tr>";
       print "<td>{$Cpt_nav_Pollusers}</td>";
       print "<td><input type='text' name='pollusers_itemperpage' value='{$PollUsers_ItemPerPage}' size=3></td>";
     print "</tr>";
     print "<tr>";
       print "<td>{$Cpt_nav_OnePassw}</td>";
       print "<td><input type='text' name='onepassw_itemperpage' value='{$OnePassw_ItemPerPage}' size=3></td>";
     print "</tr>";
     print "<tr>";
       print "<td>{$Cpt_nav_LogAndPassw}</td>";
       print "<td><input type='text' name='eachpassw_itemperpage' value='{$EachPassw_ItemPerPage}' size=3></td>";
     print "</tr>";
     print "<tr>";
       print "<td align=center colspan=2><input class=buttonsettings type=submit value='{$Cpt_Save}' name = 'SaveSettings'></td>";
     print "<tr>";
   print "</table>";
   print "</fieldset>";
   print "</form>";

?>