aboutsummaryrefslogtreecommitdiffstats
path: root/toj/php/status.php
diff options
context:
space:
mode:
Diffstat (limited to 'toj/php/status.php')
-rw-r--r--toj/php/status.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/toj/php/status.php b/toj/php/status.php
new file mode 100644
index 0000000..5c00580
--- /dev/null
+++ b/toj/php/status.php
@@ -0,0 +1,70 @@
+<?php
+ini_set("display_errors", "On");
+error_reporting(E_ALL & ~E_NOTICE);
+
+require_once('status.inc.php');
+
+$sqlc = db_connect();
+
+$action = $_POST['action'];
+$data = $_POST['data'];
+
+if(strlen($action)==0)
+ die('Eno_action');
+if($action == 'get_submit')
+{
+ //get submit from submit table
+ //data: sort, sort->subid, count, [wait, filter, last_update]
+ $dt = json_decode($data);
+ if($dt->sort->subid == null)
+ die('Eno_sort_subid');
+ if($dt->count == null)
+ die('Eno_count');
+ $cnt = intval($dt->count);
+ if($cnt <= 0)
+ die('Etoo_few_count');
+ if($cnt > SUBMIT_COUNT_MAX)
+ die('Etoo_many_count');
+
+ $wait = intval($dt->wait);
+ if($wait > SUBMIT_WAIT_MAX)
+ die('Etoo_many_wait');
+
+ $nowwait = $wait;
+ $isadm = sec_check_level($sqlc, USER_PER_PROADMIN);
+
+ while(1)
+ {
+ $ret = status::get_submit($sqlc, $dt->filter, $dt->sort, $cnt, $dt->last_update, $isadm);
+ if($ret != null)
+ {
+ /* OUTPUT */
+ echo(json_encode($ret));
+ exit(0);
+ }
+ //die('Efail');
+ $nowwait--;
+ if($nowwait<0)break;
+ sleep(SUBMIT_SLEEP_TIME);
+ }
+ die('Eno_result');
+}
+if($action == 'get_by_subid')
+{
+ //get submission data and smodname by subid.
+ //problem must be available for the user.
+ //data: subid
+ $dt = json_decode($data);
+ $subid = intval($dt->subid);
+ if(!$subid)
+ die('Eno_subid');
+ $obj = status::get_by_subid($sqlc, $subid);
+
+ if(!problem::is_available($sqlc, $obj->proid))
+ die('Epermission_denied');
+
+ echo(json_encode($obj));
+}
+
+db_close($sqlc);
+?>