リビジョン | 3b2094784e7976cf0e053f71ff9ce76deee20221 (tree) |
---|---|
日時 | 2017-01-07 16:24:06 |
作者 | Keishi Tanaka <kc@hoku...> |
コミッター | Keishi Tanaka |
Add is_downloadable_file function.
@@ -53,7 +53,6 @@ download($key); | ||
53 | 53 | |
54 | 54 | function download($auth_key){ |
55 | 55 | |
56 | - global $downloadable_path; | |
57 | 56 | $qm = get_qm(); |
58 | 57 | |
59 | 58 | $filename = isset($_GET['filename']) ? $_GET['filename'] : ''; |
@@ -63,14 +62,12 @@ function download($auth_key){ | ||
63 | 62 | $page = isset($_GET['refer']) ? $_GET['refer'] : ''; |
64 | 63 | |
65 | 64 | $filename = urldecode($filename); |
66 | - $pathinfo = pathinfo($filename); | |
67 | - $downloadable_path_array = explode(";", $downloadable_path); | |
68 | 65 | |
69 | 66 | //validate |
70 | 67 | $wikifile = 'wiki/'. encode($page) . '.txt'; |
71 | 68 | $source = file_exists($wikifile) ? file_get_contents($wikifile) : ''; |
72 | 69 | |
73 | - if(! in_array($pathinfo['dirname'], $downloadable_path_array, true)) | |
70 | + if(! is_downloadable_file($filename)) | |
74 | 71 | { |
75 | 72 | header('HTTP/1.1 403 Forbidden'); |
76 | 73 | error_msg('Error : Invalid access'); |
@@ -130,6 +127,13 @@ function download($auth_key){ | ||
130 | 127 | |
131 | 128 | } |
132 | 129 | |
130 | +function is_downloadable_file($filename){ | |
131 | + global $downloadable_path; | |
132 | + $pathinfo = pathinfo($filename); | |
133 | + $paths = explode(";", $downloadable_path); | |
134 | + return in_array($pathinfo['dirname'], $paths, true); | |
135 | +} | |
136 | + | |
133 | 137 | function dl_sendmail($email, $filename, $title){ |
134 | 138 | |
135 | 139 | global $smtp_auth, $smtp_server, $google_apps, $google_apps_domain; |
@@ -160,7 +160,7 @@ $modifierlink = 'http://www.example.co.jp/'; // Site admin's Web page | ||
160 | 160 | $googlemaps_apikey = 'ABQIAAAAiGS5xMxFoCjNEIdoMGiCBRSh3wgB-evfR4k_uhb9NTlXTFSqGRScvANPOtehBVz7qEVDLEwY4PlLng'; |
161 | 161 | // Fit videos to screen |
162 | 162 | $enable_fitvids = true; |
163 | -// Downloadable path | |
163 | +// Downloadable path delimitered semicolon (;) | |
164 | 164 | $downloadable_path = 'swfu/d;pub'; |
165 | 165 | |
166 | 166 |