summaryrefslogtreecommitdiffstats
path: root/api.php
diff options
context:
space:
mode:
authorSimon Rettberg2014-10-16 10:49:00 +0200
committerSimon Rettberg2014-10-16 10:49:00 +0200
commita962e860b5082a7c03db574b3971c80e2548c41c (patch)
tree0bcde43421644e496ef60d452337cbf52305041d /api.php
parentAvoid ID 0 for cat_settings pk (diff)
downloadslx-admin-a962e860b5082a7c03db574b3971c80e2548c41c.tar.gz
slx-admin-a962e860b5082a7c03db574b3971c80e2548c41c.tar.xz
slx-admin-a962e860b5082a7c03db574b3971c80e2548c41c.zip
Do a chdir in api.php to the script dir to simplify cmdline calls
Diffstat (limited to 'api.php')
-rw-r--r--api.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/api.php b/api.php
index 289a17f1..faf6bed0 100644
--- a/api.php
+++ b/api.php
@@ -1,15 +1,19 @@
<?php
error_reporting(E_ALL);
+chdir(dirname($_SERVER['SCRIPT_FILENAME']));
require_once 'config.php';
// Autoload classes from ./inc which adhere to naming scheme <lowercasename>.inc.php
-function slxAutoloader($class) {
+function slxAutoloader($class)
+{
$file = 'inc/' . preg_replace('/[^a-z0-9]/', '', mb_strtolower($class)) . '.inc.php';
- if (!file_exists($file)) return;
+ if (!file_exists($file))
+ return;
require_once $file;
}
+
spl_autoload_register('slxAutoloader');
function isLocalExecution()
@@ -17,7 +21,6 @@ function isLocalExecution()
return !isset($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] === '127.0.0.1';
}
-
if (!empty($_REQUEST['do'])) {
$module = preg_replace('/[^a-z]/', '', $_REQUEST['do']);
} elseif (!empty($argv[1])) {
@@ -25,7 +28,6 @@ if (!empty($_REQUEST['do'])) {
} else {
// No specific module - set default
$module = 'main';
-
}
$module = 'apis/' . $module . '.inc.php';