function cleanup_thread($thread) { $posts = BoincPost::enum("thread={$thread->id}"); foreach ($posts as $post) { $post->delete(); } $thread->delete(); }
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"; } } }
function possibly_delete_user($user) { if ($user->total_credit > 0.0) { admin_error_page("Cannot delete user: User has credit."); } // Don't delete user if they have any outstanding Results // if (BoincResult::count("userid={$user->id}")) { admin_error_page("Cannot delete user: User has count results in the database."); } // Don't delete user if they have posted to the forums // if (BoincPost::count("user={$user->id}")) { admin_error_page("Cannot delete user: User has forum posts."); } if ($user->teamid) { user_quit_team($user); } delete_user($user); }
function search_post_content($keyword_list, $forum, $user, $time, $limit, $sort_style, $show_hidden) { $db = BoincDb::get(); $search_string = "%"; foreach ($keyword_list as $key => $word) { $search_string .= BoincDb::escape_string($word) . "%"; } $optional_join = ""; // if looking in a single forum, need to join w/ thread table // because that's where the link to forum is // if ($forum) { $optional_join = " LEFT JOIN " . $db->db_name . ".thread ON post.thread = thread.id"; } $query = "select post.* from " . $db->db_name . ".post" . $optional_join . " where content like '" . $search_string . "'"; if ($forum) { $query .= " and forum = {$forum->id}"; } if ($user) { $query .= " and post.user = {$user->id} "; } if ($time) { $query .= " and post.timestamp > {$time}"; } if (!$show_hidden) { $query .= " AND post.hidden = 0"; } switch ($sort_style) { case VIEWS_MOST: $query .= ' ORDER BY views DESC'; break; case CREATE_TIME_NEW: $query .= ' ORDER by post.timestamp desc'; break; case CREATE_TIME_OLD: $query .= ' ORDER by post.timestamp asc'; break; case POST_SCORE: $query .= ' ORDER by post.score desc'; break; default: $query .= ' ORDER BY post.timestamp DESC'; break; } $query .= " limit {$limit}"; return BoincPost::enum_general($query); }
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(); }
break; case 5: $c = "User Request"; break; default: $c = "Other"; break; } $x = "\nYour post was categorized as " . $c; $x .= mod_comment(); return $x; } $user = get_logged_in_user(); check_tokens($user->authenticator); BoincForumPrefs::lookup($user); $post = BoincPost::lookup_id(get_int('id')); if (!$post) { error_page("no such post"); } $thread = BoincThread::lookup_id($post->thread); $forum = BoincForum::lookup_id($thread->forum); if (!is_moderator($user, $forum)) { error_page(tra("You are not authorized to moderate this post.")); } // See if "action" is provided - either through post or get if (!post_str('action', true)) { if (!get_str('action', true)) { error_page(tra("You must specify an action...")); } else { $action = get_str('action'); }
$postId = get_int('post'); $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); } }
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; } if ($filter != "false") { $filter = true; } else { $filter = false; } check_reply_access($logged_in_user, $forum, $thread); if (!$sort_style) { $sort_style = $logged_in_user->prefs->thread_sorting; } else {
$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"; $language = "en-us"; echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n\t<rss version=\"2.0\">\n\t<channel>\n\t<title>" . $description . "</title>\n\t<link>" . URL_BASE . "</link>\n\t<description>" . $description . "</description>\n\t<copyright>" . COPYRIGHT_HOLDER . "</copyright>\n\t<lastBuildDate>" . $create_date . "</lastBuildDate>\n\t<language>" . $language . "</language>\n\t<image>\n\t\t<url>" . $channel_image . "</url>\n\t\t<title>" . PROJECT . "</title>\n\t\t<link>" . URL_BASE . "</link>\n\t</image>\n"; // write news items // foreach ($threads as $thread) { $post_date = gmdate('D, d M Y H:i:s', $thread->create_time) . ' GMT'; $unique_url = URL_BASE . "forum_thread.php?id=" . $thread->id; $clause2 = $userid ? "and user={$userid}" : ""; $posts = BoincPost::enum("thread={$thread->id} {$clause2} order by timestamp limit 1"); $post = $posts[0]; echo "<item>\n\t<title>" . strip_tags($thread->title) . "</title>\n\t<link>{$unique_url}</link>\n\t<guid isPermaLink=\"true\">{$unique_url}</guid>\n\t<description>" . substr(strip_tags($post->content), 0, 255) . " . . .</description>\n\t<pubDate>{$post_date}</pubDate>\n</item>\n"; } // Close XML content // echo "\n\t</channel>\n\t</rss>\n";
} $hide = true; $count = 10; $user = lookup_user_id($userid); $logged_in_user = get_logged_in_user(false); if ($logged_in_user = get_logged_in_user(false)) { BoincForumPrefs::lookup($logged_in_user); if ($user->id == $logged_in_user->id || $logged_in_user->prefs->privilege(0)) { $hide = false; } } page_head("Posts by {$user->name}"); if ($hide) { $posts = BoincPost::enum("user={$userid} and hidden=0 order by id desc limit {$offset},{$count}"); } else { $posts = BoincPost::enum("user={$userid} order by id desc limit {$offset},{$count}"); } $n = 0; start_table(); $options = get_output_options($logged_in_user); foreach ($posts as $post) { $thread = BoincThread::lookup_id($post->thread); if (!$thread) { continue; } $forum = BoincForum::lookup_id($thread->forum); if (!$forum) { continue; } show_post_and_context($post, $thread, $forum, $options, $n + $offset + 1); $n++;
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";
$teamid = $logged_in_user->teamid; if ($teamid) { $team = BoincTeam::lookup_id($teamid); if ($team) { $show_team = true; if (is_team_admin($logged_in_user, $team)) { $show_team_hidden = true; } } else { $teamid = 0; } } } } page_head(tra("Posts by %1", $user->name)); $posts = BoincPost::enum("user={$userid} order by id desc limit 10000"); $n = 0; start_table(); $options = get_output_options($logged_in_user); $show_next = false; foreach ($posts as $post) { $thread = BoincThread::lookup_id($post->thread); if (!$thread) { continue; } $forum = BoincForum::lookup_id($thread->forum); if (!$forum) { continue; } if (!$show_all) { if ($forum->parent_type == 1) {
function delete_teams() { global $days, $test; $query = "nusers < 2 and seti_id=0 and total_credit=0"; if ($days) { $x = time() - $days * 86400; $query .= " and create_time > {$x}"; } $teams = BoincTeam::enum($query); foreach ($teams as $team) { $n = team_count_members($team->id); if ($n > 1) { continue; } if (!has_link($team->description)) { continue; } $user = BoincUser::lookup_id($team->userid); if ($user) { $n = BoincPost::count("user={$user->id}"); if ($n) { continue; } $n = BoincHost::count("userid={$user->id}"); if ($n) { continue; } } if ($test) { echo "would delete team:\n"; echo " ID: {$team->id}\n"; echo " name: {$team->name}\n"; echo " description: {$team->description}\n"; } else { $team->delete(); echo "deleted team ID {$team->id} name {$team->name}\n"; if ($user) { do_delete_user($user); } } } }
} $userid = get_int("userid", true); $user = lookup_user_id($userid); if (!$user) { xml_error(-136); } if ($method == "user_posts") { $count = get_int("count", true); if (!$count || $count <= 0 || $count > 50) { $count = 10; } $length = get_int("contentlength", true); if ($length == null || $length <= 0) { $length = 0; } $posts = BoincPost::enum("user={$userid} ORDER BY timestamp DESC LIMIT {$count}"); $count = count($posts); echo "<rpc_response>\n"; echo "<count>{$count}</count>\n"; echo "<posts>\n"; foreach ($posts as $post) { $thread = BoincThread::lookup_id($post->thread); echo "<post>\n"; echo "\t<id>{$post->id}</id>\n"; echo "\t<threadid>{$post->thread}</threadid>\n"; echo "\t<threadtitle><![CDATA[" . $thread->title . "]]></threadtitle>\n"; echo "\t<timestamp>{$post->timestamp}</timestamp>\n"; if ($length > 0) { echo "\t<content><![CDATA[" . substr($post->content, 0, $length) . "]]></content>\n"; } else { echo "\t<content><![CDATA[" . $post->content . "]]></content>\n";
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}"); $activity = 0; foreach ($posts as $post) { $diff = $now - $post->timestamp; $diff /= 7 * 86400; $activity += pow(2, -$diff); } echo "thread {$thread->id} forum {$activity}\n"; } $thread->update("activity={$activity}"); } echo date(DATE_RFC822), ": Finished\n";
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(); }
$userid = get_int("userid", true); $user = BoincUser::lookup_id($userid); if (!$user) { xml_error(ERR_DB_NOT_FOUND); } if ($method == "user_posts") { $count = get_int("count", true); if (!$count || $count <= 0 || $count > 50) { $count = 10; } $length = get_int("contentlength", true); if ($length == null || $length <= 0) { $length = 0; } $posts = BoincPost::enum("user={$userid} ORDER BY timestamp DESC LIMIT {$count}"); $realcount = BoincPost::count("user={$userid}"); echo "<rpc_response>\n"; echo "<count>{$realcount}</count>\n"; echo "<posts>\n"; foreach ($posts as $post) { $thread = BoincThread::lookup_id($post->thread); echo "<post>\n"; echo " <id>{$post->id}</id>\n"; echo " <threadid>{$post->thread}</threadid>\n"; echo " <threadtitle><![CDATA[" . $thread->title . "]]></threadtitle>\n"; 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"; }
function delete_profiles() { global $test, $days; $profiles = BoincProfile::enum(""); foreach ($profiles as $p) { if (has_link($p->response1) || has_link($p->response2)) { $user = BoincUser::lookup_id($p->userid); if (!$user) { echo "profile has missing user: %p->userid\n"; continue; } if ($days) { if ($user->create_time < time() - $days * 86400) { continue; } } $n = BoincHost::count("userid={$p->userid}"); if ($n) { continue; } $n = BoincPost::count("user={$p->userid}"); if ($n) { continue; } delete_user($user); if ($test) { echo "\n{$p->userid}\n{$p->response1}\n{$p->response2}\n"; } } } }