-
Notifications
You must be signed in to change notification settings - Fork 31
/
showthumb.php
72 lines (59 loc) · 1.79 KB
/
showthumb.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
<?php
/**
* Coppermine Photo Gallery
*
* v1.0 originally written by Gregory Demar
*
* @copyright Copyright (c) 2003-2018 Coppermine Dev Team
* @license GNU General Public License version 3 or later; see LICENSE
*
* showthumb.php
* @since 1.6.06
*/
define('IN_COPPERMINE', true);
define('SHOWTHUMB_PHP', true);
require("include/init.inc.php");
if (!GALLERY_ADMIN_MODE) {
cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
define("GIS_GIF", 1);
define("GIS_JPG", 2);
define("GIS_PNG", 3);
define("UNKNOW_ICON", 'images/batch/unknown.png');
define("GIF_ICON", 'images/batch/gif.png');
define("READ_ERROR_ICON", 'images/batch/file_broken.png');
function makethumbnail($src_file, $newSize)
{
global $CONFIG;
// Checks that file exists and is readable
if (!filesize($src_file) || !is_readable($src_file)) {
header("Content-type: image/png");
readfile(READ_ERROR_ICON);
exit;
}
// find the image size, no size => unknow type
$imginfo = cpg_getimagesize($src_file);
if ($imginfo == null) {
header("Content-type: image/png");
readfile(UNKNOW_ICON);
exit;
}
// GD can't handle gif images
if ($imginfo[2] == GIS_GIF && $CONFIG['GIF_support'] == 0) {
header("Content-type: image/png");
readfile(GIF_ICON);
exit;
}
// Get the appropriate tool and send the image
getImageTool();
$imgObj = new imageObject(dirname($src_file).DIRECTORY_SEPARATOR, basename($src_file));
if (!$imgObj) {
header("Content-type: image/png");
readfile(READ_ERROR_ICON);
exit;
}
$imgObj->send($newSize);
}
$matches = $superCage->get->getMatched('picfile', '/^[0-9A-Za-z~\s\/\\._-]+$/');
makethumbnail($CONFIG['fullpath'] . $matches[0], $superCage->get->getInt('size'));
//EOF