check for installed/configured froxlor in api.php and return 404 if not

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-03-14 18:13:32 +01:00
parent b03d41087a
commit 616fb77de5

View File

@@ -17,6 +17,32 @@
*/
if (! defined('FROXLOR_INSTALL_DIR')) {
define('FROXLOR_INSTALL_DIR', dirname(dirname(dirname(__DIR__))));
// ensure that default timezone is set
if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) {
@date_default_timezone_set(@date_default_timezone_get());
}
$installed = true;
// check whether the userdata file exists
if (! @file_exists(FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php')) {
$installed = false;
}
// check whether we can read the userdata file
if ($installed && ! @is_readable(FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php')) {
$installed = false;
}
if ($installed) {
// include userdata for content-check
require FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php';
if (! isset($sql) || ! is_array($sql)) {
$installed = false;
}
}
// do not try to do anything if we have no installed/configured froxlor
if (! $installed) {
header("Status: 404 Not found", 404);
header($_SERVER["SERVER_PROTOCOL"] . " 404 Not found", 404);
exit();
}
require_once FROXLOR_INSTALL_DIR . '/lib/tables.inc.php';
require_once FROXLOR_INSTALL_DIR . '/lib/functions.php';
}