Файл: inc/system/functions.php
Строк: 554
<?
function time_left_fish($tl)
{
$d=3600*24;
$day=round($tl/$d);
$tl=$tl-($d*$day);
$hour=round($tl/3600);
$tl=$tl-(3600*$hour);
$minute=floor($tl/60);
$tl=$tl-(60*$minute);
$second=floor($tl);
$dayt="".($day>0?"<span class='timer_day'>$day д</span> ":null)."";
$hourt="".($hour>0?"<span class='timer_hour'>$hour ч</span> ":null)."";
$minutet="".($minute>0?"<span class='timer_minute'>$minute м</span> ":null)."";
$secondt="".($second>0?"<span class='timer_second'>$second с</span> ":null)."";
if($day>0)
{
$hourt=NULL;
$minutet=NULL;
$secondt=NULL;
}
elseif($hour>0 && $day==0)
{
$dayt=NULL;
$minutet=NULL;
$secondt=NULL;
}
elseif($minute>0 && $hourt==0)
{
$dayt=NULL;
$hourt=NULL;
$secondt=NULL;
}
return "$dayt$hourt$minutet$secondt";
}
error_reporting(E_ALL);
$mcu =mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"));
$gos=(isset($gos));
$mc=(isset($mc));
$ct=(isset($ct));
$time=time();
function on_k($id)
{
$usk=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$id'"));
$us=$usk;
$t=time()-3600;
if($usk['date_last']<=$t)
{
if($us['pol']==0)
{
$img="user_female_50.png";
}
else
{
$img="user_male_50.png";
}
}
else
{
if($us['pol']==0)
{
$img="user_female_50.png";
}
else
{
$img="user_male_50.png";
}
}
if(!empty($usk['icon'])){
if($usk['pol']==1){$pref='male';}elseif($usk['pol']==0){$pref='female';}
$img='user/'.$usk['icon'].'_'.$pref.'.png';
}else{$folder='icons';}
echo "<img width='18' height='18' src='/img/icons/$img'/>";
if($usk['date_last']<=$t){echo "";
}else{
echo "<img src='/img/icons/on.gif'/>";
}
}
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?"<span class='timer_day'>$day д.</span> ":null)."";
$hourt="".($hour>0?"<span class='timer_hour'>$hour ч.</span> ":null)."";
$minutet="".($minute>0?"<span class='timer_minute'>$minute м.</span> ":null)."";
$secondt="".($second>0?"<span class='timer_second'>$second с.</span> ":null)."";
if($day>0)
{
$minutet=NULL;
$secondt=NULL;
}
if($hour>0 && $day==0)
{
$secondt=NULL;
$dayt=NULL;
}
return "$dayt$hourt$minutet$secondt";
}
function rating($rating)
{
$t=floor($rating/1000000000000);
$g=floor($rating/1000000000);
$m=floor($rating/1000000);
$k=floor($rating/1000);
if($t!=0)
{
$t=$rating/1000000000000;
$rating=round($t,1);
$rating="$rating t";
}
elseif($g!=0)
{
$g=$rating/1000000000;
$rating=round($g,1);
$rating="$rating g";
}
elseif($m!=0)
{
$m=$rating/1000000;
$rating=round($m,1);
$rating="$rating m";
}
elseif($k!=0)
{
$k=$rating/1000;
$rating=round($k,1);
$rating="$rating k";
}
else $rating=(int)$rating;
return "$rating";
}
function pk($pk)
{
$llr=$pk+1;
if($llr==2)$pk=500;
elseif($llr==3)$pk=500;
elseif($llr==4)$pk=500;
elseif($llr==5)$pk=500;
elseif($llr==6)$pk=500;
elseif($llr==7)$pk=500;
elseif($llr==8)$pk=500;
elseif($llr==9)$pk=500;
elseif($llr==10)$pk=500;
elseif($llr==11)$pk=500;
elseif($llr==12)$pk=500;
else $pk=0;
return $pk;
}
if($ku['action']==1){
function rl($lr)
{
$llr=$lr+1;
if($llr==2)$lr=1;
elseif($llr==3)$lr=2;
elseif($llr==4)$lr=3;
elseif($llr==5)$lr=5;
elseif($llr==6)$lr=12;
elseif($llr==7)$lr=25;
elseif($llr==8)$lr=50;
elseif($llr==9)$lr=125;
elseif($llr==10)$lr=250;
elseif($llr==11)$lr=375;
elseif($llr==12)$lr=500;
elseif($llr>12)$lr=750;
else $lr=0;
return $lr;
}
}else
{
function rl($lr)
{
$llr=$lr+1;
if($llr==2)$lr=1;
elseif($llr==3)$lr=3;
elseif($llr==4)$lr=5;
elseif($llr==5)$lr=10;
elseif($llr==6)$lr=25;
elseif($llr==7)$lr=50;
elseif($llr==8)$lr=100;
elseif($llr==9)$lr=250;
elseif($llr==10)$lr=500;
elseif($llr==11)$lr=750;
elseif($llr==12)$lr=1000;
elseif($llr>12)$lr=1500;
else $lr=0;
return $lr;
}
}
if($ku['action']==2){
function cpg($count)
{
$count=$count+1;
if($count==5)$cena=5;
elseif($count==6)$cena=12;
elseif($count==7)$cena=25;
elseif($count==8)$cena=50;
elseif($count==9)$cena=125;
elseif($count>=10 && $count<=12)$cena=250;
elseif($count>=13 && $count<=40)$cena=500;
else $cena=0;
return $cena;
}
}else{function cpg($count)
{
$count=$count+1;
if($count==5)$cena=10;
elseif($count==6)$cena=25;
elseif($count==7)$cena=50;
elseif($count==8)$cena=100;
elseif($count==9)$cena=250;
elseif($count>=10 && $count<=12)$cena=500;
elseif($count>=13 && $count<=40)$cena=1000;
elseif($count>=41 && $count<=50)$cena=2000*($count-40);
else $cena=0;
return $cena;
}}
function err_game($msg)
{
echo "<div class='feedback'><ul class='feedbackPanel'><li class='feedbackPanelERROR'><span class='feedbackPanelERROR'>$msg</span></li></ul></div>";
}
function nc($id)
{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$id'"));
$bans=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_ban` WHERE `id_user` = '".($ank['id'])."' AND `izg` = '1'"));
$time=time();
$banqq=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_ban` WHERE `id_user` = '".($ank['id'])."' AND `time` > '$time'"));
$time=time();
$anku=$ank;
$t=time()-600;
$to=time()-120;
if($ank['colorNameTime']<$time)
{
if($ank['id']==1)$d='<b>';
if($ank['id']==1)$d2='</b>';
return "<span class='nick".($ank['status']==1?"Supporter":null)."".($bans['izg']==1?"Blocked":null)."".($ank['status']==2?"Moderator":null)."".($ank['status']==3?"Admin":null)."".($banqq['time']>$time?"Banned":null)."'>".$d."$anku[nick]".$d2."</span>".($ank['date_last']>$t?"".($ank['date_last']<=$to?"*":null)."":null)."";
}else{
return "<font
color='".$ank['colorName']."'>$anku[nick]</font>".($ank['date_last']>$t?"".($ank['date_last']<=$to?"*":null)."":null)."";
}
}
function no_rubies($rubies)
{
echo "<div class='feedback'><ul><li class='n'>У Вас не хватает <span>рубинов</span>:<img src='/img/icons/ruby.png' alt='o'> <span>".strkol(floor($rubies))."</span></li><li></li><li><img src='/img/icons/ruby.png' alt='o'>
<a href='/payment'>Купить</a></li><li><img src='/img/icons/converter.png' alt='o'> <a href='/exchange'>Обменять</a></li></ul></div>";
}
function no_money($money)
{
echo "<div class='feedback'><ul><li class='n'>У Вас не хватает <span>монет</span>:<img src='/img/icons/money.png' alt='o'> <span>".strkol(floor($money))."</span></li><li></li><li><img src='/img/icons/warehouse.png' alt='o'>
<a href='/warehouse'>Продать товар из амбара</a></li><li><img src='/img/icons/converter.png' alt='o'> <a href='/exchange'>Обменять</a></li></ul></div>";
}
function strkol($colvo)
{
$t=floor($colvo/1000000000000);
$g=floor($colvo/1000000000);
$m=floor($colvo/1000000);
$k=floor($colvo/1000);
if($t!=0)
{
$t=$colvo/1000000000000;
$colvo=round($t,1);
$colvo="$colvo T";
}
elseif($g!=0)
{
$g=$colvo/1000000000;
$colvo=round($g,1);
$colvo="$colvo G";
}
elseif($m!=0)
{
$m=$colvo/1000000;
$colvo=round($m,1);
$colvo="$colvo M";
}
elseif($k!=0)
{
$k=$colvo/1000;
$colvo=round($k,1);
$colvo="$colvo K";
}
else $colvo=(int)$colvo;
return "$colvo";
}
function hsc($text)
{
return strip_tags($text);
}
function update_mc($rating)
{
global $mc,$mcu,$ku,$time;
if($mcu)
{
$pr_meh=($mc['tehnika']/20);
$go=(($rating/100)*$pr_meh);
$rating1=$go+$rating;
mysql_query("UPDATE `kolhoz_collective` SET `rating` = '".($mc['rating']+$rating1)."' WHERE `id` = '$mc[id]'");
mysql_query("UPDATE `kolhoz_collective_user` SET `rating` = '".($mcu['rating']+$rating1)."' WHERE `id` = '$mcu[id]'");
mysql_query("INSERT INTO `kolhoz_collective_rating` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$rating1', `time` = '$time'");
}
}
function podtv($yes_link,$no_link,$header)
{
echo '</div></div><div class="title">Подтверждение</div><div class="div"><li><span >Вы уверены?</span></li><li class="pt"><img alt="" src="/img/icons/tick.png"> <a href="'.$yes_link.'"><span>Да, подтверждаю</span></a></li><li><img alt="" src="/img/icons/cross.png"> <a href="'.$no_link.'"><span>
Нет, отказываюсь</span></a></li></ul></div></div>';
}
function no_money_ct($money)
{
global $mc;
echo "<div class='feedback'>n
<ul>n
<li class='n'>В колхозной кассе не хватает <span>монет</span>: <img src='/img/icons/money.png' alt='o'> <span>".strkol(floor($money))."</span></li>n
<li>В кассу может внести средства любой житель колхоза добровольно или через налоги.</li>n
<li><a href='/kolhoz/cash/$mc[id]'>Пополнить кассу</a></li>n
<li><a href='/kolhoz/taxes/$mc[id]'>В налоговую</a></li>n
</ul>n
</div>n";
}
function no_rubies_ct($rubies)
{
global $mc;
echo "<div class='feedback'>n
<ul>n
<li class='n'>В колхозной кассе не хватает <span>рубинов</span>: <img src='/img/icons/ruby.png' alt='o'> <span>".strkol(floor($rubies))."</span></li>n
<li>В кассу может внести средства любой житель колхоза.</li>n
<li><a href='/kolhoz/cash/$mc[id]'>Пополнить кассу</a></li>n
<li><a href='/kolhoz/flowerbed/$mc[id]'>На клумбу</a></li>n
</ul>n
</div>n";
}
function harvest($harvest)
{
echo "<div class='feedback'><img src='/img/icons/seat.png' alt='o'>Урожай: <span>".strkol(floor($harvest))." шт.</span></div>";
}
function mon($mon)
{
echo "<div class='feedback'><img src='/img/icons/money.png' alt='o'> Доход: <span>".strkol(floor($mon))."</span></div>";
}
function ratingg($rating)
{
echo "<div class='feedback'><img src='/img/icons/experience.png' alt='o'> Опыт: <span>".rating(floor($rating))."</span></div>";
}
function money($money)
{
global $mc,$ku,$mcu;
echo "<div class='feedback'><img src='/img/icons/money.png' alt='o'>Доход: <span class='n'>".strkol(floor($money))." </span>";
if($mc['nalog']>0)
{
$nmoney=floor(($money/100)*$mc['nalog']);
mysql_query("UPDATE `kolhoz_user` SET `umoney` = '0' WHERE `id` = '$ku[id]'");
echo " <span class='minor'>(колхозный налог <span><img
width='16' height='16' src='/img/icons/money.png' alt='o'> <span class='n'>$nmoney</span></span>)</span>";
}
mysql_query("UPDATE `kolhoz_user` SET `umoney` = '0' WHERE `id` = '$ku[id]'");
echo "</div>";
}
function msg_game($msg)
{
echo "<div class='div'>".($msg)."</div>";
}
function br($msg,$br='<br />'){return preg_replace("#((<br>)n|r)+#i",$br, $msg);} // переносы строк
function my_esc($str){return mysql_real_escape_string($str);}
/*
function links($arr)
{
return '<a href="http://'.$_SERVER['HTTP_HOST'].$arr[1].'">'.$arr[2].'</a>';
}*/
function output_text($str,$user=0)
{
$uk=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$user'"));
//$str=htmlentities($str, ENT_QUOTES, 'UTF-8'); // преобразуем все к нормальному перевариванию браузером
$q=mysql_query("SELECT * FROM `kolhoz_smiles` ORDER BY `id` ASC");
while($post=mysql_fetch_array($q))
{
$n=explode(',',$post['name']);
$nn=NULL;
foreach($n as $key => $value)
{
$str=str_replace($value,"<img src='/smiles/$post[img]' alt='o'/>",$str);
}
}
$str="<span class='nick".($uk['status']==1?"Supporter":null)."".($uk['status']==2?"Moderator":null)."".($uk['status']==3?"Admin":null)."'>$str</span>";
$bbcode=array();
$bbcode['/[img](.+)[/img]/isU']='<img src="$1"/>';
$bbcode['/[url=(.+)](.+)[/url]/isU']='<a href="//$1/"/>$2</a>';
$bbcode['/[color=(.+)](.+)[/color]/isU']='<span style="color:$1">$2</span>';
$bbcode['/[i](.+)[/i]/isU']='<i>$1</i>';
$bbcode['/[s](.+)[/s]/isU']='<s>$1</s>';
$bbcode['/[b](.+)[/b]/isU']='<b>$1</b>';
$bbcode['/[u](.+)[/u]/isU']='<u>$1</u>';
$bbcode['/[size=([0-9]+)](.+)[/size]/isU']='<span style="font-size:$1px;">$2</span>';
if (count($bbcode))$str= preg_replace(array_keys($bbcode), array_values($bbcode), $str);
//$str = preg_replace_callback('/[url=(.+)](.+)[/url]/isU', 'links', $str);
$str=br($str); // переносы строк
$col = mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$uk[id]'"));
$cp = mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `status`='1' and `id_collective`='$col[id_collective]'"));
$cop = mysql_query("SELECT * FROM `kolhoz_user` WHERE `id`='$cp[id_user]'");
if(mysql_num_rows($cop) > '0')
{
$cop2 = mysql_fetch_assoc($cop);
$str = "<font color='$cop2[colorText]'> $str </font>";
}
else
{
$str = "<font color='$uk[colorText]'> $str </font>";
}
$str = "$str</font>";
return $str; // возвращаем обработанную строку
}
function strlen2($str)
{
$rus=array('й','ц','у','к','е','н','г','ш','щ','з','х','ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я','ч','с','м','и','т','ь','б','ю','Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь','Б','Ю');
return strlen(str_replace($rus, '0', $str));
}
function page($k_page=1){ // Выдает текущую страницу
$page=1;
if (isset($_GET['page'])){
if ($_GET['page']=='end')$page=intval($k_page);elseif(is_numeric($_GET['page'])) $page=intval($_GET['page']);}
if ($page<1)$page=1;
if ($page>$k_page)$page=$k_page;
return $page;}
function k_page($k_post=0,$k_p_str=10){ // Высчитывает количество страниц
if ($k_post!=0){$v_pages=ceil($k_post/$k_p_str);return $v_pages;}
else return 1;}
function str($link='?',$k_page=1,$page=1)// Вывод номеров страниц (только на первый взгляд кажется сложно ;))
{
if ($page<1)$page=1;
echo "<center><div class="str">n <div class='flat-paging'>";
if ($page!=1)echo "<a class='page a' href="".$link."page/1/" n='Первая страница'><</a> ";
//if ($page!=1)echo "<a class='page a' href="".$link."page/1/" n='Страница №1'>1</a>";else echo "<span class='page b'>1</span>";
for ($ot=-2; $ot<=2; $ot++)
{
if ($page+$ot > 0 && $page+$ot < $k_page+1)
{
if ($ot!=0)echo " <a class='page a' href="".$link."page/".($page+$ot)."" n='Страница №".($page+$ot)."'>".($page+$ot)."</a>";else echo " <span class='page b'>".($page+$ot)."</span>";
}
}
//if ($page!=$k_page)echo " <a class='page a' href="".$link."page/".$k_page."/" n='Страница №$k_page'>$k_page</a>";elseif ($k_page>1)echo " <span class='page b'>$k_page</span>";
if ($page!=$k_page)echo " <a class='page a' href="".$link."page/".$k_page."/" n='Последняя страница'>></a>";
echo "</div></div></center>n";
}
function vremja($time=NULL)
{
global $user;
if ($time==NULL)$time=time();
if (isset($user))$time=$time+$user['set_timesdvig']*60*60;
$timep="".date("j M Y в H:i", $time)."";
$time_p[0]=date("j n Y", $time);
$time_p[1]=date("H:i", $time);
if ($time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
if (isset($user)){
if ($time_p[0]==date("j n Y", time()+$user['set_timesdvig']*60*60))$timep=date("H:i:s", $time);
if ($time_p[0]==date("j n Y", time()-60*60*(24-$user['set_timesdvig'])))$timep="Вчера в $time_p[1]";}
else{
if ($time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
if ($time_p[0]==date("j n Y", time()-60*60*24))$timep="Вчера в $time_p[1]";}
$timep=str_replace("Jan","Янв",$timep);
$timep=str_replace("Feb","Фев",$timep);
$timep=str_replace("Mar","Марта",$timep);
$timep=str_replace("May","Мая",$timep);
$timep=str_replace("Apr","Апр",$timep);
$timep=str_replace("Jun","Июня",$timep);
$timep=str_replace("Jul","Июля",$timep);
$timep=str_replace("Aug","Авг",$timep);
$timep=str_replace("Sep","Сент",$timep);
$timep=str_replace("Oct","Окт",$timep);
$timep=str_replace("Nov","Ноября",$timep);
$timep=str_replace("Dec","Дек",$timep);
return $timep;
}
function minus_money($money)
{
global $ku;
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$money)."' WHERE `id` = '$ku[id]'");
return ($ku['money']-$money);
}
function minus_rubies($rubies)
{
global $ku;
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$rubies)."' WHERE `id` = '$ku[id]'");
return ($ku['rubies']-$rubies);
}
function plus_rating($orat)
{
global $ku;
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
return ($ku['rating']+$orat);
}
function plus_money($money)
{
global $ku;
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$money)."' WHERE `id` = '$ku[id]'");
return ($ku['money']+$money);
}
function plus_rubies($rubies)
{
global $ku;
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']+$rubies)."' WHERE `id` = '$ku[id]'");
return ($ku['rubies']+$rubies);
}
function update_ku($field,$value)
{
global $ku;
mysql_query("UPDATE `kolhoz_user` SET `".$field."` = '".$value."' WHERE `id` = '$ku[id]'");
return $value;
}
function nc_otv($id)
{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$id'"));
return $ank['nick'];
}
?>