modified: app.php

new file:   database/sqlite.php
new file:   registration.php
renamed:    module/report/routes.php -> report.php
renamed:    module/update/routes.php -> update.php
This commit is contained in:
Sven Luethi committed 2024-07-03 16:16:46 +02:00
1 parent 96a281ae00
commit 9c2de8aad5
5 files changed
+36 -4

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
<?php
$router->get('/favicon.ico', function() {
http_response_code(404);
});
$router->get('/update', function() {
//(new DumpHTTPRequestToFile)->execute( __DIR__ . '/dumprequest.txt');
if ( $_SERVER['HTTP_USER_AGENT'] == 'ESP8266-http-Update' && isset($_SERVER['HTTP_X_ESP8266_SKETCH_MD5']) ) {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$curr_firmware_md5 = $_SERVER['HTTP_X_ESP8266_SKETCH_MD5'];
$firmware_file = __DIR__ . '/firmware.bin';
$firmware_md5 = md5_file($firmware_file);
echo "USER_AGENT -> ESP8266-http-Update\n";
echo 'X_ESP8266_SKETCH_MD5 -> ' . $_SERVER['HTTP_X_ESP8266_SKETCH_MD5'] . "\n";
echo 'MD5 file hash of ' . $firmware_file . ': ' . $firmware_md5;
if ( $curr_firmware_md5 == $firmware_md5 ) {
http_response_code(204);
}
else {
$fwdata = file_get_contents($firmware_file);
header('Content-Length:' . strlen($fwdata));
echo $fwdata;
http_response_code(200);
}
return;
}
http_response_code(400);
});