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
pdf-print / mpdf / includes / functions.php

functions.php in PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin 1.5, at mpdf/includes/functions.php

99 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 function _strspn($str1, $str2, $start=null, $length=null) {
5 $numargs = func_num_args();
6 if ($numargs == 2) {
7 return strspn($str1, $str2);
8 }
9 else if ($numargs == 3) {
10 return strspn($str1, $str2, $start);
11 }
12 else {
13 return strspn($str1, $str2, $start, $length);
14 }
15 }
16
17
18 function _strcspn($str1, $str2, $start=null, $length=null) {
19 $numargs = func_num_args();
20 if ($numargs == 2) {
21 return strcspn($str1, $str2);
22 }
23 else if ($numargs == 3) {
24 return strcspn($str1, $str2, $start);
25 }
26 else {
27 return strcspn($str1, $str2, $start, $length);
28 }
29 }
30
31 function _fgets (&$h, $force=false) {
32 $startpos = ftell($h);
33 $s = fgets($h, 1024);
34 if ($force && preg_match("/^([^\r\n]*[\r\n]{1,2})(.)/",trim($s), $ns)) {
35 $s = $ns[1];
36 fseek($h,$startpos+strlen($s));
37 }
38 return $s;
39 }
40
41
42 // For PHP4 compatability
43 if(!function_exists('str_ireplace')) {
44 function str_ireplace($search,$replace,$subject) {
45 $search = preg_quote($search, "/");
46 return preg_replace("/".$search."/i", $replace, $subject);
47 }
48 }
49 if(!function_exists('htmlspecialchars_decode')) {
50 function htmlspecialchars_decode ($str) {
51 return strtr($str, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
52 }
53 }
54
55 function PreparePreText($text,$ff='//FF//') {
56 // mPDF 5.0.053
57 $text = htmlspecialchars($text);
58 if ($ff) { $text = str_replace($ff,'</pre><formfeed /><pre>',$text); }
59 return ('<pre>'.$text.'</pre>');
60 }
61
62 if(!function_exists('strcode2utf')){
63 function strcode2utf($str,$lo=true) {
64 //converts all the &#nnn; and &#xhhh; in a string to Unicode
65 if ($lo) { $lo = 1; } else { $lo = 0; }
66 $str = preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str);
67 $str = preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str);
68 return $str;
69 }
70 }
71
72 if(!function_exists('code2utf')){
73 function code2utf($num,$lo=true){
74 //Returns the utf string corresponding to the unicode value
75 //added notes - http://uk.php.net/utf8_encode
76 if ($num<128) {
77 if ($lo) return chr($num);
78 else return '&#'.$num.';'; // i.e. no change
79 }
80 if ($num<2048) return chr(($num>>6)+192).chr(($num&63)+128);
81 if ($num<65536) return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
82 if ($num<2097152) return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128);
83 return '?';
84 }
85 }
86
87
88 if(!function_exists('codeHex2utf')){
89 function codeHex2utf($hex,$lo=true){
90 $num = hexdec($hex);
91 if (($num<128) && !$lo) return '&#x'.$hex.';'; // i.e. no change
92 return code2utf($num,$lo);
93 }
94 }
95
96
97
98
99 ?>