. // web interface for managing apps require_once('../inc/util_ops.inc'); function do_updates() { $id = post_int("id"); $app = BoincApp::lookup_id($id); if (!$app) admin_error_page("no such app"); $n = post_str("deprecated", true)?1:0; $app->update("deprecated=$n"); $n = post_num("weight"); $app->update("weight=$n"); $n = post_int("homogeneous_redundancy"); $app->update("homogeneous_redundancy=$n"); $n = post_str("homogeneous_app_version", true)?1:0; $app->update("homogeneous_app_version=$n"); $n = post_str("non_cpu_intensive", true)?1:0; $app->update("non_cpu_intensive=$n"); $n = post_str("beta", true)?1:0; $app->update("beta=$n"); $n = post_str("fraction_done_exact", true)?1:0; $app->update("fraction_done_exact=$n"); echo "Application $id updated.

You must restart the project for this to take effect. "; } 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.

" ); } $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.

You must restart the project for this to take effect. "; } function show_form() { echo "

Edit applications

"; start_table(); table_header( "ID", "Name and description

Click for details

", "Created", "weight

details

", "shmem items", "HR type

details

", "homogeneous app version?

details

", "deprecated?", "Non-CPU-intensive?", "Beta?", "Exact fraction done?", "" ); $total_weight = BoincApp::sum("weight"); $swi = parse_config(get_config(), ""); if (!$swi) { $swi = 100; } $apps = BoincApp::enum(""); $i = 0; foreach ($apps as $app) { // grey-out deprecated versions $f1=$f2=''; if ($app->deprecated==1) { $f1 = ""; $f2 = ""; } echo "
"; $i = 1-$i; echo "id>"; echo " $f1 $app->id $f2\n"; echo " $f1id>$app->name
$app->user_friendly_name $f2\n"; echo " $f1 " .date_str($app->create_time)."$f2\n"; $v = $app->weight; echo " \n"; if ($app->deprecated || ($total_weight == 0)) { echo ''; } else { echo ''.round($app->weight/$total_weight*$swi).''; } $v = $app->homogeneous_redundancy; echo " "; $v = ''; if ($app->homogeneous_app_version) $v=' CHECKED '; echo " "; $v = ''; if ($app->deprecated) $v = ' CHECKED '; echo " "; $v = ''; if ($app->non_cpu_intensive) $v = ' CHECKED '; echo " "; $v = ''; if ($app->beta) $v = ' CHECKED '; echo " "; $v = ''; if ($app->fraction_done_exact) $v = ' CHECKED '; echo " "; echo ""; echo "
"; } end_table(); // Entry form to create a new application // echo"

Add an application

To add an application enter the short name and description ('user friendly name') below. You can then edit the application when it appears in the table above.

"; start_table("align='center' "); table_header("Name", "Description", " "); echo " \n"; end_table(); echo "

\n"; } admin_page_head("Manage applications"); if (post_str('add_app', true)) { add_app(); } else if (post_str('submit', true)) { do_updates(); } show_form(false); admin_page_tail(); ?>