<commit_before><?php

// MAINTENANCE
if (MMRPG_CONFIG_MAINTENANCE_MODE && !in_array($_SERVER['REMOTE_ADDR'], array('172.16.31.10', '127.0.0.1', '172.16.58.3', '192.168.127.12'))){
    die('<div style="font-family: Arial; font-size: 16px; line-height: 21px; margin: 0; padding: 20px 25%; background-color: rgb(0, 122, 0); color: #FFFFFF; text-align: left; border-bottom: 1px solid #090909;">
        UPDATE IN PROGRESS<br /> The Mega Man RPG Prototype is currently being updated.  Please stand by until further notice.  Several parts of the website are being taken offline during this process and any progress made during will likely be lost, so please hold tight before trying to log in again.  I apologize for the inconvenience and thank you for your patience.<br /> - Adrian
        </div>');
}

// Include the TOP file
require_once('top.php');

// Only process session updates if we're NOT in critical error mode
if (!defined('MMRPG_CRITICAL_ERROR')){

    // If this is a ping request, simply exit now that we've loaded session
    if (!empty($_POST['ping']) && preg_match('/^[-_a-z0-9\.\s]+$/i', $_POST['ping'])){
        $ping_text = $_POST['ping'];
        $ping_page = !empty($_POST['page']) && preg_match('/^[-_a-z0-9\/]+$/i', $_POST['page']) ? $_POST['page'] : '';
        // If the ping page is not empty and we're logged in
        if (!empty($ping_page) && $this_userid != MMRPG_SETTINGS_GUEST_ID){
            // Update the database with the user's last page so we can keep track
            mmrpg_website_session_update($ping_page);
            //echo 'ping_page='.$ping_page."\n";
        }
        // Exit and print the ping relay
        exit($ping_text);
    }
    // Otherwise, if this is a regular request and we're logged in
    elseif ($this_userid != MMRPG_SETTINGS_GUEST_ID){
        // Update the database with the user's last page so we can keep track
        mmrpg_website_session_update($this_current_uri);
    }

}

// Clear the prototype temp session var
$_SESSION['PROTOTYPE_TEMP'] = array();

// Define the default SEO and markup variables
$this_seo_robots = 'index,follow';
$this_seo_title = 'Mega Man RPG Prototype | Last Updated '.preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})#', '$1/$2/$3', MMRPG_CONFIG_CACHE_DATE);
$this_seo_keywords = 'megaman,mega man,protoman,proto man,bass,rpg,prototype,dr.light,dr.wily,dr.cossack,battle,browser,pbbg,ipad,firefox,chrome,safari';
$this_seo_description = 'Battle through more than thirty robot masters in classic RPG style with either Dr. Light and Mega Man, Dr. Wily and Bass, or Dr. Cossack and Proto Man!  The Mega Man RPG Prototype is a browser-based fangame that combines the mechanics of both the Pokémon and Mega Man series of video games into one strange and wonderful little time waster.';
$this_markup_header = '';
$this_markup_counter = '';
$this_markup_body = '';
$this_markup_jsready = '';

