本文整理汇总了PHP中isAllowedTo函数的典型用法代码示例。如果您正苦于以下问题:PHP isAllowedTo函数的具体用法?PHP isAllowedTo怎么用?PHP isAllowedTo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isAllowedTo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shd_frontpage_options
function shd_frontpage_options($return_config)
{
global $context, $modSettings, $txt, $sourcedir, $smcFunc;
// Since this is potentially dangerous, real admins only, thanks.
isAllowedTo('admin_forum');
$config_vars = array(array('select', 'shdp_frontpage_appear', array('always' => $txt['shdp_frontpage_appear_always'], 'firstload' => $txt['shdp_frontpage_appear_firstload'], 'firstdefault' => $txt['shdp_frontpage_appear_firstdefault'])), '', array('select', 'shdp_frontpage_type', array('php' => $txt['shdp_frontpage_type_php'], 'bbcode' => $txt['shdp_frontpage_type_bbcode'])), array('large_text', 'shdp_frontpage_content', 'size' => 30));
$context['settings_title'] = $txt['shdp_frontpage'];
$context['settings_icon'] = 'frontpage.png';
// Are we actually going to display this, or bouncing it back just for admin search?
if (!$return_config) {
require_once $sourcedir . '/Subs-Post.php';
require_once $sourcedir . '/Subs-Editor.php';
loadTemplate('sd_plugins_template/SDPluginFrontPage');
$context['sub_template'] = 'shd_frontpage_admin';
$context['shdp_frontpage_content'] = !empty($modSettings['shdp_frontpage_content']) ? un_preparsecode($modSettings['shdp_frontpage_content']) : '';
if (isset($_GET['save'])) {
$_POST['shdp_frontpage_content'] = isset($_POST['shdp_frontpage_content']) ? $_POST['shdp_frontpage_content'] : '';
if (!empty($_POST['shdp_frontpage_type']) && $_POST['shdp_frontpage_type'] == 'php') {
$context['shdp_frontpage_content'] = $smcFunc['htmlspecialchars']($_POST['shdp_frontpage_content'], ENT_QUOTES);
} else {
$_POST['shdp_frontpage_content'] = $smcFunc['htmlspecialchars']($_POST['shdp_frontpage_content'], ENT_QUOTES);
preparsecode($_POST['shdp_frontpage_content']);
$context['shdp_frontpage_content'] = un_preparsecode($_POST['shdp_frontpage_content']);
// So it's a known safe version.
}
}
$modSettings['disable_wysiwyg'] = true;
$editorOptions = array('id' => 'shdp_frontpage_content', 'value' => $context['shdp_frontpage_content'], 'labels' => array('post_button' => $txt['save']), 'preview_type' => 0, 'width' => '70%', 'disable_smiley_box' => false);
create_control_richedit($editorOptions);
$context['post_box_name'] = $editorOptions['id'];
}
return $config_vars;
}
示例2: PackageGet
function PackageGet()
{
global $txt, $scripturl, $context, $boarddir, $sourcedir, $modSettings;
isAllowedTo('admin_forum');
require_once $sourcedir . '/Subs-Package.php';
// Still managing packages...
adminIndex('manage_packages');
// Use the Packages template... no reason to separate.
loadLanguage('Packages');
loadTemplate('Packages');
// Add the appropriate items to the link tree.
$context['linktree'][] = array('url' => $scripturl . '?action=packages', 'name' => &$txt['package1']);
$context['linktree'][] = array('url' => $scripturl . '?action=packageget', 'name' => &$txt['smf182']);
$context['page_title'] = $txt['package1'];
// Here is a list of all the potentially valid actions.
$subActions = array('servers' => 'PackageServers', 'add' => 'PackageServerAdd', 'browse' => 'PackageGBrowse', 'download' => 'PackageDownload', 'remove' => 'PackageServerRemove', 'upload' => 'PackageUpload');
// Now let's decide where we are taking this...
if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
$context['sub_action'] = $_REQUEST['sa'];
} elseif ($_REQUEST['action'] == 'pgdownload') {
$context['sub_action'] = 'download';
} else {
$context['sub_action'] = 'servers';
}
// Now create the tabs for the template.
$context['admin_tabs'] = array('title' => &$txt['package1'], 'description' => $txt['package_manager_desc'], 'tabs' => array('browse' => array('title' => $txt['package3'], 'href' => $scripturl . '?action=packages;sa=browse'), 'packageget' => array('title' => $txt['download_packages'], 'description' => $txt['download_packages_desc'], 'href' => $scripturl . '?action=packageget', 'is_selected' => true), 'installed' => array('title' => $txt['installed_packages'], 'description' => $txt['installed_packages_desc'], 'href' => $scripturl . '?action=packages;sa=installed'), 'options' => array('title' => $txt['package_settings'], 'description' => $txt['package_install_options_ftp_why'], 'href' => $scripturl . '?action=packages;sa=options', 'is_last' => true)));
$subActions[$context['sub_action']]();
}
示例3: ManageCalendar
function ManageCalendar()
{
global $context, $txt, $scripturl, $modSettings;
isAllowedTo('admin_forum');
// Administrative side bar, here we come!
adminIndex('manage_calendar');
// Everything's gonna need this.
loadLanguage('ManageCalendar');
// Default text.
$context['explain_text'] =& $txt['calendar_desc'];
// Little short on the ground of functions here... but things can and maybe will change...
$subActions = array('editholiday' => 'EditHoliday', 'holidays' => 'ModifyHolidays', 'settings' => 'ModifySettings');
$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'settings';
// Set up the two tabs here...
$context['admin_tabs'] = array('title' => &$txt['manage_calendar'], 'help' => 'calendar', 'description' => $txt['calendar_settings_desc'], 'tabs' => array('holidays' => array('title' => $txt['manage_holidays'], 'description' => $txt['manage_holidays_desc'], 'href' => $scripturl . '?action=managecalendar;sa=holidays'), 'settings' => array('title' => $txt['calendar_settings'], 'description' => $txt['calendar_settings_desc'], 'href' => $scripturl . '?action=managecalendar;sa=settings', 'is_last' => true)));
// Select the tab they're at...
if (isset($context['admin_tabs']['tabs'][$_REQUEST['sa']])) {
$context['admin_tabs']['tabs'][$_REQUEST['sa']]['is_selected'] = true;
}
// Some settings may not be enabled, disallow these from the tabs as appropriate.
if (empty($modSettings['cal_enabled'])) {
unset($context['admin_tabs']['tabs']['holidays']);
}
$subActions[$_REQUEST['sa']]();
}
示例4: Memberlist
function Memberlist()
{
global $scripturl, $txt, $modSettings, $context, $settings;
// Make sure they can view the memberlist.
isAllowedTo('view_mlist');
loadTemplate('Memberlist');
$context['listing_by'] = !empty($_GET['sa']) ? $_GET['sa'] : 'all';
// $subActions array format:
// 'subaction' => array('label', 'function', 'is_selected')
$subActions = array('all' => array(&$txt[303], 'MLAll', $context['listing_by'] == 'all'), 'search' => array(&$txt['mlist_search'], 'MLSearch', $context['listing_by'] == 'search'));
// Set up the sort links.
$context['sort_links'] = array();
foreach ($subActions as $act => $text) {
$context['sort_links'][] = array('label' => $text[0], 'action' => $act, 'selected' => $text[2]);
}
$context['num_members'] = $modSettings['totalMembers'];
// Set up the columns...
$context['columns'] = array('isOnline' => array('label' => $txt['online8'], 'width' => '20'), 'realName' => array('label' => $txt[35]), 'emailAddress' => array('label' => $txt[307], 'width' => '25'), 'websiteUrl' => array('label' => $txt[96], 'width' => '25'), 'ICQ' => array('label' => $txt[513], 'width' => '25'), 'AIM' => array('label' => $txt[603], 'width' => '25'), 'YIM' => array('label' => $txt[604], 'width' => '25'), 'MSN' => array('label' => $txt['MSN'], 'width' => '25'), 'ID_GROUP' => array('label' => $txt[87]), 'registered' => array('label' => $txt[233]), 'posts' => array('label' => $txt[21], 'width' => '115', 'colspan' => '2'));
$context['linktree'][] = array('url' => $scripturl . '?action=mlist', 'name' => &$txt[332]);
$context['can_send_pm'] = allowedTo('pm_send');
// Jump to the sub action.
if (isset($subActions[$context['listing_by']])) {
$subActions[$context['listing_by']][1]();
} else {
$subActions['all'][1]();
}
}
示例5: AdkAdmin
function AdkAdmin()
{
global $txt, $context, $settings, $adkportal, $boardurl, $adkFolder;
//Is allowed to manage adkportal
isAllowedTo('adk_portal');
//Load my template
adktemplate('Adk-Admin');
//Load Adk Language
adkLanguage('Adk-Admin');
$subActions = array('view' => 'view', 'adksettings' => 'adksettings', 'adksavesettings' => 'adksavesettings', 'manageicons' => 'manageicons');
//Set subactions for standalone mode
if ($adkportal['adk_enable'] == 2) {
$subActions += array('standalone' => 'SettingsStandAlone', 'save_stand' => 'SaveSettingsStandAlone');
}
$context['html_headers'] .= getCss('admin_adkportal');
$context['html_headers'] .= getJs('admin');
$context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['adkadmin_settings'], 'description' => $txt['adkadmin_news_desc'], 'tabs' => array('view' => array('description' => $txt['adkadmin_news_desc'], 'label' => '<img style="vertical-align: middle;" alt="" src="' . $settings['default_theme_url'] . '/images/admin/news.png" /> ' . $txt['adkadmin_news']), 'adksettings' => array('description' => $txt['adkadmin_setting_desc'], 'label' => '<img style="vertical-align: middle;" alt="" src="' . $settings['default_theme_url'] . '/images/admin/settings.png" /> ' . $txt['adkadmin_setting']), 'manageicons' => array('description' => $txt['adkadmin_icons_desc'], 'label' => '<img style="vertical-align: middle;" alt="" src="' . $settings['default_theme_url'] . '/images/admin/icons.png" /> ' . $txt['adkadmin_icons'])));
//The last thing... print the stand alone menu
if ($adkportal['adk_enable'] == 2) {
$context[$context['admin_menu_name']]['tab_data']['tabs']['standalone'] = array('description' => $txt['adkadmin_stand_desc'], 'label' => '<img style="vertical-align: middle;" alt="" src="' . $adkFolder['images'] . '/php.png" /> ' . $txt['adkadmin_stand']);
}
// Follow the sa or just go to View function
if (!empty($_GET['sa']) && !empty($subActions[$_GET['sa']])) {
$subActions[@$_GET['sa']]();
} else {
$subActions['view']();
}
}
示例6: ManagePostSettings
function ManagePostSettings()
{
global $context, $txt, $scripturl;
// Boldify "Posts and Topics" on the admin bar.
adminIndex('posts_and_topics');
$subActions = array('posts' => array('ModifyPostSettings', 'admin_forum'), 'bbc' => array('ModifyBBCSettings', 'admin_forum'), 'censor' => array('SetCensor', 'moderate_forum'), 'topics' => array('ModifyTopicSettings', 'admin_forum'));
// Default the sub-action to 'view ban list'.
$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('admin_forum') ? 'posts' : 'censor');
// Make sure you can do this.
isAllowedTo($subActions[$_REQUEST['sa']][1]);
$context['page_title'] = $txt['manageposts_title'];
// Tabs for browsing the different ban functions.
$context['admin_tabs'] = array('title' => $txt['manageposts_title'], 'help' => 'posts_and_topics', 'description' => $txt['manageposts_description'], 'tabs' => array());
if (allowedTo('admin_forum')) {
$context['admin_tabs']['tabs'][] = array('title' => $txt['manageposts_settings'], 'description' => $txt['manageposts_settings_description'], 'href' => $scripturl . '?action=postsettings;sa=posts', 'is_selected' => $_REQUEST['sa'] == 'posts');
$context['admin_tabs']['tabs'][] = array('title' => $txt['manageposts_bbc_settings'], 'description' => $txt['manageposts_bbc_settings_description'], 'href' => $scripturl . '?action=postsettings;sa=bbc', 'is_selected' => $_REQUEST['sa'] == 'bbc');
}
if (allowedTo('moderate_forum')) {
$context['admin_tabs']['tabs'][] = array('title' => $txt[135], 'description' => $txt[141], 'href' => $scripturl . '?action=postsettings;sa=censor', 'is_selected' => $_REQUEST['sa'] == 'censor', 'is_last' => !allowedTo('admin_forum'));
}
if (allowedTo('admin_forum')) {
$context['admin_tabs']['tabs'][] = array('title' => $txt['manageposts_topic_settings'], 'description' => $txt['manageposts_topic_settings_description'], 'href' => $scripturl . '?action=postsettings;sa=topics', 'is_selected' => $_REQUEST['sa'] == 'topics', 'is_last' => true);
}
// Call the right function for this sub-acton.
$subActions[$_REQUEST['sa']][0]();
}
示例7: ManageNews
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'));
// Administrative side bar, here we come!
adminIndex('news');
loadTemplate('ManageNews');
// Format: 'sub-action' => array('function', 'permission')
$subActions = array('editnews' => array('EditNews', '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['admin_tabs'] = array('title' => $txt['news_title'], 'help' => 'edit_news', 'description' => $txt[670], 'tabs' => array());
if (allowedTo('edit_news')) {
$context['admin_tabs']['tabs'][] = array('title' => $txt[7], 'description' => $txt[670], 'href' => $scripturl . '?action=news', 'is_selected' => $_REQUEST['sa'] == 'editnews');
}
if (allowedTo('send_mail')) {
$context['admin_tabs']['tabs'][] = array('title' => $txt[6], 'description' => $txt['news_mailing_desc'], 'href' => $scripturl . '?action=news;sa=mailingmembers', 'is_selected' => substr($_REQUEST['sa'], 0, 7) == 'mailing');
}
if (allowedTo('admin_forum')) {
$context['admin_tabs']['tabs'][] = array('title' => $txt['settings'], 'description' => $txt['news_settings_desc'], 'href' => $scripturl . '?action=news;sa=settings', 'is_selected' => $_REQUEST['sa'] == 'settings');
}
$context['admin_tabs']['tabs'][count($context['admin_tabs']['tabs']) - 1]['is_last'] = true;
$subActions[$_REQUEST['sa']][0]();
}
示例8: RegCenter
function RegCenter()
{
global $modSettings, $context, $txt, $db_prefix, $scripturl;
// Old templates might still request this.
if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') {
redirectexit('action=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('AdminSettings', '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]);
// Set the admin area...
adminIndex('registration_center');
// Loading, always loading.
loadLanguage('Login');
loadTemplate('Register');
// Next create the tabs for the template.
$context['admin_tabs'] = array('title' => &$txt['registration_center'], 'help' => 'registrations', 'description' => $txt['admin_settings_desc'], 'tabs' => array('register' => array('title' => $txt['admin_browse_register_new'], 'description' => $txt['admin_register_desc'], 'href' => $scripturl . '?action=regcenter;sa=register', 'is_selected' => $context['sub_action'] == 'register', 'is_last' => !allowedTo('admin_forum'))));
if (allowedTo('admin_forum')) {
$context['admin_tabs']['tabs']['agreement'] = array('title' => $txt['smf11'], 'description' => $txt['smf12'], 'href' => $scripturl . '?action=regcenter;sa=agreement', 'is_selected' => $context['sub_action'] == 'agreement');
$context['admin_tabs']['tabs']['reservednames'] = array('title' => $txt[341], 'description' => $txt[699], 'href' => $scripturl . '?action=regcenter;sa=reservednames', 'is_selected' => $context['sub_action'] == 'reservednames');
$context['admin_tabs']['tabs']['settings'] = array('title' => $txt['settings'], 'description' => $txt['admin_settings_desc'], 'href' => $scripturl . '?action=regcenter;sa=settings', 'is_last' => true, 'is_selected' => $context['sub_action'] == 'settings');
}
// Finally, get around to calling the function...
$subActions[$context['sub_action']][0]();
}
示例9: Packages
function Packages()
{
global $txt, $scripturl, $sourcedir, $context;
isAllowedTo('admin_forum');
// Managing packages!
adminIndex('manage_packages');
// Load all the basic stuff.
require_once $sourcedir . '/Subs-Package.php';
loadLanguage('Packages');
loadTemplate('Packages');
// Set up the linktree and title so it's already done.
$context['linktree'][] = array('url' => $scripturl . '?action=packages', 'name' => &$txt['package1']);
$context['page_title'] = $txt['package1'];
// Delegation makes the world... that is, the package manager go 'round.
$subActions = array('browse' => 'PackageBrowse', 'remove' => 'PackageRemove', 'list' => 'PackageList', 'install' => 'PackageInstallTest', 'install2' => 'PackageInstall', 'uninstall' => 'PackageInstallTest', 'uninstall2' => 'PackageInstall', 'installed' => 'InstalledList', 'options' => 'PackageOptions', 'flush' => 'FlushInstall', 'examine' => 'ExamineFile');
// 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['admin_tabs'] = array('title' => &$txt['package1'], 'description' => $txt['package_manager_desc'], 'tabs' => array('browse' => array('title' => $txt['package3'], 'href' => $scripturl . '?action=packages;sa=browse'), 'packageget' => array('title' => $txt['download_packages'], 'description' => $txt['download_packages_desc'], 'href' => $scripturl . '?action=packageget'), 'installed' => array('title' => $txt['installed_packages'], 'description' => $txt['installed_packages_desc'], 'href' => $scripturl . '?action=packages;sa=installed'), 'options' => array('title' => $txt['package_settings'], 'description' => $txt['package_install_options_ftp_why'], 'href' => $scripturl . '?action=packages;sa=options', 'is_last' => true)));
// Attempt to automatically select the right tab.
if (isset($context['admin_tabs']['tabs'][$context['sub_action']])) {
$context['admin_tabs']['tabs'][$context['sub_action']]['is_selected'] = true;
} else {
$context['admin_tabs']['tabs']['browse']['is_selected'] = true;
}
// Call the function we're handing control to.
$subActions[$context['sub_action']]();
}
示例10: ModifySettings
/**
* This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects
* the appropriate one based on the sub-action.
*
* Requires the admin_forum permission.
* Redirects to the appropriate function based on the sub-action.
*
* @uses edit_settings adminIndex.
*/
function ModifySettings()
{
global $context, $txt, $scripturl, $boarddir;
// This is just to keep the database password more secure.
isAllowedTo('admin_forum');
// Load up all the tabs...
$context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['admin_server_settings'], 'help' => 'serversettings', 'description' => $txt['admin_basic_settings']);
checkSession('request');
// The settings are in here, I swear!
loadLanguage('ManageSettings');
$context['page_title'] = $txt['admin_server_settings'];
$context['sub_template'] = 'show_settings';
$subActions = array('general' => 'ModifyGeneralSettings', 'database' => 'ModifyDatabaseSettings', 'cookie' => 'ModifyCookieSettings', 'cache' => 'ModifyCacheSettings', 'loads' => 'ModifyLoadBalancingSettings', 'phpinfo' => 'ShowPHPinfoSettings');
call_integration_hook('integrate_server_settings', array(&$subActions));
// By default we're editing the core settings
$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'general';
$context['sub_action'] = $_REQUEST['sa'];
// Any messages to speak of?
$context['settings_message'] = isset($_REQUEST['msg']) && isset($txt[$_REQUEST['msg']]) ? $txt[$_REQUEST['msg']] : '';
// Warn the user if there's any relevant information regarding Settings.php.
if ($_REQUEST['sa'] != 'cache') {
// Warn the user if the backup of Settings.php failed.
$settings_not_writable = !is_writable($boarddir . '/Settings.php');
$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
if ($settings_not_writable) {
$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br />';
} elseif ($settings_backup_fail) {
$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br />';
}
$context['settings_not_writable'] = $settings_not_writable;
}
// Call the right function for this sub-action.
$subActions[$_REQUEST['sa']]();
}
示例11: PackageGet
function PackageGet()
{
global $txt, $scripturl, $context, $boarddir, $sourcedir, $modSettings;
isAllowedTo('admin_forum');
require_once $sourcedir . '/Subs-Package.php';
// Use the Packages template... no reason to separate.
loadLanguage('Packages');
loadTemplate('Packages', 'admin');
$context['page_title'] = $txt['package'];
// Here is a list of all the potentially valid actions.
$subActions = array('servers' => 'PackageServers', 'add' => 'PackageServerAdd', 'browse' => 'PackageGBrowse', 'download' => 'PackageDownload', 'remove' => 'PackageServerRemove', 'upload' => 'PackageUpload');
// Now let's decide where we are taking this...
if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
$context['sub_action'] = $_REQUEST['sa'];
} elseif (isset($_GET['pgdownload'])) {
$context['sub_action'] = 'download';
} else {
$context['sub_action'] = 'servers';
}
// We need to force the "Download" tab as selected.
$context['menu_data_' . $context['admin_menu_id']]['current_subsection'] = 'packageget';
// Now create the tabs for the template.
$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'])));
$subActions[$context['sub_action']]();
}
示例12: file_source
/**
* file_source()
*
* - initialises all the basic context required for the database cleanup.
* - passes execution onto the relevant section.
* - if the passed action is not found it shows the main page.
*
* @return
*/
function file_source()
{
global $smcFunc, $context, $table_prefix, $version;
// You have to be allowed to do this
isAllowedTo('admin_forum');
// SMF 1 or 2 ?
if (isset($smcFunc)) {
db_extend('packages');
$version = 2;
$table_prefix = '{db_prefix}';
} else {
db_compat();
$version = 1;
$table_prefix = '';
}
$actions = array('examine' => 'examine', 'execute' => 'execute');
$titles = array('examine' => 'Examine Database', 'execute' => 'Execute Changes');
// Set a default action if none or an unsupported one is given
if (!isset($_GET['action']) || !isset($actions[$_GET['action']])) {
$current_action = 'examine';
} else {
$current_action = $actions[$_GET['action']];
}
// Set up the template information and language
loadtext();
$context['sub_template'] = $current_action;
$context['page_title'] = $titles[$current_action];
$context['page_title_html_safe'] = $titles[$current_action];
$context['robot_no_index'] = true;
$context['html_headers'] .= '
<style type="text/css">
.normallist li
{
list-style: circle;
line-height: 1.5em;
}
.submit_button
{
text-align: center;
}
.error
{
background-color: #FFECEC;
}
.success
{
color: #00CC00;
}
.fail
{
color: #EE0000;
}
</style>';
$current_action();
}
示例13: action_stats
/**
* Display some useful/interesting board statistics.
*
* What it does:
* - Gets all the statistics in order and puts them in.
* - Uses the Stats template and language file. (and main sub template.)
* - Requires the view_stats permission.
* - Accessed from ?action=stats.
*
* @uses Stats language file
* @uses Stats template, statistics sub template
*/
public function action_stats()
{
global $txt, $scripturl, $modSettings, $context;
// You have to be able to see these
isAllowedTo('view_stats');
// Page disabled - redirect them out
if (empty($modSettings['trackStats'])) {
fatal_lang_error('feature_disabled', true);
}
if (!empty($_REQUEST['expand'])) {
$context['robot_no_index'] = true;
$month = (int) substr($_REQUEST['expand'], 4);
$year = (int) substr($_REQUEST['expand'], 0, 4);
if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) {
$_SESSION['expanded_stats'][$year][] = $month;
}
} elseif (!empty($_REQUEST['collapse'])) {
$context['robot_no_index'] = true;
$month = (int) substr($_REQUEST['collapse'], 4);
$year = (int) substr($_REQUEST['collapse'], 0, 4);
if (!empty($_SESSION['expanded_stats'][$year])) {
$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
}
}
// Just a lil' help from our friend :P
require_once SUBSDIR . '/Stats.subs.php';
// Handle the XMLHttpRequest.
if (isset($_REQUEST['xml'])) {
// Collapsing stats only needs adjustments of the session variables.
if (!empty($_REQUEST['collapse'])) {
obExit(false);
}
$context['sub_template'] = 'stats';
getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month));
$context['yearly'][$year]['months'][$month]['date'] = array('month' => sprintf('%02d', $month), 'year' => $year);
return;
}
// Stats it is
loadLanguage('Stats');
loadTemplate('Stats');
loadJavascriptFile('stats.js');
// Build the link tree......
$context['linktree'][] = array('url' => $scripturl . '?action=stats', 'name' => $txt['stats_center']);
// Prepare some things for the template page
$context['page_title'] = $context['forum_name'] . ' - ' . $txt['stats_center'];
$context['sub_template'] = 'statistics';
// These are the templates that will be used to render the statistics
$context['statistics_callbacks'] = array('general_statistics', 'top_statistics');
// Call each area of statics to load our friend $context
$this->loadGeneralStatistics();
$this->loadTopStatistics();
$this->loadMontlyActivity();
// Custom stats (just add a template_layer or another callback to add it to the page!)
call_integration_hook('integrate_forum_stats');
}
示例14: Staff
function Staff()
{
global $context, $mbname, $txt;
//Check if the current user can view the staff list
isAllowedTo('view_stafflist');
loadtemplate('Staff');
//Load the main staff template
$context['sub_template'] = 'main';
//Set the page title
$context['page_title'] = $mbname . ' - ' . $txt['smfstaff_stafflist'];
}
示例15: RepairBoards
function RepairBoards()
{
global $txt, $scripturl, $db_connection, $context, $sourcedir;
global $salvageCatID, $salvageBoardID, $smcFunc, $errorTests;
isAllowedTo('admin_forum');
// Try secure more memory.
@ini_set('memory_limit', '128M');
// Print out the top of the webpage.
$context['page_title'] = $txt['admin_repair'];
$context['sub_template'] = 'repair_boards';
$context[$context['admin_menu_name']]['current_subsection'] = 'general';
// Load the language file.
loadLanguage('ManageMaintenance');
// Make sure the tabs stay nice.
$context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['maintain_title'], 'help' => '', 'description' => $txt['maintain_info'], 'tabs' => array());
// Start displaying errors without fixing them.
if (isset($_GET['fixErrors'])) {
checkSession('get');
}
// Will want this.
loadForumTests();
// Giant if/else. The first displays the forum errors if a variable is not set and asks
// if you would like to continue, the other fixes the errors.
if (!isset($_GET['fixErrors'])) {
$context['error_search'] = true;
$context['repair_errors'] = array();
$context['to_fix'] = findForumErrors();
if (!empty($context['to_fix'])) {
$_SESSION['repairboards_to_fix'] = $context['to_fix'];
$_SESSION['repairboards_to_fix2'] = null;
if (empty($context['repair_errors'])) {
$context['repair_errors'][] = '???';
}
}
} else {
$context['error_search'] = false;
$context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array();
require_once $sourcedir . '/Subs-Boards.php';
// Get the MySQL version for future reference.
$mysql_version = $smcFunc['db_server_info']($db_connection);
// Actually do the fix.
findForumErrors(true);
// Note that we've changed everything possible ;)
updateSettings(array('settings_updated' => time()));
updateStats('message');
updateStats('topic');
updateSettings(array('calendar_updated' => time()));
if (!empty($salvageBoardID)) {
$context['redirect_to_recount'] = true;
}
$_SESSION['repairboards_to_fix'] = null;
$_SESSION['repairboards_to_fix2'] = null;
}
}