} } // $list_fields_account_info['Accinf: '.$lbl]="a." . $name_field_accountinfo; $Accinfo = $l->g(1210) . " " . $lbl; $list_fields_account_info[$Accinfo] = "a." . $name_field_accountinfo; } //si on ajoute un champ de recherche //on efface les données précedemment en cache if ($protectedPost['delfield'] != "" or $protectedPost['multiSearch'] != $l->g(32)) { unset($protectedPost['Valid-search']); unset($_SESSION['OCS']['ID_REQ']); unset($_SESSION['OCS']['DATA_CACHE'][$table_tabname]); } //cas d'une suppression de machine if ($protectedPost['SUP_PROF'] != '') { deleteDid($protectedPost['SUP_PROF']); //on force la valeur cachée de la validation du formulaire //pour rejouer la requete et ne pas utiliser le cache $protectedPost['Valid'] = "SUP"; } //for save field and value if ($protectedPost['Valid-search'] and $protectedPost['Valid'] != '') { foreach ($protectedPost as $key => $value) { $valeur = explode("-", $key); if ($valeur[0] == "InputValue" or $valeur[0] == "SelFieldValue" or $valeur[0] == "SelFieldValue3" or $valeur[0] == "SelAndOr" or $valeur[0] == "SelComp") { $_SESSION['OCS'][$key] = $value; } } } else { foreach ($_SESSION['OCS'] as $key => $value) { $valeur = explode("-", $key);
//==================================================================================== // OCS INVENTORY REPORTS // Copyleft Erwan GOALOU 2010 (erwan(at)ocsinventory-ng(pt)org) // Web: http://www.ocsinventory-ng.org // // This code is open source and may be copied and modified as long as the source // code is always made freely available. // Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt //==================================================================================== require_once 'require/function_search.php'; require_once 'require/function_computers.php'; PrintEnTete($l->g(985)); $form_name = "del_affect"; echo open_form($form_name); echo "<div align=center>"; $list_id = multi_lot($form_name, $l->g(601)); if ($protectedPost['SUP'] != '' and isset($protectedPost['SUP'])) { $array_id = explode(',', $list_id); //$i=0; foreach ($array_id as $key => $hardware_id) { deleteDid($hardware_id); //echo $hardware_id."<br>"; } } if ($list_id) { echo "<br><br><input type='submit' value=\"" . $l->g(122) . "\" name='SUP'>"; } echo "</div>"; //<input type=submit value='Supprimer TOUTES les machines?' name='delete'> echo close_form();
// FIND AND DELETE HARDWARE NOT UPDATED SINCE A VARIABLE NUMBER OF DAYS //==================================================================================== //Modified on $Date: 18-11-2010 09:59:31 $$Author: Steeve Govindapillai //Link: http://forums.ocsinventory-ng.org/viewtopic.php?id=2719 require 'dbconfig.inc.php'; define("DB_NAME", "ocsweb"); // Database name $_SESSION["SERVER_READ"] = $_SESSION["SERVEUR_SQL"]; $_SESSION["SERVER_WRITE"] = $_SESSION["SERVEUR_SQL"]; // Number of day since last hardware update to consider for deletion. $delay = 30; dbconnect(); $res = @mysql_query('SELECT ID FROM hardware where LASTDATE<=\'' . date('Y-m-d h:i:s', mktime() - $delay * 24 * 3600) . '\' ORDER BY LASTDATE', $_SESSION['readServer']); if (mysql_num_rows($res)) { while ($row = mysql_fetch_array($res)) { deleteDid($row['ID'], false, true); } } else { echo "no records deleted." . "\n"; } function dbconnect() { $db = DB_NAME; $link = mysql_connect($_SESSION["SERVER_READ"], $_SESSION["COMPTE_BASE"], $_SESSION["PSWD_BASE"]); if (!$link) { echo "ERROR: MySql connection problem" . mysql_error() . "\n"; die; } if (!mysql_select_db($db, $link)) { echo "Error executing SELECT\n"; die;
function fusionne($afus) { global $l; $i = 0; $maxStamp = 0; $minStamp = mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")); //demain foreach ($afus as $a) { $d = $a["lastcome"]; $a["stamp"] = mktime($d[11] . $d[12], $d[14] . $d[15], $d[17] . $d[18], $d[5] . $d[6], $d[8] . $d[9], $d[0] . $d[1] . $d[2] . $d[3]); //echo "stamp:".$a["stamp"]."== mktime($d[11]$d[12],$d[14]$d[15],$d[17]$d[18],$d[5]$d[6],$d[8]$d[9],$d[0]$d[1]$d[2]$d[3]);<br>"; if ($maxStamp < $a["stamp"]) { $maxStamp = $a["stamp"]; $maxInd = $i; } if ($minStamp > $a["stamp"]) { $minStamp = $a["stamp"]; $minInd = $i; } $i++; } if ($afus[$minInd]["deviceid"] != "") { $okLock = true; foreach ($afus as $a) { if (!($okLock = $okLock && lock($a["id"]))) { break; } else { $locked[] = $a["id"]; } } if ($okLock) { //TRACE_DELETED if (mysqli_num_rows(mysql2_query_secure("SELECT * FROM config WHERE IVALUE>0 AND NAME='TRACE_DELETED'", $_SESSION['OCS']["readServer"]))) { foreach ($afus as $a) { if ($afus[$maxInd]["deviceid"] == $a["deviceid"]) { continue; } $sql = "insert into deleted_equiv(DELETED,EQUIVALENT) values('%s','%s')"; $arg = array($a["deviceid"], $afus[$maxInd]["deviceid"]); mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); } } //KEEP OLD QUALITY,FIDELITY AND CHECKSUM $sql = "SELECT CHECKSUM,QUALITY,FIDELITY FROM hardware WHERE ID='%s'"; $persistent_req = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $afus[$minInd]["id"]); $reqDelAccount = "DELETE FROM accountinfo WHERE hardware_id='%s'"; mysql2_query_secure($reqDelAccount, $_SESSION['OCS']["writeServer"], $afus[$maxInd]["id"]); msg_success($l->g(190) . " " . $afus[$maxInd]["deviceid"] . " " . $l->g(191)); $keep = array("accountinfo", "devices", "groups_cache"); foreach ($keep as $tableToBeKept) { $reqRecupAccount = "UPDATE %s SET hardware_id='%s' WHERE hardware_id='%s'"; $argRecupAccount = array($tableToBeKept, $afus[$maxInd]["id"], $afus[$minInd]["id"]); mysql2_query_secure($reqRecupAccount, $_SESSION['OCS']["writeServer"], $argRecupAccount); } msg_success($l->g(190) . " " . $afus[$minInd]["deviceid"] . " " . $l->g(206) . " " . $afus[$maxInd]["deviceid"]); $i = 0; foreach ($afus as $a) { if ($i != $maxInd) { deleteDid($a["id"], false, false, false); $lesDel .= $a["deviceid"] . "/"; } $i++; } //RESTORE PERSISTENT VALUES $persistent_values = mysqli_fetch_row($persistent_req); $sql = "UPDATE hardware SET QUALITY=%s,FIDELITY=%s,CHECKSUM=CHECKSUM|%s WHERE id='%s'"; $arg = array($persistent_values[1], $persistent_values[2], $persistent_values[0], $afus[$maxInd]["id"]); mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); } else { errlock(); } foreach ($locked as $a) { unlock($a); } } $lesDel .= " => " . $afus[$maxInd]["deviceid"]; AddLog("FUSION", $lesDel); }
function delete_group($id_supp) { global $l; if ($id_supp == "") { return array('RESULT' => 'ERROR', 'LBL' => "ID IS NULL"); } if (!is_numeric($id_supp)) { return array('RESULT' => 'ERROR', 'LBL' => "ID IS NOT NUMERIC"); } $sql_verif_group = "select id from hardware where id=%s and DEVICEID='_SYSTEMGROUP_' or DEVICEID='_DOWNLOADGROUP_'"; $arg_verif_group = $id_supp; $res_verif_group = mysql2_query_secure($sql_verif_group, $_SESSION['OCS']["readServer"], $arg_verif_group); if ($val_verif_group = mysql_fetch_array($res_verif_group)) { deleteDid($arg_verif_group); addLog("DELETE GROUPE", $id_supp); return array('RESULT' => 'OK', 'LBL' => ''); } else { return array('RESULT' => 'ERROR', 'LBL' => $l->g(623)); } }