Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
2
//============================================================+
2
//============================================================+
3
// File name   : tcpdf_static.php
3
// File name   : tcpdf_static.php
4
// Version     : 1.1.4
4
// Version     : 1.1.5
5
// Begin       : 2002-08-03
5
// Begin       : 2002-08-03
6
// Last Update : 2023-09-06
6
// Last Update : 2024-12-23
7
// Author      : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
7
// Author      : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
8
// License     : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
8
// License     : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
9
// -------------------------------------------------------------------
9
// -------------------------------------------------------------------
10
// Copyright (C) 2002-2023 Nicola Asuni - Tecnick.com LTD
10
// Copyright (C) 2002-2025 Nicola Asuni - Tecnick.com LTD
11
//
11
//
12
// This file is part of TCPDF software library.
12
// This file is part of TCPDF software library.
13
//
13
//
14
// TCPDF is free software: you can redistribute it and/or modify it
14
// TCPDF is free software: you can redistribute it and/or modify it
15
// under the terms of the GNU Lesser General Public License as
15
// under the terms of the GNU Lesser General Public License as
Línea 36... Línea 36...
36
/**
36
/**
37
 * @file
37
 * @file
38
 * This is a PHP class that contains static methods for the TCPDF class.<br>
38
 * This is a PHP class that contains static methods for the TCPDF class.<br>
39
 * @package com.tecnick.tcpdf
39
 * @package com.tecnick.tcpdf
40
 * @author Nicola Asuni
40
 * @author Nicola Asuni
41
 * @version 1.1.2
41
 * @version 1.1.5
42
 */
42
 */
Línea 43... Línea 43...
43
 
43
 
44
/**
44
/**
45
 * @class TCPDF_STATIC
45
 * @class TCPDF_STATIC
46
 * Static methods used by the TCPDF class.
46
 * Static methods used by the TCPDF class.
47
 * @package com.tecnick.tcpdf
47
 * @package com.tecnick.tcpdf
48
 * @brief PHP class for generating PDF documents without requiring external extensions.
48
 * @brief PHP class for generating PDF documents without requiring external extensions.
49
 * @version 1.1.1
49
 * @version 1.1.5
50
 * @author Nicola Asuni - info@tecnick.com
50
 * @author Nicola Asuni - info@tecnick.com
51
 */
51
 */
Línea 52... Línea 52...
52
class TCPDF_STATIC {
52
class TCPDF_STATIC {
53
 
53
 
54
	/**
54
	/**
55
	 * Current TCPDF version.
55
	 * Current TCPDF version.
56
	 * @private static
56
	 * @private static
Línea 57... Línea 57...
57
	 */
57
	 */
58
	private static $tcpdf_version = '6.6.5';
58
	private static $tcpdf_version = '6.8.2';
59
 
59
 
60
	/**
60
	/**
Línea 104... Línea 104...
104
	 * Array page boxes names
104
	 * Array page boxes names
105
	 * @public static
105
	 * @public static
106
	 */
106
	 */
107
	public static $pageboxes = array('MediaBox', 'CropBox', 'BleedBox', 'TrimBox', 'ArtBox');
107
	public static $pageboxes = array('MediaBox', 'CropBox', 'BleedBox', 'TrimBox', 'ArtBox');
Línea -... Línea 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
    ];
108
 
133
 
Línea 109... Línea 134...
109
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
134
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
110
 
135
 
111
	/**
136
	/**
Línea 377... Línea 402...
377
	public static function getRandomSeed($seed='') {
402
	public static function getRandomSeed($seed='') {
378
		$rnd = uniqid(rand().microtime(true), true);
403
		$rnd = uniqid(rand().microtime(true), true);
379
		if (function_exists('posix_getpid')) {
404
		if (function_exists('posix_getpid')) {
380
			$rnd .= posix_getpid();
405
			$rnd .= posix_getpid();
381
		}
406
		}
-
 
407
 
-
 
408
		if (function_exists('random_bytes')) {
-
 
409
			$rnd .= random_bytes(512);
382
		if (function_exists('openssl_random_pseudo_bytes') AND (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) {
410
		} elseif (function_exists('openssl_random_pseudo_bytes') AND (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) {
383
			// this is not used on windows systems because it is very slow for a know bug
411
			// this is not used on windows systems because it is very slow for a know bug
384
			$rnd .= openssl_random_pseudo_bytes(512);
412
			$rnd .= openssl_random_pseudo_bytes(512);
385
		} else {
413
		} else {
386
			for ($i = 0; $i < 23; ++$i) {
414
			for ($i = 0; $i < 23; ++$i) {
387
				$rnd .= uniqid('', true);
415
				$rnd .= uniqid('', true);
388
			}
416
			}
389
		}
417
		}
390
		return $rnd.$seed.__FILE__.serialize($_SERVER).microtime(true);
418
		return $rnd.$seed.__FILE__.microtime(true);
391
	}
419
	}
Línea 392... Línea 420...
392
 
420
 
393
	/**
421
	/**
394
	 * Encrypts a string using MD5 and returns it's value as a binary string.
422
	 * Encrypts a string using MD5 and returns it's value as a binary string.
Línea 1818... Línea 1846...
1818
	 * @public static
1846
	 * @public static
1819
	 * @since 6.2.25
1847
	 * @since 6.2.25
1820
	 */
1848
	 */
1821
	public static function url_exists($url) {
1849
	public static function url_exists($url) {
1822
		$crs = curl_init();
1850
		$crs = curl_init();
1823
		// encode query params in URL to get right response form the server
-
 
1824
		$url = self::encodeUrlQuery($url);
1851
        $curlopts = [];
1825
		curl_setopt($crs, CURLOPT_URL, $url);
1852
        if (
1826
		curl_setopt($crs, CURLOPT_NOBODY, true);
1853
            (ini_get('open_basedir') == '')
1827
		curl_setopt($crs, CURLOPT_FAILONERROR, true);
1854
            && (ini_get('safe_mode') === ''
1828
		if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
1855
            || ini_get('safe_mode') === false)
-
 
1856
        ) {
1829
			curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
1857
            $curlopts[CURLOPT_FOLLOWLOCATION] = true;
1830
		}
1858
        }
1831
		curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
-
 
1832
		curl_setopt($crs, CURLOPT_TIMEOUT, 30);
1859
        $curlopts = array_replace($curlopts, self::CURLOPT_DEFAULT);
1833
		curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
1860
        $curlopts = array_replace($curlopts, K_CURLOPTS);
1834
		curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
1861
        $curlopts = array_replace($curlopts, self::CURLOPT_FIXED);
1835
		curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
1862
        $curlopts[CURLOPT_URL] = $url;
1836
		curl_setopt($crs, CURLOPT_MAXREDIRS, 5);
1863
        curl_setopt_array($crs, $curlopts);
1837
		if (defined('CURLOPT_PROTOCOLS')) {
-
 
1838
		    curl_setopt($crs, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP |  CURLPROTO_FTP | CURLPROTO_FTPS);
-
 
1839
		}
-
 
1840
		curl_exec($crs);
1864
		curl_exec($crs);
1841
		$code = curl_getinfo($crs, CURLINFO_HTTP_CODE);
1865
		$code = curl_getinfo($crs, CURLINFO_HTTP_CODE);
1842
		curl_close($crs);
1866
		curl_close($crs);
1843
		return ($code == 200);
1867
		return ($code == 200);
1844
	}
1868
	}
