XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
image.php
Go to the documentation of this file.
1 <?php
19 error_reporting(0);
20 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
21  set_magic_quotes_runtime(0);
22 }
23 
24 if (function_exists('mb_http_output')) {
25  mb_http_output('pass');
26 }
27 $xoopsOption['nocommon'] = 1;
28 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mainfile.php';
29 
30 $image_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
31 if (empty($image_id)) {
32  header('Content-type: image/gif');
33  readfile(XOOPS_ROOT_PATH . '/uploads/blank.gif');
34  exit();
35 }
36 
37 include XOOPS_ROOT_PATH . '/include/functions.php';
38 include_once XOOPS_ROOT_PATH . '/class/xoopsload.php';
39 include_once XOOPS_ROOT_PATH . '/class/preload.php';
40 include_once XOOPS_ROOT_PATH . '/class/logger/xoopslogger.php';
41 include_once XOOPS_ROOT_PATH . '/class/module.textsanitizer.php';
42 include_once XOOPS_ROOT_PATH . '/class/database/databasefactory.php';
43 require_once XOOPS_ROOT_PATH . '/kernel/object.php';
44 require_once XOOPS_ROOT_PATH . '/class/criteria.php';
45 
47 $xoopsLogger->startTime();
48 
49 define('XOOPS_DB_PROXY', 1);
51 
52 // ################# Include class manager file ##############
54 $criteria = new CriteriaCompo(new Criteria('i.image_display', 1));
55 $criteria->add(new Criteria('i.image_id', $image_id));
56 $image = $imagehandler->getObjects($criteria, false, true);
57 if (count($image) > 0) {
58  header('Content-type: ' . $image[0]->getVar('image_mimetype'));
59  header('Cache-control: max-age=31536000');
60  header('Expires: ' . gmdate("D, d M Y H:i:s", time() + 31536000) . 'GMT');
61  header('Content-disposition: filename=' . $image[0]->getVar('image_name'));
62  header('Content-Length: ' . strlen($image[0]->getVar('image_body')));
63  header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $image[0]->getVar('image_created')) . 'GMT');
64  echo $image[0]->getVar('image_body');
65 } else {
66  header('Content-type: image/gif');
67  readfile(XOOPS_UPLOAD_PATH . '/blank.gif');
68 }
69 ?>