You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
871 B
45 lines
871 B
<?php
|
|
|
|
header("X-Accel-Buffering: no");
|
|
header('Content-Type: text/event-stream');
|
|
header('Cache-Control: no-cache');
|
|
header('Connection: keep-alive');
|
|
|
|
ignore_user_abort(true);
|
|
|
|
function sendEvent(string $event, string $data): void{
|
|
if (php_sapi_name() === 'cli')
|
|
return;
|
|
echo "event: $event\n";
|
|
echo "data: $data\n\n";
|
|
ob_flush();
|
|
flush();
|
|
}
|
|
|
|
|
|
require_once __DIR__."/../util/mysql_connect.php";
|
|
$conn = new MySQLConnection();
|
|
|
|
$result = $conn->query("
|
|
SELECT date
|
|
FROM updates
|
|
WHERE date > SUBTIME(NOW(), '00:10:00')
|
|
LIMIT 1
|
|
");
|
|
if ($result->num_rows > 0) {
|
|
sendEvent("forbidden", $result->fetch_assoc()["date"]);
|
|
die;
|
|
}
|
|
|
|
$conn->query("INSERT INTO updates VALUES ()");
|
|
|
|
require_once __DIR__."/Tracker.php";
|
|
|
|
sendEvent("progress", 0);
|
|
|
|
$tracker = new Tracker();
|
|
$tracker->update(function($value){
|
|
sendEvent('progress', $value);
|
|
});
|
|
|
|
sendEvent("done", "");
|
|
|