break;
            } else {
                $return_codes[] = 1055;
                break;
            }
        } else {
            $return_codes[] = 1154;
            break;
        }
    } elseif (isset($_REQUEST['btn_delete_x'])) {
        if (set_user_field($user_id, $_REQUEST['group'], $_REQUEST['key'], null)) {
            $return_codes[] = 1047;
            break;
        } else {
            $return_codes[] = 1154;
            break;
        }
        break;
    } elseif (isset($_REQUEST['btn_add_x'])) {
        if (set_user_field($user_id, $_REQUEST['group'], $_REQUEST['key'], $_REQUEST['value'])) {
            $return_codes[] = 1049;
            break;
        } else {
            $return_codes[] = 1155;
            break;
        }
    } else {
        $return_codes[] = 1068;
        break;
    }
} while (false);
        error_log(__FILE__ . '::' . __LINE__ . " Prepare failed: (" . $db_user->get_db()->errno . ") " . $db_user->get_db()->error);
        $return_codes[] = 1006;
        break;
    }
    $st->bind_param("ssssi", $username, $hashed_password, $salt, $session_id, $time);
    if (!$st->execute()) {
        $return_codes[] = 1006;
        error_log(__FILE__ . '::' . __LINE__ . " Query execution failed: (" . $st->errno . ") " . $st->error);
        break;
    }
    $id = $db_user->last_insert_id('users');
    if ($id > 0) {
        // Successfully signed up a user.
        $_SESSION['uid'] = $id;
        $_SESSION['form_id'] = substr(hash('sha256', microtime() . $id . $_SERVER["HTTP_USER_AGENT"]), 16, 32);
    } else {
        $return_codes[] = '1006';
        error_log(__FILE__ . '::' . __LINE__ . " Failed to get last insert id after successful insertion. (" . $db_user->get_db()->errno . ") " . $db_user->get_db()->error);
        // TODO: Better way to deal with this situation.
        break;
    }
    $return_page = 'viewport';
    if (strtolower(SIGNUP_ADMIN) == $username) {
        if (set_user_field($id, 'admin', 'admin', '1') && set_user_field($id, 'admin', 'users', '1')) {
            $return_page = 'admin';
        } else {
            $return_codes[] = 1179;
        }
    }
} while (false);
session_write_close();
Esempio n. 3
0
 public function update_avatar()
 {
     if (!is_login()) {
         return $this->un_login();
     }
     $uid = get_session_uid();
     $this->load->helper('upload');
     $save_result = save_avatar($this, $uid);
     if (is_ok_result($save_result)) {
         $avatar = $save_result['data'];
         // 新的头像地址
         $update_result = $this->user_model->update_by_id($uid, array('avatar' => $avatar));
         if (!$update_result) {
             log_message('error', 'update_avatar db failed');
             // 删除文件,因为并没有更新成功
             delete_avatar($avatar);
             return $this->ex(90303);
         } else {
             delete_old_avatar($this, $avatar);
             // 删除老的头像文件
             set_user_field('avatar', $avatar);
             // 更新session
             return $this->ok($avatar);
         }
     } else {
         return $this->ex(90302);
     }
 }
        die;
    }
}
$return_page = 'admin';
$return_vars['page'] = 'system';
if (!get_user_field(USER_ID, 'admin', 'system')) {
    header('Location: viewport.php?rc=1030');
    die;
}
do {
    /* Dummy loop for "break" support. */
    $seed = PAGE_START_TIME;
    if (isset($_REQUEST['seed']) && is_numeric($_REQUEST['seed'])) {
        $seed = $_REQUEST['seed'];
    }
    set_user_field(USER_ID, 'admin', 'system_seed', $seed);
    $db = isset($db) ? $db : new DB();
    if (!($st = $db->get_db()->prepare("update players set alliance = null where record_id > 0"))) {
        error_log(__FILE__ . '::' . __LINE__ . " Prepare failed: (" . $db->get_db()->errno . ") " . $db->get_db()->error);
        $return_codes[] = 1006;
        break;
    }
    if (!$st->execute()) {
        $return_codes[] = 1006;
        error_log(__FILE__ . '::' . __LINE__ . " Query execution failed: (" . $st->errno . ") " . $st->error);
        break;
    }
    $tables = array('user_players', 'alliance_invitations', 'messages', 'port_goods', 'dealer_inventory', 'places', 'ordnance', 'systems', 'player_cargo', 'player_log', 'alliances', 'bases', 'players', 'warps', 'port_goods');
    foreach ($tables as $table) {
        if (!($st = $db->get_db()->prepare("delete from `{$table}`"))) {
            error_log(__FILE__ . '::' . __LINE__ . " Prepare failed: (" . $db->get_db()->errno . ") " . $db->get_db()->error);