Файл: ubiznes.mobi/inc/location/aeroport/index.php
Строк: 79
<?php
// Необходимый уровень
$null_required_level = 10;
// Количество бесплатных мест со старта
$null_places = 4;
// Время постройки аэропорта
$null_built_time = 172800;
// Максимальное кол-во самолётов
$null_max = 25;
// Максимум билетов
$null_max_ticket = 30;
// Время заправки самолёта
$null_time_refueling = 120;
// Время загрузки пасажиров
$null_time_loading = 120;
// Время посадки
$null_time_landing = 60;
// Цена постройки
$null_built_money = 500000;
// Цена ускорения
$null_speed_baks = 1000;
function aeroport_place($count) {
$count = abs($count - 4);
$price = array(
15, 25, 50, 100, 250
);
if($count < count($price))
return $price[$count];
return 500;
}
/*
* aeroport -- Сам аэропорт
* id
* id_user -- Чей аэропорт
* built -- Построено ли аэропорт (true - построено, false - чистое место)
* built_time -- Время начала стройки
*/
/*
* aircraft -- Самолёты
* id
* id_aeroport -- К какому аэропорту относится
* built -- Поставлен ли самолёт (true - построено, false - чистое место)
* takeoff -- Время взлёта
* ticket -- Количество билетов
* id_direction -- Направление полёта
*/
if($user['level'] < $null_required_level) {
require_once dirname(__FILE__) . '/no-lvl.php';
include_once'sys/foot.php';
exit();
} else {
$obj_aeroport = mysql_fetch_object(mysql_query("SELECT * FROM `aeroport` WHERE `id_user` = '" . $user['id'] . "'"));
if($obj_aeroport->id > 0) {
// Аэропорт еще не построен
if($obj_aeroport->built == false) {
// Проверяем, вдруг время постройки пришло
if($obj_aeroport->built_time + $null_built_time <= time()) {
mysql_query("UPDATE `aeroport` SET `built` = '1' WHERE `id` = '" . $obj_aeroport->id . "'");
for($i = 0; $i < $null_places; $i++) {
mysql_query("INSERT INTO `aircraft` (`id_aeroport`, `built`, `takeoff`, `ticket`, `id_direction`) VALUES ('" . $obj_aeroport->id . "', '0', '0', '0', '0')");
}
header("Location: /?aeroport=true");
exit();
} else if($obj_aeroport->built_time == 0 && $_GET['aeroport'] == 'built') {
if($user['money'] < $null_built_money) {
err_game("Недостаточно монет, не хватает " . abs($null_built_money - $user['money']) . ' <img src="/images/style/money.png" width="16" height="16">');
} else {
mysql_query("UPDATE `user` SET `money` = `money` - '" . $null_built_money . "' WHERE `id` = '" . $user['id'] . "'");
mysql_query("UPDATE `aeroport` SET `built_time` = '" . time() . "' WHERE `id` = '" . $obj_aeroport->id . "'");
header("Location: /?aeroport=true");
exit();
}
} else if($obj_aeroport->built_time != 0 && $_GET['aeroport'] == 'built_speed') {
if($user['baks'] < $null_speed_baks) {
err_game("Недостаточно баксов, не хватает " . abs($null_speed_baks - $user['baks']) . ' <img src="/images/style/b.png" width="16" height="16">');
} else {
mysql_query("UPDATE `user` SET `baks` = `baks` - '" . $null_speed_baks . "' WHERE `id` = '" . $user['id'] . "'");
mysql_query("UPDATE `aeroport` SET `built` = '1' WHERE `id` = '" . $obj_aeroport->id . "'");
for($i = 0; $i < $null_places; $i++) {
mysql_query("INSERT INTO `aircraft` (`id_aeroport`, `built`, `takeoff`, `ticket`, `id_direction`) VALUES ('" . $obj_aeroport->id . "', '0', '0', '0', '0')");
}
header("Location: /?aeroport=true");
exit();
}
}
require_once dirname(__FILE__) . '/no-built.php';
include_once'sys/foot.php';
exit();
// Аэропорт построен
} else {
$aircraft_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `aircraft` WHERE `id_aeroport` = '" . $obj_aeroport->id . "'"),0);
// Постройка нового места
if($aircraft_count < $null_max && $_GET['aeroport'] == 'newplace') {
if($user['baks'] < aeroport_place($aircraft_count)) {
err_game("Недостаточно баксов, не хватает " . abs(aeroport_place($aircraft_count) - $user['baks']) . ' <img src="/images/style/b.png" width="16" height="16">');
} else {
mysql_query("UPDATE `user` SET `baks` = `baks` - '" . aeroport_place($aircraft_count) . "' WHERE `id` = '" . $user['id'] . "'");
mysql_query("INSERT INTO `aircraft` (`id_aeroport`, `built`, `takeoff`, `ticket`, `id_direction`) VALUES ('" . $obj_aeroport->id . "', '0', '0', '0', '0')");
header("Location: /?aeroport=true");
exit();
}
}
if($_GET['aeroport'] == 'set_aircraft' && isset($_GET['id'])) {
}
$aircraft = mysql_query("SELECT * FROM `aircraft` WHERE `id_aeroport` = '" . $obj_aeroport->id . "'");
require_once dirname(__FILE__) . '/aeroport.php';
include_once'sys/foot.php';
exit();
}
} else {
mysql_query("INSERT INTO `aeroport` (`id_user`, `built`, `built_time`) VALUES ('" . $user['id'] . "', '0', '0')");
header("Location: /?aeroport=true");
}
}
/*$aeroport_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `aeroport` WHERE `id_user` = '" . $user['id'] . "'"),0);
if($aeroport_count == 0) {
}*/