Просмотр файла template/functions.php

Размер файла: 9.45Kb
<?php //Кодировка win-1251
#-----------------------------------------------------#
#          ********* WAP-MOTORS *********             #
#             Made by   :  VANTUZ                     #
#               E-mail  :  [email protected]             #
#                 Site  :  http://pizdec.ru           #
#             WAP-Site  :  http://visavi.net          #
#                  ICQ  :  36-44-66                   #
#  Вы не имеете право вносить изменения в код скрипта #
#-----------------------------------------------------# 
function utf_to_win($str){
$str=strtr($str,array("Р°"=>"а","Р±"=>"б","РІ"=>"в","Рі"=>"г","Рґ"=>"д","Рµ"=>"е","С‘"=>"ё","Р¶"=>"ж","Р·"=>"з","Рё"=>"и","Р№"=>"й","Рє"=>"к","Р»"=>"л","Рј"=>"м","РЅ"=>"н","Рѕ"=>"о","Рї"=>"п","СЂ"=>"р","СЃ"=>"с","С‚"=>"т","Сѓ"=>"у","С„"=>"ф","С…"=>"х","С†"=>"ц","С‡"=>"ч","С€"=>"ш","С‰"=>"щ","СЉ"=>"ъ","С‹"=>"ы","СЊ"=>"ь","СЌ"=>"э","СЋ"=>"ю","СЏ"=>"я",
"Рђ"=>"А","Р‘"=>"Б","Р’"=>"В","Р“"=>"Г","Р”"=>"Д","Р•"=>"Е","РЃ"=>"Ё","Р–"=>"Ж","Р—"=>"З","Р?"=>"И","Р™"=>"Й","Рљ"=>"К","Р›"=>"Л","Рњ"=>"М","Рќ"=>"Н","Рћ"=>"О","Рџ"=>"П","Р "=>"Р","РЎ"=>"С","Рў"=>"Т","РЈ"=>"У","Р¤"=>"Ф","РҐ"=>"Х","Р¦"=>"Ц","Р§"=>"Ч","РЁ"=>"Ш","Р©"=>"Щ","РЄ"=>"Ъ","Р«"=>"Ы","Р¬"=>"Ь","Р­"=>"Э","Р®"=>"Ю","РЇ"=>"Я"));
 return $str;
}

function win_to_utf($str){
$str=strtr($str,array("а"=>"Р°","б"=>"Р±","в"=>"РІ","г"=>"Рі","д"=>"Рґ","е"=>"Рµ","ё"=>"С‘","ж"=>"Р¶","з"=>"Р·","и"=>"Рё","й"=>"Р№","к"=>"Рє","л"=>"Р»","м"=>"Рј","н"=>"РЅ","о"=>"Рѕ","п"=>"Рї","р"=>"СЂ","с"=>"СЃ","т"=>"С‚","у"=>"Сѓ","ф"=>"С„","х"=>"С…","ц"=>"С†","ч"=>"С‡","ш"=>"С€","щ"=>"С‰","ъ"=>"СЉ","ы"=>"С‹","ь"=>"СЊ","э"=>"СЌ","ю"=>"СЋ","я"=>"СЏ",
"А"=>"Рђ","Б"=>"Р‘","В"=>"Р’","Г"=>"Р“","Д"=>"Р”","Е"=>"Р•","Ё"=>"РЃ","Ж"=>"Р–","З"=>"Р—","И"=>"Р?","Й"=>"Р™","К"=>"Рљ","Л"=>"Р›","М"=>"Рњ","Н"=>"Рќ","О"=>"Рћ","П"=>"Рџ","Р"=>"Р ","С"=>"РЎ","Т"=>"Рў","У"=>"РЈ","Ф"=>"Р¤","Х"=>"РҐ","Ц"=>"Р¦","Ч"=>"Р§","Ш"=>"РЁ","Щ"=>"Р©","Ъ"=>"РЄ","Ы"=>"Р«","Ь"=>"Р¬","Э"=>"Р­","Ю"=>"Р®","Я"=>"РЇ"));
 return $str;
}

