Exemple #1
0
$this_city = new city($_REQUEST['city_id']);
$is_owner = $LOGIN_DATA['user_id'] == $this_city->getValue('user')->getValue('userid');
$can_edit = $this_city->getValue('user_' . $LOGIN_DATA['user_id'] . '_edit');
$can_edit = $can_edit === true || intval($can_edit) > time();
if ($can_edit !== true && intval($can_edit) > time()) {
    $can_edit_time = ceil(($can_edit - time()) / 60);
}
$can_access = $this_city->getValue('user_' . $LOGIN_DATA['user_id'] . '_access');
if ($can_access !== true && intval($can_access) > time()) {
    $can_access_time = ceil(($can_access - time()) / 60);
}
$can_access = $can_access === true || intval($can_access) > time();
//if(!$can_access) die('<head><title>Cannot View City</title></head><body><h2>You cannot view this city.</h2></body></html>');
$server = new server($_REQUEST['server_id']);
if ($can_edit && $_POST['building_id']) {
    $message = $this_city->build(intval($_POST['building_id']));
    if ($message) {
        $message = '<b style="padding:3px;border:1px solid red;display:block;"><img src="/images/error.png" alt="" /> ' . htmlentities($message) . '</b>';
    } else {
        $message = '<div style="padding:3px;border:1px solid #ccc;display:block;"><img src="/images/information.png" alt="" /> Building started.</div>';
    }
    if (isset($_REQUEST['ajax'])) {
        exit($message);
    }
}
//end if POST building_id
if ($can_edit && $_POST['unit_id']) {
    $message = $this_city->create_units(intval($_POST['unit_id']), intval($_POST['unit_count']));
    if ($message) {
        $message = '<b style="padding:3px;border:1px solid red;display:block;"><img src="/images/error.png" alt="" /> ' . htmlentities($message) . '</b>';
    } else {