From 2574e7a91cc5c8cea119d5221b91b3fedd3e49b5 Mon Sep 17 00:00:00 2001 From: Christian Staudte Date: Wed, 6 May 2020 21:24:25 +0200 Subject: [PATCH] add php files --- arduino-download.php | 59 ++++++++++++++++++++++++++++++++++++++++++++ arduino-upload.php | 53 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 arduino-download.php create mode 100644 arduino-upload.php diff --git a/arduino-download.php b/arduino-download.php new file mode 100644 index 0000000..6540d81 --- /dev/null +++ b/arduino-download.php @@ -0,0 +1,59 @@ += 1) { + $newest = $filenames[$num - 1]; + if (preg_match('/\/(\d+).bin$/', $newest, $matches)) { + $server_version = $matches[1]; + if ((int) $server_version > (int) $version) { + $path = $newest; + } + } + } +} + +if ($path) { + header($_SERVER["SERVER_PROTOCOL"].' 200 OK', true, 200); + header('Content-Type: application/octet-stream', true); + header('Content-Disposition: attachment; filename='.basename($path)); + header('Content-Length: '.filesize($path), true); + header('x-MD5: '.md5_file($path), true); + readfile($path); +} else { + header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified', true, 304); +} + +?> \ No newline at end of file diff --git a/arduino-upload.php b/arduino-upload.php new file mode 100644 index 0000000..4d04ac8 --- /dev/null +++ b/arduino-upload.php @@ -0,0 +1,53 @@ + \ No newline at end of file