From f51af664cfc7581c65a0968546895ecbd518d3a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Wed, 30 Oct 2024 17:36:59 +0100 Subject: [PATCH] CMXX - Bugfix contract_manage and authorization api --- api/v0/authorization.php | 14 +++--- api/v2/get/vin.php | 88 +++++++++++++++++++++++++++++++++++ contract_manage.php | 14 +++++- settings/settingsprofiles.php | 4 +- settings/settingsviews.php | 3 +- 5 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 api/v2/get/vin.php diff --git a/api/v0/authorization.php b/api/v0/authorization.php index b670074..e97bce4 100644 --- a/api/v0/authorization.php +++ b/api/v0/authorization.php @@ -34,19 +34,21 @@ if (!empty($username) && !empty($password)) { http_response_code(401); } else { - $service = bin2hex(random_bytes(25)); //$row['service']; - - //Check valid userkey + //Default service key + $service = $row['service']; + + //Check valid userkey lastlogin less than 30minutes $valid_key = strtotime('+30 minutes',strtotime($row['lastlogin'])); $valid = ($valid_key <= time())?0:1; if ($row['service'] != '' && $valid == 0){ - + //Key is not valid anymore => update new servicekey + $service = bin2hex(random_bytes(25)); $sql_service = 'UPDATE users SET service = ? WHERE id = ?'; $stmt_service = $conn->prepare($sql_service); $stmt_service->execute([$service, $row['id']]); - } - + } + $jwt = createCommunicationToken($service); $logindate = date('Y-m-d H:i:s'); diff --git a/api/v2/get/vin.php b/api/v2/get/vin.php new file mode 100644 index 0000000..b8ef894 --- /dev/null +++ b/api/v2/get/vin.php @@ -0,0 +1,88 @@ + $vin, + "IsValid" => (validateVIN($vin) ? "Yes" : "No"), + "Manufacturer" => getManufacturer(substr($vin, 0, 3)), + "Country" => getCountry(substr($vin, 0, 3)), + "year" => getYear($vin[6], $vin[9]) + ]; +} +else { + $messages = [ + "IsValid" => "No" + ]; +} + +//------------------------------------------ +//JSON_ENCODE +//------------------------------------------ +$messages = json_encode($messages, JSON_UNESCAPED_UNICODE); + +//Send results +echo $messages; + +?> \ No newline at end of file diff --git a/contract_manage.php b/contract_manage.php index 4f4d6d6..ca2ce02 100644 --- a/contract_manage.php +++ b/contract_manage.php @@ -193,8 +193,11 @@ $assigned_servicetools = (empty($contract['servicetool']))? '' :json_decode($con foreach ($assigned_servicetools as $tool){ $view .= ''; } + if (count($assigned_servicetools) == 0){ + $view .= ''; + } } else { - $view .= ''; + $view .= ''; } $view .=' @@ -210,6 +213,9 @@ $assigned_users = (empty($contract['assigned_users']))? '' :json_decode($contrac foreach ($assigned_users as $user){ $view .= ''; } + if (count($assigned_users) == 0){ + $view .= ''; + } } else { $view .= ''; } @@ -222,10 +228,14 @@ $view .='
//Check for assigned users $ignore_lists = (empty($contract['ignore_list']))? '' :json_decode($contract['ignore_list'],true); + if (!empty($ignore_lists) || $ignore_lists != ''){ foreach ($ignore_lists as $list){ $view .= ''; - } + } + if (count($ignore_lists) == 0){ + $view .= ''; + } } else { $view .= ''; } diff --git a/settings/settingsprofiles.php b/settings/settingsprofiles.php index 9a7c405..079e81d 100644 --- a/settings/settingsprofiles.php +++ b/settings/settingsprofiles.php @@ -6,9 +6,9 @@ define('superuser_profile','dashboard,profile,assets,equipments,equipment,equipm /*Service*/ define('service','dashboard,profile,assets,equipments,equipment,equipment_manage,histories,history,history_manage,firmwaretool,servicereports,servicereport,admin,partners,partner,marketing,application'); /*Admin*/ -define('admin_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_healthindex,application'); +define('admin_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,application'); /*AdminPlus*/ -define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,products_software,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,report_usage,config,settings,logfile,changelog,language,application,maintenance,profiles'); +define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,products_software,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,report_usage,config,settings,logfile,changelog,language,application,maintenance,profiles,vin'); /*Build*/ define('build','buildtool,buildtool,application'); /*Distribution*/ diff --git a/settings/settingsviews.php b/settings/settingsviews.php index 60fa0d6..eb76ef7 100644 --- a/settings/settingsviews.php +++ b/settings/settingsviews.php @@ -59,7 +59,8 @@ $all_views = [ "language", "application", "maintenance", - "profiles" + "profiles", + "vin" ]; ?> \ No newline at end of file