From 243b68cc371a8d4fa83dff58e0724336f40795ff Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Sun, 25 Feb 2018 11:47:28 +0100 Subject: [PATCH] minor changes for testing Signed-off-by: Michael Kaufmann (d00p) --- api.php | 10 ++++++---- lib/classes/api/abstract.ApiCommand.php | 16 +++++++++------- lib/classes/api/commands/class.Ftps.php | 2 +- lib/functions.php | 5 +++++ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/api.php b/api.php index 6dc25ff3..db419d30 100644 --- a/api.php +++ b/api.php @@ -54,11 +54,13 @@ exit(); */ function json_response($status, $status_message = '', $data = null) { - $resheader = $_SERVER["SERVER_PROTOCOL"] . " " . $status; - if (! empty($status_message)) { - $resheader .= ' ' . str_replace("\n", " ", $status_message); + if (isset($_SERVER["SERVER_PROTOCOL"]) && ! empty($_SERVER["SERVER_PROTOCOL"])) { + $resheader = $_SERVER["SERVER_PROTOCOL"] . " " . $status; + if (! empty($status_message)) { + $resheader .= ' ' . str_replace("\n", " ", $status_message); + } + header($resheader); } - header($resheader); $response['status'] = $status; $response['status_message'] = $status_message; diff --git a/lib/classes/api/abstract.ApiCommand.php b/lib/classes/api/abstract.ApiCommand.php index 8ce98e8d..82fd38c8 100644 --- a/lib/classes/api/abstract.ApiCommand.php +++ b/lib/classes/api/abstract.ApiCommand.php @@ -116,7 +116,7 @@ abstract class ApiCommand throw new Exception("Invalid user data", 500); } $this->logger = FroxlorLogger::getInstanceOf($this->user_data); - + // check whether the user is deactivated if ($this->getUserDetail('deactivated') == 1) { $this->logger()->logAction(LOG_ERROR, LOG_INFO, "[API] User '" . $this->getUserDetail('loginnname') . "' tried to use API but is deactivated"); @@ -161,13 +161,13 @@ abstract class ApiCommand // include every english language file we can get foreach ($langs['English'] as $key => $value) { - include_once makeSecurePath($value['file']); + include_once makeSecurePath(FROXLOR_INSTALL_DIR . '/' . $value['file']); } // now include the selected language if its not english if ($language != 'English') { foreach ($langs[$language] as $key => $value) { - include_once makeSecurePath($value['file']); + include_once makeSecurePath(FROXLOR_INSTALL_DIR . '/' . $value['file']); } } @@ -400,11 +400,13 @@ abstract class ApiCommand */ protected function response($status, $status_message, $data = null) { - $resheader = $_SERVER["SERVER_PROTOCOL"] . " " . $status; - if (! empty($status_message)) { - $resheader .= ' ' . str_replace("\n", " ", $status_message); + if (isset($_SERVER["SERVER_PROTOCOL"]) && ! empty($_SERVER["SERVER_PROTOCOL"])) { + $resheader = $_SERVER["SERVER_PROTOCOL"] . " " . $status; + if (! empty($status_message)) { + $resheader .= ' ' . str_replace("\n", " ", $status_message); + } + header($resheader); } - header($resheader); $response['status'] = $status; $response['status_message'] = $status_message; diff --git a/lib/classes/api/commands/class.Ftps.php b/lib/classes/api/commands/class.Ftps.php index 6b27c3fb..352302e3 100644 --- a/lib/classes/api/commands/class.Ftps.php +++ b/lib/classes/api/commands/class.Ftps.php @@ -45,7 +45,7 @@ class Ftps extends ApiCommand implements ResourceEntity $params = array(); if ($this->isAdmin()) { - if ($this->getUserDetail('customers_see_all') != 1) { + if ($this->getUserDetail('customers_see_all') == false) { // if it's a reseller or an admin who cannot see all customers, we need to check // whether the database belongs to one of his customers $json_result = Customers::getLocal($this->getUserData())->list(); diff --git a/lib/functions.php b/lib/functions.php index ebfd5bb6..5a15cac8 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -100,6 +100,11 @@ class Autoloader { return true; } + // don't load anything from a namespace, it's not our responsibility + if (strpos($class, "\\") !== false) { + return true; + } + // now iterate through the paths foreach ($paths as $path) { // valid directory?