コード例 #1
0
ファイル: create_forums.php プロジェクト: asifiqbal/cosmohome
function create_forum($category, $orderID, $title, $description, $is_dev_blog = 0)
{
    $q = "(category, orderID, title, description, is_dev_blog) values ({$category}, {$orderID}, '{$title}', '{$description}', {$is_dev_blog})";
    $db = BoincDB::get();
    $result = $db->insert("forum", $q);
    if (!$result) {
        $forum = BoincForum::lookup("category={$category} and title='{$title}'");
        if ($forum) {
            return $forum->id;
        }
        echo "can't create forum\n";
        echo $db->base_error();
        exit;
    }
    return $db->insert_id();
}
コード例 #2
0
function show_platforms()
{
    $xmlFragment = unserialize(get_cached_data(3600, "project_config_platform_xml"));
    if ($xmlFragment == false) {
        $platforms = BoincDB::get()->enum_fields("platform, DBNAME.app_version, DBNAME.app", "BoincPlatform", "platform.name, platform.user_friendly_name, plan_class", "app_version.platformid = platform.id and app_version.appid = app.id and app_version.deprecated=0 and app.deprecated=0 group by platform.name, plan_class", "");
        $xmlFragment = "    <platforms>";
        foreach ($platforms as $platform) {
            $xmlFragment .= "\n            <platform>\n                <platform_name>{$platform->name}</platform_name>\n                <user_friendly_name>{$platform->user_friendly_name}</user_friendly_name>";
            if ($platform->plan_class) {
                $xmlFragment .= "\n                <plan_class>{$platform->plan_class}</plan_class>\n";
            }
            $xmlFragment .= "\n            </platform>";
        }
        $xmlFragment .= "\n    </platforms>\n";
        set_cached_data(3600, serialize($xmlFragment), "project_config_platform_xml");
    }
    echo $xmlFragment;
}
コード例 #3
0
ファイル: server_status.php プロジェクト: suno/boinc
function get_job_status()
{
    $s = unserialize(get_cached_data(STATUS_PAGE_TTL, "job_status"));
    if ($s) {
        return $s;
    }
    $s = new StdClass();
    $apps = BoincApp::enum("deprecated=0");
    foreach ($apps as $app) {
        $info = BoincDB::get()->lookup_fields("result", "stdClass", "ceil(avg(elapsed_time)/3600*100)/100 as avg,\n            ceil(min(elapsed_time)/3600*100)/100 as min,\n            ceil(max(elapsed_time)/3600*100)/100 as max,\n            count(distinct userid) as users", "appid = {$app->id}\n            AND validate_state=1\n            AND received_time > (unix_timestamp()-86400)\n            ");
        $app->info = $info;
        $app->unsent = BoincResult::count("appid={$app->id} and server_state=2");
        $app->in_progress = BoincResult::count("appid={$app->id} and server_state=4");
    }
    $s->apps = $apps;
    $s->results_ready_to_send = BoincResult::count("server_state=2");
    $s->results_in_progress = BoincResult::count("server_state=4");
    $s->results_need_file_delete = BoincResult::count("file_delete_state=1");
    $s->wus_need_validate = BoincWorkunit::count("need_validate=1");
    $s->wus_need_assimilate = BoincWorkunit::count("assimilate_state=1");
    $s->wus_need_file_delete = BoincWorkunit::count("file_delete_state=1");
    $x = BoincDB::get()->lookup_fields("workunit", "stdClass", "MIN(transition_time) as min", "TRUE");
    $gap = (time() - $x->min) / 3600;
    if ($gap < 0 || $x->min == 0) {
        $gap = 0;
    }
    $s->transitioner_backlog = $gap;
    $s->users_with_recent_credit = BoincUser::count("expavg_credit>1");
    $s->users_with_credit = BoincUser::count("total_credit>1");
    $s->users_past_24_hours = BoincUser::count("create_time > (unix_timestamp() - 86400)");
    $s->hosts_with_recent_credit = BoincHost::count("expavg_credit>1");
    $s->hosts_with_credit = BoincHost::count("total_credit>1");
    $s->hosts_past_24_hours = BoincHost::count("create_time > (unix_timestamp() - 86400)");
    $s->flops = BoincUser::sum("expavg_credit") / 200;
    $s->db_revision = null;
    if (file_exists("../../db_revision")) {
        $s->db_revision = trim(file_get_contents("../../db_revision"));
    }
    $s->cached_time = time();
    $e = set_cached_data(STATUS_PAGE_TTL, serialize($s), "job_status");
    if ($e) {
        echo "set_cached_data(): {$e}\n";
    }
    return $s;
}
コード例 #4
0
ファイル: server_status.php プロジェクト: entibasse/superhost
function get_runtime_info($appid)
{
    $info = unserialize(get_cached_data(3600, "get_runtime_info" . $appid));
    if ($info == false) {
        $info = BoincDB::get()->lookup_fields("result", "stdClass", "ceil(avg(elapsed_time)/3600*100)/100 as avg,\n            ceil(min(elapsed_time)/3600*100)/100 as min,\n            ceil(max(elapsed_time)/3600*100)/100 as max,\n            count(distinct userid) as users", "appid = {$appid} \n            AND validate_state=1 \n            AND received_time > (unix_timestamp()-(3600*24)) \n            ");
        if (!$info) {
            // No recent jobs sound
            $info = new stdClass();
            $info->avg = $info->min = $info->max = $info->users = 0;
        }
        set_cached_data(3600, serialize($info), "get_runtime_info" . $appid);
    }
    return $info;
}