From 7c961647704c61c9605253af6555375f3bc2c72a Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Fri, 16 Feb 2018 15:39:59 +0100 Subject: [PATCH] fix lng availability; add returncode for not-found messages Signed-off-by: Michael Kaufmann (d00p) --- admin_customers.php | 19 +++++++++---------- lib/classes/api/abstract.ApiCommand.php | 8 +++++--- lib/classes/api/commands/class.Customers.php | 2 +- lib/classes/api/commands/class.Domains.php | 2 +- .../api/commands/class.IpsAndPorts.php | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/admin_customers.php b/admin_customers.php index 7e0aae18..fc53871b 100644 --- a/admin_customers.php +++ b/admin_customers.php @@ -343,22 +343,21 @@ if ($page == 'customers' && $id != 0 ) { - $result_data = array('id' => $id); - $result_stmt = Database::prepare(" - SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` - WHERE `customerid` = :id" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid") - ); - if ($userinfo['customers_see_all'] == '0') { - $result_data['adminid'] = $userinfo['adminid']; + try { + $json_result = Customers::getLocal($userinfo, array( + 'id' => $id + ))->get(); + } catch (Exception $e) { + dynamic_error($e->getMessage()); } - $result = Database::pexecute_first($result_stmt, $result_data); + $result = json_decode($json_result, true)['data']; /* * information for moving customer */ $available_admins_stmt = Database::prepare(" - SELECT * FROM `" . TABLE_PANEL_ADMINS . "` - WHERE (`customers` = '-1' OR `customers` > `customers_used`)" + SELECT * FROM `" . TABLE_PANEL_ADMINS . "` + WHERE (`customers` = '-1' OR `customers` > `customers_used`)" ); Database::pexecute($available_admins_stmt); $admin_select = makeoption("-----", 0, true, true, true); diff --git a/lib/classes/api/abstract.ApiCommand.php b/lib/classes/api/abstract.ApiCommand.php index 5ad847b3..25fa60f0 100644 --- a/lib/classes/api/abstract.ApiCommand.php +++ b/lib/classes/api/abstract.ApiCommand.php @@ -29,16 +29,18 @@ abstract class ApiCommand throw new Exception("Invalid user data", 500); } $this->logger = FroxlorLogger::getInstanceOf($this->user_data); - if ($this->debug) { - $this->logger()->logAction(LOG_ERROR, LOG_DEBUG, json_encode($params, JSON_UNESCAPED_SLASHES)); - } $this->initLang(); $this->initMail(); + + if ($this->debug) { + $this->logger()->logAction(LOG_ERROR, LOG_DEBUG, "[API] ".get_called_class().": ".json_encode($params, JSON_UNESCAPED_SLASHES)); + } } private function initLang() { + global $lng; // query the whole table $result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_LANGUAGE . "`"); diff --git a/lib/classes/api/commands/class.Customers.php b/lib/classes/api/commands/class.Customers.php index 84525d0c..eb1b1085 100644 --- a/lib/classes/api/commands/class.Customers.php +++ b/lib/classes/api/commands/class.Customers.php @@ -50,7 +50,7 @@ class Customers extends ApiCommand if ($result) { return $this->response(200, "successfull", $result); } - throw new Exception("Customer with id #" . $id . " could not be found"); + throw new Exception("Customer with id #" . $id . " could not be found", 404); } throw new Exception("Not allowed to execute given command.", 403); } diff --git a/lib/classes/api/commands/class.Domains.php b/lib/classes/api/commands/class.Domains.php index ed5db265..2d0eb4dd 100644 --- a/lib/classes/api/commands/class.Domains.php +++ b/lib/classes/api/commands/class.Domains.php @@ -54,7 +54,7 @@ class Domains extends ApiCommand if ($result) { return $this->response(200, "successfull", $result); } - throw new Exception("Domain with id #" . $id . " could not be found"); + throw new Exception("Domain with id #" . $id . " could not be found", 404); } throw new Exception("Not allowed to execute given command.", 403); } diff --git a/lib/classes/api/commands/class.IpsAndPorts.php b/lib/classes/api/commands/class.IpsAndPorts.php index 94d27115..f0b9d8e1 100644 --- a/lib/classes/api/commands/class.IpsAndPorts.php +++ b/lib/classes/api/commands/class.IpsAndPorts.php @@ -37,7 +37,7 @@ class IpsAndPorts extends ApiCommand if ($result) { return $this->response(200, "successfull", $result); } - throw new Exception("IP/port with id #" . $id . " could not be found"); + throw new Exception("IP/port with id #" . $id . " could not be found", 404); } throw new Exception("Not allowed to execute given command.", 403); }