diff --git a/html/inc/util_ops.inc b/html/inc/util_ops.inc
index 467e82851c..8810fe62c4 100644
--- a/html/inc/util_ops.inc
+++ b/html/inc/util_ops.inc
@@ -355,5 +355,35 @@ if (!isset($skip_auth_ops) && array_key_exists("SERVER_PORT", $_SERVER)) {
auth_ops();
}
+// TODO: use DB interface layer
+//
+function cancel_wus_where($clause) {
+ $q1 = "CREATE TEMPORARY TABLE tmp SELECT id FROM workunit WHERE $clause;";
+ $q2 = "UPDATE result SET server_state=5, outcome=5 WHERE server_state=2 AND workunitid in (SELECT id FROM tmp);";
+ $q3 = "UPDATE workunit SET error_mask=error_mask|16 WHERE id in (SELECT id FROM tmp);";
+ $q4 = "UPDATE workunit SET transition_time=0 WHERE id in (SELECT id FROM tmp);";
+ $q5 = "DROP TABLE tmp;";
+
+ if (!mysql_query($q1)) {
+ echo "MySQL command '$q1' failed:
unable to create temporary WU id table.
\n";
+ return 1;
+ } else if (!mysql_query($q2)) {
+ echo "MySQL command '$q2' failed:
unable to cancel unsent results.
\n";
+ mysql_query($q5);
+ return 2;
+ } else if (!mysql_query($q3)) {
+ echo "MySQL command '$q3' failed:
unable to cancel workunits.
\n";
+ mysql_query($q5);
+ return 3;
+ } else if (!mysql_query($q4)) {
+ echo "MySQL command '$q4' failed:
unable to trigger transitioner.
\n";
+ mysql_query($q5);
+ return 4;
+ }
+ mysql_query($q5);
+ echo "Successfully canceled WUs WHERE '$clause'
\n";
+ return 0;
+}
+
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
?>
diff --git a/html/ops/cancel_workunits.php b/html/ops/cancel_workunits.php
new file mode 100644
index 0000000000..57a4ac33d1
--- /dev/null
+++ b/html/ops/cancel_workunits.php
@@ -0,0 +1,158 @@
+.
+
+// web interface for canceling WUs according to a SQL where clause
+
+// TODO: use get_int() etc.
+
+require_once("../inc/util_ops.inc");
+
+admin_page_head("Cancel Jobs");
+
+$limit = 100;
+if (array_key_exists('limit',$_REQUEST)) {
+ $nlimit=$_REQUEST['limit'];
+ if ($nlimit != 0) {
+ $limit = $nlimit;
+ }
+}
+
+$clause = "";
+
+if (array_key_exists('minid',$_REQUEST) && $_REQUEST['minid'] != "" &&
+ array_key_exists('maxid',$_REQUEST) && $_REQUEST['maxid'] != "")
+ $clause = "id >=" . $_REQUEST['minid'] . " AND id <=" . $_REQUEST['maxid'];
+else if (array_key_exists('list',$_REQUEST) && $_REQUEST['list'] != "")
+ $clause = "id IN (" . $_REQUEST['list'] . ")";
+else if (array_key_exists('uclause',$_REQUEST) && $_REQUEST['uclause'] != "")
+ $clause = urldecode($_REQUEST['uclause']);
+else if (array_key_exists('clause',$_REQUEST) && $_REQUEST['clause'] != "")
+ // the following line is BS, but apparently I can't find another way to pass a
+ // double quote (") to the query
+ $clause = str_replace('\"', '"', $_REQUEST['clause']);
+
+if ($clause == "") {
+
+ // copied from old cancel_wu_form.php
+ echo "
+ This form may be used to cancel unnecessary or unwanted jobs. + We recommend that you stop the project before doing this. + Note that the jobs and their corresponding + results (if any) are NOT removed from the database. + Instead, they are marked as 'no longer needed'. + In most cases you should probably only remove jobs whose results + are all unsent, + since otherwise a user will not get credit + for a result that they might return. +
++ Please specify jobs by ID range, ID list or clause to be used in a + 'SELECT FROM workunit WHERE' query. +
++ You will be given a list of jobs matching your specification + for confirmation before these are actually canceled. +
+"; + + $page = $_SERVER["REQUEST_URI"]; + echo "\n"; + + } // if (!$dbresult) + +} // if ($clause) + +admin_page_tail(); + +$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit +?> diff --git a/html/ops/cancel_workunits_action.php b/html/ops/cancel_workunits_action.php new file mode 100644 index 0000000000..020c188d82 --- /dev/null +++ b/html/ops/cancel_workunits_action.php @@ -0,0 +1,68 @@ +. + +require_once("../inc/util_ops.inc"); + +admin_page_head("Cancel Workunits"); + +// check for WUs to cancel +$WUs=""; +if (array_key_exists('cancel',$_REQUEST) && ($_REQUEST['cancel'] == 1)) { + if (is_array($_REQUEST['WU'])) { + foreach ($_REQUEST['WU'] as $key => $value) { + if($WUs != "") + $WUs = $WUs . ","; + $WUs = $WUs . $value; + } + } +} + +// cancel WUs (if not in rops) +if($WUs != "") { + echo "\n"; + if (!in_rops()) { + db_init(); + cancel_wus_where("id IN (" . $WUs . ")"); + } +} + +if (array_key_exists('back',$_REQUEST)) { + if ($_REQUEST['back'] == "errorwus") { + echo "Return to All-error Workunits page
"; + } else if ($_REQUEST['back'] == "cancelwus") { + if (array_key_exists('clause',$_REQUEST)) { + $limit = 20; + if (array_key_exists('limit',$_REQUEST)) + $limit=$_REQUEST['limit']; + $clause=urlencode($_REQUEST['clause']); + echo ""; + echo "Cancel next (max $limit) Workunits
"; + } + echo "Return to Cancel Workunits page
"; + } +} + +echo ""; +echo "Page last updated "; +echo time_str(time()); +echo "
\n"; + +admin_page_tail(); + +$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit +?> diff --git a/html/ops/index.php b/html/ops/index.php index d813027b58..aa9c6e0dec 100644 --- a/html/ops/index.php +++ b/html/ops/index.php @@ -108,7 +108,8 @@ echo "(this can 'unstick' old jobs)