Файл: templates/func.php
Строк: 333
<?php
########################################
## WAP-ENGINE ##
########################################
## ##
## Автор : CHUMA (Токарев Владимир) ##
## e-mail : crazychuma@gmail.com ##
## WAP : http://wap-engine.ru ##
## ##
########################################
## ВЫ НЕ ИМЕЕТЕ ПРАВО ##
## ИЗМЕНЯТЬ КОД СКРИПТА ##
## ДЛЯ ДАЛЬНЕЙШЕГО РАСПРОСТРАНЕНИЯ! ##
########################################
#Системные Цвета
$color_green = 'green';
$color_red = 'red';
#Латиница в кирилицу
function tr_to_win($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"=>"ч","sh"=>"ш","sch"=>"щ","q"=>"ъ","x"=>"ы","'"=>"ь","ye"=>"э","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"=>"Ч","SH"=>"Ш","SCH"=>"Щ","Q"=>"Ъ","X"=>"Ы","YE"=>"Э","YU"=>"Ю","YA"=>"Я"));
return $str;
}
#Кирилица в латиницу
function win_to_tr($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","ш"=>"sh","щ"=>"sch","ъ"=>"q","ы"=>"x","ь"=>"'","э"=>"ye","ю"=>"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","Ш"=>"SH","Щ"=>"SCH","Ъ"=>"Q","Ы"=>"X","Э"=>"YE","Ю"=>"YU","Я"=>"YA"));
return $str;
}
#Фильтрация строк
function filter($str)
{
$filter_str = htmlspecialchars(stripslashes(trim($str)));
$filter_str = str_replace('/*', '/*', $filter_str);
$filter_str = str_replace('*/', '*/', $filter_str);
$filter_str = str_replace('|', '|', $filter_str);
return $filter_str;
}
#Смайлики
function smiles($str)
{
$sm_dir = opendir('../../sm');
while ($file = readdir($sm_dir))
{
if($file != 'Thumbs.db' && $file != '..' && $file != '.')
{
$sm_array[] = '<img src="../../sm/'.$file.'" alt="sm" />';
}
}
closedir ($sm_dir);
#sort($sm_array);
$sm_dir1 = opendir('../../sm');
while ($file1 = readdir($sm_dir1))
{
if($file1 != 'Thumbs.db' && $file1 != '..' && $file1 != '.')
{
$file1 = explode('.', $file1);
if($_POST['msgtrans'] == 1)
{
$sm_array1[] = tr_to_win(':'.$file1[0]);
}
else
{
$sm_array1[] = ':'.$file1[0];
}
}
}
#sort($sm_array1);
closedir ($sm_dir1);
$msg_str = str_replace($sm_array1, $sm_array, $str);
return $msg_str;
}
# Начало антимат
function antimat($str)
{
$mat_file = file('../../data/antimat.txt');
$count_mat_file = count($mat_file);
for ($i = 0; $i <= $count_mat_file; $i++)
{
$mat = explode('::', $mat_file[$i]);
$mat_array[] = $mat[0];
}
$mat_file1 = file('../../data/antimat.txt');
$count_mat_file1 = count($mat_file1);
for ($i = 0; $i <= $count_mat_file1; $i++)
{
$mat1 = explode('::', $mat_file1[$i]);
$mat1 = str_replace('
','', $mat1[1]);
$mat_array1[] = $mat1;
}
$msg_str = str_replace($mat_array, $mat_array1, $str);
$msg_str = str_replace('*', '*', $msg_str);
return $msg_str;
}
#Запись в файл
function write_to_file($path, $str)
{
$f = fopen($path, 'a+');
if(flock($f, LOCK_EX))
{
ftruncate($f, 0);
fputs($f, $str);
fflush($f);
flock($f, LOCK_UN);
fclose($f);
}
}
#Считывание данных пользователя
function user_data($data_file)
{
$user_f = file($data_file);
global $login, $email, $passw, $reg_date, $last_visit, $name, $site, $icq, $pol, $otkuda, $modelphone, $operator, $show_mail, $reputacia, $status, $data_rozhd, $bantime, $bantxt, $banwho, $mes_guest, $mes_forum, $mes_komm, $new_ls, $activ_account, $izm_repu, $plusov, $minusov, $o_sebe, $rating, $time_in_site, $vhodov, $all_temes, $statey, $mes_chat, $status_name, $nick_name;
$login = trim($user_f[2]);
$email = trim($user_f[3]);
$passw = trim($user_f[4]);
$reg_date = trim($user_f[5]);
$last_visit = trim($user_f[6]);
$name = trim($user_f[7]);
$site = trim($user_f[8]);
$icq = trim($user_f[9]);
$pol = trim($user_f[10]);
$otkuda = trim($user_f[11]);
$modelphone = trim($user_f[12]);
$operator = trim($user_f[13]);
$show_mail = trim($user_f[14]);
$reputacia = trim($user_f[15]);
$status = trim($user_f[16]);
$data_rozhd = trim($user_f[17]);
$bantime = trim($user_f[18]);
$bantxt = trim($user_f[19]);
$banwho = trim($user_f[20]);
$mes_guest = trim($user_f[21]);
$mes_forum = trim($user_f[22]);
$mes_komm = trim($user_f[23]);
$new_ls = trim($user_f[24]);
$activ_account = trim($user_f[25]);
$izm_repu = trim($user_f[26]);
$plusov = trim($user_f[27]);
$minusov = trim($user_f[28]);
$o_sebe = trim($user_f[29]);
$rating = trim($user_f[30]);
$time_in_site = trim($user_f[31]);
$vhodov = trim($user_f[32]);
$all_temes = trim($user_f[33]);
$statey = trim($user_f[34]);
$mes_chat = trim($user_f[35]);
$status_name = trim($user_f[36]);
$nick_name = trim($user_f[37]);
}
#Строка данных пользователя
function str_user_data()
{
global $login, $email, $passw, $reg_date, $last_visit, $name, $site, $icq, $pol, $otkuda, $modelphone, $operator, $show_mail, $reputacia, $status, $data_rozhd, $bantime, $bantxt, $banwho, $mes_guest, $mes_forum, $mes_komm, $new_ls, $activ_account, $izm_repu, $plusov, $minusov, $o_sebe, $rating, $time_in_site, $vhodov, $all_temes, $statey, $mes_chat, $status_name, $nick_name;
$str_user_data = "$loginrn$emailrn$passwrn$reg_datern$last_visitrn$namern$sitern$icqrn$polrn$otkudarn$modelphonern$operatorrn$show_mailrn$reputaciarn$statusrn$data_rozhdrn$bantimern$bantxtrn$banwhorn$mes_guestrn$mes_forumrn$mes_kommrn$new_lsrn$activ_accountrn$izm_repurn$plusovrn$minusovrn$o_sebern$ratingrn$time_in_sitern$vhodovrn$all_temesrn$stateyrn$mes_chatrn$status_namern$nick_name";
return $str_user_data;
}
#Подсветка кода
function highlight_str($str)
{
$str = preg_replace('#<img src="../../sm/(.*?).gif" alt="sm" />#',':1', trim($str[1]));
@$str = highlight_string(html_entity_decode($str, ENT_QUOTES, 'UTF-8'), true);
$str = str_replace("n",'', $str);
$str = str_replace('/*', '/*', $str);
$str = str_replace('*/', '*/', $str);
$str = str_replace('|','|', $str);
$str_exp = explode('<br />', $str);
$str_count = count($str_exp );
for($a = 0; $a < $str_count; $a++)
{
$b = $a+1;
$str_new .= '<br /><font color="#000000">'.$b.'</font> '.$str_exp[$a];
}
$str = '<font class="code">Код:'.$str_new.'</font>';
return $str;
}
#BB коды
$code_str = preg_replace_callback('#(<?(?:.*?)?>)#siu', 'highlight_str', '<? echo"здесь php код" ?>');
function bbcodes($str)
{
global $code_str;
if($str == 'show_list_bbcodes')
{
echo '<p class="b">';
echo '[b]Текст[/b] - Выделяет <b>жирным</b><br /><br />
[i]Текст[/i] - Выделяет <i>курсивом</i><br /><br />
[s]Текст[/s] - <s>Зачеркивает</s> текст<br /><br />
[u]Текст[/u] - <u>Подчеркивеат</u> текст<br /><br />
[small]Текст[/small] - <small>Уменьшает</small> текст<br /><br />
[big]Текст[/big] - <big>Увеличивает</big> текст<br /><br />
[red]Текст[/red] - <font color="red">Красный</font> текст<br /><br />
[green]Текст[/green] - <font color="green">Зеленый</font> текст<br /><br />
[blue]Текст[/blue] - <font color="blue">Синий</font> текст<br /><br />
[q]Текст[/q] - <font class="citata">Цитированный</font> текст<br /><br />
[code]<? echo"здесь php код" ?>[/code]<br />'.$code_str.'<br />
Также php код можно вставить без тегов [code][/code], написав начало и конец php кода <?php ?><br /><br />
[url=http://адрес ссылки]Название ссылки[/url] - Добавление ссылки с нужным названием ссылки<br />
Для того чтобы просто написать ссылку достаточно написать http://адрес_ссылки, так названием ссылки будет являться её адрес.</p>';
}
else
{
$str = preg_replace('#[б](.*?)[/б]#su', '<b>1</b>', $str);
$str = preg_replace('#[и](.*?)[/и]#su', '<i>1</i>', $str);
$str = preg_replace('#[с](.*?)[/с]#su', '<s>1</s>', $str);
$str = preg_replace('#[у](.*?)[/у]#su', '<u>1</u>', $str);
$str = preg_replace('#[смалл](.*?)[/смалл]#su', '<small>1</small>', $str);
$str = preg_replace('#[биг](.*?)[/биг]#su', '<big>1</big>', $str);
$str = preg_replace('#[ъ](.*?)[/ъ]#su', '<q>1</q>', $str);
$str = preg_replace('#[ред](.*?)[/ред]#su', '<font color="red">1</font>', $str);
$str = preg_replace('#[греен](.*?)[/греен]#su', '<font color="green">1</font>', $str);
$str = preg_replace('#[блуе](.*?)[/блуе]#su', '<font color="blue">1</font>', $str);
$str = preg_replace('#[b](.*?)[/b]#su', '<b>1</b>', $str);
$str = preg_replace('#[i](.*?)[/i]#su', '<i>1</i>', $str);
$str = preg_replace('#[s](.*?)[/s]#su', '<s>1</s>', $str);
$str = preg_replace('#[u](.*?)[/u]#su', '<u>1</u>', $str);
$str = preg_replace('#[small](.*?)[/small]#su', '<small>1</small>', $str);
$str = preg_replace('#[big](.*?)[/big]#su', '<big>1</big>', $str);
$str = preg_replace('#[q](.*?)[/q]#su', '<q>1</q>', $str);
$str = preg_replace('#[red](.*?)[/red]#su', '<font color="red">1</font>', $str);
$str = preg_replace('#[green](.*?)[/green]#su', '<font color="green">1</font>', $str);
$str = preg_replace('#[blue](.*?)[/blue]#su', '<font color="blue">1</font>', $str);
if(preg_match('#[code](.*?)[/code]#siu', $str))
{
$str = preg_replace_callback('#[code](.*?)[/code]#siu' , 'highlight_str', $str);
}
elseif(preg_match('#(<?(?:.*?)?>)#siu', $str))
{
$str = preg_replace_callback('#(<?(?:.*?)?>)#siu', 'highlight_str', $str);
}
if(preg_match('#[url=((?:http|https|ftp)://.*?)](.*?)[/url]#', $str))
{
$str = preg_replace('#[url=((?:http|https|ftp)://.*?)](.*?)[/url]#su', '<a href="1">2</a>', $str);
}
elseif(preg_match('#((?:http|https|ftp)://[0-9a-zA-Z._-]+.[0-9a-zA-Z]{2,6}[0-9a-zA-Z/?.~&_=/%-:#]*)#', $str))
{
$str = preg_replace('#((?:http|https|ftp)://[0-9a-zA-Z._-]+.[0-9a-zA-Z]{2,6}[0-9a-zA-Z/?.~&_=/%-:#]*)#su', '<a href="1">1</a>', $str);
}
return $str;
}
}
#BB коды наоборот
function bb_back($str)
{
$str = preg_replace('#<b>(.*?)</b>#su','[b]1[/b]', $str);
$str = preg_replace('#<i>(.*?)</i>#su','[i]1[/i]', $str);
$str = preg_replace('#<s>(.*?)</s>#su','[s]1[/s]', $str);
$str = preg_replace('#<u>(.*?)</u>#su','[u]1[/u]', $str);
$str = preg_replace('#<small>(.*?)</small>#su','[small]1[/small]', $str);
$str = preg_replace('#<big>(.*?)</big>#su','[big]1[/big]', $str);
$str = preg_replace('#<q>(.*?)</q>#su','[q]1[/q]', $str);
$str = preg_replace('#<font color="red">(.*?)</font>#su','[red]1[/red]', $str);
$str = preg_replace('#<font color="green">(.*?)</font>#su','[green]1[/green]', $str);
$str = preg_replace('#<font color="blue">(.*?)</font>#su','[blue]1[/blue]', $str);
$str = preg_replace('#<a href="((?:http|https|ftp)://.*?)">(?:(?:http|https|ftp)://(?:.*?))</a>#su','1', $str);
$str = preg_replace('#<a href="((?:http|https|ftp)://.*?)">(.*?)</a>#su','[url=1]2[/url]', $str);
return $str;
}
#Смайлы наоборот
function smiles_back($str)
{
$str = preg_replace('#<img src="../../sm/(.*?).gif" alt="sm" />#',':1', $str);
return $str;
}
#Пересчет файлов библиотеки
function book_kol($kat_kol)
{
$dir_kol = opendir("$kat_kol");
$kol = 0;
while($files_kol = readdir($dir_kol))
{
if(is_file($kat_kol.'/'.$files_kol) && $files_kol != 'Thumbs.db' && $files_kol != 'op.txt' && $files_kol != 'index.php' && $files_kol != 'kol.php' && preg_match("#^.*.txt$#", $files_kol))
{
$kol++;
if(file_exists($kat_kol.'/op.txt'))
{
$kat_file = @file($kat_kol.'/op.txt');
$kat_op_file = fopen($kat_kol.'/op.txt','w');
flock ($kat_op_file,LOCK_EX);
fputs($kat_op_file,"".trim($kat_file[0])."rn$kol");
fflush ($kat_op_file);
flock ($kat_op_file,LOCK_UN);
fclose($kat_op_file);
}
}
elseif(is_dir($kat_kol.'/'.$files_kol) && $files_kol != '.' && $files_kol != '..')
{
$es = book_kol($kat_kol.'/'.$files_kol);
$kol = $kol + $es;
}
if(file_exists($kat_kol.'/op.txt'))
{
$kat_file = @file($kat_kol.'/op.txt');
$kat_op_file = fopen($kat_kol.'/op.txt','w');
flock ($kat_op_file,LOCK_EX);
fputs($kat_op_file,"".trim($kat_file[0])."rn$kol");
fflush ($kat_op_file);
flock ($kat_op_file,LOCK_UN);
fclose($kat_op_file);
}
}
closedir($dir_kol);
return $kol;
}
#Пересчет новых файлов библиотеки
function book_kol_new($kat_kol_new)
{
$dir_kol_new = opendir($kat_kol_new);
$kol_new = 0;
while($files_kol_new = readdir($dir_kol_new))
{
if(is_file($kat_kol_new.'/'.$files_kol_new) && $files_kol_new != 'Thumbs.db' && $files_kol_new != 'op.txt' && $files_kol_new != 'index.php' && $files_kol_new != 'kol.php' && preg_match("#^.*.txt$#", $files_kol_new))
{
$datanew = filemtime($kat_kol_new.'/'.$files_kol_new) + 432000;
$datenow = time();
if($datanew > $datenow)
{
$kol_new++;
}
if(file_exists($kat_kol_new.'/op.txt'))
{
$kat_file = @file($kat_kol_new.'/op.txt');
$kat_op_file = fopen($kat_kol_new.'/op.txt','w');
flock ($kat_op_file,LOCK_EX);
fputs($kat_op_file,"".trim($kat_file[0])."rn".trim($kat_file[1])."rn$kol_new");
fflush ($kat_op_file);
flock ($kat_op_file,LOCK_UN);
fclose($kat_op_file);
}
}
elseif(is_dir($kat_kol_new.'/'.$files_kol_new) && $files_kol_new != '.' && $files_kol_new != '..')
{
$es_new = book_kol_new($kat_kol_new.'/'.$files_kol_new);
$kol_new = $kol_new + $es_new;
}
if(file_exists($kat_kol_new.'/op.txt'))
{
$kat_file = @file($kat_kol_new.'/op.txt');
$kat_op_file = fopen($kat_kol_new.'/op.txt','w');
flock ($kat_op_file,LOCK_EX);
fputs($kat_op_file,"".trim($kat_file[0])."rn".trim($kat_file[1])."rn$kol_new");
fflush ($kat_op_file);
flock ($kat_op_file,LOCK_UN);
fclose($kat_op_file);
}
}
closedir($dir_kol_new);
return $kol_new;
}
#Пересчет файлов загрузок
function zagruz_kol($kat_kol)
{
$dir_kol = opendir($kat_kol);
$kol = 0;
while($files_kol = readdir($dir_kol))
{
if(is_file($kat_kol.'/'.$files_kol) && $files_kol != 'Thumbs.db' && $files_kol != 'index.php' && $files_kol != 'kol.php' && $files_kol != 'admin.php' && $files_kol != 'kom.php' && $files_kol != 'img.php' && $files_kol != 'dload.php' && !preg_match("#^.*.jad$#", $files_kol))
{
$kol++;
if(file_exists($kat_kol.'/op/op.txt'))
{
$kat_file = @file($kat_kol.'/op/op.txt');
$kat_op_file = fopen($kat_kol.'/op/op.txt','w');
flock ($kat_op_file,LOCK_EX);
fputs($kat_op_file, trim($kat_file[0])."rn$kol");
fflush ($kat_op_file);
flock ($kat_op_file,LOCK_UN);
fclose($kat_op_file);
}
}
elseif(is_dir($kat_kol.'/'.$files_kol) && $files_kol != '.' && $files_kol != '..' && $files_kol != 'op')
{
$es = zagruz_kol($kat_kol.'/'.$files_kol);
$kol = $kol + $es;
}
if(file_exists($kat_kol.'/op/op.txt'))
{
$kat_file = @file($kat_kol.'/op/op.txt');
$kat_op_file = fopen($kat_kol.'/op/op.txt','w');
flock ($kat_op_file,LOCK_EX);
fputs($kat_op_file, trim($kat_file[0])."rn$kol");
fflush ($kat_op_file);
flock ($kat_op_file,LOCK_UN);
fclose($kat_op_file);
}
}
closedir($dir_kol);
return $kol;
}
#Пересчет новых файлов загрузок
function zagruz_kol_new($kat_kol_new)
{
$dir_kol_new = opendir($kat_kol_new);
$kol_new = 0;
while($files_kol_new = readdir($dir_kol_new))
{
if(is_file($kat_kol_new.'/'.$files_kol_new) && $files_kol_new != 'Thumbs.db' && $files_kol_new != 'index.php' && $files_kol_new != 'kol.php' && $files_kol_new != 'admin.php' && $files_kol_new != 'kom.php' && $files_kol_new != 'img.php' && $files_kol_new != 'dload.php' && !preg_match("#^.*.jad$#", $files_kol_new))
{
$datanew = filemtime($kat_kol_new.'/'.$files_kol_new) + 432000;
$datenow = time();
if($datanew > $datenow)
{
$kol_new++;
}
if(file_exists($kat_kol_new.'/op/op.txt'))
{
$kat_file = @file($kat_kol_new.'/op/op.txt');
$kat_op_file = fopen($kat_kol_new.'/op/op.txt','w');
flock ($kat_op_file,LOCK_EX);
fputs($kat_op_file, trim($kat_file[0])."rn".trim($kat_file[1])."rn$kol_new");
fflush ($kat_op_file);
flock ($kat_op_file,LOCK_UN);
fclose($kat_op_file);
}
}
elseif(is_dir($kat_kol_new.'/'.$files_kol_new) && $files_kol_new != '.' && $files_kol_new != '..' && $files_kol_new != 'op')
{
$es_new = zagruz_kol_new($kat_kol_new.'/'.$files_kol_new);
$kol_new = $kol_new + $es_new;
}
if(file_exists($kat_kol_new.'/op/op.txt'))
{
$kat_file = @file($kat_kol_new.'/op/op.txt');
$kat_op_file = fopen($kat_kol_new.'/op/op.txt','w');
flock ($kat_op_file,LOCK_EX);
fputs($kat_op_file, trim($kat_file[0])."rn".trim($kat_file[1])."rn$kol_new");
fflush ($kat_op_file);
flock ($kat_op_file,LOCK_UN);
fclose($kat_op_file);
}
}
closedir($dir_kol_new);
return $kol_new;
}
function vremya_sut($sdvig)
{
$hour = date('G', time() + ($sdvig*3600));
if ($hour>=6 && $hour<12)
{
$sut = 'Доброе утро,';
}
if ($hour>=12 && $hour<18)
{
$sut = 'Добрый день,';
}
if ($hour>=18 && $hour<=23)
{
$sut = 'Добрый вечер,';
}
if ($hour>=0 && $hour<6)
{
$sut = 'Доброй ночи,';
}
return $sut;
}
?>