Файл: titwar.ru/farm.php
Строк: 53
<?
include './system/common.php';
include './system/functions.php';
include './system/user.php';
if(!$user) {
header('location: /');
exit;
}
$title = 'Farm';
include './system/h.php';
$farm = mysql_query('SELECT * FROM `farm` WHERE `user` = "'.$user['id'].'"');
$farm = mysql_fetch_array($farm);
if(!$farm) {
mysql_query('INSERT INTO `farm` (`user`) VALUES ("'.$user['id'].'")');
}
?>
<div class='line'></div>
<?
if($user['level'] > 2) {
?>
<div class='menu'>
<li align='center'><img src='/images/town/farm.png' alt='*'/></li>
<li class='no_b' align='center'>
<?
if($farm['h'] == 0 && $farm['time'] == 0) {
$h = _string(_num($_POST['h']));
if($h && $user['level'] >= $h * 3) {
$hs = ($h * (60 * 60));
mysql_query('UPDATE `farm` SET `h` = "'.$h.'", `time` = "'.(time() + $hs).'" WHERE `user` = "'.$user['id'].'"');
header('location: /farm.php');
}
?>
<font color='#90b0c0'>Here you can find silver!</font><br/>
<form action='/farm.php' method='post'>
<select name='h'>
<?
for($h = 1; $h < 6; $h++) {
if($user['level'] >= $h * 3) {
?>
<option value='<?=$h?>'><?=$h?> hour<?=($h == 1 ? '':($h == 5 ? 'ов':'а'))?></option>
<?
}
}
?>
</select><br/>
<input type='submit' value='Go there'/>
</form>
<?
}
else
{
if($farm['time'] > time()) {
if($_GET['end'] == true) {
mysql_query('UPDATE `farm` SET `h` = "0",
`time` = "0" WHERE `user` = "'.$user['id'].'"');
header('location: /farm/');
}
?>
<font color='#90b0c0'>You go to farm!</font><br/>
Time left: <?=_time($farm['time'] - time())?><br/><br/>
<a href='/farm/?end=true' class='button'>Cancel</a>
<?
}
else
{
mysql_query('UPDATE `users` SET `s` = `s` + '.($farm['h'] * 1000).' WHERE `id` = "'.$user['id'].'"');
mysql_query('UPDATE `farm` SET `h` = "0",
`time` = "0" WHERE `user` = "'.$user['id'].'"');
?>
<font color='#90b0c0'>You get back from farm!</font><br/>
You found: <img src='/images/icon/silver.png' alt='*'/> <?=n_f($farm['h'] * 1000)?> silver<br/><br/>
<a href='/farm/' class='button'>Refresh</a>
<?
}
}
?>
</li>
</div>
<?
}
else
{
?>
<div class='content' align='center'>
<img src='/images/icon/farm.png' alt='*'/> Farm is available if <img src='/images/icon/level.png' alt='*'/> your level is 3<br/>
</div>
<?
}
include './system/f.php';
?>