[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-ocs/sources/www/ -> dico.php (source)

   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 9/27/2005
  12  
  13  $pgSize = $_SESSION["pcparpage"];
  14  $rg = isset($_GET["rg"])?$_GET["rg"]:0;    
  15  set_time_limit(0);
  16  /*
  17  foreach($_POST as $key=>$val) {    
  18      if( ($fin = stristr ($key, "inputncat_")) && $val != "") {
  19          $valName = substr( fromName(stripslashes($fin)), strlen("inputncat_"));
  20          addSoft( $val, $valName);
  21      }}
  22      
  23  */
  24  
  25  $_GET["cat"] = isset($_GET["cat"]) ? $_GET["cat"] : (isset($_POST["alleracat"]) ? $_POST["alleracat"] : null ) ;
  26  
  27  if( isset($_GET["cat"]) ) {
  28      
  29      if( isset($_GET["search"]) && $_GET["search"] != "" ) {
  30          $condG = " name LIKE '%".$_GET["search"]."%' AND";
  31          $condO = " extracted LIKE '%".$_GET["search"]."%' AND";
  32      }
  33      
  34      $order = isset($_GET["order"])&&$_GET["order"]!="" ? $_GET["order"] : 1 ;
  35      
  36      $laCat = stripslashes(fromName($_GET["cat"]));    
  37      if($laCat == "NEW")
  38          $sens = $order != 1 ? "ASC" : "DESC";
  39      else
  40          $sens = "ASC";
  41      
  42      if($laCat == "NEW") {        
  43          if(! isset($_GET["order"])) $sens = "DESC";
  44          $reqLog = "SELECT COUNT(hardware_id) as 'nbdef',name as 'extracted' FROM softwares WHERE{$condG} name NOT IN 
  45          (SELECT DISTINCT(extracted) FROM dico_soft) AND name NOT IN 
  46          (SELECT DISTINCT(extracted) FROM dico_ignored) GROUP BY name ORDER BY $order $sens";
  47          $reqCount = "SELECT COUNT(DISTINCT(name)) as 'nb' FROM softwares WHERE{$condG} name NOT IN 
  48          (SELECT DISTINCT(extracted) FROM dico_soft) AND name NOT IN 
  49          (SELECT DISTINCT(extracted) FROM dico_ignored)";
  50      }
  51      else if($laCat == "IGNORED") {
  52          $reqLog = "SELECT s.extracted FROM dico_ignored s WHERE{$condO} 1=1 ORDER BY $order $sens ";    
  53          $reqCount = "SELECT COUNT(s.extracted) as 'nb' FROM dico_ignored s WHERE{$condO} 1=1";
  54      }
  55      else if($laCat == "UNCHANGED") {
  56          $reqLog = "SELECT s.extracted FROM dico_soft s WHERE{$condO} extracted=formatted ORDER BY $order $sens";    
  57          $reqCount = "SELECT COUNT(s.extracted) as 'nb' FROM dico_soft s WHERE{$condO} extracted=formatted";
  58      }
  59      else {
  60          $reqLog = "SELECT s.extracted FROM dico_soft s WHERE{$condO} s.formatted='$laCat' ORDER BY $order $sens";    
  61          $reqCount = "SELECT COUNT(s.extracted) as 'nb' FROM dico_soft s WHERE{$condO} s.formatted='$laCat'";    
  62      }
  63      //echo $reqLog;
  64  
  65  }
  66  else if( isset($_GET["all"]) && $_GET["search"]!="" ) {
  67      $reqLog = "SELECT distinct(name) as 'extracted' FROM softwares WHERE name LIKE '%".$_GET["search"]."%' order by name asc";
  68      $reqCount = "SELECT count( distinct name) as 'nb' FROM softwares WHERE name LIKE '%".$_GET["search"]."%' order by name asc";
  69  }
  70  
  71  $lastCat = "";    
  72  if( isset($_POST["combocat"]) ) {
  73      if(isset($_POST["all"])) {
  74          $resAll = mysql_query($reqLog, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
  75          while($valAll = mysql_fetch_array($resAll)) {
  76              $_POST[ urlencode($valAll["extracted"]) ] = "on";
  77          }        
  78          unset($_POST["all"]);
  79      }    
  80      
  81      foreach($_POST as $key=>$val) {
  82          if($val == "on") {
  83              $key = addslashes(fromName($key));
  84              if( isset($_POST["inputcat"]) && $_POST["inputcat"] != "" ) {
  85                  addSoft( fromName($_POST["inputcat"]), $key);
  86                  $lastCat = fromName($_POST["inputcat"]);
  87              }
  88              else {
  89                  addSoft( fromName($_POST["combocat"]), $key);
  90                  $lastCat = fromName($_POST["combocat"]);
  91              }
  92          }        
  93      }
  94  }
  95  
  96  if( isset($reqLog) ) {
  97      $reqLog .= " LIMIT $rg,$pgSize";
  98  }
  99  
 100  if( isset($_GET["delcat"]) ) {
 101      delCat( fromName($_GET["delcat"]) );     
 102  }
 103  
 104  ?><script language='javascript'>
 105  		function actForm( field, value ) {
 106              for (var i = 0; i < document.reass.elements.length; i++) {
 107                  elm = document.reass.elements[i];
 108                  reg = new RegExp("checkbox_");
 109                  if (elm.type == 'checkbox' && reg.test(elm.id)) {
 110                      eval("elm."+field+" = "+value+";");
 111                      
 112                  }
 113              }
 114          }
 115  </script><?
 116  
 117  //les GET globaux a rajouter
 118  $hiddens ="";
 119  foreach ($_GET as $gk=>$gv) {
 120      if( $gk=="rev"|| $gk=="suppCol" || $gk == "logout" || $gk=="newcol" || $gk=="order") continue;
 121      
 122      if( $gk =="page" && ($gv==-1 || $gv==-2)) {
 123          $gv = $_SESSION["pageCur"];
 124      }    
 125      $hiddens .= "<input type='hidden' name='$gk' value='$gv'>\n";
 126  }
 127  
 128  $machNmb = array(5,10,15,20,50,100);
 129  $pcParPageHtml = "<form name='pcp' method='GET' action='index.php'>$hiddens".$l->g(340).": 
 130  <select name='pcparpage' OnChange='pcp.submit();'>";
 131  foreach( $machNmb as $nbm ) {
 132      $pcParPageHtml .=  "<option".($_SESSION["pcparpage"] == $nbm ? " selected" : "").($countHl%2==1?" class='hi'":"").">$nbm</option>";
 133      $countHl++;
 134  }
 135  $pcParPageHtml .=  "</select></form>";
 136  
 137  if( isset($_GET["cat"]) ) {    
 138      
 139      $link = "multi=14&cat=".urlencode($_GET["cat"])."&search=".urlencode($_GET["search"]);    
 140      
 141      $resCount = mysql_query($reqCount, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 142      $valCount = mysql_fetch_array($resCount);
 143      
 144      $printNbr = $valCount["nb"] == 0 ? "<font color='red'>VIDE</font>" : $valCount["nb"];
 145      printEnTete("Catégorie $laCat ( $printNbr )");
 146      echo "<br><center>$pcParPageHtml&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='index.php?multi=14&oldv=1'><= ".$l->g(398)."</a></center><br>";    
 147      
 148      if( $valCount["nb"] > 0 ) {
 149          $resLog = mysql_query($reqLog, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 150          echo "<form name='reass' method='POST' action='?$link'>";
 151          echo "<table width='80%' BORDER='0' ALIGN = 'Center' CELLPADDING='0' BGCOLOR='#C7D9F5' BORDERCOLOR='#9894B5'>";
 152          echo "<tr height='20px'>";
 153          
 154          if( $laCat == "NEW" ) echo "<td align='center' width='10%'><b><a href='?$link&order=1'>".$l->g(381)."</a></b></font></td>";
 155          echo "<td align='center' width='70%'><b>".( $laCat=="NEW" ? "<a href='?$link&order=2'>" : "" ).$l->g(382).( $laCat=="NEW" ? "</a>" : "")."</b></font></td><td align='center' width='10%'>
 156          <b><a href=# OnClick='actForm(\"checked\",\"true\")'>".$l->g(383)."</a>/<a href=# OnClick='actForm(\"checked\",\"false\")'>".$l->g(389)."</a></b></font></td></tr>";
 157  
 158          $ligne = 0;
 159          $optList = comboCat($laCat, $lastCat);                
 160          while($log = mysql_fetch_array($resLog)) {
 161          
 162              $laLigne = array(utf8_decode($log["extracted"]),"<input type='checkbox' name='".toName($log["extracted"])."' id='".toName($log["extracted"])."'>"
 163              /*,"<input name='inputncat_".toName($log["extracted"])."'>"*/ );
 164              if( $laCat == "NEW" ) $laLigne = array_merge( array($log["nbdef"]), $laLigne );
 165              printLigne($laLigne, ($ligne%2 == 1 ? "#FFFFFF" : "#F2F2F2"));            
 166              $ligne++;        
 167          }
 168          
 169          echo "<tr height='40px' bgcolor='".($ligne%2 == 1 ? "#FFFFFF" : "#F2F2F2")."'>";
 170          //if( $laCat == "NEW" ) echo "<td>&nbsp;</td>";        
 171          echo "<td align='right' colspan='4'>
 172          <input name='all' id='all' type='checkbox' OnClick='actForm(\"disabled\",document.getElementById(\"all\").checked)'>
 173          ".$l->g(384)."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$l->g(385).":</font>&nbsp;
 174          <input name='inputcat'>&nbsp;<b>".$l->g(386)."</b> ".$l->g(387).":</font>&nbsp;$optList
 175          <input type='Submit'></td></tr></table></form>";
 176      }
 177      
 178      echo "<br><table width='80%' BORDER='0' ALIGN = 'Center' CELLPADDING='0'>";
 179      echo "<tr height='30px'><td align='left'>
 180      <form action='' method='get' name='formrech'>
 181      <input type='hidden' name='cat' value='".$_GET["cat"]."'>
 182      <input type='hidden' name='order' value='".$_GET["order"]."'>
 183      <input type='hidden' name='multi' value='14'>
 184      <input name='search' id='search' value='".$_GET["search"]."'>
 185      <input type='Submit' value='".$l->g(393)."'><input type='Submit' OnClick='document.getElementById(\"search\").value=\"\"' value='".$l->g(396)."'></form></td>";
 186          
 187      $maxPgeNumber = ceil($valCount["nb"]/$pgSize);    
 188      if( $maxPgeNumber > 1 ){
 189          echo "<td align='center'>"."<form name='allera' method='post' action='index.php?multi=14'>".$l->g(397).":</font>"
 190                  .comboCat( isset($_GET["cat"])?$_GET["cat"]:"","","alleracat")."<input type='submit'></form></td>";
 191          $link = "<a href=\"?$link&order=".$_GET["order"]."&rg=";
 192          $min = 0;
 193          $prev = $rg - $pgSize < 0 ? 0 : $rg - $pgSize ;
 194          $next = $rg + $pgSize > $valCount["nb"] ? $valCount["nb"] - $pgSize : $rg + $pgSize ;
 195          $last = $valCount["nb"] - $pgSize > 0 ? $valCount["nb"] - $pgSize : 0 ;
 196          
 197          $linkMin  = $rg == 0 ? "1..</font>" : $link.$min."\">1..</a>";
 198          $linkPrev = $rg == 0 ? "<img src='image/prec24.png'></font>" : $link.$prev."\"><img src='image/prec24.png'></a>";
 199          $linkNext =  $rg >= $valCount["nb"] - $pgSize ? "<img src='image/proch24.png'></font>" : $link.$next."\"><img src='image/proch24.png'></a>";
 200          $linkLast  = $rg >= $valCount["nb"] - $pgSize ? "..$maxPgeNumber</font>" : $link.$last."\">..$maxPgeNumber</a>";
 201          $current = ceil( $rg / $pgSize )+1;
 202          
 203          echo "<td align='left'>{$linkPrev}</td><td align='right'>{$linkMin}</td>";
 204          if( $rg > 0 && $rg < $valCount["nb"] - $pgSize ) echo "<td align='center' width='0%'>$current</font></td>";
 205          echo "<td align='left'>{$linkLast}</td><td align='left'>{$linkNext}</td>";
 206      }
 207      else
 208          echo "<td align='right'>"."<form name='allera' method='post' action='index.php?multi=14'>".$l->g(397).":</font>"
 209                  .comboCat( isset($_GET["cat"])?$_GET["cat"]:"","","alleracat")."<input type='submit'></form></td>";
 210      echo "</tr></table>";
 211  }
 212  else {
 213      if( isset($_GET["oldv"]) ) {
 214          $_GET["search"] = $_SESSION["search"] ;
 215          $_GET["all"] = $_SESSION["all"] ;
 216          $rg = isset($_SESSION["rg"])?$_SESSION["rg"]:0 ;
 217      }
 218      else {
 219          $_SESSION["search"] = $_GET["search"] ;
 220          $_SESSION["all"] = $_GET["all"] ;
 221          $_SESSION["rg"] = $rg ;
 222      }
 223      
 224      $link = "multi=14&search=".urlencode($_GET["search"])."&order=$order";
 225      
 226      // multi category search
 227      if( isset($_GET["all"]) && $_GET["search"]!="" ) {
 228          $link .= "&all=1";
 229          echo "<br><form name='reass' method='POST' action='?$link'><br><center><a href='index.php?multi=14'><= ".$l->g(398)."</a></center><br><table width='90%' BORDER='0' ALIGN = 'Center' CELLPADDING='0' BGCOLOR='#C7D9F5' BORDERCOLOR='#9894B5'>";
 230          $li = 0;
 231          $resLog = mysql_query($reqLog, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));        
 232          $resCount = mysql_query($reqCount, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 233          $valCount = mysql_fetch_array($resCount);
 234          
 235          printLigne(array("<b>".$l->g(382)."</b>","<b>".$l->g(388)."</b>","<b><a href=# OnClick='actForm(\"checked\",\"true\")'>".$l->g(383)."</a>/<a href=# OnClick='actForm(\"checked\",\"false\")'>".$l->g(389)."</a></b>"));
 236          $nb = 0;
 237          while( $leLog = mysql_fetch_array($resLog) ) {
 238              $extracted = $leLog["extracted"];
 239              $reqIsIgnored = "SELECT extracted FROM dico_ignored WHERE extracted='$extracted'";
 240              $resIsIgnored = mysql_query($reqIsIgnored, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 241              if( $softIgnored = mysql_fetch_array($resIsIgnored)) {
 242                  $cat = "IGNORED";
 243              }
 244              else {
 245                  $reqIsDico = "SELECT extracted,formatted FROM dico_soft WHERE extracted='$extracted'";
 246                  $resIsDico = mysql_query($reqIsDico, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 247                  if( $softDico = mysql_fetch_array($resIsDico)) {
 248                      if( $softDico["extracted"] == $softDico["formatted"] ) {
 249                          $cat = "UNCHANGED";
 250                      }
 251                      else
 252                          $cat = $softDico["formatted"];
 253                  }
 254                  else {
 255                      $cat = 'NEW';
 256                  }
 257              }
 258              $ligne = array(utf8_decode($leLog["extracted"]), "<a href='?multi=14&cat=".toName($cat)."'>$cat</a>","<input type='checkbox' name='".toName($leLog["extracted"])."' id='".toName($leLog["extracted"])."'>");
 259              printLigne( $ligne, ($li%2 == 1 ? "#FFFFFF" : "#F2F2F2"));
 260              $li++;
 261              $nb++;
 262          }
 263          
 264          if($nb>0) {
 265              $optList = comboCat($laCat, $lastCat);
 266              echo "<tr height='30px' bgcolor='#FFFFFF'><td align='right' colspan='4'>
 267              <input name='all' id='all' type='checkbox' OnClick='actForm(\"disabled\",document.getElementById(\"all\").checked)'>
 268              ".$l->g(384)."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$l->g(385).":</font>&nbsp;
 269              <input name='inputcat'>&nbsp;<b>".$l->g(386)."</b> ".$l->g(387).":</font>&nbsp;$optList
 270              <input type='Submit'></td></tr></table></form>";
 271          }
 272      }
 273      else {        
 274          printEnTete($l->g(390));
 275          
 276          if( isset($_GET["search"]) && $_GET["search"] != "" ) {
 277              $cond = "AND formatted LIKE '%".$_GET["search"]."%'";
 278          }
 279          
 280          $reqCat = "SELECT formatted as 'name', COUNT(extracted) AS nbSoft FROM dico_soft WHERE extracted<>formatted $cond 
 281          GROUP BY formatted ORDER BY formatted ASC LIMIT $rg,$pgSize";
 282          echo "<br><center>$pcParPageHtml</center>";
 283          //echo $reqCat;
 284          $resCat = mysql_query($reqCat, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 285          echo "<table width='60%' border='0' align='center'><td align='center' width='33%'><a href='?multi=14&cat=NEW'><b><u>NEW</u></b></a></td><td align='center' width='33%'><a href='?multi=14&cat=IGNORED'><b><u>IGNORED</u></b></a></td><td align='center' width='33%'><a href='?multi=14&cat=UNCHANGED'><b><u>UNCHANGED</u></b></a></td></table>";
 286          echo "<br><table width='60%' BORDER='0' ALIGN = 'Center' CELLPADDING='0' BGCOLOR='#C7D9F5' BORDERCOLOR='#9894B5'>";
 287          echo "<tr height='20px'><td align='center' width='70%'><b>".$l->g(391)."</b></font></td><td align='center' width='15%'><b>".$l->g(381)."</b></font></td><td align='center' width='15%'><b>".$l->g(392)."</b></font></td></tr>";
 288          $ligne = 0;
 289          $reqNew = "SELECT COUNT(DISTINCT(name)) as nbNew FROM softwares WHERE name NOT IN (SELECT DISTINCT(extracted) FROM dico_soft)";
 290          
 291          while($cat = mysql_fetch_array($resCat)) {
 292          
 293              $laLigne = array("<a href='?multi=14&cat=".toName($cat["name"])."'>".$cat["name"]."</a>", $cat["nbSoft"] );
 294              $laLigne = array_merge($laLigne, array("<a href='?$link&rg=$rg&delcat=".toName($cat["name"])."'><img src='image/supp.png'></a>"));
 295              
 296              printLigne($laLigne, ($ligne%2 == 1 ? "#FFFFFF" : "#F2F2F2"));    
 297              $ligne++;
 298              
 299          }
 300          echo "</table>";
 301      }
 302      echo "<br><table width='60%' BORDER='0' ALIGN = 'Center' CELLPADDING='0'>";
 303      echo "<tr height='30px'><td align='left'>
 304      <form action='' method='get' name='formrech'>
 305      <input type='hidden' name='multi' value='14'>
 306      <input name='search' id='search' value='".$_GET["search"]."'>
 307      <input type='Submit' value='".$l->g(394)."'><input type='Submit' name='all' value='".$l->g(395)."'><input type='Submit' OnClick='document.getElementById(\"search\").value=\"\"' value='".$l->g(396)."'></form></td>";
 308      
 309      $maxPgeNumber = ceil($valCount["nb"]/$pgSize);    
 310      if( $maxPgeNumber > 1 ){
 311          $link = "<a href=\"?$link&rg=";
 312          $min = 0;
 313          $prev = $rg - $pgSize < 0 ? 0 : $rg - $pgSize ;
 314          $next = $rg + $pgSize > $valCount["nb"] ? $valCount["nb"] - $pgSize : $rg + $pgSize ;
 315          $last = $valCount["nb"] - $pgSize > 0 ? $valCount["nb"] - $pgSize : 0 ;
 316          
 317          $linkMin  = $rg == 0 ? "1..</font>" : $link.$min."\">1..</a>";
 318          $linkPrev = $rg == 0 ? "<img src='image/prec24.png'></font>" : $link.$prev."\"><img src='image/prec24.png'></a>";
 319          $linkNext =  $rg >= $valCount["nb"] - $pgSize ? "<img src='image/proch24.png'></font>" : $link.$next."\"><img src='image/proch24.png'></a>";
 320          $linkLast  = $rg >= $valCount["nb"] - $pgSize ? "..$maxPgeNumber</font>" : $link.$last."\">..$maxPgeNumber</a>";
 321          $current = ceil( $rg / $pgSize )+1;
 322          
 323          echo "<td align='left'>{$linkPrev}</td><td align='right'>{$linkMin}</td>";
 324          if( $rg > 0 && $rg < $valCount["nb"] - $pgSize ) echo "<td align='center' width='0%'>$current</font></td>";
 325          echo "<td align='left'>{$linkLast}</td><td align='left'>{$linkNext}</td>";
 326      }
 327      echo "</tr></table>";
 328  }
 329  
 330  if( isset( $_SESSION["toBeMod"] ) ) {
 331      //var_dump( $_SESSION["toBeMod"]);
 332      computeChecksums();
 333      unset(     $_SESSION["toBeMod"] );
 334  }
 335  
 336  /*function allerA() {
 337      return "<form name='allera' method='post' action='index.php?multi=14'>".$l->g(397).":</font>"
 338      .comboCat( isset($_GET["cat"])?$_GET["cat"]:"","","alleracat")."<input type='submit'></form>";
 339  }*/
 340  
 341  function comboCat( $saufCat="", $lastCat="",$name='combocat' ) {
 342      
 343      $reqCom = "SELECT formatted as 'name', COUNT(extracted) AS nbSoft FROM dico_soft WHERE extracted<>formatted AND formatted<>'$saufCat' 
 344          GROUP BY formatted ORDER BY formatted ASC";
 345      //echo $reqCom;
 346      $resCom = mysql_query($reqCom, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 347      $ret = "<select name='$name'>";
 348      $countHl = 0;
 349      $ret .= "<option".( $lastCat == "IGNORED" ? " selected" : "" )." ".($countHl%2==1?"class='hi'":"").">IGNORED</option>";
 350      $countHl++;
 351      $ret .= "<option".( $lastCat == "UNCHANGED" ? " selected" : "" )." ".($countHl%2==1?"class='hi'":"").">UNCHANGED</option>";
 352      
 353      while($cat = mysql_fetch_array($resCom)) {
 354          $countHl++;
 355          $ret .= "<option".( $lastCat==$cat["name"]?" selected":"" ).($countHl%2==1?" class='hi'":"").">".$cat["name"]."</option>";
 356      }
 357      $ret .= "</select>";
 358      return $ret;
 359  }
 360  
 361  function printLigne($ligne, $bgcol=false) {
 362      if( $bgcol ) 
 363          $affBg =  "bgcolor='$bgcol'";
 364      echo "<tr height='20px'$affBg>";
 365      
 366      foreach($ligne as $l) {
 367          echo "<td align='center'>$l</font></td>";
 368      }
 369      echo "</tr>";
 370  }
 371  
 372  function toName($nm) {
 373      $ret = str_replace(".","%point%",$nm);
 374      $ret = "checkbox_".$ret;
 375      return urlencode($ret);    
 376  }
 377  
 378  function fromName($nm) {
 379      $ret = urldecode($nm);
 380      $ret = str_replace("checkbox_","",$ret);
 381      return str_replace("%point%",".",$ret);
 382  }
 383  
 384  function addSoft( $cat, $def) {
 385      
 386      if( $cat == "UNCHANGED") {
 387          $cat = $def;
 388      }
 389      
 390      if($cat == "IGNORED") {
 391          delSoft($def);
 392          $reqIgn = "INSERT INTO dico_ignored VALUES('$def')";
 393          @mysql_query($reqIgn, $_SESSION["writeServer"]);
 394      }
 395      else {
 396          delIgnored($def);
 397          $reqUpd = "UPDATE dico_soft SET formatted='$cat' WHERE extracted='$def'";//GLPI
 398          //echo $reqUpd."<br>";    
 399          mysql_query($reqUpd, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));
 400          if( mysql_affected_rows() <= 0) {
 401              $reqUpd = "INSERT INTO dico_soft(formatted,extracted) VALUES('$cat', '$def')";//GLPI
 402              //echo $reqUpd."<br>";
 403              @mysql_query($reqUpd, $_SESSION["writeServer"]);
 404              
 405          }
 406          alterChecksum($def);            
 407      }
 408  }
 409  
 410  function delSoft($def) {
 411      $reqDcat = "DELETE FROM dico_soft WHERE extracted='$def'";//GLPI
 412      mysql_query($reqDcat, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));
 413      alterChecksum($def);
 414  }
 415  
 416  function delIgnored($def) {
 417      $reqDcat = "DELETE FROM dico_ignored WHERE extracted='$def'";
 418      mysql_query($reqDcat, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));
 419  }
 420  
 421  function delCat($cat) {
 422      alterChecksum(false,$cat);
 423      $reqDcat = "DELETE FROM dico_soft WHERE formatted='$cat'";//GLPI
 424      mysql_query($reqDcat, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));    
 425  }
 426  
 427  function alterChecksum($ext, $form=false) {
 428  
 429      if($ext) {
 430          $_SESSION["toBeMod"][]=$ext;
 431          //$reqCheck = "UPDATE hardware SET checksum=checksum|$softMod WHERE id IN( SELECT hardware_id FROM softwares WHERE name='$ext')";
 432          //mysql_query($reqCheck, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));
 433      }
 434      else {        
 435          $reqSofts = "SELECT DISTINCT(extracted) FROM dico_soft WHERE formatted='$form'";
 436          
 437          $resSofts = mysql_query($reqSofts, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));
 438          while( $valSofts = mysql_fetch_array($resSofts) ) {
 439              alterChecksum($valSofts["extracted"]);
 440          }
 441      }
 442  }
 443  
 444  function computeChecksums() {
 445      echo "COMPUTING: ".sizeof($_SESSION["toBeMod"])."<br>";
 446      flush();
 447      
 448      $softMod = "65536";
 449      $reqCheck = "UPDATE hardware SET checksum=checksum|$softMod WHERE id IN (SELECT DISTINCT(hardware_id) FROM softwares WHERE name IN(";
 450      $first = true;
 451      foreach( $_SESSION["toBeMod"] as $soft ) {
 452          if( !$first )
 453              $reqCheck .= ",";
 454          $reqCheck .= "'$soft'";
 455          if( $first ) $first = false;    
 456      }
 457      $reqCheck .= "));";
 458      //echo $reqCheck;
 459      mysql_query($reqCheck, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));
 460  }
 461  
 462  ?>


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1