<?php
  ///////////////////////////////////////////////////
  //Телефонный справочник,
  //Клиентская часть
  //2007 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $dblocation = "localhost"; // адрес mysql сервера
  $dbport = "3306"; // порт mysql сервера
  $dbname = "personal"; // имя базы данных
  $dbuser = "personal_user"; // логин
  $dbpasswd = "personal_user"; // пароль

  $dbcnx = @mysql_connect($dblocation,$dbuser,$dbpasswd);
  if(!$dbcnx)
  {
    echo "<html>
            <head>
            <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
            <link rel='StyleSheet' type='text/css' href='skins/base/reader.css' />
            <link rel='icon' href='favicon.ico' type='image/x-icon' />
            <link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
            <title>".$TEXT['global-title']."</title>
            </head><body>
            <table align='center' border='0'><tr align='center' ><td><img alt='stop' src='img/stop.png' /></td></tr><tr  align='center' ><td><span class='res'>".$TEXT['error-conf1']."</span></td></tr></table>
            </body></html>";
    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."<br />".mysql_error()."</p>");
    exit();
  }

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

  function puterror3($message)
  {
    echo("<br /><p align='center'><img alt='stop' align=middle src='../img/stop.png'><br />".$message."<br />".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 = addslashes($strin);
       $strin = str_ireplace($in_wrd,$out_wrd,$strin);
       return $strin;
     }
   }

  function rep_back($strin) {
       if(!empty($strin)) {
       $in_wrd = array("CELECT","APDATE","ENSERT","TELETE","DRUNCATE","GREATE","TROP","VHERE","ANND"," AR ","LICKE","ASKII","SUBSTRINK","BEETWEEN","UNNION");
       $out_wrd = array("SELECT","UPDATE","INSERT","DELETE","TRUNCATE","CREATE","DROP","WHERE"," AND "," OR "," LIKE ","ASCII","SUBSTRING","BETWEEN","UNION");
       $strin = str_ireplace($in_wrd,$out_wrd,$strin);
       return $strin;
     }
   }

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

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

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

  function putdel2($message)
  {
    echo("<br /><br /><p align='center'><img alt='delete' align=middle src='../img/delete.png'><br />".$message."</p>");
  }
?>