Файл: inc/func.php
Строк: 401
<?php
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:green">1</span>', $var);
$var = preg_replace('#[yellow](.*?)[/yellow]#si', '<span style="color:yellow">1</span>', $var);
$var = preg_replace('#[admin](.*?)[/admin]#si', '<span style="color:#7afe4e">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(':cool2', '')"><img src="http://'.$_SERVER[SERVER_NAME].'/pic/smiles/cool2.gif" alt=":cool2" title=":cool2" /></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($msg){
$msg = preg_replace_callback('~[url=((https?|ftp)://.+?)](.+?)[/url]|((https?|ftp)://[0-9a-zР°-СЏС‘/.;?=()_-&%#]+)~ui', 'url_replace', $msg);
return nl2br($msg);
}
$time=time();
$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' WHERE `account`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `banda_shtraf` WHERE `time`<'$time' and `account`='$account[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$text = "Время штрафа за самостоятельный выход из банды вышло, вы можете вступить в любую банду.";
mysql_query("INSERT INTO `mail` SET `user` = '2', `to` = '$account[id]', `time` = '$time', `read` = '0', `msg` = '$text'");
mysql_query("DELETE FROM `banda_shtraf` WHERE `account`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `arena_travma` 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_travma` WHERE `account`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `zahita_arena` WHERE `time`<'$time' and `account`='$account[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
mysql_query("UPDATE `account` SET `arena_zahita`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `zahita_arena` WHERE `account`='$account[id]'");
}
$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 `boy`= '0' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `arena_boy` WHERE `account`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `vip` WHERE `time`<'$time' and `accaunt`='$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 `accaunt`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `premium` WHERE `account`='$account[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
$mags= mysql_fetch_array($req);
mysql_query("UPDATE `account` SET `ataka`= `ataka`- '$mags[ataka]',`zahita`= `zahita`- '$mags[zahita]' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `premium` WHERE `account`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `podval_time` WHERE `vip_time`<'$time' and `id`='$account[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
mysql_query("UPDATE `podval` SET `podval`= '0',`podval_vip`= '0',`podval_mpall`= '3' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `podval_time` WHERE `id`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `trudaga_time` WHERE `vip_time`<'$time' and `id`='$account[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
mysql_query("UPDATE `account` SET `rabota`= '0',`rabota_vip`= '0',`rabota_mpall`= '6' WHERE `id`='$account[id]'");
mysql_query("DELETE FROM `trudaga_time` WHERE `id`='$account[id]'");
}
$req = mysql_query("SELECT * FROM `block` WHERE `tip` = '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 `tip` = '1' and `usr` = '$account[id]'");
}}
$req = mysql_query("SELECT * FROM `block` WHERE `tip` = '2' and `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 `tip` = '2' and `usr`='$account[id]'");
}else{
echo"<img src='pic/main/!.png' alt='*'/> Ваш персонаж <font color=IndianRed1>заблокирован!</font>";
echo"<br><img src='pic/main/ms.png' alt='*'/> Модератором: $pic[login]<br>";
echo"<img src='pic/main/malava.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='*'/> Время блокировки: <img src='pic/main/timeniz.png' alt='*'/><font color=IndianRed1>$ban[ban_time] сек.</font>";
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='*'/> Время блокировки: <img src='pic/main/timeniz.png' alt='*'/><font color=IndianRed1>$ban[ban_time] мин.</font>";
include ("inc/nogi.php");
exit;
}else{
$ban[ban_time]=round($ban[ban_time]/3600);
echo "<img src='pic/main/timereg.png' alt='*'/> Время блокировки: <img src='pic/main/timeniz.png' alt='*'/><font color=IndianRed1>$ban[ban_time] час.</font>";
include ("inc/nogi.php");
exit;
}
}
}
function bbcode($text){
$search[] = "/[color=(.+)](.+)[/color]/isU";
$search[] = "/[size=([1-6]{1})](.+)[/size]/isU";
$search[] = "/[i](.+)[/i]/isU";
$search[] = "/[u](.+)[/u]/isU";
$search[] = "/[b](.+)[/b]/isU";
$replace[] = '<font color="1">2</font>';
$replace[] = '<font size="1">2</font>';
$replace[] = '<i>1</i>';
$replace[] = '<u>1</u>';
$replace[] = '<b>1</b>';
$text = preg_replace($search, $replace, $text);
return $text;
}
function nastavnik($string){
$dir = opendir ("pic/nastavnik");
while ($file = readdir ($dir)) {
if (ereg (".png$", "$file")){
$file2=str_replace(".png","",$file);
$string=str_replace(":$file2",'<img src="pic/nastavnik/'.$file.'" alt="">',$string);
}}
closedir ($dir);
return $string; }
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;
}
?>