Вход Регистрация
Файл: connect.php
Строк: 273
<?


session_start
();


require(
$_SERVER['DOCUMENT_ROOT']."/config.php");


if (!
mysql_connect($dbserver, $dbuser, $dbpassword)) {
echo 
"Ошибка подключения к серверу MySQL";
exit;
}

mysql_select_db($db);
mysql_query("SET NAMES utf8");

if (isset (
$_SESSION['login']) && isset ($_SESSION['pass'])) {
    
$login = mysql_real_escape_string($_SESSION['login']);
    
$pass = mysql_real_escape_string($_SESSION['pass']);
} else { 

   if (isset (
$_COOKIE['clogin']) && isset ($_COOKIE['cpass'])) {
   
$login = mysql_real_escape_string($_COOKIE['clogin']);
   
$_SESSION['login'] = $login;
   
$pass = md5(mysql_real_escape_string($_COOKIE['cpass']));
   
$_SESSION['pass'] = $pass;
   }
}

if (
$login && $pass) {
$login = check($login);
$req = mysql_query("SELECT * FROM `users` WHERE `login` = '$login' LIMIT 1");
   if (
mysql_num_rows($req)) {
      
$u = mysql_fetch_assoc($req);
      if (
$pass === $u['pass']) {
        
      } else {
      unset (
$_SESSION['login']);
      unset (
$_SESSION['pass']);
      
setcookie('clogin', '');
      
setcookie('cpass', '');
      
$login = false;
      
$pass = false;
      }
   } else {
   unset (
$_SESSION['login']);
   unset (
$_SESSION['pass']);
   
setcookie('clogin', '');
   
setcookie('cpass', '');
   
$login = false;
   
$pass = false;
   }
}

function 
ban($id) {
$req = mysql_query("SELECT * FROM `users_ban` WHERE `user` = '".$id."' ORDER BY `time_ban` DESC LIMIT 1");
$res = mysql_fetch_assoc($req);
if(
$res['time_ban'] > time()) return true;
}

function 
error($text) {
echo 
'<div class = "div"><font color="red">'.$text.'</font></div>';
}

function 
ok($text) {
echo 
'<div class = "div"><font color="green">'.$text.'</font></div>';
}


function 
online($online) {
if(
$online > (time()-500)) {
   
$online = '<img src = "/ico/on.png">';
   } else {
   
$online = '<img src = "/ico/off.png">';
   }
#return $online;
}

function 
ico($sex,$admin,$user){
    
$u = $user;
    
    if(
$u['online'] > (time() - 500)){
        
$on = 1;
    }else{
        
$on = 0;
    }
    
    if(
$on == 1){
if(
$admin == 0) {
if(
$sex == 'm') $icon = '<img src = "ico/men.gif">'; else $icon = '<img src = "ico/woman.gif">';
}
if(
$admin == 1) {
if(
$sex == 'm') $icon = '<img src = "ico/creator_men.png">'; else $icon = '<img src = "ico/creator_woman.png">';
}
if(
$admin == 2) {
if(
$sex == 'm') $icon = '<img src = "ico/admin_men.gif">'; else $icon = '<img src = "ico/admin_woman.gif">';
}
if(
$admin == 3) {
if(
$sex == 'm') $icon = '<img src = "ico/moder_men.gif">'; else $icon = '<img src = "ico/moder_woman.gif">';
}
if(
$admin == 4) {
if(
$sex == 'm') $icon = '<img src = "ico/moder_men.gif">'; else $icon = '<img src = "ico/moder_woman.gif">';
}
if(
$admin == 5) {
if(
$sex == 'm') $icon = '<img src = "ico/moder_men.gif">'; else $icon = '<img src = "ico/moder_woman.gif">';
}
}else{
  if(
$admin == 0) {
if(
$sex == 'm') $icon = '<img src = "ico/man_disable.png">'; else $icon = '<img src = "ico/woman_disable.png">';
}
if(
$admin == 1) {
if(
$sex == 'm') $icon = '<img src = "ico/man_disable.png">'; else $icon = '<img src = "ico/woman_disable.png">';
}
if(
$admin == 2) {
if(
$sex == 'm') $icon = '<img src = "ico/man_disable.png">'; else $icon = '<img src = "ico/woman_disable.png">';
}
if(
$admin == 3) {
if(
$sex == 'm') $icon = '<img src = "ico/man_disable.png">'; else $icon = '<img src = "ico/woman_disable.png">';
}
if(
$admin == 4) {
if(
$sex == 'm') $icon = '<img src = "ico/man_disable.png">'; else $icon = '<img src = "ico/woman_disable.png">';
}
if(
$admin == 5) {
if(
$sex == 'm') $icon = '<img src = "ico/man_disable.png">'; else $icon = '<img src = "ico/woman_disable.png">';
}  
}
return 
$icon;
//return $user['online'];
}

