<?php
include_once("connect.php");
include_once("config.php");
function ban($username, $ua, $ip)
{
global $modername, $banmess, $ban_info ,$time;
$query = mysql_query("SELECT * FROM `ban`
WHERE `user`='".$ua."'
OR `ip`='".$ip."'
OR `username`='".$username."'
AND `time` > UNIX_TIMESTAMP()");
if(mysql_num_rows($query))
{
$rows = mysql_fetch_array($query);
$modername = $rows['moder'];
$banmess = $rows['mess'];
$ban_info = $rows['status'];
$time = $rows['time'];
return( true );
}
else
{
return ( false );
}
}
function translate($mess)
{
$array = array(
"Jo" => "Ё",
"jo" => "ё",
"Yo" => "Ё",
"yo" => "ё",
"Zh" => "Ж",
"zh" => "ж",
"*" => "ж",
"Ch" => "Ч",
"ch" => "ч",
"Sh" => "Ш",
"sh" => "ш",
"Shc" => "Щ",
"shc" => "щ",
"''" => 'ъ',
"'" => "ь",
"Ye" => "Э",
"ye" => "э",
"Yu" => "Ю",
"yu" => "ю",
"Ya" => "Я",
"ya" => "я",
"X" => "Ы",
"x" => "ы",
"A" => "А",
"a" => "а",
"B" => "Б",
"b" => "б",
"C" => "Ц",
"c" => "ц",
"D" => "Д",
"d" => "д",
"E" => "Е",
"e" => "е",
"F" => "Ф",
"f" => "ф",
"G" => "Г",
"g" => "г",
"H" => "Х",
"h" => "х",
"I" => "И",
"i" => "и",
"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" => "ш",
"Y" => "Й",
"y" => "й",
"Z" => "З",
"z" => "з"
);
return (strtr($mess, $array));
}
function smile($matches)
{
static $c;
$arr = array('<1>',
'<2>',
'<3>',
'<4>',
'<5>',
'<6>',
'<7>',
'<8>',
'<9>',
'<10>',
'<11>',
'<12>',
'<13>',
'<14>',
'<15>',
'<16>',
'<17>',
'<18>',
'<19>',
'<20>',
'<21>',
'<22>',
'<23>',
'<24>',
'<25>',
'<26>',
'<27>',
'<28>',
'<29>',
'<30>',
'<31>',
'<32>',
'<33>',
'<34>',
'<35>',
'<36>',
'<37>',
'<38>');
if($c == 1) return $matches[0];
if(!in_array($matches[0], $arr)) return $matches[0];
$c++;
$smiles = array(
'<img src="smiles/1.gif" alt=":-)"/>',
'<img src="smiles/2.gif" alt=":-("/>',
'<img src="smiles/3.gif" alt=":-["/>',
'<img src="smiles/4.gif" alt="8-)"/>',
'<img src="smiles/5.gif" alt=":-E)"/>',
'<img src="smiles/6.gif" alt=":-P"/>',
'<img src="smiles/7.gif" alt="{beer}"/>',
'<img src="smiles/8.gif" alt="{tee}"/>',
'<img src="smiles/9.gif" alt="{smoke}"/>',
'<img src="smiles/10.gif" alt="{vine}"/>',
'<img src="smiles/11.gif" alt="{kiss}"/>',
'<img src="smiles/12.gif" alt="{inlove}"/>',
'<img src="smiles/13.gif" alt="{heard}"/>',
'<img src="smiles/14.gif" alt="{ok}"/>',
'<img src="smiles/15.gif" alt="{no}"/>',
'<img src="smiles/16.gif" alt="{cool}"/>',
'<img src="smiles/17.gif" alt="{flower}"/>',
'<img src="smiles/18.gif" alt="{cherry}"/>',
'<img src="smiles/19.gif" alt="{ball}"/>',
'<img src="smiles/20.gif" alt="{surprise}"/>',
'<img src="smiles/21.gif" alt="{cake}"/>',
'<img src="smiles/22.gif" alt="{phone}"/>',
'<img src="smiles/23.gif" alt="{mobile}"/>',
'<img src="smiles/24.gif" alt="{wall}"/>',
'<img src="smiles/25.gif" alt="{camel}"/>',
'<img src="smiles/26.gif" alt="{cat}"/>',
'<img src="smiles/27.gif" alt="{pig}"/>',
'<img src="smiles/28.gif" alt="{hammer}"/>',
'<img src="smiles/29.gif" alt="{gun}"/>',
'<img src="smiles/30.gif" alt="{skull}"/>',
'<img src="smiles/31.gif" alt="{rip}"/>',
'<img src="smiles/32.gif" alt="{sun}"/>',
'<img src="smiles/33.gif" alt="{moon}"/>',
'<img src="smiles/34.gif" alt="{lock}"/>',
'<img src="smiles/35.gif" alt="{dollar}"/>',
'<img src="smiles/36.gif" alt="{fig}"/>',
'<img src="smiles/37.gif" alt="{drug}"/>',
'<img src="smiles/38.gif" alt="{fuck}"/>');
return str_replace($arr, $smiles, $matches[0]);
}
//____________________Удаления бана если срок окончен___________________##
function unban($username)//Удаления бана если срок окончен
{
if(time() > ".UNIX_TIMESTAMP().")
{
mysql_query("DELETE FROM ban WHERE `username`='".$username."' AND time < UNIX_TIMESTAMP()");
}}
##____________________Удаления бана если срок окончен___________________//
function username2id($username)
{
$id = mysql_fetch_array(mysql_query("SELECT id FROM users WHERE username='".$username."'"));
return( $id['id'] );
}
function ClearOnline()
{
mysql_query("DELETE FROM session WHERE time < ".(time() - (24 * 60 * 60)));
}
function RefreshLastTime($username, $fid, $lastMsgTime)
{
mysql_query("UPDATE `counter` SET `time`=".($lastMsgTime)." WHERE `fid`=".$fid." AND `username`='".$username."'");
}
function RefreshSid($username)
{
mysql_query("UPDATE `session` SET `time`=".time()." WHERE `nickname`='".$username."'");
mysql_query("UPDATE `users` SET `last_time`=".time()." WHERE `username`='".$username."'");
}
function topic2post($id_topic)
{
return(mysql_result(mysql_query("SELECT MIN(`id`) FROM `posts` WHERE `id_theme`=".$id_topic), 0));
}
function topic2postm($id_topic)
{
return(mysql_result(mysql_query("SELECT MIN(`id`) FROM `mposts` WHERE `id_theme`=".$id_topic), 0));
}
function is_author($id, $user)
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `themes` WHERE `id`=".$id." AND `name`='".$user."'"), 0))
{
return(true);
}
else
{
return(false);
}
}
function sql($str)
{
if(get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
return(str_replace('$', '$', mysql_escape_string($str)));
}
function cutString($string, $len)
{
if (strlen($string) <= $len)
{
return $string;
}
return substr($string, 0, $len) . "....";
}
function translatenick($username)
{
$array = array(
"Е" => "E",
"е" => "e",
"А" => "A",
"а" => "a",
"В" => "B",
"С" => "C",
"с" => "c",
"Н" => "H",
"Х" => "X",
"К" => "K",
"М" => "M",
"О" => "O",
"о" => "o",
"Р" => "P",
"р" => "p",
"Т" => "T",
"у" => "y"
);
return (strtr($username, $array));
}
$ua=$_SERVER['HTTP_USER_AGENT'];
$ip=$_SERVER['REMOTE_ADDR'];
$uniq=serialize(array($ip,$ua))."\n";
$store='./count/count.dat';
$offset=3600;
$date_now=date('d',time()+$offset);
$date_access=date('d',filemtime($store)+$offset);
if ($date_now!=$date_access && file_exists($store))
{
unlink($store);
}
if (!file_exists($store))
{
$hit=1;
$host=1;
}
else
{
$data=file($store);
$data[]=$uniq;
$hit=count($data);
$ip_ua=array();
$ip_ua[]=$uniq;
foreach ($data as $v)
{
if (!in_array($v,$ip_ua))
$ip_ua[]=$v;
}
$host=count($ip_ua);
}
$f=fopen($store,'a+');
flock($f,2);
fwrite($f,$uniq);
fclose($f);
$_GET['p']=intval($_GET['p']);
?>