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
<?php
/**
* $Id: display_image.php
* @author g_wang
* @access public
* @package www
*/
require_once ("user_include.inc");
// パラメータを取得
$type = ParamUtil::getRequestString("type");
$child_path = ParamUtil::getRequestString("child_path");//不包含"/"
$file_name = ParamUtil::getRequestString("file_name");
$file_path = IMAGES_PATH;
if ($type == "theme") {
$file_path = THEME_IMAGES_PATH;
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
} else if ($type == "article") {
$file_path = ARTICLE_IMAGES_PATH;
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
} else if ($type == "category") {
$file_path = ARTICLE_IMAGES_PATH;
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
} else if ($type == "course") {
$file_path = COURSE_IMAGES_PATH;
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
} else if ($type == "video") {
$file_path = VIDEO_PATH;
$file_path .= "/" . $file_name;
} else {
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
}
if (file_exists($file_path)) {
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
$handle = fopen($file_path, "rb");
$image_data = fread($handle, filesize($file_path));
$size = getimagesize($file_path);
header("Content-type: " . $size["mime"]);
header("Content-length: " . strlen($image_data));
print $image_data;
fclose($handle);
exit;
}
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
exit;