add wiot ota log

master
IoTcat 5 years ago
parent 6da73e7518
commit f89e60e85f
  1. 29
      server/cn/etc/nginx/nginx.conf
  2. 19
      server/cn/home/www/wiot/ota/check.php
  3. 24
      server/cn/home/www/wiot/ota/get.php
  4. BIN
      server/cn/home/www/wiot/ota/wiot.bin

@ -715,6 +715,35 @@ http {
}
}
server {
listen 443 ssl;
listen 80;
server_name wiot.yimian.xyz; #1
root /home/www/wiot;
index index.php index.html;
client_max_body_size 1000M;
ssl_certificate /etc/letsencrypt/live/wiot.yimian.xyz/fullchain.pem; #2
ssl_certificate_key /etc/letsencrypt/live/wiot.yimian.xyz/privkey.pem; #3
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
error_page 404 = /404.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 443 ssl;

@ -0,0 +1,19 @@
<?php
include '../../functions.php';
header('Access-Control-Allow-Origin:*');
$version = $_REQUEST['version'];
if(isset($version)){
if($version != "v0.1.4")
echo json_encode(array("update" => 1));
else
echo json_encode(array('update' => 0));
yimian__log("log_wiot", array("timestamp" => date('Y-m-d H:i:s', time()), "ip" => ip2long(get_ip()), "version" => $version /* 经md5不可逆加密,仅用于区分用户 */));
die();
}
echo "This Page is only for wIoT OTA!!";

@ -0,0 +1,24 @@
<?php
header('Access-Control-Allow-Origin:*');
header('Content-type: text/plain; charset=utf8', true);
sendFile('./wiot.bin');
// Function to send file to ESP8266
function sendFile($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);
}
?>
Loading…
Cancel
Save