View file templates/func.php

File size: 21.85Kb
<?php
########################################
##	           WAP-ENGINE             ##
########################################
##                                    ##
##  Автор : CHUMA (Токарев Владимир)  ##
##  e-mail : [email protected]     ##
##  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 calc_age($d, $m, $y)
{
$age = date('Y') - $y;
$_m = date('m');
if($_m < $m || ($_m == $m && date('d') < $d))
$age--;
return $age;
}
# Функция календарные месяца на русском языке
function rusdate($d)    {   
  $montharr = array("Января","Февраля","Марта","Апреля","Мая","Июня","Июля","Августа","Сентября","Октября","Ноября","Декабря");  
  $i =  date("m",$d) - 1;  
  return date("j",$d)." $montharr[$i] ".date("Y",$d);  
}

#функция определения знака зодиака
function zodiak($d,$m) {

$d=sprintf('%02d',$d);
$m=sprintf('%02d',$m);

if (($m=='03' AND $d>20) OR ($m=='04' AND $d<21)) return 'Oven';
if (($m=='04' AND $d>20) OR ($m=='05' AND $d<22)) return 'Taurus';
if (($m=='05' AND $d>21) OR ($m=='06' AND $d<22)) return 'Gemini';
if (($m=='06' AND $d>21) OR ($m=='07' AND $d<23)) return 'Cancer';
if (($m=='07' AND $d>22) OR ($m=='08' AND $d<24)) return 'Leo';
if (($m=='08' AND $d>23) OR ($m=='09' AND $d<24)) return 'Virgo';
if (($m=='09' AND $d>23) OR ($m=='10' AND $d<24)) return 'Libra';
if (($m=='10' AND $d>23) OR ($m=='11' AND $d<23)) return 'Scorpion';
if (($m=='11' AND $d>22) OR ($m=='12' AND $d<22)) return 'Sagittarius';
if (($m=='12' AND $d>21) OR ($m=='01' AND $d<19)) return 'Capricorn';
if (($m=='01' AND $d>20) OR ($m=='02' AND $d<19)) return 'Aquarius';
if (($m=='02' AND $d>18) OR ($m=='03' AND $d<21)) return 'Fish';

return null;
}
#Фильтрация строк
function filter($str)
{
$filter_str = htmlspecialchars(stripslashes(trim($str)));
$filter_str = str_replace('/*', '&#47;&#42;', $filter_str);
$filter_str = str_replace('*/', '&#42;&#47;', $filter_str);
$filter_str = str_replace('|', '&#124;', $filter_str);
$filter_str = str_replace('&amp;', '%26', $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;//mb_substr($mat1, 0, -2);
}
$msg_str = str_replace($mat_array, $mat_array1, $str);
$msg_str = str_replace('*', '&#42;', $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, $nickname, $mes_chat, $status_name, $nick_name, $podpis, $strana, $numbertel, $time_site, $interesy, $lybmusic, $lybfilm, $lybbook, $browser_soft, $ip_ip, $show_numbertel, $monet;

$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]);
$nickname = trim($user_f[34]);
$mes_chat = trim($user_f[35]);
$status_name = trim($user_f[36]);
$nick_name = trim($user_f[37]);
$podpis = trim($user_f[38]);
$strana = trim($user_f[39]);
$numbertel = trim($user_f[40]);
$time_site = trim($user_f[41]);
$interesy = trim($user_f[42]);
$lybmusic = trim($user_f[43]);
$lybfilm = trim($user_f[44]);
$lybbook = trim($user_f[45]);
$browser_soft = trim($user_f[46]);
$ip_ip = trim($user_f[47]);
$show_numbertel = trim($user_f[48]);
$monet = trim($user_f[49]);
}

#Строка данных пользователя
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, $nickname, $mes_chat, $status_name, $nick_name, $podpis, $strana, $numbertel, $time_site, $interesy, $lybmusic, $lybfilm, $lybbook, $browser_soft, $ip_ip, $show_numbertel, $monet;

