Move apikeys to config file
This commit is contained in:
parent
82eef68a1c
commit
cf570fdeea
3 changed files with 52 additions and 31 deletions
10
server/config.inc.php.example
Normal file
10
server/config.inc.php.example
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// api-keys
|
||||||
|
$config = array(
|
||||||
|
'ping' => array('key1'),
|
||||||
|
'ping-get' => array('key2'),
|
||||||
|
'update' => array('key3'),
|
||||||
|
);
|
||||||
|
|
||||||
|
?>
|
|
@ -1,13 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
header('Content-type: text/plain');
|
require_once('config.inc.php');
|
||||||
if(isset($_GET['apikey']) && ($_GET['apikey']=='apikey1' || $_GET['apikey']=='apikey2')){
|
|
||||||
|
$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');
|
$str=file_get_contents('pinged.txt');
|
||||||
echo $str;
|
echo $str;
|
||||||
file_put_contents ( 'pinged.txt' , 'false' );
|
file_put_contents ( 'pinged.txt' , 'false' );
|
||||||
}else{
|
} else {
|
||||||
$str=file_get_contents('pinged.txt');
|
$str=file_get_contents('pinged.txt');
|
||||||
echo "API Key Missing!\n";
|
echo "API Key Missing!\n";
|
||||||
echo $str;
|
echo $str;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
header('Content-type: text/plain');
|
|
||||||
if(isset($_GET['apikey']) && ($_GET['apikey']=='apikey1' || $_GET['apikey']=='apikey2')){
|
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')
|
if(isset($_GET['open']) && $_GET['open']=='true')
|
||||||
{
|
{
|
||||||
file_put_contents ( 'status.txt' , 'true,'.time() );
|
file_put_contents ( 'status.txt' , 'true,'.time() );
|
||||||
|
exec("./open.sh");
|
||||||
echo "true";
|
echo "true";
|
||||||
}else if(isset($_GET['open']) && $_GET['open'] =='false')
|
} else if(isset($_GET['open']) && $_GET['open'] =='false') {
|
||||||
{
|
|
||||||
file_put_contents ( 'status.txt' , 'false,'.time() );
|
file_put_contents ( 'status.txt' , 'false,'.time() );
|
||||||
|
exec("./close.sh");
|
||||||
echo "false";
|
echo "false";
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
|
echo "you are too stupid to use the api!\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$str=file_get_contents('status.txt');
|
$str=file_get_contents('status.txt');
|
||||||
$arr=explode(',',$str);
|
$arr=explode(',',$str);
|
||||||
$open=$arr[0];
|
$open=$arr[0];
|
||||||
$date=$arr[1]; //lastchange: upadate via file see explode/implode
|
$date=$arr[1]; //lastchange: upadate via file see explode/implode
|
||||||
echo "API Key Missing!\n";
|
echo "API Key Missing!\n";
|
||||||
echo $open;
|
echo $open;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
Reference in a new issue