Skip to content

Commit 95a2282

Browse files
authored
Merge pull request #1534 from OCSInventory-NG/update-2.12
Update 2.12
2 parents f5ce869 + d5fd351 commit 95a2282

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

crontab/cron_clean_orphan.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/php
2+
<?php
3+
require_once(__DIR__.'/../var.php');
4+
require_once(CONF_MYSQL);
5+
require_once(ETC_DIR.'/require/function_commun.php');
6+
require_once(ETC_DIR.'/require/config/include.php');
7+
require_once(ETC_DIR.'/require/fichierConf.class.php');
8+
9+
$_SESSION['OCS']["writeServer"] = dbconnect(SERVER_WRITE, COMPTE_BASE, PSWD_BASE, DB_NAME, SSL_KEY, SSL_CERT, CA_CERT, SERVER_PORT);
10+
$_SESSION['OCS']["readServer"] = dbconnect(SERVER_READ, COMPTE_BASE, PSWD_BASE, DB_NAME, SSL_KEY, SSL_CERT, CA_CERT, SERVER_PORT);
11+
12+
$query = "SELECT CONCAT('DELETE FROM `',TABLE_NAME,'` WHERE HARDWARE_ID NOT IN (SELECT ID FROM hardware);') as deletequery, TABLE_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '%s' AND COLUMN_NAME='HARDWARE_ID';";
13+
$args = array(DB_NAME);
14+
15+
$queryList = mysql2_query_secure($query, $_SESSION['OCS']["readServer"], $args);
16+
17+
print("[".date("Y-m-d H:i:s"). "] Start to clean orphan HARDWARE_ID\n");
18+
19+
if($queryList) {
20+
foreach($queryList as $key => $values) {
21+
print("[".date("Y-m-d H:i:s"). "] Clean orphan HARDWARE_ID from ".$values["TABLE_NAME"]."\n");
22+
$countDeletetionRowQuery = "SELECT DISTINCT HARDWARE_ID FROM `%s` WHERE HARDWARE_ID NOT IN (SELECT ID FROM hardware)";
23+
$args = array($values["TABLE_NAME"]);
24+
$countDeletetionRow = mysql2_query_secure($countDeletetionRowQuery, $_SESSION['OCS']["readServer"], $args);
25+
26+
$deleteResult = mysql2_query_secure($values["deletequery"], $_SESSION['OCS']["writeServer"]);
27+
28+
if($deleteResult) print("[".date("Y-m-d H:i:s"). "] ".$countDeletetionRow->num_rows." orphan HARDWARE_ID have been deleted from ".$values["TABLE_NAME"]."\n");
29+
else print("[".date("Y-m-d H:i:s"). "] An error occurs when attempt to clean orphan HARDWARE_ID from ".$values["TABLE_NAME"]."\n");
30+
}
31+
}
32+
33+
print("[".date("Y-m-d H:i:s"). "] End of process\n");

plugins/main_sections/ms_snmp_inventory/ms_snmp_detail.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@
136136
if ((isset($temp_field[1]) && isset($info_account_id[$getType][$getId]) && (array_key_exists($temp_field[0] . '_' . $temp_field[1], $info_account_id[$getType][$getId]))) || $temp_field[0] == 'TAG') {
137137
//cas of checkbox
138138
if (isset($temp_field[2])) {
139-
$data_fields_account[$temp_field[0] . "_" . $temp_field[1]] .= $temp_field[2] . "&&&";
139+
$temp_field2 = $temp_field;
140+
unset($temp_field2[0]);
141+
unset($temp_field2[1]);
142+
$new_value = implode(' ', $temp_field2);
143+
$data_fields_account[$temp_field[0] . "_" . $temp_field[1]] .= $new_value . "&&&";
140144
} else {
141145
$data_fields_account[$field] = $value;
142146
}

var.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
/**
7979
* GUI Version
8080
*/
81-
define('GUI_VER_SHOW', '2.11.1');
81+
define('GUI_VER_SHOW', '2.12.0');
8282
/**
8383
* Default GUI language
8484
*/

0 commit comments

Comments
 (0)