function rus_utf_tolower($str){
$str=strtr($str,array("Рђ"=>"Р°","Р‘"=>"Р±","Р’"=>"РІ","Р“"=>"Рі","Р”"=>"Рґ","Р•"=>"Рµ","РЃ"=>"С‘","Р–"=>"Р¶","Р—"=>"Р·","Р?"=>"Рё","Р™"=>"Р№","Рљ"=>"Рє","Р›"=>"Р»","Рњ"=>"Рј","Рќ"=>"РЅ","Рћ"=>"Рѕ","Рџ"=>"Рї","Р "=>"СЂ","РЎ"=>"СЃ","Рў"=>"С‚","РЈ"=>"Сѓ","Р¤"=>"С„","РҐ"=>"С…","Р¦"=>"С†","Р§"=>"С‡","РЁ"=>"С€","Р©"=>"С‰","РЄ"=>"СЉ","Р«"=>"С‹","Р¬"=>"СЊ","Р­"=>"СЌ","Р®"=>"СЋ","РЇ"=>"СЏ",
"A"=>"a","B"=>"b","C"=>"c","D"=>"d","E"=>"e","I"=>"i","F"=>"f","G"=>"g","H"=>"h","J"=>"j","K"=>"k","L"=>"l","M"=>"m","N"=>"n","O"=>"o","P"=>"p","Q"=>"q","R"=>"r","S"=>"s","T"=>"t","U"=>"u","V"=>"v","W"=>"w","X"=>"x","Y"=>"y","Z"=>"z"));
 return $str;
}


if ($_SERVER['HTTP_X_FORWARDED_FOR']) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if($_SERVER['HTTP_CLIENT_IP']) $ip = $_SERVER['HTTP_CLIENT_IP'];
else if($_SERVER['REMOTE_ADDR']) $ip = $_SERVER['REMOTE_ADDR'];
else {$ip = 'not detected';}
$ip = preg_replace("/[^0-9.]/", "", $ip);
$ip=htmlspecialchars(stripslashes($ip));

$currHour=date("H",time()); 
$currHour= round($currHour+$clocks); 
$currDate=date("d F Y", time());
$curr=date("i:s", time());
$currTime=date("$currHour:i:s", time());
$currTime2=date("$currHour:i", time());
 
$currDate = str_replace("January","Января",$currDate);
$currDate = str_replace("February","Февраля",$currDate);
$currDate = str_replace("March","Марта",$currDate);
$currDate = str_replace("April","Апреля",$currDate);
$currDate = str_replace("May","Мая",$currDate);
$currDate = str_replace("June","Июня",$currDate);
$currDate = str_replace("July","Июля",$currDate);
$currDate = str_replace("August","Августа",$currDate);
$currDate = str_replace("September","Сентября",$currDate);
$currDate = str_replace("October","Октября",$currDate);
$currDate = str_replace("November","Ноября",$currDate);
$currDate = str_replace("December","Декабря",$currDate); 
$currDate =win_to_utf($currDate);


function check($message){ 
$message=str_replace("|","I",$message); 
$message=str_replace("||","I",$message);
$message=htmlspecialchars($message);                  
$message=str_replace("'","&#39;",$message);            
$message=str_replace("\"","&#34;",$message);  
$message=str_replace("/\\\$/","&#36;",$message);    
$message=str_replace("$","&#36;",$message);          
$message=str_replace("\\","&#92;", $message);                            
$message=str_replace("@","&#64;", $message);      
$message=str_replace("`","", $message);  
$message=str_replace("^","", $message);   
$message=str_replace("%","&#37;", $message);  
$message=str_replace(":","&#58;",$message); 
$message=preg_replace("/&#58;/",":",$message,2); 
/* 
$message=preg_replace('/(j|J)(s|S)?/i',"***",$message); 
$message=preg_replace('/(s|S)(c|C)(r|R)(i|I)(p|P)(t|T)?/i',"***",$message); 
$message=preg_replace('/(i|I)(m|M)(g|G)?/i',"***",$message); 
$message=preg_replace('/(s|S)(r|R)(c|C)?/i',"***",$message); $message=preg_replace('/(a|A)(l|L)(e|E)(r|R)(t|T)?/i',"***",$message);                      
*/
$message=stripslashes(trim($message));               
return $message;  }


function check_full($message){ 
$message=str_replace("|","I",$message); 
$message=str_replace("||","I",$message);
$message=str_replace("&","",$message);
$message=str_replace("\"","",$message);
$message=str_replace(">","",$message);
$message=str_replace("<","",$message);
$message=htmlspecialchars($message);                  
$message=str_replace("'","",$message);            
$message=str_replace("\"","",$message);  
$message=str_replace("/\\\$/","",$message);    
$message=str_replace("$","",$message);          
$message=str_replace("\\","", $message);                            
$message=str_replace("@","", $message);      
$message=str_replace("`","", $message);    
$message=str_replace("%","", $message);
$message=str_replace("^","", $message); 
$message=stripslashes(trim($message));               
return $message;  }

