当前位置: 首页>>代码示例>>PHP>>正文


PHP BoincDb类代码示例

本文整理汇总了PHP中BoincDb的典型用法代码示例。如果您正苦于以下问题:PHP BoincDb类的具体用法?PHP BoincDb怎么用?PHP BoincDb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BoincDb类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search_action

function search_action()
{
    $where = "true";
    $search_string = get_str('search_string');
    if (strlen($search_string)) {
        if (strlen($search_string) < 3) {
            error_page(tra("search string must be at least 3 characters"));
        }
        $s = BoincDb::escape_string($search_string);
        $s = escape_pattern($s);
        $where .= " and name like '{$s}%'";
    }
    $country = get_str('country');
    if ($country != 'any') {
        $s = BoincDb::escape_string($country);
        $where .= " and country='{$s}'";
    }
    $t = get_str('team');
    if ($t == 'yes') {
        $where .= " and teamid<>0";
    } else {
        if ($t == 'no') {
            $where .= " and teamid=0";
        }
    }
    $t = get_str('profile');
    if ($t == 'yes') {
        $where .= " and has_profile<>0";
    } else {
        if ($t == 'no') {
            $where .= " and has_profile=0";
        }
    }
    $search_type = get_str('search_type', true);
    $order_clause = "id desc";
    if ($search_type == 'rac') {
        $order_clause = "expavg_credit desc";
    } else {
        if ($search_type == 'total') {
            $order_clause = "total_credit desc";
        }
    }
    $fields = "id, create_time, name, country, total_credit, expavg_credit, teamid, url, has_profile, donated";
    $users = BoincUser::enum_fields($fields, $where, "order by {$order_clause} limit 100");
    page_head(tra("User search results"));
    $n = 0;
    foreach ($users as $user) {
        if ($n == 0) {
            start_table();
            table_header(tra("Name"), tra("Team"), tra("Average credit"), tra("Total credit"), tra("Country"), tra("Joined"));
        }
        show_user($user);
        $n++;
    }
    end_table();
    if (!$n) {
        echo tra("No users match your search criteria.");
    }
    page_tail();
}
开发者ID:maexlich,项目名称:boinc-igemathome,代码行数:60,代码来源:user_search.php

示例2: get_data

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;
}
开发者ID:CalvinZhu,项目名称:boinc,代码行数:25,代码来源:cpu_list.php

示例3: get_output_file

function get_output_file($instance_name, $file_num, $auth_str)
{
    $result = BoincResult::lookup_name(BoincDb::escape_string($instance_name));
    if (!$result) {
        die("no job instance {$instance_name}");
    }
    $workunit = BoincWorkunit::lookup_id($result->workunitid);
    if (!$workunit) {
        die("no job {$result->workunitid}");
    }
    $batch = BoincBatch::lookup_id($workunit->batch);
    if (!$batch) {
        die("no batch {$workunit->batch}");
    }
    $user = BoincUser::lookup_id($batch->user_id);
    if (!$user) {
        die("no user {$batch->user_id}");
    }
    $x = md5($user->authenticator . $result->name);
    if ($x != $auth_str) {
        die("bad auth str");
    }
    $names = get_outfile_names($result);
    if ($file_num >= count($names)) {
        die("bad file num: {$file_num} > " . count($names));
    }
    $name = $names[$file_num];
    $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
    $upload_dir = parse_config(get_config(), "<upload_dir>");
    $path = dir_hier_path($name, $upload_dir, $fanout);
    if (!is_file($path)) {
        die("no such file {$path}");
    }
    do_download($path);
}
开发者ID:nicolas17,项目名称:boincgit-test,代码行数:35,代码来源:get_output.php

示例4: do_app

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);
}
开发者ID:suno,项目名称:boinc,代码行数:31,代码来源:size_census.php

示例5: get_includes

function get_includes()
{
    $c = getcwd();
    chdir('html/ops');
    require_once '../inc/util_ops.inc';
    BoincDb::get();
    chdir($c);
}
开发者ID:CalvinZhu,项目名称:boinc,代码行数:8,代码来源:single_job_setup.php

