コード例 #1
0
ファイル: posts.php プロジェクト: Juuro/Dreamapp-Website
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;
}
コード例 #2
0
ファイル: editor.php プロジェクト: Juuro/Dreamapp-Website
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);
}
コード例 #3
0
ファイル: common.php プロジェクト: Juuro/Dreamapp-Website
function phpbb_fetch_rows($sql = null)
{
    global $db;
    if (!$sql) {
        return;
    }
    $query = phpbb_query($sql);
    $result = array();
    while ($row = $db->sql_fetchrow($query)) {
        $result[] = $row;
    }
    return $result;
}