예제 #1
0
function cleanup_orphan_threads()
{
    $threads = BoincThread::enum("");
    foreach ($threads as $thread) {
        $forum = BoincForum::lookup_id($thread->forum);
        if (!$forum) {
            cleanup_thread($thread);
        }
    }
}
예제 #2
0
function update_thread_replies()
{
    $threads = BoincThread::enum();
    foreach ($threads as $t) {
        $n = BoincPost::count("thread={$t->id} and hidden=0");
        $n--;
        if ($t->replies != $n) {
            $t->update("replies={$n}");
            echo "updated thread {$t->id}; {$t->replies} -> {$n}\n";
        }
    }
}
예제 #3
0
function search_thread_titles($keyword_list, $forum = "", $user = "", $time = "", $limit = 200, $sort_style = CREATE_TIME_NEW, $show_hidden = false)
{
    $search_string = "%";
    foreach ($keyword_list as $key => $word) {
        $search_string .= BoincDb::escape_string($word) . "%";
    }
    $query = "title like '" . $search_string . "'";
    if ($forum && $forum != "all") {
        $query .= " and forum = {$forum->id}";
    }
    if ($user && $user != "all") {
        $query .= " and owner = {$user->id}";
    }
    if ($time && $user != "all") {
        $query .= " and timestamp > {$time}";
    }
    if (!$show_hidden) {
        $query .= " and thread.hidden = 0";
    }
    switch ($sort_style) {
        case MODIFIED_NEW:
            $query .= ' ORDER BY timestamp DESC';
            break;
        case VIEWS_MOST:
            $query .= ' ORDER BY views DESC';
            break;
        case REPLIES_MOST:
            $query .= ' ORDER BY replies DESC';
            break;
        case CREATE_TIME_NEW:
            $query .= ' ORDER by create_time desc';
            break;
        case CREATE_TIME_OLD:
            $query .= ' ORDER by create_time asc';
            break;
        case 'score':
            $query .= ' ORDER by score desc';
            break;
        default:
            $query .= ' ORDER BY timestamp DESC';
            break;
    }
    $query .= " limit {$limit}";
    return BoincThread::enum($query);
}
예제 #4
0
function remove($team)
{
    $forum = BoincForum::lookup("parent_type=1 and category={$team->id}");
    if (!$forum) {
        error_page("message board not found");
    }
    // delete threads and posts
    //
    $threads = BoincThread::enum("forum={$forum->id}");
    foreach ($threads as $thread) {
        $posts = BoincPost::enum("thread={$thread->id}");
        foreach ($posts as $post) {
            $post->delete();
        }
        $thread->delete();
    }
    $forum->delete();
    page_head(tra("Message board removed"));
    echo "<p>" . tra("Your team's message board has been removed. You may now %1create a new one%2.", "<a href=team_forum.php?teamid={$team->id}&cmd=manage>", "</a>") . "</p>";
    page_tail();
}
예제 #5
0
        echo "    <timestamp>{$post->timestamp}</timestamp>\n";
        if ($length > 0) {
            echo "    <content><![CDATA[" . substr($post->content, 0, $length) . "]]></content>\n";
        } else {
            echo "    <content><![CDATA[" . $post->content . "]]></content>\n";
        }
        echo "</post>\n";
    }
    echo "</posts>\n";
    echo "</rpc_response>\n";
} elseif ($method == "user_threads") {
    $count = get_int("count", true);
    if (!$count || $count <= 0 || $count > 50) {
        $count = 10;
    }
    $threads = BoincThread::enum("owner={$userid} ORDER BY timestamp DESC LIMIT {$count}");
    $count = count($threads);
    echo "<rpc_response>\n";
    echo "<count>{$count}</count>\n";
    echo "<threads>\n";
    foreach ($threads as $thread) {
        echo "<thread>\n";
        echo "    <id>{$thread->id}</id>\n";
        echo "    <forumid>{$thread->forum}</forumid>\n";
        echo "    <replies>{$thread->replies}</replies>\n";
        echo "    <views>{$thread->views}</views>\n";
        echo "    <timestamp>{$thread->timestamp}</timestamp>\n";
        echo "    <title><![CDATA[{$thread->title}]]></title>\n";
        echo "</thread>\n";
    }
    echo "</threads>\n";
예제 #6
0
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
$cli_only = true;
require_once "../inc/util_ops.inc";
require_once "../inc/forum_db.inc";
define('MAX_REWARD', 4096);
define('SCALAR', 0.9);
set_time_limit(0);
echo date(DATE_RFC822), ": Starting\n";
$now = time();
$threads = BoincThread::enum();
foreach ($threads as $thread) {
    $is_helpdesk = false;
    $forum = BoincForum::lookup_id($thread->forum);
    if ($forum && $forum->parent_type == 0) {
        $category = BoincCategory::lookup_id($forum->category);
        if ($category && $category->is_helpdesk) {
            $is_helpdesk = true;
        }
    }
    if ($is_helpdesk) {
        $diff = ($now - $thread->create_time) / 86400;
        $activity = ($thread->sufferers + 1) / $diff;
        echo "thread {$thread->id} helpdesk {$diff} {$activity}\n";
    } else {
        $posts = BoincPost::enum("thread={$thread->id}");
예제 #7
0
$since_time = time() - 30 * 86400;
$user = BoincUser::lookup_id($userid);
if (!$user) {
    xml_error();
}
// the auth in the URL includes "userid_"
//
$x = $user->id . "_" . notify_rss_auth($user);
if ($x != $auth) {
    xml_error(-155, 'Invalid authenticator');
}
$since_clause = "and create_time > {$since_time}";
$notifies = BoincNotify::enum("userid = {$userid} {$since_clause}");
$forum = news_forum();
if ($forum) {
    $threads = BoincThread::enum("forum = {$forum->id} and hidden=0 and status=0 {$since_clause}");
}
// there may be a better way to do this
$items = array();
foreach ($notifies as $n) {
    $i = null;
    $i->type = 0;
    $i->time = $n->create_time;
    $i->val = $n;
    $items[] = $i;
}
foreach ($threads as $t) {
    $i = null;
    $i->type = 1;
    $i->time = $t->create_time;
    $i->val = $t;
예제 #8
0
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
// This file allows people to subscribe to threads.
// Whenever someone posts to the thread
// the subscribers will receive a notification email
require_once '../inc/forum.inc';
if (DISABLE_FORUMS) {
    error_page("Forums are disabled");
}
check_get_args(array("action", "thread", "tnow", "ttok"));
$action = get_str('action');
$threadid = get_int('thread');
$thread = BoincThread::lookup_id($threadid);
$forum = BoincForum::lookup_id($thread->forum);
function show_title($forum, $thread)
{
    switch ($forum->parent_type) {
        case 0:
            $category = BoincCategory::lookup_id($forum->category);
            show_forum_title($category, $forum, $thread);
            break;
        case 1:
            show_team_forum_title($forum, $thread);
            break;
    }
}
function subscribe($forum, $thread, $user)
{
예제 #9
0
function remove($team)
{
    $forum = BoincForum::lookup("parent_type=1 and category={$team->id}");
    if (!$forum) {
        error_page("not found");
    }
    // delete threads and posts
    //
    $threads = BoincThread::enum("forum={$forum->id}");
    foreach ($threads as $thread) {
        $posts = BoincPost::enum("thread={$thread->id}");
        foreach ($posts as $post) {
            $post->delete();
        }
        $thread->delete();
    }
    $forum->delete();
    page_head("Message board removed");
    page_tail();
}
예제 #10
0
} elseif ($action == "delete") {
    $result = delete_post($post, $thread, $forum);
    if (!$result) {
        error_page("Can't delete post");
    }
    page_head("Post deleted");
    if (BoincThread::lookup_id($thread->id)) {
        echo "Post successfully deleted.\n            <p>\n            <a href=forum_thread.php?id={$thread->id}>Return to thread</a>\n        ";
    } else {
        echo "Post and thread successfully deleted.\n            <p>\n            <a href=forum_forum.php?id={$forum->id}>Return to forum</a>\n        ";
    }
    page_tail();
    exit;
} elseif ($action == "move") {
    $destid = post_int('threadid');
    $new_thread = BoincThread::lookup_id($destid);
    if (!$new_thread) {
        error_page("No such thread");
    }
    $new_forum = BoincForum::lookup_id($new_thread->forum);
    if ($forum->parent_type != $new_forum->parent_type) {
        error_page(tra("Can't move to different category type"));
    }
    if ($forum->parent_type != 0) {
        if ($forum->category != $new_forum->category) {
            error_page(tra("Can't move to different category"));
        }
    }
    $result = move_post($post, $thread, $forum, $new_thread, $new_forum);
    $explanation = "Old thread: {$thread->title}\n" . secure_url_base() . "forum_thread.php?id={$thread->id}\nNew thread: {$new_thread->title}\n" . secure_url_base() . "forum_thread.php?id={$new_thread->id}&postid={$post->id}\n";
    $explanation .= mod_comment();
예제 #11
0
    $choice = post_str('submit', true);
    $rating = post_int('rating', true);
    if (!$choice) {
        $choice = get_str('choice', true);
    }
    if ($choice == SOLUTION or $choice == "p") {
        $rating = 1;
    } else {
        $rating = -1;
    }
    $user = get_logged_in_user();
    if ($choice == null && ($rating == null || $rating > 2 || $rating < -2)) {
        show_result_page(false, NULL, NULL, $choice);
    }
    $post = BoincPost::lookup_id($postId);
    $thread = BoincThread::lookup_id($post->thread);
    $forum = BoincForum::lookup_id($thread->forum);
    // Make sure the user has the forum's minimum amount of RAC and total credit
    // before allowing them to rate a post.
    //
    if ($user->total_credit < $forum->rate_min_total_credit || $user->expavg_credit < $forum->rate_min_expavg_credit) {
        error_page(tra("You need more average or total credit to rate a post."));
    }
    if (BoincPostRating::lookup($user->id, $post->id)) {
        error_page(tra("You have already rated this post.") . "<br /><br /><a href=\"forum_thread.php?nowrap=true&id=" . $thread->id . "#" . $post->id . "\">" . tra("Return to thread") . "</a>");
    } else {
        $success = BoincPostRating::replace($user->id, $post->id, $rating);
        show_result_page($success, $post, $thread, $choice);
    }
}
function show_result_page($success, $post, $thread, $choice)
예제 #12
0
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
//
// This file was modified by contributors of "BOINC Web Tweak" project.
// Use this file you can post a reply to a thread.
// Both input (form) and action take place here.
require_once '../inc/forum_email.inc';
require_once '../inc/forum.inc';
require_once '../inc/akismet.inc';
$logged_in_user = get_logged_in_user(true);
BoincForumPrefs::lookup($logged_in_user);
check_banished($logged_in_user);
$thread = BoincThread::lookup_id(get_int('thread'));
$forum = BoincForum::lookup_id($thread->forum);
$sort_style = get_str('sort', true);
$filter = get_str('filter', true);
$content = post_str('content', true);
$preview = post_str("preview", true);
$parent_post_id = get_int('post', true);
$parent_post = null;
if ($parent_post_id) {
    $parent_post = BoincPost::lookup_id($parent_post_id);
    if ($parent_post->thread != $thread->id) {
        error_page("wrong thread");
    }
} else {
    $parent_post_id = 0;
}
예제 #13
0
파일: forum_index.php 프로젝트: happyj/qcn
}
if ($user && $user->teamid) {
    $forum = BoincForum::lookup("parent_type=1 and category={$user->teamid}");
    if ($forum) {
        show_forum_summary($forum, $i++);
    }
}
end_table();
if ($user) {
    $subs = BoincSubscription::enum("userid={$user->id}");
    if (count($subs)) {
        echo "<p><span class=title>" . tra("Subscribed threads") . "</span><p>";
        show_thread_and_context_header();
        $i = 0;
        foreach ($subs as $sub) {
            $thread = BoincThread::lookup_id($sub->threadid);
            if (!$thread) {
                BoincSubscription::delete($user->id, $sub->threadid);
                continue;
            }
            if ($thread->hidden) {
                continue;
            }
            show_thread_and_context($thread, $user, $i++);
        }
        end_table();
    }
}
page_tail();
flush();
BoincForumLogging::cleanup();
예제 #14
0
}
$clause = "forum={$forumid} ";
if ($userid) {
    $user = BoincUser::lookup_id($userid);
    if (!$user) {
        error_page("no such user");
    }
    $clause .= " and owner={$userid}";
}
class Int
{
}
$db = BoincDb::get();
$x = $db->lookup_fields("thread", "Int", "max(timestamp) as foo", "{$clause} and status=0 and hidden=0 and sticky=0");
$last_mod_time = $x->foo;
$threads = BoincThread::enum("{$clause} and status=0 and hidden=0 and sticky=0 order by create_time desc limit {$nitems}");
// Get unix time that last modification was made to the news source
//
$create_date = gmdate('D, d M Y H:i:s', $last_mod_time) . ' GMT';
// Now construct header
//
header("Expires: " . gmdate('D, d M Y H:i:s', time() + 86400) . " GMT");
header("Last-Modified: " . $create_date);
header("Content-Type: application/xml");
// Create channel header and open XML content
//
$description = PROJECT . ": {$forum->description}";
if ($user) {
    $description .= " (posts by {$user->name})";
}
$channel_image = URL_BASE . "rss_image.gif";
예제 #15
0
    if (isset($item[2])) {
        $title = $item[2];
    } else {
        $n = strpos($content, ". ");
        if ($n) {
            $title = substr($content, 0, $n);
        } else {
            $title = $content;
        }
    }
    $when = strtotime($item[0]);
    $title = html_to_bbcode($title);
    $title = str_replace("\n", " ", $title);
    $title = mysql_real_escape_string($title);
    $content = html_to_bbcode($content);
    $content = str_replace("\n", " ", $content);
    $content = mysql_real_escape_string($content);
    $thread_id = BoincThread::insert("(forum, owner, title, create_time, timestamp, replies) values ({$forum_id}, {$user->id}, '{$title}', {$when}, {$when}, 0)");
    if (!$thread_id) {
        echo "thread insert failed\n";
        echo "title: [{$title}]\n";
        echo "when: {$when}\n";
        exit;
    }
    $id = BoincPost::insert("(thread, user, timestamp, content) values ({$thread_id}, {$user->id}, {$when}, '{$content}')");
    if (!$id) {
        die("post insert");
    }
    $forum->update("threads=threads+1, posts=posts+1");
}
echo "\n\nProject news has been successfully converted from\nhtml/project/project_news.inc to forum format.\nChange your index.php to use\n   show_news(0, 5)\nto show news and related links.\n\nIf everything looks OK, you can delete html/project/project_news.inc\n\n";