Skip to content

Commit 2ea0ffa

Browse files
Merge pull request #1386 from OCSInventory-NG/compat_php8
Add PHP8 compatibility and Update version to 2.10
2 parents 2bbeced + a77bf58 commit 2ea0ffa

File tree

180 files changed

+1471
-1650
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+1471
-1650
lines changed

Changes

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
Revision history for ocsreports
2+
2.10.0
3+
* Add PHP8 compatibility
4+
* Add layout feature
5+
* Add archive/restore actions to GUI LOGS
6+
* Add CAS connection feature
7+
* Add custom interval configuration to Last Contact in dashboard
8+
* Add plugin deployment for unix systems
9+
* Add configuration to exclude archive machines from the interface
10+
* Improve archive/restore feature
11+
* Improve LDAP connection feature
12+
* Improve Software category regex display
13+
* Update password encryption
14+
* Fix subnets loading taking to much time on login
15+
* Fix activate package display for every language
16+
* Fix archive/restore action
17+
* Fix multisearch query if IS NULL operator
18+
* Fix software category deletion
19+
* Fix SNMP read mib files
20+
* Fix save search group for LDAP and CAS users
21+
* Fix rights on actions column
22+
* Fix CVE 2021-46355
23+
* Fix IpDiscover export
24+
* Fix IpDiscover bugs
25+
* Fix blank page after create networks type
26+
* Remove overriding of profile rights on extensions pages
27+
228
2.9.2
329
* Add archive button on computer details page
430
* Add local import

ajax/calendarfield.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
* Copyright 2005-2019 OCSInventory-NG/OCSInventory-ocsreports contributors.
45
* See the Contributors file for more details about them.
@@ -22,23 +23,18 @@
2223
*/
2324
require_once('../require/function_commun.php');
2425
require_once('../var.php');
25-
2626
if(isset($_GET['fieldid'])){
2727
$html = get_html($_GET['fieldid']);
2828
echo $html;
2929
}
30-
31-
3230
function get_html($fieldId) {
3331
global $l;
34-
$fieldId = htmlspecialchars($fieldId, ENT_QUOTES, 'UTF-8');
35-
$html = '<div class="input-group date form_datetime">
32+
$fieldId = htmlspecialchars($fieldId, ENT_QUOTES, 'UTF-8');
33+
34+
return '<div class="input-group date form_datetime">
3635
<input type="text" class="form-control" name="'.$fieldId.'" id="'.$fieldId.'" value=""/>
3736
<span class="input-group-addon">
3837
'.calendars($fieldId, $_SESSION['OCS']['DATE_FORMAT_LANG']).'
3938
</span>
40-
</div>';
41-
42-
return $html;
39+
</div>';
4340
}
44-
?>

backend/AUTH/auth.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
// You don't have to change these variables anymore, see var.php
3939
$affich_method = get_affiche_methode();
4040
$list_methode = get_list_methode();
41+
$limitAttempt = false;
4142

