parent
9a0d062b4d
commit
3db210ac39
2 changed files with 42 additions and 2 deletions
@ -1,6 +1,43 @@ |
||||
<?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{ |
||||
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(); |
||||
$tracker->update(function($value){ |
||||
sendEvent('progress', $value); |
||||
}); |
||||
|
||||
sendEvent("done", ""); |
||||
|
Loading…
Reference in new issue