Пример #1
0
function ManageSmileys()
{
    global $context, $txt, $scripturl, $modSettings;
    isAllowedTo('manage_smileys');
    loadLanguage('ManageSmileys');
    loadAdminTemplate('ManageSmileys');
    $subActions = array('addsmiley' => 'AddSmiley', 'editicon' => 'EditMessageIcons', 'editicons' => 'EditMessageIcons', 'editsets' => 'EditSmileySets', 'editsmileys' => 'EditSmileys', 'import' => 'EditSmileySets', 'modifyset' => 'EditSmileySets', 'modifysmiley' => 'EditSmileys', 'setorder' => 'EditSmileyOrder', 'settings' => 'EditSmileySettings', 'install' => 'InstallSmileySet');
    // Default the sub-action to 'edit smiley settings'.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'editsets';
    $context['page_title'] = $txt['smileys_manage'];
    $context['sub_action'] = $_REQUEST['sa'];
    $context['sub_template'] = $context['sub_action'];
    // Load up all the tabs...
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['smileys_manage'], 'help' => 'smileys', 'description' => $txt['smiley_settings_explain'], 'tabs' => array('editsets' => array('description' => $txt['smiley_editsets_explain']), 'addsmiley' => array('description' => $txt['smiley_addsmiley_explain']), 'editsmileys' => array('description' => $txt['smiley_editsmileys_explain']), 'setorder' => array('description' => $txt['smiley_setorder_explain']), 'editicons' => array('description' => $txt['icons_edit_icons_explain']), 'settings' => array('description' => $txt['smiley_settings_explain'])));
    // Some settings may not be enabled, disallow these from the tabs as appropriate.
    if (empty($modSettings['messageIcons_enable'])) {
        $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true;
    }
    if (empty($modSettings['smiley_enable'])) {
        $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true;
        $context[$context['admin_menu_name']]['tab_data']['tabs']['editsmileys']['disabled'] = true;
        $context[$context['admin_menu_name']]['tab_data']['tabs']['setorder']['disabled'] = true;
    }
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']]();
}
Пример #2
0
function Packages()
{
    global $txt, $sourcedir, $context;
    //!!! Remove this!
    if (isset($_GET['get']) || isset($_GET['pgdownload'])) {
        require_once $sourcedir . '/PackageGet.php';
        return PackageGet();
    }
    isAllowedTo('admin_forum');
    // Load all the basic stuff.
    require_once $sourcedir . '/lib/Subs-Package.php';
    loadLanguage('Packages');
    loadAdminTemplate('Packages');
    $context['page_title'] = $txt['package'];
    // Delegation makes the world... that is, the package manager go 'round.
    $subActions = array('browse' => 'PackageBrowse', 'remove' => 'PackageRemove', 'list' => 'PackageList', 'ftptest' => 'PackageFTPTest', 'install' => 'PackageInstallTest', 'install2' => 'PackageInstall', 'uninstall' => 'PackageInstallTest', 'uninstall2' => 'PackageInstall', 'installed' => 'InstalledList', 'options' => 'PackageOptions', 'perms' => 'PackagePermissions', 'flush' => 'FlushInstall', 'examine' => 'ExamineFile', 'showoperations' => 'ViewOperations');
    // Work out exactly who it is we are calling.
    if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
        $context['sub_action'] = $_REQUEST['sa'];
    } else {
        $context['sub_action'] = 'browse';
    }
    // Set up some tabs...
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['package_manager'], 'description' => $txt['package_manager_desc'], 'tabs' => array('browse' => array(), 'packageget' => array('description' => $txt['download_packages_desc']), 'installed' => array('description' => $txt['installed_packages_desc']), 'perms' => array('description' => $txt['package_file_perms_desc']), 'options' => array('description' => $txt['package_install_options_ftp_why'])));
    // Call the function we're handing control to.
    $subActions[$context['sub_action']]();
}
Пример #3
0
function AdminMain()
{
    global $txt, $context, $scripturl, $modSettings, $settings, $sourcedir, $options, $boarddir, $backend_subdir;
    // Load the language and templates....
    loadLanguage('Admin');
    loadAdminTemplate('Admin');
    $context['robot_no_index'] = true;
    require_once $sourcedir . '/lib/Subs-Menu.php';
    // Some preferences.
    $context['admin_preferences'] = !empty($options['admin_preferences']) ? unserialize($options['admin_preferences']) : array();
    // Define all the menu structure - see Subs-Menu.php for details!
    $admin_areas = array('forum' => array('title' => $txt['admin_main'], 'permission' => array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'), 'areas' => array('index' => array('label' => $txt['admin_center'], 'function' => 'AdminHome', 'icon' => 'administration.gif'), 'credits' => array('label' => $txt['support_credits_title'], 'function' => 'AdminHome', 'icon' => 'support.gif'), 'news' => array('label' => $txt['news_title'], 'file' => $backend_subdir . '/ManageNews.php', 'function' => 'ManageNews', 'icon' => 'news.gif', 'permission' => array('edit_news', 'send_mail', 'admin_forum'), 'subsections' => array('editnews' => array($txt['admin_edit_news'], 'edit_news'), 'mailingmembers' => array($txt['admin_newsletters'], 'send_mail'), 'settings' => array($txt['settings'], 'admin_forum'))), 'packages' => array('label' => $txt['package'], 'file' => $backend_subdir . '/Packages.php', 'function' => 'Packages', 'permission' => array('admin_forum'), 'icon' => 'packages.gif', 'subsections' => array('browse' => array($txt['browse_packages']), 'packageget' => array($txt['download_packages'], 'url' => $scripturl . '?action=admin;area=packages;sa=packageget;get'), 'installed' => array($txt['installed_packages']), 'perms' => array($txt['package_file_perms']), 'options' => array($txt['package_settings']))), 'plugins' => array('label' => $txt['plugins_title'], 'file' => $backend_subdir . '/Plugins.php', 'function' => 'PluginsMain', 'permission' => array('admin_forum'), 'icon' => 'packages.gif', 'subsections' => array('browse' => array($txt['browse_plugins']), 'hooks' => array($txt['browse_hooks']))), 'search' => array('function' => 'AdminSearch', 'permission' => array('admin_forum'), 'select' => 'index'))), 'config' => array('title' => $txt['admin_config'], 'permission' => array('admin_forum'), 'areas' => array('corefeatures' => array('label' => $txt['core_settings_title'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifyCoreFeatures', 'icon' => 'corefeatures.gif'), 'featuresettings' => array('label' => $txt['modSettings_title'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifyFeatureSettings', 'icon' => 'features.gif', 'subsections' => array('basic' => array($txt['mods_cat_features']), 'layout' => array($txt['mods_cat_layout']), 'sig' => array($txt['signature_settings_short']), 'profile' => array($txt['custom_profile_shorttitle'], 'enabled' => in_array('cp', $context['admin_features'])))), 'securitysettings' => array('label' => $txt['admin_security_moderation'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifySecuritySettings', 'icon' => 'security.gif', 'subsections' => array('general' => array($txt['mods_cat_security_general']), 'spam' => array($txt['antispam_title']), 'moderation' => array($txt['moderation_settings_short'], 'enabled' => substr($modSettings['warning_settings'], 0, 1) == 1))), 'languages' => array('label' => $txt['language_configuration'], 'file' => $backend_subdir . '/ManageServer.php', 'function' => 'ManageLanguages', 'icon' => 'languages.gif', 'subsections' => array('edit' => array($txt['language_edit']), 'add' => array($txt['language_add']), 'settings' => array($txt['language_settings']))), 'serversettings' => array('label' => $txt['admin_server_settings'], 'file' => $backend_subdir . '/ManageServer.php', 'function' => 'ModifySettings', 'icon' => 'server.gif', 'subsections' => array('general' => array($txt['general_settings']), 'database' => array($txt['database_paths_settings']), 'cookie' => array($txt['cookies_sessions_settings']), 'cache' => array($txt['caching_settings']), 'loads' => array($txt['load_balancing_settings']))), 'relatedtopics' => array('label' => $txt['admin_related_topic'], 'file' => $backend_subdir . '/RelatedTopics.php', 'function' => 'RelatedTopicsAdmin', 'subsections' => array('settings' => array($txt['admin_related_topics_settings']), 'methods' => array($txt['admin_related_topics_methods']))), 'current_theme' => array('label' => $txt['theme_current_settings'], 'file' => $backend_subdir . '/Themes.php', 'function' => 'ThemesMain', 'custom_url' => $scripturl . '?action=admin;area=theme;sa=settings;th=' . $settings['theme_id'], 'icon' => 'current_theme.gif'), 'theme' => array('label' => $txt['theme_admin'], 'file' => $backend_subdir . '/Themes.php', 'function' => 'ThemesMain', 'custom_url' => $scripturl . '?action=admin;area=theme;sa=admin', 'icon' => 'themes.gif', 'subsections' => array('admin' => array($txt['themeadmin_admin_title']), 'list' => array($txt['themeadmin_list_title']), 'reset' => array($txt['themeadmin_reset_title']), 'edit' => array($txt['themeadmin_edit_title']))), 'modsettings' => array('label' => $txt['admin_modifications'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifyModSettings', 'icon' => 'modifications.gif', 'related' => array($txt['admin_related_topic']), 'subsections' => array('general' => array($txt['mods_cat_modifications_misc']))), 'socialsettings' => array('label' => $txt['admin_social'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifySocialSettings', 'subsections' => array('general' => array($txt['socialsettings_general']), 'astream' => array($txt['socialsettings_astream']))))), 'layout' => array('title' => $txt['layout_controls'], 'permission' => array('manage_boards', 'admin_forum', 'manage_smileys', 'manage_attachments', 'moderate_forum'), 'areas' => array('manageboards' => array('label' => $txt['admin_boards'], 'file' => $backend_subdir . '/ManageBoards.php', 'function' => 'ManageBoards', 'icon' => 'boards.gif', 'permission' => array('manage_boards'), 'subsections' => array('main' => array($txt['boardsEdit']), 'newcat' => array($txt['mboards_new_cat']), 'settings' => array($txt['settings'], 'admin_forum'))), 'postsettings' => array('label' => $txt['manageposts'], 'file' => $backend_subdir . '/ManagePosts.php', 'function' => 'ManagePostSettings', 'permission' => array('admin_forum'), 'icon' => 'posts.gif', 'subsections' => array('posts' => array($txt['manageposts_settings']), 'bbc' => array($txt['manageposts_bbc_settings']), 'censor' => array($txt['admin_censored_words']), 'topics' => array($txt['manageposts_topic_settings']), 'prefixes' => array($txt['manageposts_prefix_settings']), 'tags' => array($txt['manageposts_tag_settings']), 'ratings' => array($txt['karma']))), 'managecalendar' => array('label' => $txt['manage_calendar'], 'file' => $backend_subdir . '/ManageCalendar.php', 'function' => 'ManageCalendar', 'icon' => 'calendar.gif', 'permission' => array('admin_forum'), 'enabled' => in_array('cd', $context['admin_features']), 'subsections' => array('holidays' => array($txt['manage_holidays'], 'admin_forum', 'enabled' => !empty($modSettings['cal_enabled'])), 'settings' => array($txt['calendar_settings'], 'admin_forum'))), 'managesearch' => array('label' => $txt['manage_search'], 'file' => $backend_subdir . '/ManageSearch.php', 'function' => 'ManageSearch', 'icon' => 'search.gif', 'permission' => array('admin_forum'), 'subsections' => array('weights' => array($txt['search_weights']), 'method' => array($txt['search_method']), 'settings' => array($txt['settings']), 'managesphinx' => array($txt['search_managesphinx']))), 'smileys' => array('label' => $txt['smileys_manage'], 'file' => $backend_subdir . '/ManageSmileys.php', 'function' => 'ManageSmileys', 'icon' => 'smiley.gif', 'permission' => array('manage_smileys'), 'subsections' => array('editsets' => array($txt['smiley_sets']), 'addsmiley' => array($txt['smileys_add'], 'enabled' => !empty($modSettings['smiley_enable'])), 'editsmileys' => array($txt['smileys_edit'], 'enabled' => !empty($modSettings['smiley_enable'])), 'setorder' => array($txt['smileys_set_order'], 'enabled' => !empty($modSettings['smiley_enable'])), 'editicons' => array($txt['icons_edit_message_icons'], 'enabled' => !empty($modSettings['messageIcons_enable'])), 'settings' => array($txt['settings']))), 'manageattachments' => array('label' => $txt['attachments_avatars'], 'file' => $backend_subdir . '/ManageAttachments.php', 'function' => 'ManageAttachments', 'icon' => 'attachment.gif', 'permission' => array('manage_attachments'), 'subsections' => array('browse' => array($txt['attachment_manager_browse']), 'attachments' => array($txt['attachment_manager_settings']), 'avatars' => array($txt['attachment_manager_avatar_settings']), 'maintenance' => array($txt['attachment_manager_maintenance']))))), 'members' => array('title' => $txt['admin_manage_members'], 'permission' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum'), 'areas' => array('viewmembers' => array('label' => $txt['admin_users'], 'file' => $backend_subdir . '/ManageMembers.php', 'function' => 'ViewMembers', 'icon' => 'members.gif', 'permission' => array('moderate_forum'), 'subsections' => array('all' => array($txt['view_all_members']), 'search' => array($txt['mlist_search']))), 'membergroups' => array('label' => $txt['admin_groups'], 'file' => $backend_subdir . '/ManageMembergroups.php', 'function' => 'ModifyMembergroups', 'icon' => 'membergroups.gif', 'permission' => array('manage_membergroups'), 'subsections' => array('index' => array($txt['membergroups_edit_groups'], 'manage_membergroups'), 'add' => array($txt['membergroups_new_group'], 'manage_membergroups'), 'settings' => array($txt['settings'], 'admin_forum'))), 'permissions' => array('label' => $txt['edit_permissions'], 'file' => $backend_subdir . '/ManagePermissions.php', 'function' => 'ModifyPermissions', 'icon' => 'permissions.gif', 'permission' => array('manage_permissions'), 'subsections' => array('index' => array($txt['permissions_groups'], 'manage_permissions'), 'board' => array($txt['permissions_boards'], 'manage_permissions'), 'profiles' => array($txt['permissions_profiles'], 'manage_permissions'), 'postmod' => array($txt['permissions_post_moderation'], 'manage_permissions', 'enabled' => $modSettings['postmod_active']), 'settings' => array($txt['settings'], 'admin_forum'))), 'regcenter' => array('label' => $txt['registration_center'], 'file' => $backend_subdir . '/ManageRegistration.php', 'function' => 'RegCenter', 'icon' => 'regcenter.gif', 'permission' => array('admin_forum', 'moderate_forum'), 'subsections' => array('register' => array($txt['admin_browse_register_new'], 'moderate_forum'), 'agreement' => array($txt['registration_agreement'], 'admin_forum'), 'reservednames' => array($txt['admin_reserved_set'], 'admin_forum'), 'settings' => array($txt['settings'], 'admin_forum'))), 'ban' => array('label' => $txt['ban_title'], 'file' => $backend_subdir . '/ManageBans.php', 'function' => 'Ban', 'icon' => 'ban.gif', 'permission' => 'manage_bans', 'subsections' => array('list' => array($txt['ban_edit_list']), 'add' => array($txt['ban_add_new']), 'browse' => array($txt['ban_trigger_browse']), 'log' => array($txt['ban_log']))), 'paidsubscribe' => array('label' => $txt['paid_subscriptions'], 'enabled' => in_array('ps', $context['admin_features']), 'file' => $backend_subdir . '/ManagePaid.php', 'icon' => 'paid.gif', 'function' => 'ManagePaidSubscriptions', 'permission' => 'admin_forum', 'subsections' => array('view' => array($txt['paid_subs_view']), 'settings' => array($txt['settings']))), 'sengines' => array('label' => $txt['search_engines'], 'enabled' => in_array('sp', $context['admin_features']), 'file' => $backend_subdir . '/ManageSearchEngines.php', 'icon' => 'engines.gif', 'function' => 'SearchEngines', 'permission' => 'admin_forum', 'subsections' => array('stats' => array($txt['spider_stats']), 'logs' => array($txt['spider_logs']), 'spiders' => array($txt['spiders']), 'settings' => array($txt['settings']))))), 'maintenance' => array('title' => $txt['admin_maintenance'], 'permission' => array('admin_forum'), 'areas' => array('maintain' => array('label' => $txt['maintain_title'], 'file' => $backend_subdir . '/ManageMaintenance.php', 'icon' => 'maintain.gif', 'function' => 'ManageMaintenance', 'subsections' => array('routine' => array($txt['maintain_sub_routine'], 'admin_forum'), 'database' => array($txt['maintain_sub_database'], 'admin_forum'), 'members' => array($txt['maintain_sub_members'], 'admin_forum'), 'topics' => array($txt['maintain_sub_topics'], 'admin_forum'))), 'scheduledtasks' => array('label' => $txt['maintain_tasks'], 'file' => $backend_subdir . '/ManageScheduledTasks.php', 'icon' => 'scheduled.gif', 'function' => 'ManageScheduledTasks', 'subsections' => array('tasks' => array($txt['maintain_tasks'], 'admin_forum'), 'tasklog' => array($txt['scheduled_log'], 'admin_forum'))), 'mailqueue' => array('label' => $txt['mailqueue_title'], 'file' => $backend_subdir . '/ManageMail.php', 'function' => 'ManageMail', 'icon' => 'mail.gif', 'subsections' => array('browse' => array($txt['mailqueue_browse'], 'admin_forum'), 'settings' => array($txt['mailqueue_settings'], 'admin_forum'))), 'reports' => array('enabled' => in_array('rg', $context['admin_features']), 'label' => $txt['generate_reports'], 'file' => 'Reports.php', 'function' => 'ReportsMain', 'icon' => 'reports.gif'), 'logs' => array('label' => $txt['logs'], 'function' => 'AdminLogs', 'icon' => 'logs.gif', 'subsections' => array('errorlog' => array($txt['errlog'], 'admin_forum', 'enabled' => !empty($modSettings['enableErrorLogging']), 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc'), 'adminlog' => array($txt['admin_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])), 'modlog' => array($txt['moderation_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])), 'banlog' => array($txt['ban_log'], 'manage_bans'), 'spiderlog' => array($txt['spider_logs'], 'admin_forum', 'enabled' => in_array('sp', $context['admin_features'])), 'tasklog' => array($txt['scheduled_log'], 'admin_forum'), 'pruning' => array($txt['pruning_title'], 'admin_forum'))), 'repairboards' => array('label' => $txt['admin_repair'], 'file' => $backend_subdir . '/RepairBoards.php', 'function' => 'RepairBoards', 'select' => 'maintain', 'hidden' => true))));
    if (!$modSettings['tags_active']) {
        unset($admin_areas['layout']['areas']['postsettings']['subsections']['tags']);
    }
    if (empty($modSettings['karmaMode'])) {
        unset($admin_areas['layout']['areas']['postsettings']['subsections']['ratings']);
    }
    // Any files to include for administration?
    if (!empty($modSettings['integrate_admin_include'])) {
        $admin_includes = explode(',', $modSettings['integrate_admin_include']);
        foreach ($admin_includes as $include) {
            $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
            if (file_exists($include)) {
                require_once $include;
            }
        }
    }
    // Let them modify admin areas easily.
    HookAPI::callHook('integrate_admin_areas', array(&$admin_areas));
    SimpleSEF::adminAreas($admin_areas);
    // Make sure the administrator has a valid session...
    validateSession();
    // Actually create the menu!
    $admin_include_data = createMenu($admin_areas);
    unset($admin_areas);
    // Nothing valid?
    if ($admin_include_data == false) {
        fatal_lang_error('no_access', false);
    }
    // Build the link tree.
    $context['linktree'][] = array('url' => $scripturl . '?action=admin', 'name' => $txt['admin_center']);
    if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') {
        $context['linktree'][] = array('url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'name' => $admin_include_data['label']);
    }
    if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) {
        $context['linktree'][] = array('url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0]);
    }
    // Make a note of the Unique ID for this menu.
    $context['admin_menu_id'] = $context['max_menu_id'];
    $context['admin_menu_name'] = 'menu_data_' . $context['admin_menu_id'];
    // Why on the admin are we?
    $context['admin_area'] = $admin_include_data['current_area'];
    // Now - finally - call the right place!
    if (isset($admin_include_data['file'])) {
        require_once $sourcedir . '/' . $admin_include_data['file'];
    }
    $admin_include_data['function']();
}
Пример #4
0
function EditHoliday()
{
    global $txt, $context, $scripturl, $smcFunc;
    loadAdminTemplate('ManageCalendar');
    $context['is_new'] = !isset($_REQUEST['holiday']);
    $context['page_title'] = $context['is_new'] ? $txt['holidays_add'] : $txt['holidays_edit'];
    $context['sub_template'] = 'edit_holiday';
    // Cast this for safety...
    if (isset($_REQUEST['holiday'])) {
        $_REQUEST['holiday'] = (int) $_REQUEST['holiday'];
    }
    // Submitting?
    if (isset($_POST[$context['session_var']]) && (isset($_REQUEST['delete']) || $_REQUEST['title'] != '')) {
        checkSession();
        // Not too long good sir?
        $_REQUEST['title'] = commonAPI::substr($_REQUEST['title'], 0, 60);
        $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0;
        if (isset($_REQUEST['delete'])) {
            smf_db_query('
				DELETE FROM {db_prefix}calendar_holidays
				WHERE id_holiday = {int:selected_holiday}', array('selected_holiday' => $_REQUEST['holiday']));
        } else {
            $date = strftime($_REQUEST['year'] <= 4 ? '0004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $_REQUEST['month'], $_REQUEST['day'], $_REQUEST['year']));
            if (isset($_REQUEST['edit'])) {
                smf_db_query('
					UPDATE {db_prefix}calendar_holidays
					SET event_date = {date:holiday_date}, title = {string:holiday_title}
					WHERE id_holiday = {int:selected_holiday}', array('holiday_date' => $date, 'selected_holiday' => $_REQUEST['holiday'], 'holiday_title' => $_REQUEST['title']));
            } else {
                smf_db_insert('', '{db_prefix}calendar_holidays', array('event_date' => 'date', 'title' => 'string-60'), array($date, $_REQUEST['title']), array('id_holiday'));
            }
        }
        updateSettings(array('calendar_updated' => time()));
        redirectexit('action=admin;area=managecalendar;sa=holidays');
    }
    // Default states...
    if ($context['is_new']) {
        $context['holiday'] = array('id' => 0, 'day' => date('d'), 'month' => date('m'), 'year' => '0000', 'title' => '');
    } else {
        $request = smf_db_query('
			SELECT id_holiday, YEAR(event_date) AS year, MONTH(event_date) AS month, DAYOFMONTH(event_date) AS day, title
			FROM {db_prefix}calendar_holidays
			WHERE id_holiday = {int:selected_holiday}
			LIMIT 1', array('selected_holiday' => $_REQUEST['holiday']));
        while ($row = mysql_fetch_assoc($request)) {
            $context['holiday'] = array('id' => $row['id_holiday'], 'day' => $row['day'], 'month' => $row['month'], 'year' => $row['year'] <= 4 ? 0 : $row['year'], 'title' => $row['title']);
        }
        mysql_free_result($request);
    }
    // Last day for the drop down?
    $context['holiday']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['holiday']['month'] == 12 ? 1 : $context['holiday']['month'] + 1, 0, $context['holiday']['month'] == 12 ? $context['holiday']['year'] + 1 : $context['holiday']['year']));
}
Пример #5
0
function ViewMembers()
{
    global $txt, $scripturl, $context, $modSettings, $smcFunc;
    $subActions = array('all' => array('ViewMemberlist', 'moderate_forum'), 'approve' => array('AdminApprove', 'moderate_forum'), 'browse' => array('MembersAwaitingActivation', 'moderate_forum'), 'search' => array('SearchMembers', 'moderate_forum'), 'query' => array('ViewMemberlist', 'moderate_forum'));
    // Default to sub action 'index' or 'settings' depending on permissions.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'all';
    // We know the sub action, now we know what you're allowed to do.
    isAllowedTo($subActions[$_REQUEST['sa']][1]);
    // Load the essentials.
    loadLanguage('ManageMembers');
    loadAdminTemplate('ManageMembers');
    // Get counts on every type of activation - for sections and filtering alike.
    $request = smf_db_query('
		SELECT COUNT(*) AS total_members, is_activated
		FROM {db_prefix}members
		WHERE is_activated != {int:is_activated}
		GROUP BY is_activated', array('is_activated' => 1));
    $context['activation_numbers'] = array();
    $context['awaiting_activation'] = 0;
    $context['awaiting_approval'] = 0;
    while ($row = mysql_fetch_assoc($request)) {
        $context['activation_numbers'][$row['is_activated']] = $row['total_members'];
    }
    mysql_free_result($request);
    foreach ($context['activation_numbers'] as $activation_type => $total_members) {
        if (in_array($activation_type, array(0, 2))) {
            $context['awaiting_activation'] += $total_members;
        } elseif (in_array($activation_type, array(3, 4, 5))) {
            $context['awaiting_approval'] += $total_members;
        }
    }
    // For the page header... do we show activation?
    $context['show_activate'] = !empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 || !empty($context['awaiting_activation']);
    // What about approval?
    $context['show_approve'] = !empty($modSettings['registration_method']) && $modSettings['registration_method'] == 2 || !empty($context['awaiting_approval']) || !empty($modSettings['approveAccountDeletion']);
    // Setup the admin tabs.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['admin_members'], 'help' => 'view_members', 'description' => $txt['admin_members_list'], 'tabs' => array());
    $context['tabs'] = array('viewmembers' => array('label' => $txt['view_all_members'], 'description' => $txt['admin_members_list'], 'url' => $scripturl . '?action=admin;area=viewmembers;sa=all', 'is_selected' => $_REQUEST['sa'] == 'all'), 'search' => array('label' => $txt['mlist_search'], 'description' => $txt['admin_members_list'], 'url' => $scripturl . '?action=admin;area=viewmembers;sa=search', 'is_selected' => $_REQUEST['sa'] == 'search' || $_REQUEST['sa'] == 'query'), 'approve' => array('label' => sprintf($txt['admin_browse_awaiting_approval'], $context['awaiting_approval']), 'description' => $txt['admin_browse_approve_desc'], 'url' => $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve', 'is_selected' => false), 'activate' => array('label' => sprintf($txt['admin_browse_awaiting_activate'], $context['awaiting_activation']), 'description' => $txt['admin_browse_activate_desc'], 'url' => $scripturl . '?action=admin;area=viewmembers;sa=browse;type=activate', 'is_selected' => false, 'is_last' => true));
    // Sort out the tabs for the ones which may not exist!
    if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) {
        $context['tabs']['approve']['is_last'] = true;
        unset($context['tabs']['activate']);
    }
    if (!$context['show_approve'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'approve')) {
        if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) {
            $context['tabs']['search']['is_last'] = true;
        }
        unset($context['tabs']['approve']);
    }
    $subActions[$_REQUEST['sa']][0]();
}
Пример #6
0
function ManageSearch()
{
    global $context, $txt;
    isAllowedTo('admin_forum');
    loadLanguage('Search');
    loadAdminTemplate('ManageSearch');
    db_extend('search');
    $subActions = array('settings' => 'EditSearchSettings', 'weights' => 'EditWeights', 'method' => 'EditSearchMethod', 'createfulltext' => 'EditSearchMethod', 'removecustom' => 'EditSearchMethod', 'removefulltext' => 'EditSearchMethod', 'createmsgindex' => 'CreateMessageIndex', 'managesphinx' => 'ManageSphinx', 'sphinxconfig' => 'CreateSphinxConfig');
    // Default the sub-action to 'edit search settings'.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'weights';
    $context['sub_action'] = $_REQUEST['sa'];
    // Create the tabs for the template.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['manage_search'], 'help' => 'search', 'description' => $txt['search_settings_desc'], 'tabs' => array('weights' => array('description' => $txt['search_weights_desc']), 'method' => array('description' => $txt['search_method_desc']), 'settings' => array('description' => $txt['search_settings_desc']), 'managesphinx' => array('description' => $txt['search_config_sphinx_desc'], 'label' => $txt['search_managesphinx'])));
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']]();
}
Пример #7
0
/**
 * Ban center. The main entrance point for all ban center functions.
 * It is accesssed by ?action=admin;area=ban.
 * It choses a function based on the 'sa' parameter, like many others.
 * The default sub-action is BanList().
 * It requires the ban_members permission.
 * It initializes the admin tabs.
 *
 * @uses ManageBans template.
 */
function Ban()
{
    global $context, $txt, $scripturl;
    isAllowedTo('manage_bans');
    loadAdminTemplate('ManageBans');
    $subActions = array('add' => 'BanEdit', 'browse' => 'BanBrowseTriggers', 'edittrigger' => 'BanEditTrigger', 'edit' => 'BanEdit', 'list' => 'BanList', 'log' => 'BanLog');
    HookAPI::callHook('manage_bans', array(&$subActions));
    // Default the sub-action to 'view ban list'.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'list';
    $context['page_title'] = $txt['ban_title'];
    $context['sub_action'] = $_REQUEST['sa'];
    // Tabs for browsing the different ban functions.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['ban_title'], 'help' => 'ban_members', 'description' => $txt['ban_description'], 'tabs' => array('list' => array('description' => $txt['ban_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=list', 'is_selected' => $_REQUEST['sa'] == 'list' || $_REQUEST['sa'] == 'edit' || $_REQUEST['sa'] == 'edittrigger'), 'add' => array('description' => $txt['ban_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=add', 'is_selected' => $_REQUEST['sa'] == 'add'), 'browse' => array('description' => $txt['ban_trigger_browse_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=browse', 'is_selected' => $_REQUEST['sa'] == 'browse'), 'log' => array('description' => $txt['ban_log_description'], 'href' => $scripturl . '?action=admin;area=ban;sa=log', 'is_selected' => $_REQUEST['sa'] == 'log', 'is_last' => true)));
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']]();
}
Пример #8
0
function ManagePaidSubscriptions()
{
    global $context, $txt, $scripturl, $sourcedir, $smcFunc, $modSettings;
    // Load the required language and template.
    loadLanguage('ManagePaid');
    loadAdminTemplate('ManagePaid');
    $subActions = array('modify' => array('ModifySubscription', 'admin_forum'), 'modifyuser' => array('ModifyUserSubscription', 'admin_forum'), 'settings' => array('ModifySubscriptionSettings', 'admin_forum'), 'view' => array('ViewSubscriptions', 'admin_forum'), 'viewsub' => array('ViewSubscribedUsers', 'admin_forum'));
    // Default the sub-action to 'view subscriptions', but only if they have already set things up..
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($modSettings['paid_currency_symbol']) ? 'view' : 'settings');
    // Make sure you can do this.
    isAllowedTo($subActions[$_REQUEST['sa']][1]);
    $context['page_title'] = $txt['paid_subscriptions'];
    // Tabs for browsing the different subscription functions.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['paid_subscriptions'], 'help' => '', 'description' => $txt['paid_subscriptions_desc'], 'tabs' => array('view' => array('description' => $txt['paid_subs_view_desc']), 'settings' => array('description' => $txt['paid_subs_settings_desc'])));
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']][0]();
}
Пример #9
0
 /**
  * @static
  * implements main admin UI for plugins
  */
 public static function main()
 {
     global $context, $txt, $modSettings;
     isAllowedTo('admin_forum');
     loadAdminTemplate('Plugins');
     loadLanguage('Plugins');
     /*
     if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
     	$context['sub_action'] = $_REQUEST['sa'];
     else
     	$context['sub_action'] = 'browse';
     */
     if (isset($_REQUEST['sa']) && $_REQUEST['sa'] === 'hooks') {
         return self::hooks();
     } elseif (isset($_REQUEST['sa']) && ($_REQUEST['sa'] === 'install' || $_REQUEST['sa'] === 'uninstall')) {
         self::installProducts();
     }
     $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['plugin_manager'], 'description' => $txt['plugin_manager_desc'], 'tabs' => array('browse' => array(), 'hooks' => array('description' => $txt['browse_hooks_desc'])));
     $context['page_title'] = $txt['plugin_manager'];
     $userdata = array('addonsdir' => HookAPI::getAddonsDir(), 'installedPlugins' => @unserialize($modSettings['plugins']));
     if (($_f = scandir($userdata['addonsdir'])) != false) {
         array_walk($_f, function (&$file, $key, &$data) {
             global $context, $txt, $scripturl;
             if ($file === '.' || $file === '..') {
                 return;
             }
             $fullname = $data['addonsdir'] . $file;
             if (file_exists($fullname) && file_exists($fullname . '/main.php')) {
                 $context['plugins'][$file]['found'] = true;
                 @(require_once $fullname . '/main.php');
                 $autoloader = $file . '_autoloader';
                 if (is_callable($autoloader)) {
                     $pluginInstance = $autoloader();
                     $context['plugins'][$file]['name'] = $pluginInstance->Name;
                     $context['plugins'][$file]['version'] = sprintf($txt['plugin_version'], $pluginInstance->Version);
                     $context['plugins'][$file]['desc'] = $pluginInstance->Description;
                     $context['plugins'][$file]['is_installed'] = isset($data['installedPlugins'][$file]) ? true : false;
                     $context['plugins'][$file]['install_link'] = isset($data['installedPlugins'][$file]) ? '<a href="' . $scripturl . '?action=admin;area=plugins;sa=uninstall;p=' . $file . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['uninstall_plugin'] . '</a>' : '<a href="' . $scripturl . '?action=admin;area=plugins;sa=install;p=' . $file . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['install_plugin'] . '</a>';
                     $context['plugins'][$file]['can_install'] = isset($data['installedPlugins'][$file]) ? true : $pluginInstance->canInstall();
                     $context['plugins'][$file]['install_error'] = $pluginInstance->getInstallErrorReason();
                 }
             }
         }, $userdata);
     }
 }
Пример #10
0
function ManageScheduledTasks()
{
    global $context, $txt, $modSettings;
    isAllowedTo('admin_forum');
    loadLanguage('ManageScheduledTasks');
    loadAdminTemplate('ManageScheduledTasks');
    $subActions = array('taskedit' => 'EditTask', 'tasklog' => 'TaskLog', 'tasks' => 'ScheduledTasks');
    // We need to find what's the action.
    if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
        $context['sub_action'] = $_REQUEST['sa'];
    } else {
        $context['sub_action'] = 'tasks';
    }
    // Now for the lovely tabs. That we all love.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['scheduled_tasks_title'], 'help' => '', 'description' => $txt['maintain_info'], 'tabs' => array('tasks' => array('description' => $txt['maintain_tasks_desc']), 'tasklog' => array('description' => $txt['scheduled_log_desc'])));
    // Call it.
    $subActions[$context['sub_action']]();
}
Пример #11
0
function ManageNews()
{
    global $context, $txt, $scripturl;
    // First, let's do a quick permissions check for the best error message possible.
    isAllowedTo(array('edit_news', 'send_mail', 'admin_forum'));
    loadAdminTemplate('ManageNews');
    // Format: 'sub-action' => array('function', 'permission')
    $subActions = array('editnews' => array('EditNews', 'edit_news'), 'editnewsitem' => array('EditNewsItem', 'edit_news'), 'mailingmembers' => array('SelectMailingMembers', 'send_mail'), 'mailingcompose' => array('ComposeMailing', 'send_mail'), 'mailingsend' => array('SendMailing', 'send_mail'), 'settings' => array('ModifyNewsSettings', 'admin_forum'));
    // Default to sub action 'main' or 'settings' depending on permissions.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('edit_news') ? 'editnews' : (allowedTo('send_mail') ? 'mailingmembers' : 'settings'));
    // Have you got the proper permissions?
    isAllowedTo($subActions[$_REQUEST['sa']][1]);
    // Create the tabs for the template.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['news_title'], 'help' => 'edit_news', 'description' => $txt['admin_news_desc'], 'tabs' => array('editnews' => array(), 'mailingmembers' => array('description' => $txt['news_mailing_desc']), 'settings' => array('description' => $txt['news_settings_desc'])));
    // Force the right area...
    if (substr($_REQUEST['sa'], 0, 7) == 'mailing') {
        $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
    }
    $subActions[$_REQUEST['sa']][0]();
}
Пример #12
0
function ModifyMembergroups()
{
    global $context, $txt, $scripturl, $sourcedir;
    $subActions = array('add' => array('AddMembergroup', 'manage_membergroups'), 'delete' => array('DeleteMembergroup', 'manage_membergroups'), 'edit' => array('EditMembergroup', 'manage_membergroups'), 'index' => array('MembergroupIndex', 'manage_membergroups'), 'members' => array('MembergroupMembers', 'manage_membergroups', 'Groups.php'), 'settings' => array('ModifyMembergroupsettings', 'admin_forum'));
    // Default to sub action 'index' or 'settings' depending on permissions.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings');
    // Is it elsewhere?
    if (isset($subActions[$_REQUEST['sa']][2])) {
        require_once $sourcedir . '/' . $subActions[$_REQUEST['sa']][2];
    }
    // Do the permission check, you might not be allowed her.
    isAllowedTo($subActions[$_REQUEST['sa']][1]);
    // Language and template stuff, the usual.
    loadLanguage('ManageMembers');
    loadAdminTemplate('ManageMembergroups');
    // Setup the admin tabs.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['membergroups_title'], 'help' => 'membergroups', 'description' => $txt['membergroups_description']);
    // Call the right function.
    $subActions[$_REQUEST['sa']][0]();
}
Пример #13
0
function RegCenter()
{
    global $modSettings, $context, $txt, $scripturl;
    // Old templates might still request this.
    if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') {
        redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : ''));
    }
    $subActions = array('register' => array('AdminRegister', 'moderate_forum'), 'agreement' => array('EditAgreement', 'admin_forum'), 'reservednames' => array('SetReserve', 'admin_forum'), 'settings' => array('ModifyRegistrationSettings', 'admin_forum'));
    // Work out which to call...
    $context['sub_action'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('moderate_forum') ? 'register' : 'settings');
    // Must have sufficient permissions.
    isAllowedTo($subActions[$context['sub_action']][1]);
    // Loading, always loading.
    loadLanguage('Login');
    loadAdminTemplate('Register');
    // Next create the tabs for the template.
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['registration_center'], 'help' => 'registrations', 'description' => $txt['admin_settings_desc'], 'tabs' => array('register' => array('description' => $txt['admin_register_desc']), 'agreement' => array('description' => $txt['registration_agreement_desc']), 'reservednames' => array('description' => $txt['admin_reserved_desc']), 'settings' => array('description' => $txt['admin_settings_desc'])));
    // Finally, get around to calling the function...
    $subActions[$context['sub_action']][0]();
}
Пример #14
0
function Groups()
{
    global $context, $txt, $scripturl, $sourcedir, $user_info, $modSettings;
    // The sub-actions that we can do. Format "Function Name, Mod Bar Index if appropriate".
    $subActions = array('index' => array('GroupList', 'view_groups'), 'members' => array('MembergroupMembers', 'view_groups'), 'requests' => array('GroupRequests', 'group_requests'));
    if (!isset($modSettings['groupColorsInline'])) {
        require_once $sourcedir . '/lib/Subs-Membergroups.php';
        regenerateColorStyle();
    }
    // Default to sub action 'index' or 'settings' depending on permissions.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'index';
    // Get the template stuff up and running.
    loadLanguage('ManageMembers');
    loadLanguage('ModerationCenter');
    if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'admin' || $_REQUEST['action'] === 'groups') {
        loadAdminTemplate('ManageMembergroups');
    }
    // If we can see the moderation center, and this has a mod bar entry, add the mod center bar.
    if ($_REQUEST['action'] != 'moderate' && (allowedTo('access_mod_center') || $user_info['mod_cache']['bq'] != '0=1' || $user_info['mod_cache']['gq'] != '0=1' || allowedTo('manage_membergroups'))) {
        if (isset($_REQUEST['group'])) {
            redirectexit(URL::parse('?action=moderate;area=viewgroups;sa=members;group=' . $_REQUEST['group']));
        } else {
            if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'requests' && isset($_POST[$context['session_var']])) {
                require_once $sourcedir . '/ModerationCenter.php';
                $_GET['area'] = $_REQUEST['sa'] == 'requests' ? 'groups' : 'viewgroups';
                ModerationMain(true);
            } else {
                redirectexit(URL::parse('?action=moderate;area=viewgroups'));
            }
        }
        //require_once($sourcedir . '/ModerationCenter.php');
        //$_GET['area'] = $_REQUEST['sa'] == 'requests' ? 'groups' : 'viewgroups';
        //ModerationMain(true);
    } else {
        isAllowedTo('view_mlist');
        $context['linktree'][] = array('url' => $scripturl . '?action=groups', 'name' => $txt['groups']);
    }
    // Call the actual function.
    $subActions[$_REQUEST['sa']][0]();
}
Пример #15
0
/**
 * implements features and options -> Post ratings settings page
 */
