Вход Регистрация
Файл: includes/func/func.php
Строк: 258
<?
$versiya 
'5;0';

function 
win_to_utf($str){
$str=strtr($str,array(''=>'а',''=>'б',''=>'в',''=>'г',''=>'д',''=>'е',''=>'ё',''=>'ж',''=>'з',''=>'и',''=>'й',''=>'к',''=>'л',''=>'м',''=>'н',''=>'о',''=>'п',''=>'р',''=>'с',''=>'т',''=>'у',''=>'ф',''=>'х',''=>'ц',''=>'ч',''=>'ш',''=>'щ',''=>'ъ',''=>'ы',''=>'ь',''=>'э',''=>'ю',''=>'я',''=>'А',''=>'Б',''=>'В',''=>'Г',''=>'Д',''=>'Е',''=>'Ё',''=>'Ж',''=>'З',''=>'?',''=>'Й',''=>'К',''=>'Л',''=>'М',''=>'Н',''=>'О',''=>'П',''=>'Р',''=>'С',''=>'Т',''=>'У',''=>'Ф',''=>'Х',''=>'Ц',''=>'Ч',''=>'Ш',''=>'Щ',''=>'Ъ',''=>'Ы',''=>'Ь',''=>'Э',''=>'Ю',''=>'Я'));
return 
$str;
}

function 
utf_to_win($str){
$str=strtr($str,array('а'=>'','б'=>'','в'=>'','г'=>'','д'=>'','е'=>'','ё'=>'','ж'=>'','з'=>'','и'=>'','й'=>'','к'=>'','л'=>'','м'=>'','н'=>'','о'=>'','п'=>'','р'=>'','с'=>'','т'=>'','у'=>'','ф'=>'','х'=>'','ц'=>'','ч'=>'','ш'=>'','щ'=>'','ъ'=>'','ы'=>'','ь'=>'','э'=>'','ю'=>'','я'=>'','А'=>'','Б'=>'','В'=>'','Г'=>'','Д'=>'','Е'=>'','Ё'=>'','Ж'=>'','З'=>'','И'=>'','Й'=>'','К'=>'','Л'=>'','М'=>'','Н'=>'','О'=>'','П'=>'','Р'=>'','С'=>'','Т'=>'','У'=>'','Ф'=>'','Х'=>'','Ц'=>'','Ч'=>'','Ш'=>'','Щ'=>'','Ъ'=>'','Ы'=>'','Ь'=>'','Э'=>'','Ю'=>'','Я'=>''));
return 
$str;
}

function 
getmicrotime()
{
list(
$usec$sec) = explode(' 'microtime());
return ((float)
$usec + (float)$sec);
}
function 
rus_to_k($str){
$str strtr($str, array ('а' => 'a','б' => 'b','в' => 'v','г' => 'g','д' => 'd','е' => 'e','ё' => 'e','ж' => 'j','з' => 'z','и' => 'i','й' => 'y','к' => 'k','л' => 'l','м' => 'm','н' => 'n','о' => 'o','п' => 'p','р' => 'r','с' => 's','т' => 't','у' => 'u','ф' => 'f','х' => 'h','ч' => 'c','ц' => 'q','ш' => 'w','щ' => '>','ь' => '<','ы' => 'x','ъ' => '.','э' => ':','ю' => ';','я' => '}','А' => 'a','Б' => 'b','В' => 'v','Г' => 'g','Д' => 'd','Е' => 'e','Ё' => 'e','Ж' => 'j','З' => 'z','И' => 'i','Й' => 'y','К' => 'k','Л' => 'l','М' => 'm','Н' => 'n','О' => 'o','П' => 'p','Р' => 'r','С' => 's','Т' => 't','У' => 'u','Ф' => 'f','Х' => 'h','Ч' => 'c','Ц' => 'q','Ш' => 'w','Щ' => '>','Ь' => '<','Ы' => 'x','Ъ' => '.','Э' => ':','Ю' => ';','Я' => '}'));
return 
$str;
}

