/**
  * This action handler method displays and allows to change avatar settings.
  *
  * - Called by index.php?action=admin;area=manageattachments;sa=avatars.
  *
  * @uses 'avatars' sub-template.
  */
 public function action_avatarSettings_display()
 {
     global $txt, $context, $scripturl;
     // Initialize the form
     $this->_initAvatarSettingsForm();
     $config_vars = $this->_avatarSettings->settings();
     // Saving avatar settings?
     if (isset($_GET['save'])) {
         checkSession();
         call_integration_hook('integrate_save_avatar_settings');
         // Disable if invalid values would result
         if (isset($_POST['custom_avatar_enabled']) && $_POST['custom_avatar_enabled'] == 1 && (empty($_POST['custom_avatar_dir']) || empty($_POST['custom_avatar_url']))) {
             $_POST['custom_avatar_enabled'] = 0;
         }
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=manageattachments;sa=avatars');
     }
     // Attempt to figure out if the admin is trying to break things.
     $context['settings_save_onclick'] = 'return document.getElementById(\'custom_avatar_enabled\').value == 1 && (document.getElementById(\'custom_avatar_dir\').value == \'\' || document.getElementById(\'custom_avatar_url\').value == \'\') ? confirm(\'' . $txt['custom_avatar_check_empty'] . '\') : true;';
     // We need this for the in-line permissions
     createToken('admin-mp');
     // Prepare the context.
     $context['post_url'] = $scripturl . '?action=admin;area=manageattachments;save;sa=avatars';
     Settings_Form::prepare_db($config_vars);
     // Add a layer for the javascript.
     Template_Layers::getInstance()->add('avatar_settings');
     $context['sub_template'] = 'show_settings';
 }
function sportal_admin_state_change()
{
    checkSession('get');
    if (!empty($_REQUEST['block_id'])) {
        $id = (int) $_REQUEST['block_id'];
    } elseif (!empty($_REQUEST['category_id'])) {
        $id = (int) $_REQUEST['category_id'];
    } elseif (!empty($_REQUEST['article_id'])) {
        $id = (int) $_REQUEST['article_id'];
    } else {
        fatal_lang_error('error_sp_id_empty', false);
    }
    changeState($_REQUEST['type'], $id);
    if ($_REQUEST['type'] == 'block') {
        $sides = array(1 => 'left', 2 => 'top', 3 => 'bottom', 4 => 'right');
        $list = !empty($_GET['redirect']) && isset($sides[$_GET['redirect']]) ? $sides[$_GET['redirect']] : 'list';
        redirectexit('action=admin;area=portalblocks;sa=' . $list);
    } elseif ($_REQUEST['type'] == 'category') {
        redirectexit('action=admin;area=portalarticles;sa=categories');
    } elseif ($_REQUEST['type'] == 'article') {
        redirectexit('action=admin;area=portalarticles;sa=articles');
    } else {
        redirectexit('action=admin;area=portalconfig');
    }
}
 /**
  * Adminstration page for topics: allows to display and set settings related to topics.
  *
  * Requires the admin_forum permission.
  * Accessed from ?action=admin;area=postsettings;sa=topics.
  * @uses Admin template, edit_topic_settings sub-template.
  */
 public function action_topicSettings_display()
 {
     global $context, $txt, $scripturl;
     // Initialize the form
     $this->_initTopicSettingsForm();
     // Retrieve the current config settings
     $config_vars = $this->_topicSettings->settings();
     // Setup the template.
     $context['sub_template'] = 'show_settings';
     // Are we saving them - are we??
     if (isset($_GET['save'])) {
         // Security checks
         checkSession();
         // Notify addons and integrations of the settings change.
         call_integration_hook('integrate_save_topic_settings');
         // Save the result!
         Settings_Form::save_db($config_vars);
         // We're done here, pal.
         redirectexit('action=admin;area=postsettings;sa=topics');
     }
     // Set up the template stuff nicely.
     $context['post_url'] = $scripturl . '?action=admin;area=postsettings;save;sa=topics';
     $context['settings_title'] = $txt['manageposts_topic_settings'];
     // Prepare the settings
     Settings_Form::prepare_db($config_vars);
 }
Example #4
0
/**
 * Config array for chaning the karma settings
 * Accessed  from ?action=admin;area=featuresettings;sa=karma;
 *
 * @param $return_config
 */
