Файл: sumerki.mobi/sumerki.mobi/files/func.php
Строк: 274
<?php
//////////////////////////////////////////////////////////////
//////////////////////Онлайн игра "Сумерки"///////////////////
//////////////////////Основатель: Mc Laren////////////////////
///////////////////Контакты: ICQ - 597687549//////////////////
/////////////////////Пример: Sumerki.Mobi/////////////////////
///////////Если ты это читаешь, значит скрипт слили :D////////
//////////////////////////////////////////////////////////////
defined('PROTECTOR') or die('Error: lol');
function zasad(){
global $inzasada;
if ($inzasada=='1'){
header ('Location: zasada.php?');exit;
}
}
function ryd(){
global $inryd;
if ($inryd=='1'){
header ('Location: rydnik.php?');exit;
}
}
//////////БОИ
function going(){
global $in_battle,$inpk,$inar,$inzasada;
///////////////////////////////БОЙ/////////////////////
if ($in_battle=='1'){
header ('Location: battle.php?');exit;
}
/////////////////////////////////////////////////////////////////
elseif ($inpk=='1'){
header ('Location: pk.php?');exit;
}
///////////////////////////////////////////////////////////////////
elseif ($inar=='1'){
header ('Location: combat.php?');exit;
}
}
##############################################################################################
function auto_clean(){
global $log;
$req=mysql_query("SELECT * FROM log WHERE usr = '$log' LIMIT 20");
$avto = mysql_num_rows($req);
if($avto>='20'){
$lim=round($avto/2);
mysql_query("DELETE FROM `log` WHERE `usr` = '$log' LIMIT $lim");
}
}
function del_log($lpl){
global $log;
mysql_query("DELETE FROM `log` WHERE `usr` = '$log' and `place` = '$lpl'");
}
function log_msg($tlog){
global $log;
$req=mysql_query("SELECT * FROM log WHERE usr = '$log' and place='$tlog' and timer>='".time()."' ORDER BY id DESC LIMIT 6");
$avto = mysql_num_rows($req);
if($avto>=1){
echo'<div class="logtext">';
While($ilok = mysql_fetch_assoc($req))
{
if($ilok['kto']=='system'){$color='grey';}
if($ilok['kto']=='user'){$color='green';}
if($ilok['kto']=='enemy'){$color='red';}
echo '<small><font color="'.$color.'">'.$ilok[text].'</font></small><br/>';
}
echo'</div>';
}
}
function idlog($idlog){
$reqi = mysql_query("SELECT lvl,storona,prava FROM `users` WHERE `usr` = '$idlog' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($reqi);
if($avto>=1){
$ref = mysql_fetch_assoc($reqi);
//echo'<img src="pic/main/'.$ref['storona'].'.png" alt="#"/>';
if($ref['prava']==5){
echo'<font color="ADFF2F">(Адм)</font>';
}
if($ref['prava']==2){
echo'<font color="yellow">(Мод)</font>';
}
if($ref['prava']!=5){
echo' <img src="pic/up.png"/><b>'.$ref['lvl'] ;}
echo '</b> <a href="search.php?nick='.$idlog.'&go=go">'.$idlog.'</a>';
}
}
function idlogs($idlogs){
$reqi = mysql_query("SELECT lvl,storona,prava FROM `users` WHERE `usr` = '$idlogs' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($reqi);
if($avto>=1){
$ref = mysql_fetch_assoc($reqi);
echo'<img src="pic/main/'.$ref['storona'].'.png" alt="#"/> <a href="search.php?nick='.$idlogs.'&go=go">'.$idlogs.'</a>';
if($ref['prava']==5){
echo'<font color="lime">.GM</font>';
}
if($ref['prava']==2){
echo'<font color="yellow">.M</font>';
}
echo' <img src="pic/up.png"/> '.$ref['lvl'] ;
}
}
///РЕФЕРАЛЫ
function ref(){
global $log,$udata;
if(!empty($udata['ref'])){
if($udata['lvl']>='5' and $udata['ref']!='not'){
$req = mysql_query("SELECT `exp`,`money` FROM `users` WHERE `id` = '$udata[ref]' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($req);
if ($avto == 1) {
$refer = mysql_fetch_assoc($req);
$refer[money]=$refer[money]+1000;
$refer[exp]=$refer[exp]+500;
mysql_query("UPDATE users SET money = '$refer[money]',exp='$refer[exp]' WHERE id = '$udata[ref]' LIMIT 1");
mysql_query("UPDATE users SET ref = 'not' WHERE usr = '$log' LIMIT 1");
}
}
}
}
/////////////////////
//////////////////ОТДЫХпослебоя
function out(){
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `outbuy` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `outbuy` WHERE `usr` = '$log'");
}
}
//////////////////ОТДЫХрудник
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `rudniktime` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `rudniktime` WHERE `usr` = '$log'");
}
}
//////////////////ОТДЫнападения
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `outpk` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `outpk` WHERE `usr` = '$log'");
}
}
//////////////////клан штраф
{
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `clan_straf` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `clan_straf` WHERE `usr` = '$log'");
}
}}
//////////////////ТаймаутПКбоя
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `time_pk` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `time_pk` WHERE `usr` = '$log'");
mysql_query("DELETE FROM `pk` WHERE `usr` = '$log'");
}
}
//////////////////Удаление времени покупки зерна
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `shop_hfarmer` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `shop_hfarmer` WHERE `usr` = '$log'");
}
}
//////////////////рекомендации
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `recomendation` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `recomendation` WHERE `usr` = '$log'");
}
}
//////////////////Удаление проклятия
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `proklyat` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `proklyat` WHERE `usr` = '$log'");
}
}
//////////////////Удаление времени шахты
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `shahta_times` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `shahta_times` WHERE `usr` = '$log'");
}
}
//////////////////Удаление времени рудника тайма
{
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `rudnik_times` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `rudnik_times` WHERE `usr` = '$log'");
}
}}
//////////////////Удаление временир рыбалки
{
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `ulov_times` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `ulov_times` WHERE `usr` = '$log'");
}
}
function clanwarn(){
global $log,$udata;
$time=time();
///////
$req = mysql_query("SELECT * FROM `clanwar` WHERE `timeout`<'$time' and `clan`='$udata[clan]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
mysql_query("DELETE FROM `clanwar` WHERE `usr` = '$log'");
}
}
//////////////////////Olimpiada///////////////////////////////////////////////
$date = date("d.m.y");
$date=date("D");
if(@file("data/olimpiada.dat")){
if($date=="Sun"){
$file=@file("data/olimpiada.dat");
$total=count($file);
for($i=0; $i<$total; $i++){
$data=explode("||",$file[$i]);
$data_log[]=$data[0];
$data_kol[]=$data[1];
}
arsort($data_kol);
foreach($data_kol as $a=>$b)
{
$nick[]=$data_log[$a];
$dan[]="".$data_log[$a]." - (".$data_kol[$a].")";
}
mysql_query("INSERT INTO `news` VALUES ('', '<b>Результаты турнира:</b> <br>
<b>1</b> место - $dan[0]<img src="pic/main/kristal.png"> - 30 <img width="12" height="12" src="pic/gold.png"> <br>
<b>2</b> место - $dan[1]<img src="pic/main/kristal.png"> - 3000 <img width="12" height="12" src="pic/main/lezo.jpeg"> <br>
<b>3</b> место - $dan[2]<img src="pic/main/kristal.png"> - 2500 <img width="12" height="12" src="pic/money.png">', 'Организатор турнира', '".date("H:i d.m.y")."')") or die(mysql_error());
$fp=fopen("data/olimpiada.dat","w");
flock($fp,LOCK_EX);
fputs($fp,"");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
mysql_query("DELETE FROM `res` WHERE `lat_name`='kristalsss'");
mysql_query("DELETE FROM `turnir` WHERE `lat_name`='kristalsss'");
$gold=mysql_query("SELECT * FROM `users` WHERE `usr`='$nick[0]'");
$gold= mysql_fetch_array($gold);
$gold=$gold['gold'];
$gold=$gold+30;
mysql_query("UPDATE `users` SET `gold`='$gold' WHERE `usr`='$nick[0]'");
$gelozo=mysql_query("SELECT * FROM `users` WHERE `usr`='$nick[1]'");
$gelozo=mysql_fetch_array($gelozo);
$gelozo=$gelozo['gelozo'];
$gelozo=$gelozo+3000;
mysql_query("UPDATE `users` SET `gelozo`='$gelozo' WHERE `usr`='$nick[1]'");
$money=mysql_query("SELECT * FROM `users` WHERE `usr`='$nick[2]'");
$money= mysql_fetch_array($money);
$money=$money['money'];
$money=$money+2500;
mysql_query("UPDATE `users` SET `money`='$money' WHERE `usr`='$nick[2]'");
}}
/////АУРЫ//////////////
function aura(){
global $log,$udata;
$time=time();
///////
$req = mysql_query("SELECT * FROM `aurs` WHERE `actimer`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto=='1'){
$req = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log' and `status`='1' LIMIT 1");
$avto=mysql_num_rows($req);
if($avto=='1'){
$mag = mysql_fetch_assoc($req);
$numin=$udata['umin']-$mag['umin'];
$nlovk=$udata['lovk']-$mag['lovk'];
$num=$udata['um']-$mag['um'];
$nsila=$udata['sila']-$mag['sila'];
$numax=$udata['umax']-$mag['umax'];
$nprot=$udata['prot']-$mag['prot'];
$nhp=$udata['hpall']-$mag['hp'];
$nmp=$udata['mpall']-$mag['mp'];
$nkrit=$udata['krit']-$mag['krit'];
$nukrit=$udata['ukrit']-$mag['ukrit'];
$nanti=$udata['antikrit']-$mag['antikrit'];
mysql_query("UPDATE `users` SET
`umin` = '$numin',
`umax` = '$numax',
`hpall` = '$nhp',
`mpall` = '$nmp',
`sila` = '$nsila',
`um` = '$num',
`lovk` = '$nlovk',
`krit` = '$nkrit',
`ukrit` = '$nukrit',
`antikrit` = '$nanti',
`prot` = '$nprot' WHERE usr = '$log'");
if($mag['kol']=='1'){
mysql_query("DELETE FROM `item_aura` WHERE `id` = '$mag[id]' LIMIT 1");
}else{
$mag[kol]--;
mysql_query("UPDATE item_aura SET kol = '$mag[kol]',status='0' WHERE `id` = '$mag[id]' LIMIT 1");
}
mysql_query("DELETE FROM `aurs` WHERE `usr` = '$log' LIMIT 1");
}
}
}
function avatar($log)
{
global $set;
if (is_file($path."pic/avanick/$log.gif"))
echo "<img src='pic/avanick/$log.gif' alt='АВАТАР' />n";
elseif (is_file($path."pic/avanick/$log.jpg"))
echo "<img src='pic/avanick/$log.jpg' alt='АВАТАР' />n";
elseif (is_file($path."pic/avanick/$log.png"))
echo "<img src='pic/avanick/$log.png' alt='АВАТАР' />n";
if ($_SERVER['PHP_SELF']=='/info.php' && (is_file(H."sys/avatar/$id.gif") || is_file(H."sys/avatar/$id.jpg") || is_file(H."sys/avatar/$id.png")))echo "<br />n";
}
//////////////ЧИСТИМ АРЕНУ
function clear_arena(){
$time=time();
///////
$req = mysql_query("SELECT * FROM `arena_wait` WHERE `wait`<'$time'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
While($inv = mysql_fetch_assoc($req))
{
if(empty($inv['enemy'])){
mysql_query("DELETE FROM `arena_wait` WHERE id='$inv[id]'");//чистим заявки
}else{
mysql_query("INSERT INTO
`arena` SET `usr` = '$inv[usr]',
`enemy` = '$inv[enemy]',
`xod` = 'not',
`ltime`='$time'");
mysql_query("INSERT INTO
`arena` SET `usr` = '$inv[enemy]',
`enemy` = '$inv[usr]',
`xod` = 'not',
`ltime`='$time'");
del_log($lpl='combat');
$timer=time()+300;
mysql_query("INSERT INTO log SET usr='$log',text='$inv[usr] против $inv[enemy]! Бой начался!',kto='system',place='combat',timer='$timer'");
mysql_query("DELETE FROM `arena_wait` WHERE usr='$inv[usr]' LIMIT 1");//чистим заявки
mysql_query("DELETE FROM `arena_wait` WHERE usr='$inv[enemy]' LIMIT 1");//чистим заявки
}
}
}
}
//////////////////////
///////КОРМИМ ПИТОВ
function pit_eda(){
global $log;
$time=time();
$req = mysql_query("SELECT `dies`,`lasteda`,`name` FROM `pit` WHERE `usr` = '$log' and `status`='on' LIMIT 1");
$avto=mysql_num_rows($req);
if($avto>='1'){
$pit = mysql_fetch_assoc($req);
if($pit['lasteda']<=$time){
$pit['dies']=$pit['dies']+1;
mysql_query("UPDATE `pit` SET `hp` = '0',`dies`='$pit[dies]',`status`='die' WHERE `usr` = '$log' and `status`='on' LIMIT 1");
///пишем письмо
$time = date("H:i d.m.y");
$text = $pit[name].' погиб от голода! Вы можете его воскресить в <a href="pitomec.php">питомнике</a>!';
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Зверовод', `user_to` = '$log', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
}
}
}
////////////////
//навигация
function place_okr(){
global $log;
$req = mysql_query("SELECT `city` FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
////////////////////////////
$mestouser = mysql_fetch_assoc($req);
if($mestouser['city']=='1'){
header ('Location: okrestnosti.php?');exit;
}
}
//навигация
function place_zamok(){
global $log;
$req = mysql_query("SELECT `city` FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
////////////////////////////
$mestouser = mysql_fetch_assoc($req);
if($mestouser['city']=='2'){
header ('Location: zamok.php?');exit;
}
}
//навигация
function place_tower(){
global $log;
$req = mysql_query("SELECT `city` FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
////////////////////////////
$mestouser = mysql_fetch_assoc($req);
if($mestouser['city']=='3'){
header ('Location: towers.php?');exit;
}
}
function navig2($page, $link, $pages){
for($i = 1; $i <= $pages; $i++){
if($i != $page){
echo '<a href="'.$link.'page='.$i.'">'.$i.'</a> ';
}
else{
echo '<u>'.$i.'</u> '; // выводим активую страницу текстом
}
}
if($pages>=1){
echo '<br/>';
}
}
//навигация
function place_city(){
global $log;
$req = mysql_query("SELECT `city` FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
////////////////////////////
$mestouser = mysql_fetch_assoc($req);
if($mestouser['city']=='0'){
header ('Location: gorod.php?');exit;
}
}
?>