| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- /**
- * Serves the current client script (timekeeperLocal.php) for the students'
- * machines to download:
- *
- * wget -O .timekeeper.php "https://overlord.pfip.au/e107_plugins/timekeeper/localUpdater.php"
- *
- * Changes from the current repo version:
- * - ob_clean() raised a notice when no output buffer was active; if
- * display_errors was on, that text was prepended to the download and
- * pushed the "#!/bin/php" line off line 1 (so the script could no longer
- * be run directly). It only cleans a buffer that exists now
- * - the file is found next to this script, not relative to the working directory
- * - a missing file now answers 404 instead of an empty 200
- * - Cache-Control: no-store, so clients always get the newest version
- */
- $file = __DIR__ . '/timekeeperLocal.php';
- if (!is_file($file)) {
- http_response_code(404);
- exit;
- }
- while (ob_get_level() > 0) {
- ob_end_clean();
- }
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename=' . basename($file));
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: no-store, must-revalidate');
- header('Pragma: no-cache');
- header('Content-Length: ' . filesize($file));
- readfile($file);
- exit;
|