Файл: inc/func.php
Строк: 502
<?php
$browser = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if (strpos($browser, 'Mobile') === false
&& strpos($browser, 'Symbian') === false
&& strpos($browser, 'Opera M') === false
&& strpos($browser, 'Android') === false
&& stripos($browser, 'HTC_') === false
&& strpos($browser, 'Fennec/') === false
&& stripos($browser, 'Blackberry') === false
&& strpos($browser, 'Windows Phone') === false
&& strpos($browser, 'WP7') === false
&& strpos($browser, 'WP8') === false) {
mysql_query("UPDATE `account` SET `wap_web` = 'web' WHERE `id` = '$account[id]' LIMIT 1");}else{mysql_query("UPDATE `account` SET `wap_web` = 'wap' WHERE `id` = '$account[id]' LIMIT 1");}
function time_left($tl)
{
$d=3600*24;
$day=floor($tl/$d);
$tl=$tl-($d*$day);
$hour=floor($tl/3600);
$tl=$tl-(3600*$hour);
$minute=floor($tl/60);
$tl=$tl-(60*$minute);
$second=floor($tl);
$dayt="".($day>0?"24 час. ":null)."";
$hourt="".($hour>0?"$hour час. ":null)."";
$minutet="".($minute>0?"$minute мин. ":null)."";
$secondt="".($second>0?"$second сек. ":null)."";
if($day>0)
{
$minutet=NULL;
$secondt=NULL;
}
if($hour>0 && $day==0)
{
$secondt=NULL;
$dayt=NULL;
}
return "$dayt$hourt$minutet$secondt";
}
function gtime($timediff=NULL)
{
$oneMinute=60;
$oneHour=60*60;
$oneDay=60*60*24;
$dayfield=floor($timediff/$oneDay);
$hourfield=floor(($timediff-$dayfield*$oneDay)/$oneHour);
$minutefield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour)/$oneMinute);
$secondfield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour-$minutefield*$oneMinute));
$sDaysLeft=$dayfield;
$sDaysText = "дн.";
$nDaysLeftLength =strlen($sDaysLeft);
$d_1=substr($sDaysLeft,-1,1);
if (substr($sDaysLeft,-2,1) != 1 && $nDaysLeftLength>1)
{
if ($d_1 == 2 || $d_1== 3 || $d_1== 4)
{
$sDaysText = "дн.";
}
elseif ($d_1== 1)
{
$sDaysText = "дн.";
}
}
if ($nDaysLeftLength==1)
{
if ($d_1==2 || $d_1== 3 || $d_1== 4)
{
$sDaysText = "дн.";
}
elseif ($d_1== 1)
{
$sDaysText = "дн.";
}
}
$sHoursLeft=$hourfield;
$sHoursText = "час.";
$nHoursLeftLength = strlen($sHoursLeft);
$h_1=substr($sHoursLeft,-1,1);
if (substr($sHoursLeft,-2,1) != 1 && $nHoursLeftLength>1)
{
if ($h_1== 2 || $h_1== 3 || $h_1== 4)
{
$sHoursText = "час.";
}
elseif ($h_1== 1)
{
$sHoursText = "час.";
}
}
if ($nHoursLeftLength==1)
{
if ($h_1== 2 || $h_1== 3 || $h_1== 4)
{
$sHoursText = "часа";
}
elseif ($h_1== 1)
{
$sHoursText = "час.";
}
}
$sMinsLeft =$minutefield;
$sMinsText = "мин.";
$nMinsLeftLength = strlen($sMinsLeft);
$m_1=substr($sMinsLeft,-1,1);
if ($nMinsLeftLength>1 && substr($sMinsLeft,-2,1) != 1)
{
if ($m_1== 2 || $m_1== 3 || $m_1== 4)
{
$sMinsText = "мин.";
}
else if ($m_1== 1)
{
$sMinsText = "мин.";
}
}
if ($nMinsLeftLength==1)
{
if ($m_1== 2 || $m_1==3 || $m_1== 4)
{
$sMinsText = "мин.";
}
elseif ($m_1== "1")
{
$sMinsText = "мин.";
}
}
$sSecsLeft = $secondfield;
$sSecsText = "сек.";
$s_1=substr($sSecsLeft,-1,1);
$nSecsLeftLength = strlen($sSecsLeft);
if (substr($sSecsLeft,-2,1)!= 1 && $nSecsLeftLength>1)
{
if ($s_1== 2 || $s_1== 3 || $s_1== 4)
{
$sSecsText = "сек.";
}
elseif ($s_1== 1)
{
$sSecsText = "сек.";
}
}
if ($nSecsLeftLength==1)
{
if ($s_1== 2 || $s_1== 3 || $s_1== 4)
{
$sSecsText = "сек.";
}
elseif ($sSecsLeft== "1")
{
$sSecsText = "сек.";
}
}
if ($sDaysLeft!=0)$sDaysLeft = $sDaysLeft.' '.$sDaysText.' ';
else $sDaysLeft = NULL ; $sDaysText=NULL;
if ($sHoursLeft!=0)$sHoursLeft = $sHoursLeft.' '.$sHoursText.' ';
else $sHoursLeft = NULL ; $sHoursText=NULL;
if ($sMinsLeft!=0)$sMinsLeft = $sMinsLeft.' '.$sMinsText.' ';
else $sMinsLeft = NULL ; $sMinsText=NULL;
if ($sSecsLeft!=0)$sSecsLeft = $sSecsLeft.' '.$sSecsText.' ';
else $sSecsLeft = NULL ; $sSecsText=NULL;
$displaystring="
".
$sDaysLeft." ".
$sDaysText." ".
$sHoursLeft." ".
$sHoursText." ".
$sMinsLeft." ".
$sMinsText." ".
$sSecsLeft." ".
$sSecsText;
echo $displaystring;
}
function tags($var = '') {
// Обработка ссылок и тэгов BBCODE в тексте//
$var = preg_replace('#[b](.*?)[/b]#si', '<span style="font-weight: bold;">1</span>', $var);
$var = preg_replace('#[i](.*?)[/i]#si', '<span style="font-style:italic;">1</span>', $var);
$var = preg_replace('#[u](.*?)[/u]#si', '<span style="text-decoration:underline;">1</span>', $var);
$var = preg_replace('#[del](.*?)[/del]#si', '<span style="text-decoration: line-through;">1</span>', $var);
$var = preg_replace('#[red](.*?)[/red]#si', '<span style="color:LightCoral">1</span>', $var);
$var = preg_replace('#[green](.*?)[/green]#si', '<span style="color:LimeGreen">1</span>', $var);
$var = preg_replace('#[yellow](.*?)[/yellow]#si', '<span style="color:gold">1</span>', $var);
$var = preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:#1E90FF">1</span>', $var);
return $var;
}
function bbpanel($form, $field) {
return '<script language="JavaScript" type="text/javascript">
function tag(text1, text2) {
if ((document.selection)) {
document.' . $form . '.' . $field . '.focus();
document.' . $form . '.document.selection.createRange().text = text1+document.' . $form . '.document.selection.createRange().text+text2;
} else if(document.forms['' . $form . ''].elements['' . $field . ''].selectionStart!=undefined) {
var element = document.forms['' . $form . ''].elements['' . $field . ''];
var str = element.value;
var start = element.selectionStart;
var length = element.selectionEnd - element.selectionStart;
element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
} else
document.' . $form . '.' . $field . '.value += text1+text2;
}
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<a href="javascript:tag(':bye', '')"><img src="http://'.$_SERVER[SERVER_NAME].'/pic/smiles/bye.gif" alt=":bye" title=":bye" /></a>
<a href="javascript:tag(':)', '')"><img src="http://'.$_SERVER[SERVER_NAME].'/pic/smiles/).gif" alt=":)" title=":)" /></a>
<a href="javascript:tag(':D', '')"><img src="http://'.$_SERVER[SERVER_NAME].'/pic/smiles/D.gif" alt=":D" title=":D" /></a>
<a href="javascript:tag(':nono', '')"><img src="http://'.$_SERVER[SERVER_NAME].'/pic/smiles/nono.gif" alt=":nono" title=":nono" /></a>
<a href="javascript:tag(':cool', '')"><img src="http://'.$_SERVER[SERVER_NAME].'/pic/smiles/cool.gif" alt=":cool" title=":cool" /></a>
<a href="javascript:tag(':fig', '')"><img src="http://'.$_SERVER[SERVER_NAME].'/pic/smiles/fig.gif" alt=":fig" title=":fig" /></a><br>
';
}
function hsc($text)
{
return htmlspecialchars($text);
}
function bb($text){
return nl2br($text);
}
$time=time();
$req = mysql_query("SELECT * FROM `effekt` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='4' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `effekt_4`= '0',`mpall`=`mpall` - '$mag[mp]' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `effekt` WHERE `account`='$account[id]' and `tip`='4' ");
}
$req = mysql_query("SELECT * FROM `effekt` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='3' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `effekt_3`= '0',`hpall`=`hpall` - '$mag[hp]' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `effekt` WHERE `account`='$account[id]' and `tip`='3' ");
}
$req = mysql_query("SELECT * FROM `effekt` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='2' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `effekt_2`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `effekt` WHERE `account`='$account[id]' and `tip`='2' ");
}
$req = mysql_query("SELECT * FROM `effekt` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='1' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `effekt_1`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `effekt` WHERE `account`='$account[id]' and `tip`='1' ");
}
$req = mysql_query("SELECT * FROM `effekt` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='5' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `effekt_5`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `effekt` WHERE `account`='$account[id]' and `tip`='5' ");
}
$req = mysql_query("SELECT * FROM `effekt` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='6' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `effekt_6`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `effekt` WHERE `account`='$account[id]' and `tip`='6' ");
}
$req = mysql_query("SELECT * FROM `effekt` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='7' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `effekt_7`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `effekt` WHERE `account`='$account[id]' and `tip`='7' ");
}
$req = mysql_query("SELECT * FROM `effekt` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='8' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `effekt_8`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `effekt` WHERE `account`='$account[id]' and `tip`='8' ");
}
$req = mysql_query("SELECT * FROM `zadanuya` WHERE `time`<'$time' and `zadanie`= '1' and `account`='$account[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$ban = mysql_fetch_array($req);
mysql_query("UPDATE `zadanuya` SET `zadanie`= '0',`time`= '0',`zadanue1`='0',`zadanue2`='0',`zadanue3`='0',`zadanue4`='0',`zadanue5`='0',`zadanue6`='0',`zadanue7`='0' WHERE `account`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `bonus_ryba` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='1' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `ruba1_1`= '0',`ataka`= `ataka`- '$mag[ataka]',`zahita`= `zahita`- '$mag[zahita]',`hpall`= `hpall`- '$mag[hp]',`mpall`= `mpall`- '$mag[mp]',`buyn`= `buyn`- '$mag[derz]',`bayn`= `bayn`- '$mag[buyn]',`gira`= `gira`- '$mag[zuha]' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `bonus_ryba` WHERE `account`='$account[id]' and `tip`='1' ");
}
$req = mysql_query("SELECT * FROM `bonus_ryba` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='2' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `ruba2_2`= '0',`ataka`= `ataka`- '$mag[ataka]',`zahita`= `zahita`- '$mag[zahita]',`hpall`= `hpall`- '$mag[hp]',`mpall`= `mpall`- '$mag[mp]',`buyn`= `buyn`- '$mag[derz]',`bayn`= `bayn`- '$mag[buyn]',`gira`= `gira`- '$mag[zuha]' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `bonus_ryba` WHERE `account`='$account[id]' and `tip`='2' ");
}
$req = mysql_query("SELECT * FROM `bonus_ryba` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='3' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `ruba3_3`= '0',`ataka`= `ataka`- '$mag[ataka]',`zahita`= `zahita`- '$mag[zahita]',`hpall`= `hpall`- '$mag[hp]',`mpall`= `mpall`- '$mag[mp]',`buyn`= `buyn`- '$mag[derz]',`bayn`= `bayn`- '$mag[buyn]',`gira`= `gira`- '$mag[zuha]' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `bonus_ryba` WHERE `account`='$account[id]' and `tip`='3' ");
}
$req = mysql_query("SELECT * FROM `vip` WHERE `time`<'$time' and `account`='$account[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
mysql_query("UPDATE `account` SET `vip`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `vip` WHERE `account`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `bonus_ryba` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='4' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `ruba4_4`= '0',`ataka`= `ataka`- '$mag[ataka]',`zahita`= `zahita`- '$mag[zahita]',`hpall`= `hpall`- '$mag[hp]',`mpall`= `mpall`- '$mag[mp]',`buyn`= `buyn`- '$mag[derz]',`bayn`= `bayn`- '$mag[buyn]',`gira`= `gira`- '$mag[zuha]' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `bonus_ryba` WHERE `account`='$account[id]' and `tip`='4' ");
}
$req = mysql_query("SELECT * FROM `bonus_ryba` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='5' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `ruba5_5`= '0',`ataka`= `ataka`- '$mag[ataka]',`zahita`= `zahita`- '$mag[zahita]',`hpall`= `hpall`- '$mag[hp]',`mpall`= `mpall`- '$mag[mp]',`buyn`= `buyn`- '$mag[derz]',`bayn`= `bayn`- '$mag[buyn]',`gira`= `gira`- '$mag[zuha]' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `bonus_ryba` WHERE `account`='$account[id]' and `tip`='5' ");
}
$req = mysql_query("SELECT * FROM `bonus_ryba` WHERE `time`<'$time' and `account`='$account[id]' and `tip`='6' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mag = mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `ruba6_6`= '0',`ataka`= `ataka`- '$mag[ataka]',`zahita`= `zahita`- '$mag[zahita]',`hpall`= `hpall`- '$mag[hp]',`mpall`= `mpall`- '$mag[mp]',`buyn`= `buyn`- '$mag[derz]',`bayn`= `bayn`- '$mag[buyn]',`gira`= `gira`- '$mag[zuha]' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `bonus_ryba` WHERE `account`='$account[id]' and `tip`='6' ");
}
$req = mysql_query("SELECT * FROM `arena_boy` WHERE `time`<'$time' and `account`='$account[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
mysql_query("UPDATE `account` SET `arena`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `arena_boy` WHERE `account`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `block` WHERE `nick` = '1' and `usr` = '$account[id]' LIMIT 1");
$avto = mysql_num_rows($req);
if ($avto==1) {
$ban = mysql_fetch_array($req);
if($ban[ban_time]<$time){
mysql_query("DELETE FROM `block` WHERE `nick` = '1' and `usr` = '$account[id]'");
}}
$req = mysql_query("SELECT * FROM `block` WHERE `usr`='$account[id]' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($req);
if ($avto == 1) {
$ban = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `account` WHERE `id` = '$ban[nick]'");
$pic = mysql_fetch_array($req);
if($ban[ban_time]<$time){
mysql_query("DELETE FROM `block` WHERE`usr`='$account[id]'");
}else{
echo'<div style="text-align:left;padding:6px;color:#a5a5a5" class="menu_link3">';
echo"<img src='pic/index/!.png' alt='*'/> Ваш персонаж забанен!";
echo"<br><img src='pic/main/persona.png' alt='*'/> Модератором: $pic[login]<br>";
echo"<img src='pic/main/chat3.png' alt='*'/> Причина: <i>$ban[text].</i><br>";
$ban[ban_time]=$ban[ban_time]-time();
if($ban[ban_time]<60){
echo "<img src='pic/main/timereg.png' alt='*'/> Осталось: $ban[ban_time] сек.</div>";
include ("inc/nogi.php");
exit;
}elseif($ban[ban_time]>60 and $ban[ban_time]<3600){
$ban[ban_time]=round($ban[ban_time]/60);
echo "<img src='pic/main/timereg.png' alt='*'/> Осталось: $ban[ban_time] мин.</div>";
include ("inc/nogi.php");
exit;
}else{
$ban[ban_time]=round($ban[ban_time]/3600);
echo "<img src='pic/main/timereg.png' alt='*'/> Осталось: $ban[ban_time] час.</div>";
include ("inc/nogi.php");
exit;
}
}
}
function smiles($string){
$dir = opendir ("pic/smiles");
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="pic/smiles/'.$file.'" alt="">',$string);
}}
closedir ($dir);
return $string; }
function sec2day($sec=NULL)
{
$days = floor($sec/86400);
$hours = floor(($sec/3600)-$days*24);
$minuts = floor(($sec-$hours*3600-$days*86400)/60);
$seconds = $sec-($minuts*60+$hours*3600+$days*86400);
if ($days!=0)$days = $days.' дн. ';
else $days = NULL;
if ($hours!=0)$hours = $hours.' час. ';
else $hours = NULL;
if ($minuts!=0)$minuts = $minuts.' мин. ';
else $minuts = NULL;
$sectoday = $days.''.$hours.''.$minuts.''.$seconds.' сек.';
return $sectoday;
}
?>