Файл: gonki.us/taxi_engine.php
Строк: 260
<?php
require_once('system/incfiles/core.php');
if(empty($user)) header('Location: /auth.php');
if(isset($_GET['goengine'])){
if($db->query("SELECT * FROM `engine` WHERE `us` = '$user[auto]' AND `status` = '0'")->num_rows > 0){
header('Location: /engine.php');
exit;
}
$db->query('UPDATE `user` SET `money` = `money` - 100 WHERE `id` = "'.$user['id'].'"');
$db->query('UPDATE `my_auto` SET `ls` = `ls` + 10 WHERE `id` = "'.$user['auto'].'"');
$db->query('INSERT INTO `engine` SET `ls` = "15", `money` = "125", `us` = "'.$user['auto'].'", `status` = "0"');
header('Location: /engine.php');
}
if(isset($_GET['engine'])){
if($db->query("SELECT * FROM `engine` WHERE `us` = '$user[auto]' AND `status` = '1'")->num_rows >= 10){
header('Location: /engine.php');
exit;
}
$id = intval($_GET['engine']);
$engine = $db->query("SELECT * FROM `engine` WHERE `id` = '$id' LIMIT 1")->fetch_array();
if(empty($engine['id']) or $engine['status'] == 1){
header('Location: /engine.php');
exit;
}
if($user['money'] < $engine['money']) $err .= '<div class="error">Недостаточно монет!</div>';
if($user['dollars'] < $engine['dollars']) $err .= '<div class="error">Недостаточно баксов!</div>';
if(empty($err)){
$db->query('UPDATE `user` SET `money` = `money` - '.$engine['money'].', `dollars` = `dollars` - '.$engine['dollars'].' WHERE `id` = "'.$user['id'].'"');
$db->query('UPDATE `my_auto` SET `ls` = `ls` + '.$engine['ls'].' WHERE `id` = "'.$user['auto'].'"');
$db->query('UPDATE `engine` SET `status` = "1" WHERE `id` = "'.$engine['id'].'"');
$db->query('INSERT INTO `engine` SET `ls` = "'.($engine['ls']+10).'", `money` = "'.($engine['money']+100).'", `dollars` = "'.($engine['dollars']+1).'", `us` = "'.$user['auto'].'", `status` = "0"');
header('Location: /engine.php');
}
}
if(isset($_GET['gotrans'])){
if($db->query("SELECT * FROM `trans` WHERE `us` = '$user[auto]' AND `status` = '0'")->num_rows > 0){
header('Location: /engine.php');
exit;
}
$db->query('UPDATE `user` SET `money` = `money` - 100 WHERE `id` = "'.$user['id'].'"');
$db->query('UPDATE `my_auto` SET `ls` = `ls` + 10 WHERE `id` = "'.$user['auto'].'"');
$db->query('INSERT INTO `trans` SET `ls` = "15", `money` = "125", `us` = "'.$user['auto'].'", `status` = "0"');
header('Location: /engine.php');
}
if(isset($_GET['trans'])){
if($db->query("SELECT * FROM `trans` WHERE `us` = '$user[auto]' AND `status` = '1'")->num_rows >= 10){
header('Location: /engine.php');
exit;
}
$id = intval($_GET['trans']);
$trans = $db->query("SELECT * FROM `trans` WHERE `id` = '$id' LIMIT 1")->fetch_array();
if(empty($trans['id']) or $trans['status'] == 1){
header('Location: /engine.php');
exit;
}
if($user['money'] < $trans['money']) $err .= '<div class="error">Недостаточно монет!</div>';
if($user['dollars'] < $trans['dollars']) $err .= '<div class="error">Недостаточно баксов!</div>';
if(empty($err)){
$db->query('UPDATE `user` SET `money` = `money` - '.$trans['money'].', `dollars` = `dollars` - '.$trans['dollars'].' WHERE `id` = "'.$user['id'].'"');
$db->query('UPDATE `my_auto` SET `ls` = `ls` + '.$trans['ls'].' WHERE `id` = "'.$user['auto'].'"');
$db->query('UPDATE `trans` SET `status` = "1" WHERE `id` = "'.$trans['id'].'"');
$db->query('INSERT INTO `trans` SET `ls` = "'.($trans['ls']+10).'", `money` = "'.($trans['money']+100).'", `dollars` = "'.($trans['dollars']+1).'", `us` = "'.$user['auto'].'", `status` = "0"');
header('Location: /engine.php');
}
}
$title = $copy.': Улучшения';
require_once(ROOT.'system/incfiles/header.php');
echo '<div class="razd5">Улучшения</div>';
if($user['lvl'] < 1){
echo '<div class="error">Для доступа к улучшениям вам необходимо достичь 1 уровень!</div>';
require_once(ROOT.'system/incfiles/footer.php');
exit;
}
if($db->query("SELECT * FROM `engine` WHERE `us` = '$user[auto]' AND `status` = '0'")->num_rows == 0){
echo '<div class="menu_j"><a class="top_menu_j" href="?goengine"><span style="float:right"><img src="/system/design/ico/ls.png" alt=""/> <font color="darkorange">10л.с.</font><br /><img src="/system/design/ico/money.png" alt=""/> <font color="white">100</font></span><img src="/system/design/ico/porshen.png" alt=""/> Поршни</a></div>';
}
if($db->query("SELECT * FROM `engine` WHERE `us` = '$user[auto]' AND `status` = '0'")->num_rows > 0 && $db->query("SELECT * FROM `engine` WHERE `us` = '$user[auto]' AND `status` = '1'")->num_rows < 10){
$engine = $db->query("SELECT * FROM `engine` WHERE `us` = '$user[auto]' AND `status` = '0' ORDER BY `id` DESC LIMIT 1")->fetch_array();
echo '<div class="menu_j"><a class="top_menu_j" href="?engine='.$engine['id'].'"><span style="float:right"><img src="/system/design/ico/ls.png" alt=""/> <font color="darkorange">'.$engine['ls'].'л.с.</font><br />';
if($engine['money'] > 0) echo '<img src="/system/design/ico/money.png" alt=""/> <font color="white">'.$engine['money'].'</font>';
if($engine['dollars'] > 0) echo '<br /><img src="/system/design/ico/dollars.png" alt=""/> <font color="darkgreen">'.$engine['dollars'].'</font>';
echo '</span><img src="/system/design/ico/porshen.png" alt=""/> Поршни</a></div>';
}
if($db->query("SELECT * FROM `trans` WHERE `us` = '$user[auto]' AND `status` = '0'")->num_rows == 0){
echo '<div class="menu_j"><a class="top_menu_j" href="?gotrans"><span style="float:right"><img src="/system/design/ico/ls.png" alt=""/> <font color="darkorange">10л.с.</font><br /><img src="/system/design/ico/money.png" alt=""/> <font color="white">100</font></span><img src="/system/design/ico/trans.png" alt=""/> Трансмиссия</a></div>';
}
if($db->query("SELECT * FROM `trans` WHERE `us` = '$user[auto]' AND `status` = '0'")->num_rows > 0 && $db->query("SELECT * FROM `trans` WHERE `us` = '$user[auto]' AND `status` = '1'")->num_rows < 10){
$trans = $db->query("SELECT * FROM `trans` WHERE `us` = '$user[auto]' AND `status` = '0' ORDER BY `id` DESC LIMIT 1")->fetch_array();
echo '<div class="menu_j"><a class="top_menu_j" href="?trans='.$trans['id'].'"><span style="float:right"><img src="/system/design/ico/ls.png" alt=""/> <font color="darkorange">'.$trans['ls'].'л.с.</font><br />';
if($trans['money'] > 0) echo '<img src="/system/design/ico/money.png" alt=""/> <font color="white">'.$trans['money'].'</font>';
if($trans['dollars'] > 0) echo '<br /><img src="/system/design/ico/dollars.png" alt=""/> <font color="darkgreen">'.$trans['dollars'].'</font>';
echo '</span><img src="/system/design/ico/trans.png" alt=""/> Трансмиссия</a></div>';
}
if($db->query("SELECT * FROM `trans` WHERE `us` = '$user[auto]' AND `status` = '1'")->num_rows >= 10 && $db->query("SELECT * FROM `trans` WHERE `us` = '$user[auto]' AND `status` = '1'")->num_rows >= 10){
echo '<div class="error">Ваша машина прокачана!</div>';
}
require_once(ROOT.'system/incfiles/footer.php');
?>