unix mode

This commit is contained in:
john30
2017-03-05 13:14:38 +01:00
parent f3a0f9be47
commit 5a23e5c13a
2 changed files with 40 additions and 40 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
version=`head -n 1 VERSION` version=`head -n 1 VERSION`
revision=`git describe --always` revision=`git describe --always`
echo "ebusd=${version}.${revision}" echo "ebusd=${version}.${revision}" > versions.txt
#TODO add calculation for config files #TODO add calculation for config files
+39 -39
View File
@@ -1,39 +1,39 @@
<?php <?php
$agent = $_SERVER['HTTP_USER_AGENT']; $agent = $_SERVER['HTTP_USER_AGENT'];
if (substr($agent, 0, 5)==='ebusd') { if (substr($agent, 0, 5)==='ebusd') {
$t = time(); $t = time();
$a = $_SERVER["REMOTE_ADDR"]; $a = $_SERVER["REMOTE_ADDR"];
$r = @file_get_contents('php://input'); $r = @file_get_contents('php://input');
$v = @file_get_contents('versions.txt'); $v = @file_get_contents('versions.txt');
$versions = array(); $versions = array();
if ($v) { if ($v) {
$v = explode("\n", $v); $v = explode("\n", $v);
$func = function($val, $k) { $func = function($val, $k) {
global $versions; global $versions;
$val = explode('=', $val); $val = explode('=', $val);
if (count($val)>1) { if (count($val)>1) {
$versions[$val[0]] = explode(',', $val[1]); $versions[$val[0]] = explode(',', $val[1]);
} }
}; };
array_walk($v, $func); array_walk($v, $func);
} }
header('Content-Type: text/plain'); header('Content-Type: text/plain');
$ret = 'unknown'; $ret = 'unknown';
$r = @json_decode($r, true); $r = @json_decode($r, true);
if (!$r || !isset($r['v'])) { if (!$r || !isset($r['v'])) {
$ret = 'invalid request'; $ret = 'invalid request';
} else { } else {
if (isset($versions['ebusd'])) { if (isset($versions['ebusd'])) {
if ($r['v']==$versions['ebusd'][0]) { if ($r['v']==$versions['ebusd'][0]) {
$ret = 'OK'; $ret = 'OK';
} else { } else {
$ret = 'ebusd '.$versions['ebusd'][0].' available'; $ret = 'ebusd '.$versions['ebusd'][0].' available';
} }
} }
// TODO add check for config files // TODO add check for config files
} }
echo $ret; echo $ret;
exit; exit;
} }
header('HTTP/1.1 404 Not Found'); header('HTTP/1.1 404 Not Found');
?> ?>