Файл: sys/func.php
Строк: 645
<?
//заголовок
function title($title){
echo'<title>'.$title.'</title>';
}
//подсчет
function count_one($where){
$count = DB::run() -> query("SELECT * FROM `$where`");
return $count -> rowCount();
}
function count_all($from,$where,$set){
$count = DB::run() -> query("SELECT * FROM `$from` WHERE `$where` = '$set'");
return $count -> rowCount();
}
# приветствие
function welcom($login){
if($login == !NULL){$a = $login;} else {$a = 'Гость';}
$hour = date('H');
if ($hour <= 4 || $hour >= 23) {
$time_of_day = 'Доброй ночи, '.$a.'';
}else
if ($hour >= 5 && $hour <= 10) {
$time_of_day = 'Доброе утро, '.$a.'';
}else
if ($hour >= 11 && $hour <= 17) {
$time_of_day = 'Добрый день, '.$a.'';
}else
if ($hour >= 18 && $hour <= 22) {
$time_of_day = 'Добрый вечер, '.$a.'';
}
return $time_of_day;
}
//последняя новость
function last_news(){
$last_news = DB::run() -> queryFetch("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1");
if($last_news['time'] >= time()) {
echo'<div class="title">Новости</div>
<div class="menu">';
echo'<strong>'.$last_news['title'].'</strong> ('.$last_news['data'].')<br />'.$last_news['msg'].'<hr>';
echo'<a href="/news/index.php?id_news='.$last_news['id'].'">Подробней</a> | <a href="/news/comment.php?id_news='.$last_news['id'].'">Комментарии</a> ('.count_all('news_com','id_news',$last_news['id']).')';
echo'</div>';
}
}
function times(){
$dat = date("d");
$m = date("m");
if($m == '01'){$t = 'Янв';}
if($m == '02'){$t = 'Фев';}
if($m == '03'){$t = 'Марта';}
if($m == '04'){$t = 'Апр';}
if($m == '05'){$t = 'Мая';}
if($m == '06'){$t = 'Июня';}
if($m == '07'){$t = 'Июля';}
if($m == '08'){$t = 'Авг';}
if($m == '09'){$t = 'Сен';}
if($m == '10'){$t = 'Окт';}
if($m == '11'){$t = 'Ноя';}
if($m == '12'){$t = 'Дек';}
$time = date("H:i");
$data = ''.$dat.' '.$t.' в '.$time.'';
return $data;
}
function gen_code($number){
session_start();
$arr = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','r','s','t','u','v','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','R','S','T','U','V','X','Y','Z','1','2','3','4','5','6','7','8','9','0');
// Генерируем пароль
$pass = "";
for($i = 0; $i < $number; $i++){
// Вычисляем случайный индекс массива
$index = rand(0, count($arr) - 1);
$pass .= $arr[$index];
}
$_SESSION['gener'] = $pass;
}
function addmail($mail, $subject, $messages, $sendermail="", $sendername="") {
if (empty($sendermail)) {
$setting = DB::run() -> queryFetch("SELECT * FROM `setting` WHERE `id`=? LIMIT 1",array(1));
$sendermail = $setting['admin_mail'];
$sendername = $setting['admin_pod'];
}
/*
$subject = utf_to_win($subject);
$messages = utf_to_win($messages);
$sendername = utf_to_win($sendername);
$subject = convert_cyr_string($subject, 'w', 'k');
$messages = convert_cyr_string($messages, 'w', 'k');
$sendername = convert_cyr_string($sendername, 'w', 'k');
$subject = '=?KOI8-R?B?'.base64_encode($subject).'?=';
*/
$subject = '=?UTF-8?B?'.base64_encode($subject).'?=';
$adds = "From: =?UTF-8?B?".base64_encode($sendername)."?= <".$sendermail.">n";
$adds .= "X-sender: =?UTF-8?B?".base64_encode($sendername)."?= <".$sendermail.">n";
$adds .= "Content-Type: text/plain; charset=utf-8n";
$adds .= "MIME-Version: 1.0n";
$adds .= "Content-Transfer-Encoding: 8bitn";
$adds .= "X-Mailer: PHP v.".phpversion()."n";
$adds .= "Date: ".date("r")."n";
return mail($mail, $subject, $messages, $adds);
}
function utf_strlen($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));
}
// ------------------ Функция перекодировки из UTF в WIN --------------------//
function utf_to_win($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);
}
// ------------------ Функция перекодировки из WIN в UTF --------------------//
function win_to_utf($str) {
if (function_exists('mb_convert_encoding')) return mb_convert_encoding($str, 'utf-8', 'windows-1251');
if (function_exists('iconv')) return iconv('windows-1251', 'utf-8', $str);
$win1251utf8 = 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, $win1251utf8);
}
function send_mail($my_login,$send_login,$msg) {
DB::run() -> query("INSERT INTO `send_mail` SET `my_login`=?,`send_login`=?,`msg`=?,`data`=?,`status`=?",array($my_login,$send_login,$msg,times(),0));
DB::run() -> query("UPDATE `users` SET `my_mail`=`my_mail` + 1 WHERE `login`=?",array($send_login));
}
function text($msg) {
if (is_array($msg)) {
foreach($msg as $key => $val) {
$msg[$key] = check($val);
}
} else {
$msg = htmlspecialchars($msg);
$search = array('|', ''', '$', '\', '^', '%', '`', " ", "x00", "x1A", chr(226) . chr(128) . chr(174));
$replace = array('|', ''', '$', '\', '^', '%', '`', '', '', '', '');
$msg = str_replace($search, $replace, $msg);
$msg = stripslashes(trim($msg));
}
return $msg;
}
function formattime($file_time){
if($file_time >= 86400){
$file_time = round((($file_time / 60) / 60) / 24).' д.';
}elseif(
$file_time >= 3600){
$file_time = round(($file_time / 60) / 60, 1).' ч.';
}elseif(
$file_time >= 60){
$file_time = round($file_time / 60).' мин.';
}else{
$file_time = ''.round($file_time).' сек.';}
return $file_time;
}
//функции пользователей
function hero($login){
$hero = DB::run() -> queryFetch("SELECT * FROM `users` ORDER BY `hero` LIMIT 1");
if($hero['login'] == $login && $hero['hero'] > 1){$img = '<img src="/images/hero.png">';} else {$img = NULL; }
return $img;
}
function galaxy($login){
$info = DB::run() -> queryFetch("SELECT * FROM `users` WHERE `login`=? LIMIT 1",array($login));
$g = $info['activ'];
$img = '/images/galaxy/';
$u[1] = '<img src="'.$img.'1.gif">';
$u[2] = '<img src="'.$img.'2.gif">';
$u[3] = '<img src="'.$img.'3.gif">';
$u[4] = '<img src="'.$img.'4.gif">';
$u[5] = '<img src="'.$img.'5.gif">';
$u[6] = '<img src="'.$img.'6.gif">';
$u[7] = '<img src="'.$img.'7.png">';
if($g >= 250){$i = $u[1];}
if($g >= 500){$i = $u[2];}
if($g >= 1000){$i = $u[3];}
if($g >= 2000){$i = $u[4];}
if($g >= 4000){$i = $u[5];}
if($g >= 6000){$i = $u[6];}
if($g >= 8000){$i = $u[7];}
if($g >= 10000){$i = ''.$u[7].''.$u[7].'';}
if($g >= 15000){$i = ''.$u[7].''.$u[7].''.$u[7].'';}
return $i;
}
//////////////\\\\\\\\
function online($login){
$twoz = DB::run() -> query("SELECT * FROM `session_user` WHERE user=?",array($login));
if($twoz -> rowCount() > 0){$a = ' '.hero($login).' '.galaxy($login).' <font color=green><strong>[on]</strong></font>';} else {$a = ' <font color=red><strong>[off]</strong></font>';}
return $a;
}
function status($login){
$my_info = DB::run() -> queryFetch("SELECT * FROM `users` WHERE `login`=? LIMIT 1",array($login));
if($my_info['status'] == 101){$st = 'Создатель сайта';}
if($my_info['status'] == 102){$st = 'Администратор';}
if($my_info['status'] == 103){$st = 'Старший модератор';}
if($my_info['status'] == 104){$st = 'Модератор';}
if($my_info['status'] == 105){$st = 'Пользователь';}
return $st;
}
function ava($login){
$my_info = DB::run() -> queryFetch("SELECT * FROM `users` WHERE `login`=? LIMIT 1",array($login));
if(empty($my_info['ava'])){$ava = '<img src="/images/empty_0.png">';}else {
$file = MAINDIR.'/obmen/ava/'.$my_info['ava'].'';
if($my_info['x_ava'] == NULL || $my_info['x_ava'] == 0){$x = 150; } else { $x = $my_info['x_ava']; }
if($my_info['y_ava'] == NULL || $my_info['y_ava'] == 0){$y = 100; } else { $y = $my_info['y_ava']; }
$ava = '<img src="/obmen/ava/'.$my_info['ava'].'" height="'.$y.'" width="'.$x.'">';}
return $ava;
}
function rating($login){
$my_info = DB::run() -> queryFetch("SELECT * FROM `users` WHERE `login`=? LIMIT 1",array($login));
$plus = $my_info['plus'];
$minus = $my_info['minus'];
$all = $plus - $minus;
if($all == 0){echo'<strong>0</strong>';}
if($all > 0){echo'<font color="green"><strong>+'.$all.'</strong></font>';}
if($all < 0){echo'<font color="red"><strong>-'.$all.'</strong></font>';}
}
function present($login){
echo'Подарки<br />';
$twoz = DB::run() -> query("SELECT * FROM `present_user` WHERE `send_login`=?",array($login));
if($twoz -> rowCount() > 0){
$pr = DB::run()->query("SELECT * FROM present_user WHERE send_login=? LIMIT 5",array($login));
$pr = $pr -> fetchAll();
foreach($pr AS $u){
echo' <img src="/images/present/'.$u['img'].'" width="40" height="40"> ';
}
echo'<br /><a href="/users/present.php?mode=my_present&login='.$login.'">Все подарки</a>';
} else {echo'нет подарков';}
}
function money($value)
{
$x = $value % 10;
if (($x == 1) && ($value != 11)) $s = 'рубль';
elseif ((($x > 1) && ($x < 5)) && (floor($value / 10) != 1)) $s = 'рубля'; else $s = 'рублей';
return $s;
}
//----------- Транслит -------------//
function translite($text) {
return str_replace(
array('YO','Yo','ZH','Zh','CH','Ch','SHC','SHc','Shc','SH',
'Sh','YE','Ye','YU','Yu','YA','Ya','ch','sh','shc','ye','yu',
'ya','yo ','zh','A','B','V','G','D','E','Z','I','Y','K','L',
'M','N','O','P','R' ,'S','T','U','F','H','C','X','a','b','v',
'g','d','e','z','i','y','k',' l','m','n','o','p','r','s','t',
'u','f','h','c','x','""','"',"''","'"),
array('Ё','Ё','Ж','Ж','Ч','Ч','Щ','Щ','Щ','Ш','Ш','Э','Э','Ю',
'Ю','Я', 'Я','ч','ш','щ','э','ю','я','ё','ж','A','Б','В','Г',
'Д','E','З','И','Й ','К','Л','М','Н','О','П','Р','С','Т','У',
'Ф','Х','Ц','Ы','а','б','в', 'г','д','е','з','и','й','к','л',
'м','н','о','п','р','с','т','у','ф','х ','ц','ы','Ъ','ъ','Ь',
'ь'),$text);
}
function antimat($str) {
$querymat = DB::run() -> query("SELECT `mat_string` FROM `antimat` ORDER BY LENGTH(`mat_string`) DESC;");
$arrmat = $querymat -> fetchAll(PDO::FETCH_COLUMN);
if (count($arrmat) > 0) {
foreach($arrmat as $val) {
$str = preg_replace('|'.preg_quote($val).'|iu', '***', $str);
}
}
return $str;
}
# ----------------------------------- Функция смайлов ----------------------------------- #
function smiles($str) {
$querysmiles = DB::run() -> query("SELECT `smiles_name`, `smiles_code` FROM `smiles` WHERE `smiles_cats`=? ORDER BY LENGTH(`smiles_code`) DESC;", array(1));
$arrsmiles = $querysmiles -> fetchAll();
$count = 0;
foreach($arrsmiles as $val) {
$str = str_replace($val['smiles_code'], '<img src="/images/smiles/'.$val['smiles_name'].'" alt="smile" /> ', $str);
}
if (is_admin()) {
$querysmiles = DB::run() -> query("SELECT `smiles_name`, `smiles_code` FROM `smiles` WHERE `smiles_cats`=? ORDER BY LENGTH(`smiles_code`) DESC;", array(2));
$arrsmiles = $querysmiles -> fetchAll();
foreach($arrsmiles as $val) {
$str = str_replace($val['smiles_code'], '<img src="/images/smiles2/'.$val['smiles_name'].'" alt="smile" /> ', $str);
}
}
return $str;
}
# ----------------------------------- Функция без пробелов ----------------------------------- #
function no_br($msg) {
$msg = nl2br($msg);
$msg = preg_replace('|[rn]+|si', '', $msg);
return $msg;
}
function bb($msg) {
$msg = str_replace('[nextpage]', '<br>', $msg);
$msg = preg_replace('#[code](.*?)[/code]#ie', 'highlight_code("1")', $msg);
$msg = preg_replace('#[hide](.*?)[/hide]#ie', 'hidden_text("1")', $msg);
// $msg = preg_replace_callback('~[url=((https?|ftp)://.+?)](.+?)[/url]|((https?|ftp)://[0-9a-zа-яё/.;?=()_-&%#]+)~ui', 'url_replace', $msg);
$msg = preg_replace('#[big](.*?)[/big]#si', '<big>1</big>', $msg);
$msg = preg_replace('#[b](.*?)[/b]#si', '<b>1</b>', $msg);
$msg = preg_replace('#[i](.*?)[/i]#si', '<i>1</i>', $msg);
$msg = preg_replace('#[u](.*?)[/u]#si', '<u>1</u>', $msg);
$msg = preg_replace('#[small](.*?)[/small]#si', '<small>1</small>', $msg);
$msg = preg_replace('#[red](.*?)[/red]#si', '<span style="color:#ff0000">1</span>', $msg);
$msg = preg_replace('#[green](.*?)[/green]#si', '<span style="color:#00cc00">1</span>', $msg);
$msg = preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:#0000ff">1</span>', $msg);
$msg = preg_replace('#[q](.*?)[/q]#si', '<div class="q">1</div>', $msg);
$msg = preg_replace('#[del](.*?)[/del]#si', '<del>1</del>', $msg);
$msg = preg_replace('#[url=(.*?)](.*?)[/url]#si', '<a href="1">2</a>', $msg);
return $msg;
}
# Прибавление опыта/актива/денег
function user_live($login,$exp,$activ,$money) {
$rez = DB::run() -> queryFetch("select * from `users` where `login`=? LIMIT 1",array($login));
$level = $rez['level'];
if($level == 0){ $rating = $exp; }
if($level == 1){ $rating = $exp / 5; }
if($level == 2){ $rating = $exp / 10; }
if($level == 3){ $rating = $exp / 15; }
if($level == 4){ $rating = $exp / 20; }
if($level == 5){ $rating = $exp / 25; }
if($level == 6){ $rating = $exp / 30; }
if($level == 7){ $rating = $exp / 35; }
if($level == 8){ $rating = $exp / 40; }
if($level == 9){ $rating = $exp / 50; }
if($level == 10){ $rating = $exp / 60; }
if($level > 10 && $level < 50 ){ $rating = $exp / 65; }
if($level > 50 && $level < 100 ){ $rating = $exp / 75; }
if($level > 100 && $level < 150 ){ $rating = $exp / 85; }
if($level > 150 && $level < 200 ){ $rating = $exp / 90; }
if($level > 200){ $rating = $exp / 100; }
if($rez['exp'] > 99){DB::run() -> query("UPDATE `users` SET `level`=`level` + ? WHERE `login`=?",array(1,$login));}
DB::run() -> query("UPDATE `users` SET `exp`=`exp` + ?, `money`=`money`+ ?,`activ`=`activ` + ?,`hero`=`hero` + ? WHERE `login`=?",array($rating,$money,$activ,$activ,$login));
}
# ----------------------------------- Функция убирания смайлов ----------------------------------- #
function nosmiles($string) {
$string = preg_replace('|<img src="/images/smiles/(.*?).gif" alt="(.*?)" /> |', ':$1', $string);
$string = preg_replace('|<img src="/images/smiles/(.*?).gif" alt="(.*?)" />|', ':$1', $string);
$string = preg_replace('|<img src="/images/smiles2/(.*?).gif" alt="(.*?)" /> |', ':$1', $string);
$string = preg_replace('<strong>', '[b]', $string);
$string = preg_replace('</strong>', '[/b]', $string);
return $string;
}
# ----------------------------------- Функция вывода тем на главную ----------------------------------- #
function forum_index($num){
if($num > 0){
$for = DB::run()->query("select * from `forum_themes` ORDER BY `time` DESC LIMIT $num");
$for = $for -> fetchAll();
foreach($for AS $g){
if($g['krep'] == 1){ $img = '<img src="/images/forum/lock.gif" alt="">';} else {if($g['status'] == 'on'){$img = '<img src="/images/forum/topics.gif" alt=""> ';} else {$img = '<img src="/images/forum/closed.gif" alt="">';} }
echo''.$img.' <a href="/forum/?mode=topic&themes='.$g['forum'].'&id='.$g['id'].'&end=end">'.$g['themes'].'</a> ('.count_all('forum_topic','topic',$g['id']).')<br />';
}
}
}
# ----------------------------------- Функция определения иконки ----------------------------------- #
function file_icon($type){
if($type == 'jar' || $type == 'jad' || $type == 'sis' || $type == 'sisx' || $type == 'apk' || $type == 'exe' || $type == 'mp3' || $type == 'wma' || $type == 'flac' || $type == 'aac' || $type == 'mmf' || $type == 'amr' || $type == 'm4a' || $type == 'm4r' || $type == 'ogg' || $type == 'mp2' || $type == 'wav' || $type == 'mpeg' || $type == 'mp4' || $type == 'avi' || $type == '3gp' || $type == 'rmvb' || $type == 'wmv' || $type == 'mkv' || $type == 'mpg' || $type == 'mov' || $type == 'vob' || $type == 'flv' || $type == 'jpg' || $type == 'jpeg' || $type == 'gif' || $type == 'png' || $type == 'txt' || $type == 'pdf' || $type == 'docs' || $type == 'doc' || $type == 'rar' || $type == 'zip' || $type == '7z'){
if($type == 'jar' || $type == 'jad'){ $img = '<img src="/images/catalog/java.png">'; }
if($type == 'sis' || $type == 'sisx'){ $img = '<img src="/images/catalog/simbian1.png">'; }
if($type == 'apk'){ $img = '<img src="/images/catalog/android.png">'; }
if($type == 'exe'){ $img = '<img src="/images/catalog/windows.png">'; }
if($type == 'mp3' || $type == 'wma' || $type == 'flac' || $type == 'aac' || $type == 'mmf' || $type == 'amr' || $type == 'm4a' || $type == 'm4r' || $type == 'ogg' || $type == 'mp2' || $type == 'wav' || $type == 'mpeg'){$img = '<img src="/images/catalog/muzyka.png">'; }
if($type == 'mp4' || $type == 'avi' || $type == '3gp' || $type == 'rmvb' || $type == 'wmv' || $type == 'mkv' || $type == 'mpg' || $type == 'mov' || $type == 'vob' || $type == 'flv' ){$img = '<img src="/images/catalog/video.png">'; }
if($type == 'jpg' || $type == 'jpeg' || $type == 'gif' || $type == 'png') { $img = '<img src="/images/catalog/kartinki.png">'; }
if($type == 'txt' || $type == 'pdf' || $type == 'docs' || $type == 'doc'){ $img = '<img src="/images/catalog/dokumenty.png">'; }
if($type == 'rar' || $type == 'zip' || $type == '7z'){ $img = '<img src="/images/catalog/arhivy.png">'; }
} else {$img = '<img src="/images/catalog/prilozeenija.png">'; }
return $img;
}
function regist($str){
$strold=array("Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M"); # что заменять
$strnew=array("q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m"); # на что заменять
$str=str_replace($strold, $strnew, $str);
return $str;
}
function strana($msg){
function regist_rus($str){
$strold=array("Й", "Ц", "У", "К", "Е", "Н", "Г", "Ш", "Щ", "З", "Х", "Ф", "Ы", "В", "А", "П", "Р", "О", "Л", "Д", "Ж", "Э", "Я", "Ч", "С", "М", "И", "Т", "Ь", "Б", "Ю", "Ъ"); # что заменять
$strnew=array("й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "э", "я", "ч", "с", "м", "и", "т", "ь", "б", "ю", "ъ"); # на что заменять
$str=str_replace($strold, $strnew, $str);
return $str;
}
$msg = check($msg);
$msg = regist_rus($msg);
if($msg == 'арулько'){$it = '<img src="/images/strana/1.gif">';}
if($msg == 'юар'){$it = '<img src="/images/strana/2.gif">';}
if($msg == 'ирак'){$it = '<img src="/images/strana/3.gif">';}
if($msg == 'монголия'){$it = '<img src="/images/strana/4.gif">';}
if($msg == 'доминиканская республика'){$it = '<img src="/images/strana/5.gif">';}
if($msg == 'гондурас'){$it = '<img src="/images/strana/6.gif">';}
if($msg == 'ливан'){$it = '<img src="/images/strana/7.gif">';}
if($msg == 'ямайка'){$it = '<img src="/images/strana/8.gif">';}
if($msg == 'остров мэн'){$it = '<img src="/images/strana/9.gif">';}
if($msg == 'тунис'){$it = '<img src="/images/strana/10.gif">';}
if($msg == 'мозамбик'){$it = '<img src="/images/strana/11.gif">';}
if($msg == 'куба'){$it = '<img src="/images/strana/12.gif">';}
if($msg == 'сирия'){$it = '<img src="/images/strana/13.gif">';}
if($msg == 'морокко'){$it = '<img src="/images/strana/14.gif">';}
if($msg == 'эквадор'){$it = '<img src="/images/strana/15.gif">';}
if($msg == 'ливан'){$it = '<img src="/images/strana/16.gif">';}
if($msg == 'о.а.э.'){$it = '<img src="/images/strana/17.gif">';}
if($msg == 'тайланд'){$it = '<img src="/images/strana/18.gif">';}
if($msg == 'перу'){$it = '<img src="/images/strana/19.gif">';}
if($msg == 'пакистан'){$it = '<img src="/images/strana/20.gif">';}
if($msg == 'мальта'){$it = '<img src="/images/strana/21.gif">';}
if($msg == 'македония'){$it = '<img src="/images/strana/22.gif">';}
if($msg == 'корея'){$it = '<img src="/images/strana/23.gif">';}
if($msg == 'чили'){$it = '<img src="/images/strana/24.gif">';}
if($msg == 'карибы'){$it = '<img src="/images/strana/25.gif">';}
if($msg == 'туркмения'){$it = '<img src="/images/strana/26.gif">';}
if($msg == 'тайвань'){$it = '<img src="/images/strana/27.gif">';}
if($msg == 'сингапур'){$it = '<img src="/images/strana/28.gif">';}
if($msg == 'малайзия'){$it = '<img src="/images/strana/29.gif">';}
if($msg == 'иордания'){$it = '<img src="/images/strana/30.gif">';}
if($msg == 'индонезия'){$it = '<img src="/images/strana/31.gif">';}
if($msg == 'гонконг'){$it = '<img src="/images/strana/32.gif">';}
if($msg == 'румыния'){$it = '<img src="/images/strana/33.gif">';}
if($msg == 'хорватия'){$it = '<img src="/images/strana/34.gif">';}
if($msg == 'нидерланды'){$it = '<img src="/images/strana/35.gif">';}
if($msg == 'япония'){$it = '<img src="/images/strana/36.gif">';}
if($msg == 'южная корея'){$it = '<img src="/images/strana/37.gif">';}
if($msg == 'югославия'){$it = '<img src="/images/strana/38.gif">';}
if($msg == 'эстония'){$it = '<img src="/images/strana/39.gif">';}
if($msg == 'швеция'){$it = '<img src="/images/strana/40.gif">';}
if($msg == 'швейцария'){$it = '<img src="/images/strana/41.gif">';}
if($msg == 'чехия'){$it = '<img src="/images/strana/42.gif">';}
if($msg == 'франция'){$it = '<img src="/images/strana/43.gif">';}
if($msg == 'финляндия'){$it = '<img src="/images/strana/44.gif">';}
if($msg == 'узбекистан'){$it = '<img src="/images/strana/46.gif">';}
if($msg == 'уганда'){$it = '<img src="/images/strana/47.gif">';}
if($msg == 'украина'){$it = '<img src="/images/strana/uk.gif">';}
if($msg == 'турция'){$it = '<img src="/images/strana/48.gif">';}
if($msg == 'туркс и кейкос'){$it = '<img src="/images/strana/49.gif">';}
if($msg == 'туркменистан'){$it = '<img src="/images/strana/50.gif">';}
# --------------------------------------------------------------------- #
if($msg == 'таджикистан'){$it = '<img src="/images/strana/51.gif">';}
if($msg == 'сша'){$it = '<img src="/images/strana/52.gif">';}
if($msg == 'суринам'){$it = '<img src="/images/strana/53.gif">';}
if($msg == 'словения'){$it = '<img src="/images/strana/54.gif">';}
if($msg == 'словакия'){$it = '<img src="/images/strana/55.gif">';}
if($msg == 'сальвадор'){$it = '<img src="/images/strana/56.gif">';}
if($msg == 'россия'){$it = '<img src="/images/strana/rus.gif">';}
if($msg == 'реюньон'){$it = '<img src="/images/strana/58.gif">';}
if($msg == 'португалия'){$it = '<img src="/images/strana/59.gif">';}
if($msg == 'польша'){$it = '<img src="/images/strana/60.gif">';}
if($msg == 'норвегия'){$it = '<img src="/images/strana/61.gif">';}
if($msg == 'новая зеландия'){$it = '<img src="/images/strana/62.gif">';}
if($msg == 'нонако'){$it = '<img src="/images/strana/63.gif">';}
if($msg == 'нолдова'){$it = '<img src="/images/strana/64.gif">';}
if($msg == 'нексика'){$it = '<img src="/images/strana/65.gif">';}
if($msg == 'люксембург'){$it = '<img src="/images/strana/66.gif">';}
if($msg == 'литва'){$it = '<img src="/images/strana/67.gif">';}
if($msg == 'ливия'){$it = '<img src="/images/strana/68.gif">';}
if($msg == 'латвия'){$it = '<img src="/images/strana/69.gif">';}
if($msg == 'кувейт'){$it = '<img src="/images/strana/70.gif">';}
if($msg == 'коста-рика'){$it = '<img src="/images/strana/71.gif">';}
if($msg == 'китай'){$it = '<img src="/images/strana/72.gif">';}
if($msg == 'киргызстан'){$it = '<img src="/images/strana/73.gif">';}
if($msg == 'кипр'){$it = '<img src="/images/strana/74.gif">';}
if($msg == 'канада'){$it = '<img src="/images/strana/75.gif">';}
if($msg == 'камерун'){$it = '<img src="/images/strana/76.gif">';}
if($msg == 'казахстан'){$it = '<img src="/images/strana/77.gif">';}
if($msg == 'италия'){$it = '<img src="/images/strana/78.gif">';}
if($msg == 'испания'){$it = '<img src="/images/strana/79.gif">';}
if($msg == 'ирландия'){$it = '<img src="/images/strana/80.gif">';}
if($msg == 'иран'){$it = '<img src="/images/strana/81.gif">';}
if($msg == 'индия'){$it = '<img src="/images/strana/82.gif">';}
if($msg == 'израиль'){$it = '<img src="/images/strana/83.gif">';}
if($msg == 'египет'){$it = '<img src="/images/strana/84.gif">';}
if($msg == 'дания'){$it = '<img src="/images/strana/85.gif">';}
if($msg == 'грузия'){$it = '<img src="/images/strana/86.gif">';}
if($msg == 'греция'){$it = '<img src="/images/strana/87.gif">';}
if($msg == 'голландия'){$it = '<img src="/images/strana/88.gif">';}
if($msg == 'германия'){$it = '<img src="/images/strana/89.gif">';}
if($msg == 'гваделупа'){$it = '<img src="/images/strana/90.gif">';}
if($msg == 'гаити'){$it = '<img src="/images/strana/91.gif">';}
if($msg == 'вьетнам'){$it = '<img src="/images/strana/92.gif">';}
if($msg == 'венгрия'){$it = '<img src="/images/strana/93.gif">';}
if($msg == 'великобритания'){$it = '<img src="/images/strana/94.gif">';}
if($msg == 'вразилия'){$it = '<img src="/images/strana/95.gif">';}
if($msg == 'болгария'){$it = '<img src="/images/strana/96.gif">';}
if($msg == 'бермуды'){$it = '<img src="/images/strana/97.gif">';}
if($msg == 'бельгия'){$it = '<img src="/images/strana/98.gif">';}
if($msg == 'белиз'){$it = '<img src="/images/strana/99.gif">';}
if($msg == 'беларусь'){$it = '<img src="/images/strana/100.gif">';}
if($msg == 'армения'){$it = '<img src="/images/strana/101.gif">';}
if($msg == 'аргентина'){$it = '<img src="/images/strana/102.gif">';}
if($msg == 'ангуилья'){$it = '<img src="/images/strana/103.gif">';}
if($msg == 'азербайджан'){$it = '<img src="/images/strana/104.gif">';}
if($msg == 'австрия'){$it = '<img src="/images/strana/105.gif">';}
if($msg == 'австралия'){$it = '<img src="/images/strana/106.gif">';}
if($msg == NULL){$it = '<img src="/images/info.png">';}
return $it;
}
function znak($data){
$d = explode(" ",$data);
# 1 #
if($d[1] == 'Марта' && $d[0] >= 21 && $d[0] <= 31){$zn = 'Овен';}
if($d[1] == 'Апреля' && $d[0] >= 01 && $d[0] <= 20){$zn = 'Овен';}
# 2 #
if($d[1] == 'Апреля' && $d[0] >= 21 && $d[0] <= 30){$zn = 'Телец';}
if($d[1] == 'Мая' && $d[0] >= 01 && $d[0] <= 20){$zn = 'Телец';}
# 3 #
if($d[1] == 'Мая' && $d[0] >= 21 && $d[0] <= 31){$zn = 'Близнецы';}
if($d[1] == 'Июня' && $d[0] >= 01 && $d[0] <= 21){$zn = 'Близнецы';}
# 4 #
if($d[1] == 'Июня' && $d[0] >= 22 && $d[0] <= 30){$zn = 'Рак';}
if($d[1] == 'Июля' && $d[0] >= 01 && $d[0] <= 22){$zn = 'Рак';}
# 5 #
if($d[1] == 'Июля' && $d[0] >= 27 && $d[0] <= 31){$zn = 'Лев';}
if($d[1] == 'Июля' && $d[0] >= 01 && $d[0] <= 22){$zn = 'Лев';}
# 6 #
if($d[1] == 'Июня' && $d[0] >= 22 && $d[0] <= 30){$zn = 'Дева';}
if($d[1] == 'Августа' && $d[0] >= 01 && $d[0] <= 23){$zn = 'Дева';}
# 7 #
if($d[1] == 'Сентября' && $d[0] >= 24 && $d[0] <= 30){$zn = 'Весы';}
if($d[1] == 'Октября' && $d[0] >= 01 && $d[0] <= 23){$zn = 'Весы';}
# 8 #
if($d[1] == 'Октября' && $d[0] >= 24 && $d[0] <= 31){$zn = 'Скорпион';}
if($d[1] == 'Ноября' && $d[0] >= 01 && $d[0] <= 22){$zn = 'Скорпион';}
# 9 #
if($d[1] == 'Ноября' && $d[0] >= 23 && $d[0] <= 30){$zn = 'Стрелец';}
if($d[1] == 'Декабря' && $d[0] >= 01 && $d[0] <= 21){$zn = 'Стрелец';}
# 10 #
if($d[1] == 'Декабря' && $d[0] >= 22 && $d[0] <= 31){$zn = 'Козерог';}
if($d[1] == 'Января' && $d[0] >= 01 && $d[0] <= 20){$zn = 'Козерог';}
# 11 #
if($d[1] == 'Января' && $d[0] >= 21 && $d[0] <= 31){$zn = 'Водолей';}
if($d[1] == 'Февраля' && $d[0] >= 01 && $d[0] <= 20){$zn = 'Водолей';}
# 12 #
if($d[1] == 'Февраля' && $d[0] >= 21 && $d[0] <= 29){$zn = 'Рыбы';}
if($d[1] == 'Марта' && $d[0] >= 01 && $d[0] <= 20){$zn = 'Рыбы';}
return $zn;
}
/** Функция перевода размера **/
function formatsize($file_size) {
if ($file_size >= 1048576000) {
$file_size = round(($file_size / 1073741824), 2)." Gb";
} elseif ($file_size >= 1024000) {
$file_size = round(($file_size / 1048576), 2)." Mb";
} elseif ($file_size >= 1000) {
$file_size = round(($file_size / 1024), 2)." Kb";
} else {
$file_size = round($file_size)." byte";
}
return $file_size;
}
/** Функция чтения папки и вывод веса в байтах **/
function read_dir($dir) {
if (empty($allsize)) {
$allsize = 0;
}
if ($path = opendir($dir)) {
while ($file_name = readdir($path)) {
if (($file_name !== '.') && ($file_name !== '..')) {
if (is_dir($dir."/".$file_name)) {
$allsize += read_dir($dir."/".$file_name);
} else {
$allsize += filesize($dir."/".$file_name);
}
}
}
closedir ($path);
}
return $allsize;
}
function stlol() {
$q = "DELETE FROM session_chat WHERE putdate < NOW() - INTERVAL '5' MINUTE";
mysql_query($q);
$qe = "DELETE FROM session_vic WHERE putdate < NOW() - INTERVAL '5' MINUTE";
mysql_query($qe);
##############################
$qwt=mysql_result(mysql_query("SELECT COUNT(*) FROM `session_vic`"),0);
$qwz=mysql_result(mysql_query("SELECT COUNT(*) FROM `vic_vopros`"),0);
if($qwt == 0 && $qwz >=1){mysql_query('TRUNCATE `vic_vopros`');}
}
?>