PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
← All changes | vendor/tecnickcom/tcpdf/include/tcpdf_static.php +304 -247 2.3.2 → 4.17.0 View file →
@@ -1,14 +1,14 @@
1 1 <?php
2 2 //============================================================+
3 3 // File name : tcpdf_static.php
4 -// Version : 1.1.3
4 +// Version : 1.1.5
5 5 // Begin : 2002-08-03
6 -// Last Update : 2015-04-28
6 +// Last Update : 2024-12-23
7 7 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected]
8 -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
8 +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html)
9 9 // -------------------------------------------------------------------
10 -// Copyright (C) 2002-2015 Nicola Asuni - Tecnick.com LTD
10 +// Copyright (C) 2002-2026 Nicola Asuni - Tecnick.com LTD
11 11 //
12 12 // This file is part of TCPDF software library.
13 13 //
14 14 // TCPDF is free software: you can redistribute it and/or modify it
@@ -37,9 +37,9 @@
37 37 * @file
38 38 * This is a PHP class that contains static methods for the TCPDF class.<br>
39 39 * @package com.tecnick.tcpdf
40 40 * @author Nicola Asuni
41 - * @version 1.1.2
41 + * @version 1.1.5
42 42 */
43 43
44 44 /**
45 45 * @class TCPDF_STATIC
@@ -45,9 +45,9 @@
45 45 * @class TCPDF_STATIC
46 46 * Static methods used by the TCPDF class.
47 47 * @package com.tecnick.tcpdf
48 48 * @brief PHP class for generating PDF documents without requiring external extensions.
49 - * @version 1.1.1
49 + * @version 1.1.5
50 50 * @author Nicola Asuni - [email protected]
51 51 */
52 52 class TCPDF_STATIC {
53 53
@@ -54,9 +54,9 @@
54 54 /**
55 55 * Current TCPDF version.
56 56 * @private static
57 57 */
58 - private static $tcpdf_version = '6.2.17';
58 + private static $tcpdf_version = '6.11.3';
59 59
60 60 /**
61 61 * String alias for total number of pages.
62 62 * @public static
@@ -105,13 +105,38 @@
105 105 * @public static
106 106 */
107 107 public static $pageboxes = array('MediaBox', 'CropBox', 'BleedBox', 'TrimBox', 'ArtBox');
108 108
109 + /**
110 + * Array of default cURL options for curl_setopt_array.
111 + *
112 + * @var array<int, bool|int|string> cURL options.
113 + */
114 + protected const CURLOPT_DEFAULT = [
115 + CURLOPT_CONNECTTIMEOUT => 5,
116 + CURLOPT_MAXREDIRS => 5,
117 + CURLOPT_PROTOCOLS => CURLPROTO_HTTPS | CURLPROTO_HTTP | CURLPROTO_FTP | CURLPROTO_FTPS,
118 + CURLOPT_SSL_VERIFYHOST => 2,
119 + CURLOPT_SSL_VERIFYPEER => true,
120 + CURLOPT_TIMEOUT => 30,
121 + CURLOPT_USERAGENT => 'tcpdf',
122 + ];
123 +
124 + /**
125 + * Array of fixed cURL options for curl_setopt_array.
126 + *
127 + * @var array<int, bool|int|string> cURL options.
128 + */
129 + protected const CURLOPT_FIXED = [
130 + CURLOPT_FAILONERROR => true,
131 + CURLOPT_RETURNTRANSFER => true,
132 + ];
133 +
109 134 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
110 135
111 136 /**
112 137 * Return the current TCPDF version.
113 - * @return TCPDF version string
138 + * @return string TCPDF version string
114 139 * @since 5.9.012 (2010-11-10)
115 140 * @public static
116 141 */
117 142 public static function getTCPDFVersion() {
@@ -119,9 +144,9 @@
119 144 }
120 145
121 146 /**
122 147 * Return the current TCPDF producer.
123 - * @return TCPDF producer string
148 + * @return string TCPDF producer string
124 149 * @since 6.0.000 (2013-03-16)
125 150 * @public static
126 151 */
127 152 public static function getTCPDFProducer() {
@@ -128,49 +153,19 @@
128 153 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";
129 154 }
130 155
131 156 /**
132 - * Sets the current active configuration setting of magic_quotes_runtime (if the set_magic_quotes_runtime function exist)
133 - * @param $mqr (boolean) FALSE for off, TRUE for on.
134 - * @since 4.6.025 (2009-08-17)
135 - * @public static
136 - */
137 - public static function set_mqr($mqr) {
138 - if (!defined('PHP_VERSION_ID')) {
139 - $version = PHP_VERSION;
140 - define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
141 - }
142 - if (PHP_VERSION_ID < 50300) {
143 - @set_magic_quotes_runtime($mqr);
144 - }
145 - }
146 -
147 - /**
148 - * Gets the current active configuration setting of magic_quotes_runtime (if the get_magic_quotes_runtime function exist)
149 - * @return Returns 0 if magic quotes runtime is off or get_magic_quotes_runtime doesn't exist, 1 otherwise.
150 - * @since 4.6.025 (2009-08-17)
151 - * @public static
152 - */
153 - public static function get_mqr() {
154 - if (!defined('PHP_VERSION_ID')) {
155 - $version = PHP_VERSION;
156 - define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
157 - }
158 - if (PHP_VERSION_ID < 50300) {
159 - return @get_magic_quotes_runtime();
160 - }
161 - return 0;
162 - }
163 -
164 - /**
165 157 * Check if the URL exist.
166 - * @param $url (string) URL to check.
167 - * @return Boolean true if the URl exist, false otherwise.
158 + * @param string $url URL to check.
159 + * @return boolean true if the URl exist, false otherwise.
168 160 * @since 5.9.204 (2013-01-28)
169 161 * @public static
170 162 */
171 163 public static function isValidURL($url) {
172 164 $headers = @get_headers($url);
165 + if ($headers === false) {
166 + return false;
167 + }
173 168 return (strpos($headers[0], '200') !== false);
174 169 }
175 170
176 171 /**
@@ -183,10 +178,10 @@
183 178 * <li>How to type in Microsoft Windows: [Alt +00AD] or [Alt 0173]</li>
184 179 * <li>UTF-8 (hex): 0xC2 0xAD (c2ad)</li>
185 180 * <li>UTF-8 character: chr(194).chr(173)</li>
186 181 * </ul>
187 - * @param $txt (string) input string
188 - * @param $unicode (boolean) True if we are in unicode mode, false otherwise.
182 + * @param string $txt input string
183 + * @param boolean $unicode True if we are in unicode mode, false otherwise.
189 184 * @return string without SHY characters.
190 185 * @since (4.5.019) 2009-02-28
191 186 * @public static
192 187 */
@@ -200,12 +195,12 @@
200 195
201 196
202 197 /**
203 198 * Get the border mode accounting for multicell position (opens bottom side of multicell crossing pages)
204 - * @param $brd (mixed) Indicates if borders must be drawn around the cell block. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
205 - * @param $position (string) multicell position: 'start', 'middle', 'end'
206 - * @param $opencell (boolean) True when the cell is left open at the page bottom, false otherwise.
207 - * @return border mode array
199 + * @param string|array|int $brd Indicates if borders must be drawn around the cell block. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
200 + * @param string $position multicell position: 'start', 'middle', 'end'
201 + * @param boolean $opencell True when the cell is left open at the page bottom, false otherwise.
202 + * @return array border mode array
208 203 * @since 4.4.002 (2008-12-09)
209 204 * @public static
210 205 */
211 206 public static function getBorderMode($brd, $position='start', $opencell=true) {
@@ -274,10 +269,10 @@
274 269 }
275 270
276 271 /**
277 272 * Determine whether a string is empty.
278 - * @param $str (string) string to be checked
279 - * @return boolean true if string is empty
273 + * @param string $str string to be checked
274 + * @return bool true if string is empty
280 275 * @since 4.5.044 (2009-04-16)
281 276 * @public static
282 277 */
283 278 public static function empty_string($str) {
@@ -285,10 +280,10 @@
285 280 }
286 281
287 282 /**
288 283 * Returns a temporary filename for caching object on filesystem.
289 - * @param $type (string) Type of file (name of the subdir on the tcpdf cache folder).
290 - * @param $file_id (string) TCPDF file_id.
284 + * @param string $type Type of file (name of the subdir on the tcpdf cache folder).
285 + * @param string $file_id TCPDF file_id.
291 286 * @return string filename.
292 287 * @since 4.5.000 (2008-12-31)
293 288 * @public static
294 289 */
@@ -297,9 +292,9 @@
297 292 }
298 293
299 294 /**
300 295 * Add "\" before "\", "(" and ")"
301 - * @param $s (string) string to escape.
296 + * @param string $s string to escape.
302 297 * @return string escaped string.
303 298 * @public static
304 299 */
305 300 public static function _escape($s) {
@@ -308,23 +303,23 @@
308 303 }
309 304
310 305 /**
311 306 * Escape some special characters (&lt; &gt; &amp;) for XML output.
312 - * @param $str (string) Input string to convert.
313 - * @return converted string
307 + * @param string $str Input string to convert.
308 + * @return string converted string
314 309 * @since 5.9.121 (2011-09-28)
315 310 * @public static
316 311 */
317 312 public static function _escapeXML($str) {
318 313 $replaceTable = array("\0" => '', '&' => '&amp;', '<' => '&lt;', '>' => '&gt;');
319 - $str = strtr($str, $replaceTable);
314 + $str = strtr($str === null ? '' : $str, $replaceTable);
320 315 return $str;
321 316 }
322 317
323 318 /**
324 319 * Creates a copy of a class object
325 - * @param $object (object) class object to be cloned
326 - * @return cloned object
320 + * @param object $object class object to be cloned
321 + * @return object cloned object
327 322 * @since 4.5.029 (2009-03-19)
328 323 * @public static
329 324 */
330 325 public static function objclone($object) {
@@ -336,10 +331,10 @@
336 331 }
337 332
338 333 /**
339 334 * Output input data and compress it if possible.
340 - * @param $data (string) Data to output.
341 - * @param $length (int) Data length in bytes.
335 + * @param string $data Data to output.
336 + * @param int $length Data length in bytes.
342 337 * @since 5.9.086
343 338 * @public static
344 339 */
345 340 public static function sendOutputData($data, $length) {
@@ -351,12 +346,12 @@
351 346 }
352 347
353 348 /**
354 349 * Replace page number aliases with number.
355 - * @param $page (string) Page content.
356 - * @param $replace (array) Array of replacements (array keys are replacement strings, values are alias arrays).
357 - * @param $diff (int) If passed, this will be set to the total char number difference between alias and replacements.
358 - * @return replaced page content and updated $diff parameter as array.
350 + * @param string $page Page content.
351 + * @param array $replace Array of replacements (array keys are replacement strings, values are alias arrays).
352 + * @param int $diff If passed, this will be set to the total char number difference between alias and replacements.
353 + * @return array replaced page content and updated $diff parameter as array.
359 354 * @public static
360 355 */
361 356 public static function replacePageNumAliases($page, $replace, $diff=0) {
362 357 foreach ($replace as $rep) {
@@ -371,9 +366,9 @@
371 366 }
372 367
373 368 /**
374 369 * Returns timestamp in seconds from formatted date-time.
375 - * @param $date (string) Formatted date-time.
370 + * @param string $date Formatted date-time.
376 371 * @return int seconds.
377 372 * @since 5.9.152 (2012-03-23)
378 373 * @public static
379 374 */
@@ -386,9 +381,9 @@
386 381 }
387 382
388 383 /**
389 384 * Returns a formatted date-time.
390 - * @param $time (int) Time in seconds.
385 + * @param int $time Time in seconds.
391 386 * @return string escaped date string.
392 387 * @since 5.9.152 (2012-03-23)
393 388 * @public static
394 389 */
@@ -397,9 +392,9 @@
397 392 }
398 393
399 394 /**
400 395 * Returns a string containing random data to be used as a seed for encryption methods.
401 - * @param $seed (string) starting seed value
396 + * @param string $seed starting seed value
402 397 * @return string containing random data
403 398 * @author Nicola Asuni
404 399 * @since 5.9.006 (2010-10-19)
405 400 * @public static
@@ -408,9 +403,12 @@
408 403 $rnd = uniqid(rand().microtime(true), true);
409 404 if (function_exists('posix_getpid')) {
410 405 $rnd .= posix_getpid();
411 406 }
412 - if (function_exists('openssl_random_pseudo_bytes') AND (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) {
407 +
408 + if (function_exists('random_bytes')) {
409 + $rnd .= random_bytes(512);
410 + } elseif (function_exists('openssl_random_pseudo_bytes') AND (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) {
413 411 // this is not used on windows systems because it is very slow for a know bug
414 412 $rnd .= openssl_random_pseudo_bytes(512);
415 413 } else {
416 414 for ($i = 0; $i < 23; ++$i) {
@@ -416,15 +414,15 @@
416 414 for ($i = 0; $i < 23; ++$i) {
417 415 $rnd .= uniqid('', true);
418 416 }
419 417 }
420 - return $rnd.$seed.__FILE__.serialize($_SERVER).microtime(true);
418 + return $rnd.$seed.__FILE__.microtime(true);
421 419 }
422 420
423 421 /**
424 422 * Encrypts a string using MD5 and returns it's value as a binary string.
425 - * @param $str (string) input string
426 - * @return String MD5 encrypted binary string
423 + * @param string $str input string
424 + * @return string MD5 encrypted binary string
427 425 * @since 2.0.000 (2008-01-02)
428 426 * @public static
429 427 */
430 428 public static function _md5_16($str) {
@@ -431,13 +429,13 @@
431 429 return pack('H*', md5($str));
432 430 }
433 431
434 432 /**
435 - * Returns the input text exrypted using AES algorithm and the specified key.
433 + * Returns the input text encrypted using AES algorithm and the specified key.
436 434 * This method requires openssl or mcrypt. Text is padded to 16bytes blocks
437 - * @param $key (string) encryption key
438 - * @param $text (String) input text to be encrypted
439 - * @return String encrypted text
435 + * @param string $key encryption key
436 + * @param string $text input text to be encrypted
437 + * @return string encrypted text
440 438 * @author Nicola Asuni
441 439 * @since 5.0.005 (2010-05-11)
442 440 * @public static
443 441 */
@@ -445,10 +443,14 @@
445 443 // padding (RFC 2898, PKCS #5: Password-Based Cryptography Specification Version 2.0)
446 444 $padding = 16 - (strlen($text) % 16);
447 445 $text .= str_repeat(chr($padding), $padding);
448 446 if (extension_loaded('openssl')) {
449 - $iv = openssl_random_pseudo_bytes (openssl_cipher_iv_length('aes-256-cbc'));
450 - $text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
447 + $algo = 'aes-256-cbc';
448 + if (strlen($key) == 16) {
449 + $algo = 'aes-128-cbc';
450 + }
451 + $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($algo));
452 + $text = openssl_encrypt($text, $algo, $key, OPENSSL_RAW_DATA, $iv);
451 453 return $iv.substr($text, 0, -16);
452 454 }
453 455 $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
454 456 $text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
@@ -456,13 +458,13 @@
456 458 return $text;
457 459 }
458 460
459 461 /**
460 - * Returns the input text exrypted using AES algorithm and the specified key.
462 + * Returns the input text encrypted using AES algorithm and the specified key.
461 463 * This method requires openssl or mcrypt. Text is not padded
462 - * @param $key (string) encryption key
463 - * @param $text (String) input text to be encrypted
464 - * @return String encrypted text
464 + * @param string $key encryption key
465 + * @param string $text input text to be encrypted
466 + * @return string encrypted text
465 467 * @author Nicola Asuni
466 468 * @since TODO
467 469 * @public static
468 470 */
@@ -467,10 +469,14 @@
467 469 * @public static
468 470 */
469 471 public static function _AESnopad($key, $text) {
470 472 if (extension_loaded('openssl')) {
471 - $iv = str_repeat("\x00", openssl_cipher_iv_length('aes-256-cbc'));
472 - $text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
473 + $algo = 'aes-256-cbc';
474 + if (strlen($key) == 16) {
475 + $algo = 'aes-128-cbc';
476 + }
477 + $iv = str_repeat("\x00", openssl_cipher_iv_length($algo));
478 + $text = openssl_encrypt($text, $algo, $key, OPENSSL_RAW_DATA, $iv);
473 479 return substr($text, 0, -16);
474 480 }
475 481 $iv = str_repeat("\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
476 482 $text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
@@ -479,15 +485,15 @@
479 485
480 486 /**
481 487 * Returns the input text encrypted using RC4 algorithm and the specified key.
482 488 * RC4 is the standard encryption algorithm used in PDF format
483 - * @param $key (string) Encryption key.
484 - * @param $text (String) Input text to be encrypted.
485 - * @param $last_enc_key (String) Reference to last RC4 key encrypted.
486 - * @param $last_enc_key_c (String) Reference to last RC4 computed key.
487 - * @return String encrypted text
489 + * @param string $key Encryption key.
490 + * @param string $text Input text to be encrypted.
491 + * @param string $last_enc_key Reference to last RC4 key encrypted.
492 + * @param string $last_enc_key_c Reference to last RC4 computed key.
493 + * @return string encrypted text
488 494 * @since 2.0.000 (2008-01-02)
489 - * @author Klemen Vodopivec, Nicola Asuni
495 + * @author Klemen Vodopivec,2026 Nicola Asuni
490 496 * @public static
491 497 */
492 498 public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c) {
493 499 if (function_exists('mcrypt_encrypt') AND ($out = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM, ''))) {
@@ -494,9 +500,9 @@
494 500 // try to use mcrypt function if exist
495 501 return $out;
496 502 }
497 503 if ($last_enc_key != $key) {
498 - $k = str_repeat($key, ((256 / strlen($key)) + 1));
504 + $k = str_repeat($key, (int) ((256 / strlen($key)) + 1));
499 505 $rc4 = range(0, 255);
500 506 $j = 0;
501 507 for ($i = 0; $i < 256; ++$i) {
502 508 $t = $rc4[$i];
@@ -526,10 +532,10 @@
526 532 }
527 533
528 534 /**
529 535 * Return the permission code used on encryption (P value).
530 - * @param $permissions (Array) the set of permissions (specify the ones you want to block).
531 - * @param $mode (int) encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit.
536 + * @param array $permissions the set of permissions (specify the ones you want to block).
537 + * @param int $mode encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit.
532 538 * @since 5.0.005 (2010-05-12)
533 539 * @author Nicola Asuni
534 540 * @public static
535 541 */
@@ -563,10 +569,10 @@
563 569 }
564 570
565 571 /**
566 572 * Convert hexadecimal string to string
567 - * @param $bs (string) byte-string to convert
568 - * @return String
573 + * @param string $bs byte-string to convert
574 + * @return string
569 575 * @since 5.0.005 (2010-05-12)
570 576 * @author Nicola Asuni
571 577 * @public static
572 578 */
@@ -585,10 +591,10 @@
585 591 }
586 592
587 593 /**
588 594 * Convert string to hexadecimal string (byte string)
589 - * @param $s (string) string to convert
590 - * @return byte string
595 + * @param string $s string to convert
596 + * @return string byte string
591 597 * @since 5.0.010 (2010-05-17)
592 598 * @author Nicola Asuni
593 599 * @public static
594 600 */
@@ -602,10 +608,10 @@
602 608 }
603 609
604 610 /**
605 611 * Convert encryption P value to a string of bytes, low-order byte first.
606 - * @param $protection (string) 32bit encryption permission value (P value)
607 - * @return String
612 + * @param string $protection 32bit encryption permission value (P value)
613 + * @return string
608 614 * @since 5.0.005 (2010-05-12)
609 615 * @author Nicola Asuni
610 616 * @public static
611 617 */
@@ -619,10 +625,10 @@
619 625 }
620 626
621 627 /**
622 628 * Encode a name object.
623 - * @param $name (string) Name object to encode.
624 - * @return (string) Encoded name object.
629 + * @param string $name Name object to encode.
630 + * @return string Encoded name object.
625 631 * @author Nicola Asuni
626 632 * @since 5.9.097 (2011-06-23)
627 633 * @public static
628 634 */
@@ -641,11 +647,11 @@
641 647 }
642 648
643 649 /**
644 650 * Convert JavaScript form fields properties array to Annotation Properties array.
645 - * @param $prop (array) javascript field properties. Possible values are described on official Javascript for Acrobat API reference.
646 - * @param $spot_colors (array) Reference to spot colors array.
647 - * @param $rtl (boolean) True if in Right-To-Left text direction mode, false otherwise.
651 + * @param array $prop javascript field properties. Possible values are described on official Javascript for Acrobat API reference.
652 + * @param array $spot_colors Reference to spot colors array.
653 + * @param boolean $rtl True if in Right-To-Left text direction mode, false otherwise.
648 654 * @return array of annotation properties
649 655 * @author Nicola Asuni
650 656 * @since 4.8.000 (2009-09-06)
651 657 * @public static
@@ -651,9 +657,9 @@
651 657 * @public static
652 658 */
653 659 public static function getAnnotOptFromJSProp($prop, &$spot_colors, $rtl=false) {
654 660 if (isset($prop['aopt']) AND is_array($prop['aopt'])) {
655 - // the annotation options area lready defined
661 + // the annotation options are already defined
656 662 return $prop['aopt'];
657 663 }
658 664 $opt = array(); // value to be returned
659 665 // alignment: Controls how the text is laid out within the text field.
@@ -840,11 +846,9 @@
840 846 // charLimit: Limits the number of characters that a user can type into a text field.
841 847 if (isset($prop['charLimit'])) {
842 848 $opt['maxlen'] = intval($prop['charLimit']);
843 849 }
844 - if (!isset($ff)) {
845 - $ff = 0; // default value
846 - }
850 + $ff = 0;
847 851 // readonly: The read-only characteristic of a field. If a field is read-only, the user can see the field but cannot change it.
848 852 if (isset($prop['readonly']) AND ($prop['readonly'] == 'true')) {
849 853 $ff += 1 << 0;
850 854 }
@@ -1010,10 +1014,11 @@
1010 1014 }
1011 1015
1012 1016 /**
1013 1017 * Format the page numbers.
1014 - * This method can be overriden for custom formats.
1015 - * @param $num (int) page number
1018 + * This method can be overridden for custom formats.
1019 + * @param int $num page number
1020 + * @return string
1016 1021 * @since 4.2.005 (2008-11-06)
1017 1022 * @public static
1018 1023 */
1019 1024 public static function formatPageNumber($num) {
@@ -1021,10 +1026,11 @@
1021 1026 }
1022 1027
1023 1028 /**
1024 1029 * Format the page numbers on the Table Of Content.
1025 - * This method can be overriden for custom formats.
1026 - * @param $num (int) page number
1030 + * This method can be overridden for custom formats.
1031 + * @param int $num page number
1032 + * @return string
1027 1033 * @since 4.5.001 (2009-01-04)
1028 1034 * @see addTOC(), addHTMLTOC()
1029 1035 * @public static
1030 1036 */
@@ -1033,10 +1039,10 @@
1033 1039 }
1034 1040
1035 1041 /**
1036 1042 * Extracts the CSS properties from a CSS string.
1037 - * @param $cssdata (string) string containing CSS definitions.
1038 - * @return An array where the keys are the CSS selectors and the values are the CSS properties.
1043 + * @param string $cssdata string containing CSS definitions.
1044 + * @return array An array where the keys are the CSS selectors and the values are the CSS properties.
1039 1045 * @author Nicola Asuni
1040 1046 * @since 5.1.000 (2010-05-25)
1041 1047 * @public static
1042 1048 */
@@ -1124,13 +1130,13 @@
1124 1130 }
1125 1131
1126 1132 /**
1127 1133 * Cleanup HTML code (requires HTML Tidy library).
1128 - * @param $html (string) htmlcode to fix
1129 - * @param $default_css (string) CSS commands to add
1130 - * @param $tagvs (array) parameters for setHtmlVSpace method
1131 - * @param $tidy_options (array) options for tidy_parse_string function
1132 - * @param $tagvspaces (array) Array of vertical spaces for tags.
1134 + * @param string $html htmlcode to fix
1135 + * @param string $default_css CSS commands to add
1136 + * @param array|null $tagvs parameters for setHtmlVSpace method
1137 + * @param array|null $tidy_options options for tidy_parse_string function
1138 + * @param array $tagvspaces Array of vertical spaces for tags.
1133 1139 * @return string XHTML code cleaned up
1134 1140 * @author Nicola Asuni
1135 1141 * @since 5.9.017 (2010-11-16)
1136 1142 * @see setHtmlVSpace()
@@ -1135,11 +1141,11 @@
1135 1141 * @since 5.9.017 (2010-11-16)
1136 1142 * @see setHtmlVSpace()
1137 1143 * @public static
1138 1144 */
1139 - public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces) {
1145 + public static function fixHTMLCode($html, $default_css, $tagvs, $tidy_options, &$tagvspaces) {
1140 1146 // configure parameters for HTML Tidy
1141 - if ($tidy_options === '') {
1147 + if (TCPDF_STATIC::empty_string($tidy_options)) {
1142 1148 $tidy_options = array (
1143 1149 'clean' => 1,
1144 1150 'drop-empty-paras' => 0,
1145 1151 'drop-proprietary-attributes' => 1,
@@ -1184,9 +1190,9 @@
1184 1190 $html = str_replace('<br>', '<br />', $html);
1185 1191 // remove some empty tag blocks
1186 1192 $html = preg_replace('/<div([^\>]*)><\/div>/', '', $html);
1187 1193 $html = preg_replace('/<p([^\>]*)><\/p>/', '', $html);
1188 - if ($tagvs !== '') {
1194 + if (!TCPDF_STATIC::empty_string($tagvs)) {
1189 1195 // set vertical space for some XHTML tags
1190 1196 $tagvspaces = $tagvs;
1191 1197 }
1192 1198 // return the cleaned XHTML code + CSS
@@ -1194,11 +1200,11 @@
1194 1200 }
1195 1201
1196 1202 /**
1197 1203 * Returns true if the CSS selector is valid for the selected HTML tag
1198 - * @param $dom (array) array of HTML tags and properties
1199 - * @param $key (int) key of the current HTML tag
1200 - * @param $selector (string) CSS selector string
1204 + * @param array $dom array of HTML tags and properties
1205 + * @param int $key key of the current HTML tag
1206 + * @param string $selector CSS selector string
1201 1207 * @return true if the selector is valid, false otherwise
1202 1208 * @since 5.1.000 (2010-05-25)
1203 1209 * @public static
1204 1210 */
@@ -1354,11 +1360,11 @@
1354 1360 }
1355 1361
1356 1362 /**
1357 1363 * Returns the styles array that apply for the selected HTML tag.
1358 - * @param $dom (array) array of HTML tags and properties
1359 - * @param $key (int) key of the current HTML tag
1360 - * @param $css (array) array of CSS properties
1364 + * @param array $dom array of HTML tags and properties
1365 + * @param int $key key of the current HTML tag
1366 + * @param array $css array of CSS properties
1361 1367 * @return array containing CSS properties
1362 1368 * @since 5.1.000 (2010-05-25)
1363 1369 * @public static
1364 1370 */
@@ -1401,9 +1407,9 @@
1401 1407 }
1402 1408
1403 1409 /**
1404 1410 * Compact CSS data array into single string.
1405 - * @param $css (array) array of CSS properties
1411 + * @param array $css array of CSS properties
1406 1412 * @return string containing merged CSS properties
1407 1413 * @since 5.9.070 (2011-04-19)
1408 1414 * @public static
1409 1415 */
@@ -1432,9 +1438,9 @@
1432 1438 }
1433 1439
1434 1440 /**
1435 1441 * Returns the Roman representation of an integer number
1436 - * @param $number (int) number to convert
1442 + * @param int $number number to convert
1437 1443 * @return string roman representation of the specified number
1438 1444 * @since 4.4.004 (2008-12-10)
1439 1445 * @public static
1440 1446 */
@@ -1439,8 +1445,12 @@
1439 1445 * @public static
1440 1446 */
1441 1447 public static function intToRoman($number) {
1442 1448 $roman = '';
1449 + if ($number >= 4000) {
1450 + // do not represent numbers above 4000 in Roman numerals
1451 + return strval($number);
1452 + }
1443 1453 while ($number >= 1000) {
1444 1454 $roman .= 'M';
1445 1455 $number -= 1000;
1446 1456 }
@@ -1496,12 +1506,12 @@
1496 1506 }
1497 1507
1498 1508 /**
1499 1509 * Find position of last occurrence of a substring in a string
1500 - * @param $haystack (string) The string to search in.
1501 - * @param $needle (string) substring to search.
1502 - * @param $offset (int) May be specified to begin searching an arbitrary number of characters into the string.
1503 - * @return Returns the position where the needle exists. Returns FALSE if the needle was not found.
1510 + * @param string $haystack The string to search in.
1511 + * @param string $needle substring to search.
1512 + * @param int $offset May be specified to begin searching an arbitrary number of characters into the string.
1513 + * @return int|false Returns the position where the needle exists. Returns FALSE if the needle was not found.
1504 1514 * @since 4.8.038 (2010-03-13)
1505 1515 * @public static
1506 1516 */
1507 1517 public static function revstrpos($haystack, $needle, $offset = 0) {
@@ -1512,9 +1522,9 @@
1512 1522 }
1513 1523
1514 1524 /**
1515 1525 * Returns an array of hyphenation patterns.
1516 - * @param $file (string) TEX file containing hypenation patterns. TEX pattrns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
1526 + * @param string $file TEX file containing hypenation patterns. TEX patterns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
1517 1527 * @return array of hyphenation patterns
1518 1528 * @author Nicola Asuni
1519 1529 * @since 4.9.012 (2010-04-12)
1520 1530 * @public static
@@ -1545,9 +1555,9 @@
1545 1555 }
1546 1556
1547 1557 /**
1548 1558 * Get the Path-Painting Operators.
1549 - * @param $style (string) Style of rendering. Possible values are:
1559 + * @param string $style Style of rendering. Possible values are:
1550 1560 * <ul>
1551 1561 * <li>S or D: Stroke the path.</li>
1552 1562 * <li>s or d: Close and stroke the path.</li>
1553 1563 * <li>f or F: Fill the path, using the nonzero winding number rule to determine the region to fill.</li>
@@ -1559,9 +1569,10 @@
1559 1569 * <li>CNZ: Clipping mode using the even-odd rule to determine which regions lie inside the clipping path.</li>
1560 1570 * <li>CEO: Clipping mode using the nonzero winding number rule to determine which regions lie inside the clipping path</li>
1561 1571 * <li>n: End the path object without filling or stroking it.</li>
1562 1572 * </ul>
1563 - * @param $default (string) default style
1573 + * @param string $default default style
1574 + * @return string
1564 1575 * @author Nicola Asuni
1565 1576 * @since 5.0.000 (2010-04-30)
1566 1577 * @public static
1567 1578 */
@@ -1636,11 +1647,11 @@
1636 1647 }
1637 1648
1638 1649 /**
1639 1650 * Get the product of two SVG tranformation matrices
1640 - * @param $ta (array) first SVG tranformation matrix
1641 - * @param $tb (array) second SVG tranformation matrix
1642 - * @return transformation array
1651 + * @param array $ta first SVG tranformation matrix
1652 + * @param array $tb second SVG tranformation matrix
1653 + * @return array transformation array
1643 1654 * @author Nicola Asuni
1644 1655 * @since 5.0.000 (2010-05-02)
1645 1656 * @public static
1646 1657 */
@@ -1656,9 +1667,9 @@
1656 1667 }
1657 1668
1658 1669 /**
1659 1670 * Get the tranformation matrix from SVG transform attribute
1660 - * @param $attribute (string) transformation
1671 + * @param string $attribute transformation
1661 1672 * @return array of transformations
1662 1673 * @author Nicola Asuni
1663 1674 * @since 5.0.000 (2010-05-02)
1664 1675 * @public static
@@ -1751,12 +1762,12 @@
1751 1762 }
1752 1763
1753 1764 /**
1754 1765 * Returns the angle in radiants between two vectors
1755 - * @param $x1 (int) X coordinate of first vector point
1756 - * @param $y1 (int) Y coordinate of first vector point
1757 - * @param $x2 (int) X coordinate of second vector point
1758 - * @param $y2 (int) Y coordinate of second vector point
1766 + * @param int $x1 X coordinate of first vector point
1767 + * @param int $y1 Y coordinate of first vector point
1768 + * @param int $x2 X coordinate of second vector point
1769 + * @param int $y2 Y coordinate of second vector point
1759 1770 * @author Nicola Asuni
1760 1771 * @since 5.0.000 (2010-05-04)
1761 1772 * @public static
1762 1773 */
@@ -1773,58 +1784,32 @@
1773 1784 }
1774 1785 return $angle;
1775 1786 }
1776 1787
1777 -
1778 -
1779 -
1780 -
1781 -
1782 -
1783 -
1784 -
1785 -
1786 -
1787 -
1788 -
1789 -
1790 -
1791 -
1792 -
1793 -// ====================================================================================================================
1794 -// REIMPLEMENTED
1795 -// ====================================================================================================================
1796 -
1797 -
1798 -
1799 -
1800 -
1801 -
1802 -
1803 -
1804 -
1805 -
1806 -
1807 -
1808 -
1809 -
1810 1788 /**
1811 1789 * Split string by a regular expression.
1812 1790 * This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850
1813 - * @param $pattern (string) The regular expression pattern to search for without the modifiers, as a string.
1814 - * @param $modifiers (string) The modifiers part of the pattern,
1815 - * @param $subject (string) The input string.
1816 - * @param $limit (int) If specified, then only substrings up to limit are returned with the rest of the string being placed in the last substring. A limit of -1, 0 or NULL means "no limit" and, as is standard across PHP, you can use NULL to skip to the flags parameter.
1817 - * @param $flags (int) The flags as specified on the preg_split PHP function.
1818 - * @return Returns an array containing substrings of subject split along boundaries matched by pattern.modifier
1791 + * @param string $pattern The regular expression pattern to search for without the modifiers, as a string.
1792 + * @param string $modifiers The modifiers part of the pattern,
1793 + * @param string $subject The input string.
1794 + * @param int $limit If specified, then only substrings up to limit are returned with the rest of the string being placed in the last substring. A limit of -1, 0 or NULL means "no limit" and, as is standard across PHP, you can use NULL to skip to the flags parameter.
1795 + * @param int $flags The flags as specified on the preg_split PHP function.
1796 + * @return array Returns an array containing substrings of subject split along boundaries matched by pattern.modifier
1819 1797 * @author Nicola Asuni
1820 1798 * @since 6.0.023
1821 1799 * @public static
1822 1800 */
1823 1801 public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) {
1802 + // PHP 8.1 deprecates nulls for $limit and $flags
1803 + $limit = $limit === null ? -1 : $limit;
1804 + $flags = $flags === null ? 0 : $flags;
1824 1805 // the bug only happens on PHP 5.2 when using the u modifier
1825 1806 if ((strpos($modifiers, 'u') === FALSE) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) {
1826 - return preg_split($pattern.$modifiers, $subject, $limit, $flags);
1807 + $ret = preg_split($pattern.$modifiers, $subject, $limit, $flags);
1808 + if ($ret === false) {
1809 + return array();
1810 + }
1811 + return is_array($ret) ? $ret : array();
1827 1812 }
1828 1813 // preg_split is bugged - try alternative solution
1829 1814 $ret = array();
1830 1815 while (($nl = strpos($subject, "\n")) !== FALSE) {
@@ -1839,11 +1824,11 @@
1839 1824 }
1840 1825
1841 1826 /**
1842 1827 * Wrapper to use fopen only with local files
1843 - * @param filename (string) Name of the file to open
1844 - * @param $mode (string)
1845 - * @return Returns a file pointer resource on success, or FALSE on error.
1828 + * @param string $filename Name of the file to open
1829 + * @param string $mode
1830 + * @return resource|false Returns a file pointer resource on success, or FALSE on error.
1846 1831 * @public static
1847 1832 */
1848 1833 public static function fopenLocal($filename, $mode) {
1849 1834 if (strpos($filename, '://') === false) {
@@ -1854,12 +1839,81 @@
1854 1839 return fopen($filename, $mode);
1855 1840 }
1856 1841
1857 1842 /**
1843 + * Check if the URL exist.
1844 + * @param string $url URL to check.
1845 + * @return bool Returns TRUE if the URL exists; FALSE otherwise.
1846 + * @public static
1847 + * @since 6.2.25
1848 + */
1849 + public static function url_exists($url) {
1850 + $crs = curl_init();
1851 + $curlopts = [];
1852 + if (
1853 + (ini_get('open_basedir') == '')
1854 + && (ini_get('safe_mode') === ''
1855 + || ini_get('safe_mode') === false)
1856 + ) {
1857 + $curlopts[CURLOPT_FOLLOWLOCATION] = true;
1858 + }
1859 + $curlopts = array_replace($curlopts, self::CURLOPT_DEFAULT);
1860 + $curlopts = array_replace($curlopts, K_CURLOPTS);
1861 + $curlopts = array_replace($curlopts, self::CURLOPT_FIXED);
1862 + $curlopts[CURLOPT_URL] = $url;
1863 + curl_setopt_array($crs, $curlopts);
1864 + curl_exec($crs);
1865 + $code = curl_getinfo($crs, CURLINFO_HTTP_CODE);
1866 + if (PHP_VERSION_ID < 80000) {
1867 + curl_close($crs);
1868 + }
1869 + return ($code == 200);
1870 + }
1871 +
1872 + /**
1873 + * Encode query params in URL
1874 + *
1875 + * @param string $url
1876 + * @return string
1877 + * @since 6.3.3 (2019-11-01)
1878 + * @public static
1879 + */
1880 + public static function encodeUrlQuery($url) {
1881 + $urlData = parse_url($url);
1882 + if (isset($urlData['query']) && $urlData['query']) {
1883 + $urlQueryData = array();
1884 + parse_str(urldecode($urlData['query']), $urlQueryData);
1885 + $port = isset($urlData['port']) ? ':'.$urlData['port'] : '';
1886 + $updatedUrl = $urlData['scheme'].'://'.$urlData['host'].$port.$urlData['path'].'?'.http_build_query($urlQueryData);
1887 + } else {
1888 + $updatedUrl = $url;
1889 + }
1890 + return $updatedUrl;
1891 + }
1892 +
1893 + /**
1894 + * Wrapper for file_exists.
1895 + * Checks whether a file or directory exists.
1896 + * Only allows some protocols and local files.
1897 + * @param string $filename Path to the file or directory.
1898 + * @return bool Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.
1899 + * @public static
1900 + */
1901 + public static function file_exists($filename) {
1902 + if (preg_match('|^https?://|', $filename) == 1) {
1903 + return self::url_exists($filename);
1904 + }
1905 + if (strpos($filename, '://')) {
1906 + return false; // only support http and https wrappers for security reasons
1907 + }
1908 + return @file_exists($filename);
1909 + }
1910 +
1911 + /**
1858 1912 * Reads entire file into a string.
1859 1913 * The file can be also an URL.
1860 - * @param $file (string) Name of the file or URL to read.
1861 - * @return The function returns the read data or FALSE on failure.
1914 + * @param string $file Name of the file or URL to read.
1915 + * @return string|false The function returns the read data or FALSE on failure.
1862 1916 * @author Nicola Asuni
1863 1917 * @since 6.0.025
1864 1918 * @public static
1865 1919 */
@@ -1913,12 +1967,14 @@
1913 1967 $alt[] = $urldata['scheme'].'://'.$urldata['host'].(($file[0] == '/') ? '' : '/').$file;
1914 1968 }
1915 1969 //
1916 1970 $alt = array_unique($alt);
1917 - //var_dump($alt);exit;//DEBUG
1918 1971 foreach ($alt as $path) {
1972 + if (!self::file_exists($path)) {
1973 + continue;
1974 + }
1919 1975 $ret = @file_get_contents($path);
1920 - if ($ret !== false) {
1976 + if ( $ret != false ) {
1921 1977 return $ret;
1922 1978 }
1923 1979 // try to use CURL for URLs
1924 1980 if (!ini_get('allow_url_fopen')
@@ -1926,22 +1982,25 @@
1926 1982 && preg_match('%^(https?|ftp)://%', $path)
1927 1983 ) {
1928 1984 // try to get remote file data using cURL
1929 1985 $crs = curl_init();
1930 - curl_setopt($crs, CURLOPT_URL, $path);
1931 - curl_setopt($crs, CURLOPT_BINARYTRANSFER, true);
1932 - curl_setopt($crs, CURLOPT_FAILONERROR, true);
1933 - curl_setopt($crs, CURLOPT_RETURNTRANSFER, true);
1934 - if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
1935 - curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
1986 + $curlopts = [];
1987 + if (
1988 + (ini_get('open_basedir') == '')
1989 + && (ini_get('safe_mode') === ''
1990 + || ini_get('safe_mode') === false)
1991 + ) {
1992 + $curlopts[CURLOPT_FOLLOWLOCATION] = true;
1936 1993 }
1937 - curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
1938 - curl_setopt($crs, CURLOPT_TIMEOUT, 30);
1939 - curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
1940 - curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
1941 - curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
1994 + $curlopts = array_replace($curlopts, self::CURLOPT_DEFAULT);
1995 + $curlopts = array_replace($curlopts, K_CURLOPTS);
1996 + $curlopts = array_replace($curlopts, self::CURLOPT_FIXED);
1997 + $curlopts[CURLOPT_URL] = $url;
1998 + curl_setopt_array($crs, $curlopts);
1942 1999 $ret = curl_exec($crs);
1943 - curl_close($crs);
2000 + if (PHP_VERSION_ID < 80000) {
2001 + curl_close($crs);
2002 + }
1944 2003 if ($ret !== false) {
1945 2004 return $ret;
1946 2005 }
1947 2006 }
@@ -1948,14 +2007,12 @@
1948 2007 }
1949 2008 return false;
1950 2009 }
1951 2010
1952 -
1953 -
1954 2011 /**
1955 2012 * Get ULONG from string (Big Endian 32-bit unsigned integer).
1956 - * @param $str (string) string from where to extract value
1957 - * @param $offset (int) point from where to read the data
2013 + * @param string $str string from where to extract value
2014 + * @param int $offset point from where to read the data
1958 2015 * @return int 32 bit value
1959 2016 * @author Nicola Asuni
1960 2017 * @since 5.2.000 (2010-06-02)
1961 2018 * @public static
@@ -1966,10 +2023,10 @@
1966 2023 }
1967 2024
1968 2025 /**
1969 2026 * Get USHORT from string (Big Endian 16-bit unsigned integer).
1970 - * @param $str (string) string from where to extract value
1971 - * @param $offset (int) point from where to read the data
2027 + * @param string $str string from where to extract value
2028 + * @param int $offset point from where to read the data
1972 2029 * @return int 16 bit value
1973 2030 * @author Nicola Asuni
1974 2031 * @since 5.2.000 (2010-06-02)
1975 2032 * @public static
@@ -1980,10 +2037,10 @@
1980 2037 }
1981 2038
1982 2039 /**
1983 2040 * Get SHORT from string (Big Endian 16-bit signed integer).
1984 - * @param $str (string) String from where to extract value.
1985 - * @param $offset (int) Point from where to read the data.
2041 + * @param string $str String from where to extract value.
2042 + * @param int $offset Point from where to read the data.
1986 2043 * @return int 16 bit value
1987 2044 * @author Nicola Asuni
1988 2045 * @since 5.2.000 (2010-06-02)
1989 2046 * @public static
@@ -1994,10 +2051,10 @@
1994 2051 }
1995 2052
1996 2053 /**
1997 2054 * Get FWORD from string (Big Endian 16-bit signed integer).
1998 - * @param $str (string) String from where to extract value.
1999 - * @param $offset (int) Point from where to read the data.
2055 + * @param string $str String from where to extract value.
2056 + * @param int $offset Point from where to read the data.
2000 2057 * @return int 16 bit value
2001 2058 * @author Nicola Asuni
2002 2059 * @since 5.9.123 (2011-09-30)
2003 2060 * @public static
@@ -2011,10 +2068,10 @@
2011 2068 }
2012 2069
2013 2070 /**
2014 2071 * Get UFWORD from string (Big Endian 16-bit unsigned integer).
2015 - * @param $str (string) string from where to extract value
2016 - * @param $offset (int) point from where to read the data
2072 + * @param string $str string from where to extract value
2073 + * @param int $offset point from where to read the data
2017 2074 * @return int 16 bit value
2018 2075 * @author Nicola Asuni
2019 2076 * @since 5.9.123 (2011-09-30)
2020 2077 * @public static
@@ -2025,10 +2082,10 @@
2025 2082 }
2026 2083
2027 2084 /**
2028 2085 * Get FIXED from string (32-bit signed fixed-point number (16.16).
2029 - * @param $str (string) string from where to extract value
2030 - * @param $offset (int) point from where to read the data
2086 + * @param string $str string from where to extract value
2087 + * @param int $offset point from where to read the data
2031 2088 * @return int 16 bit value
2032 2089 * @author Nicola Asuni
2033 2090 * @since 5.9.123 (2011-09-30)
2034 2091 * @public static
@@ -2043,10 +2100,10 @@
2043 2100 }
2044 2101
2045 2102 /**
2046 2103 * Get BYTE from string (8-bit unsigned integer).
2047 - * @param $str (string) String from where to extract value.
2048 - * @param $offset (int) Point from where to read the data.
2104 + * @param string $str String from where to extract value.
2105 + * @param int $offset Point from where to read the data.
2049 2106 * @return int 8 bit value
2050 2107 * @author Nicola Asuni
2051 2108 * @since 5.2.000 (2010-06-02)
2052 2109 * @public static
@@ -2057,11 +2114,11 @@
2057 2114 }
2058 2115 /**
2059 2116 * Binary-safe and URL-safe file read.
2060 2117 * Reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met: length bytes have been read; EOF (end of file) is reached.
2061 - * @param $handle (resource)
2062 - * @param $length (int)
2063 - * @return Returns the read string or FALSE in case of error.
2118 + * @param resource $handle
2119 + * @param int $length
2120 + * @return string|false Returns the read string or FALSE in case of error.
2064 2121 * @author Nicola Asuni
2065 2122 * @since 4.5.027 (2009-03-16)
2066 2123 * @public static
2067 2124 */
@@ -2078,10 +2135,10 @@
2078 2135 }
2079 2136
2080 2137 /**
2081 2138 * Read a 4-byte (32 bit) integer from file.
2082 - * @param $f (string) file name.
2083 - * @return 4-byte integer
2139 + * @param resource $f file resource.
2140 + * @return int 4-byte integer
2084 2141 * @public static
2085 2142 */
2086 2143 public static function _freadint($f) {
2087 2144 $a = unpack('Ni', fread($f, 4));
@@ -2087,13 +2144,14 @@
2087 2144 $a = unpack('Ni', fread($f, 4));
2088 2145 return $a['i'];
2089 2146 }
2090 2147
2091 -
2092 2148 /**
2093 2149 * Array of page formats
2094 2150 * measures are calculated in this way: (inches * 72) or (millimeters * 72 / 25.4)
2095 2151 * @public static
2152 + *
2153 + * @var array<string,float[]>
2096 2154 */
2097 2155 public static $page_formats = array(
2098 2156 // ISO 216 A Series + 2 SIS 014711 extensions
2099 2157 'A0' => array( 2383.937, 3370.394), // = ( 841 x 1189 ) mm = ( 33.11 x 46.81 ) in
@@ -2447,9 +2505,9 @@
2447 2505
2448 2506
2449 2507 /**
2450 2508 * Get page dimensions from format name.
2451 - * @param $format (mixed) The format name @see self::$page_format<ul>
2509 + * @param mixed $format The format name @see self::$page_format<ul>
2452 2510 * @return array containing page width and height in points
2453 2511 * @since 5.0.010 (2010-05-17)
2454 2512 * @public static
2455 2513 */
@@ -2461,22 +2519,22 @@
2461 2519 }
2462 2520
2463 2521 /**
2464 2522 * Set page boundaries.
2465 - * @param $page (int) page number
2466 - * @param $type (string) valid values are: <ul><li>'MediaBox' : the boundaries of the physical medium on which the page shall be displayed or printed;</li><li>'CropBox' : the visible region of default user space;</li><li>'BleedBox' : the region to which the contents of the page shall be clipped when output in a production environment;</li><li>'TrimBox' : the intended dimensions of the finished page after trimming;</li><li>'ArtBox' : the page's meaningful content (including potential white space).</li></ul>
2467 - * @param $llx (float) lower-left x coordinate in user units.
2468 - * @param $lly (float) lower-left y coordinate in user units.
2469 - * @param $urx (float) upper-right x coordinate in user units.
2470 - * @param $ury (float) upper-right y coordinate in user units.
2471 - * @param $points (boolean) If true uses user units as unit of measure, otherwise uses PDF points.
2472 - * @param $k (float) Scale factor (number of points in user unit).
2473 - * @param $pagedim (array) Array of page dimensions.
2474 - * @return pagedim array of page dimensions.
2523 + * @param int $page page number
2524 + * @param string $type valid values are: <ul><li>'MediaBox' : the boundaries of the physical medium on which the page shall be displayed or printed;</li><li>'CropBox' : the visible region of default user space;</li><li>'BleedBox' : the region to which the contents of the page shall be clipped when output in a production environment;</li><li>'TrimBox' : the intended dimensions of the finished page after trimming;</li><li>'ArtBox' : the page's meaningful content (including potential white space).</li></ul>
2525 + * @param float $llx lower-left x coordinate in user units.
2526 + * @param float $lly lower-left y coordinate in user units.
2527 + * @param float $urx upper-right x coordinate in user units.
2528 + * @param float $ury upper-right y coordinate in user units.
2529 + * @param boolean $points If true uses user units as unit of measure, otherwise uses PDF points.
2530 + * @param float $k Scale factor (number of points in user unit).
2531 + * @param array $pagedim Array of page dimensions.
2532 + * @return array pagedim array of page dimensions.
2475 2533 * @since 5.0.010 (2010-05-17)
2476 2534 * @public static
2477 2535 */
2478 - public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array()) {
2536 + public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points, $k, $pagedim=array()) {
2479 2537 if (!isset($pagedim[$page])) {
2480 2538 // initialize array
2481 2539 $pagedim[$page] = array();
2482 2540 }
@@ -2494,11 +2552,11 @@
2494 2552 }
2495 2553
2496 2554 /**
2497 2555 * Swap X and Y coordinates of page boxes (change page boxes orientation).
2498 - * @param $page (int) page number
2499 - * @param $pagedim (array) Array of page dimensions.
2500 - * @return pagedim array of page dimensions.
2556 + * @param int $page page number
2557 + * @param array $pagedim Array of page dimensions.
2558 + * @return array pagedim array of page dimensions.
2501 2559 * @since 5.0.010 (2010-05-17)
2502 2560 * @public static
2503 2561 */
2504 2562 public static function swapPageBoxCoordinates($page, $pagedim) {
@@ -2517,10 +2575,10 @@
2517 2575 }
2518 2576
2519 2577 /**
2520 2578 * Get the canonical page layout mode.
2521 - * @param $layout (string) The page layout. Possible values are:<ul><li>SinglePage Display one page at a time</li><li>OneColumn Display the pages in one column</li><li>TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left</li><li>TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right</li><li>TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left</li><li>TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right</li></ul>
2522 - * @return (string) Canonical page layout name.
2579 + * @param string $layout The page layout. Possible values are:<ul><li>SinglePage Display one page at a time</li><li>OneColumn Display the pages in one column</li><li>TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left</li><li>TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right</li><li>TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left</li><li>TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right</li></ul>
2580 + * @return string Canonical page layout name.
2523 2581 * @public static
2524 2582 */
2525 2583 public static function getPageLayoutMode($layout='SinglePage') {
2526 2584 switch ($layout) {
@@ -2560,10 +2618,10 @@
2560 2618 }
2561 2619
2562 2620 /**
2563 2621 * Get the canonical page layout mode.
2564 - * @param $mode (string) A name object specifying how the document should be displayed when opened:<ul><li>UseNone Neither document outline nor thumbnail images visible</li><li>UseOutlines Document outline visible</li><li>UseThumbs Thumbnail images visible</li><li>FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible</li><li>UseOC (PDF 1.5) Optional content group panel visible</li><li>UseAttachments (PDF 1.6) Attachments panel visible</li></ul>
2565 - * @return (string) Canonical page mode name.
2622 + * @param string $mode A name object specifying how the document should be displayed when opened:<ul><li>UseNone Neither document outline nor thumbnail images visible</li><li>UseOutlines Document outline visible</li><li>UseThumbs Thumbnail images visible</li><li>FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible</li><li>UseOC (PDF 1.5) Optional content group panel visible</li><li>UseAttachments (PDF 1.6) Attachments panel visible</li></ul>
2623 + * @return string Canonical page mode name.
2566 2624 * @public static
2567 2625 */
2568 2626 public static function getPageMode($mode='UseNone') {
2569 2627 switch ($mode) {
@@ -2596,9 +2654,8 @@
2596 2654 }
2597 2655 }
2598 2656 return $page_mode;
2599 2657 }
2600 -
2601 2658
2602 2659 } // END OF TCPDF_STATIC CLASS
2603 2660
2604 2661 //============================================================+