|
10 | 10 |
|
11 | 11 | namespace phpbbde\pastebin\controller; |
12 | 12 |
|
| 13 | +use Symfony\Component\HttpFoundation\Response; |
| 14 | + |
13 | 15 | class main |
14 | 16 | { |
15 | 17 | const CONFIRM_PASTEBIN = 5; |
@@ -112,7 +114,10 @@ public function handle($name = '') |
112 | 114 | 'U_VIEW_FORUM' => $this->helper->route('phpbbde_pastebin_main_controller'), |
113 | 115 | )); |
114 | 116 |
|
115 | | - $this->display_pb(); |
| 117 | + if ($response = $this->display_pb()) |
| 118 | + { |
| 119 | + return $response; |
| 120 | + } |
116 | 121 |
|
117 | 122 | return $this->helper->render('pastebin_body.html', $this->user->lang['PASTEBIN']); |
118 | 123 | } |
@@ -429,23 +434,20 @@ private function display_pb() |
429 | 434 | $filename = "filename*=UTF-8''" . rawurlencode($filename); |
430 | 435 | } |
431 | 436 |
|
432 | | - header('Pragma: public'); |
433 | | - |
434 | | - // Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer. |
435 | | - header('Content-Type: text/plain'); |
436 | | - header("Content-Disposition: attachment; $filename"); |
| 437 | + // Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer. |
| 438 | + $response = new Response($snippet_text, Response::HTTP_OK); |
| 439 | + $response->headers->set('Pragma', 'public'); |
| 440 | + $response->headers->set('Content-Type', 'text/plain'); |
| 441 | + $response->headers->set('Content-Disposition', "attachment; $filename"); |
437 | 442 |
|
438 | 443 | if ($size = @strlen($snippet_text)) |
439 | 444 | { |
440 | | - header("Content-Length: $size"); |
| 445 | + $response->headers->set('Content-Length', $size); |
441 | 446 | } |
442 | 447 |
|
443 | 448 | @set_time_limit(0); |
444 | 449 |
|
445 | | - echo $snippet_text; |
446 | | - |
447 | | - flush(); |
448 | | - exit; |
| 450 | + return $response; |
449 | 451 | } |
450 | 452 | else if ($mode == 'moderate') |
451 | 453 | { |
|
0 commit comments