Merge pdf

This commit is contained in:
Laurent Destailleur 2021-10-26 13:51:43 +02:00
commit f592318cba

View File

@ -49,7 +49,8 @@
* @version 1.1.1 * @version 1.1.1
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF_STATIC { class TCPDF_STATIC
{
/** /**
* Current TCPDF version. * Current TCPDF version.
@ -114,7 +115,8 @@ class TCPDF_STATIC {
* @since 5.9.012 (2010-11-10) * @since 5.9.012 (2010-11-10)
* @public static * @public static
*/ */
public static function getTCPDFVersion() { public static function getTCPDFVersion()
{
return self::$tcpdf_version; return self::$tcpdf_version;
} }
@ -124,7 +126,8 @@ class TCPDF_STATIC {
* @since 6.0.000 (2013-03-16) * @since 6.0.000 (2013-03-16)
* @public static * @public static
*/ */
public static function getTCPDFProducer() { public static function getTCPDFProducer()
{
return "\x54\x43\x50\x44\x46\x20".self::getTCPDFVersion()."\x20\x28\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67\x29"; return "\x54\x43\x50\x44\x46\x20".self::getTCPDFVersion()."\x20\x28\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67\x29";
} }
@ -134,7 +137,8 @@ class TCPDF_STATIC {
* @since 4.6.025 (2009-08-17) * @since 4.6.025 (2009-08-17)
* @public static * @public static
*/ */
public static function set_mqr($mqr) { public static function set_mqr($mqr)
{
if (!defined('PHP_VERSION_ID')) { if (!defined('PHP_VERSION_ID')) {
$version = PHP_VERSION; $version = PHP_VERSION;
define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4])); define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
@ -150,7 +154,8 @@ class TCPDF_STATIC {
* @since 4.6.025 (2009-08-17) * @since 4.6.025 (2009-08-17)
* @public static * @public static
*/ */
public static function get_mqr() { public static function get_mqr()
{
if (!defined('PHP_VERSION_ID')) { if (!defined('PHP_VERSION_ID')) {
$version = PHP_VERSION; $version = PHP_VERSION;
define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4])); define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
@ -168,7 +173,8 @@ class TCPDF_STATIC {
* @since 5.9.204 (2013-01-28) * @since 5.9.204 (2013-01-28)
* @public static * @public static
*/ */
public static function isValidURL($url) { public static function isValidURL($url)
{
$headers = @get_headers($url); $headers = @get_headers($url);
return (strpos($headers[0], '200') !== false); return (strpos($headers[0], '200') !== false);
} }
@ -190,7 +196,8 @@ class TCPDF_STATIC {
* @since (4.5.019) 2009-02-28 * @since (4.5.019) 2009-02-28
* @public static * @public static
*/ */
public static function removeSHY($txt='', $unicode=true) { public static function removeSHY($txt = '', $unicode = true)
{
$txt = preg_replace('/([\\xc2]{1}[\\xad]{1})/', '', $txt); $txt = preg_replace('/([\\xc2]{1}[\\xad]{1})/', '', $txt);
if (!$unicode) { if (!$unicode) {
$txt = preg_replace('/([\\xad]{1})/', '', $txt); $txt = preg_replace('/([\\xad]{1})/', '', $txt);
@ -208,7 +215,8 @@ class TCPDF_STATIC {
* @since 4.4.002 (2008-12-09) * @since 4.4.002 (2008-12-09)
* @public static * @public static
*/ */
public static function getBorderMode($brd, $position='start', $opencell=true) { public static function getBorderMode($brd, $position = 'start', $opencell = true)
{
if ((!$opencell) OR empty($brd)) { if ((!$opencell) OR empty($brd)) {
return $brd; return $brd;
} }
@ -280,7 +288,8 @@ class TCPDF_STATIC {
* @since 4.5.044 (2009-04-16) * @since 4.5.044 (2009-04-16)
* @public static * @public static
*/ */
public static function empty_string($str) { public static function empty_string($str)
{
return (is_null($str) OR (is_string($str) AND (strlen($str) == 0))); return (is_null($str) OR (is_string($str) AND (strlen($str) == 0)));
} }
@ -292,7 +301,8 @@ class TCPDF_STATIC {
* @since 4.5.000 (2008-12-31) * @since 4.5.000 (2008-12-31)
* @public static * @public static
*/ */
public static function getObjFilename($type='tmp', $file_id='') { public static function getObjFilename($type = 'tmp', $file_id = '')
{
return tempnam(K_PATH_CACHE, '__tcpdf_'.$file_id.'_'.$type.'_'.md5(TCPDF_STATIC::getRandomSeed()).'_'); return tempnam(K_PATH_CACHE, '__tcpdf_'.$file_id.'_'.$type.'_'.md5(TCPDF_STATIC::getRandomSeed()).'_');
} }
@ -302,7 +312,8 @@ class TCPDF_STATIC {
* @return string escaped string. * @return string escaped string.
* @public static * @public static
*/ */
public static function _escape($s) { public static function _escape($s)
{
// the chr(13) substitution fixes the Bugs item #1421290. // the chr(13) substitution fixes the Bugs item #1421290.
return strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r')); return strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
} }
@ -314,7 +325,8 @@ class TCPDF_STATIC {
* @since 5.9.121 (2011-09-28) * @since 5.9.121 (2011-09-28)
* @public static * @public static
*/ */
public static function _escapeXML($str) { public static function _escapeXML($str)
{
$replaceTable = array("\0" => '', '&' => '&amp;', '<' => '&lt;', '>' => '&gt;'); $replaceTable = array("\0" => '', '&' => '&amp;', '<' => '&lt;', '>' => '&gt;');
$str = strtr($str, $replaceTable); $str = strtr($str, $replaceTable);
return $str; return $str;
@ -327,7 +339,8 @@ class TCPDF_STATIC {
* @since 4.5.029 (2009-03-19) * @since 4.5.029 (2009-03-19)
* @public static * @public static
*/ */
public static function objclone($object) { public static function objclone($object)
{
if (($object instanceof Imagick) AND (version_compare(phpversion('imagick'), '3.0.1') !== 1)) { if (($object instanceof Imagick) AND (version_compare(phpversion('imagick'), '3.0.1') !== 1)) {
// on the versions after 3.0.1 the clone() method was deprecated in favour of clone keyword // on the versions after 3.0.1 the clone() method was deprecated in favour of clone keyword
return @$object->clone(); return @$object->clone();
@ -342,7 +355,8 @@ class TCPDF_STATIC {
* @since 5.9.086 * @since 5.9.086
* @public static * @public static
*/ */
public static function sendOutputData($data, $length) { public static function sendOutputData($data, $length)
{
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) OR empty($_SERVER['HTTP_ACCEPT_ENCODING'])) { if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) OR empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
// the content length may vary if the server is using compression // the content length may vary if the server is using compression
header('Content-Length: '.$length); header('Content-Length: '.$length);
@ -358,7 +372,8 @@ class TCPDF_STATIC {
* @return replaced page content and updated $diff parameter as array. * @return replaced page content and updated $diff parameter as array.
* @public static * @public static
*/ */
public static function replacePageNumAliases($page, $replace, $diff=0) { public static function replacePageNumAliases($page, $replace, $diff = 0)
{
foreach ($replace as $rep) { foreach ($replace as $rep) {
foreach ($rep[3] as $a) { foreach ($rep[3] as $a) {
if (strpos($page, $a) !== false) { if (strpos($page, $a) !== false) {
@ -377,7 +392,8 @@ class TCPDF_STATIC {
* @since 5.9.152 (2012-03-23) * @since 5.9.152 (2012-03-23)
* @public static * @public static
*/ */
public static function getTimestamp($date) { public static function getTimestamp($date)
{
if (($date[0] == 'D') AND ($date[1] == ':')) { if (($date[0] == 'D') AND ($date[1] == ':')) {
// remove date prefix if present // remove date prefix if present
$date = substr($date, 2); $date = substr($date, 2);
@ -392,7 +408,8 @@ class TCPDF_STATIC {
* @since 5.9.152 (2012-03-23) * @since 5.9.152 (2012-03-23)
* @public static * @public static
*/ */
public static function getFormattedDate($time) { public static function getFormattedDate($time)
{
return substr_replace(date('YmdHisO', intval($time)), '\'', (0 - 2), 0).'\''; return substr_replace(date('YmdHisO', intval($time)), '\'', (0 - 2), 0).'\'';
} }
@ -404,7 +421,8 @@ class TCPDF_STATIC {
* @since 5.9.006 (2010-10-19) * @since 5.9.006 (2010-10-19)
* @public static * @public static
*/ */
public static function getRandomSeed($seed='') { public static function getRandomSeed($seed = '')
{
$rnd = uniqid(rand().microtime(true), true); $rnd = uniqid(rand().microtime(true), true);
if (function_exists('posix_getpid')) { if (function_exists('posix_getpid')) {
$rnd .= posix_getpid(); $rnd .= posix_getpid();
@ -427,7 +445,8 @@ class TCPDF_STATIC {
* @since 2.0.000 (2008-01-02) * @since 2.0.000 (2008-01-02)
* @public static * @public static
*/ */
public static function _md5_16($str) { public static function _md5_16($str)
{
return pack('H*', md5($str)); return pack('H*', md5($str));
} }
@ -441,12 +460,13 @@ class TCPDF_STATIC {
* @since 5.0.005 (2010-05-11) * @since 5.0.005 (2010-05-11)
* @public static * @public static
*/ */
public static function _AES($key, $text) { public static function _AES($key, $text)
{
// padding (RFC 2898, PKCS #5: Password-Based Cryptography Specification Version 2.0) // padding (RFC 2898, PKCS #5: Password-Based Cryptography Specification Version 2.0)
$padding = 16 - (strlen($text) % 16); $padding = 16 - (strlen($text) % 16);
$text .= str_repeat(chr($padding), $padding); $text .= str_repeat(chr($padding), $padding);
if (extension_loaded('openssl')) { if (extension_loaded('openssl')) {
$iv = openssl_random_pseudo_bytes (openssl_cipher_iv_length('aes-256-cbc')); $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
$text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv); $text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
return $iv.substr($text, 0, -16); return $iv.substr($text, 0, -16);
} }
@ -466,7 +486,8 @@ class TCPDF_STATIC {
* @since TODO * @since TODO
* @public static * @public static
*/ */
public static function _AESnopad($key, $text) { public static function _AESnopad($key, $text)
{
if (extension_loaded('openssl')) { if (extension_loaded('openssl')) {
$iv = str_repeat("\x00", openssl_cipher_iv_length('aes-256-cbc')); $iv = str_repeat("\x00", openssl_cipher_iv_length('aes-256-cbc'));
$text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv); $text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
@ -489,7 +510,8 @@ class TCPDF_STATIC {
* @author Klemen Vodopivec, Nicola Asuni * @author Klemen Vodopivec, Nicola Asuni
* @public static * @public static
*/ */
public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c) { public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c)
{
if (function_exists('mcrypt_encrypt') AND ($out = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM, ''))) { if (function_exists('mcrypt_encrypt') AND ($out = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM, ''))) {
// try to use mcrypt function if exist // try to use mcrypt function if exist
return $out; return $out;
@ -533,7 +555,8 @@ class TCPDF_STATIC {
* @author Nicola Asuni * @author Nicola Asuni
* @public static * @public static
*/ */
public static function getUserPermissionCode($permissions, $mode=0) { public static function getUserPermissionCode($permissions, $mode = 0)
{
$options = array( $options = array(
'owner' => 2, // bit 2 -- inverted logic: cleared by default 'owner' => 2, // bit 2 -- inverted logic: cleared by default
'print' => 4, // bit 3 'print' => 4, // bit 3
@ -570,7 +593,8 @@ class TCPDF_STATIC {
* @author Nicola Asuni * @author Nicola Asuni
* @public static * @public static
*/ */
public static function convertHexStringToString($bs) { public static function convertHexStringToString($bs)
{
$string = ''; // string to be returned $string = ''; // string to be returned
$bslength = strlen($bs); $bslength = strlen($bs);
if (($bslength % 2) != 0) { if (($bslength % 2) != 0) {
@ -592,7 +616,8 @@ class TCPDF_STATIC {
* @author Nicola Asuni * @author Nicola Asuni
* @public static * @public static
*/ */
public static function convertStringToHexString($s) { public static function convertStringToHexString($s)
{
$bs = ''; $bs = '';
$chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY); $chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);
foreach ($chars as $c) { foreach ($chars as $c) {
@ -609,7 +634,8 @@ class TCPDF_STATIC {
* @author Nicola Asuni * @author Nicola Asuni
* @public static * @public static
*/ */
public static function getEncPermissionsString($protection) { public static function getEncPermissionsString($protection)
{
$binprot = sprintf('%032b', $protection); $binprot = sprintf('%032b', $protection);
$str = chr(bindec(substr($binprot, 24, 8))); $str = chr(bindec(substr($binprot, 24, 8)));
$str .= chr(bindec(substr($binprot, 16, 8))); $str .= chr(bindec(substr($binprot, 16, 8)));
@ -626,7 +652,8 @@ class TCPDF_STATIC {
* @since 5.9.097 (2011-06-23) * @since 5.9.097 (2011-06-23)
* @public static * @public static
*/ */
public static function encodeNameObject($name) { public static function encodeNameObject($name)
{
$escname = ''; $escname = '';
$length = strlen($name); $length = strlen($name);
for ($i = 0; $i < $length; ++$i) { for ($i = 0; $i < $length; ++$i) {
@ -650,7 +677,8 @@ class TCPDF_STATIC {
* @since 4.8.000 (2009-09-06) * @since 4.8.000 (2009-09-06)
* @public static * @public static
*/ */
public static function getAnnotOptFromJSProp($prop, &$spot_colors, $rtl=false) { public static function getAnnotOptFromJSProp($prop, &$spot_colors, $rtl = false)
{
if (isset($prop['aopt']) AND is_array($prop['aopt'])) { if (isset($prop['aopt']) AND is_array($prop['aopt'])) {
// the annotation options area lready defined // the annotation options area lready defined
return $prop['aopt']; return $prop['aopt'];
@ -1016,8 +1044,9 @@ class TCPDF_STATIC {
* @since 4.2.005 (2008-11-06) * @since 4.2.005 (2008-11-06)
* @public static * @public static
*/ */
public static function formatPageNumber($num) { public static function formatPageNumber($num)
return number_format((float)$num, 0, '', '.'); {
return number_format((float) $num, 0, '', '.');
} }
/** /**
@ -1028,8 +1057,9 @@ class TCPDF_STATIC {
* @see addTOC(), addHTMLTOC() * @see addTOC(), addHTMLTOC()
* @public static * @public static
*/ */
public static function formatTOCPageNumber($num) { public static function formatTOCPageNumber($num)
return number_format((float)$num, 0, '', '.'); {
return number_format((float) $num, 0, '', '.');
} }
/** /**
@ -1040,7 +1070,8 @@ class TCPDF_STATIC {
* @since 5.1.000 (2010-05-25) * @since 5.1.000 (2010-05-25)
* @public static * @public static
*/ */
public static function extractCSSproperties($cssdata) { public static function extractCSSproperties($cssdata)
{
if (empty($cssdata)) { if (empty($cssdata)) {
return array(); return array();
} }
@ -1136,7 +1167,8 @@ class TCPDF_STATIC {
* @see setHtmlVSpace() * @see setHtmlVSpace()
* @public static * @public static
*/ */
public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces) { public static function fixHTMLCode($html, $default_css = '', $tagvs = '', $tidy_options = '', &$tagvspaces)
{
// configure parameters for HTML Tidy // configure parameters for HTML Tidy
if ($tidy_options === '') { if ($tidy_options === '') {
$tidy_options = array ( $tidy_options = array (
@ -1202,7 +1234,8 @@ class TCPDF_STATIC {
* @since 5.1.000 (2010-05-25) * @since 5.1.000 (2010-05-25)
* @public static * @public static
*/ */
public static function isValidCSSSelectorForTag($dom, $key, $selector) { public static function isValidCSSSelectorForTag($dom, $key, $selector)
{
$valid = false; // value to be returned $valid = false; // value to be returned
$tag = $dom[$key]['value']; $tag = $dom[$key]['value'];
$class = array(); $class = array();
@ -1362,7 +1395,8 @@ class TCPDF_STATIC {
* @since 5.1.000 (2010-05-25) * @since 5.1.000 (2010-05-25)
* @public static * @public static
*/ */
public static function getCSSdataArray($dom, $key, $css) { public static function getCSSdataArray($dom, $key, $css)
{
$cssarray = array(); // style to be returned $cssarray = array(); // style to be returned
// get parent CSS selectors // get parent CSS selectors
$selectors = array(); $selectors = array();
@ -1370,7 +1404,7 @@ class TCPDF_STATIC {
$selectors = $dom[($dom[$key]['parent'])]['csssel']; $selectors = $dom[($dom[$key]['parent'])]['csssel'];
} }
// get all styles that apply // get all styles that apply
foreach($css as $selector => $style) { foreach ($css as $selector => $style) {
$pos = strpos($selector, ' '); $pos = strpos($selector, ' ');
// get specificity // get specificity
$specificity = substr($selector, 0, $pos); $specificity = substr($selector, 0, $pos);
@ -1407,7 +1441,8 @@ class TCPDF_STATIC {
* @since 5.9.070 (2011-04-19) * @since 5.9.070 (2011-04-19)
* @public static * @public static
*/ */
public static function getTagStyleFromCSSarray($css) { public static function getTagStyleFromCSSarray($css)
{
$tagstyle = ''; // value to be returned $tagstyle = ''; // value to be returned
foreach ($css as $style) { foreach ($css as $style) {
// split single css commands // split single css commands
@ -1438,8 +1473,13 @@ class TCPDF_STATIC {
* @since 4.4.004 (2008-12-10) * @since 4.4.004 (2008-12-10)
* @public static * @public static
*/ */
public static function intToRoman($number) { public static function intToRoman($number)
{
$roman = ''; $roman = '';
if ($number >= 4000) {
// do not represent numbers above 4000 in Roman numerals
return strval($number);
}
while ($number >= 1000) { while ($number >= 1000) {
$roman .= 'M'; $roman .= 'M';
$number -= 1000; $number -= 1000;
@ -1504,7 +1544,8 @@ class TCPDF_STATIC {
* @since 4.8.038 (2010-03-13) * @since 4.8.038 (2010-03-13)
* @public static * @public static
*/ */
public static function revstrpos($haystack, $needle, $offset = 0) { public static function revstrpos($haystack, $needle, $offset = 0)
{
$length = strlen($haystack); $length = strlen($haystack);
$offset = ($offset > 0)?($length - $offset):abs($offset); $offset = ($offset > 0)?($length - $offset):abs($offset);
$pos = strpos(strrev($haystack), strrev($needle), $offset); $pos = strpos(strrev($haystack), strrev($needle), $offset);
@ -1519,7 +1560,8 @@ class TCPDF_STATIC {
* @since 4.9.012 (2010-04-12) * @since 4.9.012 (2010-04-12)
* @public static * @public static
*/ */
public static function getHyphenPatternsFromTEX($file) { public static function getHyphenPatternsFromTEX($file)
{
// TEX patterns are available at: // TEX patterns are available at:
// http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/ // http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
$data = file_get_contents($file); $data = file_get_contents($file);
@ -1533,7 +1575,7 @@ class TCPDF_STATIC {
$patterns_array = preg_split('/[\s]+/', $data); $patterns_array = preg_split('/[\s]+/', $data);
// create new language array of patterns // create new language array of patterns
$patterns = array(); $patterns = array();
foreach($patterns_array as $val) { foreach ($patterns_array as $val) {
if (!TCPDF_STATIC::empty_string($val)) { if (!TCPDF_STATIC::empty_string($val)) {
$val = trim($val); $val = trim($val);
$val = str_replace('\'', '\\\'', $val); $val = str_replace('\'', '\\\'', $val);
@ -1565,9 +1607,10 @@ class TCPDF_STATIC {
* @since 5.0.000 (2010-04-30) * @since 5.0.000 (2010-04-30)
* @public static * @public static
*/ */
public static function getPathPaintOperator($style, $default='S') { public static function getPathPaintOperator($style, $default = 'S')
{
$op = ''; $op = '';
switch($style) { switch ($style) {
case 'S': case 'S':
case 'D': { case 'D': {
$op = 'S'; $op = 'S';
@ -1644,7 +1687,8 @@ class TCPDF_STATIC {
* @since 5.0.000 (2010-05-02) * @since 5.0.000 (2010-05-02)
* @public static * @public static
*/ */
public static function getTransformationMatrixProduct($ta, $tb) { public static function getTransformationMatrixProduct($ta, $tb)
{
$tm = array(); $tm = array();
$tm[0] = ($ta[0] * $tb[0]) + ($ta[2] * $tb[1]); $tm[0] = ($ta[0] * $tb[0]) + ($ta[2] * $tb[1]);
$tm[1] = ($ta[1] * $tb[0]) + ($ta[3] * $tb[1]); $tm[1] = ($ta[1] * $tb[0]) + ($ta[3] * $tb[1]);
@ -1663,7 +1707,8 @@ class TCPDF_STATIC {
* @since 5.0.000 (2010-05-02) * @since 5.0.000 (2010-05-02)
* @public static * @public static
*/ */
public static function getSVGTransformMatrix($attribute) { public static function getSVGTransformMatrix($attribute)
{
// identity matrix // identity matrix
$tm = array(1, 0, 0, 1, 0, 0); $tm = array(1, 0, 0, 1, 0, 0);
$transform = array(); $transform = array();
@ -1760,7 +1805,8 @@ class TCPDF_STATIC {
* @since 5.0.000 (2010-05-04) * @since 5.0.000 (2010-05-04)
* @public static * @public static
*/ */
public static function getVectorsAngle($x1, $y1, $x2, $y2) { public static function getVectorsAngle($x1, $y1, $x2, $y2)
{
$dprod = ($x1 * $x2) + ($y1 * $y2); $dprod = ($x1 * $x2) + ($y1 * $y2);
$dist1 = sqrt(($x1 * $x1) + ($y1 * $y1)); $dist1 = sqrt(($x1 * $x1) + ($y1 * $y1));
$dist2 = sqrt(($x2 * $x2) + ($y2 * $y2)); $dist2 = sqrt(($x2 * $x2) + ($y2 * $y2));
@ -1787,14 +1833,15 @@ class TCPDF_STATIC {
* @since 6.0.023 * @since 6.0.023
* @public static * @public static
*/ */
public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) { public static function pregSplit($pattern, $modifiers, $subject, $limit = null, $flags = null)
{
// the bug only happens on PHP 5.2 when using the u modifier // the bug only happens on PHP 5.2 when using the u modifier
if ((strpos($modifiers, 'u') === FALSE) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) { if ((strpos($modifiers, 'u') === false) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) {
return preg_split($pattern.$modifiers, $subject, $limit, $flags); return preg_split($pattern.$modifiers, $subject, $limit, $flags);
} }
// preg_split is bugged - try alternative solution // preg_split is bugged - try alternative solution
$ret = array(); $ret = array();
while (($nl = strpos($subject, "\n")) !== FALSE) { while (($nl = strpos($subject, "\n")) !== false) {
$ret = array_merge($ret, preg_split($pattern.$modifiers, substr($subject, 0, $nl), $limit, $flags)); $ret = array_merge($ret, preg_split($pattern.$modifiers, substr($subject, 0, $nl), $limit, $flags));
$ret[] = "\n"; $ret[] = "\n";
$subject = substr($subject, ($nl + 1)); $subject = substr($subject, ($nl + 1));
@ -1834,7 +1881,8 @@ class TCPDF_STATIC {
* @return Returns TRUE if the URL exists; FALSE otherwise. * @return Returns TRUE if the URL exists; FALSE otherwise.
* @public static * @public static
*/ */
public static function url_exists($url) { public static function url_exists($url)
{
$crs = curl_init(); $crs = curl_init();
curl_setopt($crs, CURLOPT_URL, $url); curl_setopt($crs, CURLOPT_URL, $url);
curl_setopt($crs, CURLOPT_NOBODY, true); curl_setopt($crs, CURLOPT_NOBODY, true);
@ -1861,7 +1909,8 @@ class TCPDF_STATIC {
* @return Returns TRUE if the file or directory specified by filename exists; FALSE otherwise. * @return Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.
* @public static * @public static
*/ */
public static function file_exists($filename) { public static function file_exists($filename)
{
if (preg_match('|^https?://|', $filename) == 1) { if (preg_match('|^https?://|', $filename) == 1) {
return self::url_exists($filename); return self::url_exists($filename);
} }
@ -1880,7 +1929,8 @@ class TCPDF_STATIC {
* @since 6.0.025 * @since 6.0.025
* @public static * @public static
*/ */
public static function fileGetContents($file) { public static function fileGetContents($file)
{
$alt = array($file); $alt = array($file);
// //
if ((strlen($file) > 1) if ((strlen($file) > 1)
@ -1977,7 +2027,8 @@ class TCPDF_STATIC {
* @since 5.2.000 (2010-06-02) * @since 5.2.000 (2010-06-02)
* @public static * @public static
*/ */
public static function _getULONG($str, $offset) { public static function _getULONG($str, $offset)
{
$v = unpack('Ni', substr($str, $offset, 4)); $v = unpack('Ni', substr($str, $offset, 4));
return $v['i']; return $v['i'];
} }
@ -1991,7 +2042,8 @@ class TCPDF_STATIC {
* @since 5.2.000 (2010-06-02) * @since 5.2.000 (2010-06-02)
* @public static * @public static
*/ */
public static function _getUSHORT($str, $offset) { public static function _getUSHORT($str, $offset)
{
$v = unpack('ni', substr($str, $offset, 2)); $v = unpack('ni', substr($str, $offset, 2));
return $v['i']; return $v['i'];
} }
@ -2005,7 +2057,8 @@ class TCPDF_STATIC {
* @since 5.2.000 (2010-06-02) * @since 5.2.000 (2010-06-02)
* @public static * @public static
*/ */
public static function _getSHORT($str, $offset) { public static function _getSHORT($str, $offset)
{
$v = unpack('si', substr($str, $offset, 2)); $v = unpack('si', substr($str, $offset, 2));
return $v['i']; return $v['i'];
} }
@ -2019,7 +2072,8 @@ class TCPDF_STATIC {
* @since 5.9.123 (2011-09-30) * @since 5.9.123 (2011-09-30)
* @public static * @public static
*/ */
public static function _getFWORD($str, $offset) { public static function _getFWORD($str, $offset)
{
$v = self::_getUSHORT($str, $offset); $v = self::_getUSHORT($str, $offset);
if ($v > 0x7fff) { if ($v > 0x7fff) {
$v -= 0x10000; $v -= 0x10000;
@ -2036,7 +2090,8 @@ class TCPDF_STATIC {
* @since 5.9.123 (2011-09-30) * @since 5.9.123 (2011-09-30)
* @public static * @public static
*/ */
public static function _getUFWORD($str, $offset) { public static function _getUFWORD($str, $offset)
{
$v = self::_getUSHORT($str, $offset); $v = self::_getUSHORT($str, $offset);
return $v; return $v;
} }
@ -2050,7 +2105,8 @@ class TCPDF_STATIC {
* @since 5.9.123 (2011-09-30) * @since 5.9.123 (2011-09-30)
* @public static * @public static
*/ */
public static function _getFIXED($str, $offset) { public static function _getFIXED($str, $offset)
{
// mantissa // mantissa
$m = self::_getFWORD($str, $offset); $m = self::_getFWORD($str, $offset);
// fraction // fraction
@ -2068,7 +2124,8 @@ class TCPDF_STATIC {
* @since 5.2.000 (2010-06-02) * @since 5.2.000 (2010-06-02)
* @public static * @public static
*/ */
public static function _getBYTE($str, $offset) { public static function _getBYTE($str, $offset)
{
$v = unpack('Ci', substr($str, $offset, 1)); $v = unpack('Ci', substr($str, $offset, 1));
return $v['i']; return $v['i'];
} }
@ -2082,7 +2139,8 @@ class TCPDF_STATIC {
* @since 4.5.027 (2009-03-16) * @since 4.5.027 (2009-03-16)
* @public static * @public static
*/ */
public static function rfread($handle, $length) { public static function rfread($handle, $length)
{
$data = fread($handle, $length); $data = fread($handle, $length);
if ($data === false) { if ($data === false) {
return false; return false;
@ -2100,7 +2158,8 @@ class TCPDF_STATIC {
* @return 4-byte integer * @return 4-byte integer
* @public static * @public static
*/ */
public static function _freadint($f) { public static function _freadint($f)
{
$a = unpack('Ni', fread($f, 4)); $a = unpack('Ni', fread($f, 4));
return $a['i']; return $a['i'];
} }
@ -2470,7 +2529,8 @@ class TCPDF_STATIC {
* @since 5.0.010 (2010-05-17) * @since 5.0.010 (2010-05-17)
* @public static * @public static
*/ */
public static function getPageSizeFromFormat($format) { public static function getPageSizeFromFormat($format)
{
if (isset(self::$page_formats[$format])) { if (isset(self::$page_formats[$format])) {
return self::$page_formats[$format]; return self::$page_formats[$format];
} }
@ -2492,7 +2552,8 @@ class TCPDF_STATIC {
* @since 5.0.010 (2010-05-17) * @since 5.0.010 (2010-05-17)
* @public static * @public static
*/ */
public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array()) { public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points = false, $k, $pagedim = array())
{
if (!isset($pagedim[$page])) { if (!isset($pagedim[$page])) {
// initialize array // initialize array
$pagedim[$page] = array(); $pagedim[$page] = array();
@ -2518,7 +2579,8 @@ class TCPDF_STATIC {
* @since 5.0.010 (2010-05-17) * @since 5.0.010 (2010-05-17)
* @public static * @public static
*/ */
public static function swapPageBoxCoordinates($page, $pagedim) { public static function swapPageBoxCoordinates($page, $pagedim)
{
foreach (self::$pageboxes as $type) { foreach (self::$pageboxes as $type) {
// swap X and Y coordinates // swap X and Y coordinates
if (isset($pagedim[$page][$type])) { if (isset($pagedim[$page][$type])) {
@ -2539,7 +2601,8 @@ class TCPDF_STATIC {
* @return (string) Canonical page layout name. * @return (string) Canonical page layout name.
* @public static * @public static
*/ */
public static function getPageLayoutMode($layout='SinglePage') { public static function getPageLayoutMode($layout = 'SinglePage')
{
switch ($layout) { switch ($layout) {
case 'default': case 'default':
case 'single': case 'single':
@ -2582,7 +2645,8 @@ class TCPDF_STATIC {
* @return (string) Canonical page mode name. * @return (string) Canonical page mode name.
* @public static * @public static
*/ */
public static function getPageMode($mode='UseNone') { public static function getPageMode($mode = 'UseNone')
{
switch ($mode) { switch ($mode) {
case 'UseNone': { case 'UseNone': {
$page_mode = 'UseNone'; $page_mode = 'UseNone';
@ -2614,8 +2678,6 @@ class TCPDF_STATIC {
} }
return $page_mode; return $page_mode;
} }
} // END OF TCPDF_STATIC CLASS } // END OF TCPDF_STATIC CLASS
//============================================================+ //============================================================+