Skip to content

Commit 82eadf3

Browse files
authored
Fix php warning API PHP8.1 (hestiacp#2534)
* Change caused admin user to act as default user * Mute output non existing var php8.1
1 parent bd4e6b7 commit 82eadf3

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

web/api/index.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,23 @@ function api($hst_hash, $hst_user, $hst_password, $hst_returncode, $hst_cmd, $hs
182182
}
183183
}
184184

185+
$array = array('user','password','hash','returncode','cmd','arg1','arg2','arg3','arg4','arg5','arg6','arg7','arg8','arg9');
186+
185187
if (isset($_POST['user']) || isset($_POST['hash'])) {
186-
188+
foreach($array as $key){
189+
if(empty($_POST[$key])){
190+
$_POST[$key] = '';
191+
}
192+
}
187193
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']);
188194

189195
} else if (json_decode(file_get_contents("php://input"), true) != NULL){ //JSON POST support
190196
$json_data = json_decode(file_get_contents("php://input"), true);
197+
foreach($array as $key){
198+
if(empty($json_data[$key])){
199+
$json_data[$key] = '';
200+
}
201+
}
191202
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']);
192203

193204
} else {

web/inc/main.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ function destroy_sessions()
127127
$user_plain = htmlentities($_SESSION['look']);
128128
}
129129

130-
if (empty($_SESSION['look'])) {
131-
$_SESSION['look'] = '';
132-
}
133-
134130
require_once(dirname(__FILE__) . '/i18n.php');
135131

136132
function check_error($return_var)

0 commit comments

Comments
 (0)