Файл: gonki.us/taxi.php
Строк: 313
<?php
require_once('system/incfiles/core.php');
if(empty($user)) header('Location: /auth.php');
if(isset($_POST['kassa']) and is_numeric($_POST['money']) or is_numeric($_POST['dollars'])){
if($user['money'] < $_POST['money']) $err .= '<div class="error">Недостачно монет!</div>';
if($user['dollars'] < $_POST['dollars']) $err .= '<div class="error">Недостачно баксов!</div>';
if($_POST['money'] == 0 && $_POST['dollars'] == 0){
header('Location: ?act=kassa&id='.$_GET['id']);
exit;
}
if(empty($err)){
$db->query('UPDATE `taxi` SET `money` = `money` + '.$_POST['money'].', `dollars` = `dollars` + '.$_POST['dollars'].' WHERE `id` = "'.$_GET['id'].'"');
$db->query('UPDATE `user` SET `money` = `money` - '.$_POST['money'].', `dollars` = `dollars` - '.$_POST['dollars'].' WHERE `id` = "'.$user['id'].'"');
$db->query('INSERT INTO `taxi_kassa` SET `money` = "'.$_POST['money'].'", `dollars` = "'.$_POST['dollars'].'", `us` = "'.$user['id'].'", `taxi` = "'.$_GET['id'].'", `time` = "'.$time.'"');
header('Location: ?act=kassa&id='.$_GET['id']);
}
}
if(isset($_GET['vyruchka'])){
$go = $db->query('SELECT * FROM `taxi_go` WHERE `us` = "'.$user['id'].'" ORDER BY `id` DESC LIMIT 1')->fetch_array();
if($go['status'] == 0) header('Location: ?act=taksovat&id='.$_GET['id']);
$db->query('UPDATE `taxi_go` SET `status` = "0" WHERE `id` = "'.$go['id'].'"');
$db->query('UPDATE `user` SET `money` = `money` + "'.$go['money'].'", `dollars` = `dollars` + "'.$go['dollars'].'" WHERE `id` = "'.$go['us'].'"');
header('Location: ?act=taksovat&id='.$_GET['id']);
}
if(!empty($_POST['text'])){
$db->query("INSERT INTO `taxi_chat` SET `text` = '$_POST[text]', `us` = '$user[id]', `time` = '$time', `taxi` = '$_GET[id]'");
header('Location: #');
}
if(isset($_POST['newtaxi']) && !empty($_POST['newname'])){
if($ustaxi != NULL) $err .= '<div class="error">Вы уже состоите в такси!</div>';
if($user['dollars'] < 100) $err .= '<div class="error">Недостачно баксов для создания такси!</div>';
if(empty($err)){
$db->query('INSERT INTO `user` SET `dollars` = `dollars` - 100 WHERE `id` = "'.$user['id'].'"');
$db->query('INSERT INTO `taxi` SET `name` = "'.$_POST['newname'].'", `us` = "'.$user['id'].'", `dollars` = "100"');
$taxid = $db->insert_id;
$db->query('INSERT INTO `taxi_us` SET `us` = "'.$user['id'].'", `taxi` = "'.$taxid.'", `status` = "1"');
header('Location: ?act=view&id='.$taxid);
}
}
if(isset($_GET['2chasa'])){
if($db->query('SELECT * FROM `taxi_go` WHERE `us` = "'.$user['id'].'" AND `time` > '.$time.'')->num_rows != 0) $err .= '<div class="error"></div>';
if(empty($err)){
$db->query('INSERT INTO `taxi_go` SET `us` = "'.$user['id'].'", `taxi` = "'.$_GET['id'].'", `time` = "'.($time+(60*60*2)).'", `money` = "1000", `dollars` = "0"');
header('Location: ?act=taksovat&id='.$_GET['id']);
}
}
if(isset($_GET['4chasa'])){
if($db->query('SELECT * FROM `taxi_go` WHERE `us` = "'.$user['id'].'" AND `time` > '.$time.'')->num_rows != 0) $err .= '<div class="error">Вы уже таксуете!</div>';
if(empty($err)){
$db->query('INSERT INTO `taxi_go` SET `us` = "'.$user['id'].'", `taxi` = "'.$_GET['id'].'", `time` = "'.($time+(60*60*4)).'", `money` = "100", `dollars` = "1"');
header('Location: ?act=taksovat&id='.$_GET['id']);
}
}
if(isset($_GET['8chasa'])){
if($db->query('SELECT * FROM `taxi_go` WHERE `us` = "'.$user['id'].'" AND `time` > '.$time.'')->num_rows != 0) $err .= '<div class="error">Вы уже таксуете!</div>';
if(empty($err)){
$db->query('INSERT INTO `taxi_go` SET `us` = "'.$user['id'].'", `taxi` = "'.$_GET['id'].'", `time` = "'.($time+(60*60*8)).'", `money` = "1000", `dollars` = "2"');
header('Location: ?act=taksovat&id='.$_GET['id']);
}
}
if(isset($_GET['24chasa'])){
if($db->query('SELECT * FROM `taxi_go` WHERE `us` = "'.$user['id'].'" AND `time` > '.$time.'')->num_rows != 0) $err .= '<div class="error">Вы уже таксуете!</div>';
if(empty($err)){
$db->query('INSERT INTO `taxi_go` SET `us` = "'.$user['id'].'", `taxi` = "'.$_GET['id'].'", `time` = "'.($time+(60*60*24)).'", `money` = "1000", `dollars` = "5"');
header('Location: ?act=taksovat&id='.$_GET['id']);
}
}
$title = $copy.': Такси';
require_once(ROOT.'system/incfiles/header.php');
if(isset($err)) echo $err;
switch($_GET['act']){
default:
echo '<div class="razd5">Список такси</div>
<div class="menu_j"><a class="top_menu_j" href="?act=new"><span style="float:right"><img src="/system/design/ico/dollars.png" alt=""/> <font color="darkgreen">100</font></span>Создать базу</a></div>';
$count = $db->query('SELECT * FROM `taxi`')->num_rows;
$n = new navigator($count, '10');
$q = 'SELECT * FROM `taxi` '.$n->limit;
$query = $db->query($q);
echo $n->back();
while($post = $query->fetch_array()){
echo '<div class="menu_j"><a class="top_menu_j" href="?act=view&id='.$post['id'].'">'.$post['name'].'</a></div>';
}
echo $n->next();
break;
case 'new':
echo '<div class="razd5">Новое такси</div>
<div class="razd4"><center><form method="post">Название:<br /><input type="text" name="newname" /><br /><input type="submit" name="newtaxi" value="Go!"/></form></center></div>';
break;
case 'view':
$id = intval($_GET['id']);
$taxi = $db->query('SELECT * FROM `taxi` WHERE `id` = "'.$id.'"')->fetch_array();
if($taxi['name'] == NULL){
echo '<div class="error">Такси с данным ID не существует!</div>';
require_once(ROOT.'system/incfiles/footer.php');
exit;
}
echo '<div class="taxi-header">'.$taxi['name'].'</div>
<div class="razd4">
<span style="float:right"><img src="/system/design/ico/ava.png" alt=""/></span>
<b>Основатель:</b> '.user($taxi['us']).'<br />
<b>Бонус:</b> <img src="/system/design/ico/ls.png" alt=""/> <font color="darkorange">'.$taxi['bonus'].'л.с.</font><br />
<b>В кассе:</b> <img src="/system/design/ico/money.png" alt=""/> '.$taxi['money'].' <img src="/system/design/ico/dollars.png" alt=""/> <font color="darkgreen">'.$taxi['dollars'].'</font></div>';
if($taxi['id'] == $ustaxi['taxi']){
echo '<table style="width:100%" cellspacing="0" cellpadding="0"><tr><td><center><div class="menu_j"><a href="?act=kassa&id='.$id.'" class="top_menu_j"><img src="/system/design/ico/cassa.png" alt="" style="width:24px; height:24px;"/><br />Касса</a></div></center></td>
<td><center><div class="menu_j"><a href="?act=taksovat&id='.$id.'" class="top_menu_j"><img src="/system/design/ico/work.png" alt="" style="width:24px; height:24px;"/><br />Таксовать';
if($db->query('SELECT * FROM `taxi_go` WHERE `us` = "'.$user['id'].'" AND `status` = "1" AND `time` < '.$time.'')->num_rows != 0) echo ' (<b>!</b>)';
echo '</a></div></center></td>
<td><center><div class="menu_j"><a href="?act=aktivnost&id='.$id.'" class="top_menu_j"><img src="/system/design/ico/zadan.png" alt="" style="width:24px; height:24px;"/><br />Активность</a></div></center></td>
<td><center><div class="menu_j"><a href="/taxi.php" class="top_menu_j"><img src="/system/design/ico/concurents.png" alt="" style="width:24px; height:24px;"/><br />Конкуренты</a></div></center></td>
</tr></table>';
}
echo '<div class="menu_j">';
if($taxi['id'] == $ustaxi['taxi']) echo '<a class="top_menu_j" href="?act=chat&id='.$id.'"><span style="float:right">'.$db->query('SELECT * FROM `taxi_chat` WHERE `taxi` = "'.$id.'"')->num_rows.'</span>Чат</a>';
echo '<a class="top_menu_j" href="?act=rabotniki&id='.$id.'"><span style="float:right">'.$db->query('SELECT * FROM `taxi_us` WHERE `taxi` = "'.$id.'" AND `status` = "1"')->num_rows.'</span>Работники</a>';
if($taxi['us'] == $user['id']) echo '<a class="top_menu_j" href="?act=zayvki&'.$id.'"><span style="float:right">'.$db->query('SELECT * FROM `taxi_us` WHERE `taxi` = "'.$id.'" AND `status` = "0"')->num_rows.'</span>Заявки</a>';
echo '</div>';
if($taxi['us'] != $user['id']){
if($db->query('SELECT * FROM `taxi_us` WHERE `taxi` = "'.$id.'" AND `us` = "'.$user['id'].'"')->num_rows == 0) echo '<div class="menu_j"><a class="top_menu_j" href="?vstupit='.$id.'">Вступить в такси</a></div>';
else echo '<div class="menu_j"><a class="top_menu_j" href="?uvolitsya='.$id.'">Уволиться из такси</a></div>';
}
break;
case 'rabotniki':
$id = intval($_GET['id']);
$taxi = $db->query('SELECT `name`, `id` FROM `taxi` WHERE `id` = "'.$id.'"')->fetch_array();
echo '<div class="razd5">Работники <a href="?act=view&id='.$id.'">'.$taxi['name'].'</a></div>';
if($taxi['name'] == NULL){
echo '<div class="error">Такси с данным ID не существует!</div>';
require_once(ROOT.'system/incfiles/footer.php');
exit;
}
$count = $db->query('SELECT * FROM `taxi_us` WHERE `taxi` = "'.$id.'" AND `status` = "1"')->num_rows;
$n = new navigator('?act=rabotniki&id='.$id.'&', $count, '10');
$q = 'SELECT * FROM `taxi_us` WHERE `taxi` = "'.$id.'" AND `status` = "1" '.$n->limit;
$query = $db->query($q);
echo $n->back();
while($post = $query->fetch_array()){
$us = $db->query('SELECT `id`, `ls`, `auto` FROM `user` WHERE `id` = "'.$post['us'].'"')->fetch_array();
$aut = $db->query('SELECT * FROM `my_auto` WHERE `id` = "'.$us['auto'].'"')->fetch_array();
echo '<div class="menu_j"><a class="top_menu_j" href="/gonki.php?gonshik='.$post['us'].'"><span style="float:right">'.user($post['us']).'<br /><img src="/system/design/ico/ls.png" alt=""/> <font color="darkorange">'.($aut['ls']+$us['ls']).'л.с. </font></span><img src="'.$aut['img'].'" alt="" style="width:100px"/><br /><img src="'.$aut['neon'].'" alt="" style="width:100px; margin-top:-17px;"/></a></div>';
}
echo $n->next();
break;
case 'kassa':
$id = intval($_GET['id']);
$taxi = $db->query('SELECT `id`, `name` FROM `taxi` WHERE `id` = "'.$id.'"')->fetch_array();
echo '<div class="razd5">Касса <a href="?act=view&id='.$id.'">'.$taxi['name'].'</a></div>';
if($taxi['name'] == NULL){
echo '<div class="error">Такси с данным ID не существует!</div>';
require_once(ROOT.'system/incfiles/footer.php');
exit;
}
if($taxi['id'] != $ustaxi['taxi']){
echo '<div class="error">Вы не состоите в такси!</div>';
require_once(ROOT.'system/incfiles/footer.php');
exit;
}
echo '<div class="razd4"><center><form method="post">
Монет:<br /><input type="text" name="money" value="0"><br />
Доллары:<br /><input type="text" name="dollars" value="0"><br />
<br /><input type="submit" name="kassa" value="Go!" /></form></center></div>';
$count = $db->query('SELECT * FROM `taxi_kassa` WHERE `taxi` = "'.$id.'"')->num_rows;
$n = new navigator('?act=kassa&id='.$id.'&', $count, '10');
$q = 'SELECT * FROM `taxi_kassa` WHERE `taxi` = "'.$id.'" '.$n->limit;
$query = $db->query($q);
echo $n->back();
while($post = $query->fetch_array()){
echo '<div class="razd4"><center>'.user($post['us']).' '.ustime($post['time']).'<br /><img src="/system/design/ico/money.png" alt=""/> <font color="white">'.$post['money'].'</font> <img src="/system/design/ico/dollars.png" alt=""/> <font color="darkgreen">'.$post['dollars'].'</font><hr /></center></div>';
}
echo $n->next();
break;
case 'taksovat':
$id = intval($_GET['id']);
$taxi = $db->query('SELECT `id`, `name` FROM `taxi` WHERE `id` = "'.$id.'"')->fetch_array();
echo '<div class="razd5">Таксовать <a href="?act=view&id='.$id.'">'.$taxi['name'].'</a></div>';
if($taxi['name'] == NULL){
echo '<div class="error">Такси с данным ID не существует!</div>';
require_once(ROOT.'system/incfiles/footer.php');
exit;
}
if($taxi['id'] != $ustaxi['taxi']){
echo '<div class="error">Вы не состоите в такси!</div>';
require_once(ROOT.'system/incfiles/footer.php');
exit;
}
$go = $db->query('SELECT * FROM `taxi_go` WHERE `us` = "'.$user['id'].'" ORDER BY `id` DESC LIMIT 1')->fetch_array();
if($go['status'] == 0){
echo '<div class="menu_j">
<a class="top_menu_j" href="?2chasa&id='.$id.'"><span style="float:right"><img src="/system/design/ico/money.png" alt=""/> <font color="white">1000</font></span>2 часа</a>
<a class="top_menu_j" href="?4chasa&id='.$id.'"><span style="float:right"><img src="/system/design/ico/money.png" alt=""/> <font color="white">100</font> <img src="/system/design/ico/dollars.png" alt=""/> <font color="darkgreen">1</font></span>4 часа</a>
<a class="top_menu_j" href="?8chasa&id='.$id.'"><span style="float:right"><img src="/system/design/ico/money.png" alt=""/> <font color="white">1000</font> <img src="/system/design/ico/dollars.png" alt=""/> <font color="darkgreen">2</font></span>8 часа</a>
<a class="top_menu_j" href="?24chasa&id='.$id.'"><span style="float:right"><img src="/system/design/ico/money.png" alt=""/> <font color="white">1000</font> <img src="/system/design/ico/dollars.png" alt=""/> <font color="darkgreen">5</font></span>24 часа</a>
</div>';
}else{
if($go['time'] > $time){
echo '<div class="ok">Приходите за выручкой '.ustime($go['time']).'</div>';
}else{
echo '<div class="menu_j"><a class="top_menu_j" href="?vyruchka&id='.$id.'">Забрать выручку</a></div>';
}
}
break;
case 'chat':
$id = intval($_GET['id']);
$taxi = $db->query('SELECT `id`, `name` FROM `taxi` WHERE `id` = "'.$id.'"')->fetch_array();
echo '<div class="razd5">Чат такси <a href="?act=view&id='.$id.'">'.$taxi['name'].'</a></div>';
if($taxi['name'] == NULL){
echo '<div class="error">Такси с данным ID не существует!</div>';
require_once(ROOT.'system/incfiles/footer.php');
exit;
}
if($taxi['id'] != $ustaxi['taxi']){
echo '<div class="error">Вы не состоите в такси!</div>';
require_once(ROOT.'system/incfiles/footer.php');
exit;
}
echo '
<div class="razd4"><center><form method="post">Сообщение:<br /><textarea name="text"></textarea><br /><input type="submit" name="msg" value="Go!" /></form></center></div>';
$count = $db->query('SELECT * FROM `taxi_chat` WHERE `taxi` = "'.$id.'"')->num_rows;
$n = new navigator('?act=chat&id='.$id.'&', $count, '10');
$q = 'SELECT * FROM `taxi_chat` WHERE `taxi` = "'.$id.'" ORDER BY `time` DESC '.$n->limit;
$query = $db->query($q);
echo $n->back();
while($post = $query->fetch_array()){
echo '<div class="menu_j"><a href="?act=otvet&id='.$post['id'].'" class="top_menu_j">'.user($post['us']).' ('.ustime($post['time']).')<br />
'.$post['text'].'</a></div>';
}
echo $n->next();
break;
}
require_once(ROOT.'system/incfiles/footer.php');
?>