Exemple #1
0
function StaffSettings()
{
    global $context, $mbname, $txt, $db_prefix;
    isAllowedTo('admin_forum');
    adminIndex('staff_settings');
    $context['sub_template'] = 'adminset';
    // Set the page title
    $context['page_title'] = $mbname . ' - ' . $txt['smfstaff_staffsetting'];
    // Get all Staff Groups
    $query2 = db_query("\n\tSELECT \n\t\tID_GROUP\n\tFROM {$db_prefix}staff", __FILE__, __LINE__);
    $staff_groups = array();
    while ($row = mysql_fetch_assoc($query2)) {
        $staff_groups[$row['ID_GROUP']] = array('ID_GROUP' => $row['ID_GROUP']);
    }
    mysql_free_result($query2);
    $groups = array();
    $groups2 = array();
    $query = db_query("\n\tSELECT \n\t\tm.ID_GROUP, m.groupName, m.onlineColor \n\tFROM {$db_prefix}membergroups as m WHERE m.minPosts = -1 \n\t\t\tORDER BY m.groupName", __FILE__, __LINE__);
    while ($row = mysql_fetch_assoc($query)) {
        // Check if the group is not listed already.
        if (!isset($staff_groups[$row['ID_GROUP']])) {
            $groups[$row['ID_GROUP']] = array('id' => $row['ID_GROUP'], 'name' => $row['groupName'], 'color' => empty($row['onlineColor']) ? '' : $row['onlineColor']);
        } else {
            $groups2[$row['ID_GROUP']] = array('id' => $row['ID_GROUP'], 'name' => $row['groupName'], 'color' => empty($row['onlineColor']) ? '' : $row['onlineColor']);
        }
    }
    mysql_free_result($query);
    $context['smfstaff_groups'] = $groups;
    $context['smfstaff_showgroups'] = $groups2;
}
Exemple #2
0
function ManageSmileys()
{
    global $context, $txt, $scripturl, $modSettings;
    isAllowedTo('manage_smileys');
    adminIndex('manage_smileys');
    loadLanguage('ManageSmileys');
    loadTemplate('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'] : 'settings';
    $context['page_title'] =& $txt['smileys_manage'];
    $context['sub_action'] = $_REQUEST['sa'];
    $context['sub_template'] =& $context['sub_action'];
    // Load up all the tabs...
    $context['admin_tabs'] = array('title' => &$txt['smileys_manage'], 'help' => 'smileys', 'description' => $txt['smiley_settings_explain'], 'tabs' => array('editsets' => array('title' => $txt['smiley_sets'], 'description' => $txt['smiley_editsets_explain'], 'href' => $scripturl . '?action=smileys;sa=editsets'), 'addsmiley' => array('title' => $txt['smileys_add'], 'description' => $txt['smiley_addsmiley_explain'], 'href' => $scripturl . '?action=smileys;sa=addsmiley'), 'editsmileys' => array('title' => $txt['smileys_edit'], 'description' => $txt['smiley_editsmileys_explain'], 'href' => $scripturl . '?action=smileys;sa=editsmileys'), 'setorder' => array('title' => $txt['smileys_set_order'], 'description' => $txt['smiley_setorder_explain'], 'href' => $scripturl . '?action=smileys;sa=setorder'), 'editicons' => array('title' => $txt['icons_edit_message_icons'], 'description' => $txt['icons_edit_icons_explain'], 'href' => $scripturl . '?action=smileys;sa=editicons'), 'settings' => array('title' => $txt['settings'], 'description' => $txt['smiley_settings_explain'], 'href' => $scripturl . '?action=smileys;sa=settings', 'is_last' => true)));
    // Select the right tab based on the sub action.
    if (isset($context['admin_tabs']['tabs'][$context['sub_action']])) {
        $context['admin_tabs']['tabs'][$context['sub_action']]['is_selected'] = true;
    }
    // Some settings may not be enabled, disallow these from the tabs as appropriate.
    if (empty($modSettings['messageIcons_enable'])) {
        unset($context['admin_tabs']['tabs']['editicons']);
    }
    if (empty($modSettings['smiley_enable'])) {
        unset($context['admin_tabs']['tabs']['addsmiley']);
        unset($context['admin_tabs']['tabs']['editsmileys']);
        unset($context['admin_tabs']['tabs']['setorder']);
    }
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']]();
}
Exemple #3
0
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']]();
}
Exemple #4
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'));
    // 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]();
}
Exemple #5
0
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']]();
}
Exemple #6
0
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']]();
}
Exemple #7
0
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]();
}
Exemple #8
0
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]();
}
Exemple #9
0
function view()
{
    global $context;
    adminIndex('globalhf');
    checkSession('get');
    //Load main trader template.
    $context['sub_template'] = 'main';
    //Set the page title
    $context['page_title'] = 'Global Headers and Footers';
}
Exemple #10
0
function ViewMembers()
{
    global $txt, $scripturl, $context, $modSettings, $db_prefix;
    $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]);
    // Administration bar, I choose you!
    adminIndex('view_members');
    // Load the essentials.
    loadLanguage('ManageMembers');
    loadTemplate('ManageMembers');
    // Get counts on every type of activation - for sections and filtering alike.
    $request = db_query("\n\t\tSELECT COUNT(*) AS totalMembers, is_activated\n\t\tFROM {$db_prefix}members\n\t\tWHERE is_activated != 1\n\t\tGROUP BY is_activated", __FILE__, __LINE__);
    $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['totalMembers'];
    }
    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']);
    // Setup the admin tabs.
    $context['admin_tabs'] = array('title' => $txt[9], 'help' => 'view_members', 'description' => $txt[11], 'tabs' => array());
    if (allowedTo('moderate_forum')) {
        $context['admin_tabs']['tabs'] = array('viewmembers' => array('title' => $txt[303], 'description' => $txt[11], 'href' => $scripturl . '?action=viewmembers;sa=all', 'is_selected' => $_REQUEST['sa'] == 'all'), 'search' => array('title' => $txt['mlist_search'], 'description' => $txt[11], 'href' => $scripturl . '?action=viewmembers;sa=search', 'is_selected' => $_REQUEST['sa'] == 'search' || $_REQUEST['sa'] == 'query'), 'approve' => array('title' => sprintf($txt['admin_browse_awaiting_approval'], $context['awaiting_approval']), 'description' => $txt['admin_browse_approve_desc'], 'href' => $scripturl . '?action=viewmembers;sa=browse;type=approve', 'is_selected' => false), 'activate' => array('title' => sprintf($txt['admin_browse_awaiting_activate'], $context['awaiting_activation']), 'description' => $txt['admin_browse_activate_desc'], 'href' => $scripturl . '?action=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']) {
        $context['admin_tabs']['tabs']['approve']['is_last'] = true;
        unset($context['admin_tabs']['tabs']['activate']);
    }
    if (!$context['show_approve']) {
        if (!$context['show_activate']) {
            $context['admin_tabs']['tabs']['search']['is_last'] = true;
        }
        unset($context['admin_tabs']['tabs']['approve']);
    }
    $subActions[$_REQUEST['sa']][0]();
}
Exemple #11
0
function GlobalHF()
{
    global $context, $settings, $txt, $global_hf;
    isAllowedTo('admin_forum');
    adminIndex('globalhf');
    define('GlobalHF_VERSION', '<a href="http://custom.simplemachines.org/mods/index.php?mod=351" target="_blank">Global Headers and Footers 2.0.1</a>');
    define('GlobalHF_COPYRIGHT', 'Copyright <a href="http://www.smfhacks.com/" target="_blank">SMFHacks.com</a> 2012');
    loadLanguage('smfhacks_languages/global-hf');
    loadTemplate('smfhacks_templates/global-hf');
    GlobalHFCheckSaving();
    $context['template_layers'][] = 'global_hf_copyright';
    $context['html_headers'] .= "\n" . '<link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/smfhacks_css/global-hf.css" />';
    $context['page_title'] = $txt['global_hf']['title'];
    $context['sub_template'] = 'global_hf_admin';
}
Exemple #12
0
function ManageSearch()
{
    global $context, $txt, $scripturl;
    isAllowedTo('admin_forum');
    adminIndex('manage_search');
    loadLanguage('Search');
    loadTemplate('ManageSearch');
    $subActions = array('settings' => 'EditSearchSettings', 'weights' => 'EditWeights', 'method' => 'EditSearchMethod', 'createfulltext' => 'EditSearchMethod', 'removecustom' => 'EditSearchMethod', 'removefulltext' => 'EditSearchMethod', 'createmsgindex' => 'CreateMessageIndex');
    // Default the sub-action to 'edit search settings'.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'settings';
    $context['sub_action'] = $_REQUEST['sa'];
    // Create the tabs for the template.
    $context['admin_tabs'] = array('title' => &$txt['manage_search'], 'help' => 'search', 'description' => $txt['search_settings_desc'], 'tabs' => array('weights' => array('title' => $txt['search_weights'], 'description' => $txt['search_weights_desc'], 'href' => $scripturl . '?action=managesearch;sa=weights'), 'method' => array('title' => $txt['search_method'], 'description' => $txt['search_method_desc'], 'href' => $scripturl . '?action=managesearch;sa=method'), 'settings' => array('title' => $txt['settings'], 'description' => $txt['search_settings_desc'], 'href' => $scripturl . '?action=managesearch;sa=settings', 'is_last' => true)));
    // Make sure the tab they are using has is_selected set.
    if (isset($context['admin_tabs']['tabs'][$_REQUEST['sa']])) {
        $context['admin_tabs']['tabs'][$_REQUEST['sa']]['is_selected'] = true;
    }
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']]();
}
Exemple #13
0
function ModifySettings()
{
    global $context, $txt, $scripturl, $modSettings;
    // This is just to keep the database password more secure.
    isAllowedTo('admin_forum');
    checkSession('get');
    // The administration bar......
    adminIndex('edit_settings');
    $context['page_title'] = $txt[222];
    $context['sub_template'] = 'show_settings';
    $subActions = array('core' => 'ModifyCoreSettings', 'other' => 'ModifyOtherSettings', 'cache' => 'ModifyCacheSettings');
    // By default we're editing the core settings
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'core';
    $context['sub_action'] = $_REQUEST['sa'];
    // Load up all the tabs...
    $context['admin_tabs'] = array('title' => &$txt[222], 'help' => 'serversettings', 'description' => $txt[347], 'tabs' => array('core' => array('title' => $txt['core_configuration'], 'href' => $scripturl . '?action=serversettings;sa=core;sesc=' . $context['session_id']), 'other' => array('title' => $txt['other_configuration'], 'href' => $scripturl . '?action=serversettings;sa=other;sesc=' . $context['session_id']), 'cache' => array('title' => $txt['caching_settings'], 'href' => $scripturl . '?action=serversettings;sa=cache;sesc=' . $context['session_id'], 'is_last' => true)));
    // Select the right tab based on the sub action.
    if (isset($context['admin_tabs']['tabs'][$context['sub_action']])) {
        $context['admin_tabs']['tabs'][$context['sub_action']]['is_selected'] = true;
    }
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']]();
}
Exemple #14
0
function PrettyInterface()
{
    global $context, $scripturl, $settings, $txt;
    //	Keep the critters out
    isAllowedTo('admin_forum');
    //	Default templating stuff
    loadTemplate('PrettyUrls');
    if (loadLanguage('PrettyUrls') == false) {
        loadLanguage('PrettyUrls', 'english');
    }
    //	Shiny chrome interface
    adminIndex('config');
    $context['template_layers']['pretty_chrome'] = 'pretty_chrome';
    $context['html_headers'] .= '
	<link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/pretty/chrome.css" media="screen,projection" />';
    $context['pretty']['chrome'] = array('admin' => true, 'menu' => array('news' => array('href' => $scripturl . '?action=admin;area=pretty', 'title' => $txt['pretty_chrome_menu_news']), 'settings' => array('href' => $scripturl . '?action=admin;area=pretty;sa=settings', 'title' => $txt['pretty_chrome_menu_settings']), 'maintenance' => array('href' => $scripturl . '?action=admin;area=pretty;sa=maintenance', 'title' => $txt['pretty_chrome_menu_maintenance'])), 'title' => $txt['pretty_chrome_title']);
    //	What can we do today?
    $subActions = array('filters' => 'pretty_edit_filters', 'maintenance' => 'pretty_maintenance', 'news' => 'pretty_news', 'settings' => 'pretty_manage_settings', 'test' => 'pretty_test_rewrites');
    if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
        call_user_func($subActions[$_REQUEST['sa']]);
    } else {
        pretty_news();
    }
}
function ModifyMembergroups()
{
    global $context, $txt, $scripturl;
    $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'), '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');
    // Do the permission check, you might not be allowed her.
    isAllowedTo($subActions[$_REQUEST['sa']][1]);
    // We're in the admin screen, so show a nice side bar.
    adminIndex('edit_groups');
    // Language and template stuff, the usual.
    loadLanguage('ManageMembers');
    loadTemplate('ManageMembergroups');
    // Setup the admin tabs.
    $context['admin_tabs'] = array('title' => $txt['membergroups_title'], 'help' => 'membergroups', 'description' => $txt['membergroups_description'], 'tabs' => array());
    if (allowedTo('manage_membergroups')) {
        $context['admin_tabs']['tabs']['index'] = array('title' => $txt['membergroups_edit_groups'], 'description' => $txt['membergroups_description'], 'href' => $scripturl . '?action=membergroups', 'is_selected' => $_REQUEST['sa'] != 'add' && $_REQUEST['sa'] != 'settings');
        $context['admin_tabs']['tabs']['add_cat'] = array('title' => $txt['membergroups_new_group'], 'description' => $txt['membergroups_description'], 'href' => $scripturl . '?action=membergroups;sa=add', 'is_selected' => $_REQUEST['sa'] == 'add', 'is_last' => !allowedTo('admin_forum'));
    }
    if (allowedTo('admin_forum')) {
        $context['admin_tabs']['tabs']['settings'] = array('title' => $txt['settings'], 'description' => $txt['membergroups_description'], 'href' => $scripturl . '?action=membergroups;sa=settings', 'is_selected' => $_REQUEST['sa'] == 'settings', 'is_last' => true);
    }
    // Call the right function.
    $subActions[$_REQUEST['sa']][0]();
}
Exemple #16
0
function ModifyPermissions()
{
    global $txt, $scripturl, $context;
    adminIndex('edit_permissions');
    loadLanguage('ManagePermissions');
    loadTemplate('ManagePermissions');
    // Format: 'sub-action' => array('function_to_call', 'permission_needed'),
    $subActions = array('board' => array('PermissionByBoard', 'manage_permissions'), 'index' => array('PermissionIndex', 'manage_permissions'), 'modify' => array('ModifyMembergroup', 'manage_permissions'), 'modify2' => array('ModifyMembergroup2', 'manage_permissions'), 'quick' => array('SetQuickGroups', 'manage_permissions'), 'quickboard' => array('SetQuickBoards', 'manage_permissions'), 'settings' => array('GeneralPermissionSettings', 'admin_forum'), 'switch' => array('SwitchBoard', 'manage_permissions'));
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_permissions') ? 'index' : 'settings');
    isAllowedTo($subActions[$_REQUEST['sa']][1]);
    // Create the tabs for the template.
    $context['admin_tabs'] = array('title' => $txt['permissions_title'], 'help' => 'permissions', 'description' => '', 'tabs' => array());
    if (allowedTo('manage_permissions')) {
        $context['admin_tabs']['tabs']['index'] = array('title' => $txt['permissions_groups'], 'description' => $txt['permission_by_membergroup_desc'], 'href' => $scripturl . '?action=permissions', 'is_selected' => in_array($_REQUEST['sa'], array('modify', 'index')) && empty($_REQUEST['boardid']));
        $context['admin_tabs']['tabs']['board_permissions'] = array('title' => $txt['permissions_boards'], 'description' => $txt['permission_by_board_desc'], 'href' => $scripturl . '?action=permissions;sa=board', 'is_selected' => in_array($_REQUEST['sa'], array('board', 'switch')) || in_array($_REQUEST['sa'], array('modify', 'index')) && !empty($_REQUEST['boardid']), 'is_last' => !allowedTo('admin_forum'));
    }
    if (allowedTo('admin_forum')) {
        $context['admin_tabs']['tabs']['settings'] = array('title' => $txt['settings'], 'description' => $txt['permission_settings_desc'], 'href' => $scripturl . '?action=permissions;sa=settings', 'is_selected' => $_REQUEST['sa'] == 'settings', 'is_last' => true);
    }
    $subActions[$_REQUEST['sa']][0]();
}
Exemple #17
0
function LinksAdminPerm()
{
    global $context, $mbname, $txt, $db_prefix;
    isAllowedTo('links_manage_cat');
    adminIndex('links_settings');
    DoLinksAdminTabs();
    $context['page_title'] = $mbname . $txt['smflinks_title'] . ' - ' . $txt['smflinks_catpermlist'];
    $context['sub_template'] = 'catpermlist';
    //Show the member groups
    $dbresult = db_query("\n\t\t  \tSELECT \n\t\t  \t\tc.ID_CAT, c.ID, c.view, c.addlink, c.editlink, c.dellink,   c.ID_GROUP, m.groupName,a.title catname \n\t\t  \tFROM ({$db_prefix}links_catperm as c, {$db_prefix}membergroups AS m,{$db_prefix}links_cat as a) \n\t\t  \tWHERE  c.ID_GROUP = m.ID_GROUP AND a.ID_CAT = c.ID_CAT", __FILE__, __LINE__);
    $context['links_membergroups'] = array();
    while ($row = mysql_fetch_assoc($dbresult)) {
        $context['links_membergroups'][] = $row;
    }
    mysql_free_result($dbresult);
    // Regular Member Groups
    $dbresult = db_query("\n\t\t  \tSELECT \n\t\t  \t\tc.ID_CAT, c.ID, c.view, c.addlink, c.editlink, c.dellink,   c.ID_GROUP,a.title catname \n\t\t  \tFROM {$db_prefix}links_catperm as c,{$db_prefix}links_cat as a \n\t\t  \tWHERE  c.ID_GROUP = 0 AND a.ID_CAT = c.ID_CAT LIMIT 1", __FILE__, __LINE__);
    $context['links_reggroups'] = array();
    while ($row = mysql_fetch_assoc($dbresult)) {
        $context['links_reggroups'][] = $row;
    }
    mysql_free_result($dbresult);
    // Guests
    $dbresult = db_query("\n\t\t  \tSELECT \n\t\t  \t\tc.ID_CAT, c.ID, c.view, c.addlink, c.editlink, c.dellink, c.ID_GROUP,a.title catname \n\t\t  \tFROM {$db_prefix}links_catperm as c,{$db_prefix}links_cat as a \n\t\t  \tWHERE  c.ID_GROUP = -1 AND a.ID_CAT = c.ID_CAT LIMIT 1", __FILE__, __LINE__);
    $context['links_guestsgroups'] = array();
    while ($row = mysql_fetch_assoc($dbresult)) {
        $context['links_guestsgroups'][] = $row;
    }
    mysql_free_result($dbresult);
}
Exemple #18
0
function TP_setThemeLayer($layer, $template, $subtemplate, $admin = false)
{
    global $context, $settings;
    if ($admin) {
        loadtemplate($template);
        if (file_exists($settings['theme_dir'] . '/' . $template . '.css')) {
            $context['html_headers'] .= '<link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/' . $template . '.css?fin11" />';
        } else {
            $context['html_headers'] .= '<link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/' . $template . '.css?fin11" />';
        }
        if (loadLanguage('TPortalAdmin') == false) {
            loadlangauge('TPortalAdmin', 'english');
        }
        if (loadLanguage($template) == false) {
            loadLanguage($template, 'english');
        }
        adminIndex('tportal');
        $context['template_layers'][] = $layer;
        $context['sub_template'] = $subtemplate;
    } else {
        loadtemplate($template);
        if (loadLanguage($template) == false) {
            loadLanguage($template, 'english');
        }
        if (file_exists($settings['theme_dir'] . '/' . $template . '.css')) {
            $context['html_headers'] .= '<link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/' . $template . '.css?fin11" />';
        } else {
            $context['html_headers'] .= '<link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/' . $template . '.css?fin11" />';
        }
        $context['template_layers'][] = $layer;
        $context['sub_template'] = $subtemplate;
    }
}
Exemple #19
0
function ManageBoards()
{
    global $context, $txt, $scripturl;
    // Everything's gonna need this.
    loadLanguage('ManageBoards');
    // Format: 'sub-action' => array('function', 'permission')
    $subActions = array('board' => array('EditBoard', 'manage_boards'), 'board2' => array('EditBoard2', 'manage_boards'), 'cat' => array('EditCategory', 'manage_boards'), 'cat2' => array('EditCategory2', 'manage_boards'), 'main' => array('ManageBoardsMain', 'manage_boards'), 'move' => array('ManageBoardsMain', 'manage_boards'), 'newcat' => array('EditCategory', 'manage_boards'), 'newboard' => array('EditBoard', 'manage_boards'), 'settings' => array('EditBoardSettings', 'admin_forum'));
    // Default to sub action 'main' or 'settings' depending on permissions.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_boards') ? 'main' : 'settings');
    // Have you got the proper permissions?
    isAllowedTo($subActions[$_REQUEST['sa']][1]);
    // Administrative side bar, here we come!
    adminIndex('manage_boards');
    // Create the tabs for the template.
    $context['admin_tabs'] = array('title' => $txt[41], 'help' => 'manage_boards', 'description' => $txt[677], 'tabs' => array());
    if (allowedTo('manage_boards')) {
        $context['admin_tabs']['tabs']['modify_boards'] = array('title' => $txt['boardsEdit'], 'description' => $txt[677], 'href' => $scripturl . '?action=manageboards', 'is_selected' => $_REQUEST['sa'] != 'newcat' && $_REQUEST['sa'] != 'settings');
        $context['admin_tabs']['tabs']['add_cat'] = array('title' => $txt['mboards_new_cat'], 'description' => $txt[677], 'href' => $scripturl . '?action=manageboards;sa=newcat', 'is_selected' => $_REQUEST['sa'] == 'newcat', 'is_last' => !allowedTo('admin_forum'));
    }
    if (allowedTo('admin_forum')) {
        $context['admin_tabs']['tabs']['settings'] = array('title' => $txt['settings'], 'description' => $txt['mboards_settings_desc'], 'href' => $scripturl . '?action=manageboards;sa=settings', 'is_selected' => $_REQUEST['sa'] == 'settings', 'is_last' => true);
    }
    $subActions[$_REQUEST['sa']][0]();
}
Exemple #20
0
function ViewErrorLog()
{
    global $db_prefix, $scripturl, $txt, $context, $modSettings, $user_profile, $filter;
    // Check for the administrative permission to do this.
    isAllowedTo('admin_forum');
    // Administration bar, templates, etc...
    adminIndex('view_errors');
    loadTemplate('Errors');
    // You can filter by any of the following columns:
    $filters = array('ID_MEMBER' => &$txt[35], 'ip' => &$txt['ip_address'], 'session' => &$txt['session'], 'url' => &$txt['error_url'], 'message' => &$txt['error_message']);
    // Set up the filtering...
    if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) {
        $filter = array('variable' => $_GET['filter'], 'value' => array('sql' => addslashes($_GET['filter'] == 'message' || $_GET['filter'] == 'url' ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : addcslashes($_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 = db_query("\n\t\tSELECT COUNT(*)\n\t\tFROM {$db_prefix}log_errors" . (isset($filter) ? "\n\t\tWHERE {$filter['variable']} LIKE '{$filter['value']['sql']}'" : ''), __FILE__, __LINE__);
    list($num_errors) = mysql_fetch_row($result);
    mysql_free_result($result);
    // If this filter is empty...
    if ($num_errors == 0 && isset($filter)) {
        redirectexit('action=viewErrorLog' . (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=viewErrorLog' . ($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 = db_query("\n\t\tSELECT ID_ERROR, ID_MEMBER, ip, url, logTime, message, session\n\t\tFROM {$db_prefix}log_errors" . (isset($filter) ? "\n\t\tWHERE {$filter['variable']} LIKE '{$filter['value']['sql']}'" : '') . "\n\t\tORDER BY ID_ERROR " . ($context['sort_direction'] == 'down' ? 'DESC' : '') . "\n\t\tLIMIT {$_GET['start']}, {$modSettings['defaultMaxMessages']}", __FILE__, __LINE__);
    $context['errors'] = array();
    $members = array();
    while ($row = mysql_fetch_assoc($request)) {
        $search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', addcslashes($row['message'], '\\_%'));
        if ($search_message == $filter['value']['sql']) {
            $search_message = addcslashes($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'][] = array('member' => array('id' => $row['ID_MEMBER'], 'ip' => $row['ip'], 'session' => $row['session']), 'time' => timeformat($row['logTime']), 'timestamp' => $row['logTime'], 'url' => array('html' => htmlspecialchars($scripturl . $row['url']), 'href' => base64_encode(addcslashes($row['url'], '\\_%'))), 'message' => array('html' => $show_message, 'href' => base64_encode($search_message)), 'id' => $row['ID_ERROR']);
        // 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 = db_query("\n\t\t\tSELECT ID_MEMBER, memberName, realName\n\t\t\tFROM {$db_prefix}members\n\t\t\tWHERE ID_MEMBER IN (" . implode(', ', $members) . ")\n\t\t\tLIMIT " . count($members), __FILE__, __LINE__);
        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, 'memberName' => '', 'realName' => $txt[28]);
        // 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]['memberName'];
            $context['errors'][$id]['member']['name'] = $members[$memID]['realName'];
            $context['errors'][$id]['member']['href'] = empty($memID) ? '' : $scripturl . '?action=profile;u=' . $memID;
            $context['errors'][$id]['member']['link'] = empty($memID) ? $txt[28] : '<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]['realName'] . '</a>';
        } elseif ($filter['variable'] == 'url') {
            $context['filter']['value']['html'] = "'" . htmlspecialchars($scripturl . stripslashes($filter['value']['sql'])) . "'";
        } elseif ($filter['variable'] == 'message') {
            $context['filter']['value']['html'] = "'" . strtr(htmlspecialchars(stripslashes($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']);
        } else {
            $context['filter']['value']['html'] =& $filter['value']['sql'];
        }
    }
    // And this is pretty basic ;).
    $context['page_title'] = $txt['errlog1'];
    $context['has_filter'] = isset($filter);
    $context['sub_template'] = 'error_log';
}
Exemple #21
0
function ReportsMain()
{
    global $db_prefix, $txt, $modSettings, $context, $scripturl;
    // Only admins, only EVER admins!
    isAllowedTo('admin_forum');
    // Let's get our things running...
    loadTemplate('Reports');
    loadLanguage('Reports');
    // We want an admin menu...
    adminIndex('generate_reports');
    $context['page_title'] = $txt['generate_reports'];
    // These are the types of reports which exist - and the functions to generate them.
    $context['report_types'] = array('boards' => 'BoardReport', 'board_perms' => 'BoardPermissionsReport', 'member_groups' => 'MemberGroupsReport', 'group_perms' => 'GroupPermissionsReport', 'staff' => 'StaffReport');
    $is_first = 0;
    foreach ($context['report_types'] as $k => $temp) {
        $context['report_types'][$k] = array('id' => $k, 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $type['id'], 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, 'function' => $temp, 'is_first' => $is_first++ == 0);
    }
    // If they haven't choosen a report type which is valid, send them off to the report type chooser!
    if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']])) {
        $context['sub_template'] = 'report_type';
        return;
    }
    $context['report_type'] = $_REQUEST['rt'];
    // What are valid templates for showing reports?
    $reportTemplates = array('main' => array('layers' => null), 'print' => array('layers' => array('print')));
    // Specific template? Use that instead of main!
    if (isset($_REQUEST['st']) && isset($reportTemplates[$_REQUEST['st']])) {
        $context['sub_template'] = $_REQUEST['st'];
        // Are we disabling the other layers - print friendly for example?
        if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) {
            $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers'];
        }
    }
    // Make the page title more descriptive.
    $context['page_title'] .= ' - ' . (isset($txt['gr_type_' . $context['report_type']]) ? $txt['gr_type_' . $context['report_type']] : $context['report_type']);
    // Now generate the data.
    $context['report_types'][$context['report_type']]['function']();
    // Finish the tables before exiting - this is to help the templates a little more.
    finishTables();
}
Exemple #22
0
function displayAdminLogin()
{
    //已经登录则直接进入后台
    if (@$_SESSION['adminusername'] != '') {
        adminIndex();
    } else {
        $c = '';
        $c = getTemplateContent('login.html');
        $c = handleDisplayLanguage($c, 'login');
        Rw($c);
    }
}
Exemple #23
0
function RepairBoards()
{
    global $db_prefix, $txt, $scripturl, $db_connection, $sc, $context, $sourcedir;
    global $salvageCatID, $salvageBoardID;
    isAllowedTo('admin_forum');
    // Set up the administrative bar thing.
    adminIndex('maintain_forum');
    // Print out the top of the webpage.
    $context['page_title'] = $txt[610];
    $context['sub_template'] = 'rawdata';
    // Start displaying errors without fixing them.
    if (isset($_GET['fixErrors'])) {
        checkSession('get');
    }
    // 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['repair_errors'] = array();
        $to_fix = findForumErrors();
        if (!empty($to_fix)) {
            $_SESSION['repairboards_to_fix'] = $to_fix;
            $_SESSION['repairboards_to_fix2'] = null;
            if (empty($context['repair_errors'])) {
                $context['repair_errors'][] = '???';
            }
        }
        $context['raw_data'] = '
			<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tborder">
				<tr class="titlebg">
					<td>' . $txt['smf73'] . '</td>
				</tr><tr>
					<td class="windowbg">';
        if (!empty($to_fix)) {
            $context['raw_data'] .= '
						' . $txt['smf74'] . ':<br />
						' . implode('
						<br />', $context['repair_errors']) . '<br />
						<br />
						' . $txt['smf85'] . '<br />
						<b><a href="' . $scripturl . '?action=repairboards;fixErrors;sesc=' . $sc . '">' . $txt[163] . '</a> - <a href="' . $scripturl . '?action=maintain">' . $txt[164] . '</a></b>';
        } else {
            $context['raw_data'] .= '
						' . $txt['maintain_no_errors'] . '<br />
						<br />
						<a href="' . $scripturl . '?action=maintain">' . $txt['maintain_return'] . '</a>';
        }
        $context['raw_data'] .= '
					</td>
				</tr>
			</table>';
    } else {
        $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 = mysql_get_server_info($db_connection);
        if (empty($to_fix) || in_array('zero_ids', $to_fix)) {
            // We don't allow 0's in the IDs...
            db_query("\n\t\t\t\tUPDATE {$db_prefix}topics\n\t\t\t\tSET ID_TOPIC = NULL\n\t\t\t\tWHERE ID_TOPIC = 0", __FILE__, __LINE__);
            db_query("\n\t\t\t\tUPDATE {$db_prefix}messages\n\t\t\t\tSET ID_MSG = NULL\n\t\t\t\tWHERE ID_MSG = 0", __FILE__, __LINE__);
        }
        // Remove all topics that have zero messages in the messages table.
        if (empty($to_fix) || in_array('missing_messages', $to_fix)) {
            $resultTopic = db_query("\n\t\t\t\tSELECT t.ID_TOPIC, COUNT(m.ID_MSG) AS numMsg\n\t\t\t\tFROM {$db_prefix}topics AS t\n\t\t\t\t\tLEFT JOIN {$db_prefix}messages AS m ON (m.ID_TOPIC = t.ID_TOPIC)\n\t\t\t\tGROUP BY t.ID_TOPIC\n\t\t\t\tHAVING numMsg = 0", __FILE__, __LINE__);
            if (mysql_num_rows($resultTopic) > 0) {
                $stupidTopics = array();
                while ($topicArray = mysql_fetch_assoc($resultTopic)) {
                    $stupidTopics[] = $topicArray['ID_TOPIC'];
                }
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}topics\n\t\t\t\t\tWHERE ID_TOPIC IN (" . implode(',', $stupidTopics) . ')
					LIMIT ' . count($stupidTopics), __FILE__, __LINE__);
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_topics\n\t\t\t\t\tWHERE ID_TOPIC IN (" . implode(',', $stupidTopics) . ')', __FILE__, __LINE__);
            }
            mysql_free_result($resultTopic);
        }
        // Fix all messages that have a topic ID that cannot be found in the topics table.
        if (empty($to_fix) || in_array('missing_topics', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT\n\t\t\t\t\tm.ID_BOARD, m.ID_TOPIC, MIN(m.ID_MSG) AS myID_FIRST_MSG, MAX(m.ID_MSG) AS myID_LAST_MSG,\n\t\t\t\t\tCOUNT(*) - 1 AS myNumReplies\n\t\t\t\tFROM {$db_prefix}messages AS m\n\t\t\t\t\tLEFT JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = m.ID_TOPIC)\n\t\t\t\tWHERE t.ID_TOPIC IS NULL\n\t\t\t\tGROUP BY m.ID_TOPIC", __FILE__, __LINE__);
            while ($row = mysql_fetch_assoc($result)) {
                // Only if we don't have a reasonable idea of where to put it.
                if ($row['ID_BOARD'] == 0) {
                    createSalvageArea();
                    $row['ID_BOARD'] = $salvageBoardID;
                }
                $memberStartedID = getMsgMemberID($row['myID_FIRST_MSG']);
                $memberUpdatedID = getMsgMemberID($row['myID_LAST_MSG']);
                db_query("\n\t\t\t\t\tINSERT INTO {$db_prefix}topics\n\t\t\t\t\t\t(ID_BOARD, ID_MEMBER_STARTED, ID_MEMBER_UPDATED, ID_FIRST_MSG, ID_LAST_MSG, numReplies)\n\t\t\t\t\tVALUES ({$row['ID_BOARD']}, {$memberStartedID}, {$memberUpdatedID},\n\t\t\t\t\t\t{$row['myID_FIRST_MSG']}, {$row['myID_LAST_MSG']}, {$row['myNumReplies']})", __FILE__, __LINE__);
                $newTopicID = db_insert_id();
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}messages\n\t\t\t\t\tSET ID_TOPIC = {$newTopicID}, ID_BOARD = {$row['ID_BOARD']}\n\t\t\t\t\tWHERE ID_TOPIC = {$row['ID_TOPIC']}", __FILE__, __LINE__);
            }
            mysql_free_result($result);
        }
        // Fix all ID_FIRST_MSG, ID_LAST_MSG and numReplies in the topic table.
        if (empty($to_fix) || in_array('stats_topics', $to_fix)) {
            $resultTopic = db_query("\n\t\t\t\tSELECT\n\t\t\t\t\tt.ID_TOPIC, MIN(m.ID_MSG) AS myID_FIRST_MSG, t.ID_FIRST_MSG,\n\t\t\t\t\tMAX(m.ID_MSG) AS myID_LAST_MSG, t.ID_LAST_MSG, COUNT(m.ID_MSG) - 1 AS myNumReplies,\n\t\t\t\t\tt.numReplies\n\t\t\t\tFROM {$db_prefix}topics AS t\n\t\t\t\t\tLEFT JOIN {$db_prefix}messages AS m ON (m.ID_TOPIC = t.ID_TOPIC)\n\t\t\t\tGROUP BY t.ID_TOPIC\n\t\t\t\tHAVING ID_FIRST_MSG != myID_FIRST_MSG OR ID_LAST_MSG != myID_LAST_MSG OR numReplies != myNumReplies", __FILE__, __LINE__);
            while ($topicArray = mysql_fetch_assoc($resultTopic)) {
                $memberStartedID = getMsgMemberID($topicArray['myID_FIRST_MSG']);
                $memberUpdatedID = getMsgMemberID($topicArray['myID_LAST_MSG']);
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}topics\n\t\t\t\t\tSET ID_FIRST_MSG = '{$topicArray['myID_FIRST_MSG']}',\n\t\t\t\t\t\tID_MEMBER_STARTED = '{$memberStartedID}', ID_LAST_MSG = '{$topicArray['myID_LAST_MSG']}',\n\t\t\t\t\t\tID_MEMBER_UPDATED = '{$memberUpdatedID}', numReplies = '{$topicArray['myNumReplies']}'\n\t\t\t\t\tWHERE ID_TOPIC = {$topicArray['ID_TOPIC']}\n\t\t\t\t\tLIMIT 1", __FILE__, __LINE__);
            }
            mysql_free_result($resultTopic);
        }
        // Fix all topics that have a board ID that cannot be found in the boards table.
        if (empty($to_fix) || in_array('missing_boards', $to_fix)) {
            $resultTopics = db_query("\n\t\t\t\tSELECT t.ID_BOARD, COUNT(*) AS myNumTopics, COUNT(m.ID_MSG) AS myNumPosts\n\t\t\t\tFROM {$db_prefix}topics AS t\n\t\t\t\t\tLEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = t.ID_BOARD)\n\t\t\t\t\tLEFT JOIN {$db_prefix}messages AS m ON (m.ID_TOPIC = t.ID_TOPIC)\n\t\t\t\tWHERE b.ID_BOARD IS NULL\n\t\t\t\tGROUP BY t.ID_BOARD", __FILE__, __LINE__);
            if (mysql_num_rows($resultTopics) > 0) {
                createSalvageArea();
            }
            while ($topicArray = mysql_fetch_assoc($resultTopics)) {
                db_query("\n\t\t\t\t\tINSERT INTO {$db_prefix}boards\n\t\t\t\t\t\t(ID_CAT, name, description, numTopics, numPosts, memberGroups)\n\t\t\t\t\tVALUES ({$salvageCatID}, 'Salvaged board', '', {$topicArray['myNumTopics']}, {$topicArray['myNumPosts']}, '1')", __FILE__, __LINE__);
                $newBoardID = db_insert_id();
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}topics\n\t\t\t\t\tSET ID_BOARD = {$newBoardID}\n\t\t\t\t\tWHERE ID_BOARD = {$topicArray['ID_BOARD']}", __FILE__, __LINE__);
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}messages\n\t\t\t\t\tSET ID_BOARD = {$newBoardID}\n\t\t\t\t\tWHERE ID_BOARD = {$topicArray['ID_BOARD']}", __FILE__, __LINE__);
            }
            mysql_free_result($resultTopics);
        }
        // Fix all boards that have a cat ID that cannot be found in the cats table.
        if (empty($to_fix) || in_array('missing_categories', $to_fix)) {
            $resultBoards = db_query("\n\t\t\t\tSELECT b.ID_CAT\n\t\t\t\tFROM {$db_prefix}boards AS b\n\t\t\t\t\tLEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)\n\t\t\t\tWHERE c.ID_CAT IS NULL\n\t\t\t\tGROUP BY b.ID_CAT", __FILE__, __LINE__);
            if (mysql_num_rows($resultBoards) > 0) {
                createSalvageArea();
            }
            while ($boardArray = mysql_fetch_assoc($resultBoards)) {
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}boards\n\t\t\t\t\tSET ID_CAT = {$salvageCatID}\n\t\t\t\t\tWHERE ID_CAT = {$boardArray['ID_CAT']}", __FILE__, __LINE__);
            }
            mysql_free_result($resultBoards);
        }
        // Last step-make sure all non-guest posters still exist.
        if (empty($to_fix) || in_array('missing_posters', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT m.ID_MSG\n\t\t\t\tFROM {$db_prefix}messages AS m\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)\n\t\t\t\tWHERE m.ID_MEMBER != 0\n\t\t\t\t\tAND mem.ID_MEMBER IS NULL", __FILE__, __LINE__);
            if (mysql_num_rows($result) > 0) {
                $guestMessages = array();
                while ($row = mysql_fetch_assoc($result)) {
                    $guestMessages[] = $row['ID_MSG'];
                }
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}messages\n\t\t\t\t\tSET ID_MEMBER = 0\n\t\t\t\t\tWHERE ID_MSG IN (" . implode(',', $guestMessages) . ')
					LIMIT ' . count($guestMessages), __FILE__, __LINE__);
            }
            mysql_free_result($result);
        }
        // Fix all boards that have a parent ID that cannot be found in the boards table.
        if (empty($to_fix) || in_array('missing_parents', $to_fix)) {
            $resultParents = db_query("\n\t\t\t\tSELECT b.ID_PARENT\n\t\t\t\tFROM {$db_prefix}boards AS b\n\t\t\t\t\tLEFT JOIN {$db_prefix}boards AS p ON (p.ID_BOARD = b.ID_PARENT)\n\t\t\t\tWHERE b.ID_PARENT != 0\n\t\t\t\t\tAND (p.ID_BOARD IS NULL OR p.ID_BOARD = b.ID_BOARD)\n\t\t\t\tGROUP BY b.ID_PARENT", __FILE__, __LINE__);
            if (mysql_num_rows($resultParents) > 0) {
                createSalvageArea();
            }
            while ($parentArray = mysql_fetch_assoc($resultParents)) {
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}boards\n\t\t\t\t\tSET ID_PARENT = {$salvageBoardID}, ID_CAT = {$salvageCatID}, childLevel = 1\n\t\t\t\t\tWHERE ID_PARENT = {$parentArray['ID_PARENT']}", __FILE__, __LINE__);
            }
            mysql_free_result($resultParents);
        }
        if (empty($to_fix) || in_array('missing_polls', $to_fix)) {
            if (version_compare($mysql_version, '4.0.4') >= 0) {
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}topics AS t\n\t\t\t\t\t\tLEFT JOIN {$db_prefix}polls AS p ON (p.ID_POLL = t.ID_POLL)\n\t\t\t\t\tSET t.ID_POLL = 0\n\t\t\t\t\tWHERE t.ID_POLL != 0\n\t\t\t\t\t\tAND p.ID_POLL IS NULL", __FILE__, __LINE__);
            } else {
                $resultPolls = db_query("\n\t\t\t\t\tSELECT t.ID_POLL\n\t\t\t\t\tFROM {$db_prefix}topics AS t\n\t\t\t\t\t\tLEFT JOIN {$db_prefix}polls AS p ON (p.ID_POLL = t.ID_POLL)\n\t\t\t\t\tWHERE t.ID_POLL != 0\n\t\t\t\t\t\tAND p.ID_POLL IS NULL\n\t\t\t\t\tGROUP BY t.ID_POLL", __FILE__, __LINE__);
                $polls = array();
                while ($rowPolls = mysql_fetch_assoc($resultPolls)) {
                    $polls[] = $rowPolls['ID_POLL'];
                }
                mysql_free_result($resultPolls);
                if (!empty($polls)) {
                    db_query("\n\t\t\t\t\t\tUPDATE {$db_prefix}topics\n\t\t\t\t\t\tSET ID_POLL = 0\n\t\t\t\t\t\tWHERE ID_POLL IN (" . implode(', ', $polls) . ")\n\t\t\t\t\t\tLIMIT " . count($polls), __FILE__, __LINE__);
                }
            }
        }
        if (empty($to_fix) || in_array('missing_calendar_topics', $to_fix)) {
            if (version_compare($mysql_version, '4.0.4') >= 0) {
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}calendar AS cal\n\t\t\t\t\t\tLEFT JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = cal.ID_TOPIC)\n\t\t\t\t\tSET cal.ID_BOARD = 0, cal.ID_TOPIC = 0\n\t\t\t\t\tWHERE cal.ID_TOPIC != 0\n\t\t\t\t\t\tAND t.ID_TOPIC IS NULL", __FILE__, __LINE__);
            } else {
                $resultEvents = db_query("\n\t\t\t\t\tSELECT cal.ID_TOPIC\n\t\t\t\t\tFROM {$db_prefix}calendar AS cal\n\t\t\t\t\t\tLEFT JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = cal.ID_TOPIC)\n\t\t\t\t\tWHERE cal.ID_TOPIC != 0\n\t\t\t\t\t\tAND t.ID_TOPIC IS NULL\n\t\t\t\t\tGROUP BY cal.ID_TOPIC", __FILE__, __LINE__);
                $events = array();
                while ($rowEvents = mysql_fetch_assoc($resultEvents)) {
                    $events[] = $rowEvents['ID_TOPIC'];
                }
                mysql_free_result($resultEvents);
                if (!empty($events)) {
                    db_query("\n\t\t\t\t\t\tUPDATE {$db_prefix}calendar\n\t\t\t\t\t\tSET ID_TOPIC = 0, ID_BOARD = 0\n\t\t\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $events) . ")\n\t\t\t\t\t\tLIMIT " . count($events), __FILE__, __LINE__);
                }
            }
        }
        if (empty($to_fix) || in_array('missing_log_topics', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT lt.ID_TOPIC\n\t\t\t\tFROM {$db_prefix}log_topics AS lt\n\t\t\t\t\tLEFT JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = lt.ID_TOPIC)\n\t\t\t\tWHERE t.ID_TOPIC IS NULL\n\t\t\t\tGROUP BY lt.ID_TOPIC", __FILE__, __LINE__);
            $topics = array();
            while ($row = mysql_fetch_assoc($result)) {
                $topics[] = $row['ID_TOPIC'];
            }
            mysql_free_result($result);
            if (!empty($topics)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_topics\n\t\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $topics) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_log_topics_members', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT lt.ID_MEMBER\n\t\t\t\tFROM {$db_prefix}log_topics AS lt\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lt.ID_MEMBER)\n\t\t\t\tWHERE mem.ID_MEMBER IS NULL\n\t\t\t\tGROUP BY lt.ID_MEMBER", __FILE__, __LINE__);
            $members = array();
            while ($row = mysql_fetch_assoc($result)) {
                $members[] = $row['ID_MEMBER'];
            }
            mysql_free_result($result);
            if (!empty($members)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_topics\n\t\t\t\t\tWHERE ID_MEMBER IN (" . implode(', ', $members) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_log_boards', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT lb.ID_BOARD\n\t\t\t\tFROM {$db_prefix}log_boards AS lb\n\t\t\t\t\tLEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = lb.ID_BOARD)\n\t\t\t\tWHERE b.ID_BOARD IS NULL\n\t\t\t\tGROUP BY lb.ID_BOARD", __FILE__, __LINE__);
            $boards = array();
            while ($row = mysql_fetch_assoc($result)) {
                $boards[] = $row['ID_BOARD'];
            }
            mysql_free_result($result);
            if (!empty($boards)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_boards\n\t\t\t\t\tWHERE ID_BOARD IN (" . implode(', ', $boards) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_log_boards_members', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT lb.ID_MEMBER\n\t\t\t\tFROM {$db_prefix}log_boards AS lb\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lb.ID_MEMBER)\n\t\t\t\tWHERE mem.ID_MEMBER IS NULL\n\t\t\t\tGROUP BY lb.ID_MEMBER", __FILE__, __LINE__);
            $members = array();
            while ($row = mysql_fetch_assoc($result)) {
                $members[] = $row['ID_MEMBER'];
            }
            mysql_free_result($result);
            if (!empty($members)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_boards\n\t\t\t\t\tWHERE ID_MEMBER IN (" . implode(', ', $members) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_log_mark_read', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT lmr.ID_BOARD\n\t\t\t\tFROM {$db_prefix}log_mark_read AS lmr\n\t\t\t\t\tLEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = lmr.ID_BOARD)\n\t\t\t\tWHERE b.ID_BOARD IS NULL\n\t\t\t\tGROUP BY lmr.ID_BOARD", __FILE__, __LINE__);
            $boards = array();
            while ($row = mysql_fetch_assoc($result)) {
                $boards[] = $row['ID_BOARD'];
            }
            mysql_free_result($result);
            if (!empty($boards)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_mark_read\n\t\t\t\t\tWHERE ID_BOARD IN (" . implode(', ', $boards) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_log_mark_read_members', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT lmr.ID_MEMBER\n\t\t\t\tFROM {$db_prefix}log_mark_read AS lmr\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lmr.ID_MEMBER)\n\t\t\t\tWHERE mem.ID_MEMBER IS NULL\n\t\t\t\tGROUP BY lmr.ID_MEMBER", __FILE__, __LINE__);
            $members = array();
            while ($row = mysql_fetch_assoc($result)) {
                $members[] = $row['ID_MEMBER'];
            }
            mysql_free_result($result);
            if (!empty($members)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_mark_read\n\t\t\t\t\tWHERE ID_MEMBER IN (" . implode(', ', $members) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_pms', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT pmr.ID_PM\n\t\t\t\tFROM {$db_prefix}pm_recipients AS pmr\n\t\t\t\t\tLEFT JOIN {$db_prefix}personal_messages AS pm ON (pm.ID_PM = pmr.ID_PM)\n\t\t\t\tWHERE pm.ID_PM IS NULL\n\t\t\t\tGROUP BY pmr.ID_PM", __FILE__, __LINE__);
            $pms = array();
            while ($row = mysql_fetch_assoc($result)) {
                $pms[] = $row['ID_PM'];
            }
            mysql_free_result($result);
            if (!empty($pms)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}pm_recipients\n\t\t\t\t\tWHERE ID_PM IN (" . implode(', ', $pms) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_recipients', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT pmr.ID_MEMBER\n\t\t\t\tFROM {$db_prefix}pm_recipients AS pmr\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = pmr.ID_MEMBER)\n\t\t\t\tWHERE pmr.ID_MEMBER != 0\n\t\t\t\t\tAND mem.ID_MEMBER IS NULL\n\t\t\t\tGROUP BY pmr.ID_MEMBER", __FILE__, __LINE__);
            $members = array();
            while ($row = mysql_fetch_assoc($result)) {
                $members[] = $row['ID_MEMBER'];
            }
            mysql_free_result($result);
            if (!empty($members)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}pm_recipients\n\t\t\t\t\tWHERE ID_MEMBER IN (" . implode(', ', $members) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_senders', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT pm.ID_PM\n\t\t\t\tFROM {$db_prefix}personal_messages AS pm\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = pm.ID_MEMBER_FROM)\n\t\t\t\tWHERE pm.ID_MEMBER_FROM != 0\n\t\t\t\t\tAND mem.ID_MEMBER IS NULL", __FILE__, __LINE__);
            if (mysql_num_rows($result) > 0) {
                $guestMessages = array();
                while ($row = mysql_fetch_assoc($result)) {
                    $guestMessages[] = $row['ID_PM'];
                }
                db_query("\n\t\t\t\t\tUPDATE {$db_prefix}personal_messages\n\t\t\t\t\tSET ID_MEMBER_FROM = 0\n\t\t\t\t\tWHERE ID_PM IN (" . implode(',', $guestMessages) . ')
					LIMIT ' . count($guestMessages), __FILE__, __LINE__);
            }
            mysql_free_result($result);
        }
        if (empty($to_fix) || in_array('missing_notify_members', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT ln.ID_MEMBER\n\t\t\t\tFROM {$db_prefix}log_notify AS ln\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = ln.ID_MEMBER)\n\t\t\t\tWHERE mem.ID_MEMBER IS NULL\n\t\t\t\tGROUP BY ln.ID_MEMBER", __FILE__, __LINE__);
            $members = array();
            while ($row = mysql_fetch_assoc($result)) {
                $members[] = $row['ID_MEMBER'];
            }
            mysql_free_result($result);
            if (!empty($members)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_notify\n\t\t\t\t\tWHERE ID_MEMBER IN (" . implode(', ', $members) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_cached_subject', $to_fix)) {
            $request = db_query("\n\t\t\t\tSELECT t.ID_TOPIC, m.subject\n\t\t\t\tFROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)\n\t\t\t\t\tLEFT JOIN {$db_prefix}log_search_subjects AS lss ON (lss.ID_TOPIC = t.ID_TOPIC)\n\t\t\t\tWHERE m.ID_MSG = t.ID_FIRST_MSG\n\t\t\t\t\tAND lss.ID_TOPIC IS NULL", __FILE__, __LINE__);
            $insertRows = array();
            while ($row = mysql_fetch_assoc($request)) {
                foreach (text2words($row['subject']) as $word) {
                    $insertRows[] = "'{$word}', {$row['ID_TOPIC']}";
                }
                if (count($insertRows) > 500) {
                    db_query("\n\t\t\t\t\t\tINSERT IGNORE INTO {$db_prefix}log_search_subjects\n\t\t\t\t\t\t\t(word, ID_TOPIC)\n\t\t\t\t\t\tVALUES (" . implode('),
							(', $insertRows) . ")", __FILE__, __LINE__);
                    $insertRows = array();
                }
            }
            mysql_free_result($request);
            if (!empty($insertRows)) {
                db_query("\n\t\t\t\t\tINSERT IGNORE INTO {$db_prefix}log_search_subjects\n\t\t\t\t\t\t(word, ID_TOPIC)\n\t\t\t\t\tVALUES (" . implode('),
						(', $insertRows) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_topic_for_cache', $to_fix)) {
            $request = db_query("\n\t\t\t\tSELECT lss.ID_TOPIC\n\t\t\t\tFROM {$db_prefix}log_search_subjects AS lss\n\t\t\t\t\tLEFT JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = lss.ID_TOPIC)\n\t\t\t\tWHERE t.ID_TOPIC IS NULL\n\t\t\t\tGROUP BY lss.ID_TOPIC", __FILE__, __LINE__);
            $deleteTopics = array();
            while ($row = mysql_fetch_assoc($request)) {
                $deleteTopics[] = $row['ID_TOPIC'];
            }
            mysql_free_result($request);
            if (!empty($deleteTopics)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_search_subjects\n\t\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $deleteTopics) . ')', __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_member_vote', $to_fix)) {
            $result = db_query("\n\t\t\t\tSELECT lp.ID_MEMBER\n\t\t\t\tFROM {$db_prefix}log_polls AS lp\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lp.ID_MEMBER)\n\t\t\t\tWHERE mem.ID_MEMBER IS NULL\n\t\t\t\tGROUP BY lp.ID_MEMBER", __FILE__, __LINE__);
            $members = array();
            while ($row = mysql_fetch_assoc($result)) {
                $members[] = $row['ID_MEMBER'];
            }
            mysql_free_result($result);
            if (!empty($members)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_polls\n\t\t\t\t\tWHERE ID_MEMBER IN (" . implode(', ', $members) . ")", __FILE__, __LINE__);
            }
        }
        if (empty($to_fix) || in_array('missing_log_poll_vote', $to_fix)) {
            $request = db_query("\n\t\t\t\tSELECT lp.ID_POLL\n\t\t\t\tFROM {$db_prefix}log_polls AS lp\n\t\t\t\t\tLEFT JOIN {$db_prefix}polls AS p ON (p.ID_POLL = lp.ID_POLL)\n\t\t\t\tWHERE p.ID_POLL IS NULL\n\t\t\t\tGROUP BY lp.ID_POLL", __FILE__, __LINE__);
            $polls = array();
            while ($row = mysql_fetch_assoc($request)) {
                $polls[] = $row['ID_POLL'];
            }
            mysql_free_result($request);
            if (!empty($polls)) {
                db_query("\n\t\t\t\t\tDELETE FROM {$db_prefix}log_polls\n\t\t\t\t\tWHERE ID_POLL IN (" . implode(', ', $polls) . ")", __FILE__, __LINE__);
            }
        }
        updateStats('message');
        updateStats('topic');
        updateStats('calendar');
        $context['raw_data'] = '
			<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tborder">
				<tr class="titlebg">
					<td>' . $txt['smf86'] . '</td>
				</tr><tr>
					<td class="windowbg">
						' . $txt['smf92'] . '<br />
						<br />
						<a href="' . $scripturl . '?action=maintain">' . $txt['maintain_return'] . '</a>
					</td>
				</tr>
			</table>';
        $_SESSION['repairboards_to_fix'] = null;
        $_SESSION['repairboards_to_fix2'] = null;
    }
}
Exemple #24
0
function AdminSettings()
{
    global $context, $txt, $mbname, $db_prefix, $scripturl;
    isAllowedTo('admin_forum');
    adminIndex('trader_settings');
    $context['page_title'] = $mbname . ' - ' . $txt['smftrader_title'] . ' - ' . $txt['smftrader_text_settings'];
    $context['sub_template'] = 'settings';
    $context['start'] = (int) $_REQUEST['start'];
    $dbresult = db_query("\n\tSELECT \n\t\tCOUNT(*) AS total \n\tFROM {$db_prefix}feedback \n\tWHERE approved = 0", __FILE__, __LINE__);
    $row = mysql_fetch_assoc($dbresult);
    $total = $row['total'];
    mysql_free_result($dbresult);
    $dbresult = db_query("\n\tSELECT \n\tf.saletype, f.feedbackid, f.FeedBackMEMBER_ID,  f.topicurl, f.comment_short,\n\tf.salevalue, f.saledate, m.realName, f.ID_MEMBER, u.realName mainName \n\tFROM ({$db_prefix}feedback AS f)\n\tLEFT JOIN {$db_prefix}members AS m ON (f.FeedBackMEMBER_ID = m.ID_MEMBER)\n\tLEFT JOIN {$db_prefix}members AS u ON (f.ID_MEMBER= u.ID_MEMBER)\n\tWHERE f.approved = 0 LIMIT {$context['start']},10", __FILE__, __LINE__);
    $context['trader_appoval'] = array();
    while ($row = mysql_fetch_assoc($dbresult)) {
        $context['trader_appoval'][] = $row;
    }
    mysql_free_result($dbresult);
    $context['page_index'] = constructPageIndex($scripturl . '?action=trader;sa=admin', $_REQUEST['start'], $total, 10);
}
Exemple #25
0
function ManageAttachments()
{
    global $txt, $db_prefix, $modSettings, $scripturl, $context, $options;
    // You have to be able to moderate the forum to do this.
    isAllowedTo('manage_attachments');
    // Show the administration bar, etc.
    adminIndex('manage_attachments');
    $context['template_layers'][] = 'manage_files';
    // If they want to delete attachment(s), delete them. (otherwise fall through..)
    $subActions = array('attachments' => 'ManageAttachmentSettings', 'avatars' => 'ManageAvatarSettings', 'browse' => 'BrowseFiles', 'byAge' => 'RemoveAttachmentByAge', 'bySize' => 'RemoveAttachmentBySize', 'maintenance' => 'MaintainFiles', 'moveAvatars' => 'MoveAvatars', 'repair' => 'RepairAttachments', 'remove' => 'RemoveAttachment', 'removeall' => 'RemoveAllAttachments');
    loadTemplate('ManageAttachments');
    if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
        $subActions[$_REQUEST['sa']]();
    } else {
        ManageAttachmentSettings();
    }
}
Exemple #26
0
function ModifyFeatureSettings()
{
    global $context, $txt, $scripturl, $modSettings, $sourcedir;
    // You need to be an admin to edit settings!
    isAllowedTo('admin_forum');
    // All the admin bar, to make it right.
    adminIndex('edit_mods_settings');
    loadLanguage('Help');
    loadLanguage('ModSettings');
    // Will need the utility functions from here.
    require_once $sourcedir . '/ManageServer.php';
    $context['page_title'] = $txt['modSettings_title'];
    $context['sub_template'] = 'show_settings';
    $subActions = array('basic' => 'ModifyBasicSettings', 'layout' => 'ModifyLayoutSettings', 'karma' => 'ModifyKarmaSettings');
    // By default do the basic settings.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'basic';
    $context['sub_action'] = $_REQUEST['sa'];
    // Load up all the tabs...
    $context['admin_tabs'] = array('title' => &$txt['modSettings_title'], 'help' => 'modsettings', 'description' => $txt['smf3'], 'tabs' => array('basic' => array('title' => $txt['mods_cat_features'], 'href' => $scripturl . '?action=featuresettings;sa=basic;sesc=' . $context['session_id']), 'layout' => array('title' => $txt['mods_cat_layout'], 'href' => $scripturl . '?action=featuresettings;sa=layout;sesc=' . $context['session_id']), 'karma' => array('title' => $txt['smf293'], 'href' => $scripturl . '?action=featuresettings;sa=karma;sesc=' . $context['session_id'], 'is_last' => true)));
    // Select the right tab based on the sub action.
    if (isset($context['admin_tabs']['tabs'][$context['sub_action']])) {
        $context['admin_tabs']['tabs'][$context['sub_action']]['is_selected'] = true;
    }
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']]();
}
Exemple #27
0
function TagsSettings()
{
    global $context, $txt, $mbname;
    adminIndex('tags_settings');
    // Check permission
    isAllowedTo('smftags_manage');
    $context['sub_template'] = 'admin_settings';
    $context['page_title'] = $mbname . ' - ' . $txt['smftags_settings'];
}
Exemple #28
0
function EditFeed()
{
    global $txt, $mbname, $context, $db_prefix;
    // Get the Feed ID
    $id = (int) $_REQUEST['id'];
    if (empty($id)) {
        fatal_error($txt['feedposter_nofeedselected'], false);
    }
    adminIndex('feeds_settings');
    // Show the boards for the feeds.
    $context['feed_boards'] = array('');
    $request = db_query("\n\tSELECT \n\t\tb.ID_BOARD, b.name AS bName, c.name AS cName \n\tFROM {$db_prefix}boards AS b, {$db_prefix}categories AS c \n\tWHERE b.ID_CAT = c.ID_CAT ORDER BY c.catOrder, b.boardOrder", __FILE__, __LINE__);
    while ($row = mysql_fetch_assoc($request)) {
        $context['feed_boards'][$row['ID_BOARD']] = $row['cName'] . ' - ' . $row['bName'];
    }
    mysql_free_result($request);
    // Get the Feed Data
    $context['feed'] = array();
    $request = db_query("\n\tSELECT \n\t\tID_FEED, ID_BOARD, feedurl, title, postername, enabled, html, ID_MEMBER, locked, \n\t\tarticlelink, topicprefix, numbertoimport, importevery,markasread, msgicon, footer, id_topic   \n\tFROM {$db_prefix}feedbot \n\tWHERE ID_FEED = {$id} LIMIT 1", __FILE__, __LINE__);
    $row = mysql_fetch_assoc($request);
    $context['feed'] = $row;
    mysql_free_result($request);
    // Load Message Icons
    $context['msg_icons'] = array();
    $result = db_query("SELECT title, filename\n\t\t\t\tFROM {$db_prefix}message_icons\n\t\t\t\t", __FILE__, __LINE__);
    while ($row = mysql_fetch_assoc($result)) {
        $context['msg_icons'][] = $row;
    }
    // Set the page title
    $context['page_title'] = $mbname . ' - ' . $txt['feedposter_editfeed'];
    $context['sub_template'] = 'editfeed';
}
Exemple #29
0
function Ban()
{
    global $context, $txt, $scripturl;
    isAllowedTo('manage_bans');
    // Boldify "Ban Members" on the admin bar.
    adminIndex('ban_members');
    loadTemplate('ManageBans');
    $subActions = array('add' => 'BanEdit', 'browse' => 'BanBrowseTriggers', 'edittrigger' => 'BanEditTrigger', 'edit' => 'BanEdit', 'list' => 'BanList', 'log' => 'BanLog');
    // 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['admin_tabs'] = array('title' => &$txt['ban_title'], 'help' => 'ban_members', 'description' => $txt['ban_description'], 'tabs' => array('list' => array('title' => $txt['ban_edit_list'], 'description' => $txt['ban_description'], 'href' => $scripturl . '?action=ban;sa=list', 'is_selected' => $_REQUEST['sa'] == 'list' || $_REQUEST['sa'] == 'edit' || $_REQUEST['sa'] == 'edittrigger'), 'add' => array('title' => $txt['ban_add_new'], 'description' => $txt['ban_description'], 'href' => $scripturl . '?action=ban;sa=add', 'is_selected' => $_REQUEST['sa'] == 'add'), 'browse' => array('title' => $txt['ban_trigger_browse'], 'description' => $txt['ban_trigger_browse_description'], 'href' => $scripturl . '?action=ban;sa=browse', 'is_selected' => $_REQUEST['sa'] == 'browse'), 'register' => array('title' => $txt['ban_log'], 'description' => $txt['ban_log_description'], 'href' => $scripturl . '?action=ban;sa=log', 'is_selected' => $_REQUEST['sa'] == 'log', 'is_last' => true)));
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']]();
}
Exemple #30
0
function ViewModlog()
{
    global $db_prefix, $txt, $modSettings, $context, $scripturl;
    isAllowedTo('admin_forum');
    loadTemplate('Modlog');
    adminIndex('view_moderation_log');
    $context['page_title'] = $txt['modlog_view'];
    // The number of entries to show per page of log file.
    $displaypage = 30;
    // Amount of hours that must pass before allowed to delete file.
    $hoursdisable = 24;
    // Handle deletion...
    if (isset($_POST['removeall'])) {
        db_query("\n\t\t\tDELETE FROM {$db_prefix}log_actions\n\t\t\tWHERE logtime < " . (time() - $hoursdisable * 3600), __FILE__, __LINE__);
    } elseif (!empty($_POST['remove']) && isset($_POST['delete'])) {
        db_query("\n\t\t\tDELETE FROM {$db_prefix}log_actions\n\t\t\tWHERE ID_ACTION IN ('" . implode("', '", array_unique($_POST['delete'])) . "')\n\t\t\t\tAND logTime < " . (time() - $hoursdisable * 3600), __FILE__, __LINE__);
    }
    // Pass order and direction variables to template so they can be used after a remove command.
    $context['dir'] = isset($_REQUEST['d']) ? ';d' : '';
    $context['sort_direction'] = !isset($_REQUEST['d']) ? 'down' : 'up';
    // Do the column stuff!
    $context['columns'] = array('action' => array('sql' => 'lm.action', 'label' => $txt['modlog_action']), 'time' => array('sql' => 'lm.logTime', 'label' => $txt['modlog_date']), 'member' => array('sql' => 'mem.realName', 'label' => $txt['modlog_member']), 'group' => array('sql' => 'mg.groupName', 'label' => $txt['modlog_position']), 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']));
    // Setup the direction stuff...
    $context['order'] = isset($_REQUEST['order']) && isset($context['columns'][$_REQUEST['order']]) ? $_REQUEST['order'] : 'time';
    $orderType = $context['columns'][$context['order']]['sql'];
    // If we're coming from a search, get the variables.
    if (isset($_REQUEST['params'])) {
        $search_params = base64_decode(strtr($_REQUEST['params'], array(' ' => '+')));
        $search_params = @unserialize($search_params);
        // To be sure, let's slash all the elements.
        foreach ($search_params as $key => $value) {
            $search_params[$key] = addslashes($value);
        }
    }
    // This array houses all the valid search types.
    $searchTypes = array('action' => array('sql' => 'lm.action', 'label' => $txt['modlog_action']), 'member' => array('sql' => 'mem.realName', 'label' => $txt['modlog_member']), 'group' => array('sql' => 'mg.groupName', 'label' => $txt['modlog_position']), 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']));
    if (!isset($search_params['string']) || !empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search']) {
        $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
    } else {
        $search_params_string = $search_params['string'];
    }
    if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) {
        $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
    } else {
        $search_params_type = $search_params['type'];
    }
    $search_params_column = $searchTypes[$search_params_type]['sql'];
    $search_params = array('string' => $search_params_string, 'type' => $search_params_type);
    // Setup the search context.
    $context['search_params'] = empty($search_params['string']) ? '' : base64_encode(serialize($search_params));
    $context['search'] = array('string' => stripslashes($search_params['string']), 'type' => $search_params['type'], 'label' => $searchTypes[$search_params_type]['label']);
    // Provide extra information about each column - the link, whether it's selected, etc.
    foreach ($context['columns'] as $col => $dummy) {
        $context['columns'][$col]['href'] = $scripturl . '?action=modlog;order=' . $col . ';start=0' . (empty($context['search_params']) ? '' : ';params=' . $context['search_params']);
        if (!isset($_REQUEST['d']) && $col == $context['order']) {
            $context['columns'][$col]['href'] .= ';d';
        }
        $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '">' . $context['columns'][$col]['label'] . '</a>';
        $context['columns'][$col]['selected'] = $context['order'] == $col;
    }
    // This text array holds all the formatting for the supported reporting type.
    $descriptions = array('lock' => $txt['modlog_ac_locked'], 'sticky' => $txt['modlog_ac_stickied'], 'modify' => $txt['modlog_ac_modified'], 'merge' => $txt['modlog_ac_merged'], 'split' => $txt['modlog_ac_split'], 'move' => $txt['modlog_ac_moved'], 'remove' => $txt['modlog_ac_removed'], 'delete' => $txt['modlog_ac_deleted'], 'delete_member' => $txt['modlog_ac_deleted_member'], 'ban' => $txt['modlog_ac_banned'], 'news' => $txt['modlog_ac_news'], 'profile' => $txt['modlog_ac_profile'], 'pruned' => $txt['modlog_ac_pruned']);
    // If they are searching by action, then we must do some manual intervention to search in their language!
    if ($search_params['type'] == 'action' && !empty($search_params['string'])) {
        // For the moment they can only search for ONE action!
        foreach ($descriptions as $key => $text) {
            if (strpos($text, $search_params['string']) !== false) {
                $search_params['string'] = $key;
                break;
            }
        }
    }
    // Count the amount of entries in total for pagination.
    $result = db_query("\n\t\tSELECT COUNT(*)\n\t\tFROM {$db_prefix}log_actions AS lm\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lm.ID_MEMBER)\n\t\t\tLEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))" . (!empty($search_params['string']) ? "\n\t\tWHERE INSTR({$search_params_column}, '{$search_params['string']}')" : ''), __FILE__, __LINE__);
    list($context['entry_count']) = mysql_fetch_row($result);
    mysql_free_result($result);
    // Create the page index.
    $context['page_index'] = constructPageIndex($scripturl . '?action=modlog;order=' . $context['order'] . $context['dir'] . (!empty($context['search_params']) ? ';params=' . $context['search_params'] : ''), $_REQUEST['start'], $context['entry_count'], $displaypage);
    $context['start'] = $_REQUEST['start'];
    // Here we have the query getting the log details.
    $result = db_query("\n\t\tSELECT\n\t\t\tlm.ID_ACTION, lm.ID_MEMBER, lm.ip, lm.logTime, lm.action, lm.extra,\n\t\t\tmem.realName, mg.groupName\n\t\tFROM {$db_prefix}log_actions AS lm\n\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lm.ID_MEMBER)\n\t\t\tLEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))" . (!empty($search_params['string']) ? "\n\t\tWHERE INSTR({$search_params_column}, '{$search_params['string']}')" : '') . "\n\t\tORDER BY {$orderType}" . (isset($_REQUEST['d']) ? '' : ' DESC') . "\n\t\tLIMIT {$context['start']}, {$displaypage}", __FILE__, __LINE__);
    // Arrays for decoding objects into.
    $topics = array();
    $boards = array();
    $members = array();
    $context['entries'] = array();
    while ($row = mysql_fetch_assoc($result)) {
        $row['extra'] = unserialize($row['extra']);
        // Corrupt?
        $row['extra'] = is_array($row['extra']) ? $row['extra'] : array();
        // Is this associated with a topic?
        if (isset($row['extra']['topic'])) {
            $topics[(int) $row['extra']['topic']][] = $row['ID_ACTION'];
        }
        if (isset($row['extra']['new_topic'])) {
            $topics[(int) $row['extra']['new_topic']][] = $row['ID_ACTION'];
        }
        // How about a member?
        if (isset($row['extra']['member'])) {
            $members[(int) $row['extra']['member']][] = $row['ID_ACTION'];
        }
        // Associated with a board?
        if (isset($row['extra']['board_to'])) {
            $boards[(int) $row['extra']['board_to']][] = $row['ID_ACTION'];
        }
        if (isset($row['extra']['board_from'])) {
            $boards[(int) $row['extra']['board_from']][] = $row['ID_ACTION'];
        }
        // IP Info?
        if (isset($row['extra']['ip_range'])) {
            $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>';
        }
        // Email?
        if (isset($row['extra']['email'])) {
            $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
        }
        // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details.
        $context['entries'][$row['ID_ACTION']] = array('id' => $row['ID_ACTION'], 'ip' => $row['ip'], 'position' => $row['groupName'], 'moderator' => array('id' => $row['ID_MEMBER'], 'name' => $row['realName'], 'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>'), 'time' => timeformat($row['logTime']), 'timestamp' => forum_time(true, $row['logTime']), 'editable' => time() > $row['logTime'] + $hoursdisable * 3600, 'extra' => $row['extra'], 'action' => isset($descriptions[$row['action']]) ? $descriptions[$row['action']] : $row['action']);
    }
    mysql_free_result($result);
    if (!empty($boards)) {
        $request = db_query("\n\t\t\tSELECT ID_BOARD, name\n\t\t\tFROM {$db_prefix}boards\n\t\t\tWHERE ID_BOARD IN (" . implode(', ', array_keys($boards)) . ")\n\t\t\tLIMIT " . count(array_keys($boards)), __FILE__, __LINE__);
        while ($row = mysql_fetch_assoc($request)) {
            foreach ($boards[$row['ID_BOARD']] as $action) {
                // Make the board number into a link - dealing with moving too.
                if ($context['entries'][$action]['extra']['board_to'] == $row['ID_BOARD']) {
                    $context['entries'][$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '">' . $row['name'] . '</a>';
                } elseif ($context['entries'][$action]['extra']['board_from'] == $row['ID_BOARD']) {
                    $context['entries'][$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '">' . $row['name'] . '</a>';
                }
            }
        }
        mysql_free_result($request);
    }
    if (!empty($topics)) {
        $request = db_query("\n\t\t\tSELECT ms.subject, t.ID_TOPIC\n\t\t\tFROM ({$db_prefix}topics AS t, {$db_prefix}messages AS ms)\n\t\t\tWHERE t.ID_TOPIC IN (" . implode(', ', array_keys($topics)) . ")\n\t\t\t\tAND ms.ID_MSG = t.ID_FIRST_MSG\n\t\t\tLIMIT " . count(array_keys($topics)), __FILE__, __LINE__);
        while ($row = mysql_fetch_assoc($request)) {
            foreach ($topics[$row['ID_TOPIC']] as $action) {
                $this_action =& $context['entries'][$action];
                // This isn't used in the current theme.
                $this_action['topic'] = array('id' => $row['ID_TOPIC'], 'subject' => $row['subject'], 'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['subject'] . '</a>');
                // Make the topic number into a link - dealing with splitting too.
                if ($this_action['extra']['topic'] == $row['ID_TOPIC']) {
                    $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
                } elseif ($this_action['extra']['new_topic'] == $row['ID_TOPIC']) {
                    $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
                }
            }
        }
        mysql_free_result($request);
    }
    if (!empty($members)) {
        $request = db_query("\n\t\t\tSELECT realName, ID_MEMBER\n\t\t\tFROM {$db_prefix}members\n\t\t\tWHERE ID_MEMBER IN (" . implode(', ', array_keys($members)) . ")\n\t\t\tLIMIT " . count(array_keys($members)), __FILE__, __LINE__);
        while ($row = mysql_fetch_assoc($request)) {
            foreach ($members[$row['ID_MEMBER']] as $action) {
                // Not used currently.
                $context['entries'][$action]['member'] = array('id' => $row['ID_MEMBER'], 'name' => $row['realName'], 'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>');
                // Make the member number into a name.
                $context['entries'][$action]['extra']['member'] = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
            }
        }
        mysql_free_result($request);
    }
}