function ModifyKarmaSettings($return_config = false)
{
    global $txt, $scripturl, $context, $modSettings;
    loadLanguage('Karma+ManageKarma');
    if (empty($modSettings['karmaMode'])) {
        $config_vars = array(array('select', 'karmaMode', explode('|', $txt['karma_options'])));
    } else {
        $config_vars = array(array('select', 'karmaMode', explode('|', $txt['karma_options'])), '', array('int', 'karmaMinPosts', 6, 'postinput' => strtolower($txt['posts'])), array('float', 'karmaWaitTime', 6, 'postinput' => $txt['hours']), array('check', 'karmaTimeRestrictAdmins'));
    }
    call_integration_hook('integrate_karma_settings', array(&$config_vars));
    if ($return_config) {
        return $config_vars;
    }
    // Saving?
    if (isset($_GET['save'])) {
        checkSession();
        call_integration_hook('integrate_save_karma_settings');
        saveDBSettings($config_vars);
        $_SESSION['adm-save'] = true;
        redirectexit('action=admin;area=featuresettings;sa=karma');
    }
    $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=karma';
    $context['settings_title'] = $txt['karma'];
    loadLanguage('ManageKarma');
    prepareDBSettingContext($config_vars);
}
Example #5
0
 public function fbc_friend()
 {
     global $context, $fbuser, $Url, $FacebookId, $fb_hook_object, $friends, $scripturl, $fb_object, $curOffset;
     $context['sub_template'] = 'fbc_friends';
     $context['fb_do'] = 'friends';
     SAFacebookhooks::face_init();
     $facebook = new Facebook(array('appId' => $fb_hook_object->modSettings['fb_app_id'], 'secret' => $fb_hook_object->modSettings['fb_app_secret']));
     $Url = $facebook->getLoginUrl(array('redirect_uri' => $scripturl . '?action=facebook', 'scope' => 'email,publish_actions'));
     $fb_object->fbc_cons_pages('friends', 32);
     if (!$fb_hook_object->modSettings['fb_mode2']) {
         redirectexit();
     }
     $fbuser = $FacebookId;
     if ($fbuser) {
         //Try it!!!!!
         try {
             //These api calls can be slow so were only do it if needed
             if (empty($_SESSION['safbfriends'][$curOffset])) {
                 $_SESSION['safbfriends'][$curOffset] = $facebook->api('/me/friends?offset=' . $curOffset . '&limit=32');
             }
             $friends = $_SESSION['safbfriends'][$curOffset];
         } catch (FacebookApiException $e) {
             //Throw it!!!!!
             fatal_error($e, false);
         }
     }
 }
function activateAccount($memID)
{
    global $sourcedir, $context, $user_profile, $modSettings;
    isAllowedTo('moderate_forum');
    if (isset($_REQUEST['save']) && isset($user_profile[$memID]['is_activated']) && $user_profile[$memID]['is_activated'] != 1) {
        // If we are approving the deletion of an account, we do something special ;)
        if ($user_profile[$memID]['is_activated'] == 4) {
            require_once $sourcedir . '/Subs-Members.php';
            deleteMembers($context['id_member']);
            redirectexit();
        }
        // Let the integrations know of the activation.
        call_integration_hook('integrate_activate', array($user_profile[$memID]['member_name']));
        // Actually update this member now, as it guarantees the unapproved count can't get corrupted.
        updateMemberData($context['id_member'], array('is_activated' => $user_profile[$memID]['is_activated'] >= 10 ? 11 : 1, 'validation_code' => ''));
        // If we are doing approval, update the stats for the member just in case.
        if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 13, 14))) {
            updateSettings(array('unapprovedMembers' => $modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0));
        }
        // Make sure we update the stats too.
        updateStats('member', false);
    }
    // Leave it be...
    redirectexit('action=profile;u=' . $memID . ';area=summary');
}
Example #7
0
function save()
{
    global $boarddir, $context;
    checkSession('post');
    $styleheaders = $_POST['headers'];
    $stylefooters = $_POST['footers'];
    $styleheaders = stripslashes($styleheaders);
    $stylefooters = stripslashes($stylefooters);
    //Save Headers
    $filename = $boarddir . '/smfheader.txt';
    @chmod($filename, 0644);
    if (!($handle = fopen($filename, 'w'))) {
        fatal_error('Can not open' . $filename . '.', false);
    }
    // Write the headers to our opened file.
    if (!fwrite($handle, $styleheaders)) {
        //fatal_error('Can not write to' . $filename   . '.',false);
    }
    fclose($handle);
    //Save Footers
    $filename = $boarddir . '/smffooter.txt';
    @chmod($filename, 0644);
    if (!($handle = fopen($filename, 'w'))) {
        fatal_error('Can not open' . $filename . '.', false);
    }
    // Write the headers to our opened file.
    if (!fwrite($handle, $stylefooters)) {
        //fatal_error('Can not write to' . $filename   . '.',false);
    }
    fclose($handle);
    redirectexit('action=globalhf;sesc=' . $context['session_id']);
}
Example #8
0
/**
 * Edit some general settings related to the search function.
 * Called by ?action=admin;area=managesearch;sa=settings.
 * Requires the admin_forum permission.
 *
 * @param $return_config
 * @uses ManageSearch template, 'modify_settings' sub-template.
 */
