$val) { if( ($fin = stristr ($key, "inputncat_")) && $val != "") { $valName = substr( fromName(stripslashes($fin)), strlen("inputncat_")); addSoft( $val, $valName); }} */ $_GET["cat"] = isset($_GET["cat"]) ? $_GET["cat"] : (isset($_POST["alleracat"]) ? $_POST["alleracat"] : null ) ; if( isset($_GET["cat"]) ) { if( isset($_GET["search"]) && $_GET["search"] != "" ) { $condG = " name LIKE '%".$_GET["search"]."%' AND"; $condO = " extracted LIKE '%".$_GET["search"]."%' AND"; } $order = isset($_GET["order"])&&$_GET["order"]!="" ? $_GET["order"] : 1 ; $laCat = stripslashes(fromName($_GET["cat"])); if($laCat == "NEW") $sens = $order != 1 ? "ASC" : "DESC"; else $sens = "ASC"; if($laCat == "NEW") { if(! isset($_GET["order"])) $sens = "DESC"; $reqLog = "SELECT COUNT(hardware_id) as 'nbdef',name as 'extracted' FROM softwares WHERE{$condG} name NOT IN (SELECT DISTINCT(extracted) FROM dico_soft) AND name NOT IN (SELECT DISTINCT(extracted) FROM dico_ignored) GROUP BY name ORDER BY $order $sens"; $reqCount = "SELECT COUNT(DISTINCT(name)) as 'nb' FROM softwares WHERE{$condG} name NOT IN (SELECT DISTINCT(extracted) FROM dico_soft) AND name NOT IN (SELECT DISTINCT(extracted) FROM dico_ignored)"; } else if($laCat == "IGNORED") { $reqLog = "SELECT s.extracted FROM dico_ignored s WHERE{$condO} 1=1 ORDER BY $order $sens "; $reqCount = "SELECT COUNT(s.extracted) as 'nb' FROM dico_ignored s WHERE{$condO} 1=1"; } else if($laCat == "UNCHANGED") { $reqLog = "SELECT s.extracted FROM dico_soft s WHERE{$condO} extracted=formatted ORDER BY $order $sens"; $reqCount = "SELECT COUNT(s.extracted) as 'nb' FROM dico_soft s WHERE{$condO} extracted=formatted"; } else { $reqLog = "SELECT s.extracted FROM dico_soft s WHERE{$condO} s.formatted='$laCat' ORDER BY $order $sens"; $reqCount = "SELECT COUNT(s.extracted) as 'nb' FROM dico_soft s WHERE{$condO} s.formatted='$laCat'"; } //echo $reqLog; } else if( isset($_GET["all"]) && $_GET["search"]!="" ) { $reqLog = "SELECT distinct(name) as 'extracted' FROM softwares WHERE name LIKE '%".$_GET["search"]."%' order by name asc"; $reqCount = "SELECT count( distinct name) as 'nb' FROM softwares WHERE name LIKE '%".$_GET["search"]."%' order by name asc"; } $lastCat = ""; if( isset($_POST["combocat"]) ) { if(isset($_POST["all"])) { $resAll = mysql_query($reqLog, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); while($valAll = mysql_fetch_array($resAll)) { $_POST[ urlencode($valAll["extracted"]) ] = "on"; } unset($_POST["all"]); } foreach($_POST as $key=>$val) { if($val == "on") { $key = addslashes(fromName($key)); if( isset($_POST["inputcat"]) && $_POST["inputcat"] != "" ) { addSoft( fromName($_POST["inputcat"]), $key); $lastCat = fromName($_POST["inputcat"]); } else { addSoft( fromName($_POST["combocat"]), $key); $lastCat = fromName($_POST["combocat"]); } } } } if( isset($reqLog) ) { $reqLog .= " LIMIT $rg,$pgSize"; } if( isset($_GET["delcat"]) ) { delCat( fromName($_GET["delcat"]) ); } ?>$gv) { if( $gk=="rev"|| $gk=="suppCol" || $gk == "logout" || $gk=="newcol" || $gk=="order") continue; if( $gk =="page" && ($gv==-1 || $gv==-2)) { $gv = $_SESSION["pageCur"]; } $hiddens .= "\n"; } $machNmb = array(5,10,15,20,50,100); $pcParPageHtml = "
$hiddens".$l->g(340).":
"; if( isset($_GET["cat"]) ) { $link = "multi=14&cat=".urlencode($_GET["cat"])."&search=".urlencode($_GET["search"]); $resCount = mysql_query($reqCount, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); $valCount = mysql_fetch_array($resCount); $printNbr = $valCount["nb"] == 0 ? "VIDE" : $valCount["nb"]; printEnTete("Catégorie $laCat ( $printNbr )"); echo "
$pcParPageHtml            <= ".$l->g(398)."

"; if( $valCount["nb"] > 0 ) { $resLog = mysql_query($reqLog, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); echo "
"; echo ""; echo ""; if( $laCat == "NEW" ) echo ""; echo ""; $ligne = 0; $optList = comboCat($laCat, $lastCat); while($log = mysql_fetch_array($resLog)) { $laLigne = array(utf8_decode($log["extracted"]),"" /*,""*/ ); if( $laCat == "NEW" ) $laLigne = array_merge( array($log["nbdef"]), $laLigne ); printLigne($laLigne, ($ligne%2 == 1 ? "#FFFFFF" : "#F2F2F2")); $ligne++; } echo ""; //if( $laCat == "NEW" ) echo ""; echo "
".$l->g(381)."".( $laCat=="NEW" ? "" : "" ).$l->g(382).( $laCat=="NEW" ? "" : "")." ".$l->g(383)."/".$l->g(389)."
  ".$l->g(384)."     ".$l->g(385).":   ".$l->g(386)." ".$l->g(387).": $optList
"; } echo "
"; echo ""; $maxPgeNumber = ceil($valCount["nb"]/$pgSize); if( $maxPgeNumber > 1 ){ echo ""; $link = " $valCount["nb"] ? $valCount["nb"] - $pgSize : $rg + $pgSize ; $last = $valCount["nb"] - $pgSize > 0 ? $valCount["nb"] - $pgSize : 0 ; $linkMin = $rg == 0 ? "1.." : $link.$min."\">1.."; $linkPrev = $rg == 0 ? "" : $link.$prev."\">"; $linkNext = $rg >= $valCount["nb"] - $pgSize ? "" : $link.$next."\">"; $linkLast = $rg >= $valCount["nb"] - $pgSize ? "..$maxPgeNumber" : $link.$last."\">..$maxPgeNumber"; $current = ceil( $rg / $pgSize )+1; echo ""; if( $rg > 0 && $rg < $valCount["nb"] - $pgSize ) echo ""; echo ""; } else echo ""; echo "
"."
".$l->g(397).":" .comboCat( isset($_GET["cat"])?$_GET["cat"]:"","","alleracat")."
{$linkPrev}{$linkMin}$current{$linkLast}{$linkNext}"."
".$l->g(397).":" .comboCat( isset($_GET["cat"])?$_GET["cat"]:"","","alleracat")."
"; } else { if( isset($_GET["oldv"]) ) { $_GET["search"] = $_SESSION["search"] ; $_GET["all"] = $_SESSION["all"] ; $rg = isset($_SESSION["rg"])?$_SESSION["rg"]:0 ; } else { $_SESSION["search"] = $_GET["search"] ; $_SESSION["all"] = $_GET["all"] ; $_SESSION["rg"] = $rg ; } $link = "multi=14&search=".urlencode($_GET["search"])."&order=$order"; // multi category search if( isset($_GET["all"]) && $_GET["search"]!="" ) { $link .= "&all=1"; echo "