if ($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) $browsus = htmlspecialchars(stripslashes($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']));
else $browsus=htmlspecialchars(stripslashes($_SERVER['HTTP_USER_AGENT']));
$brow=strtok($browsus,'(');
$brow=strtok($brow,' ');
$brow=substr($brow,0,22);
$brow=str_replace("http://","", $brow);
if(empty($brow)){$brow='not detected';}

function CheckIP () 
{global $config_floodstime;
        
$flag= false;   
$fs= filesize(BASEDIR.'local/antiflood.dat');
$f= fopen(BASEDIR.'local/antiflood.dat', 'r');
flock($f, LOCK_SH);
$arr= @unserialize(fread($f, $fs));
flock($f, LOCK_UN);
fclose($f);
$IP= $_SERVER['REMOTE_ADDR'];
$IP=htmlspecialchars(stripslashes($IP));
$t= time();                     
if (isset($arr)) { 
foreach ($arr as $k=>$v)
if ($v<$t) unset($arr[$k]);
} else $arr= array ();
if (!isset($arr[$IP])) {        
$arr[$IP]= $t + $config_floodstime;     
$flag= false;
} else {
$arr[$IP]= $t + $config_floodstime;     
$flag= true;
}
$f= fopen(BASEDIR.'local/antiflood.dat', 'a+'); 
flock($f, LOCK_EX);
ftruncate($f, 0);
@fwrite($f, serialize($arr));
fflush($f);
flock($f, LOCK_UN);
fclose($f);
return $flag;
}



function smiles($string){
$dir = opendir (BASEDIR."images/smiles"); 
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="'.BASEDIR.'images/smiles/'.$file.'" alt="">',$string);
}}
closedir ($dir);
return $string;  }


function  read_dir($dir) { 
if ($path = opendir($dir)) while ($file_name = readdir($path)) {
if (($file_name!=='.') && ($file_name!=="..")){ 
if ( is_dir($dir."/".$file_name)) $size +=read_dir($dir."/".$file_name); else  $size += filesize($dir."/".$file_name); 
}} return  $size;} 


function formatsize($file_size){

if($file_size >= 1073741824){
$file_size = round($file_size / 1073741824 * 100) / 100 . " Gb";
}elseif(
$file_size >= 1048576){
$file_size = round($file_size / 1048576 * 100) / 100 . " Mb";
}elseif(
$file_size >= 1024){
$file_size = round($file_size / 1024 * 100) / 100 . " Kb";
}else{
$file_size = $file_size . " b";}
return $file_size;
}

//------------------ Функция выводящая картинку в загрузках --------------------//
function raiting_vote($string){
if($string==0){$string=str_replace('0','<img src="../images/img/rating0.gif" alt="0"/>',$string);}
if($string>'0' && $string<='0.5'){ $string=str_replace($string,'<img src="../images/img/rating1.gif" alt="0.5"/>',$string); }
if($string>'0.5' && $string<='1'){ $string=str_replace($string,'<img src="../images/img/rating2.gif" alt="1"/>',$string); }
if($string>'1' && $string<='1.5'){ $string=str_replace($string,'<img src="../images/img/rating3.gif" alt="1.5"/>',$string); }
if($string>'1.5' && $string<='2'){ $string=str_replace($string,'<img src="../images/img/rating4.gif" alt="2"/>',$string); }
if($string>'2' && $string<='2.5'){ $string=str_replace($string,'<img src="../images/img/rating5.gif" alt="2.5"/>',$string); }
if($string>'2.5' && $string<='3'){ $string=str_replace($string,'<img src="../images/img/rating6.gif" alt="3"/>',$string); }
if($string>'3' && $string<='3.5'){ $string=str_replace($string,'<img src="../images/img/rating7.gif" alt="3.5"/>',$string); }
if($string>'3.5' && $string<='4'){ $string=str_replace($string,'<img src="../images/img/rating8.gif" alt="4"/>',$string); }
if($string>'4' && $string<='4.5'){ $string=str_replace($string,'<img src="../images/img/rating9.gif" alt="4.5"/>',$string); }
if($string>'4.5' && $string<='5'){ $string=str_replace($string,'<img src="../images/img/rating10.gif" alt="5"/>',$string); }
return $string;  }

?>