function EditSearchSettings($return_config = false)
{
    global $txt, $context, $scripturl, $sourcedir, $modSettings;
    // What are we editing anyway?
    $config_vars = array(array('permissions', 'search_posts'), array('check', 'simpleSearch'), array('check', 'search_dropdown'), array('int', 'search_results_per_page'), array('int', 'search_max_results', 'subtext' => $txt['search_max_results_disable']), '', array('int', 'search_floodcontrol_time', 'subtext' => $txt['search_floodcontrol_time_desc'], 6, 'postinput' => $txt['seconds']));
    call_integration_hook('integrate_modify_search_settings', array(&$config_vars));
    // Perhaps the search method wants to add some settings?
    require_once $sourcedir . '/Search.php';
    $searchAPI = findSearchAPI();
    if (is_callable(array($searchAPI, 'searchSettings'))) {
        call_user_func_array($searchAPI->searchSettings, array(&$config_vars));
    }
    if ($return_config) {
        return $config_vars;
    }
    $context['page_title'] = $txt['search_settings_title'];
    $context['sub_template'] = 'show_settings';
    call_integration_hook('integrate_modify_search_weights', array(&$factors));
    // We'll need this for the settings.
    require_once $sourcedir . '/ManageServer.php';
    // A form was submitted.
    if (isset($_REQUEST['save'])) {
        checkSession();
        call_integration_hook('integrate_save_search_settings');
        saveDBSettings($config_vars);
        redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']);
    }
    // Prep the template!
    $context['post_url'] = $scripturl . '?action=admin;area=managesearch;save;sa=settings';
    $context['settings_title'] = $txt['search_settings_title'];
    // We need this for the in-line permissions
    createToken('admin-mp');
    prepareDBSettingContext($config_vars);
}
function PrintTopic()
{
    global $topic, $txt, $scripturl, $context, $user_info;
    global $board_info, $smcFunc, $modSettings;
    // Redirect to the boardindex if no valid topic id is provided.
    if (empty($topic)) {
        redirectexit();
    }
    // Whatever happens don't index this.
    $context['robot_no_index'] = true;
    // Get the topic starter information.
    $request = $smcFunc['db_query']('', '
		SELECT m.poster_time, IFNULL(mem.real_name, m.poster_name) AS poster_name
		FROM {db_prefix}messages AS m
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
		WHERE m.id_topic = {int:current_topic}
		ORDER BY m.id_msg
		LIMIT 1', array('current_topic' => $topic));
    // Redirect to the boardindex if no valid topic id is provided.
    if ($smcFunc['db_num_rows']($request) == 0) {
        redirectexit();
    }
    $row = $smcFunc['db_fetch_assoc']($request);
    $smcFunc['db_free_result']($request);
    // Lets "output" all that info.
    loadTemplate('Printpage');
    $context['template_layers'] = array('print');
    $context['board_name'] = $board_info['name'];
    $context['category_name'] = $board_info['cat']['name'];
    $context['poster_name'] = $row['poster_name'];
    $context['post_time'] = timeformat($row['poster_time'], false);
    $context['parent_boards'] = array();
    foreach ($board_info['parent_boards'] as $parent) {
        $context['parent_boards'][] = $parent['name'];
    }
    // Split the topics up so we can print them.
    $request = $smcFunc['db_query']('', '
		SELECT subject, poster_time, body, IFNULL(mem.real_name, poster_name) AS poster_name
		FROM {db_prefix}messages AS m
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
		WHERE m.id_topic = {int:current_topic}' . ($modSettings['postmod_active'] && !allowedTo('approve_posts') ? '
			AND (m.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR m.id_member = {int:current_member}') . ')' : '') . '
		ORDER BY m.id_msg', array('current_topic' => $topic, 'is_approved' => 1, 'current_member' => $user_info['id']));
    $context['posts'] = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        // Censor the subject and message.
        censorText($row['subject']);
        censorText($row['body']);
        $context['posts'][] = array('subject' => $row['subject'], 'member' => $row['poster_name'], 'time' => timeformat($row['poster_time'], false), 'timestamp' => forum_time(true, $row['poster_time']), 'body' => parse_bbc($row['body'], 'print'));
        if (!isset($context['topic_subject'])) {
            $context['topic_subject'] = $row['subject'];
        }
    }
    $smcFunc['db_free_result']($request);
    // Set a canonical URL for this page.
    $context['canonical_url'] = $scripturl . '?topic=' . $topic . '.0';
}
Example #10
0
 /**
  * This is the main function for markasread file.
  *
  * @see Action_Controller::action_index()
  */
 public function action_index()
 {
     // These checks have been moved here.
     // Do NOT call the specific handlers directly.
     // Guests can't mark things.
     is_not_guest();
     checkSession('get');
     $redir = $this->_dispatch();
     redirectexit($redir);
 }
Example #11
0
function SaveNote()
{
    global $db_prefix;
    //Check if they are allowed to admin forum.
    isAllowedTo('admin_forum');
    //Make the html safe if used so it does not mess up the page
    $anotes = htmlspecialchars($_POST['txtnotes'], ENT_QUOTES);
    //Insert the admin notes into the database
    db_query("REPLACE INTO {$db_prefix}settings\n\t\t\t(variable, value)\n\t\tVALUES ('adminnotes','{$anotes}')", __FILE__, __LINE__);
    //Redirect to the main admin page to see the changed notes
    redirectexit('action=admin');
}
Example #12
0
function SaveNote()
{
    global $smcFunc;
    // Check if they are allowed to admin forum.
    isAllowedTo('admin_forum');
    // Make the html safe if used so it does not mess up the page
    $anotes = htmlspecialchars($_POST['txtnotes'], ENT_QUOTES);
    // Insert the admin notes into the database
    updateSettings(array('adminnotes' => $anotes));
    // Redirect to the main admin page to see the changed notes
    redirectexit('action=admin');
}
Example #13
0
/**
 * Related Topics
 *
 * @package RelatedTopics
 * @author Niko Pahajoki http://madjoki.com/
 * @version 1.5
 * @license http://madjoki.com/smf-mods/license/ New-BSD
 */
function RelatedTopicsAdminBuildIndex()
{
    global $smcFunc, $scripturl, $modSettings, $context, $txt;
    loadTemplate('Admin');
    loadLanguage('Admin');
    if (!isset($context['relatedClass']) && !initRelated()) {
        fatal_lang_error('no_methods_selected');
    }
    $context['step'] = empty($_REQUEST['step']) ? 0 : (int) $_REQUEST['step'];
    if ($context['step'] == 0) {
        // Clear caches
        foreach ($context['relatedClass'] as $class) {
            $class->recreateIndexTables();
        }
        $smcFunc['db_query']('', '
			DELETE FROM {db_prefix}related_topics');
    }
    $request = $smcFunc['db_query']('', '
		SELECT MAX(id_topic)
		FROM {db_prefix}topics');
    list($max_topics) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
    // How many topics to do per page load?
    $perStep = 150;
    $last = $context['step'] + $perStep;
    // Search for topic ids between first and last which are not in ignored boards
    $request = $smcFunc['db_query']('', '
		SELECT t.id_topic
		FROM {db_prefix}topics AS t
		WHERE t.id_topic > {int:start}
			AND t.id_topic <= {int:last}' . (!empty($context['rt_ignore']) ? '
			AND t.id_board NOT IN({array_int:ignored})' : ''), array('start' => $context['step'], 'last' => $last, 'ignored' => $context['rt_ignore']));
    $topics = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        $topics[] = $row['id_topic'];
    }
    $smcFunc['db_free_result']($request);
    // Update topics
    relatedUpdateTopics($topics, true);
    if ($last >= $max_topics) {
        redirectexit('action=admin;area=relatedtopics;sa=methods');
    }
    $context['sub_template'] = 'not_done';
    $context['continue_get_data'] = '?action=admin;area=relatedtopics;sa=buildIndex;step=' . $last;
    $context['continue_percent'] = round(100 * ($last / $max_topics));
    $context['continue_post_data'] = '';
    $context['continue_countdown'] = '2';
    obExit();
}
 /**
  * If you have a general mod setting to add stick it here.
  */
 public function action_addonSettings_display()
 {
     // Initialize the form
     $this->_initAddonSettingsForm();
     // Initialize settings
     $config_vars = $this->_addonSettings->settings();
     // Saving?
     if (isset($_GET['save'])) {
         checkSession();
         call_integration_hook('integrate_save_general_mod_settings');
         Settings_Form::save_db($config_vars);
         redirectexit('action=admin;area=addonsettings;sa=general');
     }
     Settings_Form::prepare_db($config_vars);
 }
Example #15
0
 /**
  * Openid_uri is the URI given by the user
  * Validates the URI and changes it to a fully canonical URL
  * Determines the IDP server and delegation
  * Optional array of fields to restore when validation complete.
  * Redirects the user to the IDP for validation
  *
  * @param string $openid_uri
  * @param bool $return = false
  * @param mixed[]|null $save_fields = array()
  * @param string|null $return_action = null
  * @return string
  */
 public function validate($openid_uri, $return = false, $save_fields = array(), $return_action = null)
 {
     global $scripturl, $modSettings;
     $openid_url = $this->canonize($openid_uri);
     $response_data = $this->getServerInfo($openid_url);
     // We can't do anything without the proper response data.
     if ($response_data === false || empty($response_data['provider'])) {
         return 'no_data';
     }
     // Is there an existing association?
     if (($assoc = $this->getAssociation($response_data['provider'])) == null) {
         $assoc = $this->makeAssociation($response_data['provider']);
     }
     // Include file for member existence
     require_once SUBSDIR . '/Members.subs.php';
     // Before we go wherever it is we are going, store the GET and POST data, because it might be useful when we get back.
     $request_time = time();
     // Just in case they are doing something else at this time.
     while (isset($_SESSION['openid']['saved_data'][$request_time])) {
         $request_time = md5($request_time);
     }
     $_SESSION['openid']['saved_data'][$request_time] = array('get' => $_GET, 'post' => $_POST, 'openid_uri' => $openid_url, 'cookieTime' => $modSettings['cookieTime']);
     // Set identity and claimed id to match the specs.
     $openid_identity = 'http://specs.openid.net/auth/2.0/identifier_select';
     $openid_claimedid = $openid_identity;
     // OpenID url an server response equal?
     if ($openid_url != $response_data['server']) {
         $openid_identity = urlencode(empty($response_data['delegate']) ? $openid_url : $response_data['delegate']);
         if (strpos($openid_identity, 'https') === 0) {
             $openid_claimedid = str_replace('http://', 'https://', $openid_url);
         } else {
             $openid_claimedid = $openid_url;
         }
     }
     // Prepare parameters for the OpenID setup.
     $parameters = array('openid.mode=checkid_setup', 'openid.realm=' . $scripturl, 'openid.ns=http://specs.openid.net/auth/2.0', 'openid.identity=' . $openid_identity, 'openid.claimed_id=' . $openid_claimedid, 'openid.assoc_handle=' . urlencode($assoc['handle']), 'openid.return_to=' . urlencode($scripturl . '?action=openidreturn&sa=' . (!empty($return_action) ? $return_action : $_REQUEST['action']) . '&t=' . $request_time . (!empty($save_fields) ? '&sf=' . base64_encode(serialize($save_fields)) : '')), 'openid.sreg.required=email');
     // If they are logging in but don't yet have an account or they are registering, let's request some additional information
     if ($_REQUEST['action'] == 'login2' && !memberExists($openid_url) || ($_REQUEST['action'] == 'register' || $_REQUEST['action'] == 'register2')) {
         $parameters[] = 'openid.sreg.optional=nickname,dob,gender';
     }
     $redir_url = $response_data['server'] . '?' . implode('&', $parameters);
     if ($return) {
         return $redir_url;
     } else {
         redirectexit($redir_url);
     }
 }
Example #16
0
function CLS_ChangeThemeSettings($return_config = false)
{
    global $txt, $scripturl, $context;
    $config_vars = array();
    $config_vars[] = array('check', 'change_theme_check_top');
    $config_vars[] = array('check', 'change_theme_check_bot');
    if ($return_config) {
        return $config_vars;
    }
    $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=cls';
    if (isset($_GET['save'])) {
        checkSession();
        saveDBSettings($config_vars);
        redirectexit('action=admin;area=modsettings;sa=cls');
    }
    prepareDBSettingContext($config_vars);
}
Example #17
0
function AdminNotepad()
{
    loadLanguage('smfhacks_languages/admin-notepad');
    loadTemplate('smfhacks_templates/admin-notepad', array('smfhacks_css/admin-notepad'));
    if (allowedTo('admin_forum')) {
        global $modSettings, $smcFunc;
        if (isset($_POST['admin_notes'])) {
            if (!empty($modSettings['admin_notes']) && $_POST['admin_notes'] == $modSettings['admin_notes']) {
                return;
            } elseif (empty($modSettings['admin_notes']) && empty($_POST['admin_notes'])) {
                return;
            } else {
                updateSettings(array('admin_notes' => $smcFunc['htmlspecialchars']($_POST['admin_notes'], ENT_QUOTES)));
                redirectexit('action=admin;notes_saved');
            }
        }
    }
}
Example #18
0
 public static function installProducts()
 {
     global $context;
     isAllowedTo('admin_forum');
     checkSession('get');
     $action = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : '';
     $pluginlist = isset($_REQUEST['p']) ? explode(',', $_REQUEST['p']) : array();
     if (!empty($pluginlist) && ($action === 'install' || $action === 'uninstall')) {
         foreach ($pluginlist as $plugin) {
             if ($action === 'install') {
                 self::install($plugin);
             } else {
                 self::uninstall($plugin);
             }
         }
     }
     redirectexit('action=admin;area=plugins;' . $context['session_var'] . '=' . $context['session_id']);
 }
Example #19
0
function SavePad()
{
    global $ID_MEMBER, $txt, $user_info, $smcFunc;
    // Get the Member ID
    $id = (int) $_REQUEST['id'];
    // Check if they are allowed to edi th user's personal notepad
    if ($id == $user_info['id'] || allowedTo('admin_forum')) {
        // Make the html safe if used so it does not mess up the page
        $anotes = $smcFunc['htmlspecialchars']($_POST['txtnotes'], ENT_QUOTES);
        // Insert the text into the users personal notepad
        $smcFunc['db_query']('', "REPLACE INTO {db_prefix}themes\n\t\t\t\t(ID_MEMBER, variable, value)\n\t\t\tVALUES ({$id},'notes','{$anotes}')");
        // Redirect to back to the users profile
        redirectexit('action=profile;u=' . $id);
    } else {
        // Give them permission denied error
        fatal_error($txt['mempad_error'], false);
    }
}
Example #20
0
function AdminNotepad()
{
    if (allowedTo('admin_forum')) {
        global $context, $modSettings, $settings;
        loadLanguage('smfhacks_languages/admin-notepad');
        loadTemplate('smfhacks_templates/admin-notepad');
        $context['html_headers'] .= "\n" . '<link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/smfhacks_css/admin-notepad.css" />';
        if (isset($_POST['admin_notes'])) {
            if (!empty($modSettings['admin_notes']) && $_POST['admin_notes'] == $modSettings['admin_notes']) {
                return;
            } elseif (empty($modSettings['admin_notes']) && empty($_POST['admin_notes'])) {
                return;
            } else {
                updateSettings(array('admin_notes' => htmlspecialchars($_POST['admin_notes'], ENT_QUOTES)));
                redirectexit('action=admin;notes_saved');
            }
        }
    }
}
/**
 * @param bool $return_config
 * @return array config vars
 */
function addMenuButtonWithBoardsListAdminSettings($return_config = false)
{
    global $txt, $scripturl, $context;
    loadLanguage('MenuButtonWithBoardsList/');
    $context['page_title'] = $txt['menu_button_with_boards'];
    $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=menu_button_with_boards';
    $context['settings_message'] = '';
    $config_vars = array(array('title', 'menu_button_with_boards_settings'), array('text', 'menu_button_with_boards_title'), array('text', 'menu_button_with_boards_cats', 'subtext' => $txt['menu_button_with_boards_cats_desc']));
    if ($return_config) {
        return $config_vars;
    }
    if (isset($_GET['save'])) {
        checkSession();
        saveDBSettings($config_vars);
        clean_cache();
        redirectexit('action=admin;area=modsettings;sa=menu_button_with_boards');
    }
    prepareDBSettingContext($config_vars);
}
Example #22
0
function KB()
{
    global $txt, $sourcedir, $scripturl, $modSettings, $context;
    if (empty($modSettings['kb_enabled'])) {
        redirectexit();
    }
    isAllowedTo('view_knowledge');
    KB_file_include(array('KBEditer', 'KBPerm', 'KBReport', 'KBApprove', 'KBSearch', 'KBEdit_Add', 'KBView_All', 'KBView', 'KBCats', 'KBMisc', 'KBMenu', 'KBSubs', 'KBRSS'));
    loadTemplate('KB');
    $context['linktree'][] = array('url' => $scripturl . '?action=kb', 'name' => $txt['knowledgebase']);
    //fix wysig
    KB_wysig_descript();
    //Are we jumping?
    KB_dojump();
    //Any headers?
    KB_doheaders();
    //Menu anyone?
    KB_Menu();
    if (isset($_REQUEST['comment_recount']) && allowedTo('manage_kb')) {
        KBrecountcomments();
    }
    if (isset($_REQUEST['article_recount']) && allowedTo('manage_kb')) {
        KBrecountItems();
    }
    if (isset($_REQUEST['cache_clean']) && allowedTo('manage_kb')) {
        KB_cleanCache();
    }
    //I am a robot
    if (empty($modSettings['kb_search_engines'])) {
        $context['robot_no_index'] = true;
    }
    $context['canonical_url'] = $scripturl . '?action=kb';
    //Put all the subactions into an array
    $subActions = array('main' => 'KB_main', 'cats' => 'KB_know', 'article' => 'KB_knowcont', 'catadd' => 'KB_catadd', 'listcat' => 'KB_catlist', 'addknow' => 'KB_addknow', 'del' => 'KB_del', 'permcat' => 'KB_perm', 'search' => 'KB_search', 'searchmain' => 'KB_searchmain', 'rate' => 'KB_rate', 'edit' => 'KB_edit', 'reporta' => 'KB_reporta', 'manage' => 'KB_manage', 'rss' => 'KB_rss', 'catup' => 'KB_movecat', 'catdown' => 'KB_movecat');
    // Default the sub-action'.
    $_REQUEST['area'] = isset($_REQUEST['area']) && isset($subActions[$_REQUEST['area']]) ? $_REQUEST['area'] : 'main';
    // Set title and default sub-action.
    $context['page_title'] = $txt['knowledgebase'];
    $context['sub_action'] = $_REQUEST['area'];
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['area']]();
}
Example #23
0
 /**
  * Called before any other action method in this class.
  *
  * - If coming from the quick reply allows to route to the proper action
  * - if needed (for example external search engine or members search
  */
 public function pre_dispatch()
 {
     global $modSettings, $scripturl;
     // Coming from quick search box and going to some custome place?
     if (isset($_REQUEST['search_selection']) && !empty($modSettings['additional_search_engines'])) {
         $engines = prepareSearchEngines();
         if (isset($engines[$_REQUEST['search_selection']])) {
             $engine = $engines[$_REQUEST['search_selection']];
             redirectexit($engine['url'] . urlencode(implode($engine['separator'], explode(' ', $_REQUEST['search']))));
         }
     }
     // if comming from the quick search box, and we want to search on members, well we need to do that ;)
     if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') {
         redirectexit($scripturl . '?action=memberlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search']));
     }
     // If load balancing is on and the load is high, no need to even show the form.
     if (!empty($modSettings['loadavg_search']) && $modSettings['current_load'] >= $modSettings['loadavg_search']) {
         fatal_lang_error('loadavg_search_disabled', false);
     }
 }