// Only collect info if we're NOT in critical error mode
if (!defined('MMRPG_CRITICAL_ERROR')){

    // Define the default Open Graph tag variables
    $this_graph_data = array(
        'title' => 'Mega Man RPG Prototype',
        'type' => 'website',
        'url' => $this_current_url,
        'image' => MMRPG_CONFIG_ROOTURL.'images/assets/mmrpg-prototype-logo.png?'.MMRPG_CONFIG_CACHE_DATE,
        'site_name' => 'Mega Man RPG Prototype',
        'description' => $this_seo_description,
        );

    // Collect the recently updated posts for this player / guest
    if ($this_userinfo['user_id'] != MMRPG_SETTINGS_GUEST_ID && !empty($this_userinfo['user_backup_login'])){ $temp_last_login = $this_userinfo['user_backup_login']; }
    else { $temp_last_login = time() - MMRPG_SETTINGS_UPDATE_TIMEOUT; }
    $temp_new_threads = $db->get_array_list("SELECT category_id, CONCAT(thread_id, '_', thread_mod_date) AS thread_session_token FROM mmrpg_threads WHERE thread_locked = 0 AND (thread_target = 0 OR thread_target = {$this_userinfo['user_id']} OR user_id = {$this_userinfo['user_id']}) AND thread_mod_date > {$temp_last_login}".($this_userid != MMRPG_SETTINGS_GUEST_ID ? "  AND thread_mod_user <> {$this_userid}" : ''));
    if (empty($_SESSION['COMMUNITY']['threads_viewed'])){ $_SESSION['COMMUNITY']['threads_viewed'] = array(); }
    if (!empty($temp_new_threads)){ foreach ($temp_new_threads AS $key => $array){
        if (in_array($array['thread_session_token'], $_SESSION['COMMUNITY']['threads_viewed'])){ unset($temp_new_threads[$key]); }  }
    }
    $_SESSION['COMMUNITY']['threads_new'] = !empty($temp_new_threads) ? $temp_new_threads : array();
    $temp_new_threads_categories = array();
    $temp_new_threads_ids = array();
    if (!empty($temp_new_threads)){
        foreach ($temp_new_threads AS $info){
            if (!isset($temp_new_threads_categories[$info['category_id']])){ $temp_new_threads_categories[$info['category_id']] = 0; }
            if (in_array($info['thread_session_token'], $_SESSION['COMMUNITY']['threads_viewed'])){ unset($_SESSION['COMMUNITY']['threads_viewed'][array_search($info['thread_session_token'], $_SESSION['COMMUNITY']['threads_viewed'])]); }
            list($temp_id, $temp_mod) = explode('_', $info['thread_session_token']);
            $temp_new_threads_ids[] = $temp_id;
            $temp_new_threads_categories[$info['category_id']] += 1;
        }
    }
    $_SESSION['COMMUNITY']['threads_new_categories'] = $temp_new_threads_categories;
    //die('<pre>'.print_r($temp_new_threads_categories, true).'</pre>');
    // Collect the online leaderboard data for the currently online players
    $temp_leaderboard_online = mmrpg_prototype_leaderboard_online();

    // Collect any members that are currently viewing the community page
    $temp_viewing_community = mmrpg_website_sessions_active('community/', 3, true);

    // Collect the number of people currently in chat
    $chat_online = $db->get_array_list("SELECT userID, userName, userRole, channel, dateTime, ip FROM ajax_chat_online WHERE 1 = 1;");
    // Increment the community count by the number in the chat room
    if (!empty($chat_online)){
        foreach ($chat_online AS $online){
            $temp_viewing_community[] = array('user_id' => $online['userID'], 'session_href' => 'chat/');
        }
    }

}

// Predefine the variable to hold nav menu markip
$index_nav_markup = '';

// Predefine a markup variable for the post and player counters too (for mobile)<commit_msg>Removed refs to legacy ajax chat from the code<commit_after><?php

// MAINTENANCE
if (MMRPG_CONFIG_MAINTENANCE_MODE && !in_array($_SERVER['REMOTE_ADDR'], array('172.16.31.10', '127.0.0.1', '172.16.58.3', '192.168.127.12'))){
    die('<div style="font-family: Arial; font-size: 16px; line-height: 21px; margin: 0; padding: 20px 25%; background-color: rgb(0, 122, 0); color: #FFFFFF; text-align: left; border-bottom: 1px solid #090909;">
        UPDATE IN PROGRESS<br /> The Mega Man RPG Prototype is currently being updated.  Please stand by until further notice.  Several parts of the website are being taken offline during this process and any progress made during will likely be lost, so please hold tight before trying to log in again.  I apologize for the inconvenience and thank you for your patience.<br /> - Adrian
        </div>');
}

// Include the TOP file
require_once('top.php');

// Only process session updates if we're NOT in critical error mode
if (!defined('MMRPG_CRITICAL_ERROR')){

    // If this is a ping request, simply exit now that we've loaded session
    if (!empty($_POST['ping']) && preg_match('/^[-_a-z0-9\.\s]+$/i', $_POST['ping'])){
        $ping_text = $_POST['ping'];
        $ping_page = !empty($_POST['page']) && preg_match('/^[-_a-z0-9\/]+$/i', $_POST['page']) ? $_POST['page'] : '';
        // If the ping page is not empty and we're logged in
        if (!empty($ping_page) && $this_userid != MMRPG_SETTINGS_GUEST_ID){
            // Update the database with the user's last page so we can keep track
            mmrpg_website_session_update($ping_page);
            //echo 'ping_page='.$ping_page."\n";
        }
        // Exit and print the ping relay
        exit($ping_text);
    }
    // Otherwise, if this is a regular request and we're logged in
    elseif ($this_userid != MMRPG_SETTINGS_GUEST_ID){
        // Update the database with the user's last page so we can keep track
        mmrpg_website_session_update($this_current_uri);
    }

}

// Clear the prototype temp session var
$_SESSION['PROTOTYPE_TEMP'] = array();

// Define the default SEO and markup variables
$this_seo_robots = 'index,follow';
$this_seo_title = 'Mega Man RPG Prototype | Last Updated '.preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})#', '$1/$2/$3', MMRPG_CONFIG_CACHE_DATE);
$this_seo_keywords = 'megaman,mega man,protoman,proto man,bass,rpg,prototype,dr.light,dr.wily,dr.cossack,battle,browser,pbbg,ipad,firefox,chrome,safari';
$this_seo_description = 'Battle through more than thirty robot masters in classic RPG style with either Dr. Light and Mega Man, Dr. Wily and Bass, or Dr. Cossack and Proto Man!  The Mega Man RPG Prototype is a browser-based fangame that combines the mechanics of both the Pokémon and Mega Man series of video games into one strange and wonderful little time waster.';
$this_markup_header = '';
$this_markup_counter = '';
$this_markup_body = '';
$this_markup_jsready = '';

