Файл: new_fanland/food.php
Строк: 88
<?php
############################################
# Данная версия скрипта принадлежит #
# LiraS aka Артур Лукин Иванович #
# Вносить свои изменения крайне #
# запрещенно! #
############################################
$u = mysql_fetch_array(mysql_query("SELECT id FROM `users` WHERE `usr` = '".mysql_real_escape_string($_GET['usr'])."'"));
$id = strip_tags($u['id']);
$n = mysql_query("SELECT * FROM `nalog` WHERE `u_id` = '$id'");
$nl = mysql_num_rows($n);
$time = time();
#################################
$s = mysql_fetch_array(mysql_query("SELECT * FROM serv_set WHERE name = 'fanland'"));
$d_time = $s['d_time'];
#################################
$t = 60*60*10*$d_time;
$tim = $time+$t;
if ($nl == 0)
{
mysql_query("INSERT INTO `nalog` SET eda = '$tim', dreiki = '$tim', u_id = '$id'");
}
$nal = mysql_fetch_array(mysql_query("SELECT * FROM `nalog` WHERE u_id = '$id'"));
$f_time = strip_tags($nal['eda']);
$dr_time = strip_tags($nal['dreiki']);
if ($f_time <= $time || $dr_time <= $time)
{
echo '<div class="main"><div class="in">';
}
if ($dr_time <= $time)
{
$p = mysql_fetch_array(mysql_query("SELECT * FROM `people` WHERE `u_id` = '$id'"));
$workers = strip_tags($p['workers']);
$lesorubi = strip_tags($p['lesorubi']);
$min_dr = ($workers+$lesorubi)*2;
$max_dr = ($workers+$lesorubi)*4;
$min_dr = round($min_dr);
$max_dr = round($max_dr);
$p_dr = rand($min_dr,$max_dr);
############################################
$n = mysql_fetch_array(mysql_query("SELECT `n_time` FROM `serv_set` WHERE name = 'fanland'"));
$n_time = strip_tags($n['n_time']);
$t = 60*60*10/$n_time;
$tim = $time+$t;
############# Записываем в базу ############
mysql_query("UPDATE `nalog` SET `dreiki` = '$tim' WHERE u_id = '$id'");
mysql_query("UPDATE `finans` SET `dreiki` = dreiki+'$p_dr' WHERE u_id = '$id'");
#####################################
echo 'Вы от рабочих получили налог в размере '.$p_dr.' дрейков<br>';
}
if ($f_time <= $time)
{
$p = mysql_fetch_array(mysql_query("SELECT * FROM `people` WHERE `u_id` = '$id'"));
$workers = strip_tags($p['workers']);
$lesorubi = strip_tags($p['lesorubi']);
$min_f = ($workers+$lesorubi)*1;
$min_f = round($min_f);
$max_f = ($workers+$lesorubi)*1.5;
$max_f = round($max_f);
$p_f = rand($min_f,$max_f);
$r = mysql_fetch_array(mysql_query("SELECT food FROM resurs WHERE u_id = '$id'"));
$food = strip_tags($r['food']);
############################################
$n = mysql_fetch_array(mysql_query("SELECT `n_time` FROM `serv_set` WHERE name = 'fanland'"));
$n_time = strip_tags($n['n_time']);
$t = 60*60*10*$n_time;
$tim = $time+$t;
if ($food >= $p_f)
{
############# Записываем в базу ############
mysql_query("UPDATE `nalog` SET `eda` = '$tim' WHERE u_id = '$id'");
mysql_query("UPDATE `resurs` SET `food` = food-'$p_f' WHERE u_id = '$id'");
#####################################
echo 'Рабочие употребили '.$p_f.' еды<br>';
} elseif ($p_f > $food)
{
$p = mysql_fetch_array(mysql_query("SELECT * FROM `people` WHERE `u_id` = '$id'"));
$workers = strip_tags($p['workers']);
$lesorubi = strip_tags($p['lesorubi']);
/*
делаем так
сколько не хватило = всего для окормления еды минус сколько есть
$kr_min =
*/
$n = $p_f - $food;
$all_min = $n/2;
$all_max = $n*2;
$all_max = $all_max/2;
$n_w = rand($all_min,$all_max);
$l_w = rand($all_min,$all_max);
/*
####################
$min_w = $workers/1.5;
$min_w = round($min_w);
$max_w = $workers/1.8;
$max_w = round($max_w);
$n_w = rand($min_w,$max_w);
####################
#####################
$min_l = $lesorubi/1.4;
$min_l = round($min_l);
$max_l = $lesorubi/1.6;
$max_l = round($max_l);
$n_l = rand($min_l,$max_l);
#####################
*/
#################################
$s = mysql_fetch_array(mysql_query("SELECT * FROM `serv_set` WHERE name = 'fanland'"));
$d_time = $s['d_time'];
#################################
$t = 60*60*10*$d_time;
$tim = $time+$t;
############# Записываем в базу ############
mysql_query("UPDATE `nalog` SET `eda` = '$tim' WHERE `u_id` = '$id'");
mysql_query("UPDATE `resurs` SET `food` = food-'$food' WHERE u_id = '$id'");
mysql_query("UPDATE `people` SET `workers` = workers-'$n_w', `lesorubi` = lesorubi-'$n_l' WHERE u_id = '$id'");
#####################################
echo 'У вас не хватило прокормить людей едой, поэтому у вас умерло '.$n_w.' крестьян и '.$n_l.' лесорубов!<br/>';
}
}
if ($f_time <= $time || $dr_time <= $time)
{
echo '</div></div>';
}
?>