예제 #1
0
function discussion_forum_categories_fetch($options)
{
    $options['url_prefix'] = isset($options['url_prefix']) ? $options['url_prefix'] : '/diskussionsforum/';
    if (isset($options['id']) && !is_array($options['id'])) {
        $options['id'] = array($options['id']);
    }
    $query = 'SELECT pf.*, t.title AS last_thread_title, t.handle AS last_thread_handle, l.username AS last_thread_username, l.id AS last_thread_author';
    $query .= ' FROM public_forums AS pf, forum_posts AS t, login AS l WHERE 1';
    //		$query .= ($options['recursive']) ? ' AND pf.parent IS NULL' : '';
    $query .= isset($options['parent']) ? ' AND pf.parent = "' . $options['parent'] . '"' : '';
    $query .= isset($options['forum_id']) ? ' AND pf.id = "' . $options['forum_id'] . '"' : '';
    // This exists, I know. But it didn't work, so I made my own
    $query .= isset($options['id']) ? ' AND pf.id IN("' . implode('", "', $options['id']) . '")' : '';
    $query .= isset($options['handle']) ? ' AND pf.handle LIKE "' . $options['handle'] . '"' : '';
    $query .= ' AND t.id = pf.last_thread';
    $query .= ' AND l.id = t.author';
    $query .= ' ORDER BY pf.priority DESC, pf.handle ASC';
    if (!isset($options['disable_query_caching'])) {
        $max_delay = 120;
        $data_rows = query_cache(array('query' => $query, 'category' => 'forum_categories', 'max_delay' => $max_delay));
    } else {
        $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
        while ($data = mysql_fetch_assoc($result)) {
            $data_rows[] = $data;
        }
    }
    foreach ($data_rows as $data) {
        /* It's a bit smarter to check this after the query (query_cache...) */
        if (isset($options['viewers_userlevel']) && forum_security(array('action' => 'view_category', 'category' => $data, 'userlevel' => $options['viewers_userlevel'])) !== true) {
            continue;
        }
        if (!isset($options['max_levels']) || $options['max_levels'] > 0) {
            $recursive_options = $options;
            $recursive_options['parent'] = $data['id'];
            if (isset($options['max_levels'])) {
                $recursive_options['max_levels'] = $options['max_levels'] - 1;
            }
            $recursive_options['url_prefix'] = $options['url_prefix'] . $data['handle'] . '/';
            $children = discussion_forum_categories_fetch($recursive_options);
        }
        if (count($children) > 0) {
            $data['children'] = $children;
        }
        $data['url'] = $options['url_prefix'] . $data['handle'] . '/';
        $categories[] = $data;
    }
    return $categories;
}
예제 #2
0
     $post['forum_id'] = $_POST['forum_id'];
     $post['title'] = $_POST['title'];
     $post['mode'] = 'new_thread';
     $thread_id = discussion_forum_post_create($post);
     $redirect_url = forum_get_url_by_post($thread_id);
     if ($_SESSION['preferences']['forum_subscribe_on_create'] == 1) {
         $query = 'INSERT INTO forum_read_posts (user_id, thread_id, subscribing, posts, has_voted) VALUES("' . $_SESSION['login']['id'] . '", "' . $thread_id;
         $query .= '", "true", 1, 0)';
         mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
         $thread = array_pop(discussion_forum_post_fetch(array('post_id' => $thread_id)));
         $_SESSION['forum']['subscriptions'][$thread_id] = $thread;
     }
     header('Location: ' . $redirect_url);
 } elseif ($_POST['mode'] == 'sub_thread') {
 } else {
     $forum_security = forum_security(array('action' => 'new_post', 'forum_id' => $_POST['forum_id'], 'parent_post' => $_POST['parent'], 'content' => $_POST['content']));
     if ($forum_security !== true) {
         $output .= $forum_security;
         break;
     }
     $post['content'] = $_POST['content'];
     $post['parent_post'] = $_POST['parent'];
     $post['forum_id'] = $_POST['forum_id'];
     $post['mode'] = 'new_post';
     $post_id = discussion_forum_post_create($post);
     if ($_SESSION['preferences']['forum_subscribe_on_post'] == 1) {
         $query = 'UPDATE forum_read_posts SET subscribing = "true" WHERE user_id = "' . $_SESSION['login']['id'] . '" AND thread_id = "' . $_POST['parent'] . '" LIMIT 1';
         mysql_query($query);
         $thread = array_pop(discussion_forum_post_fetch(array('post_id' => $_POST['parent'])));
         $_SESSION['forum']['subscriptions'][$_POST['parent']] = $thread;
     }
예제 #3
0
    $message .= '%REMOVAL_COMMENT%' . "\n";
    $message .= '-----' . "\n\n";
    $message .= 'Här är ditt inlägg:' . "\n";
    $message .= '-----' . "\n";
    $message .= '%CONTENT%' . "\n";
    $message .= '-----' . "\n\n";
    $message .= 'Har du några frågor så ta det med någon ordningsvakt, du hittar sådana i modulen "Inloggade Ordningsvakter" till höger.' . "\n";
    $message .= 'Detta är inte hela världen, men det är kanske bäst att du chillar lite extra i framtiden.' . "\n\n";
    $message .= '/Webmaster';
    $guestbook_message = array('sender' => 2348, 'recipient' => intval($post['author']), 'message' => mysql_real_escape_string(str_replace(array('%TITLE%', '%CONTENT%', '%REMOVAL_COMMENT%', '%REMOVERS_USERNAME%'), array($post['title'], $post['content'], $_GET['removal_comment'], $_SESSION['login']['username']), $message)));
    preint_r($guestbook_message);
    guestbook_insert($guestbook_message);
    log_admin_event('post removed', $post['removal_comment'], $_SESSION['login']['id'], $post['author'], $_GET['post_id']);
    admin_action_count($_SESSION['login']['id'], 'post_removed');
}
if ($_GET['action'] == 'unremove_post' && forum_security(array('action' => 'unremove_post', 'post_id' => $_GET['post_id']))) {
    discussion_forum_remove_post(array('post_id' => $_GET['post_id'], 'mode' => 'unremove'));
}
if ($_GET['action'] == 'vote' && login_checklogin() && is_numeric($_GET['thread_id'])) {
    $query = 'UPDATE forum_read_posts SET has_voted = 1 WHERE thread_id = "' . $_GET['thread_id'] . '" AND user_id = "' . $_SESSION['login']['id'] . '" AND has_voted = 0';
    mysql_query($query);
    if (mysql_affected_rows() == 1) {
        $operand = $_GET['vote'] == 'positive' ? '+' : '-';
        $query = 'UPDATE forum_posts SET score = score ' . $operand . ' 1 WHERE id = "' . $_GET['thread_id'] . '"';
        mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
    }
}
/* Thread subscriptions */
if ($_GET['action'] == 'add_thread_subscription') {
    $query = 'UPDATE forum_read_posts SET subscribing = "true" WHERE user_id = "' . $_SESSION['login']['id'] . '" AND thread_id = "' . $_GET['thread_id'] . '" LIMIT 1';
    mysql_query($query);
예제 #4
0
        if (forum_security(array('action' => 'edit_post', 'post' => $post))) {
            $query .= '"' . $_POST['content'] . $addition . '"';
        } else {
            $query .= '"' . $post['content'] . $addition . '"';
        }
        $query .= ' WHERE id = "' . $_POST['post_id'] . '" LIMIT 1';
        mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
    }
    echo '<h1>Ändring och tillägg sparat!</h1>' . "\n";
} elseif (isset($_GET['post_id']) && is_numeric($_GET['post_id'])) {
    $post = discussion_forum_post_fetch(array('post_id' => $_GET['post_id']));
    if (count($post) == 1) {
        $post = array_pop($post);
        $disabled = forum_security(array('action' => 'edit_post', 'post' => $post)) == true ? '' : ' disabled="disabled"';
        echo '<form method="post">' . "\n";
        echo '<input type="hidden" name="post_id" value="' . $_GET['post_id'] . '" />' . "\n";
        echo '<h5>Inläggstext</h5>' . "\n";
        echo '<textarea name="content"' . $disabled . ' class="content_editor">' . $post['content'] . '</textarea>' . "\n";
        if (forum_security(array('action' => 'post_addition', 'post' => $post)) == true) {
            echo '<h5>Tillägg</h5>' . "\n";
            echo '<textarea name="addition"></textarea>' . "\n";
        }
        // Edit av Joar
        echo '<input type="submit" value="Spara" />' . "\n";
        // Gamla:			echo '<input type="submit" value="Spara" />' . "\n";
    }
}
?>
</div>
</body>
</html>
예제 #5
0
파일: index.php 프로젝트: Razze/hamsterpaj
     $post['forum_id'] = $_POST['forum_id'];
     $post['title'] = $_POST['title'];
     $post['mode'] = 'new_thread';
     $thread_id = discussion_forum_post_create($post);
     $redirect_url = forum_get_url_by_post($thread_id);
     if ($_SESSION['preferences']['forum_subscribe_on_create'] == 1) {
         $query = 'INSERT INTO forum_read_posts (user_id, thread_id, subscribing, posts, has_voted) VALUES("' . $_SESSION['login']['id'] . '", "' . $thread_id;
         $query .= '", "true", 1, 0)';
         mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
         $thread = array_pop(discussion_forum_post_fetch(array('post_id' => $thread_id)));
         $_SESSION['forum']['subscriptions'][$thread_id] = $thread;
     }
     header('Location: ' . $redirect_url);
 } elseif ($_POST['mode'] == 'sub_thread') {
 } else {
     $forum_security = forum_security(array('action' => 'new_post', 'forum_id' => $_POST['forum_id'], 'parent_post' => $_POST['parent'], 'userlevel' => login_checklogin() ? $_SESSION['login']['userlevel'] : 0, 'content' => $_POST['content']));
     if ($forum_security !== true) {
         $output .= $forum_security;
         break;
     }
     $post['content'] = $_POST['content'];
     $post['parent_post'] = $_POST['parent'];
     $post['forum_id'] = $_POST['forum_id'];
     $post['mode'] = 'new_post';
     $post_id = discussion_forum_post_create($post);
     if ($_SESSION['preferences']['forum_subscribe_on_post'] == 1) {
         $query = 'UPDATE forum_read_posts SET subscribing = "true" WHERE user_id = "' . $_SESSION['login']['id'] . '" AND thread_id = "' . $_POST['parent'] . '" LIMIT 1';
         mysql_query($query);
         $thread = array_pop(discussion_forum_post_fetch(array('post_id' => $_POST['parent'])));
         $_SESSION['forum']['subscriptions'][$_POST['parent']] = $thread;
     }
예제 #6
0
function render_full_article($article)
{
    if (empty($article)) {
        $out .= rounded_corners_top(array('color' => 'red'));
        $out .= '<h1>Den här artikeln kunde tyvärr inte hittas</h1>' . "\n";
        $out .= '<a href="?action=list"><< Gå till listan över artiklar</a>' . "\n";
        $out .= rounded_corners_bottom(array('color' => 'red'));
    } else {
        $out .= render_article($article);
        if ($article['photo_category_id'] > 0) {
            $options['category'] = $article['photo_category_id'];
            $photos = photos_fetch($options);
            $out .= '<h2>Tillhörande bilder</h2>' . "\n";
            $out .= photos_list($photos);
        }
        if ($article['showauthor'] == 1) {
            $out .= render_author($article['author']);
        }
        if (isset($article['forum_category_id']) && $article['forum_category_id'] != 0) {
            $all_categories_list = discussion_forum_categories_fetch(array('id' => $article['forum_category_id']));
            $category = array_pop($all_categories_list);
            $forum_security = forum_security(array('action' => 'view_category', 'category' => $category));
            if ($forum_security == true) {
                $path_to_category = discussion_forum_path_to_category(array('id' => $category['id']));
                $locator_options['categories'] = $path_to_category;
                unset($options);
                $options['max_levels'] = 0;
                $options['parent'] = $category['id'];
                $categories = discussion_forum_categories_fetch($options);
                $out .= discussion_forum_categories_list($categories);
                $out .= '<h2>Trådar</h2>' . "\n";
                $post_options['forum_id'] = $category['id'];
                $post_options['threads_only'] = true;
                $post_options['order_by_sticky'] = true;
                $post_options['page_offset'] = $request['page_offset'];
                $post_options['url_lookup'] = true;
                $threads = discussion_forum_post_fetch($post_options);
                //$threads['url'] = $path_to_trailing_category = array_pop($path_to_category) . '/' . $thread['handle'] . '/sida_1.php';
                $out .= discussion_forum_thread_list($threads);
                $path_to_trailing_category = array_pop($path_to_category);
                $out .= '<a href="' . $path_to_trailing_category['url'] . '">Skapa en egen tråd länkad till artikeln</a>' . '<br style="clear: both;" />';
                forum_update_category_session(array('category' => $category, 'threads' => $threads));
            }
        }
        if ($article['commentable'] == 1) {
            $out .= rounded_corners_top(array('color' => 'blue_deluxe'));
            if ($article['rankable'] == 1) {
                $out .= rank_input_draw($article['id'], 'articles');
            }
            $out .= comments_input_draw($article['id'], 'articles');
            $out .= '<div style="clear: both;"></div>' . "\n";
            $out .= rounded_corners_bottom();
            $out .= comments_list($article['id'], 'articles');
        }
    }
    if (is_privilegied('articles_admin')) {
        $out .= '<a href="/artiklar/index.php?action=admin&article=edit&id=' . $article['id'] . '">Ändra i artikeln</a>' . "\n";
    }
    return $out;
}