| 1 | <?php |
|---|
| 2 | // $Id: image.php,v 1.4 2005/08/03 12:39:11 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | |
|---|
| 28 | set_magic_quotes_runtime(0); |
|---|
| 29 | if (function_exists('mb_http_output')) { |
|---|
| 30 | mb_http_output('pass'); |
|---|
| 31 | } |
|---|
| 32 | $image_id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
|---|
| 33 | if (empty($image_id)) { |
|---|
| 34 | header('Content-type: image/gif'); |
|---|
| 35 | readfile('./images/blank.gif'); |
|---|
| 36 | exit(); |
|---|
| 37 | } |
|---|
| 38 | $xoopsOption['nocommon'] = 1; |
|---|
| 39 | include './mainfile.php'; |
|---|
| 40 | include XOOPS_ROOT_PATH.'/include/functions.php'; |
|---|
| 41 | include_once XOOPS_ROOT_PATH.'/class/logger.php'; |
|---|
| 42 | $xoopsLogger =& XoopsLogger::instance(); |
|---|
| 43 | $xoopsLogger->startTime(); |
|---|
| 44 | include_once XOOPS_ROOT_PATH.'/class/database/databasefactory.php'; |
|---|
| 45 | define('XOOPS_DB_PROXY', 1); |
|---|
| 46 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); |
|---|
| 47 | // ################# Include class manager file ############## |
|---|
| 48 | require_once XOOPS_ROOT_PATH.'/kernel/object.php'; |
|---|
| 49 | require_once XOOPS_ROOT_PATH.'/class/criteria.php'; |
|---|
| 50 | $imagehandler =& xoops_gethandler('image'); |
|---|
| 51 | $criteria = new CriteriaCompo(new Criteria('i.image_display', 1)); |
|---|
| 52 | $criteria->add(new Criteria('i.image_id', $image_id)); |
|---|
| 53 | $image =& $imagehandler->getObjects($criteria, false, true); |
|---|
| 54 | if (count($image) > 0) { |
|---|
| 55 | header('Content-type: '.$image[0]->getVar('image_mimetype')); |
|---|
| 56 | header('Cache-control: max-age=31536000'); |
|---|
| 57 | header('Expires: '.gmdate("D, d M Y H:i:s",time()+31536000).'GMT'); |
|---|
| 58 | header('Content-disposition: filename='.$image[0]->getVar('image_name')); |
|---|
| 59 | header('Content-Length: '.strlen($image[0]->getVar('image_body'))); |
|---|
| 60 | header('Last-Modified: '.gmdate("D, d M Y H:i:s",$image[0]->getVar('image_created')).'GMT'); |
|---|
| 61 | echo $image[0]->getVar('image_body'); |
|---|
| 62 | } else { |
|---|
| 63 | header('Content-type: image/gif'); |
|---|
| 64 | readfile('./images/blank.gif'); |
|---|
| 65 | } |
|---|
| 66 | ?> |
|---|