Просмотр исходного кода

Fix php warning API PHP8.1 (#2534)

* Change caused admin user to act as default user

* Mute output non existing var php8.1
Jaap Marcus 3 лет назад
Родитель
Сommit
82eadf3f4b
2 измененных файлов с 12 добавлено и 5 удалено
  1. 12 1
      web/api/index.php
  2. 0 4
      web/inc/main.php

+ 12 - 1
web/api/index.php

@@ -182,12 +182,23 @@ function api($hst_hash, $hst_user, $hst_password, $hst_returncode, $hst_cmd, $hs
     }
 }
 
+$array = array('user','password','hash','returncode','cmd','arg1','arg2','arg3','arg4','arg5','arg6','arg7','arg8','arg9');
+    
 if (isset($_POST['user']) || isset($_POST['hash'])) {
-
+    foreach($array as $key){
+        if(empty($_POST[$key])){
+            $_POST[$key] = '';
+        }
+    }
     api($_POST['hash'], $_POST['user'], $_POST['password'], $_POST['returncode'], $_POST['cmd'], $_POST['arg1'], $_POST['arg2'], $_POST['arg3'], $_POST['arg4'], $_POST['arg5'], $_POST['arg6'], $_POST['arg7'], $_POST['arg8'], $_POST['arg9']);
 
 } else if (json_decode(file_get_contents("php://input"), true) != NULL){ //JSON POST support
     $json_data = json_decode(file_get_contents("php://input"), true);
+    foreach($array as $key){
+        if(empty($json_data[$key])){
+            $json_data[$key] = '';
+        }
+    }
     api($json_data['hash'], $json_data['user'], $json_data['password'], $json_data['returncode'], $json_data['cmd'], $json_data['arg1'], $json_data['arg2'], $json_data['arg3'], $json_data['arg4'], $json_data['arg5'], $json_data['arg6'], $json_data['arg7'], $json_data['arg8'], $json_data['arg9']);
 
 } else {

+ 0 - 4
web/inc/main.php

@@ -127,10 +127,6 @@ if (isset($_SESSION['look']) && $_SESSION['look']  != '' && ($_SESSION['userCont
     $user_plain = htmlentities($_SESSION['look']);
 }
 
-if (empty($_SESSION['look'])) {
-    $_SESSION['look'] = '';
-}
-
 require_once(dirname(__FILE__) . '/i18n.php');
 
 function check_error($return_var)