[ 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 session_start(); 24 $phpwcms = array(); 25 26 require_once ('../../config/phpwcms/conf.inc.php'); 27 require_once ('../inc_lib/default.inc.php'); 28 require_once (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php'); 29 30 require_once (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php'); 31 checkLogin(); 32 require_once (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php'); 33 34 35 $dl = isset($_GET["dl"]) ? intval($_GET["dl"]) : 0; 36 $pl = isset($_GET["pl"]) ? intval($_GET["pl"]) : 0; 37 38 if($dl) { 39 $err = 0; 40 if(!$pl) { 41 $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_file WHERE f_trash=0 AND ". 42 "f_id=".$dl." AND f_kid=1 AND f_uid=".intval($_SESSION["wcs_user_id"])." LIMIT 1"; 43 //09-20-2003: WHERE f_aktiv=1 AND... not neccessary 44 } else { 45 $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_file WHERE f_aktiv=1 AND f_trash=0 AND ". 46 "f_id=".$dl." AND f_kid=1 AND (f_public=1 OR f_uid=".intval($_SESSION["wcs_user_id"]).") LIMIT 1"; 47 } 48 49 if($result = mysql_query($sql, $db) or die ("error while retrieving file download infos")) {; 50 if($download = mysql_fetch_array($result)) { 51 52 $dl_filename = $download["f_hash"]; 53 if($download["f_ext"]) { 54 $dl_filename .= '.'.$download["f_ext"]; 55 } 56 57 $dl_path = PHPWCMS_ROOT.$phpwcms["file_path"]; 58 59 if(file_exists($dl_path.$dl_filename)) { 60 //Send file to user 61 //Downloads must downloaded to harddisk 62 //are not opened and showed inside browser 63 //if possible file format (PDF/JPG...) 64 //$att = (stristr($_SERVER['HTTP_USER_AGENT'],"MSIE")) ? "" : "attachment; "; 65 if(!is_mimetype_format($download["f_type"])) { 66 $download["f_type"] = get_mimetype_by_extension($download["f_ext"]); 67 } 68 69 header("Content-type: ".$download["f_type"]); 70 header('Content-Disposition: attachment; filename="'.$download["f_name"].'"'); 71 header("Content-Length: " . filesize($dl_path.$dl_filename)); 72 if(readfile($dl_path.$dl_filename)) { 73 exit(); 74 } else { 75 $err = 4; // Error reading file 76 } 77 78 } else { 79 $err = 1; // File does not exist 80 } 81 } else { 82 $err = 2; // File not found in database 83 } 84 } 85 } else { 86 $err = 3; // False ID given 87 } 88 89 if($err) { 90 session_destroy(); 91 92 ?><html> 93 <head> 94 <title>phpwcms File Error</title> 95 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo PHPWCMS_CHARSET ?>"> 96 <link href="../inc_css/phpwcms.css" rel="stylesheet" type="text/css"> 97 </head> 98 99 <body bgcolor="#FFFFFF" text="#000000" link="#FF9900" vlink="#FF9900" alink="#FF9900" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> 100 <table border="0" cellpadding="0" cellspacing="0" summary=""> 101 <tr> 102 <td width="9"><img src="../../img/leer.gif" alt="" width="9" height="1"></td> 103 <td width="250"><img src="../../img/leer.gif" alt="" width="1" height="15"><br /> 104 An error (ID:<?php echo $err ?>) occured while trying to download a file of your directory.<br /> 105 <img src="../../img/leer.gif" alt="" width="1" height="10"><br /> 106 Please <a href="<?php echo PHPWCMS_URL.get_login_file() ?>"><strong>login</strong></a> again<br /> 107 and try another file.<br /> 108 <img src="../../img/leer.gif" alt="" width="1" height="10"><br /> 109 If you think that this might be a technical problem send an email to the webmaster.</td> 110 </tr> 111 </table> 112 </body> 113 </html> 114 <?php 115 } 116 ?>
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 |