[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <? 2 //==================================================================================== 3 // OCS INVENTORY REPORTS 4 // Copyleft Pierre LEMMET 2005 5 // Web: http://ocsinventory.sourceforge.net 6 // 7 // This code is open source and may be copied and modified as long as the source 8 // code is always made freely available. 9 // Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt 10 //==================================================================================== 11 //Modified on 11/25/2005 12 13 $filtreSSN=" 14 AND b.ssn <> 'N/A' 15 AND b.ssn <> '(null string)' 16 AND b.ssn <> '' 17 AND b.ssn <> 'INVALID' 18 AND b.ssn <> 'SYS-1234567890' 19 AND b.ssn <> 'SYS-9876543210' 20 AND b.ssn <> 'SN-12345' 21 AND b.ssn <> 'SN-1234567890' 22 AND b.ssn <> '1111111111' 23 AND b.ssn <> '1111111' 24 AND b.ssn <> '1' 25 AND b.ssn <> '0123456789' 26 AND b.ssn <> '12345' 27 AND b.ssn <> '123456' 28 AND b.ssn <> '1234567' 29 AND b.ssn <> '12345678' 30 AND b.ssn <> '123456789' 31 AND b.ssn <> '1234567890' 32 AND b.ssn <> '123456789000' 33 AND b.ssn <> '12345678901234567' 34 AND b.ssn <> '0000000000' 35 AND b.ssn <> '000000000' 36 AND b.ssn <> '00000000' 37 AND b.ssn <> '0000000' 38 AND b.ssn <> '000000' 39 AND b.ssn <> 'NNNNNNN' 40 AND b.ssn <> 'xxxxxxxxxxx' 41 AND b.ssn <> 'EVAL' 42 AND b.ssn <> 'IATPASS' 43 AND b.ssn <> 'none' 44 AND b.ssn <> 'To Be Filled By O.E.M.' 45 AND b.ssn <> 'Tulip Computers' 46 AND b.ssn <> 'Serial Number xxxxxx' 47 AND b.ssn <> 'SN-123456fvgv3i0b8o5n6n7k'"; 48 49 $filtreMAC=" 50 AND n1.macaddr <> '44:45:53:54:00:00' 51 AND n1.macaddr <> '44:45:53:54:00:01' 52 AND n1.macaddr <> '00:00:00:00:00:00'"; 53 54 $fromBase="hardware h LEFT JOIN accountinfo a ON a.hardware_id = h.id LEFT JOIN bios b ON b.hardware_id = h.id LEFT OUTER JOIN networks n1 on b.hardware_id=n1.hardware_id"; 55 $whereBase="n1.hardware_id = h.id "; 56 if( $mesMachines ) { 57 $whereBase .= "AND $mesMachines"; 58 } 59 $from = array(); 60 $where = array(); 61 $group = array(); 62 $order = array(); 63 // hostname seul 64 $from[4] = "hardware h2"; 65 $where[4] = " $whereBase AND h.name = h2.name AND h.id <> h2.id"; 66 $group[4] = "h.id"; 67 $order[4] = "h.name"; 68 69 // ssn seul 70 $from[5] = "hardware h2, bios b2"; 71 $where[5] = "$whereBase AND b2.hardware_id = h2.id AND b2.ssn = b.ssn AND h.id <> h2.id $filtreSSN"; 72 $group[5] = "h.id"; 73 $order[5] = "b.ssn"; 74 75 //mac seule 76 $from[6] = "hardware h2, networks n2"; 77 $where[6] = " $whereBase AND n2.hardware_id = h2.id AND n2.macaddr = n1.macaddr AND h.id <> h2.id $filtreMAC"; 78 $group[6] = "h.id"; 79 $order[6] = "n1.macaddr"; 80 81 // hostname + ssn 82 $from[1] = "hardware h2, bios b2"; 83 $where[1] = " $whereBase AND b2.hardware_id = h2.id AND h.name=h2.name AND b2.ssn = b.ssn AND h.id <> h2.id $filtreSSN"; 84 $group[1] = "h.id"; 85 $order[1] = "h.name,b.ssn"; 86 87 // hostname + mac 88 $from[2] = "hardware h2, networks n2"; 89 $where[2] = " $whereBase AND n2.hardware_id = h2.id AND h.name = h2.name AND n2.macaddr = n1.macaddr AND h.id <> h2.id $filtreMAC"; 90 $group[2] = "h.id"; 91 $order[2] = "h.name,b.ssn"; 92 93 // mac + ssn 94 $from[3] = "networks n2, bios b2"; 95 $where[3] = " $whereBase AND b2.hardware_id = n2.hardware_id AND b2.hardware_id <> b.hardware_id AND n1.macaddr = n2.macaddr AND b2.ssn = b.ssn $filtreSSN $filtreMAC"; 96 $group[3] = "h.id"; 97 $order[3] = "n1.macaddr,b.ssn"; 98 99 if(isset($_POST["subredon"])) { 100 for( $i = 1 ; $i <= $_POST["maxredon"] ; $i++) { 101 if(! isset($_POST["ch".$i])) 102 continue; 103 104 $res = mysql_query("SELECT deviceid,id,lastcome FROM hardware WHERE id=".$_POST["ch".$i], $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); 105 $afus[] = mysql_fetch_array($res,MYSQL_ASSOC); 106 } 107 108 if(sizeof($afus)<2) { 109 echo "<center><font color=red>".$l->g(189)."</font></center>"; 110 } 111 else { 112 fusionne($afus); 113 } 114 } 115 116 117 118 if($_SESSION["typ"]&&!isset($_POST["typ"])) { 119 $_POST["typ"] = $_SESSION["typ"]; 120 } 121 122 if( !isset($_POST["typ"])) { 123 $_POST["typ"] = $l->g(192) ; 124 } 125 126 if(isset($_POST["typ"]) && $_POST["typ"]!=$l->g(192)) { 127 128 $_SESSION["typ"] = $_POST["typ"]; 129 130 switch($_POST["typ"]) { 131 case $l->g(194): $ind = 2 ; break ; 132 case $l->g(195): $ind = 3 ; break ; 133 case $l->g(196): $ind = 4 ; break; 134 case $l->g(197): $ind = 5 ; break ; 135 case $l->g(198): $ind = 6 ; break ; 136 /*case $l->g(193)*/ 137 default : $ind = 1 ; break ; 138 } 139 140 $rq_sql = $where[$ind]; 141 $rq_whereId = "h.id"; 142 $rq_linkId = "h.id"; 143 $rq_select = array_merge( array("h.id"=>"h.id", "deviceid"=>"deviceid","n1.macaddr"=>$l->g(95),"b.ssn"=>$l->g(36)), 144 $_SESSION["currentFieldList"] ); 145 146 //$select = array_merge( array("h.id"=>"h.id" ,"deviceid"=>"deviceid", "a.".TAG_NAME=>TAG_LBL), $_SESSION["currentFieldList"] ); 147 $rq_selectPrelim = array( "h.id"=>"h.id" ); 148 $rq_from = $fromBase; 149 $rq_fromPrelim = $from[$ind]; 150 $rq_group = $group[$ind]; 151 $rq_order = $order[$ind]; 152 $rq_countId = "h.id"; 153 } 154 155 echo "<table width=100%><tr align=right><td><form name='formtyp' action='index.php?multi=6' method='POST'> 156 <select name='typ' OnChange='formtyp.submit();'>"; 157 echo " <option".($_POST["typ"]==$l->g(32)?" selected":"").">".$l->g(32).":</option> 158 <option".($_POST["typ"]==$l->g(192)?" selected":"").">".$l->g(192)."</option> 159 <option".($_POST["typ"]==$l->g(193)?" selected":"").">".$l->g(193)."</option> 160 <option".($_POST["typ"]==$l->g(194)?" selected":"").">".$l->g(194)."</option> 161 <option".($_POST["typ"]==$l->g(195)?" selected":"").">".$l->g(195)."</option> 162 <option".($_POST["typ"]==$l->g(196)?" selected":"").">".$l->g(196)."</option> 163 <option".($_POST["typ"]==$l->g(197)?" selected":"").">".$l->g(197)."</option> 164 <option".($_POST["typ"]==$l->g(198)?" selected":"").">".$l->g(198)."</option> 165 </select> 166 </form></td></tr></table>"; 167 168 printEnTete($l->g(199)); 169 170 if($_POST["typ"]!=$l->g(192)) { 171 $req=new Req("Doubles",$rq_whereId,$rq_linkId,$rq_sql,$rq_select,$rq_selectPrelim,$rq_from,$rq_fromPrelim,$rq_group,$rq_order,$rq_countId,true); 172 ShowResults($req,true,false,true,true,false); 173 } 174 else { 175 echo "<br><table BORDER='0' WIDTH = '25%' ALIGN = 'Center' CELLPADDING='0' BGCOLOR='#C7D9F5' BORDERCOLOR='#9894B5'>"; 176 for($j=1;$j<=6;$j++) { 177 178 $rrqs = "SELECT COUNT(DISTINCT h.id) FROM ".$fromBase.",".$from[$j]." WHERE ".$where[$j]; 179 $rres = mysql_query( $rrqs, $_SESSION["readServer"]); 180 181 $valr = mysql_fetch_row($rres); 182 echo "<tr><td align='center'>"; 183 //if ( $valr[0] > 0 ) { 184 switch($j) { 185 case 1: echo $l->g(193); break ; 186 case 2: echo $l->g(194); break ; 187 case 3: echo $l->g(195); break ; 188 case 4: echo $l->g(196); break ; 189 case 5: echo $l->g(197); break ; 190 case 6: echo $l->g(198); break ; 191 } 192 echo ": <b>".$valr[0]."</b></td></tr>"; 193 //} 194 195 } 196 echo "</table><br>"; 197 } 198 199 function fusionne($afus) { 200 201 global $l; 202 $i=0; 203 $maxStamp = 0; 204 $minStamp = mktime(0,0,0,date("m"),date("d") + 1,date("Y")); //demain 205 foreach($afus as $a) { 206 $d = $a["lastcome"]; 207 $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]); 208 //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>"; 209 if($maxStamp<$a["stamp"]) { 210 $maxStamp = $a["stamp"]; 211 $maxInd = $i; 212 } 213 if($minStamp>$a["stamp"]) { 214 $minStamp = $a["stamp"]; 215 $minInd = $i; 216 } 217 $i++; 218 } 219 if($afus[$minInd]["deviceid"]!="") { 220 $okLock = true; 221 foreach($afus as $a) { 222 if( ! $okLock = ($okLock && lock($a["id"])) ) 223 break; 224 else 225 $locked[] = $a["id"]; 226 } 227 228 if( $okLock ) { 229 //TRACE_DELETED 230 if(mysql_num_rows(mysql_query("SELECT * FROM config WHERE IVALUE>0 AND NAME='TRACE_DELETED'", $_SESSION["writeServer"]))){ 231 foreach($afus as $a) { 232 if($afus[$maxInd]["deviceid"]==$a["deviceid"]){continue;} 233 mysql_query("insert into deleted_equiv(DELETED,EQUIVALENT) values('".$a["deviceid"]."','".$afus[$maxInd]["deviceid"]."')", $_SESSION["writeServer"]) ; 234 } 235 } 236 237 //KEEP OLD QUALITY,FIDELITY AND CHECKSUM 238 $persistent_req = mysql_query("SELECT CHECKSUM,QUALITY,FIDELITY FROM hardware WHERE ID=".$afus[$minInd]["id"]) ; 239 240 $reqDelAccount = "DELETE FROM accountinfo WHERE hardware_id=".$afus[$maxInd]["id"]; 241 mysql_query($reqDelAccount, $_SESSION["writeServer"]) ; 242 echo "<center><font color=green>".$l->g(190)." ".$afus[$maxInd]["deviceid"]." ".$l->g(191)."</font></center>"; 243 $reqRecupAccount = "UPDATE accountinfo SET hardware_id=".$afus[$maxInd]["id"]." WHERE hardware_id=".$afus[$minInd]["id"]; 244 245 mysql_query($reqRecupAccount, $_SESSION["writeServer"]) ; 246 //echo $reqRecupAccount; 247 echo "<center><font color=green>".$l->g(190)." ".$afus[$minInd]["deviceid"]." ".$l->g(206)." ".$afus[$maxInd]["deviceid"]."</font></center><br>"; 248 $i=0; 249 foreach($afus as $a) { 250 if($i != $maxInd) { 251 deleteDid($a["id"], false, false); 252 } 253 $i++; 254 } 255 256 //RESTORE PERSISTENT VALUES 257 $persistent_values = mysql_fetch_row($persistent_req); 258 mysql_query("UPDATE hardware SET QUALITY=".$persistent_values[1].",FIDELITY=".$persistent_values[2].",CHECKSUM=CHECKSUM|".$persistent_values[0]." WHERE id=".$afus[$maxInd]["id"]) ; 259 260 } 261 else 262 errlock(); 263 264 foreach($locked as $a) { 265 unlock($a); 266 } 267 } 268 } 269 270 271 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |