$query_sort = 'users.user_colour_token ' . $sort_direction_upper;
 } elseif ($sort_column == 'played') {
     $query_sort = 'user_flag_played ' . $sort_direction_upper;
 } else {
     $query_sort = 'users.user_' . $sort_column . ' ' . $sort_direction_upper;
 }
 // Count the total number of users first
 $user_total_count = $db->get_value("SELECT count(user_id) AS total FROM mmrpg_users AS users WHERE users.user_id <> 0;", 'total');
 // If the requested page would go over the limit, floor it
 if (ceil($show_limit * $sheet_number) > $user_total_count) {
     $sheet_number = ceil($user_total_count / $show_limit);
     $row_offset = $show_limit * ($sheet_number - 1);
 }
 // Collect a list of all users in the database
 $user_fields = rpg_user::get_fields(true, 'users');
 $user_roles_fields = rpg_user_role::get_fields(true, 'roles');
 $user_query = "SELECT\n        {$user_fields},\n        {$user_roles_fields},\n        (CASE WHEN leaderboard.board_points > 0 THEN 1 ELSE 0 END) AS user_flag_played\n        FROM mmrpg_users AS users\n        LEFT JOIN mmrpg_roles AS roles ON roles.role_id = users.role_id\n        LEFT JOIN mmrpg_leaderboard AS leaderboard ON leaderboard.user_id = users.user_id\n        WHERE users.user_id <> 0\n        ORDER BY {$query_sort}\n        LIMIT {$row_offset}, {$show_limit}\n        ;";
 $user_index = $db->get_array_list($user_query, 'user_id');
 $user_index_count = !empty($user_index) ? count($user_index) : 0;
 // Collect a leaderboard index so we can check if published
 $leaderboard_tokens = rpg_prototype::leaderboard_index_tokens();
 // Collect a list of completed user sprite tokens
 $random_sprite = 'kalinka';
 // Calculate the number of sheets to display
 $num_sheets = ceil($user_total_count / $show_limit);
 // Define a function for generating user sheet links
 $gen_page_link = function ($i, $show_active = true, $show_text = false) use($sort_column, $sort_direction, $show_limit, $sheet_number, $num_sheets) {
     $active = $show_active && $i == $sheet_number ? true : false;
     $visible = $i == 1 || $i == $num_sheets || abs($i - $sheet_number) < 5 ? true : false;
     $link = 'admin/users/sort=' . $sort_column . '-' . $sort_direction . '&amp;show=' . $show_limit . '&amp;sheet=' . $i;
     $class = 'link_inline' . ($active ? ' active' : '') . (!$visible ? ' compact' : '');
    public static function print_database_markup($ability_info, $print_options = array())
    {
        // Define the global variables
        global $mmrpg_index, $this_current_uri, $this_current_url;
        global $mmrpg_database_abilities, $mmrpg_database_abilities, $mmrpg_database_types;
        global $db;
        // Collect global indexes for easier search
        $mmrpg_types = rpg_type::get_index();
        // Define the markup variable
        $this_markup = '';
        // Define the print style defaults
        if (!isset($print_options['layout_style'])) {
            $print_options['layout_style'] = 'website';
        }
        if ($print_options['layout_style'] == 'website') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_icon'])) {
                $print_options['show_icon'] = true;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = true;
            }
            if (!isset($print_options['show_robots'])) {
                $print_options['show_robots'] = true;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = true;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = true;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
        } elseif ($print_options['layout_style'] == 'website_compact') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_icon'])) {
                $print_options['show_icon'] = true;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = false;
            }
            if (!isset($print_options['show_robots'])) {
                $print_options['show_robots'] = false;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = false;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = true;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
        } elseif ($print_options['layout_style'] == 'event') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_icon'])) {
                $print_options['show_icon'] = false;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = false;
            }
            if (!isset($print_options['show_robots'])) {
                $print_options['show_robots'] = false;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = false;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = false;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
        }
        // Collect the ability sprite dimensions
        $ability_image_size = !empty($ability_info['ability_image_size']) ? $ability_info['ability_image_size'] : 40;
        $ability_image_size_text = $ability_image_size . 'x' . $ability_image_size;
        $ability_image_token = !empty($ability_info['ability_image']) ? $ability_info['ability_image'] : $ability_info['ability_token'];
        // Collect the ability's type for background display
        $ability_type_class = !empty($ability_info['ability_type']) ? $ability_info['ability_type'] : 'none';
        if ($ability_type_class != 'none' && !empty($ability_info['ability_type2'])) {
            $ability_type_class .= '_' . $ability_info['ability_type2'];
        } elseif ($ability_type_class == 'none' && !empty($ability_info['ability_type2'])) {
            $ability_type_class = $ability_info['ability_type2'];
        }
        $ability_header_types = 'ability_type_' . $ability_type_class . ' ';
        // If this is a special category of item, it's a special type
        if (preg_match('/^item-score-ball-(red|blue|green|purple)$/i', $ability_info['ability_token'])) {
            $ability_info['ability_type_special'] = 'bonus';
        } elseif (preg_match('/^item-super-(pellet|capsule)$/i', $ability_info['ability_token'])) {
            $ability_info['ability_type_special'] = 'multi';
        }
        // Define the sprite sheet alt and title text
        $ability_sprite_size = $ability_image_size * 2;
        $ability_sprite_size_text = $ability_sprite_size . 'x' . $ability_sprite_size;
        $ability_sprite_title = $ability_info['ability_name'];
        //$ability_sprite_title = $ability_info['ability_number'].' '.$ability_info['ability_name'];
        //$ability_sprite_title .= ' Sprite Sheet | Robot Database | Mega Man RPG World';
        // Define the sprite frame index for robot images
        $ability_sprite_frames = array('frame_01', 'frame_02', 'frame_03', 'frame_04', 'frame_05', 'frame_06', 'frame_07', 'frame_08', 'frame_09', 'frame_10');
        // Limit any damage or recovery percents to 100%
        if (!empty($ability_info['ability_damage_percent']) && $ability_info['ability_damage'] > 100) {
            $ability_info['ability_damage'] = 100;
        }
        if (!empty($ability_info['ability_damage2_percent']) && $ability_info['ability_damage2'] > 100) {
            $ability_info['ability_damage2'] = 100;
        }
        if (!empty($ability_info['ability_recovery_percent']) && $ability_info['ability_recovery'] > 100) {
            $ability_info['ability_recovery'] = 100;
        }
        if (!empty($ability_info['ability_recovery2_percent']) && $ability_info['ability_recovery2'] > 100) {
            $ability_info['ability_recovery2'] = 100;
        }
        // Start the output buffer
        ob_start();
        ?>
        <div class="database_container database_<?php 
        echo $ability_info['ability_class'] == 'item' ? 'item' : 'ability';
        ?>
_container" data-token="<?php 
        echo $ability_info['ability_token'];
        ?>
" style="<?php 
        echo $print_options['layout_style'] == 'website_compact' ? 'margin-bottom: 2px !important;' : '';
        ?>
">

            <?php 
        if ($print_options['layout_style'] == 'website' || $print_options['layout_style'] == 'website_compact') {
            ?>
                <a class="anchor" id="<?php 
            echo $ability_info['ability_token'];
            ?>
">&nbsp;</a>
            <?php 
        }
        ?>

            <div class="subbody event event_triple event_visible" data-token="<?php 
        echo $ability_info['ability_token'];
        ?>
" style="<?php 
        echo ($print_options['layout_style'] == 'event' ? 'margin: 0 !important; ' : '') . ($print_options['layout_style'] == 'website_compact' ? 'margin-bottom: 2px !important; ' : '');
        ?>