示例6: show_error

function show_error($str)
{
    page_head("Can't create account");
    echo "{$str}<br>\n";
    echo BoincDb::error();
    echo "<p>Click your browser's <b>Back</b> button to try again.\n<p>\n";
    page_tail();
    exit;
}
开发者ID:nicolas17,项目名称:boincgit-test,代码行数:9,代码来源:openid_login.php

示例7: get_top_participants

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}");
}
开发者ID:entibasse,项目名称:superhost,代码行数:11,代码来源:top_users.php

示例8: add_app

function add_app()
{
    $name = BoincDb::escape_string(post_str('add_name'));
    $user_friendly_name = BoincDb::escape_string(post_str('add_user_friendly_name'));
    if (empty($name) || empty($user_friendly_name)) {
        admin_error_page("To add a new application please supply both a brief name and a longer 'user-friendly' name.</font></p>");
    }
    $now = time();
    $id = BoincApp::insert("(name,user_friendly_name,create_time) VALUES ('{$name}', '{$user_friendly_name}', {$now})");
    if (!$id) {
        admin_error_page("insert failed");
    }
    echo "Application added.\n        <p>\n        You must restart the project for this to take effect.\n    ";
}
开发者ID:aggroskater,项目名称:boinc,代码行数:14,代码来源:manage_apps.php

示例9: get_top_teams

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}");
}
开发者ID:CalvinZhu,项目名称:boinc,代码行数:15,代码来源:top_teams.php

示例10: search_post_content

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);
}
开发者ID:CalvinZhu,项目名称:boinc,代码行数:47,代码来源:forum_search_action.php

示例11: send_notify_emails

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);
    }
}
开发者ID:CalvinZhu,项目名称:boinc,代码行数:44,代码来源:notify.php

示例12: add_admin

function add_admin($team)
{
    $email_addr = get_str('email_addr');
    $email_addr = BoincDb::escape_string($email_addr);
    $user = BoincUser::lookup("email_addr='{$email_addr}'");
    if (!$user) {
        error_page(tra("no such user"));
    }
    if ($user->teamid != $team->id) {
        error_page(tra("User is not member of team"));
    }
    if (is_team_admin($user, $team)) {
        error_page(tra("%1 is already an admin of %2", $email_addr, $team->name));
    }
    $now = time();
    $ret = BoincTeamAdmin::insert("(teamid, userid, create_time) values ({$team->id}, {$user->id}, {$now})");
    if (!$ret) {
        error_page(tra("Couldn't add admin"));
    }
}
开发者ID:gchilders,项目名称:boinc,代码行数:20,代码来源:team_admins.php

示例13: process_batch

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);
}
开发者ID:CalvinZhu,项目名称:boinc,代码行数:41,代码来源:submit_init_priority.php

示例14: get_models

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;
}
开发者ID:maexlich,项目名称:boinc-igemathome,代码行数:21,代码来源:android_tasks.php

示例15: show_team_xml

                show_team_xml($team);
                $total++;
                if ($total == 100) {
                    break;
                }
            }
            //do not error out
        }
    }
    echo "</teams>\n";
    exit;
}
$team_name = get_str("team_name");
$name_lc = strtolower($team_name);
$name_lc = escape_pattern($name_lc);
$clause = "name like '%" . BoincDb::escape_string($name_lc) . "%' order by expavg_credit desc limit 100";
$teams = BoincTeam::enum($clause);
if ($format == 'xml') {
    echo "<teams>\n";
    $total = 0;
    foreach ($teams as $team) {
        show_team_xml($team);
        $total++;
        if ($total == 100) {
            break;
        }
    }
    echo "</teams>\n";
    exit;
}
page_head(tra("Search Results"));
开发者ID:gchilders,项目名称:boinc,代码行数:31,代码来源:team_lookup.php


注:本文中的BoincDb类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。