[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

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

   1  <?
   2  //====================================================================================
   3  // OCS INVENTORY REPORTS
   4  // Copyleft Pierre LEMMET 2006
   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 06/23/2006
  12  
  13  
  14  if( ! isset($_SESSION["saveRequest"]))
  15      $_SESSION["saveRequest"] = $_SESSION["storedRequest"];
  16  
  17  if( isset($_GET["affpack"])) {
  18      $ok = resetPack( $_GET["affpack"] );
  19      $ok = $ok && setPack( $_GET["affpack"] );
  20      if( $ok ) {
  21          $_SESSION["storedRequest"] = $_SESSION["saveRequest"];
  22          
  23          if( ! isset( $_GET["systemid"] ) )
  24              echo "<script language='javascript'>window.location='index.php?redo=1".$_SESSION["queryString"]."';</script>";
  25          else
  26              echo "<script language='javascript'>history.go(-2);</script>";    
  27          die();
  28      }
  29  }
  30  else if( isset($_GET["suppack"])) {
  31      @mysql_query("DELETE FROM download_enable WHERE ID=".$_GET["suppack"], $_SESSION["writeServer"]) or die(mysql_error());    
  32      
  33      $reqSupp = "DELETE FROM devices WHERE name='DOWNLOAD' AND ivalue=".$_GET["suppack"];
  34      if( isset($_GET["nonnot"]) )
  35          $reqSupp .= " AND tvalue IS NULL";
  36      
  37      @mysql_query($reqSupp, $_SESSION["writeServer"]) or die(mysql_error());    
  38  }
  39      
  40  if( isset($_GET["systemid"]))
  41      $nbMach = 1;
  42  else
  43      $nbMach = getCount($_SESSION["saveRequest"]);
  44  
  45  if( $nbMach > 0 ) {
  46      $canAc = 1;
  47      PrintEnTete( $l->g(477)." <font class='warn'>($nbMach ".$l->g(478).")</font>");
  48  }
  49  else {
  50      die($l->g(478));    
  51  }
  52  if( ! isset( $_GET["systemid"] ) )
  53      echo "<br><center><a href='#' OnClick=\"window.location='index.php?redo=1".$_SESSION["queryString"]."';\"><= ".$l->g(188)."</a></center>";
  54  else
  55      echo "<br><center><a href='#' OnClick='history.go(-1);'><= ".$l->g(188)."</a></center>";
  56  
  57  
  58  if( isset($_GET["systemid"]))
  59      $canAc = 3; //preferences.php must set systemid in query string
  60      
  61  $lbl = "pack";    
  62  $sql = "d.fileid = e.fileid";
  63  $whereId = "d.FILEID=e.FILEID AND d.FILEID";
  64  $linkId = "d.FILEID";
  65  $select = array("ID"=>$l->g(460), "d.FILEID"=>$l->g(475), "NAME"=>$l->g(49), 
  66  "PRIORITY"=>$l->g(440),"INFO_LOC"=>$l->g(470), "PACK_LOC"=>$l->g(471), 
  67  "FRAGMENTS"=>$l->g(480), "SIZE"=>$l->g(462), "OSNAME"=>$l->g(25));    
  68  $selectPrelim = array("d.FILEID"=>"d.FILEID");    
  69  $from = "download_available d, download_enable e";
  70  $fromPrelim = "";
  71  $group = "";
  72  $order = "";
  73  $countId = "e.ID";
  74  
  75  $requete = new Req($lbl,$whereId,$linkId,$sql,$select,$selectPrelim,$from,$fromPrelim,$group,$order,$countId,true);
  76  ShowResults($requete,true,false,false,false,false,false,$canAc);
  77  $_SESSION["storedRequest"] = $_SESSION["saveRequest"];
  78  
  79  	function setPack( $packid ) {
  80          global $_GET;
  81          if( isset($_GET["systemid"])) {
  82              $val["h.id"] = $_GET["systemid"];
  83              if( ! @mysql_query( "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES('".$val["h.id"]."', 'DOWNLOAD', $packid )", $_SESSION["writeServer"] )) {
  84                  echo "<br><center><font color=red><b>ERROR: MySql connection problem<br>".mysql_error($_SESSION["writeServer"])."</b></font></center>";
  85                  return false;
  86              }
  87              $_SESSION["justAdded"] = true;
  88          }
  89          else {
  90              $lareq = getPrelim( $_SESSION["saveRequest"] );
  91              if( ! $res = @mysql_query( $lareq, $_SESSION["readServer"] ))
  92                  return false;
  93              while( $val = @mysql_fetch_array($res)) {
  94                  if( ! @mysql_query( "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES('".$val["h.id"]."', 'DOWNLOAD', $packid)", $_SESSION["writeServer"] )) {
  95                      echo "<br><center><font color=red><b>ERROR: MySql connection problem<br>".mysql_error($_SESSION["writeServer"])."</b></font></center>";
  96                      return false;
  97                  }
  98              }
  99          }
 100          return true;    
 101      }
 102      
 103  	function resetPack( $packid ) {
 104          
 105          global $_GET;
 106          if( isset($_GET["systemid"])) {
 107              $val["h.id"] = $_GET["systemid"];
 108              if( ! @mysql_query( "DELETE FROM devices WHERE name='DOWNLOAD' AND IVALUE=$packid AND hardware_id='".$val["h.id"]."'", $_SESSION["writeServer"] )) {
 109                  echo "<br><center><font color=red><b>ERROR: MySql connection problem<br>".mysql_error($_SESSION["writeServer"])."</b></font></center>";
 110                  return false;
 111              }
 112          }
 113          else {
 114              $lareq = getPrelim( $_SESSION["saveRequest"] );
 115              if( ! $res = @mysql_query( $lareq, $_SESSION["readServer"] ))
 116                  return false;
 117              while( $val = @mysql_fetch_array($res)) {
 118              
 119                  if( ! @mysql_query( "DELETE FROM devices WHERE name='DOWNLOAD' AND IVALUE=$packid AND hardware_id='".$val["h.id"]."'", $_SESSION["writeServer"] )) {
 120                      echo "<br><center><font color=red><b>ERROR: MySql connection problem<br>".mysql_error($_SESSION["writeServer"])."</b></font></center>";
 121                      return false;
 122                  }
 123              }
 124          }
 125  
 126          return true;        
 127          //TODO: comprends pas: echo "DELETE FROM devices WHERE name='FREQUENCY' AND hardware_id IN ($lareq)";flush();        
 128      }
 129  ?>


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