Example #1
0
function ArcadeSettings()
{
    global $scripturl, $txt, $context, $sourcedir, $modSettings;
    require_once $sourcedir . '/Subs-Arcade.php';
    loadLanguage('ArcadeAdmin');
    loadArcadeSettings();
    loadTemplate('ManageArcade');
    $subActions = array('show' => array('ArcadeSettingsShow', 'arcade_admin'), 'edit' => array('ArcadeSettingsEdit', 'arcade_admin'), 'save' => array('ArcadeSettingsSave', 'arcade_admin'), 'editcats' => array('ArcadeCategoryEdit', 'arcade_admin'), 'savecats' => array('ArcadeCategorySave', 'arcade_admin'), 'quick' => array('GamesQuickEdit', 'arcade_admin'), 'listgames' => array('GamesAdminList', 'arcade_admin'), 'files' => array('GamesAdminFiles', 'arcade_admin'), 'autofiles' => array('GamesAutoFiles', 'arcade_admin'), 'delete' => array('GamesDelete', 'arcade_admin'), 'upload' => array('GamesUpload', 'arcade_admin'), 'clear' => array('GamesCacheClear', 'arcade_admin'), 'highscore' => array('HighscoreEditor', 'arcade_admin'), 'highscore2' => array('HighscoreEditor2', 'arcade_admin'), 'settopics' => array('GamesTopicUpdater', 'arcade_admin'), 'arc_maintenance' => array('Arcade_Maintenance', 'arcade_admin'), 'fix' => array('Arcade_Fix_Scores', 'arcade_admin'), 'delshout' => array('arcade_del_shouts', 'arcade_admin'));
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'show';
    isAllowedTo($subActions[$_REQUEST['sa']][1]);
    // Tabs for browsing the different functions.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['arcade_admin'], 'help' => '', 'description' => $txt['arcade_description1'], 'tabs' => array('show' => array('description' => $txt['arcade_description1'], 'href' => $scripturl . '?action=admin;area=managearcade;sa=show'), 'edit' => array('description' => $txt['arcade_description2'], 'href' => $scripturl . '?action=admin;area=managearcade;sa=edit'), 'editcats' => array('description' => $txt['arcade_description3'], 'href' => $scripturl . '?action=admin;area=managearcade;sa=editcats'), 'listgames' => array('description' => $txt['arcade_description4'], 'href' => $scripturl . '?action=admin;area=managearcade;sa=listgames'), 'files' => array('description' => $txt['arcade_description5'], 'href' => $scripturl . '?action=admin;area=managearcade;sa=files'), 'autofiles' => array('description' => $txt['arcade_description6'], 'href' => $scripturl . '?action=admin;area=managearcade;sa=autofiles'), 'arc_maintenance' => array('description' => $txt['arcade_description7'], 'href' => $scripturl . '?action=admin;area=managearcade;sa=arc_maintenance')));
    $subActions[$_REQUEST['sa']][0]();
}
Example #2
0
function Arcade()
{
    global $arcSettings, $scripturl, $txt, $context, $sourcedir, $user_info, $modSettings, $db_count;
    //start the load timer
    $ltime = explode(" ", microtime());
    $ltime = $ltime[0] + $ltime[1];
    $context['loadstart'] = $ltime;
    $arcade_db_count = $db_count;
    require_once $sourcedir . '/Subs-Arcade.php';
    loadArcadeSettings();
    ArcadeLastUpdate();
    // Is Arcade enabled?
    if (empty($arcSettings['arcadeEnabled'])) {
        fatal_lang_error('arcade_disabled');
    }
    // Do we have permission?
    isAllowedTo('arcade_view');
    // Information for actions (file, function, [permission])
    $subActions = array('rate' => array('ArcadeList.php', 'ArcadeRate', 'arcade_rate'), 'list' => array('ArcadeList.php', 'ArcadeList'), 'frontPage' => array('ArcadeList.php', 'ArcadeFrontPage'), 'favorite' => array('ArcadeList.php', 'ArcadeFavorite', 'arcade_favorite'), 'search' => array('ArcadeList.php', 'ArcadeSearchXML'), 'shout' => array('ArcadeBlocks.php', 'ArcadeShout'), 'play' => array('ArcadePlay.php', 'ArcadePlay', 'arcade_play'), 'submit' => array('ArcadePlay.php', 'ArcadeSubmit'), 'highscore' => array('ArcadePlay.php', 'ArcadeHighscore'), 'comment' => array('ArcadePlay.php', 'ArcadeComment'), 'stats' => array('ArcadeStats.php', 'ArcadeStats'), 'ibpverify' => array('ArcadePlay.php', 'ArcadeVerifyIBP'), 'ibpsubmit' => array('ArcadePlay.php', 'ArcadeSubmitIBP'), 'pro_stats' => array('ArcadeSigsStats_v2.php', 'Arcade_pro_stats'), 'v3verify' => array('ArcadePlay.php', 'ArcadeVerifyV3'), 'tour' => array('ArcadeTour.php', 'ArcadeTour'), 'tour_games' => array('ArcadeTour.php', 'ArcadeGames'));
    // Fix for broken games which doesn't send sa/do=submit
    if (isset($_POST['game']) && isset($_POST['score']) && !isset($_REQUEST['sa'])) {
        $_REQUEST['sa'] = 'submit';
    } elseif (isset($_REQUEST['game']) && is_numeric($_REQUEST['game']) && !isset($_REQUEST['sa'])) {
        $_REQUEST['sa'] = 'play';
    }
    $setFrontPage = $arcSettings['gameFrontPage'] == 0 ? 'list' : 'frontPage';
    if (isset($_REQUEST['sort']) || isset($_REQUEST['category']) || isset($_REQUEST['favorites'])) {
        $_REQUEST['sa'] = 'list';
    } else {
        $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : $setFrontPage;
    }
    if (!in_array($_REQUEST['sa'], array('highscore', 'comment')) && isset($_SESSION['arcade']['highscore'])) {
        unset($_SESSION['arcade']['highscore']);
    }
    // Load Arcade
    ArcadeLoad('normal');
    // Check permission if needed
    if (isset($actions[$_REQUEST['sa']][2])) {
        isAllowedTo($subActions[$_REQUEST['sa']][2]);
    }
    require_once $sourcedir . '/' . $subActions[$_REQUEST['sa']][0];
    $subActions[$_REQUEST['sa']][1]();
    $context['arcade']['queries'] = $db_count - $arcade_db_count;
}
Example #3
0
    /**
     *
     */
    public static function loadArcade($mode = 'normal', $index = '')
    {
        global $db_prefix, $scripturl, $txt, $modSettings, $context, $settings, $sourcedir, $user_info;
        global $smcFunc, $boarddir;
        static $loaded = false;
        if (!empty($loaded)) {
            return;
        }
        spl_autoload_register(array('SMFArcade', 'autoload'));
        $loaded = true;
        $context['arcade'] = array();
        require_once $sourcedir . '/Subs-Arcade.php';
        // Load language
        loadLanguage('Arcade');
        // Permission query
        arcadePermissionQuery();
        // Normal mode
        if ($mode == 'normal' || $mode == 'arena') {
            if (empty($modSettings['arcadeEnabled'])) {
                return false;
            }
            loadTemplate('Arcade', array('forum', 'arcade'));
            $user_info['arcade_settings'] = loadArcadeSettings($user_info['id']);
            $context['games_per_page'] = !empty($user_info['arcade_settings']['gamesPerPage']) ? $user_info['arcade_settings']['gamesPerPage'] : $modSettings['gamesPerPage'];
            $context['scores_per_page'] = !empty($user_info['arcade_settings']['scoresPerPage']) ? $user_info['arcade_settings']['scoresPerPage'] : $modSettings['scoresPerPage'];
            if (!empty($modSettings['arcadeSkipJquery'])) {
                $context['html_headers'] .= '<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/arcade/jquery.js"></script>';
            }
            // Arcade javascript
            $context['html_headers'] .= '<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/arcade/main.js"></script>';
            // Add Arcade to link tree
            $context['linktree'][] = array('url' => $scripturl . '?action=arcade', 'name' => $txt['arcade']);
            // What I can do?
            $context['arcade']['can_play'] = allowedTo('arcade_play');
            $context['arcade']['can_favorite'] = !empty($modSettings['arcadeEnableFavorites']) && !$user_info['is_guest'];
            $context['arcade']['can_rate'] = !empty($modSettings['arcadeEnableRatings']) && !$user_info['is_guest'];
            $context['arcade']['can_submit'] = allowedTo('arcade_submit');
            $context['arcade']['can_comment_own'] = allowedTo('arcade_comment_own');
            $context['arcade']['can_comment_any'] = allowedTo('arcade_comment_any');
            $context['arcade']['can_admin_arcade'] = allowedTo('arcade_admin');
            $context['arcade']['can_create_match'] = allowedTo('arcade_create_match');
            $context['arcade']['can_join_match'] = allowedTo('arcade_join_match');
            // Or can I (do I have enought posts etc.)
            PostPermissionCheck();
            // Finally load Arcade Settings
            LoadArcadeSettings();
            if (!isset($_REQUEST['xml'])) {
                $context['template_layers'][] = 'Arcade';
            }
        } elseif ($mode == 'profile') {
            loadTemplate('ArcadeProfile', array('arcade', 'forum'));
        } elseif ($mode == 'admin') {
            loadTemplate('ArcadeAdmin');
            loadLanguage('ArcadeAdmin');
            $context['html_headers'] .= '
			<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/arcade.js"></script>';
            // Update games database?
            if (file_exists($boarddir . '/Games.xml')) {
                loadClassFile('Class-Package.php');
                $games = new xmlArray(file_get_contents($boarddir . '/Games.xml'));
                $database = $games->path('smf/database');
                $database = $database->to_array();
                $xmlGames = $games->set('smf/game');
                if (!empty($modSettings['arcadeGameDatabaseVersion']) && $modSettings['arcadeGameDatabaseVersion'] > $database['version']) {
                    break;
                }
                $games = array();
                foreach ($xmlGames as $game) {
                    $games[] = array($game->fetch('id'), $game->fetch('name'), $game->fetch('description'), $game->fetch('url/info'), $game->fetch('url/download'));
                }
                $smcFunc['db_insert']('replace', '{db_prefix}arcade_game_info', array('internal_name' => 'string', 'game_name' => 'string', 'description' => 'string', 'info_url' => 'string', 'download_url' => 'string'), $games, array('internal_name'));
                updateSettings(array('arcadeGameDatabaseVersion' => $database['version'], 'arcadeGameDatabaseUpdate' => $database['update']));
                @unlink($boarddir . '/Games.xml');
            }
            $context['template_layers'][] = 'ArcadeAdmin';
            $context['page_title'] = $txt['arcade_admin_title'];
        }
    }