">

                <?php 
        if ($print_options['show_icon']) {
            ?>

                    <div class="this_sprite sprite_left" style="height: 40px;">
                        <?php 
            if ($print_options['show_icon']) {
                ?>
                            <?php 
                if ($print_options['show_key'] !== false) {
                    ?>
                                <div class="icon ability_type <?php 
                    echo $ability_header_types;
                    ?>
" style="font-size: 9px; line-height: 11px; text-align: center; margin-bottom: 2px; padding: 0 0 1px !important;"><?php 
                    echo 'No.' . $ability_info['ability_key'];
                    ?>
</div>
                            <?php 
                }
                ?>
                            <?php 
                if ($ability_image_token != 'ability') {
                    ?>
                                <div class="icon ability_type <?php 
                    echo $ability_header_types;
                    ?>
"><div style="background-image: url(i/a/<?php 
                    echo $ability_image_token;
                    ?>
/ir<?php 
                    echo $ability_image_size;
                    ?>
.png?<?php 
                    echo MMRPG_CONFIG_CACHE_DATE;
                    ?>
); background-color: #000000; background-color: rgba(0, 0, 0, 0.6); box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); " class="sprite sprite_ability sprite_40x40 sprite_40x40_icon sprite_size_<?php 
                    echo $ability_image_size_text;
                    ?>
 sprite_size_<?php 
                    echo $ability_image_size_text;
                    ?>
_icon"><?php 
                    echo $ability_info['ability_name'];
                    ?>
's Mugshot</div></div>
                            <?php 
                } else {
                    ?>
                                <div class="icon ability_type <?php 
                    echo $ability_header_types;
                    ?>
"><div style="background-image: none; background-color: #000000; background-color: rgba(0, 0, 0, 0.6); box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); " class="sprite sprite_ability sprite_40x40 sprite_40x40_icon sprite_size_<?php 
                    echo $ability_image_size_text;
                    ?>
 sprite_size_<?php 
                    echo $ability_image_size_text;
                    ?>
_icon">No Image</div></div>
                            <?php 
                }
                ?>
                        <?php 
            }
            ?>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_basics']) {
            ?>

                    <h2 class="header header_left <?php 
            echo $ability_header_types;
            ?>
 <?php 
            echo !$print_options['show_icon'] ? 'noicon' : '';
            ?>
">
                        <?php 
            if ($print_options['layout_style'] == 'website_compact') {
                ?>
                            <a href="<?php 
                echo preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' . preg_replace('/^item-/i', '', $ability_info['ability_token']) . '/' : 'database/abilities/' . $ability_info['ability_token'] . '/';
                ?>
"><?php 
                echo $ability_info['ability_name'];
                ?>
</a>
                        <?php 
            } else {
                ?>
                            <?php 
                echo $ability_info['ability_name'];
                ?>
&#39;s Data
                        <?php 
            }
            ?>
                        <?php 
            if (!empty($ability_info['ability_type_special'])) {
                ?>
                            <div class="header_core ability_type"><?php 
                echo ucfirst($ability_info['ability_type_special']);
                ?>
 Type</div>
                        <?php 
            } elseif (!empty($ability_info['ability_type']) && !empty($ability_info['ability_type2'])) {
                ?>
                            <div class="header_core ability_type"><?php 
                echo ucfirst($ability_info['ability_type']) . ' / ' . ucfirst($ability_info['ability_type2']);
                ?>
 Type</div>
                        <?php 
            } elseif (!empty($ability_info['ability_type'])) {
                ?>
                            <div class="header_core ability_type"><?php 
                echo ucfirst($ability_info['ability_type']);
                ?>
 Type</div>
                        <?php 
            } else {
                ?>
                            <div class="header_core ability_type">Neutral Type</div>
                        <?php 
            }
            ?>
                    </h2>
                    <div class="body body_left" style="margin-right: 0; margin-bottom: 5px; padding: 2px 0; min-height: 10px; <?php 
            echo !$print_options['show_icon'] ? 'margin-left: 0; ' : '';
            echo $print_options['layout_style'] == 'event' ? 'font-size: 10px; min-height: 150px; ' : '';
            ?>
">
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="48%" />
                                <col width="1%" />
                                <col width="48%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td  class="right">
                                        <label style="display: block; float: left;">Name :</label>
                                        <span class="ability_type ability_type_"><?php 
            echo $ability_info['ability_name'];
            ?>
</span>
                                    </td>
                                    <td class="center">&nbsp;</td>
                                    <td class="right">
                                        <label style="display: block; float: left;">Type :</label>
                                        <?php 
            if ($print_options['layout_style'] != 'event') {
                ?>
                                            <?php 
                if (!empty($ability_info['ability_type_special'])) {
                    echo '<a href="' . ((preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' : 'database/abilities/') . $ability_info['ability_type_special'] . '/') . '" class="ability_type ' . $ability_header_types . '">' . ucfirst($ability_info['ability_type_special']) . '</a>';
                } elseif (!empty($ability_info['ability_type'])) {
                    $temp_string = array();
                    $ability_type = !empty($ability_info['ability_type']) ? $ability_info['ability_type'] : 'none';
                    $temp_string[] = '<a href="' . ((preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' : 'database/abilities/') . $ability_type . '/') . '" class="ability_type ability_type_' . $ability_type . '">' . $mmrpg_types[$ability_type]['type_name'] . '</a>';
                    if (!empty($ability_info['ability_type2'])) {
                        $ability_type2 = !empty($ability_info['ability_type2']) ? $ability_info['ability_type2'] : 'none';
                        $temp_string[] = '<a href="' . ((preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' : 'database/abilities/') . $ability_type2 . '/') . '" class="ability_type ability_type_' . $ability_type2 . '">' . $mmrpg_types[$ability_type2]['type_name'] . '</a>';
                    }
                    echo implode(' ', $temp_string);
                } else {
                    echo '<a href="' . ((preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' : 'database/abilities/') . 'none/') . '" class="ability_type ability_type_none">Neutral</a>';
                }
                ?>
                                        <?php 
            } else {
                ?>
                                            <?php 
                if (!empty($ability_info['ability_type_special'])) {
                    echo '<span class="ability_type ' . $ability_header_types . '">' . ucfirst($ability_info['ability_type_special']) . '</span>';
                } elseif (!empty($ability_info['ability_type'])) {
                    $temp_string = array();
                    $ability_type = !empty($ability_info['ability_type']) ? $ability_info['ability_type'] : 'none';
                    $temp_string[] = '<span class="ability_type ability_type_' . $ability_type . '">' . $mmrpg_types[$ability_type]['type_name'] . '</span>';
                    if (!empty($ability_info['ability_type2'])) {
                        $ability_type2 = !empty($ability_info['ability_type2']) ? $ability_info['ability_type2'] : 'none';
                        $temp_string[] = '<span class="ability_type ability_type_' . $ability_type2 . '">' . $mmrpg_types[$ability_type2]['type_name'] . '</span>';
                    }
                    echo implode(' ', $temp_string);
                } else {
                    echo '<span class="ability_type ability_type_none">Neutral</span>';
                }
                ?>
                                        <?php 
            }
            ?>
                                    </td>
                                </tr>
                                <?php 
            if ($ability_info['ability_class'] != 'item') {
                ?>

                                    <?php 
                if ($ability_image_token != 'ability') {
                    ?>

                                        <tr>
                                            <td  class="right">
                                                <label style="display: block; float: left;">Power :</label>
                                                <?php 
                    if (!empty($ability_info['ability_damage']) || !empty($ability_info['ability_recovery'])) {
                        ?>
                                                    <?php 
                        if (!empty($ability_info['ability_damage'])) {
                            ?>
<span class="ability_stat"><?php 
                            echo $ability_info['ability_damage'] . (!empty($ability_info['ability_damage_percent']) ? '%' : '');
                            ?>
 Damage</span><?php 
                        }
                        ?>
                                                    <?php 
                        if (!empty($ability_info['ability_recovery'])) {
                            ?>
<span class="ability_stat"><?php 
                            echo $ability_info['ability_recovery'] . (!empty($ability_info['ability_recovery_percent']) ? '%' : '');
                            ?>
 Recovery</span><?php 
                        }
                        ?>
                                                <?php 
                    } else {
                        ?>
                                                    <span class="ability_stat">-</span>
                                                <?php 
                    }
                    ?>
                                            </td>
                                            <td class="center">&nbsp;</td>
                                            <td class="right">
                                                <label style="display: block; float: left;">Accuracy :</label>
                                                <span class="ability_stat"><?php 
                    echo $ability_info['ability_accuracy'] . '%';
                    ?>
</span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td  class="right">
                                                <label style="display: block; float: left;">Energy :</label>
                                                <span class="ability_stat"><?php 
                    echo (!empty($ability_info['ability_energy']) ? $ability_info['ability_energy'] : '-') . (!empty($ability_info['ability_energy_percent']) ? '%' : '');
                    ?>
</span>
                                            </td>
                                            <td class="center">&nbsp;</td>
                                            <td class="right">
                                                <label style="display: block; float: left;">Speed :</label>
                                                <span class="ability_stat"><?php 
                    echo !empty($ability_info['ability_speed']) ? $ability_info['ability_speed'] : '1';
                    ?>
</span>
                                            </td>
                                        </tr>

                                    <?php 
                } else {
                    ?>

                                        <tr>
                                            <td  class="right">
                                                <label style="display: block; float: left;">Power :</label>
                                                <span class="ability_stat">-</span>
                                            </td>
                                            <td class="center">&nbsp;</td>
                                            <td class="right">
                                                <label style="display: block; float: left;">Accuracy :</label>
                                                <span class="ability_stat">-</span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td  class="right">
                                                <label style="display: block; float: left;">Energy :</label>
                                                <span class="ability_stat">-</span>
                                            </td>
                                            <td class="center">&nbsp;</td>
                                            <td class="right">
                                                <label style="display: block; float: left;">Speed :</label>
                                                <span class="ability_stat">-</span>
                                            </td>
                                        </tr>

                                    <?php 
                }
                ?>

                                <?php 
            }
            ?>
                            </tbody>
                        </table>
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right">
                                        <?php 
            if ($print_options['layout_style'] != 'event') {
                ?>
                                            <label style="display: block; float: left;">Description :</label>
                                        <?php 
            }
            ?>
                                        <div class="description_container" style="white-space: normal; text-align: left; <?php 
            echo $print_options['layout_style'] == 'event' ? 'font-size: 12px; ' : '';
            ?>
 "><?php 
            // Define the search/replace pairs for the description
            $temp_find = array('{DAMAGE}', '{RECOVERY}', '{DAMAGE2}', '{RECOVERY2}', '{}');
            $temp_replace = array(!empty($ability_info['ability_damage']) ? $ability_info['ability_damage'] : 0, !empty($ability_info['ability_recovery']) ? $ability_info['ability_recovery'] : 0, !empty($ability_info['ability_damage2']) ? $ability_info['ability_damage2'] : 0, !empty($ability_info['ability_recovery2']) ? $ability_info['ability_recovery2'] : 0, '');
            $temp_description = !empty($ability_info['ability_description']) ? $ability_info['ability_description'] : '';
            if (!empty($ability_info['ability_description2'])) {
                $temp_description .= '  ' . $ability_info['ability_description2'];
            }
            echo !empty($temp_description) ? str_replace($temp_find, $temp_replace, $temp_description) : '&hellip;';
            ?>
</div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_sprites'] && (!isset($ability_info['ability_image_sheets']) || $ability_info['ability_image_sheets'] !== 0) && $ability_image_token != 'ability') {
            ?>

                    <?php 
            // Start the output buffer and prepare to collect sprites
            ob_start();
            // Define the alts we'll be looping through for this ability
            $temp_alts_array = array();
            $temp_alts_array[] = array('token' => '', 'name' => $ability_info['ability_name'], 'summons' => 0);
            // Append predefined alts automatically, based on the ability image alt array
            if (!empty($ability_info['ability_image_alts'])) {
                $temp_alts_array = array_merge($temp_alts_array, $ability_info['ability_image_alts']);
            } elseif ($ability_info['ability_type'] == 'copy' && preg_match('/^(mega-man|proto-man|bass)$/i', $ability_info['ability_token'])) {
                foreach ($mmrpg_database_types as $type_token => $type_info) {
                    if (empty($type_token) || $type_token == 'none' || $type_token == 'copy') {
                        continue;
                    }
                    $temp_alts_array[] = array('token' => $type_token, 'name' => $ability_info['ability_name'] . ' (' . ucfirst($type_token) . ' Core)', 'summons' => 0);
                }
            } elseif (!empty($ability_info['ability_image_sheets'])) {
                for ($i = 2; $i <= $ability_info['ability_image_sheets']; $i++) {
                    $temp_alts_array[] = array('sheet' => $i, 'name' => $ability_info['ability_name'] . ' (Sheet #' . $i . ')', 'summons' => 0);
                }
            }
            // Loop through the alts and display images for them (yay!)
            foreach ($temp_alts_array as $alt_key => $alt_info) {
                // Define the current image token with alt in mind
                $temp_ability_image_token = $ability_image_token;
                $temp_ability_image_token .= !empty($alt_info['token']) ? '_' . $alt_info['token'] : '';
                $temp_ability_image_token .= !empty($alt_info['sheet']) ? '-' . $alt_info['sheet'] : '';
                $temp_ability_image_name = $alt_info['name'];
                // Update the alt array with this info
                $temp_alts_array[$alt_key]['image'] = $temp_ability_image_token;
                // Collect the number of sheets
                $temp_sheet_number = !empty($ability_info['ability_image_sheets']) ? $ability_info['ability_image_sheets'] : 1;
                // Loop through the different frames and print out the sprite sheets
                foreach (array('right', 'left') as $temp_direction) {
                    $temp_direction2 = substr($temp_direction, 0, 1);
                    $temp_embed = '[ability:' . $temp_direction . ']{' . $temp_ability_image_token . '}';
                    $temp_title = $temp_ability_image_name . ' | Icon Sprite ' . ucfirst($temp_direction);
                    $temp_title .= '<div style="margin-top: 4px; letting-spacing: 1px; font-size: 90%; font-family: Courier New; color: rgb(159, 150, 172);">' . $temp_embed . '</div>';
                    $temp_title = htmlentities($temp_title, ENT_QUOTES, 'UTF-8', true);
                    $temp_label = 'Icon ' . ucfirst(substr($temp_direction, 0, 1));
                    echo '<div class="frame_container" data-clickcopy="' . $temp_embed . '" data-direction="' . $temp_direction . '" data-image="' . $temp_ability_image_token . '" data-frame="icon" style="padding-top: 20px; float: left; position: relative; margin: 0; box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.75); width: ' . $ability_sprite_size . 'px; height: ' . $ability_sprite_size . 'px; overflow: hidden;">';
                    echo '<img style="margin-left: 0;" data-tooltip="' . $temp_title . '" src="i/a/' . $temp_ability_image_token . '/i' . $temp_direction2 . $ability_sprite_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '" />';
                    echo '<label style="position: absolute; left: 5px; top: 0; color: #EFEFEF; font-size: 10px; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);">' . $temp_label . '</label>';
                    echo '</div>';
                }
                // Loop through the different frames and print out the sprite sheets
                foreach ($ability_sprite_frames as $this_key => $this_frame) {
                    $margin_left = ceil((0 - $this_key) * $ability_sprite_size);
                    $frame_relative = $this_frame;
                    //if ($temp_sheet > 1){ $frame_relative = 'frame_'.str_pad((($temp_sheet - 1) * count($ability_sprite_frames) + $this_key + 1), 2, '0', STR_PAD_LEFT); }
                    $frame_relative_text = ucfirst(str_replace('_', ' ', $frame_relative));
                    foreach (array('right', 'left') as $temp_direction) {
                        $temp_direction2 = substr($temp_direction, 0, 1);
                        $temp_embed = '[ability:' . $temp_direction . ':' . $frame_relative . ']{' . $temp_ability_image_token . '}';
                        $temp_title = $temp_ability_image_name . ' | ' . $frame_relative_text . ' Sprite ' . ucfirst($temp_direction);
                        $temp_title .= '<div style="margin-top: 4px; letting-spacing: 1px; font-size: 90%; font-family: Courier New; color: rgb(159, 150, 172);">' . $temp_embed . '</div>';
                        $temp_title = htmlentities($temp_title, ENT_QUOTES, 'UTF-8', true);
                        $temp_label = $frame_relative_text . ' ' . ucfirst(substr($temp_direction, 0, 1));
                        //$image_token = !empty($ability_info['ability_image']) ? $ability_info['ability_image'] : $ability_info['ability_token'];
                        //if ($temp_sheet > 1){ $temp_ability_image_token .= '-'.$temp_sheet; }
                        echo '<div class="frame_container" data-clickcopy="' . $temp_embed . '" data-direction="' . $temp_direction . '" data-image="' . $temp_ability_image_token . '" data-frame="' . $frame_relative . '" style="padding-top: 20px; float: left; position: relative; margin: 0; box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.75); width: ' . $ability_sprite_size . 'px; height: ' . $ability_sprite_size . 'px; overflow: hidden;">';
                        echo '<img style="margin-left: ' . $margin_left . 'px;" title="' . $temp_title . '" alt="' . $temp_title . '" src="i/a/' . $temp_ability_image_token . '/s' . $temp_direction2 . $ability_sprite_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '" />';
                        echo '<label style="position: absolute; left: 5px; top: 0; color: #EFEFEF; font-size: 10px; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);">' . $temp_label . '</label>';
                        echo '</div>';
                    }
                }
            }
            // Collect the sprite markup from the output buffer for later
            $this_sprite_markup = ob_get_clean();
            ?>

                    <h2 id="sprites" class="header header_full <?php 
            echo $ability_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left;">
                        <?php 
            echo $ability_info['ability_name'];
            ?>
&#39;s Sprites
                        <span class="header_links image_link_container">
                            <span class="images" style="<?php 
            echo count($temp_alts_array) == 1 ? 'visibility: hidden;' : '';
            ?>
"><?php 
            // Loop though and print links for the alts
            foreach ($temp_alts_array as $alt_key => $alt_info) {
                $alt_type = '';
                $alt_style = '';
                $alt_title = $alt_info['name'];
                if (preg_match('/^(?:[-_a-z0-9\\s]+)\\s\\(([a-z0-9]+)\\sCore\\)$/i', $alt_info['name'])) {
                    $alt_type = strtolower(preg_replace('/^(?:[-_a-z0-9\\s]+)\\s\\(([a-z0-9]+)\\sCore\\)$/i', '$1', $alt_info['name']));
                    $alt_name = '&bull;';
                    //ucfirst($alt_type); //substr(ucfirst($alt_type), 0, 2);
                    $alt_type = 'ability_type ability_type_' . $alt_type . ' core_type ';
                    $alt_style = 'border-color: rgba(0, 0, 0, 0.2) !important; ';
                } else {
                    $alt_name = $alt_key + 1;
                    //$alt_key == 0 ? $ability_info['ability_name'] : 'Alt'.($alt_key > 1 ? ' '.$alt_key : ''); //$alt_key == 0 ? $ability_info['ability_name'] : $ability_info['ability_name'].' Alt'.($alt_key > 1 ? ' '.$alt_key : '');
                    $alt_type = 'ability_type ability_type_empty ';
                    $alt_style = 'border-color: rgba(0, 0, 0, 0.2) !important; background-color: rgba(0, 0, 0, 0.2) !important; ';
                    //if ($ability_info['ability_type'] == 'copy' && $alt_key == 0){ $alt_type = 'ability_type ability_type_empty '; }
                }
                echo '<a href="#" data-tooltip="' . $alt_title . '" class="link link_image ' . ($alt_key == 0 ? 'link_active ' : '') . '" data-image="' . $alt_info['image'] . '">';
                echo '<span class="' . $alt_type . '" style="' . $alt_style . '">' . $alt_name . '</span>';
                echo '</a>';
            }
            ?>
</span>
                            <span class="pipe" style="<?php 
            echo count($temp_alts_array) == 1 ? 'visibility: hidden;' : '';
            ?>
">|</span>
                            <span class="directions"><?php 
            // Loop though and print links for the alts
            foreach (array('right', 'left') as $temp_key => $temp_direction) {
                echo '<a href="#" data-tooltip="' . ucfirst($temp_direction) . ' Facing Sprites" class="link link_direction ' . ($temp_key == 0 ? 'link_active' : '') . '" data-direction="' . $temp_direction . '">';
                echo '<span class="ability_type ability_type_empty" style="border-color: rgba(0, 0, 0, 0.2) !important; background-color: rgba(0, 0, 0, 0.2) !important; ">' . ucfirst($temp_direction) . '</span>';
                echo '</a>';
            }
            ?>
</span>
                        </span>
                    </h2>
                    <div id="sprites_body" class="body body_full" style="margin: 0; padding: 10px; min-height: auto;">
                        <div style="border: 1px solid rgba(0, 0, 0, 0.20); border-radius: 0.5em; -moz-border-radius: 0.5em; -webkit-border-radius: 0.5em; background: #4d4d4d url(images/assets/sprite-grid.gif) scroll repeat -10px -30px; overflow: hidden; padding: 10px 30px;">
                            <?php 
            echo $this_sprite_markup;
            ?>
                        </div>
                        <?
                        // Collect the sprite contributor index for display
                        $user_fields = rpg_user::get_fields(true, 'user');
                        $user_role_fields = rpg_user_role::get_fields(true, 'role');
                        $contributor_index = $db->get_array_list("SELECT
                            {$user_fields},
                            {$user_role_fields},
                            (CASE WHEN user.user_name_public <> ''
                                THEN user.user_name_public
                                ELSE user.user_name
                                END) AS user_name_current
                            FROM mmrpg_users AS user
                            LEFT JOIN mmrpg_roles AS role ON role.role_id = user.role_id
                            WHERE role.role_token IN ('developer', 'administrator', 'contributor', 'moderator')
                            ORDER BY user_name_current ASC;
                            ", 'user_id');
                        // Define the editor title based on ID
                        $temp_editor_title = 'Undefined';
                        $temp_final_divider = '<span style="color: #565656;"> | </span>';
                        $temp_editor_ids = array();
                        // Check if an image editor ID has been defined
                        if (!empty($ability_info['ability_image_editor']) && isset($contributor_index[$ability_info['ability_image_editor']])){
                            $temp_editor_ids[] = $ability_info['ability_image_editor'];
                        }
                        // Check if a second image editor ID has been defined
                        if (!empty($ability_info['ability_image_editor2']) && isset($contributor_index[$ability_info['ability_image_editor2']])){
                            $temp_editor_ids[] = $ability_info['ability_image_editor2'];
                        }
                        // If not empty, loop through and add image editors to the string
                        if (!empty($temp_editor_ids)){
                            $temp_editor_title = array();
                            foreach ($temp_editor_ids AS $editor_id){
                                $temp_editor = $contributor_index[$editor_id];
                                $temp_name_public = !empty($temp_editor['user_name_public']) ? $temp_editor['user_name_public'] : $temp_editor['user_name'];
                                $temp_name_real = !empty($temp_editor['user_name']) ? $temp_editor['user_name'] : $temp_editor['user_name_clean'];
                                $temp_name_public_clean = preg_replace('/[^a-z0-9]+/i', '', strtolower($temp_name_public));
                                $temp_name_real_clean = preg_replace('/[^a-z0-9]+/i', '', strtolower($temp_name_real));
                                if ($temp_name_public_clean != $temp_name_real_clean){ $temp_editor_title[] = '<strong>'.$temp_name_public.' / '.$temp_name_real.'</strong>'; }
                                else { $temp_editor_title[] = '<strong>'.$temp_name_public.'</strong>'; }
                            }
                            if (count($temp_editor_title) > 1){ $temp_final_divider = '<br />'; }
                            $temp_editor_title = implode(' and ', $temp_editor_title);
                        }
                        // Print out the final credits footer based on if special case or Capcom original
                        if ($ability_info['ability_game'] == 'MMRPG'){
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Artwork by <strong>Mega Man RPG Prototype</strong></p>'."\n";
                        } elseif ($ability_info['ability_game'] == 'MMRPG2'){
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Artwork by <strong>Mega Man RPG World</strong></p>'."\n";
                        } else {
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Artwork by <strong>Capcom</strong></p>'."\n";
                        }

                        ?>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_robots'] && $ability_info['ability_class'] != 'item') {
            ?>

                    <h2 class="header header_full <?php 
            echo $ability_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left;">
                        <?php 
            echo $ability_info['ability_name'];
            ?>
&#39;s Robots
                    </h2>
                    <div class="body body_full" style="margin: 0; padding: 2px 3px;">
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right">
                                        <div class="robot_container">
                                        <?php 
            // Collect the full robot index to loop through
            $ability_type_one = !empty($ability_info['ability_type']) ? $ability_info['ability_type'] : false;
            $ability_type_two = !empty($ability_info['ability_type2']) ? $ability_info['ability_type2'] : false;
            $ability_robot_rewards = array();
            $ability_robot_rewards_level = array();
            $ability_robot_rewards_core = array();
            $ability_robot_rewards_player = array();
            // Collect a FULL list of abilities for display
            $temp_required = array();
            if (!empty($ability_info['ability_master'])) {
                $temp_required[] = $ability_info['ability_master'];
            }
            $temp_robots_index = rpg_robot::get_index(false, false, 'master', $temp_required);
            // Loop through and remove any robots that do not learn the ability
            foreach ($temp_robots_index as $robot_token => $robot_info) {
                // Define the match flah to prevent doubling up
                $temp_match_flag = false;
                // Loop through this robot's ability rewards one by one
                foreach ($robot_info['robot_rewards']['abilities'] as $temp_info) {
                    // If the temp info's type token matches this ability
                    if ($temp_info['token'] == $ability_info['ability_token']) {
                        // Add this ability to the rewards list
                        $ability_robot_rewards_level[] = array_merge($robot_info, array('token' => $robot_info['robot_token'], 'level' => $temp_info['level']));
                        $temp_match_flag = true;
                        break;
                    }
                }
                // If a type match was found, continue
                if ($temp_match_flag) {
                    continue;
                }
                // If this ability's type matches the robot's first
                if (!empty($robot_info['robot_core']) && ($robot_info['robot_core'] == $ability_type_one || $robot_info['robot_core'] == $ability_type_two)) {
                    // Add this ability to the rewards list
                    $ability_robot_rewards_core[] = array_merge($robot_info, array('token' => $robot_info['robot_token'], 'level' => 'core'));
                    continue;
                }
                // If this ability's type matches the robot's second
                if (!empty($robot_info['robot_core2']) && ($robot_info['robot_core2'] == $ability_type_one || $robot_info['robot_core2'] == $ability_type_two)) {
                    // Add this ability to the rewards list
                    $ability_robot_rewards_core[] = array_merge($robot_info, array('token' => $robot_info['robot_token'], 'level' => 'core'));
                    continue;
                }
                // If a type match was found, continue
                if ($temp_match_flag) {
                    continue;
                }
                // If this ability's in the robot's list of player-only abilities
                if (!empty($robot_info['robot_abilities']) && in_array($ability_info['ability_token'], $robot_info['robot_abilities']) || !empty($robot_info['robot_core']) && $robot_info['robot_core'] == 'copy' || !empty($robot_info['robot_core2']) && $robot_info['robot_core2'] == 'copy') {
                    // Add this ability to the rewards list
                    $ability_robot_rewards_player[] = array_merge($robot_info, array('token' => $robot_info['robot_token'], 'level' => 'player'));
                    continue;
                }
                // If a type match was found, continue
                if ($temp_match_flag) {
                    continue;
                }
            }
            // Combine the arrays together into one
            $ability_robot_rewards = array_merge($ability_robot_rewards_level, $ability_robot_rewards_core, $ability_robot_rewards_player);
            // Loop through the collected robots if there are any
            if (!empty($ability_robot_rewards)) {
                $temp_string = array();
                $robot_key = 0;
                $robot_method_key = 0;
                $robot_method = '';
                $temp_global_abilities = self::get_global_abilities();
                foreach ($ability_robot_rewards as $this_info) {
                    $this_level = $this_info['level'];
                    $this_robot = $temp_robots_index[$this_info['token']];
                    $this_robot_token = $this_robot['robot_token'];
                    $this_robot_name = $this_robot['robot_name'];
                    $this_robot_image = !empty($this_robot['robot_image']) ? $this_robot['robot_image'] : $this_robot['robot_token'];
                    $this_robot_energy = !empty($this_robot['robot_energy']) ? $this_robot['robot_energy'] : 0;
                    $this_robot_attack = !empty($this_robot['robot_attack']) ? $this_robot['robot_attack'] : 0;
                    $this_robot_defense = !empty($this_robot['robot_defense']) ? $this_robot['robot_defense'] : 0;
                    $this_robot_speed = !empty($this_robot['robot_speed']) ? $this_robot['robot_speed'] : 0;
                    $this_robot_method = 'level';
                    $this_robot_method_text = 'Level Up';
                    $this_robot_title_html = '<strong class="name">' . $this_robot_name . '</strong>';
                    if (is_numeric($this_level)) {
                        if ($this_level > 1) {
                            $this_robot_title_html .= '<span class="level">Lv ' . str_pad($this_level, 2, '0', STR_PAD_LEFT) . '</span>';
                        } else {
                            $this_robot_title_html .= '<span class="level">Start</span>';
                        }
                    } else {
                        if ($this_level == 'core') {
                            $this_robot_method = 'core';
                            $this_robot_method_text = 'Core Match';
                        } elseif ($this_level == 'player') {
                            $this_robot_method = 'player';
                            $this_robot_method_text = 'Player Only';
                        }
                        $this_robot_title_html .= '<span class="level">&nbsp;</span>';
                    }
                    $this_stat_base_total = $this_robot_energy + $this_robot_attack + $this_robot_defense + $this_robot_speed;
                    $this_stat_width_total = 84;
                    if (!empty($this_robot['robot_core'])) {
                        $this_robot_title_html .= '<span class="robot_core type_' . $this_robot['robot_core'] . '">' . ucwords($this_robot['robot_core'] . (!empty($this_robot['robot_core2']) ? ' / ' . $this_robot['robot_core2'] : '')) . ' Core</span>';
                    } else {
                        $this_robot_title_html .= '<span class="robot_core type_none">Neutral Core</span>';
                    }
                    $this_robot_title_html .= '<span class="class">' . (!empty($this_robot['robot_description']) ? $this_robot['robot_description'] : '&hellip;') . '</span>';
                    if (!empty($this_robot_speed)) {
                        $temp_speed_width = floor($this_stat_width_total * ($this_robot_speed / $this_stat_base_total));
                    }
                    if (!empty($this_robot_defense)) {
                        $temp_defense_width = floor($this_stat_width_total * ($this_robot_defense / $this_stat_base_total));
                    }
                    if (!empty($this_robot_attack)) {
                        $temp_attack_width = floor($this_stat_width_total * ($this_robot_attack / $this_stat_base_total));
                    }
                    if (!empty($this_robot_energy)) {
                        $temp_energy_width = $this_stat_width_total - ($temp_speed_width + $temp_defense_width + $temp_attack_width);
                    }
                    if (!empty($this_robot_energy)) {
                        $this_robot_title_html .= '<span class="energy robot_type robot_type_energy" style="width: ' . $temp_energy_width . '%;" title="' . $this_robot_energy . ' Energy">' . $this_robot_energy . '</span>';
                    }
                    if (!empty($this_robot_attack)) {
                        $this_robot_title_html .= '<span class="attack robot_type robot_type_attack" style="width: ' . $temp_attack_width . '%;" title="' . $this_robot_attack . ' Attack">' . $this_robot_attack . '</span>';
                    }
                    if (!empty($this_robot_defense)) {
                        $this_robot_title_html .= '<span class="defense robot_type robot_type_defense" style="width: ' . $temp_defense_width . '%;" title="' . $this_robot_defense . ' Defense">' . $this_robot_defense . '</span>';
                    }
                    if (!empty($this_robot_speed)) {
                        $this_robot_title_html .= '<span class="speed robot_type robot_type_speed" style="width: ' . $temp_speed_width . '%;" title="' . $this_robot_speed . ' Speed">' . $this_robot_speed . '</span>';
                    }
                    $this_robot_sprite_size = !empty($this_robot['robot_image_size']) ? $this_robot['robot_image_size'] : 40;
                    $this_robot_sprite_path = 'images/sprites/robots/' . $this_robot_image . '/mug_left_' . $this_robot_sprite_size . 'x' . $this_robot_sprite_size . '.png';
                    if (!file_exists(MMRPG_CONFIG_ROOTDIR . $this_robot_sprite_path)) {
                        $this_robot_image = 'robot';
                        $this_robot_sprite_path = 'i/r/robot/ml40.png';
                    } else {
                        $this_robot_sprite_path = 'i/r/' . $this_robot_image . '/ml' . $this_robot_sprite_size . '.png';
                    }
                    if ($this_robot_image != 'robot') {
                        $this_robot_sprite_html = '<span class="mug"><img class="size_' . $this_robot_sprite_size . 'x' . $this_robot_sprite_size . '" src="' . $this_robot_sprite_path . '?' . MMRPG_CONFIG_CACHE_DATE . '" alt="' . $this_robot_name . ' Mug" /></span>';
                    } else {
                        $this_robot_sprite_html = '<span class="mug"></span>';
                    }
                    $this_robot_title_html = '<span class="label">' . $this_robot_title_html . '</span>';
                    //$this_robot_title_html = (is_numeric($this_level) && $this_level > 1 ? 'Lv '.str_pad($this_level, 2, '0', STR_PAD_LEFT).' : ' : $this_level.' : ').$this_robot_title_html;
                    if ($robot_method != $this_robot_method) {
                        if ($this_robot_method == 'level' && $ability_info['ability_token'] == 'buster-shot') {
                            continue;
                        }
                        $temp_separator = '<div class="robot_separator">' . $this_robot_method_text . '</div>';
                        $temp_string[] = $temp_separator;
                        $robot_method = $this_robot_method;
                        $robot_method_key++;
                        // Print out the disclaimer if a global ability
                        if (in_array($ability_info['ability_token'], $temp_global_abilities)) {
                            $temp_string[] = '<div class="" style="margin: 10px auto; text-align: center; color: #767676; font-size: 11px;">' . $ability_info['ability_name'] . ' can be equipped by <em>any</em> robot master!</div>';
                        }
                    }
                    // If this is a global ability, don't bother showing EVERY compatible robot
                    if ($this_robot_method == 'level' && $ability_info['ability_token'] == 'buster-shot' || $this_robot_method != 'level' && in_array($ability_info['ability_token'], $temp_global_abilities)) {
                        continue;
                    }
                    if ($this_level >= 0) {
                        //title="'.$this_robot_title_plain.'"
                        $temp_markup = '<a href="' . MMRPG_CONFIG_ROOTURL . 'database/robots/' . $this_robot['robot_token'] . '/"  class="robot_name robot_type robot_type_' . (!empty($this_robot['robot_core']) ? $this_robot['robot_core'] . (!empty($this_robot['robot_core2']) ? '_' . $this_robot['robot_core2'] : '') : 'none') . '" style="' . ($this_robot_image == 'robot' ? 'opacity: 0.3; ' : '') . '">';
                        $temp_markup .= '<span class="chrome">' . $this_robot_sprite_html . $this_robot_title_html . '</span>';
                        $temp_markup .= '</a>';
                        $temp_string[] = $temp_markup;
                        $robot_key++;
                        continue;
                    }
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_ability robot_type_none"><span class="chrome">Neutral</span></span>';
            }
            ?>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_footer'] && $print_options['layout_style'] == 'website') {
            ?>

                    <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                    <a class="link link_permalink permalink" href="<?php 
            echo preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' . preg_replace('/^item-/i', '', $ability_info['ability_token']) . '/' : 'database/abilities/' . $ability_info['ability_token'] . '/';
            ?>
" rel="permalink">+ Permalink</a>

                <?php 
        } elseif ($print_options['show_footer'] && $print_options['layout_style'] == 'website_compact') {
            ?>

                    <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                    <a class="link link_permalink permalink" href="<?php 
            echo preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' . preg_replace('/^item-/i', '', $ability_info['ability_token']) . '/' : 'database/abilities/' . $ability_info['ability_token'] . '/';
            ?>
" rel="permalink">+ View More</a>

                <?php 
        }
        ?>

            </div>
        </div>
        <?php 
        // Collect the outbut buffer contents
        $this_markup = trim(ob_get_clean());
        // Return the generated markup
        return $this_markup;
    }
Exemple #3
0
    </div>');
}
*/
/*
 * INDEX PAGE : FILE
 */
// Define the SEO variables for this page
//$this_seo_title = 'File | '.$this_seo_title;
//$this_seo_description = 'Mega Man RPG World 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.';
// Define the MARKUP variables for this page
//$this_markup_header = 'Mega Man RPG World File';
// Include the database index array files
require 'database/types.php';
require 'database/robots.php';
// Collect an index of user roles for display
$role_fields = rpg_user_role::get_fields(true);
$this_roles_index = $db->get_array_list("SELECT {$role_fields} FROM mmrpg_roles ORDER BY role_id ASC", 'role_id');
$this_fields_index = rpg_field::get_index();
// Collect the current request type if set
$this_action = $this_current_sub;
$allow_fadein = true;
// Define the allowable actions in this script
$allowed_actions = array('save', 'new', 'load', 'unload', 'reset', 'exit', 'game', 'profile');
// If this action is not allowed, kill the script
if (empty($this_action)) {
    die('An action must be defined!');
} elseif (!in_array($this_action, $allowed_actions)) {
    die(ucfirst($this_action) . ' is not an allowed action!');
} else {
    $allow_fadein = false;
}
    public static function print_database_markup($robot_info, $print_options = array(), $cache_markup = false)
    {
        // Define the markup variable
        $this_markup = '';
        // Define the global variables
        global $mmrpg_index, $this_current_uri, $this_current_url, $db;
        global $mmrpg_database_players, $mmrpg_database_items, $mmrpg_database_fields, $mmrpg_database_types;
        global $mmrpg_stat_base_max_value;
        // Collect the approriate database indexes
        if (empty($mmrpg_database_players)) {
            $mmrpg_database_players = rpg_player::get_index(true);
        }
        if (empty($mmrpg_database_items)) {
            $mmrpg_database_items = rpg_item::get_index(true);
        }
        if (empty($mmrpg_database_fields)) {
            $mmrpg_database_fields = rpg_field::get_index(true);
        }
        if (empty($mmrpg_database_types)) {
            $mmrpg_database_types = rpg_type::get_index();
        }
        // Define the print style defaults
        if (!isset($print_options['layout_style'])) {
            $print_options['layout_style'] = 'website';
        }
        if ($print_options['layout_style'] == 'website') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_mugshot'])) {
                $print_options['show_mugshot'] = true;
            }
            if (!isset($print_options['show_quotes'])) {
                $print_options['show_quotes'] = true;
            }
            if (!isset($print_options['show_description'])) {
                $print_options['show_description'] = true;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = true;
            }
            if (!isset($print_options['show_abilities'])) {
                $print_options['show_abilities'] = true;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = true;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = true;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
            if (!isset($print_options['show_stats'])) {
                $print_options['show_stats'] = true;
            }
        } elseif ($print_options['layout_style'] == 'website_compact') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_mugshot'])) {
                $print_options['show_mugshot'] = true;
            }
            if (!isset($print_options['show_quotes'])) {
                $print_options['show_quotes'] = false;
            }
            if (!isset($print_options['show_description'])) {
                $print_options['show_description'] = false;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = false;
            }
            if (!isset($print_options['show_abilities'])) {
                $print_options['show_abilities'] = false;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = false;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = true;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
            if (!isset($print_options['show_stats'])) {
                $print_options['show_stats'] = false;
            }
        } elseif ($print_options['layout_style'] == 'event') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_mugshot'])) {
                $print_options['show_mugshot'] = false;
            }
            if (!isset($print_options['show_quotes'])) {
                $print_options['show_quotes'] = false;
            }
            if (!isset($print_options['show_description'])) {
                $print_options['show_description'] = false;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = false;
            }
            if (!isset($print_options['show_abilities'])) {
                $print_options['show_abilities'] = false;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = false;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = false;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
            if (!isset($print_options['show_stats'])) {
                $print_options['show_stats'] = false;
            }
        }
        // Collect the robot sprite dimensions
        $robot_image_size = !empty($robot_info['robot_image_size']) ? $robot_info['robot_image_size'] : 40;
        $robot_image_size_text = $robot_image_size . 'x' . $robot_image_size;
        $robot_image_token = !empty($robot_info['robot_image']) ? $robot_info['robot_image'] : $robot_info['robot_token'];
        //die('<pre>$robot_info = '.print_r($robot_info, true).'</pre>');
        // Collect the robot's type for background display
        $robot_header_types = 'type_' . (!empty($robot_info['robot_core']) ? $robot_info['robot_core'] . (!empty($robot_info['robot_core2']) ? '_' . $robot_info['robot_core2'] : '') : 'none') . ' ';
        // Define the sprite sheet alt and title text
        $robot_sprite_size = $robot_image_size * 2;
        $robot_sprite_size_text = $robot_sprite_size . 'x' . $robot_sprite_size;
        $robot_sprite_title = $robot_info['robot_name'];
        // Prepare the variable for extra text
        $robot_info['robot_name_append'] = '';
        // Define the sprite frame index for robot images
        $robot_sprite_frames = array('base', 'taunt', 'victory', 'defeat', 'shoot', 'throw', 'summon', 'slide', 'defend', 'damage', 'base2');
        // Collect the field info if applicable
        $field_info_array = array();
        $temp_robot_fields = array();
        if (!empty($robot_info['robot_field']) && $robot_info['robot_field'] != 'field') {
            $temp_robot_fields[] = $robot_info['robot_field'];
        }
        if (!empty($robot_info['robot_field2'])) {
            $temp_robot_fields = array_merge($temp_robot_fields, $robot_info['robot_field2']);
        }
        if ($temp_robot_fields) {
            foreach ($temp_robot_fields as $key => $token) {
                if (!empty($mmrpg_database_fields[$token])) {
                    $field_info_array[] = rpg_field::parse_index_info($mmrpg_database_fields[$token]);
                }
            }
        }
        // Define the class token for this robot
        $robot_class_token = '';
        $robot_class_token_plural = '';
        if ($robot_info['robot_class'] == 'master') {
            $robot_class_token = 'robot';
            $robot_class_token_plural = 'robots';
        } elseif ($robot_info['robot_class'] == 'mecha') {
            $robot_class_token = 'mecha';
            $robot_class_token_plural = 'mechas';
        } elseif ($robot_info['robot_class'] == 'boss') {
            $robot_class_token = 'boss';
            $robot_class_token_plural = 'bosses';
        }
        // Define the default class tokens for "empty" images
        $default_robot_class_tokens = array('robot', 'mecha', 'boss');
        // Automatically disable sections if content is unavailable
        if (empty($robot_info['robot_description2'])) {
            $print_options['show_description'] = false;
        }
        if (isset($robot_info['robot_image_sheets']) && $robot_info['robot_image_sheets'] === 0) {
            $print_options['show_sprites'] = false;
        } elseif (in_array($robot_image_token, $default_robot_class_tokens)) {
            $print_options['show_sprites'] = false;
        }
        // Define the base URLs for this robot
        $database_url = 'database/';
        $database_category_url = $database_url;
        if ($robot_info['robot_class'] == 'master') {
            $database_category_url .= 'robots/';
        } elseif ($robot_info['robot_class'] == 'mecha') {
            $database_category_url .= 'mechas/';
        } elseif ($robot_info['robot_class'] == 'boss') {
            $database_category_url .= 'bosses/';
        }
        $database_category_robot_url = $database_category_url . $robot_info['robot_token'] . '/';
        // Calculate the robot base stat total
        $robot_info['robot_total'] = 0;
        $robot_info['robot_total'] += $robot_info['robot_energy'];
        $robot_info['robot_total'] += $robot_info['robot_attack'];
        $robot_info['robot_total'] += $robot_info['robot_defense'];
        $robot_info['robot_total'] += $robot_info['robot_speed'];
        // Calculate this robot's maximum base stat for reference
        $robot_info['robot_max_stat_name'] = 'unknown';
        $robot_info['robot_max_stat_value'] = 0;
        $temp_types = array('energy', 'attack', 'defense', 'speed');
        foreach ($temp_types as $type) {
            if ($robot_info['robot_' . $type] > $robot_info['robot_max_stat_value']) {
                $robot_info['robot_max_stat_value'] = $robot_info['robot_' . $type];
                $robot_info['robot_max_stat_name'] = $type;
            }
        }
        // Collect the database records for this robot
        if ($print_options['show_records']) {
            global $db;
            $temp_robot_records = array('robot_encountered' => 0, 'robot_defeated' => 0, 'robot_unlocked' => 0, 'robot_summoned' => 0, 'robot_scanned' => 0);
            //$temp_robot_records['player_count'] = $db->get_value("SELECT COUNT(board_id) AS player_count  FROM mmrpg_leaderboard WHERE board_robots LIKE '%[".$robot_info['robot_token'].":%' AND board_points > 0", 'player_count');
            $temp_player_query = "SELECT\n                mmrpg_saves.user_id,\n                mmrpg_saves.save_values_robot_database,\n                mmrpg_leaderboard.board_points\n                FROM mmrpg_saves\n                LEFT JOIN mmrpg_leaderboard ON mmrpg_leaderboard.user_id = mmrpg_saves.user_id\n                WHERE mmrpg_saves.save_values_robot_database LIKE '%\"{$robot_info['robot_token']}\"%' AND mmrpg_leaderboard.board_points > 0;";
            $temp_player_list = $db->get_array_list($temp_player_query);
            if (!empty($temp_player_list)) {
                foreach ($temp_player_list as $temp_data) {
                    $temp_values = !empty($temp_data['save_values_robot_database']) ? json_decode($temp_data['save_values_robot_database'], true) : array();
                    $temp_entry = !empty($temp_values[$robot_info['robot_token']]) ? $temp_values[$robot_info['robot_token']] : array();
                    foreach ($temp_robot_records as $temp_record => $temp_count) {
                        if (!empty($temp_entry[$temp_record])) {
                            $temp_robot_records[$temp_record] += $temp_entry[$temp_record];
                        }
                    }
                }
            }
            $temp_values = array();
            //echo '<pre>'.print_r($temp_robot_records, true).'</pre>';
        }
        // Define the common stat container variables
        $stat_container_percent = 74;
        $stat_base_max_value = 2000;
        $stat_padding_area = 76;
        if (!empty($mmrpg_stat_base_max_value[$robot_info['robot_class']])) {
            $stat_base_max_value = $mmrpg_stat_base_max_value[$robot_info['robot_class']];
        } elseif ($robot_info['robot_class'] == 'master') {
            $stat_base_max_value = 400;
        } elseif ($robot_info['robot_class'] == 'mecha') {
            $stat_base_max_value = 400;
        } elseif ($robot_info['robot_class'] == 'boss') {
            $stat_base_max_value = 2000;
        }
        // If this is a mecha class, do not show potential stat totals... for now
        //if ($robot_info['robot_class'] != 'master'){
        //  $print_options['show_stats'] = false;
        //}
        // Define the variable to hold compact footer link markup
        $compact_footer_link_markup = array();
        //$compact_footer_link_markup[] = '<a class="link link_permalink" href="'.$database_category_robot_url.'">+ Huh?</a>';
        // Add a link to the sprites in the compact footer markup
        if (!in_array($robot_image_token, $default_robot_class_tokens)) {
            $compact_footer_link_markup[] = '<a class="link" href="' . $database_category_robot_url . '#sprites">#Sprites</a>';
        }
        if (!empty($robot_info['robot_quotes']['battle_start'])) {
            $compact_footer_link_markup[] = '<a class="link" href="' . $database_category_robot_url . '#quotes">#Quotes</a>';
        }
        if (!empty($robot_info['robot_description2'])) {
            $compact_footer_link_markup[] = '<a class="link" href="' . $database_category_robot_url . '#description">#Description</a>';
        }
        if (!empty($robot_info['robot_abilities'])) {
            $compact_footer_link_markup[] = '<a class="link" href="' . $database_category_robot_url . '#abilities">#Abilities</a>';
        }
        $compact_footer_link_markup[] = '<a class="link" href="' . $database_category_robot_url . '#stats">#Stats</a>';
        $compact_footer_link_markup[] = '<a class="link" href="' . $database_category_robot_url . '#records">#Records</a>';
        /*
        $compact_footer_link_markup[] = '<a class="link '.$robot_header_types.'" href="'.$database_category_robot_url.'">View More</a>';
        */
        // Start the output buffer
        ob_start();
        /*<div class="database_container database_<?= $robot_class_token ?>_container database_<?= $print_options['layout_style'] ?>_container" data-token="<?= $robot_info['robot_token']?>" style="<?= $print_options['layout_style'] == 'website_compact' ? 'margin-bottom: 2px !important;' : '' ?>">*/
        ?>
        <div class="database_container layout_<?php 
        echo str_replace('website_', '', $print_options['layout_style']);
        ?>
" data-token="<?php 
        echo $robot_info['robot_token'];
        ?>
">

            <?php 
        if ($print_options['layout_style'] == 'website' || $print_options['layout_style'] == 'website_compact') {
            ?>
                <a class="anchor" id="<?php 
            echo $robot_info['robot_token'];
            ?>
"></a>
            <?php 
        }
        ?>

            <div class="subbody event event_triple event_visible" data-token="<?php 
        echo $robot_info['robot_token'];
        ?>
">

                <?php 
        if ($print_options['show_mugshot']) {
            ?>

                    <div class="this_sprite sprite_left" style="height: 40px;">
                        <?php 
            if ($print_options['show_mugshot']) {
                ?>
                            <?php 
                if ($print_options['show_key'] !== false) {
                    ?>
                                <div class="mugshot robot_type <?php 
                    echo $robot_header_types;
                    ?>
" style="font-size: 9px; line-height: 11px; text-align: center; margin-bottom: 2px; padding: 0 0 1px !important;"><?php 
                    echo 'No.' . $robot_info['robot_key'];
                    ?>
</div>
                            <?php 
                }
                ?>
                            <?php 
                if (!in_array($robot_image_token, $default_robot_class_tokens)) {
                    ?>
                                <div class="mugshot robot_type <?php 
                    echo $robot_header_types;
                    ?>
"><div style="background-image: url(i/r/<?php 
                    echo $robot_image_token;
                    ?>
/mr<?php 
                    echo $robot_image_size;
                    ?>
.png?<?php 
                    echo MMRPG_CONFIG_CACHE_DATE;
                    ?>
); " class="sprite sprite_robot sprite_40x40 sprite_40x40_mug sprite_size_<?php 
                    echo $robot_image_size_text;
                    ?>
 sprite_size_<?php 
                    echo $robot_image_size_text;
                    ?>
_mug robot_status_active robot_position_active"><?php 
                    echo $robot_info['robot_name'];
                    ?>
's Mugshot</div></div>
                            <?php 
                } else {
                    ?>
                                <div class="mugshot robot_type <?php 
                    echo $robot_header_types;
                    ?>
"><div style="background-image: none; background-color: #000000; background-color: rgba(0, 0, 0, 0.6); " class="sprite sprite_robot sprite_40x40 sprite_40x40_mug sprite_size_<?php 
                    echo $robot_image_size_text;
                    ?>
 sprite_size_<?php 
                    echo $robot_image_size_text;
                    ?>
_mug robot_status_active robot_position_active">No Image</div></div>
                            <?php 
                }
                ?>
                        <?php 
            }
            ?>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_basics']) {
            ?>

                    <h2 class="header header_left <?php 
            echo $robot_header_types;
            ?>
 <?php 
            echo !$print_options['show_mugshot'] ? 'nomug' : '';
            ?>
" style="<?php 
            echo !$print_options['show_mugshot'] ? 'margin-left: 0;' : '';
            ?>
">
                        <?php 
            if ($print_options['layout_style'] == 'website_compact') {
                ?>
                            <a href="<?php 
                echo $database_category_robot_url;
                ?>
"><?php 
                echo $robot_info['robot_name'] . $robot_info['robot_name_append'];
                ?>
</a>
                        <?php 
            } else {
                ?>
                            <?php 
                echo $robot_info['robot_name'] . $robot_info['robot_name_append'];
                ?>
&#39;s Data
                        <?php 
            }
            ?>
                        <div class="header_core robot_type"><?php 
            echo !empty($robot_info['robot_core']) ? ucwords($robot_info['robot_core'] . (!empty($robot_info['robot_core2']) ? ' / ' . $robot_info['robot_core2'] : '')) : 'Neutral';
            echo $robot_info['robot_class'] == 'mecha' ? ' Type' : ' Core';
            ?>
</div>
                    </h2>
                    <div class="body body_left <?php 
            echo !$print_options['show_mugshot'] ? 'fullsize' : '';
            ?>
">
                        <table class="full">
                            <colgroup>
                                <?php 
            if ($print_options['layout_style'] == 'website') {
                ?>
                                    <col width="48%" />
                                    <col width="1%" />
                                    <col width="48%" />
                                <?php 
            } else {
                ?>
                                    <col width="40%" />
                                    <col width="1%" />
                                    <col width="59%" />
                                <?php 
            }
            ?>
                            </colgroup>
                            <tbody>
                                <?php 
            if ($print_options['layout_style'] != 'event') {
                ?>
                                    <tr>
                                        <td  class="right">
                                            <label>Name :</label>
                                            <span class="robot_type" style="width: auto;"><?php 
                echo $robot_info['robot_name'];
                ?>
</span>
                                            <?php 
                if (!empty($robot_info['robot_generation'])) {
                    ?>
<span class="robot_type" style="width: auto;"><?php 
                    echo $robot_info['robot_generation'];
                    ?>
 Gen</span><?php 
                }
                ?>
                                        </td>
                                        <td></td>
                                        <td class="right">
                                            <?php 
                // Define the source game string
                if ($robot_info['robot_token'] == 'mega-man' || $robot_info['robot_token'] == 'roll') {
                    $temp_source_string = 'Mega Man';
                } elseif ($robot_info['robot_token'] == 'proto-man') {
                    $temp_source_string = 'Mega Man 3';
                } elseif ($robot_info['robot_token'] == 'bass') {
                    $temp_source_string = 'Mega Man 7';
                } elseif ($robot_info['robot_token'] == 'disco' || $robot_info['robot_token'] == 'rhythm') {
                    $temp_source_string = 'Mega Man RPG Prototype';
                } elseif (preg_match('/^flutter-fly/i', $robot_info['robot_token'])) {
                    $temp_source_string = 'Mega Man RPG Prototype';
                } elseif (preg_match('/^beetle-borg/i', $robot_info['robot_token'])) {
                    $temp_source_string = '<span title="Rockman &amp; Forte 2 : Challenger from the Future (JP)">Mega Man &amp; Bass 2</span>';
                } elseif ($robot_info['robot_token'] == 'bond-man') {
                    $temp_source_string = 'Mega Man RPG Prototype';
                } elseif ($robot_info['robot_token'] == 'enker') {
                    $temp_source_string = 'Mega Man : Dr. Wily\'s Revenge';
                } elseif ($robot_info['robot_token'] == 'punk') {
                    $temp_source_string = 'Mega Man III';
                } elseif ($robot_info['robot_token'] == 'ballade') {
                    $temp_source_string = 'Mega Man IV';
                } elseif ($robot_info['robot_token'] == 'quint') {
                    $temp_source_string = 'Mega Man II';
                } elseif ($robot_info['robot_token'] == 'oil-man' || $robot_info['robot_token'] == 'time-man') {
                    $temp_source_string = 'Mega Man Powered Up';
                } elseif ($robot_info['robot_token'] == 'solo') {
                    $temp_source_string = 'Mega Man Star Force 3';
                } elseif (preg_match('/^duo-2/i', $robot_info['robot_token'])) {
                    $temp_source_string = 'Mega Man 8';
                } elseif (preg_match('/^duo/i', $robot_info['robot_token'])) {
                    $temp_source_string = 'Mega Man Power Battles';
                } elseif (preg_match('/^trio/i', $robot_info['robot_token'])) {
                    $temp_source_string = 'Mega Man RPG Prototype';
                } elseif ($robot_info['robot_token'] == 'cosmo-man' || $robot_info['robot_token'] == 'lark-man') {
                    $temp_source_string = 'Mega Man Battle Network 5';
                } elseif ($robot_info['robot_token'] == 'laser-man') {
                    $temp_source_string = 'Mega Man Battle Network 4';
                } elseif ($robot_info['robot_token'] == 'desert-man') {
                    $temp_source_string = 'Mega Man Battle Network 3';
                } elseif ($robot_info['robot_token'] == 'planet-man' || $robot_info['robot_token'] == 'gate-man') {
                    $temp_source_string = 'Mega Man Battle Network 2';
                } elseif ($robot_info['robot_token'] == 'shark-man' || $robot_info['robot_token'] == 'number-man' || $robot_info['robot_token'] == 'color-man') {
                    $temp_source_string = 'Mega Man Battle Network';
                } elseif ($robot_info['robot_token'] == 'trill' || $robot_info['robot_token'] == 'slur') {
                    $temp_source_string = '<span title="Rockman.EXE Stream (JP)">Mega Man NT Warrior</span>';
                } elseif ($robot_info['robot_game'] == 'MM085') {
                    $temp_source_string = '<span title="Rockman &amp; Forte (JP)">Mega Man &amp; Bass</span>';
                } elseif ($robot_info['robot_game'] == 'MM30') {
                    $temp_source_string = 'Mega Man V';
                } elseif ($robot_info['robot_game'] == 'MM21') {
                    $temp_source_string = 'Mega Man : The Wily Wars';
                } elseif ($robot_info['robot_game'] == 'MM19') {
                    $temp_source_string = 'Mega Man RPG Prototype';
                } elseif ($robot_info['robot_game'] == 'MMEXE') {
                    $temp_source_string = 'Mega Man EXE';
                } elseif ($robot_info['robot_game'] == 'MM00' || $robot_info['robot_game'] == 'MM01') {
                    $temp_source_string = 'Mega Man';
                } elseif (preg_match('/^MM([0-9]{2})$/', $robot_info['robot_game'])) {
                    $temp_source_string = 'Mega Man ' . ltrim(str_replace('MM', '', $robot_info['robot_game']), '0');
                } elseif (!empty($robot_info['robot_game'])) {
                    $temp_source_string = $robot_info['robot_game'];
                } else {
                    $temp_source_string = '???';
                }
                ?>
                                            <label>Source :</label>
                                            <span class="robot_type"><?php 
                echo $temp_source_string;
                ?>
</span>
                                        </td>
                                    </tr>
                                <?php 
            }
            ?>
                                <tr>
                                    <td  class="right">
                                        <label>Model :</label>
                                        <span class="robot_type"><?php 
            echo $robot_info['robot_number'];
            ?>
</span>
                                    </td>
                                    <td></td>
                                    <td  class="right">
                                        <label>Class :</label>
                                        <span class="robot_type"><?php 
            echo !empty($robot_info['robot_description']) ? $robot_info['robot_description'] : '&hellip;';
            ?>
</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td  class="right">
                                        <label>Type :</label>
                                        <?php 
            if ($print_options['layout_style'] != 'event') {
                ?>
                                            <?php 
                if (!empty($robot_info['robot_core2'])) {
                    ?>
                                                <span class="robot_type type_<?php 
                    echo $robot_info['robot_core'] . '_' . $robot_info['robot_core2'];
                    ?>
">
                                                    <a href="<?php 
                    echo $database_category_url;
                    echo $robot_info['robot_core'];
                    ?>
/"><?php 
                    echo ucfirst($robot_info['robot_core']);
                    ?>
</a> /
                                                    <a href="<?php 
                    echo $database_category_url;
                    echo $robot_info['robot_core2'];
                    ?>
/"><?php 
                    echo ucfirst($robot_info['robot_core2']);
                    echo $robot_info['robot_class'] == 'master' ? ' Core' : ' Type';
                    ?>
</a>
                                                </span>
                                            <?php 
                } else {
                    ?>
                                                <a href="<?php 
                    echo $database_category_url;
                    echo !empty($robot_info['robot_core']) ? $robot_info['robot_core'] : 'none';
                    ?>
/" class="robot_type type_<?php 
                    echo !empty($robot_info['robot_core']) ? $robot_info['robot_core'] : 'none';
                    ?>
"><?php 
                    echo !empty($robot_info['robot_core']) ? ucfirst($robot_info['robot_core']) : 'Neutral';
                    echo $robot_info['robot_class'] == 'master' ? ' Core' : ' Type';
                    ?>
</a>
                                            <?php 
                }
                ?>
                                        <?php 
            } else {
                ?>
                                            <span class="robot_type type_<?php 
                echo !empty($robot_info['robot_core']) ? $robot_info['robot_core'] . (!empty($robot_info['robot_core2']) ? '_' . $robot_info['robot_core2'] : '') : 'none';
                ?>
"><?php 
                echo !empty($robot_info['robot_core']) ? ucwords($robot_info['robot_core'] . (!empty($robot_info['robot_core2']) ? ' / ' . $robot_info['robot_core2'] : '')) : 'Neutral';
                echo $robot_info['robot_class'] == 'master' ? ' Core' : ' Type';
                ?>
</span>
                                        <?php 
            }
            ?>
                                    </td>
                                    <td></td>
                                    <td  class="right">
                                        <label><?php 
            echo empty($field_info_array) || count($field_info_array) == 1 ? 'Field' : 'Fields';
            ?>
 :</label>
                                        <?php 
            // Loop through the robots fields if available
            if (!empty($field_info_array)) {
                foreach ($field_info_array as $key => $field_info) {
                    ?>
                                                    <?php 
                    if ($print_options['layout_style'] != 'event') {
                        ?>
                                                        <a href="<?php 
                        echo $database_url;
                        ?>
fields/<?php 
                        echo $field_info['field_token'];
                        ?>
/" class="field_type field_type_<?php 
                        echo (!empty($field_info['field_type']) ? $field_info['field_type'] : 'none') . (!empty($field_info['field_type2']) ? '_' . $field_info['field_type2'] : '');
                        ?>
" <?php 
                        echo $key > 0 ? 'title="' . $field_info['field_name'] . '"' : '';
                        ?>
><?php 
                        echo $key == 0 ? $field_info['field_name'] : preg_replace('/^([a-z0-9]+)\\s([a-z0-9]+)$/i', '$1&hellip;', $field_info['field_name']);
                        ?>
</a>
                                                    <?php 
                    } else {
                        ?>
                                                        <span class="field_type field_type_<?php 
                        echo (!empty($field_info['field_type']) ? $field_info['field_type'] : 'none') . (!empty($field_info['field_type2']) ? '_' . $field_info['field_type2'] : '');
                        ?>
" <?php 
                        echo $key > 0 ? 'title="' . $field_info['field_name'] . '"' : '';
                        ?>
><?php 
                        echo $key == 0 ? $field_info['field_name'] : preg_replace('/^([a-z0-9]+)\\s([a-z0-9]+)$/i', '$1&hellip;', $field_info['field_name']);
                        ?>
</span>
                                                    <?php 
                    }
                    ?>
                                                <?php 
                }
            } else {
                ?>
                                                <span class="field_type">&hellip;</span>
                                            <?php 
            }
            ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td  class="right">
                                        <label>Energy :</label>
                                        <span class="stat" style="width: <?php 
            echo $stat_container_percent;
            ?>
%;">
                                            <?php 
            if (false && $print_options['layout_style'] == 'website_compact') {
                ?>
                                                <span class="robot_stat type_energy" style="padding-left: <?php 
                echo round($robot_info['robot_energy'] / $robot_info['robot_total'] * $stat_padding_area, 4);
                ?>
%;"><span style="display: inline-block; width: 35px;"><?php 
                echo $robot_info['robot_energy'];
                ?>
</span></span>
                                            <?php 
            } else {
                ?>
                                                <span class="robot_stat type_energy" style="padding-left: <?php 
                echo round($robot_info['robot_energy'] / $robot_info['robot_max_stat_value'] * $stat_padding_area, 4);
                ?>
%;"><span style="display: inline-block; width: 35px;"><?php 
                echo $robot_info['robot_energy'];
                ?>
</span></span>
                                            <?php 
            }
            ?>
                                        </span>
                                    </td>
                                    <td></td>
                                    <td class="right">
                                        <label>Weaknesses :</label>
                                        <?php 
            if (!empty($robot_info['robot_weaknesses'])) {
                $temp_string = array();
                foreach ($robot_info['robot_weaknesses'] as $robot_weakness) {
                    if ($print_options['layout_style'] != 'event') {
                        $temp_string[] = '<a href="' . $database_url . 'abilities/' . $robot_weakness . '/" class="robot_weakness robot_type type_' . $robot_weakness . '">' . $mmrpg_database_types[$robot_weakness]['type_name'] . '</a>';
                    } else {
                        $temp_string[] = '<span class="robot_weakness robot_type type_' . $robot_weakness . '">' . $mmrpg_database_types[$robot_weakness]['type_name'] . '</span>';
                    }
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_weakness robot_type type_none">None</span>';
            }
            ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td  class="right">
                                        <label>Attack :</label>
                                        <span class="stat" style="width: <?php 
            echo $stat_container_percent;
            ?>
%;">
                                            <?php 
            if (false && $print_options['layout_style'] == 'website_compact') {
                ?>
                                                <span class="robot_stat type_attack" style="padding-left: <?php 
                echo round($robot_info['robot_attack'] / $robot_info['robot_total'] * $stat_padding_area, 4);
                ?>
%;"><span style="display: inline-block; width: 35px;"><?php 
                echo $robot_info['robot_attack'];
                ?>
</span></span>
                                            <?php 
            } else {
                ?>
                                                <span class="robot_stat type_attack" style="padding-left: <?php 
                echo round($robot_info['robot_attack'] / $robot_info['robot_max_stat_value'] * $stat_padding_area, 4);
                ?>
%;"><span style="display: inline-block; width: 35px;"><?php 
                echo $robot_info['robot_attack'];
                ?>
</span></span>
                                            <?php 
            }
            ?>
                                        </span>
                                    </td>
                                    <td></td>
                                    <td class="right">
                                        <label>Resistances :</label>
                                        <?php 
            if (!empty($robot_info['robot_resistances'])) {
                $temp_string = array();
                foreach ($robot_info['robot_resistances'] as $robot_resistance) {
                    if ($print_options['layout_style'] != 'event') {
                        $temp_string[] = '<a href="' . $database_url . 'abilities/' . $robot_resistance . '/" class="robot_resistance robot_type type_' . $robot_resistance . '">' . $mmrpg_database_types[$robot_resistance]['type_name'] . '</a>';
                    } else {
                        $temp_string[] = '<span class="robot_resistance robot_type type_' . $robot_resistance . '">' . $mmrpg_database_types[$robot_resistance]['type_name'] . '</span>';
                    }
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_resistance robot_type type_none">None</span>';
            }
            ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td  class="right">
                                        <label>Defense :</label>
                                        <span class="stat" style="width: <?php 
            echo $stat_container_percent;
            ?>
%;">
                                            <?php 
            if (false && $print_options['layout_style'] == 'website_compact') {
                ?>
                                                <span class="robot_stat type_defense" style="padding-left: <?php 
                echo round($robot_info['robot_defense'] / $robot_info['robot_total'] * $stat_padding_area, 4);
                ?>
%;"><span style="display: inline-block; width: 35px;"><?php 
                echo $robot_info['robot_defense'];
                ?>
</span></span>
                                            <?php 
            } else {
                ?>
                                                <span class="robot_stat type_defense" style="padding-left: <?php 
                echo round($robot_info['robot_defense'] / $robot_info['robot_max_stat_value'] * $stat_padding_area, 4);
                ?>
%;"><span style="display: inline-block; width: 35px;"><?php 
                echo $robot_info['robot_defense'];
                ?>
</span></span>
                                            <?php 
            }
            ?>
                                        </span>
                                    </td>
                                    <td></td>
                                    <td class="right">
                                        <label>Affinities :</label>
                                        <?php 
            if (!empty($robot_info['robot_affinities'])) {
                $temp_string = array();
                foreach ($robot_info['robot_affinities'] as $robot_affinity) {
                    if ($print_options['layout_style'] != 'event') {
                        $temp_string[] = '<a href="' . $database_url . 'abilities/' . $robot_affinity . '/" class="robot_affinity robot_type type_' . $robot_affinity . '">' . $mmrpg_database_types[$robot_affinity]['type_name'] . '</a>';
                    } else {
                        $temp_string[] = '<span class="robot_affinity robot_type type_' . $robot_affinity . '">' . $mmrpg_database_types[$robot_affinity]['type_name'] . '</span>';
                    }
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_affinity robot_type type_none">None</span>';
            }
            ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right">
                                        <label>Speed :</label>
                                        <span class="stat" style="width: <?php 
            echo $stat_container_percent;
            ?>
%;">
                                            <?php 
            if (false && $print_options['layout_style'] == 'website_compact') {
                ?>
                                                <span class="robot_stat type_speed" style="padding-left: <?php 
                echo round($robot_info['robot_speed'] / $robot_info['robot_total'] * $stat_padding_area, 4);
                ?>
%;"><span style="display: inline-block; width: 35px;"><?php 
                echo $robot_info['robot_speed'];
                ?>
</span></span>
                                            <?php 
            } else {
                ?>
                                                <span class="robot_stat type_speed" style="padding-left: <?php 
                echo round($robot_info['robot_speed'] / $robot_info['robot_max_stat_value'] * $stat_padding_area, 4);
                ?>
%;"><span style="display: inline-block; width: 35px;"><?php 
                echo $robot_info['robot_speed'];
                ?>
</span></span>
                                            <?php 
            }
            ?>
                                        </span>
                                    </td>
                                    <td></td>
                                    <td class="right">
                                        <label>Immunities :</label>
                                        <?php 
            if (!empty($robot_info['robot_immunities'])) {
                $temp_string = array();
                foreach ($robot_info['robot_immunities'] as $robot_immunity) {
                    if ($print_options['layout_style'] != 'event') {
                        $temp_string[] = '<a href="' . $database_url . 'abilities/' . $robot_immunity . '/" class="robot_immunity robot_type type_' . $robot_immunity . '">' . $mmrpg_database_types[$robot_immunity]['type_name'] . '</a>';
                    } else {
                        $temp_string[] = '<span class="robot_immunity robot_type type_' . $robot_immunity . '">' . $mmrpg_database_types[$robot_immunity]['type_name'] . '</span>';
                    }
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_immunity robot_type type_none">None</span>';
            }
            ?>
                                    </td>
                                </tr>

                                <?php 
            if (false && ($print_options['layout_style'] == 'website' || $print_options['layout_style'] == 'website_compact')) {
                ?>

                                    <tr>
                                        <td class="right">
                                            <label>Total :</label>
                                            <span class="stat" style="width: <?php 
                echo $stat_container_percent;
                ?>
%;">
                                                <?php 
                if ($print_options['layout_style'] == 'website_compact' && $robot_info['robot_total'] < $stat_base_max_value) {
                    ?>
                                                    <span class="robot_stat type_empty">
                                                        <span class="robot_stat type_none" style="padding-left: <?php 
                    echo round($robot_info['robot_total'] / $stat_base_max_value * $stat_padding_area, 4);
                    ?>
%;"><span><?php 
                    echo $robot_info['robot_total'];
                    ?>
</span></span>
                                                    </span>
                                                <?php 
                } else {
                    ?>
                                                    <span class="robot_stat type_none" style="padding-left: <?php 
                    echo $stat_padding_area;
                    ?>
%;"><span style="display: inline-block; width: 35px;"><?php 
                    echo $robot_info['robot_total'];
                    ?>
</span></span>
                                                <?php 
                }
                ?>
                                            </span>
                                        </td>
                                        <td></td>
                                        <td class="right"><?/*
                                            <label>Immunities :</label>
                                            <?php 
                if (!empty($robot_info['robot_immunities'])) {
                    $temp_string = array();
                    foreach ($robot_info['robot_immunities'] as $robot_immunity) {
                        if ($print_options['layout_style'] != 'event') {
                            $temp_string[] = '<a href="' . $database_url . 'abilities/' . $robot_immunity . '/" class="robot_immunity robot_type type_' . $robot_immunity . '">' . $mmrpg_database_types[$robot_immunity]['type_name'] . '</a>';
                        } else {
                            $temp_string[] = '<span class="robot_immunity robot_type type_' . $robot_immunity . '">' . $mmrpg_database_types[$robot_immunity]['type_name'] . '</span>';
                        }
                    }
                    echo implode(' ', $temp_string);
                } else {
                    echo '<span class="robot_immunity robot_type type_none">None</span>';
                }
                ?>
*/?>
                                        </td>
                                    </tr>

                                <?php 
            }
            ?>

                                <?php 
            if ($print_options['layout_style'] == 'event') {
                ?>

                                    <?php 
                // Define the search and replace arrays for the robot quotes
                $temp_find = array('{this_player}', '{this_robot}', '{target_player}', '{target_robot}');
                $temp_replace = array('Doctor', $robot_info['robot_name'], 'Doctor', 'Robot');
                ?>
                                    <tr>
                                        <td colspan="3" class="center" style="font-size: 13px; padding: 5px 0; ">
                                            <span class="robot_quote">&quot;<?php 
                echo !empty($robot_info['robot_quotes']['battle_taunt']) ? str_replace($temp_find, $temp_replace, $robot_info['robot_quotes']['battle_taunt']) : '&hellip;';
                ?>
&quot;</span>
                                        </td>
                                    </tr>

                                <?php 
            }
            ?>

                            </tbody>
                        </table>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['layout_style'] == 'website') {
            ?>

                    <?php 
            // Define the various tabs we are able to scroll to
            $section_tabs = array();
            if ($print_options['show_sprites']) {
                $section_tabs[] = array('sprites', 'Sprites', false);
            }
            if ($print_options['show_quotes']) {
                $section_tabs[] = array('quotes', 'Quotes', false);
            }
            if ($print_options['show_description']) {
                $section_tabs[] = array('description', 'Description', false);
            }
            if ($print_options['show_abilities']) {
                $section_tabs[] = array('abilities', 'Abilities', false);
            }
            if ($print_options['show_stats']) {
                $section_tabs[] = array('stats', 'Stats', false);
            }
            if ($print_options['show_records']) {
                $section_tabs[] = array('records', 'Records', false);
            }
            // Automatically mark the first element as true or active
            $section_tabs[0][2] = true;
            // Define the current URL for this robot or mecha page
            $temp_url = 'database/';
            if ($robot_info['robot_class'] == 'mecha') {
                $temp_url .= 'mechas/';
            } elseif ($robot_info['robot_class'] == 'master') {
                $temp_url .= 'robots/';
            } elseif ($robot_info['robot_class'] == 'boss') {
                $temp_url .= 'bosses/';
            }
            $temp_url .= $robot_info['robot_token'] . '/';
            ?>

                    <div class="section_tabs">
                        <?php 
            foreach ($section_tabs as $tab) {
                echo '<a class="link_inline link_' . $tab[0] . ' ' . ($tab[2] ? 'active' : '') . '" href="' . $temp_url . '#' . $tab[0] . '" data-anchor="#' . $tab[0] . '"><span class="wrap">' . $tab[1] . '</span></a>';
            }
            ?>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_sprites']) {
            ?>

                    <?php 
            // Start the output buffer and prepare to collect sprites
            ob_start();
            // Define the alts we'll be looping through for this robot
            $temp_alts_array = array();
            $temp_alts_array[] = array('token' => '', 'name' => $robot_info['robot_name'], 'summons' => 0);
            // Append predefined alts automatically, based on the robot image alt array
            if (!empty($robot_info['robot_image_alts'])) {
                $temp_alts_array = array_merge($temp_alts_array, $robot_info['robot_image_alts']);
            } elseif ($robot_info['robot_core'] == 'copy' && preg_match('/^(mega-man|proto-man|bass|doc-robot)$/i', $robot_info['robot_token'])) {
                foreach ($mmrpg_database_types as $type_token => $type_info) {
                    if (empty($type_token) || $type_token == 'none' || $type_token == 'copy') {
                        continue;
                    }
                    $temp_alts_array[] = array('token' => $type_token, 'name' => $robot_info['robot_name'] . ' (' . ucfirst($type_token) . ' Core)', 'summons' => 0);
                }
            } elseif (!empty($robot_info['robot_image_sheets'])) {
                for ($i = 2; $i <= $robot_info['robot_image_sheets']; $i++) {
                    $temp_alts_array[] = array('sheet' => $i, 'name' => $robot_info['robot_name'] . ' (Sheet #' . $i . ')', 'summons' => 0);
                }
            }
            // Loop through the alts and display images for them (yay!)
            foreach ($temp_alts_array as $alt_key => $alt_info) {
                // Define the current image token with alt in mind
                $temp_robot_image_token = $robot_image_token;
                $temp_robot_image_token .= !empty($alt_info['token']) ? '_' . $alt_info['token'] : '';
                $temp_robot_image_token .= !empty($alt_info['sheet']) ? '-' . $alt_info['sheet'] : '';
                $temp_robot_image_name = $alt_info['name'];
                // Update the alt array with this info
                $temp_alts_array[$alt_key]['image'] = $temp_robot_image_token;
                // Collect the number of sheets
                $temp_sheet_number = !empty($robot_info['robot_image_sheets']) ? $robot_info['robot_image_sheets'] : 1;
                // Loop through the different frames and print out the sprite sheets
                foreach (array('right', 'left') as $temp_direction) {
                    $temp_direction2 = substr($temp_direction, 0, 1);
                    $temp_embed = '[robot:' . $temp_direction . ']{' . $temp_robot_image_token . '}';
                    $temp_title = $temp_robot_image_name . ' | Mugshot Sprite ' . ucfirst($temp_direction);
                    $temp_title .= '<div style="margin-top: 4px; letting-spacing: 1px; font-size: 90%; font-family: Courier New; color: rgb(159, 150, 172);">' . $temp_embed . '</div>';
                    $temp_title = htmlentities($temp_title, ENT_QUOTES, 'UTF-8', true);
                    $temp_label = 'Mugshot ' . ucfirst(substr($temp_direction, 0, 1));
                    echo '<div class="frame_container" data-clickcopy="' . $temp_embed . '" data-direction="' . $temp_direction . '" data-image="' . $temp_robot_image_token . '" data-frame="mugshot" style="padding-top: 20px; float: left; position: relative; margin: 0; box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.75); width: ' . $robot_sprite_size . 'px; height: ' . $robot_sprite_size . 'px; overflow: hidden;">';
                    echo '<img style="margin-left: 0;" data-tooltip="' . $temp_title . '" src="i/r/' . $temp_robot_image_token . '/m' . $temp_direction2 . $robot_sprite_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '" />';
                    echo '<label style="position: absolute; left: 5px; top: 0; color: #EFEFEF; font-size: 10px; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);">' . $temp_label . '</label>';
                    echo '</div>';
                }
                // Loop through the different frames and print out the sprite sheets
                foreach ($robot_sprite_frames as $this_key => $this_frame) {
                    $margin_left = ceil((0 - $this_key) * $robot_sprite_size);
                    $frame_relative = $this_frame;
                    //if ($temp_sheet > 1){ $frame_relative = 'frame_'.str_pad((($temp_sheet - 1) * count($robot_sprite_frames) + $this_key + 1), 2, '0', STR_PAD_LEFT); }
                    $frame_relative_text = ucfirst(str_replace('_', ' ', $frame_relative));
                    foreach (array('right', 'left') as $temp_direction) {
                        $temp_direction2 = substr($temp_direction, 0, 1);
                        $temp_embed = '[robot:' . $temp_direction . ':' . $frame_relative . ']{' . $temp_robot_image_token . '}';
                        $temp_title = $temp_robot_image_name . ' | ' . $frame_relative_text . ' Sprite ' . ucfirst($temp_direction);
                        $temp_title .= '<div style="margin-top: 4px; letting-spacing: 1px; font-size: 90%; font-family: Courier New; color: rgb(159, 150, 172);">' . $temp_embed . '</div>';
                        $temp_title = htmlentities($temp_title, ENT_QUOTES, 'UTF-8', true);
                        $temp_label = $frame_relative_text . ' ' . ucfirst(substr($temp_direction, 0, 1));
                        //$image_token = !empty($robot_info['robot_image']) ? $robot_info['robot_image'] : $robot_info['robot_token'];
                        //if ($temp_sheet > 1){ $temp_robot_image_token .= '-'.$temp_sheet; }
                        echo '<div class="frame_container" data-clickcopy="' . $temp_embed . '" data-direction="' . $temp_direction . '" data-image="' . $temp_robot_image_token . '" data-frame="' . $frame_relative . '" style="padding-top: 20px; float: left; position: relative; margin: 0; box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.75); width: ' . $robot_sprite_size . 'px; height: ' . $robot_sprite_size . 'px; overflow: hidden;">';
                        echo '<img style="margin-left: ' . $margin_left . 'px;" title="' . $temp_title . '" alt="' . $temp_title . '" src="i/r/' . $temp_robot_image_token . '/s' . $temp_direction2 . $robot_sprite_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '" />';
                        echo '<label style="position: absolute; left: 5px; top: 0; color: #EFEFEF; font-size: 10px; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);">' . $temp_label . '</label>';
                        echo '</div>';
                    }
                }
            }
            // Collect the sprite markup from the output buffer for later
            $this_sprite_markup = ob_get_clean();
            ?>

                    <h2 id="sprites" class="header header_full <?php 
            echo $robot_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left; overflow: hidden; height: auto;">
                        <?php 
            echo $robot_info['robot_name'] . $robot_info['robot_name_append'];
            ?>
&#39;s Sprites
                        <span class="header_links image_link_container">
                            <span class="images" style="<?php 
            echo count($temp_alts_array) == 1 ? 'visibility: hidden;' : '';
            ?>
"><?php 
            // Loop though and print links for the alts
            $alt_type_base = 'robot_type type_' . (!empty($robot_info['robot_core']) ? $robot_info['robot_core'] : 'none') . ' ';
            foreach ($temp_alts_array as $alt_key => $alt_info) {
                $alt_type = '';
                $alt_style = '';
                $alt_title = $alt_info['name'];
                $alt_type2 = $alt_type_base;
                if (preg_match('/^(?:[-_a-z0-9\\s]+)\\s\\(([a-z0-9]+)\\sCore\\)$/i', $alt_info['name'])) {
                    $alt_type = strtolower(preg_replace('/^(?:[-_a-z0-9\\s]+)\\s\\(([a-z0-9]+)\\sCore\\)$/i', '$1', $alt_info['name']));
                    $alt_name = '&bull;';
                    //ucfirst($alt_type); //substr(ucfirst($alt_type), 0, 2);
                    $alt_type = 'robot_type type_' . $alt_type . ' core_type ';
                    $alt_type2 = 'robot_type type_' . $alt_type . ' ';
                    $alt_style = 'border-color: rgba(0, 0, 0, 0.2) !important; ';
                } else {
                    $alt_name = $alt_key == 0 ? $robot_info['robot_name'] : 'Alt' . ($alt_key > 1 ? ' ' . $alt_key : '');
                    //$alt_key == 0 ? $robot_info['robot_name'] : $robot_info['robot_name'].' Alt'.($alt_key > 1 ? ' '.$alt_key : '');
                    $alt_type = 'robot_type type_empty ';
                    $alt_style = 'border-color: rgba(0, 0, 0, 0.2) !important; background-color: rgba(0, 0, 0, 0.2) !important; ';
                    //if ($robot_info['robot_core'] == 'copy' && $alt_key == 0){ $alt_type = 'robot_type type_empty '; }
                }
                echo '<a href="#" data-tooltip="' . $alt_title . '" data-tooltip-type="' . $alt_type2 . '" class="link link_image ' . ($alt_key == 0 ? 'link_active ' : '') . '" data-image="' . $alt_info['image'] . '">';
                echo '<span class="' . $alt_type . '" style="' . $alt_style . '">' . $alt_name . '</span>';
                echo '</a>';
            }
            ?>
</span>
                            <span class="pipe" style="<?php 
            echo count($temp_alts_array) == 1 ? 'visibility: hidden;' : '';
            ?>
">|</span>
                            <span class="directions"><?php 
            // Loop though and print links for the alts
            foreach (array('right', 'left') as $temp_key => $temp_direction) {
                echo '<a href="#" data-tooltip="' . ucfirst($temp_direction) . ' Facing Sprites" data-tooltip-type="' . $alt_type_base . '" class="link link_direction ' . ($temp_key == 0 ? 'link_active' : '') . '" data-direction="' . $temp_direction . '">';
                echo '<span class="ability_type ability_type_empty" style="border-color: rgba(0, 0, 0, 0.2) !important; background-color: rgba(0, 0, 0, 0.2) !important; ">' . ucfirst($temp_direction) . '</span>';
                echo '</a>';
            }
            ?>
</span>
                        </span>
                    </h2>
                    <div id="sprites_body" class="body body_full" style="margin: 0; padding: 10px; min-height: 10px;">
                        <div style="border: 1px solid rgba(0, 0, 0, 0.20); border-radius: 0.5em; -moz-border-radius: 0.5em; -webkit-border-radius: 0.5em; background: #4d4d4d url(images/assets/sprite-grid.gif) scroll repeat -10px -30px; overflow: hidden; padding: 10px 30px;">
                            <?php 
            echo $this_sprite_markup;
            ?>
                        </div>
                        <?
                        // Collect the sprite contributor index for display
                        $user_fields = rpg_user::get_fields(true, 'user');
                        $user_role_fields = rpg_user_role::get_fields(true, 'role');
                        $contributor_index = $db->get_array_list("SELECT
                            {$user_fields},
                            {$user_role_fields},
                            (CASE WHEN user.user_name_public <> ''
                                THEN user.user_name_public
                                ELSE user.user_name
                                END) AS user_name_current
                            FROM mmrpg_users AS user
                            LEFT JOIN mmrpg_roles AS role ON role.role_id = user.role_id
                            WHERE role.role_token IN ('developer', 'administrator', 'contributor', 'moderator')
                            ORDER BY user_name_current ASC;
                            ", 'user_id');
                        // Define the editor title based on ID
                        $temp_editor_title = 'Undefined';
                        $temp_final_divider = '<span style="color: #565656;"> | </span>';
                        $temp_editor_ids = array();
                        // Check if an image editor ID has been defined
                        if (!empty($robot_info['robot_image_editor']) && isset($contributor_index[$robot_info['robot_image_editor']])){
                            $temp_editor_ids[] = $robot_info['robot_image_editor'];
                        }
                        // Check if a second image editor ID has been defined
                        if (!empty($robot_info['robot_image_editor2']) && isset($contributor_index[$robot_info['robot_image_editor2']])){
                            $temp_editor_ids[] = $robot_info['robot_image_editor2'];
                        }
                        // If not empty, loop through and add image editors to the string
                        if (!empty($temp_editor_ids)){
                            $temp_editor_title = array();
                            foreach ($temp_editor_ids AS $editor_id){
                                $temp_editor = $contributor_index[$editor_id];
                                $temp_name_public = !empty($temp_editor['user_name_public']) ? $temp_editor['user_name_public'] : $temp_editor['user_name'];
                                $temp_name_real = !empty($temp_editor['user_name']) ? $temp_editor['user_name'] : $temp_editor['user_name_clean'];
                                $temp_name_public_clean = preg_replace('/[^a-z0-9]+/i', '', strtolower($temp_name_public));
                                $temp_name_real_clean = preg_replace('/[^a-z0-9]+/i', '', strtolower($temp_name_real));
                                if ($temp_name_public_clean != $temp_name_real_clean){ $temp_editor_title[] = '<strong>'.$temp_name_public.' / '.$temp_name_real.'</strong>'; }
                                else { $temp_editor_title[] = '<strong>'.$temp_name_public.'</strong>'; }
                            }
                            if (count($temp_editor_title) > 1){ $temp_final_divider = '<br />'; }
                            $temp_editor_title = implode(' and ', $temp_editor_title);
                        }
                        // Define the robots created by specific creators outside of the Capcom characters
                        $temp_adrian_robots = array('disco', 'rhythm', 'flutter-fly', 'flutter-fly-2', 'flutter-fly-3');
                        // Print out the final credits footer based on if special case or Capcom original
                        if (in_array($robot_info['robot_token'], $temp_adrian_robots)){
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Character by <strong>Adrian Marceau</strong></p>'."\n";
                        } elseif ($robot_info['robot_game'] == 'MMRPG'){
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Artwork by <strong>Mega Man RPG Prototype</strong></p>'."\n";
                        } elseif ($robot_info['robot_game'] == 'MMRPG2'){
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Artwork by <strong>Mega Man RPG World</strong></p>'."\n";
                        }else {
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Artwork by <strong>Capcom</strong></p>'."\n";
                        }
                        ?>
                    </div>

                    <?php 
            if ($print_options['show_footer'] && $print_options['layout_style'] == 'website') {
                ?>
                        <div class="link_wrapper">
                            <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                            <a class="link link_permalink" href="<?php 
                echo $database_category_robot_url;
                ?>
#sprites" rel="permalink">#Sprites</a>
                        </div>
                    <?php 
            }
            ?>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_quotes']) {
            ?>

                    <h2 id="quotes" class="header header_left <?php 
            echo $robot_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left;">
                        <?php 
            echo $robot_info['robot_name'] . $robot_info['robot_name_append'];
            ?>
&#39;s Quotes
                    </h2>
                    <div class="body body_left" style="margin-right: 0; margin-left: 0; margin-bottom: 5px; padding: 2px 0; min-height: 10px;">
                        <?php 
            // Define the search and replace arrays for the robot quotes
            $temp_find = array('{this_player}', '{this_robot}', '{target_player}', '{target_robot}');
            $temp_replace = array('Doctor', $robot_info['robot_name'], 'Doctor', 'Robot');
            ?>
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right">
                                        <label>Start Quote : </label>
                                        <span class="robot_quote">&quot;<?php 
            echo !empty($robot_info['robot_quotes']['battle_start']) ? str_replace($temp_find, $temp_replace, $robot_info['robot_quotes']['battle_start']) : '&hellip;';
            ?>
&quot;</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right">
                                        <label>Taunt Quote : </label>
                                        <span class="robot_quote">&quot;<?php 
            echo !empty($robot_info['robot_quotes']['battle_taunt']) ? str_replace($temp_find, $temp_replace, $robot_info['robot_quotes']['battle_taunt']) : '&hellip;';
            ?>
&quot;</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right">
                                        <label>Victory Quote : </label>
                                        <span class="robot_quote">&quot;<?php 
            echo !empty($robot_info['robot_quotes']['battle_victory']) ? str_replace($temp_find, $temp_replace, $robot_info['robot_quotes']['battle_victory']) : '&hellip;';
            ?>
&quot;</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right">
                                        <label>Defeat Quote : </label>
                                        <span class="robot_quote">&quot;<?php 
            echo !empty($robot_info['robot_quotes']['battle_defeat']) ? str_replace($temp_find, $temp_replace, $robot_info['robot_quotes']['battle_defeat']) : '&hellip;';
            ?>
&quot;</span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <?php 
            if ($print_options['show_footer'] && $print_options['layout_style'] == 'website') {
                ?>
                        <div class="link_wrapper">
                            <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                            <a class="link link_permalink" href="<?php 
                echo $database_category_robot_url;
                ?>
#quotes" rel="permalink">#Quotes</a>
                        </div>
                    <?php 
            }
            ?>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_description'] && !empty($robot_info['robot_description2'])) {
            ?>

                    <h2 id="description" class="header header_left <?php 
            echo $robot_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left; ">
                        <?php 
            echo $robot_info['robot_name'] . $robot_info['robot_name_append'];
            ?>
&#39;s Description
                    </h2>
                    <div class="body body_left" style="margin-right: 0; margin-left: 0; margin-bottom: 5px; padding: 2px 0; min-height: 10px;">
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right">
                                        <div class="robot_description" style="text-align: left; padding: 0 4px;"><?php 
            echo $robot_info['robot_description2'];
            ?>
</div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <?php 
            if ($print_options['show_footer'] && $print_options['layout_style'] == 'website') {
                ?>
                        <div class="link_wrapper">
                            <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                            <a class="link link_permalink" href="<?php 
                echo $database_category_robot_url;
                ?>
#description" rel="permalink">#Description</a>
                        </div>
                    <?php 
            }
            ?>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_abilities']) {
            ?>

                    <h2 id="abilities" class="header header_full <?php 
            echo $robot_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left;">
                        <?php 
            echo $robot_info['robot_name'] . $robot_info['robot_name_append'];
            ?>
&#39;s Abilities
                    </h2>
                    <div class="body body_full" style="margin: 0; padding: 2px 3px; min-height: 10px;">
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right">
                                        <div class="ability_container">
                                        <?php 
            // Define the robot ability class and collect the cores for testing
            $robot_ability_class = !empty($robot_info['robot_class']) ? $robot_info['robot_class'] : 'master';
            $robot_ability_core = !empty($robot_info['robot_core']) ? $robot_info['robot_core'] : false;
            $robot_ability_core2 = !empty($robot_info['robot_core2']) ? $robot_info['robot_core2'] : false;
            $robot_ability_list = !empty($robot_info['robot_abilities']) ? $robot_info['robot_abilities'] : array();
            $robot_ability_rewards = !empty($robot_info['robot_rewards']['abilities']) ? $robot_info['robot_rewards']['abilities'] : array();
            // Collect a FULL list of abilities for display
            $temp_required = array();
            foreach ($robot_ability_rewards as $info) {
                $temp_required[] = $info['token'];
            }
            $temp_abilities_index = rpg_ability::get_index(false, false, '', $temp_required);
            // Clone abilities into new array for filtering
            $new_ability_rewards = array();
            foreach ($robot_ability_rewards as $this_info) {
                $new_ability_rewards[$this_info['token']] = $this_info;
            }
            $robot_copy_program = $robot_ability_core == 'copy' || $robot_ability_core2 == 'copy' ? true : false;
            //if ($robot_copy_program){ $robot_ability_list = $temp_all_ability_tokens; }
            $robot_ability_core_list = array();
            if ((!empty($robot_ability_core) || !empty($robot_ability_core2)) && $robot_ability_class != 'mecha') {
                // only robot masters can core match abilities
                foreach ($temp_abilities_index as $token => $info) {
                    if (!empty($info['ability_type']) && ($robot_copy_program || $info['ability_type'] == $robot_ability_core || $info['ability_type'] == $robot_ability_core2) || !empty($info['ability_type2']) && ($info['ability_type2'] == $robot_ability_core || $info['ability_type2'] == $robot_ability_core2)) {
                        $robot_ability_list[] = $info['ability_token'];
                        $robot_ability_core_list[] = $info['ability_token'];
                    }
                }
            }
            foreach ($robot_ability_list as $this_token) {
                if ($this_token == '*') {
                    continue;
                }
                if (!isset($new_ability_rewards[$this_token])) {
                    if (in_array($this_token, $robot_ability_core_list)) {
                        $new_ability_rewards[$this_token] = array('level' => 'Player', 'token' => $this_token);
                    } else {
                        $new_ability_rewards[$this_token] = array('level' => 'Player', 'token' => $this_token);
                    }
                }
            }
            $robot_ability_rewards = $new_ability_rewards;
            //die('<pre>'.print_r($robot_ability_rewards, true).'</pre>');
            if (!empty($robot_ability_rewards)) {
                $temp_string = array();
                $ability_key = 0;
                $ability_method_key = 0;
                $ability_method = '';
                foreach ($robot_ability_rewards as $this_info) {
                    if (!isset($temp_abilities_index[$this_info['token']])) {
                        continue;
                    }
                    $this_level = $this_info['level'];
                    $this_ability = $temp_abilities_index[$this_info['token']];
                    $this_ability_token = $this_ability['ability_token'];
                    $this_ability_name = $this_ability['ability_name'];
                    $this_ability_class = !empty($this_ability['ability_class']) ? $this_ability['ability_class'] : 'master';
                    $this_ability_image = !empty($this_ability['ability_image']) ? $this_ability['ability_image'] : $this_ability['ability_token'];
                    $this_ability_type = !empty($this_ability['ability_type']) ? $this_ability['ability_type'] : false;
                    $this_ability_type2 = !empty($this_ability['ability_type2']) ? $this_ability['ability_type2'] : false;
                    if (!empty($this_ability_type) && !empty($mmrpg_database_types[$this_ability_type])) {
                        $this_ability_type = $mmrpg_database_types[$this_ability_type]['type_name'] . ' Type';
                    } else {
                        $this_ability_type = '';
                    }
                    if (!empty($this_ability_type2) && !empty($mmrpg_database_types[$this_ability_type2])) {
                        $this_ability_type = str_replace('Type', '/ ' . $mmrpg_database_types[$this_ability_type2]['type_name'], $this_ability_type);
                    }
                    $this_ability_damage = !empty($this_ability['ability_damage']) ? $this_ability['ability_damage'] : 0;
                    $this_ability_damage2 = !empty($this_ability['ability_damage2']) ? $this_ability['ability_damage2'] : 0;
                    $this_ability_damage_percent = !empty($this_ability['ability_damage_percent']) ? true : false;
                    $this_ability_damage2_percent = !empty($this_ability['ability_damage2_percent']) ? true : false;
                    if ($this_ability_damage_percent && $this_ability_damage > 100) {
                        $this_ability_damage = 100;
                    }
                    if ($this_ability_damage2_percent && $this_ability_damage2 > 100) {
                        $this_ability_damage2 = 100;
                    }
                    $this_ability_recovery = !empty($this_ability['ability_recovery']) ? $this_ability['ability_recovery'] : 0;
                    $this_ability_recovery2 = !empty($this_ability['ability_recovery2']) ? $this_ability['ability_recovery2'] : 0;
                    $this_ability_recovery_percent = !empty($this_ability['ability_recovery_percent']) ? true : false;
                    $this_ability_recovery2_percent = !empty($this_ability['ability_recovery2_percent']) ? true : false;
                    if ($this_ability_recovery_percent && $this_ability_recovery > 100) {
                        $this_ability_recovery = 100;
                    }
                    if ($this_ability_recovery2_percent && $this_ability_recovery2 > 100) {
                        $this_ability_recovery2 = 100;
                    }
                    $this_ability_accuracy = !empty($this_ability['ability_accuracy']) ? $this_ability['ability_accuracy'] : 0;
                    $this_ability_description = !empty($this_ability['ability_description']) ? $this_ability['ability_description'] : '';
                    $this_ability_description = str_replace('{DAMAGE}', $this_ability_damage, $this_ability_description);
                    $this_ability_description = str_replace('{RECOVERY}', $this_ability_recovery, $this_ability_description);
                    $this_ability_description = str_replace('{DAMAGE2}', $this_ability_damage2, $this_ability_description);
                    $this_ability_description = str_replace('{RECOVERY2}', $this_ability_recovery2, $this_ability_description);
                    //$this_ability_title_plain = $this_ability_name;
                    //if (!empty($this_ability_type)){ $this_ability_title_plain .= ' | '.$this_ability_type; }
                    //if (!empty($this_ability_damage)){ $this_ability_title_plain .= ' | '.$this_ability_damage.' Damage'; }
                    //if (!empty($this_ability_recovery)){ $this_ability_title_plain .= ' | '.$this_ability_recovery.' Recovery'; }
                    //if (!empty($this_ability_accuracy)){ $this_ability_title_plain .= ' | '.$this_ability_accuracy.'% Accuracy'; }
                    //if (!empty($this_ability_description)){ $this_ability_title_plain .= ' | '.$this_ability_description; }
                    $this_ability_title_plain = rpg_ability::print_editor_title_markup($robot_info, $this_ability);
                    $this_ability_method = 'level';
                    $this_ability_method_text = 'Level Up';
                    $this_ability_title_html = '<strong class="name">' . $this_ability_name . '</strong>';
                    if (is_numeric($this_level)) {
                        if ($this_level > 1) {
                            $this_ability_title_html .= '<span class="level">Lv ' . str_pad($this_level, 2, '0', STR_PAD_LEFT) . '</span>';
                        } else {
                            $this_ability_title_html .= '<span class="level">Start</span>';
                        }
                    } else {
                        $this_ability_method = 'player';
                        $this_ability_method_text = 'Player Only';
                        if (!in_array($this_ability_token, $robot_info['robot_abilities'])) {
                            $this_ability_method = 'core';
                            $this_ability_method_text = 'Core Match';
                        }
                        $this_ability_title_html .= '<span class="level">&nbsp;</span>';
                    }
                    // If this is a boss, don't bother showing player or core match abilities
                    if ($this_ability_method != 'level' && $robot_info['robot_class'] == 'boss') {
                        continue;
                    }
                    if (!empty($this_ability_type)) {
                        $this_ability_title_html .= '<span class="type">' . $this_ability_type . '</span>';
                    }
                    if (!empty($this_ability_damage)) {
                        $this_ability_title_html .= '<span class="damage">' . $this_ability_damage . (!empty($this_ability_damage_percent) ? '%' : '') . ' ' . ($this_ability_damage && $this_ability_recovery ? 'D' : 'Damage') . '</span>';
                    }
                    if (!empty($this_ability_recovery)) {
                        $this_ability_title_html .= '<span class="recovery">' . $this_ability_recovery . (!empty($this_ability_recovery_percent) ? '%' : '') . ' ' . ($this_ability_damage && $this_ability_recovery ? 'R' : 'Recovery') . '</span>';
                    }
                    if (!empty($this_ability_accuracy)) {
                        $this_ability_title_html .= '<span class="accuracy">' . $this_ability_accuracy . '% Accuracy</span>';
                    }
                    $this_ability_sprite_path = 'images/sprites/abilities/' . $this_ability_image . '/icon_left_40x40.png';
                    if (!file_exists(MMRPG_CONFIG_ROOTDIR . $this_ability_sprite_path)) {
                        $this_ability_image = 'ability';
                        $this_ability_sprite_path = 'i/a/ability/il40.png';
                    } else {
                        $this_ability_sprite_path = 'i/a/' . $this_ability_image . '/il40.png';
                    }
                    $this_ability_sprite_html = '<span class="icon"><img src="' . $this_ability_sprite_path . '?' . MMRPG_CONFIG_CACHE_DATE . '" alt="' . $this_ability_name . ' Icon" /></span>';
                    $this_ability_title_html = '<span class="label">' . $this_ability_title_html . '</span>';
                    //$this_ability_title_html = (is_numeric($this_level) && $this_level > 1 ? 'Lv '.str_pad($this_level, 2, '0', STR_PAD_LEFT).' : ' : $this_level.' : ').$this_ability_title_html;
                    // Show the ability method separator if necessary
                    if ($ability_method != $this_ability_method && $robot_info['robot_class'] == 'master') {
                        $temp_separator = '<div class="ability_separator">' . $this_ability_method_text . '</div>';
                        $temp_string[] = $temp_separator;
                        $ability_method = $this_ability_method;
                        $ability_method_key++;
                        // Print out the disclaimer if a copy-core robot
                        if ($this_ability_method != 'level' && $robot_copy_program) {
                            $temp_string[] = '<div class="" style="margin: 10px auto; text-align: center; color: #767676; font-size: 11px;">Copy Core robots can equip <em>any</em> ' . ($this_ability_method == 'player' ? 'player' : 'type') . ' ability!</div>';
                        }
                    }
                    // If this is a copy core robot, don't bother showing EVERY core-match ability
                    if ($this_ability_method != 'level' && $robot_copy_program) {
                        continue;
                    } elseif ($this_level >= 0 || !$robot_copy_program) {
                        $temp_element = $this_ability_class == 'master' ? 'a' : 'span';
                        $temp_markup = '<' . $temp_element . ' ' . ($this_ability_class == 'master' ? 'href="' . MMRPG_CONFIG_ROOTURL . 'database/abilities/' . $this_ability['ability_token'] . '/"' : '') . ' class="ability_name ability_class_' . $this_ability_class . ' ability_type ability_type_' . (!empty($this_ability['ability_type']) ? $this_ability['ability_type'] : 'none') . (!empty($this_ability['ability_type2']) ? '_' . $this_ability['ability_type2'] : '') . '" title="' . $this_ability_title_plain . '" style="' . ($this_ability_image == 'ability' ? 'opacity: 0.3; ' : '') . '">';
                        $temp_markup .= '<span class="chrome">' . $this_ability_sprite_html . $this_ability_title_html . '</span>';
                        $temp_markup .= '</' . $temp_element . '>';
                        $temp_string[] = $temp_markup;
                        $ability_key++;
                        continue;
                    }
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_ability type_none"><span class="chrome">None</span></span>';
            }
            ?>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <?php 
            if ($print_options['show_footer'] && $print_options['layout_style'] == 'website') {
                ?>
                        <div class="link_wrapper">
                            <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                            <a class="link link_permalink" href="<?php 
                echo $database_category_robot_url;
                ?>
#abilities" rel="permalink">#Abilities</a>
                        </div>
                    <?php 
            }
            ?>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_stats']) {
            ?>

                    <h2 id="stats" class="header header_full <?php 
            echo $robot_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left;">
                        <?php 
            echo $robot_info['robot_name'] . $robot_info['robot_name_append'];
            ?>
&#39;s Stats
                    </h2>
                    <div class="body body_full" style="margin: 0 auto 5px; padding: 2px 0; min-height: 10px;">
                        <?php 
            // Define the various levels we'll display in this chart
            $display_levels = array(1, 5, 10, 50, 100);
            //range(1, 100, 1);
            ?>
                        <table class="full stat_container" style="">
                            <colgroup>
                                <col width="20%" />
                                <col width="10%" />
                                <col width="10%" />
                                <col width="10%" />
                                <col width="10%" />
                                <col width="10%" />
                                <col width="10%" />
                                <col width="10%" />
                                <col width="10%" />
                            </colgroup>
                            <thead>
                                <tr>
                                    <th class="top left level">Level</th>
                                    <th class="top center energy" colspan="1">Energy</th>
                                    <th class="top center weapons" colspan="1">Weapons</th>
                                    <th class="top center attack" colspan="2">Attack</th>
                                    <th class="top center defense" colspan="2">Defense</th>
                                    <th class="top center speed" colspan="2">Speed</th>
                                </tr>
                                <tr>
                                    <th class="sub left level" >&nbsp;</th>
                                    <th class="sub center energy max">-</th>
                                    <th class="sub center weapons max">-</th>
                                    <th class="sub center attack min">Min</th>
                                    <th class="sub center attack max">Max</th>
                                    <th class="sub center defense min">Min</th>
                                    <th class="sub center defense max">Max</th>
                                    <th class="sub center speed min">Min</th>
                                    <th class="sub center speed max">Max</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
            // Define or collect the base stats for this robot, ready to be modified
            $base_stats = array();
            $base_stats['energy'] = $robot_info['robot_energy'];
            $base_stats['weapons'] = $robot_info['robot_weapons'];
            $base_stats['attack'] = $robot_info['robot_attack'];
            $base_stats['defense'] = $robot_info['robot_defense'];
            $base_stats['speed'] = $robot_info['robot_speed'];
            // Loop through the display levels and calculate stat adjustments
            foreach ($display_levels as $level) {
                // Calculate the minimum stat values for this robot with only level-based stat boosts
                $min_stats = array();
                $min_stats['energy'] = MMRPG_SETTINGS_STATS_GET_ROBOTMIN($base_stats['energy'], $level);
                $min_stats['attack'] = MMRPG_SETTINGS_STATS_GET_ROBOTMIN($base_stats['attack'], $level);
                $min_stats['defense'] = MMRPG_SETTINGS_STATS_GET_ROBOTMIN($base_stats['defense'], $level);
                $min_stats['speed'] = MMRPG_SETTINGS_STATS_GET_ROBOTMIN($base_stats['speed'], $level);
                // Calculate the maximum stat values for this robot considering both level and overkill-based stat boosts
                $max_stats = array();
                //$max_stats['energy'] = MMRPG_SETTINGS_STATS_GET_ROBOTMAX($base_stats['energy'], $level);
                $max_stats['attack'] = MMRPG_SETTINGS_STATS_GET_ROBOTMAX($base_stats['attack'], $level);
                $max_stats['defense'] = MMRPG_SETTINGS_STATS_GET_ROBOTMAX($base_stats['defense'], $level);
                $max_stats['speed'] = MMRPG_SETTINGS_STATS_GET_ROBOTMAX($base_stats['speed'], $level);
                ?>
                                    <tr>
                                        <td class="left level">Lv <?php 
                echo $level;
                ?>
</td>
                                        <td class="center energy max"><?php 
                echo number_format($min_stats['energy'], 0, '.', ',');
                ?>
</td>
                                        <td class="center weapons max"><?php 
                echo number_format($base_stats['weapons'], 0, '.', ',');
                ?>
</td>
                                        <td class="center attack min"><?php 
                echo number_format($min_stats['attack'], 0, '.', ',');
                ?>
</td>
                                        <td class="center attack max"><?php 
                echo number_format($max_stats['attack'], 0, '.', ',');
                ?>
</td>
                                        <td class="center defense min"><?php 
                echo number_format($min_stats['defense'], 0, '.', ',');
                ?>
</td>
                                        <td class="center defense max"><?php 
                echo number_format($max_stats['defense'], 0, '.', ',');
                ?>
</td>
                                        <td class="center speed min"><?php 
                echo number_format($min_stats['speed'], 0, '.', ',');
                ?>
</td>
                                        <td class="center speed max"><?php 
                echo number_format($max_stats['speed'], 0, '.', ',');
                ?>
</td>
                                    </tr>
                                    <?php 
            }
            ?>
                                <tr>
                                    <td class="left help" colspan="9">
                                        <?php 
            if ($robot_info['robot_class'] == 'master') {
                ?>
                                            * Min stats represent a robot's base values without any knockout bonuses applied.<br />
                                            ** Max stats represent a robot's potential values with maximum knockout bonuses applied.
                                        <?php 
            } elseif ($robot_info['robot_class'] == 'mecha') {
                ?>
                                            * Min stats represent a mecha's base values without any difficulty mods applied.<br />
                                            ** Max stats represent a mecha's potential values with maximum difficulty mods applied.
                                        <?php 
            } elseif ($robot_info['robot_class'] == 'boss') {
                ?>
                                            * Min stats represent a boss's base values without any difficulty mods applied.<br />
                                            ** Max stats represent a boss's potential values with maximum difficulty mods applied.
                                        <?php 
            }
            ?>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <?php 
            if ($print_options['show_footer'] && $print_options['layout_style'] == 'website') {
                ?>
                        <div class="link_wrapper">
                            <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                            <a class="link link_permalink" href="<?php 
                echo $database_category_robot_url;
                ?>
#stats" rel="permalink">#Stats</a>
                        </div>
                    <?php 
            }
            ?>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_records']) {
            ?>

                    <h2 id="records" class="header header_full <?php 
            echo $robot_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left;">
                        <?php 
            echo $robot_info['robot_name'] . $robot_info['robot_name_append'];
            ?>
&#39;s Records
                    </h2>
                    <div class="body body_full" style="margin: 0 auto 5px; padding: 2px 0; min-height: 10px;">
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <?php 
            if ($robot_info['robot_class'] == 'master') {
                ?>
                                    <tr>
                                        <td class="right">
                                            <label>Unlocked By : </label>
                                            <span class="robot_quote"><?php 
                echo $temp_robot_records['robot_unlocked'] == 1 ? '1 Player' : number_format($temp_robot_records['robot_unlocked'], 0, '.', ',') . ' Players';
                ?>
</span>
                                        </td>
                                    </tr>
                                <?php 
            }
            ?>
                                <tr>
                                    <td class="right">
                                        <label>Encountered : </label>
                                        <span class="robot_quote"><?php 
            echo $temp_robot_records['robot_encountered'] == 1 ? '1 Time' : number_format($temp_robot_records['robot_encountered'], 0, '.', ',') . ' Times';
            ?>
</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right">
                                        <label>Summoned : </label>
                                        <span class="robot_quote"><?php 
            echo $temp_robot_records['robot_summoned'] == 1 ? '1 Time' : number_format($temp_robot_records['robot_summoned'], 0, '.', ',') . ' Times';
            ?>
</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right">
                                        <label>Defeated : </label>
                                        <span class="robot_quote"><?php 
            echo $temp_robot_records['robot_defeated'] == 1 ? '1 Time' : number_format($temp_robot_records['robot_defeated'], 0, '.', ',') . ' Times';
            ?>
</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right">
                                        <label>Scanned : </label>
                                        <span class="robot_quote"><?php 
            echo $temp_robot_records['robot_scanned'] == 1 ? '1 Time' : number_format($temp_robot_records['robot_scanned'], 0, '.', ',') . ' Times';
            ?>
</span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <?php 
            if ($print_options['show_footer'] && $print_options['layout_style'] == 'website') {
                ?>
                        <div class="link_wrapper">
                            <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                            <a class="link link_permalink" href="<?php 
                echo $database_category_robot_url;
                ?>
#records" rel="permalink">#Records</a>
                        </div>
                    <?php 
            }
            ?>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_footer'] && $print_options['layout_style'] == 'website_compact') {
            ?>

                    <div class="link_wrapper">
                        <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                        <a class="link link_permalink" href="<?php 
            echo $database_category_robot_url;
            ?>
" rel="permalink">+ View More</a>
                    </div>
                    <span class="link_container">
                        <?php 
            echo !empty($compact_footer_link_markup) ? implode("\n", $compact_footer_link_markup) : '';
            ?>
                    </span>

                <?php 
        }
        ?>

            </div>
        </div>
        <?php 
        // Collect the outbut buffer contents
        $this_markup = trim(ob_get_clean());
        // Return the generated markup
        return $this_markup;
    }
 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;
 }
 */
// Define the SEO variables for this page
$this_seo_title = 'Credits | About | ' . $this_seo_title;
$this_seo_description = 'Mega Man RPG World was created and is continually developed and maintained by Adrian Marceau / Ageman20XX, though the project would not have been possible without a great deal of inspiration and contributions from multiple outside sources. Being a Mega Man fan-game, this project obviously owes most of it\'s thanks to Capcom and of course, Keiji Inafune. Mega Man RPG World 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.';
// Define the Open Graph variables for this page
$this_graph_data['title'] = 'Credits and Contributors';
$this_graph_data['description'] = 'Mega Man RPG World was created and is continually developed and maintained by Adrian Marceau / Ageman20XX, though the project would not have been possible without a great deal of inspiration and contributions from multiple outside sources. Being a Mega Man fan-game, this project obviously owes most of it\'s thanks to Capcom and of course, Keiji Inafune.';
//$this_graph_data['image'] = MMRPG_CONFIG_ROOTURL.'images/assets/mmrpg-prototype-logo.png';
//$this_graph_data['type'] = 'website';
// Define the MARKUP variables for this page
$this_markup_header = 'Mega Man RPG World Credits';
// Collect user data for all contributors in the database
$contributor_ids = array(412, 92, 3842, 2, 110, 18, 435, 4117, 4091, 4307, 1330);
// 484 Ephnee
$user_fields = rpg_user::get_fields(true, 'user');
$role_fields = rpg_user_role::get_fields(true, 'role');
$contributor_index = $db->get_array_list("SELECT\n  {$user_fields}, {$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 IN (" . implode(', ', $contributor_ids) . ")\n  ;", 'user_id');
//die(print_r($contributor_index, true));
function temp_sort_by_date($u1, $u2)
{
    global $contributor_ids;
    if ($u1['user_id'] == 412) {
        return -1;
    } elseif ($u2['user_id'] == 412) {
        return 1;
    } elseif (array_search($u1['user_id'], $contributor_ids) < array_search($u2['user_id'], $contributor_ids)) {
        return -1;
    } elseif (array_search($u1['user_id'], $contributor_ids) > array_search($u2['user_id'], $contributor_ids)) {
        return 1;
    } elseif ($u1['user_date_created'] < $u2['user_date_created']) {
        return -1;