Esempio n. 1
0
function cleanup_orphan_threads()
{
    $threads = BoincThread::enum("");
    foreach ($threads as $thread) {
        $forum = BoincForum::lookup_id($thread->forum);
        if (!$forum) {
            cleanup_thread($thread);
        }
    }
}
Esempio n. 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";
        }
    }
}
Esempio 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);
}
Esempio n. 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();
}
Esempio n. 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";
// 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}");
Esempio n. 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;
Esempio n. 8
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();
}
Esempio n. 9
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";