public static function campaign_complete($player_token = '') { // Pull in global variables //global $mmrpg_index; $mmrpg_index_players = rpg_player::get_index(); $session_token = rpg_game::session_token(); // If the player token was provided, do a quick check if (!empty($player_token)) { // Return the prototype complete flag for this player if (!empty($_SESSION[$session_token]['flags']['prototype_events'][$player_token]['prototype_complete'])) { return 1; } else { return 0; } } else { // Loop through unlocked robots and return true if any are found to be completed $complete_count = 0; foreach ($mmrpg_index_players as $player_token => $player_info) { if (rpg_game::player_unlocked($player_token)) { if (!empty($_SESSION[$session_token]['flags']['prototype_events'][$player_token]['prototype_complete'])) { $complete_count += 1; } } } // Otherwise return false by default return $complete_count; } }
$object_multi_token = 'robots'; } // Define object class tokens for BOSSES elseif ($this_current_sub == 'bosses'){ $object_class_token = 'boss'; $object_single_token = 'boss'; $object_multi_token = 'bosses'; } // Define the object names based on tokens $object_single_name = ucfirst($object_single_token); $object_multi_name = ucfirst($object_multi_token); // Collect the various global indexes for display and looping $type_index = rpg_type::get_index(true); $player_index = rpg_player::get_index(true, true); $field_index = rpg_field::get_index(true, true); $ability_index = rpg_ability::get_index(true); // Collect the robot ID from the request header $robot_id = isset($_GET['num']) && is_numeric($_GET['num']) ? (int)($_GET['num']) : false; // Collect robot fields to pull from the database $robot_fields = rpg_robot::get_index_fields(true); // Collect robot info from the database if an ID was provided if (!empty($robot_id)){ $robot_info = $db->get_array("SELECT {$robot_fields} FROM mmrpg_index_robots WHERE robot_id = {$robot_id} AND robot_class = '{$object_class_token}';"); } // Generate new robot info given a class and the database robot template elseif ($robot_id === 0){
if ($temp_index['robot_class'] == 'master' && !empty($temp_counter_robots[$token])){ $temp_counter_database['unlocked'] += 1; } elseif ($temp_index['robot_class'] == 'mecha' && !empty($array[''])){ $temp_counter_database['unlocked'] += 1; } $temp_counter_database['encountered'] += 1; $temp_counter_database['total'] += 1; } */ } // Sort the points array for most-used asort($temp_counter_points); $temp_counter_points = array_reverse($temp_counter_points); // Sort the levels array for most-used asort($temp_counter_levels); $temp_counter_levels = array_reverse($temp_counter_levels); // Collect the most users player and most used robots $temp_player_index = rpg_player::get_index(); $temp_top_player = ''; foreach ($temp_counter_points as $token => $value) { if ($token != 'total') { $temp_top_player = '<strong>' . $temp_player_index[$token]['player_name'] . '</strong>'; break; } } $temp_top_robots = array(); // Collect the favourite robots if there are set $temp_top_robots = array(); $temp_top_robots_tokens = array(); $temp_top_robots_counter = 5; if (!empty($this_playerinfo['save_values']['robot_favourites'])) { //die('we have favourites, people!'); $temp_top_robots_method = 'favourite';
function mmrpg_leaderboard_parse_index($board_key, $board_info, $quick_parse = false) { global $mmrpg_index; global $this_cache_stamp, $this_cache_filename, $this_cache_filedir; global $this_leaderboard_count, $this_leaderboard_online_count; global $this_leaderboard_online_players, $this_leaderboard_online_pages; global $this_leaderboard_index; global $this_userid, $this_userinfo, $this_boardinfo; global $this_display_limit, $this_display_limit_default, $this_num_offset; global $this_time, $this_online_timeout, $place_counter, $points_counter, $this_start_key; // Collect this player's base info $this_stars = !empty($board_info['board_stars']) ? $board_info['board_stars'] : 0; $this_abilities = !empty($board_info['board_abilities']) ? $board_info['board_abilities'] : 0; //$this_battles = !empty($board_info['board_battles']) ? $board_info['board_battles'] : 0; $this_missions = !empty($board_info['board_missions']) ? $board_info['board_missions'] : 0; $this_awards = !empty($board_info['board_awards']) ? explode(',', $board_info['board_awards']) : array(); $this_first_save = !empty($board_info['board_date_created']) ? $board_info['board_date_created'] : 0; $this_last_save = !empty($board_info['board_date_modified']) ? $board_info['board_date_modified'] : 0; $this_last_access = !empty($board_info['user_date_accessed']) ? $board_info['user_date_accessed'] : 0; $this_is_online = !empty($this_last_access) && $this_time - $this_last_access <= $this_online_timeout ? true : false; $this_last_save = !empty($this_last_save) ? date('Y/m/d @ H:i', $this_last_save) : '????-??-?? ??:??'; $this_style = $this_is_online ? 'border-color: green; ' : ''; $this_place = rpg_website::number_suffix($place_counter, true, true); //str_pad(($place_counter), 2, '0', STR_PAD_LEFT); $this_username = !empty($board_info['user_name_public']) ? $board_info['user_name_public'] : $board_info['user_name']; $this_username = htmlentities($this_username, ENT_QUOTES, 'UTF-8', true); $this_user_id = !empty($board_info['user_id']) ? $board_info['user_id'] : 0; if ($this_userid != MMRPG_SETTINGS_GUEST_ID && $this_user_id == $_SESSION['GAME']['USER']['userid']) { $this_boardinfo['board_rank'] = $place_counter; $_SESSION['GAME']['BOARD']['boardrank'] = $this_boardinfo['board_rank']; } //die('<pre>'.print_r($this_battles, true).'</pre>'); // Define the current page this player is on $this_current_page_number = ceil($board_key / $this_display_limit_default); //echo('$board_key = '.$board_key.'; $this_display_limit_default = '.$this_display_limit_default.'; $this_current_page_number = '.$this_current_page_number); // If online, add this player to the array if ($this_is_online) { $this_leaderboard_online_count++; $this_leaderboard_online_players[] = array('id' => $this_user_id, 'name' => $this_username, 'token' => $board_info['user_name_clean'], 'place' => $this_place, 'placeint' => $place_counter, 'colour' => $board_info['user_colour_token'], 'image' => $board_info['user_image_path']); //$this_current_page_number = ceil($board_key / $this_display_limit); //echo('$board_key = '.$board_key.'; $this_display_limit = '.$this_display_limit.'; $this_current_page_number = '.$this_current_page_number); //$this_leaderboard_online_pages[] = $board_key; if (!in_array($this_current_page_number, $this_leaderboard_online_pages)) { $this_leaderboard_online_pages[] = $this_current_page_number; } } // If quick parse was requested, return now if ($quick_parse) { return ''; } // Collect the points and increment the counter if necessary $this_points = $board_info['board_points']; if ($this_points != $points_counter) { $points_counter = $this_points; } // Define the awards strong and default to empty $this_user_awards = ' '; // Break apart the battle and battle values into arrays $temp_battles = !empty($board_info['board_battles']) ? explode(',', $board_info['board_battles']) : array(); $board_info['board_battles'] = $temp_battles; // Loop through the available players $mmrpg_index_players = rpg_player::get_index(); foreach ($mmrpg_index_players as $ptoken => $pinfo) { $ptoken2 = str_replace('-', '_', $ptoken); $temp_battles = !empty($board_info['board_battles_' . $ptoken2]) ? explode(',', $board_info['board_battles_' . $ptoken2]) : array(); $board_info['board_battles_' . $ptoken2] = $temp_battles; } // Break apart the robot and battle values into arrays $temp_robots = !empty($board_info['board_robots']) ? $board_info['board_robots'] : array(); if (!empty($temp_robots)) { $temp_robots = explode(',', $temp_robots); foreach ($temp_robots as $key => $string) { list($token, $level) = explode(':', substr($string, 1, -1)); $temp_info = array('robot_token' => $token, 'robot_level' => $level); $temp_robots[$key] = $temp_info; } } $this_robots = $temp_robots; // Start the output buffer ob_start(); // Only continue if markup is special constants have not been defined if (!defined('MMRPG_SKIP_MARKUP') || defined('MMRPG_SHOW_MARKUP_' . $this_user_id)) { // Only generate markup if we're withing the viewing range if ($board_key >= $this_start_key && $board_key < $this_display_limit || defined('MMRPG_SHOW_MARKUP_' . $this_user_id)) { $this_robots_count = !empty($this_robots) ? count($this_robots) : 0; $this_robots_count = $this_robots_count == 1 ? '1 Robot' : $this_robots_count . ' Robots'; $this_stars_count = $this_stars; $this_abilities_count = $this_abilities; $this_missions_count = $this_missions; $this_stars_count = $this_stars_count == 1 ? '1 Star' : $this_stars_count . ' Stars'; $this_abilities_count = $this_abilities_count == 1 ? '1 Ability' : $this_abilities_count . ' Abilities'; $this_missions_count = $this_missions_count == 1 ? '1 Mission' : $this_missions_count . ' Missions'; //$this_points_html = preg_replace('#^([0]+)([0-9]+)$#', '<span class="padding">$1</span><span class="value">$2</span>', str_pad((!empty($this_points) ? $this_points : 0), 13, '0', STR_PAD_LEFT)).' BP'; $this_records_html = '<span class="count">' . $this_missions_count . '</span>'; $this_records_html .= ' <span class="pipe">|</span> <span class="count">' . $this_robots_count . '</span>'; $this_records_html .= ' <span class="pipe">|</span> <span class="count">' . $this_abilities_count . '</span>'; $this_records_html .= ' <span class="pipe">|</span> <span class="count">' . $this_stars_count . '</span>'; $this_points_html = '<span class="value">' . (!empty($this_points) ? number_format($this_points, 0, '.', ',') : 0) . '</span>' . ' BP'; $this_points_plain = (!empty($this_points) ? number_format($this_points, 0, '.', ',') : 0) . ' BP'; $this_details = '' . $this_last_save; // -- LEADERBOARD MARKUP -- // // Add the prototype complete flags if applicable if (count($board_info['board_battles_dr_light']) >= 17) { $this_user_awards .= '<span class="prototype_complete prototype_complete_dr-light" data-tooltip="Completed Dr. Light\'s Game" data-tooltip-type="player_type player_type_defense">♥</span>'; } if (count($board_info['board_battles_dr_wily']) >= 17) { $this_user_awards .= '<span class="prototype_complete prototype_complete_dr-wily" data-tooltip="Completed Dr. Wily\'s Game" data-tooltip-type="player_type player_type_attack">♣</span>'; } if (count($board_info['board_battles_dr_cossack']) >= 17) { $this_user_awards .= '<span class="prototype_complete prototype_complete_dr-cossack" data-tooltip="Completed Dr. Cossack\'s Game" data-tooltip-type="player_type player_type_speed">♦</span>'; } if (in_array('ranking_first_place', $this_awards)) { $this_user_awards .= '<span class="prototype_complete prototype_complete_firstplace" data-tooltip="Reached First Place" data-tooltip-type="player_type player_type_level">★</span>'; } //die('$this_awards = '.print_r($this_awards, true)); // Display the user's save file listing //echo '<a data-id="'.$board_info['user_id'].'" data-player="'.$board_info['user_name_clean'].'" class="file file_'.$this_place.'" name="file_'.$key.'" style="'.$this_style.'" title="'.$this_title.'" href="leaderboard/'.$board_info['user_name_clean'].'/">'."\n"; echo '<a data-id="' . $board_info['user_id'] . '" data-player="' . $board_info['user_name_clean'] . '" class="file file_' . strip_tags($this_place) . '" name="file_' . $key . '" style="' . $this_style . '" href="leaderboard/' . $board_info['user_name_clean'] . '/">' . "\n"; echo '<div class="inset player_type_' . (!empty($board_info['user_colour_token']) ? $board_info['user_colour_token'] : 'none') . '">' . "\n"; echo '<span class="place">' . $this_place . '</span>' . "\n"; echo '<span class="userinfo"><strong class="username">' . $this_username . $this_user_awards . '</strong><span class="details">' . $this_details . '</span></span>' . "\n"; echo '<span class="points">' . $this_points_html . '</span>' . "\n"; echo '<span class="records">' . $this_records_html . '</span>' . "\n"; echo '</div>' . "\n"; if (!empty($board_info['user_image_path'])) { list($avatar_class, $avatar_token, $avatar_size) = explode('/', $board_info['user_image_path']); } else { $avatar_class = 'robots'; $avatar_token = 'mega-man'; $avatar_size = 40; } if (!empty($board_info['user_background_path'])) { list($background_class, $background_token) = explode('/', $board_info['user_background_path']); } else { $background_class = 'fields'; $background_token = 'intro-field'; } $avatar_size = $avatar_size * 2; $avatar_path = 'images/sprites/' . $avatar_class . '/' . $avatar_token . '/sprite_left_' . $avatar_size . 'x' . $avatar_size . '.png'; $shadow_path = 'images/shadows/' . $avatar_class . '/' . preg_replace('/^([-a-z0-9]+)(_[a-z]+)?$/i', '$1', $avatar_token) . '/sprite_left_' . $avatar_size . 'x' . $avatar_size . '.png'; if (!file_exists($shadow_path)) { $shadow_path = 'images/shadows/' . $avatar_class . '/' . preg_replace('/^([-a-z0-9]+)(_[a-z0-9]+)?$/i', '$1', $avatar_token) . '/sprite_left_' . $avatar_size . 'x' . $avatar_size . '.png'; } echo '<span class="avatar"><span class="avatar_wrapper">'; echo '<span class="sprite sprite_shadow sprite_' . $avatar_size . 'x' . $avatar_size . ' sprite_shadow_' . $avatar_size . 'x' . $avatar_size . ' sprite_' . $avatar_size . 'x' . $avatar_size . '_' . ($place_counter > 3 ? 'base' : 'victory') . '" style="background-image: url(' . $shadow_path . '?' . MMRPG_CONFIG_CACHE_DATE . ');">' . $this_username . '</span>'; echo '<span class="sprite sprite_' . $avatar_size . 'x' . $avatar_size . ' sprite_' . $avatar_size . 'x' . $avatar_size . '_' . ($place_counter > 3 ? 'base' : 'victory') . '" style="background-image: url(' . $avatar_path . '?' . MMRPG_CONFIG_CACHE_DATE . ');">' . $this_username . '</span>'; echo '</span></span>' . "\n"; echo '</a>' . "\n"; } } // Collect the output into the buffer return preg_replace('/\\s+/', ' ', ob_get_clean()); }
/** * Get the formatted editor title markup for this field object given field info * @param array $field_info * @return string */ public static function print_editor_title_markup($field_info) { // Collect references to global objects $db = cms_database::get_database(); // Collect references to global indexes $mmrpg_types = rpg_type::get_index(); $mmrpg_players = rpg_player::get_index(); $mmrpg_robots = rpg_robot::get_index(); // Expand the field index info $field_token = $field_info['field_token']; $field_info = rpg_field::get_index_info($field_token); if (empty($field_info) || empty($field_info)) { return false; } // Collect the field type info and expand master/mecha data $temp_field_type = !empty($field_info['field_type']) ? $mmrpg_types[$field_info['field_type']] : false; $temp_field_type2 = !empty($field_info['field_type2']) ? $mmrpg_types[$field_info['field_type2']] : false; $temp_field_master = !empty($field_info['field_master']) ? rpg_robot::parse_index_info($mmrpg_robots[$field_info['field_master']]) : false; $temp_field_mechas = !empty($field_info['field_mechas']) ? $field_info['field_mechas'] : array(); foreach ($temp_field_mechas as $key => $token) { $temp_mecha = rpg_robot::parse_index_info($mmrpg_robots[$token]); if (!empty($temp_mecha)) { $temp_field_mechas[$key] = $temp_mecha['robot_name']; } else { unset($temp_field_mechas[$key]); } } // Generate the field title markup $temp_field_title = $field_info['field_name']; if (!empty($temp_field_type)) { $temp_field_title .= ' (' . $temp_field_type['type_name'] . ' Type)'; } if (!empty($temp_field_type2)) { $temp_field_title = str_replace('Type', '/ ' . $temp_field_type2['type_name'] . ' Type', $temp_field_title); } $temp_field_title .= ' // '; if (!empty($temp_field_master)) { $temp_field_title .= 'Robot : ' . $temp_field_master['robot_name'] . ' // '; } if (!empty($temp_field_mechas)) { $temp_field_title .= 'Mecha : ' . implode(', ', array_unique($temp_field_mechas)) . ' // '; } // Return the generated markup return $temp_field_title; }
public static function save_session($user_id = 0) { // Reference global variables global $db; $session_token = self::session_token(); $mmrpg_index_players = rpg_player::get_index(); // Do NOT load, save, or otherwise alter the game file while viewing remote if (defined('MMRPG_REMOTE_GAME')) { return true; } // Collect or update the user ID in the session if (empty($user_id) && isset($_SESSION[$session_token]['USER']['userid'])) { $user_id = $_SESSION[$session_token]['USER']['userid']; } else { $_SESSION[$session_token]['USER']['userid'] = $user_id; } // Update the last saved value $_SESSION[$session_token]['values']['last_save'] = time(); // If this is NOT demo mode, load from database if (empty($_SESSION[$session_token]['DEMO'])) { // UPDATE DATABASE INFO // Collect the save info $save = $_SESSION[$session_token]; $this_user = $save['USER']; $this_cache_date = !empty($save['CACHE_DATE']) ? $save['CACHE_DATE'] : MMRPG_CONFIG_CACHE_DATE; $this_counters = !empty($save['counters']) ? $save['counters'] : array(); $this_values = !empty($save['values']) ? $save['values'] : array(); $this_flags = !empty($save['flags']) ? $save['flags'] : array(); $this_settings = !empty($save['battle_settings']) ? $save['battle_settings'] : array(); $this_stars = !empty($save['values']['battle_stars']) ? $save['values']['battle_stars'] : array(); unset($save); // Collect this user's ID from the database if not set if (empty($user_id)) { // Generate new user, save, and board IDs for this listing $temp_user_id = $db->get_value('SELECT MAX(user_id) AS user_id FROM mmrpg_users WHERE user_id < ' . MMRPG_SETTINGS_GUEST_ID, 'user_id') + 1; $temp_save_id = $db->get_value('SELECT MAX(save_id) AS save_id FROM mmrpg_saves', 'save_id') + 1; $temp_board_id = $db->get_value('SELECT MAX(board_id) AS board_id FROM mmrpg_leaderboard', 'board_id') + 1; // Generate the USER details for import $temp_user_array = array(); $temp_user_array['user_id'] = $temp_user_id; $temp_user_array['role_id'] = isset($this_user['roleid']) ? $this_user['roleid'] : 3; $temp_user_array['user_name'] = $this_user['username']; $temp_user_array['user_name_clean'] = $this_user['username_clean']; $temp_user_array['user_name_public'] = !empty($this_user['displayname']) ? $this_user['displayname'] : ''; $temp_user_array['user_password'] = $this_user['password']; $temp_user_array['user_password_encoded'] = $this_user['password_encoded']; $temp_user_array['user_profile_text'] = !empty($this_user['profiletext']) ? $this_user['profiletext'] : ''; $temp_user_array['user_credit_text'] = !empty($this_user['creditstext']) ? $this_user['creditstext'] : ''; $temp_user_array['user_credit_line'] = !empty($this_user['creditsline']) ? $this_user['creditsline'] : ''; $temp_user_array['user_image_path'] = !empty($this_user['imagepath']) ? $this_user['imagepath'] : ''; $temp_user_array['user_background_path'] = !empty($this_user['backgroundpath']) ? $this_user['backgroundpath'] : ''; $temp_user_array['user_colour_token'] = !empty($this_user['colourtoken']) ? $this_user['colourtoken'] : ''; $temp_user_array['user_gender'] = !empty($this_user['gender']) ? $this_user['gender'] : ''; $temp_user_array['user_email_address'] = !empty($this_user['emailaddress']) ? $this_user['emailaddress'] : ''; $temp_user_array['user_website_address'] = !empty($this_user['websiteaddress']) ? $this_user['websiteaddress'] : ''; $temp_user_array['user_date_created'] = time(); $temp_user_array['user_date_accessed'] = time(); $temp_user_array['user_date_modified'] = time(); $temp_user_array['user_date_birth'] = !empty($this_user['dateofbirth']) ? $this_user['dateofbirth'] : 0; $temp_user_array['user_flag_approved'] = !empty($this_user['approved']) ? 1 : 0; // Generate the BOARD details for import $temp_board_array = array(); $temp_board_array['board_id'] = $temp_board_id; $temp_board_array['user_id'] = $temp_user_id; $temp_board_array['save_id'] = $temp_save_id; $temp_board_array['board_points'] = !empty($this_counters['battle_points']) ? $this_counters['battle_points'] : 0; $temp_board_array['board_robots'] = array(); $temp_board_array['board_battles'] = array(); $temp_board_array['board_stars'] = 0; $temp_board_array['board_stars_dr_light'] = 0; $temp_board_array['board_stars_dr_wily'] = 0; $temp_board_array['board_stars_dr_cossack'] = 0; $temp_board_array['board_abilities'] = 0; $temp_board_array['board_abilities_dr_light'] = 0; $temp_board_array['board_abilities_dr_wily'] = 0; $temp_board_array['board_abilities_dr_cossack'] = 0; $temp_board_array['board_missions'] = 0; $temp_board_array['board_missions_dr_light'] = 0; $temp_board_array['board_missions_dr_wily'] = 0; $temp_board_array['board_missions_dr_cossack'] = 0; $temp_board_ability_tokens = array(); if (!empty($this_values['battle_rewards'])) { //foreach ($this_values['battle_rewards'] AS $player_token => $player_array){ foreach ($mmrpg_index_players as $player_token => $player_array) { if ($player_token == 'player') { continue; } $player_reward_array = !empty($this_values['battle_rewards'][$player_token]) ? $this_values['battle_rewards'][$player_token] : array(); $player_battles_array = !empty($this_values['battle_complete'][$player_token]) ? $this_values['battle_complete'][$player_token] : array(); $player_database_token = str_replace('-', '_', $player_token); if (!empty($player_reward_array)) { $temp_board_array['board_points_' . $player_database_token] = $player_reward_array['player_points']; $temp_board_array['board_robots_' . $player_database_token] = array(); $temp_board_array['board_battles_' . $player_database_token] = array(); if (!empty($player_reward_array['player_robots'])) { foreach ($player_reward_array['player_robots'] as $robot_token => $robot_array) { $temp_token = $robot_array['robot_token']; $temp_level = !empty($robot_array['robot_level']) ? $robot_array['robot_level'] : 1; $temp_robot_info = array('robot_token' => $temp_token, $temp_level); $temp_board_array['board_robots'][] = '[' . $temp_token . ':' . $temp_level . ']'; $temp_board_array['board_robots_' . $player_database_token][] = '[' . $temp_token . ':' . $temp_level . ']'; } } if (!empty($player_reward_array['player_abilities'])) { foreach ($player_reward_array['player_abilities'] as $ability_token => $ability_array) { //if (!isset($ability_array['ability_token'])){ die('player_abilities->'.print_r($ability_array, true)); } $temp_token = !empty($ability_array['ability_token']) ? $ability_array['ability_token'] : $ability_token; $temp_board_array['board_abilities_' . $player_database_token] += 1; if (!in_array($temp_token, $temp_board_ability_tokens)) { $temp_board_array['board_abilities'] += 1; $temp_board_ability_tokens[] = $temp_token; } } } if (!empty($player_battles_array)) { foreach ($player_battles_array as $battle_token => $battle_info) { $temp_token = $battle_info['battle_token']; $temp_board_array['board_battles'][] = '[' . $temp_token . ']'; $temp_board_array['board_battles_' . $player_database_token][] = '[' . $temp_token . ']'; $temp_board_array['board_missions'] += 1; $temp_board_array['board_missions_' . $player_database_token] += 1; } } } else { $temp_board_array['board_points_' . $player_database_token] = 0; $temp_board_array['board_robots_' . $player_database_token] = array(); $temp_board_array['board_battles_' . $player_database_token] = array(); } $temp_board_array['board_robots_' . $player_database_token] = !empty($temp_board_array['board_robots_' . $player_database_token]) ? implode(',', $temp_board_array['board_robots_' . $player_database_token]) : ''; $temp_board_array['board_battles_' . $player_database_token] = !empty($temp_board_array['board_battles_' . $player_database_token]) ? implode(',', $temp_board_array['board_battles_' . $player_database_token]) : ''; } } if (!empty($this_stars)) { foreach ($this_stars as $temp_star_token => $temp_star_info) { $temp_star_player = str_replace('-', '_', $temp_star_info['star_player']); $temp_board_array['board_stars'] += 1; $temp_board_array['board_stars_' . $temp_star_player] += 1; } } $temp_board_array['board_robots'] = !empty($temp_board_array['board_robots']) ? implode(',', $temp_board_array['board_robots']) : ''; $temp_board_array['board_battles'] = !empty($temp_board_array['board_battles']) ? implode(',', $temp_board_array['board_battles']) : ''; $temp_board_array['board_date_created'] = $temp_user_array['user_date_created']; $temp_board_array['board_date_modified'] = $temp_user_array['user_date_modified']; // Generate the SAVE details for import $temp_save_array = array(); if (!empty($this_values['battle_index'])) { unset($this_values['battle_index']); } if (!empty($this_values['battle_complete'])) { $temp_save_array['save_values_battle_complete'] = json_encode($this_values['battle_complete']); $temp_hash = md5($temp_save_array['save_values_battle_complete']); if (isset($this_values['battle_complete_hash']) && $this_values['battle_complete_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_complete']); } unset($this_values['battle_complete'], $this_values['battle_complete_hash']); } if (!empty($this_values['battle_failure'])) { $temp_save_array['save_values_battle_failure'] = json_encode($this_values['battle_failure']); $temp_hash = md5($temp_save_array['save_values_battle_failure']); if (isset($this_values['battle_failure_hash']) && $this_values['battle_failure_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_failure']); } unset($this_values['battle_failure'], $this_values['battle_failure_hash']); } if (!empty($this_values['battle_rewards'])) { $temp_save_array['save_values_battle_rewards'] = json_encode($this_values['battle_rewards']); $temp_hash = md5($temp_save_array['save_values_battle_rewards']); if (isset($this_values['battle_rewards_hash']) && $this_values['battle_rewards_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_rewards']); } unset($this_values['battle_rewards'], $this_values['battle_rewards_hash']); } if (!empty($this_values['battle_settings'])) { $temp_save_array['save_values_battle_settings'] = json_encode($this_values['battle_settings']); $temp_hash = md5($temp_save_array['save_values_battle_settings']); if (isset($this_values['battle_settings_hash']) && $this_values['battle_settings_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_settings']); } unset($this_values['battle_settings'], $this_values['battle_settings_hash']); } if (!empty($this_values['battle_items'])) { $temp_save_array['save_values_battle_items'] = json_encode($this_values['battle_items']); $temp_hash = md5($temp_save_array['save_values_battle_items']); if (isset($this_values['battle_items_hash']) && $this_values['battle_items_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_items']); } unset($this_values['battle_items'], $this_values['battle_items_hash']); } if (!empty($this_values['battle_stars'])) { $temp_save_array['save_values_battle_stars'] = json_encode($this_values['battle_stars']); $temp_hash = md5($temp_save_array['save_values_battle_stars']); if (isset($this_values['battle_stars_hash']) && $this_values['battle_stars_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_stars']); } unset($this_values['battle_stars'], $this_values['battle_stars_hash']); } if (!empty($this_values['robot_database'])) { $temp_save_array['save_values_robot_database'] = json_encode($this_values['robot_database']); $temp_hash = md5($temp_save_array['save_values_robot_database']); if (isset($this_values['robot_database_hash']) && $this_values['robot_database_hash'] == $temp_hash) { unset($temp_save_array['save_values_robot_database']); } unset($this_values['robot_database'], $this_values['robot_database_hash']); } $temp_save_array['save_id'] = $temp_save_id; $temp_save_array['user_id'] = $temp_user_id; $temp_save_array['save_counters'] = json_encode($this_counters); $temp_save_array['save_values'] = json_encode($this_values); $temp_save_array['save_flags'] = json_encode($this_flags); $temp_save_array['save_settings'] = json_encode($this_settings); $temp_save_array['save_cache_date'] = $this_cache_date; $temp_save_array['save_file_name'] = $this_file['name']; $temp_save_array['save_file_path'] = $this_file['path']; $temp_save_array['save_date_created'] = $temp_user_array['user_date_created']; $temp_save_array['save_date_accessed'] = $temp_user_array['user_date_accessed']; $temp_save_array['save_date_modified'] = $temp_user_array['user_date_modified']; // Insert these users into the database $temp_user_array_return = $db->insert('mmrpg_users', $temp_user_array); $temp_save_array_return = $db->insert('mmrpg_saves', $temp_save_array); $temp_board_array_return = $db->insert('mmrpg_leaderboard', $temp_board_array); unset($temp_user_array, $temp_save_array, $temp_board_array); // Update the ID in the user array and continue $this_user['userid'] = $temp_user_id; $user_id = $temp_user_id; } // DEBUG $DEBUG = ''; // Define the user database update array and populate $temp_user_array = array(); $temp_user_array['user_name'] = $this_user['username']; $temp_user_array['user_name_clean'] = $this_user['username_clean']; $temp_user_array['user_name_public'] = !empty($this_user['displayname']) ? $this_user['displayname'] : ''; $temp_user_array['user_password'] = $this_user['password']; $temp_user_array['user_password_encoded'] = $this_user['password_encoded']; $temp_user_array['user_profile_text'] = !empty($this_user['profiletext']) ? $this_user['profiletext'] : ''; $temp_user_array['user_credit_text'] = !empty($this_user['creditstext']) ? $this_user['creditstext'] : ''; $temp_user_array['user_credit_line'] = !empty($this_user['creditsline']) ? $this_user['creditsline'] : ''; $temp_user_array['user_image_path'] = !empty($this_user['imagepath']) ? $this_user['imagepath'] : ''; $temp_user_array['user_background_path'] = !empty($this_user['backgroundpath']) ? $this_user['backgroundpath'] : ''; $temp_user_array['user_colour_token'] = !empty($this_user['colourtoken']) ? $this_user['colourtoken'] : ''; $temp_user_array['user_gender'] = !empty($this_user['gender']) ? $this_user['gender'] : ''; $temp_user_array['user_email_address'] = !empty($this_user['emailaddress']) ? $this_user['emailaddress'] : ''; $temp_user_array['user_website_address'] = !empty($this_user['websiteaddress']) ? $this_user['websiteaddress'] : ''; $temp_user_array['user_date_modified'] = time(); $temp_user_array['user_date_accessed'] = time(); $temp_user_array['user_date_birth'] = !empty($this_user['dateofbirth']) ? $this_user['dateofbirth'] : 0; $temp_user_array['user_flag_approved'] = !empty($this_user['approved']) ? 1 : 0; // Update this user's info in the database $db->update('mmrpg_users', $temp_user_array, 'user_id = ' . $this_user['userid']); unset($temp_user_array); // DEBUG //$DEBUG .= '$db->update(\'mmrpg_users\', $temp_user_array, \'user_id = \'.$this_user[\'userid\']);'; //$DEBUG .= '<pre>$temp_user_array = '.print_r($temp_user_array, true).'</pre>'; //$DEBUG .= '<pre>$this_user = '******'</pre>'; // Define the board database update array and populate $temp_board_array = array(); $temp_board_array['board_points'] = !empty($this_counters['battle_points']) ? $this_counters['battle_points'] : 0; $temp_board_array['board_robots'] = array(); $temp_board_array['board_battles'] = array(); $temp_board_array['board_stars'] = 0; $temp_board_array['board_stars_dr_light'] = 0; $temp_board_array['board_stars_dr_wily'] = 0; $temp_board_array['board_stars_dr_cossack'] = 0; $temp_board_array['board_abilities'] = 0; $temp_board_array['board_abilities_dr_light'] = 0; $temp_board_array['board_abilities_dr_wily'] = 0; $temp_board_array['board_abilities_dr_cossack'] = 0; $temp_board_array['board_missions'] = 0; $temp_board_array['board_missions_dr_light'] = 0; $temp_board_array['board_missions_dr_wily'] = 0; $temp_board_array['board_missions_dr_cossack'] = 0; $temp_board_array['board_awards'] = !empty($this_values['prototype_awards']) ? array_keys($this_values['prototype_awards']) : ''; $temp_board_ability_tokens = array(); if (!empty($this_values['battle_rewards'])) { //foreach ($this_values['battle_rewards'] AS $player_token => $player_array){ foreach ($mmrpg_index_players as $player_token => $player_array) { if ($player_token == 'player' || !self::player_unlocked($player_token)) { continue; } $player_reward_array = !empty($this_values['battle_rewards'][$player_token]) ? $this_values['battle_rewards'][$player_token] : array(); $player_battles_array = !empty($this_values['battle_complete'][$player_token]) ? $this_values['battle_complete'][$player_token] : array(); $player_database_token = str_replace('-', '_', $player_token); if (!empty($player_reward_array)) { $temp_board_array['board_points_' . $player_database_token] = !empty($player_reward_array['player_points']) ? $player_reward_array['player_points'] : 0; $temp_board_array['board_robots_' . $player_database_token] = array(); $temp_board_array['board_battles_' . $player_database_token] = array(); if (!empty($player_reward_array['player_robots'])) { foreach ($player_reward_array['player_robots'] as $robot_token => $robot_array) { //if (!isset($robot_array['robot_token'])){ die('player_robots->'.print_r($robot_array, true)); } $temp_token = !empty($robot_array['robot_token']) ? $robot_array['robot_token'] : $robot_token; $temp_level = !empty($robot_array['robot_level']) ? $robot_array['robot_level'] : 1; $temp_robot_info = array('robot_token' => $temp_token, $temp_level); $temp_board_array['board_robots'][] = '[' . $temp_token . ':' . $temp_level . ']'; $temp_board_array['board_robots_' . $player_database_token][] = '[' . $temp_token . ':' . $temp_level . ']'; } } if (!empty($player_reward_array['player_abilities'])) { foreach ($player_reward_array['player_abilities'] as $ability_token => $ability_array) { //if (!isset($ability_array['ability_token'])){ die('player_abilities->'.print_r($ability_array, true)); } $temp_token = !empty($ability_array['ability_token']) ? $ability_array['ability_token'] : $ability_token; $temp_board_array['board_abilities_' . $player_database_token] += 1; if (!in_array($temp_token, $temp_board_ability_tokens)) { $temp_board_array['board_abilities'] += 1; $temp_board_ability_tokens[] = $temp_token; } } } if (!empty($player_battles_array)) { foreach ($player_battles_array as $battle_token => $battle_info) { $temp_token = $battle_info['battle_token']; $temp_board_array['board_battles'][] = '[' . $temp_token . ']'; $temp_board_array['board_battles_' . $player_database_token][] = '[' . $temp_token . ']'; $temp_board_array['board_missions'] += 1; $temp_board_array['board_missions_' . $player_database_token] += 1; } } } else { $temp_board_array['board_points_' . $player_database_token] = 0; $temp_board_array['board_robots_' . $player_database_token] = array(); $temp_board_array['board_battles_' . $player_database_token] = array(); } $temp_board_array['board_robots_' . $player_database_token] = !empty($temp_board_array['board_robots_' . $player_database_token]) ? implode(',', $temp_board_array['board_robots_' . $player_database_token]) : ''; $temp_board_array['board_battles_' . $player_database_token] = !empty($temp_board_array['board_battles_' . $player_database_token]) ? implode(',', $temp_board_array['board_battles_' . $player_database_token]) : ''; } } if (!empty($this_stars)) { foreach ($this_stars as $temp_star_token => $temp_star_info) { $temp_star_player = str_replace('-', '_', $temp_star_info['star_player']); $temp_board_array['board_stars'] += 1; $temp_board_array['board_stars_' . $temp_star_player] += 1; } } //$temp_board_array['board_robots'] = json_encode($temp_board_array['board_robots']); $temp_board_array['board_robots'] = !empty($temp_board_array['board_robots']) ? implode(',', $temp_board_array['board_robots']) : ''; $temp_board_array['board_battles'] = !empty($temp_board_array['board_battles']) ? implode(',', $temp_board_array['board_battles']) : ''; $temp_board_array['board_awards'] = !empty($temp_board_array['board_awards']) ? implode(',', $temp_board_array['board_awards']) : ''; $temp_board_array['board_date_modified'] = time(); // Update this board's info in the database $db->update('mmrpg_leaderboard', $temp_board_array, 'user_id = ' . $this_user['userid']); unset($temp_board_array); // Clear any leaderboard data that exists in the session, forcing it to recache if (isset($_SESSION[$session_token]['BOARD']['boardrank'])) { unset($_SESSION[$session_token]['BOARD']['boardrank']); } // Define the save database update array and populate $temp_save_array = array(); if (!empty($this_values['battle_index'])) { ////foreach ($this_values['battle_index'] AS $key => $array){ $this_values['battle_index'][$key] = json_decode($array, true); } ////$temp_save_array['save_values_battle_index'] = json_encode($this_values['battle_index']); ////$temp_hash = md5($temp_save_array['save_values_battle_index']); ////if (isset($this_values['battle_index_hash']) && $this_values['battle_index_hash'] == $temp_hash){ unset($temp_save_array['save_values_battle_index']); } //unset($this_values['battle_index'], $this_values['battle_index_hash']); unset($this_values['battle_index']); } if (!empty($this_values['battle_complete'])) { $temp_save_array['save_values_battle_complete'] = json_encode($this_values['battle_complete']); $temp_hash = md5($temp_save_array['save_values_battle_complete']); if (isset($this_values['battle_complete_hash']) && $this_values['battle_complete_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_complete']); } unset($this_values['battle_complete'], $this_values['battle_complete_hash']); } if (!empty($this_values['battle_failure'])) { $temp_save_array['save_values_battle_failure'] = json_encode($this_values['battle_failure']); $temp_hash = md5($temp_save_array['save_values_battle_failure']); if (isset($this_values['battle_failure_hash']) && $this_values['battle_failure_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_failure']); } unset($this_values['battle_failure'], $this_values['battle_failure_hash']); } if (!empty($this_values['battle_rewards'])) { $temp_save_array['save_values_battle_rewards'] = json_encode($this_values['battle_rewards']); $temp_hash = md5($temp_save_array['save_values_battle_rewards']); if (isset($this_values['battle_rewards_hash']) && $this_values['battle_rewards_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_rewards']); } unset($this_values['battle_rewards'], $this_values['battle_rewards_hash']); } if (!empty($this_values['battle_settings'])) { $temp_save_array['save_values_battle_settings'] = json_encode($this_values['battle_settings']); $temp_hash = md5($temp_save_array['save_values_battle_settings']); if (isset($this_values['battle_settings_hash']) && $this_values['battle_settings_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_settings']); } unset($this_values['battle_settings'], $this_values['battle_settings_hash']); } if (!empty($this_values['battle_items'])) { $temp_save_array['save_values_battle_items'] = json_encode($this_values['battle_items']); $temp_hash = md5($temp_save_array['save_values_battle_items']); if (isset($this_values['battle_items_hash']) && $this_values['battle_items_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_items']); } unset($this_values['battle_items'], $this_values['battle_items_hash']); } if (!empty($this_values['battle_stars'])) { $temp_save_array['save_values_battle_stars'] = json_encode($this_values['battle_stars']); $temp_hash = md5($temp_save_array['save_values_battle_stars']); if (isset($this_values['battle_stars_hash']) && $this_values['battle_stars_hash'] == $temp_hash) { unset($temp_save_array['save_values_battle_stars']); } unset($this_values['battle_stars'], $this_values['battle_stars_hash']); } if (!empty($this_values['robot_database'])) { $temp_save_array['save_values_robot_database'] = json_encode($this_values['robot_database']); $temp_hash = md5($temp_save_array['save_values_robot_database']); if (isset($this_values['robot_database_hash']) && $this_values['robot_database_hash'] == $temp_hash) { unset($temp_save_array['save_values_robot_database']); } unset($this_values['robot_database'], $this_values['robot_database_hash']); } $temp_save_array['save_counters'] = json_encode($this_counters); $temp_save_array['save_values'] = json_encode($this_values); $temp_save_array['save_flags'] = json_encode($this_flags); $temp_save_array['save_settings'] = json_encode($this_settings); $temp_save_array['save_cache_date'] = $this_cache_date; $temp_save_array['save_date_modified'] = time(); // Update this save's info in the database $db->update('mmrpg_saves', $temp_save_array, 'user_id = ' . $this_user['userid']); unset($temp_save_array); // DEBUG //$DEBUG .= '$db->update(\'mmrpg_saves\', $temp_save_array, \'user_id = \'.$this_user[\'userid\']);'; //$DEBUG .= '<pre>$temp_save_array = '.print_r($temp_save_array, true).'</pre>'; //$DEBUG .= '<pre>$this_user = '******'</pre>'; // DEBUG //$DEBUG .= '$db->update(\'mmrpg_leaderboard\', $temp_board_array, \'user_id = \'.$this_user[\'userid\']);'; //$DEBUG .= '<pre>$temp_board_array = '.print_r($temp_board_array, true).'</pre>'; //$DEBUG .= '<pre>$this_user = '******'</pre>'; } else { // DEBUG //echo 'but we\'re in demo mode'; } // Pull the updated user info from the database $user_fields = rpg_user::get_fields(true, 'user'); $user_role_fields = rpg_user_role::get_fields(true, 'role'); $this_userinfo = $db->get_array("SELECT\n {$user_fields}, {$user_role_fields}\n FROM mmrpg_users AS user\n LEFT JOIN mmrpg_roles AS role ON role.role_id = user.role_id\n WHERE user.user_id = '{$user_id}'\n LIMIT 1"); // Update the session with the new user info $_SESSION['GAME']['USER']['userinfo'] = $this_userinfo; // Return true on success return true; }
/* * INDEX PAGE : ADMIN */ // Require actions file for form processing require_once MMRPG_CONFIG_ROOTDIR . 'pages/admin_index_actions.php'; // Define the SEO variables for this page $this_seo_title = 'Admin Index | ' . $this_seo_title; $this_seo_description = 'Admin control panel index for the Mega Man RPG World.'; $this_seo_robots = ''; // Define the MARKUP variables for this page $this_markup_header = ''; // Count the numer of users in the database $mmrpg_user_count = $db->get_value("SELECT COUNT(user_id) AS user_count FROM mmrpg_users WHERE user_id <> 0;", 'user_count'); // Count the numer of players in the database $mmrpg_players = rpg_player::get_index(); $mmrpg_player_count = count($mmrpg_players); // Count the numer of mechas in the database $mmrpg_mecha_count = $db->get_value("SELECT COUNT(robot_id) AS robot_count FROM mmrpg_index_robots WHERE robot_id <> 0 AND robot_class IN ('mecha');", 'robot_count'); // Count the numer of robots in the database $mmrpg_robot_count = $db->get_value("SELECT COUNT(robot_id) AS robot_count FROM mmrpg_index_robots WHERE robot_id <> 0 AND robot_class IN ('master');", 'robot_count'); // Count the numer of bosses in the database $mmrpg_boss_count = $db->get_value("SELECT COUNT(robot_id) AS robot_count FROM mmrpg_index_robots WHERE robot_id <> 0 AND robot_class IN ('boss');", 'robot_count'); // Count the numer of abilities in the database $mmrpg_ability_count = $db->get_value("SELECT COUNT(ability_id) AS ability_count FROM mmrpg_index_abilities WHERE ability_id <> 0;", 'ability_count'); // Count the numer of items in the database $mmrpg_item_count = $db->get_value("SELECT COUNT(item_id) AS item_count FROM mmrpg_index_items WHERE item_id <> 0;", 'item_count'); // Count the numer of fields in the database $mmrpg_field_count = $db->get_value("SELECT COUNT(field_id) AS field_count FROM mmrpg_index_fields WHERE field_id <> 0;", 'field_count'); // Start generating the page markup ob_start();