Example #4
0
function arcadeSettings($memID)
{
    global $scripturl, $txt, $db_prefix, $context, $smcFunc, $user_info, $sourcedir, $modSettings;
    require_once $sourcedir . '/Arcade.php';
    SMFArcade::loadArcade('profile');
    $events = arcadeEvent('get');
    $arcadeSettings = loadArcadeSettings($memID);
    $context['profile_fields'] = array('notifications' => array('type' => 'callback', 'callback_func' => 'arcade_notification'), 'gamesPerPage' => array('label' => $txt['arcade_user_gamesPerPage'], 'type' => 'select', 'options' => array(0 => sprintf($txt['arcade_user_gamesPerPage_default'], $modSettings['gamesPerPage']), 5 => 5, 10 => 10, 20 => 20, 25 => 25, 50 => 50), 'cast' => 'int', 'validate' => 'int', 'value' => isset($arcadeSettings['gamesPerPage']) ? $arcadeSettings['gamesPerPage'] : 0), 'scoresPerPage' => array('label' => $txt['arcade_user_scoresPerPage'], 'type' => 'select', 'options' => array(0 => sprintf($txt['arcade_user_scoresPerPage_default'], $modSettings['scoresPerPage']), 5 => 5, 10 => 10, 20 => 20, 25 => 25, 50 => 50), 'cast' => 'int', 'validate' => 'int', 'value' => isset($arcadeSettings['scoresPerPage']) ? $arcadeSettings['scoresPerPage'] : 0));
    if (!empty($modSettings['disableCustomPerPage'])) {
        unset($context['profile_fields']['gamesPerPage']);
        unset($context['profile_fields']['scoresPerPage']);
    }
    if (isset($_REQUEST['save'])) {
        checkSession('post');
        $updates = array();
        $errors = false;
        foreach ($events as $event) {
            foreach ($event['notification'] as $notify => $default) {
                if (empty($_POST[$notify])) {
                    $updates[] = array($memID, $notify, 0);
                } else {
                    $updates[] = array($memID, $notify, 1);
                }
            }
        }
        foreach ($context['profile_fields'] as $id => $field) {
            if ($id == 'notifications' || !isset($_POST[$id])) {
                continue;
            }
            if ($field['cast'] == 'int') {
                $_POST[$id] = (int) $_POST[$id];
            }
            if ($field['type'] == 'select') {
                if (isset($field['options'][$_POST[$id]])) {
                    $updates[] = array($memID, $id, $_POST[$id]);
                }
            }
        }
        if (!$errors) {
            $smcFunc['db_insert']('replace', '{db_prefix}arcade_settings', array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string'), $updates, array('id_member', 'variable'));
            redirectexit('action=profile;u=' . $memID . ';sa=arcadeSettings');
        }
    }
    $context['notifications'] = array();
    foreach ($events as $event) {
        foreach ($event['notification'] as $notify => $default) {
            $context['notifications'][$notify] = array('id' => $notify, 'text' => $txt['arcade_notification_' . $notify], 'value' => isset($arcadeSettings[$notify]) ? (bool) $arcadeSettings[$notify] : $default, 'default' => !isset($arcadeSettings[$notify]));
        }
    }
    // Template
    $context['profile_custom_submit_url'] = $scripturl . '?action=profile;area=arcadeSettings;u=' . $memID . ';save';
    $context['page_desc'] = $txt['arcade_usersettings_desc'];
    $context['sub_template'] = 'edit_options';
}
Example #5
0
template_poparc_stats()
		-the output for the popup

Arcade_pro_stats()
		-sets up the popup window

hhmmss()
		-turns seconds in to readable time

/********************************************************************************/
//Make sure we have language
LoadLanguage('Arcade');
global $sourcedir;
require_once $sourcedir . '/Subs-Arcade.php';
loadArcadeSettings();
function arcade_champs_post_profile($message)
{
    global $context, $settings, $scripturl, $sourcedir, $arcSettings, $txt, $user_info;
    if ($user_info['id'] != 0) {
        $icon_type = $arcSettings['arcade_champion_pp'];
        if (!$message['member']['is_guest']) {
            echo '&nbsp;<a href="#" onclick="window.open(\'', $scripturl, '?action=arcade;sa=pro_stats;ta=', $message['member']['id'], '\',\'PopupWindow\',\'height=300,width=700,scrollbars=1\');return false;"><img src="' . $settings['images_url'] . '/arc_icons/arc.gif" width="18" height="18" border="0" alt="Stats" title="' . $txt['arcade_champions_stats'] . '" ></a>';
            if ($icon_type != 2) {
                if (@is_array($context['arcade']['championsGold'][$message['member']['id']])) {
                    $k = 0;
                    $j = 0;
                    echo $icon_type == 1 ? "<br /><br />" . $txt['arcade_champions_cho'] . '<br />' : "<br /><br />" . $txt['arcade_champions_tro'] . '<br />';
                    foreach ($context['arcade']['championsGold'][$message['member']['id']] as $tmp) {
                        if ($icon_type == 0) {
                            echo '<a href="', $tmp['url'], '"><img src="' . $settings['images_url'] . '/arc_icons/gold.gif" border="0" alt="cup" title="' . $txt['arcade_champions_play'] . ' ', $tmp['game_name'], '"></a>&nbsp;';