diff --git a/server/config.inc.php.example b/server/config.inc.php.example new file mode 100644 index 0000000..d55735f --- /dev/null +++ b/server/config.inc.php.example @@ -0,0 +1,10 @@ + array('key1'), + 'ping-get' => array('key2'), + 'update' => array('key3'), +); + +?> diff --git a/server/ping-get.php b/server/ping-get.php index 4199aff..5985715 100644 --- a/server/ping-get.php +++ b/server/ping-get.php @@ -1,13 +1,16 @@ +require_once('config.inc.php'); +$apikeys = $config['ping-get']; + +header('Content-type: text/plain'); +if(isset($_GET['apikey']) && in_array($_GET['apikey'], $apikeys, true)) { + $str=file_get_contents('pinged.txt'); + echo $str; + file_put_contents ( 'pinged.txt' , 'false' ); +} else { + $str=file_get_contents('pinged.txt'); + echo "API Key Missing!\n"; + echo $str; +} +?> diff --git a/server/update.php b/server/update.php index 02aa585..8494869 100755 --- a/server/update.php +++ b/server/update.php @@ -1,22 +1,30 @@ +require_once('config.inc.php'); + +$apikeys = $config['update']; + +header('Content-type: text/plain'); +if( isset($_GET['apikey']) && in_array($_GET['apikey'], $apikeys, true) ) { + if(isset($_GET['open']) && $_GET['open']=='true') + { + file_put_contents ( 'status.txt' , 'true,'.time() ); + exec("./open.sh"); + echo "true"; + } else if(isset($_GET['open']) && $_GET['open'] =='false') { + file_put_contents ( 'status.txt' , 'false,'.time() ); + exec("./close.sh"); + echo "false"; + }else{ + echo "you are too stupid to use the api!\n"; + } +} else { + $str=file_get_contents('status.txt'); + $arr=explode(',',$str); + $open=$arr[0]; + $date=$arr[1]; //lastchange: upadate via file see explode/implode + echo "API Key Missing!\n"; + echo $open; +} + +?>