|
23 | 23 | response(trans('Lang_Not_Found').AddErrorLocation())->send(); |
24 | 24 | exit; |
25 | 25 | } |
| 26 | + |
| 27 | + |
| 28 | +//check $_GET['file'] |
| 29 | +if(isset($_GET['file']) && !checkRelativePath($_GET['file'])) { |
| 30 | + response(trans('wrong path'))->send(); |
| 31 | + exit; |
| 32 | +} |
| 33 | + |
| 34 | +//check $_GET['file'] |
| 35 | +if(isset($_GET['path']) && !checkRelativePath($_GET['path'])) { |
| 36 | + response(trans('wrong path'))->send(); |
| 37 | + exit; |
| 38 | +} |
| 39 | + |
| 40 | + |
26 | 41 | $ftp = ftp_con($config); |
27 | 42 |
|
28 | 43 | if(isset($_GET['action'])) |
|
83 | 98 | case 'save_img': |
84 | 99 | $info = pathinfo($_POST['name']); |
85 | 100 |
|
86 | | - if ( |
87 | | - strpos($_POST['path'], '/') === 0 |
88 | | - || strpos($_POST['path'], '../') !== false |
89 | | - || strpos($_POST['path'], '..\\') !== false |
90 | | - || strpos($_POST['path'], './') === 0 |
91 | | - || (strpos($_POST['url'], 'http://s3.amazonaws.com/feather') !== 0 && strpos($_POST['url'], 'https://s3.amazonaws.com/feather') !== 0) |
| 101 | + if ((strpos($_POST['url'], 'http://s3.amazonaws.com/feather') !== 0 && strpos($_POST['url'], 'https://s3.amazonaws.com/feather') !== 0) |
92 | 102 | || $_POST['name'] != fix_filename($_POST['name'], $config) |
93 | 103 | || ! in_array(strtolower($info['extension']), array( 'jpg', 'jpeg', 'png' )) |
94 | 104 | ) |
|
135 | 145 | } |
136 | 146 | break; |
137 | 147 | case 'extract': |
138 | | - if ( strpos($_POST['path'], '/') === 0 |
139 | | - || strpos($_POST['path'], '../') !== false |
140 | | - || strpos($_POST['path'], '..\\') !== false |
141 | | - || strpos($_POST['path'], './') === 0) |
142 | | - { |
143 | | - response(trans('wrong path'.AddErrorLocation()))->send(); |
144 | | - exit; |
| 148 | + if(!$config['extract_files']){ |
| 149 | + response(trans('wrong action'))->send(); |
145 | 150 | } |
146 | | - |
147 | 151 | if($ftp){ |
148 | 152 | $path = $config['ftp_base_url'].$config['upload_dir'] . $_POST['path']; |
149 | 153 | $base_folder = $config['ftp_base_url'].$config['upload_dir'] . fix_dirname($_POST['path']) . "/"; |
|
186 | 190 | exit; |
187 | 191 | } |
188 | 192 |
|
189 | | - //make all the folders |
190 | | - for ($i = 0; $i < $zip->numFiles; $i++) |
191 | | - { |
192 | | - $OnlyFileName = $zip->getNameIndex($i); |
193 | | - $FullFileName = $zip->statIndex($i); |
194 | | - if (substr($FullFileName['name'], -1, 1) == "/") |
195 | | - { |
196 | | - create_folder($base_folder . $FullFileName['name']); |
197 | | - } |
198 | | - } |
199 | | - //unzip into the folders |
| 193 | + //make all the folders and unzip into the folders |
200 | 194 | for ($i = 0; $i < $zip->numFiles; $i++) |
201 | 195 | { |
202 | | - $OnlyFileName = $zip->getNameIndex($i); |
203 | 196 | $FullFileName = $zip->statIndex($i); |
204 | 197 |
|
205 | | - if ( ! (substr($FullFileName['name'], -1, 1) == "/")) |
206 | | - { |
207 | | - $fileinfo = pathinfo($OnlyFileName); |
208 | | - if (in_array(strtolower($fileinfo['extension']), $config['ext'])) |
| 198 | + if(checkRelativePath($FullFileName['name'])){ |
| 199 | + if (substr($FullFileName['name'], -1, 1) == "/") |
209 | 200 | { |
210 | | - copy('zip://' . $path . '#' . $OnlyFileName, $base_folder . $FullFileName['name']); |
| 201 | + create_folder($base_folder . $FullFileName['name']); |
| 202 | + } |
| 203 | + |
| 204 | + if ( ! (substr($FullFileName['name'], -1, 1) == "/")) |
| 205 | + { |
| 206 | + $fileinfo = pathinfo($FullFileName['name']); |
| 207 | + if (in_array(strtolower($fileinfo['extension']), $config['ext'])) |
| 208 | + { |
| 209 | + copy('zip://' . $path . '#' . $FullFileName['name'], $base_folder . $FullFileName['name']); |
| 210 | + } |
211 | 211 | } |
212 | 212 | } |
213 | 213 | } |
|
232 | 232 | $phar = new PharData($path); |
233 | 233 | $phar->decompressFiles(); |
234 | 234 | $files = array(); |
235 | | - check_files_extensions_on_phar($phar, $files, '', $config['ext']); |
| 235 | + check_files_extensions_on_phar($phar, $files, '', $config); |
236 | 236 | $phar->extractTo($base_folder, $files, true); |
237 | 237 |
|
238 | 238 | break; |
|
365 | 365 | case 'copy_cut': |
366 | 366 | if ($_POST['sub_action'] != 'copy' && $_POST['sub_action'] != 'cut') |
367 | 367 | { |
368 | | - response(trans('wrong sub-action').AddErrorLocation())->send(); |
369 | | - exit; |
370 | | - } |
371 | | - |
372 | | - if (strpos($_POST['path'],'../') !== FALSE |
373 | | - || strpos($_POST['path'],'./') !== FALSE |
374 | | - || strpos($_POST['path'],'..\\') !== FALSE |
375 | | - || strpos($_POST['path'],'.\\') !== FALSE ) |
376 | | - { |
377 | | - response(trans('wrong path'.AddErrorLocation()))->send(); |
| 368 | + response(trans('wrong sub-action'))->send(); |
378 | 369 | exit; |
379 | 370 | } |
380 | 371 |
|
|
611 | 602 |
|
612 | 603 | if ($sub_action != 'preview' && $sub_action != 'edit') |
613 | 604 | { |
614 | | - response(trans('wrong action').AddErrorLocation())->send(); |
| 605 | + response(trans('wrong action'))->send(); |
615 | 606 | exit; |
616 | 607 | } |
617 | 608 |
|
|
0 commit comments