Beispiel #1
0
function phpbb_edit_post($post_id = null, $subject = null, $message = null)
{
    global $CFG, $userdata, $phpbb_root_path, $phpEx;
    include_once $phpbb_root_path . 'includes/functions_post.' . $phpEx;
    include_once $phpbb_root_path . 'includes/functions_search.' . $phpEx;
    if (empty($subject)) {
        phpbb_raise_error('Subject must not be empty.');
    }
    if (empty($message)) {
        phpbb_raise_error('Message must not be empty.');
    }
    if (empty($post_id)) {
        phpbb_raise_error('Post does not exists.');
    }
    $sql = 'SELECT *
				FROM ' . POSTS_TABLE . '
				WHERE post_id = ' . $post_id;
    $result = phpbb_fetch_row($sql);
    if ($result) {
        $topic_id = $result['topic_id'];
    } else {
        phpbb_raise_error('Post does not exists.', __FILE__, __LINE__, $sql);
    }
    $sql = 'SELECT *
				FROM ' . TOPICS_TABLE . '
				WHERE topic_id = ' . $topic_id;
    $topic_info = phpbb_fetch_row($sql);
    remove_search_post($post_id);
    if ($post_id == $topic_info['topic_first_post_id']) {
        $sql = 'UPDATE ' . TOPICS_TABLE . '
					SET topic_title = \'' . str_replace("\\'", "''", $subject) . '\'
					WHERE topic_id = ' . $topic_id;
        phpbb_query($sql);
    }
    $sql = 'UPDATE ' . POSTS_TEXT_TABLE . '
				SET post_text = \'' . str_replace("\\'", "''", $message) . '\',
					post_subject = \'' . str_replace("\\'", "''", $subject) . '\'
				WHERE post_id = ' . $post_id;
    phpbb_query($sql);
    add_search_words('single', $post_id, stripslashes($message), stripslashes($subject));
}
Beispiel #2
0
function phpbb_fetch_poll_bt($topic_id = null)
{
    global $CFG;
    if (!isset($topic_id)) {
        return;
    }
    $sql = 'SELECT f.*, p.*, pt.*, t.*, u.*, vd.*
				FROM ' . TOPICS_TABLE . ' AS t,
					 ' . USERS_TABLE . ' AS u,
					 ' . POSTS_TEXT_TABLE . ' AS pt,
					 ' . POSTS_TABLE . ' AS p,
					 ' . FORUMS_TABLE . ' AS f,
					 ' . VOTE_DESC_TABLE . ' AS vd
				WHERE vd.topic_id = ' . $topic_id . '
					AND t.topic_poster = u.user_id
					AND t.topic_first_post_id = pt.post_id
					AND t.topic_first_post_id = p.post_id
					AND t.topic_status <> 1
					AND t.topic_status <> 2
					AND t.topic_vote = 1
					AND t.forum_id = f.forum_id
					AND t.topic_id = vd.topic_id';
    $sql .= '
				ORDER BY p.post_time DESC
				LIMIT 0,1';
    $result = phpbb_fetch_row($sql);
    if ($result) {
        //
        // perform an auth check if requested
        //
        if ($CFG['auth_check']) {
            phpbb_get_auth_list();
            if (!in_array($result['forum_id'], $CFG['auth_list'])) {
                return;
            }
        }
        $sql = 'SELECT *
					FROM ' . VOTE_RESULTS_TABLE . '
					WHERE vote_id = ' . $result['vote_id'] . '
					ORDER BY vote_option_id';
        $result['options'] = phpbb_fetch_rows($sql);
    }
    return $result;
}
function smartor_photo_album_fetch_image($category_id = null)
{
    global $CFG;
    $sql = 'SELECT p.pic_id, p.pic_title, p.pic_username, p.pic_user_id,
			p.pic_time, p.pic_desc, p.pic_lock, p.pic_approval,
			u.username
			FROM ' . ALBUM_TABLE . ' AS p
			LEFT JOIN ' . USERS_TABLE . ' AS u
			ON p.pic_user_id = u.user_id
			WHERE pic_approval = 1 AND pic_lock = 0';
    if ($category_id) {
        if (!is_array($category_id)) {
            $sql .= '
				AND pic_cat_id = ' . $category_id;
        } else {
            $sql .= '
				AND pic_cat_id IN (';
            for ($i = 0; $i < count($category_id); $i++) {
                $sql .= $category_id[$i] . ',';
            }
            $sql = substr($sql, 0, strlen($sql) - 1);
            $sql .= ')';
        }
    }
    if ($CFG['smartor_photo_album_display'] == 'newest') {
        $sql .= '
				ORDER BY pic_time DESC';
    }
    if ($CFG['smartor_photo_album_display'] == 'random') {
        $sql .= '
			ORDER BY RAND()';
    }
    $sql .= '
			LIMIT 0, 1';
    $result = phpbb_fetch_row($sql);
    return $result;
}
Beispiel #4
0
function phpbb_fetch_random_user($group_id = null)
{
    //
    // 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';
    if ($group_id) {
        $sql .= ', g.*, ug.*';
    }
    $sql .= '
		FROM ' . USERS_TABLE . ' AS u';
    if ($group_id) {
        $sql .= ',
			' . GROUPS_TABLE . ' AS g,
			' . USER_GROUP_TABLE . ' AS ug';
    }
    $sql .= '
		WHERE u.user_id <> -1
		AND u.user_posts > 0';
    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';
    }
    $result = phpbb_fetch_rows($sql);
    //
    // initialize random generator and determine the lucky one :-)
    //
    srand((double) microtime() * 1000000);
    $the_one = rand(0, count($result) - 1);
    $sql = 'SELECT u.*
			FROM ' . USERS_TABLE . ' AS u
			WHERE u.user_id = ' . $result[$the_one]['user_id'];
    $result = phpbb_fetch_row($sql);
    return $result;
}
Beispiel #5
0
function phpbb_fetch_new_posts()
{
    global $userdata;
    $result['total'] = 0;
    if ($userdata['session_logged_in']) {
        $sql = 'SELECT COUNT(post_id) AS total
					FROM ' . POSTS_TABLE . '
					WHERE post_time >= ' . $userdata['user_lastvisit'];
        $result = phpbb_fetch_row($sql);
    }
    return $result;
}
Beispiel #6
0
function phpbb_fetch_style($user_id = null)
{
    global $userdata, $board_config, $phpbb_root_path;
    if ($board_config['override_user_style']) {
        $style = $board_config['default_style'];
    } else {
        if ($userdata['session_logged_in']) {
            $style = $userdata['user_style'];
        } else {
            $style = $board_config['default_style'];
        }
    }
    $sql = 'SELECT *
				FROM ' . THEMES_TABLE . '
				WHERE themes_id = ' . $style;
    $row = phpbb_fetch_row($sql);
    return $row['template_name'];
}