<?php
  ///////////////////////////////////////////////////
  //2007 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////
  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if(is_file ("../lang/".$lang."/".$lang.".php")) include "../lang/".$lang."/".$lang.".php";
     else include "../lang/ru/ru.php";

  $title=$titlepage = $TEXT['global-srvset'];
  $helppage = $TEXT['global-srvset-title'];
  require_once "../config.php";
  require_once "../util/top.php";

  if($result2['administrator'] == 0) puterror2($TEXT['error-loginform4']);

  if(strlen($_POST['srvp_id'])>1) puterror2($TEXT['error-srvpar1'].$TEXT['global-srvset7']);
  if(strlen($_POST['ldp'])>1) puterror2($TEXT['global-srvldap'].$TEXT['global-srvset7']);
  if(strlen($_POST['ldp_dn'])>255) puterror2($TEXT['global-srvldap3'].$TEXT['global-srvset7']);
  if(strlen($_POST['ldp_user'])>255) puterror2($TEXT['login-user'].$TEXT['global-srvset7']);
  if(strlen($_POST['ldp_pass'])>255) puterror2($TEXT['login-password'].$TEXT['global-srvset7']);
  if(strlen($_POST['dlp_srv'])>255) puterror2($TEXT['global-srvldap4'].$TEXT['global-srvset7']);
  if(strlen($_POST['ldp_port'])>5) puterror2($TEXT['global-srvldap5'].$TEXT['global-srvset7']);
  if(strlen($_POST['rep_org_id'])>11) puterror2($TEXT['error-org1']);
  if(strlen($_POST['prx_set'])>21) puterror2($TEXT['global-srvset9']);

  if(strlen($_POST['exim_shell'])>255) puterror2($TEXT['user-shell'].$TEXT['global-srvset7']);
  if(strlen($_POST['exim_uid'])>5) puterror2($TEXT['user-uid'].$TEXT['global-srvset7']);
  if(strlen($_POST['exim_gid'])>5) puterror2($TEXT['user-gid'].$TEXT['global-srvset7']);
  if(strlen($_POST['exim_home'])>255) puterror2($TEXT['global-srvldap6'].$TEXT['global-srvset7']);
  if(strlen($_POST['exim_kvota'])>5) puterror2($TEXT['res-field11'].$TEXT['global-srvset7']);
  if(strlen($_POST['exim_pas'])>5) puterror2($TEXT['global-srvldap7'].$TEXT['global-srvset7']);

  if(strlen($_POST['admin_mail_rss'])>255) puterror2($TEXT['global-srvldap10'].$TEXT['global-srvset7']);
  if(strlen($_POST['admin_mail_news'])>255) puterror2($TEXT['global-srvldap11'].$TEXT['global-srvset7']);
  if(strlen($_POST['admin_mail'])>255) puterror2($TEXT['global-srvldap12'].$TEXT['global-srvset7']);
  if(strlen($_POST['spr_pass'])>5) puterror2($TEXT['global-srvldap7'].$TEXT['global-srvset7']);

  if(strlen($_POST['glob_w'])>5) puterror2($TEXT['global-srvset3']." (W)".$TEXT['error-srvpar3']);
  if(strlen($_POST['glob_h'])>5) puterror2($TEXT['global-srvset3']." (H)".$TEXT['global-srvset7']);
  if(strlen($_POST['user_w'])>5) puterror2($TEXT['global-srvset4']." (W)".$TEXT['global-srvset7']);
  if(strlen($_POST['user_h'])>5) puterror2($TEXT['global-srvset4']." (H)".$TEXT['global-srvset7']);
  if(strlen($_POST['exim_w'])>5) puterror2($TEXT['global-srvset5']." (W)".$TEXT['global-srvset7']);
  if(strlen($_POST['exim_h'])>5) puterror2($TEXT['global-srvset5']." (H)".$TEXT['global-srvset7']);
  if(strlen($_POST['res_w'])>5) puterror2($TEXT['global-srvset6']." (W)".$TEXT['global-srvset7']);
  if(strlen($_POST['res_h'])>5) puterror2($TEXT['global-srvset6']." (H)".$TEXT['global-srvset7']);

  $_POST['srvp_id'] = rep($_POST['srvp_id']);
  $_POST['prx_set'] = rep($_POST['prx_set']);
  $_POST['ldp_dn'] = rep($_POST['ldp_dn']);
  $_POST['ldp_user'] = rep($_POST['ldp_user']);
  $_POST['ldp_pass'] = rep($_POST['ldp_pass']);
  $_POST['dlp_srv'] = rep($_POST['dlp_srv']);
  $_POST['ldp_port'] = rep($_POST['ldp_port']);
  $_POST['exim_shell'] = rep($_POST['exim_shell']);
  $_POST['exim_uid'] = rep($_POST['exim_uid']);
  $_POST['exim_gid'] = rep($_POST['exim_gid']);
  $_POST['exim_home'] = rep($_POST['exim_home']);
  $_POST['exim_kvota'] = rep($_POST['exim_kvota']);
  $_POST['exim_pas'] = rep($_POST['exim_pas']);
  $_POST['admin_mail_rss'] = rep($_POST['admin_mail_rss']);
  $_POST['admin_mail_news'] = rep($_POST['admin_mail_news']);
  $_POST['admin_mail'] = rep($_POST['admin_mail']);
  $_POST['spr_pass'] = rep($_POST['spr_pass']);
  $_POST['glob_w'] = rep($_POST['glob_w']);
  $_POST['glob_h'] = rep($_POST['glob_h']);
  $_POST['user_w'] = rep($_POST['user_w']);
  $_POST['user_h'] = rep($_POST['user_h']);
  $_POST['exim_w'] = rep($_POST['exim_w']);
  $_POST['exim_h'] = rep($_POST['exim_h']);
  $_POST['res_w'] = rep($_POST['res_w']);
  $_POST['res_h'] = rep($_POST['res_h']);
  $_POST['rep_org_id'] = rep($_POST['rep_org_id']);

  if($_POST['repl'] == "on") $repl = "1";
   else $repl = "0";

  if($_POST['repl_mail'] == "on") $repl_mail = "yes";
   else $repl_mail = "no";

  //*************************************
  //Информация для лога
  $ip = $_SERVER['REMOTE_ADDR'];
  $doing = $TEXT['log-srvpar'];
  $what = $TEXT['log-srvpar-text'];
  $who = $result2['fullname'];
  //*************************************

  $query = "UPDATE `tbl_srv_param` SET
  `ldp` = '".$_POST['ldp']."',
  `ldp_dn` = '".$_POST['ldp_dn']."',
  `ldp_user` = '".$_POST['ldp_user']."',
  `ldp_pass` = '".$_POST['ldp_pass']."',
  `dlp_srv` = '".$_POST['dlp_srv']."',
  `ldp_port` = ".$_POST['ldp_port'].",
  `exim_shell` = '".$_POST['exim_shell']."',
  `exim_uid` = ".$_POST['exim_uid'].",
  `exim_gid` = ".$_POST['exim_gid'].",
  `exim_home` = '".$_POST['exim_home']."',
  `exim_kvota` = ".$_POST['exim_kvota'].",
  `exim_pass` = '".$_POST['exim_pas']."',
  `admin_mail_rss` = '".$_POST['admin_mail_rss']."',
  `admin_mail_news` = '".$_POST['admin_mail_news']."',
  `admin_mail` = '".$_POST['admin_mail']."',
  `spr_pass` = '".$_POST['spr_pass']."',
  `glob_w` = ".$_POST['glob_w'].",
  `glob_h` = ".$_POST['glob_h'].",
  `user_w` = ".$_POST['user_w'].",
  `user_h` = ".$_POST['user_h'].",
  `exim_w` = ".$_POST['exim_w'].",
  `exim_h` = ".$_POST['exim_h'].",
  `res_w` = ".$_POST['res_w'].",
  `res_h` = ".$_POST['res_h'].",
  `repl` = '$repl',
  `rep_org_id` = '".$_POST['rep_org_id']."',
  `prx_set` = '".$_POST['prx_set']."',
  `repl_mail` = '$repl_mail'
  WHERE `srvp_id`='".$_POST['srvp_id']."'";
  if(mysql_query($query))
  {
    $query2 = "INSERT INTO tbl_logs ( `log_id` , `data` , `ip` , `who` , `doing` , `what` ) VALUES ( NULL , NOW() , '$ip' , '$who' , '$doing' , '$what')";
        if(mysql_query($query2))
           {
           echo "<html><head>
                <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=index.php' />
                </head></html>";
           } else puterror2($TEXT['error-log']);
   } else puterror2(mysql_error());
 require_once "../util/bottom.php";
?>