Пример #1
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";
        }
    }
}
Пример #2
0
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);
}
Пример #3
0
$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";
        }
Пример #4
0
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);
            }
        }
    }
}
Пример #5
0
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";
            }
        }
    }
}