• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP BoincDb类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: tra

            if ($existing) {
                echo tra("There's already an account with that email address");
            } else {
                $passwd_hash = md5($passwd . $user->email_addr);
                // deal with the case where user hasn't set passwd
                // (i.e. passwd is account key)
                //
                if ($passwd_hash != $user->passwd_hash) {
                    $passwd = $user->authenticator;
                    $passwd_hash = md5($passwd . $user->email_addr);
                }
                if ($passwd_hash != $user->passwd_hash) {
                    echo tra("Invalid password.");
                } else {
                    $passwd_hash = md5($passwd . $email_addr);
                    $email_addr = BoincDb::escape_string($email_addr);
                    $result = $user->update("email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', email_validated=0");
                    if ($result) {
                        echo tra("The email address of your account is now %1.", $email_addr);
                        if (defined("SHOW_NONVALIDATED_EMAIL_ADDR")) {
                            echo "<p>" . tra("Please %1validate this email address%2.", "<a href=validate_email_addr.php>", "</a>") . "\n";
                        }
                    } else {
                        echo tra("We can't update your email address due to a database problem.  Please try again later.");
                    }
                }
            }
        }
    }
}
page_tail();
开发者ID:CalvinZhu,项目名称:boinc,代码行数:31,代码来源:edit_email_action.php


示例17: error_page

// 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";
if (DISABLE_PROFILES) {
    error_page("Profiles are disabled");
}
check_get_args(array("search_string", "offset"));
function show_profile_link2($profile, $n)
{
    $user = BoincUser::lookup_id($profile->userid);
    echo "<tr><td>" . user_links($user) . "</td><td>" . date_str($user->create_time) . "</td><td>{$user->country}</td><td>" . (int) $user->total_credit . "</td><td>" . (int) $user->expavg_credit . "</td></tr>\n";
}
$search_string = get_str('search_string');
$search_string = sanitize_tags($search_string);
$search_string = BoincDb::escape_string($search_string);
$offset = get_int('offset', true);
if (!$offset) {
    $offset = 0;
}
$count = 10;
page_head(tra("Profiles containing '%1'", $search_string));
$profiles = BoincProfile::enum("match(response1, response2) against ('{$search_string}') limit {$offset},{$count}");
start_table();
echo "\n    <tr><th>" . tra("User name") . "</th>\n    <th>" . tra("Joined project") . "</th>\n    <th>" . tra("Country") . "</th>\n    <th>" . tra("Total credit") . "</th>\n    <th>" . tra("Recent credit") . "</th></tr>\n";
$n = 0;
foreach ($profiles as $profile) {
    show_profile_link2($profile, $n + $offset + 1);
    $n += 1;
}
end_table();
开发者ID:maexlich,项目名称:boinc-igemathome,代码行数:31,代码来源:profile_search_action.php


示例18: error_page

    error_page("no such team");
}
require_admin($user, $team);
$team_url = BoincDb::escape_string(strip_tags(post_str("url", true)));
$x = strstr($team_url, "http://");
if ($x) {
    $team_url = substr($team_url, 7);
}
$team_name = BoincDb::escape_string(strip_tags(post_str("name")));
$team_name_lc = strtolower($team_name);
$tnh = post_str("name_html", true);
$team_name_html = sanitize_html($tnh);
$team_name_html = BoincDb::escape_string($team_name_html);
$team_description = BoincDb::escape_string(post_str("description", true));
$type = BoincDb::escape_string(post_str("type", true));
$country = BoincDb::escape_string(post_str("country", true));
if ($country == "") {
    $country = "International";
}
if (!is_valid_country($country)) {
    error_page("bad country");
}
$joinable = post_str('joinable', true) ? 1 : 0;
$t = BoincTeam::lookup("name='{$team_name}'");
if ($t && $t->id != $teamid) {
    error_page("The name '{$team_name}' is being used by another team.");
}
if (strlen($team_name) == 0) {
    error_page("Must specify team name");
}
// Should be caught up with the post_str("name"),
开发者ID:Turante,项目名称:boincweb,代码行数:31,代码来源:team_edit_action.php


示例19: edit_action

function edit_action($forum)
{
    $title = strip_tags(post_str('title'));
    $title = BoincDb::escape_string($title);
    $description = strip_tags(post_str('description'));
    $description = BoincDb::escape_string($description);
    $post_min_interval = post_int('post_min_interval');
    $post_min_total_credit = post_int('post_min_total_credit');
    $post_min_expavg_credit = post_int('post_min_expavg_credit');
    $ret = $forum->update("title='{$title}', description='{$description}', post_min_interval={$post_min_interval}, post_min_total_credit={$post_min_total_credit}, post_min_expavg_credit={$post_min_expavg_credit}");
    if ($ret) {
        page_head("Team Message Board Updated");
        echo "Update successful";
        page_tail();
    } else {
        error_page("update failed");
    }
}
开发者ID:Turante,项目名称:boincweb,代码行数:18,代码来源:team_forum.php


示例20: check_get_args

// You should have received a copy of the GNU Lesser General Public License
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
// Show results with pending credit for a user
require_once "../inc/util.inc";
require_once "../inc/boinc_db.inc";
require_once "../inc/xml.inc";
check_get_args(array("format", "authenticator"));
BoincDb::get(true);
$config = get_config();
if (!parse_bool($config, "show_results")) {
    error_page("This feature is turned off temporarily");
}
$format = get_str("format", true);
if ($format == "xml") {
    xml_header();
    $auth = BoincDb::escape_string(get_str('authenticator'));
    $user = BoincUser::lookup("authenticator='{$auth}'");
    if (!$user) {
        echo "<error>" . xml_error(-136) . "</error>\n";
        exit;
    }
    $sum = 0;
    echo "<pending_credit>\n";
    $results = BoincResult::enum("userid={$user->id} AND (validate_state=0 OR validate_state=4) AND claimed_credit > 0");
    foreach ($results as $result) {
        echo "<result>\n";
        echo "    <resultid>" . $result->id . "</resultid>\n";
        echo "    <workunitid>" . $result->workunitid . "</workunitid>\n";
        echo "    <hostid>" . $result->hostid . "</hostid>\n";
        echo "    <claimed_credit>" . $result->claimed_credit . "</claimed_credit>\n";
        echo "    <received_time>" . $result->received_time . "</received_time>\n";
开发者ID:nicolas17,项目名称:boincgit-test,代码行数:31,代码来源:pending.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP BoincForumPrefs类代码示例发布时间:2022-05-23
下一篇:
PHP Board类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap