[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-ocs/sources/www/ -> multicritere.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 12/14/2005
  12  
  13      printEnTete($l->g(9));
  14      $req = NULL;
  15      
  16      if( !isset($_SESSION["optCol"]) ) {
  17          $reqCol = "SHOW COLUMNS FROM accountinfo";
  18          $resCol = mysql_query($reqCol, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
  19          while($colname=mysql_fetch_array($resCol)) {
  20              if( strcasecmp($colname["Field"], TAG_NAME) != 0 )
  21                  $_SESSION["optCol"][] = $colname["Field"] ;    
  22          }
  23      }    
  24      
  25      include ("req.class.php");
  26      $indLigne=0;
  27      $softPresent = false;
  28      $cuPresent = -1;
  29      $leSelect = array_merge( array("h.id"=>"h.id", "deviceid"=>"deviceid"), $_SESSION["currentFieldList"] );
  30      
  31      if( is_array($_SESSION["selectSofts"]) && $_POST["sub"]!=$l->g(30)) 
  32          $leSelect = array_merge( $leSelect, $_SESSION["selectSofts"] );
  33      $selFinal ="";
  34      
  35      if($_POST["reset"]==$l->g(41))
  36      {
  37          unset($_SESSION["OPT"]);
  38          unset($_SESSION["reqs"]);
  39          unset($_SESSION["softs"]);
  40      }
  41      else if($_POST["selOpt"])
  42      {
  43          $_POST["selOpt"] = urldecode( $_POST["selOpt"] );
  44          if( $_POST["selOpt"]==$l->g(20) ||  ((! is_array($_SESSION["OPT"]))  ||   ( !in_array($_POST["selOpt"],$_SESSION["OPT"])))) {
  45              $_SESSION["OPT"][]=stripslashes($_POST["selOpt"]);
  46          }
  47      }    
  48      else if($_POST["sub"]==$l->g(30))
  49      {
  50          unset($_SESSION["selectSofts"]);
  51          unset($_SESSION["storedRequest"], $_SESSION["c"],$_SESSION["reqs"],$_SESSION["softs"]);
  52          $i=0; $nb=0; 
  53          $laRequete="";                
  54  
  55          for($i=0;$i<$_POST["max"];$i++)    {
  56          
  57              if( urldecode($_POST["lbl_".$i]) == $l->g(20))
  58                  $_SESSION["softs"][] = array( $_POST["act_".$i], urldecode($_POST["chm_".$i]), $_POST["ega_".$i], 
  59                  strtr($_POST["val_".$i],"\"","'"), strtr($_POST["val2_".$i],"\"","'"), $_POST["valreg_".$i] ); 
  60              
  61              $_SESSION["reqs"][ urldecode($_POST["lbl_".$i]) ] = array( $_POST["act_".$i], urldecode($_POST["chm_".$i]), $_POST["ega_".$i], 
  62              strtr($_POST["val_".$i],"\"","'"), strtr($_POST["val2_".$i],"\"","'"), $_POST["valreg_".$i] ); 
  63                              
  64              if(!isset($_POST["act_".$i]))
  65                  continue;            
  66          
  67              /*VOIRif( ($_POST["chm_".$i]=="name") && $_POST["ega_".$i]==$l->g(129) ) {            
  68                  $laRequete.=", s.name AS \"".$l->g(20)."\"";
  69              }*/            
  70  
  71              $nb++;            
  72          }
  73  
  74          $from = " hardware h LEFT JOIN accountinfo a ON a.hardware_id=h.id LEFT JOIN bios b ON b.hardware_id=h.id,";    
  75          //$laRequete.=" FROM hardware h,accountinfo a, bios b, ";        
  76              
  77          $softTable = false ;
  78          $logIndex = 1;
  79          $fromPrelim  ="";
  80          for($i=0;$i<$_POST["max"];$i++)
  81          {
  82              
  83              if(!isset($_POST["act_".$i]))
  84              continue;
  85              
  86              //jokers
  87              if( $_POST["ega_".$i] != $l->g(410) )
  88                  $_POST["val_".$i] = strtr($_POST["val_".$i], "?*", "_%");
  89                          
  90              if( isFieldDate($_POST["chm_".$i]) ) {
  91                  $_POST["val_".$i] = dateToMysql($_POST["val_".$i]);
  92              }
  93              
  94              if( ($_POST["chm_".$i]=="name") && ($_POST["ega_".$i]==$l->g(129) || $_POST["ega_".$i]==$l->g(410))) {        
  95                  $leSelect["s".$logIndex.".name"] = $l->g(20)." $logIndex";
  96                  $_SESSION["selectSofts"]["s".$logIndex.".name"] = $l->g(20)." $logIndex";
  97              }
  98              
  99              $regRes = null;
 100              if( ($_POST["ega_".$i]==$l->g(129)||$_POST["ega_".$i]==$l->g(410)) && $_POST["chm_".$i]=="name" ) {
 101                  //$fromPrelim.=" softwares s".$logIndex.",";
 102                  $from .= " softwares s".$logIndex.",";
 103                  $logIndex++;
 104              }
 105              
 106              if( ($_POST["chm_".$i]=="regval" || $_POST["chm_".$i]=="regname") && ($_POST["ega_".$i]==$l->g(129)||$_POST["ega_".$i]==$l->g(410))) {
 107                  $fromPrelim.=" registry r,";
 108              }
 109              
 110              if($_POST["chm_".$i]=="smonitor") {
 111                  $fromPrelim.=" monitors m,";
 112              }
 113              
 114              if($_POST["chm_".$i]=="free") {
 115                  $fromPrelim.=" drives dr,";
 116              }
 117  
 118              if(($_POST["chm_".$i]=="ipmask"||$_POST["chm_".$i]=="ipgateway"||$_POST["chm_".$i]=="ipaddr"||$_POST["chm_".$i]=="ipsubnet"||$_POST["chm_".$i]=="macaddr") && !$netTable) {
 119                  $fromPrelim.=" networks n,";
 120                  $netTable=true;
 121              }        
 122          }
 123          
 124          if($fromPrelim[strlen($fromPrelim)-1]==",")
 125              $fromPrelim[strlen($fromPrelim)-1]=" ";
 126          if($from[strlen($from)-1]==",")
 127              $from[strlen($from)-1]=" ";
 128  
 129          $first = true;
 130          for($i=0;$i<$_POST["max"];$i++)
 131          {                
 132              if(!isset($_POST["act_".$i]))
 133                  continue;
 134                  
 135                      
 136              if( $_POST["act_".$i]="checked" && $_POST["chm_".$i] == "ipdisc" ) {
 137                              
 138                  if( !$first )
 139                      $laRequete.= " AND ";
 140                      
 141                  $first = false;
 142                  $laRequete.= " h.id ";
 143                  switch( $_POST["val_".$i] ) {
 144                      case "elu":
 145                          $laRequete.= "IN (SELECT hardware_id FROM devices WHERE ivalue=1 AND name='IPDISCOVER') "; 
 146                      break;
 147                      case "for":
 148                          $laRequete.= "IN (SELECT hardware_id FROM devices WHERE ivalue=2 AND name='IPDISCOVER') "; 
 149                      break;
 150                      case "nelu":
 151                          $laRequete.= "NOT IN (SELECT hardware_id FROM devices WHERE ivalue=1 AND name='IPDISCOVER') "; 
 152                      break;
 153                      case "eli":
 154                          $laRequete.= "NOT IN (SELECT hardware_id FROM devices WHERE ivalue=0 AND name='IPDISCOVER') ";
 155                      break;
 156                      case "neli":
 157                          $laRequete.= "IN (SELECT hardware_id FROM devices WHERE ivalue=0 AND name='IPDISCOVER') ";
 158                      break;
 159                  }
 160                  continue;
 161              }
 162              
 163              if( $_POST["act_".$i]="checked" && $_POST["chm_".$i] == "freq" ) {
 164                              
 165                  if( !$first )
 166                      $laRequete.= " AND ";
 167                      
 168                  $first = false;
 169                  $laRequete.= " h.id ";
 170                  switch( $_POST["val_".$i] ) {
 171                      case "std":
 172                          $laRequete.= "NOT IN (SELECT hardware_id FROM devices WHERE name='FREQUENCY') "; 
 173                      break;
 174                      case "always":
 175                          $laRequete.= "IN (SELECT hardware_id FROM devices WHERE name='FREQUENCY' AND ivalue=0) "; 
 176                      break;
 177                      case "never":
 178                          $laRequete.= "IN (SELECT hardware_id FROM devices WHERE name='FREQUENCY' AND ivalue=-1) "; 
 179                      break;
 180                      case "custom":
 181                          $laRequete.= "IN (SELECT hardware_id FROM devices WHERE name='FREQUENCY' AND ivalue>0)  ";
 182                      break;                    
 183                  }
 184                  continue;
 185              }
 186              
 187              if( $_POST["act_".$i]="checked" && $_POST["chm_".$i] == "tele" ) {
 188                              
 189                  if( !$first )
 190                      $laRequete.= " AND ";
 191                      
 192                  $first = false;
 193                  $laRequete.= " h.id ";
 194                  
 195                  if( $_POST["ega_".$i] == "ayant" ) {
 196                      $laRequete.= " IN ";
 197                  }
 198                  else if( $_POST["ega_".$i] == "nayant" ) {
 199                      $laRequete.= " NOT IN ";
 200                  }
 201                  
 202                  switch( $_POST["val2_".$i] ) {
 203                      case "suc":
 204                          $laRequete.= "(SELECT d.hardware_id FROM devices d, download_available a, download_enable e
 205                           WHERE d.name='DOWNLOAD' AND a.name='".$_POST["val_".$i].
 206                           "' AND d.tvalue like 'SUCCESS_%' AND e.fileid=a.fileid AND e.id=d.ivalue) "; 
 207                      break;
 208                      case "nsuc":
 209                          $laRequete.= "(SELECT d.hardware_id FROM devices d, download_available a, download_enable e
 210                           WHERE d.name='DOWNLOAD' AND a.name='".$_POST["val_".$i].
 211                           "' AND (d.tvalue not like 'SUCCESS_%' OR d.tvalue IS NULL) AND e.fileid=a.fileid AND e.id=d.ivalue) "; 
 212                      break;
 213                      case "ind":
 214                          $laRequete.= "(SELECT d.hardware_id FROM devices d, download_available a, download_enable e
 215                           WHERE d.name='DOWNLOAD' AND a.name='".$_POST["val_".$i].
 216                           "' AND e.fileid=a.fileid AND e.id=d.ivalue) "; 
 217                      break;
 218                      default: //standard case
 219                          $laRequete.= "(SELECT d.hardware_id FROM devices d, download_available a, download_enable e
 220                           WHERE d.name='DOWNLOAD' AND a.name='".$_POST["val_".$i].
 221                           "' AND d.tvalue='".$_POST["val2_".$i]."' AND e.fileid=a.fileid AND e.id=d.ivalue) ";  
 222                      break;                                    
 223                  }
 224                  continue;
 225              }
 226              
 227              if( $_POST["act_".$i]="checked" && ! (  ($cuPresent != -1 ) && $_POST["chm_".$i] == "cu") )
 228              {                
 229                  // cas particulier avec LOGICIEL
 230                  if( ($_POST["chm_".$i] == "name" ) ) {
 231                      if( $_POST["ega_".$i] == $l->g(129)||$_POST["ega_".$i]==$l->g(410) )
 232                          $softsEg[] = Array( $_POST["val_".$i], urldecode($_POST["lbl_".$i]), $_POST["ega_".$i] );
 233                      else
 234                          $softsDi[] = Array( $_POST["val_".$i], urldecode($_POST["lbl_".$i]), "" );
 235                      continue ;
 236                  }
 237                  
 238                  // cas particulier avec registry DIFFERENT DE
 239                  if( $_POST["chm_".$i] == "regname" && $_POST["ega_".$i] == $l->g(130) ) {
 240                      $regDiff=Array($_POST["val_".$i],$_POST["valreg_".$i]);
 241                      continue ;
 242                  }
 243                  
 244                  if($nb>0&&!$first)
 245                  {
 246                      $laRequete.=" AND ";                        
 247                  }
 248                  if( $first ) $first = false;                
 249                  $forceEgal=false;
 250                                                  
 251                  if($_POST["chm_".$i]=="regname") {
 252                      $laRequete.="r.hardware_id=h.id AND ";
 253                  }
 254                  $tblIneq = "h";                        
 255                  switch($_POST["chm_".$i])
 256                  {
 257                      case "ssn": $laRequete.="b.ssn";break;
 258                      case "bmanufacturer": $laRequete.="b.bmanufacturer";break;
 259                      case "bversion": $laRequete.="b.bversion";break;
 260                      case "smanufacturer": $laRequete.="b.smanufacturer";break;
 261                      case "smodel": $laRequete.="b.smodel";break;
 262                      case "ipmask": $laRequete.="n.hardware_id=h.id AND n.ipmask";break;
 263                      case "ipgateway": $laRequete.="n.hardware_id=h.id AND n.ipgateway";break;
 264                      case "free": $laRequete.="dr.hardware_id=h.id AND dr.free";$tblIneq="dr";break;
 265                      case "ipsubnet": $laRequete.="n.hardware_id=h.id AND n.ipsubnet";break;
 266                      case "regname": 
 267                              if( $_POST["valreg_".$i] != $l->g(265) ) {
 268                                  if( $_POST["ega_".$i] != $l->g(410) )
 269                                      $_POST["valreg_".$i] = strtr($_POST["valreg_".$i], "?*", "_%");
 270                                  $comp = $_POST["ega_".$i] == $l->g(129) ? " like '%" : " = '";
 271                                  $compFin = $_POST["ega_".$i] == $l->g(129) ? "%' " : "' ";
 272                                  $laRequete.="r.regvalue$comp".$_POST["valreg_".$i]."{$compFin}AND ";
 273                              }
 274                              $laRequete.="r.name";
 275                              $forceEgal=true;
 276                              break;                    
 277                      
 278                      case "name":                             
 279                              $laRequete.="s.hardware_id=h.id AND s.name";
 280                              $softPresent = true;
 281                              if( $_POST["ega_".$i] == $l->g(129)||$_POST["ega_".$i]==$l->g(410) )
 282                                  $unSoftnEgal = true ;
 283                              break;            
 284                              
 285                      case "ORDEROWNER": $laRequete.="a.orderowner";break;
 286                      case "ORDERID": $laRequete.="a.orderid";break;
 287                      case "PRODUCTID": $laRequete.="a.productid";break;
 288                      case "BILLDATE": $laRequete.="a.billnbr";break;
 289                      case "cu": $laRequete.="a.".TAG_NAME;$forceEgal=true;break;
 290                      case "processors": $laRequete.="h.processors";break;
 291                      case "memory": $laRequete.="h.memory";break;
 292                      case "osname": $laRequete.="h.osname";$forceEgal=false;break;
 293                      case "userid": $laRequete.="h.userid";break;
 294                      case "ipaddr": $laRequete.="n.hardware_id=h.id AND n.ipaddress";break;
 295                      case "macaddr": $laRequete.="n.hardware_id=h.id AND n.macaddr";break;
 296                      case "useragent": $laRequete.="h.useragent";$forceEgal=true;break;
 297                      case "workgroup": $laRequete.="h.workgroup";$forceEgal=true;break;
 298                      case "hname": $laRequete.="h.name";break;
 299                      case "description": $laRequete.="h.description";break;
 300                      case "lastdate": $laRequete.="h.lastdate";break;
 301                      case "smonitor": $laRequete.="m.hardware_id=h.id AND m.serial";break;
 302                      default: $laRequete.="a.".$_POST["chm_".$i]; break;
 303                  }        
 304                  
 305                  if( ! $forceEgal ) {
 306                      switch($_POST["ega_".$i]) {
 307                          case $l->g(410): $laRequete.=" = ";$forceEgal=true; break;    
 308                          case $l->g(129): $laRequete.=" LIKE ";$forceLike=true; break;                        
 309                          case $l->g(130): $laRequete.=" NOT LIKE ";$forceLike=true; break;                    
 310                          case $l->g(346):
 311                          case $l->g(201): $laRequete.="<"; $forceEgal=true; break;
 312                          case $l->g(347):
 313                          case $l->g(202): $laRequete.=">"; $forceEgal=true; break;
 314                          case $l->g(203): $laRequete.="<'".$_POST["val2_".$i]."' AND $tblIneq.".$_POST["chm_".$i].">"; $forceEgal=true; break;
 315                          //case $l->g(204): $laRequete.=">'".$_POST["val2_".$i]."' OR h.".$_POST["chm_".$i]."<";break;
 316                          default: $laRequete.=" LIKE "; $forceLike=true;break;
 317                      }
 318                  }
 319                  else 
 320                      $laRequete.=" = ";
 321                  
 322                  if( $forceEgal || !$forceLike )
 323                      $laRequete.="'".$_POST["val_".$i]."'";    
 324                  else
 325                      $laRequete.="'%".$_POST["val_".$i]."%'";                
 326              }            
 327          }
 328          
 329          if( $nb > 0 ) {        
 330              $laRequeteF=$laRequete;                
 331              $logIndexEg = 1;
 332      
 333              for($ii=0;$ii<sizeof($softsEg);$ii++) {            
 334                  $selFinal .= " AND ";
 335                  if( ! $first  ) {
 336                          $laRequeteF .= " AND ";                                
 337                  }
 338                  else
 339                      $first = false;
 340                  
 341                  $comp = $softsEg[$ii][2] == $l->g(129) ? " like '%" : " = '";
 342                  $compFin = $softsEg[$ii][2] == $l->g(129) ? "%' " : "' ";
 343                  $laRequeteF .= " s$logIndexEg.hardware_id=h.id AND s$logIndexEg.name$comp".$softsEg[$ii][0]."$compFin";
 344                  $selFinal .= " s$logIndexEg.hardware_id=h.id AND s$logIndexEg.name$comp".$softsEg[$ii][0]."$compFin";
 345                  $logIndexEg++;
 346              }
 347                          
 348              for($ii=0;$ii<sizeof($softsDi);$ii++) {
 349                  $reqInterm = "";
 350                  if( !$first ) $laRequeteF .=" AND";
 351                  $first = false;                
 352                  $laRequeteF .= " h.id NOT IN(SELECT DISTINCT(ss.hardware_id) FROM softwares ss WHERE ss.name like '%".$softsDi[$ii][0]."%')";
 353              }
 354              
 355              if(sizeof($regDiff)>=1) {
 356                  if($regDiff[1]!=$l->g(265)) {
 357                      $valRegR = "AND rr.regvalue = '".$regDiff[1]."'";
 358                  }
 359                  
 360                  if( !$first ) $laRequeteF .= " AND";
 361                  $laRequeteF .= " h.id NOT IN(SELECT DISTINCT(rr.hardware_id) FROM registry rr WHERE rr.name = '".$regDiff[0]."' $valRegR)";
 362              }
 363              if( ! $first && $mesMachines != "" ) $laRequeteF .= " AND ";
 364              
 365              
 366              $group =  " h.id";
 367              
 368              $lbl="Recherche multicritères";    
 369              $lblChmp[0]=NULL;
 370              $selectPrelim = array("h.id"=>"h.id");
 371              $linkId = "h.id";
 372              $whereId = "h.id";
 373              $countId = "h.id";
 374     
 375              $req=new Req($lbl,$whereId,$linkId,$laRequeteF,$leSelect,$selectPrelim,$from,$fromPrelim,$group,"h.lastdate DESC",$countId,null,true,null,null,null,null,$selFinal);
 376          }        
 377      }
 378      else if($_GET["redo"] || $_GET["c"] || $_GET["av"] || $_GET["page"] || isset($_GET["pcparpage"]) || isset($_GET["newcol"])  )
 379      {
 380          $lblChmp[0]=NULL;                
 381          $req=new Req($_SESSION["storedRequest"]->label,$_SESSION["storedRequest"]->whereId,$_SESSION["storedRequest"]->linkId,$_SESSION["storedRequest"]->where,$leSelect,$_SESSION["storedRequest"]->selectPrelim,
 382          $_SESSION["storedRequest"]->from,$_SESSION["storedRequest"]->fromPrelim,$_SESSION["storedRequest"]->group,$_SESSION["storedRequest"]->order,$_SESSION["storedRequest"]->countId,null,true,null,null,null,null,$_SESSION["storedRequest"]->selFinal); // Instanciation du nouvel objet de type "Req"        
 383          //echo $requeteCount[0];
 384      }    
 385      
 386      if( $req != NULL )
 387          ShowResults($req);
 388  
 389  ?>
 390  
 391  <br>
 392  <table border=0 width=80% align=center><tr align=right><td width=50%>
 393  <form name='optionss' action='index.php?multi=1' method='post'><b><?echo $l->g(31);?>:&nbsp;&nbsp;&nbsp;</b> 
 394  <select name=selOpt OnChange="optionss.submit();"><?
 395  
 396  $optArray = array($l->g(34), $l->g(33), $l->g(20), $l->g(26), $l->g(35),
 397  $l->g(36), $l->g(207), $l->g(25), $l->g(24), $l->g(377), $l->g(65), $l->g(284), $l->g(64), $l->g(359), 
 398  TAG_LBL, $l->g(357), $l->g(46),$l->g(257),$l->g(331),$l->g(209),$l->g(53),$l->g(45), $l->g(312), $l->g(429), $l->g(512),$l->g(95));
 399  
 400  $optArray  = array_merge( $optArray, $_SESSION["optCol"]);
 401  sort($optArray);
 402  $countHl++;
 403  echo "<option".($countHl%2==1?" class='hi'":"").">".$l->g(32)."</option>"; $countHl++;
 404  
 405  foreach( $optArray as $val) {
 406      if( (!is_array($_SESSION["OPT"]) || !in_array($val,$_SESSION["OPT"])) && $val!="DEVICEID"&& $val!="HARDWARE_ID" || $val==$l->g(20)) {
 407          $countHl++;
 408          echo "<option".($countHl%2==1?" class='hi'":"").">$val</option>";
 409      }
 410  }
 411  
 412  ?>
 413  </select>
 414  </form></td><td align=left>
 415  <form method=post name=res action=index.php?multi=1><input taborder=2 type=submit name=reset value=<?echo $l->g(41);?>></form></td>
 416  </td></tr></table>
 417  
 418  <?
 419  
 420  if($_SESSION["OPT"]!=0)
 421  {    
 422      echo "<form name=machine action=index.php?multi=1 method=post><table border=1 class= 'Fenetre' WIDTH = '75%' ALIGN = 'Center' CELLPADDING='5'>";
 423      
 424      $ligne[] = array( $l->g(34),"ipaddr","hardware","",2,5,"",false,true);
 425      $ligne[] = array( $l->g(33),"workgroup","hardware","SELECT workgroup FROM hardware GROUP BY workgroup",1,1,"",false,true);
 426      
 427      foreach( $_SESSION["OPT"] as $op )
 428          if( $op == $l->g(20) )
 429              $ligne[] = array( $l->g(20),"name","softwares","",2,7,"",false,true);
 430      
 431      $ligne[] = array( $l->g(26),"memory","hardware","",2,3,"MO",false,false);
 432      $ligne[] = array( $l->g(35),"hname","hardware","",2,1,"",false,true);
 433      $ligne[] = array( $l->g(53),"description","hardware","",2,1,"",false,true);
 434      $ligne[] = array( $l->g(46),"lastdate","hardware","",2,2,"",true);
 435      $ligne[] = array( $l->g(357),"useragent","hardware","SELECT useragent FROM hardware GROUP BY useragent",1,1,"",false,false);
 436      $ligne[] = array( $l->g(36),"ssn","bios","",2,1,"",false,true);    
 437      $ligne[] = array( $l->g(64),"smanufacturer","bios","",2,1,"",false,true);
 438      $ligne[] = array( $l->g(65),"smodel","bios","",2,1,"",false,true);
 439      $ligne[] = array( $l->g(284),"bmanufacturer","bios","",2,1,"",false,true);
 440      $ligne[] = array( $l->g(207),"ipgateway","networks","",2,5,"",false,true);
 441      $ligne[] = array( $l->g(331),"ipsubnet","networks","",2,5,"",false,true);
 442      $ligne[] = array( $l->g(95),"macaddr","networks","",2,5,"",false,true);
 443      $ligne[] = array( $l->g(25),"osname","hardware","SELECT osname FROM hardware GROUP BY osname",1,1,"",false,false);
 444      $ligne[] = array( $l->g(24),"userid","hardware","SELECT userid FROM hardware GROUP BY userid",2,1,"",false,true);
 445      $ligne[] = array( $l->g(377),"processors","hardware","",2,3,"MHZ",false,false);
 446      $ligne[] = array( $l->g(45),"free","drives","",2,3,"MB",false,false);
 447      $ligne[] = array( $l->g(257),"regname","hardware","SELECT DISTINCT(name) FROM registry",1,6,"",false,false);
 448      $ligne[] = array( $l->g(359),"smonitor","hardware","",2,1,"",false,true);
 449      $ligne[] = array( $l->g(209),"bversion","bios","",2,1,"",false,true);
 450  
 451      //HARDCODED OPTIONS
 452      $ligne[] = array( $l->g(312), "ipdisc");
 453      $ligne[] = array( $l->g(429), "freq" );
 454      $ligne[] = array( $l->g(512), "tele" );
 455      //GEND
 456      $ligne[] = array( TAG_LBL,"cu","accountinfo","",2,4,"",false,false);
 457      //FGEND    
 458      foreach($_SESSION["optCol"] AS $col) {
 459          if($col!="TAG"&&$col!="DEVICEID"&&$col!="HARDWARE_ID") {
 460              $isDate = isFieldDate($col);
 461              $ligne[]  =  array( $col,$col,"hardware","accountinfo",2,$isDate ? 2 : 1,"",$isDate,true);
 462          }
 463      }
 464      
 465      foreach( $ligne as $laLigne) {
 466          $colATrier[] = $laLigne[0];
 467      }
 468      $indLigneSoft = 0;
 469      sort($colATrier);
 470      foreach($colATrier as $nomLigne) {
 471          foreach($ligne as $laLigne) {
 472              if($laLigne[0] == $nomLigne) {
 473                  afficheLigne($laLigne);
 474                  break;
 475              }
 476          }
 477      }    
 478      
 479      $color=$indLigne%2==0?"#F2F2F2":"#FFFFFF";
 480      echo "<tr bgcolor='$color'><td colspan='3' align='right'><input type='hidden' name='max' value='$indLigne'>";
 481      
 482      if($_SESSION["OPT"]!=0)
 483      {
 484          echo "<input type=submit taborder=1 name=sub value=".$l->g(30).">";
 485      }    
 486      echo "</td></tr></table></form>";
 487      if($_SESSION["OPT"]!=0)
 488      {
 489          echo "<center><i>".$l->g(358)."</i></font></center><br>";
 490      }    
 491  }
 492  
 493  function afficheLigne($ligne)
 494  {    
 495      global $indLigne,$indLigneSoft,$l,$_POST;    
 496      
 497      $label = $ligne[0];
 498      $champ = $ligne[1];
 499      $table = $ligne[2];
 500      $laRequete = $ligne[3];
 501      $combo = isset($ligne[4]) ? $ligne[4] : 1 ;
 502      $type = isset($ligne[5]) ? $ligne[5] : 1 ;
 503      $leg = isset($ligne[6]) ? $ligne[6] : "" ;
 504      $isDate = isset($ligne[7]) ? $ligne[7] : false ;
 505      $allowExact = isset($ligne[8]) ? $ligne[8] : true ;
 506  
 507      if(is_array($_SESSION["OPT"])) {
 508          if(!in_array($label,$_SESSION["OPT"]))
 509              return;
 510      }
 511      else
 512          return;
 513      
 514      $color=$indLigne%2==0?"#F2F2F2":"#FFFFFF";
 515      $suff="_".$indLigne;
 516      
 517      if( $type == 7) {// un soft
 518          echo"<tr bgcolor=$color><td>
 519              <input type=checkbox id='act$suff' name='act$suff'".($_SESSION["softs"][$indLigneSoft][0]=="on"?" checked":"").">&nbsp;".$l->g(205)."</input>
 520              <input type=hidden name='chm$suff' value=$champ>
 521              <input type=hidden name='lbl$suff' value='".urlencode($label)."'>
 522          </td><td><font color=#000000>$label</font></td><td>";
 523          echo "<select OnClick='act$suff.checked=true' name='ega$suff'>";        
 524          echo "<option".($_SESSION["softs"][$indLigneSoft][2]==$l->g(129)?" selected":"").">".$l->g(129)."</option>";
 525          if( $allowExact ) echo "<option".($_SESSION["softs"][$indLigneSoft][2]==$l->g(410)?" selected":"").">".$l->g(410)."</option>";
 526          echo "<option".($_SESSION["softs"][$indLigneSoft][2]==$l->g(130)?" selected":"").">".$l->g(130)."</option>";
 527          echo "</select>&nbsp;&nbsp;";
 528          echo "<input OnClick='act$suff.checked=true' name='val$suff' value=\"".stripslashes($_SESSION["softs"][$indLigneSoft][3])."\">";
 529          $indLigne++;
 530          $indLigneSoft++;
 531          return;
 532      }
 533  
 534      echo"        
 535      <tr bgcolor=$color>
 536          <td>
 537              <input type=checkbox id='act$suff' name='act$suff'".($_SESSION["reqs"][$label][0]=="on"?" checked":"").">&nbsp;".$l->g(205)."</input>
 538              <input type=hidden name='chm$suff' value=$champ>
 539              <input type=hidden name='lbl$suff' value='".urlencode($label)."'>
 540          </td>
 541          <td><font color=#000000>
 542              $label
 543          </font>    
 544          </td>
 545          <td>";    
 546          
 547      if( $champ == "ipdisc" ) {    
 548          echo "<select OnClick='act$suff.checked=true' name='val$suff'>
 549          <option ".($_SESSION["reqs"][$label][3]=="elu"?" selected":"")." value='elu'>".$l->g(502)."</option>
 550          <option ".($_SESSION["reqs"][$label][3]=="for"?" selected":"")." value='for'>".$l->g(503)."</option>
 551          <option ".($_SESSION["reqs"][$label][3]=="nelu"?" selected":"")." value='nelu'>".$l->g(504)."</option>
 552          <option ".($_SESSION["reqs"][$label][3]=="eli"?" selected":"")." value='eli'>".$l->g(505)."</option>
 553          <option ".($_SESSION["reqs"][$label][3]=="neli"?" selected":"")." value='neli'>".$l->g(506)."</option></select></td></tr>";
 554          $indLigne++;
 555          return;    
 556      }
 557      else if( $champ == "freq" ) {
 558          echo "<select OnClick='act$suff.checked=true' name='val$suff'>
 559          <option ".($_SESSION["reqs"][$label][3]=="std"?" selected":"")." value='std'>".$l->g(488)."</option>
 560          <option ".($_SESSION["reqs"][$label][3]=="always"?" selected":"")." value='always'>".$l->g(485)."</option>
 561          <option ".($_SESSION["reqs"][$label][3]=="never"?" selected":"")." value='never'>".$l->g(486)."</option>
 562          <option ".($_SESSION["reqs"][$label][3]=="custom"?" selected":"")." value='custom'>".$l->g(487)."</option></select></td></tr>";
 563          $indLigne++;
 564          return;    
 565      }
 566      else if( $champ == "tele" ) {
 567          
 568          $resTele = @mysql_query("SELECT distinct(NAME) FROM download_available", $_SESSION["readServer"]);
 569          
 570          if( mysql_num_rows( $resTele ) >0 ) {        
 571              echo "<select OnClick='act$suff.checked=true' name='ega$suff'>
 572              <option ".($_SESSION["reqs"][$label][2]=="ayant"?" selected":"")." value='ayant'>".$l->g(507)."</option>
 573              <option ".($_SESSION["reqs"][$label][2]=="nayant"?" selected":"")." value='nayant'>".$l->g(508)."</option>
 574              </select>  ".$l->g(498).": <select OnClick='act$suff.checked=true' name='val$suff'>";
 575              while( $valTele = mysql_fetch_array( $resTele )) {
 576                  echo "<option ".($_SESSION["reqs"][$label][3]==$valTele["NAME"]?" selected":"").">".$valTele["NAME"]."
 577                  </option>";    
 578              }                
 579              
 580              echo "</select> ".$l->g(546).": <select OnClick='act$suff.checked=true' name='val2$suff'>
 581              <option ".($_SESSION["reqs"][$label][4]=="ind"?" selected":"")." value='ind'>".$l->g(509)."</option>
 582              <option ".($_SESSION["reqs"][$label][4]=="nsuc"?" selected":"")." value='nsuc'>".$l->g(548)."</option>
 583              <option ".($_SESSION["reqs"][$label][4]=="suc"?" selected":"")." value='suc'>SUCCESS</option>";
 584              
 585              $resState = @mysql_query("SELECT distinct(tvalue) FROM devices WHERE name='DOWNLOAD' AND tvalue NOT LIKE
 586               'SUCCESS_%' AND tvalue IS NOT NULL", $_SESSION["readServer"]);
 587              while( $valState = @mysql_fetch_array( $resState )) {
 588                  echo "<option ".($_SESSION["reqs"][$label][4]==$valState["tvalue"]?" selected":"")." value='".$valState["tvalue"]."'>".$valState["tvalue"]."</option>";
 589              }         
 590              
 591              echo "</select>";
 592              $indLigne++;
 593          }
 594          else {
 595              echo $l->g(510);    
 596          }
 597          return;    
 598      }
 599          
 600          if($type != 4 && $type != 6) {
 601                      
 602              echo "<select OnClick='act$suff.checked=true' name='ega$suff'>            
 603              <option".($_SESSION["reqs"][$label][2]==$l->g(129)?" selected":"").">".$l->g(129)."</option>";
 604              if( $allowExact ) echo "<option".($_SESSION["reqs"][$label][2]==$l->g(410)?" selected":"").">".$l->g(410)."</option>";
 605              echo "<option".($_SESSION["reqs"][$label][2]==$l->g(130)?" selected":"").">".$l->g(130)."</option>";
 606      
 607              if( $isDate) {
 608                  echo "<option".($_SESSION["reqs"][$label][2]==$l->g(346)?" selected":"").">".$l->g(346)."</option><option".($_SESSION["reqs"][$label][2]==$l->g(347)?" selected":"").">".$l->g(347)."</option>"; 
 609              }
 610              else if( $type==2||$type==3 )
 611              {
 612                  echo "<option".($_SESSION["reqs"][$label][2]==$l->g(201)?" selected":"").">".$l->g(201)."</option><option".($_SESSION["reqs"][$label][2]==$l->g(202)?" selected":"").">".$l->g(202)."</option>";
 613              }
 614              if ($type==3)
 615              {
 616                  echo "<option".($_SESSION["reqs"][$label][2]==$l->g(203)?" selected":"").">".$l->g(203)."</option>";//<option".($_POST["ega$suff"]==$l->g(204)?" selected":"").">".$l->g(204)."</option>";        
 617              }
 618          }
 619          else if( $type != 6)
 620              echo $l->g(129);
 621          if( $type != 6)
 622              echo "</select>&nbsp;&nbsp;";
 623              
 624      if($combo==1)
 625      {
 626          echo "<select OnClick='act$suff.checked=true' name='val$suff'>";    
 627          $res=mysql_query($laRequete, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
 628          
 629          $linSel = "Linux"== $_SESSION["reqs"][$label][3] ?" selected":"";
 630          $winSel = "Windows"== $_SESSION["reqs"][$label][3] ?" selected":"";
 631          
 632          if( $champ=="osname")
 633              echo "<option value='Linux' $linSel>LINUX (".$l->g(547).")</option>
 634                    <option value='Windows' $winSel>WINDOWS (".$l->g(547).")</option>";
 635          
 636          while($row=mysql_fetch_array($res))
 637          {
 638              if($row[0]=="") continue;    
 639              $selected = $row[0]== $_SESSION["reqs"][$label][3] ?" selected":"";
 640              echo "<option$selected>".$row[0]."</option>\n";    
 641          }
 642          
 643          echo "</select>";
 644      }
 645      else
 646      {
 647          if( $isDate ) {
 648              echo "<input READONLY ".dateOnClick("val$suff","act$suff")." OnClick='act$suff.checked=true' name='val$suff' id='val$suff' value='"./*dateFromMysql(*/$_SESSION["reqs"][$label][3]/*)*/."'>".datePick("val$suff","act$suff");
 649          }
 650          else
 651              echo "<input OnClick='act$suff.checked=true' name='val$suff' value=\"".stripslashes($_SESSION["reqs"][$label][3])."\">";
 652          
 653          if ($type==3) // deux inputs pour "entre machin et truc"
 654          {
 655              echo "&nbsp;&nbsp;--&nbsp;&nbsp;<input OnClick='act$suff.checked=true' name='val2$suff' value='".$_SESSION["reqs"][$label][4]."'>";
 656          }    
 657      }
 658      if( $type == 6) {
 659              echo "<select OnClick='act$suff.checked=true' name='ega$suff'>            
 660              <option".($_SESSION["reqs"][$label][2]==$l->g(129)?" selected":"").">".$l->g(129)."</option>";
 661              if( $allowExact ) echo "<option".($_SESSION["reqs"][$label][2]==$l->g(410)?" selected":"").">".$l->g(410)."</option>";
 662              echo "<option".($_SESSION["reqs"][$label][2]==$l->g(130)?" selected":"").">".$l->g(130)."</option></select>";
 663              /*$reqRes = mysql_query("SELECT DISTINCT(regvalue) FROM registry", $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"])); //todo mesmachines
 664              echo "&nbsp;&nbsp;".$l->g(224).":&nbsp;&nbsp;*/
 665              echo "<input OnClick='act$suff.checked=true' name='valreg$suff' value='".($_SESSION["reqs"][$label][5])."'>";
 666                      
 667              /*while($row=mysql_fetch_array($reqRes))
 668              {
 669                  if($row[0]=="") continue;    
 670                  $selected = $row[0]== $_SESSION["reqs"][$label][5] ?" selected":"";
 671                  echo "<option$selected>".$row[0]."</option>\n";    
 672              }*/
 673              
 674              echo "</input>";            
 675      }    
 676      
 677      echo "&nbsp;&nbsp;&nbsp;$leg</td></tr>";
 678      $indLigne++;
 679  }
 680  
 681  function isFieldDate($nom) {
 682      if( $nom == "lastdate" )
 683          return true;
 684          
 685      $reqType = "SELECT $nom FROM accountinfo";
 686      if( $resType = @mysql_query($reqType, $_SESSION["readServer"])) {
 687          $valType = mysql_fetch_field($resType);
 688          return ($valType->type == "date");
 689      }
 690      return false;
 691  }
 692  
 693          
 694  ?>


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