PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 1.5
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v1.5
trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 All 71 releases
← All changes | mpdf/includes/out.php +58 -68 trunk1.5 View file →
@@ -1,68 +1,58 @@
1 -<?php
2 -
3 -$path = '../tmp/';
4 -
5 -$tempfilename = $_REQUEST['filename'].'.pdf';
6 -
7 -if (strstr($tempfilename,'/') || strstr($tempfilename,'\\')) {
8 - throw new MpdfException('Output filename can not not contain \ or /');
9 -}
10 -
11 -$name = $_REQUEST['opname'];
12 -$dest = $_REQUEST['dest'];
13 -
14 -if ($tempfilename && file_exists($path . $tempfilename)) {
15 - // mPDF 5.3.17
16 - if ($dest === 'I') {
17 - if (PHP_SAPI != 'cli') {
18 - header('Content-Type: application/pdf');
19 - header('Content-disposition: inline; filename="' . $name . '"');
20 - header('Cache-Control: public, must-revalidate, max-age=0');
21 - header('Pragma: public');
22 - header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
23 - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
24 - }
25 - } elseif ($dest === 'D') {
26 -
27 - if (headers_sent()) {
28 - throw new MpdfException('Some data has already been output to browser, can\'t send PDF file');
29 - }
30 -
31 - header('Content-Description: File Transfer');
32 - header('Content-Transfer-Encoding: binary');
33 - header('Cache-Control: public, must-revalidate, max-age=0');
34 - header('Pragma: public');
35 - header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
36 - header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
37 - header('Content-Type: application/force-download');
38 - header('Content-Type: application/octet-stream', false);
39 - header('Content-Type: application/download', false);
40 - header('Content-Type: application/pdf', false);
41 - header('Content-disposition: attachment; filename="' . $name . '"');
42 - }
43 -
44 - $filesize = filesize($path.$tempfilename);
45 - if (empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
46 - // don't use length if server using compression
47 - header('Content-Length: ' . $filesize);
48 - }
49 -
50 - $fd = fopen($path . $tempfilename, 'rb');
51 - fpassthru($fd);
52 - fclose($fd);
53 - unlink($path . $tempfilename);
54 -
55 - // ====================== DELETE OLD FILES - Housekeeping =========================================
56 - // Clear any files in directory that are >24 hrs old
57 -
58 - $interval = 86400;
59 - if ($handle = opendir(dirname($path.'dummy'))) {
60 - while (false !== ($file = readdir($handle))) {
61 - if (((filemtime($path.$file)+$interval) < time()) && ($file != "..") && ($file != ".") && substr($file, -3)=='pdf') {
62 - unlink($path.$file);
63 - }
64 - }
65 - closedir($handle);
66 - }
67 - exit;
68 -}
1 +<?php
2 +
3 +
4 +$tempfilename = $_REQUEST['filename'].'.pdf';
5 +$opname = $_REQUEST['opname'];
6 +$path = urldecode($_REQUEST['path']);
7 +$dest = $_REQUEST['dest'];
8 + if ($tempfilename && file_exists($path.$tempfilename)) {
9 + // mPDF 5.3.17
10 + if ($dest=='I') {
11 + if(PHP_SAPI!='cli') {
12 + header('Content-Type: application/pdf');
13 + header('Content-disposition: inline; filename="'.$name.'"');
14 + header('Cache-Control: public, must-revalidate, max-age=0');
15 + header('Pragma: public');
16 + header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
17 + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
18 + }
19 + }
20 +
21 + else if ($dest=='D') {
22 + header('Content-Description: File Transfer');
23 + if (headers_sent())
24 + $this->Error('Some data has already been output to browser, can\'t send PDF file');
25 + header('Content-Transfer-Encoding: binary');
26 + header('Cache-Control: public, must-revalidate, max-age=0');
27 + header('Pragma: public');
28 + header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
29 + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
30 + header('Content-Type: application/force-download');
31 + header('Content-Type: application/octet-stream', false);
32 + header('Content-Type: application/download', false);
33 + header('Content-Type: application/pdf', false);
34 + header('Content-disposition: attachment; filename="'.$name.'"');
35 + }
36 + $filesize = filesize($path.$tempfilename);
37 + if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) OR empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
38 + // don't use length if server using compression
39 + header('Content-Length: '.$filesize);
40 + }
41 + $fd=fopen($path.$tempfilename,'rb'); // mPDF 5.3.85
42 + fpassthru($fd);
43 + fclose($fd);
44 + unlink($path.$tempfilename);
45 + // ====================== DELETE OLD FILES - Housekeeping =========================================
46 + // Clear any files in directory that are >24 hrs old
47 + $interval = 86400;
48 + if ($handle = opendir(dirname($path.'dummy'))) {
49 + while (false !== ($file = readdir($handle))) {
50 + if (((filemtime($path.$file)+$interval) < time()) && ($file != "..") && ($file != ".") && substr($file, -3)=='pdf') {
51 + unlink($path.$file);
52 + }
53 + }
54 + closedir($handle);
55 + }
56 + exit;
57 + }
58 +?>