]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - inc/3rdparty/libraries/mpdf/compress.php
3 $excl = array ( 'HTML-CSS' , 'DIRECTW' , 'TABLES' , 'LISTS' , 'IMAGES-CORE' ,
4 'IMAGES-BMP' , 'IMAGES-WMF' , 'TABLES-ADVANCED-BORDERS' , 'HTMLHEADERS-FOOTERS' , 'COLUMNS' , 'TOC' , 'INDEX' , 'BOOKMARKS' , 'BARCODES' , 'FORMS' , 'WATERMARK' , 'CJK-FONTS' , 'RTL' , 'INDIC' , 'ANNOTATIONS' , 'BACKGROUNDS' , 'CSS-FLOAT' , 'CSS-IMAGE-FLOAT' , 'CSS-POSITION' , 'CSS-PAGE' , 'BORDER-RADIUS' , 'HYPHENATION' , 'ENCRYPTION' , 'IMPORTS' , 'PROGRESS-BAR' );
7 // *DIRECTW* = Write, WriteText, WriteCell, Text, Shaded_box, AutosizeText
8 // IMAGES-CORE = [PNG, GIF, and JPG] NB background-images and watermark images
10 // 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'
12 // Text is marked in mpdf_source.php with e.g. :
13 /*-- TABLES-ADVANCED-BORDERS --*/
14 /*-- END TABLES-ADVANCED-BORDERS --*/
15 // *TABLES-ADVANCED-BORDERS*
18 if (! isset ( $_POST [ 'generate' ]) || $_POST [ 'generate' ]!= 'generate' ) {
21 if (! file_exists ( 'mpdf_source.php' )) {
22 die ( "ERROR - Could not find mpdf_source.php file in current directory. Please rename mpdf.php as mpdf_source.php" );
30 <script language=javascript>
32 function checkedAll (frm1) {
33 var aa= document.getElementById("frm1");
42 for (var i =0; i < aa.elements.length; i++)
44 aa.elements[i].checked = checked;
50 <p><span style="color:red; font-weight: bold;">WARNING</span>: This utility will OVERWRITE mpdf.php file in the current directory.</p>
51 <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>
54 <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>
55 <li>DIRECTW includes the functions to Write directly to the PDF file e.g. Write, WriteText, WriteCell, Text, Shaded_box, AutosizeText</li>
56 <li>You must include either HTML-CSS or DIRECTW</li>
57 <li>JPG, PNG and JPG images are supported with IMAGES-CORE</li>
58 <li>For WMF Images, you must include both IMAGES-CORE and IMAGES-WMF</li>
59 <li>IMAGES-CORE are required for BACKGROUNDS (IMAGES) or WATERMARKS to work</li>
62 <input type="checkbox" name="checkall" onclick="checkedAll(frm1);"> <i>Select/Unselect All</i><br /><br />
64 <form id="frm1" action="compress.php" method="POST">
66 foreach ( $excl AS $k => $ex ) {
67 echo '<input type="checkbox" value="1" name="inc[' . $ex . ']"' ;
68 if ( $k == 0 || ( $k > 1 && $k < 5 )) {
69 echo ' checked="checked"' ;
71 echo ' /> ' . $ex . '<br />' ;
75 <input type="submit" name="generate" value="generate" />
83 if ( is_array ( $inc ) && count ( $inc )> 0 ) {
84 foreach ( $inc AS $i => $v ) {
85 $key = array_search ( $i , $excl );
90 if (! defined ( 'PHP_VERSION_ID' )) {
91 $version = explode ( '.' , PHP_VERSION
);
92 define ( 'PHP_VERSION_ID' , ( $version [ 0 ] * 10000 +
$version [ 1 ] * 100 +
$version [ 2 ]));
94 if ( PHP_VERSION_ID
< 50300 ) { $mqr
= @ get_magic_quotes_runtime (); }
96 if ( $mqr ) { set_magic_quotes_runtime ( 0 ); }
98 $l = file ( 'mpdf_source.php' );
99 if (! count ( $l )) { die ( "ERROR - Could not find mpdf_source.php file in current directory" ); }
100 $exclflags = array ();
103 // 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'
104 if ( $excl [ 0 ]== 'HTML-CSS' ) {
107 $excl [] = 'TABLES-ADVANCED-BORDERS' ;
108 $excl [] = 'HTMLHEADERS-FOOTERS' ;
110 $excl [] = 'BACKGROUNDS' ;
111 $excl [] = 'CSS-FLOAT' ;
112 $excl [] = 'CSS-IMAGE-FLOAT' ;
113 $excl [] = 'CSS-POSITION' ;
114 $excl [] = 'CSS-PAGE' ;
115 $excl [] = 'BORDER-RADIUS' ;
117 $excl = array_unique ( $excl );
119 foreach ( $l AS $k => $ln ) {
122 preg_match_all ( "/\/\/ \*([A-Za-z\-]+)\*/" , $ln , $m );
123 foreach ( $m [ 1 ] AS $mm ) {
124 if ( in_array ( $mm , $excl )) {
129 preg_match_all ( "/\/\*-- ([A-Za-z\-]+) --\*\//" , $ln , $m );
130 foreach ( $m [ 1 ] AS $mm ) {
131 if ( in_array ( $mm , $excl )) {
132 $exclflags [ $mm ] = true ;
136 $exclflags = array_unique ( $exclflags );
138 preg_match_all ( "/\/\*-- END ([A-Za-z\-]+) --\*\//" , $ln , $m );
139 foreach ( $m [ 1 ] AS $mm ) {
140 if ( in_array ( $mm , $excl )) {
141 unset ( $exclflags [ $mm ]);
145 if ( count ( $exclflags )== 0 && ! $exclude ) {
150 if ( function_exists ( 'file_put_contents' )) {
151 $check = file_put_contents ( 'mpdf.php' , $x );
154 $f = fopen ( 'mpdf.php' , 'w' );
155 $check = fwrite ( $f , $x );
158 if (! $check ) { die ( "ERROR - Could not write to mpdf.php file. Are permissions correctly set?" ); }
159 echo '<p><b>mPDF file generated successfully!</b></p>' ;
160 echo '<div>mPDF file size ' . number_format (( strlen ( $x )/ 1024 )). ' kB</div>' ;
168 echo '<div>Memory usage on loading mPDF class ' . number_format (( memory_get_usage ( true )/( 1024 * 1024 )), 2 ). ' MB</div>' ;