/**
 * Toggles the current state of a block / control
 *
 * - calls sp_changeState to toggle the on/off status
 * - directs back based on type passed
 *
 * @param string $type type of control
 * @param int $id id of the control
 */
function sportal_admin_state_change($type, $id)
{
    if (!in_array($type, array('block', 'category', 'article'))) {
        fatal_lang_error('error_sp_id_empty', false);
    }
    // Toggle the current state
    sp_changeState($type, $id);
    // Based on the type, find our way back
    if ($type == 'block') {
        $sides = array(1 => 'left', 2 => 'top', 3 => 'bottom', 4 => 'right');
        $list = !empty($_GET['redirect']) && isset($sides[$_GET['redirect']]) ? $sides[$_GET['redirect']] : 'list';
        redirectexit('action=admin;area=portalblocks;sa=' . $list);
    } elseif ($type == 'category') {
        redirectexit('action=admin;area=portalarticles;sa=categories');
    } elseif ($type == 'article') {
        redirectexit('action=admin;area=portalarticles;sa=articles');
    } else {
        redirectexit('action=admin;area=portalconfig');
    }
}
function pv_delete($memID)
{
    global $smcFunc, $context, $user_info;
    checkSession('get');
    if ($context['user']['is_owner'] && !allowedTo('pv_remove_own')) {
        isAllowedTo('pv_remove_any_any');
    } elseif ($user_info['id'] == $member && !allowedTo('pv_remove_any_own')) {
        isAllowedTo('pv_remove_any_any');
    }
    $member = !empty($_REQUEST['member']) ? (int) $_REQUEST['member'] : 0;
    if (empty($member)) {
        fatal_lang_error('pv_no_member', false);
    }
    $smcFunc['db_query']('', '
		DELETE FROM {db_prefix}log_Maximum_visitors
		WHERE id_member = {int:member}
			AND id_profile = {int:profile}
		LIMIT 1', array('member' => $member, 'profile' => $memID));
    redirectexit('action=profile;u=' . $memID . ';pv');
}
    /**
     * Modify any setting related to drafts.
     *
     * - Requires the admin_forum permission.
     * - Accessed from ?action=admin;area=managedrafts
     *
     * @uses Admin template, edit_topic_settings sub-template.
     */
    public function action_draftSettings_display()
    {
        global $context, $txt, $scripturl;
        isAllowedTo('admin_forum');
        loadLanguage('Drafts');
        // Initialize the form
        $this->_initDraftSettingsForm();
        $config_vars = $this->_draftSettings->settings();
        // Setup the template.
        $context['page_title'] = $txt['managedrafts_settings'];
        $context['sub_template'] = 'show_settings';
        $context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['drafts'], 'help' => '', 'description' => $txt['managedrafts_settings_description']);
        // Saving them ?
        if (isset($_GET['save'])) {
            checkSession();
            call_integration_hook('integrate_save_drafts_settings');
            // Protect them from themselves.
            $_POST['drafts_autosave_frequency'] = $_POST['drafts_autosave_frequency'] < 30 ? 30 : $_POST['drafts_autosave_frequency'];
            Settings_Form::save_db($config_vars);
            redirectexit('action=admin;area=managedrafts');
        }
        // Some javascript to enable / disable the frequency input box
        addInlineJavascript('
			var autosave = document.getElementById(\'drafts_autosave_enabled\');

			createEventListener(autosave);
			autosave.addEventListener(\'change\', toggle);
			toggle();

			function toggle()
			{
				var select_elem = document.getElementById(\'drafts_autosave_frequency\');

				select_elem.disabled = !autosave.checked;
			}', true);
        // Final settings...
        $context['post_url'] = $scripturl . '?action=admin;area=managedrafts;save';
        $context['settings_title'] = $txt['managedrafts_settings'];
        // Prepare the settings...
        Settings_Form::prepare_db($config_vars);
    }
Example #27
0
function Groups()
{
    global $context, $txt, $scripturl, $sourcedir, $user_info, $modSettings;
    // The sub-actions that we can do. Format "Function Name, Mod Bar Index if appropriate".
    $subActions = array('index' => array('GroupList', 'view_groups'), 'members' => array('MembergroupMembers', 'view_groups'), 'requests' => array('GroupRequests', 'group_requests'));
    if (!isset($modSettings['groupColorsInline'])) {
        require_once $sourcedir . '/lib/Subs-Membergroups.php';
        regenerateColorStyle();
    }
    // Default to sub action 'index' or 'settings' depending on permissions.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'index';
    // Get the template stuff up and running.
    loadLanguage('ManageMembers');
    loadLanguage('ModerationCenter');
    if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'admin' || $_REQUEST['action'] === 'groups') {
        loadAdminTemplate('ManageMembergroups');
    }
    // If we can see the moderation center, and this has a mod bar entry, add the mod center bar.
    if ($_REQUEST['action'] != 'moderate' && (allowedTo('access_mod_center') || $user_info['mod_cache']['bq'] != '0=1' || $user_info['mod_cache']['gq'] != '0=1' || allowedTo('manage_membergroups'))) {
        if (isset($_REQUEST['group'])) {
            redirectexit(URL::parse('?action=moderate;area=viewgroups;sa=members;group=' . $_REQUEST['group']));
        } else {
            if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'requests' && isset($_POST[$context['session_var']])) {
                require_once $sourcedir . '/ModerationCenter.php';
                $_GET['area'] = $_REQUEST['sa'] == 'requests' ? 'groups' : 'viewgroups';
                ModerationMain(true);
            } else {
                redirectexit(URL::parse('?action=moderate;area=viewgroups'));
            }
        }
        //require_once($sourcedir . '/ModerationCenter.php');
        //$_GET['area'] = $_REQUEST['sa'] == 'requests' ? 'groups' : 'viewgroups';
        //ModerationMain(true);
    } else {
        isAllowedTo('view_mlist');
        $context['linktree'][] = array('url' => $scripturl . '?action=groups', 'name' => $txt['groups']);
    }
    // Call the actual function.
    $subActions[$_REQUEST['sa']][0]();
}
Example #28
0
function ManageShoutbox_Settings2()
{
    global $smcFunc, $smcFunc;
    checkSession();
    $config = array('disable' => 'checkbox', 'startHide' => 'checkbox', 'backgroundColor' => 'text', 'textColor' => 'text', 'boxTitle' => 'text', 'refreshShouts' => 'text', 'startShouts' => 'text', 'keepShouts' => 'text', 'height' => 'text', 'printClass' => 'text', 'timeColor' => 'text', 'timeFormat' => 'text', 'maxMsgLenght' => 'text', 'minMsgLenght' => 'text', 'maxLinkLenght' => 'text', 'fixLongWords' => 'text', 'disableTags' => 'textarea', 'faces' => 'textarea', 'showActions' => 'textarea', 'out_main' => 'textarea', 'showform_down' => 'checkbox', 'showmsg_down' => 'checkbox');
    foreach ($config as $s => $t) {
        if ($t == 'textarea' && isset($_POST[$s])) {
            $_POST[$s] = str_replace("\n", ',', str_replace(array("\r", "\t", "<br />"), '', $_POST[$s]));
        }
        if ($t == 'checkbox') {
            $v = !isset($_POST[$s]) ? 0 : 1;
        } else {
            $v = !isset($_POST[$s]) ? 0 : addslashes($smcFunc['htmlspecialchars']($smcFunc['htmltrim'](stripslashes($_POST[$s])), ENT_QUOTES));
        }
        if (!empty($v)) {
            $smcFunc['db_insert']('replace', '{db_prefix}shoutbox_settings', array('variable' => 'string', 'value' => 'string'), array($s, $v), array('variable'));
        } else {
            $smcFunc['db_query']('', "\r\r\n\t\t\t\tDELETE FROM {db_prefix}shoutbox_settings\r\r\n\t\t\t\tWHERE variable = {string:value} LIMIT 1", array('value' => $s));
        }
    }
    redirectexit('action=admin;area=shoutbox');
}
Example #29
0
function KB_file_include($file)
{
    global $sourcedir;
    $kb_dir = $sourcedir . '/KB';
    if (is_array($file)) {
        foreach ($file as $n => $filename) {
            $path = $kb_dir . '/' . $filename . '.php';
            if (file_exists($path)) {
                include $path;
            } else {
                redirectexit();
            }
        }
    } else {
        $path = $kb_dir . '/' . $file . '.php';
        if (file_exists($path)) {
            include $path;
        } else {
            redirectexit();
        }
    }
}
function sportal_main()
{
    global $smcFunc, $context, $sourcedir;
    if (WIRELESS) {
        redirectexit('action=forum');
    }
    $context['page_title'] = $context['forum_name'];
    if (isset($context['page_title_html_safe'])) {
        $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title']));
    }
    if (!empty($context['standalone'])) {
        setupMenuContext();
    }
    $actions = array('addarticle' => array('PortalArticles.php', 'sportal_add_article'), 'articles' => array('PortalArticles.php', 'sportal_articles'), 'credits' => array('', 'sportal_credits'), 'pages' => array('PortalPages.php', 'sportal_pages'), 'removearticle' => array('PortalArticles.php', 'sportal_remove_article'), 'shoutbox' => array('PortalShoutbox.php', 'sportal_shoutbox'));
    if (!isset($_REQUEST['sa']) || !isset($actions[$_REQUEST['sa']])) {
        $_REQUEST['sa'] = 'articles';
    }
    if (!empty($actions[$_REQUEST['sa']][0])) {
        require_once $sourcedir . '/' . $actions[$_REQUEST['sa']][0];
    }
    $actions[$_REQUEST['sa']][1]();
}