function ModifyRatingSettings()
{
    global $txt, $scripturl, $context, $settings, $sc, $modSettings, $sourcedir;
    @(require_once $sourcedir . '/lib/Subs-Ratings.php');
    loadAdminTemplate('ManageRatings');
    $context['sub_template'] = 'manage_ratings';
    $context['rating_show_repair'] = empty($modSettings['rating_show_repair']) ? false : true;
    $context['rating_allow_comments'] = empty($modSettings['rating_allow_comments']) ? false : true;
    for ($i = 1; $i <= 10; $i++) {
        if (isset($modSettings['ratings'][$i])) {
            $rating =& $modSettings['ratings'][$i];
            $context['rating_classes'][$i] = array('id' => $i, 'desc' => isset($rating['desc']) ? $rating['desc'] : '', 'format' => isset($rating['format']) ? $rating['format'] : '<span>%s</span>', 'label' => $rating['label'], 'localized' => isset($rating['localized']) ? $rating['localized'] : '', 'points' => isset($rating['points']) ? $rating['points'] : 0, 'groups' => isset($rating['groups']) && !empty($rating['groups']) ? implode(',', $rating['groups']) : '', 'boards' => isset($rating['boards']) && !empty($rating['boards']) ? implode(',', $rating['boards']) : '', 'boards_denied' => isset($rating['boards_denied']) && !empty($rating['boards_denied']) ? implode(',', $rating['boards_denied']) : '', 'groups_denied' => isset($rating['groups_denied']) && !empty($rating['groups_denied']) ? implode(',', $rating['groups_denied']) : '', 'unique' => isset($rating['unique']) && !empty($rating['unique']) ? true : false);
        } else {
            $context['rating_classes'][$i] = array('id' => $i, 'desc' => '', 'format' => '', 'label' => '', 'points' => '', 'groups' => '', 'boards' => '', 'boards_denied' => '', 'groups_denied' => '', 'localized' => '', 'unique' => true);
        }
    }
    // Saving?
    if (isset($_GET['save'])) {
        checkSession();
        $new_ratings = array();
        for ($i = 1; $i <= 10; $i++) {
            if (isset($_REQUEST['rating_id_' . $i]) && (int) $_REQUEST['rating_id_' . $i] >= 1 && (int) $_REQUEST['rating_id_' . $i] <= 10 && isset($_REQUEST['rating_label_' . $i]) && !empty($_REQUEST['rating_label_' . $i])) {
                $new_ratings[$i] = array('desc' => isset($_REQUEST['rating_desc_' . $i]) ? strip_tags($_REQUEST['rating_desc_' . $i]) : '', 'format' => htmlentities(isset($_REQUEST['rating_format_' . $i]) ? $_REQUEST['rating_format_' . $i] : '<span>%s</span>'), 'label' => htmlspecialchars(isset($_REQUEST['rating_label_' . $i]) ? $_REQUEST['rating_label_' . $i] : 'No label'), 'localized' => htmlentities(isset($_REQUEST['rating_localized_' . $i]) ? $_REQUEST['rating_localized_' . $i] : ''), 'groups' => isset($_REQUEST['rating_groups_' . $i]) && !empty($_REQUEST['rating_groups_' . $i]) ? explode(',', normalizeCommaDelimitedList($_REQUEST['rating_groups_' . $i])) : array(), 'groups_denied' => isset($_REQUEST['rating_groups_denied_' . $i]) && !empty($_REQUEST['rating_groups_denied_' . $i]) ? explode(',', normalizeCommaDelimitedList($_REQUEST['rating_groups_denied_' . $i])) : array(), 'boards' => isset($_REQUEST['rating_boards_' . $i]) && !empty($_REQUEST['rating_boards_' . $i]) ? explode(',', normalizeCommaDelimitedList($_REQUEST['rating_boards_' . $i])) : array(), 'boards_denied' => isset($_REQUEST['rating_boards_denied_' . $i]) && !empty($_REQUEST['rating_boards_denied_' . $i]) ? explode(',', normalizeCommaDelimitedList($_REQUEST['rating_boards_denied_' . $i])) : array(), 'points' => isset($_REQUEST['rating_points_' . $i]) && !empty($_REQUEST['rating_points_' . $i]) ? $_REQUEST['rating_points_' . $i] : 0, 'unique' => isset($_REQUEST['rating_unique_' . $i]) && $_REQUEST['rating_unique_' . $i] ? true : false);
            }
        }
        $settings_to_update = array('rating_show_repair' => isset($_REQUEST['rating_show_repair']) ? $_REQUEST['rating_show_repair'] : 0, 'rating_allow_comments' => isset($_REQUEST['rating_allow_comments']) ? $_REQUEST['rating_allow_comments'] : 0);
        if (!empty($new_ratings)) {
            $settings_to_update['raw_ratings'] = @serialize($new_ratings);
        }
        updateSettings($settings_to_update);
        redirectexit('action=admin;area=postsettings;sa=ratings');
    }
    $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=ratings';
}
Пример #16
0
function ManageMaintenance()
{
    global $txt, $modSettings, $scripturl, $context, $options;
    // You absolutely must be an admin by here!
    isAllowedTo('admin_forum');
    // Need something to talk about?
    loadLanguage('ManageMaintenance');
    loadAdminTemplate('ManageMaintenance');
    // This uses admin tabs - as it should!
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['maintain_title'], 'description' => $txt['maintain_info'], 'tabs' => array('routine' => array(), 'database' => array(), 'members' => array(), 'topics' => array()));
    // So many things you can do - but frankly I won't let you - just these!
    $subActions = array('routine' => array('function' => 'MaintainRoutine', 'template' => 'maintain_routine', 'activities' => array('version' => 'VersionDetail', 'repair' => 'MaintainFindFixErrors', 'recount' => 'AdminBoardRecount', 'logs' => 'MaintainEmptyUnimportantLogs', 'cleancache' => 'MaintainCleanCache')), 'database' => array('function' => 'MaintainDatabase', 'template' => 'maintain_database', 'activities' => array('optimize' => 'OptimizeTables', 'convertentities' => 'ConvertEntities', 'convertutf8' => 'ConvertUtf8')), 'members' => array('function' => 'MaintainMembers', 'template' => 'maintain_members', 'activities' => array('reattribute' => 'MaintainReattributePosts', 'purgeinactive' => 'MaintainPurgeInactiveMembers')), 'topics' => array('function' => 'MaintainTopics', 'template' => 'maintain_topics', 'activities' => array('massmove' => 'MaintainMassMoveTopics', 'pruneold' => 'MaintainRemoveOldPosts')), 'destroy' => array('function' => 'Destroy', 'activities' => array()));
    // Yep, sub-action time!
    if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
        $subAction = $_REQUEST['sa'];
    } else {
        $subAction = 'routine';
    }
    // Doing something special?
    if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) {
        $activity = $_REQUEST['activity'];
    }
    // Set a few things.
    $context['page_title'] = $txt['maintain_title'];
    $context['sub_action'] = $subAction;
    $context['sub_template'] = !empty($subActions[$subAction]['template']) ? $subActions[$subAction]['template'] : '';
    // Finally fall through to what we are doing.
    $subActions[$subAction]['function']();
    // Any special activity?
    if (isset($activity)) {
        $subActions[$subAction]['activities'][$activity]();
    }
    //converted to UTF-8? show a small maintenance info
    if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') {
        $context['maintenance_finished'] = $txt['utf8_title'];
    }
}
Пример #17
0
function ViewErrorLog()
{
    global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $boarddir, $sourcedir, $themedir, $smcFunc;
    // Viewing contents of a file?
    if (isset($_GET['file'])) {
        return ViewFile();
    }
    // Check for the administrative permission to do this.
    isAllowedTo('admin_forum');
    // Templates, etc...
    loadLanguage('ManageMaintenance');
    loadAdminTemplate('Errors');
    // You can filter by any of the following columns:
    $filters = array('id_member' => $txt['username'], 'ip' => $txt['ip_address'], 'session' => $txt['session'], 'url' => $txt['error_url'], 'message' => $txt['error_message'], 'error_type' => $txt['error_type'], 'file' => $txt['file'], 'line' => $txt['line']);
    // Set up the filtering...
    if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) {
        $filter = array('variable' => $_GET['filter'], 'value' => array('sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : smf_db_escape_wildcard_string($_GET['value'])), 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], 'entity' => $filters[$_GET['filter']]);
    }
    // Deleting, are we?
    if (isset($_POST['delall']) || isset($_POST['delete'])) {
        deleteErrors();
    }
    // Just how many errors are there?
    $result = smf_db_query('
		SELECT COUNT(*)
		FROM {db_prefix}log_errors' . (isset($filter) ? '
		WHERE ' . $filter['variable'] . ' LIKE {string:filter}' : ''), array('filter' => isset($filter) ? $filter['value']['sql'] : ''));
    list($num_errors) = mysql_fetch_row($result);
    mysql_free_result($result);
    // If this filter is empty...
    if ($num_errors == 0 && isset($filter)) {
        redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
    }
    // Clean up start.
    if (!isset($_GET['start']) || $_GET['start'] < 0) {
        $_GET['start'] = 0;
    }
    // Do we want to reverse error listing?
    $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
    // Set the page listing up.
    $context['page_index'] = constructPageIndex($scripturl . '?action=admin;area=logs;sa=errorlog' . ($context['sort_direction'] == 'down' ? ';desc' : '') . (isset($filter) ? $filter['href'] : ''), $_GET['start'], $num_errors, $modSettings['defaultMaxMessages']);
    $context['start'] = $_GET['start'];
    // Find and sort out the errors.
    $request = smf_db_query('
		SELECT id_error, id_member, ip, url, log_time, message, session, error_type, file, line
		FROM {db_prefix}log_errors' . (isset($filter) ? '
		WHERE ' . $filter['variable'] . ' LIKE {string:filter}' : '') . '
		ORDER BY id_error ' . ($context['sort_direction'] == 'down' ? 'DESC' : '') . '
		LIMIT ' . $_GET['start'] . ', ' . $modSettings['defaultMaxMessages'], array('filter' => isset($filter) ? $filter['value']['sql'] : ''));
    $context['errors'] = array();
    $members = array();
    for ($i = 0; $row = mysql_fetch_assoc($request); $i++) {
        $search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', smf_db_escape_wildcard_string($row['message']));
        if ($search_message == $filter['value']['sql']) {
            $search_message = smf_db_escape_wildcard_string($row['message']);
        }
        $show_message = strtr(strtr(preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $row['message']), array("\r" => '', '<br />' => "\n", '<' => '&lt;', '>' => '&gt;', '"' => '&quot;')), array("\n" => '<br />'));
        $context['errors'][$row['id_error']] = array('alternate' => $i % 2 == 0, 'member' => array('id' => $row['id_member'], 'ip' => $row['ip'], 'session' => $row['session']), 'time' => timeformat($row['log_time']), 'timestamp' => $row['log_time'], 'url' => array('html' => htmlspecialchars((substr($row['url'], 0, 1) == '?' ? $scripturl : '') . $row['url']), 'href' => base64_encode(smf_db_escape_wildcard_string($row['url']))), 'message' => array('html' => $show_message, 'href' => base64_encode($search_message)), 'id' => $row['id_error'], 'error_type' => array('type' => $row['error_type'], 'name' => isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type']), 'file' => array());
        if (!empty($row['file']) && !empty($row['line'])) {
            // Eval'd files rarely point to the right location and cause havoc for linking, so don't link them.
            $linkfile = strpos($row['file'], 'eval') === false || strpos($row['file'], '?') === false;
            // De Morgan's Law.  Want this true unless both are present.
            $matches = array();
            preg_match('~(.*\\.php).*~', $row['file'], $matches);
            $context['errors'][$row['id_error']]['file'] = array('file' => $row['file'], 'line' => $row['line'], 'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;file=' . base64_encode($matches[1]) . ';line=' . $row['line'], 'link' => $linkfile ? '<a href="' . $scripturl . '?action=admin;area=logs;sa=errorlog;file=' . base64_encode($matches[1]) . ';line=' . $row['line'] . '" onclick="return showFile(\'' . base64_encode($matches[1]) . '\', ' . $row['line'] . ');return(false);">' . $row['file'] . '</a>' : $row['file'], 'search' => base64_encode($row['file']));
        }
        // Make a list of members to load later.
        $members[$row['id_member']] = $row['id_member'];
    }
    mysql_free_result($request);
    // Load the member data.
    if (!empty($members)) {
        // Get some additional member info...
        $request = smf_db_query('
			SELECT id_member, member_name, real_name
			FROM {db_prefix}members
			WHERE id_member IN ({array_int:member_list})
			LIMIT ' . count($members), array('member_list' => $members));
        while ($row = mysql_fetch_assoc($request)) {
            $members[$row['id_member']] = $row;
        }
        mysql_free_result($request);
        // This is a guest...
        $members[0] = array('id_member' => 0, 'member_name' => '', 'real_name' => $txt['guest_title']);
        // Go through each error and tack the data on.
        foreach ($context['errors'] as $id => $dummy) {
            $memID = $context['errors'][$id]['member']['id'];
            $context['errors'][$id]['member']['username'] = $members[$memID]['member_name'];
            $context['errors'][$id]['member']['name'] = $members[$memID]['real_name'];
            $context['errors'][$id]['member']['href'] = empty($memID) ? '' : $scripturl . '?action=profile;u=' . $memID;
            $context['errors'][$id]['member']['link'] = empty($memID) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $memID . '">' . $context['errors'][$id]['member']['name'] . '</a>';
        }
    }
    // Filtering anything?
    if (isset($filter)) {
        $context['filter'] =& $filter;
        // Set the filtering context.
        if ($filter['variable'] == 'id_member') {
            $id = $filter['value']['sql'];
            loadMemberData($id, false, 'minimal');
            $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>';
        } elseif ($filter['variable'] == 'url') {
            $context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\\_' => '_')) . '\'';
        } elseif ($filter['variable'] == 'message') {
            $context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars($filter['value']['sql']), array("\n" => '<br />', '&lt;br /&gt;' => '<br />', "\t" => '&nbsp;&nbsp;&nbsp;', '\\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
            $context['filter']['value']['html'] = preg_replace('~&amp;lt;span class=&amp;quot;remove&amp;quot;&amp;gt;(.+?)&amp;lt;/span&amp;gt;~', '$1', $context['filter']['value']['html']);
        } elseif ($filter['variable'] == 'error_type') {
            $context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars($filter['value']['sql']), array("\n" => '<br />', '&lt;br /&gt;' => '<br />', "\t" => '&nbsp;&nbsp;&nbsp;', '\\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
        } else {
            $context['filter']['value']['html'] =& $filter['value']['sql'];
        }
    }
    $context['error_types'] = array();
    $context['error_types']['all'] = array('label' => $txt['errortype_all'], 'description' => isset($txt['errortype_all_desc']) ? $txt['errortype_all_desc'] : '', 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog' . ($context['sort_direction'] == 'down' ? ';desc' : ''), 'is_selected' => empty($filter));
    $sum = 0;
    // What type of errors do we have and how many do we have?
    $request = smf_db_query('
		SELECT error_type, COUNT(*) AS num_errors
		FROM {db_prefix}log_errors
		GROUP BY error_type
		ORDER BY error_type = {string:critical_type} DESC, error_type ASC', array('critical_type' => 'critical'));
    while ($row = mysql_fetch_assoc($request)) {
        // Total errors so far?
        $sum += $row['num_errors'];
        $context['error_types'][$sum] = array('label' => (isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type']) . ' (' . $row['num_errors'] . ')', 'description' => isset($txt['errortype_' . $row['error_type'] . '_desc']) ? $txt['errortype_' . $row['error_type'] . '_desc'] : '', 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog' . ($context['sort_direction'] == 'down' ? ';desc' : '') . ';filter=error_type;value=' . $row['error_type'], 'is_selected' => isset($filter) && $filter['value']['sql'] == smf_db_escape_wildcard_string($row['error_type']));
    }
    mysql_free_result($request);
    // Update the all errors tab with the total number of errors
    $context['error_types']['all']['label'] .= ' (' . $sum . ')';
    // Finally, work out what is the last tab!
    if (isset($context['error_types'][$sum])) {
        $context['error_types'][$sum]['is_last'] = true;
    } else {
        $context['error_types']['all']['is_last'] = true;
    }
    // And this is pretty basic ;).
    $context['page_title'] = $txt['errlog'];
    $context['has_filter'] = isset($filter);
    $context['sub_template'] = 'error_log';
}
Пример #18
0
function ManageAttachments()
{
    global $txt, $modSettings, $scripturl, $context, $options;
    // You have to be able to moderate the forum to do this.
    isAllowedTo('manage_attachments');
    // Setup the template stuff we'll probably need.
    loadAdminTemplate('ManageAttachments');
    // If they want to delete attachment(s), delete them. (otherwise fall through..)
    $subActions = array('attachments' => 'ManageAttachmentSettings', 'attachpaths' => 'ManageAttachmentPaths', 'avatars' => 'ManageAvatarSettings', 'browse' => 'BrowseFiles', 'byAge' => 'RemoveAttachmentByAge', 'bySize' => 'RemoveAttachmentBySize', 'maintenance' => 'MaintainFiles', 'moveAvatars' => 'MoveAvatars', 'repair' => 'RepairAttachments', 'remove' => 'RemoveAttachment', 'removeall' => 'RemoveAllAttachments');
    // Pick the correct sub-action.
    if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
        $context['sub_action'] = $_REQUEST['sa'];
    } else {
        $context['sub_action'] = 'browse';
    }
    // Default page title is good.
    $context['page_title'] = $txt['attachments_avatars'];
    // This uses admin tabs - as it should!
    $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['attachments_avatars'], 'help' => 'manage_files', 'description' => $txt['attachments_desc']);
    // Finally fall through to what we are doing.
    $subActions[$context['sub_action']]();
}
Пример #19
0
function SpiderLogs()
{
    global $context, $txt, $sourcedir, $scripturl, $modSettings;
    // Load the template and language just incase.
    loadLanguage('Search');
    loadAdminTemplate('ManageSearch');
    // Did they want to delete some entries?
    if (!empty($_POST['delete_entries']) && isset($_POST['older'])) {
        checkSession();
        $deleteTime = time() - (int) $_POST['older'] * 24 * 60 * 60;
        // Delete the entires.
        smf_db_query('
			DELETE FROM {db_prefix}log_spider_hits
			WHERE log_time < {int:delete_period}', array('delete_period' => $deleteTime));
    }
    $listOptions = array('id' => 'spider_logs', 'items_per_page' => 20, 'title' => $txt['spider_logs'], 'no_items_label' => $txt['spider_logs_empty'], 'base_href' => $context['admin_area'] == 'sengines' ? $scripturl . '?action=admin;area=sengines;sa=logs' : $scripturl . '?action=admin;area=logs;sa=spiderlog', 'default_sort_col' => 'log_time', 'get_items' => array('function' => 'list_getSpiderLogs'), 'get_count' => array('function' => 'list_getNumSpiderLogs'), 'columns' => array('name' => array('header' => array('value' => $txt['spider']), 'data' => array('db' => 'spider_name'), 'sort' => array('default' => 's.spider_name', 'reverse' => 's.spider_name DESC')), 'log_time' => array('header' => array('value' => $txt['spider_time']), 'data' => array('function' => create_function('$rowData', '
						return timeformat($rowData[\'log_time\']);
					')), 'sort' => array('default' => 'sl.id_hit DESC', 'reverse' => 'sl.id_hit')), 'viewing' => array('header' => array('value' => $txt['spider_viewing']), 'data' => array('db' => 'url'))), 'additional_rows' => array(array('position' => 'after_title', 'value' => $txt['spider_logs_info'], 'class' => 'smalltext')));
    require_once $sourcedir . '/lib/Subs-List.php';
    createList($listOptions);
    // Now determine the actions of the URLs.
    if (!empty($context['spider_logs']['rows'])) {
        $urls = array();
        // Grab the current /url.
        foreach ($context['spider_logs']['rows'] as $k => $row) {
            // Feature disabled?
            if (empty($row['viewing']['value']) && isset($modSettings['spider_mode']) && $modSettings['spider_mode'] < 3) {
                $context['spider_logs']['rows'][$k]['viewing']['value'] = '<em>' . $txt['spider_disabled'] . '</em>';
            } else {
                $urls[$k] = array($row['viewing']['value'], -1);
            }
        }
        // Now stick in the new URLs.
        require_once $sourcedir . '/Who.php';
        $urls = determineActions($urls, 'whospider_');
        foreach ($urls as $k => $new_url) {
            $context['spider_logs']['rows'][$k]['viewing']['value'] = $new_url;
        }
    }
    $context['page_title'] = $txt['spider_logs'];
    $context['sub_template'] = 'show_spider_logs';
    $context['default_list'] = 'spider_logs';
}
Пример #20
0
function BrowseMailQueue()
{
    global $scripturl, $context, $modSettings, $txt, $smcFunc;
    global $sourcedir;
    // First, are we deleting something from the queue?
    if (isset($_REQUEST['delete'])) {
        checkSession('post');
        smf_db_query('
			DELETE FROM {db_prefix}mail_queue
			WHERE id_mail IN ({array_int:mail_ids})', array('mail_ids' => $_REQUEST['delete']));
    }
    // How many items do we have?
    $request = smf_db_query('
		SELECT COUNT(*) AS queue_size, MIN(time_sent) AS oldest
		FROM {db_prefix}mail_queue', array());
    list($mailQueueSize, $mailOldest) = mysql_fetch_row($request);
    mysql_free_result($request);
    $context['oldest_mail'] = empty($mailOldest) ? $txt['mailqueue_oldest_not_available'] : time_since(time() - $mailOldest);
    $context['mail_queue_size'] = comma_format($mailQueueSize);
    $listOptions = array('id' => 'mail_queue', 'title' => $txt['mailqueue_browse'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=mailqueue', 'default_sort_col' => 'age', 'no_items_label' => $txt['mailqueue_no_items'], 'get_items' => array('function' => 'list_getMailQueue'), 'get_count' => array('function' => 'list_getMailQueueSize'), 'columns' => array('subject' => array('header' => array('value' => $txt['mailqueue_subject']), 'data' => array('function' => create_function('$rowData', '
						global $smcFunc;
						return $smcFunc[\'strlen\']($rowData[\'subject\']) > 50 ? sprintf(\'%1$s...\', htmlspecialchars($smcFunc[\'substr\']($rowData[\'subject\'], 0, 47))) : htmlspecialchars($rowData[\'subject\']);
					'), 'class' => 'smalltext'), 'sort' => array('default' => 'subject', 'reverse' => 'subject DESC')), 'recipient' => array('header' => array('value' => $txt['mailqueue_recipient']), 'data' => array('sprintf' => array('format' => '<a href="mailto:%1$s">%1$s</a>', 'params' => array('recipient' => true)), 'class' => 'smalltext'), 'sort' => array('default' => 'recipient', 'reverse' => 'recipient DESC')), 'priority' => array('header' => array('value' => $txt['mailqueue_priority']), 'data' => array('function' => create_function('$rowData', '
						global $txt;

						// We probably have a text label with your priority.
						$txtKey = sprintf(\'mq_mpriority_%1$s\', $rowData[\'priority\']);

						// But if not, revert to priority 0.
						return isset($txt[$txtKey]) ? $txt[$txtKey] : $txt[\'mq_mpriority_1\'];
					'), 'class' => 'smalltext'), 'sort' => array('default' => 'priority', 'reverse' => 'priority DESC')), 'age' => array('header' => array('value' => $txt['mailqueue_age']), 'data' => array('function' => create_function('$rowData', '
						return time_since(time() - $rowData[\'time_sent\']);
					'), 'class' => 'smalltext'), 'sort' => array('default' => 'time_sent', 'reverse' => 'time_sent DESC')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />'), 'data' => array('function' => create_function('$rowData', '
						return \'<input type="checkbox" name="delete[]" value="\' . $rowData[\'id_mail\'] . \'" class="input_check" />\';
					'), 'class' => 'smalltext'))), 'form' => array('href' => $scripturl . '?action=admin;area=mailqueue', 'include_start' => true, 'include_sort' => true), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '[<a href="' . $scripturl . '?action=admin;area=mailqueue;sa=clear;' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'' . $txt['mailqueue_clear_list_warning'] . '\');">' . $txt['mailqueue_clear_list'] . '</a>] <input type="submit" name="delete_redirects" value="' . $txt['delete'] . '" onclick="return confirm(\'' . $txt['quickmod_confirm'] . '\');" class="button_submit" />')));
    require_once $sourcedir . '/lib/Subs-List.php';
    createList($listOptions);
    loadAdminTemplate('ManageMail');
    $context['sub_template'] = 'browse';
}
Пример #21
0
function init_inline_permissions($permissions, $excluded_groups = array())
{
    global $context, $txt, $modSettings, $smcFunc;
    loadLanguage('ManagePermissions');
    loadAdminTemplate('ManagePermissions');
    $context['can_change_permissions'] = allowedTo('manage_permissions');
    // Nothing to initialize here.
    if (!$context['can_change_permissions']) {
        return;
    }
    // Load the permission settings for guests
    foreach ($permissions as $permission) {
        $context[$permission] = array(-1 => array('id' => -1, 'name' => $txt['membergroups_guests'], 'is_postgroup' => false, 'status' => 'off'), 0 => array('id' => 0, 'name' => $txt['membergroups_members'], 'is_postgroup' => false, 'status' => 'off'));
    }
    $request = smf_db_query('
		SELECT id_group, CASE WHEN add_deny = {int:denied} THEN {string:deny} ELSE {string:on} END AS status, permission
		FROM {db_prefix}permissions
		WHERE id_group IN (-1, 0)
			AND permission IN ({array_string:permissions})', array('denied' => 0, 'permissions' => $permissions, 'deny' => 'deny', 'on' => 'on'));
    while ($row = mysql_fetch_assoc($request)) {
        $context[$row['permission']][$row['id_group']]['status'] = $row['status'];
    }
    mysql_free_result($request);
    $request = smf_db_query('
		SELECT mg.id_group, mg.group_name, mg.min_posts, IFNULL(p.add_deny, -1) AS status, p.permission
		FROM {db_prefix}membergroups AS mg
			LEFT JOIN {db_prefix}permissions AS p ON (p.id_group = mg.id_group AND p.permission IN ({array_string:permissions}))
		WHERE mg.id_group NOT IN (1, 3)
			AND mg.id_parent = {int:not_inherited}' . (empty($modSettings['permission_enable_postgroups']) ? '
			AND mg.min_posts = {int:min_posts}' : '') . '
		ORDER BY mg.min_posts, CASE WHEN mg.id_group < {int:newbie_group} THEN mg.id_group ELSE 4 END, mg.group_name', array('not_inherited' => -2, 'min_posts' => -1, 'newbie_group' => 4, 'permissions' => $permissions));
    while ($row = mysql_fetch_assoc($request)) {
        // Initialize each permission as being 'off' until proven otherwise.
        foreach ($permissions as $permission) {
            if (!isset($context[$permission][$row['id_group']])) {
                $context[$permission][$row['id_group']] = array('id' => $row['id_group'], 'name' => $row['group_name'], 'is_postgroup' => $row['min_posts'] != -1, 'status' => 'off');
            }
        }
        $context[$row['permission']][$row['id_group']]['status'] = empty($row['status']) ? 'deny' : ($row['status'] == 1 ? 'on' : 'off');
    }
    mysql_free_result($request);
    // Some permissions cannot be given to certain groups. Remove the groups.
    foreach ($excluded_groups as $group) {
        foreach ($permissions as $permission) {
            if (isset($context[$permission][$group])) {
                unset($context[$permission][$group]);
            }
        }
    }
}
Пример #22
0
function EditBoardSettings($return_config = false)
{
    global $context, $txt, $sourcedir, $modSettings, $scripturl, $backend_subdir;
    // Load the boards list - for the recycle bin!
    $recycle_boards = array('');
    $request = smf_db_query('
		SELECT b.id_board, b.name AS board_name, c.name AS cat_name
		FROM {db_prefix}boards AS b
			LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
		WHERE redirect = {string:empty_string}', array('empty_string' => ''));
    while ($row = mysql_fetch_assoc($request)) {
        $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
    }
    mysql_free_result($request);
    // Here and the board settings...
    $config_vars = array(array('title', 'settings'), array('permissions', 'manage_boards'), '', array('check', 'countChildPosts'), array('check', 'recycle_enable', 'onclick' => 'document.getElementById(\'recycle_board\').disabled = !this.checked;'), array('select', 'recycle_board', $recycle_boards), array('check', 'allow_ignore_boards'), '', array('int', 'tidy_child_display_columns'), array('int', 'child_board_desc_shortened'));
    if ($return_config) {
        return $config_vars;
    }
    // Needed for the settings template and inline permission functions.
    require_once $sourcedir . '/' . $backend_subdir . '/ManagePermissions.php';
    require_once $sourcedir . '/' . $backend_subdir . '/ManageServer.php';
    // Don't let guests have these permissions.
    $context['post_url'] = $scripturl . '?action=admin;area=manageboards;save;sa=settings';
    $context['permissions_excluded'] = array(-1);
    $context['page_title'] = $txt['boards_and_cats'] . ' - ' . $txt['settings'];
    loadAdminTemplate('ManageBoards');
    $context['sub_template'] = 'show_settings';
    // Add some javascript stuff for the recycle box.
    $context['settings_insert_below'] = '
		<script type="text/javascript"><!-- // --><![CDATA[
			document.getElementById("recycle_board").disabled = !document.getElementById("recycle_enable").checked;
		// ]]></script>';
    // Warn the admin against selecting the recycle topic without selecting a board.
    $context['force_form_onsubmit'] = 'if(document.getElementById(\'recycle_enable\').checked && document.getElementById(\'recycle_board\').value == 0) { return confirm(\'' . $txt['recycle_board_unselected_notice'] . '\');} return true;';
    // Doing a save?
    if (isset($_GET['save'])) {
        checkSession();
        saveDBSettings($config_vars);
        redirectexit('action=admin;area=manageboards;sa=settings');
    }
    // Prepare the settings...
    prepareDBSettingContext($config_vars);
}
Пример #23
0
function loadTheme($id_theme = 0, $initialize = true)
{
    global $user_info, $user_settings, $board_info, $boarddir, $db_show_debug;
    global $txt, $boardurl, $scripturl, $mbname, $modSettings;
    global $context, $settings, $options, $sourcedir, $ssi_theme;
    // The theme was specified by parameter.
    if (!empty($id_theme)) {
        $id_theme = (int) $id_theme;
    } elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
        $id_theme = (int) $_REQUEST['theme'];
        $_SESSION['id_theme'] = $id_theme;
    } elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
        $id_theme = (int) $_SESSION['id_theme'];
    } elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
        $id_theme = $user_info['theme'];
    } elseif (!empty($board_info['theme'])) {
        $id_theme = $board_info['theme'];
    } else {
        $id_theme = $modSettings['theme_guests'];
    }
    // Verify the id_theme... no foul play.
    // Always allow the board specific theme, if they are overriding.
    if (!empty($board_info['theme']) && $board_info['override_theme']) {
        $id_theme = $board_info['theme'];
    } elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) {
        $id_theme = (int) $id_theme;
    } elseif (!empty($modSettings['knownThemes']) && !allowedTo('admin_forum')) {
        $themes = explode(',', $modSettings['knownThemes']);
        if (!in_array($id_theme, $themes)) {
            $id_theme = $modSettings['theme_guests'];
        } else {
            $id_theme = (int) $id_theme;
        }
    } else {
        $id_theme = (int) $id_theme;
    }
    $member = empty($user_info['id']) ? -1 : $user_info['id'];
    if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = CacheAPI::getCache('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) {
        $themeData = $temp;
        $flag = true;
    } elseif (($temp = CacheAPI::getCache('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) {
        $themeData = $temp + array($member => array());
    } else {
        $themeData = array(-1 => array(), 0 => array(), $member => array());
    }
    if (empty($flag)) {
        // Load variables from the current or default theme, global or this user's.
        $result = smf_db_query('
			SELECT variable, value, id_member, id_theme
			FROM {db_prefix}themes
			WHERE id_member' . (empty($themeData[0]) ? ' IN (-1, 0, {int:id_member})' : ' = {int:id_member}') . '
				AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)'), array('id_theme' => $id_theme, 'id_member' => $member));
        // Pick between $settings and $options depending on whose data it is.
        while ($row = mysql_fetch_assoc($result)) {
            // There are just things we shouldn't be able to change as members.
            if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) {
                continue;
            }
            // If this is the theme_dir of the default theme, store it.
            if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) {
                $themeData[0]['default_' . $row['variable']] = $row['value'];
            }
            // If this isn't set yet, is a theme option, or is not the default theme..
            if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') {
                $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
            }
        }
        mysql_free_result($result);
        if (!empty($themeData[-1])) {
            foreach ($themeData[-1] as $k => $v) {
                if (!isset($themeData[$member][$k])) {
                    $themeData[$member][$k] = $v;
                }
            }
        }
        if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
            CacheAPI::putCache('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
        } elseif (!isset($temp)) {
            CacheAPI::putCache('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
        }
    }
    $settings = $themeData[0];
    $options = $themeData[$member];
    $member_tracking_optin = $user_info['is_guest'] || (empty($options['disable_analytics']) ? 1 : !$options['disable_analytics']);
    if (isset($modSettings['embed_GA']) && $modSettings['embed_GA'] && !empty($modSettings['GA_tracker_id']) && !empty($modSettings['GA_domain_name']) && $member_tracking_optin) {
        $context['want_GA_embedded'] = true;
    }
    if (isset($modSettings['embed_piwik']) && $modSettings['embed_piwik'] && !empty($modSettings['piwik_uri']) && !empty($modSettings['piwik_tracker_id']) && $member_tracking_optin) {
        $context['want_piwik_embedded'] = true;
        $modSettings['piwik_uri'] = rtrim($modSettings['piwik_uri'], '/\\ ');
    }
    $settings['theme_id'] = $id_theme;
    $settings['actual_theme_url'] = $settings['theme_url'];
    $settings['actual_images_url'] = $settings['images_url'];
    $settings['actual_theme_dir'] = $settings['theme_dir'];
    $settings['posticons_url'] = $settings['images_url'] . '/post/';
    $settings['template_dirs'] = array();
    // This theme first.
    $settings['template_dirs'][] = $settings['theme_dir'];
    // Based on theme (if there is one).
    if (!empty($settings['base_theme_dir'])) {
        $settings['template_dirs'][] = $settings['base_theme_dir'];
    }
    // Lastly the default theme.
    if ($settings['theme_dir'] != $settings['default_theme_dir']) {
        $settings['template_dirs'][] = $settings['default_theme_dir'];
    }
    if (!$initialize) {
        return;
    }
    // Check to see if they're accessing it from the wrong place.
    if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) {
        $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://';
        $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
        $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
        if ($temp != '/') {
            $detected_url .= $temp;
        }
    }
    if (isset($detected_url) && $detected_url != $boardurl) {
        // Try #1 - check if it's in a list of alias addresses.
        if (!empty($modSettings['forum_alias_urls'])) {
            $aliases = explode(',', $modSettings['forum_alias_urls']);
            foreach ($aliases as $alias) {
                // Rip off all the boring parts, spaces, etc.
                if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) {
                    $do_fix = true;
                }
            }
        }
        // Hmm... check #2 - is it just different by a www?  Send them to the correct place!!
        if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') {
            // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;).
            if (empty($_GET)) {
                redirectexit('wwwRedirect');
            } else {
                list($k, $v) = each($_GET);
                if ($k != 'wwwRedirect') {
                    redirectexit('wwwRedirect;' . $k . '=' . $v);
                }
            }
        }
        // #3 is just a check for SSL...
        if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) {
            $do_fix = true;
        }
        // Okay, #4 - perhaps it's an IP address?  We're gonna want to use that one, then. (assuming it's the IP or something...)
        if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\\d\\.:]+|\\[[\\d:]+\\](?::\\d+)?)(?:$|/)~', $detected_url) == 1) {
            // Caching is good ;).
            $oldurl = $boardurl;
            // Fix $boardurl and $scripturl.
            $boardurl = $detected_url;
            $scripturl = strtr($scripturl, array($oldurl => $boardurl));
            $_SERVER['REQUEST_URL'] = strtr($_SERVER['REQUEST_URL'], array($oldurl => $boardurl));
            // Fix the theme urls...
            $settings['theme_url'] = strtr($settings['theme_url'], array($oldurl => $boardurl));
            $settings['default_theme_url'] = strtr($settings['default_theme_url'], array($oldurl => $boardurl));
            $settings['actual_theme_url'] = strtr($settings['actual_theme_url'], array($oldurl => $boardurl));
            $settings['images_url'] = strtr($settings['images_url'], array($oldurl => $boardurl));
            $settings['default_images_url'] = strtr($settings['default_images_url'], array($oldurl => $boardurl));
            $settings['actual_images_url'] = strtr($settings['actual_images_url'], array($oldurl => $boardurl));
            // And just a few mod settings :).
            $modSettings['smileys_url'] = strtr($modSettings['smileys_url'], array($oldurl => $boardurl));
            $modSettings['avatar_url'] = strtr($modSettings['avatar_url'], array($oldurl => $boardurl));
            // Clean up after loadBoard().
            if (isset($board_info['moderators'])) {
                foreach ($board_info['moderators'] as $k => $dummy) {
                    $board_info['moderators'][$k]['href'] = strtr($dummy['href'], array($oldurl => $boardurl));
                    $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl));
                }
            }
            foreach ($context['linktree'] as $k => $dummy) {
                $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
            }
        }
    }
    // Set up the contextual user array.
    $context['user'] = array('id' => $user_info['id'], 'is_logged' => !$user_info['is_guest'], 'is_guest' => &$user_info['is_guest'], 'is_admin' => &$user_info['is_admin'], 'is_mod' => &$user_info['is_mod'], 'can_mod' => allowedTo('access_mod_center') || !$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])), 'username' => $user_info['username'], 'language' => $user_info['language'], 'email' => $user_info['email'], 'ignoreusers' => $user_info['ignoreusers']);
    if (!$context['user']['is_guest']) {
        $context['user']['name'] = $user_info['name'];
    } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) {
        $context['user']['name'] = $txt['guest_title'];
    }
    // Determine the current smiley set and map it to a numeric id (parsed post cache needs this, because
    // we don't want to left join with string matching
    $smiley_sets = explode(',', $modSettings['smiley_sets_known']);
    $user_info['smiley_set'] = !in_array($user_info['smiley_set'], $smiley_sets) && $user_info['smiley_set'] != 'none' || empty($modSettings['smiley_sets_enable']) ? !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'] : $user_info['smiley_set'];
    if ($user_info['smiley_set'] == 'none') {
        $user_info['smiley_set_id'] = 0;
    } else {
        $user_info['smiley_set_id'] = array_search($user_info['smiley_set'], $smiley_sets) + 1;
    }
    $context['user']['smiley_set'] = $user_info['smiley_set'];
    // Some basic information...
    if (!isset($context['html_headers'])) {
        $context['html_headers'] = '';
    }
    $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | ';
    $context['session_var'] = $_SESSION['session_var'];
    $context['session_id'] = $_SESSION['session_value'];
    $context['forum_name'] = $mbname;
    $context['forum_name_html_safe'] = commonAPI::htmlspecialchars($context['forum_name']);
    $context['header_logo_url_html_safe'] = empty($settings['header_logo_url']) ? '' : commonAPI::htmlspecialchars($settings['header_logo_url']);
    $context['current_action'] = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null;
    if (isset($modSettings['load_average'])) {
        $context['load_average'] = $modSettings['load_average'];
    }
    // Set some permission related settings.
    $context['show_login_bar'] = $user_info['is_guest'] && !empty($modSettings['enableVBStyleLogin']);
    // This determines the server... not used in many places, except for login fixing.
    $context['server'] = array('is_iis' => isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false, 'is_apache' => isset($_SERVER['SERVER_SOFTWARE']) && (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false), 'is_lighttpd' => isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') !== false, 'is_nginx' => isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false, 'is_cgi' => isset($_SERVER['SERVER_SOFTWARE']) && strpos(php_sapi_name(), 'cgi') !== false, 'is_windows' => strpos(PHP_OS, 'WIN') === 0, 'iso_case_folding' => ord(strtolower(chr(138))) === 154, 'complex_preg_chars' => 1);
    // A bug in some versions of IIS under CGI (older ones) makes cookie setting not work with Location: headers.
    $context['server']['needs_login_fix'] = $context['server']['is_cgi'] && $context['server']['is_iis'];
    // Detect the browser. This is separated out because it's also used in attachment downloads
    detectBrowser();
    // Set the top level linktree up.
    /*
    array_unshift($context['linktree'], array(
    	'url' => URL::home(),
    	'name' => $context['forum_name_html_safe']
    ));
    */
    // This allows sticking some HTML on the page output - useful for controls.
    if (!isset($txt)) {
        $txt = array();
    }
    $simpleActions = array('findmember', 'helpadmin', 'printpage', 'quotefast');
    if (isset($_REQUEST['xml'])) {
        loadLanguage('index+Modifications');
        loadTemplate('Xml');
        $context['template_layers'] = array();
    } elseif (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], $simpleActions)) {
        loadLanguage('index+Modifications');
        $context['template_layers'] = array();
    } else {
        loadLanguage('index+Modifications');
        // Custom templates to load, or just default?
        $is_admin = isset($_REQUEST['action']) && $_REQUEST['action'] === 'admin';
        $templates = array('index');
        // Load each template...
        foreach ($templates as $template) {
            if (!$is_admin) {
                loadTemplate($template);
            } else {
                loadAdminTemplate($template);
            }
        }
        $context['template_layers'] = array('html', 'body');
    }
    if (isset($db_show_debug) && !empty($db_show_debug)) {
        loadLanguage('Debug');
    }
    if (file_exists($settings['theme_dir'] . '/theme_support.php')) {
        @(require_once $settings['theme_dir'] . '/theme_support.php');
    } else {
        @(require_once $settings['default_theme_dir'] . '/theme_support.php');
    }
    // Guests may still need a name.
    if ($context['user']['is_guest'] && empty($context['user']['name'])) {
        $context['user']['name'] = $txt['guest_title'];
    }
    // Any theme-related strings that need to be loaded?
    if (!empty($settings['require_theme_strings'])) {
        loadLanguage('ThemeStrings', '', false);
    }
    // We allow theme variants, because we're cool.
    $context['theme_variant'] = '';
    $context['theme_variant_url'] = '';
    if (empty($settings['theme_variants'])) {
        $settings['theme_variants'] = array('default');
    }
    // Overriding - for previews and that ilk.
    if (!empty($_REQUEST['variant'])) {
        $_SESSION['id_variant'] = $_REQUEST['variant'];
    }
    // User selection?
    if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) {
        $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
    }
    // If not a user variant, select the default.
    if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) {
        $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
    }
    if (!in_array($context['theme_variant'], $settings['theme_variants'])) {
        $context['theme_variant'] = 'default';
    }
    // Do this to keep things easier in the templates.
    $context['theme_variant'] = '_' . $context['theme_variant'];
    $context['theme_variant_url'] = $context['theme_variant'] . '/';
    /*
    	if(!empty($context['theme_variant']) && $context['theme_variant'] != '_default') {
    		if(!empty($settings['base_theme_dir']))
    			$settings['template_dirs'][] = $settings['base_theme_dir'] . '/variants/' . $context['theme_variant'];
    		else
    			$settings['template_dirs'][] = $settings['default_theme_dir'] . '/variants/' . $context['theme_variant'];
    	}
    */
    // Allow overriding the board wide time/number formats.
    if (empty($user_settings['time_format']) && !empty($txt['time_format'])) {
        $user_info['time_format'] = $txt['time_format'];
    }
    $txt['number_format'] = empty($txt['number_format']) ? empty($modSettings['number_format']) ? '' : $modSettings['number_format'] : $txt['number_format'];
    if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'always') {
        $settings['theme_url'] = $settings['default_theme_url'];
        $settings['images_url'] = $settings['default_images_url'];
        $settings['theme_dir'] = $settings['default_theme_dir'];
    }
    // Make a special URL for the language.
    $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
    // Set the character set from the template.
    $context['character_set'] = 'UTF-8';
    $context['utf8'] = true;
    $context['right_to_left'] = !empty($txt['lang_rtl']);
    $context['tabindex'] = 1;
    // Compatibility.
    if (!isset($settings['theme_version'])) {
        $modSettings['memberCount'] = $modSettings['totalMembers'];
    }
    // This allows us to change the way things look for the admin.
    $context['admin_features'] = isset($modSettings['admin_features']) ? explode(',', $modSettings['admin_features']) : array('cd,cp,k,w,rg,ml,pm');
    // If we think we have mail to send, let's offer up some possibilities... robots get pain (Now with scheduled task support!)
    if (!empty($modSettings['mail_next_send']) && $modSettings['mail_next_send'] < time() && empty($modSettings['mail_queue_use_cron']) || empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
        if ($context['browser']['possibly_robot']) {
            //!!! Maybe move this somewhere better?!
            require_once $sourcedir . '/ScheduledTasks.php';
            // What to do, what to do?!
            if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
                AutoTask();
            } else {
                ReduceMailQueue();
            }
        } else {
            $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq';
            $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time'];
            $context['html_headers'] .= '
	<script type="text/javascript">
		function smfAutoTask()
		{
			var tempImage = new Image();
			tempImage.src = "' . $scripturl . '?scheduled=' . $type . ';ts=' . $ts . '";
		}
		window.setTimeout("smfAutoTask();", 1);
	</script>';
        }
    }
    // Any files to include at this point?
    if (!empty($modSettings['integrate_theme_include'])) {
        $theme_includes = explode(',', $modSettings['integrate_theme_include']);
        foreach ($theme_includes as $include) {
            $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
            if (file_exists($include)) {
                require_once $include;
            }
        }
    }
    $settings['primary_css'] = $settings['theme_url'] . MOBILE_SUBDIR . '/css/' . CSS_PRIMARY_BASE . $context['theme_variant'];
    $context['theme_scripts'] = array();
    $context['inline_footer_script'] = '';
    $context['news_item_count'] = 0;
    $context['hot_topic_message'] = sprintf($txt['hot_topics'], $modSettings['hotTopicPosts']);
    $context['very_hot_topic_message'] = sprintf($txt['very_hot_topics'], $modSettings['hotTopicVeryPosts']);
    $context['old_topic_message'] = sprintf($txt['old_topic_message'], $modSettings['oldTopicDays']);
    // Call load theme integration functions.
    HookAPI::callHook('integrate_load_theme');
    // We are ready to go.
    $context['theme_loaded'] = true;
}
Пример #24
0
 /**
  * Modifies the Action Aliasing settings
  *
  * @global string $scripturl
  * @global array $txt
  * @global array $context
  * @global array $modSettings
  */
 public static function ModifyAliasSettings()
 {
     global $scripturl, $context, $modSettings;
     loadAdminTemplate('SimpleSEF');
     $context['sub_template'] = 'alias_settings';
     $context['simplesef_aliases'] = !empty($modSettings['simplesef_aliases']) ? unserialize($modSettings['simplesef_aliases']) : array();
     $context['post_url'] = $scripturl . '?action=admin;area=simplesef;sa=alias';
     if (isset($_POST['save'])) {
         checkSession();
         // Start with some fresh arrays
         $alias_original = array();
         $alias_new = array();
         // Clean up the passed in arrays
         if (isset($_POST['original'], $_POST['alias'])) {
             // Make sure we don't allow duplicate actions or aliases
             $_POST['original'] = array_unique(array_filter($_POST['original'], create_function('$x', 'return $x != \'\';')));
             $_POST['alias'] = array_unique(array_filter($_POST['alias'], create_function('$x', 'return $x != \'\';')));
             $alias_original = array_intersect_key($_POST['original'], $_POST['alias']);
             $alias_new = array_intersect_key($_POST['alias'], $_POST['original']);
         }
         $aliases = !empty($alias_original) ? array_combine($alias_original, $alias_new) : array();
         // One last check
         foreach ($aliases as $orig => $alias) {
             if ($orig == $alias) {
                 unset($aliases[$orig]);
             }
         }
         $updates = array('simplesef_aliases' => serialize($aliases));
         updateSettings($updates);
         CacheAPI::putCache('simplesef_board_list', null, 0);
         CacheAPI::putCache('simplesef_extensions', null, 0);
         redirectexit('action=admin;area=simplesef;sa=alias');
     }
 }