<?php
include 'connect.php';
define('H', 'http://'.$_SERVER['HTTP_HOST'].'/');
function smile($text){
$arr=array(':)', '=)', ':-)', ')))', '))');
$arr2=array(':D', ':Д', ':-D', ':-d', ':-Д');
$arr3=array(':yahoo', ':яхуу');
$arr4=array(':rip', ':гроб');
$arr5=array(':plaksa', ':плакса');
$arr6=array(':haha', ':хаха');
$arr7=array(':kur', ':кур');
$arr9=array(':lol2', ':лол2');
$arr8=array(':lol', ':лол');
$arr10=array(':glaza', ':глаза');
$arr11=array(':fu', ':фу');
$arr12=array(':druzhba', ':дружба');
$arr13=array(':mail', ':почта');
$arr14=array(':poka', ':пока');
$arr15=array(':(', '=(', '((');
$arr16=array(':super', ':супер');
$arr17=array(':umora', ':умора');
$arr18=array(':vantuz', ':вантуз');
$arr19=array(':хм', ':неверю', ':hm', ':\\');
$arr20=array(':vopros', ':вопрос');
$arr21=array(':dovolen', ':доволен');
$arr22=array(':dash', ':стена');
$arr23=array(':афигеть', ':afiget');
$arr24=array(':аларм', ':alarm');
$arr25=array(':podmig', ':подмиг');
$arr26=array(';)', ';-)');
$arr27=array('*facepalm*', ':фп');
$arr28=array('О_о', 'О-О');
$qwe=str_ireplace($arr, '<img src=\'smile/smile.gif\'>', $text);
$qwe=str_ireplace($arr2, '<img src=\'smile/xd.gif\'>', $qwe);
$qwe=str_ireplace($arr3, '<img src=\'smile/yahoo.gif\'>', $qwe);
$qwe=str_ireplace($arr4, '<img src=\'smile/rip.gif\'>', $qwe);
$qwe=str_ireplace($arr5, '<img src=\'smile/plaksa.gif\'>', $qwe);
$qwe=str_ireplace($arr6, '<img src=\'smile/haha.gif\'>', $qwe);
$qwe=str_ireplace($arr7, '<img src=\'smile/kur.gif\'>', $qwe);
$qwe=str_ireplace($arr9, '<img src=\'smile/lol2.gif\'>', $qwe);
$qwe=str_ireplace($arr8, '<img src=\'smile/lol.gif\'>', $qwe);
$qwe=str_ireplace($arr10, '<img src=\'smile/glaza.gif\'>', $qwe);
$qwe=str_ireplace($arr11, '<img src=\'smile/fu.gif\'>', $qwe);
$qwe=str_ireplace($arr12, '<img src=\'smile/druzhba.gif\'>', $qwe);
$qwe=str_ireplace($arr13, '<img src=\'smile/mail.gif\'>', $qwe);
$qwe=str_ireplace($arr14, '<img src=\'smile/poka.gif\'>', $qwe);
$qwe=str_ireplace($arr15, '<img src=\'smile/sad.gif\'>', $qwe);
$qwe=str_ireplace($arr16, '<img src=\'smile/super.gif\'>', $qwe);
$qwe=str_ireplace($arr17, '<img src=\'smile/umora.gif\'>', $qwe);
$qwe=str_ireplace($arr18, '<img src=\'smile/vantuz.gif\'>', $qwe);
$qwe=str_ireplace($arr19, '<img src=\'smile/xm.gif\'>', $qwe);
$qwe=str_ireplace($arr20, '<img src=\'smile/vopros.gif\'>', $qwe);
$qwe=str_ireplace($arr21, '<img src=\'smile/dovolen.gif\'>', $qwe);
$qwe=str_ireplace($arr22, '<img src=\'smile/dash.gif\'>', $qwe);
$qwe=str_ireplace($arr23, '<img src=\'smile/afiget.gif\'>', $qwe);
$qwe=str_ireplace($arr24, '<img src=\'smile/alarm.gif\'>', $qwe);
$qwe=str_ireplace($arr25, '<img src=\'smile/wink.gif\'>', $qwe);
$qwe=str_ireplace($arr26, '<img src=\'smile/wink.gif\'>', $qwe);
$qwe=str_ireplace($arr27, '<img src=\'smile/facepalm.gif\'>', $qwe);
$qwe=str_ireplace($arr28, '<img src=\'smile/blink.gif\'>', $qwe);
return $qwe;
}
function pages($q, $w, $e){
if ($q==2)echo '<div class=\'input\'><a href=\''.$e.'=1\'>1</a> <a href=\''.$e.'=2\'>2</a></div>';
if ($q==3)echo '<div class="input"><a href="'.$e.'=1">1</a> <a href="'.$e.'=2">2</a> <a href="'.$e.'=3">3</a></div>';
if (($q>3) && ($w!=1) && ($w!=$q))echo '<div class="input"><a href="'.$e.'=1">[1]</a> <a href="'.$e.'='.($w-1).'">['.($w-1).']</a> .. <a href="'.$e.'='.($w+1).'">['.($w+1).']</a> <a href="'.$e.'='.$q.'">['.$q.']</a><br><form method="GET" action="'.$e.'"><input type="text" size="2" name="p" value="'.$w.'"> <input type="submit" value="Ок"></form></div>';
elseif (($q>3) && ($w!=1) && ($w==$q))echo '<div class="input"><a href="'.$e.'=1">[1]</a> <a href="'.$e.'='.($w-1).'">['.($w-1).']</a><br><form method="GET" action="'.$e.'"><input type="text" size="2" name="p" value="'.$w.'"> <input type="submit" value="Ок"></form></div>';
elseif (($q>3) && ($w==1) && ($w!=$q))echo '<div class="input"><a href="'.$e.'='.($w+1).'">['.($w+1).']</a> <a href='.$e.'='.$q.'>['.$q.']</a><br><form method="GET" action="'.$e.'"><input type="text" size="2" name="p" value="'.$w.'"> <input type="submit" value="Ок"></form></div>';
}
function div($in){
echo '<div class=\''.$in.'\'>';
return true;
}
function nodiv(){
echo '</div>';
return true;
}
function msg($txt){
echo '<div class=\'msg\'>'.$txt.'</div>';
return true;
}
//за изменение данного кода последует жлоба хостеру, затем блокировка сайта
function copyright(){
echo '<b>Powered by <a href=\'http://QCMS.in\'>QCMS</a></b>';
return true;
//за изменение данного кода последует жлоба хостеру, затем блокировка сайта
}
function vremja($time=NULL)
{
$time1=date('j M Y в H:i', $time);
if (date('j')==date('j', $time))$time1=date('в H:i:s', $time);
if (date('j')==(date('j', $time)+1))$time1=date('вчера в H:i', $time);
$time1=str_replace('Jan','Янв',$time1);
$time1=str_replace('Feb','Фев',$time1);
$time1=str_replace('Mar','Марта',$time1);
$time1=str_replace('May','Мая',$time1);
$time1=str_replace('Apr','Апр',$time1);
$time1=str_replace('Jun','Июня',$time1);
$time1=str_replace('Jul','Июля',$time1);
$time1=str_replace('Aug','Авг',$time1);
$time1=str_replace('Sep','Сент',$time1);
$time1=str_replace('Oct','Окт',$time1);
$time1=str_replace('Nov','Ноября',$time1);
$time1=str_replace('Dec','Дек',$time1);
return $time1;
}
if (isset($_COOKIE['name']) && isset($_COOKIE['pass'])){
$name=mysql_escape_string($_COOKIE['name']);
$pass=mysql_escape_string($_COOKIE['pass']);
$ma=mysql_fetch_array(mysql_query("SELECT `pass` FROM `user` WHERE `name` = '$name'"));
if ($ma['pass']==$pass){
$user=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `name` = '$name'"));
}
}
function on($in){
$i=intval($in);
$ank=mysql_fetch_assoc(mysql_query("SELECT `famous` FROM `user` WHERE `id` = '$i'"));
if (($ank['famous']>3) && ($ank['famous']<6))$ret='<img src="/icon/m1.png">';
if (($ank['famous']>6) && ($ank['famous']<12))$ret='<img src="/icon/m2.png">';
if ($ank['famous']>12)$ret='<img src="/icon/m3.png">';
//if ($ank['moder']==1)$ret.=" <font color='blue'><b>[+]</b></font>";
return $ret;
}
function gus($in){
if ($in==0){
$ank2['name']='Информатор';
$ank2['click']=time();
$ank2['famous']=100500;
$ank2['pol']=0;
return $ank2;
}
else
return mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$in'"));
}
function rekl($in){
global $web;
if ($web==1)$bbb='<b>';
$ret='</div><div class="rekl">'.$bbb;
$q=mysql_query("SELECT `img`, `href`, `name` FROM `rekl` WHERE `where` = '$in' AND `time` > '".time()."'");
$b=1;
if ($web>0)$brr=' - ';
else
$brr='<br>';
while ($f=mysql_fetch_assoc($q)){
if ((mysql_num_rows($q)!=1) && ($b>1))$ret.=$brr;
if ($f['img'])$ret.='<a href="'.htmlspecialchars($f['href']).'"><img src="'.htmlspecialchars($f['img']).'" alt="'.htmlspecialchars($f['name']).'"></a>';
else $ret.='<a href="'.htmlspecialchars($f['href']).'">'.htmlspecialchars($f['name']).'</a>';
$b++;
}
$ret.='</b></div>';
if (mysql_num_rows($q)==0)$ret='';
return $ret;
}
function im($in)
{
global $set,$time;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$in' AND `click` > '".(time()-600)."' LIMIT 1"),0)==1)
{$ank=mysql_fetch_array(mysql_query("SELECT `pol`, `moder`, `admin` FROM `user` WHERE `id` = '$in' LIMIT 1"));
if ($ank['pol']==1)
{ $onchel='<img src="/icon/man_on.png" width="14">';}else{$onchel='<img src="/icon/girl_on.png" width="14">';}
if (($ank['moder']==1) && ($ank['pol']==1))$onchel='<img src="/icon/moder_on.png" width="14">';
if (($ank['moder']==1) && ($ank['pol']==0))$onchel='<img src="/icon/girl_moder_on.png" width="14">';
if (($ank['admin']==1) && ($ank['pol']==1))$onchel='<img src="/icon/admin_on.png" width="14">';
if (($ank['admin']==1) && ($ank['pol']==0))$onchel='<img src="/icon/girl_admin_on.png" width="14">';
} else {$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$in' LIMIT 1"));
if ($ank['pol']==1)
{$onchel='<img src="/icon/man_off.png" width="14">';}else{
$onchel='<img src="/icon/girl_off.png" width="14">';}
if (($ank['moder']==1) && ($ank['pol']==1))$onchel='<img src="/icon/moder_off.png" width="14">';
if (($ank['moder']==1) && ($ank['pol']==0))$onchel='<img src="/icon/girl_moder_off.png" width="14">';
if (($ank['admin']==1) && ($ank['pol']==1))$onchel='<img src="/icon/admin_on.png" width="14">';
if (($ank['admin']==1) && ($ank['pol']==0))$onchel='<img src="/icon/girl_admin_on.png" width="14">';
}
return $onchel;
}
function bbcode($in){
$in=preg_replace("/\[url=http(.+)\](.+)\[\/url\]/isU", "<a href='http$1'>$2</a>", $in);
$in=preg_replace("/\[b\](.+)\[\/b\]/isU", "<b>$1</b>", $in);
$in=preg_replace("/\[u\](.+)\[\/u\]/isU", "<u>$1</u>", $in);
$in=preg_replace("/\[s\](.+)\[\/s\]/isU", "<s>$1</s>", $in);
$in=preg_replace("/\[color=(.+)\](.+)\[\/color\]/isU", "<font color='$1'>$2</font>", $in);
return $in;
}
function spfunc($in){
$loll=str_replace('\\', '', $in);
return $loll;
}
function out($in){
return spfunc(nl2br(smile(bbcode(htmlspecialchars($in)))));
}
if (!$user){
$ip=htmlspecialchars($_SERVER['REMOTE_ADDR']);
$browser=htmlspecialchars($_SERVER['HTTP_USER_AGENT']);
$q=mysql_query("SELECT `click` FROM `guests` WHERE `ip` = '$ip' AND `tel` = '$browser'");
if (mysql_num_rows($q)==0){
mysql_query("INSERT INTO `guests` (`ip`, `tel`, `click`, `time`) values ('$ip', '$browser', '1', '".time()."')");
}
else
{
$now=mysql_fetch_array($q);
$click=($now['click']+1);
mysql_query("UPDATE `guests` SET `click` = '$click' WHERE `ip` = '$ip' AND `tel` = '$browser'");
mysql_query("UPDATE `guests` SET `time` = '".time()."' WHERE `ip` = '$ip' AND `tel` = '$browser'");
}
}
mysql_query("DELETE FROM `guests` WHERE `time` < '".(time()-86400)."'");
if ((mysql_num_rows(mysql_query("SELECT `id` FROM `ban` WHERE `user` = '$user[id]' AND `time` > '".time()."'"))>0) && ($_SERVER['PHP_SELF']!='/ban.php') && ($user['moder']<1) && ($user['admin']<1)){
header('Location: /ban.php');
die('АКТИВНЫЙ БАН!');
}
//$ip=htmlspecialchars($_SERVER['REMOTE_ADDR']);
//$qqqqq=mysql_query("SELECT * FROM `visits` WHERE `ip` = '$ip' ORDER BY `time` DESC LIMIT 1");
//$frer=mysql_fetch_assoc($qqqqq);
//$pred=$frer['time'];
//if ((time()-$pred)<2)die('Не так часто. Подождите секунду и обновите страницу. Амплитуда: '.(time()-$pred));
//mysql_query("INSERT INTO `visits` (`ip`, `time`) values ('$ip', '".time()."')");
//mysql_query("DELETE FROM `visits` WHERE `time` < '".(time()-50)."'");
?>