diff --git a/web/API/crons.php b/web/API/crons.php index a2b1dfa..d66d61e 100644 --- a/web/API/crons.php +++ b/web/API/crons.php @@ -2,7 +2,8 @@ namespace API\cron; function all($params) { - + tle($params); + autoFail($params); } function tle($params) { @@ -36,4 +37,17 @@ } return $updated; + } + + function autoFail($params) { + $observations = new \wsos\database\core\table(\DAL\observation::class); + $ob = new \DAL\observation(); + + $faild = $observations->query("status==? && startstatus->getVal("assigned"), time() - 300]); + + foreach ($fob in $faild->values) { + $fob->status->set("fail"); + $fob->commit(); + } + } \ No newline at end of file diff --git a/web/API/observations.php b/web/API/observations.php index cdc959b..08f5e7d 100644 --- a/web/API/observations.php +++ b/web/API/observations.php @@ -132,14 +132,26 @@ $adir = __DIR__ . "/../ARTEFACTS/" . $params["id"]; + $fname = basename($params["fname"]); + mkdir($adir, 0777, true); - - $artefacts = $obs->artefacts->get(); - foreach ($_FILES as $file) { - move_uploaded_file($file["tmp_name"], $adir . "/" . $file["name"]); - $artefacts[] = "/ARTEFACTS/{$params['id']}/{$file['name']}"; + + // chunk upload file + if ($params["offset"] == 0) { + // get current artifasts + $artefacts = $obs->artefacts->get(); + + $artefacts[] = "/ARTEFACTS/{$params['id']}/{$fname}"; + + $obs->artefacts->set($artefacts); + $obs->commit(); } - $obs->artefacts->set($artefacts); - $obs->commit(); + // file pointer + $ifp = fopen($adir . "/" . $fname, 'ab'); + + fwrite($ifp, $params["data"]); + + // clean up the file resource + fclose($ifp); }