[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/package/ -> export.php (source)

   1  <?php
   2  //
   3  // Created on: <21-Nov-2003 18:11:45 amos>
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  include_once ( "kernel/classes/ezpackage.php" );
  28  
  29  $module =& $Params['Module'];
  30  
  31  $packageName = $Params['PackageName'];
  32  
  33  $package = eZPackage::fetch( $packageName );
  34  if ( !$package )
  35      return $module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
  36  
  37  if ( !$package->attribute( 'can_export' ) )
  38      return $module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' );
  39  
  40  
  41  $exportDirectory = eZPackage::temporaryExportPath();
  42  $exportName = $package->exportName();
  43  $exportPath = $exportDirectory . '/' . $exportName;
  44  $exportPath = $package->exportToArchive( $exportPath );
  45  
  46  //return $module->redirectToView( 'view', array( 'full', $package->attribute( 'name' ) ) );
  47  
  48  $fileName = $exportPath;
  49  if ( $fileName != "" and file_exists( $fileName ) )
  50  {
  51      clearstatcache();
  52      $fileSize = filesize( $fileName );
  53      $mimeType =  'application/octet-stream';
  54      $originalFileName = $exportName;
  55      $contentLength = $fileSize;
  56      $fileOffset = false;
  57      $fileLength = false;
  58      if ( isset( $_SERVER['HTTP_RANGE'] ) )
  59      {
  60          $httpRange = trim( $_SERVER['HTTP_RANGE'] );
  61          if ( preg_match( "/^bytes=([0-9]+)-$/", $httpRange, $matches ) )
  62          {
  63              $fileOffset = $matches[1];
  64              header( "Content-Range: bytes $fileOffset-" . $fileSize - 1 . "/$fileSize" );
  65              header( "HTTP/1.1 206 Partial content" );
  66              $contentLength -= $fileOffset;
  67          }
  68      }
  69  
  70      header( "Pragma: " );
  71      header( "Cache-Control: " );
  72      header( "Content-Length: $contentLength" );
  73      header( "Content-Type: $mimeType" );
  74      header( "X-Powered-By: eZ publish" );
  75      header( "Content-disposition: attachment; filename=$originalFileName" );
  76      header( "Content-Transfer-Encoding: binary" );
  77      header( "Accept-Ranges: bytes" );
  78  
  79      $fh = fopen( $fileName, "rb" );
  80      if ( $fileOffset )
  81      {
  82          eZDebug::writeDebug( $fileOffset, "seeking to fileoffset" );
  83          fseek( $fh, $fileOffset );
  84      }
  85  
  86      ob_end_clean();
  87      fpassthru( $fh );
  88      fflush( $fh );
  89      fclose( $fh );
  90      unlink( $fileName );
  91      eZExecution::cleanExit();
  92  }
  93  
  94  
  95  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7