-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbootstrap.php
54 lines (46 loc) · 1.39 KB
/
bootstrap.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
<?php
include 'include/functions.php';
include 'include/upload.class.php';
$conf = include 'config.php';
$tpl = array();
// get config info
$base = Upload::$filename_config['base'];
$length = Upload::$filename_config['length'];
// check file
$file_name = str_replace('thumb/', '', $conf['uri_param'], $count);
$is_thumb = $count == 1;
$is_valid_file = preg_match('/^[' . $base . ']{' . $length . '}\.[a-z]+$/', $file_name) == 1;
if (!$is_valid_file) {
if (!empty($conf['password'])) {
// check password
if (!isHaveAccess()) {
if (isset($_GET['badpassword'])) {
$tpl['message'] = 'Password is incorrect';
}
$tpl['content'] = get_include_contents($conf['tpl_path'] . 'password.php');
return;
}
} else {
$tpl['content'] = get_include_contents($conf['tpl_path'] . 'upload.php');
return;
}
}
// check uri
if (empty($conf['uri_param'])) {
$tpl['content'] = get_include_contents($conf['tpl_path'] . 'upload.php');
return;
}
if ($is_thumb) {
$file_path = 'file/thumb/' . $file_name[0] . '/' . $file_name[1] . '/' . $file_name;
} else {
$file_path = 'file/' . $file_name[0] . '/' . $file_name[1] . '/' . $file_name;
}
if (file_exists($file_path)) {
$img_info = getimagesize($file_path);
header('Content-type: ' . $img_info['mime']);
readfile($file_path);
} else {
header('HTTP/1.0 404 Not Found');
echo 'Error 404: Not Found';
}
exit;