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(); }
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; }
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); }
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); }
function get_includes() { $c = getcwd(); chdir('html/ops'); require_once '../inc/util_ops.inc'; BoincDb::get(); chdir($c); }
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; }
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}"); }
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 "; }
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}"); }
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); }
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); } }
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")); } }
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); }
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; }
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"));
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();
// 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();
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"),
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"); } }
// 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";
$content = post_str("content", true); $title = post_str("title", true); $preview = post_str("preview", true); if (post_str('submit', true) && !$preview) { check_tokens($logged_in_user->authenticator); $add_signature = post_str('add_signature', true) == "1" ? 1 : 0; $content = substr($content, 0, 64000); $content = trim($content); if (strlen($content)) { $content = BoincDb::escape_string($content); $now = time(); $post->update("signature={$add_signature}, content='{$content}', modified={$now}"); if ($can_edit_title) { $title = trim($title); $title = sanitize_tags($title); $title = BoincDb::escape_string($title); $thread->update("title='{$title}'"); } header("Location: forum_thread.php?id={$thread->id}&postid={$postid}"); } else { delete_post($post, $thread, $forum); header("Location: forum_forum.php?id={$forum->id}"); } } page_head(tra("Forum"), '', '', '', $bbcode_js); show_forum_header($logged_in_user); switch ($forum->parent_type) { case 0: $category = BoincCategory::lookup_id($forum->category); show_forum_title($category, $forum, $thread); break;
function get_wu_output_file($wu_name, $file_num, $auth_str) { $wu_name = BoincDb::escape_string($wu_name); $wu = BoincWorkunit::lookup("name='{$wu_name}'"); if (!$wu) { die("no workunit {$wu_name}"); } $batch = BoincBatch::lookup_id($wu->batch); if (!$batch) { die("no batch {$wu->batch}"); } $user = BoincUser::lookup_id($batch->user_id); if (!$user) { die("no user {$batch->user_id}"); } if ($user->authenticator != $auth_str) { die("bad auth str: x={$x}, auth_str={$auth_str}"); } $fanout = parse_config(get_config(), "<uldl_dir_fanout>"); $upload_dir = parse_config(get_config(), "<upload_dir>"); if (!$wu->canonical_resultid) { die("no canonical result for wu {$wu->name}"); } $result = BoincResult::lookup_id($wu->canonical_resultid); $names = get_outfile_names($result); $path = dir_hier_path($names[$file_num], $upload_dir, $fanout); if (file_exists($path)) { do_download($path); } else { echo "no such file: {$path}"; } }
function ping($r) { xml_start_tag("ping"); BoincDb::get(); // errors out if DB down or web disabled echo "<success>1</success>\n </ping>\n "; }
require_once "../inc/countries.inc"; $user = get_logged_in_user(); check_tokens($user->authenticator); $name = boinc_htmlentities(post_str("user_name")); if ($name != strip_tags($name)) { error_page("HTML tags not allowed in name"); } if (strlen($name) == 0) { error_page("You must supply a name for your account."); } $url = post_str("url", true); $url = strip_tags($url); $country = post_str("country"); if ($country == "") { $country = "International"; } if (!is_valid_country($country)) { error_page("bad country"); } $country = BoincDb::escape_string($country); $postal_code = post_str("postal_code", true); $postal_code = strip_tags($postal_code); $name = BoincDb::escape_string($name); $url = BoincDb::escape_string($url); $postal_code = BoincDb::escape_string($postal_code); $result = $user->update("name='{$name}', url='{$url}', country='{$country}', postal_code='{$postal_code}'"); if ($result) { Header("Location: home.php"); } else { error_page("Couldn't update user info."); }
$hide_signatures = $_POST["forum_hide_signatures"] != "" ? 1 : 0; $highlight_special = $_POST["forum_highlight_special"] != "" ? 1 : 0; $jump_to_unread = $_POST["forum_jump_to_unread"] != "" ? 1 : 0; $ignore_sticky_posts = $_POST["forum_ignore_sticky_posts"] != "" ? 1 : 0; $no_signature_by_default = $_POST["signature_by_default"] != "" ? 0 : 1; $signature = post_str("signature", true); if (strlen($signature) > 250) { error_page(tra("Your signature was too long, please keep it less than 250 characters.")); } $forum_sort = post_int("forum_sort"); $thread_sort = post_int("thread_sort"); $display_wrap_postcount = post_int("forum_display_wrap_postcount"); if ($display_wrap_postcount < 1) { $display_wrap_postcount = 1; } $signature = BoincDb::escape_string($signature); $user->prefs->update("images_as_links={$images_as_links}, link_popup={$link_popup}, hide_avatars={$hide_avatars}, hide_signatures={$hide_signatures}, highlight_special={$highlight_special}, jump_to_unread={$jump_to_unread}, ignore_sticky_posts={$ignore_sticky_posts}, no_signature_by_default={$no_signature_by_default}, avatar='{$avatar_url}', signature='{$signature}', forum_sorting={$forum_sort}, thread_sorting={$thread_sort}, display_wrap_postcount={$display_wrap_postcount}"); } // DISABLE_FORUMS $add_user_to_filter = $_POST["add_user_to_filter"] != ""; if ($add_user_to_filter) { $user_to_add = trim($_POST["forum_filter_user"]); if ($user_to_add != "" and $user_to_add == strval(intval($user_to_add))) { $other_user = BoincUser::lookup_id($user_to_add); if (!$other_user) { echo tra("No such user:"******" " . $user_to_add; } else { add_ignored_user($user, $other_user); } } }
function update_team($t, $team, $user) { global $dry_run; if (trim($t->url) == $team->url && $t->type == $team->type && trim($t->name_html) == $team->name_html && trim($t->description) == $team->description && $t->country == $team->country && $t->id == $team->seti_id) { echo " no changes\n"; return; } echo " updating\n"; $url = BoincDb::escape_string($t->url); $name_html = BoincDb::escape_string($t->name_html); $description = BoincDb::escape_string($t->description); $country = BoincDb::escape_string($t->country); $query = "update team set url='{$url}', type={$t->type}, name_html='{$name_html}', description='{$description}', country='{$country}', seti_id={$t->id} where id={$team->id}"; if ($dry_run) { echo " {$query}\n"; return; } $retval = mysql_query($query); if (!$retval) { echo " update failed: {$query}\n"; exit; } }
$delete_problem .= "Cannot delete user: User has " . $c->count . " forum posts.<br/>"; } if ($delete_problem) { return false; } $q = "DELETE FROM user WHERE id=" . $user->id; $result = mysql_query($q); $delete_problem .= "User " . $user->id . " deleted."; unset($user); } $delete_problem = ""; // Process user search form $matches = ""; if (isset($_POST['search_submit'])) { $search_name = post_str('search_text'); $search_name = BoincDb::escape_string(sanitize_tags($search_name)); if (!empty($search_name)) { $result = mysql_query("SELECT * FROM user WHERE name='{$search_name}'"); if (mysql_num_rows($result) == 1) { $user = mysql_fetch_object($result); mysql_free_result($result); } else { $q = "SELECT * FROM user WHERE name LIKE '%" . $search_name . "%'"; $result = mysql_query($q); if (mysql_num_rows($result) == 1) { $user = mysql_fetch_object($result); mysql_free_result($result); } if (mysql_num_rows($result) > 1) { while ($row = mysql_fetch_object($result)) { if (!empty($matches)) {
// 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/>. // lock all threads older than N days $cli_only = true; require_once "../inc/util_ops.inc"; $max_age_days = 90; // lock threads older than this if ($argc > 2) { if ($argv[1] == "--ndays") { $max_age_days = $argv[2]; } } $t = time_str(time()); echo "starting at {$t}\n"; $t = time() - $max_age_days * 86400; $db = BoincDb::get(); if (!$db) { die("can't open DB\n"); } $db->do_query("update " . $db->db_name . ".thread, " . $db->db_name . ".forum set " . $db->db_name . ".thread.locked=1 where " . $db->db_name . ".thread.forum=" . $db->db_name . ".forum.id and " . $db->db_name . ".forum.parent_type=0 and " . $db->db_name . ".thread.timestamp<{$t} and " . $db->db_name . ".thread.locked=0 and " . $db->db_name . ".thread.sticky=0"); $n = $db->affected_rows(); $t = time_str(time()); echo "finished at {$t}; locked {$n} threads\n";
// 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/>. // code for one-time database updates goes here. // Don't run this unless you know what you're doing! $cli_only = true; require_once "../inc/util_ops.inc"; $db = BoincDb::get_aux(false); if (!$db) { echo "Can't open database\n"; exit; } set_time_limit(0); function do_query($query) { echo "Doing query:\n{$query}\n"; $result = _mysql_query($query); if (!$result) { echo "Failed:\n" . _mysql_error() . "\n"; } else { echo "Success.\n"; } }
require_once "../inc/boinc_db.inc"; require_once "../inc/util.inc"; require_once "../inc/email.inc"; require_once "../inc/team.inc"; $xml = get_int('xml', true); if ($xml) { require_once "../inc/xml.inc"; } if (DISABLE_TEAMS) { if ($xml) { xml_error(-1, "Teams are disabled"); } else { error_page("Teams are disabled"); } } BoincDb::get(true); if ($xml) { $creditonly = get_int('creditonly', true); xml_header(); $retval = db_init_xml(); if ($retval) { xml_error($retval); } $teamid = get_int("teamid"); $team = BoincTeam::lookup_id($teamid); if (!$team) { xml_error(ERR_DB_NOT_FOUND); } $account_key = get_str('account_key', true); $user = BoincUser::lookup_auth($account_key); $show_email = $user && is_team_founder($user, $team);