From 5709c3b0132ed0a7fa9b6c36320361266e2186df Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 12 Nov 2021 14:10:37 +0000 Subject: [PATCH 001/187] fix theme not loading --- require/function_commun.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/require/function_commun.php b/require/function_commun.php index 407e6ccab..7d20202a5 100644 --- a/require/function_commun.php +++ b/require/function_commun.php @@ -342,12 +342,12 @@ function msg_error($txt, $close = false) { } function html_header($noJavascript = false) { - if (!$_SESSION['OCS']['readServer']) { - $value_theme['tvalue']['CUSTOM_THEME'] = DEFAULT_THEME; + if ($_SESSION['OCS']['readServer']) { + $value_theme = look_config_default_values('CUSTOM_THEME'); } if(is_null($value_theme)) { - $value_theme = look_config_default_values('CUSTOM_THEME'); + $value_theme['tvalue']['CUSTOM_THEME'] = DEFAULT_THEME; } header("Pragma: no-cache"); From 52081c1066e9cf242c7b1486ff6030d1e5884d98 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 09:20:27 +0000 Subject: [PATCH 002/187] php8 syntax update on backend/identity/ --- backend/identity/identity.php | 10 +++------- backend/identity/methode/ldap.php | 22 ++++++---------------- backend/identity/methode/local.php | 7 ++----- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/backend/identity/identity.php b/backend/identity/identity.php index c334c5573..805c5ef46 100755 --- a/backend/identity/identity.php +++ b/backend/identity/identity.php @@ -1,4 +1,5 @@ $error) { + foreach ($tab_error as $error) { $LIST_ERROR .= $error; addLog('ERROR_IDENTITY', $error); } $_SESSION['OCS']["mesmachines"] = "NOTAG"; } elseif (isset($tab_tag)) { - foreach ($list_methode as $prio => $script) { + foreach ($list_methode as $script) { if (isset($tab_tag[$script])) { foreach ($tab_tag[$script] as $tag => $lbl) { $list_tag[$tag] = $tag; @@ -71,7 +69,5 @@ $_SESSION['OCS']["mytag"] = $lbl_list_tag; $_SESSION['OCS']['TAGS'] = $list_tag; } - if (isset($lvluser)) $_SESSION['OCS']["lvluser"] = $lvluser; -?> \ No newline at end of file diff --git a/backend/identity/methode/ldap.php b/backend/identity/methode/ldap.php index 5c42b962a..ea41d43bf 100644 --- a/backend/identity/methode/ldap.php +++ b/backend/identity/methode/ldap.php @@ -1,4 +1,5 @@ NAME] = $item->TVALUE; } - // checks if the user already exists $reqOp = "SELECT new_accesslvl as accesslvl FROM operators WHERE id='%s'"; $argOp = array($_SESSION['OCS']["loggeduser"]); $resOp = mysql2_query_secure($reqOp, $link_ocs, $argOp); - // defines the user level according to specific LDAP attributes // default: normal user $defaultRole = $config['LDAP_CHECK_DEFAULT_ROLE']; @@ -87,14 +83,12 @@ $f2_name = $config['LDAP_CHECK_FIELD2_NAME']; $f1_value = $_SESSION['OCS']['details'][$f1_name]; $f2_value = $_SESSION['OCS']['details'][$f2_name]; - if (!empty($f1_value)) { if (strtolower($f1_name) == "memberof") { //the idea here is to iterate through the groups array looking for a match //if we find it, unset the array and store only the match, else leave as it is foreach ($f1_value as $group) { if ($group == $config['LDAP_CHECK_FIELD1_VALUE']) { - $f1_value = array(); $f1_value = $group; } } @@ -106,12 +100,10 @@ $defaultRole = $config['LDAP_CHECK_FIELD1_ROLE']; } } - if (!empty($f2_value)) { if (strtolower($f2_name) == "memberof") { foreach ($f2_value as $group) { if ($group == $config['LDAP_CHECK_FIELD2_VALUE']) { - $f2_value = array(); $f2_value = $group; } } @@ -121,14 +113,13 @@ $defaultRole = $config['LDAP_CHECK_FIELD2_ROLE']; } } - // uncomment this section for DEBUG // note: cannot use the global DEBUG variable because this happens before the toggle is available. /* - echo ("field1: ".$f1_name." value=".$f1_value." condition: ".$config['LDAP_CHECK_FIELD1_VALUE']." role=".$config['LDAP_CHECK_FIELD1_ROLE']." level=".$config['LDAP_CHECK_FIELD1_USERLEVEL']."
"); - echo ("field2: ".$item['CONEX_LDAP_CHECK_FIELD2_NAME']." value=".$f2_value." condition: ".$config['LDAP_CHECK_FIELD2_VALUE']." role=".$config['LDAP_CHECK_FIELD2_ROLE']." level=".$config['LDAP_CHECK_FIELD2_USERLEVEL']."
"); - echo ("user: ".$_SESSION['OCS']["loggeduser"]." will have level=".$defaultLevel." and role=".$defaultRole."
"); - */ + echo ("field1: ".$f1_name." value=".$f1_value." condition: ".$config['LDAP_CHECK_FIELD1_VALUE']." role=".$config['LDAP_CHECK_FIELD1_ROLE']." level=".$config['LDAP_CHECK_FIELD1_USERLEVEL']."
"); + echo ("field2: ".$item['CONEX_LDAP_CHECK_FIELD2_NAME']." value=".$f2_value." condition: ".$config['LDAP_CHECK_FIELD2_VALUE']." role=".$config['LDAP_CHECK_FIELD2_ROLE']." level=".$config['LDAP_CHECK_FIELD2_USERLEVEL']."
"); + echo ("user: ".$_SESSION['OCS']["loggeduser"]." will have level=".$defaultLevel." and role=".$defaultRole."
"); +*/ //if defaultRole is define if (isset($defaultRole) && $defaultRole != '') { // if it doesn't exist, create the user record @@ -202,7 +193,7 @@ $res = mysql2_query_secure($sql, $link_ocs, $arg); while ($row = mysqli_fetch_object($res)) { // Check for wildcard - if (strpos($row->tag, '*') !== false || strpos($row->tag,'?') !== false) { + if (str_contains($row->tag, '*') || str_contains($row->tag,'?')) { $wildcard = true; $row->tag = str_replace("*", "%", $row->tag); $row->tag = str_replace("?", "_", $row->tag); @@ -230,4 +221,3 @@ } else { $ERROR = $l->g(1278); } -?> \ No newline at end of file diff --git a/backend/identity/methode/local.php b/backend/identity/methode/local.php index bf781a247..c2b4ad29b 100644 --- a/backend/identity/methode/local.php +++ b/backend/identity/methode/local.php @@ -1,4 +1,5 @@ accesslvl)) { $lvluser = $rowOp->accesslvl; @@ -63,7 +61,7 @@ $res = mysql2_query_secure($sql, $link_ocs, $arg); while ($row = mysqli_fetch_object($res)) { // Check for wildcard - if (strpos($row->tag, '*') !== false || strpos($row->tag,'?') !== false) { + if (str_contains($row->tag, '*') || str_contains($row->tag,'?')) { $wildcard = true; $row->tag = str_replace("*", "%", $row->tag); $row->tag = str_replace("?", "_", $row->tag); @@ -88,4 +86,3 @@ } else { $ERROR = $l->g(894); } -?> \ No newline at end of file From 2aeacc4c56db38c0a6890373be0cbbe4ba7f0d89 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 09:21:54 +0000 Subject: [PATCH 003/187] php8 fix warnings on backend/ipdiscover/ --- backend/ipdiscover/ipdiscover.php | 8 +++----- backend/ipdiscover/methode/local.php | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/backend/ipdiscover/ipdiscover.php b/backend/ipdiscover/ipdiscover.php index 8e8884cd6..39ae6ec90 100755 --- a/backend/ipdiscover/ipdiscover.php +++ b/backend/ipdiscover/ipdiscover.php @@ -1,4 +1,5 @@ "local.php"); - if (!isset($_SESSION['OCS']["ipdiscover"])) { $i = 0; //methode pour le calcul des droits - while ($list_methode[$i]) { + while (isset($list_methode[$i]) == true) { require_once('methode/' . $list_methode[$i]); //on garde les droits de l'utilisateur sur l'ipdiscover if (isset($list_ip)) { @@ -40,7 +39,7 @@ } unset($list_ip); if (isset($tab_ip)) { - foreach ($list_methode as $prio => $script) { + foreach ($list_methode as $script) { if (isset($tab_ip[$script])) { foreach ($tab_ip[$script] as $ip => $lbl) { $list_ip[$ip] = $lbl; @@ -58,4 +57,3 @@ $_SESSION['OCS']["ipdiscover"] = $tab_info; $_SESSION['OCS']["ipdiscover_methode"] = $base; } -?> \ No newline at end of file diff --git a/backend/ipdiscover/methode/local.php b/backend/ipdiscover/methode/local.php index d3a03fad4..c567e1ccb 100755 --- a/backend/ipdiscover/methode/local.php +++ b/backend/ipdiscover/methode/local.php @@ -65,7 +65,7 @@ /* applied again patch of revision 484 ( fix bug: https://bugs.launchpad.net/ocsinventory-ocsreports/+bug/637834 ) */ - if (is_array($subnetToBlacklist)) { + if (isset($subnetToBlacklist) && is_array($subnetToBlacklist)) { foreach ($subnetToBlacklist as $key => $value) { if ($key == $row->ipsubnet) { $id = '--' . $l->g(703) . '--'; @@ -89,7 +89,7 @@ /* applied again patch of revision 484 ( fix bug: https://bugs.launchpad.net/ocsinventory-ocsreports/+bug/637834 ) */ - if (is_array($subnetToBlacklist)) { + if (isset($subnetToBlacklist) && is_array($subnetToBlacklist)) { foreach ($subnetToBlacklist as $key => $value) { if ($key == $row->ipsubnet) { $id = '--' . $l->g(703) . '--'; From 4e110d4a125cb03cdba94ca30c32de46f21b28b2 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 09:23:46 +0000 Subject: [PATCH 004/187] php8 syntax update --- backend/require/auth.manager.php | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/backend/require/auth.manager.php b/backend/require/auth.manager.php index 54d0da42c..2f05f440e 100644 --- a/backend/require/auth.manager.php +++ b/backend/require/auth.manager.php @@ -1,4 +1,5 @@ - "local.php" ); - break; case 2: return array( 0 => "local.php", 1 => "ldap.php" ); - break; case 3: return array( 0 => "ldap.php" ); - break; case 4: - if($identity){ - return array( - 0 => "ldap.php" - ); - }else{ - return array( - 0 => "always_ok.php" - ); - } - - break; case 5: if($identity){ @@ -79,6 +64,5 @@ function get_list_methode($identity = false){ return array( 0 => "local.php" ); - break; } -} \ No newline at end of file +} From 88b3387ec128f99bbc9ab75e7476f6a24a88286b Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:09:17 +0000 Subject: [PATCH 005/187] php8 syntax updat --- plugins/computer_detail/cd_bios/cd_bios.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/computer_detail/cd_bios/cd_bios.php b/plugins/computer_detail/cd_bios/cd_bios.php index 051188bf0..b7bb55fc9 100755 --- a/plugins/computer_detail/cd_bios/cd_bios.php +++ b/plugins/computer_detail/cd_bios/cd_bios.php @@ -1,4 +1,5 @@ g(273)); if (!isset($protectedPost['SHOW'])) { $protectedPost['SHOW'] = 'NOSHOW'; @@ -74,25 +73,21 @@ $tab_options['OTHER_BIS']['IMG'] = 'image/green.png'; } } - if ($show_all_column) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del[$l->g(36)] = $l->g(36); } - $default_fields = $list_fields; $queryDetails = "SELECT "; -foreach ($list_fields as $lbl => $value) { +foreach ($list_fields as $value) { $queryDetails .= $value . ","; } $queryDetails = substr($queryDetails, 0, -1) . " FROM bios WHERE (hardware_id=$systemid)"; ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); - echo close_form(); if (AJAX) { ob_end_clean(); tab_req($list_fields, $default_fields, $list_col_cant_del, $queryDetails, $tab_options); ob_start(); } -?> \ No newline at end of file From 338fabb3ff4198fae9650cda7bc6d393a3612bc1 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:11:52 +0000 Subject: [PATCH 006/187] php8 fix warnings on ms_config --- plugins/main_sections/ms_config/ms_blacklist.php | 12 ++---------- plugins/main_sections/ms_config/ms_config.php | 2 +- .../main_sections/ms_config/ms_custom_download.php | 10 +++++----- .../main_sections/ms_config/ms_custom_frequency.php | 6 +++--- .../main_sections/ms_config/ms_custom_ipdiscover.php | 10 +++++----- plugins/main_sections/ms_config/ms_custom_param.php | 8 ++++++-- plugins/main_sections/ms_config/ms_custom_prolog.php | 2 +- 7 files changed, 23 insertions(+), 27 deletions(-) diff --git a/plugins/main_sections/ms_config/ms_blacklist.php b/plugins/main_sections/ms_config/ms_blacklist.php index 7bdcd1bd1..8bd90c253 100755 --- a/plugins/main_sections/ms_config/ms_blacklist.php +++ b/plugins/main_sections/ms_config/ms_blacklist.php @@ -1,4 +1,5 @@ g(703)); if (!is_defined($protectedPost['onglet'])) $protectedPost['onglet'] = 1; - $tab_options = $protectedPost; - //définition des onglets $data_on[1] = $l->g(95); $data_on[2] = $l->g(36); @@ -64,7 +60,6 @@ echo open_form($form_name, '', '', 'form-horizontal'); show_tabs($data_on,$form_name,"onglet",true); echo '
'; - switch ($protectedPost['onglet']) { case 1: $table_name = "blacklist_macaddresses"; @@ -150,7 +145,7 @@ ?>
- "; echo close_form(); - if (AJAX) { ob_end_clean(); tab_req($list_fields, $default_fields, $list_col_cant_del, $sql['SQL'], $tab_options); } -?> \ No newline at end of file diff --git a/plugins/main_sections/ms_config/ms_config.php b/plugins/main_sections/ms_config/ms_config.php index dafda07e6..069fb7cd5 100755 --- a/plugins/main_sections/ms_config/ms_config.php +++ b/plugins/main_sections/ms_config/ms_config.php @@ -40,7 +40,7 @@ $def_onglets['DEV'] = $l->g(1302); } -if ($protectedPost['Valid'] == $l->g(103)) { +if (isset($protectedPost['Valid']) && $protectedPost['Valid'] == $l->g(103)) { $etat = verif_champ(); if ($etat == "") { update_default_value($protectedPost); //function in function_config_generale.php diff --git a/plugins/main_sections/ms_config/ms_custom_download.php b/plugins/main_sections/ms_config/ms_custom_download.php index 615fed28f..bab88b948 100755 --- a/plugins/main_sections/ms_config/ms_custom_download.php +++ b/plugins/main_sections/ms_config/ms_custom_download.php @@ -59,7 +59,7 @@ $champ_value['IGNORED'] = $l->g(718); $champ_value['VALUE'] = 'IGNORED'; } -ligne("DOWNLOAD_CYCLE_LATENCY", $l->g(720), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_CYCLE_LATENCY'], 'END' => $l->g(511), 'JAVASCRIPT' => $numeric)); +ligne("DOWNLOAD_CYCLE_LATENCY", $l->g(720), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_CYCLE_LATENCY'] ?? '', 'END' => $l->g(511), 'JAVASCRIPT' => $numeric)); if (!isset($optvalue['DOWNLOAD_FRAG_LATENCY'])) { $optvalueselected = 'SERVER DEFAULT'; @@ -73,7 +73,7 @@ $champ_value['IGNORED'] = $l->g(718); $champ_value['VALUE'] = 'IGNORED'; } -ligne("DOWNLOAD_FRAG_LATENCY", $l->g(721), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_FRAG_LATENCY'], 'END' => $l->g(511), 'JAVASCRIPT' => $numeric)); +ligne("DOWNLOAD_FRAG_LATENCY", $l->g(721), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_FRAG_LATENCY'] ?? '', 'END' => $l->g(511), 'JAVASCRIPT' => $numeric)); if (!isset($optvalue['DOWNLOAD_PERIOD_LATENCY'])) { $optvalueselected = 'SERVER DEFAULT'; @@ -87,7 +87,7 @@ $champ_value['IGNORED'] = $l->g(718); $champ_value['VALUE'] = 'IGNORED'; } -ligne("DOWNLOAD_PERIOD_LATENCY", $l->g(722), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_PERIOD_LATENCY'], 'END' => $l->g(511), 'JAVASCRIPT' => $numeric)); +ligne("DOWNLOAD_PERIOD_LATENCY", $l->g(722), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_PERIOD_LATENCY'] ?? '', 'END' => $l->g(511), 'JAVASCRIPT' => $numeric)); if (!isset($optvalue['DOWNLOAD_PERIOD_LENGTH'])) { $optvalueselected = 'SERVER DEFAULT'; @@ -101,7 +101,7 @@ $champ_value['IGNORED'] = $l->g(718); $champ_value['VALUE'] = 'IGNORED'; } -ligne("DOWNLOAD_PERIOD_LENGTH", $l->g(723), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_PERIOD_LENGTH'], 'JAVASCRIPT' => $numeric)); +ligne("DOWNLOAD_PERIOD_LENGTH", $l->g(723), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_PERIOD_LENGTH'] ?? '', 'JAVASCRIPT' => $numeric)); if (!isset($optvalue['DOWNLOAD_TIMEOUT'])) { $optvalueselected = 'SERVER DEFAULT'; @@ -115,7 +115,7 @@ $champ_value['IGNORED'] = $l->g(718); $champ_value['VALUE'] = 'IGNORED'; } -ligne("DOWNLOAD_TIMEOUT", $l->g(424), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_TIMEOUT'], 'END' => $l->g(496), 'JAVASCRIPT' => $numeric)); +ligne("DOWNLOAD_TIMEOUT", $l->g(424), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['DOWNLOAD_TIMEOUT'] ?? '', 'END' => $l->g(496), 'JAVASCRIPT' => $numeric)); fin_tab(); ?> \ No newline at end of file diff --git a/plugins/main_sections/ms_config/ms_custom_frequency.php b/plugins/main_sections/ms_config/ms_custom_frequency.php index 9377f5f0b..549aef022 100755 --- a/plugins/main_sections/ms_config/ms_custom_frequency.php +++ b/plugins/main_sections/ms_config/ms_custom_frequency.php @@ -27,9 +27,9 @@ 'CELLPADDING' => '0', 'BGCOLOR' => '#C7D9F5', 'BORDERCOLOR' => '#9894B5')); -if ($optvalue['FREQUENCY'] == 0 && isset($optvalue['FREQUENCY'])) { +if (isset($optvalue['FREQUENCY']) && $optvalue['FREQUENCY'] == 0) { $optvalueselected = 'ALWAYS'; -} elseif ($optvalue['FREQUENCY'] == -1) { +} elseif (isset($optvalue['FREQUENCY']) && $optvalue['FREQUENCY'] == -1) { $optvalueselected = 'NEVER'; } elseif (!isset($optvalue['FREQUENCY'])) { $optvalueselected = 'SERVER DEFAULT'; @@ -45,6 +45,6 @@ $champ_value['IGNORED'] = $l->g(718); $champ_value['VALUE'] = 'IGNORED'; } -ligne("FREQUENCY", $l->g(494), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['FREQUENCY'], 'END' => $l->g(496), 'JAVASCRIPT' => $numeric)); +ligne("FREQUENCY", $l->g(494), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['FREQUENCY'] ?? '', 'END' => $l->g(496), 'JAVASCRIPT' => $numeric)); fin_tab(); ?> \ No newline at end of file diff --git a/plugins/main_sections/ms_config/ms_custom_ipdiscover.php b/plugins/main_sections/ms_config/ms_custom_ipdiscover.php index 3b16d1bda..b7d7b1302 100755 --- a/plugins/main_sections/ms_config/ms_custom_ipdiscover.php +++ b/plugins/main_sections/ms_config/ms_custom_ipdiscover.php @@ -29,15 +29,15 @@ 'BORDERCOLOR' => '#9894B5')); $mode = 0; -if ($optvalueTvalue['IPDISCOVER'] && $optvalue['IPDISCOVER'] == 1) { +if (isset($optvalueTvalue['IPDISCOVER']) && $optvalue['IPDISCOVER'] == 1) { $select_value = $optvalueTvalue['IPDISCOVER']; echo "
" . $l->g(519) . ": " . $optvalueTvalue['IPDISCOVER'] . "
"; $mode = 1; -} else if ($optvalue['IPDISCOVER'] == 2) { +} else if (isset($optvalue['IPDISCOVER']) && $optvalue['IPDISCOVER'] == 2) { $select_value = $optvalueTvalue['IPDISCOVER']; echo "
" . $l->g(520) . ": " . $optvalueTvalue['IPDISCOVER'] . "
"; $mode = 3; -} else if ($optvalue['IPDISCOVER'] === "0") { +} else if (isset($optvalue['IPDISCOVER']) && $optvalue['IPDISCOVER'] === "0") { $select_value = "OFF"; echo "
" . $l->g(521) . "
"; $mode = 2; @@ -62,7 +62,7 @@ } } -ligne('IPDISCOVER', $l->g(518), 'select', array('SELECT_VALUE' => $lesRez, 'VALUE' => $select_value)); +ligne('IPDISCOVER', $l->g(518), 'select', array('SELECT_VALUE' => $lesRez, 'VALUE' => $select_value ?? '')); if (!isset($optvalue['SNMP_SWITCH'])) { $optvalueselected = 'SERVER DEFAULT'; @@ -80,7 +80,7 @@ $champ_value['VALUE'] = 'IGNORED'; } ligne("SNMP_SWITCH", $l->g(1197), 'radio', $champ_value); -ligne('SNMP_NETWORK', $l->g(1198), 'long_text', array('VALUE' => $optvalueTvalue['SNMP_NETWORK'], 'COLS' => 40, 'ROWS' => 1)); +ligne('SNMP_NETWORK', $l->g(1198), 'long_text', array('VALUE' => $optvalueTvalue['SNMP_NETWORK'] ?? '', 'COLS' => 40, 'ROWS' => 1)); unset($champ_value); fin_tab(); diff --git a/plugins/main_sections/ms_config/ms_custom_param.php b/plugins/main_sections/ms_config/ms_custom_param.php index 3ef45335a..ccc43f1a7 100644 --- a/plugins/main_sections/ms_config/ms_custom_param.php +++ b/plugins/main_sections/ms_config/ms_custom_param.php @@ -35,7 +35,7 @@ $def_onglets['TELE'] = $l->g(512); //Télédéploiement $def_onglets['RSX'] = $l->g(1198); //ipdiscover //update values -if ($protectedPost['Valid'] == $l->g(103)) { +if (isset($protectedPost['Valid']) && $protectedPost['Valid'] == $l->g(103)) { if ($list_id) { //more then one value if (strstr($list_id, ',') != "") { @@ -67,7 +67,11 @@ } $MAJ = $l->g(711); echo "
"; - msg_success($MAJ . $add_lbl); + if (isset($add_lbl)) { + msg_success($MAJ . $add_lbl); + } else { + msg_success($MAJ); + } echo "
"; if (isset($protectedGet['origine']) && $protectedGet['origine'] == 'machine') { $form_to_reload = 'config_mach'; diff --git a/plugins/main_sections/ms_config/ms_custom_prolog.php b/plugins/main_sections/ms_config/ms_custom_prolog.php index 623376885..7748cfe94 100644 --- a/plugins/main_sections/ms_config/ms_custom_prolog.php +++ b/plugins/main_sections/ms_config/ms_custom_prolog.php @@ -40,7 +40,7 @@ $champ_value['IGNORED'] = $l->g(718); $champ_value['VALUE'] = 'IGNORED'; } -ligne("PROLOG_FREQ", $l->g(724), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['PROLOG_FREQ'], 'END' => $l->g(730), 'JAVASCRIPT' => $numeric)); +ligne("PROLOG_FREQ", $l->g(724), 'radio', $champ_value, array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $optvalue['PROLOG_FREQ'] ?? '', 'END' => $l->g(730), 'JAVASCRIPT' => $numeric)); unset($champ_value); if (!isset($optvalue['INVENTORY_ON_STARTUP'])) { From 468e4877bf27216eb8c044ce69086f0e8f123121 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:13:38 +0000 Subject: [PATCH 007/187] php8 fix warnings on ms_ipdiscover --- .../ms_ipdiscover/ms_admin_ipdiscover.php | 66 +++++++++---------- .../ms_ipdiscover/ms_custom_info.php | 43 +++++++----- .../ms_ipdiscover/ms_ipdiscover.php | 3 +- .../ms_ipdiscover/ms_ipdiscover_analyse.php | 1 - 4 files changed, 57 insertions(+), 56 deletions(-) diff --git a/plugins/main_sections/ms_ipdiscover/ms_admin_ipdiscover.php b/plugins/main_sections/ms_ipdiscover/ms_admin_ipdiscover.php index 65c7d731a..9c6987eea 100644 --- a/plugins/main_sections/ms_ipdiscover/ms_admin_ipdiscover.php +++ b/plugins/main_sections/ms_ipdiscover/ms_admin_ipdiscover.php @@ -1,4 +1,5 @@ g(837)); @@ -66,7 +62,6 @@ echo '
'; } - /************************************* SUBNET *************************************/ if ($protectedPost['onglet'] == 'ADMIN_RSX') { $method = $ipdiscover->verif_base_methode('OCS'); @@ -79,7 +74,7 @@ $tab_options['CACHE'] = 'RESET'; } if (isset($protectedPost['Valid_modif'])) { - $result = $ipdiscover->add_subnet($protectedPost['ADD_IP'], $protectedPost['RSX_NAME'], $protectedPost['ID_NAME'], $protectedPost['ADD_SX_RSX'], $protectedPost['ADD_TAG']); + $result = $ipdiscover->add_subnet($protectedPost['ADD_IP'], $protectedPost['RSX_NAME'], $protectedPost['ID_NAME'], $protectedPost['ADD_SX_RSX'], $protectedPost['ADD_TAG'] ?? ''); if ($result) { msg_error($result); } else { @@ -106,42 +101,47 @@ if (isset($protectedPost['ADD_SUB'])) { echo "g(931); $result = $ipdiscover->find_info_subnet($protectedPost['MODIF']); - if (!isset($protectedPost['RSX_NAME'])) { - $protectedPost['RSX_NAME'] = $result->NAME; - } - if (!isset($protectedPost['ID_NAME'])) { - $protectedPost['ID_NAME'] = $result->ID; - } - if (!isset($protectedPost['ADD_TAG'])) { - $protectedPost['ADD_TAG'] = $result->TAG; - } - if (!isset($protectedPost['ADD_IP'])) { - $protectedPost['ADD_IP'] = $result->NETID; - } - if (!isset($protectedPost['ADD_SX_RSX'])) { - $protectedPost['ADD_SX_RSX'] = $result->MASK; + if(isset($result)) { + if (!isset($protectedPost['RSX_NAME'])) { + $protectedPost['RSX_NAME'] = $result->NAME; + } + if (!isset($protectedPost['ID_NAME'])) { + $protectedPost['ID_NAME'] = $result->ID; + } + if (!isset($protectedPost['ADD_TAG'])) { + $protectedPost['ADD_TAG'] = $result->TAG; + } + if (!isset($protectedPost['ADD_IP'])) { + $protectedPost['ADD_IP'] = $result->NETID; + } + if (!isset($protectedPost['ADD_SX_RSX'])) { + $protectedPost['ADD_SX_RSX'] = $result->MASK; + } + } if (is_defined($protectedGet['value'])) { $explode = explode(";", $protectedGet['value']); $protectedPost['ADD_IP'] = $explode[0]; - $protectedPost['ADD_TAG'] = $explode[1]; - } + // no tag = empty val + $protectedPost['ADD_TAG'] = $explode[1] ?? ''; + } + } else { $title = $l->g(303); } $list_id_subnet = look_config_default_values('ID_IPDISCOVER_%', 'LIKE'); if (isset($list_id_subnet)) { - foreach ($list_id_subnet['tvalue'] as $key => $value) { + foreach ($list_id_subnet['tvalue'] as $value) { $list_subnet[$value] = $value; } } else { @@ -155,14 +155,14 @@ $list_tag = $ipdiscover->get_tag(); $default_values = array( - 'RSX_NAME' => $protectedPost['RSX_NAME'], + 'RSX_NAME' => $protectedPost['RSX_NAME'] ?? '', 'ID_NAME' => $list_subnet, 'ADD_TAG' => $list_tag, - 'ADD_IP' => $protectedPost['ADD_IP'], - 'ADD_SX_RSX' => $protectedPost['ADD_SX_RSX'] + 'ADD_IP' => $protectedPost['ADD_IP'] ?? '', + 'ADD_SX_RSX' => $protectedPost['ADD_SX_RSX'] ?? '' ); - $ipdiscover->form_add_subnet($title, $default_values, $form_name, $is_tag_linked['ivalue']['IPDISCOVER_LINK_TAG_NETWORK']); + $ipdiscover->form_add_subnet($default_values, $form_name, $is_tag_linked['ivalue']['IPDISCOVER_LINK_TAG_NETWORK'], $title); } else { $sql = "SELECT NETID, NAME, ID, MASK, TAG, CONCAT(NETID,IFNULL(TAG, '')) as supsub FROM subnet"; @@ -187,7 +187,6 @@ msg_warning($method); } } - /************************************* TYPES *************************************/ if ($protectedPost['onglet'] == 'ADMIN_TYPE') { if (isset($protectedPost['Reset_modif'])) { @@ -248,7 +247,6 @@ echo ""; } } - /************************************* COMMUNITIES *************************************/ if ($protectedPost['onglet'] == 'ADMIN_SMTP' && $_SESSION['OCS']['profile']->getConfigValue('MANAGE_SMTP_COMMUNITIES') == 'YES') { if (isset($protectedPost['Valid_modif'])) { @@ -348,11 +346,9 @@ $protectedPost['ADD_COMM'] = $l->g(116); } } - echo '
'; echo close_form(); - if (AJAX) { ob_end_clean(); tab_req($list_fields, $default_fields, $list_col_cant_del, $sql, $tab_options); -} \ No newline at end of file +} diff --git a/plugins/main_sections/ms_ipdiscover/ms_custom_info.php b/plugins/main_sections/ms_ipdiscover/ms_custom_info.php index c8516ead4..5f9c3701b 100644 --- a/plugins/main_sections/ms_ipdiscover/ms_custom_info.php +++ b/plugins/main_sections/ms_ipdiscover/ms_custom_info.php @@ -70,7 +70,7 @@ } if (!isset($ERROR)) { - if ($protectedPost['USER_ENTER'] != '') { + if (!empty($protectedPost['USER_ENTER'])) { $sql = "UPDATE network_devices SET DESCRIPTION = '%s', TYPE = '%s', @@ -97,7 +97,7 @@ } //del the selection -if ($protectedPost['DEL_ALL'] != '') { +if (!empty($protectedPost['DEL_ALL'])) { foreach ($protectedPost as $key => $value) { $checkbox = explode('check', $key); if (isset($checkbox[1])) { @@ -125,10 +125,14 @@ $protectedPost['USER'] = $val['USER']; $protectedPost['MODIF_ID'] = $protectedPost['MODIF']; } - $tab_hidden['USER_ENTER'] = $protectedPost['USER']; - $tab_hidden['MODIF_ID'] = $protectedPost['MODIF_ID']; + + if(isset($protectedPost['USER']) && isset($protectedPost['MODIF_ID'])) { + $tab_hidden['USER_ENTER'] = $protectedPost['USER']; + $tab_hidden['MODIF_ID'] = $protectedPost['MODIF_ID']; + } + //si on est dans le cas d'une modif, on affiche le login qui a saisi la donnée - if ($protectedPost['MODIF_ID'] != '') { + if (!empty($protectedPost['MODIF_ID'])) { $tab_typ_champ[3]['DEFAULT_VALUE'] = $protectedPost['USER']; $tab_typ_champ[3]['INPUT_NAME'] = "USER"; $tab_typ_champ[3]['INPUT_TYPE'] = 3; @@ -144,7 +148,7 @@ $tab_typ_champ[0]['INPUT_TYPE'] = 13; $tab_name[0] = $l->g(95) . ": "; - $tab_typ_champ[1]['DEFAULT_VALUE'] = $protectedPost['COMMENT']; + $tab_typ_champ[1]['DEFAULT_VALUE'] = $protectedPost['COMMENT'] ?? ''; $tab_typ_champ[1]['INPUT_NAME'] = "COMMENT"; $tab_typ_champ[1]['INPUT_TYPE'] = 0; $tab_typ_champ[1]['CONFIG']['SIZE'] = 60; @@ -175,7 +179,7 @@ if (isset($protectedGet['value'])) { $explode = explode(";", $protectedGet['value']); $value_preg = preg_replace("/[^A-zA-Z0-9\._]/", "", $explode[0]); - $tag = addslashes($explode[1]); + $tag = addslashes($explode[1] ?? ''); if ($protectedGet['prov'] == "no_inv") { $title = $l->g(947); @@ -234,16 +238,19 @@ $default_fields = array($l->g(34) => $l->g(34), $l->g(66) => $l->g(66), $l->g(53) => $l->g(53), $l->g(95) => 'MAC', $l->g(232) => $l->g(232), $l->g(369) => $l->g(369), 'SUP' => 'SUP', 'MODIF' => 'MODIF'); } elseif ($protectedGet['prov'] == "inv" || $protectedGet['prov'] == "ipdiscover") { - //BEGIN SHOW ACCOUNTINFO - require_once('require/function_admininfo.php'); - $accountinfo_value = interprete_accountinfo($list_fields, $tab_options); - if (array($accountinfo_value['TAB_OPTIONS'])) - $tab_options = $accountinfo_value['TAB_OPTIONS']; - if (array($accountinfo_value['DEFAULT_VALUE'])) - $default_fields = $accountinfo_value['DEFAULT_VALUE']; - $list_fields = $accountinfo_value['LIST_FIELDS']; - $tab_options['FILTRE'] = array_flip($list_fields); - //END SHOW ACCOUNTINFO + if(isset($list_fields)) { + //BEGIN SHOW ACCOUNTINFO + require_once('require/function_admininfo.php'); + $accountinfo_value = interprete_accountinfo($list_fields, $tab_options); + if (array($accountinfo_value['TAB_OPTIONS'])) + $tab_options = $accountinfo_value['TAB_OPTIONS']; + if (array($accountinfo_value['DEFAULT_VALUE'])) + $default_fields = $accountinfo_value['DEFAULT_VALUE']; + $list_fields = $accountinfo_value['LIST_FIELDS']; + $tab_options['FILTRE'] = array_flip($list_fields); + //END SHOW ACCOUNTINFO + } + $list_fields2 = array($l->g(46) => "h.lastdate", 'NAME' => 'h.name', $l->g(24) => "h.userid", @@ -255,7 +262,7 @@ $l->g(557) => "h.userdomain"); $tab_options["replace_query_arg"]['MD5_DEVICEID'] = " md5(deviceid) "; - $list_fields = array_merge($list_fields, $list_fields2); + $list_fields = isset($list_fields) ? array_merge($list_fields, $list_fields2) : $list_fields2; $sql = prepare_sql_tab($list_fields); $list_fields = array_merge($list_fields, array('MD5_DEVICEID' => "MD5_DEVICEID")); $tab_options['ARG_SQL'] = $sql['ARG']; diff --git a/plugins/main_sections/ms_ipdiscover/ms_ipdiscover.php b/plugins/main_sections/ms_ipdiscover/ms_ipdiscover.php index 468d3667f..fab37d713 100644 --- a/plugins/main_sections/ms_ipdiscover/ms_ipdiscover.php +++ b/plugins/main_sections/ms_ipdiscover/ms_ipdiscover.php @@ -56,8 +56,7 @@ $list_index[$key] = $value; } asort($list_index); - - if ($protectedPost['onglet'] == "") { + if (!isset($protectedPost['onglet'])) { $protectedPost['onglet'] = 1; } diff --git a/plugins/main_sections/ms_ipdiscover/ms_ipdiscover_analyse.php b/plugins/main_sections/ms_ipdiscover/ms_ipdiscover_analyse.php index d7da5a108..e8135047b 100755 --- a/plugins/main_sections/ms_ipdiscover/ms_ipdiscover_analyse.php +++ b/plugins/main_sections/ms_ipdiscover/ms_ipdiscover_analyse.php @@ -52,7 +52,6 @@ $l->g(49) => "NAME", $l->g(232) => "DATE", $l->g(66) => "TYPE"); - $ret = array(); $ret = parse_xml_file($file_name, $tabBalises, "HOST"); if ($ret != array()) { $sql = "select "; From 06ad81189774358330c11b25f293874a398a33ca Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:15:21 +0000 Subject: [PATCH 008/187] php8 fix warnings on ms_teledeploy --- .../ms_teledeploy/ms_custom_pack.php | 2 +- .../ms_teledeploy/ms_tele_activate.php | 20 ++++++------- .../ms_teledeploy/ms_tele_actives.php | 11 +++---- .../ms_teledeploy/ms_tele_popup_active.php | 8 ++--- .../ms_teledeploy/ms_tele_stats.php | 1 + .../ms_teledeploy/views/package_form_view.php | 29 +++++-------------- 6 files changed, 27 insertions(+), 44 deletions(-) diff --git a/plugins/main_sections/ms_teledeploy/ms_custom_pack.php b/plugins/main_sections/ms_teledeploy/ms_custom_pack.php index 8e66ae138..3bd3d20f1 100644 --- a/plugins/main_sections/ms_teledeploy/ms_custom_pack.php +++ b/plugins/main_sections/ms_teledeploy/ms_custom_pack.php @@ -76,7 +76,7 @@ //activation options if(isset($protectedPost['Valid_package'])) { foreach ($protectedPost as $key => $value) { - if(strpos($key, 'check') !== false){ + if(str_contains($key, 'check')){ $id[] = substr($key, 5); } } diff --git a/plugins/main_sections/ms_teledeploy/ms_tele_activate.php b/plugins/main_sections/ms_teledeploy/ms_tele_activate.php index 147fd9602..9c284bc46 100644 --- a/plugins/main_sections/ms_teledeploy/ms_tele_activate.php +++ b/plugins/main_sections/ms_teledeploy/ms_tele_activate.php @@ -55,7 +55,7 @@ $data_on['AVAILABLE_PACKET'] = $l->g(2123); $data_on['DELETED_PACKET'] = $l->g(2124); -if ($protectedPost['onglet'] != $protectedPost['old_onglet']) { +if (isset($protectedPost['onglet']) && isset($protectedPost['old_onglet']) && ($protectedPost['onglet'] != $protectedPost['old_onglet'])) { unset($protectedPost['MODIF']); } @@ -96,7 +96,7 @@ } if (isset($protectedPost['Valid_modif']) || isset($protectedPost['YES'])) { - if ($protectedPost['choix_activ'] == "MAN") { + if (isset($protectedPost['choix_activ']) && $protectedPost['choix_activ'] == "MAN") { activ_pack($protectedGet["active"], $protectedPost["HTTPS_SERV"], $protectedPost['FILE_SERV']); } echo ""; @@ -109,12 +109,12 @@ if ($protectedPost['onglet'] == "AVAILABLE_PACKET") { //only for profils who can activate packet if (!$cant_active) { - if ($protectedPost["SUP_PROF"] != "") { + if (!empty($protectedPost["SUP_PROF"])) { del_pack($protectedPost["SUP_PROF"]); $tab_options['CACHE'] = 'RESET'; } //delete more than one packet - if ($protectedPost['del_check'] != '') { + if (!empty($protectedPost['del_check'])) { foreach (explode(",", $protectedPost['del_check']) as $key) { del_pack($key); $tab_options['CACHE'] = 'RESET'; @@ -122,7 +122,7 @@ } } - if (!$protectedPost['SHOW_SELECT']) { + if (!isset($protectedPost['SHOW_SELECT'])) { $protectedPost['SHOW_SELECT'] = 'download'; $tab_options['SHOW_SELECT'] = 'download'; } @@ -148,7 +148,7 @@ $config_document_root = "DOWNLOAD_REP_CREAT"; } $info_document_root = look_config_default_values($config_document_root); - $document_root = $info_document_root["tvalue"][$config_document_root]; + $document_root = $info_document_root["tvalue"][$config_document_root] ?? ''; //if no directory in base, take $_SERVER["DOCUMENT_ROOT"] if (!isset($document_root)) { $document_root = VARLIB_DIR . '/download'; @@ -271,7 +271,7 @@ function manualActive() 'SUCC' => $l->g(572), 'ERR_' => $l->g(344)); $tab_options['REQUEST']['STAT'] = 'select distinct fileid AS FIRST from devices d,download_enable de where d.IVALUE=de.ID '; - if ($restrict_computers) { + if (isset($restrict_computers)) { $tab_options['REQUEST']['STAT'] .= 'and d.hardware_id in '; $temp = mysql2_prepare($tab_options['REQUEST']['STAT'], array(), $restrict_computers); $tab_options['ARG']['STAT'] = $temp['ARG']; @@ -282,7 +282,7 @@ function manualActive() $tab_options['REQUEST']['SHOWACTIVE'] = 'select distinct fileid AS FIRST from download_enable'; $tab_options['FIELD']['SHOWACTIVE'] = 'FILEID'; //on force le tri desc pour l'ordre des paquets - if (!$protectedPost['sens_' . $table_name]) { + if (!isset($protectedPost['sens_' . $table_name])) { $protectedPost['sens_' . $table_name] = 'DESC'; } @@ -305,7 +305,7 @@ function manualActive() $_SESSION['OCS']['ARG_DATA_FIXE'][$table_name]['NOTI'] = array('NOTI', 'LIKE', 'NOTI%'); $_SESSION['OCS']['ARG_DATA_FIXE'][$table_name]['NO_NOTIF'] = array('NO_NOTIF', 'IS NULL'); - if ($restrict_computers) { + if (isset($restrict_computers)) { $sql_data_fixe .= " and d.hardware_id in "; $sql_data_fixe_bis .= " and d.hardware_id in "; $sql_data_fixe_ter .= " and d.hardware_id in "; @@ -314,7 +314,7 @@ function manualActive() $temp_ter = mysql2_prepare($sql_data_fixe_ter, array(), $restrict_computers); } foreach ($_SESSION['OCS']['ARG_DATA_FIXE'][$table_name] as $key => $value) { - if ($restrict_computers) { + if (isset($restrict_computers)) { if ($key != 'NO_NOTIF' && $key != 'ERR_') { $_SESSION['OCS']['ARG_DATA_FIXE'][$table_name][$key] = array_merge($_SESSION['OCS']['ARG_DATA_FIXE'][$table_name][$key], $temp['ARG']); $_SESSION['OCS']['SQL_DATA_FIXE'][$table_name][$key] = $temp['SQL'] . " group by FILEID"; diff --git a/plugins/main_sections/ms_teledeploy/ms_tele_actives.php b/plugins/main_sections/ms_teledeploy/ms_tele_actives.php index f7d0203fb..fbab46b64 100644 --- a/plugins/main_sections/ms_teledeploy/ms_tele_actives.php +++ b/plugins/main_sections/ms_teledeploy/ms_tele_actives.php @@ -1,4 +1,5 @@ getRestriction('TELEDIFF_ACTIVATE') == 'NO') { $cant_active = false; } else { $cant_active = true; } - if (!$cant_active) { - if ($protectedPost['DEL_ALL'] != '') { + if (!empty($protectedPost['DEL_ALL'])) { $sql_listIDdel = "select distinct ID from download_enable where FILEID=%s"; $arg_listIDdel = $protectedPost['DEL_ALL']; $res_listIDdel = mysql2_query_secure($sql_listIDdel, $_SESSION['OCS']["readServer"], $arg_listIDdel); @@ -44,14 +42,14 @@ $listIDdel[] = $val_listIDdel['ID']; } if ($listIDdel != '') { - foreach ($listIDdel as $k => $v) { + foreach ($listIDdel as $v) { desactive_packet('', $v); } } mysql2_query_secure("DELETE FROM download_enable WHERE FILEID=%s", $_SESSION['OCS']["writeServer"], $protectedPost['DEL_ALL']); echo ""; } - if ($protectedPost['SUP_PROF'] != '') { + if (!empty($protectedPost['SUP_PROF'])) { desactive_packet('', $protectedPost['SUP_PROF']); mysql2_query_secure("DELETE FROM download_enable WHERE ID=%s", $_SESSION['OCS']["writeServer"], $protectedPost['SUP_PROF']); } @@ -102,4 +100,3 @@ ob_end_clean(); tab_req($list_fields, $default_fields, $list_col_cant_del, $querypack, $tab_options); } -?> \ No newline at end of file diff --git a/plugins/main_sections/ms_teledeploy/ms_tele_popup_active.php b/plugins/main_sections/ms_teledeploy/ms_tele_popup_active.php index e32bef4d5..7b452518c 100755 --- a/plugins/main_sections/ms_teledeploy/ms_tele_popup_active.php +++ b/plugins/main_sections/ms_teledeploy/ms_tele_popup_active.php @@ -29,11 +29,11 @@ //ouverture du formulaire echo open_form($form_name, $action_redirect, '', 'form-horizontal'); - if ((!isset($protectedPost['FILE_SERV']) && $protectedPost['choix_activ'] == 'MAN') || !isset($protectedPost['HTTPS_SERV'])) { + if ((!isset($protectedPost['FILE_SERV']) && isset($protectedPost['choix_activ']) && $protectedPost['choix_activ'] == 'MAN') || !isset($protectedPost['HTTPS_SERV'])) { $default = $_SERVER["SERVER_ADDR"] . "/download"; $values = look_config_default_values(array('DOWNLOAD_URI_INFO', 'DOWNLOAD_URI_FRAG')); - $protectedPost['FILE_SERV'] = $values['tvalue']['DOWNLOAD_URI_FRAG']; - $protectedPost['HTTPS_SERV'] = $values['tvalue']['DOWNLOAD_URI_INFO']; + $protectedPost['FILE_SERV'] = $values['tvalue']['DOWNLOAD_URI_FRAG'] ?? ''; + $protectedPost['HTTPS_SERV'] = $values['tvalue']['DOWNLOAD_URI_INFO'] ?? ''; if ($protectedPost['FILE_SERV'] == "") { $protectedPost['FILE_SERV'] = $default; } @@ -68,7 +68,7 @@ } } } - modif_values($tab_name, $tab_typ_champ, $tab_hidden, array( + modif_values($tab_name, $tab_typ_champ, $tab_hidden ?? '', array( 'title' => $l->g(465) . ' => ' . $info_id['NAME'] . " (" . $protectedGet["active"] . ")" )); } diff --git a/plugins/main_sections/ms_teledeploy/ms_tele_stats.php b/plugins/main_sections/ms_teledeploy/ms_tele_stats.php index 78a61c7a6..80953fb42 100644 --- a/plugins/main_sections/ms_teledeploy/ms_tele_stats.php +++ b/plugins/main_sections/ms_teledeploy/ms_tele_stats.php @@ -157,6 +157,7 @@ " . $l->g(55) . " "; $j = 0; +$nb = 0; while ($j < $i) { $nb += $count_value[$j]; echo ""; diff --git a/plugins/main_sections/ms_teledeploy/views/package_form_view.php b/plugins/main_sections/ms_teledeploy/views/package_form_view.php index 4fb35fb39..7308d5ca4 100755 --- a/plugins/main_sections/ms_teledeploy/views/package_form_view.php +++ b/plugins/main_sections/ms_teledeploy/views/package_form_view.php @@ -1,4 +1,5 @@ '; } - function show_basic_info_frame($data, $errors) { global $l; @@ -140,20 +138,12 @@ function show_basic_info_frame($data, $errors) { ), )); - switch ($data['ACTION']) { - case 'EXECUTE': - $action_input_label = $l->g(444); - break; - case 'STORE': - $action_input_label = $l->g(445); - break; - case 'LAUNCH': - $action_input_label = $l->g(446); - break; - default: - $action_input_label = ''; - break; - } + $action_input_label = match ($data['ACTION']) { + 'EXECUTE' => $l->g(444), + 'STORE' => $l->g(445), + 'LAUNCH' => $l->g(446), + default => '', + }; show_form_field($data, $errors, 'input', 'ACTION_INPUT', $action_input_label); echo ''; @@ -162,7 +152,6 @@ function show_basic_info_frame($data, $errors) { echo ''; } - function show_deploy_speed_frame($data, $errors) { global $l; @@ -196,8 +185,6 @@ function show_deploy_speed_frame($data, $errors) { echo ''; } - - function show_user_messages_frame($data, $errors) { global $l; @@ -258,5 +245,3 @@ function show_user_messages_frame($data, $errors) { echo ''; echo ''; } - -?> \ No newline at end of file From a073b44c369a6322cb51cbc5443546d060122381 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:16:54 +0000 Subject: [PATCH 009/187] php8 fix warnings on require/teledeploy/ --- require/teledeploy/PackageBuilder.php | 27 +++++++------------ require/teledeploy/PackageBuilderForm.php | 24 +++++------------ .../PackageBuilderFormInteractions.php | 8 +++--- .../PackageBuilderFormOperatingSystem.php | 4 +-- .../teledeploy/PackageBuilderFormOptions.php | 15 +++-------- require/teledeploy/Teledeploy.php | 2 +- 6 files changed, 24 insertions(+), 56 deletions(-) diff --git a/require/teledeploy/PackageBuilder.php b/require/teledeploy/PackageBuilder.php index 3337e4cc2..bfa4877c0 100644 --- a/require/teledeploy/PackageBuilder.php +++ b/require/teledeploy/PackageBuilder.php @@ -26,8 +26,6 @@ */ class PackageBuilder { - private $packageBuilderForm; - private $packageBuilderParseXml; private $downloadConfig = []; /** @@ -38,10 +36,7 @@ class PackageBuilder * * @return void */ - function __construct($packageBuilderForm, $packageBuilderParseXml) { - $this->packageBuilderForm = $packageBuilderForm; - $this->packageBuilderParseXml = $packageBuilderParseXml; - + function __construct(private $packageBuilderForm, private $packageBuilderParseXml) { $this->downloadConfig = look_config_default_values([ 'DOWNLOAD_PACK_DIR' => 'DOWNLOAD_PACK_DIR', 'DOWNLOAD_ACTIVATE_FRAG' => 'DOWNLOAD_ACTIVATE_FRAG', @@ -52,13 +47,13 @@ function __construct($packageBuilderForm, $packageBuilderParseXml) { 'DOWNLOAD_PROTOCOL' => 'DOWNLOAD_PROTOCOL' ]); - if ($this->downloadConfig['tvalue']['DOWNLOAD_URI_FRAG'] == "") { + if (empty($this->downloadConfig['tvalue']['DOWNLOAD_URI_FRAG'])) { $this->downloadConfig['tvalue']['DOWNLOAD_URI_FRAG'] = $_SERVER["SERVER_ADDR"]."/download"; } - if ($this->downloadConfig['tvalue']['DOWNLOAD_URI_INFO'] == "") { + if (empty($this->downloadConfig['tvalue']['DOWNLOAD_URI_INFO'])) { $this->downloadConfig['tvalue']['DOWNLOAD_URI_INFO'] = $_SERVER["SERVER_ADDR"]."/download"; } - if ($this->downloadConfig['tvalue']['DOWNLOAD_PROTOCOL'] == "") { + if (empty($this->downloadConfig['tvalue']['DOWNLOAD_PROTOCOL'])) { $this->downloadConfig['tvalue']['DOWNLOAD_PROTOCOL'] = "HTTP"; } } @@ -103,7 +98,7 @@ public function buildPackage($post, $file = null) { fclose($handscript); } - if($file["additionalfiles"]['size'] != 0 && file_exists($file["additionalfiles"]["tmp_name"])) { + if(!empty($file["additionalfiles"]['size']) && file_exists($file["additionalfiles"]["tmp_name"])) { //verif if is an archive file $name_file_extention = explode('.', $file["additionalfiles"]["name"]); $extention = array_pop($name_file_extention); @@ -163,7 +158,7 @@ public function buildPackage($post, $file = null) { } // Generate info xml - $info = $this->writePackageInfo($xmlDetails, $timestamp, $details['frag'], $digest, $post['pathfile']); + $info = $this->writePackageInfo($xmlDetails, $timestamp, $details['frag'], $digest); // Create info file $handinfo = fopen($downloadPath."/info", "w+"); fwrite($handinfo, $info); @@ -254,7 +249,7 @@ private function tarScriptFile($path, $name, $newName) { if(file_exists($tarPath)) { unlink($tarPath); } - } catch (Exception $e) { + } catch (Exception) { error_log(print_r("error when tar gz file",true)); } @@ -390,17 +385,15 @@ private function writePackageInfo($xmlDetails, $timestamp, $nbFrag, $digest) { if ($xmlDetails->packagedefinition->ACT == 'EXECUTE') { $info .= "COMMAND=\"" . $xmlDetails->packagedefinition->COMMAND . "\" "; } - - $info .= "NOTIFY_USER=\"" . $xmlDetails->packagedefinition->NOTIFY_USER . "\" " . + + return $info . ("NOTIFY_USER=\"" . $xmlDetails->packagedefinition->NOTIFY_USER . "\" " . "NOTIFY_TEXT=\"" . $xmlDetails->packagedefinition->NOTIFY_TEXT . "\" " . "NOTIFY_COUNTDOWN=\"" . $xmlDetails->packagedefinition->NOTIFY_COUNTDOWN . "\" " . "NOTIFY_CAN_ABORT=\"" . $xmlDetails->packagedefinition->NOTIFY_CAN_ABORT . "\" " . "NOTIFY_CAN_DELAY=\"" . $xmlDetails->packagedefinition->NOTIFY_CAN_DELAY . "\" " . "NEED_DONE_ACTION=\"" . $xmlDetails->packagedefinition->NEED_DONE_ACTION . "\" " . "NEED_DONE_ACTION_TEXT=\"" . $xmlDetails->packagedefinition->NEED_DONE_ACTION_TEXT . "\" " . - "GARDEFOU=\"rien\" />\n"; - - return $info; + "GARDEFOU=\"rien\" />\n"); } diff --git a/require/teledeploy/PackageBuilderForm.php b/require/teledeploy/PackageBuilderForm.php index 887d2e3a1..3abf2d538 100644 --- a/require/teledeploy/PackageBuilderForm.php +++ b/require/teledeploy/PackageBuilderForm.php @@ -26,11 +26,6 @@ */ class PackageBuilderForm { - private $packageBuildeFormInteractions; - private $packageBuilderFormOperatingSystem; - private $packageBuilderParseXml; - private $packageBuilderFormOptions; - /** * Method __construct * @@ -41,11 +36,8 @@ class PackageBuilderForm * * @return void */ - function __construct($packageBuildeFormInteractions, $packageBuilderFormOperatingSystem, $packageBuilderParseXml, $packageBuilderFormOptions) { - $this->packageBuilderFormOperatingSystem = $packageBuilderFormOperatingSystem; - $this->packageBuildeFormInteractions = $packageBuildeFormInteractions; - $this->packageBuilderParseXml = $packageBuilderParseXml; - $this->packageBuilderFormOptions = $packageBuilderFormOptions; + function __construct(private $packageBuildeFormInteractions, private $packageBuilderFormOperatingSystem, private $packageBuilderParseXml, private $packageBuilderFormOptions) + { } /** @@ -60,9 +52,8 @@ public function generateOperatingSystem() { foreach($operating->osdefinition as $system) { $html .= $this->packageBuilderFormOperatingSystem->generateTile($system); } - $html .= ''; - return $html; + return $html . ''; } /** @@ -116,9 +107,8 @@ public function generateOptions($os, $linkedOption, $language) { $optionInfos = $this->packageBuilderParseXml->parseOptions($linkedOption); $html = '

'.$l->g(intval($optionInfos->name)).'


'; - $html .= $this->packageBuilderFormOptions->generateOptions($optionInfos, $l); - return $html; + return $html . $this->packageBuilderFormOptions->generateOptions($optionInfos, $l); } /** @@ -133,7 +123,7 @@ public function generateResume($packageInfos) { $html = '

Resume



'; - $html .= '
+ return $html . ('
@@ -156,8 +146,6 @@ public function generateResume($packageInfos) {
-
'; - - return $html; +
'); } } \ No newline at end of file diff --git a/require/teledeploy/PackageBuilderFormInteractions.php b/require/teledeploy/PackageBuilderFormInteractions.php index 55a092b45..a60cfa2a8 100644 --- a/require/teledeploy/PackageBuilderFormInteractions.php +++ b/require/teledeploy/PackageBuilderFormInteractions.php @@ -26,10 +26,8 @@ */ class PackageBuilderFormInteractions { - private $packageBuilderParseXml; - - function __construct($packageBuilderParseXml) { - $this->packageBuilderParseXml = $packageBuilderParseXml; + function __construct(private $packageBuilderParseXml) + { } /** @@ -62,7 +60,7 @@ public function generateInteractionCollapse($interactions) { global $l; $html = ""; - $orderInteractions = $this->orderInteractions($interactions); + $this->orderInteractions($interactions); foreach($interactions as $interactionDetails) { $xmlInteractionDetails = $this->packageBuilderParseXml->parseInteractions($interactionDetails); $html .= '
diff --git a/require/teledeploy/PackageBuilderFormOperatingSystem.php b/require/teledeploy/PackageBuilderFormOperatingSystem.php index 096dc1fc8..ca0ceb380 100644 --- a/require/teledeploy/PackageBuilderFormOperatingSystem.php +++ b/require/teledeploy/PackageBuilderFormOperatingSystem.php @@ -32,8 +32,7 @@ class PackageBuilderFormOperatingSystem */ public function generateTile($system) { global $l; - - $tile = '
+ return ''; - return $tile; } } \ No newline at end of file diff --git a/require/teledeploy/PackageBuilderFormOptions.php b/require/teledeploy/PackageBuilderFormOptions.php index a2b9c4a00..85b60dee2 100644 --- a/require/teledeploy/PackageBuilderFormOptions.php +++ b/require/teledeploy/PackageBuilderFormOptions.php @@ -20,18 +20,11 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ - - /** - * Class for PackageBuilderFormOptions - */ +/** + * Class for PackageBuilderFormOptions + */ class PackageBuilderFormOptions { - private $packageBuilderParseXml; - - function __construct($packageBuilderParseXml) { - $this->packageBuilderParseXml = $packageBuilderParseXml; - } - /** * Generate Options */ @@ -116,7 +109,6 @@ function changeLabelAction(){ "; } return $select; - break; case 'code': return '
@@ -142,7 +134,6 @@ function changeLabelAction(){ }); '; - break; default: return 'javascript.' '.$formblockDetails->mandatory.'>'; diff --git a/require/teledeploy/Teledeploy.php b/require/teledeploy/Teledeploy.php index 158cef36a..2843ecbb3 100644 --- a/require/teledeploy/Teledeploy.php +++ b/require/teledeploy/Teledeploy.php @@ -28,7 +28,7 @@ class Teledeploy { public function get_package($timestamp){ - $zipfile = new zipArchive(); + new zipArchive(); $sql_document_root = "SELECT tvalue FROM config WHERE NAME='DOWNLOAD_PACK_DIR'"; From 41ff0585b0ab2e17df6ab66209a47aafa0095c80 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:18:03 +0000 Subject: [PATCH 010/187] php8 fix warnings on reuire/tables/ --- require/tables/Column.php | 7 +------ require/tables/LinkColumn.php | 8 ++------ require/tables/Table.php | 7 ++----- require/tables/table.html.php | 30 +++++++++++++++++++++++------- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/require/tables/Column.php b/require/tables/Column.php index 2e1c08385..1875686da 100755 --- a/require/tables/Column.php +++ b/require/tables/Column.php @@ -22,23 +22,18 @@ */ class Column { - private $name; - private $label; private $required; private $sortable; private $searchable; private $formatter; - public function __construct($name, $label, $options = array()) { + public function __construct(private $name, private $label, $options = array()) { $options = array_merge(array( 'required' => false, 'sortable' => true, 'searchable' => true, 'formatter' => null ), $options); - - $this->name = $name; - $this->label = $label; $this->required = $options['required']; $this->sortable = $options['sortable']; $this->searchable = $options['searchable']; diff --git a/require/tables/LinkColumn.php b/require/tables/LinkColumn.php index 6746b08d1..ed4eb49aa 100755 --- a/require/tables/LinkColumn.php +++ b/require/tables/LinkColumn.php @@ -1,4 +1,5 @@ url = $url; $this->idProperty = $options['idProperty'] ?: 'id'; parent::__construct($name, $label, $options); @@ -69,4 +66,3 @@ public function formatLink($record) { } } -?> \ No newline at end of file diff --git a/require/tables/Table.php b/require/tables/Table.php index 5b6266854..dce1d7e70 100755 --- a/require/tables/Table.php +++ b/require/tables/Table.php @@ -1,4 +1,5 @@ name = $name; + public function __construct(private $name) { $this->columns = array(); } @@ -53,4 +51,3 @@ public function getColumn($name) { } } -?> \ No newline at end of file diff --git a/require/tables/table.html.php b/require/tables/table.html.php index 48960bb7a..983c218de 100755 --- a/require/tables/table.html.php +++ b/require/tables/table.html.php @@ -1,13 +1,28 @@ +
- +
- - getColumns() as $name => $col) { +
+ getColumns() as $col) { echo ""; } - ?> +?>
" . $col->getLabel() . "
@@ -21,7 +36,8 @@ - +
\ No newline at end of file + endif ?> From f24c1da6a8a74869245006a25bce6dc7b325a290 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:31:08 +0000 Subject: [PATCH 011/187] php8 syntax update on require/table/ --- require/table/Column.php | 15 ++------------- require/table/Columns.php | 19 ------------------- require/table/Table.php | 5 +---- 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/require/table/Column.php b/require/table/Column.php index 3d26f9222..3e6c7b374 100755 --- a/require/table/Column.php +++ b/require/table/Column.php @@ -20,23 +20,12 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ - /** * Handle properties of every column of the table */ abstract class Column { - private $label; - private $key; - private $visible; - private $deletable; - private $sortable; - - public function __construct($key, $label, $visible, $deletable, $sortable) { - $this->key = $key; - $this->label = $label; - $this->visible = $visible; - $this->deletable = $deletable; - $this->sortable = $sortable; + public function __construct(private $label, private $visible, private $deletable, private $sortable) + { } /* diff --git a/require/table/Columns.php b/require/table/Columns.php index a53d71e6f..4ba0fb7d5 100755 --- a/require/table/Columns.php +++ b/require/table/Columns.php @@ -20,32 +20,16 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ - /** * Handle Column Objects arrays for the table */ class Columns { private $allcolumns; - private $columnscantdel; - private $columnscandel; private $columnsvisible; - private $columnsspecial; - private $defaultcolumns; public function __construct() { $this->allcolumns = array(); - $this->columnscantdel = array(); - $this->columnscandel = array(); $this->columnsvisible = array(); - $this->columnsspecial = array( - "CHECK", "SUP", - "GROUP_NAME", - "NULL", "MODIF", - "SELECT", "ZIP", - "OTHER", "STAT", - "ACTIVE", "MAC", - "MD5_DEVICEID", - ); } /* @@ -99,9 +83,6 @@ public function addColumn($key, $label, $visible, $deletable, $sortable) { if ($visible) { $this->columnsvisible[] = $key; } - if ($cantdel) { - $this->columnscantdel[] = $key; - } return $this->allcolumns[$key]; } else { return $column; diff --git a/require/table/Table.php b/require/table/Table.php index f4ce0a1b0..dd4c2ce4b 100755 --- a/require/table/Table.php +++ b/require/table/Table.php @@ -25,17 +25,14 @@ * Handle tables display */ class Table { - private $columns; private $params; public function __construct() { include("Columns.php"); - $this->columns = new Columns(); } public function getColumns() { - $allcolumns = $this->getColumns(); - $columnsreturn; + $this->getColumns(); } /* From 0554f2326909c4bae27af5687aad5380566376c9 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:34:18 +0000 Subject: [PATCH 012/187] php8 fix warnings on require/search/ --- require/search/AccountinfoSearch.php | 10 +-- require/search/DatabaseSearch.php | 20 +++--- require/search/SQLCache.php | 19 +++--- require/search/Search.php | 94 +++++++++++----------------- require/search/SoftwareSearch.php | 49 +++++---------- require/search/TranslationSearch.php | 8 +-- 6 files changed, 76 insertions(+), 124 deletions(-) diff --git a/require/search/AccountinfoSearch.php b/require/search/AccountinfoSearch.php index 6d136b6f4..62601f999 100644 --- a/require/search/AccountinfoSearch.php +++ b/require/search/AccountinfoSearch.php @@ -55,9 +55,8 @@ class AccountinfoSearch /** * Objects */ - private $dbObject = null; - private $dbName = null; - private $accountInfosStruct = null; + private $dbObject; + private $accountInfosStruct; /** @@ -65,7 +64,6 @@ class AccountinfoSearch */ function __construct() { $this->dbObject = $_SESSION['OCS']["readServer"]; - $this->dbName = DB_NAME; $this->createAccountInfoStruct(); $this->retrieveAccountInfosConfig(); } @@ -151,9 +149,7 @@ public function find_accountinfo_values($field, $typeInfo = null){ $info = 'ACCOUNT_VALUE_'.$type['NAME']; } - $values = find_value_field($info, $typeInfo); - - return $values; + return find_value_field($info, $typeInfo); } } diff --git a/require/search/DatabaseSearch.php b/require/search/DatabaseSearch.php index 318157d24..2c7644a5c 100644 --- a/require/search/DatabaseSearch.php +++ b/require/search/DatabaseSearch.php @@ -34,7 +34,7 @@ class DatabaseSearch */ const FIELD = 'Field'; const TYPE = 'Type'; - const NULLABLE = 'Nullable'; + const NULLABLE = 'Null'; const KEY = 'Key'; const DEFAULT_VAL = 'Default'; const EXTRA = 'Extra'; @@ -79,9 +79,8 @@ class DatabaseSearch /** * Objects */ - private $dbObject = null; - private $dbName = null; - private $softwareSearch = null; + private $dbObject; + private $dbName; /** * Constructor @@ -102,7 +101,10 @@ function __construct($softwareSearch) */ public function getColumnsList($tableName) { - return $this->columnsList[$tableName]; + if(isset($this->columnsList[$tableName])) { + return $this->columnsList[$tableName]; + } + } /** @@ -176,7 +178,6 @@ private function retireveColumnsList($tableName) /** * Get an list of id of the current multi search (needed for buttons at the bottom of the page) * - * @param Search $searchObj * @return Array list of computers ID */ public function getIdList(Search $searchObj){ @@ -184,7 +185,7 @@ public function getIdList(Search $searchObj){ $idList = mysql2_query_secure($query, $this->dbObject, $searchObj->queryArgs); $idArray = []; - if($idList) foreach ($idList as $index => $fields) { + if($idList) foreach ($idList as $fields) { $idArray[] = $fields['hardwareID']; } return $idArray; @@ -200,8 +201,7 @@ public function getIdList(Search $searchObj){ */ private function normalizeFieldType($type) { - $splittedType = preg_replace('/\(.*?\)|\s*/', '', $type); - return $splittedType; + return preg_replace('/\(.*?\)|\s*/', '', $type); } /** @@ -221,7 +221,7 @@ public function get_package_id($fileid){ $sql= "SELECT id FROM download_enable d_e LEFT JOIN download_available d_a ON d_a.fileid=d_e.fileid WHERE 1=1 AND d_a.comment NOT LIKE '%[VISIBLE=0]%' AND d_e.fileid='".$fileid."'"; $idPackage = mysql2_query_secure($sql, $this->dbObject); - foreach ($idPackage as $index => $fields) { + foreach ($idPackage as $fields) { $idArray[] = $fields['id']; } return $idArray; diff --git a/require/search/SQLCache.php b/require/search/SQLCache.php index 25cf3a69a..02cc5e7cc 100644 --- a/require/search/SQLCache.php +++ b/require/search/SQLCache.php @@ -29,18 +29,13 @@ class SQLCache { const GROUP_TABLE = "groups_cache"; - - private $search; - private $software; private $searchQuery; private $columnsQueryConditions; /** * @param Search $search */ - function __construct($search, $software) { - $this->search = $search; - $this->software = $software; + function __construct(private $search, private $software) { $this->searchQuery = "SELECT DISTINCT hardware.ID FROM hardware "; } @@ -69,14 +64,14 @@ public function generateCacheSql($sessData){ $this->searchQuery .= "LEFT JOIN software_version on software_version.id = $tableName.version_id "; } - foreach ($searchInfos as $index => $value) { + foreach ($searchInfos as $value) { if($tableName == "download_history" && $value['fields'] == "PKG_NAME") { // Generate union $this->searchQuery .= "INNER JOIN download_available on download_available.FILEID = $tableName.PKG_ID "; } - if($value['comparator'] != null){ + if(isset($value['comparator'])){ $operator[] = $value['comparator']; - }elseif($i != 0 && $value['comparator'] == null){ + }elseif($i != 0 && empty($value['comparator'])){ $operator[] = "AND"; }else{ $operator[] = ""; @@ -94,7 +89,7 @@ public function generateCacheSql($sessData){ $containvalue[$index] = $value['operator']; } - foreach ($searchInfos as $index => $value) { + foreach ($searchInfos as $value) { $nameTable = $tableName; $open=""; $close=""; @@ -117,11 +112,11 @@ public function generateCacheSql($sessData){ } } - if($p == 0 && $operator[$p+1] == 'OR'){ + if($p == 0 && isset($operator[$p+1]) && $operator[$p+1] == 'OR'){ $open = "("; }if($operator[$p] =='OR' && $operator[$p+1] !='OR'){ $close=")"; - }if($p != 0 && $operator[$p] !='OR' && $operator[$p+1] =='OR'){ + }if($p != 0 && $operator[$p] !='OR' && isset($operator[$p+1]) && $operator[$p+1] =='OR'){ $open = "("; } diff --git a/require/search/Search.php b/require/search/Search.php index a4d15439b..22bd6e784 100644 --- a/require/search/Search.php +++ b/require/search/Search.php @@ -20,7 +20,6 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ - /** * This class implement the base behavior for search : * - Query generation @@ -141,18 +140,6 @@ class Search "OR" ]; - /** - * Multiples fields search - */ - private $multipleFieldsSearch = []; - private $multipleFieldsSearchCache = []; - - /** - * Final query and args used for multicrits - */ - private $finalQuery; - private $finalArgs; - /** * Constructor @@ -214,7 +201,7 @@ public function updateSessionsInfos($postData) { foreach ($postData as $key => $value) { $keyExploded = explode("_", $key); - if(count($keyExploded) > 1 && !is_null($_SESSION['OCS']['multi_search'][$keyExploded[1]])){ + if(count($keyExploded) > 1 && isset($_SESSION['OCS']['multi_search'][$keyExploded[1]]) && !is_null($_SESSION['OCS']['multi_search'][$keyExploded[1]])){ if ($keyExploded[2] == self::SESS_OPERATOR) { $_SESSION['OCS']['multi_search'][$keyExploded[1]][$keyExploded[0]][self::SESS_OPERATOR] = $value; } elseif($keyExploded[2] == self::SESS_FIELDS && $_SESSION['OCS']['multi_search'][$keyExploded[1]][$keyExploded[0]][self::SESS_OPERATOR] != 'ISNULL') { @@ -224,7 +211,7 @@ public function updateSessionsInfos($postData) } }elseif(count($keyExploded) == 4){ $keyExplodedBis = $keyExploded[1]."_".$keyExploded[2]; - if(!is_null($_SESSION['OCS']['multi_search'][$keyExplodedBis])){ + if(isset ($_SESSION['OCS']['multi_search'][$keyExplodedBis]) && !is_null($_SESSION['OCS']['multi_search'][$keyExplodedBis])){ if ($keyExploded[3] == self::SESS_OPERATOR) { $_SESSION['OCS']['multi_search'][$keyExplodedBis][$keyExploded[0]][self::SESS_OPERATOR] = $value; } elseif($keyExploded[3] == self::SESS_COMPARATOR){ @@ -269,7 +256,7 @@ public function removeSessionsInfos($rowReference){ public function getSearchedFieldType($tablename, $fieldsname) { $tableFields = $this->databaseSearch->getColumnsList($tablename); - return $tableFields[$fieldsname][DatabaseSearch::TYPE]; + return $tableFields[$fieldsname][DatabaseSearch::TYPE] ?? ''; } /** @@ -316,7 +303,7 @@ public function getFieldUniqId($uniqid, $tableName) */ public function generateSearchQuery($sessData){ - $accountInfos = new AccountinfoSearch(); + new AccountinfoSearch(); $this->pushBaseQueryForTable("hardware", null); if(!isset($sessData['accountinfo'])) $sessData['accountinfo'] = array(); foreach ($sessData as $tableName => $searchInfos) { @@ -344,15 +331,15 @@ public function generateSearchQuery($sessData){ $this->searchQuery .= "LEFT JOIN software_version on software_version.id = $tableName.version_id "; } - foreach ($searchInfos as $index => $value) { + foreach ($searchInfos as $value) { if($tableName == "download_history" && $value['fields'] == "PKG_NAME") { // Generate union $this->searchQuery .= "INNER JOIN download_available on download_available.FILEID = $tableName.PKG_ID "; } - if($value['comparator'] != null){ + if(isset($value['comparator'])){ $operator[] = $value['comparator']; - }elseif($i != 0 && $value['comparator'] == null){ + }elseif($i != 0 && !isset($value['comparator'])){ $operator[] = "AND"; }else{ $operator[] = ""; @@ -371,7 +358,7 @@ public function generateSearchQuery($sessData){ $containvalue[$index] = $value['operator']; } - foreach ($searchInfos as $index => $value) { + foreach ($searchInfos as $value) { $nameTable = $tableName; $open=""; $close=""; @@ -395,11 +382,11 @@ public function generateSearchQuery($sessData){ } } - if($p == 0 && $operator[$p+1] == 'OR'){ + if($p == 0 && isset($operator[$p+1]) && $operator[$p+1] == 'OR'){ $open = "("; }if($operator[$p] =='OR' && $operator[$p+1] !='OR'){ $close=")"; - }if($p != 0 && $operator[$p] !='OR' && $operator[$p+1] =='OR'){ + }if($p != 0 && $operator[$p] !='OR' && isset($operator[$p+1]) && $operator[$p+1] =='OR'){ $open = "("; } @@ -580,7 +567,7 @@ public function generateSearchQuery($sessData){ } // has lock machine ? - if (isset($_SESSION['OCS']["mesmachines"]) && strpos($_SESSION['OCS']["mesmachines"], 'a.TAG') === false) { + if (isset($_SESSION['OCS']["mesmachines"]) && !str_contains($_SESSION['OCS']["mesmachines"], 'a.TAG')) { $lockResult = str_replace('a.hardware_id', 'accountinfo.hardware_id', $_SESSION['OCS']["mesmachines"]); $this->columnsQueryConditions .= " AND " . $lockResult; } @@ -593,17 +580,15 @@ public function generateSearchQuery($sessData){ * Generate select query for table using session variables generated from the search * * @param String $tableName - * @param Array $sessData * @return void */ - private function pushBaseQueryForTable($tableName, $sessData = null){ - foreach($this->databaseSearch->getColumnsList($tableName) as $index => $fieldsInfos){ - $name = ""; + private function pushBaseQueryForTable($tableName){ + foreach($this->databaseSearch->getColumnsList($tableName) as $fieldsInfos){ + $name = ""; if($tableName == "download_history" && $fieldsInfos['Field'] == "PKG_NAME"){ $tableName = "download_available"; $fieldsInfos['Field'] = "NAME"; } - if($tableName == "software" && array_key_exists($fieldsInfos['Field'], $this->correspondance)) { if($fieldsInfos['Field'] == "CATEGORY") { $table = $tableName."_name"; @@ -721,14 +706,13 @@ public function getSelectOptionForOperators($defaultValue, $table = null, $field } $html = ""; - $operatorList = array(); if($table == self::GROUP_TABLE || $field == "CATEGORY_ID" || $field == "CATEGORY") { $operatorList = $this->operatorGroup; } elseif($accounttype == '2' || $accounttype == '11') { $operatorList = $this->operatorAccount; } elseif($accounttype == '5') { $operatorList = $this->operatorAccountCheckbox; - } elseif($this->getSearchedFieldType($table, $field) == 'datetime') { + } elseif(isset($field) && $this->getSearchedFieldType($table, $field) == 'datetime') { $operatorList = array_merge($this->operatorList, $this->operatorDelay); } else { $operatorList = $this->operatorList; @@ -757,7 +741,7 @@ public function getSelectOptionForTables($defautValue = null) $html = ""; foreach ($this->databaseSearch->getTablesList() as $tableName) { $translation = $this->translationSearch->getTranslationFor($tableName); - $sortTable[$tableName] .= $translation; + $sortTable[$tableName] = $translation; } asort($sortTable); foreach ($sortTable as $key => $value){ @@ -786,28 +770,28 @@ public function getSelectOptionForColumns($tableName = null) $accountFields = $accountinfoList->getAccountInfosList(); if(isset($accountFields['COMPUTERS']) && is_array($accountFields['COMPUTERS'])) foreach ($accountFields['COMPUTERS'] as $index => $fieldsInfos) { - if(!in_array($fieldsIndefaultTablefos[DatabaseSearch::FIELD], $this->excludedVisuColumns)){ + // if(!in_array($fieldsIndefaultTablefos[DatabaseSearch::FIELD], $this->excludedVisuColumns)){ $trField = $fieldsInfos; - $sortColumn[$index] .= $trField; - } + $sortColumn[$index] = $trField; + // } } }elseif($tableName == self::GROUP_TABLE){ $trField = $this->translationSearch->getTranslationFor('NAME'); $sortColumn['name'] = $trField; }else{ $fields = $this->databaseSearch->getColumnsList($tableName); - if(is_array($fields)) foreach ($fields as $index => $fieldsInfos) { - if(!in_array($fieldsIndefaultTablefos[DatabaseSearch::FIELD], $this->excludedVisuColumns)){ + if(is_array($fields)) foreach ($fields as $fieldsInfos) { + //if(!in_array($fieldsIndefaultTablefos[DatabaseSearch::FIELD], $this->excludedVisuColumns)){ $trField = $this->translationSearch->getTranslationFor($fieldsInfos[DatabaseSearch::FIELD]); - $sortColumn[$fieldsInfos[DatabaseSearch::FIELD]] .= $trField; - } + $sortColumn[$fieldsInfos[DatabaseSearch::FIELD]] = $trField; + //} } } asort($sortColumn); foreach ($sortColumn as $key => $value){ - if(!in_array($fieldsIndefaultTablefos[DatabaseSearch::FIELD], $this->excludedVisuColumns)){ + //if(!in_array($fieldsIndefaultTablefos[DatabaseSearch::FIELD], $this->excludedVisuColumns)){ $html .= ""; - } + //} } return $html; } @@ -837,7 +821,7 @@ public function returnFieldHtml($uniqid, $fieldsInfos, $tableName, $field = null $this->type = self::HTML_SELECT; } elseif(array_key_exists($field, $this->correspondance)) { $this->type = $this->correspondance[$field]; - }elseif($accounttype == '2' || $accounttype == '11' || $accounttype =='5') { + }elseif(isset($accounttype) && ($accounttype == '2' || $accounttype == '11' || $accounttype =='5')) { $this->type = self::HTML_SELECT; } else { $this->type = $this->getSearchedFieldType($tableName, $fieldsInfos[self::SESS_FIELDS]); @@ -856,8 +840,6 @@ public function returnFieldHtml($uniqid, $fieldsInfos, $tableName, $field = null switch ($this->type) { case self::DB_VARCHAR: - $html = ''; - break; case self::DB_TEXT: $html = ''; @@ -914,13 +896,13 @@ public function returnFieldHtmlAndOr($uniqid, $fieldsInfos, $infos, $tableName, global $l; $i = 0; - foreach ($infos as $id => $value){ + foreach ($infos as $value){ if($value['fields'] == $fieldsInfos['fields']){ $i++; } } - $fieldId = $this->getFieldUniqId($uniqid, $tableName); + $this->getFieldUniqId($uniqid, $tableName); $html = ""; if($i > 1){ @@ -993,7 +975,7 @@ public function link_multi($fields, $value, $option = ""){ case 'ipdiscover1': $_SESSION['OCS']['multi_search'] = array(); if(!isset($_SESSION['OCS']['multi_search']['networks']['ipdiscover1'])){ - if(strpos($value, ";") !== false) { + if(str_contains($value, ";")) { $explode = explode(";", $value); $value = $explode[0]; if(count($explode) == 2) { @@ -1028,7 +1010,7 @@ public function link_multi($fields, $value, $option = ""){ 'value' => $value, 'operator' => 'EQUAL', ]; - if($tag != null && $tag != "") { + if(isset($tag) && !empty($tag)) { $_SESSION['OCS']['multi_search']['accountinfo']['ipdiscover5'] = [ 'fields' => 'TAG', 'value' => $tag, @@ -1144,7 +1126,7 @@ public function query_save($id) { * @param string $value [description] * @return [type] [description] */ - public function link_index($fields, $comp = "", $value, $value2 = null){ + public function link_index($fields, $value, $comp = "", $value2 = null){ $field = explode("-", $fields) ; if($comp== 'small') { $operator = 'LESS'; } @@ -1156,7 +1138,7 @@ public function link_index($fields, $comp = "", $value, $value2 = null){ } if(empty($field[2])){ - if(strpos($field[0], 'HARDWARE') !== false){ + if(str_contains($field[0], 'HARDWARE')){ if(!isset($_SESSION['OCS']['multi_search']['hardware']) || !array_key_exists('HARDWARE-'.$field[1].$comp.preg_replace("/\s+/","", preg_replace("/_/","",$value)).preg_replace("/_/","",$value2),$_SESSION['OCS']['multi_search']['hardware'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['hardware']['HARDWARE-'.$field[1].$comp.preg_replace("/\s+/","", preg_replace("/_/","",$value)).preg_replace("/_/","",$value2)] = [ @@ -1171,7 +1153,7 @@ public function link_index($fields, $comp = "", $value, $value2 = null){ 'operator' => 'LIKE', ]; } - }elseif(strpos($field[0], 'ACCOUNTINFO') !== false){ + }elseif(str_contains($field[0], 'ACCOUNTINFO')){ if(!isset($_SESSION['OCS']['multi_search']['accountinfo']) || !array_key_exists('ACCOUNTINFO-'.$field[1].$comp.$value,$_SESSION['OCS']['multi_search']['accountinfo'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['accountinfo']['ACCOUNTINFO-'.$field[1].$comp.preg_replace("/_/","",$value)] = [ @@ -1180,7 +1162,7 @@ public function link_index($fields, $comp = "", $value, $value2 = null){ 'operator' => $operator, ]; } - }elseif(strpos($field[0], 'NETWORKS') !== false){ + }elseif(str_contains($field[0], 'NETWORKS')){ if(!isset($_SESSION['OCS']['multi_search']['networks']) || !array_key_exists('NETWORKS-'.$field[1].$comp.$value,$_SESSION['OCS']['multi_search']['networks'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['networks']['NETWORKS-'.$field[1].$comp.preg_replace("/_/","",$value)] = [ @@ -1189,7 +1171,7 @@ public function link_index($fields, $comp = "", $value, $value2 = null){ 'operator' => $operator, ]; } - }elseif(strpos($field[0], 'VIDEOS') !== false){ + }elseif(str_contains($field[0], 'VIDEOS')){ if(!isset($_SESSION['OCS']['multi_search']['videos']) || !array_key_exists('VIDEOS-'.$field[1].$comp.$value,$_SESSION['OCS']['multi_search']['videos'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['videos']['VIDEOS-'.$field[1].$comp.preg_replace("/_/","",$value)] = [ @@ -1198,7 +1180,7 @@ public function link_index($fields, $comp = "", $value, $value2 = null){ 'operator' => $operator, ]; } - }elseif(strpos($field[0], 'ASSETS') !== false){ + }elseif(str_contains($field[0], 'ASSETS')){ if(!isset($_SESSION['OCS']['multi_search']['hardware']) || !array_key_exists('ASSETS'.$value,$_SESSION['OCS']['multi_search']['hardware'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['hardware']['ASSETS'.preg_replace("/_/","",$value)] = [ @@ -1287,7 +1269,7 @@ public function containmulti($name, $value){ $fieldname = "ID"; } - foreach ($value as $uniqID => $values){ + foreach ($value as $values){ if ($values['fields'] == $field && $values['operator'] == "DOESNTCONTAIN"){ $search[] = $values['value']; if($values['comparator'] != null){ @@ -1311,7 +1293,7 @@ public function containmulti($name, $value){ for($i = 0; $i != count($comparator)+1; $i++){ foreach($excluID as $key => $values){ - foreach($allID as $searching => $compare){ + foreach($allID as $compare){ if(!array_key_exists($values, $compare) && $comparator[$i] == "AND"){ unset($excluID[$key]); } diff --git a/require/search/SoftwareSearch.php b/require/search/SoftwareSearch.php index 379869ff1..68a7af74d 100644 --- a/require/search/SoftwareSearch.php +++ b/require/search/SoftwareSearch.php @@ -36,8 +36,7 @@ class SoftwareSearch self::NAME_TABLE, ]; - private $dbObject = null; - private $dbName = null; + private $dbObject; private $columnsList = []; /** @@ -46,7 +45,6 @@ class SoftwareSearch function __construct() { $this->dbObject = $_SESSION['OCS']["readServer"]; - $this->dbName = DB_NAME; } /** @@ -82,49 +80,32 @@ public function retrieveSoftwareColumns() { */ private function normalizeFieldType($type) { - $splittedType = preg_replace('/\(.*?\)|\s*/', '', $type); - return $splittedType; + return preg_replace('/\(.*?\)|\s*/', '', $type); } /** * Get Software table name */ public function getTableName($field) { - switch ($field) { - case "NAME_ID": - return self::NAME_TABLE; - break; - case "PUBLISHER_ID": - return self::PUBLISHER_TABLE; - break; - case "VERSION_ID" : - return self::VERSION_TABLE; - case "CATEGORY" : - return self::NAME_TABLE; - break; - default : - return self::SOFTWARE_TABLE; - break; - } + return match ($field) { + "NAME_ID" => self::NAME_TABLE, + "PUBLISHER_ID" => self::PUBLISHER_TABLE, + "VERSION_ID" => self::VERSION_TABLE, + "CATEGORY" => self::NAME_TABLE, + default => self::SOFTWARE_TABLE, + }; } /** * Get software column name */ public function getColumnName($field) { - switch ($field) { - case "NAME_ID": - return "NAME"; - break; - case "PUBLISHER_ID": - return "PUBLISHER"; - break; - case "VERSION_ID" : - return "VERSION"; - default : - return $field; - break; - } + return match ($field) { + "NAME_ID" => "NAME", + "PUBLISHER_ID" => "PUBLISHER", + "VERSION_ID" => "VERSION", + default => $field, + }; } } \ No newline at end of file diff --git a/require/search/TranslationSearch.php b/require/search/TranslationSearch.php index da3205733..f86837944 100644 --- a/require/search/TranslationSearch.php +++ b/require/search/TranslationSearch.php @@ -69,7 +69,6 @@ class TranslationSearch "virtualmachines" => 1266, "id" => 1402, "hardware_id" => 1433, - "userid" => 1434, "logdate" => 232, "processes" => 1436, "location" => 1435, @@ -107,7 +106,6 @@ class TranslationSearch "voltage" => 1319, "current_speed" => 1315, "socket" => 1316, - "comments" => 51, "pkg_id" => 512, "pkg_name" => 1037, "comments" => 51, @@ -246,7 +244,7 @@ class TranslationSearch public function getTranslationFor($name){ global $l; $name = strtolower($name); - if(empty($l->g($this->translationArray[$name]))){ + if(empty($this->translationArray[$name])){ return $name; } return $l->g($this->translationArray[$name]); @@ -275,9 +273,9 @@ public function getTranslationForListField($string){ $name = strtolower($values[1]); - if(!empty($l->g($this->translationArray[$name]))){ + if(!empty($this->translationArray[$name])){ $name = $l->g($this->translationArray[$name]); - }elseif(strpos($name, 'fields_') !== false){ + }elseif(str_contains($name, 'fields_')){ $accountInfoSearch = new AccountinfoSearch(); $translateAccount = $accountInfoSearch->getAccountInfosList(); $name = $translateAccount['COMPUTERS'][$name]; From 8a31c634134b7660dc5ab1dd03cae0952c5a7993 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:35:03 +0000 Subject: [PATCH 013/187] php8 fix warnings on require/menu/ --- require/menu/ComputerMenuRenderer.php | 8 +------- require/menu/MainMenuRenderer.php | 8 +------- require/menu/Menu.php | 8 ++------ require/menu/MenuElem.php | 14 ++++---------- require/menu/MenuRenderer.php | 14 +++++--------- 5 files changed, 13 insertions(+), 39 deletions(-) diff --git a/require/menu/ComputerMenuRenderer.php b/require/menu/ComputerMenuRenderer.php index 94a6a14b4..e8dcbf6d2 100755 --- a/require/menu/ComputerMenuRenderer.php +++ b/require/menu/ComputerMenuRenderer.php @@ -25,14 +25,8 @@ * Renders the computer menu */ class ComputerMenuRenderer extends MenuRenderer { - private $computer_id; - private $urls; - - public function __construct($computer_id, $urls) { + public function __construct(private $computer_id, private $urls) { parent::__construct(); - - $this->computer_id = $computer_id; - $this->urls = $urls; } public function getUrl(MenuElem $menu_elem) { diff --git a/require/menu/MainMenuRenderer.php b/require/menu/MainMenuRenderer.php index 7a0fff1b7..e8bd41adf 100644 --- a/require/menu/MainMenuRenderer.php +++ b/require/menu/MainMenuRenderer.php @@ -25,14 +25,8 @@ * Renders the main menu */ class MainMenuRenderer extends MenuRenderer { - private $profile; - private $urls; - - public function __construct($profile, $urls) { + public function __construct(private $profile, private $urls) { parent::__construct(); - - $this->profile = $profile; - $this->urls = $urls; } protected function canSeeElem(MenuElem $menu_elem) { diff --git a/require/menu/Menu.php b/require/menu/Menu.php index ccb63feee..824185a29 100755 --- a/require/menu/Menu.php +++ b/require/menu/Menu.php @@ -28,18 +28,14 @@ * */ class Menu { - private $_children; - private $_priority; - /** * Constructor * * @param array $_children An array of MenuElem * @param number $_priority The priority of this element to sort */ - public function __construct(array $_children = array(), $_priority = 0) { - $this->_children = $_children; - $this->_priority = $_priority; + public function __construct(private array $_children = array(), private $_priority = 0) + { } /** diff --git a/require/menu/MenuElem.php b/require/menu/MenuElem.php index bfb2949ad..39cb42e80 100755 --- a/require/menu/MenuElem.php +++ b/require/menu/MenuElem.php @@ -27,21 +27,15 @@ * The class generate one menu element */ class MenuElem extends Menu { - private $_label; - private $_url; - /** * The constructor - * - * @param string $label Label - * @param string $url Url + * + * @param string $_label Label + * @param string $_url Url * @param array $_children Children * @param number $_priority The priority of the MenuElem */ - public function __construct($label, $url, array $_children = array(), $_priority = 0) { - $this->_label = $label; - $this->_url = $url; - + public function __construct(private $_label, private $_url, array $_children = array(), $_priority = 0) { parent::__construct($_children, $_priority); } diff --git a/require/menu/MenuRenderer.php b/require/menu/MenuRenderer.php index 2b60ad532..688200bff 100644 --- a/require/menu/MenuRenderer.php +++ b/require/menu/MenuRenderer.php @@ -62,7 +62,7 @@ public function render(Menu $menu) { // If extension generate new menu / sub menus if($this->extension_hooks->needHookTrigger(ExtensionHook::MENU_HOOK)){ - foreach ($this->extension_hooks->menuExtensionsHooks as $ext_key => $menus_array) { + foreach ($this->extension_hooks->menuExtensionsHooks as $menus_array) { for ($index = 0; $index < count($menus_array); $index++) { $extension_menus_elem = $this->extension_hooks->generateMenuRenderer($menus_array[$index], false); $html .= $this->renderElem($extension_menus_elem, 0, true); @@ -70,9 +70,7 @@ public function render(Menu $menu) { } } - $html .= ''; - - return $html; + return $html . ''; } /** @@ -128,9 +126,7 @@ public function renderElem(MenuElem $menu_elem, $level = 0, $extFrom = false) { $html .= ''; } - $html .= ''; - - return $html; + return $html . ''; } public function getActiveLink() { @@ -166,7 +162,7 @@ protected function getUrl(MenuElem $menu_elem) { protected function getLabel(MenuElem $menu_elem) { $label = $this->translateLabel($menu_elem->getLabel()); - if ($menu_elem->hasChildren() && $level == 0) { + if ($menu_elem->hasChildren() && isset($level) && $level == 0) { $label .= ' '; } @@ -178,7 +174,7 @@ protected function buildAttrs(MenuElem $menu_elem) { if ($menu_elem->hasChildren()) { //@TODO : buggy code - if ($level > 0) { + if (isset($level) && $level > 0) { $attr_li['class'][] = 'dropdown-submenu'; if (!$this->isParentElemClickable()) { From a37d868f912c7e4c4e729a2278fc32d1f90f120d Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:35:40 +0000 Subject: [PATCH 014/187] php8 fix warnings on require/softwares/ --- require/softwares/AllSoftware.php | 11 ++++------- require/softwares/SoftwareCategory.php | 10 +++------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/require/softwares/AllSoftware.php b/require/softwares/AllSoftware.php index 2b3499fb5..8b5e5c0a8 100644 --- a/require/softwares/AllSoftware.php +++ b/require/softwares/AllSoftware.php @@ -29,7 +29,7 @@ class AllSoftware public function software_link_treatment() { // First clean software_link - $delSoftLink = $this->delete_software_link(); + $this->delete_software_link(); // Get all softwares $allSoft = $this->get_software_informations(); // Get categories @@ -59,7 +59,7 @@ public function software_link_treatment() { if(!empty($softwareCategory)) { foreach($software as $identifier => $values) { - foreach($softwareCategory as $key => $infos) { + foreach($softwareCategory as $infos) { if($values['NAME_ID'] == $infos['NAME_ID'] && $values['PUBLISHER_ID'] == $infos['PUBLISHER_ID'] && $values['VERSION_ID'] == $infos['VERSION_ID']) { $software[$identifier]['CATEGORY_ID'] = $infos['CATEGORY_ID']; } @@ -101,16 +101,13 @@ private function get_software_informations() { LEFT JOIN software_version v ON s.VERSION_ID = v.ID GROUP BY s.NAME_ID, s.PUBLISHER_ID, s.VERSION_ID"; - $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]); - - return $result; + return mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]); } private function get_software_categories_link_informations() { $sql = "SELECT * FROM `software_categories_link`"; - $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]); - return $result; + return mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]); } /** diff --git a/require/softwares/SoftwareCategory.php b/require/softwares/SoftwareCategory.php index 6a55d2432..c807cc8d7 100644 --- a/require/softwares/SoftwareCategory.php +++ b/require/softwares/SoftwareCategory.php @@ -67,9 +67,7 @@ public function add_category($catName, $osVersion){ }else{ $sql = "INSERT INTO `software_categories` (`CATEGORY_NAME`, `OS`) values('%s', '%s');"; $arg_sql = array($catName, $osVersion); - - $result = mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg_sql); - return ($result); + return (mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg_sql)); } } @@ -106,9 +104,7 @@ public function insert_exp($id_cat, $regExp, $sign = null, $version = null, $ven $sql_reg = "INSERT INTO `software_category_exp` (`CATEGORY_ID`, `SOFTWARE_EXP`, `SIGN_VERSION`, `VERSION`, `PUBLISHER`) values(%s, '%s', '%s', '%s', '%s')"; $arg_reg = array($id_cat, $regExp, $sign, $version, $vendor); - - $result = mysql2_query_secure($sql_reg, $_SESSION['OCS']["writeServer"], $arg_reg); - return ($result); + return (mysql2_query_secure($sql_reg, $_SESSION['OCS']["writeServer"], $arg_reg)); } /** @@ -162,7 +158,7 @@ public function get_table_html_soft(){ '; } }else{ - foreach($cat as $key => $value){ + foreach($cat as $value){ $this->html .= " ".$value." 0 From 43956d5ed23e9a7ea878caadea57b91d5f8c5f40 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:36:38 +0000 Subject: [PATCH 015/187] php8 fix warnings on cd_controllers --- plugins/computer_detail/cd_controllers/cd_controllers.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/computer_detail/cd_controllers/cd_controllers.php b/plugins/computer_detail/cd_controllers/cd_controllers.php index 118d4c0d1..11bbbaaa3 100755 --- a/plugins/computer_detail/cd_controllers/cd_controllers.php +++ b/plugins/computer_detail/cd_controllers/cd_controllers.php @@ -1,4 +1,5 @@ g(93)); if (!isset($protectedPost['SHOW'])) $protectedPost['SHOW'] = 'NOSHOW'; @@ -42,25 +42,21 @@ $l->g(80) => 'CAPTION', $l->g(53) => 'DESCRIPTION', $l->g(277) => 'VERSION'); - if ($show_all_column) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del[$l->g(66)] = $l->g(66); } - $default_fields = array($l->g(64) => $l->g(64), $l->g(49) => $l->g(49), $l->g(66) => $l->g(66)); $queryDetails = "SELECT "; -foreach ($list_fields as $lbl => $value) { +foreach ($list_fields as $value) { $queryDetails .= $value . ","; } $queryDetails = substr($queryDetails, 0, -1) . " FROM controllers WHERE (hardware_id=$systemid)"; ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); - echo close_form(); if (AJAX) { ob_end_clean(); tab_req($list_fields, $default_fields, $list_col_cant_del, $queryDetails, $tab_options); ob_start(); } -?> \ No newline at end of file From b3e58cd3a064d2c100429aa0be8e21136e24f3d8 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:37:04 +0000 Subject: [PATCH 016/187] php8 fix warnings on tools/ --- tools/cron_mailer.php | 2 +- tools/recompose_paquet.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/cron_mailer.php b/tools/cron_mailer.php index addfa224b..02f8c8c63 100644 --- a/tools/cron_mailer.php +++ b/tools/cron_mailer.php @@ -14,7 +14,7 @@ $week = array('MON' => 'Monday', 'TUE' => 'Tuesday', 'WED' => 'Wednesday', 'THURS' => 'Thursday', 'FRI' => 'Friday', 'SAT' => 'Saturday', 'SUN' => 'Sunday'); $values = $mail->get_info_smtp(); -foreach ($values as $key => $value){ +foreach ($values as $value){ if(array_key_exists($value, $week)){ $day[$week[$value]] = $week[$value]; } diff --git a/tools/recompose_paquet.php b/tools/recompose_paquet.php index 29a24cba6..11ae9c752 100755 --- a/tools/recompose_paquet.php +++ b/tools/recompose_paquet.php @@ -1,4 +1,5 @@ PROBLEME AVEC LE NOM DU FICHIER
"; $valid = 'KO'; } if (substr($info_traite[6], 0, 5) != 'FRAGS') { - "PROBLEME AVEC LE NOMBRE DE FRAGMENT
"; $valid = 'KO'; } $name = substr($name, 6); @@ -85,4 +83,3 @@ } else { echo "PAGE INDISPONIBLE"; } -?> \ No newline at end of file From a18db6dd2f577344b1f22f0d00726c7f632934b9 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:37:56 +0000 Subject: [PATCH 017/187] php8 fix warnings on require/extensions/ --- require/extensions/ExtensionCommon.php | 2 +- require/extensions/ExtensionHook.php | 10 +++------- require/extensions/ExtensionManager.php | 19 +++++++++---------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/require/extensions/ExtensionCommon.php b/require/extensions/ExtensionCommon.php index 676762f6c..9cb54f3a1 100644 --- a/require/extensions/ExtensionCommon.php +++ b/require/extensions/ExtensionCommon.php @@ -26,7 +26,7 @@ class ExtensionCommon{ /** * Objects */ - private $dbObject = null; + private $dbObject; /** * Constructor diff --git a/require/extensions/ExtensionHook.php b/require/extensions/ExtensionHook.php index 34abcf972..ecbf1a7df 100644 --- a/require/extensions/ExtensionHook.php +++ b/require/extensions/ExtensionHook.php @@ -42,8 +42,6 @@ class ExtensionHook{ public $languageExtensionsHooks = array(); public $computerDetailExtensionsHooks = array(); - public $activatedExt = array(); - // Simple array of menu available in all loaded extension public $extDeclaredMenu = array(); public $computerDeclaredMenu = array(); @@ -52,11 +50,9 @@ class ExtensionHook{ private $currentScannedExt = ""; - function __construct($activatedExtArray) { - - $this->activatedExt = $activatedExtArray; + function __construct(public $activatedExt) { - foreach ($activatedExtArray as $extLabel) { + foreach ($activatedExt as $extLabel) { if($this->haveHook($extLabel)){ $this->readHookXml($extLabel); } @@ -302,7 +298,7 @@ public function generateMenuChildrensRenderer($mainMenuIdentifier){ return false; }else{ $menusElemArray = array(); - foreach ($subMenus as $extKey => $subMenusInfos) { + foreach ($subMenus as $subMenusInfos) { for ($index = 0; $index < count($subMenusInfos); $index++) { $menusElemArray[$subMenusInfos[$index][self::IDENTIFIER]] = $this->generateMenuRenderer($subMenusInfos[$index], true); } diff --git a/require/extensions/ExtensionManager.php b/require/extensions/ExtensionManager.php index 7d9b9b27e..29e61a58e 100644 --- a/require/extensions/ExtensionManager.php +++ b/require/extensions/ExtensionManager.php @@ -26,10 +26,10 @@ class ExtensionManager{ /** * Attributes */ - public $installedExtensionsList = null; - public $installableExtensionsList = null; + public $installedExtensionsList; + public $installableExtensionsList; public $installableExtensions_errors = array(); - public $errorMessage = null; + public $errorMessage; /** * Constants @@ -62,7 +62,6 @@ class ExtensionManager{ * List query */ private $selectQuery = "SELECT * FROM `extensions`"; - private $selectQueryTarget = "SELECT * FROM `extensions` WHERE id = '%s'"; /** * Insert query @@ -77,12 +76,12 @@ class ExtensionManager{ /** * Objects */ - private $dbObject = null; + private $dbObject; /** * Write server. */ - private $dbWrite = null; + private $dbWrite; /** * Constructor @@ -107,7 +106,7 @@ public function checkInstallableExtensions(){ // Scan dir and get all sub directory in extensions directory $items = scandir(EXT_DL_DIR); $installableExtList = []; - foreach ($items as $index => $name) { + foreach ($items as $name) { if(in_array($name, $this->FORBIDEN_EXT_NAME) || !is_dir(EXT_DL_DIR.$name)){ continue; } @@ -144,7 +143,7 @@ private function isExtensionCompliant($name){ } return true; - } catch (Exception $ex) { + } catch (Exception) { $this->installableExtensions_errors[] = sprintf($l->g(7021), $name).': '.$l->g(7023); return false; } @@ -187,7 +186,7 @@ public function installExtension($name){ $installMethod(); // TODO : Successfuly instllaed return true; - } catch (Exception $ex) { + } catch (Exception) { // TODO : PHP Error occured return false; } @@ -211,7 +210,7 @@ public function deleteExtension($name){ $deleteMethod = self::EXTENSION_DELETE_METHD.$name; $deleteMethod(); return true; - } catch (Exception $ex) { + } catch (Exception) { return false; } From d8cf33ab5414238d5b640f23b5e8d812bb59d8e5 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:39:11 +0000 Subject: [PATCH 018/187] php8 fix warnings on require/config/ --- require/config/Profile.php | 7 +------ require/config/XMLProfileSerializer.php | 2 +- require/config/include.php | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/require/config/Profile.php b/require/config/Profile.php index 331013843..be7b70281 100755 --- a/require/config/Profile.php +++ b/require/config/Profile.php @@ -25,17 +25,12 @@ * Holds the config for a profile */ class Profile { - private $name; - private $label; private $restrictions; private $config; private $blacklist; private $pages; - public function __construct($name, $label) { - $this->name = $name; - $this->label = $label; - + public function __construct(private $name, private $label) { $this->restrictions = array(); $this->config = array(); $this->blacklist = array(); diff --git a/require/config/XMLProfileSerializer.php b/require/config/XMLProfileSerializer.php index 78074ba9d..cb797d51b 100755 --- a/require/config/XMLProfileSerializer.php +++ b/require/config/XMLProfileSerializer.php @@ -61,7 +61,7 @@ public function serialize(Profile $profile) { $pages_xml = $doc_xml->createElement('pages'); $profile_xml->appendChild($pages_xml); - foreach ($profile->getPages() as $key => $page) { + foreach ($profile->getPages() as $page) { $page_xml = $doc_xml->createElement('page', $page); $pages_xml->appendChild($page_xml); } diff --git a/require/config/include.php b/require/config/include.php index efbcc2c36..cc1f7340d 100644 --- a/require/config/include.php +++ b/require/config/include.php @@ -113,7 +113,7 @@ function migrate_adminData_2_5(){ $sql = "SELECT TYPE FROM accountinfo_config"; $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]); - if($result) foreach ($result as $index => $type){ + if($result) foreach ($result as $type){ if($type['TYPE'] == '4' || $type['TYPE'] == '6' || $type['TYPE'] == '7'){ $sql_replace = "UPDATE accountinfo_config SET TYPE = '%s' WHERE TYPE = '%s'"; $arg_replace = array($type_replace[$type['TYPE']], $type['TYPE']); From cfebac49ec68a14c6e37db44581cc37ba0d8a5c6 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:39:54 +0000 Subject: [PATCH 019/187] php8 fix warnings on ms_snmp/ --- .../main_sections/ms_snmp/ms_snmp_detail.php | 101 ++++++++---------- .../ms_snmp/require/function_snmp.php | 18 +--- 2 files changed, 47 insertions(+), 72 deletions(-) diff --git a/plugins/main_sections/ms_snmp/ms_snmp_detail.php b/plugins/main_sections/ms_snmp/ms_snmp_detail.php index 7b0474c9e..6be24298e 100755 --- a/plugins/main_sections/ms_snmp/ms_snmp_detail.php +++ b/plugins/main_sections/ms_snmp/ms_snmp_detail.php @@ -1,4 +1,5 @@ ID; // SNMP SUMMARY $lbl_affich = array('NAME' => $l->g(49), 'UPTIME' => $l->g(352), 'MACADDR' => $l->g(95), 'IPADDR' => $l->g(34), @@ -52,79 +51,71 @@
- $v){ - - if($k == 'ID'){ + $v){ + if ($k != 'ID') { + if (isset($v)) { + if (!isset($lbl_affich[$k])) { + $label = $k; } else { + $label = $lbl_affich[$k]; + } + $value = $v; - if (isset($v)) { - if (!isset($lbl_affich[$k])) { - $label = $k; - } else { - $label = $lbl_affich[$k]; - } - $value = $v; - - ?> + ?> = 5): ?>
-
-
    -
  • -
-
-
-
    -
  • -
-
-
- +
+
    +
  • +
+
+
+
    +
  • +
+
+
+ - +
-
-
    -
  • -
-
-
-
    -
  • -
-
-
- +
    +
  • +
+
+
+
    +
  • +
+
+
+ + } +} +?>
- $value) { $sql = "select count(*) c from %s where SNMP_ID=%s"; $arg = array($value, $systemid); @@ -171,8 +160,6 @@ } echo ""; echo close_form(); - if (AJAX) { ob_end_clean(); } -?> \ No newline at end of file diff --git a/plugins/main_sections/ms_snmp/require/function_snmp.php b/plugins/main_sections/ms_snmp/require/function_snmp.php index a05c06b1d..c68c891dc 100755 --- a/plugins/main_sections/ms_snmp/require/function_snmp.php +++ b/plugins/main_sections/ms_snmp/require/function_snmp.php @@ -1,4 +1,5 @@ g(1215) => 'SNMP_BLADES', $l->g(1216) => 'SNMP_FIREWALLS', $l->g(1217) => 'SNMP_LOADBALANCERS', $l->g(79) => 'SNMP_PRINTERS', $l->g(1218) => 'SNMP_SWITCHINFOS', $l->g(729) => 'SNMP_COMPUTERS'); - $snmp_tables = array('SNMP_ACCOUNTINFO', 'SNMP_CARDS', 'SNMP_CARTRIDGES', 'SNMP_CPUS', 'SNMP_DRIVES', 'SNMP_FANS', 'SNMP_INPUTS', 'SNMP_LOCALPRINTERS', 'SNMP_MEMORIES', 'SNMP_MODEMS', 'SNMP_NETWORKS', 'SNMP_PORTS', 'SNMP_POWERSUPPLIES', 'SNMP_SOFTWARES', 'SNMP_SOUNDS', 'SNMP_STORAGES', 'SNMP_SWITCHS', 'SNMP_TRAYS', 'SNMP_VIDEOS', 'SNMP_VIRTUALMACHINES'); - $all_snmp_table = array_merge($snmp_tables_type, $snmp_tables); - //is ID exist? function info_snmp($snmp_id) { global $l, $snmp_tables_type; @@ -55,7 +53,6 @@ function info_snmp($snmp_id) { return $array; } } - function subnet_name($systemid) { if (!is_numeric($systemid)) return false; @@ -68,7 +65,6 @@ function subnet_name($systemid) { } return $returnVal; } - function print_item_header($text) { echo ""; echo ""; @@ -76,7 +72,6 @@ function print_item_header($text) { echo ""; echo "
"; } - function bandeau($data, $lbl_affich, $title = '', $class = 'mlt_bordure') { $nb_col = 2; $data_exist = false; @@ -86,7 +81,7 @@ function bandeau($data, $lbl_affich, $title = '', $class = 'mlt_bordure') { } $show_table .= " "; $i = 0; - foreach ($data as $table => $values) { + foreach ($data as $values) { if (is_object($values)) { foreach ($values as $field => $field_value) { $data_exist = true; @@ -116,7 +111,6 @@ function bandeau($data, $lbl_affich, $title = '', $class = 'mlt_bordure') { } return false; } - function deleteDid_snmp($id) { global $all_snmp_table; if (is_array($id)) { @@ -135,12 +129,10 @@ function deleteDid_snmp($id) { $del_sql = mysql2_prepare($sql, array(), $id_snmp, $nocot = true); mysql2_query_secure($del_sql['SQL'], $_SESSION['OCS']["writeServer"], $del_sql['ARG'], true); } - /* * Find all accountinfo for * snmp data */ - function admininfo_snmp($id = "") { global $l; if (!is_numeric($id) && $id != "") { @@ -156,10 +148,8 @@ function admininfo_snmp($id = "") { } $res_account_data = mysql2_query_secure($sql_account_data, $_SESSION['OCS']["readServer"], $arg_account_data); - $val_account_data = mysqli_fetch_array($res_account_data); - return $val_account_data; + return mysqli_fetch_array($res_account_data); } - function updateinfo_snmp($id, $values, $list = '') { global $l; if (!is_numeric($id) && $list == '') { @@ -184,5 +174,3 @@ function updateinfo_snmp($id, $values, $list = '') { mysql2_query_secure($sql_account_data, $_SESSION['OCS']["writeServer"], $arg_account_data); return $l->g(1121); } - -?> \ No newline at end of file From f77139d00d547f8a91822308437567993b7a45b7 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:40:39 +0000 Subject: [PATCH 020/187] php8 fix warnings on ms_multi_search/ --- .../ms_multi_search/ms_custom_sup.php | 4 ++-- .../ms_multi_search/ms_multi_search.php | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/main_sections/ms_multi_search/ms_custom_sup.php b/plugins/main_sections/ms_multi_search/ms_custom_sup.php index 53d5d7e7e..563bd2d8f 100644 --- a/plugins/main_sections/ms_multi_search/ms_custom_sup.php +++ b/plugins/main_sections/ms_multi_search/ms_custom_sup.php @@ -1,4 +1,5 @@ "; if (is_defined($protectedPost['SUP'])) { $array_id = explode(',', $list_id); - foreach ($array_id as $key => $hardware_id) { + foreach ($array_id as $hardware_id) { deleteDid($hardware_id); } } @@ -38,4 +39,3 @@ echo ""; } echo close_form(); -?> \ No newline at end of file diff --git a/plugins/main_sections/ms_multi_search/ms_multi_search.php b/plugins/main_sections/ms_multi_search/ms_multi_search.php index 80d611fec..fe64c19eb 100644 --- a/plugins/main_sections/ms_multi_search/ms_multi_search.php +++ b/plugins/main_sections/ms_multi_search/ms_multi_search.php @@ -57,7 +57,7 @@ // Get search object to perform action and show result //$legacySearch = new LegacySearch(); -$search = new Search($translationSearch, $databaseSearch, $accountinfoSearch, $groupSearch, $softwareSearch); +$search = new Search($translationSearch, $databaseSearch, $accountInfoSearch, $groupSearch, $softwareSearch); $sqlCache = new SQLCache($search, $softwareSearch); $_SESSION['OCS']['DATE_FORMAT_LANG'] = $l->g(1270); @@ -182,11 +182,10 @@ foreach ($_SESSION['OCS']['multi_search'] as $table => $infos) { $i = 0; - foreach ($infos as $uniqid => $values) { ?>
- returnFieldHtmlAndOr($uniqid, $values, $infos, $table, $values['comparator']); if($htmlComparator != ""){ echo "
@@ -198,7 +197,7 @@ } ?>
getAccountInfosList(); echo $translationSearch->getTranslationFor($table)." : ".$fields['COMPUTERS'][$values['fields']]; }else{ @@ -210,7 +209,7 @@
'; } - - $table .= "
' . $softs. '

'.$l->g(20).'
\n"; - return $table; + return $table . "\n"; } /** @@ -224,7 +222,7 @@ public function html_software_cat($cat){ } } }else{ - foreach($cat as $key => $value){ + foreach($cat as $value){ $html .= "".$value."0"; } } From 167084841bca22195eef5bc43f3b20da4a72fe58 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:46:21 +0000 Subject: [PATCH 030/187] php8 update syntax on require/commandLine/ --- require/commandLine/CommandLine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/commandLine/CommandLine.php b/require/commandLine/CommandLine.php index 2446bafa1..e521a4d9b 100644 --- a/require/commandLine/CommandLine.php +++ b/require/commandLine/CommandLine.php @@ -36,7 +36,7 @@ public function get_mib_oid($file) { $result_cmd = preg_split("/\r\n|\n|\r/", $result_cmd); $result_cmd = str_replace('"', "", $result_cmd); - foreach ($result_cmd as $label => $oid) { + foreach ($result_cmd as $oid) { $split = preg_split('/\t/', $oid, null, PREG_SPLIT_NO_EMPTY); if($split[0] != "") { $oids[$split[0]] = $split[1]; From af94b6e4f32f885722e14f5b658d65c9b096c008 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:46:49 +0000 Subject: [PATCH 031/187] php8 update syntax on require/charts/ --- require/charts/StatsChartsRenderer.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/require/charts/StatsChartsRenderer.php b/require/charts/StatsChartsRenderer.php index 18ba3747d..9e32f3eac 100644 --- a/require/charts/StatsChartsRenderer.php +++ b/require/charts/StatsChartsRenderer.php @@ -65,11 +65,7 @@ public function createChartCanvas($name, $legend = true, $offset = true){ $mainClass = "col-md-6 col-sm-6"; } - if($offset){ - $offset = ""; - }else{ - $offset = ""; - } + $offset = ""; ?>
@@ -142,7 +138,7 @@ public function createChart($chart, $seen = null, $quants_seen = null, $man = nu }, title: { display: true, - text: "" + text: "" }, animation: { animateScale: true, @@ -234,7 +230,7 @@ public function createChart($chart, $seen = null, $quants_seen = null, $man = nu ?> "; } diff --git a/require/function_admininfo.php b/require/function_admininfo.php index 3720ac747..321d74fde 100644 --- a/require/function_admininfo.php +++ b/require/function_admininfo.php @@ -37,22 +37,12 @@ '11' => 'VARCHAR(255)' ); -$array_qr_values = array('URL' => $l->g(646), - 'NAME' => $l->g(35), - 'UID' => $l->g(1268), - 'IPADDR' => $l->g(34)); -$array_qr_action = array('URL' => array('TYPE' => 'url', 'VALUE' => OCSREPORT_URL . "/index.php?" . PAG_INDEX . "=" . $pages_refs['ms_computer'] . "&head=1&systemid=" . $_GET['systemid']), - 'NAME' => array('TYPE' => 'bdd', 'VALUE' => "hardware.name"), - 'UID' => array('TYPE' => 'bdd', 'VALUE' => "hardware.uuid"), - 'IPADDR' => array('TYPE' => 'bdd', 'VALUE' => "hardware.ipaddr")); - function accountinfo_tab($id) { $info_tag = find_info_accountinfo($id); if ($info_tag[$id]['type'] == 2 or $info_tag[$id]['type'] == 5 or $info_tag[$id]['type'] == 11) { - $info = find_value_field('ACCOUNT_VALUE_' . $info_tag[$id]['name']); - return $info; + return find_value_field('ACCOUNT_VALUE_' . $info_tag[$id]['name']); } elseif ($info_tag[$id]['type'] == 8) { return false; } @@ -354,8 +344,6 @@ function dde_exist($name, $id = '', $type) { //name can't be null return $l->g(1068); } - - return; } /* @@ -431,8 +419,7 @@ function changeDateFormat($lang, $val){ $tab = array("fr_FR", "br_BR", "it_IT", "pl_PL", "pt_PT", "ru_RU", "si_SI", "es_ES", "tr_TR"); if(in_array($lang, $tab)){ $tab2 = explode("/", $val); - $ret = $tab2[1]."/".$tab2[0]."/".$tab2[2]; - return $ret; + return $tab2[1]."/".$tab2[0]."/".$tab2[2]; }else{ return $val; } @@ -538,7 +525,11 @@ function replace_tag_value($type = '', $option = array()) { } } } - return $tab_options; + + if(isset($tab_options)) { + return $tab_options; + } + } function find_value_in_field($tag, $value_2_find, $type = 'COMPUTERS') { @@ -586,20 +577,13 @@ function interprete_accountinfo($list_fields, $tab_options) { */ function adminData_to_input($typeID){ - switch ($typeID){ - - case '2': - return 'select'; - case '4': - return 'checkbox'; - case '5': - return 'file'; - case '7': - return 'radio'; - - default: - return 'text'; - } + return match ($typeID) { + '2' => 'select', + '4' => 'checkbox', + '5' => 'file', + '7' => 'radio', + default => 'text', + }; } ?> diff --git a/require/function_commun.php b/require/function_commun.php index 7d20202a5..5a2ce5f00 100644 --- a/require/function_commun.php +++ b/require/function_commun.php @@ -55,7 +55,9 @@ function look_config_default_values($field_name, $like = '', $default_values = ' } } - return $result; + if (isset($result)) { + return $result; + } } /* * ****************************************************SQL FUNCTION*************************************************** */ @@ -66,7 +68,7 @@ function generate_secure_sql($sql, $arg = '') { foreach ($arg as $value) { $arg_array_escape_string[] = mysqli_real_escape_string($_SESSION['OCS']["readServer"], $value); } - $arg_escape_string = $arg_array_escape_string; + $arg_escape_string = $arg_array_escape_string ?? null; } elseif ($arg != '') { $arg_escape_string = mysqli_real_escape_string($_SESSION['OCS']["readServer"], $arg); } @@ -87,7 +89,7 @@ function mysql2_query_secure($sql, $link, $arg = '', $log = false) { addLog($log, $query, $lbl_log); } - if ($_SESSION['OCS']['DEBUG'] == 'ON') { + if (isset($_SESSION['OCS']['DEBUG']) && $_SESSION['OCS']['DEBUG'] == 'ON') { $_SESSION['OCS']['SQL_DEBUG'][] = html_entity_decode($query, ENT_QUOTES); } @@ -102,7 +104,7 @@ function mysql2_query_secure($sql, $link, $arg = '', $log = false) { } } $result = mysqli_query($link, $query); - if ($_SESSION['OCS']['DEBUG'] == 'ON' && !$result) { + if (isset($_SESSION['OCS']['DEBUG']) && $_SESSION['OCS']['DEBUG'] == 'ON' && !$result) { msg_error(mysqli_error($link)); } return $result; @@ -289,8 +291,7 @@ function read_files($search, $ms_cfg_file, $writable = '') { } if (file_exists($ms_cfg_file)) { - $profil_data = read_configuration($ms_cfg_file, $search); - return $profil_data; + return read_configuration($ms_cfg_file, $search); } else { return false; } @@ -303,7 +304,7 @@ function msg($txt, $css, $closeid = false) { $_SESSION['OCS']['CLOSE_ALERT'][$protectedPost['close_alert']] = 1; } - if (!$_SESSION['OCS']['CLOSE_ALERT'][$closeid]) { + if (!isset($_SESSION['OCS']['CLOSE_ALERT'][$closeid])) { echo "
"; } diff --git a/require/function_computers.php b/require/function_computers.php index 1e07183ae..8ef3b05b0 100755 --- a/require/function_computers.php +++ b/require/function_computers.php @@ -1,4 +1,5 @@ g(376)); } - function computer_list_by_tag($tag = "", $format = 'LIST') { $arg_sql = array(); if ($tag == "") { @@ -84,7 +81,6 @@ function computer_list_by_tag($tag = "", $format = 'LIST') { return $array_mycomputers; } } - /** * Deleting function * @param id Hardware identifier to be deleted @@ -107,7 +103,7 @@ function deleteDid($id, $checkLock = true, $traceDel = true, $silent = false $did = $valId["deviceid"]; if ($did) { //Deleting a network device - if (strpos($did, "NETWORK_DEVICE-") === false) { + if (!str_contains($did, "NETWORK_DEVICE-")) { $sql = "SELECT macaddr FROM networks WHERE hardware_id='%s'"; $resNetm = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $idHard); while ($valNetm = mysqli_fetch_array($resNetm)) { @@ -161,7 +157,6 @@ function deleteDid($id, $checkLock = true, $traceDel = true, $silent = false errlock(); } } - function fusionne($afus) { global $l; $i = 0; @@ -220,7 +215,7 @@ function fusionne($afus) { $accountTable = []; // Check if accountinfo data exist and get ID of the more recent - foreach($afus as $key => $values) { + foreach($afus as $values) { $sqlverif = "SELECT * FROM accountinfo WHERE hardware_id = '%s' ORDER BY hardware_id ASC"; $verif_req = mysql2_query_secure($sqlverif, $_SESSION['OCS']["readServer"], $values["id"]); while($row = mysqli_fetch_array($verif_req)){ @@ -230,9 +225,9 @@ function fusionne($afus) { } } - foreach($accountTable as $id => $table) { + foreach($accountTable as $table) { foreach($table as $key => $value) { - if(strpos($key,"fields_") !== false) { + if(str_contains($key,"fields_")) { if($value != null && $value != "") { $accountid = $table['HARDWARE_ID']; } @@ -258,7 +253,7 @@ function fusionne($afus) { } // Delete all old accountinfo - foreach($afus as $key => $values) { + foreach($afus as $values) { if($values["id"] != $afus[$maxInd]["id"]) { $reqDelAccount = "DELETE FROM accountinfo WHERE hardware_id='%s'"; mysql2_query_secure($reqDelAccount, $_SESSION['OCS']["writeServer"], $values["id"]); @@ -291,7 +286,6 @@ function fusionne($afus) { $lesDel .= " => " . $afus[$maxInd]["deviceid"]; AddLog("FUSION", $lesDel); } - function insert_manual_computer($values, $nb = 1) { global $i; if ($nb == 1) { @@ -319,12 +313,10 @@ function insert_manual_computer($values, $nb = 1) { return $id_computer; } - /* * function to verify if user can access * on computer */ - function is_mine_computer($id) { if (isset($_SESSION['OCS']['TAGS']) && is_array($_SESSION['OCS']['TAGS'])) { $sql = "select hardware_id from accountinfo where hardware_id = %s and tag in "; @@ -338,7 +330,6 @@ function is_mine_computer($id) { } return true; } - function RandomMAC() { $word = "A,B,C,D,E,F,0,1,2,3,4,5,6,7,8,9"; $mac = ''; @@ -356,5 +347,3 @@ function RandomMAC() { return substr($mac, 0, -1); } - -?> \ No newline at end of file diff --git a/require/function_config_generale.php b/require/function_config_generale.php index 31ae6a37c..f4c879f49 100644 --- a/require/function_config_generale.php +++ b/require/function_config_generale.php @@ -158,12 +158,12 @@ function active(id, sens) { echo "
"; echo "
"; - if ($data_hidden['BEGIN'] != '' || isset($data_hidden['BEGIN'])) { + if (isset($data_hidden['BEGIN']) && $data_hidden['BEGIN'] != '') { echo "" . $data_hidden['BEGIN'] . ""; } echo ""; - if ($data_hidden['END'] != '' || isset($data_hidden['END'])) { + if (isset($data_hidden['END']) && $data_hidden['END'] != '') { echo "" . $data_hidden['END'] . ""; } @@ -182,10 +182,10 @@ function active(id, sens) { $ajout_readonly = " disabled=\"disabled\" style='color:black; background-color:#e1e1e2;'"; } echo "
"; - if ($data['BEGIN'] != '' || isset($data['BEGIN'])) { + if (isset($data['BEGIN']) || !empty($data['BEGIN'])) { echo "" . $data['BEGIN'] . ""; } - echo ""; + echo ""; if ($data['END'] != '' || isset($data['END'])) { echo "" . $data['END'] . ""; @@ -233,7 +233,7 @@ function active(id, sens) { } echo ""; }elseif ($type == 'long_text') { - echo "" . $data['END']; + echo "" . ($data['END'] ?? ''); }elseif($type == 'password'){ echo ""; echo "

" . $helpInput . "

"; @@ -271,7 +271,7 @@ function verif_champ() { 'CUSTOM_THEME' => array('FIELD_READ' => 'CUSTOME_THEME_edit', 'END' => "", 'FILE' => "", 'TYPE' =>'r')); foreach ($file_exist as $key => $value) { - if ($protectedPost[$key] == 'CUSTOM') { + if (isset($protectedPost[$key]) && $protectedPost[$key] == 'CUSTOM') { //Try to find a file if ($value['FILE'] != '') { if ($protectedPost[$value['FIELD_READ']] != '' and ! @fopen($protectedPost[$value['FIELD_READ']] . $value['END'] . $value['FILE'], $value['TYPE'])) { @@ -288,14 +288,14 @@ function verif_champ() { $i = 0; while ($supp1[$i]) { - if ($protectedPost[$supp1[$i]] < 1 && isset($protectedPost[$supp1[$i]])) { + if (isset($protectedPost[$supp1[$i]]) && $protectedPost[$supp1[$i]] < 1) { $tab_error[$supp1[$i]] = '1'; } $i++; } $i = 0; while ($supp10[$i]) { - if ($protectedPost[$supp10[$i]] < 10 && isset($protectedPost[$supp10[$i]])) { + if (isset($protectedPost[$supp10[$i]]) && $protectedPost[$supp10[$i]] < 10) { $tab_error[$supp10[$i]] = '10'; } $i++; @@ -395,8 +395,7 @@ function update_default_value($POST) { //tableau des champs ou il faut interpréter la valeur retourner et mettre à jour tvalue $array_interprete_tvalue = array('DOWNLOAD_REP_CREAT' => 'DOWNLOAD_REP_CREAT_edit', 'DOWNLOAD_PACK_DIR' => 'DOWNLOAD_PACK_DIR_edit', - 'IPDISCOVER_IPD_DIR' => 'IPDISCOVER_IPD_DIR_edit', 'LOG_DIR' => 'LOG_DIR_edit', 'TMP_DIR' => 'TMP_DIR_edit', - 'LOG_SCRIPT' => 'LOG_SCRIPT_edit', 'DOWNLOAD_URI_FRAG' => 'DOWNLOAD_URI_FRAG_edit', + 'IPDISCOVER_IPD_DIR' => 'IPDISCOVER_IPD_DIR_edit', 'LOG_DIR' => 'LOG_DIR_edit', 'TMP_DIR' => 'TMP_DIR_edit', 'DOWNLOAD_URI_FRAG' => 'DOWNLOAD_URI_FRAG_edit', 'DOWNLOAD_URI_INFO' => 'DOWNLOAD_URI_INFO_edit', 'LOG_SCRIPT' => 'LOG_SCRIPT_edit', 'CONF_PROFILS_DIR' => 'CONF_PROFILS_DIR_edit', 'OLD_CONF_DIR' => 'OLD_CONF_DIR_edit', 'LOCAL_URI_SERVER' => 'LOCAL_URI_SERVER_edit', 'WOL_BIOS_PASSWD' => 'WOL_BIOS_PASSWD_edit'); diff --git a/require/function_console.php b/require/function_console.php index 653b5d2d7..212782bde 100644 --- a/require/function_console.php +++ b/require/function_console.php @@ -44,9 +44,7 @@ $_SESSION['DATE']['HARDWARE-LASTDATE-TALL'] = date($l->g(1242)); $_SESSION['DATE']['HARDWARE-LASTCOME-SMALL'] = date($l->g(1242), mktime(0, 0, 0, date("m"), date("d") - $data_limit['GUI_REPORT_AGIN_MACH'], date("Y"))); -$multi_search = array("OCS_REPORT_NB_NOTIFIED" => array("FIELD" => '', "COMP" => '', "VALUE" => ''), - "OCS_REPORT_NB_ERR" => array("FIELD" => '', "COMP" => '', "VALUE" => ''), - "OCS_REPORT_NB_CONTACT" => array("FIELD" => 'HARDWARE-LASTCOME', "COMP" => 'tall', "VALUE" => $_SESSION['DATE']['HARDWARE-LASTCOME-TALL']), +$multi_search = array("OCS_REPORT_NB_CONTACT" => array("FIELD" => 'HARDWARE-LASTCOME', "COMP" => 'tall', "VALUE" => $_SESSION['DATE']['HARDWARE-LASTCOME-TALL']), "OCS_REPORT_NB_INV" => array("FIELD" => 'HARDWARE-LASTDATE', "COMP" => 'tall', "VALUE" => $_SESSION['DATE']['HARDWARE-LASTDATE-TALL']), "OCS_REPORT_NB_4_MOMENT" => array("FIELD" => 'HARDWARE-LASTCOME', "COMP" => 'small', "VALUE" => $_SESSION['DATE']['HARDWARE-LASTCOME-SMALL']), "OCS_REPORT_NB_HARD_DISK_H" => array("FIELD" => '', "COMP" => '', "VALUE" => ''), @@ -262,7 +260,7 @@ function show_active_tab($data_on) { } } } - foreach ($repart as $key => $value) { + foreach ($repart as $value) { $data[$value] = $value; } diff --git a/require/function_groups.php b/require/function_groups.php index 97019885c..dc0c77722 100644 --- a/require/function_groups.php +++ b/require/function_groups.php @@ -1,4 +1,5 @@ 'OK', 'LBL' => $l->g(607) . " " . $l->g(608)); } - //function to add computer in groups_cache function add_computers_cache($list_id, $groupid, $static) { require_once('function_computers.php'); @@ -147,7 +141,6 @@ function add_computers_cache($list_id, $groupid, $static) { return $cached; } } - //generation du xml en fonction des requetes function generate_xml($req) { //si il exite une requete @@ -167,13 +160,11 @@ function generate_xml($req) { return $xml; } - function clean($txt) { $cherche = array("&", "<", ">", "\"", "'"); $replace = array("&", "<", ">", """, "'"); return str_replace($cherche, $replace, $txt); } - function delete_group($id_supp) { global $l; if ($id_supp == "") { @@ -194,7 +185,6 @@ function delete_group($id_supp) { return array('RESULT' => 'ERROR', 'LBL' => $l->g(623)); } } - function group_4_all($id_group) { if ($id_group == "") { return array('RESULT' => 'ERROR', 'LBL' => "ID IS NULL"); @@ -219,7 +209,6 @@ function group_4_all($id_group) { addLog("ACTION VISIBILITY OF GROUPE", $id_group); return $return_result; } - function show_redistrib_groups_packages($systemid){ global $l; @@ -278,5 +267,3 @@ function show_redistrib_groups_packages($systemid){ \ No newline at end of file diff --git a/require/function_ipdiscover.php b/require/function_ipdiscover.php index 5633ef58f..c8cecbeb2 100644 --- a/require/function_ipdiscover.php +++ b/require/function_ipdiscover.php @@ -25,8 +25,7 @@ function find_info_subnet($netid) { $sql = "select NETID,NAME,ID,MASK from subnet where netid='%s'"; $arg = $netid; $res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); - $row = mysqli_fetch_object($res); - return $row; + return mysqli_fetch_object($res); } function find_info_type($name = '', $id = '', $update = '') { @@ -42,8 +41,7 @@ function find_info_type($name = '', $id = '', $update = '') { $arg[] = $update; } $res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); - $row = mysqli_fetch_object($res); - return $row; + return mysqli_fetch_object($res); } function form_add_subnet($title = '', $default_value, $form) { @@ -246,8 +244,7 @@ function find_community_info($id) { $sql = "select * from snmp_communities where id=%s"; $arg = $id; $res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); - $row = mysqli_fetch_object($res); - return $row; + return mysqli_fetch_object($res); } function runCommand($command = "", $fname) { diff --git a/require/function_opt_param.php b/require/function_opt_param.php index a6d13d6db..d539db650 100755 --- a/require/function_opt_param.php +++ b/require/function_opt_param.php @@ -114,7 +114,7 @@ function optperso($lbl, $lblPerso, $helpText, $optPerso, $default_value = '', $e

- $field_value, 'field_value_complement' => $field_value_complement); - return $monRetour; + return array('field_value' => $field_value, 'field_value_complement' => $field_value_complement); } //fonction qui permet de passer en SESSION @@ -230,7 +229,7 @@ function sql_group_cache($cache_sql) { //requête de recherche "normale" (ressemble, exactement) if ($cache_sql['NORMAL']) { - foreach ($cache_sql['NORMAL'] as $poids => $list) { + foreach ($cache_sql['NORMAL'] as $list) { $i = 0; while ($list[$i]) { $fin_sql = ""; @@ -246,7 +245,7 @@ function sql_group_cache($cache_sql) { } //requête de recherche "différent", "n'appartient pas" if ($cache_sql['DIFF']) { - foreach ($cache_sql['DIFF'] as $poids => $list) { + foreach ($cache_sql['DIFF'] as $list) { $i = 0; while ($list[$i]) { $fin_sql = ""; @@ -534,6 +533,7 @@ function garde_check(image,id,computer)
"; - echo "
" . $l->g(90) . " (" . $l->g(183) . ")
"; + echo "
" . $l->g(90) . " (" . $l->g(183) . ")
"; + echo "
" . $l->g(90) . " (" . $l->g(183) . ")
"; } ?>
@@ -526,7 +525,7 @@ function checkall() "; @@ -556,7 +555,7 @@ function checkall() echo ""; echo ""; - if ($_SESSION['OCS']['DEBUG'] == 'ON') { + if (isset($_SESSION['OCS']['DEBUG']) && $_SESSION['OCS']['DEBUG'] == 'ON') { ?>
"; - return $champs; + return $champs . ""; } elseif ($input_type == 3) { $hid = ""; // echo $name."
"; @@ -786,8 +784,7 @@ function show_modif($name, $input_name, $input_type, $input_reload = "", $config if ($configinput['JAVASCRIPT'] != '') $champs .= $configinput['JAVASCRIPT'] . " "; - $champs .= ">"; - return $champs; + return $champs . ">"; //""; } elseif ($input_type == 13) { @@ -1128,7 +1125,7 @@ function onglet($def_onglets,$form_name,$post_name,$ligne) global $protectedPost; /* $protectedPost['onglet_soft']=stripslashes($protectedPost['onglet_soft']); $protectedPost['old_onglet_soft']=stripslashes($protectedPost['old_onglet_soft']);*/ - if ($protectedPost["old_".$post_name] != $protectedPost[$post_name]){ + if (!isset($protectedPost["old_".$post_name]) || $protectedPost["old_".$post_name] != $protectedPost[$post_name]){ $protectedPost['page']=0; } if (!isset($protectedPost[$post_name]) and is_array($def_onglets)){ @@ -1173,7 +1170,7 @@ function show_tabs($def_onglets,$form_name,$post_name, $onclick = false) { global $protectedPost; - if ($protectedPost["old_".$post_name] != $protectedPost[$post_name]){ + if (isset($protectedPost["old_".$post_name]) && $protectedPost["old_".$post_name] != $protectedPost[$post_name]){ $protectedPost['page']=0; } if (!isset($protectedPost[$post_name]) and is_array($def_onglets)){ @@ -1224,7 +1221,7 @@ function gestion_col($entete,$data,$list_col_cant_del,$form_name,$tab_name,$list //search in cookies columns values if (isset($_COOKIE[$tab_name]) and $_COOKIE[$tab_name] != '' and !isset($_SESSION['OCS']['col_tab'][$tab_name])){ $col_tab=explode("///", $_COOKIE[$tab_name]); - foreach ($col_tab as $key=>$value){ + foreach ($col_tab as $value){ $_SESSION['OCS']['col_tab'][$tab_name][$value]=$value; } } @@ -1299,14 +1296,14 @@ function lbl_column($list_fields){ require_once('maps.php'); $return_fields=array(); $return_default=array(); - foreach($list_fields as $poub=>$table){ + foreach($list_fields as $table){ if (isset($lbl_column[$table])){ foreach($lbl_column[$table] as $field=>$lbl){ //echo $field; if (isset($alias_table[$table])){ $return_fields[$lbl]=$alias_table[$table].'.'.$field; if (isset($default_column[$table])){ - foreach($default_column[$table] as $poub2=>$default_field) + foreach($default_column[$table] as $default_field) $return_default[$lbl_column[$table][$default_field]]=$lbl_column[$table][$default_field]; }else{ msg_error($table.' DEFAULT VALUES NOT DEFINE IN MAPS.PHP'); @@ -1355,7 +1352,7 @@ function ajaxfiltre($queryDetails,$tab_options){ if ($key == 3){ $rang =0; - foreach($tab_options['visible_col'] as $index=>$column){ + foreach($tab_options['visible_col'] as $column){ if($tab_options['columns'][$column]['name'] == $tab_options['NO_SEARCH'][$tab_options['columns'][$column]['name']]){ $tab_options['columns'][$column]['searchable'] = false; } @@ -1410,7 +1407,7 @@ function ajaxfiltre($queryDetails,$tab_options){ // Check if at least one of the column used in the query if full-text indexed foreach ($tab_options['visible_col'] as $column) { - if ($tab_options['columns'][$column]['ft_index'] == 'true') { + if (isset($tab_options['columns'][$column]['ft_index']) && $tab_options['columns'][$column]['ft_index'] == 'true') { // Find the correct place where to do the full-text search in the query if (count($sqlword['WHERE'])>1) { $ft_queryDetails1 = $sqlword['WHERE'][0]; @@ -1496,7 +1493,7 @@ function ajaxfiltre($queryDetails,$tab_options){ if($info_tag[$id_tag[1]]['type'] == 2) { $info = find_value_field('ACCOUNT_VALUE_' . $info_tag[$id_tag[1]]['name']); foreach($info as $key => $value) { - if(strpos(strtolower($value), strtolower($search)) !== false) { + if(str_contains(strtolower($value), strtolower($search))) { $acc_select[$key] = $key; } } @@ -1508,13 +1505,13 @@ function ajaxfiltre($queryDetails,$tab_options){ } // (Cyrille: The following 2 tests are used at least 3 times in this file. Wouldn't it be a good time to create a function?) - if($tab_options['columns'][$column]['name'] == $tab_options['NO_SEARCH'][$tab_options['columns'][$column]['name']]){ + if(isset($tab_options['NO_SEARCH']) && ((isset($tab_options['columns'][$column]['name']) && isset($tab_options['NO_SEARCH'][$tab_options['columns'][$column]['name']])) && $tab_options['columns'][$column]['name'] == $tab_options['NO_SEARCH'][$tab_options['columns'][$column]['name']])){ $tab_options['columns'][$column]['searchable'] = false; } $searchable = ($tab_options['columns'][$column]['searchable'] == "true") ? true : false; // (Cyrille: What the hell is the purpose of this "HAVING" array?) - if(is_array($tab_options['HAVING'])&&isset($tab_options['HAVING'][$column])){ + if(isset($tab_options['HAVING'][$column]) && is_array($tab_options['HAVING'])){ $searchable =true; } @@ -1527,7 +1524,7 @@ function ajaxfiltre($queryDetails,$tab_options){ // If column is searchable and doesn't have a full-text index if ($searchable && (empty($tab_options['columns'][$column]['ft_index']) || $tab_options['columns'][$column]['ft_index'] == 'false')) { - if ($cname != 'c' && $tab_options['COL_SEARCH'] == 'default') { + if ($cname != 'c' && isset($tab_options['COL_SEARCH']) && $tab_options['COL_SEARCH'] == 'default') { if ($index == 0){ $filter = " (( ".$cname." ".$search_arg." ) "; } else { @@ -1573,7 +1570,7 @@ function ajaxsort(&$tab_options) { // field name is IP format alike if (in_array(mb_strtoupper($name),$tab_iplike)) { $tri .= " INET_ATON(".$name.") ".$v['dir'].", "; - } else if($tab_options['TRI']['DATE'][$name]) { + } else if(isset($tab_options['TRI']['DATE'][$name]) && $tab_options['TRI']['DATE'][$name]) { if(isset($tab_options['ARG_SQL'])) { $tri .= " STR_TO_DATE(%s,'%s') %s"; $tab_options['ARG_SQL'][] = $name; @@ -1583,7 +1580,7 @@ function ajaxsort(&$tab_options) { $tri .= " STR_TO_DATE(".$name.",'".$tab_options['TRI']['DATE'][$name]."') ".$v['dir']; } } else { - if ( strpos($name,".") === false ) { + if ( !str_contains($name,".") ) { $tri .= "".$name." ".$v['dir'].", "; } else { $tri .= $name . " ".$v['dir'].", "; @@ -1643,7 +1640,7 @@ function ajaxgestionresults($resultDetails,$list_fields,$tab_options){ $form_name=$tab_options['form_name']; $_SESSION['OCS']['list_fields'][$tab_options['table_name']]=$list_fields; $_SESSION['OCS']['col_tab'][$tab_options['table_name']]= array_flip($list_fields); - if($resultDetails){ + if(!empty($resultDetails->num_rows)){ while($row = mysqli_fetch_assoc($resultDetails)) { if (isset($tab_options['AS'])){ @@ -1662,7 +1659,7 @@ function ajaxgestionresults($resultDetails,$list_fields,$tab_options){ foreach($list_fields as $key=>$column){ $name = explode('.',$column); $column = end($name); - $value_of_field = $row[$column]; + $value_of_field = $row[$column] ?? ''; switch($key){ case "CHECK": // condition below added to fix static grp visbility checkbox @@ -1700,12 +1697,12 @@ function ajaxgestionresults($resultDetails,$list_fields,$tab_options){ case "NAME": if ( !isset($tab_options['NO_NAME']['NAME'])){ $link_computer="index.php?".PAG_INDEX."=".$pages_refs['ms_computer']."&head=1"; - if ($row['ID']) + if (isset($row['ID'])) $link_computer.="&systemid=".$row['ID']; - elseif($row['hardwareID']) + elseif(isset($row['hardwareID'])) $link_computer.="&systemid=".$row['hardwareID']; - if ($row['MD5_DEVICEID']) + if (isset($row['MD5_DEVICEID'])) $link_computer.= "&crypt=".$row['MD5_DEVICEID']; $row[$column]="".$value_of_field.""; } @@ -1774,7 +1771,7 @@ function ajaxgestionresults($resultDetails,$list_fields,$tab_options){ $row[$column]="
".percent_bar($value_of_field)."
"; } - if (!empty($tab_options['REPLACE_VALUE'][$key])){ + if (isset($tab_options['REPLACE_VALUE'][$key])){ $temp_val=explode('&&&',$value_of_field); if (count($temp_val)==1) { $temp_val=explode('&&&',$value_of_field); @@ -1798,10 +1795,12 @@ function ajaxgestionresults($resultDetails,$list_fields,$tab_options){ if(!empty($tab_options['LIEN_CHAMP'][$key])){ $value_of_field=$tab_options['VALUE'][$key][$row[$tab_options['LIEN_CHAMP'][$key]]]; }else{ + if(isset($tab_options['VALUE'][$key][$row['ID']])) { $row[$column] = $tab_options['VALUE'][$key][$row['ID']]; } } - if(!empty($tab_options['REPLACE_VALUE_ALL_TIME'][$key][$row[$tab_options['FIELD_REPLACE_VALUE_ALL_TIME']]])){ + } + if(isset($tab_options['REPLACE_VALUE_ALL_TIME']) && !empty($tab_options['REPLACE_VALUE_ALL_TIME'][$key][$row[$tab_options['FIELD_REPLACE_VALUE_ALL_TIME']]])){ $row[$column]=$tab_options['REPLACE_VALUE_ALL_TIME'][$key][$row[$tab_options['FIELD_REPLACE_VALUE_ALL_TIME']]]; } if (!empty($tab_options['LIEN_LBL'][$key])){ @@ -1817,11 +1816,11 @@ function ajaxgestionresults($resultDetails,$list_fields,$tab_options){ } if(!empty($tab_options['COLOR'][$key])){ - $row[$column]= "".$row[$column].""; + $row[$column]= "".($row[$column] ?? '').""; } if(!empty($tab_options['SHOW_ONLY'][$key])){ if(empty($tab_options['SHOW_ONLY'][$key][$value_of_field])&& empty($tab_options['EXIST'][$key]) - ||(reset($tab_options['SHOW_ONLY'][$key]) == $row[$tab_options['EXIST'][$key]])){ + ||(isset($tab_options['EXIST']) && reset($tab_options['SHOW_ONLY'][$key]) == $row[$tab_options['EXIST'][$key]])){ $row[$key]=""; } } @@ -1838,10 +1837,15 @@ function ajaxgestionresults($resultDetails,$list_fields,$tab_options){ "ARCHIVER", "RESTORE", ); - foreach($actions as $action){ - $row['ACTIONS'].= " ".$row[$action]; + + $row['ACTIONS'] = ''; + foreach($actions as $action){ + if(isset($row[$action])) { + $row['ACTIONS'].= " ".$row[$action]; + } } $rows[] = $row; + } }else{ $rows = 0; @@ -1944,7 +1948,7 @@ function tab_req($list_fields,$default_fields,$list_col_cant_del,$queryDetails,$ } if (isset($tab_options['REQUEST'])){ foreach ($tab_options['REQUEST'] as $field_name => $value){ - $resultDetails = mysql2_query_secure($value, $_SESSION['OCS']["readServer"],$tab_options['ARG'][$field_name]); + $resultDetails = mysql2_query_secure($value, $_SESSION['OCS']["readServer"],$tab_options['ARG'][$field_name] ?? ''); while($item = mysqli_fetch_object($resultDetails)){ if ($item -> FIRST != "") $tab_options['SHOW_ONLY'][$field_name][$item -> FIRST]=$item -> FIRST; @@ -1966,16 +1970,15 @@ function tab_req($list_fields,$default_fields,$list_col_cant_del,$queryDetails,$ $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]); }else{ //add sort on column if need it - if ($protectedPost['tri_fixe']!='' and strstr($sql,$protectedPost['tri_fixe'])){ + if (!empty($protectedPost['tri_fixe']) && strstr($sql,$protectedPost['tri_fixe'])){ $sql.=" order by '%s' %s"; array_push($protectedPost['tri_fixe'],$arg); array_push($protectedPost['sens_'.$table_name],$arg); } - $sql.= $limit; $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"],$arg); } while($item = mysqli_fetch_object($result)){ - if ($item->HARDWARE_ID != "") + if (!empty($item->HARDWARE_ID)) $champs_index=$item->HARDWARE_ID; elseif($item->FILEID != "") $champs_index=$item->FILEID; @@ -2016,7 +2019,9 @@ function tab_req($list_fields,$default_fields,$list_col_cant_del,$queryDetails,$ $_SESSION['OCS']['csv']['SQLNOLIMIT'][$tab_options['table_name']]=$queryDetails; $queryDetails .= ajaxlimit($tab_options); $_SESSION['OCS']['csv']['SQL'][$tab_options['table_name']]=$queryDetails; + if(isset($tab_options['REPLACE_VALUE'])) { $_SESSION['OCS']['csv']['REPLACE_VALUE'][$tab_options['table_name']]=$tab_options['REPLACE_VALUE']; + } if (isset($tab_options['ARG_SQL'])) $_SESSION['OCS']['csv']['ARG'][$tab_options['table_name']]=$tab_options['ARG_SQL']; @@ -2034,7 +2039,7 @@ function tab_req($list_fields,$default_fields,$list_col_cant_del,$queryDetails,$ $rows=0; } - if(is_array($_SESSION['OCS']['SQL_DEBUG']) && ($_SESSION['OCS']['DEBUG'] == 'ON')){ + if(isset($_SESSION['OCS']['SQL_DEBUG']) && is_array($_SESSION['OCS']['SQL_DEBUG']) && ($_SESSION['OCS']['DEBUG'] == 'ON')){ $debug = end($_SESSION['OCS']['SQL_DEBUG']); } // Data set length after filtering @@ -2053,7 +2058,7 @@ function tab_req($list_fields,$default_fields,$list_col_cant_del,$queryDetails,$ }else{ $recordsTotal=$recordsFiltered; } - if(is_array($_SESSION['OCS']['SQL_DEBUG']) && ($_SESSION['OCS']['DEBUG'] == 'ON')){ + if(isset($_SESSION['OCS']['SQL_DEBUG']) && is_array($_SESSION['OCS']['SQL_DEBUG']) && ($_SESSION['OCS']['DEBUG'] == 'ON')){ $res = array("draw"=> $tab_options['draw'],"recordsTotal"=> $recordsTotal, "recordsFiltered"=> $recordsFiltered, "data"=>$rows, "customized"=>$customized, "debug"=>$debug); diff --git a/require/function_telediff.php b/require/function_telediff.php index 27b09fa3e..dc7ccca90 100644 --- a/require/function_telediff.php +++ b/require/function_telediff.php @@ -109,7 +109,7 @@ function desactive_option($name, $list_id, $packid) { $res_desactive = mysql2_query_secure($sql['SQL'], $_SESSION['OCS']["writeServer"], $sql['ARG'], $l->g(512)); } else { $sql_desactive .= " and hardware_id=%s"; - $arg_desactive[] = $_GET['systemid']; + $arg_desactive[] = $_GET['systemid'] ?? ''; $res_desactive = mysql2_query_secure($sql_desactive, $_SESSION['OCS']["writeServer"], $arg_desactive, $l->g(512)); } return( mysqli_affected_rows($_SESSION['OCS']["writeServer"]) ); @@ -120,7 +120,7 @@ function active_option($name, $list_id, $packid, $tvalue = '') { if(strpos($packid, ',')) { $pack_id = explode(',',$packid); - foreach($pack_id as $key => $value){ + foreach($pack_id as $value){ desactive_option($name, $list_id, $value); $sql_active = "insert into devices (HARDWARE_ID, NAME, IVALUE,TVALUE) select ID,'%s','%s',"; if ($tvalue == '') { @@ -158,8 +158,7 @@ function desactive_download_option($list_id, $packid) { function desactive_packet($list_id, $packid) { desactive_download_option($list_id, $packid); - $nb_line = desactive_option('DOWNLOAD', $list_id, $packid); - return $nb_line; + return desactive_option('DOWNLOAD', $list_id, $packid); } function active_serv($list_id, $packid, $id_rule) { @@ -306,7 +305,7 @@ function del_pack($fileid) { $list_id[] = $valEnable["id"]; } //delete packet in DEVICES table - if ($list_id != "") { + if (!empty($list_id)) { foreach ($list_id as $v) { desactive_packet('', $v); } @@ -609,14 +608,12 @@ function found_info_pack($id) { $sql = "select NAME,PRIORITY,FRAGMENTS,SIZE,OSNAME,COMMENT from download_available where fileid=%s"; $res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $id); - $val = mysqli_fetch_array($res); - return $val; + return mysqli_fetch_array($res); } function multiexplode ($delimiters, $date) { $ready = str_replace($delimiters, $delimiters[0], $date); - $launch = explode($delimiters[0], $ready); - return $launch; + return explode($delimiters[0], $ready); } ?> diff --git a/require/header.php b/require/header.php index 36a4b770b..514aefaf6 100644 --- a/require/header.php +++ b/require/header.php @@ -36,9 +36,12 @@ @session_start(); error_reporting(E_ALL & ~E_NOTICE); /* * ******************************************FIND SERVER URL*************************************** */ -$addr_server = explode('/', $_SERVER['HTTP_REFERER']); -array_pop($addr_server); -define("OCSREPORT_URL", implode('/', $addr_server)); +if (isset($_SERVER['HTTP_REFERER'])) { + $addr_server = explode('/', $_SERVER['HTTP_REFERER']); + array_pop($addr_server); + define("OCSREPORT_URL", implode('/', $addr_server)); +} + if ($_SESSION['OCS']['LOG_GUI'] == 1) { define("LOG_FILE", $_SESSION['OCS']['LOG_DIR'] . "log.csv"); @@ -60,7 +63,7 @@ } //If you have to reload conf -if ($_POST['RELOAD_CONF'] == 'RELOAD') { +if (isset($_POST['RELOAD_CONF']) && $_POST['RELOAD_CONF'] == 'RELOAD') { $_SESSION['OCS']['CONF_RESET'] = true; } @@ -399,7 +402,7 @@ $csrf = true; if (isset($_SESSION['OCS']['CSRF'])) { foreach ($_SESSION['OCS']['CSRF'] as $k => $v) { - if ($v == $protectedPost['CSRF_' . $k]) { + if (isset($protectedPost['CSRF_' . $k]) && $v == $protectedPost['CSRF_' . $k]) { $csrf = false; } } diff --git a/require/html_header.php b/require/html_header.php index 486eb907c..ab5ca9792 100644 --- a/require/html_header.php +++ b/require/html_header.php @@ -124,7 +124,7 @@ $need_display = look_config_default_values("WARN_UPDATE"); if ($need_display['ivalue']['WARN_UPDATE'] == '1') { $data = get_update_json(); - if (GUI_VER_SHOW < $data->version) { + if (!empty($data) && GUI_VER_SHOW < $data->version) { $txt = $l->g(2118) . " " . $data->version . " " . $l->g(2119); $txt .= "
" . $l->g(2120) . ""; @@ -233,7 +233,7 @@ echo "
"; -if ($_SESSION['OCS']["mesmachines"] == "NOTAG" && !(array_search('ms_debug', $_SESSION['OCS']['TRUE_PAGES']['ms_debug']) && $protectedGet[PAG_INDEX] == $pages_refs['ms_debug'])) { +if (isset($_SESSION['OCS']["mesmachines"]) && $_SESSION['OCS']["mesmachines"] == "NOTAG" && !(array_search('ms_debug', $_SESSION['OCS']['TRUE_PAGES']['ms_debug']) && $protectedGet[PAG_INDEX] == $pages_refs['ms_debug'])) { if (isset($LIST_ERROR)) { $msg_error = $LIST_ERROR; } else { From 940e2ce1caa1cc14cd358f63daa1a6ff45d40614 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:49:02 +0000 Subject: [PATCH 035/187] php8 fix warnings on ms_users --- .../main_sections/ms_users/ms_custom_perim.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/plugins/main_sections/ms_users/ms_custom_perim.php b/plugins/main_sections/ms_users/ms_custom_perim.php index 470b3969f..329d4da6b 100644 --- a/plugins/main_sections/ms_users/ms_custom_perim.php +++ b/plugins/main_sections/ms_users/ms_custom_perim.php @@ -1,4 +1,5 @@ $value) { + foreach ($info_tag as $value) { $info_value_tag = accountinfo_tab($value['id']); if (is_array($info_value_tag)) { $tab_options['REPLACE_VALUE'][$value['comment']] = $info_value_tag; @@ -48,7 +47,6 @@ } } //END SHOW ACCOUNTINFO - printEnTete($l->g(616) . " " . $protectedGet["id"]); if ($protectedPost['newtag'] != "") { if (isset($protectedPost['use_generic_0'])) { @@ -78,7 +76,6 @@ unset($protectedPost['newtag']); } - //suppression d'une liste de tag if (is_defined($protectedPost['del_check'])) { $sql = "DELETE FROM tags WHERE tag in "; @@ -89,24 +86,20 @@ mysql2_query_secure($sql['SQL'], $_SESSION['OCS']["writeServer"], $sql['ARG']); $tab_options['CACHE'] = 'RESET'; } - if (isset($protectedPost['SUP_PROF'])) { $sql = "DELETE FROM tags WHERE tag='%s' AND login='%s'"; $arg = array($protectedPost['SUP_PROF'], $protectedGet["id"]); mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); } echo "
"; - echo open_form($form_name); $list_fields = array('TAG' => 'tag', ); - $tab_options['FILTRE'] = array_flip($list_fields); $tab_options['FILTRE']['NAME'] = $l->g(49); asort($tab_options['FILTRE']); $list_fields['SUP'] = 'tag'; $list_fields['CHECK'] = 'tag'; - $list_col_cant_del = array('SUP' => 'SUP', 'CHECK' => 'CHECK'); $default_fields = array('TAG' => 'tag'); $sql = prepare_sql_tab($list_fields, $list_col_cant_del); @@ -115,18 +108,15 @@ $tab_options['ARG_SQL'] = $sql['ARG']; $queryDetails = $sql['SQL']; $tab_options['LBL']['SUP'] = $l->g(122); - ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); $img['image/delete.png'] = $l->g(162); del_selection($form_name); - if (is_array($info_value_tag) && !isset($protectedPost['use_generic_0'])) { $type = 2; } else { $type = 0; $info_value_tag = $protectedPost['newtag']; } - echo "
"; echo "
"; $select_choise = show_modif($info_value_tag, 'newtag', $type); @@ -137,9 +127,7 @@ echo "
"; echo "
"; echo close_form(); - if (AJAX) { ob_end_clean(); tab_req($list_fields, $default_fields, $list_col_cant_del, $queryDetails, $tab_options); } -?> \ No newline at end of file From f0642ed5fbd51c7cd10e2731da37b754cbda8631 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:49:29 +0000 Subject: [PATCH 036/187] php8 fix warnings on ms_upload_file --- .../ms_upload_file/ms_local_import.php | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/plugins/main_sections/ms_upload_file/ms_local_import.php b/plugins/main_sections/ms_upload_file/ms_local_import.php index 8df689360..ef9566bb7 100644 --- a/plugins/main_sections/ms_upload_file/ms_local_import.php +++ b/plugins/main_sections/ms_upload_file/ms_local_import.php @@ -1,4 +1,5 @@ g(1258)); - $form_name="insert_computers"; - echo open_form($form_name, '', '', 'form-horizontal'); - echo "

"; - //list fields for form $form_fields_typeinput = array( 'COMPUTER_NAME_GENERIC' => $l->g(35), 'SERIAL_GENERIC' => $l->g(36), 'ADDR_MAC_GENERIC' => $l->g(95) ); - - if(isset($protectedPost['Valid_modif'])) { $error = ''; if (!is_numeric($protectedPost['NB_COMPUTERS'])) { @@ -70,11 +64,9 @@ } } //cas of checkbox - if ($check_trait != array()) { - foreach ($check_trait as $key => $value) { - $fields[] = $key; - $values_fields[] = $value; - } + foreach ($check_trait as $key => $value) { + $fields[] = $key; + $values_fields[] = $value; } $i = 0; @@ -92,7 +84,6 @@ msg_error($l->g(684)."
".$error); } } - $i = 0; $info_form['FIELDS']['name_field'][$i] = 'NB_COMPUTERS'; $info_form['FIELDS']['type_field'][$i] = 0; @@ -102,7 +93,6 @@ $config[$i]['CONFIG']['MAXLENGTH'] = 4; $other_data['COMMENT_AFTER'][$i] = ''; $config[$i]['CONFIG']['JAVASCRIPT'] = $chiffres; - foreach ($form_fields_typeinput as $key => $value) { $i++; $info_form['FIELDS']['name_field'][$i] = $key; @@ -116,9 +106,7 @@ $config[$i]['CONFIG']['SIZE'] = 30; $other_data['COMMENT_AFTER'][$i] = '_M'; } - $accountinfo_form = show_accountinfo('','COMPUTERS','5'); - //merge data $info_form['FIELDS']['name_field'] = array_merge($info_form['FIELDS']['name_field'], $accountinfo_form['FIELDS']['name_field']); $info_form['FIELDS']['type_field'] = array_merge($info_form['FIELDS']['type_field'], $accountinfo_form['FIELDS']['type_field']); @@ -126,20 +114,15 @@ $info_form['FIELDS']['tab_name'] = array_merge($info_form['FIELDS']['tab_name'], $accountinfo_form['FIELDS']['tab_name']); $config = array_merge($config, $accountinfo_form['CONFIG']); $other_data['COMMENT_AFTER'] = array_merge($other_data['COMMENT_AFTER'], $accountinfo_form['COMMENT_AFTER']); - $tab_typ_champ = show_field($info_form['FIELDS']['name_field'], $info_form['FIELDS']['type_field'], $info_form['FIELDS']['value_field']); - foreach($config as $key=>$value) { $tab_typ_champ[$key]['CONFIG'] = $value['CONFIG']; $tab_typ_champ[$key]['COMMENT_AFTER'] = $other_data['COMMENT_AFTER'][$key]; } - if(isset($tab_typ_champ)) { modif_values($info_form['FIELDS']['tab_name'], $tab_typ_champ,$tab_hidden, array( 'show_frame' => false )); } - echo "
"; echo close_form(); -?> \ No newline at end of file From 57bce3d499f249063dab04cf015d7c71802afd9c Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:50:09 +0000 Subject: [PATCH 037/187] php8 fix warnings on ms_snmp_inventory --- .../ms_snmp_inventory/ms_snmp_inventory.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/main_sections/ms_snmp_inventory/ms_snmp_inventory.php b/plugins/main_sections/ms_snmp_inventory/ms_snmp_inventory.php index 62057b238..63922b44c 100644 --- a/plugins/main_sections/ms_snmp_inventory/ms_snmp_inventory.php +++ b/plugins/main_sections/ms_snmp_inventory/ms_snmp_inventory.php @@ -41,7 +41,7 @@ //definition of onglet foreach($typeList as $id => $values) { $def_onglets[$id] = $values['TYPENAME']; - if ($protectedPost['onglet'] == "") { + if (empty($protectedPost['onglet'])) { $protectedPost['onglet'] = $id; } } @@ -55,7 +55,7 @@ //show first lign of onglet if($count < 15){ - show_tabs($def_onglets,$form_name,"onglet",true, $i); + show_tabs($def_onglets,$form_name,"onglet",true); } if ($count >= 15) { @@ -94,7 +94,7 @@ $tab_options['form_name'] = $form_name; $tab_options['table_name'] = $table_name; - for($i = 0; $columns[$i] != null; $i++) { + for($i = 0; !empty($columns[$i]); $i++) { if($i <= 3) { $list_fields[$columns[$i]] = $columns[$i]; } else { @@ -107,7 +107,7 @@ $list_col_cant_del = $list_fields; $default_fields = $list_fields; - if($list_fields2 != null) { + if(!empty($list_fields2)) { $list_fields = array_merge($list_fields,$list_fields2); } @@ -141,7 +141,7 @@ echo ''; echo ''.$column.''; echo ''; - if(strpos($values[$column], " - ") !== false) { + if(str_contains($values[$column], " - ")) { $list = explode(" - ", $values[$column]); natsort($list); foreach($list as $lists) { From 59d8389a4631897006e3c4f0e7c92deb6ec2ee7a Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:54:28 +0000 Subject: [PATCH 038/187] php8 syntax update on p sd_powersupplies/ --- plugins/snmp_detail/sd_powersupplies/sd_powersupplies.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/snmp_detail/sd_powersupplies/sd_powersupplies.php b/plugins/snmp_detail/sd_powersupplies/sd_powersupplies.php index 681e2378c..85448301a 100755 --- a/plugins/snmp_detail/sd_powersupplies/sd_powersupplies.php +++ b/plugins/snmp_detail/sd_powersupplies/sd_powersupplies.php @@ -36,7 +36,6 @@ } $table_name = "sd_powersupplies"; $tab_options = $protectedPost; -$tab_options = $protectedPost; $tab_options['form_name'] = $form_name; $tab_options['table_name'] = $table_name; $list_fields = array($l->g(64) => 'MANUFACTURER', @@ -58,4 +57,4 @@ tab_req($list_fields, $default_fields, $list_col_cant_del, $sql['SQL'], $tab_options); ob_start(); } -?> \ No newline at end of file +?> From 97202e1bb9d84f89f9c222cd2c6e2c8e0622fa6b Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:54:58 +0000 Subject: [PATCH 039/187] php8 fix warnings on ms_search_soft --- plugins/main_sections/ms_search_soft/ms_search_soft.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/main_sections/ms_search_soft/ms_search_soft.php b/plugins/main_sections/ms_search_soft/ms_search_soft.php index ecfd0fef4..2b944b85e 100644 --- a/plugins/main_sections/ms_search_soft/ms_search_soft.php +++ b/plugins/main_sections/ms_search_soft/ms_search_soft.php @@ -73,7 +73,7 @@ } else { $logiciel = $protectedPost['logiciel_text']; // Check for wildcard - if (strpos($logiciel, '*') !== false || strpos($logiciel,'?') !== false) { + if (str_contains($logiciel, '*') || str_contains($logiciel,'?')) { $wildcard = true; $logiciel = str_replace("*", "%", $logiciel); $logiciel = str_replace("?", "_", $logiciel); @@ -97,7 +97,7 @@ $default_fields = $list_fields; $tab_options['AS']['s.NAME'] = 'SNAME'; $queryDetails = "SELECT DISTINCT h.ID,"; - foreach ($list_fields as $lbl => $value) { + foreach ($list_fields as $value) { if ($value == 's.NAME') { $queryDetails .= $value . " as " . $tab_options['AS']['s.NAME'] . ","; } else { From 22a560ff86dee94f35799f8280483275f3dcaef0 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:55:27 +0000 Subject: [PATCH 040/187] php8 fix warnings on ms_save_query --- plugins/main_sections/ms_save_query/ms_save_query_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/main_sections/ms_save_query/ms_save_query_list.php b/plugins/main_sections/ms_save_query/ms_save_query_list.php index 4edfb3406..211cfc8f5 100644 --- a/plugins/main_sections/ms_save_query/ms_save_query_list.php +++ b/plugins/main_sections/ms_save_query/ms_save_query_list.php @@ -56,7 +56,7 @@ $def_onglets['NEW_QUERY'] = $l->g(2142); //New category //default => first onglet -if ($protectedPost['onglet'] == "") { +if (empty($protectedPost['onglet'])) { $protectedPost['onglet'] = "QUERY_LIST"; } From e751f50d531123e5a1599dbde9da575fe308585b Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:56:03 +0000 Subject: [PATCH 041/187] php8 update syntax on ms_saas_soft --- plugins/main_sections/ms_saas_soft/ms_saas_soft.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/main_sections/ms_saas_soft/ms_saas_soft.php b/plugins/main_sections/ms_saas_soft/ms_saas_soft.php index e9bf363ae..09b726ffb 100644 --- a/plugins/main_sections/ms_saas_soft/ms_saas_soft.php +++ b/plugins/main_sections/ms_saas_soft/ms_saas_soft.php @@ -33,7 +33,7 @@ printEnTete($l->g(8100)); echo "
"; //ADD new static group - if ($protectedPost['Valid_modif']) { + if (isset($protectedPost['Valid_modif'])) { $result = $saas->add_saas($protectedPost['SAAS_NAME'], $protectedPost['DNS_SAAS']); if (!$result) { msg_error($l->g(8107)); @@ -44,14 +44,14 @@ $tab_options['CACHE'] = 'RESET'; } //reset add saas - if ($protectedPost['Reset_modif'] || ($protectedPost['onglet'] != $protectedPost['old_onglet'])) { + if (isset($protectedPost['Reset_modif']) || (isset($protectedPost['onglet']) && isset($protectedPost['old_onglet']) && ($protectedPost['onglet'] != $protectedPost['old_onglet']))) { unset($protectedPost['SAAS_NAME']); unset($protectedPost['DNS_SAAS']); } $tab_options = $protectedPost; //if delete saas - if ($protectedPost['SUP_PROF'] != "") { + if (!empty($protectedPost['SUP_PROF'])) { $sqlQuery = "DELETE FROM `saas_exp` WHERE ID = %s"; $sqlArg = [$protectedPost['SUP_PROF']]; mysql2_query_secure($sqlQuery, $_SESSION['OCS']["writeServer"], $sqlArg); @@ -69,7 +69,7 @@ $def_onglets['SAAS_LIST']=$l->g(8101); //Dynamic group $def_onglets['SAAS_ADD']=$l->g(8102); //Static group centraux - if ($protectedPost['onglet'] == ""){ + if (empty($protectedPost['onglet'])){ $protectedPost['onglet']="SAAS_LIST"; } @@ -94,7 +94,8 @@ $tab_options['LBL']['nb'] = $l->g(1120); }elseif($protectedPost['onglet'] == "SAAS_ADD"){ - + $protectedPost['SAAS_NAME'] = isset($protectedPost['SAAS_NAME']) ? $protectedPost['SAAS_NAME'] : ''; + $protectedPost['DNS_SAAS'] = isset($protectedPost['DNS_SAAS']) ? $protectedPost['DNS_SAAS'] : ''; ?>
From 6ac6373896049b318bcaf9339350a01e1a77bdc2 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:56:32 +0000 Subject: [PATCH 042/187] php8 fix warnings on ms_repart_tag --- plugins/main_sections/ms_repart_tag/ms_repart_tag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/main_sections/ms_repart_tag/ms_repart_tag.php b/plugins/main_sections/ms_repart_tag/ms_repart_tag.php index 7a6537f68..9f15f77da 100755 --- a/plugins/main_sections/ms_repart_tag/ms_repart_tag.php +++ b/plugins/main_sections/ms_repart_tag/ms_repart_tag.php @@ -36,7 +36,7 @@ } //BEGIN SHOW ACCOUNTINFO require_once('require/function_admininfo.php'); -$accountinfo_value = interprete_accountinfo($list_fields, $tab_options); +$accountinfo_value = interprete_accountinfo($list_fields ?? null, $tab_options); $list_fields = $accountinfo_value['LIST_FIELDS']; $list_fields_flip = array_flip($list_fields); From f3fca6897d656c904945d2641d26361aabb5a1e6 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:56:56 +0000 Subject: [PATCH 043/187] php8 syntax update on ms_logs --- plugins/main_sections/ms_logs/ms_logs.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/main_sections/ms_logs/ms_logs.php b/plugins/main_sections/ms_logs/ms_logs.php index 6feaa5abe..3252556a2 100755 --- a/plugins/main_sections/ms_logs/ms_logs.php +++ b/plugins/main_sections/ms_logs/ms_logs.php @@ -1,4 +1,5 @@ g(766)); } - if (AJAX) { ob_end_clean(); tab_req($list_fields, $default_fields, $list_col_cant_del, $sql, $tab_options); } -?> \ No newline at end of file From af580fb0c4986eafdf84e5ce2fec7d33e41f7fcb Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:57:26 +0000 Subject: [PATCH 044/187] php8 fix warnings on ms_extensionmanager --- .../main_sections/ms_extensionmanager/ms_extensionmanager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/main_sections/ms_extensionmanager/ms_extensionmanager.php b/plugins/main_sections/ms_extensionmanager/ms_extensionmanager.php index f0e4671a8..a0cc88982 100755 --- a/plugins/main_sections/ms_extensionmanager/ms_extensionmanager.php +++ b/plugins/main_sections/ms_extensionmanager/ms_extensionmanager.php @@ -60,7 +60,7 @@
"; - //show details for category if ($protectedPost['detail'] != '') { // category reminder @@ -330,15 +311,13 @@ function groupBy($key, $data) { $duplicates = mysql2_query_secure($sql['SQL'], $_SESSION['OCS']["readServer"], $sql['ARG']); $duplicates = mysqli_fetch_all($duplicates, MYSQLI_ASSOC); - // grouping of duplicates is conditional - switch($protectedPost['detail']) { - case "hostname_serial": $criteria = 'name'; break; - case "hostname_macaddress": $criteria = 'macaddr'; break; - case "macaddress_serial": $criteria = 'macaddr'; break; - case "hostname": $criteria = 'name'; break; - case "ssn": $criteria = 'ssn'; break; - case "macaddress": $criteria = 'macaddr'; break; - } + $criteria = match ($protectedPost['detail']) { + "hostname_serial" => 'name', + "hostname_macaddress", "macaddress_serial" => 'macaddr', + "hostname" => 'name', + "ssn" => 'ssn', + "macaddress" => 'macaddr', + }; $grpDuplis = groupBy($criteria, $duplicates); $i = 0; @@ -363,7 +342,7 @@ function groupBy($key, $data) { echo "
".strtoupper($itemagain['name']). "


"; echo "
"; foreach ($itemagain as $key => $info) { - if(strpos($key, "fields_") !== false) { + if(str_contains($key, "fields_")) { $admininfoId = explode("_", $key); $admininfo = find_info_accountinfo($admininfoId[1]); @@ -395,9 +374,7 @@ function groupBy($key, $data) { # echo "

"; echo ""; } - echo close_form(); - // merge selected duplicates if ($protectedPost['FUSION']) { // if duplicates selection is coming from checkbox "all" @@ -460,9 +437,7 @@ function groupBy($key, $data) { if (isset($protectedPost['selected_dupli']) && count($protectedPost['selected_dupli']) < 2) { echo ""; } -} - - +} // merge all duplicates if ($protectedPost['FUSION_ALL']) { // $grpDuplis as already been grouped by criteria and contains all duplicates @@ -478,9 +453,7 @@ function groupBy($key, $data) { } } } - // END MODIF DUPLICATES if (AJAX) { ob_end_clean(); } -?> \ No newline at end of file From f9123fb86242ea1049c1f2dce5a8d77f3620381d Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:58:39 +0000 Subject: [PATCH 047/187] php8 fix warnings on ms_cve_search --- .../main_sections/ms_cve_search/ms_cve_search.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/main_sections/ms_cve_search/ms_cve_search.php b/plugins/main_sections/ms_cve_search/ms_cve_search.php index 4e8aa8aca..2489a2a05 100644 --- a/plugins/main_sections/ms_cve_search/ms_cve_search.php +++ b/plugins/main_sections/ms_cve_search/ms_cve_search.php @@ -35,7 +35,7 @@ printEnTete($l->g(1463)); //If RESET -if ($protectedPost['RESET']) { +if (isset($protectedPost['RESET'])) { unset($protectedPost['FILTRE1']); unset($protectedPost['FILTRE2']); } @@ -55,7 +55,7 @@ $def_onglets['BY_COMPUTER'] = $l->g(1486); //All CVE by computer. //default => first onglet - if ($protectedPost['onglet'] == "") { + if (empty($protectedPost['onglet'])) { $protectedPost['onglet'] = "BY_CVSS"; } @@ -68,7 +68,7 @@ if($protectedPost['onglet'] == "BY_CVSS"){ //Filter CVSS - if ($protectedPost['FILTRE1'] != "" && $protectedPost['FILTRE2'] != "") { + if (!empty($protectedPost['FILTRE1']) && !empty($protectedPost['FILTRE2'])) { $query = " WHERE c.CVSS BETWEEN %s AND %s "; $sql['ARG'] = array($protectedPost['FILTRE1'], $protectedPost['FILTRE2']); } @@ -78,7 +78,7 @@ LEFT JOIN software_publisher p ON p.ID = c.PUBLISHER_ID LEFT JOIN software_version v ON v.ID = c.VERSION_ID'; - if($query != null) { + if(!empty($query)) { $sql['SQL'] .= $query; } @@ -141,7 +141,7 @@ $tab_options['LIEN_LBL']['Link'] = ' '; $tab_options['LIEN_CHAMP']['Link'] = 'LINK'; $tab_options['LBL']['Link'] = $l->g(1467); - $tab_options['ARG_SQL'] = $sql['ARG']; + $tab_options['ARG_SQL'] = $sql['ARG'] ?? ''; $tab_options['form_name'] = $form_name; $tab_options['table_name'] = $form_name; $result_exist = ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); @@ -158,11 +158,11 @@
- '; + '; echo '
- +
From 221d6d408a4095f30db40d552ddfcd0dd4f0d433 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:59:04 +0000 Subject: [PATCH 048/187] php8 fix warnings on ms_computer --- plugins/main_sections/ms_computer/ms_computer.php | 2 +- plugins/main_sections/ms_computer/ms_computer_views.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/main_sections/ms_computer/ms_computer.php b/plugins/main_sections/ms_computer/ms_computer.php index 9e23dfaa3..992f4d4a9 100644 --- a/plugins/main_sections/ms_computer/ms_computer.php +++ b/plugins/main_sections/ms_computer/ms_computer.php @@ -35,7 +35,7 @@ require_once('ms_computer_views.php'); require_once('require/archive/ArchiveComputer.php'); //recherche des infos de la machine -$item = info($protectedGet, $protectedPost['systemid']); +$item = info($protectedGet, $protectedPost['systemid'] ?? ''); if (!is_object($item)) { msg_error($item); require_once(FOOTER_HTML); diff --git a/plugins/main_sections/ms_computer/ms_computer_views.php b/plugins/main_sections/ms_computer/ms_computer_views.php index 6ff20ffd7..ec4b1fbd3 100644 --- a/plugins/main_sections/ms_computer/ms_computer_views.php +++ b/plugins/main_sections/ms_computer/ms_computer_views.php @@ -38,7 +38,7 @@ function show_computer_menu($computer_id) { $url = $menu_elem->getUrl(); $label = $menu_renderer->getLabel($menu_elem); echo "
  • " . $label . "
  • "; @@ -139,7 +139,7 @@ function show_computer_summary($computer) { foreach ($labels as $cat) { foreach ($cat as $key => $lbl) { - $computer_info = addslashes($computer->$key); + $computer_info = isset($computer->$key) ? addslashes($computer->$key) : ''; if ($key == "MEMORY") { $sqlMem = "SELECT SUM(capacity) AS 'capa' FROM memories WHERE hardware_id=%s"; $argMem = $computer->ID; @@ -174,8 +174,8 @@ function show_computer_summary($computer) { $argVM = $computer->UUID; $resVM = mysql2_query_secure($sqlVM, $_SESSION['OCS']["readServer"], $argVM); $valVM = mysqli_fetch_array($resVM); - $data[$key] = $valVM['vmtype']; - $link_vm = "" . $valVM['name'] . ""; + $data[$key] = $valVM['vmtype'] ?? ''; + $link_vm = "" . ($valVM['name'] ?? '') . ""; $link[$key] = true; if ($data[$key] != '') { From 64278a2ec9d78590d89340b57ef800e495543b88 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 13:59:33 +0000 Subject: [PATCH 049/187] php8 fix warnings on ms_all_soft --- plugins/main_sections/ms_all_soft/ms_all_soft.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/main_sections/ms_all_soft/ms_all_soft.php b/plugins/main_sections/ms_all_soft/ms_all_soft.php index e07996d0c..ddc5642ad 100644 --- a/plugins/main_sections/ms_all_soft/ms_all_soft.php +++ b/plugins/main_sections/ms_all_soft/ms_all_soft.php @@ -35,7 +35,7 @@ $softCat = new SoftwareCategory(); //If RESET -if ($protectedPost['RESET']) { +if (isset($protectedPost['RESET'])) { unset($protectedPost['NAME_RESTRICT']); unset($protectedPost['NBRE']); unset($protectedPost['CLASS']); @@ -43,7 +43,7 @@ } //If SUBMIT -if ($protectedPost['SUBMIT_FORM']) { +if (isset($protectedPost['SUBMIT_FORM'])) { $tab_options['CACHE'] = 'RESET'; } @@ -101,7 +101,7 @@ //definition of onglet $def_onglets['ALL'] = $l->g(765); //Category list. $def_onglets['WITHOUT'] = $l->g(1516); //Category list. -for($i=1; $list_cat[$i] != null; $i++){ +for($i=1; isset($list_cat[$i]); $i++){ $def_onglets[$list_cat['category_name'][$list_cat[$i]]] = $list_cat[$i]; } @@ -109,7 +109,7 @@ if (isset($protectedGet['onglet']) && !isset($protectedPost['old_onglet'])){ $protectedPost['onglet'] = $protectedGet['onglet']; } -if ($protectedPost['onglet'] == "") { +if (empty($protectedPost['onglet'])) { $protectedPost['onglet'] = "ALL"; } @@ -169,7 +169,7 @@ $list_col_cant_del = $default_fields; $tab_options['LBL']['name'] = $l->g(847); $tab_options['LBL']['nbre'] = $l->g(1120); - $tab_options['ARG_SQL'] = $sql['ARG']; + $tab_options['ARG_SQL'] = $sql['ARG'] ?? ''; $tab_options['form_name'] = $form_name; $tab_options['table_name'] = $form_name; $result_exist = ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); @@ -300,7 +300,7 @@
    - +



    - - + + readCSVHeader(); // delete csv field of reconciliation from header > cant link it with any other field unset($header[$protectedPost['csv_field']]); - + // get ocs fields from accountinfo_config $req = "SELECT ID, NAME from accountinfo_config WHERE account_type = 'computers'"; $ocs_fields = mysql2_query_secure($req, $_SESSION['OCS']["readServer"]); @@ -495,7 +495,7 @@ echo ' '; echo ' '.$column.''; echo '
    "; - - + + // 5th - results @@ -521,7 +521,7 @@ // get array of links foreach ($protectedPost as $key => $value) { - if (strpos($key, 'link_') === 0) { + if (str_starts_with($key, 'link_')) { $links[$key] = $value; } } @@ -604,7 +604,7 @@ function logCSVErrors($lvl) { $error = "CSV line $key : ".$l->g($error); msg_error($error); } - + // 1st - import csv } else { // Open new form for csv file From e2cda7ce131741cce33a8fc8ad1c2906284b6708 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 14:01:27 +0000 Subject: [PATCH 052/187] php8 syntax update on cd_saas --- plugins/computer_detail/cd_saas/cd_saas.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/computer_detail/cd_saas/cd_saas.php b/plugins/computer_detail/cd_saas/cd_saas.php index adfe01207..3011645bc 100644 --- a/plugins/computer_detail/cd_saas/cd_saas.php +++ b/plugins/computer_detail/cd_saas/cd_saas.php @@ -51,7 +51,7 @@ $default_fields = array($l->g(49) => $l->g(49), $l->g(8104) => $l->g(8104), $l->g(8105) => $l->g(8105)); $queryDetails = "SELECT DISTINCT "; - foreach ($list_fields as $lbl => $value) { + foreach ($list_fields as $value) { $queryDetails .= $value . ","; } $queryDetails = substr($queryDetails, 0, -1) . " FROM saas s LEFT JOIN saas_exp e ON e.ID = s.SAAS_EXP_ID WHERE (hardware_id=$systemid)"; From acd5d08babe71e87aeb15cb53136975409751a5b Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 14:01:56 +0000 Subject: [PATCH 053/187] php8 fix warnings on cd_networks --- plugins/computer_detail/cd_networks/cd_networks.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/computer_detail/cd_networks/cd_networks.php b/plugins/computer_detail/cd_networks/cd_networks.php index 1bc9f728e..76ab2bb5f 100755 --- a/plugins/computer_detail/cd_networks/cd_networks.php +++ b/plugins/computer_detail/cd_networks/cd_networks.php @@ -1,4 +1,5 @@ g(82)); if (!isset($protectedPost['SHOW'])) { $protectedPost['SHOW'] = 'NOSHOW'; } $tab_options = $protectedPost; - if ($protectedPost['OTHER_BIS'] != '') { //verify @mac if (preg_match('/([0-9A-F]{2}:){5}[0-9A-F]{2}$/i', $protectedPost['OTHER_BIS'])) { @@ -50,7 +49,6 @@ $tab_options['CACHE'] = 'RESET'; } } - $form_name = "affich_networks"; $table_name = $form_name; $tab_options['form_name'] = $form_name; @@ -84,16 +82,14 @@ } } } - if ($show_all_column) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del[$l->g(34)] = $l->g(34); } - $default_fields = $list_fields; $queryDetails = "SELECT "; -foreach ($list_fields as $lbl => $value) { +foreach ($list_fields as $value) { $queryDetails .= $value . ","; } $queryDetails = substr($queryDetails, 0, -1) . " FROM networks WHERE (hardware_id=$systemid)"; @@ -104,4 +100,3 @@ tab_req($list_fields, $default_fields, $list_col_cant_del, $queryDetails, $tab_options); ob_start(); } -?> \ No newline at end of file From c11577e3c04dbc7211a74388299df17f964b8d91 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 14:06:13 +0000 Subject: [PATCH 054/187] php8 syntax update on cron_wol.php --- crontab/cron_wol.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crontab/cron_wol.php b/crontab/cron_wol.php index 7fe91b5ac..5b403dc58 100644 --- a/crontab/cron_wol.php +++ b/crontab/cron_wol.php @@ -29,7 +29,7 @@ $id = explode(',', $wol[$i]['WOL_ID']); if($date_wol == $today){ - foreach($id as $key => $value){ + foreach($id as $value){ $sql_computer = "SELECT MACADDR,IPADDRESS FROM networks WHERE (hardware_id=%s) AND status='Up'"; $sql_arg = array($value); $resultDetails = mysql2_query_secure($sql_computer, $_SESSION['OCS']["readServer"], $sql_arg); From b156e84cbd9190791a2e51535edaca127fb1b807 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 22 Nov 2021 14:07:05 +0000 Subject: [PATCH 055/187] php8 syntax update on ajax/calendarfield.php --- ajax/calendarfield.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ajax/calendarfield.php b/ajax/calendarfield.php index 72659e88f..bb6bcf9d2 100644 --- a/ajax/calendarfield.php +++ b/ajax/calendarfield.php @@ -1,4 +1,5 @@ + $fieldId = htmlspecialchars($fieldId, ENT_QUOTES, 'UTF-8'); + + return '
    '.calendars($fieldId, $_SESSION['OCS']['DATE_FORMAT_LANG']).' -
    '; - - return $html; + '; } -?> \ No newline at end of file From f702cc930f479bc3d3df31c88eb7ca1cd7def088 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:34:32 +0000 Subject: [PATCH 056/187] php8 fix warnings on index.php --- index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index cc0e260ed..341229588 100644 --- a/index.php +++ b/index.php @@ -42,7 +42,9 @@ } require ('require/header.php'); -addLog('PAGE', $protectedGet[PAG_INDEX]); +if (isset($protectedGet[PAG_INDEX])) { + addLog('PAGE', $protectedGet[PAG_INDEX]); +} if (!AJAX && !isset($protectedGet["popup"]) && !isset($protectedGet["no_footer"])) { require (FOOTER_HTML); From f71b5207e2af2dddef9d574f1a3b95370d1ecb23 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:35:47 +0000 Subject: [PATCH 057/187] php8 fix warnings on ms_computer --- plugins/main_sections/ms_computer/ms_computer.php | 2 +- plugins/main_sections/ms_computer/ms_computer_views.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/main_sections/ms_computer/ms_computer.php b/plugins/main_sections/ms_computer/ms_computer.php index 731b18623..b96148c58 100644 --- a/plugins/main_sections/ms_computer/ms_computer.php +++ b/plugins/main_sections/ms_computer/ms_computer.php @@ -147,7 +147,7 @@ echo '
    '; } } - if(file_exists($file_extension)){ + if(isset($file_extension) && file_exists($file_extension)){ require $file_extension; }else{ require $plugin_file; diff --git a/plugins/main_sections/ms_computer/ms_computer_views.php b/plugins/main_sections/ms_computer/ms_computer_views.php index ec4b1fbd3..81d7696b0 100644 --- a/plugins/main_sections/ms_computer/ms_computer_views.php +++ b/plugins/main_sections/ms_computer/ms_computer_views.php @@ -162,9 +162,9 @@ function show_computer_summary($computer) { $nb_val = count($data_RZ); } - if ($nb_val == 1) { + if (isset($nb_val) && $nb_val == 1) { $data[$key] = $data_RZ[0]; - } elseif (isset($data_RZ)) { + } elseif (isset($data_RZ) && is_array($data_RZ)) { foreach ($data_RZ as $index => $value) { $data[$key] .= $index . " => " . $value . "
    "; } @@ -219,7 +219,7 @@ function show_summary($data, $labels, $cat_labels, $links = array()) { echo '
    ' . mb_strtoupper($cat_labels[$cat_key]) . '
    '; foreach ($cat as $name => $label) { - $value = $data[$name]; + $value = isset($data[$name])? $data[$name] : ''; if (trim($value) != '') { if (!array_key_exists($name, $links)) { From 7222ed0bae9c811b87eefd17306c692f49c2c8e5 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:37:31 +0000 Subject: [PATCH 058/187] php8 fix warnings on ms_config --- .../ms_config/ms_notification.php | 30 +++++++++---------- .../ms_config/ms_snmp_config.php | 10 +++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/plugins/main_sections/ms_config/ms_notification.php b/plugins/main_sections/ms_config/ms_notification.php index ed02138d3..85339dcc8 100644 --- a/plugins/main_sections/ms_config/ms_notification.php +++ b/plugins/main_sections/ms_config/ms_notification.php @@ -40,7 +40,7 @@ $def_onglets['NOTIF_PERSO'] = $l->g(8012); //Notification personnalisation //default => first onglet -if ($protectedPost['onglet'] == "") { +if (empty($protectedPost['onglet'])) { $protectedPost['onglet'] = "NOTIF_CONFIG"; } @@ -66,7 +66,7 @@ if($protectedPost['onglet'] == 'NOTIF_CONFIG'){ - if ($protectedPost['Valid'] == $l->g(103)) { + if (isset($protectedPost['Valid']) && $protectedPost['Valid'] == $l->g(103)) { $mail->insert_info_smtp($protectedPost); } @@ -78,7 +78,7 @@ $send_mode = array('nonsecure' => 'SMTP'/*, 'PHP' => 'PHP'*/,'ssl' => 'SMTP+SSL', 'tls'=>'SMTP+TLS'); echo $mail->div['NOTIF_FOLLOW']; - if($mail->info['NOTIF_FOLLOW'] == 'ON'){ + if(isset($mail->info['NOTIF_FOLLOW']) && $mail->info['NOTIF_FOLLOW'] == 'ON'){ echo "ON
    "; echo "OFF"; $required = "required"; @@ -89,23 +89,23 @@ } echo "
    "; echo $mail->div['NOTIF_MAIL_ADMIN']; - echo ""; + echo ""; echo ""; echo $mail->div['NOTIF_NAME_ADMIN']; - echo ""; + echo ""; echo ""; echo $mail->div['NOTIF_MAIL_REPLY']; - echo ""; + echo ""; echo "

    " . $l->g(8010) . "

    "; echo ""; echo $mail->div['NOTIF_NAME_REPLY']; - echo ""; + echo ""; echo "

    " . $l->g(8010) . "

    "; echo ""; echo $mail->div['NOTIF_SEND_MODE']; echo ""; echo ""; echo $mail->div['NOTIF_SMTP_HOST']; - echo ""; + echo ""; echo ""; echo $mail->div['NOTIF_PORT_SMTP']; - echo ""; + echo ""; echo ""; echo $mail->div['NOTIF_USER_SMTP']; - echo ""; + echo ""; echo "

    " . $l->g(8010) . "

    "; echo ""; echo $mail->div['NOTIF_PASSWD_SMTP']; - echo ""; + echo ""; echo "

    " . $l->g(8010) . "

    "; echo ""; echo $mail->div['NOTIF_PROG_TIME']; - echo ""; + echo ""; echo ""; echo $mail->div['NOTIF_PROG_DAY']; @@ -155,7 +155,7 @@ if($protectedPost['onglet'] == 'NOTIF_PERSO'){ echo "

    "; - if ($protectedPost['Send'] == $l->g(103)) { + if (isset($protectedPost['Send']) && $protectedPost['Send'] == $l->g(103)) { $mail->update_perso($protectedPost['notif_choice']); if($protectedPost['notif_choice'] == 'PERSO'){ $result =$mail->upload_file($_FILES, $protectedPost['subject']); @@ -185,7 +185,7 @@ echo '
    '; //Default - echo "
    "; + echo "
    "; echo "
    "; $output = $mail->replace_value('require/mail/Templates/OCS_template.html', 'DEFAULT'); diff --git a/plugins/main_sections/ms_config/ms_snmp_config.php b/plugins/main_sections/ms_config/ms_snmp_config.php index 4136fd584..8c8a3e43e 100644 --- a/plugins/main_sections/ms_config/ms_snmp_config.php +++ b/plugins/main_sections/ms_config/ms_snmp_config.php @@ -54,7 +54,7 @@ } //default => first onglet -if ($protectedPost['onglet'] == "") { +if (empty($protectedPost['onglet'])) { $protectedPost['onglet'] = "SNMP_RULE"; } @@ -147,7 +147,7 @@ unset($protectedPost['create_type_condition']); } - if($protectedPost['type_filter'] != "empty" && $protectedPost['type_filter'] != null) { + if(isset($protectedPost['type_filter']) && $protectedPost['type_filter'] != "empty" && $protectedPost['type_filter'] != null) { $filter = " WHERE c.TYPE_ID = ".$protectedPost['type_filter']; } else { $filter = ""; @@ -174,7 +174,7 @@ echo "
    "; - formGroup('select', 'type_filter', $l->g(9011), '', '', $protectedPost['type_filter'], '', $filter_type, $filter_type); + formGroup('select', 'type_filter', $l->g(9011), '', '', $protectedPost['type_filter'] ?? '', '', $filter_type, $filter_type); echo "
    "; echo "
    "; echo ""; @@ -274,7 +274,7 @@ unset($protectedPost['update_snmp']); } - if($protectedPost['type_filter'] != "empty" && $protectedPost['type_filter'] != null) { + if(isset($protectedPost['type_filter']) && $protectedPost['type_filter'] != "empty" && $protectedPost['type_filter'] != null) { $filter = " WHERE c.TYPE_ID ='".$protectedPost['type_filter']."'"; } else { $filter = ""; @@ -302,7 +302,7 @@ echo "
    "; - formGroup('select', 'type_filter', $l->g(9011), '', '', $protectedPost['type_filter'], '', $filter_type, $filter_type); + formGroup('select', 'type_filter', $l->g(9011), '', '', $protectedPost['type_filter'] ?? '', '', $filter_type, $filter_type); echo "
    "; echo "
    "; echo ""; From 73323bc937626126da160201d84a13ca0cf225e6 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:39:18 +0000 Subject: [PATCH 059/187] php8 fix warnings on computer_detail --- .../cd_admininfo/cd_admininfo.php | 10 +++++----- plugins/computer_detail/cd_bios/cd_bios.php | 12 ++++++----- .../cd_comments/cd_comments.php | 8 ++++---- .../cd_configuration/cd_configuration.php | 20 +++++++++---------- .../cd_controllers/cd_controllers.php | 2 +- plugins/computer_detail/cd_cve/cd_cve.php | 2 +- .../computer_detail/cd_drives/cd_drives.php | 2 +- .../computer_detail/cd_inputs/cd_inputs.php | 2 +- .../cd_memories/cd_memories.php | 2 +- .../computer_detail/cd_modems/cd_modems.php | 2 +- .../cd_monitors/cd_monitors.php | 2 +- .../cd_networks/cd_networks.php | 8 ++++---- plugins/computer_detail/cd_saas/cd_saas.php | 2 +- .../cd_softwares/cd_softwares.php | 2 +- .../computer_detail/cd_sounds/cd_sounds.php | 2 +- .../cd_storages/cd_storages.php | 2 +- .../computer_detail/cd_videos/cd_videos.php | 2 +- 17 files changed, 42 insertions(+), 40 deletions(-) diff --git a/plugins/computer_detail/cd_admininfo/cd_admininfo.php b/plugins/computer_detail/cd_admininfo/cd_admininfo.php index dd375335b..091c2bce0 100644 --- a/plugins/computer_detail/cd_admininfo/cd_admininfo.php +++ b/plugins/computer_detail/cd_admininfo/cd_admininfo.php @@ -42,7 +42,7 @@ $list_tab = find_all_account_tab('TAB_ACCOUNTAG', 'COMPUTERS', 1); if ($list_tab != '') { - if ($protectedPost['Valid_modif'] != "" && $protectedPost['NOTE'] == "" && $protectedPost['NOTE_MODIF'] == "") { + if (isset($protectedPost['Valid_modif']) && $protectedPost['NOTE'] == "" && $protectedPost['NOTE_MODIF'] == "") { if (!is_defined($protectedPost['onglet']) || !is_numeric($protectedPost['onglet'])) { $protectedPost['onglet'] = $list_tab['FIRST']; } @@ -97,7 +97,7 @@ unset($list_tab['FIRST']); echo open_form($form_name, '', '', 'form-horizontal'); - if (!$show_all_column) { + if (!isset($show_all_column)) { onglet($list_tab, $form_name, "onglet", 6); $sql_admin_info = "select ID,TYPE,NAME,COMMENT,NAME_ACCOUNTINFO,SHOW_ORDER,DEFAULT_VALUE from accountinfo_config where ID_TAB = %s and account_type='COMPUTERS' order by SHOW_ORDER ASC"; @@ -107,7 +107,7 @@ order by SHOW_ORDER ASC"; $arg_admin_info = array('COMPUTERS'); } - if ($_SESSION['OCS']['profile']->getConfigValue('ACCOUNTINFO') == 'YES' && !$show_all_column) { + if ($_SESSION['OCS']['profile']->getConfigValue('ACCOUNTINFO') == 'YES' && !isset($show_all_column)) { $show_admin_button = ""; if (isset($_SESSION['OCS']['ADMIN']['ACCOUNTINFO'])) { $show_admin_button .= ""; @@ -230,7 +230,7 @@ array_push($config['SIZE'], 'width=80 height=80'); } else { array_push($value_field, $info_account_id[$name_accountinfo]); - if ($admin_accountinfo) { + if (isset($admin_accountinfo)) { array_push($config['COMMENT_AFTER'], $up_png); } else { array_push($config['COMMENT_AFTER'], ""); @@ -270,7 +270,7 @@ if ($_SESSION['OCS']['profile']->getConfigValue('ACCOUNTINFO') == 'YES') { $tab_hidden = array('ADMIN' => '', 'UP' => '', 'DOWN' => ''); } - if ($show_all_column || $admin_accountinfo) { + if (isset($show_all_column) || isset($admin_accountinfo)) { $showbutton = false; } else { $showbutton = true; diff --git a/plugins/computer_detail/cd_bios/cd_bios.php b/plugins/computer_detail/cd_bios/cd_bios.php index b7bb55fc9..50592c572 100755 --- a/plugins/computer_detail/cd_bios/cd_bios.php +++ b/plugins/computer_detail/cd_bios/cd_bios.php @@ -34,16 +34,18 @@ if (!isset($protectedPost['SHOW'])) { $protectedPost['SHOW'] = 'NOSHOW'; } -if ($protectedPost['OTHER_BIS'] != '') { +if (isset($protectedPost['OTHER_BIS'])) { $sql = "INSERT INTO blacklist_serials (SERIAL) value ('%s')"; $arg = array($protectedPost['OTHER_BIS']); mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); } -if ($protectedPost['OTHER'] != '') { +if (isset($protectedPost['OTHER'])) { $sql = "DELETE FROM blacklist_serials WHERE SERIAL='%s'"; $arg = array($protectedPost['OTHER']); mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); } + +$form_name = 'cd_bios'; echo open_form($form_name, '', '', 'form-horizontal'); $list_fields = array($l->g(36) => 'SSN', $l->g(64) => 'SMANUFACTURER', @@ -62,9 +64,9 @@ $resultDetails = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); $item = mysqli_fetch_object($resultDetails); $sql = "select ID from blacklist_serials where SERIAL='%s'"; -$arg = array($item->SSN); +$arg = array($item->SSN) ?? ''; $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); -if ($_SESSION['OCS']['ADMIN_BLACKLIST']['SERIAL'] == 'YES') { +if (isset($_SESSION['OCS']['ADMIN_BLACKLIST']['SERIAL']) && $_SESSION['OCS']['ADMIN_BLACKLIST']['SERIAL'] == 'YES') { if (mysqli_num_rows($result) == 1) { $tab_options['OTHER'][$l->g(36)][$item->SSN] = $item->SSN; $tab_options['OTHER']['IMG'] = 'image/red.png'; @@ -73,7 +75,7 @@ $tab_options['OTHER_BIS']['IMG'] = 'image/green.png'; } } -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del[$l->g(36)] = $l->g(36); diff --git a/plugins/computer_detail/cd_comments/cd_comments.php b/plugins/computer_detail/cd_comments/cd_comments.php index bc3c040be..19f9827d6 100644 --- a/plugins/computer_detail/cd_comments/cd_comments.php +++ b/plugins/computer_detail/cd_comments/cd_comments.php @@ -42,7 +42,7 @@ echo open_form($form_name, '', '', 'form-horizontal'); //delete a list of notes -if ($protectedPost['del_check'] != '') { +if (isset($protectedPost['del_check'])) { $arg_sql = array(); $sql = "update itmgmt_comments set visible=0 where id in "; $sql = mysql2_prepare($sql, $arg_sql, $protectedPost['del_check']); @@ -85,7 +85,7 @@ $tab_options['CACHE'] = 'RESET'; } } -if ($protectedPost['ADD_NOTE']) { +if (isset($protectedPost['ADD_NOTE'])) { unset($tab_name, $tab_typ_champ); $tab_name[1] = $l->g(1126) . ": "; $tab_name[2] = $l->g(1127) . ": "; @@ -105,7 +105,7 @@ $l->g(51) => 'COMMENTS', $l->g(443) => 'ACTION'); -if (!$show_all_column) { +if (!isset($show_all_column)) { // modif management $list_fields['MODIF'] = 'ID'; @@ -119,7 +119,7 @@ $default_fields = $list_fields; ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); -if (!$show_all_column) { +if (!isset($show_all_column)) { echo "

    "; del_selection($form_name); } diff --git a/plugins/computer_detail/cd_configuration/cd_configuration.php b/plugins/computer_detail/cd_configuration/cd_configuration.php index a618a4339..0f24eb536 100644 --- a/plugins/computer_detail/cd_configuration/cd_configuration.php +++ b/plugins/computer_detail/cd_configuration/cd_configuration.php @@ -120,7 +120,7 @@ function url(id) { } else { $returnIP = $l->g(493); } -optperso("IPDISCOVER", $l->g(489), "IPDISCOVER", $optPerso, '', $returnIP); +optperso("IPDISCOVER", $l->g(489), "IPDISCOVER", $optPerso ?? '', '', $returnIP); //FREQUENCY if (isset($optPerso["FREQUENCY"])) { @@ -134,7 +134,7 @@ function url(id) { } else { $returnFrequency = $l->g(497); } -optperso("FREQUENCY", $l->g(494), "FREQUENCY", $optPerso, '', $returnFrequency); +optperso("FREQUENCY", $l->g(494), "FREQUENCY", $optPerso ?? '', '', $returnFrequency); //DOWNLOAD_SWITCH if (isset($optPerso["DOWNLOAD_SWITCH"])) { @@ -152,29 +152,29 @@ function url(id) { $returnDL = $l->g(733); } } -optperso("DOWNLOAD", $l->g(417), "DOWNLOAD", $optPerso, '', $returnDL); +optperso("DOWNLOAD", $l->g(417), "DOWNLOAD", $optPerso ?? '', '', $returnDL); //DOWNLOAD_CYCLE_LATENCY -optperso("DOWNLOAD_CYCLE_LATENCY", $l->g(720), "DOWNLOAD_CYCLE_LATENCY", $optPerso, $optdefault['ivalue']["DOWNLOAD_CYCLE_LATENCY"], $l->g(511)); +optperso("DOWNLOAD_CYCLE_LATENCY", $l->g(720), "DOWNLOAD_CYCLE_LATENCY", $optPerso ?? '', $optdefault['ivalue']["DOWNLOAD_CYCLE_LATENCY"], $l->g(511)); //DOWNLOAD_FRAG_LATENCY -optperso("DOWNLOAD_FRAG_LATENCY", $l->g(721), "DOWNLOAD_FRAG_LATENCY", $optPerso, $optdefault['ivalue']["DOWNLOAD_FRAG_LATENCY"], $l->g(511)); +optperso("DOWNLOAD_FRAG_LATENCY", $l->g(721), "DOWNLOAD_FRAG_LATENCY", $optPerso ?? '', $optdefault['ivalue']["DOWNLOAD_FRAG_LATENCY"], $l->g(511)); //DOWNLOAD_PERIOD_LATENCY -optperso("DOWNLOAD_PERIOD_LATENCY", $l->g(722), "DOWNLOAD_PERIOD_LATENCY", $optPerso, $optdefault['ivalue']["DOWNLOAD_PERIOD_LATENCY"], $l->g(511)); +optperso("DOWNLOAD_PERIOD_LATENCY", $l->g(722), "DOWNLOAD_PERIOD_LATENCY", $optPerso ?? '', $optdefault['ivalue']["DOWNLOAD_PERIOD_LATENCY"], $l->g(511)); //DOWNLOAD_PERIOD_LENGTH -optperso("DOWNLOAD_PERIOD_LENGTH", $l->g(723), "DOWNLOAD_PERIOD_LENGTH", $optPerso, $optdefault['ivalue']["DOWNLOAD_PERIOD_LENGTH"]); +optperso("DOWNLOAD_PERIOD_LENGTH", $l->g(723), "DOWNLOAD_PERIOD_LENGTH", $optPerso ?? '', $optdefault['ivalue']["DOWNLOAD_PERIOD_LENGTH"]); //PROLOG_FREQ -optperso("PROLOG_FREQ", $l->g(724), "PROLOG_FREQ", $optPerso, $optdefault['ivalue']["PROLOG_FREQ"], $l->g(730)); +optperso("PROLOG_FREQ", $l->g(724), "PROLOG_FREQ", $optPerso ?? '', $optdefault['ivalue']["PROLOG_FREQ"], $l->g(730)); //PROLOG_FREQ -optperso("DOWNLOAD_TIMEOUT", $l->g(424), "DOWNLOAD_TIMEOUT", $optPerso, $optdefault['ivalue']["DOWNLOAD_TIMEOUT"], $l->g(496)); +optperso("DOWNLOAD_TIMEOUT", $l->g(424), "DOWNLOAD_TIMEOUT", $optPerso ?? '', $optdefault['ivalue']["DOWNLOAD_TIMEOUT"], $l->g(496)); //DOWNLOAD_SWITCH -optperso("SNMP_SWITCH", $l->g(1197), "SNMP_SWITCH", $optPerso, '', ($optPerso["SNMP_SWITCH"]["IVALUE"] == 1) ? $l->g(733) : $l->g(205)); +optperso("SNMP_SWITCH", $l->g(1197), "SNMP_SWITCH", $optPerso ?? '', '', (isset($optPerso["SNMP_SWITCH"]["IVALUE"]) && $optPerso["SNMP_SWITCH"]["IVALUE"] == 1) ? $l->g(733) : $l->g(205)); //GROUPS $sql_groups = "SELECT static, name, group_id,workgroup diff --git a/plugins/computer_detail/cd_controllers/cd_controllers.php b/plugins/computer_detail/cd_controllers/cd_controllers.php index 11bbbaaa3..d1ce72787 100755 --- a/plugins/computer_detail/cd_controllers/cd_controllers.php +++ b/plugins/computer_detail/cd_controllers/cd_controllers.php @@ -42,7 +42,7 @@ $l->g(80) => 'CAPTION', $l->g(53) => 'DESCRIPTION', $l->g(277) => 'VERSION'); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del[$l->g(66)] = $l->g(66); diff --git a/plugins/computer_detail/cd_cve/cd_cve.php b/plugins/computer_detail/cd_cve/cd_cve.php index 187353822..63365aaf8 100644 --- a/plugins/computer_detail/cd_cve/cd_cve.php +++ b/plugins/computer_detail/cd_cve/cd_cve.php @@ -45,7 +45,7 @@ $l->g(1467) => 'LINK' ); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del[$l->g(8104)] = $l->g(8104); diff --git a/plugins/computer_detail/cd_drives/cd_drives.php b/plugins/computer_detail/cd_drives/cd_drives.php index b760fd9fd..81f9c5e24 100755 --- a/plugins/computer_detail/cd_drives/cd_drives.php +++ b/plugins/computer_detail/cd_drives/cd_drives.php @@ -44,7 +44,7 @@ $l->g(87) . " (MB)" => 'TOTAL', "PERCENT_BAR" => 'CAPACITY'); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del = array('PERCENT_BAR' => 'PERCENT_BAR', $l->g(85) => $l->g(85)); diff --git a/plugins/computer_detail/cd_inputs/cd_inputs.php b/plugins/computer_detail/cd_inputs/cd_inputs.php index 8bda9968a..158675d89 100755 --- a/plugins/computer_detail/cd_inputs/cd_inputs.php +++ b/plugins/computer_detail/cd_inputs/cd_inputs.php @@ -41,7 +41,7 @@ $l->g(53) => 'DESCRIPTION', $l->g(84) => 'INTERFACE'); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del = array($l->g(66) => $l->g(66), $l->g(84) => $l->g(84)); diff --git a/plugins/computer_detail/cd_memories/cd_memories.php b/plugins/computer_detail/cd_memories/cd_memories.php index 932f6c393..549d53e3a 100755 --- a/plugins/computer_detail/cd_memories/cd_memories.php +++ b/plugins/computer_detail/cd_memories/cd_memories.php @@ -44,7 +44,7 @@ $l->g(94) => 'NUMSLOTS', $l->g(36) => 'SERIALNUMBER'); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del = array($l->g(80) => $l->g(80), $l->g(83) => $l->g(83)); diff --git a/plugins/computer_detail/cd_modems/cd_modems.php b/plugins/computer_detail/cd_modems/cd_modems.php index 8277f7714..66550fbef 100755 --- a/plugins/computer_detail/cd_modems/cd_modems.php +++ b/plugins/computer_detail/cd_modems/cd_modems.php @@ -40,7 +40,7 @@ $l->g(65) => 'MODEL', $l->g(53) => 'DESCRIPTION', $l->g(66) => 'TYPE'); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del = array($l->g(49) => $l->g(49), $l->g(66) => $l->g(66)); diff --git a/plugins/computer_detail/cd_monitors/cd_monitors.php b/plugins/computer_detail/cd_monitors/cd_monitors.php index c73610314..460b0e437 100755 --- a/plugins/computer_detail/cd_monitors/cd_monitors.php +++ b/plugins/computer_detail/cd_monitors/cd_monitors.php @@ -40,7 +40,7 @@ $l->g(360) => 'DESCRIPTION', $l->g(66) => 'TYPE', $l->g(36) => 'SERIAL'); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del = array($l->g(64) => $l->g(64), $l->g(36) => $l->g(36)); diff --git a/plugins/computer_detail/cd_networks/cd_networks.php b/plugins/computer_detail/cd_networks/cd_networks.php index 76ab2bb5f..0a1e03d5a 100755 --- a/plugins/computer_detail/cd_networks/cd_networks.php +++ b/plugins/computer_detail/cd_networks/cd_networks.php @@ -31,7 +31,7 @@ $protectedPost['SHOW'] = 'NOSHOW'; } $tab_options = $protectedPost; -if ($protectedPost['OTHER_BIS'] != '') { +if (isset($protectedPost['OTHER_BIS'])) { //verify @mac if (preg_match('/([0-9A-F]{2}:){5}[0-9A-F]{2}$/i', $protectedPost['OTHER_BIS'])) { $sql = "INSERT INTO blacklist_macaddresses (macaddress) value ('%s')"; @@ -40,7 +40,7 @@ $tab_options['CACHE'] = 'RESET'; } } -if ($protectedPost['OTHER'] != '') { +if (isset($protectedPost['OTHER'])) { //verify @mac if (preg_match('/([0-9A-F]{2}:){5}[0-9A-F]{2}$/i', $protectedPost['OTHER'])) { $sql = "DELETE FROM blacklist_macaddresses WHERE macaddress='%s'"; @@ -65,7 +65,7 @@ $l->g(207) => 'IPGATEWAY', $l->g(331) => 'IPSUBNET', $l->g(281) => 'IPDHCP'); -if ($_SESSION['OCS']['ADMIN_BLACKLIST']['MACADD'] == "YES") { +if (isset($_SESSION['OCS']['ADMIN_BLACKLIST']['MACADD']) && $_SESSION['OCS']['ADMIN_BLACKLIST']['MACADD'] == "YES") { $sql = "select MACADDR from networks WHERE (hardware_id=%s)"; $arg = $systemid; $resultDetails = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); @@ -82,7 +82,7 @@ } } } -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del[$l->g(34)] = $l->g(34); diff --git a/plugins/computer_detail/cd_saas/cd_saas.php b/plugins/computer_detail/cd_saas/cd_saas.php index 3011645bc..017eec0a8 100644 --- a/plugins/computer_detail/cd_saas/cd_saas.php +++ b/plugins/computer_detail/cd_saas/cd_saas.php @@ -43,7 +43,7 @@ $l->g(8106) => 's.TTL', ); - if ($show_all_column) { + if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del[$l->g(8104)] = $l->g(8104); diff --git a/plugins/computer_detail/cd_softwares/cd_softwares.php b/plugins/computer_detail/cd_softwares/cd_softwares.php index bbb0d553a..b5bd0342f 100755 --- a/plugins/computer_detail/cd_softwares/cd_softwares.php +++ b/plugins/computer_detail/cd_softwares/cd_softwares.php @@ -96,7 +96,7 @@ $list_fields[$l->g(277)] = 'VERSION'; $list_fields[$l->g(51)] = 'COMMENTS'; -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del = array($l->g(49) => $l->g(49)); diff --git a/plugins/computer_detail/cd_sounds/cd_sounds.php b/plugins/computer_detail/cd_sounds/cd_sounds.php index 0f725e750..961d4c320 100755 --- a/plugins/computer_detail/cd_sounds/cd_sounds.php +++ b/plugins/computer_detail/cd_sounds/cd_sounds.php @@ -38,7 +38,7 @@ $list_fields = array($l->g(49) => 'NAME', $l->g(64) => 'MANUFACTURER', $l->g(53) => 'DESCRIPTION'); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del = array($l->g(49) => $l->g(49)); diff --git a/plugins/computer_detail/cd_storages/cd_storages.php b/plugins/computer_detail/cd_storages/cd_storages.php index 42f0100c5..ee59d1616 100755 --- a/plugins/computer_detail/cd_storages/cd_storages.php +++ b/plugins/computer_detail/cd_storages/cd_storages.php @@ -40,7 +40,7 @@ $l->g(67) . " (MB)" => 'DISKSIZE', $l->g(36) => 'SERIALNUMBER', $l->g(1229) => 'FIRMWARE'); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del = array($l->g(49) => $l->g(49)); diff --git a/plugins/computer_detail/cd_videos/cd_videos.php b/plugins/computer_detail/cd_videos/cd_videos.php index f43aa3aab..4846ae475 100755 --- a/plugins/computer_detail/cd_videos/cd_videos.php +++ b/plugins/computer_detail/cd_videos/cd_videos.php @@ -39,7 +39,7 @@ $l->g(276) => 'CHIPSET', $l->g(26) . " (MB)" => 'MEMORY', $l->g(62) => 'RESOLUTION'); -if ($show_all_column) { +if (isset($show_all_column)) { $list_col_cant_del = $list_fields; } else { $list_col_cant_del = array($l->g(49) => $l->g(49)); From ac8dc000d953e49782f1417466daee6d4f915b8c Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:41:24 +0000 Subject: [PATCH 060/187] php8 fix warnings on ms_teledepoy --- .../main_sections/ms_teledeploy/ms_custom_pack.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/main_sections/ms_teledeploy/ms_custom_pack.php b/plugins/main_sections/ms_teledeploy/ms_custom_pack.php index 3bd3d20f1..a8e236f9b 100644 --- a/plugins/main_sections/ms_teledeploy/ms_custom_pack.php +++ b/plugins/main_sections/ms_teledeploy/ms_custom_pack.php @@ -47,6 +47,7 @@ } } +$name = ''; foreach ($ids as $value) { $protectedPost['systemid'] = $value; $item = info($protectedGet, $protectedPost['systemid']); @@ -85,7 +86,7 @@ } } -if ($protectedPost['MODIF'] != '' && isset($protectedPost['DWL_OPT']) && $protectedPost['DWL_OPT'] == "YES") { +if (!empty($protectedPost['MODIF']) && isset($protectedPost['DWL_OPT']) && $protectedPost['DWL_OPT'] == "YES") { // Show form $tab_hidden['SELECT'] = $protectedPost['MODIF']; $tab_hidden['onglet'] = $protectedPost['onglet']; @@ -117,7 +118,7 @@ $protectedPost['SELECT'] = $protectedPost['MODIF']; $protectedPost['Valid_modif'] = true; } - if ($protectedPost['SELECT'] != '' && isset($protectedPost['Valid_modif'])) { + if (!empty($protectedPost['SELECT']) && isset($protectedPost['Valid_modif'])) { if (isset($protectedPost['TELE_FORCE_'])) { active_option('DOWNLOAD_FORCE', $list_id, $protectedPost['SELECT'], '1'); } @@ -162,11 +163,11 @@ } } - if ($protectedPost['sens_' . $table_name] == "") { + if (empty($protectedPost['sens_' . $table_name])) { $protectedPost['sens_' . $table_name] = 'DESC'; } - if ($protectedPost['onglet'] == "") { + if (empty($protectedPost['onglet'])) { $protectedPost['onglet'] = 'MACH'; } @@ -201,14 +202,14 @@ if ($protectedPost['onglet'] == 'MACH') { $selectValues = array('' => '', 'NO' => $l->g(454), 'YES' => $l->g(455)); - formGroup('select', 'DWL_OPT', $l->g(1292), '', '', $protectedPost['DWL_OPT'], '', $selectValues, $selectValues); + formGroup('select', 'DWL_OPT', $l->g(1292), '', '', $protectedPost['DWL_OPT'] ?? '', '', $selectValues, $selectValues); ?>

    'e.FILEID', 'INFO_LOC' => 'e.INFO_LOC', From d45bed3f726e261c9c4f3d0182cd78733ae1f293 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:42:15 +0000 Subject: [PATCH 061/187] php8 fix warnings on require/extensions/ --- require/extensions/ExtensionHook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/extensions/ExtensionHook.php b/require/extensions/ExtensionHook.php index ecbf1a7df..90600fb28 100644 --- a/require/extensions/ExtensionHook.php +++ b/require/extensions/ExtensionHook.php @@ -157,7 +157,7 @@ private function readHookXml($extLabel){ * @return array : Values */ public function getCdEntryByCategory($catName){ - return $this->computerDetailExtensionsHooks[$catName]; + return $this->computerDetailExtensionsHooks[$catName] ?? ''; } /** From 0dd57dd49eaf8803312ed08fad53072e8a0b4a83 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:42:52 +0000 Subject: [PATCH 062/187] php8 fix warnings on require/snmp/ --- require/snmp/Snmp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/snmp/Snmp.php b/require/snmp/Snmp.php index a1c03a342..7145ff56c 100644 --- a/require/snmp/Snmp.php +++ b/require/snmp/Snmp.php @@ -450,7 +450,7 @@ public function get_mib() { $mib_name[$mib] = $mib; } - return $mib_name; + return $mib_name ?? ''; } public function sort_mib($post) { From eee40d266da483c11eb73a4e58ddd1d8668e97b6 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:43:44 +0000 Subject: [PATCH 063/187] php8 fix warnings on require/softwares/ --- require/softwares/SoftwareCategory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/softwares/SoftwareCategory.php b/require/softwares/SoftwareCategory.php index c807cc8d7..44d2a5c11 100644 --- a/require/softwares/SoftwareCategory.php +++ b/require/softwares/SoftwareCategory.php @@ -146,7 +146,7 @@ public function get_table_html_soft(){ while ($computer = mysqli_fetch_array($result)) { $nb[$value][] = $computer['NAME']; } - if($nb[$value] != null){ + if(isset($nb[$value])){ $nb_computer[$value] = count($nb[$value]); } } From e5411b1e316d51b3dadf07261e5ee77d05a420c5 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:46:28 +0000 Subject: [PATCH 064/187] php8 fix warnings on require/function_config_generale --- require/function_config_generale.php | 81 +++++++++++++++------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/require/function_config_generale.php b/require/function_config_generale.php index d595e95ce..05437b04c 100644 --- a/require/function_config_generale.php +++ b/require/function_config_generale.php @@ -143,7 +143,7 @@ function active(id, sens) { } elseif (isset($data['JAVASCRIPT'])) { echo $data['JAVASCRIPT']; } - if ($data['VALUE'] == $key || isset($data['CHECK'][$key])) { + if ((isset($data['VALUE']) && $data['VALUE'] == $key) || isset($data['CHECK'][$key])) { echo "checked"; } echo ">" . $value; @@ -161,7 +161,7 @@ function active(id, sens) { if (isset($data_hidden['BEGIN']) && $data_hidden['BEGIN'] != '') { echo "" . $data_hidden['BEGIN'] . ""; } - echo ""; + echo ""; if (isset($data_hidden['END']) && $data_hidden['END'] != '') { echo "" . $data_hidden['END'] . ""; @@ -185,9 +185,9 @@ function active(id, sens) { if (isset($data['BEGIN']) || !empty($data['BEGIN'])) { echo "" . $data['BEGIN'] . ""; } - echo ""; + echo ""; - if ($data['END'] != '' || isset($data['END'])) { + if (!empty($data['END']) || isset($data['END'])) { echo "" . $data['END'] . ""; } echo "
    "; @@ -235,7 +235,7 @@ function active(id, sens) { }elseif ($type == 'long_text') { echo "" . ($data['END'] ?? ''); }elseif($type == 'password'){ - echo ""; + echo ""; echo "

    " . $helpInput . "

    "; } else { echo $data['LINKS']; @@ -271,7 +271,7 @@ function verif_champ() { 'CUSTOM_THEME' => array('FIELD_READ' => 'CUSTOME_THEME_edit', 'END' => "", 'FILE' => "", 'TYPE' =>'r')); foreach ($file_exist as $key => $value) { - if (isset($protectedPost[$key]) && ($protectedPost[$key] == 'CUSTOM') || preg_match('/^(\/+\w{0,}){0,}/', $protectedPost[$key]) == true) { + if ((isset($protectedPost[$key])) && (($protectedPost[$key] == 'CUSTOM') || preg_match('/^(\/+\w{0,}){0,}/', $protectedPost[$key]) == true)) { //Try to find a file if ($value['FILE'] != '' ) { if ($protectedPost[$value['FIELD_READ']] != '' and ! @fopen($protectedPost[$value['FIELD_READ']] . $value['END'] . $value['FILE'], $value['TYPE'])) { @@ -287,20 +287,25 @@ function verif_champ() { } $i = 0; - while ($supp1[$i]) { - if (isset($protectedPost[$supp1[$i]]) && $protectedPost[$supp1[$i]] < 1) { - $tab_error[$supp1[$i]] = '1'; - } + if(is_array($supp1[$i])) { + while ($supp1[$i]) { + if (isset($protectedPost[$supp1[$i]]) && $protectedPost[$supp1[$i]] < 1) { + $tab_error[$supp1[$i]] = '1'; + } $i++; + } } + $i = 0; - while ($supp10[$i]) { - if (isset($protectedPost[$supp10[$i]]) && $protectedPost[$supp10[$i]] < 10) { - $tab_error[$supp10[$i]] = '10'; + if(is_array($supp1[$i])) { + while ($supp10[$i]) { + if (isset($protectedPost[$supp10[$i]]) && $protectedPost[$supp10[$i]] < 10) { + $tab_error[$supp10[$i]] = '10'; + } + $i++; } - $i++; } - return $tab_error; + return $tab_error ?? ''; } function fin_tab($disable = '') { @@ -565,7 +570,7 @@ function pageGUI($advance) { ligne('CUSTOM_THEME', $l->g(1420), 'select', array('VALUE' => $values['tvalue']['CUSTOM_THEME'], 'SELECT_VALUE' => $themes)); - ligne('LOCAL_URI_SERVER', $l->g(565), 'radio', array('DEFAULT' => $l->g(823) . " (http://localhost:80/ocsinventory)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_local_uri), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['LOCAL_URI_SERVER'], 'SIZE' => "30%", 'MAXLENGTH' => 254)); + ligne('LOCAL_URI_SERVER', $l->g(565), 'radio', array('DEFAULT' => $l->g(823) . " (http://localhost:80/ocsinventory)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_local_uri), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['LOCAL_URI_SERVER'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254)); $def = VARLIB_DIR . '/download'; ligne('DOWNLOAD_PACK_DIR', $l->g(775), 'radio', array('DEFAULT' => $l->g(823) . " ($def)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_pack), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['DOWNLOAD_PACK_DIR'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/download")); @@ -578,17 +583,17 @@ function pageGUI($advance) { ligne('LOG_DIR', $l->g(825), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_log), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['LOG_DIR'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/logs")); $def = VARLIB_DIR . '/tmp_dir'; - ligne('TMP_DIR', $l->g(9611), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_tmp), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['TMP_DIR'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/tmp_dir")); + ligne('TMP_DIR', $l->g(9611), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_tmp), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['TMP_DIR'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/tmp_dir")); $def = VARLOG_DIR . '/scripts'; ligne('LOG_SCRIPT', $l->g(1254), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_scripts), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['LOG_SCRIPT'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/scripts")); $def = ETC_DIR . '/' . MAIN_SECTIONS_DIR . 'conf/'; - ligne('CONF_PROFILS_DIR', $l->g(1252), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_profils), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['CONF_PROFILS_DIR'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/conf")); + ligne('CONF_PROFILS_DIR', $l->g(1252), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_profils), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['CONF_PROFILS_DIR'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/conf")); $def = ETC_DIR . '/' . MAIN_SECTIONS_DIR . 'old_conf/'; - ligne('OLD_CONF_DIR', $l->g(1253), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_old_profils), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['OLD_CONF_DIR'], 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/old_conf")); - ligne('EXPORT_SEP', $l->g(1213), 'input', array('VALUE' => $values['tvalue']['EXPORT_SEP'], 'SIZE' => "30%", 'MAXLENGTH' => 4)); + ligne('OLD_CONF_DIR', $l->g(1253), 'radio', array('DEFAULT' => $l->g(823) . " (" . $def . ")", 'CUSTOM' => $l->g(822), 'VALUE' => $select_old_profils), array('HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['OLD_CONF_DIR'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 254, 'END' => "/old_conf")); + ligne('EXPORT_SEP', $l->g(1213), 'input', array('VALUE' => $values['tvalue']['EXPORT_SEP'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 4)); ligne('TAB_CACHE', $l->g(1249), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['TAB_CACHE'])); ligne('WARN_UPDATE', $l->g(2117), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['WARN_UPDATE'])); }else{ @@ -664,8 +669,8 @@ function pageteledeploy($advance) { ligne('DOWNLOAD_PERIOD_LENGTH', $l->g(723), 'input', array('VALUE' => $values['ivalue']['DOWNLOAD_PERIOD_LENGTH'], 'SIZE' => 1, 'MAXLENGTH' => 3, 'JAVASCRIPT' => $numeric)); } ligne('DEPLOY', $l->g(414), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['DEPLOY'])); - ligne('DOWNLOAD_URI_FRAG', $l->g(826), 'radio', array('DEFAULT' => $l->g(823) . " (HTTP://localhost/download)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_frag), array('BEGIN' => "http://", 'HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['DOWNLOAD_URI_FRAG'], 'SIZE' => 70, 'MAXLENGTH' => 254)); - ligne('DOWNLOAD_URI_INFO', $l->g(827), 'radio', array('DEFAULT' => $l->g(823) . " (HTTPS://localhost/download)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_info), array('BEGIN' => "https://", 'HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['DOWNLOAD_URI_INFO'], 'SIZE' => 70, 'MAXLENGTH' => 254)); + ligne('DOWNLOAD_URI_FRAG', $l->g(826), 'radio', array('DEFAULT' => $l->g(823) . " (HTTP://localhost/download)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_frag), array('BEGIN' => "http://", 'HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['DOWNLOAD_URI_FRAG'] ?? '', 'SIZE' => 70, 'MAXLENGTH' => 254)); + ligne('DOWNLOAD_URI_INFO', $l->g(827), 'radio', array('DEFAULT' => $l->g(823) . " (HTTPS://localhost/download)", 'CUSTOM' => $l->g(822), 'VALUE' => $select_info), array('BEGIN' => "https://", 'HIDDEN' => 'CUSTOM', 'HIDDEN_VALUE' => $values['tvalue']['DOWNLOAD_URI_INFO'] ?? '', 'SIZE' => 70, 'MAXLENGTH' => 254)); ligne('DOWNLOAD_ACTIVATE_FRAG', $l->g(9203), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['DOWNLOAD_ACTIVATE_FRAG'])); ligne('DOWNLOAD_RATIO_FRAG', $l->g(9204), 'input', array('VALUE' => $values['ivalue']['DOWNLOAD_RATIO_FRAG'], 'END' => 'MB', 'SIZE' => 2, 'MAXLENGTH' => 4, 'JAVASCRIPT' => $numeric), '', '', $sup1); ligne('DOWNLOAD_AUTO_ACTIVATE', $l->g(9205), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['DOWNLOAD_AUTO_ACTIVATE'])); @@ -729,7 +734,7 @@ function pageserveur($advance) { 'CHECK' => $check, )); if($advance){ - ligne('SECURITY_LEVEL', $l->g(739), 'input', array('VALUE' => $values['ivalue']['SECURITY_LEVEL'], 'SIZE' => 1, 'MAXLENGTH' => 3, 'JAVASCRIPT' => $numeric), '', "readonly"); + ligne('SECURITY_LEVEL', $l->g(739), 'input', array('VALUE' => $values['ivalue']['SECURITY_LEVEL'] ?? '', 'SIZE' => 1, 'MAXLENGTH' => 3, 'JAVASCRIPT' => $numeric), '', "readonly"); ligne('LOCK_REUSE_TIME', $l->g(740), 'input', array('END' => $l->g(511), 'VALUE' => $values['ivalue']['LOCK_REUSE_TIME'], 'SIZE' => 1, 'MAXLENGTH' => 3, 'JAVASCRIPT' => $numeric), '', '', $sup1); ligne('SESSION_VALIDITY_TIME', $l->g(777), 'input', array('END' => $l->g(511), 'VALUE' => $values['ivalue']['SESSION_VALIDITY_TIME'], 'SIZE' => 1, 'MAXLENGTH' => 4, 'JAVASCRIPT' => $numeric), '', '', $sup1); } @@ -931,20 +936,20 @@ function pageConnexion() { $default_role[''] = ''; $default_role = array_merge($default_role, $role1); - ligne('CONEX_LDAP_SERVEUR', $l->g(830), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_SERVEUR'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); - ligne('CONEX_ROOT_DN', $l->g(1016) . '
    ' . $l->g(1018), 'input', array('VALUE' => $values['tvalue']['CONEX_ROOT_DN'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); - ligne('CONEX_ROOT_PW', $l->g(1017) . '
    ' . $l->g(1018), 'password', array('VALUE' => $values['tvalue']['CONEX_ROOT_PW'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); - ligne('CONEX_LDAP_PORT', $l->g(831), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_PORT'], 'SIZE' => "30%", 'MAXLENGTH' => 20)); - ligne('CONEX_DN_BASE_LDAP', $l->g(832), 'input', array('VALUE' => $values['tvalue']['CONEX_DN_BASE_LDAP'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); - ligne('CONEX_LOGIN_FIELD', $l->g(833), 'input', array('VALUE' => $values['tvalue']['CONEX_LOGIN_FIELD'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); - ligne('CONEX_LDAP_PROTOCOL_VERSION', $l->g(834), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_PROTOCOL_VERSION'], 'SIZE' => "30%", 'MAXLENGTH' => 5)); - ligne('CONEX_LDAP_CHECK_FIELD1_NAME', $l->g(1111), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD1_NAME'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); - ligne('CONEX_LDAP_CHECK_FIELD1_VALUE', $l->g(1112), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD1_VALUE'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); - ligne('CONEX_LDAP_CHECK_FIELD1_ROLE', $l->g(1113), 'select', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD1_ROLE'], 'SELECT_VALUE' => $role1)); - ligne('CONEX_LDAP_CHECK_FIELD2_NAME', $l->g(1114), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD2_NAME'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); - ligne('CONEX_LDAP_CHECK_FIELD2_VALUE', $l->g(1115), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD2_VALUE'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); - ligne('CONEX_LDAP_CHECK_FIELD2_ROLE', $l->g(1116), 'select', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD2_ROLE'], 'SELECT_VALUE' => $role1)); - ligne('CONEX_LDAP_CHECK_DEFAULT_ROLE', $l->g(1277), 'select', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_DEFAULT_ROLE'], 'SELECT_VALUE' => $default_role)); + ligne('CONEX_LDAP_SERVEUR', $l->g(830), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_SERVEUR'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 200)); + ligne('CONEX_ROOT_DN', $l->g(1016) . '
    ' . $l->g(1018), 'input', array('VALUE' => $values['tvalue']['CONEX_ROOT_DN'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 200)); + ligne('CONEX_ROOT_PW', $l->g(1017) . '
    ' . $l->g(1018), 'password', array('VALUE' => $values['tvalue']['CONEX_ROOT_PW'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 200)); + ligne('CONEX_LDAP_PORT', $l->g(831), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_PORT'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 20)); + ligne('CONEX_DN_BASE_LDAP', $l->g(832), 'input', array('VALUE' => $values['tvalue']['CONEX_DN_BASE_LDAP'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 200)); + ligne('CONEX_LOGIN_FIELD', $l->g(833), 'input', array('VALUE' => $values['tvalue']['CONEX_LOGIN_FIELD'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 200)); + ligne('CONEX_LDAP_PROTOCOL_VERSION', $l->g(834), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_PROTOCOL_VERSION'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 5)); + ligne('CONEX_LDAP_CHECK_FIELD1_NAME', $l->g(1111), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD1_NAME'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 200)); + ligne('CONEX_LDAP_CHECK_FIELD1_VALUE', $l->g(1112), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD1_VALUE'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 200)); + ligne('CONEX_LDAP_CHECK_FIELD1_ROLE', $l->g(1113), 'select', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD1_ROLE'] ?? '', 'SELECT_VALUE' => $role1)); + ligne('CONEX_LDAP_CHECK_FIELD2_NAME', $l->g(1114), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD2_NAME'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 200)); + ligne('CONEX_LDAP_CHECK_FIELD2_VALUE', $l->g(1115), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD2_VALUE'] ?? '', 'SIZE' => "30%", 'MAXLENGTH' => 200)); + ligne('CONEX_LDAP_CHECK_FIELD2_ROLE', $l->g(1116), 'select', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD2_ROLE'] ?? '', 'SELECT_VALUE' => $role1)); + ligne('CONEX_LDAP_CHECK_DEFAULT_ROLE', $l->g(1277), 'select', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_DEFAULT_ROLE'] ?? '', 'SELECT_VALUE' => $default_role)); } @@ -981,7 +986,7 @@ function pageswol() { } ligne('WOL_PORT', $l->g(272) . " (" . $l->g(1320) . ")", 'input', array('VALUE' => $values['tvalue']['WOL_PORT'], 'SIZE' => "30%", 'MAXLENGTH' => "30%", 'JAVASCRIPT' => $numeric_semicolon)); - ligne('WOL_BIOS_PASSWD', 'Bios password', 'radio', array('ON' => 'ON', 'OFF' => 'OFF', 'VALUE' => $wol_passwd), array('HIDDEN' => 'ON', 'HIDDEN_VALUE' => $values['tvalue']['WOL_BIOS_PASSWD'], 'SIZE' => 40, 'MAXLENGTH' => 254), "readonly"); + ligne('WOL_BIOS_PASSWD', 'Bios password', 'radio', array('ON' => 'ON', 'OFF' => 'OFF', 'VALUE' => $wol_passwd), array('HIDDEN' => 'ON', 'HIDDEN_VALUE' => $values['tvalue']['WOL_BIOS_PASSWD'] ?? '', 'SIZE' => 40, 'MAXLENGTH' => 254), "readonly"); } function pagesSecurity(){ From bdb04fe02440bade3113fa3482a211a130771732 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 7 Dec 2021 08:47:23 +0000 Subject: [PATCH 065/187] php8 fix multiple warnings on require/ files --- require/fichierConf.class.php | 4 ++-- require/function_commun.php | 8 +++++--- require/function_console.php | 2 +- require/function_machine.php | 8 ++++---- require/function_table_html.php | 2 +- require/header.php | 6 ++++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/require/fichierConf.class.php b/require/fichierConf.class.php index e78cc1469..e68cf6fd0 100644 --- a/require/fichierConf.class.php +++ b/require/fichierConf.class.php @@ -76,9 +76,9 @@ function addExternalLangFile($path){ function g($i) { global $tab_dont_see; //If word doesn't exist for language, return default english word - if ($this->tableauMots[$i] == null) { + if (empty($this->tableauMots[$i])) { $defword = new language('en_GB'); - $word = $defword->tableauMots[$i]; + $word = $defword->tableauMots[$i] ?? ''; } else { $word = $this->tableauMots[$i]; } diff --git a/require/function_commun.php b/require/function_commun.php index ed47f8c73..005064636 100644 --- a/require/function_commun.php +++ b/require/function_commun.php @@ -480,9 +480,11 @@ function formGroup($inputType, $inputName, $name, $size, $maxlength, $inputValue if($inputType == "select"){ echo ""; } else { if($inputType == "checkbox") { diff --git a/require/function_console.php b/require/function_console.php index 212782bde..67ebe203b 100644 --- a/require/function_console.php +++ b/require/function_console.php @@ -23,7 +23,7 @@ $data_limit = find_limit_values(); require_once('require/function_ipdiscover.php'); -if ($_SESSION['OCS']["TAGS"]) { +if (isset($_SESSION['OCS']["TAGS"])) { $sql_tag = mysql2_prepare('select id from hardware h, accountinfo a where a.hardware_id=h.id and a.tag in ', array(), $_SESSION['OCS']["TAGS"]); $result = mysql2_query_secure($sql_tag['SQL'], $_SESSION['OCS']["readServer"], $sql_tag['ARG']); while ($val = mysqli_fetch_object($result)) { diff --git a/require/function_machine.php b/require/function_machine.php index b1f27a292..13efa3a26 100644 --- a/require/function_machine.php +++ b/require/function_machine.php @@ -95,7 +95,7 @@ function subnet_name($systemid) { $returnVal[] = $valSub->NAME . " (" . $valSub->NETID . ")"; } - return $returnVal; + return $returnVal ?? ''; } function print_item_header($text) { @@ -251,7 +251,7 @@ function checkForComputerPackagesAction(){ } //affect again a packet - if ($protectedPost['Valid_modif']) { + if (isset($protectedPost['Valid_modif'])) { if (trim($protectedPost['MOTIF'])) { if ($protectedPost["ACTION"] == "again") { //delete all info of specific teledeploy @@ -274,11 +274,11 @@ function checkForComputerPackagesAction(){ } } - if ($protectedPost['Reset_modif']) { + if (isset($protectedPost['Reset_modif'])) { unset($protectedGet['affect_again'], $protectedGet['affect_reset']); } - if ($protectedGet['affect_again'] || $protectedGet['affect_reset']) { + if (isset($protectedGet['affect_again']) && ($protectedGet['affect_again']) || (isset($protectedGet['affect_reset']) && $protectedGet['affect_reset'])) { if ($protectedGet['affect_again']) { $id_pack_affect = $protectedGet['affect_again']; $hidden_action = 'again'; diff --git a/require/function_table_html.php b/require/function_table_html.php index ebfa571f3..e89afbf4a 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -1574,7 +1574,7 @@ function ajaxsort(&$tab_options) { // field name is IP format alike if (in_array(mb_strtoupper($cleanname),$tab_iplike)) { $tri .= " INET_ATON(".$cleanname.") ".$v['dir'].", "; - } else if($tab_options['TRI']['DATE'][$cleanname]) { + } else if(isset($tab_options['TRI']['DATE'][$cleanname])) { if(isset($tab_options['ARG_SQL'])) { $tri .= " STR_TO_DATE(%s,'%s') %s"; $tab_options['ARG_SQL'][] = $cleanname; diff --git a/require/header.php b/require/header.php index 514aefaf6..f8f5e1103 100644 --- a/require/header.php +++ b/require/header.php @@ -379,7 +379,9 @@ require_once (HEADER_HTML); } -$url_name = $urls->getUrlName($protectedGet[PAG_INDEX]); +if (isset($protectedGet[PAG_INDEX])) { + $url_name = $urls->getUrlName($protectedGet[PAG_INDEX]); +} //VERIF ACCESS TO THIS PAGE if (isset($protectedGet[PAG_INDEX]) && !$profile->hasPage($url_name) && (!$_SESSION['OCS']['TRUE_PAGES'] || !array_search($url_name, $_SESSION['OCS']['TRUE_PAGES'])) @@ -396,7 +398,7 @@ die(); } -if ($url_name) { +if (isset($url_name)) { //CSRF security if ($_SERVER['REQUEST_METHOD'] == 'POST') { $csrf = true; From 0aff7be27a9ddf9be879d5e3c3103ac2cbcdb7a5 Mon Sep 17 00:00:00 2001 From: RudyLaurent Date: Fri, 24 Dec 2021 14:39:09 +0100 Subject: [PATCH 066/187] php8 fix warning login page --- backend/AUTH/auth.php | 6 +++--- require/function_files.php | 2 +- require/html_header.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/AUTH/auth.php b/backend/AUTH/auth.php index baefd0397..241d11984 100755 --- a/backend/AUTH/auth.php +++ b/backend/AUTH/auth.php @@ -94,7 +94,7 @@ } // login ok? -if ($login_successful == "OK" && isset($login_successful) && !$limitAttempt) { +if (isset($login_successful) && $login_successful == "OK" && !$limitAttempt) { $_SESSION['OCS']["loggeduser"] = $login; $_SESSION['OCS']['cnx_origine'] = $cnx_origine; $_SESSION['OCS']['user_group'] = $user_group; @@ -206,11 +206,11 @@
    - ' placeholder="g(243); ?>"> + ' placeholder="g(243); ?>">
    - ' placeholder="g(217); ?>"> + ' placeholder="g(217); ?>">
    diff --git a/require/function_files.php b/require/function_files.php index ff162d865..a75b6c868 100755 --- a/require/function_files.php +++ b/require/function_files.php @@ -101,7 +101,7 @@ function read_configuration($ms_cfg_file, $search, $id_field = '') { } } } - if ($line[0] == "<") { //Getting tag type for the next launch of the loop + if (substr($line, 0, 1) == "<") { //Getting tag type for the next launch of the loop $capture = 'OK_' . substr(substr($line, 1), 0, -1); } } diff --git a/require/html_header.php b/require/html_header.php index ab5ca9792..b951cb98b 100644 --- a/require/html_header.php +++ b/require/html_header.php @@ -60,7 +60,7 @@
    "; } elseif ($protectedPost['onglet'] == "ARCHIVE") { From 1d9fea261683724d87fe562e04e1ca5e8382f6f5 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 17 May 2022 13:16:15 +0000 Subject: [PATCH 119/187] fix warnings on package manual activation --- plugins/main_sections/ms_teledeploy/ms_tele_activate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/main_sections/ms_teledeploy/ms_tele_activate.php b/plugins/main_sections/ms_teledeploy/ms_tele_activate.php index 8b197e10d..09e11f97a 100644 --- a/plugins/main_sections/ms_teledeploy/ms_tele_activate.php +++ b/plugins/main_sections/ms_teledeploy/ms_tele_activate.php @@ -90,7 +90,7 @@ $fragOk = true; } - if ($fragAvail) { + if (isset($fragOk) && !is_bool($fragAvail)) { fclose($fragOk); } } From 24637a1ac123d3fe0eaf6d55299c18d7636a095b Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 07:21:46 +0000 Subject: [PATCH 120/187] fix warnings on config > interface update --- require/function_config_generale.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/function_config_generale.php b/require/function_config_generale.php index be547fe60..09d242626 100644 --- a/require/function_config_generale.php +++ b/require/function_config_generale.php @@ -278,7 +278,7 @@ function verif_champ() { $tab_error[$key] = array('FILE_NOT_EXIST' => $protectedPost[$value['FIELD_READ']] . $value['END'] . $value['FILE']); } //Try to find a directory - } elseif (!is_dir($protectedPost[$value['FIELD_READ']] . $value['END'])) { + } elseif (isset($protectedPost[$value['FIELD_READ']]) && !is_dir($protectedPost[$value['FIELD_READ']] . $value['END'])) { if ($protectedPost[$value['FIELD_READ']] != '') { $tab_error[$key] = array('FILE_NOT_EXIST' => $protectedPost[$value['FIELD_READ']] . $value['END']); } From 89e479b4f695524a3a0b8979bf18aa2f0b167f35 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 07:28:20 +0000 Subject: [PATCH 121/187] fix warnings on notifiations custom template --- require/assets/AssetsCategory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/assets/AssetsCategory.php b/require/assets/AssetsCategory.php index 7a4f890ed..dae13feea 100644 --- a/require/assets/AssetsCategory.php +++ b/require/assets/AssetsCategory.php @@ -45,7 +45,7 @@ public function get_assets(){ } public function get_computer_assets($list_asset){ - $nb_computer = 0; + $nb_computer = array(); foreach($list_asset as $values){ $nb = []; $asset = explode(",", $values['SQL_ARGS']); From 3ac74cb9efa34fc23c7242362ee566b868f05ac2 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 08:02:09 +0000 Subject: [PATCH 122/187] fix warnings on admin data from computer details --- plugins/computer_detail/cd_admininfo/cd_admininfo.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/computer_detail/cd_admininfo/cd_admininfo.php b/plugins/computer_detail/cd_admininfo/cd_admininfo.php index 6079f30b2..f6aeb9d55 100644 --- a/plugins/computer_detail/cd_admininfo/cd_admininfo.php +++ b/plugins/computer_detail/cd_admininfo/cd_admininfo.php @@ -42,7 +42,7 @@ $list_tab = find_all_account_tab('TAB_ACCOUNTAG', 'COMPUTERS', 1); if ($list_tab != '') { - if (isset($protectedPost['Valid_modif']) && $protectedPost['NOTE'] == "" && $protectedPost['NOTE_MODIF'] == "") { + if (isset($protectedPost['Valid_modif']) && empty($protectedPost['NOTE']) && empty($protectedPost['NOTE_MODIF'])) { if (!is_defined($protectedPost['onglet']) || !is_numeric($protectedPost['onglet'])) { $protectedPost['onglet'] = $list_tab['FIRST']; } @@ -62,7 +62,7 @@ foreach ($protectedPost as $field => $value) { $temp_field = explode('_', $field); - if (array_key_exists($temp_field[0] . '_' . $temp_field[1], $info_account_id) || $temp_field[0] == 'TAG') { + if ((isset($temp_field[1]) && (array_key_exists($temp_field[0] . '_' . $temp_field[1], $info_account_id))) || $temp_field[0] == 'TAG') { //cas of checkbox if (isset($temp_field[2])) { $data_fields_account[$temp_field[0] . "_" . $temp_field[1]] .= $temp_field[2] . "&&&"; @@ -70,6 +70,7 @@ $data_fields_account[$field] = $value; } } + } updateinfo_computer($systemid, $data_fields_account); //search all admininfo for this computer From 2cb723055cea57b529cddd9b878544efdecd83fb Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 09:04:14 +0000 Subject: [PATCH 123/187] fix warnings adding a note on computer detail --- plugins/computer_detail/cd_comments/cd_comments.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/computer_detail/cd_comments/cd_comments.php b/plugins/computer_detail/cd_comments/cd_comments.php index 19f9827d6..c7b287e78 100644 --- a/plugins/computer_detail/cd_comments/cd_comments.php +++ b/plugins/computer_detail/cd_comments/cd_comments.php @@ -94,9 +94,11 @@ $tab_typ_champ[2]['DEFAULT_VALUE'] = $_SESSION['OCS']["loggeduser"]; $tab_typ_champ[1]['INPUT_TYPE'] = 0; $tab_typ_champ[2]['INPUT_TYPE'] = 13; + $tab_typ_champ[1]['INPUT_NAME'] = 'NOTE'; + $tab_typ_champ[2]['INPUT_NAME'] = 'NOTE'; $tab_typ_champ[3]['INPUT_NAME'] = 'NOTE'; $tab_typ_champ[3]['INPUT_TYPE'] = 1; - modif_values($tab_name, $tab_typ_champ, $tab_hidden); + modif_values($tab_name, $tab_typ_champ, $tab_hidden ?? ''); } $queryDetails = "SELECT ID,DATE_INSERT,USER_INSERT,COMMENTS,ACTION FROM itmgmt_comments WHERE (visible is null or visible =1) and hardware_id=$systemid"; @@ -138,6 +140,8 @@ $tab_typ_champ[3]['DEFAULT_VALUE'] = $item['COMMENTS']; $tab_typ_champ[1]['INPUT_TYPE'] = 0; $tab_typ_champ[2]['INPUT_TYPE'] = 13; + $tab_typ_champ[1]['INPUT_NAME'] = 'NOTE_MODIF'; + $tab_typ_champ[2]['INPUT_NAME'] = 'NOTE_MODIF'; $tab_typ_champ[3]['INPUT_NAME'] = 'NOTE_MODIF'; $tab_typ_champ[3]['INPUT_TYPE'] = 1; $tab_hidden['USER_INSERT'] = $item['USER_INSERT']; From a1d92cf62bb7b89e1d32f23b07b8040df3274739 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 09:22:50 +0000 Subject: [PATCH 124/187] fix warnings when deleting package from computer detail --- require/function_machine.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/require/function_machine.php b/require/function_machine.php index 41dc9d37f..9e5d3b761 100644 --- a/require/function_machine.php +++ b/require/function_machine.php @@ -312,11 +312,11 @@ function checkForComputerPackagesAction(){ if (isset($protectedGet["suppack"]) & $_SESSION['OCS']['profile']->getConfigValue('TELEDIFF') == "YES") { if ($_SESSION['OCS']["justAdded"] == false) { - desactive_packet($systemid, $protectedGet["suppack"]); + desactive_packet($systemid ?? '', $protectedGet["suppack"]); } else { $_SESSION['OCS']["justAdded"] = false; } - addLog($l->g(512), $l->g(886) . " " . $protectedGet["suppack"] . " => " . $systemid); + addLog($l->g(512), $l->g(886) . " " . $protectedGet["suppack"] . " => " . $_GET["systemid"]); } else { $_SESSION['OCS']["justAdded"] = false; } From 9ee868e07d29235466cd27a3ddc5b5bdba0d0f0a Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 09:35:50 +0000 Subject: [PATCH 125/187] fix warnings on Snmp --- require/snmp/Snmp.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/require/snmp/Snmp.php b/require/snmp/Snmp.php index ab66edb75..30c59496e 100644 --- a/require/snmp/Snmp.php +++ b/require/snmp/Snmp.php @@ -530,8 +530,10 @@ public function get_infos($tablename, $columns) { $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); $infos = []; - while($item = mysqli_fetch_array($result)) { - $infos[$item['ID']] = $item; + if (!empty($result)) { + while($item = mysqli_fetch_array($result)) { + $infos[$item['ID']] = $item; + } } return $infos; From 8eb62e79a62e58fe1ee68ae65cfed4bb9e47befa Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 12:32:16 +0000 Subject: [PATCH 126/187] fix warnings on admin data section --- plugins/main_sections/ms_admininfo/ms_admininfo.php | 2 +- require/function_admininfo.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/main_sections/ms_admininfo/ms_admininfo.php b/plugins/main_sections/ms_admininfo/ms_admininfo.php index bdf85a51f..4f1d61c1c 100644 --- a/plugins/main_sections/ms_admininfo/ms_admininfo.php +++ b/plugins/main_sections/ms_admininfo/ms_admininfo.php @@ -210,7 +210,7 @@ $list = $protectedPost['del_check']; $tab_values = explode(',', $list); $i = 0; - while ($tab_values[$i]) { + while (isset($tab_values[$i])) { del_accountinfo($tab_values[$i]); $i++; } diff --git a/require/function_admininfo.php b/require/function_admininfo.php index 4b4e3d792..f3e0befaa 100644 --- a/require/function_admininfo.php +++ b/require/function_admininfo.php @@ -110,9 +110,9 @@ function del_accountinfo($id) { $arg_found_account_type = $id; $result = mysql2_query_secure($sql_found_account_type, $_SESSION['OCS']["readServer"], $arg_found_account_type); $val = mysqli_fetch_array($result); - if ($val['account_type'] == "SNMP") { + if (isset($val['account_type']) && $val['account_type'] == "SNMP") { $table = "snmp_accountinfo"; - } elseif ($val['account_type'] == "COMPUTERS") { + } elseif (isset($val['account_type']) && $val['account_type'] == "COMPUTERS") { $table = "accountinfo"; } else { return false; @@ -158,7 +158,7 @@ function find_all_account_tab($tab_value, $onlyactiv = '', $first = '') { } $array_tab_account[$val_tab_account['IVALUE']] = $val_tab_account['TVALUE']; } - return $array_tab_account; + return $array_tab_account ?? ''; } function find_value_field($name, $type = null) { From 3f103fa4b75a4e1726b38db3324578a63497ccb5 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 13:07:03 +0000 Subject: [PATCH 127/187] fix warnings on soft category --- plugins/main_sections/ms_soft_cat/ms_soft_cat.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/main_sections/ms_soft_cat/ms_soft_cat.php b/plugins/main_sections/ms_soft_cat/ms_soft_cat.php index 02517b621..2b13b6eb6 100644 --- a/plugins/main_sections/ms_soft_cat/ms_soft_cat.php +++ b/plugins/main_sections/ms_soft_cat/ms_soft_cat.php @@ -366,8 +366,8 @@ echo '
    '.$l->g(1509).'

    '; if(isset($protectedPost['advanced'])){ - $version = $softCat->search_version($protectedPost['regular_exp']); - $vendor = $softCat->search_vendor($protectedPost['regular_exp']); + $version = $softCat->search_version($protectedPost['regular_exp'] ?? ''); + $vendor = $softCat->search_vendor($protectedPost['regular_exp'] ?? ''); formGroup('select', 'version_sign', $l->g(1510).' :', '', '',$protectedPost['version_sign'] ?? 0, '', $operatorsArray, $operatorsArray); formGroup('select', 'version_soft', $l->g(1507).' :', '', '', $protectedPost['version_soft'] ?? 0, '', $version, $version); From 1573e261bc33b9c6165821e2ddea0c96f62251c8 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 15:07:14 +0000 Subject: [PATCH 128/187] fix warnings on interface config --- require/function_config_generale.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/require/function_config_generale.php b/require/function_config_generale.php index 09d242626..7b7554d33 100644 --- a/require/function_config_generale.php +++ b/require/function_config_generale.php @@ -678,11 +678,11 @@ function pageGUI($advance) { ligne('TAB_CACHE', $l->g(1249), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['TAB_CACHE'] ?? 0)); ligne('WARN_UPDATE', $l->g(2117), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['WARN_UPDATE'])); }else{ - ligne('EXCLUDE_ARCHIVE_COMPUTER', $l->g(9800), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['EXCLUDE_ARCHIVE_COMPUTER'])); - ligne('ACTIVE_NEWS', $l->g(8026), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['ACTIVE_NEWS'])); + ligne('EXCLUDE_ARCHIVE_COMPUTER', $l->g(9800), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['EXCLUDE_ARCHIVE_COMPUTER'] ?? 0)); + ligne('ACTIVE_NEWS', $l->g(8026), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['ACTIVE_NEWS'] ?? 0)); ligne('CUSTOM_THEME', $l->g(1420), 'select', array('VALUE' => $values['tvalue']['CUSTOM_THEME'], 'SELECT_VALUE' => $themes)); ligne('INTERFACE_LAST_CONTACT', $l->g(484), 'input', array('END' => $l->g(496), 'VALUE' => $values['ivalue']['INTERFACE_LAST_CONTACT'], 'SIZE' => 1, 'MAXLENGTH' => 3, 'JAVASCRIPT' => $numeric), '', '', $sup1); - ligne('LOG_GUI', $l->g(824), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['LOG_GUI'])); + ligne('LOG_GUI', $l->g(824), 'radio', array(1 => 'ON', 0 => 'OFF', 'VALUE' => $values['ivalue']['LOG_GUI'] ?? 0)); } } From 5016ce5980821380ff73a7de8483faac65c8ab4b Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Wed, 18 May 2022 15:08:03 +0000 Subject: [PATCH 129/187] fix warnings when snmp dir not defined --- require/snmp/Snmp.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/require/snmp/Snmp.php b/require/snmp/Snmp.php index 30c59496e..bb2cda82e 100644 --- a/require/snmp/Snmp.php +++ b/require/snmp/Snmp.php @@ -447,15 +447,18 @@ public function get_mib() { $champs = array('SNMP_MIB_DIRECTORY' => 'SNMP_MIB_DIRECTORY'); $values = look_config_default_values($champs); - $mib_files = glob($values['tvalue']['SNMP_MIB_DIRECTORY'].'/*', GLOB_BRACE); - $mib_files = str_replace($values['tvalue']['SNMP_MIB_DIRECTORY']."/", "", $mib_files); + if(isset($values['tvalue']['SNMP_MIB_DIRECTORY'])) { + $mib_files = glob($values['tvalue']['SNMP_MIB_DIRECTORY'].'/*', GLOB_BRACE); + $mib_files = str_replace($values['tvalue']['SNMP_MIB_DIRECTORY']."/", "", $mib_files); - foreach($mib_files as $mib) { - $mib_name[$mib] = $mib; + foreach($mib_files as $mib) { + $mib_name[$mib] = $mib; + } } + return $mib_name ?? ''; } From 3b402be730025bab155c78c262f0a1c87fb98247 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 20 May 2022 07:09:45 +0000 Subject: [PATCH 130/187] fix warnings on plugins tables --- plugins/main_sections/ms_computer/ms_computer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/main_sections/ms_computer/ms_computer.php b/plugins/main_sections/ms_computer/ms_computer.php index 81eaacdad..901dfbb03 100644 --- a/plugins/main_sections/ms_computer/ms_computer.php +++ b/plugins/main_sections/ms_computer/ms_computer.php @@ -135,14 +135,14 @@ } } else if (isset($protectedGet['option'])) { // If specific plugin - $plugin = $plugins[$protectedGet['option']]; + $plugin = $plugins[$protectedGet['option']] ?? ''; if($plugin != null){ $plugin_file = PLUGINS_DIR . "computer_detail/" . $plugin->getId() . "/" . $plugin->getId() . ".php"; }else{ $file_extension = EXT_DL_DIR . $protectedGet['option'] . "/cd_" . $protectedGet['option'] . "/cd_" . $protectedGet['option'] .".php"; } - if (file_exists($plugin_file) || file_exists($file_extension)) { + if (isset($plugin_file) && (file_exists($plugin_file) || file_exists($file_extension))) { if (!AJAX) { if(file_exists($file_extension)){ echo '
    '; From e011806da3039c0c540bc37714212b30602f5ce3 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 20 May 2022 12:35:11 +0000 Subject: [PATCH 131/187] fix warning on auth --- backend/AUTH/auth.php | 2 +- backend/AUTH/methode/ldap.php | 10 +++++----- backend/AUTH/methode/local.php | 4 ++-- backend/identity/methode/cas.php | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/AUTH/auth.php b/backend/AUTH/auth.php index bc16eb7c5..79b9b76cf 100755 --- a/backend/AUTH/auth.php +++ b/backend/AUTH/auth.php @@ -167,7 +167,7 @@ } } else { if ($auth['ivalue']['SECURITY_AUTHENTICATION_BLOCK_IP'] == 1){ - if ($login != ""){ + if (!empty($login)){ $sql = "INSERT INTO auth_attempt (`DATETIMEATTEMPT`,`LOGIN`,`IP`,`SUCCESS`) VALUES ('%s','%s','%s','%s')"; $datetime = new DateTime(); diff --git a/backend/AUTH/methode/ldap.php b/backend/AUTH/methode/ldap.php index ab2fdbe58..eaa90b5fd 100755 --- a/backend/AUTH/methode/ldap.php +++ b/backend/AUTH/methode/ldap.php @@ -107,11 +107,11 @@ function search_on_loginnt($login) { } // save user fields in session - $_SESSION['OCS']['details']['givenname'] = $info[0]['givenname'][0]; - $_SESSION['OCS']['details']['sn'] = $info[0]['sn'][0]; - $_SESSION['OCS']['details']['cn'] = $info[0]['cn'][0]; - $_SESSION['OCS']['details']['mail'] = $info[0]['mail'][0]; - $_SESSION['OCS']['details']['title'] = $info[0]['title'][0]; + $_SESSION['OCS']['details']['givenname'] = $info[0]['givenname'][0] ?? ''; + $_SESSION['OCS']['details']['sn'] = $info[0]['sn'][0] ?? ''; + $_SESSION['OCS']['details']['cn'] = $info[0]['cn'][0] ?? ''; + $_SESSION['OCS']['details']['mail'] = $info[0]['mail'][0] ?? ''; + $_SESSION['OCS']['details']['title'] = $info[0]['title'][0] ?? ''; return $info; } diff --git a/backend/AUTH/methode/local.php b/backend/AUTH/methode/local.php index b281d7b71..7773bfad4 100755 --- a/backend/AUTH/methode/local.php +++ b/backend/AUTH/methode/local.php @@ -28,7 +28,7 @@ $resOp = mysql2_query_secure($reqOp, $_SESSION['OCS']["readServer"], $arg_reqOp); $rowOp = mysqli_fetch_object($resOp); -if ($rowOp->PASSWORD_VERSION === '0') { +if (isset($rowOp->PASSWORD_VERSION) && $rowOp->PASSWORD_VERSION === '0') { $reqOp = "SELECT ID, USER_GROUP FROM operators WHERE ID='%s' and PASSWD ='%s'"; $arg_reqOp = array($login, md5($protectedMdp)); @@ -69,7 +69,7 @@ } } - if ($login_status == true || hash(PASSWORD_CRYPT, $mdp) == $rowOp->PASSWD) { + if ($login_status == true || (isset($rowOp->PASSWD) && hash(PASSWORD_CRYPT, $mdp) == $rowOp->PASSWD)) { $login_successful = "OK"; $user_group = $rowOp->USER_GROUP; $type_log = 'CONNEXION'; diff --git a/backend/identity/methode/cas.php b/backend/identity/methode/cas.php index b7926b705..455b18e2b 100644 --- a/backend/identity/methode/cas.php +++ b/backend/identity/methode/cas.php @@ -64,11 +64,11 @@ $arg_insert = array($_SESSION['OCS']["loggeduser"], 'Default', - $_SESSION['OCS']['details']['sn'], + $_SESSION['OCS']['details']['sn'] ?? '', "", "CAS", $defaultRole, - $_SESSION['OCS']['details']['mail'], + $_SESSION['OCS']['details']['mail'] ?? '', "NULL" ); } else { @@ -78,7 +78,7 @@ WHERE ID='%s'"; $arg_insert = array( - $_SESSION['OCS']['details']['mail'], + $_SESSION['OCS']['details']['mail'] ?? '', $_SESSION['OCS']["loggeduser"]); } connexion_local_write(); From decf26bacd63b3760bca578346abd82589b99f44 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 20 May 2022 12:37:52 +0000 Subject: [PATCH 132/187] fix warnings on connection --- plugins/main_sections/ms_ipdiscover/ms_admin_ipdiscover.php | 3 ++- require/html_header.php | 2 +- update.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/main_sections/ms_ipdiscover/ms_admin_ipdiscover.php b/plugins/main_sections/ms_ipdiscover/ms_admin_ipdiscover.php index 7a3c64928..e14ffd8bf 100644 --- a/plugins/main_sections/ms_ipdiscover/ms_admin_ipdiscover.php +++ b/plugins/main_sections/ms_ipdiscover/ms_admin_ipdiscover.php @@ -133,7 +133,7 @@ if (is_defined($protectedGet['value'])) { $explode = explode(";", $protectedGet['value']); $protectedPost['ADD_IP'] = $explode[0]; - $protectedPost['ADD_TAG'] = $explode[1]; + $protectedPost['ADD_TAG'] = $explode[1] ?? ''; } } else { $title = $l->g(303); @@ -246,6 +246,7 @@ $result_exist = ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); echo ""; + } } diff --git a/require/html_header.php b/require/html_header.php index b70b01cea..ec67377af 100644 --- a/require/html_header.php +++ b/require/html_header.php @@ -89,7 +89,7 @@ echo ""; } } else if (!isset($_SESSION['OCS']['DEBUG'])) { - if (($_SESSION['OCS']['profile'] && $_SESSION['OCS']['profile']->hasPage('ms_debug')) || (is_array($_SESSION['OCS']['TRUE_PAGES']) && array_search('ms_debug', $_SESSION['OCS']['TRUE_PAGES']))) { + if (($_SESSION['OCS']['profile'] && $_SESSION['OCS']['profile']->hasPage('ms_debug')) || (isset($_SESSION['OCS']['TRUE_PAGES']) && is_array($_SESSION['OCS']['TRUE_PAGES']) && array_search('ms_debug', $_SESSION['OCS']['TRUE_PAGES']))) { echo "" . $l->g(1011) . ""; } } diff --git a/update.php b/update.php index c01604d0d..e64c6d131 100644 --- a/update.php +++ b/update.php @@ -90,7 +90,7 @@ //Logout after update(s) //Contrib of FranciX (http://forums.ocsinventory-ng.org/viewtopic.php?pid=41923#p41923) - if ($_SESSION['OCS']['cnx_origine'] == "CAS") { + if (isset($_SESSION['OCS']['cnx_origine']) && $_SESSION['OCS']['cnx_origine'] == "CAS") { $sql_update = 'update'; require(BACKEND . 'AUTH/methode/cas.php'); $config = get_cas_config(); From ac87bcc9ddf0d824138f89f6619b31390f5593e2 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 20 May 2022 12:38:25 +0000 Subject: [PATCH 133/187] fix warnings on multisearch --- require/search/SQLCache.php | 2 +- require/search/Search.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/require/search/SQLCache.php b/require/search/SQLCache.php index 02cc5e7cc..29314a5aa 100644 --- a/require/search/SQLCache.php +++ b/require/search/SQLCache.php @@ -114,7 +114,7 @@ public function generateCacheSql($sessData){ if($p == 0 && isset($operator[$p+1]) && $operator[$p+1] == 'OR'){ $open = "("; - }if($operator[$p] =='OR' && $operator[$p+1] !='OR'){ + }if($operator[$p] =='OR' && (!isset($operator[$p+1]) || $operator[$p+1] !='OR')){ $close=")"; }if($p != 0 && $operator[$p] !='OR' && isset($operator[$p+1]) && $operator[$p+1] =='OR'){ $open = "("; diff --git a/require/search/Search.php b/require/search/Search.php index a3242e9f7..2ee82da0f 100644 --- a/require/search/Search.php +++ b/require/search/Search.php @@ -386,7 +386,7 @@ public function generateSearchQuery($sessData){ if($p == 0 && isset($operator[$p+1]) && $operator[$p+1] == 'OR'){ $open = "("; - }if($operator[$p] =='OR' && $operator[$p+1] !='OR'){ + }if($operator[$p] =='OR' && (!isset($operator[$p+1]) || $operator[$p+1] !='OR')){ $close=")"; }if($p != 0 && $operator[$p] !='OR' && isset($operator[$p+1]) && $operator[$p+1] =='OR'){ $open = "("; From 0d2b3ca3de5e785404f8b6c8bb7614a544f4577b Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 20 May 2022 12:48:40 +0000 Subject: [PATCH 134/187] fix plugin's display --- plugins/main_sections/ms_computer/ms_computer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/main_sections/ms_computer/ms_computer.php b/plugins/main_sections/ms_computer/ms_computer.php index 901dfbb03..864a81d8b 100644 --- a/plugins/main_sections/ms_computer/ms_computer.php +++ b/plugins/main_sections/ms_computer/ms_computer.php @@ -142,7 +142,7 @@ $file_extension = EXT_DL_DIR . $protectedGet['option'] . "/cd_" . $protectedGet['option'] . "/cd_" . $protectedGet['option'] .".php"; } - if (isset($plugin_file) && (file_exists($plugin_file) || file_exists($file_extension))) { + if ((isset($plugin_file) && (file_exists($plugin_file)) || file_exists($file_extension))) { if (!AJAX) { if(file_exists($file_extension)){ echo '
    '; From 421f62f6b63043283224f48de15b8df126df7d13 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 24 May 2022 09:16:48 +0000 Subject: [PATCH 135/187] fix warnings on plugin management --- backend/AUTH/methode/local.php | 1 - .../main_sections/ms_extensionmanager/ms_extensionmanager.php | 2 +- require/header.php | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/AUTH/methode/local.php b/backend/AUTH/methode/local.php index 7773bfad4..9b49edb26 100755 --- a/backend/AUTH/methode/local.php +++ b/backend/AUTH/methode/local.php @@ -62,7 +62,6 @@ if(password_verify($mdp, $rowOp->PASSWD)) { require_once('require/function_users.php'); $update = updatePasswordMd5toHash($login, $mdp); - error_log(print_r($update, true)); if($update) { $login_status = true; } diff --git a/plugins/main_sections/ms_extensionmanager/ms_extensionmanager.php b/plugins/main_sections/ms_extensionmanager/ms_extensionmanager.php index a0cc88982..47b859767 100755 --- a/plugins/main_sections/ms_extensionmanager/ms_extensionmanager.php +++ b/plugins/main_sections/ms_extensionmanager/ms_extensionmanager.php @@ -41,7 +41,7 @@ $extMgr = new ExtensionManager(); if($extMgr->checkPrerequisites()){ $extMgr->checkInstallableExtensions(); - + $extensions_errors = ''; if (!empty($extMgr->installableExtensions_errors)) { $extensions_errors .= '
      '; foreach($extMgr->installableExtensions_errors as $error_msg) { diff --git a/require/header.php b/require/header.php index 60422742e..ea286b8ba 100644 --- a/require/header.php +++ b/require/header.php @@ -383,7 +383,7 @@ } //VERIF ACCESS TO THIS PAGE -if (isset($protectedGet[PAG_INDEX]) && !$profile->hasPage($url_name) && (!$_SESSION['OCS']['TRUE_PAGES'] || !array_search($url_name, $_SESSION['OCS']['TRUE_PAGES'])) +if (isset($protectedGet[PAG_INDEX]) && !$profile->hasPage($url_name) && (!isset($_SESSION['OCS']['TRUE_PAGES']) || !array_search($url_name, $_SESSION['OCS']['TRUE_PAGES'])) //force access to profils witch have CONFIGURATION TELEDIFF == 'YES' for ms_admin_ipdiscover page && !($profile->getConfigValue('TELEDIFF') == 'YES' && $url_name == 'ms_admin_ipdiscover')) { msg_error("ACCESS DENIED"); From 268926ffd701fa24ed22704b904eebbad75a8ade Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 24 May 2022 12:55:59 +0000 Subject: [PATCH 136/187] fix warnings on saas --- require/search/Search.php | 2 +- require/search/TranslationSearch.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/require/search/Search.php b/require/search/Search.php index 2ee82da0f..c15ffa57f 100644 --- a/require/search/Search.php +++ b/require/search/Search.php @@ -1084,7 +1084,7 @@ public function link_multi($fields, $value, $option = ""){ break; case 'saas': - if(!array_key_exists('saas',$_SESSION['OCS']['multi_search']['saas'])){ + if(!isset($_SESSION['OCS']['multi_search']['saas']) || !array_key_exists('saas',$_SESSION['OCS']['multi_search']['saas'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['saas']['saas'] = [ 'fields' => 'ENTRY', diff --git a/require/search/TranslationSearch.php b/require/search/TranslationSearch.php index f86837944..cf026f1bd 100644 --- a/require/search/TranslationSearch.php +++ b/require/search/TranslationSearch.php @@ -264,8 +264,8 @@ public function getTranslationForListField($string){ global $l; $values = explode(".", $string); - - if(!empty($l->g($this->translationArray[$values[0]]))){ + + if(isset($this->translationArray[$values[0]]) && !empty($l->g($this->translationArray[$values[0]]))){ $table = $l->g($this->translationArray[$values[0]]); }else{ $table = $values[0]; From c0976d1a6dedebc54ecff28c79c33c14159d1738 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 24 May 2022 12:57:07 +0000 Subject: [PATCH 137/187] fix error on logging if log file not writable --- require/function_commun.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/require/function_commun.php b/require/function_commun.php index d8acc6b0b..17d001f68 100644 --- a/require/function_commun.php +++ b/require/function_commun.php @@ -222,14 +222,16 @@ function addLog($type, $value = "", $lbl_sql = '') { if (isset($_SESSION['OCS']['LOG_GUI']) && $_SESSION['OCS']['LOG_GUI'] == 1) { //if (is_writable(LOG_FILE)) { $logHandler = fopen(LOG_FILE, "a"); - $dte = getDate(); - $date = sprintf("%02d/%02d/%04d %02d:%02d:%02d", $dte["mday"], $dte["mon"], $dte["year"], $dte["hours"], $dte["minutes"], $dte["seconds"]); - if ($lbl_sql != '') { - $value = $lbl_sql . ' => ' . $value; + if(!empty($logHandler)) { + $dte = getDate(); + $date = sprintf("%02d/%02d/%04d %02d:%02d:%02d", $dte["mday"], $dte["mon"], $dte["year"], $dte["hours"], $dte["minutes"], $dte["seconds"]); + if ($lbl_sql != '') { + $value = $lbl_sql . ' => ' . $value; + } + $towite = $_SESSION['OCS']["loggeduser"] ?? '' . ";" . $date . ";" . DB_NAME . ";" . $type . ";" . $value . ";" . $_SERVER['REMOTE_ADDR'] . ";\n"; + fwrite($logHandler, $towite); + fclose($logHandler); } - $towite = $_SESSION['OCS']["loggeduser"] ?? '' . ";" . $date . ";" . DB_NAME . ";" . $type . ";" . $value . ";" . $_SERVER['REMOTE_ADDR'] . ";\n"; - fwrite($logHandler, $towite); - fclose($logHandler); //} } } From 3fcc5d32ad1b5ee309cd1c3e37b89fe1476725fb Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 24 May 2022 13:36:48 +0000 Subject: [PATCH 138/187] fix wrong log format --- require/function_commun.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/require/function_commun.php b/require/function_commun.php index 17d001f68..654b9e6eb 100644 --- a/require/function_commun.php +++ b/require/function_commun.php @@ -228,10 +228,11 @@ function addLog($type, $value = "", $lbl_sql = '') { if ($lbl_sql != '') { $value = $lbl_sql . ' => ' . $value; } - $towite = $_SESSION['OCS']["loggeduser"] ?? '' . ";" . $date . ";" . DB_NAME . ";" . $type . ";" . $value . ";" . $_SERVER['REMOTE_ADDR'] . ";\n"; + $towite = ($_SESSION['OCS']["loggeduser"] ?? ' '). ";" . $date . ";" . DB_NAME . ";" . $type . ";" . $value . ";" . $_SERVER['REMOTE_ADDR'] . ";\n"; fwrite($logHandler, $towite); fclose($logHandler); } + //} } } From d03c9c40c981c6465541f7dccd3feb67d37192de Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 24 May 2022 14:48:54 +0000 Subject: [PATCH 139/187] fix warnings on dashboard --- plugins/main_sections/ms_multi_search/ms_multi_search.php | 4 ++-- require/search/SQLCache.php | 2 +- require/search/Search.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/main_sections/ms_multi_search/ms_multi_search.php b/plugins/main_sections/ms_multi_search/ms_multi_search.php index eff6a270e..18725cdeb 100644 --- a/plugins/main_sections/ms_multi_search/ms_multi_search.php +++ b/plugins/main_sections/ms_multi_search/ms_multi_search.php @@ -143,7 +143,7 @@ } if(isset($protectedGet['fields'])){ - $search->link_index($protectedGet['fields'], $protectedGet['comp'], $protectedGet['values'], $protectedGet['values2']); + $search->link_index($protectedGet['fields'], $protectedGet['values'], $protectedGet['comp'], $protectedGet['values2']); } if(isset($protectedGet['prov'])){ @@ -267,7 +267,7 @@ foreach ($_SESSION['OCS']['multi_search'] as $key => $value) { foreach ($value as $k => $v) { - if (is_null($v['value']) && $v['operator'] != "ISNULL") { + if (isset($v['value']) && (is_null($v['value'])) && $v['operator'] != "ISNULL") { $isValid = false; } } diff --git a/require/search/SQLCache.php b/require/search/SQLCache.php index 29314a5aa..f2a82a8fc 100644 --- a/require/search/SQLCache.php +++ b/require/search/SQLCache.php @@ -148,7 +148,7 @@ public function generateCacheSql($sessData){ $argFields = $value[Search::SESS_FIELDS]; $argOperators = $value[Search::SESS_OPERATOR]; - $argValues = $value[Search::SESS_VALUES]; + $argValues = $value[Search::SESS_VALUES] ?? ''; if(!empty($isSameColumn) && $isSameColumn[$nameTable] == $value[Search::SESS_FIELDS] && !array_key_exists("ignore", $value) && !array_key_exists('devices', $isSameColumn)){ diff --git a/require/search/Search.php b/require/search/Search.php index c15ffa57f..449941921 100644 --- a/require/search/Search.php +++ b/require/search/Search.php @@ -847,7 +847,7 @@ public function returnFieldHtml($uniqid, $fieldsInfos, $tableName, $field = null break; case self::DB_INT: - $html = ''; + $html = ''; break; case self::DB_DATETIME: @@ -1142,7 +1142,7 @@ public function link_index($fields, $value, $comp = "", $value2 = null){ 'EXCLUDE_ARCHIVE_COMPUTER' => 'EXCLUDE_ARCHIVE_COMPUTER' ]; - $configValues = look_config_default_values($configToLookOut)['ivalue']['EXCLUDE_ARCHIVE_COMPUTER']; + $configValues = look_config_default_values($configToLookOut)['ivalue']['EXCLUDE_ARCHIVE_COMPUTER'] ?? ''; if(empty($field[2])){ if(str_contains($field[0], 'HARDWARE')){ From 6813caae1ab3daa0b3878fe9e6f52ea4c5fa2ef5 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 24 May 2022 15:47:34 +0000 Subject: [PATCH 140/187] fix warnings on multisearch --- require/search/Search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/search/Search.php b/require/search/Search.php index 449941921..33a24050d 100644 --- a/require/search/Search.php +++ b/require/search/Search.php @@ -861,7 +861,7 @@ public function returnFieldHtml($uniqid, $fieldsInfos, $tableName, $field = null case self::HTML_SELECT: $html = ''.$l->g(488).'
      '.$l->g(8012).' -


      '; +


      '; msg_warning($l->g(8016)); echo '
      '; @@ -198,7 +198,7 @@ if(!$output){ $output = $l->g(8020); } - echo "
      "; + echo "
      "; echo "
      "; echo $output; From 37d073aad7ecaefe685d648fd8db060e5b1ebbfe Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 15 Jun 2022 09:54:24 +0000 Subject: [PATCH 145/187] Test if file exists before unlink --- plugins/main_sections/ms_users/lib/profile_functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/main_sections/ms_users/lib/profile_functions.php b/plugins/main_sections/ms_users/lib/profile_functions.php index 1a9f94a80..709a744d5 100644 --- a/plugins/main_sections/ms_users/lib/profile_functions.php +++ b/plugins/main_sections/ms_users/lib/profile_functions.php @@ -108,7 +108,9 @@ function remove_profile($profile_id) { if (!is_writable(PROFILES_DIR)) { msg_error($l->g(2116)); } else { - unlink(PROFILES_DIR . $profile_id . '.xml'); + if(file_exists(PROFILES_DIR . $profile_id . '.xml')) { + unlink(PROFILES_DIR . $profile_id . '.xml'); + } } } From e361fb534a3164ed1f86ed9c04641d84878d2f2f Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 15 Jun 2022 12:37:01 +0000 Subject: [PATCH 146/187] Fix fatal error import admin data from CSV --- plugins/main_sections/ms_admininfo/ms_admininfo.php | 10 +++++++--- require/CSV.class.php | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/main_sections/ms_admininfo/ms_admininfo.php b/plugins/main_sections/ms_admininfo/ms_admininfo.php index 4f1d61c1c..dd0318f4e 100644 --- a/plugins/main_sections/ms_admininfo/ms_admininfo.php +++ b/plugins/main_sections/ms_admininfo/ms_admininfo.php @@ -414,7 +414,7 @@ msg_info($l->g(9608)); msg_success($l->g(9607)); // display form for CSV field selection - formGroup('select', 'csv_field', $l->g(9600), '', '', $protectedPost['csv_field'], '', $protectedPost['csv_header'], $protectedPost['csv_header']); + formGroup('select', 'csv_field', $l->g(9600), '', '', ($protectedPost['csv_field'] ?? 0), '', $protectedPost['csv_header'], $protectedPost['csv_header']); echo "



      "; echo ""; // close file @@ -478,7 +478,11 @@ $req = "SELECT ID, NAME from accountinfo_config WHERE account_type = 'computers'"; $ocs_fields = mysql2_query_secure($req, $_SESSION['OCS']["readServer"]); $ocs_fields = mysqli_fetch_all($ocs_fields, MYSQLI_ASSOC); - array_unshift($ocs_fields, "----"); + $emptyfields = [ + 'ID' => 0, + 'NAME' => "----" + ]; + array_unshift($ocs_fields, $emptyfields); echo '
      '; msg_info($l->g(9610)); @@ -496,7 +500,7 @@ echo ' '.$column.''; echo ' "; From 5f6090d854adbb5aa9cd78beadaf4b6fcb832970 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 15 Jun 2022 13:56:00 +0000 Subject: [PATCH 149/187] Fix undef --- plugins/main_sections/ms_multi_search/ms_custom_tag.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/main_sections/ms_multi_search/ms_custom_tag.php b/plugins/main_sections/ms_multi_search/ms_custom_tag.php index e343b794c..d2b1a9ea5 100644 --- a/plugins/main_sections/ms_multi_search/ms_custom_tag.php +++ b/plugins/main_sections/ms_multi_search/ms_custom_tag.php @@ -201,6 +201,7 @@ from download_available d_a, download_enable d_e where d_e.FILEID=d_a.FILEID group by d_a.NAME order by 1 desc"; $resultDetails = mysql2_query_secure($queryDetails, $_SESSION['OCS']["readServer"]); + $List = []; while ($val = mysqli_fetch_array($resultDetails)) { $List[$val["fileid"]] = $val["name"]; } From 9f9506f2cf1161d9ccd64b39e744d40469de098c Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 15 Jun 2022 14:03:30 +0000 Subject: [PATCH 150/187] Fix illagal offset --- require/function_table_html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/require/function_table_html.php b/require/function_table_html.php index 5b26cfe37..23d019bae 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -890,9 +890,9 @@ function tab_modif_values($field_labels, $fields, $hidden_fields, $options = arr function show_field($name_field,$type_field,$value_field,$config=array()){ global $protectedPost; foreach($name_field as $key=>$value){ - $tab_typ_champ[$key]['DEFAULT_VALUE']=$value_field[$key]; - $tab_typ_champ[$key]['INPUT_NAME']=$name_field[$key]; - $tab_typ_champ[$key]['INPUT_TYPE']=$type_field[$key]; + $tab_typ_champ[$key]['DEFAULT_VALUE']=$value_field[$key] ?? ""; + $tab_typ_champ[$key]['INPUT_NAME']=$name_field[$key] ?? ""; + $tab_typ_champ[$key]['INPUT_TYPE']=$type_field[$key] ?? ""; if (!isset($config['ROWS'][$key]) or $config['ROWS'][$key] == '') From 020a6f6a2b26791887ad506c95e64e8c2879d017 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Fri, 17 Jun 2022 13:40:29 +0000 Subject: [PATCH 151/187] Fix warning in ipdiscover --- plugins/main_sections/ms_ipdiscover/ms_custom_info.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/main_sections/ms_ipdiscover/ms_custom_info.php b/plugins/main_sections/ms_ipdiscover/ms_custom_info.php index 39a422f10..5b3723c49 100644 --- a/plugins/main_sections/ms_ipdiscover/ms_custom_info.php +++ b/plugins/main_sections/ms_ipdiscover/ms_custom_info.php @@ -29,7 +29,7 @@ require_once('require/function_ipdiscover.php'); -if (!isset($protectedPost['MODIF'])) { +if (!isset($protectedPost['MODIF']) || (isset($protectedPost['MODIF']) && $protectedPost['MODIF'] == "")) { echo "".$l->g(188)."

      "; } @@ -134,9 +134,8 @@ } //si on est dans le cas d'une modif, on affiche le login qui a saisi la donnée - if ($protectedPost['MODIF_ID'] != '') { + if (isset($protectedPost['MODIF_ID']) && $protectedPost['MODIF_ID'] != '') { $tab_name[3] = $l->g(944) . ": "; - $title = $l->g(945); } else { $title = $l->g(946); @@ -151,7 +150,7 @@ $tab_name = array($l->g(944), $l->g(95), $l->g(53), $l->g(66)); $name_field = array('USER', 'MAC', 'COMMENT', 'TYPE'); $type_field = array(13, 13, 0, 2); - $value_field = array($protectedPost['USER'], $protectedPost['MODIF'], $protectedPost['COMMENT'], $list_type); + $value_field = array($protectedPost['USER'] ?? '', $protectedPost['MODIF'] ?? '', $protectedPost['COMMENT'] ?? '', $list_type ?? []); $tab_typ_champ = show_field($name_field, $type_field, $value_field); $tab_hidden['mac'] = $protectedPost['MODIF']; @@ -161,7 +160,7 @@ foreach ($tab_typ_champ as $id => $values) { if($tab_typ_champ[$id]["INPUT_TYPE"] == 2) { - $tab_typ_champ[$id]['CONFIG']['SELECTED_VALUE'] = $protectedPost[$tab_typ_champ[$id]['INPUT_NAME']]; + $tab_typ_champ[$id]['CONFIG']['SELECTED_VALUE'] = $protectedPost[$tab_typ_champ[$id]['INPUT_NAME']] ?? 0; } } From c31291cd1862178c55838af06701a225658b7c9b Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Mon, 20 Jun 2022 08:31:25 +0000 Subject: [PATCH 152/187] Fix comparator display --- .../ms_multi_search/ms_multi_search.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/main_sections/ms_multi_search/ms_multi_search.php b/plugins/main_sections/ms_multi_search/ms_multi_search.php index 18725cdeb..8e9645e41 100644 --- a/plugins/main_sections/ms_multi_search/ms_multi_search.php +++ b/plugins/main_sections/ms_multi_search/ms_multi_search.php @@ -181,20 +181,21 @@ } foreach ($_SESSION['OCS']['multi_search'] as $table => $infos) { - $i = 0; + $i = 0; foreach ($infos as $uniqid => $values) { ?>
      - returnFieldHtmlAndOr($uniqid, $values, $infos, $table, $values['comparator']); - if($htmlComparator != ""){ - echo "
      -
      - ".$htmlComparator." -
      -



      "; - } - } ?> + returnFieldHtmlAndOr($uniqid, $values, $infos, $table, $values['comparator']); + if($htmlComparator != ""){ + echo "
      +
      + ".$htmlComparator." +
      +



      "; + } + } ?>
      Date: Mon, 20 Jun 2022 09:09:55 +0000 Subject: [PATCH 153/187] Fix warning on undefined array key for deploy linux plugin --- .../teledeploy/options/installpluginlinuxopt.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/teledeploy/options/installpluginlinuxopt.xml b/config/teledeploy/options/installpluginlinuxopt.xml index b99311617..b0f86339a 100644 --- a/config/teledeploy/options/installpluginlinuxopt.xml +++ b/config/teledeploy/options/installpluginlinuxopt.xml @@ -100,18 +100,18 @@ sh installplugin.sh - :NOTIFY_USER: + 0 - :NOTIFY_TEXT: + - :NOTIFY_COUNTDOWN: + - :NOTIFY_CAN_ABORT: + 0 - :NOTIFY_CAN_DELAY: + 0 - :NEED_DONE_ACTION: + 0 - :NEED_DONE_ACTION_TEXT: + \ No newline at end of file From 9e8d1d45d9bc3f98e14bb87486635508181a4740 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Mon, 20 Jun 2022 09:25:33 +0000 Subject: [PATCH 154/187] Fix warning redirection deployment stat to multisearch --- plugins/main_sections/ms_multi_search/ms_multi_search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/main_sections/ms_multi_search/ms_multi_search.php b/plugins/main_sections/ms_multi_search/ms_multi_search.php index 8e9645e41..75b546895 100644 --- a/plugins/main_sections/ms_multi_search/ms_multi_search.php +++ b/plugins/main_sections/ms_multi_search/ms_multi_search.php @@ -160,7 +160,7 @@ }elseif($protectedGet['prov'] == 'stat'){ $options['idPackage'] = $databaseSearch->get_package_id($protectedGet['id_pack']); $options['stat'] = $protectedGet['stat']; - $search->link_multi($protectedGet['prov'], $protectedGet['value'], $options); + $search->link_multi($protectedGet['prov'], $protectedGet['value'] ?? null, $options); }elseif($protectedGet['prov'] == 'saas'){ $search->link_multi($protectedGet['prov'], $protectedGet['value']); }elseif($protectedGet['prov'] == 'querysave'){ @@ -187,7 +187,7 @@
      returnFieldHtmlAndOr($uniqid, $values, $infos, $table, $values['comparator']); + $htmlComparator = $search->returnFieldHtmlAndOr($uniqid, $values, $infos, $table, $values['comparator'] ?? null); if($htmlComparator != ""){ echo "
      From 837301ac0796554858cda0db232086355572b002 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Mon, 20 Jun 2022 09:37:22 +0000 Subject: [PATCH 155/187] Remove irc --- config/main_menu.xml | 4 ---- config/profiles/admin.xml | 1 - config/profiles/ladmin.xml | 1 - config/profiles/read-only.xml | 1 - config/profiles/sadmin.xml | 1 - config/urls.xml | 4 ---- plugins/main_sections/ms_help/ms_irc.php | 26 ------------------------ 7 files changed, 38 deletions(-) delete mode 100755 plugins/main_sections/ms_help/ms_irc.php diff --git a/config/main_menu.xml b/config/main_menu.xml index 46500f5ee..5963568e0 100644 --- a/config/main_menu.xml +++ b/config/main_menu.xml @@ -180,10 +180,6 @@ ms_wiki - - - ms_irc - ms_ask diff --git a/config/profiles/admin.xml b/config/profiles/admin.xml index e13d99ab3..05cbd4c68 100755 --- a/config/profiles/admin.xml +++ b/config/profiles/admin.xml @@ -38,7 +38,6 @@ ms_ipdiscover ms_doubles ms_wiki - ms_irc ms_offers ms_ask ms_console diff --git a/config/profiles/ladmin.xml b/config/profiles/ladmin.xml index a6e33ab89..d3e527699 100755 --- a/config/profiles/ladmin.xml +++ b/config/profiles/ladmin.xml @@ -52,7 +52,6 @@ ms_qrcode ms_server_infos ms_wiki - ms_irc ms_offers ms_ask ms_cve_search diff --git a/config/profiles/read-only.xml b/config/profiles/read-only.xml index cb77d2ae9..9a52e91be 100755 --- a/config/profiles/read-only.xml +++ b/config/profiles/read-only.xml @@ -32,7 +32,6 @@ ms_custom_groups ms_help ms_custom_info - ms_irc ms_custom_lock ms_offers ms_opt_ipdiscover diff --git a/config/profiles/sadmin.xml b/config/profiles/sadmin.xml index b976882ba..2da6af326 100755 --- a/config/profiles/sadmin.xml +++ b/config/profiles/sadmin.xml @@ -101,7 +101,6 @@ ms_stats_top ms_server_infos ms_wiki - ms_irc ms_offers ms_ask ms_extensionmanager diff --git a/config/urls.xml b/config/urls.xml index 129c09ba7..93f5538f5 100644 --- a/config/urls.xml +++ b/config/urls.xml @@ -268,10 +268,6 @@ wiki ms_help - - irc - ms_help - offers ms_help diff --git a/plugins/main_sections/ms_help/ms_irc.php b/plugins/main_sections/ms_help/ms_irc.php deleted file mode 100755 index 27a059463..000000000 --- a/plugins/main_sections/ms_help/ms_irc.php +++ /dev/null @@ -1,26 +0,0 @@ - -

      g(1123); ?>

      - Date: Mon, 20 Jun 2022 13:32:17 +0000 Subject: [PATCH 156/187] Fix fatal error archive mass processing --- plugins/main_sections/ms_multi_search/ms_custom_tag.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/main_sections/ms_multi_search/ms_custom_tag.php b/plugins/main_sections/ms_multi_search/ms_custom_tag.php index d2b1a9ea5..8076d0a07 100644 --- a/plugins/main_sections/ms_multi_search/ms_custom_tag.php +++ b/plugins/main_sections/ms_multi_search/ms_custom_tag.php @@ -31,7 +31,7 @@ echo "
      "; $list_id = multi_lot($form_name, $l->g(601)); - +var_dump($list_id); if (is_defined($list_id)) { echo "
      "; @@ -111,7 +111,7 @@ require_once('require/archive/ArchiveComputer.php'); $archive = new ArchiveComputer(); if (is_defined($protectedPost['ARCHIVER'])) { - $result = $archive->archive($protectedGet['idchecked']); + $result = $archive->archive($list_id); unset($protectedPost['ARCHIVER']); if($result){ msg_success($l->g(572)); @@ -119,7 +119,7 @@ } if (is_defined($protectedPost['RESTORE'])) { - $result = $archive->restore($protectedGet['idchecked']); + $result = $archive->restore($list_id); unset($protectedPost['RESTORE']); if($result){ msg_success($l->g(572)); From 5516c9ca076af30583f5e64ffac79c7747f94628 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Mon, 20 Jun 2022 13:47:42 +0000 Subject: [PATCH 157/187] Fix warning --- require/function_computers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/function_computers.php b/require/function_computers.php index 85dd99372..390df6edf 100755 --- a/require/function_computers.php +++ b/require/function_computers.php @@ -65,7 +65,7 @@ function computer_list_by_tag($tag = "", $format = 'LIST') { $sql_mycomputers = "select hardware_id from accountinfo a where a.tag in "; $sql_mycomputers = mysql2_prepare($sql_mycomputers, $arg_sql, $tag); } - $res_mycomputers = mysql2_query_secure($sql_mycomputers['SQL'], $_SESSION['OCS']["readServer"], $sql_mycomputers['ARG']); + $res_mycomputers = mysql2_query_secure($sql_mycomputers['SQL'], $_SESSION['OCS']["readServer"], $sql_mycomputers['ARG'] ?? []); $mycomputers = "("; while ($item_mycomputers = mysqli_fetch_object($res_mycomputers)) { $mycomputers .= $item_mycomputers->hardware_id . ","; From e0039a02b50b8449b1ddb117e50bdff8943cb76e Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Mon, 20 Jun 2022 13:50:37 +0000 Subject: [PATCH 158/187] Fix php warning --- plugins/computer_detail/cd_admininfo/cd_admininfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/computer_detail/cd_admininfo/cd_admininfo.php b/plugins/computer_detail/cd_admininfo/cd_admininfo.php index f6aeb9d55..5856ba7be 100644 --- a/plugins/computer_detail/cd_admininfo/cd_admininfo.php +++ b/plugins/computer_detail/cd_admininfo/cd_admininfo.php @@ -289,7 +289,7 @@ } echo "
      "; - modif_values($tab_name, $tab_typ_champ, $tab_hidden, array( + modif_values($tab_name, $tab_typ_champ, $tab_hidden ?? [], array( 'show_button' => $showbutton, 'form_name' => $form_name = 'NO_FORM', 'top_action' => $show_admin_button, From 56ad3f99e6b53a6072c27ccc0f3b5a7ea88694c2 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Tue, 21 Jun 2022 08:41:02 +0000 Subject: [PATCH 159/187] Fix ldap warning --- require/function_config_generale.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/require/function_config_generale.php b/require/function_config_generale.php index 13a9d297d..882f630d0 100644 --- a/require/function_config_generale.php +++ b/require/function_config_generale.php @@ -542,8 +542,12 @@ function nb_ldap_filters($nb, $default = false) { $old_filters = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]); $nb_old = $old_filters->num_rows; $old_filters = end(mysqli_fetch_all($old_filters, MYSQLI_ASSOC)); - $last_filter = (int) preg_replace('/[^0-9]/', '', $old_filters['NAME']); - + if(isset($old_filters['NAME'])) { + $last_filter = (int) preg_replace('/[^0-9]/', '', $old_filters['NAME']); + } else { + $last_filter = 2; + } + if ($nb > $nb_old) { // new filters added $i = $last_filter; From 7b08c0891cee28f3c8007702de739bc5e0f83a57 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Tue, 21 Jun 2022 08:41:52 +0000 Subject: [PATCH 160/187] Update to 2.10.0 --- var.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/var.php b/var.php index ab3120c08..88a6c1c66 100644 --- a/var.php +++ b/var.php @@ -78,7 +78,7 @@ /** * GUI Version */ -define('GUI_VER_SHOW', '2.9.2'); +define('GUI_VER_SHOW', '2.10.0'); /** * Default GUI language */ From 6b519b89230e7050647e23494f18e22d6dfbd57f Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Tue, 21 Jun 2022 14:37:20 +0200 Subject: [PATCH 161/187] Fix warning in install --- require/function_commun.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/require/function_commun.php b/require/function_commun.php index 654b9e6eb..3433833cf 100644 --- a/require/function_commun.php +++ b/require/function_commun.php @@ -350,9 +350,9 @@ function msg_error($txt, $close = false) { } function html_header($noJavascript = false) { - if ($_SESSION['OCS']['readServer']) { - $value_theme = look_config_default_values('CUSTOM_THEME'); - + $value_theme = null; + if (isset($_SESSION['OCS']['readServer'])) { + $value_theme = look_config_default_values('CUSTOM_THEME'); } if (is_null($value_theme)) { $value_theme['tvalue']['CUSTOM_THEME'] = DEFAULT_THEME; From 5083b44738a2febc0df9f9c972565bef20aae9e0 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 08:00:53 +0000 Subject: [PATCH 162/187] Add close form --- plugins/main_sections/ms_history/ms_history.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/main_sections/ms_history/ms_history.php b/plugins/main_sections/ms_history/ms_history.php index 75852a980..6e0a12785 100644 --- a/plugins/main_sections/ms_history/ms_history.php +++ b/plugins/main_sections/ms_history/ms_history.php @@ -51,6 +51,7 @@ $queryDetails = "SELECT USER, DATETIME_ACTION, ACTION, TARGET FROM `history`"; ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); +echo close_form(); if (AJAX) { From 58c68f6db8bd238bebba42e7c25a48445971b861 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 08:02:01 +0000 Subject: [PATCH 163/187] Add layout trad --- plugins/language/en_GB/en_GB.txt | 5 ++++- plugins/language/fr_FR/fr_FR.txt | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/language/en_GB/en_GB.txt b/plugins/language/en_GB/en_GB.txt index 9b7932809..aa89dfb9f 100755 --- a/plugins/language/en_GB/en_GB.txt +++ b/plugins/language/en_GB/en_GB.txt @@ -1839,4 +1839,7 @@ 9907 Manage layouts 9908 Show all layouts 9909 Add new layout -9910 Available layouts : \ No newline at end of file +9910 Available layouts : +9911 Layout name +9912 Layout description +9913 Table name \ No newline at end of file diff --git a/plugins/language/fr_FR/fr_FR.txt b/plugins/language/fr_FR/fr_FR.txt index 588e49393..75f05089b 100644 --- a/plugins/language/fr_FR/fr_FR.txt +++ b/plugins/language/fr_FR/fr_FR.txt @@ -1835,4 +1835,7 @@ 9907 Gestion des dispositions 9908 Afficher les dispositions 9909 Ajouter une disposition -9910 Dispositions disponibles : \ No newline at end of file +9910 Dispositions disponibles : +9911 Nom de la disposition +9912 Description de la disposition +9913 Nom du tableau \ No newline at end of file From a86328746b7bbef7cacae188151d5da50cea768a Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 08:02:18 +0000 Subject: [PATCH 164/187] Fix layout table warning and add trad --- .../main_sections/ms_layouts/ms_layouts.php | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/plugins/main_sections/ms_layouts/ms_layouts.php b/plugins/main_sections/ms_layouts/ms_layouts.php index 26d76c30f..d7e65877e 100644 --- a/plugins/main_sections/ms_layouts/ms_layouts.php +++ b/plugins/main_sections/ms_layouts/ms_layouts.php @@ -28,7 +28,11 @@ } printEnTete($l->g(9907)); + +$tab_options = $protectedPost; $form_name = "layouts"; +$tab_options['form_name'] = $form_name; +$tab_options['table_name'] = $form_name; $layout = new Layout($protectedGet['value']); //ADD new layout @@ -38,17 +42,27 @@ if (!empty($dupli)) { unset($protectedPost['Valid_modif']); } +} + +//delete layout +if (isset($protectedPost['SUP_PROF']) && $protectedPost['SUP_PROF'] != '') { + $layout->deleteLayout($protectedPost['SUP_PROF']); + $tab_options['CACHE'] = 'RESET'; +} +if (is_defined($protectedPost['del_check'])) { + $layout->deleteLayout($protectedPost['del_check']); + $tab_options['CACHE'] = 'RESET'; } // if no layout has been added yet and user did not delete layout : show the form if ((isset($protectedGet['tab']) && $protectedGet['tab'] == 'add') && (!isset($protectedPost['Valid_modif'])) && (!isset($protectedPost['SUP_PROF']) && !isset($protectedPost['del_check'])) && !isset($protectedPost['show_list'])) { - echo open_form('layouts', '', '', 'form-horizontal'); + echo open_form($form_name, '', '', 'form-horizontal'); ?>
      g(9911).' :', '', '', $protectedPost['LAYOUT_NAME'] ?? ''); + formGroup('text', 'LAYOUT_DESCR', $l->g(9912).' :', '', '', $protectedPost['LAYOUT_DESCR'] ?? ''); ?>
      @@ -62,43 +76,27 @@ // show the table } else { - echo open_form('layouts', '', '', 'form-horizontal'); - //delete layout - if (isset($protectedPost['SUP_PROF']) && $protectedPost['SUP_PROF'] != '') { - $layout->deleteLayout($protectedPost['SUP_PROF']); - $tab_options['CACHE'] = 'RESET'; - } - - if (is_defined($protectedPost['del_check'])) { - $layout->deleteLayout($protectedPost['del_check']); - $tab_options['CACHE'] = 'RESET'; - } - $table_name = $form_name; - $tab_options['form_name'] = $form_name; - $tab_options['table_name'] = $table_name; + echo open_form($form_name, '', '', 'form-horizontal'); $list_fields = array( - 'LAYOUT_NAME' => 'LAYOUT_NAME', - 'USER' => 'USER', - 'TABLE_NAME' => 'TABLE_NAME', - 'DESCRIPTION' => 'DESCRIPTION', + $l->g(9911) => 'LAYOUT_NAME', + $l->g(243) => 'USER', + $l->g(9913) => 'TABLE_NAME', + $l->g(53) => 'DESCRIPTION', + 'SUP' => 'SUP', + 'CHECK' => 'CHECK' ); - $list_col_cant_del = array( - 'LAYOUT_NAME' => 'LAYOUT_NAME', - 'USER' => 'USER', - 'TABLE_NAME' => 'TABLE_NAME', - 'SUP' => 'SUP', - 'CHECK' => 'CHECK' - ); + + $list_col_cant_del = $list_fields; $list_fields['SUP'] = 'ID'; $list_fields['CHECK'] = 'ID'; + $tab_options['LBL_POPUP']['SUP'] = 'LAYOUT_NAME'; $default_fields = $list_col_cant_del; $queryDetails = "SELECT ID, LAYOUT_NAME, USER, TABLE_NAME, DESCRIPTION FROM `layouts` WHERE USER = '".$_SESSION['OCS']['loggeduser']."'"; ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); - $img['image/delete.png'] = $l->g(162); del_selection($form_name); echo close_form(); From 6fa6947bdbffef61308613d07622100a03f87489 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 08:02:32 +0000 Subject: [PATCH 165/187] Fix layout warning --- require/function_table_html.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/require/function_table_html.php b/require/function_table_html.php index c0b28106d..215df291e 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -257,10 +257,14 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout'], $option['table_name']); - $visible_col = json_decode($cols['VISIBLE_COL'], true) ?? $visible_col; + // layouts + $layout = new Layout($option['table_name']); + $cols = $layout->displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout'] ?? 0, $option['table_name']); + if(!empty($cols['VISIBLE_COL']) || !empty($visible_col)) { + $visible_col = json_decode($cols['VISIBLE_COL'] ?? null, true) ?? $visible_col; + } else { + $visible_col = null; + } } ?>
      @@ -542,8 +546,10 @@ function checkall() Date: Wed, 22 Jun 2022 09:46:09 +0000 Subject: [PATCH 166/187] Add changelog for 2.10 --- Changes | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Changes b/Changes index 8b2edff14..62c105ef1 100755 --- a/Changes +++ b/Changes @@ -1,4 +1,30 @@ Revision history for ocsreports +2.10.0 + * Add PHP8 compatibility + * Add layout feature + * Add archive/restore actions to GUI LOGS + * Add CAS connection feature + * Add custom interval configuration to Last Contact in dashboard + * Add plugin deployment for unix systems + * Add configuration to exclude archive machines from the interface + * Improve archive/restore feature + * Improve LDAP connection feature + * Improve Software category regex display + * Update password encryption + * Fix subnets loading taking to much time on login + * Fix activate package display for every language + * Fix archive/restore action + * Fix multisearch query if IS NULL operator + * Fix software category deletion + * Fix SNMP read mib files + * Fix save search group for LDAP and CAS users + * Fix rights on actions column + * Fix CVE 2021-46355 + * Fix IpDiscover export + * Fix IpDiscover bugs + * Fix blank page after create networks type + * Remove overriding of profile rights on extensions pages + 2.9.2 * Add archive button on computer details page * Add local import From d554d0e4ffba2be3cecb714bde80d4df2ad24e54 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 12:25:47 +0000 Subject: [PATCH 167/187] Revert construct declaration typo --- require/config/Profile.php | 6 +++++- require/extensions/ExtensionHook.php | 7 +++++-- require/menu/ComputerMenuRenderer.php | 9 ++++++++- require/menu/MainMenuRenderer.php | 8 +++++++- require/menu/Menu.php | 8 ++++++-- require/menu/MenuElem.php | 8 +++++++- require/plugin/ComputerPlugin.php | 9 ++++++++- require/search/SQLCache.php | 6 +++++- require/table/Column.php | 14 ++++++++++++-- require/tables/Column.php | 9 +++++++-- require/tables/LinkColumn.php | 4 +++- require/tables/Table.php | 4 +++- require/teledeploy/PackageBuilder.php | 7 ++++++- require/teledeploy/PackageBuilderForm.php | 11 ++++++++++- .../teledeploy/PackageBuilderFormInteractions.php | 5 ++++- 15 files changed, 96 insertions(+), 19 deletions(-) diff --git a/require/config/Profile.php b/require/config/Profile.php index be7b70281..c6bc2a40a 100755 --- a/require/config/Profile.php +++ b/require/config/Profile.php @@ -29,12 +29,16 @@ class Profile { private $config; private $blacklist; private $pages; + private $name; + private $label; - public function __construct(private $name, private $label) { + public function __construct($name, $label) { $this->restrictions = array(); $this->config = array(); $this->blacklist = array(); $this->pages = array(); + $this->name = $name; + $this->label = $label; } public function getName() { diff --git a/require/extensions/ExtensionHook.php b/require/extensions/ExtensionHook.php index 90600fb28..582aa73e3 100644 --- a/require/extensions/ExtensionHook.php +++ b/require/extensions/ExtensionHook.php @@ -50,9 +50,12 @@ class ExtensionHook{ private $currentScannedExt = ""; - function __construct(public $activatedExt) { + public $activatedExt = array(); - foreach ($activatedExt as $extLabel) { + function __construct($activatedExt) { + $this->activatedExt = $activatedExt; + + foreach ($this->activatedExt as $extLabel) { if($this->haveHook($extLabel)){ $this->readHookXml($extLabel); } diff --git a/require/menu/ComputerMenuRenderer.php b/require/menu/ComputerMenuRenderer.php index e8dcbf6d2..50e47f170 100755 --- a/require/menu/ComputerMenuRenderer.php +++ b/require/menu/ComputerMenuRenderer.php @@ -25,8 +25,15 @@ * Renders the computer menu */ class ComputerMenuRenderer extends MenuRenderer { - public function __construct(private $computer_id, private $urls) { + + private $computer_id; + private $urls; + + public function __construct($computer_id, $urls) { parent::__construct(); + + $this->computer_id = $computer_id; + $this->urls = $urls; } public function getUrl(MenuElem $menu_elem) { diff --git a/require/menu/MainMenuRenderer.php b/require/menu/MainMenuRenderer.php index 8116a0719..0c525c5d0 100644 --- a/require/menu/MainMenuRenderer.php +++ b/require/menu/MainMenuRenderer.php @@ -25,8 +25,14 @@ * Renders the main menu */ class MainMenuRenderer extends MenuRenderer { - public function __construct(private $profile, private $urls) { + private $profile; + private $urls; + + public function __construct($profile, $urls) { parent::__construct(); + + $this->profile = $profile; + $this->urls = $urls; } protected function canSeeElem(MenuElem $menu_elem) { diff --git a/require/menu/Menu.php b/require/menu/Menu.php index 824185a29..21143b6eb 100755 --- a/require/menu/Menu.php +++ b/require/menu/Menu.php @@ -28,14 +28,18 @@ * */ class Menu { + private $_children; + private $_priority; + /** * Constructor * * @param array $_children An array of MenuElem * @param number $_priority The priority of this element to sort */ - public function __construct(private array $_children = array(), private $_priority = 0) - { + public function __construct($_children = array(), $_priority = 0) { + $this->_children = $_children; + $this->_priority = $_priority; } /** diff --git a/require/menu/MenuElem.php b/require/menu/MenuElem.php index 39cb42e80..668ed8fd8 100755 --- a/require/menu/MenuElem.php +++ b/require/menu/MenuElem.php @@ -27,6 +27,9 @@ * The class generate one menu element */ class MenuElem extends Menu { + private $_label; + private $_url; + /** * The constructor * @@ -35,7 +38,10 @@ class MenuElem extends Menu { * @param array $_children Children * @param number $_priority The priority of the MenuElem */ - public function __construct(private $_label, private $_url, array $_children = array(), $_priority = 0) { + public function __construct($_label, $_url, array $_children = array(), $_priority = 0) { + $this->_label = $_label; + $this->_url = $_url; + parent::__construct($_children, $_priority); } diff --git a/require/plugin/ComputerPlugin.php b/require/plugin/ComputerPlugin.php index 17bdba107..ec599e84f 100755 --- a/require/plugin/ComputerPlugin.php +++ b/require/plugin/ComputerPlugin.php @@ -29,7 +29,14 @@ class ComputerPlugin { private $available; private $hideFrame; - public function __construct(private $id, private $system, private $label) { + private $id; + private $system; + private $label; + + public function __construct($id, $system, $label) { + $this->id = $id; + $this->system = $system; + $this->label = $label; $this->category = 'other'; $this->available = null; $this->hideFrame = false; diff --git a/require/search/SQLCache.php b/require/search/SQLCache.php index f2a82a8fc..21507800e 100644 --- a/require/search/SQLCache.php +++ b/require/search/SQLCache.php @@ -31,11 +31,15 @@ class SQLCache const GROUP_TABLE = "groups_cache"; private $searchQuery; private $columnsQueryConditions; + private $search; + private $software; /** * @param Search $search */ - function __construct(private $search, private $software) { + function __construct($search, $software) { + $this->search = $search; + $this->software = $software; $this->searchQuery = "SELECT DISTINCT hardware.ID FROM hardware "; } diff --git a/require/table/Column.php b/require/table/Column.php index 3e6c7b374..56ef44701 100755 --- a/require/table/Column.php +++ b/require/table/Column.php @@ -24,8 +24,18 @@ * Handle properties of every column of the table */ abstract class Column { - public function __construct(private $label, private $visible, private $deletable, private $sortable) - { + private $label; + private $key; + private $visible; + private $deletable; + private $sortable; + + public function __construct($label, $visible, $deletable, $sortable) { + $this->key = $key; + $this->label = $label; + $this->visible = $visible; + $this->deletable = $deletable; + $this->sortable = $sortable; } /* diff --git a/require/tables/Column.php b/require/tables/Column.php index 1875686da..913f362db 100755 --- a/require/tables/Column.php +++ b/require/tables/Column.php @@ -27,13 +27,18 @@ class Column { private $searchable; private $formatter; - public function __construct(private $name, private $label, $options = array()) { + private $name; + private $label; + + public function __construct($name, $label, $options = array()) { $options = array_merge(array( 'required' => false, 'sortable' => true, 'searchable' => true, 'formatter' => null - ), $options); + ), $options); + $this->name = $name; + $this->label = $label; $this->required = $options['required']; $this->sortable = $options['sortable']; $this->searchable = $options['searchable']; diff --git a/require/tables/LinkColumn.php b/require/tables/LinkColumn.php index ed4eb49aa..5f4814abb 100755 --- a/require/tables/LinkColumn.php +++ b/require/tables/LinkColumn.php @@ -24,10 +24,12 @@ require_once('require/tables/Column.php'); class LinkColumn extends Column { private $idProperty; + private $url; - public function __construct($name, $label, private $url, $options = array()) { + public function __construct($name, $label, $url, $options = array()) { $options['formatter'] = array($this, 'formatLink'); $this->idProperty = $options['idProperty'] ?: 'id'; + $this->url = $url; parent::__construct($name, $label, $options); } diff --git a/require/tables/Table.php b/require/tables/Table.php index dce1d7e70..01f138da2 100755 --- a/require/tables/Table.php +++ b/require/tables/Table.php @@ -24,8 +24,10 @@ require_once('require/tables/Column.php'); class Table { private $columns; + private $name; - public function __construct(private $name) { + public function __construct($name) { + $this->name = $name; $this->columns = array(); } diff --git a/require/teledeploy/PackageBuilder.php b/require/teledeploy/PackageBuilder.php index 6277e8e83..097fcb56b 100644 --- a/require/teledeploy/PackageBuilder.php +++ b/require/teledeploy/PackageBuilder.php @@ -27,6 +27,8 @@ class PackageBuilder { private $downloadConfig = []; + private $packageBuilderForm; + private $packageBuilderParseXml; /** * Method __construct @@ -36,7 +38,7 @@ class PackageBuilder * * @return void */ - function __construct(private $packageBuilderForm, private $packageBuilderParseXml) { + function __construct($packageBuilderForm, $packageBuilderParseXml) { $this->downloadConfig = look_config_default_values([ 'DOWNLOAD_PACK_DIR' => 'DOWNLOAD_PACK_DIR', 'DOWNLOAD_ACTIVATE_FRAG' => 'DOWNLOAD_ACTIVATE_FRAG', @@ -56,6 +58,9 @@ function __construct(private $packageBuilderForm, private $packageBuilderParseXm if (empty($this->downloadConfig['tvalue']['DOWNLOAD_PROTOCOL'])) { $this->downloadConfig['tvalue']['DOWNLOAD_PROTOCOL'] = "HTTP"; } + + $this->packageBuilderForm = $packageBuilderForm; + $this->packageBuilderParseXml = $packageBuilderParseXml; } /** diff --git a/require/teledeploy/PackageBuilderForm.php b/require/teledeploy/PackageBuilderForm.php index 3abf2d538..43531a5e0 100644 --- a/require/teledeploy/PackageBuilderForm.php +++ b/require/teledeploy/PackageBuilderForm.php @@ -26,6 +26,11 @@ */ class PackageBuilderForm { + private $packageBuildeFormInteractions; + private $packageBuilderFormOperatingSystem; + private $packageBuilderParseXml; + private $packageBuilderFormOptions; + /** * Method __construct * @@ -36,8 +41,12 @@ class PackageBuilderForm * * @return void */ - function __construct(private $packageBuildeFormInteractions, private $packageBuilderFormOperatingSystem, private $packageBuilderParseXml, private $packageBuilderFormOptions) + function __construct($packageBuildeFormInteractions, $packageBuilderFormOperatingSystem, $packageBuilderParseXml, $packageBuilderFormOptions) { + $this->packageBuilderFormOperatingSystem = $packageBuilderFormOperatingSystem; + $this->packageBuildeFormInteractions = $packageBuildeFormInteractions; + $this->packageBuilderParseXml = $packageBuilderParseXml; + $this->packageBuilderFormOptions = $packageBuilderFormOptions; } /** diff --git a/require/teledeploy/PackageBuilderFormInteractions.php b/require/teledeploy/PackageBuilderFormInteractions.php index a60cfa2a8..7b00c0859 100644 --- a/require/teledeploy/PackageBuilderFormInteractions.php +++ b/require/teledeploy/PackageBuilderFormInteractions.php @@ -26,8 +26,11 @@ */ class PackageBuilderFormInteractions { - function __construct(private $packageBuilderParseXml) + private $packageBuilderParseXml; + + function __construct($packageBuilderParseXml) { + $this->packageBuilderParseXml = $packageBuilderParseXml; } /** From a0b081d89e69fbb94eab673f4e985837ea0c9ea9 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 12:29:18 +0000 Subject: [PATCH 168/187] Fix fatal error php7 --- require/extensions/ExtensionManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/extensions/ExtensionManager.php b/require/extensions/ExtensionManager.php index 29e61a58e..87db14be5 100644 --- a/require/extensions/ExtensionManager.php +++ b/require/extensions/ExtensionManager.php @@ -143,7 +143,7 @@ private function isExtensionCompliant($name){ } return true; - } catch (Exception) { + } catch (Exception $ex) { $this->installableExtensions_errors[] = sprintf($l->g(7021), $name).': '.$l->g(7023); return false; } From 9499ee02206b5ff00d42f2e7dc798489edba0c33 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 12:31:10 +0000 Subject: [PATCH 169/187] Fix fatal error php7 --- require/extensions/ExtensionManager.php | 6 +++--- require/teledeploy/PackageBuilder.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/require/extensions/ExtensionManager.php b/require/extensions/ExtensionManager.php index 87db14be5..beed11c01 100644 --- a/require/extensions/ExtensionManager.php +++ b/require/extensions/ExtensionManager.php @@ -143,7 +143,7 @@ private function isExtensionCompliant($name){ } return true; - } catch (Exception $ex) { + } catch (Exception $e) { $this->installableExtensions_errors[] = sprintf($l->g(7021), $name).': '.$l->g(7023); return false; } @@ -186,7 +186,7 @@ public function installExtension($name){ $installMethod(); // TODO : Successfuly instllaed return true; - } catch (Exception) { + } catch (Exception $e) { // TODO : PHP Error occured return false; } @@ -210,7 +210,7 @@ public function deleteExtension($name){ $deleteMethod = self::EXTENSION_DELETE_METHD.$name; $deleteMethod(); return true; - } catch (Exception) { + } catch (Exception $e) { return false; } diff --git a/require/teledeploy/PackageBuilder.php b/require/teledeploy/PackageBuilder.php index 097fcb56b..0ed2517f4 100644 --- a/require/teledeploy/PackageBuilder.php +++ b/require/teledeploy/PackageBuilder.php @@ -261,7 +261,7 @@ private function tarScriptFile($path, $name, $newName, $attachmentScript = null) if(file_exists($tarPath)) { unlink($tarPath); } - } catch (Exception) { + } catch (Exception $e) { error_log(print_r("error when tar gz file",true)); } From aa965dc11bf64cce98eb668ee2aa7412b9272af4 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 12:33:48 +0000 Subject: [PATCH 170/187] Fix fatal error php7 --- require/function_commun.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/function_commun.php b/require/function_commun.php index 3433833cf..020e2eb92 100644 --- a/require/function_commun.php +++ b/require/function_commun.php @@ -419,7 +419,7 @@ function html_header($noJavascript = false) { function strip_tags_array($value = '') { if (is_object($value)) { - $value = $value::class; + $value = get_class($value); $value = strip_tags($value, "


      "); return "Objet de la classe " . $value; } From 0f59999ac8ed4ddb12cbceb223702e1082903ea0 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 12:37:00 +0000 Subject: [PATCH 171/187] Fix fatal error php7 --- require/function_admininfo.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/require/function_admininfo.php b/require/function_admininfo.php index f3e0befaa..f2677092d 100644 --- a/require/function_admininfo.php +++ b/require/function_admininfo.php @@ -576,14 +576,19 @@ function interprete_accountinfo($list_fields, $tab_options) { * */ function adminData_to_input($typeID){ - - return match ($typeID) { - '2' => 'select', - '4' => 'checkbox', - '5' => 'file', - '7' => 'radio', - default => 'text', - }; + switch ($typeID){ + case '2': + return 'select'; + case '4': + return 'checkbox'; + case '5': + return 'file'; + case '7': + return 'radio'; + + default: + return 'text'; + } } ?> From d08ed31badf87a91d7d362f34642e0698f797755 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 12:51:01 +0000 Subject: [PATCH 172/187] Fix fatal error php7 --- backend/identity/methode/ldap.php | 2 +- backend/identity/methode/local.php | 2 +- plugins/main_sections/ms_doubles/ms_doubles.php | 2 +- plugins/main_sections/ms_export/ms_csv.php | 4 ++-- .../ms_multi_search/ms_multi_search.php | 6 +++--- .../main_sections/ms_search_soft/ms_search_soft.php | 2 +- .../ms_snmp_inventory/ms_snmp_inventory.php | 2 +- .../main_sections/ms_teledeploy/ms_custom_pack.php | 2 +- require/console/Console.php | 12 ++++++------ require/cve/Cve.php | 2 +- require/function_computers.php | 4 ++-- require/function_table_html.php | 2 +- require/ipdiscover/Ipdiscover.php | 2 +- require/mail/NotificationMail.php | 8 ++++---- require/search/Search.php | 12 ++++++------ require/search/TranslationSearch.php | 2 +- require/snmp/Snmp.php | 2 +- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/backend/identity/methode/ldap.php b/backend/identity/methode/ldap.php index 73c6d7020..eac957339 100644 --- a/backend/identity/methode/ldap.php +++ b/backend/identity/methode/ldap.php @@ -159,7 +159,7 @@ $res = mysql2_query_secure($sql, $link_ocs, $arg); while ($row = mysqli_fetch_object($res)) { // Check for wildcard - if (str_contains($row->tag, '*') || str_contains($row->tag,'?')) { + if (strpos($row->tag, '*') || strpos($row->tag,'?')) { $wildcard = true; $row->tag = str_replace("*", "%", $row->tag); $row->tag = str_replace("?", "_", $row->tag); diff --git a/backend/identity/methode/local.php b/backend/identity/methode/local.php index 656f3337c..2c97c6830 100644 --- a/backend/identity/methode/local.php +++ b/backend/identity/methode/local.php @@ -61,7 +61,7 @@ $res = mysql2_query_secure($sql, $link_ocs, $arg); while ($row = mysqli_fetch_object($res)) { // Check for wildcard - if (str_contains($row->tag, '*') || str_contains($row->tag,'?')) { + if (strpos($row->tag, '*') || strpos($row->tag,'?')) { $wildcard = true; $row->tag = str_replace("*", "%", $row->tag); $row->tag = str_replace("?", "_", $row->tag); diff --git a/plugins/main_sections/ms_doubles/ms_doubles.php b/plugins/main_sections/ms_doubles/ms_doubles.php index 19fbc16be..fdeda8d81 100644 --- a/plugins/main_sections/ms_doubles/ms_doubles.php +++ b/plugins/main_sections/ms_doubles/ms_doubles.php @@ -424,7 +424,7 @@ function returnTrad($lbl){ echo "
      ".strtoupper($itemagain['name']). "


      "; echo "
      "; foreach ($itemagain as $key => $info) { - if(str_contains($key, "fields_")) { + if(strpos($key, "fields_")) { $admininfoId = explode("_", $key); $admininfo = find_info_accountinfo($admininfoId[1]); diff --git a/plugins/main_sections/ms_export/ms_csv.php b/plugins/main_sections/ms_export/ms_csv.php index 3e35d8a5d..858dbf06e 100644 --- a/plugins/main_sections/ms_export/ms_csv.php +++ b/plugins/main_sections/ms_export/ms_csv.php @@ -101,7 +101,7 @@ $found = false; // find value case-insensitive foreach ($col as $key => $val) { - if (str_contains($key, ".")) { + if (strpos($key, ".")) { $exploded_key = explode(".", $key); $key = $exploded_key[1]; } @@ -125,7 +125,7 @@ $found = true; } elseif (array_key_exists(strtoupper($key),$cont)){ // in the case key is in lower case and array cont is in upper case $data[$i][strtoupper($key)] = $cont[strtoupper($key)]; - } elseif (str_contains($key, ' AS ') || str_contains($key, ' as ')) { + } elseif (strpos($key, ' AS ') || strpos($key, ' as ')) { $key_explode = explode(" ", $key); $data[$i][$key_explode[2]] = $cont[$key_explode[2]]; } diff --git a/plugins/main_sections/ms_multi_search/ms_multi_search.php b/plugins/main_sections/ms_multi_search/ms_multi_search.php index 75b546895..2141ecc42 100644 --- a/plugins/main_sections/ms_multi_search/ms_multi_search.php +++ b/plugins/main_sections/ms_multi_search/ms_multi_search.php @@ -198,7 +198,7 @@ } ?>
      getAccountInfosList(); echo $translationSearch->getTranslationFor($table)." : ".$fields['COMPUTERS'][$values['fields']]; }else{ @@ -210,7 +210,7 @@
      - getSearchedFieldType($table, $values['fields']) == 'datetime'))) { + getSearchedFieldType($table, $values['fields']) == 'datetime'))) { echo $search->getSelectOptionForOperators($values['operator'], $table, $values['fields']); } else { echo $search->getSelectOptionForOperators($values['operator'], $table); @@ -220,7 +220,7 @@
      - correspondance)){ + correspondance)){ echo $search->returnFieldHtml($uniqid, $values, $table, $values['fields']); }else { echo $search->returnFieldHtml($uniqid, $values, $table, null, $values['operator']); diff --git a/plugins/main_sections/ms_search_soft/ms_search_soft.php b/plugins/main_sections/ms_search_soft/ms_search_soft.php index 2a3b5e487..831ffc08c 100644 --- a/plugins/main_sections/ms_search_soft/ms_search_soft.php +++ b/plugins/main_sections/ms_search_soft/ms_search_soft.php @@ -73,7 +73,7 @@ } else { $logiciel = $protectedPost['logiciel_text']; // Check for wildcard - if (strpos($logiciel, '*') || strpos($logiciel,'?')) { + if (strpos($logiciel, '*') !== false || strpos($logiciel,'?') !== false) { $wildcard = true; $logiciel = str_replace("*", "%", $logiciel); $logiciel = str_replace("?", "_", $logiciel); diff --git a/plugins/main_sections/ms_snmp_inventory/ms_snmp_inventory.php b/plugins/main_sections/ms_snmp_inventory/ms_snmp_inventory.php index 74361c714..c94ff3453 100644 --- a/plugins/main_sections/ms_snmp_inventory/ms_snmp_inventory.php +++ b/plugins/main_sections/ms_snmp_inventory/ms_snmp_inventory.php @@ -141,7 +141,7 @@ echo ''; echo ''.$column.''; echo ''; - if(strpos($values[$column], " - ")) { + if(strpos($values[$column], " - ") !== false) { $list = explode(" - ", $values[$column]); natsort($list); foreach($list as $lists) { diff --git a/plugins/main_sections/ms_teledeploy/ms_custom_pack.php b/plugins/main_sections/ms_teledeploy/ms_custom_pack.php index 0cd4283c9..12ca892cd 100644 --- a/plugins/main_sections/ms_teledeploy/ms_custom_pack.php +++ b/plugins/main_sections/ms_teledeploy/ms_custom_pack.php @@ -73,7 +73,7 @@ //activation options if(isset($protectedPost['Valid_package'])) { foreach ($protectedPost as $key => $value) { - if(strpos($key, 'check')){ + if(strpos($key, 'check') !== false){ $id[] = substr($key, 5); } } diff --git a/require/console/Console.php b/require/console/Console.php index d3b7a2685..cd4a9cb28 100644 --- a/require/console/Console.php +++ b/require/console/Console.php @@ -54,13 +54,13 @@ public function get_machine_contacted_td($title){ $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]); while($item = mysqli_fetch_array($result)) { - if(strpos($item['USERAGENT'], 'unix')) { + if(strpos($item['USERAGENT'], 'unix') !== false) { $machine['unix'] = intval($item['nb']); $machine['all'] = $machine['all'] + intval($item['nb']); - } elseif(strpos(strtoupper($item['USERAGENT']), 'WINDOWS')) { + } elseif(strpos(strtoupper($item['USERAGENT']), 'WINDOWS') !== false) { $machine['windows'] = intval($item['nb']); $machine['all'] = $machine['all'] + intval($item['nb']); - } elseif(strpos($item['USERAGENT'], 'Android')) { + } elseif(strpos($item['USERAGENT'], 'Android') !== false) { $machine['android'] = intval($item['nb']); $machine['all'] = $machine['all'] + intval($item['nb']); } @@ -78,13 +78,13 @@ public function get_machine_contacted_td($title){ $sql .= " GROUP BY h.USERAGENT"; $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]); while($item = mysqli_fetch_array($result)){ - if(strpos($item['USERAGENT'], 'unix')) { + if(strpos($item['USERAGENT'], 'unix') !== false) { $machine['unix'] = $machine['unix'] + intval($item['nb']); $machine['all'] = $machine['all'] + intval($item['nb']); - } elseif(strpos($item['USERAGENT'], 'WINDOWS')) { + } elseif(strpos($item['USERAGENT'], 'WINDOWS') !== false) { $machine['windows'] = $machine['windows'] + intval($item['nb']); $machine['all'] = $machine['all'] + intval($item['nb']); - } elseif(strpos($item['USERAGENT'], 'Android')) { + } elseif(strpos($item['USERAGENT'], 'Android') !== false) { $machine['android'] = $machine['android'] + intval($item['nb']); $machine['all'] = $machine['all'] + intval($item['nb']); }else{ diff --git a/require/cve/Cve.php b/require/cve/Cve.php index 0c9cdde97..308cae32c 100644 --- a/require/cve/Cve.php +++ b/require/cve/Cve.php @@ -372,7 +372,7 @@ private function search_by_version($vars, $software){ foreach($array as $values) { if(isset($values["vulnerable_configuration"])) { foreach($values["vulnerable_configuration"] as $vuln){ - if((!empty(strval($vuln_conf)) && (strpos(strval($vuln), strval($vuln_conf)))) || (!empty(strval($vuln_conf_all)) && (strpos(strval($vuln), strval($vuln_conf_all))))){ + if((!empty(strval($vuln_conf)) && (strpos(strval($vuln), strval($vuln_conf)) !== false)) || (!empty(strval($vuln_conf_all)) && (strpos(strval($vuln), strval($vuln_conf_all)) !== false))){ $result = $this->get_infos_cve($values['cvss'], $values['id'], $values['references'][0]); if($result != null) { if($this->CVE_VERBOSE == 1) { diff --git a/require/function_computers.php b/require/function_computers.php index 024cd839d..26aaf1625 100755 --- a/require/function_computers.php +++ b/require/function_computers.php @@ -227,7 +227,7 @@ function fusionne($afus) { foreach($accountTable as $table) { foreach($table as $key => $value) { - if(strpos($key,"fields_")) { + if(strpos($key,"fields_") !== false) { if($value != null && $value != "") { $accountid = $table['HARDWARE_ID']; } diff --git a/require/function_table_html.php b/require/function_table_html.php index 3d4698260..034444770 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -1518,7 +1518,7 @@ function ajaxfiltre($queryDetails,$tab_options){ if($info_tag[$id_tag[1]]['type'] == 2) { $info = find_value_field('ACCOUNT_VALUE_' . $info_tag[$id_tag[1]]['name']); foreach($info as $key => $value) { - if(strpos(strtolower($value), strtolower($search))) { + if(strpos(strtolower($value), strtolower($search)) !== false) { $acc_select[$key] = $key; } } diff --git a/require/ipdiscover/Ipdiscover.php b/require/ipdiscover/Ipdiscover.php index 7e2d61713..b1514aa61 100644 --- a/require/ipdiscover/Ipdiscover.php +++ b/require/ipdiscover/Ipdiscover.php @@ -50,7 +50,7 @@ public function verif_base_methode($base) { } public function find_info_subnet($netid, $tag = null) { - if(strpos($netid,";")) { + if(strpos($netid,";") !== false) { $explode = explode(";", $netid); $netid = $explode[0]; $tag = $explode[1]; diff --git a/require/mail/NotificationMail.php b/require/mail/NotificationMail.php index da9fabb45..10e0db1f6 100644 --- a/require/mail/NotificationMail.php +++ b/require/mail/NotificationMail.php @@ -234,10 +234,10 @@ public function replace_value($file, $selected){ } } - if(strpos($template, "{{")){ + if(strpos($template, "{{") !== false){ $explode1 = explode("{{", $template); foreach($explode1 as $value){ - if(strpos($value, "}}")){ + if(strpos($value, "}}") !== false){ $explode2[] = explode("}}", $value); } } @@ -251,7 +251,7 @@ public function replace_value($file, $selected){ } foreach ($explode3 as $replace){ - if(strpos($replace, "g")){ + if(strpos($replace, "g") !== false){ $traduction = explode(".", $replace); $pattern[] = $replace; $replacement[] = $l->g($traduction[1]); diff --git a/require/search/Search.php b/require/search/Search.php index 5faf78e73..b72bc14b5 100644 --- a/require/search/Search.php +++ b/require/search/Search.php @@ -976,7 +976,7 @@ public function link_multi($fields, $value, $option = ""){ case 'ipdiscover1': $_SESSION['OCS']['multi_search'] = array(); if(!isset($_SESSION['OCS']['multi_search']['networks']['ipdiscover1'])){ - if(strpos($value, ";")) { + if(strpos($value, ";") !== false) { $explode = explode(";", $value); $value = $explode[0]; if(count($explode) == 2) { @@ -1130,7 +1130,7 @@ public function query_save($id) { public function link_index($fields, $value, $comp = "", $value2 = null){ $field = explode("-", $fields) ; - if($comp== 'small') { $operator = 'LESS'; } + if($comp == 'small') { $operator = 'LESS'; } elseif($comp == 'tall') { $operator = 'MORE'; } elseif($comp == 'exact') { $operator = 'EQUAL'; } @@ -1145,7 +1145,7 @@ public function link_index($fields, $value, $comp = "", $value2 = null){ $configValues = look_config_default_values($configToLookOut)['ivalue']['EXCLUDE_ARCHIVE_COMPUTER'] ?? ''; if(empty($field[2])){ - if(strpos($field[0], 'HARDWARE')){ + if(strpos($field[0], 'HARDWARE') !== false){ if(!isset($_SESSION['OCS']['multi_search']['hardware']) || !array_key_exists('HARDWARE-'.$field[1].$comp.preg_replace("/\s+/","", preg_replace("/_/","",$value)).preg_replace("/_/","",$value2),$_SESSION['OCS']['multi_search']['hardware'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['hardware']['HARDWARE-'.$field[1].$comp.preg_replace("/\s+/","", preg_replace("/_/","",$value)).preg_replace("/_/","",$value2)] = [ @@ -1175,7 +1175,7 @@ public function link_index($fields, $value, $comp = "", $value2 = null){ 'operator' => $operator, ]; } - }elseif(strpos($field[0], 'NETWORKS')){ + }elseif(strpos($field[0], 'NETWORKS') !== false){ if(!isset($_SESSION['OCS']['multi_search']['networks']) || !array_key_exists('NETWORKS-'.$field[1].$comp.$value,$_SESSION['OCS']['multi_search']['networks'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['networks']['NETWORKS-'.$field[1].$comp.preg_replace("/_/","",$value)] = [ @@ -1184,7 +1184,7 @@ public function link_index($fields, $value, $comp = "", $value2 = null){ 'operator' => $operator, ]; } - }elseif(strpos($field[0], 'VIDEOS')){ + }elseif(strpos($field[0], 'VIDEOS') !== false){ if(!isset($_SESSION['OCS']['multi_search']['videos']) || !array_key_exists('VIDEOS-'.$field[1].$comp.$value,$_SESSION['OCS']['multi_search']['videos'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['videos']['VIDEOS-'.$field[1].$comp.preg_replace("/_/","",$value)] = [ @@ -1193,7 +1193,7 @@ public function link_index($fields, $value, $comp = "", $value2 = null){ 'operator' => $operator, ]; } - }elseif(strpos($field[0], 'ASSETS')){ + }elseif(strpos($field[0], 'ASSETS') !== false){ if(!isset($_SESSION['OCS']['multi_search']['hardware']) || !array_key_exists('ASSETS'.$value,$_SESSION['OCS']['multi_search']['hardware'])){ $_SESSION['OCS']['multi_search'] = array(); $_SESSION['OCS']['multi_search']['hardware']['ASSETS'.preg_replace("/_/","",$value)] = [ diff --git a/require/search/SoftwareSearch.php b/require/search/SoftwareSearch.php index 68a7af74d..76e326a75 100644 --- a/require/search/SoftwareSearch.php +++ b/require/search/SoftwareSearch.php @@ -87,25 +87,41 @@ private function normalizeFieldType($type) * Get Software table name */ public function getTableName($field) { - return match ($field) { - "NAME_ID" => self::NAME_TABLE, - "PUBLISHER_ID" => self::PUBLISHER_TABLE, - "VERSION_ID" => self::VERSION_TABLE, - "CATEGORY" => self::NAME_TABLE, - default => self::SOFTWARE_TABLE, - }; + switch ($field) { + case "NAME_ID": + return self::NAME_TABLE; + break; + case "PUBLISHER_ID": + return self::PUBLISHER_TABLE; + break; + case "VERSION_ID" : + return self::VERSION_TABLE; + case "CATEGORY" : + return self::NAME_TABLE; + break; + default : + return self::SOFTWARE_TABLE; + break; + } } /** * Get software column name */ public function getColumnName($field) { - return match ($field) { - "NAME_ID" => "NAME", - "PUBLISHER_ID" => "PUBLISHER", - "VERSION_ID" => "VERSION", - default => $field, - }; + switch ($field) { + case "NAME_ID": + return "NAME"; + break; + case "PUBLISHER_ID": + return "PUBLISHER"; + break; + case "VERSION_ID" : + return "VERSION"; + default : + return $field; + break; + } } } \ No newline at end of file diff --git a/require/search/TranslationSearch.php b/require/search/TranslationSearch.php index 61d42af06..dcdb6f619 100644 --- a/require/search/TranslationSearch.php +++ b/require/search/TranslationSearch.php @@ -275,7 +275,7 @@ public function getTranslationForListField($string){ if(!empty($this->translationArray[$name])){ $name = $l->g($this->translationArray[$name]); - }elseif(strpos($name, 'fields_')){ + }elseif(strpos($name, 'fields_') !== false){ $accountInfoSearch = new AccountinfoSearch(); $translateAccount = $accountInfoSearch->getAccountInfosList(); $name = $translateAccount['COMPUTERS'][$name]; diff --git a/require/snmp/Snmp.php b/require/snmp/Snmp.php index ee558a0fe..089fddc87 100644 --- a/require/snmp/Snmp.php +++ b/require/snmp/Snmp.php @@ -467,7 +467,7 @@ public function sort_mib($post) { $config = null; foreach($post as $key => $value) { - if(strpos($key, "checkbox_")) { + if(strpos($key, "checkbox_") !== false) { $mib_check = explode("_", $key); } From 0a17b0e0eed89aa2859fca4c592fe5a21750d9b4 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 13:58:54 +0000 Subject: [PATCH 174/187] Fix warning --- require/function_table_html.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/require/function_table_html.php b/require/function_table_html.php index 034444770..dedbc9827 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -260,11 +260,7 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list // layouts $layout = new Layout($option['table_name']); $cols = $layout->displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout'] ?? 0, $option['table_name']); - if(!empty($cols['VISIBLE_COL']) || !empty($visible_col)) { - $visible_col = json_decode($cols['VISIBLE_COL'] ?? null, true) ?? $visible_col; - } else { - $visible_col = null; - } + $visible_col = json_decode($cols['VISIBLE_COL'] ?? null, true) ?? $visible_col ?? null; } ?>
      @@ -546,10 +542,8 @@ function checkall() Date: Wed, 22 Jun 2022 14:25:33 +0000 Subject: [PATCH 175/187] Fix layout select --- require/function_table_html.php | 2 +- require/layouts/Layout.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/require/function_table_html.php b/require/function_table_html.php index dedbc9827..8f3bf18f6 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -259,7 +259,7 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list if (isset($option['table_name']) && $option['table_name'] != 'affich_multi_crit') { // layouts $layout = new Layout($option['table_name']); - $cols = $layout->displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout'] ?? 0, $option['table_name']); + $cols = $layout->displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout'] ?? '----', $option['table_name']); $visible_col = json_decode($cols['VISIBLE_COL'] ?? null, true) ?? $visible_col ?? null; } ?> diff --git a/require/layouts/Layout.php b/require/layouts/Layout.php index 63896b9a4..33d6adcd3 100644 --- a/require/layouts/Layout.php +++ b/require/layouts/Layout.php @@ -121,12 +121,11 @@ public function displayLayoutButtons($user, $current_tab, $table) { foreach ($layout_tabs as $key => $value) { echo ""; } From 9e6e6cbf5f1e4d3828caad80ed7efec3d3792b08 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 15:44:53 +0000 Subject: [PATCH 176/187] Fix auto complete var --- install.php | 128 ++++++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/install.php b/install.php index b3f0d81b7..56ecf5ef1 100755 --- a/install.php +++ b/install.php @@ -232,71 +232,73 @@ function exec_fichier_sql($fichier, $link) { } //die(); } +if(is_readable(CONF_MYSQL)) { + require(CONF_MYSQL); +} //use values in mysql config file -if (is_readable(CONF_MYSQL)) { - if (defined('COMPTE_BASE')) { - $valNme = COMPTE_BASE; - } else { - $valNme = ''; - } - if (defined('PSWD_BASE')) { - $valPass = PSWD_BASE; - } else { - $valPass = ''; - } - if (defined('SERVER_WRITE')) { - $valServ = SERVER_WRITE; - } else { - $valServ = ''; - } - if (defined('SERVER_PORT')) { - $valPort = SERVER_PORT; - } else { - $valPort = 3306; - } - if (defined('DB_NAME')) { - $valdatabase = DB_NAME; - } else { - $valdatabase = ''; - } - if (defined('ENABLE_SSL')) { - $valenablessl = [ - "1" => $l->g(455), - "0" => $l->g(454) - ]; - } else { - $valenablessl = [ - "1" => $l->g(455), - "0" => $l->g(454) - ]; - } - if (defined('SSL_MODE')) { - $valsslmode = [ - "MYSQLI_CLIENT_SSL" => "MYSQLI_CLIENT_SSL", - "MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT" => "MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT" - ]; - } else { - $valsslmode = [ - "MYSQLI_CLIENT_SSL" => "MYSQLI_CLIENT_SSL", - "MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT" => "MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT" - ]; - } - if (defined('SSL_KEY')) { - $valsslkey = SSL_KEY; - } else { - $valsslkey = ''; - } - if (defined('SSL_CERT')) { - $valsslcert = SSL_CERT; - } else { - $valsslcert = ''; - } - if (defined('CA_CERT')) { - $valcacert = CA_CERT; - } else { - $valcacert = ''; - } +if (defined('COMPTE_BASE')) { + $valNme = COMPTE_BASE; +} else { + $valNme = ''; +} +if (defined('PSWD_BASE')) { + $valPass = PSWD_BASE; +} else { + $valPass = ''; +} +if (defined('SERVER_WRITE')) { + $valServ = SERVER_WRITE; +} else { + $valServ = ''; +} +if (defined('SERVER_PORT')) { + $valPort = SERVER_PORT; +} else { + $valPort = 3306; +} +if (defined('DB_NAME')) { + $valdatabase = DB_NAME; +} else { + $valdatabase = ''; +} +if (defined('ENABLE_SSL')) { + $valenablessl = [ + "1" => $l->g(455), + "0" => $l->g(454) + ]; +} else { + $valenablessl = [ + "1" => $l->g(455), + "0" => $l->g(454) + ]; +} +if (defined('SSL_MODE')) { + $valsslmode = [ + "MYSQLI_CLIENT_SSL" => "MYSQLI_CLIENT_SSL", + "MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT" => "MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT" + ]; +} else { + $valsslmode = [ + "MYSQLI_CLIENT_SSL" => "MYSQLI_CLIENT_SSL", + "MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT" => "MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT" + ]; +} +if (defined('SSL_KEY')) { + $valsslkey = SSL_KEY; +} else { + $valsslkey = ''; } +if (defined('SSL_CERT')) { + $valsslcert = SSL_CERT; +} else { + $valsslcert = ''; +} +if (defined('CA_CERT')) { + $valcacert = CA_CERT; +} else { + $valcacert = ''; +} + //show first form $form_name = 'fsub'; $name_field = array("name", "pass", "database", "host", "port", "enablessl", "sslmode", "sslkey", "sslcert", "cacert"); From 342bae729ffa6890434d5835b5e8c104e0db9fa8 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 15:45:33 +0000 Subject: [PATCH 177/187] Fix installation fatal error on php8 --- require/function_commun.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/require/function_commun.php b/require/function_commun.php index 020e2eb92..1a7784af9 100644 --- a/require/function_commun.php +++ b/require/function_commun.php @@ -351,7 +351,9 @@ function msg_error($txt, $close = false) { function html_header($noJavascript = false) { $value_theme = null; - if (isset($_SESSION['OCS']['readServer'])) { + if (is_readable(CONF_MYSQL) && isset($_SESSION['OCS']['readServer']) + && defined("SERVER_READ") && defined("DB_NAME") && defined("SERVER_WRITE") && defined("COMPTE_BASE") && defined("PSWD_BASE") + ) { $value_theme = look_config_default_values('CUSTOM_THEME'); } if (is_null($value_theme)) { From 1a059e8e76d99d95b306227692b2c16eb5b43f29 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Thu, 23 Jun 2022 07:10:24 +0000 Subject: [PATCH 178/187] Fix double installation form --- install.php | 1 + 1 file changed, 1 insertion(+) diff --git a/install.php b/install.php index 56ecf5ef1..fd4b70509 100755 --- a/install.php +++ b/install.php @@ -223,6 +223,7 @@ function exec_fichier_sql($fichier, $link) { unlink(CONF_MYSQL); } else { msg_success("" . $l->g(2050) . "

      " . $l->g(2051) . ""); + require(CONF_MYSQL); unset($_SESSION['OCS']['SQL_BASE_VERS']); } die(); From a547aff69856678ce96cfa8131d1c4557c53d85d Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Thu, 23 Jun 2022 10:45:45 +0200 Subject: [PATCH 179/187] Remove php warning when delete snmp label without configuration --- require/snmp/Snmp.php | 47 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/require/snmp/Snmp.php b/require/snmp/Snmp.php index 089fddc87..807f54b22 100644 --- a/require/snmp/Snmp.php +++ b/require/snmp/Snmp.php @@ -332,19 +332,25 @@ public function delete_label($id){ private function drop_column($id){ $type = $this->get_config($id); $label = $this->get_label_drop($id); + $tableName = []; - foreach($type as $value){ - $tableName[] = $this->get_table_type_drop($value); + if(!empty($type)) { + foreach($type as $key => $value){ + $tableName[] = $this->get_table_type_drop($value); + } } - foreach($tableName as $name){ - $sql_alter_table = "ALTER TABLE `%s` DROP `%s`"; - $arg_alter_table = array($name, $label); - $result_alter = mysql2_query_secure($sql_alter_table, $_SESSION['OCS']["writeServer"], $arg_alter_table); - if(!$result_alter){ - return false; + if(!empty($tableName)) { + foreach($tableName as $id => $name){ + $sql_alter_table = "ALTER TABLE `%s` DROP `%s`"; + $arg_alter_table = array($name, $label); + $result_alter = mysql2_query_secure($sql_alter_table, $_SESSION['OCS']["writeServer"], $arg_alter_table); + if(!$result_alter){ + return false; + } } } + return true; } @@ -447,19 +453,14 @@ public function get_mib() { $champs = array('SNMP_MIB_DIRECTORY' => 'SNMP_MIB_DIRECTORY'); $values = look_config_default_values($champs); - if(isset($values['tvalue']['SNMP_MIB_DIRECTORY'])) { - $mib_files = glob($values['tvalue']['SNMP_MIB_DIRECTORY'].'/*', GLOB_BRACE); - $mib_files = str_replace($values['tvalue']['SNMP_MIB_DIRECTORY']."/", "", $mib_files); + $mib_files = glob($values['tvalue']['SNMP_MIB_DIRECTORY'].'/*', GLOB_BRACE); + $mib_files = str_replace($values['tvalue']['SNMP_MIB_DIRECTORY']."/", "", $mib_files); - foreach($mib_files as $mib) { - $mib_name[$mib] = $mib; - } + foreach($mib_files as $mib) { + $mib_name[$mib] = $mib; } - - - - return $mib_name ?? ''; + return $mib_name; } public function sort_mib($post) { @@ -482,7 +483,8 @@ public function sort_mib($post) { } } - foreach($config as $key => $value) { + if(!empty($config)) { + foreach($config as $key => $value) { if($config[$key]['label'] != null && $config[$key]['oid'] != null) { $result = $this->snmp_config($post['type_id'], $config[$key]['label'], $config[$key]['oid'], $config[$key]['reconciliation']); @@ -491,6 +493,7 @@ public function sort_mib($post) { } } } + } return true; } @@ -533,10 +536,8 @@ public function get_infos($tablename, $columns) { $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); $infos = []; - if (!empty($result)) { - while($item = mysqli_fetch_array($result)) { - $infos[$item['ID']] = $item; - } + while($item = mysqli_fetch_array($result)) { + $infos[$item['ID']] = $item; } return $infos; From 117ac7cc322150a868273b3710c3b5f3223b777b Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Thu, 23 Jun 2022 11:27:30 +0200 Subject: [PATCH 180/187] Fix fatal error on php7 str_start_with --- plugins/main_sections/ms_admininfo/ms_admininfo.php | 2 +- plugins/main_sections/ms_all_computers/ms_all_computers.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/main_sections/ms_admininfo/ms_admininfo.php b/plugins/main_sections/ms_admininfo/ms_admininfo.php index dd0318f4e..18f1e31ef 100644 --- a/plugins/main_sections/ms_admininfo/ms_admininfo.php +++ b/plugins/main_sections/ms_admininfo/ms_admininfo.php @@ -525,7 +525,7 @@ // get array of links foreach ($protectedPost as $key => $value) { - if (str_starts_with($key, 'link_')) { + if (strpos($key, 'link_') === 0) { $links[$key] = $value; } } diff --git a/plugins/main_sections/ms_all_computers/ms_all_computers.php b/plugins/main_sections/ms_all_computers/ms_all_computers.php index ef2280285..e946c34d5 100644 --- a/plugins/main_sections/ms_all_computers/ms_all_computers.php +++ b/plugins/main_sections/ms_all_computers/ms_all_computers.php @@ -255,7 +255,7 @@ } // TAG RESTRICTIONS -if (is_defined($_GET['value']) && str_starts_with($_GET['filtre'], 'a.fields_')){ +if (is_defined($_GET['value']) && strpos($_GET['filtre'], 'a.fields_') === 0){ $tag = $_GET['value']; $fields = $_GET['filtre']; $queryDetails .= "AND ".$fields."= '$tag' "; From d571a0758d3a629b14b8259262b349bfb767f196 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Thu, 23 Jun 2022 11:42:31 +0200 Subject: [PATCH 181/187] Revert match per switch function --- .../main_sections/ms_doubles/ms_doubles.php | 16 ++++++++------- .../ms_teledeploy/views/package_form_view.php | 20 +++++++++++++------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/plugins/main_sections/ms_doubles/ms_doubles.php b/plugins/main_sections/ms_doubles/ms_doubles.php index 9c2cff921..508a818df 100644 --- a/plugins/main_sections/ms_doubles/ms_doubles.php +++ b/plugins/main_sections/ms_doubles/ms_doubles.php @@ -394,13 +394,15 @@ function returnTrad($lbl){ $duplicates = mysql2_query_secure($sql['SQL'], $_SESSION['OCS']["readServer"], $sql['ARG']); $duplicates = mysqli_fetch_all($duplicates, MYSQLI_ASSOC); - $criteria = match ($protectedPost['detail']) { - "hostname_serial" => 'name', - "hostname_macaddress", "macaddress_serial" => 'macaddr', - "hostname" => 'name', - "ssn" => 'ssn', - "macaddress" => 'macaddr', - }; + // grouping of duplicates is conditional + switch($protectedPost['detail']) { + case "hostname_serial": $criteria = 'name'; break; + case "hostname_macaddress": $criteria = 'macaddr'; break; + case "macaddress_serial": $criteria = 'macaddr'; break; + case "hostname": $criteria = 'name'; break; + case "ssn": $criteria = 'ssn'; break; + case "macaddress": $criteria = 'macaddr'; break; + } $grpDuplis = groupBy($criteria ?? '', $duplicates); $i = 0; // iterate through each group of duplicates to build collapsible diff --git a/plugins/main_sections/ms_teledeploy/views/package_form_view.php b/plugins/main_sections/ms_teledeploy/views/package_form_view.php index 7308d5ca4..0512f330f 100755 --- a/plugins/main_sections/ms_teledeploy/views/package_form_view.php +++ b/plugins/main_sections/ms_teledeploy/views/package_form_view.php @@ -138,12 +138,20 @@ function show_basic_info_frame($data, $errors) { ), )); - $action_input_label = match ($data['ACTION']) { - 'EXECUTE' => $l->g(444), - 'STORE' => $l->g(445), - 'LAUNCH' => $l->g(446), - default => '', - }; + switch ($data['ACTION']) { + case 'EXECUTE': + $action_input_label = $l->g(444); + break; + case 'STORE': + $action_input_label = $l->g(445); + break; + case 'LAUNCH': + $action_input_label = $l->g(446); + break; + default: + $action_input_label = ''; + break; + } show_form_field($data, $errors, 'input', 'ACTION_INPUT', $action_input_label); echo ''; From ab0c6d99a8cfc830eecb75d57d1b240b9441a893 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Thu, 23 Jun 2022 14:50:59 +0200 Subject: [PATCH 182/187] Remove all var_dump --- plugins/main_sections/ms_config/ms_blacklist.php | 1 - plugins/main_sections/ms_ipdiscover/ms_custom_info.php | 1 - plugins/main_sections/ms_multi_search/ms_custom_tag.php | 1 - plugins/main_sections/ms_teledeploy/ms_tele_popup_active.php | 1 - require/search/Search.php | 1 - 5 files changed, 5 deletions(-) diff --git a/plugins/main_sections/ms_config/ms_blacklist.php b/plugins/main_sections/ms_config/ms_blacklist.php index 948d9da3e..8abbfc438 100755 --- a/plugins/main_sections/ms_config/ms_blacklist.php +++ b/plugins/main_sections/ms_config/ms_blacklist.php @@ -126,7 +126,6 @@ if ($protectedPost['BLACK_CHOICE'] == 1) { // 6 cases POST BASE_NAME VALUE PER FIELD SIZE SEPARATOR : JS - //var_dump($MACnb_field, $protectedPost, $MACfield_name, $MACnb_value_by_field, $MACsize, $MACseparat, $javascript_mac); ?>
      diff --git a/plugins/main_sections/ms_ipdiscover/ms_custom_info.php b/plugins/main_sections/ms_ipdiscover/ms_custom_info.php index 5b3723c49..b8840b764 100644 --- a/plugins/main_sections/ms_ipdiscover/ms_custom_info.php +++ b/plugins/main_sections/ms_ipdiscover/ms_custom_info.php @@ -49,7 +49,6 @@ if ($protectedGet['prov'] == "ident") { //dismiss manufacturer name and mac to be able to remove it properly. $exploded_data = explode(' ', $protectedPost['SUP_PROF']); - //var_dump($exploded_data); $protectedPost['SUP_PROF'] = $exploded_data[0]; } diff --git a/plugins/main_sections/ms_multi_search/ms_custom_tag.php b/plugins/main_sections/ms_multi_search/ms_custom_tag.php index 8076d0a07..97ff2ef72 100644 --- a/plugins/main_sections/ms_multi_search/ms_custom_tag.php +++ b/plugins/main_sections/ms_multi_search/ms_custom_tag.php @@ -31,7 +31,6 @@ echo "
      "; $list_id = multi_lot($form_name, $l->g(601)); -var_dump($list_id); if (is_defined($list_id)) { echo "
      "; diff --git a/plugins/main_sections/ms_teledeploy/ms_tele_popup_active.php b/plugins/main_sections/ms_teledeploy/ms_tele_popup_active.php index 7b452518c..4aae26ea6 100755 --- a/plugins/main_sections/ms_teledeploy/ms_tele_popup_active.php +++ b/plugins/main_sections/ms_teledeploy/ms_tele_popup_active.php @@ -74,7 +74,6 @@ } } - //var_dump($tab_typ_champ); //fermeture du formulaire. echo close_form(); } else { diff --git a/require/search/Search.php b/require/search/Search.php index b72bc14b5..a6428e241 100644 --- a/require/search/Search.php +++ b/require/search/Search.php @@ -369,7 +369,6 @@ public function generateSearchQuery($sessData){ if($nameTable == SoftwareSearch::SOFTWARE_TABLE) { $nameTable = $this->softwareSearch->getTableName($value['fields']); $value[self::SESS_FIELDS] = $this->softwareSearch->getColumnName($value['fields']); - //var_dump() } foreach(array_count_values($columnName) as $name => $nb){ From ca43b2b100f2e648cdfb8f992029a064bb367d8c Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Thu, 23 Jun 2022 14:53:24 +0200 Subject: [PATCH 183/187] Fix warning on download computer details xml --- .../main_sections/ms_export/ms_export_ocs.php | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/main_sections/ms_export/ms_export_ocs.php b/plugins/main_sections/ms_export/ms_export_ocs.php index 32cb8746a..ecb830fad 100755 --- a/plugins/main_sections/ms_export/ms_export_ocs.php +++ b/plugins/main_sections/ms_export/ms_export_ocs.php @@ -43,20 +43,22 @@ $arg = array($tablename, $protectedGet['systemid']); $res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); - while ($item = mysqli_fetch_object($res)) { - $xml .= "\t\t<" . mb_strtoupper($tablename) . ">\n"; - foreach ($_SESSION['OCS']['SQL_TABLE'][$tablename] as $field_name => $field_type) { - if ($field_name != 'HARDWARE_ID') { - if (replace_entity_xml($item->$field_name) != '') { - $xml .= "\t\t\t<" . $field_name . ">"; - $xml .= replace_entity_xml($item->$field_name); - $xml .= "\n"; - } else { - $xml .= "\t\t\t<" . $field_name . " />\n"; + if($res) { + while ($item = mysqli_fetch_object($res)) { + $xml .= "\t\t<" . mb_strtoupper($tablename) . ">\n"; + foreach ($_SESSION['OCS']['SQL_TABLE'][$tablename] as $field_name => $field_type) { + if ($field_name != 'HARDWARE_ID') { + if (replace_entity_xml($item->$field_name) != '') { + $xml .= "\t\t\t<" . $field_name . ">"; + $xml .= replace_entity_xml($item->$field_name); + $xml .= "\n"; + } else { + $xml .= "\t\t\t<" . $field_name . " />\n"; + } } } + $xml .= "\t\t\n"; } - $xml .= "\t\t\n"; } } } From bbff88cde0c6fa8b106bff8205a4147ac3a4403a Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Fri, 24 Jun 2022 10:04:34 +0200 Subject: [PATCH 184/187] Fix warning on SNMP configuration in PHP8 --- plugins/language/en_GB/en_GB.txt | 1 + plugins/language/fr_FR/fr_FR.txt | 1 + .../ms_config/ms_snmp_config.php | 8 +++- require/commandLine/CommandLine.php | 2 +- require/snmp/Snmp.php | 42 +++++++++++-------- 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/plugins/language/en_GB/en_GB.txt b/plugins/language/en_GB/en_GB.txt index aa89dfb9f..a823e3714 100755 --- a/plugins/language/en_GB/en_GB.txt +++ b/plugins/language/en_GB/en_GB.txt @@ -1715,6 +1715,7 @@ 9033 Authentication Protocol 9034 Privacy Protocol 9035 Privacy Password +9036 No OID found 9100 SSL key path 9101 SSL certificat path diff --git a/plugins/language/fr_FR/fr_FR.txt b/plugins/language/fr_FR/fr_FR.txt index 75f05089b..bf903d695 100644 --- a/plugins/language/fr_FR/fr_FR.txt +++ b/plugins/language/fr_FR/fr_FR.txt @@ -1710,6 +1710,7 @@ 9033 Protocole d'authentification 9034 Protocole de confidentialité 9035 Mot de passe de confidentialité +9036 Aucun OID trouvé 9100 Chemin de la clé SSL 9101 Chemin du certificat SSL diff --git a/plugins/main_sections/ms_config/ms_snmp_config.php b/plugins/main_sections/ms_config/ms_snmp_config.php index a11c41f0a..eed1f92ce 100644 --- a/plugins/main_sections/ms_config/ms_snmp_config.php +++ b/plugins/main_sections/ms_config/ms_snmp_config.php @@ -347,8 +347,12 @@ if(isset($protectedPost['update_snmp'])) { $result_oids = $command->get_mib_oid($protectedPost['mib_file'] ?? ''); - - $protectedPost['select_mib'] = true; + if(!empty($result_oids)) { + $protectedPost['select_mib'] = true; + } else { + msg_error($l->g(9036)); + } + unset($protectedPost['update_snmp']); } diff --git a/require/commandLine/CommandLine.php b/require/commandLine/CommandLine.php index e521a4d9b..ad73782a2 100644 --- a/require/commandLine/CommandLine.php +++ b/require/commandLine/CommandLine.php @@ -38,7 +38,7 @@ public function get_mib_oid($file) { foreach ($result_cmd as $oid) { $split = preg_split('/\t/', $oid, null, PREG_SPLIT_NO_EMPTY); - if($split[0] != "") { + if(isset($split[0]) && $split[0] != "") { $oids[$split[0]] = $split[1]; } } diff --git a/require/snmp/Snmp.php b/require/snmp/Snmp.php index 807f54b22..961618660 100644 --- a/require/snmp/Snmp.php +++ b/require/snmp/Snmp.php @@ -399,10 +399,14 @@ private function get_table_type_drop($id){ private function get_config($labelID){ $sql = "SELECT DISTINCT `TYPE_ID` FROM `snmp_configs` WHERE `LABEL_ID` = %s"; $arg = array($labelID); + $type = []; $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); - while ($item = mysqli_fetch_array($result)) { - $type[] = $item['TYPE_ID']; + + if($result) { + while ($item = mysqli_fetch_array($result)) { + $type[] = $item['TYPE_ID']; + } } return $type; @@ -452,12 +456,15 @@ public function delete_config($id){ public function get_mib() { $champs = array('SNMP_MIB_DIRECTORY' => 'SNMP_MIB_DIRECTORY'); $values = look_config_default_values($champs); + $mib_name = []; - $mib_files = glob($values['tvalue']['SNMP_MIB_DIRECTORY'].'/*', GLOB_BRACE); - $mib_files = str_replace($values['tvalue']['SNMP_MIB_DIRECTORY']."/", "", $mib_files); - - foreach($mib_files as $mib) { - $mib_name[$mib] = $mib; + if(!empty($values['tvalue']['SNMP_MIB_DIRECTORY'])) { + $mib_files = glob($values['tvalue']['SNMP_MIB_DIRECTORY'].'/*', GLOB_BRACE); + $mib_files = str_replace($values['tvalue']['SNMP_MIB_DIRECTORY']."/", "", $mib_files); + + foreach($mib_files as $mib) { + $mib_name[$mib] = $mib; + } } return $mib_name; @@ -471,22 +478,23 @@ public function sort_mib($post) { if(strpos($key, "checkbox_") !== false) { $mib_check = explode("_", $key); } - - if($key == "label_".$mib_check[1]) { - $config[$mib_check[1]]['label'] = $value; - } - if($key == "oid_".$mib_check[1]) { - $config[$mib_check[1]]['oid'] = $value; - } - if($key == "reconciliation_".$mib_check[1]) { - $config[$mib_check[1]]['reconciliation'] = $value; + if(!empty($mib_check)) { + if($key == "label_".$mib_check[1]) { + $config[$mib_check[1]]['label'] = $value; + } + if($key == "oid_".$mib_check[1]) { + $config[$mib_check[1]]['oid'] = $value; + } + if($key == "reconciliation_".$mib_check[1]) { + $config[$mib_check[1]]['reconciliation'] = $value; + } } } if(!empty($config)) { foreach($config as $key => $value) { if($config[$key]['label'] != null && $config[$key]['oid'] != null) { - $result = $this->snmp_config($post['type_id'], $config[$key]['label'], $config[$key]['oid'], $config[$key]['reconciliation']); + $result = $this->snmp_config($post['type_id'], $config[$key]['label'], $config[$key]['oid'], $config[$key]['reconciliation'] ?? null); if($result != 0) { return false; From 1b9f3d71bc5c9b1333b886989af2194c407c3b92 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Fri, 24 Jun 2022 10:32:54 +0200 Subject: [PATCH 185/187] Fix warning php8 --- require/mail/NotificationMail.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/require/mail/NotificationMail.php b/require/mail/NotificationMail.php index 10e0db1f6..ce16a509a 100644 --- a/require/mail/NotificationMail.php +++ b/require/mail/NotificationMail.php @@ -254,7 +254,9 @@ public function replace_value($file, $selected){ if(strpos($replace, "g") !== false){ $traduction = explode(".", $replace); $pattern[] = $replace; - $replacement[] = $l->g($traduction[1]); + if(isset($traduction[1])) { + $replacement[] = $l->g($traduction[1]); + } }elseif($replace == 'Report.Asset'){ $pattern[] = $replace; $asset->get_assets(); From 91c0125fcadc02f7d51bd75522557ce430419696 Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Fri, 24 Jun 2022 10:53:49 +0200 Subject: [PATCH 186/187] Fix warning in php8 --- plugins/main_sections/ms_admininfo/ms_admininfo.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/main_sections/ms_admininfo/ms_admininfo.php b/plugins/main_sections/ms_admininfo/ms_admininfo.php index 18f1e31ef..967c8ba07 100644 --- a/plugins/main_sections/ms_admininfo/ms_admininfo.php +++ b/plugins/main_sections/ms_admininfo/ms_admininfo.php @@ -552,6 +552,8 @@ function logCSVErrors($lvl) { // req to retrieve hardware id $sql_h_id = "SELECT %s FROM %s WHERE %s = '%s'"; $i = 0; + $success = null; + while ($line = $csvObj->readCSVLine()) { $i++; // first line means header @@ -601,7 +603,7 @@ function logCSVErrors($lvl) { $delete_csv = $csvObj->deleteCSV($protectedPost['csv_filename']); echo "


      "; - if ($success != '') { + if (!is_null($success)) { msg_info($l->g(9605)); } foreach ($errors as $key => $error) { From a77bf58ac6b603c0c195fffb1b814aec4d0aef1c Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Fri, 24 Jun 2022 10:57:05 +0200 Subject: [PATCH 187/187] Fix warning php8 --- require/ipdiscover/Ipdiscover.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/ipdiscover/Ipdiscover.php b/require/ipdiscover/Ipdiscover.php index b1514aa61..46752e460 100644 --- a/require/ipdiscover/Ipdiscover.php +++ b/require/ipdiscover/Ipdiscover.php @@ -110,7 +110,7 @@ public function form_add_subnet($title = '', $default_value, $form, $is_tag_link foreach ($tab_typ_champ as $id => $values) { $tab_typ_champ[$id]['CONFIG']['SIZE'] = 30; if($tab_typ_champ[$id]["INPUT_TYPE"] == 2) { - $tab_typ_champ[$id]['CONFIG']['SELECTED_VALUE'] = $post[$tab_typ_champ[$id]['INPUT_NAME']]; + $tab_typ_champ[$id]['CONFIG']['SELECTED_VALUE'] = $post[$tab_typ_champ[$id]['INPUT_NAME']] ?? ''; } }