-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_picture.php
More file actions
61 lines (52 loc) · 1.68 KB
/
show_picture.php
File metadata and controls
61 lines (52 loc) · 1.68 KB
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
<?php
/**
* show_image.php
*
* Example utility file for dynamically displaying images
*
* @author Ian Selby
* @version 1.0 (php 5 version)
*/
//reference thumbnail class
include_once('thumbnail.inc.php');
// Bind gallery pathing so we wont get any hacks.
if (isset ($_GET['gallery'])){
$path = "../../images/".$_GET['gallery']."s/";
$thum_p = "./cache/".$_GET['gallery']."s/";
}
// Prevent stupid hackers. So they cant do:
// show_picture.php?filename=../../../index.php
if(strstr($_GET['filename'], '/.')){
die(" \"/.\" is not allowed in a file name.");
}
// Die if the script cannot find the image.
if (file_exists($path.$_GET['filename']) == false){
die('Picture doesnt exsist!');
}
// Check if the required paths is not included.
if (empty($path) || empty($_GET['filename'])){
}else{
// Does this thumbnail exists, we dont want to overload the CPU with our gallery.
if (file_exists($thum_p.$_GET['filename'])){
// Well if the image that we have.. is newer and same name we must create a new tempalte.
if(file_exists($path.$_GET['filename']) && filemtime($thum_p.$_GET['filename']) < filemtime($path.$_GET['filename'])){
unlink($thum_p.$_GET['filename']);
$thumb = new Thumbnail($path.$_GET['filename']);
$thumb->resize($_GET['width'],$_GET['height']);
$thumb->save($thum_p.$_GET['filename']);
$thumb->show();
// Ok we just show our thumbnail.
}else{
$thumb = new Thumbnail($thum_p.$_GET['filename']);
$thumb->show();
}
// We gotta create a thumbnail because our thumbnail does not exist.
}else{
$thumb = new Thumbnail($path.$_GET['filename']);
$thumb->resize($_GET['width'],$_GET['height']);
$thumb->save($thum_p.$_GET['filename']);
$thumb->show();
}
}
exit;
?>