2006-11-17 19:52:09 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
2013-07-02 21:51:19 +00:00
|
|
|
// Copyright (C) 2013 University of California
|
2008-08-05 22:43:14 +00:00
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// 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/>.
|
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
// web interface for managing apps
|
2010-11-05 04:44:14 +00:00
|
|
|
|
2006-11-17 19:52:09 +00:00
|
|
|
require_once('../inc/util_ops.inc');
|
|
|
|
|
2012-05-20 23:02:12 +00:00
|
|
|
function do_updates() {
|
2013-07-02 21:51:19 +00:00
|
|
|
$id = post_int("id");
|
|
|
|
$app = BoincApp::lookup_id($id);
|
2014-10-29 19:25:35 +00:00
|
|
|
if (!$app) admin_error_page("no such app");
|
2012-05-20 23:02:12 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
$n = post_str("deprecated", true)?1:0;
|
|
|
|
$app->update("deprecated=$n");
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
$n = post_num("weight");
|
|
|
|
$app->update("weight=$n");
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
$n = post_int("homogeneous_redundancy");
|
|
|
|
$app->update("homogeneous_redundancy=$n");
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
$n = post_str("homogeneous_app_version", true)?1:0;
|
|
|
|
$app->update("homogeneous_app_version=$n");
|
2012-11-08 07:43:43 +00:00
|
|
|
|
2014-04-20 07:29:32 +00:00
|
|
|
$n = post_str("non_cpu_intensive", true)?1:0;
|
2013-07-02 21:51:19 +00:00
|
|
|
$app->update("non_cpu_intensive=$n");
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
$n = post_str("beta", true)?1:0;
|
|
|
|
$app->update("beta=$n");
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2014-05-04 07:02:32 +00:00
|
|
|
$n = post_str("fraction_done_exact", true)?1:0;
|
|
|
|
$app->update("fraction_done_exact=$n");
|
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
echo "Application $id updated.
|
|
|
|
<p>
|
|
|
|
You must restart the project for this to take effect.
|
|
|
|
";
|
2012-01-21 00:04:54 +00:00
|
|
|
}
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
function add_app() {
|
2014-06-01 17:14:13 +00:00
|
|
|
$name = BoincDb::escape_string(post_str('add_name'));
|
|
|
|
$user_friendly_name = BoincDb::escape_string(post_str('add_user_friendly_name'));
|
2013-07-02 21:51:19 +00:00
|
|
|
if (empty($name) || empty($user_friendly_name) ) {
|
2014-10-29 19:25:35 +00:00
|
|
|
admin_error_page(
|
2013-07-02 21:51:19 +00:00
|
|
|
"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) {
|
2014-10-29 19:25:35 +00:00
|
|
|
admin_error_page("insert failed");
|
2012-05-20 23:02:12 +00:00
|
|
|
}
|
2013-07-02 21:51:19 +00:00
|
|
|
echo "Application added.
|
|
|
|
<p>
|
|
|
|
You must restart the project for this to take effect.
|
|
|
|
";
|
|
|
|
}
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
function show_form() {
|
2012-05-20 23:02:12 +00:00
|
|
|
echo "
|
|
|
|
<h2>Edit applications</h2>
|
|
|
|
";
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2012-05-20 23:02:12 +00:00
|
|
|
start_table();
|
|
|
|
table_header(
|
|
|
|
"ID",
|
2014-10-02 19:15:54 +00:00
|
|
|
"Name and description<br><p class=\"text-muted\">Click for details</p>",
|
2012-05-20 23:02:12 +00:00
|
|
|
"Created",
|
2014-10-02 19:15:54 +00:00
|
|
|
"weight<br><a href=http://boinc.berkeley.edu/trac/wiki/BackendPrograms#feeder><p class=\"text-muted\">details</p></a>",
|
2013-05-10 07:17:39 +00:00
|
|
|
"shmem items",
|
2014-10-02 19:15:54 +00:00
|
|
|
"HR type<br><a href=http://boinc.berkeley.edu/trac/wiki/HomogeneousRedundancy><p class=\"text-muted\">details</p></a>",
|
|
|
|
"homogeneous app version?<br><a href=http://boinc.berkeley.edu/trac/wiki/HomogeneousAppVersion><p class=\"text-muted\">details</p></a>",
|
2012-08-25 04:09:24 +00:00
|
|
|
"deprecated?",
|
2012-11-08 07:43:43 +00:00
|
|
|
"Non-CPU-intensive?",
|
2013-12-24 05:02:55 +00:00
|
|
|
"Beta?",
|
2014-05-04 07:02:32 +00:00
|
|
|
"Exact fraction done?",
|
2013-12-24 05:02:55 +00:00
|
|
|
""
|
2012-05-20 23:02:12 +00:00
|
|
|
);
|
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
$total_weight = BoincApp::sum("weight");
|
2013-05-10 07:17:39 +00:00
|
|
|
$swi = parse_config(get_config(), "<shmem_work_items>");
|
2013-05-19 17:00:42 +00:00
|
|
|
if (!$swi) {
|
|
|
|
$swi = 100;
|
|
|
|
}
|
2012-05-20 23:02:12 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
$apps = BoincApp::enum("");
|
2013-12-24 05:02:55 +00:00
|
|
|
$i = 0;
|
2013-07-02 21:51:19 +00:00
|
|
|
foreach ($apps as $app) {
|
2012-05-20 23:02:12 +00:00
|
|
|
// grey-out deprecated versions
|
|
|
|
$f1=$f2='';
|
2013-07-02 21:51:19 +00:00
|
|
|
if ($app->deprecated==1) {
|
2012-05-20 23:02:12 +00:00
|
|
|
$f1 = "<font color='GREY'>";
|
|
|
|
$f2 = "</font>";
|
|
|
|
}
|
2013-12-24 05:02:55 +00:00
|
|
|
echo "<tr class=row$i><form action=manage_apps.php method=POST>";
|
|
|
|
$i = 1-$i;
|
2013-07-02 21:51:19 +00:00
|
|
|
echo "<input type=hidden name=id value=$app->id>";
|
|
|
|
echo " <TD align='center'>$f1 $app->id $f2</TD>\n";
|
2012-05-20 23:02:12 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
echo " <TD align='left'>$f1<a href=app_details.php?appid=$app->id>$app->name</a><br> $app->user_friendly_name $f2</TD>\n";
|
2012-05-20 23:02:12 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
echo " <TD align='center'>$f1 " .date_str($app->create_time)."$f2</TD>\n";
|
2012-05-20 23:02:12 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
$v = $app->weight;
|
2012-05-20 23:02:12 +00:00
|
|
|
echo " <TD align='center'>
|
2013-07-02 21:51:19 +00:00
|
|
|
<input type='text' size='4' name='weight' value='$v'></TD>\n";
|
2013-05-10 07:17:39 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
if ($app->deprecated || ($total_weight == 0)) {
|
2013-05-10 07:17:39 +00:00
|
|
|
echo '<td></td>';
|
|
|
|
} else {
|
2013-07-02 21:51:19 +00:00
|
|
|
echo '<td align="right">'.round($app->weight/$total_weight*$swi).'</td>';
|
2013-05-10 07:17:39 +00:00
|
|
|
}
|
2012-05-20 23:02:12 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
$v = $app->homogeneous_redundancy;
|
2012-05-20 23:02:12 +00:00
|
|
|
echo " <TD align='center'>
|
2013-07-02 21:51:19 +00:00
|
|
|
<input name='homogeneous_redundancy' value='$v'></TD>
|
2012-05-20 23:02:12 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
$v = '';
|
2013-07-02 21:51:19 +00:00
|
|
|
if ($app->homogeneous_app_version) $v=' CHECKED ';
|
2012-05-20 23:02:12 +00:00
|
|
|
echo " <TD align='center'>
|
2013-07-02 21:51:19 +00:00
|
|
|
<input name='homogeneous_app_version' type='checkbox' $v></TD>
|
2012-05-20 23:02:12 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
$v = '';
|
2013-07-02 21:51:19 +00:00
|
|
|
if ($app->deprecated) $v = ' CHECKED ';
|
2012-05-20 23:02:12 +00:00
|
|
|
echo " <TD align='center'>
|
2013-07-02 21:51:19 +00:00
|
|
|
<input name='deprecated' type='checkbox' $v></TD>
|
2012-05-20 23:02:12 +00:00
|
|
|
";
|
|
|
|
|
2012-08-25 04:09:24 +00:00
|
|
|
$v = '';
|
2013-07-02 21:51:19 +00:00
|
|
|
if ($app->non_cpu_intensive) $v = ' CHECKED ';
|
2012-08-25 04:09:24 +00:00
|
|
|
echo " <TD align='center'>
|
2013-07-02 21:51:19 +00:00
|
|
|
<input name='non_cpu_intensive' type='checkbox' $v></TD>
|
2012-08-25 04:09:24 +00:00
|
|
|
";
|
|
|
|
|
2012-11-08 07:43:43 +00:00
|
|
|
$v = '';
|
2013-07-02 21:51:19 +00:00
|
|
|
if ($app->beta) $v = ' CHECKED ';
|
2012-11-08 07:43:43 +00:00
|
|
|
echo " <TD align='center'>
|
2013-07-02 21:51:19 +00:00
|
|
|
<input name='beta' type='checkbox' $v></TD>
|
2012-11-08 07:43:43 +00:00
|
|
|
";
|
|
|
|
|
2014-05-04 07:02:32 +00:00
|
|
|
$v = '';
|
|
|
|
if ($app->fraction_done_exact) $v = ' CHECKED ';
|
|
|
|
echo " <TD align='center'>
|
|
|
|
<input name='fraction_done_exact' type='checkbox' $v></TD>
|
|
|
|
";
|
|
|
|
|
2014-10-02 19:15:54 +00:00
|
|
|
echo "<td><input class=\"btn btn-default\" type=submit name=submit value=Update>";
|
2013-07-02 21:51:19 +00:00
|
|
|
echo "</tr></form>";
|
2012-05-20 23:02:12 +00:00
|
|
|
}
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2012-05-20 23:02:12 +00:00
|
|
|
end_table();
|
2006-11-17 19:52:09 +00:00
|
|
|
|
|
|
|
|
2012-05-20 23:02:12 +00:00
|
|
|
// Entry form to create a new application
|
|
|
|
//
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2012-05-20 23:02:12 +00:00
|
|
|
echo"<P>
|
2013-07-02 21:51:19 +00:00
|
|
|
<h2>Add an application</h2>
|
|
|
|
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.
|
|
|
|
<p>
|
|
|
|
<form action=manage_apps.php method=POST>
|
|
|
|
";
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2012-05-20 23:02:12 +00:00
|
|
|
start_table("align='center' ");
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
table_header("Name", "Description", " ");
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2012-05-20 23:02:12 +00:00
|
|
|
echo "<TR>
|
|
|
|
<TD> <input type='text' size='12' name='add_name' value=''></TD>
|
|
|
|
<TD> <input type='text' size='35' name='add_user_friendly_name' value=''></TD>
|
|
|
|
<TD align='center' >
|
|
|
|
<input type='submit' name='add_app' value='Add Application'></TD>
|
|
|
|
</TR>\n";
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2012-05-20 23:02:12 +00:00
|
|
|
end_table();
|
|
|
|
echo "</form><p>\n";
|
|
|
|
}
|
2006-11-17 19:52:09 +00:00
|
|
|
|
2013-07-02 21:51:19 +00:00
|
|
|
admin_page_head("Manage applications");
|
|
|
|
|
|
|
|
if (post_str('add_app', true)) {
|
|
|
|
add_app();
|
|
|
|
} else if (post_str('submit', true)) {
|
2012-05-20 23:02:12 +00:00
|
|
|
do_updates();
|
|
|
|
}
|
2013-07-02 21:51:19 +00:00
|
|
|
show_form(false);
|
|
|
|
admin_page_tail();
|
2006-11-17 19:52:09 +00:00
|
|
|
|
|
|
|
?>
|