Exemplo n.º 1
0
function phpbb_increase_topic_counter($topic_id = null)
{
    if (!intval($topic_id)) {
        phpbb_raise_error('Topic ID must be a numeric value.', __FILE__, __LINE__);
    }
    $sql = 'UPDATE ' . TOPICS_TABLE . '
			SET topic_views = topic_views + 1
			WHERE topic_id = ' . $topic_id;
    phpbb_query($sql);
}
Exemplo n.º 2
0
function phpbb_fetch_poll_voters($vote_id = null)
{
    if ($vote_id and !intval($vote_id)) {
        phpbb_raise_error('Vote ID must be a numeric value.', __FILE__, __LINE__);
    }
    $sql = 'SELECT * FROM ' . VOTE_USERS_TABLE . '
		WHERE vote_id = ' . $vote_id . '
		ORDER BY vote_user_id';
    $result = phpbb_fetch_rows($sql);
    return $result;
}
Exemplo n.º 3
0
function phpbb_fetch_thread($topic_id = null)
{
    global $CFG, $userdata;
    if (!$topic_id) {
        phpbb_raise_error('no topic id specified', __FILE__, __LINE__);
    }
    $sql = 'SELECT p.*, pt.*, u.*';
    if (!$CFG['posts_hide_ranks']) {
        $sql .= ', r.*';
    }
    $sql .= '
				FROM ' . USERS_TABLE . ' AS u,
					 ' . POSTS_TEXT_TABLE . ' AS pt,
					 ' . POSTS_TABLE . ' AS p';
    if (!$CFG['posts_hide_ranks']) {
        $sql .= ',
					 ' . RANKS_TABLE . ' AS r';
    }
    $sql .= '
				WHERE p.topic_id = ' . $topic_id . '
					AND u.user_id  = p.poster_id
					AND pt.post_id = p.post_id
					AND u.user_id  = p.poster_id';
    if (!$CFG['posts_hide_ranks']) {
        $sql .= '
					AND r.rank_id = u.user_rank';
    }
    if ($CFG['posts_search_string']) {
        $sql .= '
					AND (' . $CFG['posts_search_string'] . ')';
    }
    $sql .= '
				ORDER BY ' . $CFG['posts_order'];
    if ($CFG['posts_span_pages']) {
        $CFG['posts_span_pages_numrows'] = phpbb_numrows(phpbb_query($sql));
        if ($CFG['posts_span_pages_offset'] > $CFG['posts_span_pages_numrows']) {
            $CFG['posts_span_pages_offset'] = $CFG['posts_span_pages_numrows'] - 1;
        }
        $CFG['posts_offset'] = $CFG['posts_span_pages_offset'];
    } else {
        $CFG['posts_offset'] = 0;
    }
    if ($CFG['posts_limit'] != 0) {
        $sql .= ' LIMIT ' . $CFG['posts_offset'] . ',' . $CFG['posts_limit'];
    }
    $result = phpbb_fetch_rows($sql);
    if ($result) {
        if ($CFG['auth_check']) {
            phpbb_get_auth_list();
            $authed = array();
            for ($i = 0; $i < count($result); $i++) {
                if (in_array($result[$i]['forum_id'], $CFG['auth_list'])) {
                    $authed[] = $result[$i];
                }
            }
            $result = $authed;
        }
        $orig_word = array();
        $replacement_word = array();
        obtain_word_list($orig_word, $replacement_word);
        for ($i = 0; $i < count($result); $i++) {
            $result[$i]['post_time'] = $result[$i]['post_time'] + $CFG['time_zone'];
            $result[$i]['topic_time'] = $result[$i]['topic_time'] + $CFG['time_zone'];
            $result[$i]['post_edit_time'] = $result[$i]['post_edit_time'] + $CFG['time_zone'];
            $result[$i]['date'] = date($CFG['date_format'], $result[$i]['post_time']);
            $result[$i]['time'] = date($CFG['time_format'], $result[$i]['post_time']);
            $result[$i]['edit_date'] = date($CFG['date_format'], $result[$i]['post_edit_time']);
            $result[$i]['edit_time'] = date($CFG['time_format'], $result[$i]['post_edit_time']);
            $result[$i]['post_text'] = phpbb_parse_text($result[$i]['post_text'], $result[$i]['bbcode_uid'], $result[$i]['enable_smilies'], $CFG['posts_enable_bbcode'], $CFG['posts_enable_html'], $CFG['posts_hide_images'], $CFG['posts_replace_images']);
            if (count($orig_word)) {
                $result[$i]['topic_title'] = preg_replace($orig_word, $replacement_word, $result[$i]['topic_title']);
                $result[$i]['post_text'] = preg_replace($orig_word, $replacement_word, $result[$i]['post_text']);
            }
            $result[$i]['trimmed'] = false;
            phpbb_trim_text($result[$i]['post_text'], $result[$i]['trimmed'], $CFG['posts_trim_text_character'], $CFG['posts_trim_text_number'], $CFG['posts_trim_text_words']);
            $result[$i]['topic_trimmed'] = false;
            phpbb_trim_text($result[$i]['topic_title'], $result[$i]['topic_trimmed'], '', $CFG['posts_trim_topic_number'], '');
        }
        if (is_array($topic_id)) {
            $sorted = array();
            for ($i = 0; $i < count($topic_id); $i++) {
                for ($j = 0; $j < count($result); $j++) {
                    if ($topic_id[$i] == $result[$j]['topic_id']) {
                        $sorted[] = $result[$j];
                    }
                }
            }
            $result = $sorted;
        }
    }
    return $result;
}
Exemplo n.º 4
0
function phpbb_fetch_online_users($group_id = null)
{
    global $CFG;
    //
    // sanity check
    //
    if ($group_id and !intval($group_id)) {
        phpbb_raise_error('Group ID must be a numeric value.', __FILE__, __LINE__);
    }
    //
    // build the sql string
    //
    $sql = 'SELECT u.user_id, u.username, u.user_allow_viewonline,
			u.user_level, s.session_logged_in, s.session_time';
    if ($group_id) {
        $sql .= ', g.*, ug.*';
    }
    $sql .= '
		FROM
		' . USERS_TABLE . ' AS u,
		' . SESSIONS_TABLE . ' AS s';
    if ($group_id) {
        $sql .= ',
			' . GROUPS_TABLE . ' AS g,
			' . USER_GROUP_TABLE . ' AS ug';
    }
    $sql .= '
		WHERE u.user_id = s.session_user_id
		AND s.session_time >= ' . (time() - $CFG['users_session_time']);
    if ($group_id) {
        $sql .= '
			AND g.group_id = ' . $group_id . '
			AND ug.group_id = ' . $group_id . '
			AND u.user_id = ug.user_id
			AND ug.user_pending = 0';
    }
    $sql .= '
		ORDER BY u.username ASC';
    $result = phpbb_fetch_rows($sql);
    //
    // delete hidden and guest users
    //
    $cleanup = array();
    $prev_user = 0;
    for ($i = 0; $i < count($result); $i++) {
        if ($result[$i]['session_logged_in']) {
            $user_id = $result[$i]['user_id'];
            if ($user_id != $prev_user) {
                if ($result[$i]['user_allow_viewonline']) {
                    $cleanup[] = $result[$i];
                }
                $prev_user = $user_id;
            }
        }
    }
    return $cleanup;
}
Exemplo n.º 5
0
function phpbb_get_forum_list($forum_id = null)
{
    global $CFG;
    $result = '';
    if (!$forum_id and $CFG['auth_check']) {
        reset($CFG['auth_list']);
        while (list($k, $v) = each($CFG['auth_list'])) {
            $result .= $v . ',';
        }
        if ($result) {
            $result = substr($result, 0, strlen($result) - 1);
        }
    }
    if ($forum_id) {
        if (!is_array($forum_id)) {
            if (!intval($forum_id)) {
                phpbb_raise_error('Forum ID must be a numeric value.', __FILE__, __LINE__);
            }
            if ($CFG['auth_check']) {
                if (in_array($forum_id, $CFG['auth_list'])) {
                    $result = $forum_id;
                }
            } else {
                $result = $forum_id;
            }
        } else {
            for ($i = 0; $i < count($forum_id); $i++) {
                if (!intval($forum_id[$i])) {
                    phpbb_raise_error('Forum ID must be a numeric value.', __FILE__, __LINE__);
                }
                if ($CFG['auth_check']) {
                    if (in_array($forum_id[$i], $CFG['auth_list'])) {
                        $result .= $forum_id[$i] . ',';
                    }
                } else {
                    $result .= $forum_id[$i] . ',';
                }
            }
            if ($result) {
                $result = substr($result, 0, strlen($result) - 1);
            }
        }
    }
    //
    // exclude forums from result?
    //
    if ($result and isset($CFG['posts_exclude_forums'])) {
        if (!is_array($CFG['posts_exclude_forums'])) {
            $CFG['posts_exclude_forums'] = array($CFG['posts_exclude_forums']);
        }
        $arr = explode(',', $result);
        $result = '';
        while (list($k, $v) = each($arr)) {
            if (!in_array($v, $CFG['posts_exclude_forums'])) {
                $result .= $v . ',';
            }
        }
        if ($result) {
            $result = substr($result, 0, strlen($result) - 1);
        }
    }
    return $result;
}