$str_user_data = "$login\r\n$email\r\n$passw\r\n$reg_date\r\n$last_visit\r\n$name\r\n$site\r\n$icq\r\n$pol\r\n$otkuda\r\n$modelphone\r\n$operator\r\n$show_mail\r\n$reputacia\r\n$status\r\n$data_rozhd\r\n$bantime\r\n$bantxt\r\n$banwho\r\n$mes_guest\r\n$mes_forum\r\n$mes_komm\r\n$new_ls\r\n$activ_account\r\n$izm_repu\r\n$plusov\r\n$minusov\r\n$o_sebe\r\n$rating\r\n$time_in_site\r\n$vhodov\r\n$all_temes\r\n$nickname\r\n$mes_chat\r\n$status_name\r\n$nick_name\r\n$podpis\r\n$strana\r\n$numbertel\r\n$time_site\r\n$interesy\r\n$lybmusic\r\n$lybfilm\r\n$lybbook\r\n$browser_soft\r\n$ip_ip\r\n$show_numbertel\r\n$monet";

return $str_user_data;
}

#Вывод цветного ника
function nick_user($login_user)
{
$login_user_arr = explode('::', $login_user);
$login_user = $login_user_arr[0];
$nick_user = $login_user_arr[1];
$nick_user_color = $login_user_arr[2];

if(!empty($nick_user) && !empty($nick_user_color))
{
$nick_user_show = '<font color="'.$nick_user_color.'">'.$nick_user.'</font>';
}
elseif(!empty($nick_user))
{
$nick_user_show = $nick_user;
}
else
{
$nick_user_show = $login_user;
}

$nickname_user[] = $login_user;
$nickname_user[] = $nick_user_show;

return $nickname_user;
}

#Подсветка кода
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('/*', '&#47;&#42;', $str);
$str = str_replace('*/', '&#42;&#47;', $str);
$str = str_replace('|','&#124;', $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>&nbsp;&nbsp;&nbsp;'.$str_exp[$a];
}

$str = '<font class="code">Код:'.$str_new.'</font>';

return $str;
}

#BB коды
$code_str = preg_replace_callback('#(&lt;\?(?:.*?)\?&gt;)#siu', 'highlight_str', '&lt;? echo"здесь php код" ?&gt;');
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]&lt;? echo"здесь php код" ?&gt;[/code]<br />'.$code_str.'<br />
Также php код можно вставить без тегов [code][/code], написав начало и конец php кода <?php ?><br /><br />

[url=http://адрес ссылки]Название ссылки[/url] - Добавление ссылки с нужным названием ссылки<br />
Для того чтобы просто написать ссылку достаточно написать http://адрес_ссылки, так названием ссылки будет являться её адрес. <p class="a">Значение картинок</p> <p class="b"><img src="/images/st/1.gif"/> - означает Отправить сообщение пользователю.<br /> <img src="/images/st/r.gif"/> - означает редактирование сообщения(на форуме).<br /> <img src="/images/st/g.gif"/> - означает написать кому(логин) в гостевой, чате, на форуме.<br /> <img src="/images/st/c.gif"/> - означает цитата, цитирование сообщения(на форуме).<br /></p></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('#(&lt;\?(?:.*?)\?&gt;)#siu', $str))
{
$str = preg_replace_callback('#(&lt;\?(?:.*?)\?&gt;)#siu', 'highlight_str', $str);
}


if(preg_match('#\[url=((?:http|https|ftp)://.*?)\](.*?)\[/url\]#', $str))
{
$str = preg_replace('#\[url=((?:http|https|ftp)://.*?)\](.*?)\[/url\]#su', '<a href="'.$dob_url.'/go.php?url=\1">\2</a>', $str);
}
elseif(preg_match('#((?:http|https|ftp)://[0-9a-zA-Z\._-]+\.[0-9a-zA-Z]{2,6}[0-9a-zA-Z/\?\.\~&amp;_=/%-:\#\+\!]*)#', $str))
{
$str = preg_replace('#((?:http|https|ftp)://[0-9a-zA-Z\._-]+\.[0-9a-zA-Z]{2,6}[0-9a-zA-Z/\?\.\~&amp;_=/%-:\#\+\!]*)#su', '<a href="'.$dob_url.'/go.php?url=\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 = str_replace('/go.php?url=', '', $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])."\r\n$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])."\r\n$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])."\r\n".trim($kat_file[1])."\r\n$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])."\r\n".trim($kat_file[1])."\r\n$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])."\r\n$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])."\r\n$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])."\r\n".trim($kat_file[1])."\r\n$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])."\r\n".trim($kat_file[1])."\r\n$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;
}
?>