Example #1
0
function get_data()
{
    $db = BoincDb::get();
    // get CPU model status in a special query;
    // enumerating hosts was too slow on SETI@home.
    //
    // Ideally a model's fpops should be the median over hosts of that model.
    // But SQL has no median function.
    // Instead, take the mean of plausible values
    //
    $x = $db->enum_fields('host', 'StdClass', 'p_model, count(*) as nhosts, avg(p_ncpus) as ncores, avg(p_fpops) as fpops', 'p_fpops>1e6 and p_fpops<1e11 and p_fpops <> 1e9 and expavg_credit>".MIND_CREDIT." group by p_model', null);
    $m2 = array();
    foreach ($x as $m) {
        if ($m->nhosts < MIN_COUNT) {
            continue;
        }
        $y = new StdClass();
        $y->model = $m->p_model;
        $y->p_fpops = $m->fpops;
        $y->mean_ncores = $m->ncores;
        $y->nhosts = $m->nhosts;
        $m2[] = $y;
    }
    return $m2;
}
Example #2
0
function do_app($app)
{
    // enumerate the host_app_versions for this app,
    // joined to the host
    $db = BoincDb::get();
    $query = "select et_avg, host.on_frac, host.active_frac, host.gpu_active_frac, app_version.plan_class " . " from DBNAME.host_app_version, DBNAME.host, DBNAME.app_version " . " where host_app_version.app_version_id = app_version.id " . " and app_version.appid = {$app->id} " . " and et_n > 0  and et_avg > 0 " . " and host.id = host_app_version.host_id";
    $result = $db->do_query($query);
    $a = array();
    while ($x = _mysql_fetch_object($result)) {
        if (is_gpu($x->plan_class)) {
            $av = $x->on_frac;
            if ($x->gpu_active_frac) {
                $av *= $x->gpu_active_frac;
            } else {
                $av *= $x->active_frac;
            }
        } else {
            $av = $x->on_frac * $x->active_frac;
        }
        $a[] = 1 / $x->et_avg * $av;
    }
    _mysql_free_result($result);
    sort($a);
    $n = count($a);
    $f = fopen("../../size_census_" . $app->name, "w");
    for ($i = 1; $i < $app->n_size_classes; $i++) {
        $k = (int) ($i * $n / $app->n_size_classes);
        fprintf($f, "%e\n", $a[$k]);
    }
    fclose($f);
}
Example #3
0
function get_includes()
{
    $c = getcwd();
    chdir('html/ops');
    require_once '../inc/util_ops.inc';
    BoincDb::get();
    chdir($c);
}
Example #4
0
function get_top_participants($offset, $sort_by)
{
    global $users_per_page;
    $db = BoincDb::get(true);
    if ($sort_by == "total_credit") {
        $sort_order = "total_credit desc";
    } else {
        $sort_order = "expavg_credit desc";
    }
    return BoincUser::enum(null, "order by {$sort_order} limit {$offset},{$users_per_page}");
}
Example #5
0
function get_top_teams($offset, $sort_by, $type)
{
    global $teams_per_page;
    $db = BoincDb::get(true);
    $type_clause = null;
    if ($type) {
        $type_clause = "type={$type}";
    }
    if ($sort_by == "total_credit") {
        $sort_order = "total_credit desc";
    } else {
        $sort_order = "expavg_credit desc";
    }
    return BoincTeam::enum($type_clause, "order by {$sort_order} limit {$offset}, {$teams_per_page}");
}
Example #6
0
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);
}
Example #7
0
function send_notify_emails()
{
    $db = BoincDb::get();
    $t = time() - (86400 + 3600);
    // 1-hour slop factor
    $query = "select notify.* from " . $db->db_name . ".notify, " . $db->db_name . ".forum_preferences where forum_preferences.pm_notification=2 and notify.userid = forum_preferences.userid and notify.create_time > {$t}";
    $notifies = BoincNotify::enum_general($query);
    $userid = 0;
    $message = "";
    $i = 1;
    foreach ($notifies as $notify) {
        if ($userid && $notify->userid != $userid && strlen($message)) {
            send_notify_email($userid, $message);
            $message = "";
            $found = false;
            $i = 1;
        }
        $userid = $notify->userid;
        $x = null;
        switch ($notify->type) {
            case NOTIFY_FRIEND_REQ:
                $x = friend_notify_req_email_line($notify);
                break;
            case NOTIFY_FRIEND_ACCEPT:
                $x = friend_notify_accept_email_line($notify);
                break;
            case NOTIFY_PM:
                $x = pm_email_line($notify);
                break;
            case NOTIFY_SUBSCRIBED_POST:
                $x = subscribed_post_email_line($notify);
                break;
        }
        if ($x) {
            $message .= "{$i}) {$x}\n";
            $i++;
        } else {
            $notify->delete();
        }
    }
    if ($userid && strlen($message)) {
        send_notify_email($userid, $message);
    }
}
Example #8
0
function process_batch($b)
{
    $app = BoincApp::lookup_id($b->app_id);
    if (!$app) {
        echo "no app for batch {$b->id}\n";
        return;
    }
    if ($b->fraction_done > 0 && $b->credit_canonical > 0) {
        $credit_total = $b->credit_canonical / $b->fraction_done;
        $fpops_total = $credit_total * (86400000000000.0 / 200);
    } else {
        $db = BoincDb::get();
        $fpops_total = $db->sum("workunit", "rsc_fpops_est*target_nresults", "where batch={$b->id}");
    }
    echo "batch {$b->id} fpops_total {$fpops_total}\n";
    if ($fpops_total == 0) {
        return;
    }
    // adjust the user's logical start time
    //
    $user = BoincUser::lookup_id($b->user_id);
    if (!$user) {
        die("no user {$b->user_id}\n");
    }
    $us = BoincUserSubmit::lookup_userid("{$user->id}");
    if (!$us) {
        die("no user submit record\n");
    }
    $lst = $us->logical_start_time;
    $cmd = "cd ../../bin; ./adjust_user_priority --user {$user->id} --flops {$fpops_total} --app {$app->name}";
    system($cmd);
    $us = BoincUserSubmit::lookup_userid("{$user->id}");
    $let = $us->logical_start_time;
    $let = (int) $let;
    // set the priority of workunits and results in this batch
    // to the user's new logical start time
    //
    $clause = "priority={$let} where batch={$b->id}";
    BoincResult::update_aux($clause);
    BoincWorkunit::update_aux($clause);
}
function get_models()
{
    $db = BoincDb::get();
    $result = $db->do_query("select result.appid, result.outcome, host.product_name from result join host where host.os_name='Android' and result.hostid=host.id");
    $models = array();
    while ($r = $result->fetch_object()) {
        // standardize case to combine e.g. Samsung and samsung
        //
        $name_uc = strtoupper($r->product_name);
        if (array_key_exists($name_uc, $models)) {
            $m = $models[$name_uc];
            $m[$r->outcome]++;
            $models[$name_uc] = $m;
        } else {
            $m = array(0, 0, 0, 0, 0, 0, 0, 0);
            $m[$r->outcome]++;
            $models[$name_uc] = $m;
        }
    }
    return $models;
}
Example #10
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/>.
require_once "../inc/boinc_db.inc";
require_once "../inc/util.inc";
require_once "../inc/team.inc";
if (DISABLE_TEAMS) {
    error_page("Teams are disabled");
}
check_get_args(array("format", "team_id", "team_ids", "team_name"));
$format = get_str("format", true);
$team_id = get_int("team_id", true);
$team_ids = get_str("team_ids", true);
BoincDb::get(true);
if ($team_id || $team_ids || $format == 'xml') {
    require_once '../inc/xml.inc';
    xml_header();
    $retval = db_init_xml();
    if ($retval) {
        xml_error($retval);
    }
}
if ($team_id) {
    $team = BoincTeam::lookup_id($team_id);
    if ($team) {
        show_team_xml($team);
    } else {
        xml_error(ERR_DB_NOT_FOUND);
    }
Example #11
0
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// 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/>.
// lock all threads older than N days
$cli_only = true;
require_once "../inc/util_ops.inc";
$max_age_days = 90;
// lock threads older than this
if ($argc > 2) {
    if ($argv[1] == "--ndays") {
        $max_age_days = $argv[2];
    }
}
$t = time_str(time());
echo "starting at {$t}\n";
$t = time() - $max_age_days * 86400;
$db = BoincDb::get();
if (!$db) {
    die("can't open DB\n");
}
$db->do_query("update " . $db->db_name . ".thread, " . $db->db_name . ".forum set " . $db->db_name . ".thread.locked=1 where " . $db->db_name . ".thread.forum=" . $db->db_name . ".forum.id and " . $db->db_name . ".forum.parent_type=0 and " . $db->db_name . ".thread.timestamp<{$t} and " . $db->db_name . ".thread.locked=0 and " . $db->db_name . ".thread.sticky=0");
$n = $db->affected_rows();
$t = time_str(time());
echo "finished at {$t}; locked {$n} threads\n";
Example #12
0
function ping($r)
{
    xml_start_tag("ping");
    BoincDb::get();
    // errors out if DB down or web disabled
    echo "<success>1</success>\n        </ping>\n    ";
}
Example #13
0
function get_error_wus()
{
    global $notification_level;
    global $appid_filter;
    // this query is obviously expensive for big projects but if there is a replica this does not impact the project
    $db = BoincDb::get(true);
    $dbresult = $db->do_query("\n        SELECT id, name, appid, unsent, in_progress, successes, compute_errors,\n               download_errors, validate_errors, error_mask, min_quorum,\n               (compute_errors + download_errors + validate_errors) as total_errors\n        FROM (\n            SELECT\n                workunitid,\n                SUM(IF(outcome=1,1,0)) AS successes,\n                SUM(IF((outcome=3 AND client_state=1),1,0)) AS download_errors,\n                SUM(IF((outcome=3 AND client_state=3),1,0)) AS compute_errors,\n                SUM(IF(outcome=6,1,0)) AS validate_errors,\n                SUM(IF(server_state=2,1,0)) AS unsent,\n                SUM(IF(server_state=4,1,0)) AS in_progress\n            FROM result\n            WHERE server_state IN (2,4,5)\n            GROUP BY workunitid\n            ) AS t1\n            JOIN workunit ON workunit.id = workunitid\n        WHERE canonical_resultid=0 AND {$appid_filter}\n        GREATEST(download_errors, compute_errors, validate_errors) > min_quorum + {$notification_level}\n        ORDER BY name\n    ;");
    $row_cache = array();
    while ($row = $dbresult->fetch_object()) {
        $row_cache[] = $row;
    }
    $dbresult->free();
    return $row_cache;
}
function ping($r)
{
    BoincDb::get();
    // errors out if DB down or web disabled
    echo "<success>1</success>";
}
Example #15
0
function remove_backslashes($table, $field)
{
    $db = BoincDb::get();
    $query = "update DBNAME.{$table} set {$field}=replace(replace({$field}, '\\\\\\\"', '\\\"'), '\\\\\\'', '\\'')";
    $db->do_query($query);
}
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// 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/>.
// script to repair the "has_picture" field of profiles
ini_set("memory_limit", "1023M");
$cli_only = true;
require_once "../inc/util_ops.inc";
BoincDb::get();
$profiles = BoincProfile::enum("");
foreach ($profiles as $p) {
    $id = $p->userid;
    $path = "../user_profile/images/{$id}.jpg";
    $smpath = "../user_profile/images/" . $id . "_sm.jpg";
    $has_pic = file_exists($path);
    $has_pic_sm = file_exists($smpath);
    if ($p->has_picture) {
        if (!$has_pic || !$has_pic_sm) {
            echo "{$id} {$p->has_picture} {$has_pic} {$has_pic_sm}\n";
            BoincProfile::update_aux("has_picture=0 where userid={$id}");
        }
    } else {
        if ($has_pic && $has_pic_sm) {
            echo "{$id} {$p->has_picture} {$has_pic} {$has_pic_sm}\n";