Просмотр файла sistem/global.dat

Размер файла: 10.73Kb
<?php
Error_Reporting(0);//не сообщать об ошибках

session_name("SID");
session_start();
header('Content-type: text/html; charset=utf-8');
header('Cache-control: no-cache');



///////////////КОМПРЕССИЯ СТРАНИЦ///////////////
if($step_gzip > "0" && $step_gzip <= "9")
{
   $step = $step_gzip;
   if($_SERVER['HTTP_ACCEPT_ENCODING'])//Узнаем какие типы сжатия поддерживает браузер
   { $compress = strtolower($_SERVER['HTTP_ACCEPT_ENCODING']); }else{ $compress = strtolower($_SERVER['HTTP_TE']); }
}else{ $compress = "fgjdfgfg"; }

// Если поддерживается deflate
if(substr_count($compress,'deflate'))
{
   function compress_output_deflate($output)
   {
      global $step;
      return gzdeflate($output, $step);
   }
   
   $method = 'deflate';
   header('Content-Encoding: deflate');
   ob_start('compress_output_deflate');
   ob_implicit_flush(0);
}
// Если поддерживается gzip
elseif(substr_count($compress,'gzip'))
{
   function compress_output_gzip($output)
   {
      global $step;
      return gzencode($output, $step);
   }
   
   $method = 'gzip';
   header('Content-Encoding: gzip');
   ob_start('compress_output_gzip');
   ob_implicit_flush(0);
}
// Если поддерживается x-gzip
elseif(substr_count($compress,'x-gzip'))
{
   function compress_output_x_gzip($output)
   {
      global $step;
      $size = strlen($output);
      $crc = crc32($output);
      $output = gzcompress($output, $step);
      $output = substr($output, 0, strlen($output) - 4);
      return "\x1f\x8b\x08\x00\x00\x00\x00\x00".$output.pack('V',$crc).pack('V',$size);
   }
   
   $method = 'x-gzip';
   header('Content-Encoding: x-gzip');
   ob_start('compress_output_x_gzip');
   ob_implicit_flush(0);
}



//Функция для вывода инфы о проценте сжатия и др.
function info_compress()
{
   global $method, $step;
   
   $contents = ob_get_contents();
   // Сколько весит исходная страница
   $in = strlen($contents);
   
   switch($method)
   {
      default:
      echo'';//Сжатие не поддерживается<br>
      break;
      
      case 'deflate':
      $out = strlen(gzdeflate($contents, $step));
      
      echo 'IN: '.round($in/1024,2).' kb<br>
      OUT: '.round($out/1024,2).' kb<br>
      Сжатие: '.round(100-(100/($in/$out)),1).' %<br>
      Метод: '.$method.'<br/>';
      break;
      
      case 'gzip':
      $out = strlen(gzencode($contents, $step));
      
      echo 'IN: '.round($in/1024,2).' kb<br>
      OUT: '.round($out/1024,2).' kb<br>
      Сжатие: '.round(100-(100/($in/$out)),1).' %<br>
      Метод: '.$method.'<br/>';
      break;
      
      case 'x-gzip':
      $out = strlen(gzcompress($contents, $step));
      
      echo 'IN: '.round($in/1024,2).' kb<br>
      OUT: '.round($out/1024,2).' kb<br>
      Сжатие: '.round(100-(100/($in/$out)),1).' %<br>
      Метод: '.$method.'<br/>';
      break;
   }
   
   return;
}




///////////////НАЧАЛО ПОДСЧЁТА ГЕНЕРАЦИИ///////////////
$starttime=microtime();//начало отщета
$starttime=explode(" ",$starttime);
$starttime=$starttime[0]+$starttime[1];




