Exemplo n.º 1
0
function get_mysql_count($hr_class)
{
    $result = _mysql_query("select count(id) as count from workunit where hr_class=" . $hr_class);
    $count = _mysql_fetch_object($result);
    _mysql_free_result($result);
    return $count->count;
}
Exemplo n.º 2
0
function delete_user($user)
{
    if (!empty($user->teamid)) {
        user_quit_team($user);
    }
    if ($user->has_profile) {
        _mysql_query("DELETE FROM profile WHERE userid = {$user->id}");
        delete_user_pictures($user->id);
        _mysql_query("UPDATE user SET has_profile=0 WHERE id={$user->id}");
    }
    if ($user->total_credit > 0.0) {
        error_page("Cannot delete user: User has credit.");
        return false;
    }
    // Don't delete user if they have any outstanding Results
    //
    $q = "SELECT COUNT(*) AS count FROM result WHERE userid=" . $user->id;
    $result = _mysql_query($q);
    $c = _mysql_fetch_object($result);
    _mysql_free_result($result);
    if ($c->count) {
        error_page("Cannot delete user: User has {$c->count} results in the database.");
    }
    // Don't delete user if they have posted to the forums
    //
    $q = "SELECT COUNT(*) AS count FROM post WHERE user="******"Cannot delete user: User has {$c->count} forum posts.");
    }
    $q = "DELETE FROM user WHERE id=" . $user->id;
    $result = _mysql_query($q);
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
function user_permissions_form()
{
    global $special_user_bitfield;
    page_head('Manage user privileges');
    start_table();
    row1("Current special users", 99);
    echo "<tr><th>User</th>";
    for ($i = 0; $i < S_NFLAGS; $i++) {
        echo "<th>" . $special_user_bitfield[$i] . "</th>\n";
    }
    echo "<th> </th></tr>";
    $result = _mysql_query("SELECT prefs.userid, prefs.special_user, user.id, user.name \n        FROM forum_preferences as prefs, user \n        WHERE CONVERT(special_user, DECIMAL) > 0 and prefs.userid=user.id");
    $i = 0;
    while ($foo = _mysql_fetch_object($result)) {
        echo "<tr class=row{$i}>\n            <td>{$foo->name} ({$foo->id})</td>\n            <form action=\"user_permissions.php\" method=\"POST\">\n            <input type=\"hidden\" name=\"userid\" value=\"{$foo->userid}\">\n        ";
        for ($j = 0; $j < S_NFLAGS; $j++) {
            $bit = substr($foo->special_user, $j, 1);
            $c = $bit == 1 ? "checked" : "";
            echo "<td>\n                <input type=\"checkbox\" name=\"role" . $j . "\" value=\"1\" {$c}>\n                </td>\n            ";
        }
        echo "<td><input class=\"btn btn-default\" type=\"submit\" value=\"Update\"></td>";
        echo "</form></tr>\n";
        $i = 1 - $i;
    }
    echo "\n        <tr class=row{$i}>\n        <form action=\"user_permissions.php\" method=\"POST\">\n        <td>Add User ID:<input type=\"text\" name=\"userid\" size=\"6\"></td>\n    ";
    for ($j = 0; $j < S_NFLAGS; $j++) {
        echo "<td>\n            <input type=\"checkbox\" name=\"role" . $j . "\" value=\"1\">\n            </td>\n        ";
    }
    echo "<td>\n        <input class=\"btn btn-default\" type=\"submit\" value=\"Update\">\n        </td>\n        </form>\n        </tr>\n    ";
    end_table();
    page_tail();
}
Exemplo n.º 5
0
function profile_word($word)
{
    $q = "select userid from profile where response1 like '%{$word}%'";
    echo "{$q}\n";
    $r = _mysql_query($q);
    while ($x = _mysql_fetch_object($r)) {
        purge_user($x->userid);
    }
}
Exemplo n.º 6
0
function update_4_18_2004()
{
    do_query("alter table user add cross_project_id varchar(254) not null");
    $result = do_query("select * from user");
    while ($user = _mysql_fetch_object($result)) {
        $x = random_string();
        do_query("update user set cross_project_id='{$x}' where id={$user->id}");
    }
}
Exemplo n.º 7
0
function show_graph()
{
    db_init();
    $xaxis = $_GET['xaxis'];
    $yaxis = $_GET['yaxis'];
    $granularity = $_GET['granularity'];
    $active = $_GET['active'];
    $inactive = $_GET['inactive'];
    $show_text = $_GET['show_text'];
    if (!$active && !$inactive) {
        echo "You must select at least one of (active, inactive)";
        exit;
    }
    $fields = 'host.id, user.create_time';
    if ($xaxis == 'active' || !$active || !$inactive) {
        $query = "select {$fields}, max(rpc_time) as max_rpc_time from host, user where host.userid=user.id group by userid";
    } else {
        $query = 'select $fields from user';
    }
    $result = _mysql_query($query);
    $yarr = array();
    $now = time();
    $maxind = 0;
    $active_thresh = time() - 30 * 86400;
    while ($user = _mysql_fetch_object($result)) {
        $val = $now - $user->max_rpc_time;
        if (!$active) {
            if ($user->max_rpc_time > $active_thresh) {
                continue;
            }
        }
        if (!$inactive) {
            if ($user->max_rpc_time < $active_thresh) {
                continue;
            }
        }
        $life = $user->max_rpc_time - $user->create_time;
        $ind = $life / $granularity;
        $ind = (int) $ind;
        $yarr[$ind]++;
        if ($ind > $maxind) {
            $maxind = $ind;
        }
    }
    $xarr = array();
    for ($i = 0; $i <= $maxind; $i++) {
        $xarr[$i] = $i;
        if (is_null($yarr[$i])) {
            $yarr[$i] = 0;
        }
    }
    if ($show_text) {
        show_text($xarr, $yarr);
    } else {
        draw_graph($xarr, $yarr);
    }
}
Exemplo n.º 8
0
function update_thread_timestamps()
{
    $threads = BoincThread::enum();
    foreach ($threads as $thread) {
        $q = "select max(timestamp) as foo from post where thread={$thread->id}";
        $r2 = _mysql_query($q);
        $m = _mysql_fetch_object($r2);
        echo "id: {$thread->id}; min: {$m->foo}\n";
        _mysql_free_result($r2);
        $n = $m->foo;
        if ($n) {
            $q = "update thread set timestamp={$n} where id={$thread->id}";
            _mysql_query($q);
        }
    }
}
Exemplo n.º 9
0
function get_data()
{
    $nwus = 4000;
    $sum = array();
    for ($i = 0; $i <= 10; $i++) {
        $sum[] = 0;
    }
    $r1 = _mysql_query("select id from workunit where canonical_resultid>0 limit {$nwus}");
    $n = 0;
    while ($wu = _mysql_fetch_object($r1)) {
        $results = array();
        $r2 = _mysql_query("select * from result where workunitid={$wu->id}");
        $found_zero = false;
        while ($result = _mysql_fetch_object($r2)) {
            if ($result->granted_credit == 0) {
                continue;
            }
            // skip invalid
            $host = BoincHost::lookup_id($result->hostid);
            $r = new StdClass();
            $r->cpu_time = $result->cpu_time;
            $r->p_fpops = $host->p_fpops;
            $r->p_iops = $host->p_iops;
            $results[] = $r;
        }
        //echo "Wu $wu->id -------------\n";
        if (count($results) < 2) {
            continue;
        }
        for ($i = 0; $i <= 10; $i++) {
            $fpw = $i / 10.0;
            $sum[$i] += fpw_var($results, $fpw);
        }
        $n++;
    }
    echo "This script recommends value for <fp_benchmark_weight> in config.xml.\nIt does this by finding the value that minimizes the variance\namong claimed credit for workunits currently in your database.\nIt examines at most {$nwus} WUs (edit the script to change this).\n\nNumber of workunits analyzed: {$n}\n\n";
    for ($i = 0; $i <= 10; $i++) {
        $fpw = $i / 10.0;
        $r = $sum[$i] / $n;
        echo "FP weight {$fpw}: variance is {$r}\n";
        if ($i == 0) {
            $best = $r;
            $fbest = $fpw;
        } else {
            if ($r < $best) {
                $best = $r;
                $fbest = $fpw;
            }
        }
    }
    echo "\nRecommended value: {$fbest}\n";
}
admin_page_head("screen profiles");
if (function_exists('profile_screen_query')) {
    $query = profile_screen_query();
} else {
    if (profile_screening()) {
        $query = "select * from profile, user where profile.userid=user.id " . " and has_picture>0 " . " and verification=0 " . " limit 20";
    } else {
        $query = "select * from profile, user where profile.userid=user.id " . " and has_picture>0 " . " and verification=0 " . " and uotd_time is null " . " and expavg_credit>1 " . " and (response1 <> '' or response2 <> '') " . " order by recommend desc limit 20";
    }
}
$result = _mysql_query($query);
$n = 0;
echo "<form action=profile_screen_action.php>\n";
start_table();
$found = false;
while ($profile = _mysql_fetch_object($result)) {
    $found = true;
    echo "<tr><td valign=top>";
    buttons($n);
    echo "\n        <br>Name: {$profile->name}\n        <br>recommends: {$profile->recommend}\n        <br>rejects: {$profile->reject}\n        <br>RAC: {$profile->expavg_credit}\n        <br>\n    ";
    echo "</td><td><table border=2> ";
    show_profile($profile, $g_logged_in_user, true);
    echo "</table></td></tr>\n";
    echo "<input type=\"hidden\" name=\"userid{$n}\" value=\"{$profile->userid}\">\n";
    $n++;
}
end_table();
if ($found) {
    echo "\n        <input type=\"hidden\" name=\"n\" value=\"{$n}\">\n        <input type=\"submit\" value=\"OK\">\n    ";
} else {
    echo "No more profiles to screen.";
Exemplo n.º 11
0
function fix_fix()
{
    $profiles = _mysql_query("select * from profile where id=99");
    $profile = _mysql_fetch_object($profiles);
    fix_profile($profile);
}
Exemplo n.º 12
0
// 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/forum.inc';
require_once '../inc/util_ops.inc';
db_init();
admin_page_head('Manage user privileges');
start_table("align=\"center\"");
row1("Current special users", '9');
echo "<tr><td>User</td>";
for ($i = 0; $i < S_NFLAGS; $i++) {
    echo "<td width=\"15\">" . $special_user_bitfield[$i] . "</td>\n";
}
echo "</tr>";
$result = _mysql_query("SELECT prefs.userid, prefs.special_user, user.id, user.name \n    FROM forum_preferences as prefs, user \n    WHERE CONVERT(special_user, DECIMAL) > 0 and prefs.userid=user.id");
for ($i = 1; $i <= _mysql_num_rows($result); $i++) {
    $foo = _mysql_fetch_object($result);
    echo "<form action=\"manage_special_users_action.php\" method=\"POST\">\n";
    echo "<input type=\"hidden\" name=\"userid\" value=\"{$foo->userid}\"\n        <tr><td>{$foo->name} ({$foo->id})</td>\n    ";
    for ($j = 0; $j < S_NFLAGS; $j++) {
        $bit = substr($foo->special_user, $j, 1);
        echo "<td><input type=\"checkbox\" name=\"role" . $j . "\" value=\"1\"";
        if ($bit == 1) {
            echo " checked=\"checked\"";
        }
        echo "></td>\n";
    }
    echo "<td><input class=\"btn btn-default\" type=\"submit\" value=\"Update\"></form></td>";
    echo "</tr>\n";
}
echo "<tr><form action=\"manage_special_users_action.php\" method=\"POST\">\n";
echo "<td>Add UserID:<input type=\"text\" name=\"userid\" size=\"6\"></td>";
Exemplo n.º 13
0
function fix_fix()
{
    $posts = _mysql_query("select * from post where id=99");
    $post = _mysql_fetch_object($posts);
    fix_post($post);
}
Exemplo n.º 14
0
function do_lapsed()
{
    global $globals;
    $max_last_rpc_time = time() - $globals->lapsed_interval;
    // the following is an efficient way of getting the list of
    // users for which no host has done an RPC recently
    //
    $result = _mysql_query("select userid from host group by userid having max(rpc_time)<{$max_last_rpc_time};");
    while ($host = _mysql_fetch_object($result)) {
        $uresult = _mysql_query("select * from user where id = {$host->userid};");
        $user = _mysql_fetch_object($uresult);
        _mysql_free_result($uresult);
        if (!$user) {
            echo "Can't find user {$host->userid}\n";
            continue;
        }
        handle_user($user, 'lapsed');
    }
    _mysql_free_result($result);
}
Exemplo n.º 15
0
function find_oldest()
{
    $result = _mysql_query("select name,create_time from result where server_state=2 order by create_time limit 1");
    $x = _mysql_fetch_object($result);
    return $x->create_time;
}
Exemplo n.º 16
0
function grant_credits_for_cancelled()
{
    $ngranted = 0;
    $query_w = _mysql_query("select * from workunit where error_mask!=0");
    while ($workunit = _mysql_fetch_object($query_w)) {
        // echo "Starting WU $workunit->id\n";
        $ngranted += grant_credits_for_wu($workunit->id);
        // NEED TO SET assimilate_state=READY for WU!!
    }
    _mysql_free_result($query_w);
    echo "\nGranted credits to {$ngranted} results\n";
}
Exemplo n.º 17
0
function do_one($thisid, $log)
{
    $result = _mysql_query("select * from user where id={$thisid}");
    $user = _mysql_fetch_object($result);
    if ($user) {
        handle_user($user);
        fputs($log, $user->id . "\n");
        fflush($log);
    }
    _mysql_free_result($result);
    return $startid;
}
Exemplo n.º 18
0
function analyze($appid, $app_version_id, $nresults)
{
    global $hist;
    $clause = $app_version_id ? " and app_version_id = {$app_version_id} " : "";
    $query = "select id, server_state, outcome, elapsed_time, flops_estimate from result where server_state=5 and appid={$appid} and outcome=1 and validate_state=1 {$clause} order by id desc limit {$nresults}";
    $r = _mysql_query($query);
    $n = 0;
    while ($result = _mysql_fetch_object($r)) {
        handle_result($result);
        $n++;
    }
    if (!$n) {
        echo "No done results for that app";
        exit;
    }
    ksort($hist);
    show_stats($hist);
    echo "<hr>\n";
    show_as_table();
    echo "<hr>\n";
    show_as_xml();
}
Exemplo n.º 19
0
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$payer_name = $_POST['first_name'] . " " . $_POST['last_name'];
$ip = $_SERVER['REMOTE_ADDR'];
$agent = strtolower($_SERVER[HTTP_USER_AGENT]);
if (!$fp) {
    // HTTP ERROR, might want to do additional handling here
} else {
    fputs($fp, $header . $req);
    while (!feof($fp)) {
        $res = fgets($fp, 1024);
        if (strcmp($res, "VERIFIED") == 0) {
            $item_array = explode("_", $item_number);
            $payment_id = abs($item_array[0]);
            $order_time = abs($item_array[1]);
            $result = _mysql_query("SELECT * FROM donation_paypal WHERE order_time = '{$order_time}' AND id = '{$payment_id}' AND processed = '0'");
            $num_rows = _mysql_num_rows($result);
            if ($num_rows == 1) {
                $row = _mysql_fetch_object($result);
                $userid = $row->userid;
                _mysql_query("UPDATE donation_paypal SET processed = '1', payment_time = '" . time() . "', item_name = '{$item_name}', payment_status = '{$payment_status}', payment_amount = '{$payment_amount}', payment_fee = '{$payment_fee}', payment_currency = '{$payment_currency}', txn_id = '{$txn_id}', receiver_email = '{$receiver_email}', payer_email = '{$payer_email}', payer_name = '{$payer_name}' WHERE id = '{$payment_id}'");
                if ($userid > 0) {
                    _mysql_query("UPDATE user SET donated = '1' WHERE id = '{$userid}'");
                }
            }
        }
    }
    fclose($fp);
}
// 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/util_ops.inc";
db_init();
admin_page_head("Failures grouped by app version and host");
$query_appid = $_GET['appid'];
$query_received_time = time() - $_GET['nsecs'];
$main_query = "\nSELECT\n       app_version_id,\n       app_version_num,\n       hostid AS Host_ID,\n       case\n           when INSTR(host.os_name, 'Darwin') then 'Darwin'\n           when INSTR(host.os_name, 'Linux') then 'Linux'\n           when INSTR(host.os_name, 'Windows') then 'Windows'\n           when INSTR(host.os_name, 'SunOS') then 'SunOS'\n           when INSTR(host.os_name, 'Solaris') then 'Solaris'\n           when INSTR(host.os_name, 'Mac') then 'Mac'\n           else 'Unknown'\n       end AS OS_Name,\n       case\n           when INSTR(host.os_name, 'Linux') then \n               case\n                   when INSTR(LEFT(host.os_version, 6), '-') then LEFT(host.os_version, (INSTR(LEFT(host.os_version, 6), '-') - 1))\n                   else LEFT(host.os_version, 6)\n               end\n           else host.os_version\n       end AS OS_Version,\n       host.nresults_today AS Results_Today, \n       COUNT(*) AS error_count\nFROM   result\n           left join host on result.hostid = host.id \nWHERE\n       appid = '{$query_appid}' and\n       server_state = '5' and\n       outcome = '3' and \n       received_time > '{$query_received_time}'\nGROUP BY\n       app_version_id,\n       hostid\norder by error_count desc\n";
$result = _mysql_query($main_query);
start_table();
table_header("App version", "Host ID", "OS Version", "Results today", "Error count");
while ($res = _mysql_fetch_object($result)) {
    table_row(app_version_desc($res->app_version_id), "<a href=" . URL_BASE . "show_host_detail.php?hostid={$res->Host_ID}>{$res->Host_ID}</a>", $res->OS_Version, $res->Results_Today, "<a href=db_action.php?table=result&detail=low&hostid={$res->Host_ID}&app_version_id={$res->app_version_id}&server_state=5&outcome=3>{$res->error_count}</a>");
}
_mysql_free_result($result);
end_table();
admin_page_tail();
$cvs_version_tracker[] = "\$Id\$";
//Generated automatically - do not edit
Exemplo n.º 21
0
page_head(tra("%1 donations", PROJECT));
if (function_exists("donations_intro")) {
    donations_intro();
} else {
    echo "<div>" . tra("This project is accepting donations via\n%1.", "<a href=\"http://www.paypal.com/\">PayPal</a>") . "</div>\n        <div class=\"smalltext\">\n        " . tra("To donate, fill in the amount you want to donate using the field below.\n        PayPal is accepting multiple currencies\n        (Canadian Dollars, Euros, Pounds Sterling, U.S. Dollars,\n         Yen, Australian Dollars, New Zealand Dollars,\n        Swiss Francs, Hong Kong Dollars, Singapore Dollars, Swedish Kronor,\n        Danish Kroner, Polish Zloty, Norwegian Kroner,\n        Hungarian Forint, Czech Koruna).\n        You can use included currency converter\n        to see the donation amount equivalent in different currencies\n        (please note that the rates are only estimates\n         and the actual amount may differ).") . "</div>\n    ";
}
echo "<script src=\"currency.js\" type=\"text/javascript\"></script>\n";
$query = _mysql_query("SELECT * FROM donation_items");
echo "<form name=\"calcForm\" action=\"donate.php\" method=\"post\">\n";
start_table();
// If donation_items table is filled, a list of donation targets is shown
$first_row = true;
while ($row = _mysql_fetch_object($query)) {
    $col1 = $row->title . "<br><span class=\"smalltext\">" . $row->description . "</span>";
    $query_amount = _mysql_query("SELECT SUM(payment_amount-payment_fee) AS amount FROM donation_paypal WHERE processed = 1 AND item_number = '" . $row->id . "'");
    $acquired = _mysql_fetch_object($query_amount)->amount;
    $required = $row->required;
    if ($acquired > $required) {
        $acquired = $acquired - $required;
        $progress = 100;
    } else {
        $progress = round($acquired / $required * 100);
        $progress2 = round($acquired / $required * 100, 1);
    }
    $col2 = "<input style=\"float: left\" type=\"radio\" name=\"item_id\" value=\"" . $row->id . "\"";
    if ($first_row) {
        $first_row = false;
        $col2 .= " checked=\"checked\"";
    }
    $col2 .= ">";
    if ($progress == 0) {
Exemplo n.º 22
0
function fix_fix()
{
    $forum_preferencess = _mysql_query("select * from forum_preferences where id=99");
    $forum_preferences = _mysql_fetch_object($forum_preferencess);
    fix_forum_preferences($forum_preferences);
}
Exemplo n.º 23
0
<?php

// generate a data file for use by credit_test.php
require_once "../inc/boinc_db.inc";
db_init();
$min_claimed_credit = 0;
$max_claimed_credit = 5000;
$limit = 0;
$appid = 2;
$query = "select result.id, result.workunitid, result.appid, result.hostid, result.claimed_credit, result.app_version_id, result.elapsed_time, result.flops_estimate, result.cpu_time, workunit.rsc_fpops_est from result, workunit where workunit.id = result.workunitid and result.validate_state=1 and claimed_credit > {$min_claimed_credit} and claimed_credit < {$max_claimed_credit} and app_version_id<>0";
if ($appid) {
    $query .= " and result.appid = {$appid}";
}
if ($limit) {
    $query .= " limit {$limit}";
}
$r = _mysql_query($query);
$f = fopen("credit_test_data", "w");
while ($x = _mysql_fetch_object($r)) {
    fprintf($f, "{$x->id} {$x->workunitid} {$x->appid} {$x->hostid} {$x->claimed_credit} {$x->app_version_id} {$x->elapsed_time} {$x->flops_estimate} {$x->cpu_time} {$x->rsc_fpops_est}\n");
}
fclose($f);