[ Index ] |
PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 $phpwcms = array(); 24 25 require_once ('config/phpwcms/conf.inc.php'); 26 27 if( !empty($phpwcms['SESSION_FEinit']) ) { 28 @session_start(); 29 } 30 31 require_once ('include/inc_lib/default.inc.php'); 32 require_once (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php'); 33 require_once (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php'); 34 35 // try to get hash for file download 36 $success = false; 37 $hash = false; 38 $countonly = empty($_GET['countonly']) ? false : true; 39 $hash = empty($_GET['f']) ? '' : clean_slweg($_GET['f']); 40 41 if(isset($_GET['target'])) { 42 $phpwcms["inline_download"] = empty($_GET['target']) ? 0 : 1; 43 } elseif(!isset($phpwcms["inline_download"])) { 44 $phpwcms["inline_download"] = 0; 45 } 46 47 if(!empty($hash) && strlen($hash) == 32) { 48 49 require_once (PHPWCMS_ROOT.'/include/inc_lib/functions.file.inc.php'); 50 require_once (PHPWCMS_ROOT.'/include/inc_front/front.func.inc.php'); 51 52 _checkFrontendUserAutoLogin(); 53 54 // get file info - limit 1 entry 55 $download = _getFileInfo($hash, 1); 56 57 if(is_array($download) && count($download)) { 58 // all we need is the first array value 59 60 $download = current($download); 61 62 // ok fine - we have download information 63 // then count up download try for this file 64 $sql = "UPDATE ".DB_PREPEND."phpwcms_file "; 65 $sql .= "SET f_dlstart=f_dlstart+1 WHERE "; 66 $sql .= "f_hash='".aporeplace($download["f_hash"])."' LIMIT 1"; 67 @mysql_query($sql, $db); 68 69 70 $fileinfo = array(); 71 72 $fileinfo['filename'] = $download["f_hash"]; 73 if($download["f_ext"]) { 74 $fileinfo['filename'] .= '.'.$download["f_ext"]; 75 } 76 77 // just count up a download 78 if($countonly) { 79 80 $success = true; 81 82 // just use built-in download 83 } else { 84 85 86 $fileinfo['path'] = PHPWCMS_ROOT.$phpwcms["file_path"]; 87 $fileinfo['filesize'] = $download['f_size']; 88 $fileinfo['method'] = empty($phpwcms["inline_download"]) ? 'attachment' : 'inline'; 89 $fileinfo['mimetype'] = $download["f_type"]; 90 $fileinfo['file'] = $fileinfo['path'].$fileinfo['filename']; 91 $fileinfo['extension'] = $download["f_ext"]; 92 $fileinfo['realfname'] = $download["f_name"]; 93 94 // start download 95 $success = dl_file_resume($fileinfo['file'], $fileinfo, true); 96 97 } 98 99 100 } 101 102 // we hack in the stream.php here 103 } elseif( ($file = isset($_GET['file']) ? clean_slweg($_GET['file'], 40) : '') ) { 104 105 $filename = basename($file); 106 $file = PHPWCMS_ROOT.'/'.PHPWCMS_FILES . $filename; 107 108 if(is_file($file)) { 109 110 $mime = empty($_GET['type']) ? '' : clean_slweg($_GET['type'], 100); 111 112 if(!is_mimetype_format($mime)) { 113 $mime = get_mimetype_by_extension( which_ext($file) ); 114 } 115 116 header('Content-Type: ' . $mime); 117 118 if(BROWSER_OS == 'iOS') { 119 120 require_once (PHPWCMS_ROOT.'/include/inc_lib/functions.file.inc.php'); 121 122 rangeDownload($file); 123 124 } else { 125 126 header('Content-Transfer-Encoding: binary'); 127 if(!isset($_GET['ios'])) { 128 header('Content-Disposition: inline; filename="'.$filename.'"'); 129 } 130 header('Content-Length: ' . filesize($file)); 131 132 readfile($file); 133 134 } 135 136 $success = true; 137 138 } 139 140 } 141 142 if($success) { 143 144 $sql = "UPDATE ".DB_PREPEND."phpwcms_file "; 145 $sql .= "SET f_dlfinal=f_dlfinal+1 WHERE f_hash='".aporeplace($download["f_hash"])."' LIMIT 1"; 146 @mysql_query($sql, $db); 147 148 if($countonly) { 149 150 headerRedirect(PHPWCMS_URL . PHPWCMS_FILES . $fileinfo['filename']); 151 152 } 153 154 } else { 155 156 header("HTTP/1.0 404 Not Found"); 157 echo '<strong>404 File Not Found</strong>'; 158 159 } 160 161 exit(); 162 163 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Jan 29 16:31:14 2012 | Cross-referenced by PHPXref 0.7.1 |