1#!/usr/bin/env php
2<?php
3// This file is part of BOINC.
4// http://boinc.berkeley.edu
5// Copyright (C) 2008 University of California
6//
7// BOINC is free software; you can redistribute it and/or modify it
8// under the terms of the GNU Lesser General Public License
9// as published by the Free Software Foundation,
10// either version 3 of the License, or (at your option) any later version.
11//
12// BOINC is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15// See the GNU Lesser General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
19
20$cli_only = true;
21require_once("../inc/util_ops.inc");
22require_once("../inc/forum_db.inc");
23
24define('MAX_REWARD', 4096);
25define('SCALAR', 0.9);
26set_time_limit(0);
27
28echo date(DATE_RFC822), ": Starting\n";
29
30$now = time();
31$threads = BoincThread::enum();
32foreach ($threads as $thread) {
33    $is_helpdesk = false;
34    $forum = BoincForum::lookup_id($thread->forum);
35    if ($forum && $forum->parent_type == 0) {
36        $category = BoincCategory::lookup_id($forum->category);
37        if ($category && $category->is_helpdesk) {
38            $is_helpdesk = true;
39        }
40    }
41    if ($is_helpdesk) {
42        $diff = ($now - $thread->create_time)/86400;
43        $activity = ($thread->sufferers+1)/$diff;
44        echo "thread $thread->id helpdesk $diff $activity\n";
45    } else {
46        $posts = BoincPost::enum("thread=$thread->id");
47        $activity = 0;
48
49        foreach ($posts as $post) {
50            $diff = $now - $post->timestamp;
51            $diff /= 7*86400;
52            $activity += pow(2, -$diff);
53        }
54        echo "thread $thread->id forum $activity\n";
55    }
56    $thread->update("activity=$activity");
57
58}
59
60echo date(DATE_RFC822), ": Finished\n";
61
62?>
63