////////////////ОБОЗНАЧАЕМ ПЕРЕМЕННЫЕ////////////////
if (isset($_SESSION['login'])){  $login = $_SESSION['login'];}elseif(isset($_COOKIE['login'])){ $login = $_COOKIE['login']; }else{ $login =""; }
if (isset($_SESSION['pass'])){  $pass = $_SESSION['pass'];}elseif(isset($_COOKIE['pass'])){ $pass = $_COOKIE['pass']; }else{ $pass =""; }
/////////////////////////GET//////////////////////////
if(isset($_GET['act'])){$act = $_GET['act'];}
if(isset($_GET['i'])){$i = $_GET['i'];}
///////////////////POST////////////////////////////////
if(isset($_POST['act'])){$act = $_POST['act'];}
///////////////////Корневая папка//////////////////////
$koren_dir=htmlspecialchars($_SERVER['DOCUMENT_ROOT']);


////////////////проверяем незабанено ли IP пользователя////////////////
$addr = $_SERVER['REMOTE_ADDR'];
if(file_exists("$koren_dir/data/ban/$addr.dat"))
{
   $redirekt_url = "http://".htmlspecialchars($_SERVER['HTTP_HOST'])."/pages/baned.php";
   header("Location: $redirekt_url");
}




////////////////ВЫЧИСЛЕНИЯ НАД СЕССИЕЙ У ЮЗЕРА////////////////
if ($login =="" || $pass =="")
{
   $status = 'gost';
}else{
   if($cfg = @file("$koren_dir/data/uzer/$login.dat"))
   {
      $cfg=explode("<||>",$cfg[0]);
      $pass_real = $cfg[0];
      if(md5($pass)==$pass_real)
      {
         $status = htmlspecialchars($cfg[1]);
         $postov = htmlspecialchars($cfg[2]);
         $golos_za = htmlspecialchars($cfg[3]);
         $golos_protiv = htmlspecialchars($cfg[4]);
         $prichina_bana = htmlspecialchars($cfg[5]);
         $time_reg = htmlspecialchars($cfg[6]);
         $den_plusa = htmlspecialchars($cfg[7]);
         $real_name = htmlspecialchars($cfg[8]);
         $real_name2 = htmlspecialchars($cfg[9]);
         $gorod = htmlspecialchars($cfg[10]);
         $a_baut = $cfg[11];
         $vozrost = htmlspecialchars($cfg[12]);
         $pol = htmlspecialchars($cfg[13]);
         $posled_ip = htmlspecialchars($cfg[14]);
         $posled_time_pribivanij = htmlspecialchars($cfg[15]);
         $posled_time = htmlspecialchars($cfg[16]);
         
         $my_tema = htmlspecialchars($cfg[17]);
         $rezerv1 = htmlspecialchars($cfg[18]);//время до конца бана
         $rezerv2 = htmlspecialchars($cfg[19]);//time регистрации
         $rezerv3 = htmlspecialchars($cfg[20]);
         $rezerv4 = htmlspecialchars($cfg[21]);
         $rezerv5 = htmlspecialchars($cfg[22]);
         $rezerv6 = htmlspecialchars($cfg[23]);
         $rezerv7 = htmlspecialchars($cfg[24]);
         $rezerv8 = htmlspecialchars($cfg[25]);
         $rezerv9 = htmlspecialchars($cfg[26]);
         $rezerv10 = htmlspecialchars($cfg[27]);
         $rezerv11 = htmlspecialchars($cfg[28]);
         $rezerv12 = htmlspecialchars($cfg[29]);
         $rezerv13 = htmlspecialchars($cfg[30]);
         $rezerv14 = htmlspecialchars($cfg[31]);
         $rezerv15 = htmlspecialchars($cfg[32]);
         $rezerv16 = htmlspecialchars($cfg[33]);
         $rezerv17 = htmlspecialchars($cfg[34]);
         $rezerv18 = htmlspecialchars($cfg[35]);
         $rezerv19 = htmlspecialchars($cfg[36]);
         $rezerv20 = htmlspecialchars($cfg[37]);
         
         
         
         
         //обновление статуса активации
         if($status == "no_aktiv")
         {
            $fghrr = $rezerv2 + $time_aktiv;
            if(time() >= $fghrr)
            {
               $status = "uzer";
            }
         }
         
         
         
         
         //обновление статуса бана
         if($status == "ban")
         {
            if(time() >= $rezerv1)
            {
               $status = "uzer";
               $rezerv1 = "";
            }
         }
         
         
         
         
         
         //Обновление данных пользователя
         //Пароль<||>статус на сайте<||>Количество сообщений<||>голосов за<||>голосов против<||>причина бана<||>дата и время регистрации<||>число месяца для присваивания плюсов<||>Реалное имя юзера<||>Реальное фамилие юзера<||>город проживания<||>расказ юзера о себе<||>возрост юзера<||>пол юзера<||>ip адрес юзера<||>дата и время последнего прибывания<||>time для определения online<||>выбранная тема<||>
         
         $ip=htmlspecialchars($_SERVER['REMOTE_ADDR']);
         $posled_time_pribivanij = htmlspecialchars(date("d.m.Y H:i:s"));
         $posled_time = htmlspecialchars(time());
         
         $kod=''.$pass_real.'<||>'.$status.'<||>'.$postov.'<||>'.$golos_za.'<||>'.$golos_protiv.'<||>'.$prichina_bana.'<||>'.$time_reg.'<||>'.$den_plusa.'<||>'.$real_name.'<||>'.$real_name2.'<||>'.$gorod.'<||>'.$a_baut.'<||>'.$vozrost.'<||>'.$pol.'<||>'.$ip.'<||>'.$posled_time_pribivanij.'<||>'.$posled_time.'<||>'.$my_tema.'<||>'.$rezerv1.'<||>'.$rezerv2.'<||>'.$rezerv3.'<||>'.$rezerv4.'<||>'.$rezerv5.'<||>'.$rezerv6.'<||>'.$rezerv7.'<||>'.$rezerv8.'<||>'.$rezerv9.'<||>'.$rezerv10.'<||>'.$rezerv11.'<||>'.$rezerv12.'<||>'.$rezerv13.'<||>'.$rezerv14.'<||>'.$rezerv15.'<||>'.$rezerv16.'<||>'.$rezerv17.'<||>'.$rezerv18.'<||>'.$rezerv19.'<||>'.$rezerv20.'<||>';
         $file_login_data = fopen("$koren_dir/data/uzer/$login.dat", "w+");
         flock ($file_login_data,LOCK_EX);
         fputs($file_login_data,$kod);
         flock ($file_login_data,LOCK_UN);
         fclose($file_login_data);
         @chmod("$koren_dir/data/uzer/$login.dat", 0666);
         //закончили записывать и получать данные от юзера-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
         
         if(empty($asdasdasd)){$asdasdasd = "000";}
         if(($status == "no_aktiv") && ($asdasdasd != "123")){ header("Location: /pages/no_aktiv.php?".SID.""); }
         
         
         
         //продление куков и создание сессий если их нет
         $http_host = $_SERVER['HTTP_HOST'];//Определили в каком домене будет доступны каки
         $timecook = time()+32000000;
         setcookie("login","$login","$timecook","/");//продлили куки
         setcookie("pass","$pass","$timecook","/");//продлили куки
         if (!isset($_SESSION['login'])){ $_SESSION['login'] = $login;}
         if (!isset($_SESSION['pass'])){ $_SESSION['pass'] = $pass;}
         
      }else{ 
         $status = 'gost'; 
         session_destroy();
         @SetCookie("login","");
         @SetCookie("pass","");
      }
   }else{
      $status = 'gost';
      session_destroy();
      @SetCookie("login","");
      @SetCookie("pass","");
   }
}




////////////////если юзер авторизирован то включаем его настройку темы////////////////
if($status=="ban" || $status=="uzer" || $status=="moder" || $status=="admin")
{
   $my_tema = str_replace(".","",$my_tema);
   $my_tema = str_replace("/","",$my_tema);
   
   if(file_exists("$koren_dir/temes/$my_tema/verh.dat"))
   {
      $teme = $my_tema;
   }
}

?>