<?php
  ///////////////////////////////////////////////////
  //2007 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $dblocation = "localhost"; // адрес mysql сервера
  $dbport = "3306"; // порт mysql сервера
  $dbname = "personal"; // имя базы данных
  $dbuser = "personal_admin"; // логин
  $dbpasswd = "Pgt7d34smb9"; // пароль
  
  $dbcnx = @mysql_connect($dblocation,$dbuser,$dbpasswd);
  if(!$dbcnx)
  {
    echo("<p>At this moment the server of a database is not accessible, therefore correct display of page is impossible.<br />If you do not install project previously, run script <a href=install.php>http://".$_SERVER['SERVER_ADDR']."/personal/install.php</a></p>");
    exit();
  }
  mysql_query("SET CHARACTER SET 'utf8'") or exit('SET CHARACTER SET error');
  mysql_query("SET character_set_client='utf8'") or exit('SET character_set_client error');
  mysql_query("SET character_set_results='utf8'") or exit('SET character_set_results error');
  mysql_query("SET collation_connection='utf8_general_ci'") or exit('SET collation_connection error');
  mysql_query("SET NAMES `utf8`") or exit('SET NAMES error');

  function puterror($message)
  {
    echo("<br /><br /><p align='center'><img alt='stop' align=middle src='img/stop.png'><br />".$message." ".mysql_error()."</p>");
    exit();
  }

  function puterror2($message)
  {
    echo("<br /><br /><p align='center'><img alt='stop' align=middle src='../img/stop.png'><br />".$message." ".mysql_error()."</p>");
    exit();
  }

  function puterror3($message)
  {
    echo("<br /><br /><p align='center'><img alt='stop' align=middle src='../../img/stop.png'><br />".$message." ".mysql_error()."</p>");
    exit();
  }

  function rep($strin) {
       if(!empty($strin)) {
       $in_wrd = array("select","update","insert","delete","truncate","create","drop","where"," and "," or "," like ","`","&amp;quote;","ascii","substring","between","union");
       $out_wrd = array("CELECT","APDATE","ENSERT","TELETE","DRUNCATE","GREATE","TROP","VHERE","ANND"," AR ","LICKE","&lsquo;","&quote;","ASKII","SUBSTRINK","BEETWEEN","UNNION");
       $strin = trim($strin);
       $strin = htmlspecialchars(stripslashes($strin));
       $strin = str_ireplace($in_wrd,$out_wrd,$strin);
       return $strin;
     }
   }

  function rep2($strin) {
       if(!empty($strin)) {
       $in_wrd = array("select","update","insert","delete","truncate","create","drop","where"," and "," or "," like ","`","&amp;quote;","ascii","substring","between","union");
       $out_wrd = array("CELECT","APDATE","ENSERT","TELETE","DRUNCATE","GREATE","TROP","VHERE","ANND"," AR ","LICKE","&lsquo;","&quote;","ASKII","SUBSTRINK","BEETWEEN","UNNION");
       $strin = trim($strin);
       $strin = addslashes($strin);
       $strin = str_ireplace($in_wrd,$out_wrd,$strin);
       return $strin;
     }
   }

 // Проверка наличия обновлений
  function update_check($url,$proxy) {
     if(!empty($url)) {
      if(trim($proxy) !== "") {
       $opts = array('http' => array('proxy' => $proxy, 'request_fulluri' => true));
       $context = stream_context_create($opts);
       $open_upd_file = @file_get_contents($url, false, $context);
       } else $open_upd_file = @file_get_contents($url);
        if(!$open_upd_file) $upd_line = "";
         else $upd_line = $open_upd_file;
         @fclose($open_upd_file);
         return $upd_line;
         }
    }
?>