Файл: zfarm.mobi/inc/collective/count_cash.php
Строк: 85
<?
$q=mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` != '0' ORDER BY `time` DESC");
$theli=0;
while($post=mysql_fetch_array($q))
{
$ttheli=500;
if($post['heli']==3)$ttheli=1000;
if($post['heli']==4)$ttheli=3000;
$theli=$theli+$ttheli;
}
$meh_all=0;
$rating_gos_all=0;
$q=mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_collective` = '$mc[id]'");
while($post=mysql_fetch_array($q))
{
$usk=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_user]'"));
$meh_all=$meh_all+$usk['tehnika'];
$count=array();
$count['money']=mysql_result(mysql_query("SELECT SUM(`count`) FROM `kolhoz_collective_cash` WHERE `id_user` = '$post[id_user]' AND `id_collective` = '$mc[id]' AND `type` = 'money'"),0);
if($count['money']<1)$count['money']=0;
$count['rubies']=mysql_result(mysql_query("SELECT SUM(`count`) FROM `kolhoz_collective_cash` WHERE `id_user` = '$post[id_user]' AND `id_collective` = '$mc[id]' AND `type` = 'rubies'"),0);
if($count['rubies']<1)$count['rubies']=0;
$count['rubies_week']=mysql_result(mysql_query("SELECT SUM(`count`) FROM `kolhoz_collective_cash` WHERE `id_user` = '$post[id_user]' AND `id_collective` = '$mc[id]' AND `type` = 'rubies' AND `time` > '".($time-(3600*24*7))."'"),0);
//echo $count['rubies'];
if($count['rubies_week']<1)$count['rubies_week']=0;
$count['rating']=mysql_result(mysql_query("SELECT SUM(`count`) FROM `kolhoz_collective_rating` WHERE `id_user` = '$post[id_user]' AND `id_collective` = '$mc[id]'"),0);
if($count['rating']<1)$count['rating']=0;
$count['rating_week']=mysql_result(mysql_query("SELECT SUM(`count`) FROM `kolhoz_collective_rating` WHERE `id_user` = '$post[id_user]' AND `id_collective` = '$mc[id]' AND `time` > '".($time-(3600*24*7))."'"),0);
if($count['rating_week']<1)$count['rating_week']=0;
$count['rating_gos']=mysql_result(mysql_query("SELECT SUM(`count`) FROM `kolhoz_collective_rating_gos` WHERE `id_user` = '$post[id_user]' AND `id_collective` = '$mc[id]'"),0);
if($count['rating_gos']<1)$count['rating_gos']=0;
if($post['money']!=$count['money'])mysql_query("UPDATE `kolhoz_collective_user` SET `money` = '$count[money]' WHERE `id` = '$post[id]'");
if($post['rubies']!=$count['rubies'])mysql_query("UPDATE `kolhoz_collective_user` SET `rubies` = '$count[rubies]' WHERE `id` = '$post[id]'");
if($post['rubies_week']!=$count['rubies_week'])mysql_query("UPDATE `kolhoz_collective_user` SET `rubies_week` = '$count[rubies_week]' WHERE `id` = '$post[id]'");
if($post['rating']!=$count['rating'])mysql_query("UPDATE `kolhoz_collective_user` SET `rating` = '$count[rating]' WHERE `id` = '$post[id]'");
if($post['rating_week']!=$count['rating_week'])mysql_query("UPDATE `kolhoz_collective_user` SET `rating_week` = '$count[rating_week]' WHERE `id` = '$post[id]'");
if($post['rating_gos']!=$count['rating_gos'])mysql_query("UPDATE `kolhoz_collective_user` SET `rating_gos` = '$count[rating_gos]' WHERE `id` = '$post[id]'");
if($post['tehnika']!=$usk['tehnika'])mysql_query("UPDATE `kolhoz_collective_user` SET `tehnika` = '$usk[tehnika]' WHERE `id` = '$post[id]'");
$rating_gos_all=$rating_gos_all+$count['rating_gos'];
}
$meh_all=$meh_all+$theli;
mysql_query("UPDATE `kolhoz_collective` SET `rating_gos` = '$rating_gos_all' WHERE `id` = '$mc[id]'");
if($meh_all>$mc['tehnika'])mysql_query("UPDATE `kolhoz_collective` SET `tehnika` = '$meh_all' WHERE `id` = '$mc[id]'");?>