Línea 1955... Línea 1979...
1955
				&& function_exists('curl_init')
1979
				&& function_exists('curl_init')
1956
				&& preg_match('%^(https?|ftp)://%', $path)
1980
				&& preg_match('%^(https?|ftp)://%', $path)
1957
			) {
1981
			) {
1958
				// try to get remote file data using cURL
1982
				// try to get remote file data using cURL
1959
				$crs = curl_init();
1983
				$crs = curl_init();
1960
				curl_setopt($crs, CURLOPT_URL, $path);
1984
				$curlopts = [];
1961
				curl_setopt($crs, CURLOPT_BINARYTRANSFER, true);
1985
				if (
1962
				curl_setopt($crs, CURLOPT_FAILONERROR, true);
1986
					(ini_get('open_basedir') == '')
1963
				curl_setopt($crs, CURLOPT_RETURNTRANSFER, true);
1987
					&& (ini_get('safe_mode') === ''
1964
				if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
1988
					|| ini_get('safe_mode') === false)
-
 
1989
				) {
1965
				    curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
1990
					$curlopts[CURLOPT_FOLLOWLOCATION] = true;
1966
				}
1991
				}
1967
				curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
-
 
1968
				curl_setopt($crs, CURLOPT_TIMEOUT, 30);
1992
				$curlopts = array_replace($curlopts, self::CURLOPT_DEFAULT);
1969
				curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
1993
				$curlopts = array_replace($curlopts, K_CURLOPTS);
1970
				curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
1994
				$curlopts = array_replace($curlopts, self::CURLOPT_FIXED);
1971
				curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
1995
				$curlopts[CURLOPT_URL] = $url;
1972
				curl_setopt($crs, CURLOPT_MAXREDIRS, 5);
1996
				curl_setopt_array($crs, $curlopts);
1973
				if (defined('CURLOPT_PROTOCOLS')) {
-
 
1974
				    curl_setopt($crs, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP |  CURLPROTO_FTP | CURLPROTO_FTPS);
-
 
1975
				}
-
 
1976
				$ret = curl_exec($crs);
1997
				$ret = curl_exec($crs);
1977
				curl_close($crs);
1998
				curl_close($crs);
1978
				if ($ret !== false) {
1999
				if ($ret !== false) {
1979
					return $ret;
2000
					return $ret;
1980
				}
2001
				}