<= ".$l->g(398)."

"; $li = 0; $resLog = mysql_query($reqLog, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); $resCount = mysql_query($reqCount, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); $valCount = mysql_fetch_array($resCount); printLigne(array("".$l->g(382)."","".$l->g(388)."","".$l->g(383)."/".$l->g(389)."")); $nb = 0; while( $leLog = mysql_fetch_array($resLog) ) { $extracted = $leLog["extracted"]; $reqIsIgnored = "SELECT extracted FROM dico_ignored WHERE extracted='$extracted'"; $resIsIgnored = mysql_query($reqIsIgnored, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); if( $softIgnored = mysql_fetch_array($resIsIgnored)) { $cat = "IGNORED"; } else { $reqIsDico = "SELECT extracted,formatted FROM dico_soft WHERE extracted='$extracted'"; $resIsDico = mysql_query($reqIsDico, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); if( $softDico = mysql_fetch_array($resIsDico)) { if( $softDico["extracted"] == $softDico["formatted"] ) { $cat = "UNCHANGED"; } else $cat = $softDico["formatted"]; } else { $cat = 'NEW'; } } $ligne = array(utf8_decode($leLog["extracted"]), "$cat",""); printLigne( $ligne, ($li%2 == 1 ? "#FFFFFF" : "#F2F2F2")); $li++; $nb++; } if($nb>0) { $optList = comboCat($laCat, $lastCat); echo "
".$l->g(384)."     ".$l->g(385).":   ".$l->g(386)." ".$l->g(387).": $optList
"; } } else { printEnTete($l->g(390)); if( isset($_GET["search"]) && $_GET["search"] != "" ) { $cond = "AND formatted LIKE '%".$_GET["search"]."%'"; } $reqCat = "SELECT formatted as 'name', COUNT(extracted) AS nbSoft FROM dico_soft WHERE extracted<>formatted $cond GROUP BY formatted ORDER BY formatted ASC LIMIT $rg,$pgSize"; echo "
$pcParPageHtml
"; //echo $reqCat; $resCat = mysql_query($reqCat, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); echo "
NEWIGNOREDUNCHANGED
"; echo "
"; echo ""; $ligne = 0; $reqNew = "SELECT COUNT(DISTINCT(name)) as nbNew FROM softwares WHERE name NOT IN (SELECT DISTINCT(extracted) FROM dico_soft)"; while($cat = mysql_fetch_array($resCat)) { $laLigne = array("".$cat["name"]."", $cat["nbSoft"] ); $laLigne = array_merge($laLigne, array("")); printLigne($laLigne, ($ligne%2 == 1 ? "#FFFFFF" : "#F2F2F2")); $ligne++; } echo "
".$l->g(391)."".$l->g(381)."".$l->g(392)."
"; } echo "
"; echo ""; $maxPgeNumber = ceil($valCount["nb"]/$pgSize); if( $maxPgeNumber > 1 ){ $link = " $valCount["nb"] ? $valCount["nb"] - $pgSize : $rg + $pgSize ; $last = $valCount["nb"] - $pgSize > 0 ? $valCount["nb"] - $pgSize : 0 ; $linkMin = $rg == 0 ? "1.." : $link.$min."\">1.."; $linkPrev = $rg == 0 ? "" : $link.$prev."\">"; $linkNext = $rg >= $valCount["nb"] - $pgSize ? "" : $link.$next."\">"; $linkLast = $rg >= $valCount["nb"] - $pgSize ? "..$maxPgeNumber" : $link.$last."\">..$maxPgeNumber"; $current = ceil( $rg / $pgSize )+1; echo ""; if( $rg > 0 && $rg < $valCount["nb"] - $pgSize ) echo ""; echo ""; } echo "
{$linkPrev}{$linkMin}$current{$linkLast}{$linkNext}
"; } if( isset( $_SESSION["toBeMod"] ) ) { //var_dump( $_SESSION["toBeMod"]); computeChecksums(); unset( $_SESSION["toBeMod"] ); } /*function allerA() { return "
".$l->g(397).":" .comboCat( isset($_GET["cat"])?$_GET["cat"]:"","","alleracat")."
"; }*/ function comboCat( $saufCat="", $lastCat="",$name='combocat' ) { $reqCom = "SELECT formatted as 'name', COUNT(extracted) AS nbSoft FROM dico_soft WHERE extracted<>formatted AND formatted<>'$saufCat' GROUP BY formatted ORDER BY formatted ASC"; //echo $reqCom; $resCom = mysql_query($reqCom, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); $ret = ""; return $ret; } function printLigne($ligne, $bgcol=false) { if( $bgcol ) $affBg = "bgcolor='$bgcol'"; echo ""; foreach($ligne as $l) { echo "$l"; } echo ""; } function toName($nm) { $ret = str_replace(".","%point%",$nm); $ret = "checkbox_".$ret; return urlencode($ret); } function fromName($nm) { $ret = urldecode($nm); $ret = str_replace("checkbox_","",$ret); return str_replace("%point%",".",$ret); } function addSoft( $cat, $def) { if( $cat == "UNCHANGED") { $cat = $def; } if($cat == "IGNORED") { delSoft($def); $reqIgn = "INSERT INTO dico_ignored VALUES('$def')"; @mysql_query($reqIgn, $_SESSION["writeServer"]); } else { delIgnored($def); $reqUpd = "UPDATE dico_soft SET formatted='$cat' WHERE extracted='$def'";//GLPI //echo $reqUpd."
"; mysql_query($reqUpd, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"])); if( mysql_affected_rows() <= 0) { $reqUpd = "INSERT INTO dico_soft(formatted,extracted) VALUES('$cat', '$def')";//GLPI //echo $reqUpd."
"; @mysql_query($reqUpd, $_SESSION["writeServer"]); } alterChecksum($def); } } function delSoft($def) { $reqDcat = "DELETE FROM dico_soft WHERE extracted='$def'";//GLPI mysql_query($reqDcat, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"])); alterChecksum($def); } function delIgnored($def) { $reqDcat = "DELETE FROM dico_ignored WHERE extracted='$def'"; mysql_query($reqDcat, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"])); } function delCat($cat) { alterChecksum(false,$cat); $reqDcat = "DELETE FROM dico_soft WHERE formatted='$cat'";//GLPI mysql_query($reqDcat, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"])); } function alterChecksum($ext, $form=false) { if($ext) { $_SESSION["toBeMod"][]=$ext; //$reqCheck = "UPDATE hardware SET checksum=checksum|$softMod WHERE id IN( SELECT hardware_id FROM softwares WHERE name='$ext')"; //mysql_query($reqCheck, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"])); } else { $reqSofts = "SELECT DISTINCT(extracted) FROM dico_soft WHERE formatted='$form'"; $resSofts = mysql_query($reqSofts, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"])); while( $valSofts = mysql_fetch_array($resSofts) ) { alterChecksum($valSofts["extracted"]); } } } function computeChecksums() { echo "COMPUTING: ".sizeof($_SESSION["toBeMod"])."
"; flush(); $softMod = "65536"; $reqCheck = "UPDATE hardware SET checksum=checksum|$softMod WHERE id IN (SELECT DISTINCT(hardware_id) FROM softwares WHERE name IN("; $first = true; foreach( $_SESSION["toBeMod"] as $soft ) { if( !$first ) $reqCheck .= ","; $reqCheck .= "'$soft'"; if( $first ) $first = false; } $reqCheck .= "));"; //echo $reqCheck; mysql_query($reqCheck, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"])); } ?>