function 
navigation($page, $total, $link) {
if (
$page != 1) $pervpage = ' &larr; <a href= "'.$link.'page='. ($page - 1) .'"><u>Предыдущая</u></a> '; 
if (
$page != $total) $nextpage = ' <a href= "'.$link.'page='. ($page + 1) .'"><u>Следующая</u></a> &rarr;'; 
if(
$page - 2 > 0) $page3left = ' <a href= "'.$link.'page='. ($page - 2) .'" class="next">'. ($page - 2) .'</a>  '; 
if(
$page - 1 > 0) $page2left = ' <a href= "'.$link.'page='. ($page - 1) .'" class="next">'. ($page - 1) .'</a>  '; 
if(
$page - 1 > 0) $page1left = '</a>  '; 
if(
$page + 2 <= $total) $page3right = '  <a href= "'.$link.'page='. ($page + 2) .'" class="next">'. ($page + 2) .'</a>'; 
if(
$page + 1 <= $total) $page2right = '  <a href= "'.$link.'page='. ($page + 1) .'" class="next">'. ($page + 1) .'</a>'; 
if(
$page + 1 <= $total) $page1right = '</a>'; 
if (
$page != $total || $page - 1 > 0) {
echo 
'<div class="navig">';
}
if (
$page != $total || $page - 1 > 0) {
echo 
$pervpage.''.$nextpage;
echo 
'</br></br>';
echo 
$page3left.$page2left.'<l>'.$page.'</l>'.$page2right.$page3right;
}
echo 
'</div>';
echo 
'</div>';
}

function 
login($id){
   
$id = abs(intval($id));
   
$login = mysql_result(mysql_query("SELECT `login` FROM `users` WHERE `id` = '$id'"), 0);
   return 
$login;
}

function 
vremya_ban($time=NULL)
{
global 
$user;
if (
$time==NULL)$time=time();
if (isset(
$user))$time=$time+$user['set_timesdvig']*60*60;
$timep="".date("j M в H:i", $time)."";
$time_p[0]=date("j n", $time);
$time_p[1]=date("H:i", $time);
if (
$time_p[0]==date("j n"))$timep=date("H:i", $time);
if (isset(
$user)){
if (
$time_p[0]==date("j n", time()+$user['set_timesdvig']*60*60))$timep=date("H:i", $time);
if (
$time_p[0]==date("j n", time()-60*60*(24-$user['set_timesdvig'])))$timep="Вчера в $time_p[1]";
}else{
if (
$time_p[0]==date("j n"))$timep=date("H:i", $time);
if (
$time_p[0]==date("j n", time()-60*60*24))$timep="Вчера в $time_p[1]";
}
$timep=str_replace("Jan","Янв",$timep);
$timep=str_replace("Feb","Фев",$timep);
$timep=str_replace("Mar","Марта",$timep);
$timep=str_replace("May","Мая",$timep);
$timep=str_replace("Apr","Апр",$timep);
$timep=str_replace("Jun","Июня",$timep);
$timep=str_replace("Jul","Июля",$timep);
$timep=str_replace("Aug","Авг",$timep);
$timep=str_replace("Sep","Сент",$timep);
$timep=str_replace("Oct","Окт",$timep);
$timep=str_replace("Nov","Ноября",$timep);
$timep=str_replace("Dec","Дек",$timep);
return 
$timep;
}

