diff --git a/pub/api/classes/API.php b/pub/api/classes/API.php index 21da535..4e6e791 100644 --- a/pub/api/classes/API.php +++ b/pub/api/classes/API.php @@ -6,8 +6,8 @@ use JetBrains\PhpStorm\NoReturn; class API { - public $conn; - public $pdo; + public mixed $conn; + public mixed $pdo; # The user uuid that requested the API protected $user_uuid; @@ -21,7 +21,7 @@ class API protected $content_type; # The original posted data to the API, this data is NOT sanitized and validated, never use this data for queries! - public $postedData; + public mixed $postedData; # The validated and sanitized data can be uses for the API actions public $data; @@ -32,7 +32,7 @@ class API # The return url that the frontend request will forward to after the api call is done. if set to false it will only output # the json response with an http code. API calls always respond with json. $return_url can be set to supply the form with an input # with the name _return and value of the url to return to. - public $return_url; + public mixed $return_url; # Used for the query builder base public $baseQuery = false; @@ -46,8 +46,8 @@ class API public function __construct() { - require_once $_SERVER['DOCUMENT_ROOT'] . '/bin/php/db_connect.php'; - include_once $_SERVER['DOCUMENT_ROOT'] . '/bin/php/Functions/globalFunctions.php'; + require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/php/db_connect.php"; + require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/php/Functions/globalFunctions.php"; # Setup Database connection $this->conn = $GLOBALS['conn']; @@ -100,7 +100,7 @@ class API } - private function InitUserTypeFrontend() + private function InitUserTypeFrontend(): void { $this->user_uuid = $_SESSION['user']['user_uuid']; $this->user_type = 'frontend'; @@ -265,8 +265,11 @@ class API { switch ($rules['type']) { case 'string': + case 'password': + case 'html': if (!is_string($value)) return false; return $this->isValidLength($value, $rules); + case 'slugify': if (!is_string($value) || !preg_match('/^[a-z0-9]+(-[a-z0-9]+)*$/', $value)) return false; return $this->isValidLength($value, $rules); @@ -290,14 +293,6 @@ class API if (!filter_var($value, FILTER_VALIDATE_EMAIL)) return false; return $this->isValidLength($value, $rules); - case 'password': - if (!is_string($value)) return false; - return $this->isValidLength($value, $rules); - - case 'html': - if (!is_string($value)) return false; - return $this->isValidLength($value, $rules); - case 'int': if (!is_int($value) && !ctype_digit($value)) return false; $value = (int)$value; diff --git a/pub/api/classes/API_inserve.php b/pub/api/classes/API_inserve.php index 9edda0e..b399a13 100644 --- a/pub/api/classes/API_inserve.php +++ b/pub/api/classes/API_inserve.php @@ -10,13 +10,13 @@ require_once 'API.php'; class API_inserve extends API { - private $inserve_url; + private string $inserve_url; - private $inserve_token; + private string $inserve_token; - public $inserve_source_uuid; + public string $inserve_source_uuid; - public $inserve_custom_data; + public array $inserve_custom_data; private $ch; diff --git a/pub/api/classes/API_users.php b/pub/api/classes/API_users.php index f7d6aa3..da3ec9f 100644 --- a/pub/api/classes/API_users.php +++ b/pub/api/classes/API_users.php @@ -8,7 +8,7 @@ use bin\php\Classes\mailBuilder; use JetBrains\PhpStorm\NoReturn; require_once 'API.php'; -require_once $_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/mailBuilder.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/php/Classes/mailBuilder.php"; class API_users extends API { diff --git a/pub/api/classes/API_usersavatar.php b/pub/api/classes/API_usersavatar.php index cad8ff0..34772aa 100644 --- a/pub/api/classes/API_usersavatar.php +++ b/pub/api/classes/API_usersavatar.php @@ -32,7 +32,7 @@ class API_usersavatar extends API user_profile_picture_thumbnail = ? WHERE user_uuid = ?"; - $stmt = $stmt = $this->prepareStatement($query); + $stmt = $this->prepareStatement($query); $stmt->bind_param("sss", $this->data['user_profile_picture'], $this->data['user_profile_picture_thumbnail'], diff --git a/pub/api/classes/imageProcessor.php b/pub/api/classes/imageProcessor.php index 24e9bb5..cb010c2 100644 --- a/pub/api/classes/imageProcessor.php +++ b/pub/api/classes/imageProcessor.php @@ -115,7 +115,7 @@ class imageProcessor return in_array($mime, ['image/png', 'image/webp']); } - private function setTransparentCanvas($image, $width, $height) + private function setTransparentCanvas($image, $width, $height): void { // Enable alpha blending and preserve alpha channel imagealphablending($image, false); @@ -125,7 +125,6 @@ class imageProcessor $transparent = imagecolorallocatealpha($image, 0, 0, 0, 127); imagefilledrectangle($image, 0, 0, $width, $height, $transparent); - return $image; } private function resizeToFitRestrictions($mime, $width, $height) diff --git a/pub/api/v1/autop/devices/files/index.php b/pub/api/v1/autop/devices/files/index.php index 1627776..f4b4377 100644 --- a/pub/api/v1/autop/devices/files/index.php +++ b/pub/api/v1/autop/devices/files/index.php @@ -3,7 +3,7 @@ use api\classes\API_devices; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_devices.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_devices.php"; $API_devices = new API_devices(); diff --git a/pub/api/v1/autop/devices/index.php b/pub/api/v1/autop/devices/index.php index d32b11e..2f4a926 100644 --- a/pub/api/v1/autop/devices/index.php +++ b/pub/api/v1/autop/devices/index.php @@ -3,8 +3,8 @@ use api\classes\API_devices; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_devices.php'; -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/imageProcessor.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_devices.php"; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/imageProcessor.php"; $API_devices = new API_devices(); diff --git a/pub/api/v1/autop/platforms/index.php b/pub/api/v1/autop/platforms/index.php index 6842247..c03e683 100644 --- a/pub/api/v1/autop/platforms/index.php +++ b/pub/api/v1/autop/platforms/index.php @@ -4,8 +4,8 @@ use api\classes\API_platforms; use api\classes\imageProcessor; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_platforms.php'; -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/imageProcessor.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_platforms.php"; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/imageProcessor.php"; $API_platforms = new API_platforms(); diff --git a/pub/api/v1/autop/vendors/index.php b/pub/api/v1/autop/vendors/index.php index 251536a..705e376 100644 --- a/pub/api/v1/autop/vendors/index.php +++ b/pub/api/v1/autop/vendors/index.php @@ -4,8 +4,8 @@ use api\classes\API_vendors; use api\classes\imageProcessor; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_vendors.php'; -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/imageProcessor.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_vendors.php"; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/imageProcessor.php"; $API_vendors = new API_vendors(); diff --git a/pub/api/v1/customers/companies/activate/index.php b/pub/api/v1/customers/companies/activate/index.php index efdea98..ae01c10 100644 --- a/pub/api/v1/customers/companies/activate/index.php +++ b/pub/api/v1/customers/companies/activate/index.php @@ -4,7 +4,7 @@ use api\classes\API_companies; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_companies.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_companies.php"; # Check permissions $API_companies = new API_companies(); diff --git a/pub/api/v1/portal-management/group-permissions/index.php b/pub/api/v1/portal-management/group-permissions/index.php index 6b52289..48555bc 100644 --- a/pub/api/v1/portal-management/group-permissions/index.php +++ b/pub/api/v1/portal-management/group-permissions/index.php @@ -4,8 +4,8 @@ use api\classes\API_permissions; use api\classes\API_usergroups; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php'; -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usergroups.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_permissions.php"; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_usergroups.php"; $API_permissions = new API_permissions(); $API_usergroups = new API_usergroups(); diff --git a/pub/api/v1/portal-management/mail/test/index.php b/pub/api/v1/portal-management/mail/test/index.php index a38d80d..3f0397c 100644 --- a/pub/api/v1/portal-management/mail/test/index.php +++ b/pub/api/v1/portal-management/mail/test/index.php @@ -4,8 +4,8 @@ use api\classes\API_mailsettings; use bin\php\Classes\mailBuilder; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_mailsettings.php'; -require_once $_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/mailBuilder.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_mailsettings.php"; +require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/php/Classes/mailBuilder.php"; $API_mailsettings = new API_mailsettings(); diff --git a/pub/api/v1/portal-management/modules/index.php b/pub/api/v1/portal-management/modules/index.php index be1a9a9..221be9b 100644 --- a/pub/api/v1/portal-management/modules/index.php +++ b/pub/api/v1/portal-management/modules/index.php @@ -3,7 +3,7 @@ use api\classes\API_system_modules; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_modules.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_system_modules.php"; $API_system_modules = new API_system_modules(); diff --git a/pub/api/v1/portal-management/permissions/index.php b/pub/api/v1/portal-management/permissions/index.php index 3ffbc34..41181d5 100644 --- a/pub/api/v1/portal-management/permissions/index.php +++ b/pub/api/v1/portal-management/permissions/index.php @@ -4,7 +4,7 @@ use api\classes\API_permissions; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_permissions.php"; $API_permissions = new API_permissions(); diff --git a/pub/api/v1/portal-management/sources/inserve/index.php b/pub/api/v1/portal-management/sources/inserve/index.php index 47d31f0..52c6c99 100644 --- a/pub/api/v1/portal-management/sources/inserve/index.php +++ b/pub/api/v1/portal-management/sources/inserve/index.php @@ -3,7 +3,7 @@ use api\classes\API_system_sources; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_sources.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_system_sources.php"; $API_system_sources = new API_system_sources(); diff --git a/pub/api/v1/portal-management/user-groups/index.php b/pub/api/v1/portal-management/user-groups/index.php index 8402bbc..7338fd6 100644 --- a/pub/api/v1/portal-management/user-groups/index.php +++ b/pub/api/v1/portal-management/user-groups/index.php @@ -3,7 +3,7 @@ use api\classes\API_usergroups; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usergroups.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_usergroups.php"; $API_usergroups = new API_usergroups(); diff --git a/pub/api/v1/portal-management/users/index.php b/pub/api/v1/portal-management/users/index.php index 6152c9e..d9e45d4 100644 --- a/pub/api/v1/portal-management/users/index.php +++ b/pub/api/v1/portal-management/users/index.php @@ -3,7 +3,7 @@ use api\classes\API_users; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_users.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_users.php"; $API_users = new API_users(); diff --git a/pub/api/v1/servers/index.php b/pub/api/v1/servers/index.php index 308b8db..b0feb7f 100644 --- a/pub/api/v1/servers/index.php +++ b/pub/api/v1/servers/index.php @@ -4,7 +4,7 @@ use api\classes\API_servers; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_servers.php"; $API_servers = new API_servers(); diff --git a/pub/api/v1/sources/inserve/index.php b/pub/api/v1/sources/inserve/index.php index 26c9a2e..92eb53a 100644 --- a/pub/api/v1/sources/inserve/index.php +++ b/pub/api/v1/sources/inserve/index.php @@ -4,7 +4,7 @@ use api\classes\API_inserve; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_inserve.php"; $API_inserve = new API_inserve(); $API_inserve->setupConnection(); diff --git a/pub/api/v1/sources/inserve/sync-cloud-distributor/index.php b/pub/api/v1/sources/inserve/sync-cloud-distributor/index.php index 5370d16..eda868b 100644 --- a/pub/api/v1/sources/inserve/sync-cloud-distributor/index.php +++ b/pub/api/v1/sources/inserve/sync-cloud-distributor/index.php @@ -4,7 +4,7 @@ use api\classes\API_inserve; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_inserve.php"; $API_inserve = new API_inserve(); diff --git a/pub/api/v1/sources/inserve/sync-companies/index.php b/pub/api/v1/sources/inserve/sync-companies/index.php index 295f0bd..3de0473 100644 --- a/pub/api/v1/sources/inserve/sync-companies/index.php +++ b/pub/api/v1/sources/inserve/sync-companies/index.php @@ -4,7 +4,7 @@ use api\classes\API_inserve; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_inserve.php"; $API_inserve = new API_inserve(); $API_inserve->setupConnection(); @@ -20,7 +20,7 @@ if ($API_inserve->request_method === 'POST' || $API_inserve->request_method === do { $result = $API_inserve->companies($page); - if (!isset($result['data']) || empty($result['data'])) { + if (empty($result['data'])) { break; } diff --git a/pub/api/v1/sources/inserve/sync-server-licenses/index.php b/pub/api/v1/sources/inserve/sync-server-licenses/index.php index 2d37935..2216828 100644 --- a/pub/api/v1/sources/inserve/sync-server-licenses/index.php +++ b/pub/api/v1/sources/inserve/sync-server-licenses/index.php @@ -4,7 +4,7 @@ use api\classes\API_inserve; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_inserve.php"; $API_inserve = new API_inserve(); diff --git a/pub/api/v1/sources/inserve/sync-server-subscriptions/index.php b/pub/api/v1/sources/inserve/sync-server-subscriptions/index.php index 24f9d40..bb22a37 100644 --- a/pub/api/v1/sources/inserve/sync-server-subscriptions/index.php +++ b/pub/api/v1/sources/inserve/sync-server-subscriptions/index.php @@ -4,7 +4,7 @@ use api\classes\API_inserve; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_inserve.php"; $API_inserve = new API_inserve(); diff --git a/pub/api/v1/user/apitoken/index.php b/pub/api/v1/user/apitoken/index.php index 5b165c6..78868c2 100644 --- a/pub/api/v1/user/apitoken/index.php +++ b/pub/api/v1/user/apitoken/index.php @@ -5,7 +5,7 @@ use api\classes\API_users; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_apitoken.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_apitoken.php"; $API_apitoken = new API_apitoken(); diff --git a/pub/api/v1/user/avatar/index.php b/pub/api/v1/user/avatar/index.php index f123825..d5b5839 100644 --- a/pub/api/v1/user/avatar/index.php +++ b/pub/api/v1/user/avatar/index.php @@ -4,8 +4,8 @@ use api\classes\API_usersavatar; session_start(); -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usersavatar.php'; -require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/imageProcessor.php'; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_usersavatar.php"; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/imageProcessor.php"; $API_usersavatar = new API_usersavatar(); diff --git a/pub/api/v1/user/mfa/index.php b/pub/api/v1/user/mfa/index.php index 7059431..d06029e 100644 --- a/pub/api/v1/user/mfa/index.php +++ b/pub/api/v1/user/mfa/index.php @@ -1,8 +1,8 @@ 'Last modified date', 'last_update' => 'Last update', 'never' => 'Never', + 'invalid_data' => 'Invalid date', 'save' => 'Save', 'add_vendor' => 'Add vendor', 'edit_vendor' => 'Edit vendor', diff --git a/pub/bin/locales/nl.php b/pub/bin/locales/nl.php index 7e3dcaa..7f448bd 100644 --- a/pub/bin/locales/nl.php +++ b/pub/bin/locales/nl.php @@ -73,6 +73,7 @@ return [ 'last_modified_date' => 'Laatst gewijzigd datum', 'last_update' => 'Laatste update', 'never' => 'Nooit', + 'invalid_data' => 'Ongeldige datum', 'save' => 'Opslaan', 'add_vendor' => 'Vendor toevoegen', 'edit_vendor' => 'Vendor bewerken', diff --git a/pub/bin/pages/autop/pageDevices.php b/pub/bin/pages/autop/pageDevices.php index 1a53178..d339823 100644 --- a/pub/bin/pages/autop/pageDevices.php +++ b/pub/bin/pages/autop/pageDevices.php @@ -3,11 +3,11 @@ if (!defined('APP_INIT')) { exit; } if (isset($_GET['add'])) { - include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageDevices_add.php'); + require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/pages/autop/pageDevices_add.php"; } elseif (isset($_GET['edit'])) { - include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageDevices_edit.php'); + require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/pages/autop/pageDevices_edit.php"; } elseif (isset($_GET['view'])) { - include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageDevices_view.php'); + require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/pages/autop/pageDevices_view.php"; } else { - include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/autop/pageDevices_list.php'); + require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/pages/autop/pageDevices_list.php"; } \ No newline at end of file diff --git a/pub/bin/pages/autop/pageDevices_add.php b/pub/bin/pages/autop/pageDevices_add.php index 83bdd6b..986331b 100644 --- a/pub/bin/pages/autop/pageDevices_add.php +++ b/pub/bin/pages/autop/pageDevices_add.php @@ -10,10 +10,10 @@ if (!defined('APP_INIT')) { # IDE Section # Includes Section -include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php'); -include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/formBuilder.php'); -include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php'); -include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_devices.php'); +require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/php/Classes/pageNavbar.php"; +require_once "{$_SERVER['DOCUMENT_ROOT']}/bin/php/Classes/formBuilder.php"; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API.php"; +require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API_devices.php"; # Check permissions $API = new API(); @@ -145,7 +145,7 @@ $formBuilder->startForm();
+