[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-ocs/sources/www/ -> ipcsv.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/13/2005
  12  include ("req.class.php");
  13  include ("preferences.php");
  14  
  15  if( isset($_SESSION["forcedRequest"] )) {
  16      $lareq = $_SESSION["forcedRequest"];
  17      unset( $_SESSION["forcedRequest"] );
  18  }
  19  else
  20      $lareq = $_SESSION["storedRequest"]->getFullRequest();
  21  
  22  $lareq = str_replace("h.id AS \"h.id\",","",$lareq);
  23  $lareq = str_replace("deviceid AS \"deviceid\",","",$lareq);
  24  //echo $lareq;die();
  25  $result=mysql_query($lareq, $_SESSION["readServer"]) or die(mysql_error($_SESSION["readServer"]));
  26  
  27  // iexplorer problem
  28  if( ini_get("zlib.output-compression"))
  29      ini_set("zlib.output-compression","Off");
  30      
  31  header("Pragma: public");
  32  header("Expires: 0");
  33  header("Cache-control: must-revalidate, post-check=0, pre-check=0");
  34  header("Cache-control: private", false);
  35  header("Content-type: application/force-download");
  36  header("Content-Disposition: attachment; filename=\"export.csv\"");
  37  header("Content-Transfer-Encoding: binary");
  38  
  39  $colnb = 0;
  40  $nameIndex = -1;
  41  $toBeWritten = "";
  42  
  43  while( $colname = mysql_fetch_field($result) ) {
  44      $cols[] = $colname->name;
  45      $nameIndex = ($colname->name == $l->g(24) ? $colnb : $nameIndex);
  46      $colnb++;    
  47  }
  48  writeTab($fp,$cols);
  49  
  50  while( $cont = mysql_fetch_array($result,MYSQL_ASSOC) ) {
  51      writeTab($fp,$cont,$nameIndex);
  52  }
  53  
  54  header("Content-Length: ".strlen($toBeWritten));
  55  echo $toBeWritten;
  56  
  57  function writeTab ($fich,$tab,$rgn=-1) {    
  58      global $toBeWritten;
  59      $colnb = 0;
  60      foreach($tab as $t) {
  61              $toBeWritten .= $t;
  62  
  63          $toBeWritten .= ",";
  64          $colnb++;
  65      }
  66      $toBeWritten .= "\r\n";
  67  }
  68  ?>


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