diff --git a/frontend/dropjob.php b/frontend/dropjob.php
new file mode 100644
index 0000000..cb45e26
--- /dev/null
+++ b/frontend/dropjob.php
@@ -0,0 +1,19 @@
+
+$link = mysql_connect('127.0.0.1', 'Rbatch', 'Rbatch');
+if (!$link) { echo "Unable to connect to DB: " . mysql_error(); exit; }
+if (!mysql_select_db('R')) { echo "Unable to select database: " . mysql_error(); exit; }
+
+$id = 1 * $_REQUEST['ID'];
+
+if ($id < 1) {
+ header('Location: /');
+ exit();
+}
+
+$sql = "UPDATE jobs SET Retired = 'Y', RetiredDate = NOW()
+ WHERE ID = ". $id. " AND Retired != 'Y' LIMIT 1";
+
+$result = mysql_query($sql);
+if (!$result) { echo "Could not select jobs" . mysql_error(); exit; }
+header('Location: /');
+?>
diff --git a/frontend/index.php b/frontend/index.php
new file mode 100644
index 0000000..4576ed1
--- /dev/null
+++ b/frontend/index.php
@@ -0,0 +1,122 @@
+
+$link = mysql_connect('127.0.0.1', 'Rbatch', 'Rbatch');
+if (!$link) { echo "Unable to connect to DB: " . mysql_error(); exit; }
+if (!mysql_select_db('R')) { echo "Unable to select database: " . mysql_error(); exit; }
+
+#$sql = 'SELECT jobs.*, environment.Name AS EnvName, environment.Commands AS EnvCmd FROM jobs
+# JOIN environment ON (jobs.Environment = environment.ID)
+# ORDER BY Queued DESC
+# LIMIT 10';
+$sql = "SELECT ID, Name, Status, Result, UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(IF(Status IN ('Parsing-Fail','Success','Failure'), Completed, IF(Status = 'Running', Started, Queued))) AS LastChange FROM jobs
+ WHERE Retired = 'N'
+ ORDER BY (Status = 'Running') DESC, (Status = 'Queued') DESC, LastChange ASC
+ LIMIT 3000";
+
+$result = mysql_query($sql);
+if (!$result) { echo "Could not select jobs" . mysql_error(); exit; }
+if (mysql_num_rows($result) == 0) { echo "No jobs found"; exit; }
+
+?>
+
MySQL-RMySQL-R
+
+
+
+
+
+// function time_ago based on time_ago by Matt Jones
+// http://www.mdj.us/web-development/php-programming/another-variation-on-the-time-ago-php-function-use-mysqls-datetime-field-type/
+// DISPLAYS COMMENT POST TIME AS "1 year, 1 week ago" or "5 minutes, 7 seconds ago", etc...
+function time_ago($difference,$granularity=1) {
+# $date = strtotime($date);
+# $difference = time() - $date;
+ $periods = array('decade' => 315360000,
+ 'year' => 31536000,
+ 'month' => 2628000,
+ 'week' => 604800,
+ 'day' => 86400,
+ 'hour' => 3600,
+ 'minute' => 60,
+ 'second' => 1);
+ if ($difference < 20) { // less than 5 seconds ago, let's say "just now"
+ $retval = " just now";
+ return $retval;
+ } else {
+ $retval = '';
+ foreach ($periods as $key => $value) {
+ if ($difference >= $value) {
+ $time = floor($difference/$value);
+ $difference %= $value;
+ $retval .= ($retval ? ' ' : '').$time.' ';
+ $retval .= (($time > 1) ? $key.'s' : $key);
+ $granularity--;
+ }
+ if ($granularity == '0') { break; }
+ }
+ return ' '.$retval.' ago';
+ }
+}
+
+
+while ($row = mysql_fetch_assoc($result)) {
+
+ print '';
+ print '
#'.$row['ID'].' – '.htmlentities($row['Name']).' – '. $row['Status'] .', '. time_ago($row['LastChange']). '';
+ print '
';
+ print '
';
+
+ if (trim($row['Result']) != '') {
+ print 'Output:
';
+ print '
';
+ print htmlentities($row['Result']);
+ print '
';
+ }
+
+ $sql2 = 'SELECT ID FROM results WHERE JobID = ' . $row['ID'] . ' LIMIT 16';
+ $result2 = mysql_query($sql2);
+ if (!$result2) { echo "Could not select results" . mysql_error(); exit; }
+ if (mysql_num_rows($result2) > 0) {
+ print '
';
+ while ($resrow = mysql_fetch_assoc($result2)) {
+ print '
';
+ print '
';
+ print '
';
+ }
+ print '
';
+ }
+ print '
';
+
+ mysql_free_result($result2);
+}
+
+mysql_free_result($result);
+
+?>
+
diff --git a/frontend/indexall.php b/frontend/indexall.php
new file mode 100644
index 0000000..ffb7d98
--- /dev/null
+++ b/frontend/indexall.php
@@ -0,0 +1,117 @@
+
+$link = mysql_connect('127.0.0.1', 'Rbatch', 'Rbatch');
+if (!$link) { echo "Unable to connect to DB: " . mysql_error(); exit; }
+if (!mysql_select_db('R')) { echo "Unable to select database: " . mysql_error(); exit; }
+
+$sql = "SELECT ID, Name, Status, Result, UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(IF(Status IN ('Parsing-Fail','Success','Failure'), Completed, IF(Status = 'Running', Started, Queued))) AS LastChange FROM jobs
+ ORDER BY (Status = 'Running') DESC, (Status = 'Queued') DESC, LastChange ASC
+ LIMIT 3000";
+
+$result = mysql_query($sql);
+if (!$result) { echo "Could not select jobs" . mysql_error(); exit; }
+if (mysql_num_rows($result) == 0) { echo "No jobs found"; exit; }
+
+?>
+MySQL-RMySQL-R
+
+
+
+
+
+// function time_ago based on time_ago by Matt Jones
+// http://www.mdj.us/web-development/php-programming/another-variation-on-the-time-ago-php-function-use-mysqls-datetime-field-type/
+// DISPLAYS COMMENT POST TIME AS "1 year, 1 week ago" or "5 minutes, 7 seconds ago", etc...
+function time_ago($difference,$granularity=1) {
+# $date = strtotime($date);
+# $difference = time() - $date;
+ $periods = array('decade' => 315360000,
+ 'year' => 31536000,
+ 'month' => 2628000,
+ 'week' => 604800,
+ 'day' => 86400,
+ 'hour' => 3600,
+ 'minute' => 60,
+ 'second' => 1);
+ if ($difference < 20) { // less than 5 seconds ago, let's say "just now"
+ $retval = " just now";
+ return $retval;
+ } else {
+ $retval = '';
+ foreach ($periods as $key => $value) {
+ if ($difference >= $value) {
+ $time = floor($difference/$value);
+ $difference %= $value;
+ $retval .= ($retval ? ' ' : '').$time.' ';
+ $retval .= (($time > 1) ? $key.'s' : $key);
+ $granularity--;
+ }
+ if ($granularity == '0') { break; }
+ }
+ return ' '.$retval.' ago';
+ }
+}
+
+
+while ($row = mysql_fetch_assoc($result)) {
+
+ print '';
+ print '
#'.$row['ID'].' – '.htmlentities($row['Name']).' – '. $row['Status'] .', '. time_ago($row['LastChange']). '';
+ print '
';
+ print '
';
+
+ if (trim($row['Result']) != '') {
+ print 'Output:
';
+ print '
';
+ print htmlentities($row['Result']);
+ print '
';
+ }
+
+ $sql2 = 'SELECT ID FROM results WHERE JobID = ' . $row['ID'] . ' LIMIT 16';
+ $result2 = mysql_query($sql2);
+ if (!$result2) { echo "Could not select results" . mysql_error(); exit; }
+ if (mysql_num_rows($result2) > 0) {
+ print '
';
+ while ($resrow = mysql_fetch_assoc($result2)) {
+ print '
';
+ print '
';
+ print '
';
+ }
+ print '
';
+ }
+ print '
';
+
+ mysql_free_result($result2);
+}
+
+mysql_free_result($result);
+
+?>
+
diff --git a/frontend/newjob.php b/frontend/newjob.php
new file mode 100644
index 0000000..1d9cc7b
--- /dev/null
+++ b/frontend/newjob.php
@@ -0,0 +1,36 @@
+
+$envir = 1 * $_POST['environment'];
+$name = $_POST['name'];
+$comment = $_POST['comments'];
+$cmds = $_POST['commands'];
+if (get_magic_quotes_gpc()) {
+ $cmds = stripslashes($cmds);
+ $name = stripslashes($name);
+ $comment = stripslashes($comment);
+}
+
+if ($envir > 0) {
+ $link = mysql_connect('127.0.0.1', 'Rbatch', 'Rbatch');
+ if (!$link) { echo "Unable to connect to DB: " . mysql_error(); exit; }
+ if (!mysql_select_db('R')) { echo "Unable to select database: " . mysql_error(); exit; }
+
+ $query = sprintf("INSERT INTO jobs (Status, Queued, Environment, Name, Commands, Comments) VALUES ('Queued', NOW(), %d, '%s', '%s', '%s')",
+ $envir,
+ mysql_real_escape_string($name),
+ mysql_real_escape_string($cmds),
+ mysql_real_escape_string($comment));
+
+ // Perform Query
+ $result = mysql_query($query);
+
+ // Check result
+ // This shows the actual query sent to MySQL, and the error. Useful for debugging.
+ if (!$result) {
+ $message = 'Invalid query: ' . mysql_error() . "\n";
+ $message .= 'Whole query: ' . $query;
+ die($message);
+ }
+
+}
+header("Location: /");
+?>
diff --git a/frontend/prepare.php b/frontend/prepare.php
new file mode 100644
index 0000000..d398a57
--- /dev/null
+++ b/frontend/prepare.php
@@ -0,0 +1,73 @@
+
+$link = mysql_connect('127.0.0.1', 'Rbatch', 'Rbatch');
+if (!$link) { echo "Unable to connect to DB: " . mysql_error(); exit; }
+if (!mysql_select_db('R')) { echo "Unable to select database: " . mysql_error(); exit; }
+
+$id = 1 * $_REQUEST['preload'];
+
+if ($id > 0) {
+ $sql = "SELECT Name, Environment, Commands, Comments FROM jobs WHERE ID = $id";
+ $result = mysql_query($sql);
+ if (!$result) { echo "Could not select jobs" . mysql_error(); exit; }
+ if (mysql_num_rows($result) == 0) { echo "Job not found"; exit; }
+ $preparedata = mysql_fetch_assoc($result);
+ mysql_free_result($result);
+}
+
+?>
+MySQL-RMySQL-R
+
+
+
+
+
+
+
+
diff --git a/frontend/showjob.php b/frontend/showjob.php
new file mode 100644
index 0000000..6840fac
--- /dev/null
+++ b/frontend/showjob.php
@@ -0,0 +1,167 @@
+
+$link = mysql_connect('127.0.0.1', 'Rbatch', 'Rbatch');
+if (!$link) { echo "Unable to connect to DB: " . mysql_error(); exit; }
+if (!mysql_select_db('R')) { echo "Unable to select database: " . mysql_error(); exit; }
+
+$id = 1 * $_REQUEST['ID'];
+
+if ($id < 1) {
+ header('Location: /');
+ exit();
+}
+
+$sql = 'SELECT jobs.*, environment.Name AS EnvName, environment.Commands AS EnvCmd,
+ UNIX_TIMESTAMP(Completed) - UNIX_TIMESTAMP(Started) AS Runtime,
+ UNIx_TIMESTAMP(Started) - UNIX_TIMESTAMP(Queued) AS Queuetime
+ FROM jobs
+ JOIN environment ON (jobs.Environment = environment.ID)
+ WHERE jobs.ID = '. $id;
+
+$result = mysql_query($sql);
+if (!$result) { echo "Could not select jobs" . mysql_error(); exit; }
+if (mysql_num_rows($result) == 0) { echo "No jobs found"; exit; }
+
+$job = mysql_fetch_assoc($result);
+mysql_free_result($result);
+
+?>
+MySQL-RMySQL-R
+
+
+
+
+
+ print '
#'.$job['ID'].' – '.htmlentities($job['Name']).' – '.$job['Status'].'';
+ print '
';
+
+ $job['Queued'] = $job['Queued'] == '' ? '---------- --:--:--' : $job['Queued'];
+ $job['Started'] = $job['Started'] == '' ? '---------- --:--:--' : $job['Started'];
+ $job['Completed'] = $job['Completed'] == '' ? '---------- --:--:--' : $job['Completed'];
+ $job['RetiredDate'] = $job['RetiredDate'] == '' ? '---------- --:--:--' : $job['RetiredDate'];
+
+?>
+
Queued: = $job['Queued'] ?>
Started: = $job['Started'] ?>
Completed: = $job['Completed'] ?>
Retired: = $job['RetiredDate'] ?>
(= $job['Runtime'] ?>s runtime, = $job['Queuetime'] ?>s queuetime)
+
+ if (trim($job['Comments']) != '') {
+ print '';
+ }
+
+ $sql2 = 'SELECT ID, FilenameInternal FROM results WHERE JobID = ' . $job['ID'];
+ $result2 = mysql_query($sql2);
+ if (!$result2) { echo "Could not select results" . mysql_error(); exit; }
+ if (mysql_num_rows($result2) > 0) {
+ print '
';
+ while ($resrow = mysql_fetch_assoc($result2)) {
+ print '
';
+ print '
'.htmlentities($resrow['FilenameInternal']).'
';
+ print '
';
+ print '
[PDF]
';
+ print '
';
+ }
+ print '
';
+ }
+
+ mysql_free_result($result2);
+
+ if (trim($job['Result']) != '') {
+ print '
';
+ print "# Output\n\n";
+ print htmlentities(trim($job['Result']));
+ print '
';
+ }
+
+ if (trim($job['EnvCmd']) != '') {
+ print '
';
+ print '# Environment: '. htmlentities($job['EnvName'])."\n\n";
+ print htmlentities(trim($job['EnvCmd']));
+ print '
';
+ }
+
+ if (trim($job['Commands']) != '') {
+ print '
';
+ print htmlentities(trim($job['Commands']));
+ print '
';
+ }
+
+ print '
';
+
+?>
+