forked from sauruscms/Saurus-CMS-Community-Edition
-
Notifications
You must be signed in to change notification settings - Fork 1
/
image.php
75 lines (59 loc) · 2.33 KB
/
image.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* This source file is is part of Saurus CMS content management software.
* It is licensed under MPL 1.1 (http://www.opensource.org/licenses/mozilla1.1.php).
* Copyright (C) 2000-2010 Saurused Ltd (http://www.saurus.info/).
* Redistribution of this file must retain the above copyright notice.
*
* Please note that the original authors never thought this would turn out
* such a great piece of software when the work started using Perl in year 2000.
* Due to organic growth, you may find parts of the software being
* a bit (well maybe more than a bit) old fashioned and here's where you can help.
* Good luck and keep your open source minds open!
*
* @package SaurusCMS
* @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/)
* @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php)
*
*/
##############################
# Prints picture object as stand-alone html
# : is usually value for image source (<img src="image.php?555t" ..>)
# : is independent script, not for including, new Site is generated
##############################
# CURRENT FILE WAS pilt.php" in ver 3
global $site;
preg_match('/\/(admin|editor)\//i', $_SERVER["REQUEST_URI"], $matches);
$class_path = $matches[1] == "editor" ? "../classes/" : "./classes/";
include($class_path."port.inc.php");
# otsitakse id-d enne "t"-d
# nt image.php?555t => id = 555
if (preg_match("/^(\d+)(t)?.*?$/", $_SERVER['QUERY_STRING'], $matches)) {
$id = $matches[1];
$is_thumb = $matches[2];
}
$_GET[id] = $id;
$site = new Site(array(
on_debug=>0
));
$objekt = new Objekt(array(
objekt_id => $id,
on_sisu=>1,
));
if (($objekt->all[klass]=="pilt" && ($objekt->on_avaldatud || $site->admin!=0) && ($ipAccess>0))) {
$ctype = $objekt->all[mime_tyyp] ? $objekt->all[mime_tyyp] : "application/saurus";
header("Content-Type: $ctype");
$sql = $site->db->prepare("select * from obj_pilt WHERE objekt_id = ?",$objekt->objekt_id);
$sth = new SQL($sql);
$data = $sth->fetch();
$site->debug->msg($sth->debug->get_msgs());
if ($is_thumb) {
$body = $data[vaike_blob];
} else {
$body = $data[sisu_blob];
}
print $body;
} else {
header("Location: ".(empty($_SERVER['HTTPS']) ? 'http://': 'https://').$site->CONF[hostname].$site->CONF[wwwroot].($site->admin?"/editor":"")."/?op=error&error_id=404");
}
$site->debug->print_msg();