Beispiel #1
0
if (!defined('MMRPG_INDEX_SESSION') && !defined('MMRPG_INDEX_STYLES')) {
    // If this user is a member, collect background and type settings from the account
    if (rpg_user::is_member()) {
        // Collect theme settings from the user's profile settings
        $temp_field_path = !empty($this_userinfo['user_background_path']) ? $this_userinfo['user_background_path'] : 'fields/intro-field';
        $temp_field_type = !empty($this_userinfo['user_colour_token']) ? $this_userinfo['user_colour_token'] : '';
    } else {
        // Define the theme timeout for auto updating
        $theme_timeout = 60 * 60 * 1;
        // 60s x 60m = 1 hr
        if (!isset($_SESSION['INDEX']['theme_cache']) || time() - $_SESSION['INDEX']['theme_cache'] > $theme_timeout) {
            // Hard code the type to none but collect a ranzomized field token
            $temp_field_info = $db->get_array("SELECT\n                field_token,\n                CONCAT('fields/', field_token) AS field_path,\n                field_type\n                FROM mmrpg_index_fields\n                WHERE field_flag_complete = 1 AND field_flag_published = 1 AND field_flag_hidden = 0 AND field_game IN ('MM01', 'MM02', 'MM03', 'MM04')\n                ORDER BY RAND() LIMIT 1\n                ;");
            $temp_field_type = 'none';
            $temp_field_path = $temp_field_info['field_path'];
            $temp_mecha_tokens = $db->get_array_list("SELECT\n                robot_token AS mecha_token\n                FROM mmrpg_index_robots\n                WHERE robot_flag_complete = 1 AND robot_flag_published = 1 AND robot_flag_hidden = 0 AND robot_class = 'mecha' AND robot_core = '{$temp_field_info['field_type']}' AND robot_game IN ('MM01', 'MM02', 'MM03', 'MM04')\n                ORDER BY RAND()\n                ;", 'mecha_token');
            $temp_mecha_tokens = array_keys($temp_mecha_tokens);
            // Update the session with these settings
            $_SESSION['INDEX']['theme_cache'] = time();
            $_SESSION['INDEX']['theme_field_path'] = $temp_field_path;
            $_SESSION['INDEX']['theme_field_type'] = $temp_field_type;
            $_SESSION['INDEX']['theme_mecha_tokens'] = $temp_mecha_tokens;
        } else {
            // Collect existing theme settings from the session
            $temp_field_path = $_SESSION['INDEX']['theme_field_path'];
            $temp_field_type = $_SESSION['INDEX']['theme_field_type'];
            $temp_mecha_tokens = $_SESSION['INDEX']['theme_mecha_tokens'];
        }
    }
    // Collect the info for the chosen temp field
    list($temp_field_kind, $temp_field_token) = explode('/', $temp_field_path);