Файл: test.zfarm.mobi/msclub/msfarm.php
Строк: 226
<?php
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_club` WHERE `type` = '".num($user['msclub'])."'"),0)<1){
///////// Лог Пользователя ///// By MyStyle
$text = 'Вас нет в клане';
$_SESSION['msg'] = $text;
header("Location: ./?msclan");
exit;
}else{
if(isset($_GET['collect']) && num($_GET['collect'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_cfarm` WHERE `id` = '".num($_GET['collect'])."' AND `club` = '".$user['msclub']."' AND `time` <= '".$time."'LIMIT 1"),0)!=0){
$img = '';
$farm = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_cfarm` WHERE `club` = '".$user['msclub']."' AND `id` = '".num($_GET['collect'])."' AND `time` <= '".$time."'"));
$trrti = $farm['img_sclad'].'.png';
$sclad = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_cwarehouse` WHERE `img` = '".$trrti."' AND `club` = '".$user['msclub']."'"));
$mscrypt = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_cseat` WHERE `id` = '".$farm['type']."'"));
$rat = $mscrypt['exp'];
$avatar = 0;
$mozgi_exp_sql = 0;
if(isset($mozgi_exp))$mozgi_exp_sql=(($rat/100)*200);
if(isset($user['avatar_exp']))$avatar=(($rat/100)*$user['avatar_exp']);
$rat_user = $avatar+$mozgi_exp_sql;
if($rat_user==0)$rat=$rat;
else $rat=$rat_user;
$cerdce = $user['sunduk3']+30;
$rating = $user['rating']+$rat;
$money = $user['money']+$mscrypt['money'];
///////////////////////////////////////////
///////////////////////////////////////////
///////// Лог Пользователя ///// By MyStyle
$text = 'Урожай перемещён в склад. Опыта: '.$rat.' + <img width="16" height="16" src="images/zombi/coins.png" alt="" title=""/> '.$mscrypt['money'].' + 30 <img width="16" height="16" src="images/who_postroyki/brain.png" alt="" />';
$_SESSION['msg'] = $text;
///////////////////////////////////////////
///////////////////////////////////////////
///////////////////////////////////////////
mysql_query("UPDATE `mystyle_user` SET `money` = '".$money ."', `rating` = '".$rating."', `sunduk3` = '".$cerdce."' WHERE `id` = '".$user['id']."' LIMIT 1");
$cratq = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_club` WHERE `id` = '".num($user['msclub'])."'"));
$cole = $cratq['rating']+$ret;
$coleq = $cratq['money']+$mscrypt['money'];
mysql_query("UPDATE `mystyle_club` SET `money` = '".$money ."', `rating` = '".$cole."' WHERE `id` = '".$user['msclub']."' LIMIT 1");
$msg = 'Собрал урожай ('.$mscrypt['name'].') положил в клан <span class="faith">'.$mscrypt['money'].'</span> монет и '.$rat.' рейтинга.';
mysql_query("INSERT INTO `mystyle_clog` SET `club` = '".num($user['msclub'])."', `msg` = '".$msg."', `user` = '".$user['id']."', `time` = '".$time."'");
if($trrti == $sclad['img']){
$vol = $sclad['col']+1;
mysql_query("UPDATE `mystyle_cwarehouse` SET `col` = '".$vol."', `name` = '".my_esc($mscrypt['name'])."' WHERE `id` = '".$sclad['id']."' AND `club` = '".$user['msclub']."'");
include 'mystylecollect/mystylecollectionsrand.php';
$rand1 = rand(1,10);
$rand2 = rand(1,10);
$rand3 = rand(1,211);
if($rand1 == $rand2){
$collections = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_collections` WHERE `id` = '".$rand3."'")); //////////////// Нет отношений
$img_coll = ''.$collections['img'].'.png';
mysql_query("INSERT INTO `mystyle_sklad` SET `user` = '".$user['id']."', `name` = '".$collections['name']."', `img` = '".$img_coll."', `money` = '".$collections['money']."', `type` = '".num(2)."', `col` = '".num(1)."'");
}
}else{
include 'mystylecollect/mystylecollectionsrand.php';
$rand1 = rand(1,20);
$rand2 = rand(1,30);
$rand3 = rand(1,211);
if($rand1 == $rand2){
$collections = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_collections` WHERE `id` = '".$rand3."'")); /////////////// Нет отношений
$img_coll = ''.$collections['img'].'.png';
mysql_query("INSERT INTO `mystyle_sklad` SET `user` = '".$user['id']."', `name` = '".$collections['name']."', `img` = '".$img_coll."', `money` = '".$collections['money']."', `type` = '".num(2)."', `col` = '".num(1)."'");
}
$reimgt = ''.$farm['img_sclad'].'.png';
mysql_query("INSERT INTO `mystyle_cwarehouse` SET `club` = '".$user['msclub']."', `name` = '".my_esc($mscrypt['name'])."', `img` = '".$reimgt."', `money` = '".$mscrypt['money']."', `type` = '".num(1)."', `col` = '".num(1)."'");
}
mysql_query("UPDATE `mystyle_cfarm` SET `img_sclad` = '', `type` = '0', `time_left` = '0', `img` = '', `time` = '0', `fertilize` = '0', `pour` = '0' WHERE `id` = '".$farm['id']."' AND `club` = '".$user['msclub']."'");
header("Location: ./?msfarm");
exit;
}elseif(isset($_GET['watertheplant']) && num($_GET['watertheplant'])!=NULL && mysql_result(mysql_query("SELECT COUNT(id) FROM `mystyle_cfarm` WHERE `club` = '".num($user['msclub'])."' AND `id` = '".num($_GET['watertheplant'])."' LIMIT 1"),0)!=0){
$post = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_cfarm` WHERE `id` = '".num($_GET['watertheplant'])."' LIMIT 1"));
if(num($_GET['page']))$page = 'page='.num($_GET['page']).'';
if($post['pour'] < $time){
$rat = rand(10,100);
$avatar = 0;
$mozgi_exp_sql = 0;
if(isset($mozgi_exp))$mozgi_exp_sql=(($rat/100)*200);
if(isset($user['avatar_exp']))$avatar=(($rat/100)*$user['avatar_exp']);
$rat_user = $avatar+$mozgi_exp_sql;
if($rat_user==0)$rat=$rat;
else $rat=$rat_user;
$rtime = $time+1800;
$voda = $post['pour']+$rtime;
$time_all = $post['time']-1800;
$msg = 'Полил урожай ('.$post['name'].').';
mysql_query("INSERT INTO `mystyle_clog` SET `club` = '".num($user['msclub'])."', `msg` = '".$msg."', `user` = '".$user['id']."', `time` = '".$time."'");
mysql_query("UPDATE `mystyle_cfarm` SET `pour` = '".$voda."', `time` = '".$time_all."' WHERE `id` = '".$post['id']."' AND `club` = '".$user['msclub']."' LIMIT 1");
//////////////////////////////////////////////////////////////////
include_once 'mystylecollect/mystylecollectionsrand.php';
//////////////////////////////////////////////////////////////////
///////// Лог Пользователя ///// By MyStyle
$text = 'Успешно полито.';
$_SESSION['msg'] = $text;
$re2 = $user['rating']+$rat;
mysql_query("UPDATE `mystyle_user` SET `rating` = '".$re2."' WHERE `id` = '".$user['id']."' LIMIT 1");
header("Location: ./?msfarm&$page");
exit;
}else{
$text = 'Рано поливать.';
$_SESSION['msg'] = $text;
header("Location: ./?msfarm&$page");
exit;
}
}elseif(isset($_GET['mscseatid']) && num($_GET['mscseatid'])!=NULL && isset($_GET['id']) && num($_GET['id'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_cseat` WHERE `id` = '".num($_GET['id'])."' AND `level` <= '".$msclub['level']."' LIMIT 1"),0) && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_cfarm` WHERE `id` = '".num($_GET['mscseatid'])."' AND `club` = '".$user['msclub']."' LIMIT 1"),0)!=0){
$fer = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_cseat` WHERE `id` = '".num($_GET['id'])."' AND `level` <= '".$msclub['level']."'"));
$les = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_cfarm` WHERE `id` = '".num($_GET['mscseatid'])."' AND `club` = '".$user['msclub']."'"));
$need=$fer['money']/2;
if($msclub['money']>=$need){
$time_got = $time+$fer['time'];
$needs = $msclub['money']-$need;
mysql_query("UPDATE `mystyle_club` SET `money` = '".$needs."' WHERE `id` = '".$user['msclub']."' LIMIT 1");
mysql_query("UPDATE `mystyle_cfarm` SET `name` = '".$fer['name']."', `img_sclad` = '".$fer['img_sclad']."', `time` = '".$time_got."', `img` = '".$fer['img']."', `time_left` = '".$fer['time']."', `type` = '".$fer['id']."' WHERE `id` = '".num($_GET['mscseatid'])."' AND `club` = '".$user['msclub']."'");
$msclub = 0;
$rat = 10;
$avatar = 0;
$mozgi_exp_sql = 0;
if(isset($user['msclub']))$msclub = (($rat/100)*200);
if(isset($mozgi_exp))$mozgi_exp_sql=(($rat/100)*200);
if(isset($user['avatar_exp']))$avatar=(($rat/100)*$user['avatar_exp']);
$rat_user = $msclub+$avatar+$mozgi_exp_sql;
if($rat_user==0)$rat=$rat;
else $rat=$rat_user;
$ret = $rat;
$cuser = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_cuser` WHERE `user` = '".num($user['id'])."'"));
$crat = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_club` WHERE `id` = '".num($user['msclub'])."'"));
$col = $crat['rating']+$ret;
$col2 = $cuser['rating']+$ret;
$col3 = $user['rating']+$ret;
$msg = 'Посадил урожай ('.$fer['name'].')! Снятие '.$need.' монет с клана.';
mysql_query("INSERT INTO `mystyle_clog` SET `club` = '".num($user['msclub'])."', `msg` = '".$msg."', `user` = '".$user['id']."', `time` = '".$time."'");
mysql_query("UPDATE `mystyle_club` SET `rating` = '".$col."' WHERE `id` = '".$user['msclub']."' LIMIT 1");
mysql_query("UPDATE `mystyle_cuser` SET `rating` = '".$col2."' WHERE `user` = '".$user['id']."' LIMIT 1");
mysql_query("UPDATE `mystyle_user` SET `rating` = '".$col3."' WHERE `id` = '".$user['id']."' LIMIT 1");
$text = 'Посадили: + <span class="level">'.$rat.'</span> <img width="16" height="16" alt="" title="" src="images/zombi/xp.png">';
$_SESSION['msg'] = $text;
header("Location: ./?msfarm");
exit;
}else{
err_money($need-$msclub['money']);
}
}elseif(isset($_GET['mscseat']) && num($_GET['mscseat'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_cfarm` WHERE `club` = '".$user['msclub']."' AND `id` = '".num($_GET['mscseat'])."' AND `time` = '0' LIMIT 1"),0)!=0){
$farm = mysql_fetch_array(mysql_query("SELECT * FROM `mystyle_cfarm` WHERE `id` = '".num($_GET['mscseat'])."'"));
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_cseat`"),0);
$k_page=k_page($k_post,$user['set']);
$page=page($k_page);
$start=$user['set']*$page-$user['set'];
$q=mysql_query("SELECT * FROM `mystyle_cseat` LIMIT $start, $user[set]");
while($post=mysql_fetch_array($q))
{
$cena = $post['money']/2;
echo '<li class="emptyPanel"><span class="whiteBoldLink textshadow"><div>
<img class="portrait pt6 pl6 pr6 center kartinki_div" width="60" height="60" src="images/msfarmclub/'.$post['img'].'.png" alt="" />
<span style="clear: both;">Название: '.$post['name'].'</span><br />
<span style="clear: both;">Уровень: '.$post['level'].'</span>
<br /><span class="pt6">Созреет через: '.time_left($post['time']).'</span>
<span class="whiteBoldLink fr">Даёт после сбора: <span><img width="16" height="16" alt="" title="" src="images/zombi/xp.png"> '.$post['exp'].'</span> <span>
<img width="16" height="16" alt="" title="" src="images/zombi/coins.png"> '.$post['money'].'</span></span>';
echo '<div style="clear:both"></div></div></li>';
if($msclub['level']>=$post['level']){
echo '<a class="btnwom" href="?msfarm&mscseatid='.num($_GET['mscseat']).'&id='.$post['id'].'">Посадить
<span class="money nobr textshadow"><img width="16" height="16" src="images/zombi/coins.png" alt=""/> <span class="required">'.$cena.'</span></span>
</a>';
}
echo '</div></li>';
}
if ($k_page>1)str("?msfarm&mscseat=".num($_GET['mscseat'])."&",$k_page,$page); // Вывод страниц
}else{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$user['set'] = 9;
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `mystyle_cfarm` WHERE `club` = '".$user['msclub']."'"),0);
if ($k_post==0){}
$k_page=k_page($k_post,$user['set']);
$page=page($k_page);
$start=$user['set']*$page-$user['set'];
echo '<table class="center pt6 pb6" style="margin:0 auto; width: 80%;">';
$q=mysql_query("SELECT * FROM `mystyle_cfarm` WHERE `club` = '".$user['msclub']."' LIMIT $start, $user[set]");
while($post=mysql_fetch_array($q))
{
$sr = $start+1;
if($sr == 1)echo '<tr class="whiteBoldLink textshadow">';
if($sr == 4)echo '<tr class="whiteBoldLink textshadow">';
if($sr == 7)echo '<tr class="whiteBoldLink textshadow">';
/////////////////////////////////////////////////////////
@$bte = $post['time']-time();
@$timr = $bte/$post['time_left']*100;
echo '<td>';
if($post['time'] < time()){}else{
echo '<span class="fr like">'.time_left($post['time']-$time).'</span>';
}
if($post['time'] < time() && $post['time'] != 0){
echo '<a href="?msfarm&collect='.$post['id'].'" title="Пора собирать..."><img class="btnp fr" width="16" height="16" alt="o" src="/images/icons/tick.png"/></a>';
}
if(!$post['img']){
echo '<a href="./?msfarm&mscseat='.$post['id'].'" title="Посадить...">
<img width="75" height="75" src="images/msfarmclub/gryadka2.png" alt="" /></a>
<div><div><div class="fr" style="padding: 5px 0 0 5px; width: 100%;">
<div class="expBorder"><div class="expline2" style="width:0%;"></div></div></div>';
}else{
echo '<img width="75" height="75" src="images/msfarmclub/'.$post['img'].'.png" alt="" />';
if($post['pour'] < time() && $post['time'] > time()) echo '<a href="?msfarm&watertheplant='.$post['id'].''.$pad.'"><img class="fr btnp" src="images/msfarmclub/water.png" alt="" /></a>';
if($post['time'] < time()){
echo '<div><div><div class="fr" style="padding: 5px 0 0 5px; width: 100%;">
<div class="expBorder"><div class="expline2" style="width:0%;"></div></div></div>';
}else{
echo '<div><div><div class="fr" style="padding: 5px 0 0 5px; width: 100%;">
<div class="expBorder"><div class="expline2" style="width:'.$timr.'%;"></div></div></div></div></div>';
}
echo '</td>';
}
/////////////////////////////////////////////////////////
if($sr == 3)echo '</tr>';
if($sr == 6)echo '</tr>';
if($sr == 9)echo '</tr>';
$start++;
}
echo '</table>';
}
echo '<div>
<div class="feedbackPanel">
<div style="text-align: center;">
<div class="fl" style="width: 49%;">
<a class="btn" href="?msclub">
<img width="16" height="16" alt="o" src="/images/icons/tick.png"/>
<span>В клан!</span>
</a>
</div>
<div class="fr" style="width: 49%;">
<a class="btn" href="./">
<img width="16" height="16" alt="o" src="/images/icons/cross.png"/>
<span>На главную!</span>
</a>
</div>
<div style="clear: both;"></div>
</div>
</div>
</div>';
}
?>