| 1 |
<?php |
| 2 |
|
| 3 |
$excl = array('HTML-CSS', 'DIRECTW', 'TABLES', 'IMAGES-CORE', |
| 4 |
'IMAGES-BMP', 'IMAGES-WMF', 'TABLES-ADVANCED-BORDERS', 'COLUMNS', 'TOC', 'INDEX', 'BOOKMARKS', 'BARCODES', 'FORMS', |
| 5 |
'WATERMARK', 'CJK-FONTS', 'INDIC', 'ANNOTATIONS', 'BACKGROUNDS', 'CSS-FLOAT', 'CSS-IMAGE-FLOAT', 'CSS-POSITION', |
| 6 |
'CSS-PAGE', 'BORDER-RADIUS', 'HYPHENATION', 'ENCRYPTION', 'IMPORTS', 'PROGRESS-BAR', 'OTL'); |
| 7 |
|
| 8 |
// *DIRECTW* = Write, WriteText, WriteCell, Text, Shaded_box, AutosizeText |
| 9 |
// IMAGES-CORE = [PNG, GIF, and JPG] NB background-images and watermark images |
| 10 |
|
| 11 |
// Excluding 'HTML-CSS' will also exclude: 'TABLES', 'LISTS', 'TABLES-ADVANCED-BORDERS', 'FORMS', 'BACKGROUNDS', 'CSS-FLOAT', 'CSS-IMAGE-FLOAT', 'CSS-POSITION', 'CSS-PAGE', 'BORDER-RADIUS' |
| 12 |
// Text is marked in mpdf_source.php with e.g. : |
| 13 |
/* -- TABLES-ADVANCED-BORDERS -- */ |
| 14 |
/* -- END TABLES-ADVANCED-BORDERS -- */ |
| 15 |
// *TABLES-ADVANCED-BORDERS* |
| 16 |
|
| 17 |
if (!isset($_POST['generate']) || $_POST['generate'] != 'generate') { |
| 18 |
|
| 19 |
if (!file_exists('mpdf_source.php')) { |
| 20 |
die("ERROR - Could not find mpdf_source.php file in current directory. Please rename mpdf.php as mpdf_source.php"); |
| 21 |
} |
| 22 |
|
| 23 |
echo '<html> |
| 24 |
<head> |
| 25 |
<script language=javascript> |
| 26 |
checked=false; |
| 27 |
function checkedAll (frm1) { |
| 28 |
var aa= document.getElementById("frm1"); |
| 29 |
if (checked == false) |
| 30 |
{ |
| 31 |
checked = true |
| 32 |
} |
| 33 |
else |
| 34 |
{ |
| 35 |
checked = false |
| 36 |
} |
| 37 |
for (var i =0; i < aa.elements.length; i++) |
| 38 |
{ |
| 39 |
aa.elements[i].checked = checked; |
| 40 |
} |
| 41 |
} |
| 42 |
</script> |
| 43 |
</head> |
| 44 |
<body> |
| 45 |
<p><span style="color:red; font-weight: bold;">WARNING</span>: This utility will OVERWRITE mpdf.php file in the current directory.</p> |
| 46 |
<p>Select the functions you wish to INCLUDE in your mpdf.php program. When you click generate, a new mpdf.php file will be written to the current directory.</p> |
| 47 |
<div><b>Notes</b> |
| 48 |
<ul> |
| 49 |
<li>HTML-CSS is required for many of the other functions to work including: Tables, Lists, Backgrounds, Forms, Border-radius and all other CSS</li> |
| 50 |
<li>DIRECTW includes the functions to Write directly to the PDF file e.g. Write, WriteText, WriteCell, Text, Shaded_box, AutosizeText</li> |
| 51 |
<li>You must include either HTML-CSS or DIRECTW</li> |
| 52 |
<li>JPG, PNG and JPG images are supported with IMAGES-CORE</li> |
| 53 |
<li>For WMF Images, you must include both IMAGES-CORE and IMAGES-WMF</li> |
| 54 |
<li>IMAGES-CORE are required for BACKGROUNDS (IMAGES) or WATERMARKS to work</li> |
| 55 |
<li>OTL (OpenType Layout) is required for RTL (right-to-left) scripts to work</li> |
| 56 |
</ul> |
| 57 |
</div> |
| 58 |
<input type="checkbox" name="checkall" onclick="checkedAll(frm1);"> <i>Select/Unselect All</i><br /><br /> |
| 59 |
|
| 60 |
<form id="frm1" action="compress.php" method="POST"> |
| 61 |
'; |
| 62 |
foreach ($excl AS $k => $ex) { |
| 63 |
echo '<input type="checkbox" value="1" name="inc[' . $ex . ']"'; |
| 64 |
if ($k == 0 || ($k > 1 && $k < 5)) { |
| 65 |
echo ' checked="checked"'; |
| 66 |
} |
| 67 |
echo ' /> ' . $ex . '<br />'; |
| 68 |
} |
| 69 |
|
| 70 |
echo '<br /> |
| 71 |
<input type="submit" name="generate" value="generate" /> |
| 72 |
</form> |
| 73 |
</body> |
| 74 |
</html>'; |
| 75 |
exit; |
| 76 |
} |
| 77 |
|
| 78 |
$inc = $_POST['inc']; |
| 79 |
if (is_array($inc) && count($inc) > 0) { |
| 80 |
foreach ($inc AS $i => $v) { |
| 81 |
$key = array_search($i, $excl); |
| 82 |
unset($excl[$key]); |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
if (!defined('PHP_VERSION_ID')) { |
| 87 |
$version = explode('.', PHP_VERSION); |
| 88 |
define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); |
| 89 |
} |
| 90 |
if (PHP_VERSION_ID < 50300) { |
| 91 |
$mqr = @get_magic_quotes_runtime(); |
| 92 |
} else { |
| 93 |
$mqr = 0; |
| 94 |
} |
| 95 |
if ($mqr) { |
| 96 |
set_magic_quotes_runtime(0); |
| 97 |
} |
| 98 |
|
| 99 |
$l = file('mpdf_source.php'); |
| 100 |
if (!count($l)) { |
| 101 |
die("ERROR - Could not find mpdf_source.php file in current directory"); |
| 102 |
} |
| 103 |
$exclflags = array(); |
| 104 |
$x = ''; |
| 105 |
|
| 106 |
// Excluding 'HTML-CSS' will also exclude: 'TABLES', 'LISTS', 'TABLES-ADVANCED-BORDERS', 'HTMLHEADERS-FOOTERS', 'FORMS', 'BACKGROUNDS', 'CSS-FLOAT', 'CSS-IMAGE-FLOAT', 'CSS-POSITION', 'CSS-PAGE', 'BORDER-RADIUS' |
| 107 |
if (isset($excl[0]) && $excl[0] == 'HTML-CSS') { |
| 108 |
$excl[] = 'TABLES'; |
| 109 |
$excl[] = 'TABLES-ADVANCED-BORDERS'; |
| 110 |
$excl[] = 'FORMS'; |
| 111 |
$excl[] = 'BACKGROUNDS'; |
| 112 |
$excl[] = 'CSS-FLOAT'; |
| 113 |
$excl[] = 'CSS-IMAGE-FLOAT'; |
| 114 |
$excl[] = 'CSS-POSITION'; |
| 115 |
$excl[] = 'CSS-PAGE'; |
| 116 |
$excl[] = 'BORDER-RADIUS'; |
| 117 |
} |
| 118 |
$excl = array_unique($excl); |
| 119 |
|
| 120 |
foreach ($l AS $k => $ln) { |
| 121 |
$exclude = false; |
| 122 |
// *XXXXX* |
| 123 |
preg_match_all("/\/\/ \*([A-Za-z\-]+)\*/", $ln, $m); |
| 124 |
foreach ($m[1] AS $mm) { |
| 125 |
if (in_array($mm, $excl)) { |
| 126 |
$exclude = true; |
| 127 |
} |
| 128 |
} |
| 129 |
/* -- XXXXX -- */ |
| 130 |
preg_match_all("/\/\*-- ([A-Za-z\-]+) --\*\//", $ln, $m); |
| 131 |
foreach ($m[1] AS $mm) { |
| 132 |
if (in_array($mm, $excl)) { |
| 133 |
$exclflags[$mm] = true; |
| 134 |
} |
| 135 |
$exclude = true; |
| 136 |
} |
| 137 |
$exclflags = array_unique($exclflags); |
| 138 |
/* -- END XXXX -- */ |
| 139 |
preg_match_all("/\/\*-- END ([A-Za-z\-]+) --\*\//", $ln, $m); |
| 140 |
foreach ($m[1] AS $mm) { |
| 141 |
if (in_array($mm, $excl)) { |
| 142 |
unset($exclflags[$mm]); |
| 143 |
} |
| 144 |
$exclude = true; |
| 145 |
} |
| 146 |
if (count($exclflags) == 0 && !$exclude) { |
| 147 |
$x .= $ln; |
| 148 |
} |
| 149 |
} |
| 150 |
// mPDF 5.0 |
| 151 |
if (function_exists('file_put_contents')) { |
| 152 |
$check = file_put_contents('mpdf.php', $x); |
| 153 |
} else { |
| 154 |
$f = fopen('mpdf.php', 'w'); |
| 155 |
$check = fwrite($f, $x); |
| 156 |
fclose($f); |
| 157 |
} |
| 158 |
if (!$check) { |
| 159 |
die("ERROR - Could not write to mpdf.php file. Are permissions correctly set?"); |
| 160 |
} |
| 161 |
echo '<p><b>mPDF file generated successfully!</b></p>'; |
| 162 |
echo '<div>mPDF file size ' . number_format((strlen($x) / 1024)) . ' kB</div>'; |
| 163 |
|
| 164 |
unset($l); |
| 165 |
unset($x); |
| 166 |
|
| 167 |
include('mpdf.php'); |
| 168 |
$mpdf = new mPDF(); |
| 169 |
|
| 170 |
echo '<div>Memory usage on loading mPDF class ' . number_format((memory_get_usage(true) / (1024 * 1024)), 2) . ' MB</div>'; |
| 171 |
|
| 172 |
exit; |
| 173 |
|