Compare commits

..

No commits in common. "a8bbdf907a10e4ce0dd9cb1017fc749df6d12138" and "82eef68a1c01027e01c2dd42686bbe71550682c3" have entirely different histories.

4 changed files with 41 additions and 67 deletions

View file

@ -1,10 +0,0 @@
<?php
// api-keys
$config = array(
'ping' => array('key1'),
'ping-get' => array('key2'),
'update' => array('key3'),
);
?>

View file

@ -1,16 +1,13 @@
<?php
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;
}
header('Content-type: text/plain');
if(isset($_GET['apikey']) && ($_GET['apikey']=='apikey1' || $_GET['apikey']=='apikey2')){
$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;
}
?>

View file

@ -1,17 +1,12 @@
<?php
require_once('config.inc.php');
$apikeys = $config['ping'];
header('Content-type: text/plain');
if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
isset($_GET['apikey']) && in_array($_GET['apikey'], $apikeys, true))
{
file_put_contents ( 'pinged.txt' , 'true' );
echo $str;
} else {
$str=file_get_contents('pinged.txt');
echo "API Key Missing (must be POST method)!\n";
echo $str;
}
header('Content-type: text/plain');
if(isset($_GET['apikey']) && ($_GET['apikey']=='apikey1' || $_GET['apikey']=='apikey2')){
file_put_contents ( 'pinged.txt' , 'true' );
echo true;
}else{
$str=file_get_contents('pinged.txt');
echo "API Key Missing!\n";
echo $str;
}
?>

View file

@ -1,30 +1,22 @@
<?php
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;
}
header('Content-type: text/plain');
if(isset($_GET['apikey']) && ($_GET['apikey']=='apikey1' || $_GET['apikey']=='apikey2')){
if(isset($_GET['open']) && $_GET['open']=='true')
{
file_put_contents ( 'status.txt' , 'true,'.time() );
echo "true";
}else if(isset($_GET['open']) && $_GET['open'] =='false')
{
file_put_contents ( 'status.txt' , 'false,'.time() );
echo "false";
}
}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;
}
?>