Example #1
0
function get_php_net()
{
    $st = @stat(CACHEFILE);
    if ($st === false) {
        // fallthrough and download it
        return download_url();
    }
    if (CACHETIME < time() - $st['mtime']) {
        return get_cached_data();
    }
    return download_url();
}
Example #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;
}
Example #3
0
        echo "{$x->model}: {$g} gflops {$x->mean_ncores} cores {$x->nhosts} hosts \n";
    }
}
function show_cpu_list($data)
{
    page_head("CPU performance");
    echo "\n        This table shows peak CPU speed\n        (based on Whetstone benchmarks)\n        of computers participating in this project.\n        <p>\n    ";
    start_table();
    row_heading_array(array("CPU model", "Number of computers", "Avg. cores/computer", "GFLOPS/core", "GFLOPs/computer"));
    $i = 0;
    $total_nhosts = 0;
    $total_gflops = 0;
    foreach ($data->cpus as $d) {
        row_array(array($d->model, $d->nhosts, number_format($d->mean_ncores, 2), number_format($d->p_fpops / 1000000000.0, 2), number_format($d->mean_ncores * $d->p_fpops / 1000000000.0, 2)), "row{$i}");
        $total_nhosts += $d->nhosts;
        $total_gflops += $d->nhosts * $d->mean_ncores * $d->p_fpops / 1000000000.0;
        $i = 1 - $i;
    }
    row_array(array("Total", number_format($total_nhosts, 0) . " computers", "", "", number_format($total_gflops / 1000.0, 2) . " TeraFLOPS"), "row{$i}");
    end_table();
    echo "Generated " . time_str($data->time);
    page_tail();
}
$d = get_cached_data(86400);
if ($d) {
    $data = unserialize($d);
} else {
    $data = get_cpu_list();
    set_cached_data(86400, serialize($data));
}
show_cpu_list($data);
Example #4
0
        $user = lookup_user_id($id);
        $show_hosts = false;
    }
    if (!$user) {
        xml_error(-136);
    }
    show_user_xml($user, $show_hosts);
} else {
    db_init();
    // need to do this in any case,
    // since show_user_summary_public() etc. accesses DB
    // The page may be presented in many different languages,
    // so here we cache the data instead
    //
    $cache_args = "userid=" . $id;
    $cached_data = get_cached_data(USER_PAGE_TTL, $cache_args);
    if ($cached_data) {
        // We found some old but non-stale data, let's use it
        $data = unserialize($cached_data);
        $user = $data->user;
        $community_links = $data->clo;
    } else {
        // No data was found, generate new data for the cache and store it
        $user = lookup_user_id($id);
        BoincForumPrefs::lookup($user);
        $user = @get_other_projects($user);
        $community_links = get_community_links_object($user);
        $data->user = $user;
        $data->clo = $community_links;
        set_cached_data(USER_PAGE_TTL, serialize($data), $cache_args);
    }
Example #5
0
    case "total_credit":
    case "expavg_credit":
        break;
    default:
        $sort_by = "expavg_credit";
}
$offset = get_int("offset", true);
if (!$offset) {
    $offset = 0;
}
if ($offset % $users_per_page) {
    $offset = 0;
}
if ($offset < ITEM_LIMIT) {
    $cache_args = "sort_by={$sort_by}&offset={$offset}";
    $cacheddata = get_cached_data(TOP_PAGES_TTL, $cache_args);
    // Do we have the data in cache?
    //
    if ($cacheddata) {
        $data = unserialize($cacheddata);
        // use the cached data
    } else {
        //if not do queries etc to generate new data
        $data = get_top_participants($offset, $sort_by);
        //save data in cache
        //
        set_cached_data(TOP_PAGES_TTL, serialize($data), $cache_args);
    }
} else {
    error_page(tra("Limit exceeded - Sorry, first %1 items only", ITEM_LIMIT));
}
Example #6
0
}
if (!$user->has_profile) {
    // check whether user.has_profile is out of synch w/ profile table
    //
    $profile = BoincProfile::lookup("userid={$user->id}");
    if ($profile) {
        $user->update("has_profile=1");
        $user->has_profile = 1;
    } else {
        error_page(tra("This user has no profile"));
    }
}
$logged_in_user = get_logged_in_user(false);
check_whether_to_show_profile($user, $logged_in_user);
$cache_args = "userid={$userid}";
$cacheddata = get_cached_data(USER_PROFILE_TTL, $cache_args);
if ($cacheddata) {
    // Already got a cached version of the information
    $community_links_object = unserialize($cacheddata);
} else {
    // Need to generate a new bunch of data
    $community_links_object = get_community_links_object($user);
    set_cached_data(USER_PROFILE_TTL, serialize($community_links_object), $cache_args);
}
page_head(tra("Profile: %1", $user->name));
start_table();
echo "<tr><td valign=\"top\">";
start_table();
show_profile($user, $logged_in_user);
end_table();
echo "</td><td valign=\"top\">";
Example #7
0
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;
}
Example #8
0
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;
}
    $y = array(0, 0, 0, 0, 0, 0, 0, 0);
    foreach ($vendors as $name => $x) {
        if (!$name) {
            $name = "not reported by client";
        } else {
            $name = "<a href=android_tasks.php?vendor={$name}>{$name}</a>";
        }
        show_item($name, $x);
        $y[1] += $x[1];
        $y[3] += $x[3];
    }
    show_item("total", $y);
    end_table();
    page_tail();
}
$models = get_cached_data(86400);
if ($models) {
    $models = unserialize($models);
} else {
    $models = get_models();
    set_cached_data(86400, serialize($models));
}
$vendor = get_str("vendor", true);
if ($vendor) {
    uasort($models, 'compare');
    show_vendor($vendor, $models);
} else {
    $vendors = get_vendors($models);
    uasort($vendors, 'compare');
    show_vendors($vendors);
}
Example #10
0
    $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;
}
$last_update = 0;
$row_array = null;
$cache_args = "level={$notification_level}";
if ($appid) {
    $cache_args .= "&appid={$appid}";
}
$cache_data = get_cached_data($cache_sec, $cache_args);
if ($cache_data && !$refresh_cache) {
    $cache_data = unserialize($cache_data);
    $last_update = $cache_data['last_update'];
    $row_array = $cache_data['row_array'];
} else {
    $row_array = get_error_wus();
    $last_update = time();
    $cache_data = array('last_update' => $last_update, 'row_array' => $row_array);
    set_cached_data($cache_sec, serialize($cache_data), $cache_args);
}
echo "<br/>";
echo "<form method=\"get\" action=\"errorwus.php\">\n";
print_checkbox("Hide canceled WUs", "hide_canceled", $hide_canceled);
print_checkbox("Hide WUs with only d/l errors", "hide_dlerr", $hide_dlerr);
if ($appid) {
Example #11
0
    // default to northern California
    $pm->centerMap(38, -100);
}
$data = array();
$bUseContinual = false;
if (file_exists($cachedatafile)) {
    $cacheddata = get_cached_data(MAPTRIG_TTL, "maptrig", $cachedatafile);
    // regenerate every 15 minutes
    if ($cacheddata) {
        $data = unserialize($cacheddata);
        // use the cached data
    }
}
// continual data
if (file_exists($cachedatafileContinual)) {
    $cacheddataContinual = get_cached_data(MAPTRIG_TTL, "maptrig", $cachedatafileContinual);
    // regenerate every 15 minutes
    if ($cacheddataContinual) {
        $bUseContinual = true;
        $dataContinual = unserialize($cacheddataContinual);
        // use the cached data
    }
}
$i = 0;
for ($i = 0; $i < sizeof($data); $i++) {
    if ($data[$i]) {
        $pm->addGeoPoint($data[$i]->lat, $data[$i]->lng, $data[$i]->descript, $data[$i]->is_quake, $data[$i]->is_usb);
    }
}
if ($bUseContinual) {
    // show continual points
    if (($fileModTime = @filemtime($fileDirectory . $file)) === false) {
        $pos = strpos($file, "/", 1);
        if ($pos === false) {
            throw new IllegalArgumentException("File does not exist");
        } else {
            $file = substr($file, $pos);
        }
    }
}
$file = $fileDirectory . $file;
if (!$fileFilter->isValid($file)) {
    throw new IllegalArgumentException("File was not accepted by the server for tracking.");
}
// Everything's fine let's lookup the .torrent in the cache if needed:
$cache_args = "file=" . $file . "&modtime=" . $fileModTime;
$cacheddata = get_cached_data(TORRENT_CACHE_TTL, $cache_args);
if ($cacheddata) {
    //If we have got the data in cache
    $torrent = unserialize($cacheddata);
    // use the cached data
} else {
    //if not do queries etc to generate new data
    for ($i = 0; $i < sizeof($webseeds); $i++) {
        $realWebseeds[] = $webseeds[$i] . substr($file, strlen($fileDirectory));
    }
    $torrent = new Torrent($file, $trackerURL, $realWebseeds);
    $torrent->ensureSHA1Loaded();
    db_init();
    $torrent->register();
    set_cache_data(serialize($torrent), $cache_args);
    //save data in cache
Example #13
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/util.inc";
require_once "../inc/team.inc";
require_once "../inc/cache.inc";
check_get_args(array("sort_by", "offset", "teamid"));
if (isset($_GET["sort_by"])) {
    $sort_by = $_GET["sort_by"];
} else {
    $sort_by = "expavg_credit";
}
$offset = get_int("offset", true);
if (!$offset) {
    $offset = 0;
}
if ($offset > 1000) {
    error_page(tra("Limit exceeded:  Can only display the first 1000 members."));
}
$teamid = get_int("teamid");
$cache_args = "teamid={$teamid}";
$team = unserialize(get_cached_data(TEAM_PAGE_TTL, $cache_args));
if (!$team) {
    $team = BoincTeam::lookup_id($teamid);
    set_cached_data(TEAM_PAGE_TTL, serialize($team), $cache_args);
}
page_head(tra("Members of %1", "<a href=team_display.php?teamid={$teamid}>{$team->name}</a>"));
display_team_members($team, $offset, $sort_by);
page_tail();
Example #14
0
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// 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/>.
require_once "../inc/db.inc";
require_once "../inc/util.inc";
require_once "../inc/cache.inc";
check_get_args(array());
page_head(tra("Download BOINC add-on software"));
echo "\n    <p>" . tra("You can download applications in several categories.") . "\n    <ul>\n    <li>" . tra("These applications are not endorsed by %1 and you use them at your own risk.", PROJECT) . "\n    <li>" . tra("We do not provide instructions for installing these applications.\nHowever, the author may have provided some help on installing or uninstalling the application. \nIf this is not enough you should contact the author.") . tra("Instructions for installing and running BOINC are %1here%2.", "<a href=http://boinc.berkeley.edu/participate.php>", "</a>") . "<li>" . tra("This list is managed centrally at %1the BOINC website%2.", "<a href=\"http://boinc.berkeley.edu/addons.php\">", "</a>") . "\n    </ul>\n";
$httpFile = unserialize(get_cached_data(3600));
if (!$httpFile) {
    $httpFile = @file_get_contents("http://boinc.berkeley.edu/addons.php?strip_header=true");
    if ($httpFile) {
        set_cached_data(3600, serialize($httpFile));
    }
}
echo $httpFile;
echo "\n    <p><p>\n";
page_tail();
Example #15
0
function get_runtime_info($appid)
{
    $info = unserialize(get_cached_data(3600, "get_runtime_info" . $appid));
    if ($info == false) {
        $result = mysql_query("\n        Select 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        from (SELECT elapsed_time FROM `result` WHERE appid = {$appid} and validate_state =1 and received_time > (unix_timestamp()-(3600*24)) ORDER BY `received_time` DESC limit 100) t");
        $info = mysql_fetch_object($result);
        mysql_free_result($result);
        set_cached_data(3600, serialize($info), "get_runtime_info" . $appid);
    }
    return $info;
}
Example #16
0
$data = mysql_fetch_object($queryHandle);
$complete = intval($data->complete);
$queryHandle = mysql_query("SELECT count(fileid) as incomplete from bittorrent_peers where fileid = '" . $infoHashObject->id . "' and status!='completed'");
$data = mysql_fetch_object($queryHandle);
$incomplete = intval($data->incomplete);
$peersElement = new BElement(BList::toEncoded($peerList));
$out = BDictionary::toEncoded(array("interval" => DEFAULT_CONNECTION_INTERVAL, "complete" => $complete, "incomplete" => $incomplete, "peers" => $peersElement));
// Echo the answer to stdout
echo $out;
$fh = fopen(TRACKER_LOGFILE, "a");
fputs($fh, date(DATE_ATOM, time()) . " " . $_SERVER["REMOTE_ADDR"] . " - " . $event . "\n");
fclose($fh);
// ------------------------------------------------------
// Check if the database needs cleaning
$cache_args = "tracker_timer";
$cacheddata = get_cached_data(DB_CLEAN_TTL, $cache_args);
if ($cacheddata) {
    //If we have got the timer in cache
    // Do nothing
} else {
    //if not do queries etc to clean DB
    // TODO: update the bittorrent_statistics table here before deleting entries
    mysql_query("DELETE from bittorrent_files where timestamp<" . (time() - TORRENT_TTL));
    echo mysql_error();
    mysql_query("DELETE from bittorrent_peers where timestamp<" . (time() - PEER_TTL));
    echo mysql_error();
    mysql_query("DELETE from bittorrent_ipbans where timestamp<" . time());
    echo mysql_error();
    // And reset the timer in the cache
    set_cache_data(serialize(time()), $cache_args);
    //save data in cache
Example #17
0
$team = BoincTeam::lookup_id($teamid);
$get_from_db = false;
$user = get_logged_in_user(false);
// always show fresh copy to admins; they might be editing info
//
if (is_team_admin($user, $team)) {
    $get_from_db = true;
}
if ($user->id == $team->ping_user) {
    $get_from_db = true;
}
// Cache the team record, its forum record, its new members,
// its admins, and its member counts
$cache_args = "teamid={$teamid}";
if (!$get_from_db) {
    $cached_data = get_cached_data(TEAM_PAGE_TTL, $cache_args);
    if ($cached_data) {
        // We found some old but non-stale data, let's use it
        $team = unserialize($cached_data);
    } else {
        $get_from_db = true;
    }
}
if ($get_from_db) {
    $team->nusers = BoincUser::count("teamid={$teamid}");
    $team->nusers_worked = BoincUser::count("teamid={$teamid} and total_credit>0");
    $team->nusers_active = BoincUser::count("teamid={$teamid} and expavg_credit>0.1");
    $team->forum = BoincForum::lookup("parent_type=1 and category={$team->id}");
    $team->new_members = new_member_list($teamid);
    $team->admins = admin_list($teamid);
    $team->founder = BoincUser::lookup_id($team->userid);
Example #18
0
} else {
    $programIn = file_get_contents('php://input');
    $incoming_data = json_decode($programIn, TRUE);
    $action = $incoming_data['action'];
}
$outgoing_data = array();
switch ($action) {
    case 'update':
    case 'update_asm':
        $outgoing_data = get_update_info();
        break;
    case 'sign_in':
        $outgoing_data = user_sign_in($incoming_data);
        break;
    case 'cache_data':
        $outgoing_data = get_cached_data($incoming_data);
        break;
        // case 'memory_game_list':
        // 	$outgoing_data = get_memory_game_list($incoming_data);
        // 	break;
        // case 'test':
        // 	$outgoing_data['foo'] = 'bar';
        // 	break;
    // case 'memory_game_list':
    // 	$outgoing_data = get_memory_game_list($incoming_data);
    // 	break;
    // case 'test':
    // 	$outgoing_data['foo'] = 'bar';
    // 	break;
    default:
        $outgoing_data = $error_manager->error_generator(ERROR_INVALID_ACTION);