示例#1
0
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 = smf_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 (mysql_num_rows($request) == 0) {
        redirectexit();
    }
    $row = mysql_fetch_assoc($request);
    mysql_free_result($request);
    // Lets "output" all that info.
    EoS_Smarty::loadTemplate('topic/printpage');
    $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 = smf_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 = mysql_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'];
        }
    }
    mysql_free_result($request);
    // Set a canonical URL for this page.
    $context['canonical_url'] = $scripturl . '?topic=' . $topic . '.0';
}
示例#2
0
function smf_db_create_word_search($size)
{
    if ($size == 'small') {
        $size = 'smallint(5)';
    } elseif ($size == 'medium') {
        $size = 'mediumint(8)';
    } else {
        $size = 'int(10)';
    }
    smf_db_query('
		CREATE TABLE {db_prefix}log_search_words (
			id_word {raw:size} unsigned NOT NULL default {string:string_zero},
			id_msg int(10) unsigned NOT NULL default {string:string_zero},
			PRIMARY KEY (id_word, id_msg)
		) ENGINE=InnoDB', array('string_zero' => '0', 'size' => $size));
}
示例#3
0
    private function __searchRelated($subject)
    {
        global $smcFunc, $modSettings;
        $request = smf_db_query('
			SELECT rs.id_topic, MATCH(rs.subject) AGAINST({string:subject}) AS score
			FROM {db_prefix}related_subjects AS rs
			WHERE MATCH(rs.subject) AGAINST({string:subject})
			ORDER BY MATCH(rs.subject) AGAINST({string:subject}) DESC
			LIMIT {int:limitTopics}', array('subject' => $subject, 'limitTopics' => round((!empty($modSettings['relatedTopicsCount']) ? (int) $modSettings['relatedTopicsCount'] : 5) * 2.5)));
        $return = array();
        while ($row = mysql_fetch_assoc($request)) {
            $return[$row['id_topic']] = array($row['id_topic'], $row['score']);
        }
        mysql_free_result($request);
        return $return;
    }
示例#4
0
function getBoardList($boardListOptions = array())
{
    global $smcFunc, $user_info;
    if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) {
        trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR);
    }
    $where = array();
    $where_parameters = array();
    if (isset($boardListOptions['excluded_boards'])) {
        $where[] = 'b.id_board NOT IN ({array_int:excluded_boards})';
        $where_parameters['excluded_boards'] = $boardListOptions['excluded_boards'];
    }
    if (isset($boardListOptions['included_boards'])) {
        $where[] = 'b.id_board IN ({array_int:included_boards})';
        $where_parameters['included_boards'] = $boardListOptions['included_boards'];
    }
    if (!empty($boardListOptions['ignore_boards'])) {
        $where[] = '{query_wanna_see_board}';
    } elseif (!empty($boardListOptions['use_permissions'])) {
        $where[] = '{query_see_board}';
    }
    if (!empty($boardListOptions['not_redirection'])) {
        $where[] = 'b.redirect = {string:blank_redirect}';
        $where_parameters['blank_redirect'] = '';
    }
    $request = smf_db_query('
		SELECT c.name AS cat_name, c.id_cat, b.id_board, b.name AS board_name, b.child_level
		FROM {db_prefix}boards AS b
			LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)' . (empty($where) ? '' : '
		WHERE ' . implode('
			AND ', $where)), $where_parameters);
    $return_value = array();
    if (mysql_num_rows($request) !== 0) {
        while ($row = mysql_fetch_assoc($request)) {
            if (!isset($return_value[$row['id_cat']])) {
                $return_value[$row['id_cat']] = array('id' => $row['id_cat'], 'name' => $row['cat_name'], 'boards' => array());
            }
            $return_value[$row['id_cat']]['boards'][] = array('id' => $row['id_board'], 'name' => $row['board_name'], 'child_level' => $row['child_level'], 'selected' => isset($boardListOptions['selected_board']) && $boardListOptions['selected_board'] == $row['id_board']);
        }
    }
    mysql_free_result($request);
    return $return_value;
}
示例#5
0
function fix_serialized_columns()
{
    global $smcFunc;
    $request = smf_db_query('
		SELECT id_action, extra
		FROM {db_prefix}log_actions
		WHERE action IN ({string:remove}, {string:delete})', array('remove' => 'remove', 'delete' => 'delete'));
    while ($row = mysql_fetch_assoc($request)) {
        if (@unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\\d+;s:7:"subject";s:)(\\d+):"(.+)"(;s:6:"member";s:5:"\\d+";})$~', $row['extra'], $matches) === 1) {
            smf_db_query('
				UPDATE {db_prefix}log_actions
				SET extra = {string:extra}
				WHERE id_action = {int:current_action}', array('current_action' => $row['id_action'], 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4]));
        }
    }
    mysql_free_result($request);
    // Refresh some cached data.
    updateSettings(array('memberlist_updated' => time()));
}
示例#6
0
function getLastPosts($latestPostOptions)
{
    global $scripturl, $txt, $user_info, $modSettings, $smcFunc, $context;
    // Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
    // !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
    $request = smf_db_query('
		SELECT
			m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg, b.name, m1.subject AS first_subject,
			IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name,
			SUBSTRING(m.body, 1, 385) AS body, m.smileys_enabled
		FROM {db_prefix}messages AS m
			INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
			INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
			INNER JOIN {db_prefix}messages AS m1 ON (m1.id_msg = t.id_first_msg)
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
		WHERE m.id_msg >= {int:likely_max_msg}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
			AND b.id_board != {int:recycle_board}' : '') . '
			AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
			AND t.approved = {int:is_approved}
			AND m.approved = {int:is_approved}' : '') . '
		ORDER BY m.id_msg DESC
		LIMIT ' . $latestPostOptions['number_posts'], array('likely_max_msg' => max(0, $modSettings['maxMsgID'] - 50 * $latestPostOptions['number_posts']), 'recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1));
    $posts = array();
    while ($row = mysql_fetch_assoc($request)) {
        // Censor the subject and post for the preview ;).
        censorText($row['subject']);
        censorText($row['body']);
        $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '&#10;')));
        if (commonAPI::strlen($row['body']) > 128) {
            $row['body'] = commonAPI::substr($row['body'], 0, 128) . '...';
        }
        $bhref = URL::board($row['id_board'], $row['board_name'], 0, true);
        $mhref = URL::user($row['id_member'], $row['poster_name']);
        $thref = URL::topic($row['id_topic'], $row['first_subject'], 0, false, '.msg' . $row['id_msg'], ';topicseen#msg' . $row['id_msg']);
        // Build the array.
        $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $bhref, 'link' => '<a href="' . $bhref . '">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $mhref, 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $mhref . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => shorten_subject($row['subject'], 35), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'raw_timestamp' => $row['poster_time'], 'href' => $thref, 'link' => '<a href="' . $thref . '" rel="nofollow">' . $row['first_subject'] . '</a>');
    }
    mysql_free_result($request);
    return $posts;
}
示例#7
0
function AdminRegister()
{
    global $txt, $context, $sourcedir, $scripturl, $smcFunc;
    if (!empty($_POST['regSubmit'])) {
        checkSession();
        foreach ($_POST as $key => $value) {
            if (!is_array($_POST[$key])) {
                $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
            }
        }
        $regOptions = array('interface' => 'admin', 'username' => $_POST['user'], 'email' => $_POST['email'], 'password' => $_POST['password'], 'password_check' => $_POST['password'], 'check_reserved_name' => true, 'check_password_strength' => false, 'check_email_ban' => false, 'send_welcome_email' => isset($_POST['emailPassword']) || empty($_POST['password']), 'require' => isset($_POST['emailActivate']) ? 'activation' : 'nothing', 'memberGroup' => empty($_POST['group']) || !allowedTo('manage_membergroups') ? 0 : (int) $_POST['group']);
        require_once $sourcedir . '/lib/Subs-Members.php';
        $memberID = registerMember($regOptions);
        if (!empty($memberID)) {
            $context['new_member'] = array('id' => $memberID, 'name' => $_POST['user'], 'href' => $scripturl . '?action=profile;u=' . $memberID, 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $memberID . '">' . $_POST['user'] . '</a>');
            $context['registration_done'] = sprintf($txt['admin_register_done'], $context['new_member']['link']);
        }
    }
    // Basic stuff.
    $context['sub_template'] = 'admin_register';
    $context['page_title'] = $txt['registration_center'];
    // Load the assignable member groups.
    if (allowedTo('manage_membergroups')) {
        $request = smf_db_query('
			SELECT group_name, id_group
			FROM {db_prefix}membergroups
			WHERE id_group != {int:moderator_group}
				AND min_posts = {int:min_posts}' . (allowedTo('admin_forum') ? '' : '
				AND id_group != {int:admin_group}
				AND group_type != {int:is_protected}') . '
				AND hidden != {int:hidden_group}
			ORDER BY min_posts, CASE WHEN id_group < {int:newbie_group} THEN id_group ELSE 4 END, group_name', array('moderator_group' => 3, 'min_posts' => -1, 'admin_group' => 1, 'is_protected' => 1, 'hidden_group' => 2, 'newbie_group' => 4));
        $context['member_groups'] = array(0 => $txt['admin_register_group_none']);
        while ($row = mysql_fetch_assoc($request)) {
            $context['member_groups'][$row['id_group']] = $row['group_name'];
        }
        mysql_free_result($request);
    } else {
        $context['member_groups'] = array();
    }
}
示例#8
0
文件: Poll.php 项目: norv/EosAlpha
function RemovePoll()
{
    global $topic, $user_info, $smcFunc;
    // Make sure the topic is not empty.
    if (empty($topic)) {
        fatal_lang_error('no_access', false);
    }
    // Verify the session.
    checkSession('get');
    // Check permissions.
    if (!allowedTo('poll_remove_any')) {
        $request = smf_db_query('
			SELECT t.id_member_started, p.id_member AS poll_starter
			FROM {db_prefix}topics AS t
				INNER JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
			WHERE t.id_topic = {int:current_topic}
			LIMIT 1', array('current_topic' => $topic));
        if (mysql_num_rows($request) == 0) {
            fatal_lang_error('no_access', false);
        }
        list($topicStarter, $pollStarter) = mysql_fetch_row($request);
        mysql_free_result($request);
        isAllowedTo('poll_remove_' . ($topicStarter == $user_info['id'] || $pollStarter != 0 && $user_info['id'] == $pollStarter ? 'own' : 'any'));
    }
    // Retrieve the poll ID.
    $request = smf_db_query('
		SELECT id_poll
		FROM {db_prefix}topics
		WHERE id_topic = {int:current_topic}
		LIMIT 1', array('current_topic' => $topic));
    list($pollID) = mysql_fetch_row($request);
    mysql_free_result($request);
    // Remove all user logs for this poll.
    smf_db_query('
		DELETE FROM {db_prefix}log_polls
		WHERE id_poll = {int:id_poll}', array('id_poll' => $pollID));
    // Remove all poll choices.
    smf_db_query('
		DELETE FROM {db_prefix}poll_choices
		WHERE id_poll = {int:id_poll}', array('id_poll' => $pollID));
    // Remove the poll itself.
    smf_db_query('
		DELETE FROM {db_prefix}polls
		WHERE id_poll = {int:id_poll}', array('id_poll' => $pollID));
    // Finally set the topic poll ID back to 0!
    smf_db_query('
		UPDATE {db_prefix}topics
		SET id_poll = {int:no_poll}
		WHERE id_topic = {int:current_topic}', array('current_topic' => $topic, 'no_poll' => 0));
    // Take the moderator back to the topic.
    redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
}
示例#9
0
    function __construct($request, $total_items, $not_profile = false)
    {
        global $context, $txt, $user_info, $scripturl, $options, $memberContext, $modSettings;
        if (!isset($context['pageindex_multiplier'])) {
            $context['pageindex_multiplier'] = commonAPI::getMessagesPerPage();
        }
        $cb_name = isset($context['cb_name']) ? $context['cb_name'] : 'topics[]';
        while ($row = mysql_fetch_assoc($request)) {
            censorText($row['subject']);
            $this->topic_ids[] = $row['id_topic'];
            $f_post_mem_href = !empty($row['id_member']) ? URL::user($row['id_member'], $row['first_member_name']) : '';
            $t_href = URL::topic($row['id_topic'], $row['subject'], 0);
            $l_post_mem_href = !empty($row['id_member_updated']) ? URL::user($row['id_member_updated'], $row['last_real_name']) : '';
            $l_post_msg_href = URL::topic($row['id_topic'], $row['last_subject'], $user_info['is_guest'] ? !empty($options['view_newest_first']) ? 0 : (int) ($row['num_replies'] / $context['pageindex_multiplier']) * $context['pageindex_multiplier'] : 0, $user_info['is_guest'] ? true : false, $user_info['is_guest'] ? '' : '.msg' . $row['id_last_msg'], $user_info['is_guest'] ? '#msg' . $row['id_last_msg'] : '#new');
            $this->topiclist[$row['id_topic']] = array('id' => $row['id_topic'], 'id_member_started' => empty($row['id_member']) ? 0 : $row['id_member'], 'first_post' => array('id' => $row['id_first_msg'], 'member' => array('username' => $row['first_member_name'], 'name' => $row['first_member_name'], 'id' => empty($row['id_member']) ? 0 : $row['id_member'], 'href' => $f_post_mem_href, 'link' => !empty($row['id_member']) ? '<a onclick="getMcard(' . $row['id_member'] . ', $(this));return(false);" href="' . $f_post_mem_href . '" title="' . $txt['profile_of'] . ' ' . $row['first_member_name'] . '">' . $row['first_member_name'] . '</a>' : $row['first_member_name']), 'time' => timeformat($row['first_poster_time']), 'timestamp' => forum_time(true, $row['first_poster_time']), 'subject' => $row['subject'], 'icon' => $row['first_icon'], 'icon_url' => getPostIcon($row['first_icon']), 'href' => $t_href, 'link' => '<a href="' . $t_href . '">' . $row['subject'] . '</a>'), 'last_post' => array('id' => $row['id_last_msg'], 'member' => array('username' => $row['last_real_name'], 'name' => $row['last_real_name'], 'id' => $row['id_member_updated'], 'href' => $l_post_mem_href, 'link' => !empty($row['id_member_updated']) ? '<a onclick="getMcard(' . $row['id_member_updated'] . ', $(this));return(false);" href="' . $l_post_mem_href . '">' . $row['last_real_name'] . '</a>' : $row['last_real_name']), 'time' => timeformat($row['last_post_time']), 'timestamp' => forum_time(true, $row['last_post_time']), 'subject' => $row['last_subject'], 'href' => $l_post_msg_href, 'link' => '<a href="' . $l_post_msg_href . ($row['num_replies'] == 0 ? '' : ' rel="nofollow"') . '>' . $row['last_subject'] . '</a>'), 'checkbox_name' => $cb_name, 'subject' => $row['subject'], 'new' => $row['new_from'] <= $row['id_msg_modified'], 'new_from' => $row['new_from'], 'newtime' => $row['new_from'], 'updated' => timeformat($row['poster_time']), 'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . '#new', 'new_link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . '#new">' . $row['subject'] . '</a>', 'replies' => comma_format($row['num_replies']), 'views' => comma_format($row['num_views']), 'approved' => $row['approved'], 'unapproved_posts' => $row['unapproved_posts'], 'is_old' => !empty($modSettings['oldTopicDays']) ? $context['time_now'] - $row['last_post_time'] > $modSettings['oldTopicDays'] * 86400 : false, 'is_posted_in' => false, 'prefix' => '', 'pages' => '', 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']), 'is_locked' => !empty($row['locked']), 'is_poll' => false, 'is_hot' => $row['num_replies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => $row['num_replies'] >= $modSettings['hotTopicVeryPosts'], 'board' => isset($row['id_board']) && !empty($row['id_board']) ? array('name' => $row['board_name'], 'id' => $row['id_board'], 'href' => URL::board($row['id_board'], $row['board_name'])) : array('name' => '', 'id' => 0, 'href' => ''));
            determineTopicClass($this->topiclist[$row['id_topic']]);
            if (!empty($row['id_member']) && ($row['id_member'] != $user_info['id'] || $not_profile)) {
                $this->users_to_load[$row['id_member']] = $row['id_member'];
            }
        }
        loadMemberData($this->users_to_load);
        foreach ($this->topiclist as &$topic) {
            if (!isset($memberContext[$topic['id_member_started']])) {
                loadMemberContext($topic['id_member_started']);
            }
            $topic['first_post']['member']['avatar'] =& $memberContext[$topic['id_member_started']]['avatar']['image'];
        }
        // figure out whether we have posted in a topic (but only if we are not the topic starter)
        if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($this->topic_ids)) {
            $result = smf_db_query('
				SELECT id_topic
				FROM {db_prefix}messages
				WHERE id_topic IN ({array_int:topic_list})
					AND id_member = {int:current_member}
				GROUP BY id_topic
				LIMIT ' . count($this->topic_ids), array('current_member' => $user_info['id'], 'topic_list' => $this->topic_ids));
            while ($row = mysql_fetch_assoc($result)) {
                if ($this->topiclist[$row['id_topic']]['first_post']['member']['id'] != $user_info['id']) {
                    $this->topiclist[$row['id_topic']]['is_posted_in'] = true;
                }
            }
            mysql_free_result($result);
        }
    }
示例#10
0
/**
 * @param $memID	int member ID
 * 
 * show the settings to customize opt-outs for activity entries and notifications
 * to receive.
 * 
 * todo: we need to find a way to filter out notifications that are for
 * admins/mods only. probably needs a db scheme change...
 */
function showActivitiesProfileSettings($memID)
{
    global $modSettings, $context, $user_info, $txt, $user_profile, $scripturl;
    loadLanguage('Activities-Profile');
    if (empty($modSettings['astream_active']) || $user_info['id'] != $memID && !$user_info['is_admin']) {
        fatal_lang_error('no_access');
    }
    Eos_Smarty::getConfigInstance()->registerHookTemplate('profile_content_area', 'profile/astream_settings');
    $context['submiturl'] = $scripturl . '?action=profile;area=activities;sa=settings;save;u=' . $memID;
    $context['page_title'] = $txt['showActivities'] . ' - ' . $user_profile[$memID]['real_name'];
    $context[$context['profile_menu_name']]['tab_data'] = array('title' => $txt['showActivitiesSettings'], 'description' => $txt['showActivitiesSettings_desc'], 'tabs' => array());
    $result = smf_db_query('SELECT * FROM {db_prefix}activity_types ORDER BY id_type ASC');
    if ($user_info['id'] == $memID) {
        $my_act_optout = empty($user_info['act_optout']) ? array(0) : explode(',', $user_info['act_optout']);
        $my_notify_optout = empty($user_info['notify_optout']) ? array(0) : explode(',', $user_info['notify_optout']);
    } else {
        loadMemberData($memID, false, 'minimal');
        $my_act_optout = empty($user_profile[$memID]['act_optout']) ? array(0) : explode(',', $user_profile[$memID]['act_optout']);
        $my_notify_optout = empty($user_profile[$memID]['notify_optout']) ? array(0) : explode(',', $user_profile[$memID]['notify_optout']);
    }
    $context['activity_types'] = array();
    while ($row = mysql_fetch_assoc($result)) {
        $context['activity_types'][] = array('id' => $row['id_type'], 'shortdesc' => $row['id_desc'], 'longdesc_act' => $txt['actdesc_' . trim($row['id_desc'])], 'longdesc_not' => isset($txt['ndesc_' . trim($row['id_desc'])]) ? $txt['ndesc_' . trim($row['id_desc'])] : '', 'act_optout' => in_array($row['id_type'], $my_act_optout), 'notify_optout' => in_array($row['id_type'], $my_notify_optout));
    }
    mysql_free_result($result);
    if (isset($_GET['save'])) {
        $new_not_optout = array();
        $new_act_optout = array();
        $update_array = array();
        foreach ($context['activity_types'] as $t) {
            $_id = trim($t['id']);
            if (!empty($t['longdesc_act']) && (!isset($_REQUEST['act_check_' . $_id]) || empty($_REQUEST['act_check_' . $_id]))) {
                $new_act_optout[] = $_id;
            }
            if (!empty($t['longdesc_not']) && (!isset($_REQUEST['not_check_' . $_id]) || empty($_REQUEST['not_check_' . $_id]))) {
                $new_not_optout[] = $_id;
            }
        }
        //if(count(array_unique($new_act_optout)) > 0)
        $update_array['act_optout'] = implode(',', array_unique($new_act_optout));
        //if(count(array_unique($new_not_optout)) > 0)
        $update_array['notify_optout'] = implode(',', array_unique($new_not_optout));
        if (count($update_array)) {
            updateMemberData($memID, $update_array);
        }
        redirectexit($scripturl . '?action=profile;area=activities;sa=settings;u=' . $memID);
    }
}
示例#11
0
function CoppaForm()
{
    global $context, $modSettings, $txt;
    loadLanguage('Login');
    EoS_Smarty::loadTemplate('register/base');
    // No User ID??
    if (!isset($_GET['member'])) {
        fatal_lang_error('no_access', false);
    }
    // Get the user details...
    $request = smf_db_query('
		SELECT member_name
		FROM {db_prefix}members
		WHERE id_member = {int:id_member}
			AND is_activated = {int:is_coppa}', array('id_member' => (int) $_GET['member'], 'is_coppa' => 5));
    if (mysql_num_rows($request) == 0) {
        fatal_lang_error('no_access', false);
    }
    list($username) = mysql_fetch_row($request);
    mysql_free_result($request);
    if (isset($_GET['form'])) {
        // Some simple contact stuff for the forum.
        $context['forum_contacts'] = (!empty($modSettings['coppaPost']) ? $modSettings['coppaPost'] . '<br /><br />' : '') . (!empty($modSettings['coppaFax']) ? $modSettings['coppaFax'] . '<br />' : '');
        $context['forum_contacts'] = !empty($context['forum_contacts']) ? $context['forum_name_html_safe'] . '<br />' . $context['forum_contacts'] : '';
        // Showing template?
        if (!isset($_GET['dl'])) {
            // Shortcut for producing underlines.
            $context['ul'] = '<u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u>';
            $context['template_layers'] = array();
            EoS_Smarty::getConfigInstance()->registerHookTemplate('register_content_area', 'register/coppa_form');
            $context['page_title'] = $txt['coppa_form_title'];
            $context['coppa_body'] = str_replace(array('{PARENT_NAME}', '{CHILD_NAME}', '{USER_NAME}'), array($context['ul'], $context['ul'], $username), $txt['coppa_form_body']);
        } else {
            // The data.
            $ul = '                ';
            $crlf = "\r\n";
            $data = $context['forum_contacts'] . $crlf . $txt['coppa_form_address'] . ':' . $crlf . $txt['coppa_form_date'] . ':' . $crlf . $crlf . $crlf . $txt['coppa_form_body'];
            $data = str_replace(array('{PARENT_NAME}', '{CHILD_NAME}', '{USER_NAME}', '<br>', '<br />'), array($ul, $ul, $username, $crlf, $crlf), $data);
            // Send the headers.
            header('Connection: close');
            header('Content-Disposition: attachment; filename="approval.txt"');
            header('Content-Type: ' . ($context['browser']['is_ie'] || $context['browser']['is_opera'] ? 'application/octetstream' : 'application/octet-stream'));
            header('Content-Length: ' . count($data));
            echo $data;
            obExit(false);
        }
    } else {
        $context += array('page_title' => $txt['coppa_title']);
        EoS_Smarty::getConfigInstance()->registerHookTemplate('register_content_area', 'register/coppa_info');
        $context['coppa'] = array('body' => str_replace('{MINIMUM_AGE}', $modSettings['coppaAge'], $txt['coppa_after_registration']), 'many_options' => !empty($modSettings['coppaPost']) && !empty($modSettings['coppaFax']), 'post' => empty($modSettings['coppaPost']) ? '' : $modSettings['coppaPost'], 'fax' => empty($modSettings['coppaFax']) ? '' : $modSettings['coppaFax'], 'phone' => empty($modSettings['coppaPhone']) ? '' : str_replace('{PHONE_NUMBER}', $modSettings['coppaPhone'], $txt['coppa_send_by_phone']), 'id' => $_GET['member']);
    }
}
示例#12
0
function getBoardIndex($boardIndexOptions)
{
    global $smcFunc, $scripturl, $user_info, $modSettings, $txt;
    global $settings, $context;
    // For performance, track the latest post while going through the boards.
    if (!empty($boardIndexOptions['set_latest_post'])) {
        $latest_post = array('timestamp' => 0, 'ref' => 0);
    }
    // Find all boards and categories, as well as related information.  This will be sorted by the natural order of boards and categories, which we control.
    $result_boards = smf_db_query('
		SELECT' . ($boardIndexOptions['include_categories'] ? '
			c.id_cat, c.name AS cat_name, c.description AS cat_desc,' : '') . '
			b.id_board, b.name AS board_name, b.description, b.redirect, b.icon AS boardicon,
			CASE WHEN b.redirect != {string:blank_string} THEN 1 ELSE 0 END AS is_redirect,
			b.num_posts, b.num_topics, b.unapproved_posts, b.unapproved_topics, b.id_parent, b.allow_topics,
			IFNULL(m.poster_time, 0) AS poster_time, IFNULL(mem.member_name, m.poster_name) AS poster_name,
			m.subject, m1.subject AS first_subject, m.id_topic, t.id_first_msg AS id_first_msg, t.id_prefix, m1.icon AS icon, IFNULL(mem.real_name, m.poster_name) AS real_name, p.name as topic_prefix,
			' . ($user_info['is_guest'] ? ' 1 AS is_read, 0 AS new_from,' : '
			(IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read, IFNULL(lb.id_msg, -1) + 1 AS new_from,' . ($boardIndexOptions['include_categories'] ? '
			c.can_collapse, IFNULL(cc.id_member, 0) AS is_collapsed,' : '')) . '
			IFNULL(mem.id_member, 0) AS id_member, m.id_msg,
			IFNULL(mods_mem.id_member, 0) AS id_moderator, mods_mem.real_name AS mod_real_name
		FROM {db_prefix}boards AS b' . ($boardIndexOptions['include_categories'] ? '
			LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)' : '') . '
			LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = b.id_last_msg)
			LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
			LEFT JOIN {db_prefix}prefixes AS p ON (p.id_prefix = t.id_prefix)
			LEFT JOIN {db_prefix}messages AS m1 ON (m1.id_msg = t.id_first_msg)
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . ($user_info['is_guest'] ? '' : '
			LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})' . ($boardIndexOptions['include_categories'] ? '
			LEFT JOIN {db_prefix}collapsed_categories AS cc ON (cc.id_cat = c.id_cat AND cc.id_member = {int:current_member})' : '')) . '
			LEFT JOIN {db_prefix}moderators AS mods ON (mods.id_board = b.id_board)
			LEFT JOIN {db_prefix}members AS mods_mem ON (mods_mem.id_member = mods.id_member)
		WHERE {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? empty($boardIndexOptions['base_level']) ? '' : '
			AND b.child_level >= {int:child_level}' : '
			AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)), array('current_member' => $user_info['id'], 'child_level' => $boardIndexOptions['base_level'], 'blank_string' => ''));
    // Start with an empty array.
    if ($boardIndexOptions['include_categories']) {
        $categories = array();
    } else {
        $this_category = array();
    }
    $total_ignored_boards = 0;
    // Run through the categories and boards (or only boards)....
    while ($row_board = mysql_fetch_assoc($result_boards)) {
        // Perhaps we are ignoring this board?
        $ignoreThisBoard = in_array($row_board['id_board'], $user_info['ignoreboards']);
        $total_ignored_boards += $ignoreThisBoard ? 1 : 0;
        $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0';
        if ($boardIndexOptions['include_categories']) {
            // Haven't set this category yet.
            if (empty($categories[$row_board['id_cat']])) {
                $categories[$row_board['id_cat']] = array('id' => $row_board['id_cat'], 'name' => $row_board['cat_name'], 'desc' => $row_board['cat_desc'], 'is_collapsed' => isset($row_board['can_collapse']) && $row_board['can_collapse'] == 1 && $row_board['is_collapsed'] > 0, 'can_collapse' => isset($row_board['can_collapse']) && $row_board['can_collapse'] == 1, 'collapse_href' => isset($row_board['can_collapse']) ? $scripturl . '?action=collapse;c=' . $row_board['id_cat'] . ';sa=' . ($row_board['is_collapsed'] > 0 ? 'expand;' : 'collapse;') . $context['session_var'] . '=' . $context['session_id'] . '#c' . $row_board['id_cat'] : '', 'collapse_image' => isset($row_board['can_collapse']) ? '<img class="clipsrc ' . ($row_board['is_collapsed'] ? ' _expand' : '_collapse') . '" src="' . $settings['images_url'] . '/clipsrc.png" alt="-" />' : '', 'href' => $scripturl . '#c' . $row_board['id_cat'], 'boards' => array(), 'is_root' => $row_board['cat_name'][0] === '!' ? true : false, 'new' => false);
                $categories[$row_board['id_cat']]['link'] = '<a id="c' . $row_board['id_cat'] . '"></a>' . ($categories[$row_board['id_cat']]['can_collapse'] ? '<a href="' . $categories[$row_board['id_cat']]['collapse_href'] . '">' . $row_board['cat_name'] . '</a>' : $row_board['cat_name']);
            }
            // If this board has new posts in it (and isn't the recycle bin!) then the category is new.
            if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) {
                $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != '';
            }
            // Avoid showing category unread link where it only has redirection boards.
            $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect'];
            // Collapsed category - don't do any of this.
            //if ($categories[$row_board['id_cat']]['is_collapsed'])
            //	continue;
            // Let's save some typing.  Climbing the array might be slower, anyhow.
            $this_category =& $categories[$row_board['id_cat']]['boards'];
        }
        // This is a parent board.
        if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) {
            // Is this a new board, or just another moderator?
            if (!isset($this_category[$row_board['id_board']])) {
                // Not a child.
                $isChild = false;
                $href = URL::board($row_board['id_board'], $row_board['board_name'], 0, false);
                $this_category[$row_board['id_board']] = array('new' => empty($row_board['is_read']), 'id' => $row_board['id_board'], 'name' => $row_board['board_name'], 'description' => $row_board['description'], 'moderators' => array(), 'link_moderators' => array(), 'children' => array(), 'link_children' => array(), 'children_new' => false, 'topics' => $row_board['num_topics'], 'posts' => $row_board['num_posts'], 'is_redirect' => $row_board['is_redirect'], 'is_page' => !empty($row_board['redirect']) && $row_board['redirect'][0] === '%' && intval(substr($row_board['redirect'], 1)) > 0, 'redirect' => $row_board['redirect'], 'boardicon' => $row_board['boardicon'], 'unapproved_topics' => $row_board['unapproved_topics'], 'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'], 'can_approve_posts' => !empty($user_info['mod_cache']['ap']) && ($user_info['mod_cache']['ap'] == array(0) || in_array($row_board['id_board'], $user_info['mod_cache']['ap'])), 'href' => $href, 'link' => '<a href="' . $href . '">' . $row_board['board_name'] . '</a>', 'act_as_cat' => $row_board['allow_topics'] ? false : true, 'ignored' => $ignoreThisBoard);
                $this_category[$row_board['id_board']]['page_link'] = $this_category[$row_board['id_board']]['is_page'] ? URL::topic(intval(substr($this_category[$row_board['id_board']]['redirect'], 1)), $this_category[$row_board['id_board']]['name'], 0) : '';
            }
            if (!empty($row_board['id_moderator'])) {
                $this_category[$row_board['id_board']]['moderators'][$row_board['id_moderator']] = array('id' => $row_board['id_moderator'], 'name' => $row_board['mod_real_name'], 'href' => $scripturl . '?action=profile;u=' . $row_board['id_moderator'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_moderator'] . '" title="' . $txt['board_moderator'] . '">' . $row_board['mod_real_name'] . '</a>');
                $this_category[$row_board['id_board']]['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_moderator'] . '" title="' . $txt['board_moderator'] . '">' . $row_board['mod_real_name'] . '</a>';
            }
        } elseif (isset($this_category[$row_board['id_parent']]['children']) && !isset($this_category[$row_board['id_parent']]['children'][$row_board['id_board']])) {
            // A valid child!
            $isChild = true;
            $href = URL::board($row_board['id_board'], $row_board['board_name'], 0, false);
            $this_category[$row_board['id_parent']]['children'][$row_board['id_board']] = array('id' => $row_board['id_board'], 'name' => $row_board['board_name'], 'description' => $row_board['description'], 'short_description' => !empty($row_board['description']) ? $modSettings['child_board_desc_shortened'] ? '(' . commonAPI::substr($row_board['description'], 0, $modSettings['child_board_desc_shortened']) . '...)' : '(' . $row_board['description'] . ')' : '', 'new' => empty($row_board['is_read']) && $row_board['poster_name'] != '', 'topics' => $row_board['num_topics'], 'posts' => $row_board['num_posts'], 'is_redirect' => $row_board['is_redirect'], 'is_page' => !empty($row_board['redirect']) && $row_board['redirect'][0] === '%' && intval(substr($row_board['redirect'], 1)) > 0, 'redirect' => $row_board['redirect'], 'boardicon' => $row_board['boardicon'], 'unapproved_topics' => $row_board['unapproved_topics'], 'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'], 'can_approve_posts' => !empty($user_info['mod_cache']['ap']) && ($user_info['mod_cache']['ap'] == array(0) || in_array($row_board['id_board'], $user_info['mod_cache']['ap'])), 'href' => $href, 'link' => '<a href="' . $href . '">' . $row_board['board_name'] . '</a>', 'act_as_cat' => $row_board['allow_topics'] ? false : true, 'ignored' => $ignoreThisBoard);
            $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['page_link'] = $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['is_page'] ? URL::topic(intval(substr($this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['redirect'], 1)), $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['name'], 0) : '';
            // Counting child board posts is... slow :/.
            if (!empty($boardIndexOptions['countChildPosts']) && !$row_board['is_redirect']) {
                $this_category[$row_board['id_parent']]['posts'] += $row_board['num_posts'];
                $this_category[$row_board['id_parent']]['topics'] += $row_board['num_topics'];
            }
            // Does this board contain new boards?
            $this_category[$row_board['id_parent']]['children_new'] |= empty($row_board['is_read']);
            // This is easier to use in many cases for the theme....
            $this_category[$row_board['id_parent']]['link_children'][] =& $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['link'];
        } elseif (!empty($boardIndexOptions['countChildPosts'])) {
            if (!isset($parent_map)) {
                $parent_map = array();
            }
            if (!isset($parent_map[$row_board['id_parent']])) {
                foreach ($this_category as $id => $board) {
                    if (!isset($board['children'][$row_board['id_parent']])) {
                        continue;
                    }
                    $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]);
                    $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]);
                    break;
                }
            }
            if (isset($parent_map[$row_board['id_parent']]) && !$row_board['is_redirect']) {
                $parent_map[$row_board['id_parent']][0]['posts'] += $row_board['num_posts'];
                $parent_map[$row_board['id_parent']][0]['topics'] += $row_board['num_topics'];
                $parent_map[$row_board['id_parent']][1]['posts'] += $row_board['num_posts'];
                $parent_map[$row_board['id_parent']][1]['topics'] += $row_board['num_topics'];
                continue;
            }
            continue;
        } else {
            continue;
        }
        // Prepare the subject, and make sure it's not too long.
        censorText($row_board['subject']);
        $mhref = $row_board['poster_name'] != '' && !empty($row_board['id_member']) ? URL::user($row_board['id_member'], $row_board['real_name']) : '';
        $this_last_post = array('id' => $row_board['id_msg'], 'time' => $row_board['poster_time'] > 0 ? timeformat($row_board['poster_time']) : $txt['not_applicable'], 'timestamp' => forum_time(true, $row_board['poster_time']), 'member' => array('id' => $row_board['id_member'], 'username' => $row_board['poster_name'] != '' ? $row_board['poster_name'] : $txt['not_applicable'], 'name' => $row_board['real_name'], 'href' => $mhref, 'link' => $row_board['poster_name'] != '' ? !empty($row_board['id_member']) ? '<a onclick="getMcard(' . $row_board['id_member'] . ', $(this));return(false);" href="' . $mhref . '">' . $row_board['real_name'] . '</a>' : $row_board['real_name'] : $txt['not_applicable']), 'start' => 'msg' . $row_board['new_from'], 'topic' => $row_board['id_topic'], 'prefix' => !empty($row_board['topic_prefix']) ? html_entity_decode($row_board['topic_prefix']) . '&nbsp;' : '');
        $row_board['short_subject'] = shorten_subject($row_board['subject'], 50);
        $this_last_post['subject'] = $row_board['short_subject'];
        $this_first_post = array('id' => $row_board['id_first_msg'], 'icon' => $row_board['icon'], 'icon_url' => getPostIcon($row_board['icon']));
        // Provide the href and link.
        if ($row_board['subject'] != '') {
            $this_last_post['href'] = URL::topic($row_board['id_topic'], $row_board['first_subject'], 0, false, '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']), '#new');
            if (empty($row_board['is_read'])) {
                $this_last_post['href'] = URL::addParam($this_last_post['href'], 'boardseen');
            }
            //$this_last_post['href'] = $scripturl . '?topic=' . $row_board['id_topic'] . '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']) . (empty($row_board['is_read']) ? ';boardseen' : '') . '#new';
            $this_last_post['link'] = '<a rel="nofollow" href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>';
            $this_last_post['topichref'] = URL::topic($row_board['id_topic'], $row_board['first_subject'], 0);
            // $scripturl . '?topic=' . $row_board['id_topic'];
            $this_last_post['topiclink'] = '<a href="' . $this_last_post['topichref'] . '" title="' . $row_board['first_subject'] . '">' . $row_board['short_subject'] . '</a>';
        } else {
            $this_last_post['href'] = '';
            $this_last_post['link'] = $txt['not_applicable'];
            $this_last_post['topiclink'] = $txt['not_applicable'];
        }
        // Set the last post in the parent board.
        if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || $isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time'])) {
            $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post;
            $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['first_post'] = $this_first_post;
        }
        // Just in the child...?
        if ($isChild) {
            $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post;
            $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['first_post'] = $this_first_post;
            // If there are no posts in this board, it really can't be new...
            $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != '';
        } elseif ($row_board['poster_name'] == '') {
            $this_category[$row_board['id_board']]['new'] = false;
        }
        // Determine a global most recent topic.
        if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) {
            $latest_post = array('timestamp' => $row_board['poster_time'], 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post']);
        }
    }
    mysql_free_result($result_boards);
    // By now we should know the most recent post...if we wanna know it that is.
    if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) {
        $context['latest_post'] = $latest_post['ref'];
    }
    $hidden_boards = $visible_boards = 0;
    $context['hidden_boards']['id'] = $context['hidden_boards']['is_collapsed'] = 0;
    // only run this if we actually have some boards on the ignore list to save cycles.
    if ($total_ignored_boards) {
        if ($boardIndexOptions['include_categories']) {
            foreach ($categories as &$cat) {
                $hidden_boards += hideIgnoredBoards($cat['boards']);
            }
        } else {
            if (count($this_category)) {
                $hidden_boards += hideIgnoredBoards($this_category);
            }
        }
        $context['hidden_boards']['notice'] = $txt[$hidden_boards > 1 ? 'hidden_boards_notice_many' : 'hidden_boards_notice_one'];
        $context['hidden_boards']['setup_notice'] = sprintf($txt['hidden_boards_setup_notice'], $scripturl . '?action=profile;area=ignoreboards');
    }
    $context['hidden_boards']['hidden_count'] = $hidden_boards;
    $context['hidden_boards']['visible_count'] = $visible_boards;
    return $boardIndexOptions['include_categories'] ? $categories : $this_category;
}
示例#13
0
function scheduled_paid_subscriptions()
{
    global $txt, $sourcedir, $scripturl, $modSettings, $language;
    // Start off by checking for removed subscriptions.
    $request = smf_db_query('
		SELECT id_subscribe, id_member
		FROM {db_prefix}log_subscribed
		WHERE status = {int:is_active}
			AND end_time < {int:time_now}', array('is_active' => 1, 'time_now' => time()));
    while ($row = mysql_fetch_assoc($request)) {
        require_once $sourcedir . '/ManagePaid.php';
        removeSubscription($row['id_subscribe'], $row['id_member']);
    }
    mysql_free_result($request);
    // Get all those about to expire that have not had a reminder sent.
    $request = smf_db_query('
		SELECT ls.id_sublog, m.id_member, m.member_name, m.email_address, m.lngfile, s.name, ls.end_time
		FROM {db_prefix}log_subscribed AS ls
			INNER JOIN {db_prefix}subscriptions AS s ON (s.id_subscribe = ls.id_subscribe)
			INNER JOIN {db_prefix}members AS m ON (m.id_member = ls.id_member)
		WHERE ls.status = {int:is_active}
			AND ls.reminder_sent = {int:reminder_sent}
			AND s.reminder > {int:reminder_wanted}
			AND ls.end_time < ({int:time_now} + s.reminder * 86400)', array('is_active' => 1, 'reminder_sent' => 0, 'reminder_wanted' => 0, 'time_now' => time()));
    $subs_reminded = array();
    while ($row = mysql_fetch_assoc($request)) {
        // If this is the first one load the important bits.
        if (empty($subs_reminded)) {
            require_once $sourcedir . '/lib/Subs-Post.php';
            // Need the below for loadLanguage to work!
            loadEssentialThemeData();
        }
        $subs_reminded[] = $row['id_sublog'];
        $replacements = array('PROFILE_LINK' => $scripturl . '?action=profile;area=subscriptions;u=' . $row['id_member'], 'REALNAME' => $row['member_name'], 'SUBSCRIPTION' => $row['name'], 'END_DATE' => strip_tags(timeformat($row['end_time'])));
        $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
        // Send the actual email.
        sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, null, false, 2);
    }
    mysql_free_result($request);
    // Mark the reminder as sent.
    if (!empty($subs_reminded)) {
        smf_db_query('
			UPDATE {db_prefix}log_subscribed
			SET reminder_sent = {int:reminder_sent}
			WHERE id_sublog IN ({array_int:subscription_list})', array('subscription_list' => $subs_reminded, 'reminder_sent' => 1));
    }
    return true;
}
示例#14
0
function Sticky()
{
    global $modSettings, $topic, $board, $sourcedir;
    // Make sure the user can sticky it, and they are stickying *something*.
    isAllowedTo('make_sticky');
    // You shouldn't be able to (un)sticky a topic if the setting is disabled.
    if (empty($modSettings['enableStickyTopics'])) {
        fatal_lang_error('cannot_make_sticky', false);
    }
    // You can't sticky a board or something!
    if (empty($topic)) {
        fatal_lang_error('not_a_topic', false);
    }
    checkSession('get');
    // We need Subs-Post.php for the sendNotifications() function.
    require_once $sourcedir . '/lib/Subs-Post.php';
    // Is this topic already stickied, or no?
    $request = smf_db_query('
		SELECT is_sticky
		FROM {db_prefix}topics
		WHERE id_topic = {int:current_topic}
		LIMIT 1', array('current_topic' => $topic));
    list($is_sticky) = mysql_fetch_row($request);
    mysql_free_result($request);
    // Toggle the sticky value.... pretty simple ;).
    smf_db_query('
		UPDATE {db_prefix}topics
		SET is_sticky = {int:is_sticky}
		WHERE id_topic = {int:current_topic}', array('current_topic' => $topic, 'is_sticky' => empty($is_sticky) ? 1 : 0));
    // Log this sticky action - always a moderator thing.
    logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board));
    // Notify people that this topic has been stickied?
    if (empty($is_sticky)) {
        sendNotifications($topic, 'sticky');
    }
    // Take them back to the now stickied topic.
    redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
}
示例#15
0
文件: Modlog.php 项目: norv/EosAlpha
function list_getModLogEntries($start, $items_per_page, $sort, $query_string = '', $query_params = array(), $log_type = 1)
{
    global $context, $scripturl, $txt, $smcFunc, $user_info;
    $modlog_query = allowedTo('admin_forum') || $user_info['mod_cache']['bq'] == '1=1' ? '1=1' : ($user_info['mod_cache']['bq'] == '0=1' ? 'lm.id_board = 0 AND lm.id_topic = 0' : strtr($user_info['mod_cache']['bq'], array('id_board' => 'b.id_board')) . ' AND ' . strtr($user_info['mod_cache']['bq'], array('id_board' => 't.id_board')));
    // Do a little bit of self protection.
    if (!isset($context['hoursdisable'])) {
        $context['hoursdisable'] = 24;
    }
    // Can they see the IP address?
    $seeIP = allowedTo('moderate_forum');
    // Here we have the query getting the log details.
    $result = smf_db_query('
		SELECT
			lm.id_action, lm.id_member, lm.ip, lm.log_time, lm.action, lm.id_board, lm.id_topic, lm.id_msg, lm.extra,
			mem.real_name, mg.group_name
		FROM {db_prefix}log_actions AS lm
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lm.id_member)
			LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_group_id} THEN mem.id_post_group ELSE mem.id_group END)
			LEFT JOIN {db_prefix}boards AS b ON (b.id_board = lm.id_board)
			LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = lm.id_topic)
			WHERE id_log = {int:log_type}
				AND {raw:modlog_query}' . (!empty($query_string) ? '
				AND ' . $query_string : '') . '
		ORDER BY ' . $sort . '
		LIMIT ' . $start . ', ' . $items_per_page, array_merge($query_params, array('reg_group_id' => 0, 'log_type' => $log_type, 'modlog_query' => $modlog_query)));
    // Arrays for decoding objects into.
    $topics = array();
    $boards = array();
    $members = array();
    $messages = array();
    $entries = array();
    while ($row = mysql_fetch_assoc($result)) {
        $row['extra'] = @unserialize($row['extra']);
        // Corrupt?
        $row['extra'] = is_array($row['extra']) ? $row['extra'] : array();
        // Add on some of the column stuff info
        if (!empty($row['id_board'])) {
            if ($row['action'] == 'move') {
                $row['extra']['board_to'] = $row['id_board'];
            } else {
                $row['extra']['board'] = $row['id_board'];
            }
        }
        if (!empty($row['id_topic'])) {
            $row['extra']['topic'] = $row['id_topic'];
        }
        if (!empty($row['id_msg'])) {
            $row['extra']['message'] = $row['id_msg'];
        }
        // 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'])) {
            // Guests don't have names!
            if (empty($row['extra']['member'])) {
                $row['extra']['member'] = $txt['modlog_parameter_guest'];
            } else {
                // Try to find it...
                $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'];
        }
        if (isset($row['extra']['board'])) {
            $boards[(int) $row['extra']['board']][] = $row['id_action'];
        }
        // A message?
        if (isset($row['extra']['message'])) {
            $messages[(int) $row['extra']['message']][] = $row['id_action'];
        }
        // IP Info?
        if (isset($row['extra']['ip_range'])) {
            if ($seeIP) {
                $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>';
            } else {
                $row['extra']['ip_range'] = $txt['logged'];
            }
        }
        // Email?
        if (isset($row['extra']['email'])) {
            $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
        }
        // Bans are complex.
        if ($row['action'] == 'ban') {
            $row['action_text'] = $txt['modlog_ac_ban'];
            foreach (array('member', 'email', 'ip_range', 'hostname') as $type) {
                if (isset($row['extra'][$type])) {
                    $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type];
                }
            }
        }
        // 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.
        $entries[$row['id_action']] = array('id' => $row['id_action'], 'ip' => $seeIP ? $row['ip'] : $txt['logged'], 'position' => empty($row['real_name']) && empty($row['group_name']) ? $txt['guest'] : $row['group_name'], 'moderator_link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>' : (empty($row['real_name']) ? $txt['guest'] . (!empty($row['extra']['member_acted']) ? ' (' . $row['extra']['member_acted'] . ')' : '') : $row['real_name']), 'time' => timeformat($row['log_time']), 'timestamp' => forum_time(true, $row['log_time']), 'editable' => time() > $row['log_time'] + $context['hoursdisable'] * 3600, 'extra' => $row['extra'], 'action' => $row['action'], 'action_text' => isset($row['action_text']) ? $row['action_text'] : '');
    }
    mysql_free_result($result);
    if (!empty($boards)) {
        $request = smf_db_query('
			SELECT id_board, name
			FROM {db_prefix}boards
			WHERE id_board IN ({array_int:board_list})
			LIMIT ' . count(array_keys($boards)), array('board_list' => array_keys($boards)));
        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 (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) {
                    $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
                } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) {
                    $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
                } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) {
                    $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
                }
            }
        }
        mysql_free_result($request);
    }
    if (!empty($topics)) {
        $request = smf_db_query('
			SELECT ms.subject, t.id_topic
			FROM {db_prefix}topics AS t
				INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
			WHERE t.id_topic IN ({array_int:topic_list})
			LIMIT ' . count(array_keys($topics)), array('topic_list' => array_keys($topics)));
        while ($row = mysql_fetch_assoc($request)) {
            foreach ($topics[$row['id_topic']] as $action) {
                $this_action =& $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 (isset($this_action['extra']['topic']) && $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 (isset($this_action['extra']['new_topic']) && $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($messages)) {
        $request = smf_db_query('
			SELECT id_msg, subject
			FROM {db_prefix}messages
			WHERE id_msg IN ({array_int:message_list})
			LIMIT ' . count(array_keys($messages)), array('message_list' => array_keys($messages)));
        while ($row = mysql_fetch_assoc($request)) {
            foreach ($messages[$row['id_msg']] as $action) {
                $this_action =& $entries[$action];
                // This isn't used in the current theme.
                $this_action['message'] = array('id' => $row['id_msg'], 'subject' => $row['subject'], 'href' => $scripturl . '?msg=' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>');
                // Make the message number into a link.
                if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) {
                    $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
                }
            }
        }
        mysql_free_result($request);
    }
    if (!empty($members)) {
        $request = smf_db_query('
			SELECT real_name, id_member
			FROM {db_prefix}members
			WHERE id_member IN ({array_int:member_list})
			LIMIT ' . count(array_keys($members)), array('member_list' => array_keys($members)));
        while ($row = mysql_fetch_assoc($request)) {
            foreach ($members[$row['id_member']] as $action) {
                // Not used currently.
                $entries[$action]['member'] = array('id' => $row['id_member'], 'name' => $row['real_name'], 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>');
                // Make the member number into a name.
                $entries[$action]['extra']['member'] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
            }
        }
        mysql_free_result($request);
    }
    // Do some formatting of the action string.
    foreach ($entries as $k => $entry) {
        // Make any message info links so its easier to go find that message.
        if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) {
            $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
        }
        // Mark up any deleted members, topics and boards.
        foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) {
            if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) {
                $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]);
            }
        }
        if (empty($entries[$k]['action_text'])) {
            $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
        }
        $entries[$k]['action_text'] = preg_replace('~\\{([A-Za-z\\d_]+)\\}~ie', 'isset($entries[$k][\'extra\'][\'$1\']) ? $entries[$k][\'extra\'][\'$1\'] : \'\'', $entries[$k]['action_text']);
    }
    // Back we go!
    return $entries;
}
示例#16
0
function smf_db_get_version()
{
    $request = smf_db_query('
		SELECT VERSION()', array());
    list($ver) = mysql_fetch_row($request);
    mysql_free_result($request);
    return $ver;
}
示例#17
0
function PackagePermissions()
{
    global $context, $txt, $modSettings, $boarddir, $sourcedir, $cachedir, $package_ftp;
    // Let's try and be good, yes?
    checkSession('get');
    // If we're restoring permissions this is just a pass through really.
    if (isset($_GET['restore'])) {
        create_chmod_control(array(), array(), true);
        fatal_lang_error('no_access', false);
    }
    // This is a memory eat.
    @ini_set('memory_limit', '128M');
    @set_time_limit(600);
    // Load up some FTP stuff.
    create_chmod_control();
    if (empty($package_ftp) && !isset($_POST['skip_ftp'])) {
        loadClassFile('Class-Package.php');
        $ftp = new ftp_connection(null);
        list($username, $detect_path, $found_path) = $ftp->detect_path($boarddir);
        $context['package_ftp'] = array('server' => isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost', 'port' => isset($modSettings['package_port']) ? $modSettings['package_port'] : '21', 'username' => empty($username) ? isset($modSettings['package_username']) ? $modSettings['package_username'] : '' : $username, 'path' => $detect_path, 'form_elements_only' => true);
    } else {
        $context['ftp_connected'] = true;
    }
    // Define the template.
    $context['page_title'] = $txt['package_file_perms'];
    $context['sub_template'] = 'file_permissions';
    // Define what files we're interested in, as a tree.
    $context['file_tree'] = array(strtr($boarddir, array('\\' => '/')) => array('type' => 'dir', 'contents' => array('agreement.txt' => array('type' => 'file', 'writable_on' => 'standard'), 'Settings.php' => array('type' => 'file', 'writable_on' => 'restrictive'), 'Settings_bak.php' => array('type' => 'file', 'writable_on' => 'restrictive'), 'attachments' => array('type' => 'dir', 'writable_on' => 'restrictive'), 'avatars' => array('type' => 'dir', 'writable_on' => 'standard'), 'cache' => array('type' => 'dir', 'writable_on' => 'restrictive'), 'custom_avatar_dir' => array('type' => 'dir', 'writable_on' => 'restrictive'), 'Smileys' => array('type' => 'dir_recursive', 'writable_on' => 'standard'), 'Sources' => array('type' => 'dir', 'list_contents' => true, 'writable_on' => 'standard'), 'Themes' => array('type' => 'dir_recursive', 'writable_on' => 'standard', 'contents' => array('default' => array('type' => 'dir_recursive', 'list_contents' => true, 'contents' => array('languages' => array('type' => 'dir', 'list_contents' => true))))), 'Packages' => array('type' => 'dir', 'writable_on' => 'standard', 'contents' => array('temp' => array('type' => 'dir'), 'backup' => array('type' => 'dir'), 'installed.list' => array('type' => 'file', 'writable_on' => 'standard'))))));
    // Directories that can move.
    if (substr($sourcedir, 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Sources']);
        $context['file_tree'][strtr($sourcedir, array('\\' => '/'))] = array('type' => 'dir', 'list_contents' => true, 'writable_on' => 'standard');
    }
    // Moved the cache?
    if (substr($cachedir, 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['cache']);
        $context['file_tree'][strtr($cachedir, array('\\' => '/'))] = array('type' => 'dir', 'list_contents' => false, 'writable_on' => 'restrictive');
    }
    // Are we using multiple attachment directories?
    if (!empty($modSettings['currentAttachmentUploadDir'])) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']);
        if (!is_array($modSettings['attachmentUploadDir'])) {
            $modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
        }
        // !!! Should we suggest non-current directories be read only?
        foreach ($modSettings['attachmentUploadDir'] as $dir) {
            $context['file_tree'][strtr($dir, array('\\' => '/'))] = array('type' => 'dir', 'writable_on' => 'restrictive');
        }
    } elseif (substr($modSettings['attachmentUploadDir'], 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']);
        $context['file_tree'][strtr($modSettings['attachmentUploadDir'], array('\\' => '/'))] = array('type' => 'dir', 'writable_on' => 'restrictive');
    }
    if (substr($modSettings['smileys_dir'], 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Smileys']);
        $context['file_tree'][strtr($modSettings['smileys_dir'], array('\\' => '/'))] = array('type' => 'dir_recursive', 'writable_on' => 'standard');
    }
    if (substr($modSettings['avatar_directory'], 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['avatars']);
        $context['file_tree'][strtr($modSettings['avatar_directory'], array('\\' => '/'))] = array('type' => 'dir', 'writable_on' => 'standard');
    }
    if (isset($modSettings['custom_avatar_dir']) && substr($modSettings['custom_avatar_dir'], 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['custom_avatar_dir']);
        $context['file_tree'][strtr($modSettings['custom_avatar_dir'], array('\\' => '/'))] = array('type' => 'dir', 'writable_on' => 'restrictive');
    }
    // Load up any custom themes.
    $request = smf_db_query('
		SELECT value
		FROM {db_prefix}themes
		WHERE id_theme > {int:default_theme_id}
			AND id_member = {int:guest_id}
			AND variable = {string:theme_dir}
		ORDER BY value ASC', array('default_theme_id' => 1, 'guest_id' => 0, 'theme_dir' => 'theme_dir'));
    while ($row = mysql_fetch_assoc($request)) {
        if (substr(strtolower(strtr($row['value'], array('\\' => '/'))), 0, strlen($boarddir) + 7) == strtolower(strtr($boarddir, array('\\' => '/')) . '/Themes')) {
            $context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Themes']['contents'][substr($row['value'], strlen($boarddir) + 8)] = array('type' => 'dir_recursive', 'list_contents' => true, 'contents' => array('languages' => array('type' => 'dir', 'list_contents' => true)));
        } else {
            $context['file_tree'][strtr($row['value'], array('\\' => '/'))] = array('type' => 'dir_recursive', 'list_contents' => true, 'contents' => array('languages' => array('type' => 'dir', 'list_contents' => true)));
        }
    }
    mysql_free_result($request);
    // If we're submitting then let's move on to another function to keep things cleaner..
    if (isset($_POST['action_changes'])) {
        return PackagePermissionsAction();
    }
    $context['look_for'] = array();
    // Are we looking for a particular tree - normally an expansion?
    if (!empty($_REQUEST['find'])) {
        $context['look_for'][] = base64_decode($_REQUEST['find']);
    }
    // Only that tree?
    $context['only_find'] = isset($_GET['xml']) && !empty($_REQUEST['onlyfind']) ? $_REQUEST['onlyfind'] : '';
    if ($context['only_find']) {
        $context['look_for'][] = $context['only_find'];
    }
    // Have we got a load of back-catalogue trees to expand from a submit etc?
    if (!empty($_GET['back_look'])) {
        $potententialTrees = unserialize(base64_decode($_GET['back_look']));
        foreach ($potententialTrees as $tree) {
            $context['look_for'][] = $tree;
        }
    }
    // ... maybe posted?
    if (!empty($_POST['back_look'])) {
        $context['only_find'] = array_merge($context['only_find'], $_POST['back_look']);
    }
    $context['back_look_data'] = base64_encode(serialize(array_slice($context['look_for'], 0, 15)));
    // Are we finding more files than first thought?
    $context['file_offset'] = !empty($_REQUEST['fileoffset']) ? (int) $_REQUEST['fileoffset'] : 0;
    // Don't list more than this many files in a directory.
    $context['file_limit'] = 150;
    // How many levels shall we show?
    $context['default_level'] = empty($context['only_find']) ? 2 : 25;
    // This will be used if we end up catching XML data.
    $context['xml_data'] = array('roots' => array('identifier' => 'root', 'children' => array(array('value' => preg_replace('~[^A-Za-z0-9_\\-=:]~', ':-:', $context['only_find'])))), 'folders' => array('identifier' => 'folder', 'children' => array()));
    foreach ($context['file_tree'] as $path => $data) {
        // Run this directory.
        if (file_exists($path) && (empty($context['only_find']) || substr($context['only_find'], 0, strlen($path)) == $path)) {
            // Get the first level down only.
            fetchPerms__recursive($path, $context['file_tree'][$path], 1);
            $context['file_tree'][$path]['perms'] = array('chmod' => @is_writable($path), 'perms' => @fileperms($path));
        } else {
            unset($context['file_tree'][$path]);
        }
    }
    // Is this actually xml?
    if (isset($_GET['xml'])) {
        loadTemplate('Xml');
        $context['sub_template'] = 'generic_xml';
        $context['template_layers'] = array();
    }
}
示例#18
0
function ModifyLanguage()
{
    global $settings, $context, $txt, $modSettings, $boarddir, $sourcedir, $language;
    loadLanguage('ManageSettings');
    // Select the languages tab.
    $context['menu_data_' . $context['admin_menu_id']]['current_subsection'] = 'edit';
    $context['page_title'] = $txt['edit_languages'];
    $context['sub_template'] = 'modify_language_entries';
    $context['lang_id'] = $_GET['lid'];
    list($theme_id, $file_id) = empty($_REQUEST['tfid']) || strpos($_REQUEST['tfid'], '+') === false ? array(1, '') : explode('+', $_REQUEST['tfid']);
    // Clean the ID - just in case.
    preg_match('~([A-Za-z0-9_-]+)~', $context['lang_id'], $matches);
    $context['lang_id'] = $matches[1];
    // Get all the theme data.
    $request = smf_db_query('
		SELECT id_theme, variable, value
		FROM {db_prefix}themes
		WHERE id_theme != {int:default_theme}
			AND id_member = {int:no_member}
			AND variable IN ({string:name}, {string:theme_dir})', array('default_theme' => 1, 'no_member' => 0, 'name' => 'name', 'theme_dir' => 'theme_dir'));
    $themes = array(1 => array('name' => $txt['dvc_default'], 'theme_dir' => $settings['default_theme_dir']));
    while ($row = mysql_fetch_assoc($request)) {
        $themes[$row['id_theme']][$row['variable']] = $row['value'];
    }
    mysql_free_result($request);
    // This will be where we look
    $lang_dirs = array();
    // Check we have themes with a path and a name - just in case - and add the path.
    foreach ($themes as $id => $data) {
        if (count($data) != 2) {
            unset($themes[$id]);
        } elseif (is_dir($data['theme_dir'] . '/languages')) {
            $lang_dirs[$id] = $data['theme_dir'] . '/languages';
        }
        // How about image directories?
        if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) {
            $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
        }
    }
    $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : '';
    // Now for every theme get all the files and stick them in context!
    $context['possible_files'] = array();
    foreach ($lang_dirs as $theme => $theme_dir) {
        // Open it up.
        $dir = dir($theme_dir);
        while ($entry = $dir->read()) {
            // We're only after the files for this language.
            if (preg_match('~^([A-Za-z]+)\\.' . $context['lang_id'] . '\\.php$~', $entry, $matches) == 0) {
                continue;
            }
            //!!! Temp!
            if ($matches[1] == 'EmailTemplates') {
                continue;
            }
            if (!isset($context['possible_files'][$theme])) {
                $context['possible_files'][$theme] = array('id' => $theme, 'name' => $themes[$theme]['name'], 'files' => array());
            }
            $context['possible_files'][$theme]['files'][] = array('id' => $matches[1], 'name' => isset($txt['lang_file_desc_' . $matches[1]]) ? $txt['lang_file_desc_' . $matches[1]] : $matches[1], 'selected' => $theme_id == $theme && $file_id == $matches[1]);
        }
        $dir->close();
    }
    // We no longer wish to speak this language.
    if (!empty($_POST['delete_main']) && $context['lang_id'] != 'english') {
        checkSession();
        // !!! Todo: FTP Controls?
        require_once $sourcedir . '/lib/Subs-Package.php';
        // First, Make a backup?
        if (!empty($modSettings['package_make_backups']) && (!isset($_SESSION['last_backup_for']) || $_SESSION['last_backup_for'] != $context['lang_id'] . '$$$')) {
            $_SESSION['last_backup_for'] = $context['lang_id'] . '$$$';
            package_create_backup('backup_lang_' . $context['lang_id']);
        }
        // Second, loop through the array to remove the files.
        foreach ($lang_dirs as $curPath) {
            foreach ($context['possible_files'][1]['files'] as $lang) {
                if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) {
                    unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php');
                }
            }
            // Check for the email template.
            if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) {
                unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
            }
        }
        // Third, the agreement file.
        if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) {
            unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
        }
        // Fourth, a related images folder?
        foreach ($images_dirs as $curPath) {
            if (is_dir($curPath)) {
                deltree($curPath);
            }
        }
        // Members can no longer use this language.
        smf_db_query('
			UPDATE {db_prefix}members
			SET lngfile = {string:empty_string}
			WHERE lngfile = {string:current_language}', array('empty_string' => '', 'current_language' => $context['lang_id']));
        // Fifth, update getLanguages() cache.
        if (!empty($modSettings['cache_enable'])) {
            CacheAPI::putCache('known_languages', null, !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
            CacheAPI::putCache('known_languages_all', null, !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
        }
        // Sixth, if we deleted the default language, set us back to english?
        if ($context['lang_id'] == $language) {
            require_once $sourcedir . '/lib/Subs-Admin.php';
            $language = 'english';
            updateSettingsFile(array('language' => '\'' . $language . '\''));
        }
        // Seventh, get out of here.
        redirectexit('action=admin;area=languages;sa=edit;' . $context['session_var'] . '=' . $context['session_id']);
    }
    // Saving primary settings?
    $madeSave = false;
    if (!empty($_POST['save_main']) && !$current_file) {
        checkSession();
        // Read in the current file.
        $current_data = implode('', file($settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php'));
        // These are the replacements. old => new
        $replace_array = array('~\\$txt\\[\'lang_character_set\'\\]\\s=\\s(\'|")[^\\r\\n]+~' => '$txt[\'lang_character_set\'] = \'' . addslashes($_POST['character_set']) . '\';', '~\\$txt\\[\'lang_locale\'\\]\\s=\\s(\'|")[^\\r\\n]+~' => '$txt[\'lang_locale\'] = \'' . addslashes($_POST['locale']) . '\';', '~\\$txt\\[\'lang_dictionary\'\\]\\s=\\s(\'|")[^\\r\\n]+~' => '$txt[\'lang_dictionary\'] = \'' . addslashes($_POST['dictionary']) . '\';', '~\\$txt\\[\'lang_spelling\'\\]\\s=\\s(\'|")[^\\r\\n]+~' => '$txt[\'lang_spelling\'] = \'' . addslashes($_POST['spelling']) . '\';', '~\\$txt\\[\'lang_rtl\'\\]\\s=\\s[A-Za-z0-9]+;~' => '$txt[\'lang_rtl\'] = ' . (!empty($_POST['rtl']) ? 'true' : 'false') . ';');
        $current_data = preg_replace(array_keys($replace_array), array_values($replace_array), $current_data);
        $fp = fopen($settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php', 'w+');
        fwrite($fp, $current_data);
        fclose($fp);
        $madeSave = true;
    }
    // Quickly load index language entries.
    $old_txt = $txt;
    require $settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php';
    $context['lang_file_not_writable_message'] = is_writable($settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php') ? '' : sprintf($txt['lang_file_not_writable'], $settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php');
    // Setup the primary settings context.
    $context['primary_settings'] = array('name' => commonAPI::ucwords(strtr($context['lang_id'], array('_' => ' ', '-utf8' => ''))), 'character_set' => $txt['lang_character_set'], 'locale' => $txt['lang_locale'], 'dictionary' => $txt['lang_dictionary'], 'spelling' => $txt['lang_spelling'], 'rtl' => $txt['lang_rtl']);
    // Restore normal service.
    $txt = $old_txt;
    // Are we saving?
    $save_strings = array();
    if (isset($_POST['save_entries']) && !empty($_POST['entry'])) {
        checkSession();
        // Clean each entry!
        foreach ($_POST['entry'] as $k => $v) {
            // Only try to save if it's changed!
            if ($_POST['entry'][$k] != $_POST['comp'][$k]) {
                $save_strings[$k] = cleanLangString($v, false);
            }
        }
    }
    // If we are editing a file work away at that.
    if ($current_file) {
        $context['entries_not_writable_message'] = is_writable($current_file) ? '' : sprintf($txt['lang_entries_not_writable'], $current_file);
        $entries = array();
        // We can't just require it I'm afraid - otherwise we pass in all kinds of variables!
        $multiline_cache = '';
        foreach (file($current_file) as $line) {
            // Got a new entry?
            if ($line[0] == '$' && !empty($multiline_cache)) {
                preg_match('~\\$(helptxt|txt)\\[\'(.+)\'\\]\\s=\\s(.+);~', strtr($multiline_cache, array("\n" => '', "\t" => '')), $matches);
                if (!empty($matches[3])) {
                    $entries[$matches[2]] = array('type' => $matches[1], 'full' => $matches[0], 'entry' => $matches[3]);
                    $multiline_cache = '';
                }
            }
            $multiline_cache .= $line . "\n";
        }
        // Last entry to add?
        if ($multiline_cache) {
            preg_match('~\\$(helptxt|txt)\\[\'(.+)\'\\]\\s=\\s(.+);~', strtr($multiline_cache, array("\n" => '', "\t" => '')), $matches);
            if (!empty($matches[3])) {
                $entries[$matches[2]] = array('type' => $matches[1], 'full' => $matches[0], 'entry' => $matches[3]);
            }
        }
        // These are the entries we can definitely save.
        $final_saves = array();
        $context['file_entries'] = array();
        foreach ($entries as $entryKey => $entryValue) {
            // Ignore some things we set separately.
            $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl');
            if (in_array($entryKey, $ignore_files)) {
                continue;
            }
            // These are arrays that need breaking out.
            $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short');
            if (in_array($entryKey, $arrays)) {
                // Get off the first bits.
                $entryValue['entry'] = substr($entryValue['entry'], strpos($entryValue['entry'], '(') + 1, strrpos($entryValue['entry'], ')') - strpos($entryValue['entry'], '('));
                $entryValue['entry'] = explode(',', strtr($entryValue['entry'], array(' ' => '')));
                // Now create an entry for each item.
                $cur_index = 0;
                $save_cache = array('enabled' => false, 'entries' => array());
                foreach ($entryValue['entry'] as $id => $subValue) {
                    // Is this a new index?
                    if (preg_match('~^(\\d+)~', $subValue, $matches)) {
                        $cur_index = $matches[1];
                        $subValue = substr($subValue, strpos($subValue, '\''));
                    }
                    // Clean up some bits.
                    $subValue = strtr($subValue, array('"' => '', '\'' => '', ')' => ''));
                    // Can we save?
                    if (isset($save_strings[$entryKey . '-+- ' . $cur_index])) {
                        $save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => ''));
                        $save_cache['enabled'] = true;
                    } else {
                        $save_cache['entries'][$cur_index] = $subValue;
                    }
                    $context['file_entries'][] = array('key' => $entryKey . '-+- ' . $cur_index, 'value' => $subValue, 'rows' => 1);
                    $cur_index++;
                }
                // Do we need to save?
                if ($save_cache['enabled']) {
                    // Format the string, checking the indexes first.
                    $items = array();
                    $cur_index = 0;
                    foreach ($save_cache['entries'] as $k2 => $v2) {
                        // Manually show the custom index.
                        if ($k2 != $cur_index) {
                            $items[] = $k2 . ' => \'' . $v2 . '\'';
                            $cur_index = $k2;
                        } else {
                            $items[] = '\'' . $v2 . '\'';
                        }
                        $cur_index++;
                    }
                    // Now create the string!
                    $final_saves[$entryKey] = array('find' => $entryValue['full'], 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');');
                }
            } else {
                // Saving?
                if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry']) {
                    // !!! Fix this properly.
                    if ($save_strings[$entryKey] == '') {
                        $save_strings[$entryKey] = '\'\'';
                    }
                    // Set the new value.
                    $entryValue['entry'] = $save_strings[$entryKey];
                    // And we know what to save now!
                    $final_saves[$entryKey] = array('find' => $entryValue['full'], 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = ' . $save_strings[$entryKey] . ';');
                }
                $editing_string = cleanLangString($entryValue['entry'], true);
                $context['file_entries'][] = array('key' => $entryKey, 'value' => $editing_string, 'rows' => (int) (strlen($editing_string) / 38) + substr_count($editing_string, "\n") + 1);
            }
        }
        // Any saves to make?
        if (!empty($final_saves)) {
            checkSession();
            $file_contents = implode('', file($current_file));
            foreach ($final_saves as $save) {
                $file_contents = strtr($file_contents, array($save['find'] => $save['replace']));
            }
            // Save the actual changes.
            $fp = fopen($current_file, 'w+');
            fwrite($fp, $file_contents);
            fclose($fp);
            $madeSave = true;
        }
        // Another restore.
        $txt = $old_txt;
    }
    // If we saved, redirect.
    if ($madeSave) {
        redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']);
    }
}
示例#19
0
function PackageServerRemove()
{
    global $smcFunc;
    checkSession('get');
    smf_db_query('
		DELETE FROM {db_prefix}package_servers
		WHERE id_server = {int:current_server}', array('current_server' => (int) $_GET['server']));
    redirectexit('action=admin;area=packages;get');
}
示例#20
0
文件: Karma.php 项目: norv/EosAlpha
function ModifyKarma()
{
    global $modSettings, $txt, $user_info, $topic, $smcFunc, $context;
    // If the mod is disabled, show an error.
    if (empty($modSettings['karmaMode'])) {
        fatal_lang_error('feature_disabled', true);
    }
    // If you're a guest or can't do this, blow you off...
    is_not_guest();
    isAllowedTo('karma_edit');
    checkSession('get');
    // If you don't have enough posts, tough luck.
    // !!! Should this be dropped in favor of post group permissions?  Should this apply to the member you are smiting/applauding?
    if (!$user_info['is_admin'] && $user_info['posts'] < $modSettings['karmaMinPosts']) {
        fatal_lang_error('not_enough_posts_karma', true, array($modSettings['karmaMinPosts']));
    }
    // And you can't modify your own, punk! (use the profile if you need to.)
    if (empty($_REQUEST['uid']) || (int) $_REQUEST['uid'] == $user_info['id']) {
        fatal_lang_error('cant_change_own_karma', false);
    }
    // The user ID _must_ be a number, no matter what.
    $_REQUEST['uid'] = (int) $_REQUEST['uid'];
    // Applauding or smiting?
    $dir = $_REQUEST['sa'] != 'applaud' ? -1 : 1;
    // Delete any older items from the log. (karmaWaitTime is by hour.)
    smf_db_query('
		DELETE FROM {db_prefix}log_karma
		WHERE {int:current_time} - log_time > {int:wait_time}', array('wait_time' => (int) ($modSettings['karmaWaitTime'] * 3600), 'current_time' => time()));
    // Start off with no change in karma.
    $action = 0;
    // Not an administrator... or one who is restricted as well.
    if (!empty($modSettings['karmaTimeRestrictAdmins']) || !allowedTo('moderate_forum')) {
        // Find out if this user has done this recently...
        $request = smf_db_query('
			SELECT action
			FROM {db_prefix}log_karma
			WHERE id_target = {int:id_target}
				AND id_executor = {int:current_member}
			LIMIT 1', array('current_member' => $user_info['id'], 'id_target' => $_REQUEST['uid']));
        if (mysql_num_rows($request) > 0) {
            list($action) = mysql_fetch_row($request);
        }
        mysql_free_result($request);
    }
    // They haven't, not before now, anyhow.
    if (empty($action) || empty($modSettings['karmaWaitTime'])) {
        // Put it in the log.
        smf_db_insert('replace', '{db_prefix}log_karma', array('action' => 'int', 'id_target' => 'int', 'id_executor' => 'int', 'log_time' => 'int'), array($dir, $_REQUEST['uid'], $user_info['id'], time()), array('id_target', 'id_executor'));
        // Change by one.
        updateMemberData($_REQUEST['uid'], array($dir == 1 ? 'karma_good' : 'karma_bad' => '+'));
    } else {
        // If you are gonna try to repeat.... don't allow it.
        if ($action == $dir) {
            fatal_lang_error('karma_wait_time', false, array($modSettings['karmaWaitTime'], $txt['hours']));
        }
        // You decided to go back on your previous choice?
        smf_db_query('
			UPDATE {db_prefix}log_karma
			SET action = {int:action}, log_time = {int:current_time}
			WHERE id_target = {int:id_target}
				AND id_executor = {int:current_member}', array('current_member' => $user_info['id'], 'action' => $dir, 'current_time' => time(), 'id_target' => $_REQUEST['uid']));
        // It was recently changed the OTHER way... so... reverse it!
        if ($dir == 1) {
            updateMemberData($_REQUEST['uid'], array('karma_good' => '+', 'karma_bad' => '-'));
        } else {
            updateMemberData($_REQUEST['uid'], array('karma_bad' => '+', 'karma_good' => '-'));
        }
    }
    // Figure out where to go back to.... the topic?
    if (!empty($topic)) {
        redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . '#msg' . (int) $_REQUEST['m']);
    } elseif (isset($_REQUEST['f'])) {
        redirectexit('action=pm;f=' . $_REQUEST['f'] . ';start=' . $_REQUEST['start'] . (isset($_REQUEST['l']) ? ';l=' . (int) $_REQUEST['l'] : '') . (isset($_REQUEST['pm']) ? '#' . (int) $_REQUEST['pm'] : ''));
    } else {
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
	<head>
		<title>...</title>
		<script type="text/javascript"><!-- // --><![CDATA[
			history.go(-1);
		// ]]></script>
	</head>
	<body>&laquo;</body>
</html>';
        obExit(false);
    }
}
示例#21
0
function ApproveAttachments($attachments)
{
    global $smcFunc;
    if (empty($attachments)) {
        return 0;
    }
    // For safety, check for thumbnails...
    $request = smf_db_query('
		SELECT
			a.id_attach, a.id_member, IFNULL(thumb.id_attach, 0) AS id_thumb
		FROM {db_prefix}attachments AS a
			LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = a.id_thumb)
		WHERE a.id_attach IN ({array_int:attachments})
			AND a.attachment_type = {int:attachment_type}', array('attachments' => $attachments, 'attachment_type' => 0));
    $attachments = array();
    while ($row = mysql_fetch_assoc($request)) {
        // Update the thumbnail too...
        if (!empty($row['id_thumb'])) {
            $attachments[] = $row['id_thumb'];
        }
        $attachments[] = $row['id_attach'];
    }
    mysql_free_result($request);
    // Approving an attachment is not hard - it's easy.
    smf_db_query('
		UPDATE {db_prefix}attachments
		SET approved = {int:is_approved}
		WHERE id_attach IN ({array_int:attachments})', array('attachments' => $attachments, 'is_approved' => 1));
    // Remove from the approval queue.
    smf_db_query('
		DELETE FROM {db_prefix}approval_queue
		WHERE id_attach IN ({array_int:attachments})', array('attachments' => $attachments));
}
示例#22
0
function AutoSuggest_Search_Tags()
{
    global $user_info, $txt, $smcFunc;
    $_REQUEST['search'] = trim(commonAPI::strtolower($_REQUEST['search'])) . '*';
    $_REQUEST['search'] = strtr($_REQUEST['search'], array('%' => '\\%', '_' => '\\_', '*' => '%', '?' => '_', '&#038;' => '&amp;'));
    // Find tags
    $request = smf_db_query('
		SELECT id_member, real_name
		FROM {db_prefix}tags
		WHERE tag LIKE {string:search} 
		LIMIT ' . (strlen($_REQUEST['search']) <= 2 ? '100' : '800'), array('search' => $_REQUEST['search']));
    $xml_data = array('tags' => array('identifier' => 'tag', 'children' => array()));
    while ($row = mysql_fetch_assoc($request)) {
        $xml_data['tags']['children'][] = array('attributes' => array('id' => $row['id_tag']), 'value' => $row['tag']);
    }
    mysql_free_result($request);
    return $xml_data;
}
示例#23
0
function package_create_backup($id = 'backup')
{
    global $sourcedir, $boarddir, $smcFunc;
    $files = array();
    $base_files = array('index.php', 'SSI.php', 'agreement.txt', 'ssi_examples.php', 'ssi_examples.shtml');
    foreach ($base_files as $file) {
        if (file_exists($boarddir . '/' . $file)) {
            $files[realpath($boarddir . '/' . $file)] = array(empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file, stat($boarddir . '/' . $file));
        }
    }
    $dirs = array($sourcedir => empty($_REQUEST['use_full_paths']) ? 'Sources/' : strtr($sourcedir . '/', '\\', '/'));
    $request = smf_db_query('
		SELECT value
		FROM {db_prefix}themes
		WHERE id_member = {int:no_member}
			AND variable = {string:theme_dir}', array('no_member' => 0, 'theme_dir' => 'theme_dir'));
    while ($row = mysql_fetch_assoc($request)) {
        $dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/');
    }
    mysql_free_result($request);
    while (!empty($dirs)) {
        list($dir, $dest) = each($dirs);
        unset($dirs[$dir]);
        $listing = @dir($dir);
        if (!$listing) {
            continue;
        }
        while ($entry = $listing->read()) {
            if (preg_match('~^(\\.{1,2}|CVS|backup.*|help|images|.*\\~)$~', $entry) != 0) {
                continue;
            }
            $filepath = realpath($dir . '/' . $entry);
            if (isset($files[$filepath])) {
                continue;
            }
            $stat = stat($dir . '/' . $entry);
            if ($stat['mode'] & 040000) {
                $files[$filepath] = array($dest . $entry . '/', $stat);
                $dirs[$dir . '/' . $entry] = $dest . $entry . '/';
            } else {
                $files[$filepath] = array($dest . $entry, $stat);
            }
        }
        $listing->close();
    }
    if (!file_exists($boarddir . '/Packages/backups')) {
        mktree($boarddir . '/Packages/backups', 0777);
    }
    if (!is_writable($boarddir . '/Packages/backups')) {
        package_chmod($boarddir . '/Packages/backups');
    }
    $output_file = $boarddir . '/Packages/backups/' . strftime('%Y-%m-%d_') . preg_replace('~[$\\\\/:<>|?*"\']~', '', $id);
    $output_ext = '.tar' . (function_exists('gzopen') ? '.gz' : '');
    if (file_exists($output_file . $output_ext)) {
        $i = 2;
        while (file_exists($output_file . '_' . $i . $output_ext)) {
            $i++;
        }
        $output_file = $output_file . '_' . $i . $output_ext;
    } else {
        $output_file .= $output_ext;
    }
    @set_time_limit(300);
    if (function_exists('apache_reset_timeout')) {
        @apache_reset_timeout();
    }
    if (function_exists('gzopen')) {
        $fwrite = 'gzwrite';
        $fclose = 'gzclose';
        $output = gzopen($output_file, 'wb');
    } else {
        $fwrite = 'fwrite';
        $fclose = 'fclose';
        $output = fopen($output_file, 'wb');
    }
    foreach ($files as $real_file => $file) {
        if (!file_exists($real_file)) {
            continue;
        }
        $stat = $file[1];
        if (substr($file[0], -1) == '/') {
            $stat['size'] = 0;
        }
        $current = pack('a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12', $file[0], decoct($stat['mode']), sprintf('%06d', decoct($stat['uid'])), sprintf('%06d', decoct($stat['gid'])), decoct($stat['size']), decoct($stat['mtime']), '', 0, '', '', '', '', '', '', '', '', '');
        $checksum = 256;
        for ($i = 0; $i < 512; $i++) {
            $checksum += ord($current[$i]);
        }
        $fwrite($output, substr($current, 0, 148) . pack('a8', decoct($checksum)) . substr($current, 156, 511));
        if ($stat['size'] == 0) {
            continue;
        }
        $fp = fopen($real_file, 'rb');
        while (!feof($fp)) {
            $fwrite($output, fread($fp, 16384));
        }
        fclose($fp);
        $fwrite($output, pack('a' . (512 - $stat['size'] % 512), ''));
    }
    $fwrite($output, pack('a1024', ''));
    $fclose($output);
}
示例#24
0
文件: Admin.php 项目: norv/EosAlpha
function DisplayAdminFile()
{
    global $context, $modSettings;
    @ini_set('memory_limit', '32M');
    if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) {
        fatal_lang_error('no_access', false);
    }
    $request = smf_db_query('
		SELECT data, filetype
		FROM {db_prefix}admin_info_files
		WHERE filename = {string:current_filename}
		LIMIT 1', array('current_filename' => $_REQUEST['filename']));
    if (mysql_num_rows($request) == 0) {
        fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']));
    }
    list($file_data, $filetype) = mysql_fetch_row($request);
    mysql_free_result($request);
    // !!! Temp.
    // Figure out if sesc is still being used.
    if (strpos($file_data, ';sesc=') !== false) {
        $file_data = '
if (!(\'smfForum_sessionvar\' in window))
	window.smfForum_sessionvar = \'sesc\';
' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'='));
    }
    $context['template_layers'] = array();
    // Lets make sure we aren't going to output anything nasty.
    @ob_end_clean();
    if (!empty($modSettings['enableCompressedOutput'])) {
        @ob_start('ob_gzhandler');
    } else {
        @ob_start();
    }
    // Make sure they know what type of file we are.
    header('Content-Type: ' . $filetype);
    echo $file_data;
    obExit(false);
}
示例#25
0
文件: install.php 项目: norv/EosAlpha
function DeleteInstall()
{
    global $txt, $HTTP_SESSION_VARS, $incontext;
    global $current_smf_version, $sourcedir, $forum_version, $modSettings, $user_info, $db_type;
    $incontext['page_title'] = $txt['congratulations'];
    $incontext['sub_template'] = 'delete_install';
    $incontext['continue'] = 0;
    require dirname(__FILE__) . '/Settings.php';
    load_database();
    chdir(dirname(__FILE__));
    require_once $sourcedir . '/Errors.php';
    require_once $sourcedir . '/lib/Subs.php';
    require_once $sourcedir . '/CommonAPI.php';
    require_once $sourcedir . '/Load.php';
    require_once $sourcedir . '/Security.php';
    require_once $sourcedir . '/lib/Subs-Auth.php';
    // Bring a warning over.
    if (!empty($incontext['account_existed'])) {
        $incontext['warning'] = $incontext['account_existed'];
    }
    smf_db_query('
		SET NAMES utf8', array());
    // As track stats is by default enabled let's add some activity.
    smf_db_insert('ignore', '{db_prefix}log_activity', array('date' => 'date', 'topics' => 'int', 'posts' => 'int', 'registers' => 'int'), array(strftime('%Y-%m-%d', time()), 1, 1, !empty($incontext['member_id']) ? 1 : 0), array('date'));
    // Automatically log them in ;)
    if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
        setLoginCookie(3153600 * 60, $incontext['member_id'], sha1(sha1(strtolower($_POST['username']) . $_POST['password1']) . $incontext['member_salt']));
    }
    $result = smf_db_query('
		SELECT value
		FROM {db_prefix}settings
		WHERE variable = {string:db_sessions}', array('db_sessions' => 'databaseSession_enable', 'db_error_skip' => true));
    if (mysql_num_rows($result) != 0) {
        list($db_sessions) = mysql_fetch_row($result);
    }
    mysql_free_result($result);
    if (empty($db_sessions)) {
        if (@version_compare(PHP_VERSION, '4.2.0') == -1) {
            $HTTP_SESSION_VARS['php_412_bugfix'] = true;
        }
        $_SESSION['admin_time'] = time();
    } else {
        $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
        smf_db_insert('replace', '{db_prefix}sessions', array('session_id' => 'string', 'last_update' => 'int', 'data' => 'string'), array(session_id(), time(), 'USER_AGENT|s:' . strlen($_SERVER['HTTP_USER_AGENT']) . ':"' . $_SERVER['HTTP_USER_AGENT'] . '";admin_time|i:' . time() . ';'), array('session_id'));
    }
    // We're going to want our lovely $modSettings now.
    $request = smf_db_query('
		SELECT variable, value
		FROM {db_prefix}settings', array('db_error_skip' => true));
    // Only proceed if we can load the data.
    if ($request) {
        while ($row = mysql_fetch_row($request)) {
            $modSettings[$row[0]] = $row[1];
        }
        mysql_free_result($request);
    }
    updateStats('member');
    updateStats('message');
    updateStats('topic');
    $request = smf_db_query('
		SELECT id_msg
		FROM {db_prefix}messages
		WHERE id_msg = 1
			AND modified_time = 0
		LIMIT 1', array('db_error_skip' => true));
    if (mysql_num_rows($request) > 0) {
        updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
    }
    mysql_free_result($request);
    // Now is the perfect time to fetch the SM files.
    require_once $sourcedir . '/ScheduledTasks.php';
    // Sanity check that they loaded earlier!
    if (isset($modSettings['recycle_board'])) {
        $forum_version = $current_smf_version;
        // The variable is usually defined in index.php so lets just use our variable to do it for us.
        scheduled_fetchSMfiles();
        // Now go get those files!
        // We've just installed!
        $user_info['ip'] = $_SERVER['REMOTE_ADDR'];
        $user_info['id'] = isset($incontext['member_id']) ? $incontext['member_id'] : 0;
        logAction('install', array('version' => $forum_version), 'admin');
    }
    // Check if we need some stupid MySQL fix.
    $server_version = smf_db_get_version();
    if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
        updateSettings(array('db_mysql_group_by_fix' => '1'));
    }
    // Some final context for the template.
    $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
    $incontext['probably_delete_install'] = isset($_SESSION['installer_temp_ftp']) || is_writable(dirname(__FILE__)) || is_writable(__FILE__);
    return false;
}
示例#26
0
function collapseCategories($categories, $new_status, $members = null, $check_collapsable = true)
{
    global $smcFunc;
    // Collapse or expand the categories.
    if ($new_status === 'collapse' || $new_status === 'expand') {
        smf_db_query('
			DELETE FROM {db_prefix}collapsed_categories
			WHERE id_cat IN ({array_int:category_list})' . ($members === null ? '' : '
				AND id_member IN ({array_int:member_list})'), array('category_list' => $categories, 'member_list' => $members));
        if ($new_status === 'collapse') {
            smf_db_query('
				INSERT INTO {db_prefix}collapsed_categories
					(id_cat, id_member)
				SELECT c.id_cat, mem.id_member
				FROM {db_prefix}categories AS c
					INNER JOIN {db_prefix}members AS mem ON (' . ($members === null ? '1=1' : '
						mem.id_member IN ({array_int:member_list})') . ')
				WHERE c.id_cat IN ({array_int:category_list})' . ($check_collapsable ? '
					AND c.can_collapse = {int:is_collapsible}' : ''), array('member_list' => $members, 'category_list' => $categories, 'is_collapsible' => 1));
        }
    } elseif ($new_status === 'toggle') {
        // Get the current state of the categories.
        $updates = array('insert' => array(), 'remove' => array());
        $request = smf_db_query('
			SELECT mem.id_member, c.id_cat, IFNULL(cc.id_cat, 0) AS is_collapsed, c.can_collapse
			FROM {db_prefix}members AS mem
				INNER JOIN {db_prefix}categories AS c ON (c.id_cat IN ({array_int:category_list}))
				LEFT JOIN {db_prefix}collapsed_categories AS cc ON (cc.id_cat = c.id_cat AND cc.id_member = mem.id_member)
			' . ($members === null ? '' : '
				WHERE mem.id_member IN ({array_int:member_list})'), array('category_list' => $categories, 'member_list' => $members));
        while ($row = mysql_fetch_assoc($request)) {
            if (empty($row['is_collapsed']) && (!empty($row['can_collapse']) || !$check_collapsable)) {
                $updates['insert'][] = array($row['id_member'], $row['id_cat']);
            } elseif (!empty($row['is_collapsed'])) {
                $updates['remove'][] = '(id_member = ' . $row['id_member'] . ' AND id_cat = ' . $row['id_cat'] . ')';
            }
        }
        mysql_free_result($request);
        // Collapse the ones that were originally expanded...
        if (!empty($updates['insert'])) {
            smf_db_insert('replace', '{db_prefix}collapsed_categories', array('id_cat' => 'int', 'id_member' => 'int'), $updates['insert'], array('id_cat', 'id_member'));
        }
        // And expand the ones that were originally collapsed.
        if (!empty($updates['remove'])) {
            smf_db_query('
				DELETE FROM {db_prefix}collapsed_categories
				WHERE ' . implode(' OR ', $updates['remove']), array());
        }
    }
}
示例#27
0
文件: Load.php 项目: norv/EosAlpha
function logSpider()
{
    global $modSettings, $context;
    if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot'])) {
        return;
    }
    // Attempt to update today's entry.
    if ($modSettings['spider_mode'] == 1) {
        $date = strftime('%Y-%m-%d', forum_time(false));
        smf_db_query('
			UPDATE {db_prefix}log_spider_stats
			SET last_seen = {int:current_time}, page_hits = page_hits + 1
			WHERE id_spider = {int:current_spider}
				AND stat_date = {date:current_date}', array('current_date' => $date, 'current_time' => time(), 'current_spider' => $_SESSION['id_robot']));
        // Nothing updated?
        if (smf_db_affected_rows() == 0) {
            smf_db_insert('ignore', '{db_prefix}log_spider_stats', array('id_spider' => 'int', 'last_seen' => 'int', 'stat_date' => 'date', 'page_hits' => 'int'), array($_SESSION['id_robot'], time(), $date, 1), array('id_spider', 'stat_date'));
        }
    } else {
        if ($modSettings['spider_mode'] > 2) {
            $url = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
            unset($url['sesc'], $url[$context['session_var']]);
            $url = serialize($url);
        } else {
            $url = '';
        }
        smf_db_insert('insert', '{db_prefix}log_spider_hits', array('id_spider' => 'int', 'log_time' => 'int', 'url' => 'string'), array($_SESSION['id_robot'], time(), $url), array());
    }
}
示例#28
0
/**
 * @param type $message the message: this must run before bb codes are parsed,
 *						because user tags are translated to bb codes.
 * @return type int -	an array of member ids that were tagged in the message.
 *						the array contains unique ids only.
 */
function handleUserTags(&$message)
{
    global $user_info, $modSettings, $context;
    $users_found = array();
    if (!isset($context['can_tag_users']) || !$context['can_tag_users'] || isset($_REQUEST['allowtags']) && $_REQUEST['allowtags'] || empty($modSettings['enableUserTagging']) || 0 == $modSettings['maxTagsPerPost']) {
        return $users_found;
    }
    $pat = '~@@([\\s\\w,;-_\\[\\]\\{\\}\\\\/\\+\\.\\~\\$\\!]+):~u';
    $matches = array();
    $querynames = array();
    $searchnames = array();
    $displaynames = array();
    /*
     * maximum number of unique tagged users a single message can have. defaults to 10, but never more than
     * 20 which should be waaaaaay enough anyway and we don't want to abuse this feature.
     */
    $max_unique_tags = empty($modSettings['maxTagsPerPost']) ? 10 : min(array(20, $modSettings['maxTagsPerPost']));
    /*
     * collect all @mentions and build an array of unique, lowercased
     * names to use in the db query.
     */
    if (preg_match_all($pat, $message, $matches, PREG_SET_ORDER)) {
        foreach ($matches as $match) {
            $names = explode(',', trim($match[1]));
            foreach ($names as $name) {
                $querynames[] = CommonAPI::strtolower(trim($name));
            }
        }
    } else {
        return $users_found;
    }
    // nothing to see here, sir...
    $querynames = array_slice(array_unique($querynames), 0, $max_unique_tags);
    $result = smf_db_query('SELECT id_member, real_name FROM {db_prefix}members
		WHERE LOWER(real_name) IN({array_string:names})', array('names' => array_unique($querynames)));
    while ($row = mysql_fetch_assoc($result)) {
        $searchnames[$row['id_member']] = CommonAPI::strtolower($row['real_name']);
        // this is for the lookup
        $displaynames[$row['id_member']] = $row['real_name'];
        // ... and this for pretty-formatting the output
    }
    mysql_free_result($result);
    reset($matches);
    /*
     * look at our matches again and build the formatted result(s). Filter out any names
     * that couldn't be found in the db query (mis-spelled, non-existing or whatever... simply ignore them).
     */
    foreach ($matches as $match) {
        $bbc_results = array();
        $names = explode(',', trim($match[1]));
        foreach ($names as $name) {
            $id = array_search(CommonAPI::strtolower(trim($name)), $searchnames);
            if ((int) $id > 0 && $id != $user_info['id']) {
                // trying to be funny and mention yourself? troll alert... :)
                $bbc_results[] = '[user id=' . $id . ']' . $displaynames[$id] . '[/user]';
                $users_found[] = $id;
            }
        }
        $bbc_result = count($bbc_results) ? '@' . implode(', ', $bbc_results) . ':' : '';
        $message = str_replace($match[0], $bbc_result, $message);
    }
    return array_unique($users_found);
}
示例#29
0
文件: Ratings.php 项目: norv/EosAlpha
/**
 * @param $memID 		int id_member
 *
 * fetch all likes received by the given user and display them
 * part of the profile -> show content area.
 */
function LikesByUser($memID)
{
    global $context, $user_info, $scripturl, $memberContext, $txt, $modSettings, $options;
    if ($memID != $user_info['id']) {
        isAllowedTo('can_view_ratings');
    }
    // let us use the same value as for topics per page here.
    $perpage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
    $out = $_GET['sa'] === 'likesout';
    // display likes *given* instead of received ones
    $is_owner = $user_info['id'] == $memID;
    // we are the owner of this profile, this is important for proper formatting (you/yours etc.)
    $boards_like_see = boardsAllowedTo('like_see');
    // respect permissions
    $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
    if (!($user_info['is_admin'] || allowedTo('moderate_forum'))) {
        // admins and global mods can see everything
        $bq = ' AND b.id_board IN({array_int:boards})';
    } else {
        $bq = '';
    }
    $q = $out ? 'l.id_user = {int:id_user}' : 'l.id_receiver = {int:id_user}';
    $request = smf_db_query('SELECT count(l.id_msg) FROM {db_prefix}likes AS l
			INNER JOIN {db_prefix}messages AS m ON (m.id_msg = l.id_msg)
			INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
			INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
			WHERE ' . $q . ' AND {query_see_board}' . $bq, array('id_user' => $memID, 'boards' => $boards_like_see));
    list($context['total_likes']) = mysql_fetch_row($request);
    mysql_free_result($request);
    $request = smf_db_query('SELECT m.subject, m.id_topic, l.id_user, l.id_receiver, l.updated, l.id_msg, l.rtype, mfirst.subject AS first_subject, SUBSTRING(m.body, 1, 150) AS body FROM {db_prefix}likes AS l
			INNER JOIN {db_prefix}messages AS m ON (m.id_msg = l.id_msg)
			INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
			INNER JOIN {db_prefix}messages AS mfirst ON (mfirst.id_msg = t.id_first_msg)
			INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
			WHERE ' . $q . ' AND {query_see_board} ' . $bq . ' ORDER BY l.id_like DESC LIMIT {int:startwith}, {int:perpage}', array('id_user' => $memID, 'startwith' => $start, 'perpage' => $perpage, 'boards' => $boards_like_see));
    $context['results_count'] = 0;
    $context['likes'] = array();
    $context['displaymode'] = $out ? true : false;
    $context['pages'] = '';
    if ($context['total_likes'] > $perpage) {
        $context['pages'] = constructPageIndex($scripturl . '?action=profile;area=showposts;sa=' . $_GET['sa'] . ';u=' . trim($memID), $start, $context['total_likes'], $perpage);
    }
    $users = array();
    while ($row = mysql_fetch_assoc($request)) {
        $context['results_count']++;
        $thref = URL::topic($row['id_topic'], $row['first_subject'], 0);
        $phref = URL::topic($row['id_topic'], $row['subject'], 0, false, '.msg' . $row['id_msg'], '#msg' . $row['id_msg']);
        $users[] = $out ? $row['id_receiver'] : $row['id_user'];
        $context['likes'][] = array('id_user' => $out ? $row['id_receiver'] : $row['id_user'], 'time' => timeformat($row['updated']), 'topic' => array('href' => $thref, 'link' => '<a href="' . $thref . '">' . $row['first_subject'] . '</a>', 'subject' => $row['first_subject']), 'post' => array('href' => $phref, 'link' => '<a href="' . $phref . '">' . $row['subject'] . '</a>', 'subject' => $row['subject'], 'id' => $row['id_msg']), 'rtype' => $row['rtype'], 'teaser' => strip_tags(preg_replace('~[[\\/\\!]*?[^\\[\\]]*?]~si', '', $row['body'])) . '...', 'morelink' => URL::parse('?msg=' . $row['id_msg'] . ';perma'));
    }
    loadMemberData(array_unique($users));
    foreach ($context['likes'] as &$like) {
        loadMemberContext($like['id_user']);
        $like['member'] =& $memberContext[$like['id_user']];
        $like['text'] = $out ? $is_owner ? sprintf($txt['liked_a_post'], $is_owner ? $txt['you_liker'] : $memberContext[$memID]['name'], $memberContext[$like['id_user']]['link'], $like['post']['href'], $like['topic']['link'], $modSettings['ratings'][$like['rtype']]['text']) : sprintf($txt['liked_a_post'], $is_owner ? $txt['you_liker'] : $memberContext[$memID]['name'], $memberContext[$like['id_user']]['link'], $like['post']['href'], $like['topic']['link'], $modSettings['ratings'][$like['rtype']]['text']) : ($is_owner ? sprintf($txt['liked_your_post'], $like['id_user'] == $user_info['id'] ? $txt['you_liker'] : $like['member']['link'], $like['post']['href'], $like['topic']['link'], $modSettings['ratings'][$like['rtype']]['text']) : sprintf($txt['liked_a_post'], $like['id_user'] == $user_info['id'] ? $txt['you_liker'] : $like['member']['link'], $memberContext[$memID]['name'], $like['post']['href'], $like['topic']['link'], $modSettings['ratings'][$like['rtype']]['text']));
    }
    mysql_free_result($request);
    EoS_Smarty::getConfigInstance()->registerHookTemplate('profile_content_area', 'ratings/profile_display');
}
示例#30
0
function generateValidationCode()
{
    global $smcFunc, $modSettings;
    $request = smf_db_query('
		SELECT RAND()', array());
    list($dbRand) = mysql_fetch_row($request);
    mysql_free_result($request);
    return substr(preg_replace('/\\W/', '', sha1(microtime() . mt_rand() . $dbRand . $modSettings['rand_seed'])), 0, 10);
}