// Only collect info if we're NOT in critical error mode
if (!defined('MMRPG_CRITICAL_ERROR')){

    // Define the default Open Graph tag variables
    $this_graph_data = array(
        'title' => 'Mega Man RPG Prototype',
        'type' => 'website',
        'url' => $this_current_url,
        'image' => MMRPG_CONFIG_ROOTURL.'images/assets/mmrpg-prototype-logo.png?'.MMRPG_CONFIG_CACHE_DATE,
        'site_name' => 'Mega Man RPG Prototype',
        'description' => $this_seo_description,
        );

    // Collect the recently updated posts for this player / guest
    if ($this_userinfo['user_id'] != MMRPG_SETTINGS_GUEST_ID && !empty($this_userinfo['user_backup_login'])){ $temp_last_login = $this_userinfo['user_backup_login']; }
    else { $temp_last_login = time() - MMRPG_SETTINGS_UPDATE_TIMEOUT; }
    $temp_new_threads = $db->get_array_list("SELECT category_id, CONCAT(thread_id, '_', thread_mod_date) AS thread_session_token FROM mmrpg_threads WHERE thread_locked = 0 AND (thread_target = 0 OR thread_target = {$this_userinfo['user_id']} OR user_id = {$this_userinfo['user_id']}) AND thread_mod_date > {$temp_last_login}".($this_userid != MMRPG_SETTINGS_GUEST_ID ? "  AND thread_mod_user <> {$this_userid}" : ''));
    if (empty($_SESSION['COMMUNITY']['threads_viewed'])){ $_SESSION['COMMUNITY']['threads_viewed'] = array(); }
    if (!empty($temp_new_threads)){ foreach ($temp_new_threads AS $key => $array){
        if (in_array($array['thread_session_token'], $_SESSION['COMMUNITY']['threads_viewed'])){ unset($temp_new_threads[$key]); }  }
    }
    $_SESSION['COMMUNITY']['threads_new'] = !empty($temp_new_threads) ? $temp_new_threads : array();
    $temp_new_threads_categories = array();
    $temp_new_threads_ids = array();
    if (!empty($temp_new_threads)){
        foreach ($temp_new_threads AS $info){
            if (!isset($temp_new_threads_categories[$info['category_id']])){ $temp_new_threads_categories[$info['category_id']] = 0; }
            if (in_array($info['thread_session_token'], $_SESSION['COMMUNITY']['threads_viewed'])){ unset($_SESSION['COMMUNITY']['threads_viewed'][array_search($info['thread_session_token'], $_SESSION['COMMUNITY']['threads_viewed'])]); }
            list($temp_id, $temp_mod) = explode('_', $info['thread_session_token']);
            $temp_new_threads_ids[] = $temp_id;
            $temp_new_threads_categories[$info['category_id']] += 1;
        }
    }
    $_SESSION['COMMUNITY']['threads_new_categories'] = $temp_new_threads_categories;
    //die('<pre>'.print_r($temp_new_threads_categories, true).'</pre>');
    // Collect the online leaderboard data for the currently online players
    $temp_leaderboard_online = mmrpg_prototype_leaderboard_online();

    // Collect any members that are currently viewing the community page
    $temp_viewing_community = mmrpg_website_sessions_active('community/', 3, true);

}

// Predefine the variable to hold nav menu markip
$index_nav_markup = '';

// Predefine a markup variable for the post and player counters too (for mobile)
{'fraction_non_alphanumeric': 0.14329588620383094, 'fraction_numerical': 0.012931382849753495, 'mean_word_length': 4.361351819757366, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5781206', 'n_tokens_mistral': 4076, 'n_tokens_neox': 3906, 'n_words': 1016}