4243
if ($affich_method == 'HTML' && isset($protectedPost['Valid_CNX']) && trim($protectedPost['LOGIN']) != "") {
4344
$login = $protectedPost['LOGIN'];
@@ -85,7 +86,7 @@
8586

8687
if (isset($login) && isset($mdp)) {
8788
$i = 0;
88-
while ($list_methode[$i]) {
89+
while (array_key_exists($i, $list_methode) && $list_methode[$i]) {
8990
require_once('methode/' . $list_methode[$i]);
9091
if ($login_successful == "OK")
9192
break;
@@ -94,7 +95,7 @@
9495
}
9596

9697
// login ok?
97-
if ($login_successful == "OK" && isset($login_successful) && !$limitAttempt) {
98+
if (isset($login_successful) && $login_successful == "OK" && !$limitAttempt) {
9899
$_SESSION['OCS']["loggeduser"] = $login;
99100
$_SESSION['OCS']['cnx_origine'] = $cnx_origine;
100101
$_SESSION['OCS']['user_group'] = $user_group;
@@ -166,7 +167,7 @@
166167
}
167168
} else {
168169
if ($auth['ivalue']['SECURITY_AUTHENTICATION_BLOCK_IP'] == 1){
169-
if ($login != ""){
170+
if (!empty($login)){
170171
$sql = "INSERT INTO auth_attempt (`DATETIMEATTEMPT`,`LOGIN`,`IP`,`SUCCESS`)
171172
VALUES ('%s','%s','%s','%s')";
172173
$datetime = new DateTime();
@@ -179,6 +180,9 @@
179180
if ($affich_method == 'HTML') {
180181
require_once (HEADER_HTML);
181182
if (isset($protectedPost['Valid_CNX'])) {
183+
if (empty($_SESSION['OCS']["loggeduser"])) {
184+
$login_successful = "No user provided";
185+
}
182186
msg_error($login_successful);
183187
flush();
184188
//you can't send a new login/passwd before 2 seconds
@@ -204,11 +208,11 @@
204208

205209
<div class="form-group">
206210
<label for="LOGIN"><?php echo $l->g(243); ?> :</label>
207-
<input type="text" class="form-control login-username-input" name="LOGIN" id="LOGIN" value='<?php echo preg_replace("/[^A-Za-z0-9-_\.]/", "", $protectedPost['LOGIN']); ?>' placeholder="<?php echo $l->g(243); ?>">
211+
<input type="text" class="form-control login-username-input" name="LOGIN" id="LOGIN" value='<?php echo preg_replace("/[^A-Za-z0-9-_\.]/", "", $protectedPost['LOGIN'] ?? ""); ?>' placeholder="<?php echo $l->g(243); ?>">
208212
</div>
209213
<div class="form-group">
210214
<label for="PASSWD"><?php echo $l->g(217); ?> :</label>
211-
<input type="password" class="form-control login-password-input" name="PASSWD" id="PASSWD" value='<?php echo preg_replace("/[^A-Za-z0-9-_\.]/", "", $protectedPost['PASSWD']); ?>' placeholder="<?php echo $l->g(217); ?>">
215+
<input type="password" class="form-control login-password-input" name="PASSWD" id="PASSWD" value='<?php echo preg_replace("/[^A-Za-z0-9-_\.]/", "", $protectedPost['PASSWD'] ?? ""); ?>' placeholder="<?php echo $l->g(217); ?>">
212216
</div>
213217

214218
<input type="submit" class="btn btn-lg btn-block btn-success login-btn" id="btn-logon" name="Valid_CNX" value="<?php echo $l->g(13); ?>" />

backend/AUTH/methode/ldap.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ function search_on_loginnt($login) {
107107
}
108108

109109
// save user fields in session
110-
$_SESSION['OCS']['details']['givenname'] = $info[0]['givenname'][0];
111-
$_SESSION['OCS']['details']['sn'] = $info[0]['sn'][0];
112-
$_SESSION['OCS']['details']['cn'] = $info[0]['cn'][0];
113-
$_SESSION['OCS']['details']['mail'] = $info[0]['mail'][0];
114-
$_SESSION['OCS']['details']['title'] = $info[0]['title'][0];
110+
$_SESSION['OCS']['details']['givenname'] = $info[0]['givenname'][0] ?? '';
111+
$_SESSION['OCS']['details']['sn'] = $info[0]['sn'][0] ?? '';
112+
$_SESSION['OCS']['details']['cn'] = $info[0]['cn'][0] ?? '';
113+
$_SESSION['OCS']['details']['mail'] = $info[0]['mail'][0] ?? '';
114+
$_SESSION['OCS']['details']['title'] = $info[0]['title'][0] ?? '';
115115

116116
return $info;
117117
}

backend/AUTH/methode/local.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
$resOp = mysql2_query_secure($reqOp, $_SESSION['OCS']["readServer"], $arg_reqOp);
2929
$rowOp = mysqli_fetch_object($resOp);
3030

31-
if ($rowOp->PASSWORD_VERSION === '0') {
31+
if (isset($rowOp->PASSWORD_VERSION) && $rowOp->PASSWORD_VERSION === '0') {
3232
$reqOp = "SELECT ID, USER_GROUP FROM operators WHERE ID='%s' and PASSWD ='%s'";
3333
$arg_reqOp = array($login, md5($protectedMdp));
3434

@@ -68,7 +68,7 @@
6868
}
6969
}
7070

71-
if ($login_status == true || hash(PASSWORD_CRYPT, $mdp) == $rowOp->PASSWD) {
71+
if ($login_status == true || (isset($rowOp->PASSWD) && hash(PASSWORD_CRYPT, $mdp) == $rowOp->PASSWD)) {
7272
$login_successful = "OK";
7373
$user_group = $rowOp->USER_GROUP;
7474
$type_log = 'CONNEXION';

backend/identity/identity.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
* Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
45
* See the Contributors file for more details about them.
@@ -22,14 +23,12 @@
2223
*/
2324
require_once(BACKEND . 'require/connexion.php');
2425
require_once(BACKEND . 'require/auth.manager.php');
25-
2626
// You don't have to change these variables anymore, see var.php
2727
$list_methode = get_list_methode(true);
28-
2928
if (!isset($_SESSION['OCS']["lvluser"])) {
3029
$i = 0;
3130
//methode pour le calcul des droits
32-
while ($list_methode[$i]) {
31+
while (isset($list_methode[$i]) && $list_methode[$i]) {
3332
require_once('methode/' . $list_methode[$i]);
3433
//on garde les erreurs présentes
3534
//entre chaque méthode
@@ -45,16 +44,15 @@
4544
$i++;
4645
}
4746
}
48-
4947
if (!isset($tab_tag) && $restriction != 'NO') {
5048
$LIST_ERROR = "";
51-
foreach ($tab_error as $script => $error) {
49+
foreach ($tab_error as $error) {
5250
$LIST_ERROR .= $error;
5351
addLog('ERROR_IDENTITY', $error);
5452
}
5553
$_SESSION['OCS']["mesmachines"] = "NOTAG";
5654
} elseif (isset($tab_tag)) {
57-
foreach ($list_methode as $prio => $script) {
55+
foreach ($list_methode as $script) {
5856
if (isset($tab_tag[$script])) {
5957
foreach ($tab_tag[$script] as $tag => $lbl) {
6058
$list_tag[$tag] = $tag;
@@ -71,7 +69,5 @@
7169
$_SESSION['OCS']["mytag"] = $lbl_list_tag;
7270
$_SESSION['OCS']['TAGS'] = $list_tag;
7371
}
74-
7572
if (isset($lvluser))
7673
$_SESSION['OCS']["lvluser"] = $lvluser;
77-
?>

backend/identity/methode/cas.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464

6565
$arg_insert = array($_SESSION['OCS']["loggeduser"],
6666
'Default',
67-
$_SESSION['OCS']['details']['sn'],
67+
$_SESSION['OCS']['details']['sn'] ?? '',
6868
"",
6969
"CAS",
7070
$defaultRole,
71-
$_SESSION['OCS']['details']['mail'],
71+
$_SESSION['OCS']['details']['mail'] ?? '',
7272
"NULL"
7373
);
7474
} else {
@@ -78,7 +78,7 @@
7878
WHERE ID='%s'";
7979

8080
$arg_insert = array(
81-
$_SESSION['OCS']['details']['mail'],
81+
$_SESSION['OCS']['details']['mail'] ?? '',
8282
$_SESSION['OCS']["loggeduser"]);
8383
}
8484
connexion_local_write();

backend/identity/methode/ldap.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
* Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
45
* See the Contributors file for more details about them.
@@ -53,23 +54,19 @@
5354
if ($_SESSION['OCS']['cnx_origine'] != "LDAP") {
5455
return false;
5556
}
56-
5757
require_once ('require/function_files.php');
5858
// page name
5959
$name = "ldap.php";
6060
connexion_local_read();
61-
6261
// select the main database
6362
mysqli_select_db($link_ocs, $db_ocs);
64-
6563
// retrieve LDAP-related config values into an array
6664
$sql = "select substr(NAME,7) as NAME,TVALUE from config where NAME like '%s'";
6765
$arg = array("%CONEX%");
6866
$res = mysql2_query_secure($sql, $link_ocs, $arg);
6967
while ($item = mysqli_fetch_object($res)) {
7068
$config[$item->NAME] = $item->TVALUE;
7169
}
72-
7370
// checks if the user already exists
7471
$reqOp = "SELECT new_accesslvl as accesslvl FROM operators WHERE id='%s'";
7572
$argOp = array($_SESSION['OCS']["loggeduser"]);
@@ -82,14 +79,13 @@
8279
if (isset($_SESSION['OCS']['details']["filter"])) {
8380
$defaultRole = $config[$_SESSION['OCS']['details']["filter"]];
8481
}
85-
8682
// uncomment this section for DEBUG
8783
// note: cannot use the global DEBUG variable because this happens before the toggle is available.
8884
/*
89-
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']."<br>");
90-
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']."<br>");
91-
echo ("user: ".$_SESSION['OCS']["loggeduser"]." will have level=".$defaultLevel." and role=".$defaultRole."<br>");
92-
*/
85+
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']."<br>");
86+
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']."<br>");
87+
echo ("user: ".$_SESSION['OCS']["loggeduser"]." will have level=".$defaultLevel." and role=".$defaultRole."<br>");
88+
*/
9389
//if defaultRole is define
9490
if (isset($defaultRole) && trim($defaultRole) != '') {
9591
// if it doesn't exist, create the user record

backend/identity/methode/local.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
* Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
45
* See the Contributors file for more details about them.
@@ -28,19 +29,16 @@
2829
* si une erreur est rencontrée, on retourne un code erreur
2930
*
3031
*/
31-
3232
require_once ('require/function_files.php');
3333
//nom de la page
3434
$name = "local.php";
3535
connexion_local_read();
3636
mysqli_select_db($link_ocs, $db_ocs);
37-
3837
//recherche du niveau de droit de l'utilisateur
3938
$reqOp = "SELECT new_accesslvl as accesslvl FROM operators WHERE id='%s'";
4039
$argOp = array($_SESSION['OCS']["loggeduser"]);
4140
$resOp = mysql2_query_secure($reqOp, $link_ocs, $argOp);
4241
$rowOp = mysqli_fetch_object($resOp);
43-
4442
if (isset($rowOp->accesslvl)) {
4543
$lvluser = $rowOp->accesslvl;
4644

@@ -95,4 +93,3 @@
9593
} else {
9694
$ERROR = $l->g(894);
9795
}
98-
?>

backend/ipdiscover/ipdiscover.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
* Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
45
* See the Contributors file for more details about them.
@@ -22,13 +23,11 @@
2223
*/
2324
require_once(BACKEND . 'require/connexion.php');
2425
require_once(BACKEND . 'require/auth.manager.php');
25-
2626
$list_methode = array(0 => "local.php");
27-
2827
if (!isset($_SESSION['OCS']["ipdiscover"])) {
2928
$i = 0;
3029
//methode pour le calcul des droits
31-
while ($list_methode[$i]) {
30+
while (isset($list_methode[$i]) == true) {
3231
require_once('methode/' . $list_methode[$i]);
3332
//on garde les droits de l'utilisateur sur l'ipdiscover
3433
if (isset($list_ip)) {
@@ -40,7 +39,7 @@
4039
}
4140
unset($list_ip);
4241
if (isset($tab_ip)) {
43-
foreach ($list_methode as $prio => $script) {
42+
foreach ($list_methode as $script) {
4443
if (isset($tab_ip[$script])) {
4544
foreach ($tab_ip[$script] as $ip => $lbl) {
4645
$list_ip[$ip] = $lbl;
@@ -58,4 +57,3 @@
5857
$_SESSION['OCS']["ipdiscover"] = $tab_info;
5958
$_SESSION['OCS']["ipdiscover_methode"] = $base;
6059
}
61-
?>

0 commit comments

Comments
 (0)