function possibly_delete_user($user) { if ($user->total_credit > 0.0) { admin_error_page("Cannot delete user: User has credit."); } // Don't delete user if they have any outstanding Results // if (BoincResult::count("userid={$user->id}")) { admin_error_page("Cannot delete user: User has count results in the database."); } // Don't delete user if they have posted to the forums // if (BoincPost::count("user={$user->id}")) { admin_error_page("Cannot delete user: User has forum posts."); } if ($user->teamid) { user_quit_team($user); } delete_user($user); }
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; }