Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezimagecatalogue/user/filedownload.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: filedownload.php 6484 2001-08-17 13:36:01Z jhe $
5 //
6 // Created on: <10-Dec-2000 16:39:10 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // clear what might be in the output buffer
28 ob_end_clean();
29
30 // include_once( "ezimagecatalogue/classes/ezimage.php" );
31 // include_once( "ezuser/classes/ezobjectpermission.php" );
32 // include_once( "ezuser/classes/ezuser.php" );
33
34 $ini =& eZINI::instance( 'site.ini' );
35 $watermarkToggle = $ini->variable( "watermark", "watermarkEnabled" ) == "true" ? true : false;
36
37 $file = new eZImage( $ImageID );
38
39 // $fileName = $file->fileName();
40 $fileName = $file->name();
41 $originalFileName = $file->originalFileName();
42 $filePath = $file->filePath( true );
43
44 if ( $watermarkToggle == true )
45 {
46 $watermarkPath = $file->watermarkPath(true);
47 $watermarkFileSize = eZPBFile::filesize( $watermarkPath );
48 }
49
50 $user =& eZUser::currentUser();
51 $image = new eZImage( $ImageID );
52 if ( eZObjectPermission::hasPermission( $image->id(), "imagecatalogue_image", "r", $user ) == false )
53 {
54 eZHTTPTool::header( "Location: /error/403/" );
55 exit();
56 }
57
58 // print( $filePath );
59
60 // # the file may be a local file with full path.
61 $fileSize = eZPBFile::filesize( $filePath );
62 $fp = eZPBFile::fopen( $filePath, "r" );
63 $content =& fread( $fp, $fileSize );
64
65 //Header("Content-type: application/oct-stream");
66 //Header("Content-length: $fileSize");
67 //Header("Content-disposition: attachment; filename=\"$originalFileName\"");
68 /*
69 //header( "Cache-Control:" );
70 Header("Content-type: application/oct-stream");
71 Header( "Content-Length: $fileSize" );
72 Header( "Content-disposition: attachment; filename=\"$fileName\"" );
73 //header( "Content-Transfer-Encoding: binary" );
74 */
75
76 //echo($content);
77 if ( $watermarkToggle == true ) {
78 header( "Cache-Control:" );
79 Header("Content-type: application/oct-stream");
80 header( "Content-Length: $watermarkFileSize" );
81 header( "Content-disposition: attachment; filename=\"$originalFileName\"" );
82
83 $fh = eZPBFile::fopen( "$watermarkPath", "rb" );
84 fpassthru( $fh );
85 exit();
86 } else {
87 header( "Cache-Control:" );
88 Header("Content-type: application/oct-stream");
89 header( "Content-Length: $fileSize" );
90 header( "Content-disposition: attachment; filename=\"$originalFileName\"" );
91 //header( "Content-Transfer-Encoding: binary" );
92
93 $fh = eZPBFile::fopen( "$filePath", "rb" );
94 fpassthru( $fh );
95 exit();
96 }
97
98 //$fh = eZPBFile::fopen( "../ezimagecatalogue/catalogue/$fileName", "rb" );
99 //fpassthru( $fh );
100 //exit();
101
102 ?>
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZImage
Definition: ezimage.php:95
eZObjectPermission\hasPermission
static hasPermission( $objectID, $moduleTable, $permission, $user=false)
Definition: ezobjectpermission.php:76
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZPBFile\filesize
static filesize( $filename)
Definition: ezpbfile.php:339
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$ImageID
$ImageID
Definition: companytypelist.php:201
$fh
$fh
Definition: ezimagecatalogue/user/filedownload.php:93
$fp
$fp
Definition: ezimagecatalogue/user/filedownload.php:62
$watermarkToggle
$watermarkToggle
Definition: ezimagecatalogue/user/filedownload.php:35
$user
if( $watermarkToggle==true) $user
Definition: ezimagecatalogue/user/filedownload.php:50
$content
$content
Definition: ezimagecatalogue/user/filedownload.php:63
$originalFileName
$originalFileName
Definition: ezimagecatalogue/user/filedownload.php:41
$fileName
$fileName
Definition: ezimagecatalogue/user/filedownload.php:40
$fileSize
if(eZObjectPermission::hasPermission( $image->id(), "imagecatalogue_image", "r", $user)==false) $fileSize
Definition: ezimagecatalogue/user/filedownload.php:61
$ini
$ini
Definition: ezimagecatalogue/user/filedownload.php:34
$file
$file
Definition: ezimagecatalogue/user/filedownload.php:37
$image
$image
Definition: ezimagecatalogue/user/filedownload.php:51
$filePath
$filePath
Definition: ezimagecatalogue/user/filedownload.php:42
exit
exit
Definition: folder.php:81
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.