function 
rus_to_lat($str) {
$str strtr($str, array ('а' => 'a','б' => 'b','в' => 'v','г' => 'g','д' => 'd','е' => 'e','ё' => 'e','ж' => 'j','з' => 'z','и' => 'i','й' => 'i','к' => 'k','л' => 'l','м' => 'm','н' => 'n','о' => 'o','п' => 'p','р' => 'r','с' => 's','т' => 't','у' => 'u','ф' => 'f','х' => 'h','ц' => 'c','ч' => 'ch','ш' => 'sh','щ' => 'sch','ъ' => "",'ы' => 'y','ь' => "",
'э' => 'ye','ю' => 'yu','я' => 'ya'));
return 
$str;
}

function 
tolower($str) {
if (
function_exists('mb_strtolower')) return mb_strtolower($str'utf-8');
$arraytolower = 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 
strtr($str$arraytolower);
}

function 
toupper($str) {
if (
function_exists('mb_strtoupper')) return mb_strtoupper($str'utf-8');
$arraytoupper = 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 
strtr($str$arraytoupper);
}

function 
znak0($str) {
$znak = array(' ' => '''!' => '''?' => '''.' => ''',' => '');
return 
strtr($str$znak);
}

function 
zamb($str) {
$zamb = array('е' => 'Э''Е' => 'э''я' => 'ЙА''Я' => 'йа''ё' => 'ЙО''Ё' => 'йо''Ё' => 'йо''ю' => 'ЙУ''Ю' => 'йу''к' => 'Г''K' => 'г''В' => 'ф''в' => 'Ф''р' => 'Л''Р' => 'л''т' => 'Д''Т' => 'д''ч' => 'Ш''Ч' => 'ш');
return 
strtr($str$zamb);
}




function 
translit($str) {

$str strtr($str, array ('a' => 'а','b' => 'б','v' => 'в','g' => 'г','d' => 'д','e' => 'е','yo' => 'ё','zh' => 'ж','z' => 'з','i' => 'и','j' => 'й','k' => 'к','l' => 'л','m' => 'м','n' => 'н','o' => 'о','p' => 'п','r' => 'р','s' => 'с','t' => 'т','u' => 'у','f' => 'ф','h' => 'х','c' => 'ц','ch' => 'ч','w' => 'ш','sh' => 'щ','q' => 'ъ','y' => 'ы','x' => 'э','yu' => 'ю','ya' => 'я','A' => 'А','B' => 'Б','V' => 'В','G' => 'Г','D' => 'Д','E' => 'Е','YO' => 'Ё','ZH' => 'Ж','Z' => 'З','I' => 'И','J' => 'Й','K' => 'К','L' => 'Л','M' => 'М','N' => 'Н','O' => 'О','P' => 'П','R' => 'Р','S' => 'С','T' => 'Т','U' => 'У','F' => 'Ф','H' => 'Х','C' => 'Ц','CH' => 'Ч','W' => 'Ш','SH' => 'Щ','Q' => 'Ъ','Y' => 'Ы','X' => 'Э','YU' => 'Ю','YA' => 'Я'));
return 
$str;
}


function 
strlen2($str)
{
if (
function_exists('mb_strlen')) return mb_strlen($str'utf-8');
if (
function_exists('iconv_strlen')) return iconv_strlen($str'utf-8');
if (
function_exists('utf8_decode')) return strlen(utf8_decode($str));
return 
strlen(utf_to_win($str));
}

function 
substr2($str)
{
global 
$db,  $v_us,$set;
$str=substr($str0$set['size_lich']);
$str=preg_replace('#^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,0}'.'((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,500}).*#s','$1',$str);
return 
$str;
}

function 
times($times=NULL)
{ global 
$db;
$timesp=date("j M  в H:i"$times);
$timesp strtr($timesp, array ("Jan" => "Янв","Feb" => "Фев","Mar" => "Марта","May" => "Мая","Apr" => "Апр","Jun" => "Июня","Jul" => "Июля","Aug" => "Авг","Sep" => "Сент","Oct" => "Окт","Nov" => "Ноября","Dec" => "Дек",));
return 
$timesp;
}

function 
opsos($ips=NULL){
global 
$db,  $ip;
if (
$ips==NULL)$ips=$ip;
$ipl=ip2long($ips);
if (
mysql_result(query("SELECT COUNT(*) FROM `opsos` WHERE  `min` <= '$ipl' AND `max` >= '$ipl'"), 0)!=0){
$opsos=mysql_fetch_assoc(query("SELECT opsos FROM `opsos` WHERE  `min` <= '$ipl' AND `max` >= '$ipl' LIMIT 1"));
return 
check($opsos['opsos']);
}else return 
false;
}

function 
page($k_page=1){
$page=1;
$page=check($page);
$k_page=check($k_page);
if (isset(
$_GET['page'])){
if (
$_GET['page']=='end')$page=check(intval($k_page));elseif(is_numeric($_GET['page'])) $page=check(intval($_GET['page']));}
if (
$page<1)$page=1;
if (
$page>$k_page)$page=$k_page;
return 
$page;}
// Определяем кол-во страниц
function k_page($k_post=0,$k_p_str=10){
if (
$k_post!=0){$v_pages=ceil($k_post/$k_p_str);return $v_pages;}
else return 
1;}
$HOSTik md5($_SERVER['HTTP_HOST']);
function 
str($link='?',$k_page=1,$page=1){
if (
$page<1)$page=1;
$page=check($page);
$k_page=check($k_page);
if (
$page!=1)echo '<a href="'.$link.'page=1">&lt;&lt;</a> ';
if (
$page>1)echo '<a href="'.$link.'page='.($page-1).'">&lt;</a> ';
echo 
" ";
if (
$page<$k_page)echo ' <a href="'.$link.'page='.($page+1).'" >&gt;</a>';
if (
$page!=$k_page)echo ' <a href="'.$link.'page=end">&gt;&gt;</a>';
echo 
"<br />";
if (
$page!=1)echo '<a href="'.$link.'page=1" >1</a>';else echo '<b>1</b>';
for (
$ot=-3$ot<=3$ot++){
if (
$page+$ot>&& $page+$ot<$k_page){
if (
$ot==-&& $page+$ot>2)echo " ..";
if (
$ot!=0)echo '|<a href="'.$link.'page='.($page+$ot).'" >'.($page+$ot).'</a>';else echo '|<b>'.($page+$ot).'</b>';
if (
$ot==&& $page+$ot<$k_page-1)echo "|..";}}
if (
$page!=$k_page)echo '|<a href="'.$link.'page=end" >'.$k_page.'</a>';elseif ($k_page>1)echo '|<b>'.$k_page.'</b>';
}

function 
str2($link='?',$k_page=1,$page=1){
if (
$page<1)$page=1;
$page=check($page);
$k_page=check($k_page);
if (
$page!=1)echo "<a href="".$link."_1">&lt;&lt;</a> ";
if (
$page>1)echo "<a href="".$link."_".($page-1)."">&lt;</a> ";
echo 
" ";
if (
$page<$k_page)echo " <a href="".$link."_".($page+1)."" >&gt;</a>";
if (
$page!=$k_page)echo " <a href="".$link."_end">&gt;&gt;</a>";
echo 
"<br />";
if (
$page!=1)echo "<a href="".$link."_1" >1</a>";else echo "<b>1</b>";
for (
$ot=-3$ot<=3$ot++){
if (
$page+$ot>&& $page+$ot<$k_page){
if (
$ot==-&& $page+$ot>2)echo " ..";
if (
$ot!=0)echo "|<a href="".$link."_".($page+$ot)."" >".($page+$ot)."</a>";else echo "|<b>".($page+$ot)."</b>";
if (
$ot==&& $page+$ot<$k_page-1)echo "|..";}}
if (
$page!=$k_page)echo "|<a href="".$link."_end" >$k_page</a>";elseif ($k_page>1)echo "|<b>$k_page</b>";

}

function 
passgen($k_simb=8) {
$password="";
$small="abcdefghijklmnopqrstuvwxyz";
$large="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$numbers="1234567890";
mt_srand((double)microtime()*1000000);
for (
$i=0$i<$k_simb$i++) {
$type=mt_rand(1,3);
switch (
$type) {
case 
1:
$password.=$large[mt_rand(0,25)];
break;
case 
2:
$password.=$small[mt_rand(0,25)];
break;
case 
3:
$password.=$numbers[mt_rand(0,9)];
break;}}return 
$password;}

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


function 
lev_neme($lv) { global $db,  $time;
$ln = @mysql_fetch_assoc(query ("Select * from levels WHERE level='".intval($lv)."'"));
return 
$ln['name'];
}

function 
addmail($v_usmail$subject$msg) {
global 
$db,  $set;

$mail 'admin@'.$_SERVER['HTTP_HOST'];
$name $set['name'];

function 
utf_to_win2($str) {

if (
function_exists('mb_convert_encoding')) return mb_convert_encoding($str'windows-1251''utf-8');
if (
function_exists('iconv')) return iconv('utf-8''windows-1251'$str);

$utf8win1251 = array("А"=>"xC0","Б"=>"xC1","В"=>"xC2","Г"=>"xC3","Д"=>"xC4","Е"=>"xC5","Ё"=>"xA8","Ж"=>"xC6","З"=>"xC7","И"=>"xC8","Й"=>"xC9","К"=>"xCA","Л"=>"xCB","М"=>"xCC","Н"=>"xCD","О"=>"xCE","П"=>"xCF","Р"=>"xD0","С"=>"xD1","Т"=>"xD2","У"=>"xD3","Ф"=>"xD4","Х"=>"xD5","Ц"=>"xD6","Ч"=>"xD7","Ш"=>"xD8","Щ"=>"xD9","Ъ"=>"xDA",
"Ы"=>"xDB","Ь"=>"xDC","Э"=>"xDD","Ю"=>"xDE","Я"=>"xDF","а"=>"xE0","б"=>"xE1","в"=>"xE2","г"=>"xE3","д"=>"xE4","е"=>"xE5","ё"=>"xB8","ж"=>"xE6","з"=>"xE7",
"и"=>"xE8","й"=>"xE9","к"=>"xEA","л"=>"xEB","м"=>"xEC","н"=>"xED","о"=>"xEE","п"=>"xEF","р"=>"xF0","с"=>"xF1","т"=>"xF2","у"=>"xF3","ф"=>"xF4","х"=>"xF5",
"ц"=>"xF6","ч"=>"xF7","ш"=>"xF8","щ"=>"xF9","ъ"=>"xFA","ы"=>"xFB","ь"=>"xFC","э"=>"xFD","ю"=>"xFE","я"=>"xFF");

return 
strtr($str$utf8win1251);
}

$subject utf_to_win2($subject);
$msg utf_to_win2($msg);
$name utf_to_win2($name);

$subject convert_cyr_string($subject'w','k');
$msg convert_cyr_string($msg'w','k');
$name convert_cyr_string($name'w','k');

$subject '=?KOI8-R?B?'.base64_encode($subject).'?=';

$adds "From: ".$name." <".$mail.">n";
$adds .= "X-sender: ".$name." <".$mail.">n";
$adds .= "Content-Type: text/plain; charset=koi8-rn";
$adds .= "MIME-Version: 1.0n";
$adds .= "Content-Transfer-Encoding: 8bitn";
$adds .= "X-Mailer: PHP v.".phpversion();

return 
mail($v_usmail,$subject,$msg,$adds);
}

// Город
function cities($c=NULL,$w=NULL,$i=NULL) {
global 
$db$sid;

if(
$w==1){ $crc 'cities';
$crc2 'city_id';
$crc3 'city_rus';
}else if(
$w==2){ $crc 'regions';
$crc2 'region_id';
$crc3 'region_rus';
}else if(
$w==3){ $crc 'country';
$crc2 'country_id';
$crc3 'country_rus';
}
$l mysql_fetch_assoc(query("Select * from `".$crc."` where `".$crc2."` = '$c'"));
if(
$i==NULL)return $l[$crc3];
else return 
$l[$crc2];
}

function 
extract16color($color16){
$mask16=array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
$color_mask=array("r","g","b");
$true_color=array("r"=>0,"g"=>0,"b"=>0);
$color16=substr($color16,1);
for(
$icm=0$icm<count($color_mask); $icm++){
$color16_temp=array(substr($color16,($icm*2),1),substr($color16,($icm*2)+1,1));
for (
$ic=0$ic<2$ic++){
for(
$i=0$i<count($mask16); $i++){
if (
$color16_temp[$ic]==$mask16[$i]){
$color16_temp[$ic]=$i;
break;
}
}
}
$true_color[$color_mask[$icm]]=((int)$color16_temp[0]*16)+(int)$color16_temp[1];
}
return 
$true_color;
}
function 
make16color($color10){
$mask16=array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
$color_mask=array("r","g","b");
$true_color="#";
for(
$icm=0$icm<count($color_mask); $icm++){
$color10_temp=(int)$color10[$color_mask[$icm]];
$true_color.=$mask16[(int)($color10_temp/16)];
$true_color.=$mask16[$color10_temp%16];
}
return 
$true_color;
}
function 
GradientText($text,$sColor,$eColor){
$color_mask=array("r","g","b");
$color_move=array("r"=>0,"g"=>0,"b"=>0);
$color_add=array("r"=>0,"g"=>0,"b"=>0);
$word=array();
$length=strlen($text);
$output="";
$Gzip="";
$current_color="#000000";
$max=0;
if(
$length>0){
$sColor=extract16color($sColor);
$eColor=extract16color($eColor);
$cColor=$sColor;
for(
$i=0$i<count($color_mask); $i++){
$temp=$sColor[$color_mask[$i]]-$eColor[$color_mask[$i]];
$color_add[$color_mask[$i]]=abs($temp);
if(
abs($temp)>$max){
$max=abs($temp);
}
if(
$temp<0){
$color_move[$color_mask[$i]]=1;
} else if (
$temp>0){
$color_move[$color_mask[$i]]=-1;
} else {
$color_move[$color_mask[$i]]=0;
}
}
for(
$i=0$i<$length$i++){
$char=substr($text,$i,1);
$test=ord($char);
if(
$test>=128 and $test<=255 $test=""){
$char=substr($text,$i,2);
$i++;
}
$word[]=$char;
}
}
$length=count($word);
$koeff_add=@(($max/$length)/$max)*100;
for(
$i=0$i<$length$i++){
for(
$i2=0$i2<count($color_mask); $i2++){
$add=(($color_add[$color_mask[$i2]]/100)*$koeff_add)*$color_move[$color_mask[$i2]];
$cColor[$color_mask[$i2]]+=$add;
}
$current_color=make16color($cColor);
if(!
$i){
$output.='<font color="'.$current_color.'">'.$word[$i];
$Gzip=$current_color;
} else {
if(
$current_color==$Gzip $word[$i]==" "){
$output.=$word[$i];
} else {
$output.='</font><font color="'.$current_color.'">'.$word[$i];
$Gzip=$current_color;
}
}
}
if(
strlen($output)){
$output.="</font>";
}
return 
$output;
}







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