. require_once("../inc/bossa_db.inc"); require_once("../inc/bolt_db.inc"); require_once("../inc/util_ops.inc"); function job_state_string($s) { switch ($s) { case 0: return "Embargoed"; case 1: return "In progress"; case 2: return "Completed"; } } function include_app_file($app_id) { $app = BossaApp::lookup_id($app_id); $file = "../inc/$app->short_name.inc"; require_once($file); } function show_bossa_app($app, $i) { $j = $i%2; echo "
"; add_app_form(); echo "
"; user_settings(); admin_page_tail(); } function job_duration($inst) { if ($inst->finish_time) { $d = $inst->finish_time - $inst->create_time; $d /= 60; $d = number_format($d, 2); $d = "$d min."; } else { $d = "---"; } return $d; } function job_show_instances($job) { $insts = BossaJobInst::enum("job_id=$job->id"); if (!count($insts)) { echo "---"; return; } start_table(); table_header("User", "Start", "Duration", "Result"); foreach ($insts as $inst) { $user = BoincUser::lookup_id($inst->user_id); $t = time_str($inst->create_time); $d = job_duration($inst); echo "
Are you sure you want to do this?
Yes "; admin_page_tail(); } function clear_batch($batch_id) { admin_page_head("Deleting instances"); if (BossaJobInst::delete_aux("batch_id=$batch_id")) { echo "Job instances deleted."; $jobs = BossaJob::enum("batch_id=$batch_id"); foreach ($jobs as $job) { $job->update("priority_0=1"); } } else { echo "Database error."; } admin_page_tail(); } $user = get_logged_in_user(); $db = BossaDb::get(); if (!$db) error_page("Can't connect to database server"); if (!$db->table_exists('bossa_app')) { admin_page_head("Create Bossa database"); $db_name = $db->db_name; echo " The database tables for Bossa don't seem to exist. To create them, go to ~/boinc/db and type
mysql $db_name < bossa_schema.sql mysql $db_name < bossa_constraints.sqlThen reload this page. "; admin_page_tail(); exit; } BossaUser::lookup($user); $action = get_str('action', true); switch ($action) { case 'add_app': $name = BossaDb::escape_string(get_str('app_name')); $short_name = get_str('short_name'); $description = BossaDb::escape_string(get_str('description')); $training_course = get_str('training_course', true); if (strlen($training_course)) { $course = BoltCourse::lookup_name($training_course); if (!$course) { error_page("No course named $training_course"); } $courseid = $course->id; } else { $courseid = 0; } $time_estimate = get_str('time_estimate'); if (!$time_estimate) $time_estimate = 60; $time_limit = get_str('time_limit'); if (!$time_limit) $time_limit = 3600; $calibration_frac = get_str('calibration_frac' , true); if (!$calibration_frac) $calibration_frac = 0; $now = time(); $app_id = BossaApp::insert("(create_time, name, short_name, description, bolt_course_id, time_estimate, time_limit, calibration_frac) values ($now, '$name', '$short_name', '$description', $courseid, $time_estimate, $time_limit, $calibration_frac)"); if ($courseid) { $course->update("bossa_app_id=$app_id"); } Header('Location: bossa_admin.php'); exit; case 'update_user': $flags = 0; if (get_str('show_all', true)) $flags |= BOLT_FLAGS_SHOW_ALL; if (get_str('debug', true)) $flags |= BOLT_FLAGS_DEBUG; $user->bossa->update("flags=$flags"); $user->bossa->flags = $flags; Header('Location: bossa_admin.php'); exit; case 'show_user': show_bossa_user(); exit; case 'show_batches': $app_id = get_int('app_id'); show_batches($app_id); exit; case 'show_batch': $batch_id = get_int('batch_id'); show_batch($batch_id); exit; case 'job_show_insts': $job_id = get_int('job_id'); job_show_insts($job_id); exit; case 'hide': $app_id = get_int('app_id'); $app = BossaApp::lookup_id($app_id); if (!$app) error_page("no such app"); $app->update("hidden=1"); break; case 'unhide': $app_id = get_int('app_id'); $app = BossaApp::lookup_id($app_id); if (!$app) error_page("no such app"); $app->update("hidden=0"); break; case 'clear_batch_confirm': $batch_id = get_int('batch_id'); clear_batch_confirm($batch_id); exit; case 'clear_batch': $batch_id = get_int('batch_id'); clear_batch($batch_id); exit; case '': show_all(); exit; default: error_page("unknown action $action"); } Header('Location: bossa_admin.php'); ?>