diff --git a/api.php b/api.php index 400c42a..0a10cec 100644 --- a/api.php +++ b/api.php @@ -107,4 +107,14 @@ else http_response_code(403); //Forbidden } } + +//------------------------------------------ +// Debuglog +//------------------------------------------ +if (debug){ + $time_elapsed = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]; + $message = $date.';'.$collection.';'.$time_elapsed.';'.$username; + debuglog($message); +} + ?> \ No newline at end of file diff --git a/api/v2/authorization.php b/api/v2/authorization.php index c8c38b3..a510e45 100644 --- a/api/v2/authorization.php +++ b/api/v2/authorization.php @@ -64,9 +64,9 @@ if ($stmt->rowCount() == 1) { $stmt_login->execute([$login_attempt, $user_data['id']]); //Encrypt results - $messages = $user; + $messages = json_encode($user, JSON_UNESCAPED_UNICODE); //Send results - print_r($messages); + echo $messages; } else { diff --git a/api/v2/get/products_software.php b/api/v2/get/products_software.php index c105c6e..8ffbd17 100644 --- a/api/v2/get/products_software.php +++ b/api/v2/get/products_software.php @@ -43,6 +43,8 @@ foreach ($messages as $message){ if (file_exists($software_file)){ //GET SOURCE CODE $file_contents = file_get_contents($software_file); + //REMOVE RETURN \R + $file_contents = str_replace("\r", '',$file_contents); } else { $file_contents = ''; } diff --git a/assets/functions.php b/assets/functions.php index e13e620..40dbac6 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -554,7 +554,7 @@ function ioServer($api_call, $data){ } //------------------------------------------ -// API TO API +// API TO API version 1 //------------------------------------------ function ioAPI($api_call, $data, $token){ @@ -595,6 +595,52 @@ function ioAPI($api_call, $data, $token){ //Response return $resp; } + +//------------------------------------------ +// API TO API version 2 +//------------------------------------------ +function ioAPIv2($api_call, $data, $token){ + + include dirname(__FILE__,2).'/settings/settings.php'; + + $token = (!empty($token) || $token !='')? $token : 'authorization_request'; + $bearertoken = createCommunicationToken($token); + + $url = $baseurl.$api_call; + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + + $headers = array( + "Authorization: Bearer $bearertoken", + "Content-Type: application/json", + ); + + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + if (!empty($data)){ + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + } + + $resp = curl_exec($curl); + $http_status = curl_getinfo($curl) ?? '200'; + curl_close($curl); + + + //Check If errorcode is returned + if($http_status['http_code'] == '403' || $http_status['http_code'] == '400') {$resp = json_encode('NOK');} + + if (debug){ + $message = $date.';'.$api_call; + debuglog($message); + } + + //Response + return $resp; +} + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //get user profile||$profile=settings, $permision = userright() //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/cronjob.php b/cronjob.php index 0128147..8ffe377 100644 --- a/cronjob.php +++ b/cronjob.php @@ -101,6 +101,15 @@ storeMeasurementEquipment(''); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ geolocationUpdate($token); +// +++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Debuglog ++++++++++++++ +// +++++++++++++++++++++++++++++++++++++++++++++++++++++++ +if (debug){ + $time_elapsed = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]; + $message = $date.';cronjob;'.$time_elapsed.';interface'; + debuglog($message); +} + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ // EXIT ++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/profile.php b/profile.php index 53e26ee..1d05f0e 100644 --- a/profile.php +++ b/profile.php @@ -115,11 +115,11 @@ $view .= '
+ '; + foreach ($supportedLanguages as $language){ + $view .=''; + } +$view .=' '; if ($update_allowed === 1 && $_SESSION['permission'] != 0){ diff --git a/register.php b/register.php index 34bfa6e..a7f40cf 100644 --- a/register.php +++ b/register.php @@ -2,7 +2,13 @@ include './assets/functions.php'; include './settings/settings.php'; include './settings/config.php'; -include_once './settings/translations/translations_US.php'; + +//GET BROWSER LANGUAGE +$lang = strtoupper(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)); +$lang = in_array($lang, $supportedLanguages) ? $lang : 'US'; + +//INCLUDE THE TRANSLATION +include_once './settings/translations/translations_'.$lang.'.php'; // Default input values $display =''; @@ -56,7 +62,7 @@ echo ' - Productregistration + '.$register_title.'