1
0
Fork 0

Add optional API key for cron, rename entry point

master
Anonymous Contributor 2023-08-27 12:56:12 +02:00
parent ea2fffa872
commit 6c22684b2f
3 changed files with 29 additions and 29 deletions

View File

@ -1,5 +1,5 @@
<?php
$RUNTIME['PDO'] = new PDO('mysql:host=...;dbname=...', '...', '...');
<?php
$RUNTIME['PDO'] = new PDO('mysql:host=...;dbname=...', '...', '...');
$RUNTIME['GRID']['NAME'] = "OpenSim";
$RUNTIME['GRID']['MAIN_NEWS'] = "Yet an other OpenSim Grid.";
@ -24,4 +24,6 @@ $RUNTIME['DOMAIN'] = "mcp.4creative.net";
$RUNTIME['IAR']['BASEURL'] = "https://mcp.4creative.net/data/";
$RUNTIME['PASSWORD_MIN_LENGTH'] = 8;
?>
$RUNTIME['CRON_RESTRICTION'] = 'key';
$RUNTIME['CRON_KEY'] = 'changeme';

24
cron.php Normal file
View File

@ -0,0 +1,24 @@
<?php
$RUNTIME = array();
$RUNTIME['BASEDIR'] = __DIR__;
set_include_path('.:'.$RUNTIME['BASEDIR']);
include_once "config.php";
if(!isset($RUNTIME['CRON_RESTRICTION'])) {
http_response_code(500);
die();
}
if ($RUNTIME['CRON_RESTRICTION'] != 'none' && (!isset($RUNTIME['CRON_KEY']) || !isset($REQUEST['key']) || $_REQUEST['key'] !== $RUNTIME['CRON_KEY'])) {
http_response_code(401);
die();
}
if ($handle = opendir('./cron/')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
include_once "./cron/".$entry;
}
}
closedir($handle);
}

View File

@ -1,26 +0,0 @@
<?php
date_default_timezone_set("Europe/Berlin");
error_reporting(E_ALL);
session_start();
$RUNTIME = array();
$RUNTIME['BASEDIR'] = __DIR__;
set_include_path('.:'.$RUNTIME['BASEDIR']);
include_once("app/utils.php");
include_once("app/HTML.php");
include_once("config.php");
if ($handle = opendir('./cron/'))
{
while (false !== ($entry = readdir($handle)))
{
if ($entry != "." && $entry != "..")
{
include_once "./cron/".$entry;
}
}
closedir($handle);
}
?>