function 
vremya($time=NULL)
{
global 
$user;
if (
$time==NULL)$time=time();
if (isset(
$user))$time=$time+$user['set_timesdvig']*60*60;
$timep="".date("j M Y в H:i", $time)."";
$time_p[0]=date("j n Y", $time);
$time_p[1]=date("H:i", $time);
if (
$time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
if (isset(
$user)){
if (
$time_p[0]==date("j n Y", time()+$user['set_timesdvig']*60*60))$timep=date("H:i:s", $time);
if (
$time_p[0]==date("j n Y", time()-60*60*(24-$user['set_timesdvig'])))$timep="Вчера в $time_p[1]";}
else{
if (
$time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
if (
$time_p[0]==date("j n Y", time()-60*60*24))$timep="Вчера в $time_p[1]";}
$timep=str_replace("Jan","Янв",$timep);
$timep=str_replace("Feb","Фев",$timep);
$timep=str_replace("Mar","Марта",$timep);
$timep=str_replace("May","Мая",$timep);
$timep=str_replace("Apr","Апр",$timep);
$timep=str_replace("Jun","Июня",$timep);
$timep=str_replace("Jul","Июля",$timep);
$timep=str_replace("Aug","Авг",$timep);
$timep=str_replace("Sep","Сент",$timep);
$timep=str_replace("Oct","Окт",$timep);
$timep=str_replace("Nov","Ноября",$timep);
$timep=str_replace("Dec","Дек",$timep);
return 
$timep;
}

function 
kikt($t)
{
$t2 = $t - time();
if (
$t2 > (60 * 60 * 24 * 30)) $t3 = round($t2 / (60 * 60 * 24 * 30)) . ' месяцев';
elseif (
$t2 > (60 * 60 * 24)) $t3 = round($t2 / (60 * 60 * 24)) . ' дней';
elseif (
$t2 > (60 * 60)) $t3 = round($t2 / (60 * 60)) . ' часов';
elseif (
$t2 > 60) $t3 = round($t2 / 60) . ' минут';
else 
$t3 = $t2 . ' секунд';
return 
$t3;
}

function 
num($num){
 
$num = abs(intval($num));
 return 
$num;
}

function 
check($str) {
 
$str = htmlentities(trim($str), ENT_QUOTES, 'UTF-8');
 
$str = mysql_real_escape_string($str);
return 
$str;
}

function 
checkout($str) {
    
$str = nl2br($str);
    
$str = str_replace(chr(226) . chr(128) . chr(174), '.', $str);
    return 
$str; 
}

function 
strtolower_utf8($string){ 
  
$convert_to = array( 
    
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", 
    
"v", "w", "x", "y", "z", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", 
    
"ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "а", "б", "в", "г", "д", "е", "ё", "ж", 
    
"з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", 
    
"ь", "э", "ю", "я" 
  
); 
  
$convert_from = array( 
    
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", 
    
"V", "W", "X", "Y", "Z", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", 
    
"Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "А", "Б", "В", "Г", "Д", "Е", "Ё", "Ж", 
    
"З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т", "У", "Ф", "Х", "Ц", "Ч", "Ш", "Щ", "Ъ", "Ъ", 
    
"Ь", "Э", "Ю", "Я" 
  
); 

  return 
str_replace($convert_from, $convert_to, $string); 
}


if (
extension_loaded('zlib') and ini_get('zlib.output_compression') != 1 and ini_get('output_handler') != 'ob_gzhandler')
{
$PREFER_DEFLATE = false;
$FORCE_COMPRESSION = false;

function 
compress_output_gzip($output)
{
    return 
gzencode($output);
}

function 
compress_output_deflate($output)
{
    return 
gzdeflate($output, 9);
}

function 
compress_output_x_gzip($output)
{
    return 
gzcompress($output, 9);
}

if (isset(
$_SERVER['HTTP_ACCEPT_ENCODING']))
    
$AE = $_SERVER['HTTP_ACCEPT_ENCODING'];
else
    
$AE = $_SERVER['HTTP_TE'];

$support_gzip = (strpos($AE, 'gzip') !== FALSE) || $FORCE_COMPRESSION;
$support_deflate = (strpos($AE, 'deflate') !== FALSE) || $FORCE_COMPRESSION;
$support_x_gzip = (strpos($AE, 'x-gzip') !== FALSE) || $FORCE_COMPRESSION;


if (
$support_gzip && $support_deflate)
{
    
$support_deflate = $PREFER_DEFLATE;
}

if (
$support_deflate)
{
header("Content-Encoding: deflate");
ob_start("compress_output_deflate");
}
else
{
if (
$support_gzip)
{
header("Content-Encoding: gzip");
ob_start("compress_output_gzip");
}
else
{
if (
$support_x_gzip)
{
header("Content-Encoding: x_gzip");
ob_start("compress_output_x_gzip");    
}
else 
{
ob_start();
$config_gzip = 0;
}
}
}
}
else
{
$config_gzip = 0;
}




?>
Онлайн: 2
Реклама