diff --git a/Core/Business/Email/Core_Business_Email_EmailLister.php b/Core/Business/Email/Core_Business_Email_EmailLister.php index 1fc64a0874..4301af576d 100644 --- a/Core/Business/Email/Core_Business_Email_EmailLister.php +++ b/Core/Business/Email/Core_Business_Email_EmailLister.php @@ -51,7 +51,7 @@ public function getAvailableMails($dir) // Remove unwanted .html / .txt / .tpl / .php / . / .. foreach ($mail_directory as $mail) { - if (strpos($mail->getFilename(), '.') !== false) { + if (str_contains($mail->getFilename(), '.')) { $tmp = explode('.', $mail->getFilename()); // Check for filename existence (left part) and if extension is html (right part) @@ -76,7 +76,7 @@ public function getAvailableMails($dir) */ public function getCleanedMailName($mail_name) { - if (strpos($mail_name, '.') !== false) { + if (str_contains($mail_name, '.')) { $tmp = explode('.', $mail_name); if ($tmp === false || !isset($tmp[0])) { diff --git a/Core/Foundation/Database/Core_Foundation_Database_EntityRepository.php b/Core/Foundation/Database/Core_Foundation_Database_EntityRepository.php index 319e8aa278..0f104b2c88 100644 --- a/Core/Foundation/Database/Core_Foundation_Database_EntityRepository.php +++ b/Core/Foundation/Database/Core_Foundation_Database_EntityRepository.php @@ -46,10 +46,10 @@ public function __construct( public function __call($method, $arguments) { - if (0 === strpos($method, 'findOneBy')) { + if (str_starts_with($method, 'findOneBy')) { $one = true; $by = substr($method, 9); - } elseif (0 === strpos($method, 'findBy')) { + } elseif (str_starts_with($method, 'findBy')) { $one = false; $by = substr($method, 6); } else { diff --git a/Core/Foundation/IoC/Core_Foundation_IoC_Container.php b/Core/Foundation/IoC/Core_Foundation_IoC_Container.php index 6cc2faf662..0ce9c30828 100644 --- a/Core/Foundation/IoC/Core_Foundation_IoC_Container.php +++ b/Core/Foundation/IoC/Core_Foundation_IoC_Container.php @@ -91,7 +91,7 @@ private function makeInstanceFromClassName($className, array $alreadySeen) try { $refl = new ReflectionClass($className); - } catch (ReflectionException $re) { + } catch (ReflectionException) { throw new Core_Foundation_IoC_Exception(sprintf('This doesn\'t seem to be a class name: `%s`.', $className)); } diff --git a/admin/backup.php b/admin/backup.php index 007e761d6c..0546a69dfd 100644 --- a/admin/backup.php +++ b/admin/backup.php @@ -57,9 +57,9 @@ die(Tools::dieOrLog('The backup file does not exist.')); } -if (substr($backupfile, -4) == '.bz2') { +if (str_ends_with($backupfile, '.bz2')) { $contentType = 'application/x-bzip2'; -} elseif (substr($backupfile, -3) == '.gz') { +} elseif (str_ends_with($backupfile, '.gz')) { $contentType = 'application/x-gzip'; } else { $contentType = 'text/x-sql'; diff --git a/admin/filemanager/ajax_calls.php b/admin/filemanager/ajax_calls.php index c7e007f3c8..e7e8df0599 100644 --- a/admin/filemanager/ajax_calls.php +++ b/admin/filemanager/ajax_calls.php @@ -34,7 +34,7 @@ if (preg_match('/\.{1,2}[\/|\\\]/', $path_pos) !== 0 || $filename !== fix_filename($filename, $transliteration) || !in_array(strtolower($info['extension']), array('jpg', 'jpeg', 'png')) - || strpos($_POST['url'], 'http://featherfiles.aviary.com/') !== 0 + || !str_starts_with($_POST['url'], 'http://featherfiles.aviary.com/') || !isset($info['extension']) ) { @@ -78,7 +78,7 @@ }*/ break; case 'extract': - if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0) { + if (str_starts_with($_POST['path'], '/') || str_contains($_POST['path'], '../') || str_starts_with($_POST['path'], './')) { die('wrong path'); } $path = $current_path.$_POST['path']; diff --git a/admin/filemanager/dialog.php b/admin/filemanager/dialog.php index 48f4945d2e..b11da7b5be 100644 --- a/admin/filemanager/dialog.php +++ b/admin/filemanager/dialog.php @@ -20,11 +20,11 @@ } //remember last position - setcookie('last_position', $subdir, time() + (86400 * 7)); + setcookie('last_position', $subdir, ['expires' => time() + (86400 * 7)]); if ($subdir == '') { if (!empty($_COOKIE['last_position']) - && strpos($_COOKIE['last_position'], '.') === false + && !str_contains($_COOKIE['last_position'], '.') ) { $subdir = trim($_COOKIE['last_position']); } @@ -42,9 +42,9 @@ $_SESSION['subfolder'] = ''; } $subfolder = ''; - if (!empty($_SESSION['subfolder']) && strpos($_SESSION['subfolder'], '../') === false - && strpos($_SESSION['subfolder'], './') === false && strpos($_SESSION['subfolder'], '/') !== 0 - && strpos($_SESSION['subfolder'], '.') === false + if (!empty($_SESSION['subfolder']) && !str_contains($_SESSION['subfolder'], '../') + && !str_contains($_SESSION['subfolder'], './') && !str_starts_with($_SESSION['subfolder'], '/') + && !str_contains($_SESSION['subfolder'], '.') ) { $subfolder = $_SESSION['subfolder']; } @@ -794,7 +794,7 @@ function extensionSort($x, $y) ); foreach ($files as $file_array) { $file = $file_array['file']; - if ($file == '.' || (isset($file_array['extension']) && $file_array['extension'] != lang_Type_dir) || ($file == '..' && $subdir == '') || in_array($file, $hidden_folders) || ($filter != '' && $file != ".." && strpos($file, $filter) === false)) { + if ($file == '.' || (isset($file_array['extension']) && $file_array['extension'] != lang_Type_dir) || ($file == '..' && $subdir == '') || in_array($file, $hidden_folders) || ($filter != '' && $file != ".." && !str_contains($file, $filter))) { continue; } $new_name = fix_filename($file, $transliteration); @@ -925,7 +925,7 @@ function extensionSort($x, $y) foreach ($files as $nu => $file_array) { $file = $file_array['file']; - if ($file == '.' || $file == '..' || is_dir($current_path.$subfolder.$subdir.$file) || in_array($file, $hidden_files) || !in_array(fix_strtolower($file_array['extension']), $ext) || ($filter != '' && strpos($file, $filter) === false)) { + if ($file == '.' || $file == '..' || is_dir($current_path.$subfolder.$subdir.$file) || in_array($file, $hidden_files) || !in_array(fix_strtolower($file_array['extension']), $ext) || ($filter != '' && !str_contains($file, $filter))) { continue; } @@ -971,7 +971,7 @@ function extensionSort($x, $y) try { create_img_gd($file_path, $src_thumb, 122, 91); new_thumbnails_creation($current_path.$subfolder.$subdir, $file_path, $file, $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height); - } catch (Exception $e) { + } catch (Exception) { $src_thumb = $mini_src = ""; } } diff --git a/admin/filemanager/execute.php b/admin/filemanager/execute.php index e823838743..44124acfa8 100644 --- a/admin/filemanager/execute.php +++ b/admin/filemanager/execute.php @@ -15,8 +15,8 @@ if (preg_match('/\.{1,2}[\/|\\\]/', $_POST['path_thumb']) !== 0 || preg_match('/\.{1,2}[\/|\\\]/', $_POST['path']) !== 0 - || ($realPath && strpos($realPath, realpath($current_path)) !== 0) - || ($realPathThumb && strpos($realPathThumb, realpath($thumbs_base_path)) !== 0) + || ($realPath && !str_starts_with($realPath, realpath($current_path))) + || ($realPathThumb && !str_starts_with($realPathThumb, realpath($thumbs_base_path))) ) { die('wrong path'); } diff --git a/admin/filemanager/force_download.php b/admin/filemanager/force_download.php index fe51c869eb..275ea7db08 100644 --- a/admin/filemanager/force_download.php +++ b/admin/filemanager/force_download.php @@ -9,7 +9,7 @@ die('wrong path'); } -if (strpos($_POST['name'], '/') !== false || strpos($_POST['name'], '\\') !== false) { +if (str_contains($_POST['name'], '/') || str_contains($_POST['name'], '\\')) { die('wrong path'); } diff --git a/admin/filemanager/include/php_image_magician.php b/admin/filemanager/include/php_image_magician.php index 0922a72364..9afd1c43dd 100644 --- a/admin/filemanager/include/php_image_magician.php +++ b/admin/filemanager/include/php_image_magician.php @@ -257,8 +257,8 @@ function __construct($fileName) private function initialise() { - $this->psdReaderPath = dirname(__FILE__) . '/classPhpPsdReader.php'; - $this->filterOverlayPath = dirname(__FILE__) . '/filters'; + $this->psdReaderPath = __DIR__ . '/classPhpPsdReader.php'; + $this->filterOverlayPath = __DIR__ . '/filters'; // *** Set if image should be interlaced or not. $this->isInterlace = false; @@ -315,7 +315,7 @@ public function resizeImage($newWidth, $newHeight, $option = 0, $sharpen = false $cropPos = 'm'; if (is_array($option) && fix_strtolower($option[0]) == 'crop') { $cropPos = $option[1]; # get the crop option - } elseif (strpos($option, '-') !== false) { + } elseif (str_contains($option, '-')) { // *** Or pass in a hyphen seperated option $optionPiecesArray = explode('-', $option); $cropPos = end($optionPiecesArray); @@ -873,7 +873,7 @@ private function prepOption($option) } else { throw new Exception('Crop resize option array is badly formatted.'); } - } elseif (strpos($option, 'crop') !== false) { + } elseif (str_contains($option, 'crop')) { return 'crop'; } @@ -983,7 +983,7 @@ public function greyScaleEnhanced() imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15); imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 2); - $this->sharpen($this->width); + $this->sharpen(); } } @@ -2169,7 +2169,7 @@ public function addText($text, $pos = '20x20', $padding = 0, $fontColor='#fff', private function getTextFont($font) { // *** Font path (shou - $fontPath = dirname(__FILE__) . '/' . $this->fontDir; + $fontPath = __DIR__ . '/' . $this->fontDir; // *** The below is/may be needed depending on your version (see ref) @@ -3049,7 +3049,7 @@ private function transparentImage($src) function checkStringStartsWith($needle, $haystack) # Check if a string starts with a specific pattern { - return (substr($haystack, 0, strlen($needle))==$needle); + return (str_starts_with($haystack, $needle)); } diff --git a/admin/filemanager/include/utils.php b/admin/filemanager/include/utils.php index b8c3295de0..c10b2f8856 100644 --- a/admin/filemanager/include/utils.php +++ b/admin/filemanager/include/utils.php @@ -185,7 +185,7 @@ function fix_filename($str, $transliteration) // Empty or incorrectly transliterated filename. // Here is a point: a good file UNKNOWN_LANGUAGE.jpg could become .jpg in previous code. // So we add that default 'file' name to fix that issue. - if (strpos($str, '.') === 0) { + if (str_starts_with($str, '.')) { $str = 'file'.$str; } @@ -291,7 +291,7 @@ function image_check_memory_usage($img, $max_breedte, $max_hoogte) function endsWith($haystack, $needle) { - return $needle === "" || substr($haystack, -strlen($needle)) === $needle; + return $needle === "" || str_ends_with($haystack, $needle); } function new_thumbnails_creation($targetPath, $targetFile, $name, $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height) @@ -352,7 +352,6 @@ function get_file_by_url($url) curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); - curl_close($ch); return $data; } diff --git a/admin/filemanager/upload.php b/admin/filemanager/upload.php index 0367709421..0acb2275ef 100644 --- a/admin/filemanager/upload.php +++ b/admin/filemanager/upload.php @@ -11,8 +11,8 @@ $storeFolder = $_POST['path']; $storeFolderThumb = $_POST['path_thumb']; -$path_pos = strpos($storeFolder, $current_path); -$thumb_pos = strpos($_POST['path_thumb'], $thumbs_base_path); +$path_pos = strpos($storeFolder, (string) $current_path); +$thumb_pos = strpos($_POST['path_thumb'], (string) $thumbs_base_path); if ($path_pos === false || $thumb_pos === false || preg_match('/\.{1,2}[\/|\\\]/', $_POST['path_thumb']) !== 0 diff --git a/admin/functions.php b/admin/functions.php index d6d2d148c7..2fbe6a5fb5 100644 --- a/admin/functions.php +++ b/admin/functions.php @@ -477,11 +477,11 @@ function runAdminTab($tab, $ajax_mode = false) foreach ($_POST as $key => $value) { if (is_array($admin_obj->table)) { foreach ($admin_obj->table as $table) { - if (strncmp($key, $table.'Filter_', 7) === 0 || strncmp($key, 'submitFilter', 12) === 0) { + if (strncmp($key, $table.'Filter_', 7) === 0 || str_starts_with($key, 'submitFilter')) { $cookie->$key = !is_array($value) ? $value : json_encode($value); } } - } elseif (strncmp($key, $admin_obj->table.'Filter_', 7) === 0 || strncmp($key, 'submitFilter', 12) === 0) { + } elseif (strncmp($key, $admin_obj->table.'Filter_', 7) === 0 || str_starts_with($key, 'submitFilter')) { $cookie->$key = !is_array($value) ? $value : json_encode($value); } } @@ -515,7 +515,7 @@ function runAdminTab($tab, $ajax_mode = false) // ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17) $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$admin_obj->token.'$2', $_SERVER['REQUEST_URI']); - if (false === strpos($url, '?token=') && false === strpos($url, '&token=')) { + if (!str_contains($url, '?token=') && !str_contains($url, '&token=')) { $url .= '&token='.$admin_obj->token; } @@ -530,7 +530,7 @@ function runAdminTab($tab, $ajax_mode = false) // ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17) $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$admin_obj->token.'$2', $_SERVER['REQUEST_URI']); - if (false === strpos($url, '?token=') && false === strpos($url, '&token=')) { + if (!str_contains($url, '?token=') && !str_contains($url, '&token=')) { $url .= '&token='.$admin_obj->token; } diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 0e54eac071..34752cdee6 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -203,7 +203,7 @@ public function __construct() { $this->context = Context::getContext(); - $this->id = Tab::getIdFromClassName(get_class($this)); + $this->id = Tab::getIdFromClassName(static::class); $this->_conf = array( 1 => $this->l('Deletion successful'), 2 => $this->l('Selection successfully deleted'), 3 => $this->l('Creation successful'), 4 => $this->l('Update successful'), @@ -225,7 +225,7 @@ public function __construct() if (!$this->_defaultOrderBy) { $this->_defaultOrderBy = $this->identifier; } - $className = get_class($this); + $className = static::class; // if ($className == 'AdminCategories' OR $className == 'AdminProducts') // $className = 'AdminCatalog'; $this->token = Tools::getAdminToken($className.(int)$this->id.(int)$this->context->employee->id); @@ -247,19 +247,19 @@ public function __construct() protected function l($string, $class = 'AdminTab', $addslashes = false, $htmlentities = true) { // if the class is extended by a module, use modules/[module_name]/xx.php lang file - $current_class = get_class($this); + $current_class = static::class; if (Module::getModuleNameFromClass($current_class)) { $string = str_replace('\'', '\\\'', $string); return Translate::getModuleTranslation(Module::$classInModule[$current_class], $string, $current_class); } global $_LANGADM; - if ($class == __CLASS__) { + if ($class == self::class) { $class = 'AdminTab'; } $key = md5(str_replace('\'', '\\\'', $string)); - $str = (array_key_exists(get_class($this).$key, $_LANGADM)) ? $_LANGADM[get_class($this).$key] : ((array_key_exists($class.$key, $_LANGADM)) ? $_LANGADM[$class.$key] : $string); + $str = (array_key_exists(static::class.$key, $_LANGADM)) ? $_LANGADM[static::class.$key] : ((array_key_exists($class.$key, $_LANGADM)) ? $_LANGADM[$class.$key] : $string); $str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str; return str_replace('"', '"', ($addslashes ? addslashes($str) : stripslashes($str))); } @@ -1189,7 +1189,7 @@ protected function copyFromPost(&$object, $table) } /* Multilingual fields */ - $rules = call_user_func(array(get_class($object), 'getValidationRules'), get_class($object)); + $rules = call_user_func(array($object::class, 'getValidationRules'), $object::class); if (count($rules['validateLang'])) { $language_ids = Language::getIDs(false); foreach ($language_ids as $id_lang) { @@ -1673,7 +1673,9 @@ public function displayListContent($token = null) $irow = 0; if ($this->_list && isset($this->fieldsDisplay['position'])) { - $positions = array_map(create_function('$elem', 'return (int)$elem[\'position\'];'), $this->_list); + $positions = array_map(function ($elem) { + return (int) $elem['position']; + }, $this->_list); sort($positions); } if ($this->_list) { @@ -1805,7 +1807,7 @@ protected function _displayEnableLink($token, $id, $value, $active, $id_category protected function _displayDuplicate($token, $id) { $_cacheLang['Duplicate'] = $this->l('Duplicate'); - $_cacheLang['Copy images too?'] = $this->l('This will copy the images too. If you wish to proceed, click "OK". If not, click "Cancel".', __CLASS__, true, false); + $_cacheLang['Copy images too?'] = $this->l('This will copy the images too. If you wish to proceed, click "OK". If not, click "Cancel".', self::class, true, false); $duplicate = Tools::safeOutput(self::$currentIndex.'&'.$this->identifier.'='.$id.'&duplicate'.$this->table.'&token='.($token != null ? $token : $this->token)); echo ' @@ -1833,7 +1835,7 @@ protected function _displayEditLink($token, $id) protected function _displayDeleteLink($token, $id) { $_cacheLang['Delete'] = $this->l('Delete'); - $_cacheLang['DeleteItem'] = $this->l('Delete item #', __CLASS__, true, false); + $_cacheLang['DeleteItem'] = $this->l('Delete item #', self::class, true, false); $href = Tools::safeOutput(self::$currentIndex.'&'.$this->identifier.'='.(int)$id.'&delete'.$this->table.'&token='.($token != null ? $token : $this->token)); echo '

'; + echo '

'; } echo ' diff --git a/classes/Cart.php b/classes/Cart.php index 96fe2c68c6..5ca6418bf9 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2089,7 +2089,7 @@ public function getGiftWrappingPrice($with_taxes = true, $id_address = null) } try { $address[$this->id] = Address::initialize($id_address); - } catch (Exception $e) { + } catch (Exception) { $address[$this->id] = new Address(); $address[$this->id]->id_country = Configuration::get('PS_COUNTRY_DEFAULT'); } @@ -3284,10 +3284,8 @@ public function getDeliveryOption($default_country = null, $dontAutoSelectOption break; } } - - reset($options); if (!isset($delivery_option[$id_address])) { - $delivery_option[$id_address] = key($options); + $delivery_option[$id_address] = array_key_first($options); } } @@ -4325,7 +4323,7 @@ public function duplicate() $customized_value = $custom['value']; if ((int)$custom['type'] == 0) { - $customized_value = md5(uniqid(rand(), true)); + $customized_value = md5(uniqid(random_int(0, mt_getrandmax()), true)); Tools::copy(_PS_UPLOAD_DIR_.$custom['value'], _PS_UPLOAD_DIR_.$customized_value); Tools::copy(_PS_UPLOAD_DIR_.$custom['value'].'_small', _PS_UPLOAD_DIR_.$customized_value.'_small'); } diff --git a/classes/ConfigurationTest.php b/classes/ConfigurationTest.php index fe733a1614..855b5cdcc8 100644 --- a/classes/ConfigurationTest.php +++ b/classes/ConfigurationTest.php @@ -145,14 +145,14 @@ public static function run($ptr, $arg = 0) public static function test_phpversion() { return ( - version_compare(substr(phpversion(), 0, 5), '8.1.0', '>=') - && version_compare(substr(phpversion(), 0, 5), '8.5', '<') + version_compare(substr(phpversion(), 0, 5), '8.3.0', '>=') + && version_compare(substr(phpversion(), 0, 5), '8.6.0', '<') ); } public static function test_new_phpversion() { - return version_compare(substr(phpversion(), 0, 5), '8.1.0', '>='); + return version_compare(substr(phpversion(), 0, 5), '8.3.0', '>='); } public static function test_mysql_support() diff --git a/classes/Connection.php b/classes/Connection.php index c14ee13feb..a329f2ca1e 100644 --- a/classes/Connection.php +++ b/classes/Connection.php @@ -82,7 +82,7 @@ public static function setPageConnection($cookie, $full = true) { $id_page = false; // The connection is created if it does not exist yet and we get the current page id - if (!isset($cookie->id_connections) || !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', Tools::getHttpHost(false, false))) { + if (!isset($cookie->id_connections) || !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', (string) Tools::getHttpHost(false, false))) { $id_page = Connection::setNewConnection($cookie); } // If we do not track the pages, no need to get the page id diff --git a/classes/Cookie.php b/classes/Cookie.php index ef31241ee4..9ae0875b82 100644 --- a/classes/Cookie.php +++ b/classes/Cookie.php @@ -381,11 +381,7 @@ protected function _setcookie($cookie = null) return setcookie( $this->_name, $content, - $time, - $this->_path, - $this->_domain . '; SameSite=' . $this->_sameSite, - $this->_secure, - true + ['expires' => $time, 'path' => $this->_path, 'domain' => $this->_domain . '; SameSite=' . $this->_sameSite, 'secure' => $this->_secure, 'httponly' => true] ); } @@ -444,7 +440,7 @@ public function getFamily($origin) return $result; } foreach ($this->_content as $key => $value) { - if (strncmp($key, $origin, strlen($origin)) == 0) { + if (str_starts_with($key, $origin)) { $result[$key] = $value; } } diff --git a/classes/Customer.php b/classes/Customer.php index d5644633b0..880243441b 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -239,7 +239,7 @@ public function add($autodate = true, $null_values = true) $this->id_shop_group = ($this->id_shop_group) ? $this->id_shop_group : Context::getContext()->shop->id_shop_group; $this->id_lang = ($this->id_lang) ? $this->id_lang : Context::getContext()->language->id; $this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days); - $this->secure_key = md5(uniqid(rand(), true)); + $this->secure_key = md5(uniqid(random_int(0, mt_getrandmax()), true)); $this->last_passwd_gen = date('Y-m-d H:i:s', strtotime('-'.Configuration::get('PS_PASSWD_TIME_FRONT').'minutes')); if ($this->newsletter diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php index 7452b49244..810cbba2e4 100644 --- a/classes/Dispatcher.php +++ b/classes/Dispatcher.php @@ -851,11 +851,11 @@ public static function getModuleControllers($type = 'all', $module = null) foreach ($modules as $mod) { foreach (Dispatcher::getControllersInDirectory(_PS_MODULE_DIR_.$mod->name.'/controllers/') as $controller) { if ($type == 'admin') { - if (strpos($controller, 'Admin') !== false) { + if (str_contains($controller, 'Admin')) { $modules_controllers[$mod->name][] = $controller; } } elseif ($type == 'front') { - if (strpos($controller, 'Admin') === false) { + if (!str_contains($controller, 'Admin')) { $modules_controllers[$mod->name][] = $controller; } } else { diff --git a/classes/ImageManager.php b/classes/ImageManager.php index c811fdbcfb..d14b65648b 100644 --- a/classes/ImageManager.php +++ b/classes/ImageManager.php @@ -340,7 +340,7 @@ public static function isRealImage($filename, $file_mime_type = null, $mime_type // For each allowed MIME type, we are looking for it inside the current MIME type foreach ($mime_type_list as $type) { - if (strstr($mime_type, $type)) { + if (strstr($mime_type, (string) $type)) { return true; } } @@ -411,7 +411,7 @@ public static function validateIconUpload($file, $max_file_size = 0) $max_file_size / 1000 ); } - if (substr($file['name'], -4) != '.ico') { + if (!str_ends_with($file['name'], '.ico')) { return Tools::displayError('Image format not recognized, allowed formats are: .ico'); } if ($file['error']) { diff --git a/classes/ImageType.php b/classes/ImageType.php index ac1a307067..9a858d94a2 100644 --- a/classes/ImageType.php +++ b/classes/ImageType.php @@ -186,7 +186,7 @@ public static function getFormatedName($name) $name_without_theme_name = str_replace(array('_'.$theme_name, $theme_name.'_'), '', $name); //check if the theme name is already in $name if yes only return $name - if ($theme_name !== null && strstr($name, $theme_name) && self::getByNameNType($name)) { + if ($theme_name !== null && strstr($name, (string) $theme_name) && self::getByNameNType($name)) { return $name; } elseif (self::getByNameNType($name_without_theme_name.'_'.$theme_name)) { return $name_without_theme_name.'_'.$theme_name; diff --git a/classes/Language.php b/classes/Language.php index 0963279bbd..2f26cdb385 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -956,7 +956,7 @@ public static function downloadAndInstallLanguagePack($iso, $version = null, $pa $other_files = array(); foreach ($files_list as $key => $data) { - if (substr($data['filename'], 0, 5) == 'mails') { + if (str_starts_with($data['filename'], 'mails')) { $mails_files[] = $data; } else { $other_files[] = $data; @@ -1049,7 +1049,7 @@ public static function updateModulesTranslations(array $modules_list) $gz = new Archive_Tar($filegz, true); $files_list = Language::getLanguagePackListContent($lang['iso_code'], $gz); foreach ($files_list as $i => $file) { - if (strpos($file['filename'], 'modules/'.$module_name.'/') !== 0) { + if (!str_starts_with($file['filename'], 'modules/'.$module_name.'/')) { unset($files_list[$i]); } } diff --git a/classes/Link.php b/classes/Link.php index f5c58e6b95..4d5b8f000b 100644 --- a/classes/Link.php +++ b/classes/Link.php @@ -421,7 +421,7 @@ public function getImageLink($name, $ids, $type = null) $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : ''); if ((Configuration::get('PS_LEGACY_IMAGES') && (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg'))) - || ($not_default = strpos($ids, 'default') !== false)) { + || ($not_default = str_contains($ids, 'default'))) { if ($this->allow == 1 && !$not_default) { $uri_path = __PS_BASE_URI__.$ids.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg'; } else { diff --git a/classes/Media.php b/classes/Media.php index 779d3f4bb9..8dc24ea510 100644 --- a/classes/Media.php +++ b/classes/Media.php @@ -753,11 +753,11 @@ public static function cccJS($js_files) } // rebuild the original js_files array - if (strpos($compressed_js_path, _PS_ROOT_DIR_) !== false) { + if (str_contains($compressed_js_path, _PS_ROOT_DIR_)) { $url = str_replace(_PS_ROOT_DIR_.'/', __PS_BASE_URI__, $compressed_js_path); } - if (strpos($compressed_js_path, _PS_CORE_DIR_) !== false) { + if (str_contains($compressed_js_path, _PS_CORE_DIR_)) { $url = str_replace(_PS_CORE_DIR_.'/', __PS_BASE_URI__, $compressed_js_path); } @@ -859,7 +859,7 @@ public static function deferInlineScripts($output) foreach ($scripts as $script) { /** @var DOMElement $script */ if ($src = $script->getAttribute('src')) { - if (substr($src, 0, 2) == '//') { + if (str_starts_with($src, '//')) { $src = Tools::getCurrentUrlProtocolPrefix().substr($src, 2); } @@ -929,7 +929,7 @@ public static function deferScript($matches) /* This is an external script, if it already belongs to js_files then remove it from content */ preg_match('/src\s*=\s*["\']?([^"\']*)[^>]/ims', $original, $results); if (array_key_exists(1, $results)) { - if (substr($results[1], 0, 2) == '//') { + if (str_starts_with($results[1], '//')) { $protocol_link = Tools::getCurrentUrlProtocolPrefix(); $results[1] = $protocol_link.ltrim($results[1], '/'); } diff --git a/classes/Meta.php b/classes/Meta.php index e77a966b31..3889df6827 100644 --- a/classes/Meta.php +++ b/classes/Meta.php @@ -94,7 +94,7 @@ public static function getPages($exclude_filled = false, $add_page = false) continue; } - $module = Tools::strtolower(basename(dirname(dirname(dirname($file))))); + $module = Tools::strtolower(basename(dirname($file, 3))); $selected_pages[$module.' - '.$filename] = 'module-'.$module.'-'.$filename; } diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index e960ee8375..4707437905 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -179,7 +179,7 @@ public static function getRepositoryClassName() * * @return array Validation rules (fields validity) */ - public static function getValidationRules($class = __CLASS__) + public static function getValidationRules($class = self::class) { $object = new $class(); return array( @@ -204,7 +204,7 @@ public static function getValidationRules($class = __CLASS__) */ public function __construct($id = null, $id_lang = null, $id_shop = null) { - $class_name = get_class($this); + $class_name = static::class; if (!isset(ObjectModel::$loaded_classes[$class_name])) { $this->def = ObjectModel::getDefinition($class_name); $this->setDefinitionRetrocompatibility(); @@ -469,7 +469,7 @@ public function add($auto_date = true, $null_values = false) // @hook actionObject*AddBefore Hook::exec('actionObjectAddBefore', array('object' => $this)); - Hook::exec('actionObject'.get_class($this).'AddBefore', array('object' => $this)); + Hook::exec('actionObject'.static::class.'AddBefore', array('object' => $this)); // Automatically fill dates if ($auto_date && property_exists($this, 'date_add')) { @@ -540,7 +540,7 @@ public function add($auto_date = true, $null_values = false) // @hook actionObject*AddAfter Hook::exec('actionObjectAddAfter', array('object' => $this)); - Hook::exec('actionObject'.get_class($this).'AddAfter', array('object' => $this)); + Hook::exec('actionObject'.static::class.'AddAfter', array('object' => $this)); return $result; } @@ -626,7 +626,7 @@ public function update($null_values = false) { // @hook actionObject*UpdateBefore Hook::exec('actionObjectUpdateBefore', array('object' => $this)); - Hook::exec('actionObject'.get_class($this).'UpdateBefore', array('object' => $this)); + Hook::exec('actionObject'.static::class.'UpdateBefore', array('object' => $this)); $this->clearCache(); @@ -743,7 +743,7 @@ public function update($null_values = false) // @hook actionObject*UpdateAfter Hook::exec('actionObjectUpdateAfter', array('object' => $this)); - Hook::exec('actionObject'.get_class($this).'UpdateAfter', array('object' => $this)); + Hook::exec('actionObject'.static::class.'UpdateAfter', array('object' => $this)); return $result; } @@ -758,7 +758,7 @@ public function delete() { // @hook actionObject*DeleteBefore Hook::exec('actionObjectDeleteBefore', array('object' => $this)); - Hook::exec('actionObject'.get_class($this).'DeleteBefore', array('object' => $this)); + Hook::exec('actionObject'.static::class.'DeleteBefore', array('object' => $this)); $this->clearCache(); $result = true; @@ -789,7 +789,7 @@ public function delete() // @hook actionObject*DeleteAfter Hook::exec('actionObjectDeleteAfter', array('object' => $this)); - Hook::exec('actionObject'.get_class($this).'DeleteAfter', array('object' => $this)); + Hook::exec('actionObject'.static::class.'DeleteAfter', array('object' => $this)); return $result; } @@ -822,7 +822,7 @@ public function toggleStatus() { // Object must have a variable called 'active' if (!property_exists($this, 'active')) { - throw new PrestaShopException('property "active" is missing in object '.get_class($this)); + throw new PrestaShopException('property "active" is missing in object '.static::class); } // Update only active field @@ -1008,7 +1008,7 @@ public function validateField($field, $value, $id_lang = null, $skip = array(), // Check if field is required - $required_fields = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array(); + $required_fields = (isset(self::$fieldsRequiredDatabase[static::class])) ? self::$fieldsRequiredDatabase[static::class] : array(); if (!$id_lang || $id_lang == $ps_lang_default) { // if validation is being done for webservice request then check if that field is required in webservice parameters or not $isWebserviceFieldRequired = true; @@ -1025,9 +1025,9 @@ public function validateField($field, $value, $id_lang = null, $skip = array(), ) { if (Tools::isEmpty($value)) { if ($human_errors) { - return sprintf(Tools::displayError('The %s field is required.'), self::displayFieldName($field, get_class($this))); + return sprintf(Tools::displayError('The %s field is required.'), self::displayFieldName($field, static::class)); } else { - return 'Property '.get_class($this).'->'.$field.' is empty'; + return 'Property '.static::class.'->'.$field.' is empty'; } } } @@ -1041,7 +1041,7 @@ public function validateField($field, $value, $id_lang = null, $skip = array(), // Check field values if (!in_array('values', $skip) && !empty($data['values']) && is_array($data['values']) && !in_array($value, $data['values'])) { - return 'Property '.get_class($this).'->'.$field.' has bad value (allowed values are: '.implode(', ', $data['values']).')'; + return 'Property '.static::class.'->'.$field.' has bad value (allowed values are: '.implode(', ', $data['values']).')'; } // Check field size @@ -1056,12 +1056,12 @@ public function validateField($field, $value, $id_lang = null, $skip = array(), if ($human_errors) { if (isset($data['lang']) && $data['lang']) { $language = new Language((int)$id_lang); - return sprintf(Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'), self::displayFieldName($field, get_class($this)), $language->name, $size['max']); + return sprintf(Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'), self::displayFieldName($field, static::class), $language->name, $size['max']); } else { - return sprintf(Tools::displayError('The %1$s field is too long (%2$d chars max).'), self::displayFieldName($field, get_class($this)), $size['max']); + return sprintf(Tools::displayError('The %1$s field is too long (%2$d chars max).'), self::displayFieldName($field, static::class), $size['max']); } } else { - return 'Property '.get_class($this).'->'.$field.' length ('.$length.') must be between '.$size['min'].' and '.$size['max']; + return 'Property '.static::class.'->'.$field.' length ('.$length.') must be between '.$size['min'].' and '.$size['max']; } } } @@ -1085,9 +1085,9 @@ public function validateField($field, $value, $id_lang = null, $skip = array(), } if (!$res) { if ($human_errors) { - return sprintf(Tools::displayError('The %s field is invalid.'), self::displayFieldName($field, get_class($this))); + return sprintf(Tools::displayError('The %s field is invalid.'), self::displayFieldName($field, static::class)); } else { - return 'Property '.get_class($this).'->'.$field.' is not valid'; + return 'Property '.static::class.'->'.$field.' is not valid'; } } } @@ -1106,7 +1106,7 @@ public function validateField($field, $value, $id_lang = null, $skip = array(), * * @return string */ - public static function displayFieldName($field, $class = __CLASS__, $htmlentities = true, ?Context $context = null) + public static function displayFieldName($field, $class = self::class, $htmlentities = true, ?Context $context = null) { global $_FIELDS; @@ -1145,7 +1145,7 @@ public function validateController($htmlentities = true) { $this->cacheFieldsRequiredDatabase(); $errors = array(); - $required_fields_database = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array(); + $required_fields_database = (isset(self::$fieldsRequiredDatabase[static::class])) ? self::$fieldsRequiredDatabase[static::class] : array(); foreach ($this->def['fields'] as $field => $data) { $value = Tools::getValue($field, $this->{$field}); // Check if field is required by user @@ -1156,7 +1156,7 @@ public function validateController($htmlentities = true) // Checking for required fields if (isset($data['required']) && $data['required'] && empty($value) && $value !== '0') { if (!$this->id || $field != 'passwd') { - $errors[$field] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is required.'); + $errors[$field] = ''.self::displayFieldName($field, static::class, $htmlentities).' '.Tools::displayError('is required.'); } } @@ -1164,7 +1164,7 @@ public function validateController($htmlentities = true) if (isset($data['size']) && !empty($value) && Tools::strlen($value) > $data['size']) { $errors[$field] = sprintf( Tools::displayError('%1$s is too long. Maximum length: %2$d'), - self::displayFieldName($field, get_class($this), $htmlentities), + self::displayFieldName($field, static::class, $htmlentities), $data['size'] ); } @@ -1176,7 +1176,7 @@ public function validateController($htmlentities = true) if (isset($data['validate'])) { $data_validate = $data['validate']; if (!Validate::$data_validate($value) && (!empty($value) || $data['required'])) { - $errors[$field] = ''.self::displayFieldName($field, get_class($this), $htmlentities). + $errors[$field] = ''.self::displayFieldName($field, static::class, $htmlentities). ' '.Tools::displayError('is invalid.'); $validation_error = true; } @@ -1214,7 +1214,7 @@ public function getWebserviceParameters($ws_params_attribute_name = null) $default_resource_parameters = array( 'objectSqlId' => $this->def['primary'], 'retrieveData' => array( - 'className' => get_class($this), + 'className' => static::class, 'retrieveMethod' => 'getWebserviceObjectList', 'params' => array(), 'table' => $this->def['table'], @@ -1252,7 +1252,7 @@ public function getWebserviceParameters($ws_params_attribute_name = null) $resource_parameters = array_merge_recursive($default_resource_parameters, $this->{$ws_params_attribute_name}); - $required_fields = (isset(self::$fieldsRequiredDatabase[get_class($this)]) ? self::$fieldsRequiredDatabase[get_class($this)] : array()); + $required_fields = (isset(self::$fieldsRequiredDatabase[static::class]) ? self::$fieldsRequiredDatabase[static::class] : array()); foreach ($this->def['fields'] as $field_name => $details) { if (!isset($resource_parameters['fields'][$field_name])) { $resource_parameters['fields'][$field_name] = array(); @@ -1361,7 +1361,7 @@ public function validateFieldsRequiredDatabase($htmlentities = true) { $this->cacheFieldsRequiredDatabase(); $errors = array(); - $required_fields = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array(); + $required_fields = (isset(self::$fieldsRequiredDatabase[static::class])) ? self::$fieldsRequiredDatabase[static::class] : array(); foreach ($this->def['fields'] as $field => $data) { if (!in_array($field, $required_fields)) { @@ -1375,7 +1375,7 @@ public function validateFieldsRequiredDatabase($htmlentities = true) $value = Tools::getValue($field); if (empty($value)) { - $errors[$field] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities)); + $errors[$field] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, static::class, $htmlentities)); } } @@ -1395,7 +1395,7 @@ public function getFieldsRequiredDatabase($all = false) return Db::getInstance()->executeS(' SELECT id_required_field, object_name, field_name FROM '._DB_PREFIX_.'required_field - '.(!$all ? 'WHERE object_name = \''.pSQL(get_class($this)).'\'' : '')); + '.(!$all ? 'WHERE object_name = \''.pSQL(static::class).'\'' : '')); } /** @@ -1431,12 +1431,12 @@ public function addFieldsRequiredDatabase($fields) return false; } - if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'required_field WHERE object_name = \''.get_class($this).'\'')) { + if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'required_field WHERE object_name = \''.static::class.'\'')) { return false; } foreach ($fields as $field) { - if (!Db::getInstance()->insert('required_field', array('object_name' => get_class($this), 'field_name' => pSQL($field)))) { + if (!Db::getInstance()->insert('required_field', array('object_name' => static::class, 'field_name' => pSQL($field)))) { return false; } } @@ -1863,7 +1863,7 @@ public static function hydrateCollection($class, array $datas, $id_lang = null) public static function getDefinition($class, $field = null) { if (is_object($class)) { - $class = get_class($class); + $class = $class::class; } if ($field === null) { diff --git a/classes/PhpEncryption.php b/classes/PhpEncryption.php index 13d4fa7a1c..848452e67c 100644 --- a/classes/PhpEncryption.php +++ b/classes/PhpEncryption.php @@ -100,7 +100,7 @@ public static function createNewRandomKey() try { $randomKey = $engine::createNewRandomKey(); - } catch (EnvironmentIsBrokenException $exception) { + } catch (EnvironmentIsBrokenException) { $buf = $engine::randomCompat(); $randomKey = $engine::saveToAsciiSafeString($buf); } diff --git a/classes/PrestaShopAutoload.php b/classes/PrestaShopAutoload.php index ea680aadfb..1957d452b9 100644 --- a/classes/PrestaShopAutoload.php +++ b/classes/PrestaShopAutoload.php @@ -102,7 +102,7 @@ public function load($classname) } // If $classname has not core suffix (E.g. Shop, Product) - if (substr($classname, -4) != 'Core') { + if (!str_ends_with($classname, 'Core')) { $class_dir = (isset($this->index[$classname]['override']) && $this->index[$classname]['override'] === true) ? $this->normalizeDirectory(_PS_ROOT_DIR_) : $this->root_dir; @@ -185,7 +185,7 @@ protected function getClassesFromDir($path, $host_mode = false) if ($file[0] != '.') { if (is_dir($root_dir.$path.$file)) { $classes = array_merge($classes, $this->getClassesFromDir($path.$file.'/', $host_mode)); - } elseif (substr($file, -4) == '.php') { + } elseif (str_ends_with($file, '.php')) { $content = file_get_contents($root_dir.$path.$file); $namespacePattern = '[\\a-z0-9_]*[\\]'; @@ -199,7 +199,7 @@ protected function getClassesFromDir($path, $host_mode = false) 'override' => $host_mode ); - if (substr($m['classname'], -4) == 'Core') { + if (str_ends_with($m['classname'], 'Core')) { $classes[substr($m['classname'], 0, -4)] = array( 'path' => '', 'type' => $classes[$m['classname']]['type'], diff --git a/classes/PrestaShopBackup.php b/classes/PrestaShopBackup.php index d7e926799d..aff2ccdfe1 100644 --- a/classes/PrestaShopBackup.php +++ b/classes/PrestaShopBackup.php @@ -228,7 +228,7 @@ public function add() $table = current($table); // Skip tables which do not start with _DB_PREFIX_ - if (strlen($table) < strlen(_DB_PREFIX_) || strncmp($table, _DB_PREFIX_, strlen(_DB_PREFIX_)) != 0) { + if (strlen($table) < strlen(_DB_PREFIX_) || !str_starts_with($table, _DB_PREFIX_)) { continue; } @@ -268,7 +268,7 @@ public function add() $s .= $tmp; } else { foreach ($lines as $line) { - if (strpos($line, '`'.$field.'`') !== false) { + if (str_contains($line, '`'.$field.'`')) { if (preg_match('/(.*NOT NULL.*)/Ui', $line)) { $s .= "'',"; } else { diff --git a/classes/Product.php b/classes/Product.php index fc962d3c03..2c2d1bffeb 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -5101,7 +5101,7 @@ public function updateLabels() $has_required_fields = 0; foreach ($_POST as $field => $value) { /* Label update */ - if (strncmp($field, 'label_', 6) == 0) { + if (str_starts_with($field, 'label_')) { if (!$tmp = $this->_checkLabelField($field, $value)) { return false; } diff --git a/classes/QuickAccess.php b/classes/QuickAccess.php index 1a71b14bbe..cced1167e2 100644 --- a/classes/QuickAccess.php +++ b/classes/QuickAccess.php @@ -68,7 +68,7 @@ public static function getQuickAccesses($id_lang) public function toggleNewWindow() { if (!array_key_exists('new_window', get_object_vars($this))) { - throw new PrestaShopException('property "new_window" is missing in object '.get_class($this)); + throw new PrestaShopException('property "new_window" is missing in object '.static::class); } $this->setFieldsToUpdate(array('new_window' => true)); diff --git a/classes/Search.php b/classes/Search.php index 57223a382e..5efb2fa017 100644 --- a/classes/Search.php +++ b/classes/Search.php @@ -279,7 +279,7 @@ public static function find($id_lang, $expr, $page_number = 1, $page_size = 1, $ if (empty($product_pool)) { return ($ajax ? array() : array('total' => 0, 'result' => array())); } - $product_pool = ((strpos($product_pool, ',') === false) ? (' = '.(int)$product_pool.' ') : (' IN ('.rtrim($product_pool, ',').') ')); + $product_pool = ((!str_contains($product_pool, ',')) ? (' = '.(int)$product_pool.' ') : (' IN ('.rtrim($product_pool, ',').') ')); if ($ajax) { $sql = 'SELECT DISTINCT p.id_product, pl.name pname, cl.name cname, diff --git a/classes/SearchEngine.php b/classes/SearchEngine.php index 7dc8b5f140..c00ccfbb42 100644 --- a/classes/SearchEngine.php +++ b/classes/SearchEngine.php @@ -51,7 +51,7 @@ public static function getKeywords($url) foreach ($result as $row) { $host =& $row['server']; $varname =& $row['getvar']; - if (strstr($parsed_url['host'], $host)) { + if (strstr($parsed_url['host'], (string) $host)) { $array = array(); preg_match('/[^a-z]'.$varname.'=.+\&/U', $parsed_url['query'], $array); if (empty($array[0])) { diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index 79c63995e7..b901eaf504 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -190,7 +190,7 @@ protected static function _getScoreQuery($id_product, $id_shop, $id_currency, $i foreach (array_reverse($priority) as $k => $field) { if (!empty($field)) { - $select .= ' IF (`'.bqSQL($field).'` = '.(int)$$field.', '.pow(2, $k + 1).', 0) + '; + $select .= ' IF (`'.bqSQL($field).'` = '.(int)${$field}.', '.pow(2, $k + 1).', 0) + '; } } diff --git a/classes/Supplier.php b/classes/Supplier.php index eafe31b87a..4677c99894 100644 --- a/classes/Supplier.php +++ b/classes/Supplier.php @@ -259,7 +259,7 @@ public static function getProducts($id_supplier, $id_lang, $p, $n, $nb_days_new_product = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20; - if (strpos('.', $order_by) > 0) { + if (strpos('.', (string) $order_by) > 0) { $order_by = explode('.', $order_by); $order_by = pSQL($order_by[0]).'.`'.pSQL($order_by[1]).'`'; } diff --git a/classes/Tab.php b/classes/Tab.php index 4f8dfed89c..a605a7f62a 100644 --- a/classes/Tab.php +++ b/classes/Tab.php @@ -312,7 +312,7 @@ public static function getTabs($id_lang, $id_parent = null, $include_kpi = false $objreflect = new ReflectionMethod($class_name, 'renderKpis'); $tab['has_kpi'] = ($objreflect->getDeclaringClass()->getName() === $class_name) || isset($hookKpiClasses[$tab['class_name']]); - } catch (ReflectionException $e) { + } catch (ReflectionException) { $tab['has_kpi'] = isset($hookKpiClasses[$tab['class_name']]); } } diff --git a/classes/Tag.php b/classes/Tag.php index 92b0434e52..e9f7f12804 100644 --- a/classes/Tag.php +++ b/classes/Tag.php @@ -97,7 +97,7 @@ public static function addTags($id_lang, $id_product, $tag_list, $separator = ', } if (!is_array($tag_list)) { - $tag_list = array_filter(array_unique(array_map('trim', preg_split('#\\'.$separator.'#', $tag_list, null, PREG_SPLIT_NO_EMPTY)))); + $tag_list = array_filter(array_unique(array_map('trim', preg_split('#\\'.$separator.'#', $tag_list, 0, PREG_SPLIT_NO_EMPTY)))); } $list = array(); diff --git a/classes/Theme.php b/classes/Theme.php index ec6cb09f96..878cc7ed5a 100644 --- a/classes/Theme.php +++ b/classes/Theme.php @@ -346,7 +346,7 @@ public function toggleResponsive() { // Object must have a variable called 'responsive' if (!property_exists($this, 'responsive')) { - throw new PrestaShopException('property "responsive" is missing in object '.get_class($this)); + throw new PrestaShopException('property "responsive" is missing in object '.static::class); } // Update only responsive field @@ -362,7 +362,7 @@ public function toggleResponsive() public function toggleDefaultLeftColumn() { if (!property_exists($this, 'default_left_column')) { - throw new PrestaShopException('property "default_left_column" is missing in object '.get_class($this)); + throw new PrestaShopException('property "default_left_column" is missing in object '.static::class); } $this->setFieldsToUpdate(array('default_left_column' => true)); @@ -375,7 +375,7 @@ public function toggleDefaultLeftColumn() public function toggleDefaultRightColumn() { if (!property_exists($this,'default_right_column')) { - throw new PrestaShopException('property "default_right_column" is missing in object '.get_class($this)); + throw new PrestaShopException('property "default_right_column" is missing in object '.static::class); } $this->setFieldsToUpdate(array('default_right_column' => true)); diff --git a/classes/Tools.php b/classes/Tools.php index 2ffec44341..5ab83db418 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -142,7 +142,7 @@ public static function getBytes($length) public static function strReplaceFirst($search, $replace, $subject, $cur = 0) { - return (strpos($subject, $search, $cur))?substr_replace($subject, $replace, (int)strpos($subject, $search, $cur), strlen($search)):$subject; + return (strpos($subject, (string) $search, $cur))?substr_replace($subject, $replace, (int)strpos($subject, (string) $search, $cur), strlen($search)):$subject; } /** @@ -159,11 +159,11 @@ public static function redirect($url, $base_uri = __PS_BASE_URI__, ?Link $link = $link = Context::getContext()->link; } - if (strpos($url, 'http://') === false && strpos($url, 'https://') === false && $link) { - if (strpos($url, $base_uri) === 0) { + if (!str_contains($url, 'http://') && !str_contains($url, 'https://') && $link) { + if (str_starts_with($url, $base_uri)) { $url = substr($url, strlen($base_uri)); } - if (strpos($url, 'index.php?controller=') !== false && strpos($url, 'index.php/') == 0) { + if (str_starts_with($url, 'index.php?controller=')) { $url = substr($url, strlen('index.php?controller=')); if (Configuration::get('PS_REWRITING_SETTINGS')) { $url = Tools::strReplaceFirst('&', '?', $url); @@ -203,10 +203,10 @@ public static function redirect($url, $base_uri = __PS_BASE_URI__, ?Link $link = public static function redirectLink($url) { if (!preg_match('@^https?://@i', $url)) { - if (strpos($url, __PS_BASE_URI__) !== false && strpos($url, __PS_BASE_URI__) == 0) { + if (str_contains($url, __PS_BASE_URI__) && str_starts_with($url, __PS_BASE_URI__)) { $url = substr($url, strlen(__PS_BASE_URI__)); } - if (strpos($url, 'index.php?controller=') !== false && strpos($url, 'index.php/') == 0) { + if (str_starts_with($url, 'index.php?controller=')) { $url = substr($url, strlen('index.php?controller=')); } $explode = explode('?', $url); @@ -224,7 +224,7 @@ public static function redirectLink($url) * * @param string $url Desired URL */ - public static function redirectAdmin($url) + public static function redirectAdmin($url): never { header('Location: '.$url); exit; @@ -1794,7 +1794,7 @@ public static function strpos($str, $find, $offset = 0, $encoding = 'UTF-8') if (function_exists('mb_strpos')) { return mb_strpos($str, $find, $offset, $encoding); } - return strpos($str, $find, $offset); + return strpos($str, (string) $find, $offset); } public static function strrpos($str, $find, $offset = 0, $encoding = 'utf-8') @@ -1802,7 +1802,7 @@ public static function strrpos($str, $find, $offset = 0, $encoding = 'utf-8') if (function_exists('mb_strrpos')) { return mb_strrpos($str, $find, $offset, $encoding); } - return strrpos($str, $find, $offset); + return strrpos($str, (string) $find, $offset); } public static function ucfirst($str) @@ -1891,13 +1891,13 @@ public static function math_round($value, $places, $mode = PS_ROUND_HALF_UP) } $precision_places = 14 - floor(log10(abs($value))); - $f1 = pow(10.0, (double)abs($places)); + $f1 = pow(10.0, (float) abs($places)); /* If the decimal precision guaranteed by FP arithmetic is higher than * the requested places BUT is small enough to make sure a non-zero value * is returned, pre-round the result to the precision */ if ($precision_places > $places && $precision_places - $places < 15) { - $f2 = pow(10.0, (double)abs($precision_places)); + $f2 = pow(10.0, (float) abs($precision_places)); if ($precision_places >= 0) { $tmp_value = $value * $f2; @@ -1909,7 +1909,7 @@ public static function math_round($value, $places, $mode = PS_ROUND_HALF_UP) * thus never larger than 1e15 here) */ $tmp_value = Tools::round_helper($tmp_value, $mode); /* now correctly move the decimal point */ - $f2 = pow(10.0, (double)abs($places - $precision_places)); + $f2 = pow(10.0, (float) abs($places - $precision_places)); /* because places < precision_places */ $tmp_value = $tmp_value / $f2; } else { @@ -1977,7 +1977,7 @@ public static function ceilf($value, $precision = 0) $tmp = $value * $precision_factor; $tmp2 = (string)$tmp; // If the current value has already the desired precision - if (strpos($tmp2, '.') === false) { + if (!str_contains($tmp2, '.')) { return ($value); } if ($tmp2[strlen($tmp2) - 1] == 0) { @@ -1999,7 +1999,7 @@ public static function floorf($value, $precision = 0) $tmp = $value * $precision_factor; $tmp2 = (string)$tmp; // If the current value has already the desired precision - if (strpos($tmp2, '.') === false) { + if (!str_contains($tmp2, '.')) { return ($value); } if ($tmp2[strlen($tmp2) - 1] == 0) { @@ -2049,7 +2049,7 @@ public static function refreshCACertFile() if ( preg_match('/(.*-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----){50}$/Uims', $ca_cert_content) && - substr(rtrim($ca_cert_content), -1) == '-' + str_ends_with(rtrim($ca_cert_content), '-') ) { file_put_contents(_PS_CACHE_CA_CERT_FILE_, $ca_cert_content); } @@ -2091,7 +2091,6 @@ public static function file_get_contents($url, $use_include_path = false, $strea } } $content = curl_exec($curl); - curl_close($curl); return $content; } else { return false; @@ -2776,7 +2775,7 @@ public static function str_replace_once($needle, $replace, $haystack) { $pos = false; if ($needle) { - $pos = strpos($haystack, $needle); + $pos = strpos($haystack, (string) $needle); } if ($pos === false) { return $haystack; @@ -2824,7 +2823,7 @@ public static function checkPhpVersion() } //Case management system of ubuntu, php version return 5.2.4-2ubuntu5.2 - if (strpos($version, '-') !== false) { + if (str_contains($version, '-')) { $version = substr($version, 0, strpos($version, '-')); } @@ -2965,11 +2964,11 @@ public static function convertBytes($value) /** * @deprecated as of 1.5 use Controller::getController('PageNotFoundController')->run(); */ - public static function display404Error() + public static function display404Error(): never { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); - include(dirname(__FILE__).'/../404.php'); + include(__DIR__.'/../404.php'); die; } @@ -2983,7 +2982,7 @@ public static function display404Error() */ public static function url($begin, $end) { - return $begin.((strpos($begin, '?') !== false) ? '&' : '?').$end; + return $begin.((str_contains($begin, '?')) ? '&' : '?').$end; } /** @@ -3184,7 +3183,7 @@ public static function apacheModExists($name) // we need strpos (example, evasive can be evasive20) foreach ($apache_module_list as $module) { - if (strpos($module, $name) !== false) { + if (str_contains($module, $name)) { return true; } } @@ -3322,7 +3321,7 @@ public static function modRewriteActive() public static function unSerialize($serialized, $object = false) { - if (is_string($serialized) && (strpos($serialized, 'O:') === false || !preg_match('/(^|;|{|})O:[0-9]+:"/', $serialized)) && !$object || $object) { + if (is_string($serialized) && (!str_contains($serialized, 'O:') || !preg_match('/(^|;|{|})O:[0-9]+:"/', $serialized)) && !$object || $object) { return @unserialize($serialized); } @@ -3789,11 +3788,9 @@ public static function arrayReplaceRecursive($base, $replacements) $head_stack = array($replacements); do { - end($bref_stack); - - $bref = &$bref_stack[key($bref_stack)]; + $bref = &$bref_stack[array_key_last($bref_stack)]; $head = array_pop($head_stack); - unset($bref_stack[key($bref_stack)]); + unset($bref_stack[array_key_last($bref_stack)]); foreach (array_keys($head) as $key) { if (isset($key, $bref) && is_array($bref[$key]) && is_array($head[$key])) { $bref_stack[] = &$bref[$key]; diff --git a/classes/Translate.php b/classes/Translate.php index 7fac824620..ae0a4d63dc 100644 --- a/classes/Translate.php +++ b/classes/Translate.php @@ -188,7 +188,7 @@ public static function getModuleTranslation($module, $string, $source, $sprintf $current_key = strtolower('<{'.$name.'}'._THEME_NAME_.'>'.$source).'_'.$key; $default_key = strtolower('<{'.$name.'}prestashop>'.$source).'_'.$key; - if ('controller' == substr($source, -10, 10)) { + if (str_ends_with($source, 'controller')) { $file = substr($source, 0, -10); $current_key_file = strtolower('<{'.$name.'}'._THEME_NAME_.'>'.$file).'_'.$key; $default_key_file = strtolower('<{'.$name.'}prestashop>'.$file).'_'.$key; @@ -560,9 +560,9 @@ public static function getTranslationsCountBackOffice($isoCode) if (preg_match('/^(.*)\.php$/', $file) && Tools::file_exists_cache($filePath = $dir.$file) && !in_array($file, self::$ignore_folder)) { $prefixKey = basename($file); // -4 becomes -14 to remove the ending "Controller.php" from the filename - if (strpos($file, 'Controller.php') !== false) { + if (str_contains($file, 'Controller.php')) { $prefixKey = basename(substr($file, 0, -14)); - } elseif (strpos($file, 'Helper') !== false) { + } elseif (str_contains($file, 'Helper')) { $prefixKey = 'Helper'; } diff --git a/classes/Upgrader.php b/classes/Upgrader.php index 19e52e2495..24e9c98b69 100644 --- a/classes/Upgrader.php +++ b/classes/Upgrader.php @@ -231,15 +231,15 @@ protected function addChangedFile($path) { $this->version_is_modified = true; - if (strpos($path, 'mails/') !== false) { + if (str_contains($path, 'mails/')) { $this->changed_files['mail'][] = $path; } elseif ( - strpos($path, '/en.php') !== false - || strpos($path, '/fr.php') !== false - || strpos($path, '/es.php') !== false - || strpos($path, '/it.php') !== false - || strpos($path, '/de.php') !== false - || strpos($path, 'translations/') !== false + str_contains($path, '/en.php') + || str_contains($path, '/fr.php') + || str_contains($path, '/es.php') + || str_contains($path, '/it.php') + || str_contains($path, '/de.php') + || str_contains($path, 'translations/') ) { $this->changed_files['translation'][] = $path; } else { diff --git a/classes/Uploader.php b/classes/Uploader.php index 218f81a3e0..47ddf2ffd7 100644 --- a/classes/Uploader.php +++ b/classes/Uploader.php @@ -123,7 +123,7 @@ public function getPostMaxSizeBytes() case 'k': $bytes *= 1024; } - if ($bytes == '') { + if ($bytes == 0) { $bytes = null; } return $bytes; diff --git a/classes/Validate.php b/classes/Validate.php index 0d59c99e78..774c7ad775 100644 --- a/classes/Validate.php +++ b/classes/Validate.php @@ -61,10 +61,10 @@ public static function isModuleUrl($url, &$errors) { if (!$url || $url == 'http://') { $errors[] = Tools::displayError('Please specify module URL'); - } elseif (substr($url, -4) != '.tar' && substr($url, -4) != '.zip' && substr($url, -4) != '.tgz' && substr($url, -7) != '.tar.gz') { + } elseif (!str_ends_with($url, '.tar') && !str_ends_with($url, '.zip') && !str_ends_with($url, '.tgz') && !str_ends_with($url, '.tar.gz')) { $errors[] = Tools::displayError('Unknown archive type'); } else { - if ((strpos($url, 'http')) === false) { + if (!str_contains($url, 'http')) { $url = 'http://'.$url; } if (!is_array(@get_headers($url))) { @@ -936,7 +936,7 @@ public static function isDniLite($dni) */ public static function isCookie($data) { - return (is_object($data) && get_class($data) == 'Cookie'); + return (is_object($data) && $data::class == 'Cookie'); } /** diff --git a/classes/cache/Cache.php b/classes/cache/Cache.php index aa91c3119f..781cfadbf3 100644 --- a/classes/cache/Cache.php +++ b/classes/cache/Cache.php @@ -292,7 +292,7 @@ public function delete($key) $keys = array(); if ($key == '*') { $keys = $this->keys; - } elseif (strpos($key, '*') === false) { + } elseif (!str_contains($key, '*')) { $keys = array($key); } else { $pattern = str_replace('\\*', '.*', preg_quote($key)); @@ -483,11 +483,7 @@ protected function adjustTableCacheSize($table, $keyToKeep = null) // sort the array with the query with the lowest count first uasort($this->sql_tables_cached[$table], function ($a, $b) { - if ($a['count'] == $b['count']) { - return 0; - } - - return ($a['count'] < $b['count']) ? -1 : 1; + return $a['count'] <=> $b['count']; }); // reduce the size of the cache : delete the first entries (those with the lowest count) $tableBuffer = array_slice( @@ -633,7 +629,7 @@ private function removeEntryInTableMapCache($key, $table) protected function isBlacklist($query) { foreach ($this->blacklist as $find) { - if (false !== strpos($query, _DB_PREFIX_.$find)) { + if (str_contains($query, _DB_PREFIX_.$find)) { return true; } } @@ -673,7 +669,7 @@ public static function isStored($key) public static function clean($key) { - if (strpos($key, '*') !== false) { + if (str_contains($key, '*')) { $regexp = str_replace('\\*', '.*', preg_quote($key, '#')); foreach (array_keys(Cache::$local) as $key) { if (preg_match('#^'.$regexp.'$#', $key)) { diff --git a/classes/cache/CacheApc.php b/classes/cache/CacheApc.php index 944b65f015..1f04e7261a 100644 --- a/classes/cache/CacheApc.php +++ b/classes/cache/CacheApc.php @@ -56,7 +56,7 @@ public function delete($key) { if ($key == '*') { $this->flush(); - } elseif (strpos($key, '*') === false) { + } elseif (!str_contains($key, '*')) { $this->_delete($key); } else { $pattern = str_replace('\\*', '.*', preg_quote($key)); diff --git a/classes/cache/CacheMemcache.php b/classes/cache/CacheMemcache.php index 319f6c15b6..6c75d58a86 100644 --- a/classes/cache/CacheMemcache.php +++ b/classes/cache/CacheMemcache.php @@ -190,7 +190,7 @@ public function delete($key) { if ($key == '*') { $this->flush(); - } elseif (strpos($key, '*') === false) { + } elseif (!str_contains($key, '*')) { $this->_delete($key); } else { // Get keys (this code comes from Doctrine 2 project) diff --git a/classes/cache/CacheMemcached.php b/classes/cache/CacheMemcached.php index f7450bba20..2a223c0847 100644 --- a/classes/cache/CacheMemcached.php +++ b/classes/cache/CacheMemcached.php @@ -190,7 +190,7 @@ public function delete($key) { if ($key == '*') $this->flush(); - elseif (strpos($key, '*') === false) + elseif (!str_contains($key, '*')) $this->_delete($key); else { diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 9166f17508..cffda5b735 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -451,7 +451,7 @@ public function __construct() global $token; $this->controller_type = 'admin'; - $this->controller_name = get_class($this); + $this->controller_name = static::class; if (strpos($this->controller_name, 'ControllerOverride')) { $this->controller_name = substr($this->controller_name, 0, -18); } @@ -864,7 +864,7 @@ public function checkToken() */ protected function getCookieFilterPrefix() { - return str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this))); + return str_replace(array('admin', 'controller'), '', Tools::strtolower(static::class)); } public function processFilter() @@ -1136,12 +1136,12 @@ public function postProcess() // no need to use displayConf() here if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action))) { Hook::exec('actionAdmin'.ucfirst($action).'Before', array('controller' => $this)); - Hook::exec('action'.get_class($this).ucfirst($action).'Before', array('controller' => $this)); + Hook::exec('action'.static::class.ucfirst($action).'Before', array('controller' => $this)); $return = $this->{'ajaxProcess'.Tools::toCamelCase($action)}(); Hook::exec('actionAdmin'.ucfirst($action).'After', array('controller' => $this, 'return' => $return)); - Hook::exec('action'.get_class($this).ucfirst($action).'After', array('controller' => $this, 'return' => $return)); + Hook::exec('action'.static::class.ucfirst($action).'After', array('controller' => $this, 'return' => $return)); return $return; } elseif (!empty($action) && $this->controller_name == 'AdminModules' && Tools::getIsset('configure')) { @@ -1165,12 +1165,12 @@ public function postProcess() if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action)))) { // Hook before action Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this)); - Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this)); + Hook::exec('action'.static::class.ucfirst($this->action).'Before', array('controller' => $this)); // Call process $return = $this->{'process'.Tools::toCamelCase($this->action)}(); // Hook After Action Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return)); - Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return)); + Hook::exec('action'.static::class.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return)); return $return; } } @@ -1517,7 +1517,7 @@ public function processStatus() ); $matches = array(); if (preg_match('/[\?|&]controller=([^&]*)/', (string)$_SERVER['HTTP_REFERER'], $matches) !== false - && strtolower($matches[1]) != strtolower(preg_replace('/controller/i', '', get_class($this)))) { + && strtolower($matches[1]) != strtolower(preg_replace('/controller/i', '', static::class))) { $this->redirect_after = preg_replace('/[\?|&]conf=([^&]*)/i', '', (string)$_SERVER['HTTP_REFERER']); } else { $this->redirect_after = self::$currentIndex.'&token='.$this->token; @@ -1571,7 +1571,7 @@ public function processResetFilters($list_id = null) $list_id = isset($this->list_id) ? $this->list_id : $this->table; } - $prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this))); + $prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(static::class)); $filters = $this->context->cookie->getFamily($prefix.$list_id.'Filter_'); foreach ($filters as $cookie_key => $filter) { if (strncmp($cookie_key, $prefix.$list_id.'Filter_', 7 + Tools::strlen($prefix.$list_id)) == 0) { @@ -1898,10 +1898,10 @@ public function checkAccess() // ${1} in the replacement string of the regexp is required, // because the token may begin with a number and mix up with it (e.g. $17) $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$this->token.'$2', $_SERVER['REQUEST_URI']); - if (false === strpos($url, '?token=') && false === strpos($url, '&token=')) { + if (!str_contains($url, '?token=') && !str_contains($url, '&token=')) { $url .= '&token='.$this->token; } - if (strpos($url, '?') === false) { + if (!str_contains($url, '?')) { $url = str_replace('&token', '?controller=AdminDashboard&token', $url); } @@ -2135,7 +2135,7 @@ public function initHeader() $img = str_replace('png', 'gif', $img); } // tab[class_name] does not contains the "Controller" suffix - $tabs[$index]['current'] = ($tab['class_name'].'Controller' == get_class($this)) || ($current_id == $tab['id_tab']); + $tabs[$index]['current'] = ($tab['class_name'].'Controller' == static::class) || ($current_id == $tab['id_tab']); $tabs[$index]['img'] = $img; $tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']); @@ -2153,8 +2153,8 @@ public function initHeader() // class_name is the name of the class controller if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool)$sub_tab['active'] && $sub_tab['class_name'] != 'AdminCarrierWizard') { $sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']); - $sub_tabs[$index2]['current'] = ($sub_tab['class_name'].'Controller' == get_class($this) || $sub_tab['class_name'] == Tools::getValue('controller')); - } elseif ($sub_tab['class_name'] == 'AdminCarrierWizard' && $sub_tab['class_name'].'Controller' == get_class($this)) { + $sub_tabs[$index2]['current'] = ($sub_tab['class_name'].'Controller' == static::class || $sub_tab['class_name'] == Tools::getValue('controller')); + } elseif ($sub_tab['class_name'] == 'AdminCarrierWizard' && $sub_tab['class_name'].'Controller' == static::class) { foreach ($sub_tabs as $i => $tab) { if ($tab['class_name'] == 'AdminCarriers') { break; @@ -2939,7 +2939,7 @@ public function setMedia() protected function l($string, $class = null, $addslashes = false, $htmlentities = true) { if ($class === null || $class == 'AdminTab') { - $class = substr(get_class($this), 0, -10); + $class = substr(static::class, 0, -10); } elseif (strtolower(substr($class, -10)) == 'controller') { /* classname has changed, from AdminXXX to AdminXXXController, so we remove 10 characters and we keep same keys */ $class = substr($class, 0, -10); @@ -3338,7 +3338,7 @@ public function getList( if (!Validate::isTableOrIdentifier($this->table)) { throw new PrestaShopException(sprintf('Table name %s is invalid:', $this->table)); } - $prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this))); + $prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(static::class)); if (empty($order_by)) { if ($this->context->cookie->{$prefix.$this->list_id.'Orderby'}) { $order_by = $this->context->cookie->{$prefix.$this->list_id.'Orderby'}; @@ -3856,7 +3856,7 @@ protected function copyFromPost(&$object, $table) } /* Multilingual fields */ - $class_vars = get_class_vars(get_class($object)); + $class_vars = get_class_vars($object::class); $fields = array(); if (isset($class_vars['definition']['fields'])) { $fields = $class_vars['definition']['fields']; diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index a83afd4fc6..c1d2a5efc2 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -97,7 +97,7 @@ abstract public function viewAccess(); public function init() { if (_PS_MODE_DEV_ && $this->controller_type == 'admin') { - set_error_handler(array(__CLASS__, 'myErrorHandler')); + set_error_handler(array(self::class, 'myErrorHandler')); } if (!defined('_PS_BASE_URL_')) { @@ -159,8 +159,8 @@ public function __construct() if (!headers_sent() && isset($_SERVER['HTTP_USER_AGENT']) - && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false - || strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false)) { + && (str_contains($_SERVER['HTTP_USER_AGENT'], 'MSIE') + || str_contains($_SERVER['HTTP_USER_AGENT'], 'Trident'))) { header('X-UA-Compatible: IE=edge,chrome=1'); } } @@ -647,7 +647,7 @@ public static function myErrorHandler($errno, $errstr, $errfile, $errline) protected function ajaxDie($value = null, $controller = null, $method = null) { if ($controller === null) { - $controller = get_class($this); + $controller = static::class; } if ($method === null) { diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 5252400ca9..f813229eb0 100644 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -539,7 +539,7 @@ public function init() } foreach ($assign_array as $assign_key => $assign_value) { - if (substr($assign_value, 0, 1) == '/' || $protocol_content == 'https://') { + if (str_starts_with($assign_value, '/') || $protocol_content == 'https://') { $this->context->smarty->assign($assign_key, $protocol_content.Tools::getMediaServer($assign_value).$assign_value); } else { $this->context->smarty->assign($assign_key, $assign_value); @@ -809,7 +809,7 @@ protected function displayMaintenancePage() 'link' => $this->context->link, )); // If the controller is a module, then getTemplatePath will try to find the template in the modules, so we need to instanciate a real frontcontroller - $front_controller = preg_match('/ModuleFrontController$/', get_class($this)) ? new FrontController() : $this; + $front_controller = preg_match('/ModuleFrontController$/', static::class) ? new FrontController() : $this; $this->smartyOutputContent($front_controller->getTemplatePath($this->getThemeDir().'maintenance.tpl')); exit; } @@ -1046,7 +1046,7 @@ protected function geolocationManagement($default_country) $reader = new GeoIp2\Database\Reader(_PS_GEOIP_DIR_ . _PS_GEOIP_CITY_FILE_); try { $record = $reader->city(Tools::getRemoteAddr()); - } catch (GeoIp2\Exception\AddressNotFoundException $e) { + } catch (GeoIp2\Exception\AddressNotFoundException) { $record = null; } @@ -1505,7 +1505,7 @@ public function addMedia($media_uri, $css_media_type = null, $offset = null, $re $type = 'js'; $file = $media; } - if (strpos($file, __PS_BASE_URI__.'modules/') === 0) { + if (str_starts_with($file, __PS_BASE_URI__.'modules/')) { $override_path = str_replace(__PS_BASE_URI__.'modules/', _PS_ROOT_DIR_.'/themes/'._THEME_NAME_.'/'.$type.'/modules/', $file, $different); if (strrpos($override_path, $type.'/'.basename($file)) !== false) { $override_path_css = str_replace($type.'/'.basename($file), basename($file), $override_path, $different_css); @@ -1739,7 +1739,7 @@ public function getTemplatePath($template) } $tpl_file = basename($template); - $dirname = dirname($template).(substr(dirname($template), -1, 1) == '/' ? '' : '/'); + $dirname = dirname($template).(str_ends_with(dirname($template), '/') ? '' : '/'); if ($dirname == _PS_THEME_DIR_) { if (file_exists(_PS_THEME_MOBILE_DIR_.$tpl_file)) { diff --git a/classes/controller/ModuleAdminController.php b/classes/controller/ModuleAdminController.php index 2eeb15b1bd..9f801639f3 100644 --- a/classes/controller/ModuleAdminController.php +++ b/classes/controller/ModuleAdminController.php @@ -43,7 +43,7 @@ public function __construct() $tab = new Tab($this->id); if (!$tab->module) { - throw new PrestaShopException('Admin tab '.get_class($this).' is not a module tab'); + throw new PrestaShopException('Admin tab '.static::class.' is not a module tab'); } $this->module = Module::getInstanceByName($tab->module); diff --git a/classes/db/DbMySQLi.php b/classes/db/DbMySQLi.php index c10e8391f5..60d7518058 100644 --- a/classes/db/DbMySQLi.php +++ b/classes/db/DbMySQLi.php @@ -91,7 +91,7 @@ public function connect() */ public static function createDatabase($host, $user = null, $password = null, $database = null, $dropit = false) { - if (strpos($host, ':') !== false) { + if (str_contains($host, ':')) { list($host, $port) = explode(':', $host); $link = @new mysqli($host, $user, $password, null, $port); } else { diff --git a/classes/db/DbPDO.php b/classes/db/DbPDO.php index 3be1c4326d..a12632481c 100644 --- a/classes/db/DbPDO.php +++ b/classes/db/DbPDO.php @@ -60,8 +60,13 @@ protected static function _getPDO($host, $user, $password, $dbname, $timeout = 5 } else { $dsn .= 'host='.$host; } - - return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true)); + if(class_exists(\Pdo\Mysql::class)){ + $bufferedQueryAttr = \Pdo\Mysql::ATTR_USE_BUFFERED_QUERY; + }else{ + $bufferedQueryAttr = PDO::MYSQL_ATTR_USE_BUFFERED_QUERY; + } + + return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, $bufferedQueryAttr => true)); } /** @@ -82,7 +87,7 @@ public static function createDatabase($host, $user, $password, $dbname, $dropit if ($dropit && ($link->exec('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`') !== false)) { return true; } - } catch (PDOException $e) { + } catch (PDOException) { return false; } return $success; @@ -290,7 +295,7 @@ public static function hasTableWithSamePrefix($server, $user, $pwd, $db, $prefix { try { $link = DbPDO::_getPDO($server, $user, $pwd, $db, 5); - } catch (PDOException $e) { + } catch (PDOException) { return false; } @@ -314,7 +319,7 @@ public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, { try { $link = DbPDO::_getPDO($server, $user, $pwd, $db, 5); - } catch (PDOException $e) { + } catch (PDOException) { return false; } @@ -407,7 +412,7 @@ public static function tryUTF8($server, $user, $pwd) { try { $link = DbPDO::_getPDO($server, $user, $pwd, false, 5); - } catch (PDOException $e) { + } catch (PDOException) { return false; } $result = $link->exec('SET NAMES \'utf8\''); @@ -428,7 +433,7 @@ public static function checkAutoIncrement($server, $user, $pwd) { try { $link = DbPDO::_getPDO($server, $user, $pwd, false, 5); - } catch (PDOException $e) { + } catch (PDOException) { return false; } $ret = (bool)(($result = $link->query('SELECT @@auto_increment_increment as aii')) && ($row = $result->fetch()) && $row['aii'] == 1); diff --git a/classes/db/DbQuery.php b/classes/db/DbQuery.php index 5b193cb1e4..7c050de5f6 100644 --- a/classes/db/DbQuery.php +++ b/classes/db/DbQuery.php @@ -29,7 +29,7 @@ * * @since 1.5.0.1 */ -class DbQueryCore +class DbQueryCore implements \Stringable { /** * List of data to build the query @@ -329,7 +329,7 @@ public function build() * * @return string */ - public function __toString() + public function __toString(): string { return $this->build(); } diff --git a/classes/exception/PrestaShopDatabaseException.php b/classes/exception/PrestaShopDatabaseException.php index c647b2b43f..c6d4d0dbd3 100644 --- a/classes/exception/PrestaShopDatabaseException.php +++ b/classes/exception/PrestaShopDatabaseException.php @@ -27,10 +27,10 @@ /** * @since 1.5.0 */ -class PrestaShopDatabaseExceptionCore extends PrestaShopException +class PrestaShopDatabaseExceptionCore extends PrestaShopException implements \Stringable { - public function __toString() + public function __toString(): string { - return $this->message; + return (string) $this->message; } } diff --git a/classes/exception/PrestaShopException.php b/classes/exception/PrestaShopException.php index a57e99ad9e..a1c3f46251 100644 --- a/classes/exception/PrestaShopException.php +++ b/classes/exception/PrestaShopException.php @@ -49,7 +49,7 @@ public function displayMessage() #psException pre .selected{color: #F20000; font-weight: bold;} '; echo '
'; - echo '

['.get_class($this).']

'; + echo '

['.static::class.']

'; echo $this->getExtendedMessage(); $this->displayFileDebug($this->getFile(), $this->getLine()); @@ -162,7 +162,7 @@ protected function hideCriticalArgs(array $trace) $hiddenArgs[] = $args[$argIndex]; } } - } catch (ReflectionException $e) { + } catch (ReflectionException) { //In worst case scenario there are some critical args we could't detect so we return an empty array } diff --git a/classes/helper/Helper.php b/classes/helper/Helper.php index cf34180bac..ec9c95fa7c 100644 --- a/classes/helper/Helper.php +++ b/classes/helper/Helper.php @@ -307,12 +307,12 @@ public function renderCategoryTree($root = null, protected function l($string, $class = 'AdminTab', $addslashes = false, $htmlentities = true) { // if the class is extended by a module, use modules/[module_name]/xx.php lang file - $current_class = get_class($this); + $current_class = static::class; if (Module::getModuleNameFromClass($current_class)) { return Translate::getModuleTranslation(Module::$classInModule[$current_class], $string, $current_class); } - return Translate::getAdminTranslation($string, get_class($this), $addslashes, $htmlentities); + return Translate::getAdminTranslation($string, static::class, $addslashes, $htmlentities); } /** diff --git a/classes/helper/HelperList.php b/classes/helper/HelperList.php index 5e0a4e76fa..6b3b1144d9 100644 --- a/classes/helper/HelperList.php +++ b/classes/helper/HelperList.php @@ -473,7 +473,7 @@ public function displayDetailsLink($token, $id, $name = null) $tpl->assign(array( 'id' => $id, 'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&details'.$this->table.'&token='.($token != null ? $token : $this->token), - 'controller' => str_replace('Controller', '', get_class($this->context->controller)), + 'controller' => str_replace('Controller', '', $this->context->controller::class), 'token' => $token != null ? $token : $this->token, 'action' => self::$cache_lang['Details'], 'params' => $ajax_params, diff --git a/classes/helper/HelperOptions.php b/classes/helper/HelperOptions.php index d1e846e6bb..c05349b48c 100644 --- a/classes/helper/HelperOptions.php +++ b/classes/helper/HelperOptions.php @@ -160,7 +160,7 @@ public function generateOptions($option_list) } // Fill values for all languages for all lang fields - if (substr($field['type'], -4) == 'Lang') { + if (str_ends_with($field['type'], 'Lang')) { $field['value'] = array(); $field['languages'] = array(); foreach ($languages as $language) { diff --git a/classes/module/Module.php b/classes/module/Module.php index 6b08a164ec..c79e44b642 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -1116,10 +1116,10 @@ public static function getModuleNameFromClass($current_class) $reflection_class = new ReflectionClass($current_class); $file_path = realpath($reflection_class->getFileName()); $realpath_module_dir = realpath(_PS_MODULE_DIR_); - if (substr(realpath($file_path), 0, strlen($realpath_module_dir)) == $realpath_module_dir) { + if (str_starts_with(realpath($file_path), $realpath_module_dir)) { // For controllers in module/controllers path - if (basename(dirname(dirname($file_path))) == 'controllers') { - self::$classInModule[$current_class] = basename(dirname(dirname(dirname($file_path)))); + if (basename(dirname($file_path, 2)) == 'controllers') { + self::$classInModule[$current_class] = basename(dirname($file_path, 3)); } else { // For old AdminTab controllers self::$classInModule[$current_class] = substr(dirname($file_path), strlen($realpath_module_dir) + 1); @@ -1426,11 +1426,11 @@ public static function getModulesOnDisk($use_config = false, $logged_on_addons = $file_path = _PS_MODULE_DIR_.$module.'/'.$module.'.php'; $file = trim(file_get_contents(_PS_MODULE_DIR_.$module.'/'.$module.'.php')); - if (substr($file, 0, 5) == '') { + if (str_ends_with($file, '?>')) { $file = substr($file, 0, -2); } @@ -1869,7 +1869,7 @@ final public static function isModuleTrusted($module_name, $check_api = true) if ($trusted_modules_list_content === null) { $trusted_modules_list_content = Tools::file_get_contents(_PS_ROOT_DIR_.self::CACHE_FILE_TRUSTED_MODULES_LIST); - if (strpos($trusted_modules_list_content, $context->theme->name) === false) { + if (!str_contains($trusted_modules_list_content, $context->theme->name)) { self::generateTrustedXml(); } } @@ -1888,7 +1888,7 @@ final public static function isModuleTrusted($module_name, $check_api = true) // If the module is trusted, which includes both partner modules and modules bought on Addons - if (stripos($trusted_modules_list_content, $module_name) !== false) { + if (stripos($trusted_modules_list_content, (string) $module_name) !== false) { // If the module is not a partner, then return 1 (which means the module is "trusted") if (stripos($modules_list_content, '') == false) { return 1; @@ -1898,7 +1898,7 @@ final public static function isModuleTrusted($module_name, $check_api = true) } // The module seems to be trusted, but it does not seem to be dedicated to this country return 2; - } elseif (stripos($untrusted_modules_list_content, $module_name) !== false) { + } elseif (stripos($untrusted_modules_list_content, (string) $module_name) !== false) { // If the module is already in the untrusted list, then return 0 (untrusted) return 0; } else { @@ -2024,7 +2024,7 @@ final public static function checkModuleFromAddonsApi($module_name) // 'module_key' => $obj->module_key, ); $xml = Tools::addonsRequest('check_module', $params); - return (bool)(strpos($xml, 'success') !== false); + return (bool)(str_contains($xml, 'success')); } } @@ -2977,7 +2977,7 @@ public function addOverride($classInfo) // require module controller file require_once _PS_ROOT_DIR_.'/'.$parentClassFilePath; if ($classInfo['controller_type'] == 'admin') { - $overrideClassName = $classname.((strpos($classname, 'Controller') === false) ? 'Controller' : '').'Override'; + $overrideClassName = $classname.((!str_contains($classname, 'Controller')) ? 'Controller' : '').'Override'; } else { $overrideClassName = Tools::ucfirst($classInfo['module']).Tools::ucfirst($classInfo['class']).'ModuleFrontControllerOverride'; } @@ -3178,7 +3178,7 @@ public function removeOverride($classInfo) require_once _PS_ROOT_DIR_.'/'.$parentClassFilePath; if ($classInfo['controller_type'] == 'admin') { - $overrideClassName = $classname.((strpos($classname, 'Controller') === false) ? 'Controller' : '').'Override'; + $overrideClassName = $classname.((!str_contains($classname, 'Controller')) ? 'Controller' : '').'Override'; } else { $overrideClassName = Tools::ucfirst($classInfo['module']).Tools::ucfirst($classInfo['class']).'ModuleFrontControllerOverride'; } diff --git a/classes/order/Order.php b/classes/order/Order.php index e5d501141e..9a7a316987 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -1362,7 +1362,7 @@ public function setInvoice($use_existing_payment = false) Order::setInvoiceDetails($order_invoice); if (Configuration::get('PS_INVOICE')) { - $this->setLastInvoiceNumber($order_invoice->id, $this->id_shop); + static::setLastInvoiceNumber($order_invoice->id, $this->id_shop); } // Update order_carrier @@ -1422,8 +1422,8 @@ public function setInvoice($use_existing_payment = false) if (Configuration::get('PS_INVOICE')) { $this->invoice_number = $this->getInvoiceNumber($order_invoice->id); $invoice_number = Hook::exec('actionSetInvoice', array( - get_class($this) => $this, - get_class($order_invoice) => $order_invoice, + static::class => $this, + $order_invoice::class => $order_invoice, 'use_existing_payment' => (bool)$use_existing_payment )); @@ -2411,10 +2411,7 @@ public function getIdOrderCarrier() public static function sortDocuments($a, $b) { - if ($a->date_add == $b->date_add) { - return 0; - } - return ($a->date_add < $b->date_add) ? -1 : 1; + return $a->date_add <=> $b->date_add; } public function getWsShippingNumber() diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 9d097b5d4f..1bb32d9d7b 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -1174,7 +1174,7 @@ public function getOrderPaymentDetail() public function getInvoiceNumberFormatted($id_lang, $id_shop = null) { $invoice_formatted_number = Hook::exec('actionInvoiceNumberFormatted', array( - get_class($this) => $this, + static::class => $this, 'id_lang' => (int)$id_lang, 'id_shop' => (int)$id_shop, 'number' => (int)$this->number diff --git a/classes/pdf/HTMLTemplate.php b/classes/pdf/HTMLTemplate.php index a0a7bdb304..736686f053 100644 --- a/classes/pdf/HTMLTemplate.php +++ b/classes/pdf/HTMLTemplate.php @@ -155,7 +155,7 @@ public function assignCommonHeaderData() */ public function assignHookData($object) { - $template = ucfirst(str_replace('HTMLTemplate', '', get_class($this))); + $template = ucfirst(str_replace('HTMLTemplate', '', static::class)); $hook_name = 'displayPDF'.$template; $this->smarty->assign(array( diff --git a/classes/pdf/PDFGenerator.php b/classes/pdf/PDFGenerator.php index 4cd27a6bb0..6df29783ad 100644 --- a/classes/pdf/PDFGenerator.php +++ b/classes/pdf/PDFGenerator.php @@ -236,7 +236,7 @@ protected function getRandomSeed($seed = '') } $seed .= uniqid('', true); - $seed .= rand(); + $seed .= random_int(0, mt_getrandmax()); $seed .= __FILE__; $seed .= $this->bufferlen; @@ -259,7 +259,7 @@ protected function getRandomSeed($seed = '') $seed .= $_SERVER['HTTP_ACCEPT_CHARSET']; } - $seed .= rand(); + $seed .= random_int(0, mt_getrandmax()); $seed .= uniqid('', true); $seed .= microtime(); diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 1e2880583f..653a2cc422 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -414,7 +414,7 @@ public static function initialize() $url .= $default_shop->getBaseURI().'index.php?'.http_build_query($params); } else { // Catch url with subdomain "www" - if (strpos($url, 'www.') === 0 && 'www.'.$_SERVER['HTTP_HOST'] === $url || $_SERVER['HTTP_HOST'] === 'www.'.$url) { + if (str_starts_with($url, 'www.') && 'www.'.$_SERVER['HTTP_HOST'] === $url || $_SERVER['HTTP_HOST'] === 'www.'.$url) { $url .= $_SERVER['REQUEST_URI']; } else { $url .= $default_shop->getBaseURI(); @@ -1008,7 +1008,7 @@ public static function addSqlRestriction($share = false, $alias = null) public static function addSqlAssociation($table, $alias, $inner_join = true, $on = null, $force_not_default = false) { $table_alias = $table.'_shop'; - if (strpos($table, '.') !== false) { + if (str_contains($table, '.')) { list($table_alias, $table) = explode('.', $table); } diff --git a/classes/stock/SupplyOrderDetail.php b/classes/stock/SupplyOrderDetail.php index 299aeaadf9..4729cc1e83 100644 --- a/classes/stock/SupplyOrderDetail.php +++ b/classes/stock/SupplyOrderDetail.php @@ -271,17 +271,17 @@ public function validateController($htmlentities = true) /* required fields */ $fields_required = $this->fieldsRequired; - if (isset(self::$fieldsRequiredDatabase[get_class($this)])) { + if (isset(self::$fieldsRequiredDatabase[static::class])) { $fields_required = array_merge( $this->fieldsRequired, - self::$fieldsRequiredDatabase[get_class($this)] + self::$fieldsRequiredDatabase[static::class] ); } foreach ($fields_required as $field) { if (($value = $this->{$field}) == false && (string)$value != '0') { if (!$this->id || $field != 'passwd') { - $errors[] = ''.SupplyOrderDetail::displayFieldName($field, get_class($this), $htmlentities) + $errors[] = ''.SupplyOrderDetail::displayFieldName($field, static::class, $htmlentities) .' '.Tools::displayError('is required.'); } } @@ -292,7 +292,7 @@ public function validateController($htmlentities = true) if ($value = $this->{$field} && Tools::strlen($value) > $max_length) { $errors[] = sprintf( Tools::displayError('%1$s is too long. Maximum length: %2$d'), - SupplyOrderDetail::displayFieldName($field, get_class($this), $htmlentities), + SupplyOrderDetail::displayFieldName($field, static::class, $htmlentities), $max_length ); } @@ -302,7 +302,7 @@ public function validateController($htmlentities = true) foreach ($this->fieldsValidate as $field => $function) { if ($value = $this->{$field}) { if (!Validate::$function($value) && (!empty($value) || in_array($field, $this->fieldsRequired))) { - $errors[] = ''.SupplyOrderDetail::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is invalid.'); + $errors[] = ''.SupplyOrderDetail::displayFieldName($field, static::class, $htmlentities).' '.Tools::displayError('is invalid.'); } elseif ($field == 'passwd') { if ($value = Tools::getValue($field)) { $this->{$field} = Tools::encrypt($value); @@ -314,15 +314,15 @@ public function validateController($htmlentities = true) } if ($this->quantity_expected <= 0) { - $errors[] = ''.SupplyOrderDetail::displayFieldName('quantity_expected', get_class($this)).' '.Tools::displayError('is invalid.'); + $errors[] = ''.SupplyOrderDetail::displayFieldName('quantity_expected', static::class).' '.Tools::displayError('is invalid.'); } if ($this->tax_rate < 0 || $this->tax_rate > 100) { - $errors[] = ''.SupplyOrderDetail::displayFieldName('tax_rate', get_class($this)).' '.Tools::displayError('is invalid.'); + $errors[] = ''.SupplyOrderDetail::displayFieldName('tax_rate', static::class).' '.Tools::displayError('is invalid.'); } if ($this->discount_rate < 0 || $this->discount_rate > 100) { - $errors[] = ''.SupplyOrderDetail::displayFieldName('discount_rate', get_class($this)).' '.Tools::displayError('is invalid.'); + $errors[] = ''.SupplyOrderDetail::displayFieldName('discount_rate', static::class).' '.Tools::displayError('is invalid.'); } return $errors; diff --git a/classes/tree/Tree.php b/classes/tree/Tree.php index fd51343dad..87eb0f97d4 100644 --- a/classes/tree/Tree.php +++ b/classes/tree/Tree.php @@ -24,7 +24,7 @@ * International Registered Trademark & Property of PrestaShop SA */ -class TreeCore +class TreeCore implements \Stringable { const DEFAULT_TEMPLATE_DIRECTORY = 'helpers/tree'; const DEFAULT_TEMPLATE = 'tree.tpl'; @@ -62,9 +62,9 @@ public function __construct($id, $data = null) } } - public function __toString() + public function __toString(): string { - return $this->render(); + return (string) $this->render(); } public function setActions($value) @@ -281,7 +281,7 @@ public function getTemplateDirectory() public function getTemplateFile($template) { - if (preg_match_all('/[^Admin].*(?=Controller)/', get_class($this->getContext()->controller), $matches) !== false) { + if (preg_match_all('/[^Admin].*(?=Controller)/', $this->getContext()->controller::class, $matches) !== false) { $controller_name = strtolower(Tools::toUnderscoreCase($matches[0][0])); } diff --git a/classes/tree/TreeToolbar.php b/classes/tree/TreeToolbar.php index 904be15901..433187cbe6 100644 --- a/classes/tree/TreeToolbar.php +++ b/classes/tree/TreeToolbar.php @@ -35,9 +35,9 @@ class TreeToolbarCore implements ITreeToolbarCore private $_template; private $_template_directory; - public function __toString() + public function __toString(): string { - return $this->render(); + return (string) $this->render(); } public function setActions($actions) @@ -123,7 +123,7 @@ public function getTemplateDirectory() public function getTemplateFile($template) { - if (preg_match_all('/((?:^|[A-Z])[a-z]+)/', get_class($this->getContext()->controller), $matches) !== false) { + if (preg_match_all('/((?:^|[A-Z])[a-z]+)/', $this->getContext()->controller::class, $matches) !== false) { $controllerName = strtolower($matches[0][1]); } diff --git a/classes/tree/TreeToolbarButton.php b/classes/tree/TreeToolbarButton.php index 097600ab49..770752f7b9 100644 --- a/classes/tree/TreeToolbarButton.php +++ b/classes/tree/TreeToolbarButton.php @@ -24,7 +24,7 @@ * International Registered Trademark & Property of PrestaShop SA */ -abstract class TreeToolbarButtonCore +abstract class TreeToolbarButtonCore implements \Stringable { const DEFAULT_TEMPLATE_DIRECTORY = 'helpers/tree'; @@ -45,9 +45,9 @@ public function __construct($label, $id = null, $name = null, $class = null) $this->setClass($class); } - public function __toString() + public function __toString(): string { - return $this->render(); + return (string) $this->render(); } public function setAttribute($name, $value) @@ -167,7 +167,7 @@ public function getTemplateDirectory() public function getTemplateFile($template) { - if (preg_match_all('/((?:^|[A-Z])[a-z]+)/', get_class($this->getContext()->controller), $matches) !== false) { + if (preg_match_all('/((?:^|[A-Z])[a-z]+)/', $this->getContext()->controller::class, $matches) !== false) { $controllerName = strtolower($matches[0][1]); } diff --git a/classes/webservice/WebserviceOutputBuilder.php b/classes/webservice/WebserviceOutputBuilder.php index 12b29b698f..8205955bea 100644 --- a/classes/webservice/WebserviceOutputBuilder.php +++ b/classes/webservice/WebserviceOutputBuilder.php @@ -360,7 +360,7 @@ public function getContent($objects, $schema_to_display = null, $fields_to_displ $type_of_view = self::VIEW_DETAILS; } - $class = get_class($objects['empty']); + $class = $objects['empty']::class; if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class])) { WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $objects['empty']->getWebserviceParameters(); } @@ -411,7 +411,7 @@ public function getContent($objects, $schema_to_display = null, $fields_to_displ */ public function renderEntityMinimum($object, $depth) { - $class = get_class($object); + $class = $object::class; if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class])) { WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $object->getWebserviceParameters(); } @@ -455,7 +455,7 @@ public function renderEntity($object, $depth) { $output = ''; - $class = get_class($object); + $class = $object::class; if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class])) { WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $object->getWebserviceParameters(); } @@ -551,7 +551,7 @@ protected function renderField($object, $ws_params, $field_name, $field, $depth) $field = $this->overrideSpecificField($ws_params['objectsNodeName'], $field_name, $field, $object, $ws_params); // don't display informations for a not existant id - if (substr($field['sqlId'], 0, 3) == 'id_' && !$field['value']) { + if (str_starts_with($field['sqlId'], 'id_') && !$field['value']) { if ($field['value'] === null) { $field['value'] = ''; } diff --git a/classes/webservice/WebserviceRequest.php b/classes/webservice/WebserviceRequest.php index ff62a66e53..08d1ad7b36 100644 --- a/classes/webservice/WebserviceRequest.php +++ b/classes/webservice/WebserviceRequest.php @@ -242,7 +242,7 @@ protected function getOutputObject($type) $this->outputFormat = $type; switch ($type) { case 'JSON' : - require_once dirname(__FILE__).'/WebserviceOutputJSON.php'; + require_once __DIR__.'/WebserviceOutputJSON.php'; $obj_render = new WebserviceOutputJSON(); break; case 'XML' : @@ -942,14 +942,14 @@ protected function parseDisplayFields($str) } $fields = array(); foreach ($part as $str) { - $field_name = trim(substr($str, 0, (strpos($str, '[') === false ? strlen($str) : strpos($str, '[')))); + $field_name = trim(substr($str, 0, (!str_contains($str, '[') ? strlen($str) : strpos($str, '[')))); if (!isset($fields[$field_name])) { $fields[$field_name] = null; } - if (strpos($str, '[') !== false) { + if (str_contains($str, '[')) { $sub_fields = substr($str, strpos($str, '[') + 1, strlen($str) - strpos($str, '[') - 2); $tmp_array = array(); - if (strpos($sub_fields, ',') !== false) { + if (str_contains($sub_fields, ',')) { $tmp_array = explode(',', $sub_fields); } else { $tmp_array = array($sub_fields); @@ -1614,18 +1614,18 @@ public function filterLanguage() $arr_languages[] = (int)$this->urlFragments['language']; } // if a range or a list is asked - elseif (strpos($this->urlFragments['language'], '[') === 0 + elseif (str_starts_with($this->urlFragments['language'], '[') && strpos($this->urlFragments['language'], ']') === $length_values - 1) { - if (strpos($this->urlFragments['language'], '|') !== false - xor strpos($this->urlFragments['language'], ',') !== false) { + if (str_contains($this->urlFragments['language'], '|') + xor str_contains($this->urlFragments['language'], ',')) { $params_values = str_replace(array(']', '['), '', $this->urlFragments['language']); // it's a list - if (strpos($params_values, '|') !== false) { + if (str_contains($params_values, '|')) { $list_enabled_lang = explode('|', $params_values); $arr_languages = $list_enabled_lang; } // it's a range - elseif (strpos($params_values, ',') !== false) { + elseif (str_contains($params_values, ',')) { $range_enabled_lang = explode(',', $params_values); if (count($range_enabled_lang) != 2) { $this->setError(400, 'A range value for a language must contains only 2 values', 78); @@ -1773,7 +1773,7 @@ public static function getallheaders() $headers = array_merge($_ENV, $_SERVER); foreach ($headers as $key => $val) { //we need this header - if (strpos(strtolower($key), 'content-type') !== false) { + if (str_contains(strtolower($key), 'content-type')) { continue; } if (strtoupper(substr($key, 0, 5)) != 'HTTP_') { diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index 19763851a0..1f8e1cc45b 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -296,7 +296,7 @@ public function getContent() public function manage() { $this->context = Context::getContext(); - if (get_class($this->objOutput->getObjectRender()) == 'WebserviceOutputJSON') { + if ($this->objOutput->getObjectRender()::class == 'WebserviceOutputJSON') { $this->outputType = 'json'; } @@ -392,7 +392,7 @@ public function getRequestParams($head = false) return; } } else if (simplexml_load_string($inputXML)) { - if (isset($inputXML) && strncmp($inputXML, 'xml=', 4) == 0) { + if (isset($inputXML) && str_starts_with($inputXML, 'xml=')) { $inputXML = Tools::substr($inputXML, 4); } } else { @@ -585,7 +585,7 @@ public function formatServicesInRequestData($data) $formattedServices = array(); foreach ($selectedServices as $service) { - $key = isset($service['id_service']) ? $service['id_service'] : 'new_'.rand(); + $key = isset($service['id_service']) ? $service['id_service'] : 'new_'.random_int(0, mt_getrandmax()); if (isset($service['id_service'])) { $formattedServices[$key]['quantity'] = isset($service['quantity']) ? $service['quantity'] : 1; $formattedServices[$key]['id_product'] = $service['id_service']; @@ -3669,7 +3669,7 @@ private function validateBookingFilterValue($field, $raw) private function validateBookingNumericFilter($field, $operator, $value) { - $values = strpos($value, '|') !== false ? explode('|', $value) : array($value); + $values = str_contains($value, '|') ? explode('|', $value) : array($value); foreach ($values as $filterValue) { if (!Validate::isUnsignedInt($filterValue)) { $this->wsObject->setError(400, 'Invalid value for filter "'.$field.'".', 39); @@ -4000,7 +4000,7 @@ public function getBookingsList() ->overrideContent($this->output); - } catch (\Throwable $th) { + } catch (\Throwable) { $this->wsObject->setError(400, 'Invalid request data provided.', 39); } } diff --git a/classes/webservice/WebserviceSpecificManagementImages.php b/classes/webservice/WebserviceSpecificManagementImages.php index 2a1cff79ca..ee187f65d1 100644 --- a/classes/webservice/WebserviceSpecificManagementImages.php +++ b/classes/webservice/WebserviceSpecificManagementImages.php @@ -1239,7 +1239,7 @@ protected function writePostedImageOnDisk($reception_path, $dest_width = null, $ @unlink(_PS_TMP_IMG_DIR_.$tmp_name); $this->imgToDisplay = $reception_path; } elseif ($this->imageType == 'customizations') { - $filename = md5(uniqid(rand(), true)); + $filename = md5(uniqid(random_int(0, mt_getrandmax()), true)); $this->imgToDisplay = _PS_UPLOAD_DIR_.$filename; if (!($tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($file['tmp_name'], $tmp_name)) { throw new WebserviceException('An error occurred during the image upload', array(76, 400)); diff --git a/composer.json b/composer.json index db48f1054c..b868522506 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "source": "https://github.com/Qloapps/QloApps" }, "require": { - "php": ">8.0 <8.5", + "php": ">=8.3 <8.6", "ext-curl": "*", "ext-dom": "*", "ext-gd": "*", diff --git a/controllers/admin/AdminAttributesGroupsController.php b/controllers/admin/AdminAttributesGroupsController.php index 29f379e4e2..b4854db472 100644 --- a/controllers/admin/AdminAttributesGroupsController.php +++ b/controllers/admin/AdminAttributesGroupsController.php @@ -756,7 +756,7 @@ public function postProcess() $_POST['position'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); } $_POST['id_parent'] = 0; - $this->processSave($this->token); + $this->processSave(); } if (Tools::getValue('id_attribute') && Tools::isSubmit('submitAddattribute') && Tools::getValue('color') && !Tools::getValue('filename')) { diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index b72199d67d..bf24923583 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -544,7 +544,7 @@ public function ajaxProcessUpdateCustomizationFields() if (!($tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES[$field_id]['tmp_name'], $tmp_name)) { $errors[] = Tools::displayError('An error occurred during the image upload process.'); } - $file_name = md5(uniqid(rand(), true)); + $file_name = md5(uniqid(random_int(0, mt_getrandmax()), true)); if (!ImageManager::resize($tmp_name, _PS_UPLOAD_DIR_.$file_name)) { continue; } elseif (!ImageManager::resize($tmp_name, _PS_UPLOAD_DIR_.$file_name.'_small', (int)Configuration::get('PS_PRODUCT_PICTURE_WIDTH'), (int)Configuration::get('PS_PRODUCT_PICTURE_HEIGHT'))) { diff --git a/controllers/admin/AdminCmsController.php b/controllers/admin/AdminCmsController.php index 43bd164cdf..1c2678dbb4 100644 --- a/controllers/admin/AdminCmsController.php +++ b/controllers/admin/AdminCmsController.php @@ -416,7 +416,7 @@ public function getPreviewUrl(CMS $cms) 'id_employee' => (int)$this->context->employee->id ) ); - $preview_url .= (strpos($preview_url, '?') === false ? '?' : '&').$params; + $preview_url .= (!str_contains($preview_url, '?') ? '?' : '&').$params; } return $preview_url; diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index 616b4154c7..ae50c1bc1b 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -1339,7 +1339,7 @@ public function syncImap() $match_found = true; } - $new_ct = (Configuration::get('PS_SAV_IMAP_CREATE_THREADS') && !$match_found && (strpos($subject, '[no_sync]') == false)); + $new_ct = (Configuration::get('PS_SAV_IMAP_CREATE_THREADS') && !$match_found && (!str_contains($subject, '[no_sync]'))); if ($match_found || $new_ct) { if ($new_ct) { @@ -1355,7 +1355,7 @@ public function syncImap() } foreach ($contacts as $contact) { - if (strpos($overview->to, $contact['email']) !== false) { + if (str_contains($overview->to, $contact['email'])) { $id_contact = $contact['id_contact']; } } diff --git a/controllers/admin/AdminEmployeesController.php b/controllers/admin/AdminEmployeesController.php index 39cba1f8b5..3cb7d894cf 100644 --- a/controllers/admin/AdminEmployeesController.php +++ b/controllers/admin/AdminEmployeesController.php @@ -128,7 +128,7 @@ public function __construct() if (file_exists($path.$theme.DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.'schemes'.$rtl)) { foreach (scandir($path.$theme.DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.'schemes'.$rtl) as $css) { if ($css[0] != '.' && preg_match('/\.css$/', $css)) { - $name = strpos($css, 'admin-theme-') !== false ? Tools::ucfirst(preg_replace('/^admin-theme-(.*)\.css$/', '$1', $css)) : $css; + $name = str_contains($css, 'admin-theme-') ? Tools::ucfirst(preg_replace('/^admin-theme-(.*)\.css$/', '$1', $css)) : $css; $this->themes[] = array('id' => $theme.'|schemes'.$rtl.'/'.$css, 'name' => $name); } } @@ -513,12 +513,12 @@ public function processSave() // Unset set shops foreach ($_POST as $postkey => $postvalue) { - if (strstr($postkey, 'checkBoxShopAsso_'.$this->table) !== false) { + if (str_contains($postkey, 'checkBoxShopAsso_'.$this->table)) { unset($_POST[$postkey]); } } foreach ($_GET as $postkey => $postvalue) { - if (strstr($postkey, 'checkBoxShopAsso_'.$this->table) !== false) { + if (str_contains($postkey, 'checkBoxShopAsso_'.$this->table)) { unset($_GET[$postkey]); } } diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 6be582d490..d5a4ab3c91 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -448,7 +448,7 @@ public function renderForm() case 'k': $bytes *= 1024; } - if (!isset($bytes) || $bytes == '') { + if (!isset($bytes) || $bytes == 0) { $bytes = 20971520; } // 20Mb @@ -3257,10 +3257,7 @@ protected function getNbrColumn($handle, $glue) protected static function usortFiles($a, $b) { - if ($a == $b) { - return 0; - } - return ($b < $a) ? 1 : - 1; + return $a <=> $b; } protected function openCsvFile() diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php index 6300da814e..f49794e1ad 100644 --- a/controllers/admin/AdminLoginController.php +++ b/controllers/admin/AdminLoginController.php @@ -101,7 +101,7 @@ public function initContent() } if (basename(_PS_ADMIN_DIR_) == 'admin' && file_exists(_PS_ADMIN_DIR_.'/../admin/')) { - $rand = 'admin'.sprintf('%03d', rand(0, 999)).Tools::strtolower(Tools::passwdGen(6)).'/'; + $rand = 'admin'.sprintf('%03d', random_int(0, 999)).Tools::strtolower(Tools::passwdGen(6)).'/'; if (@rename(_PS_ADMIN_DIR_.'/../admin/', _PS_ADMIN_DIR_.'/../'.$rand)) { Tools::redirectAdmin('../'.$rand); } else { diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index 1ac3d18182..5485df0000 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -411,7 +411,7 @@ protected function extractArchive($file, $redirect = true) $tmp_folder = _PS_MODULE_DIR_.md5(time()); $success = false; - if (substr($file, -4) == '.zip') { + if (str_ends_with($file, '.zip')) { if (Tools::ZipExtract($file, $tmp_folder)) { $zip_folders = scandir($tmp_folder); if (Tools::ZipExtract($file, _PS_MODULE_DIR_)) { @@ -457,7 +457,7 @@ protected function extractArchive($file, $redirect = true) protected function recursiveDeleteOnDisk($dir) { - if (strpos(realpath($dir), realpath(_PS_MODULE_DIR_)) === false) { + if (!str_contains(realpath($dir), realpath(_PS_MODULE_DIR_))) { return; } if (is_dir($dir)) { @@ -608,8 +608,8 @@ public function postProcessDownload($redirect = true) } } elseif (!isset($_FILES['file']['tmp_name']) || empty($_FILES['file']['tmp_name'])) { $this->errors[] = $this->l('No file has been selected'); - } elseif (substr($_FILES['file']['name'], -4) != '.tar' && substr($_FILES['file']['name'], -4) != '.zip' - && substr($_FILES['file']['name'], -4) != '.tgz' && substr($_FILES['file']['name'], -7) != '.tar.gz') { + } elseif (!str_ends_with($_FILES['file']['name'], '.tar') && !str_ends_with($_FILES['file']['name'], '.zip') + && !str_ends_with($_FILES['file']['name'], '.tgz') && !str_ends_with($_FILES['file']['name'], '.tar.gz')) { $this->errors[] = Tools::displayError('Unknown archive type.'); } elseif (!move_uploaded_file($_FILES['file']['tmp_name'], _PS_MODULE_DIR_.$_FILES['file']['name'])) { $this->errors[] = Tools::displayError('An error occurred while copying the archive to the module directory.'); @@ -931,7 +931,7 @@ public function postProcessCallback() $echo = $module->{$method}(); // After a successful install of a single module that has a configuration method, to the configuration page - if ($key == 'install' && $echo === true && strpos(Tools::getValue('install'), '|') === false && method_exists($module, 'getContent')) { + if ($key == 'install' && $echo === true && !str_contains(Tools::getValue('install'), '|') && method_exists($module, 'getContent')) { Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&configure='.$module->name.'&conf=12'); } } @@ -1266,7 +1266,7 @@ public function isModuleFiltered($module) // Filter on module name $filter_name = Tools::getValue('filtername'); if (!empty($filter_name)) { - if (stristr($module->name, $filter_name) === false && stristr($module->displayName, $filter_name) === false && stristr($module->description, $filter_name) === false) { + if (stristr($module->name, (string) $filter_name) === false && stristr($module->displayName, (string) $filter_name) === false && stristr($module->description, (string) $filter_name) === false) { return true; } return false; @@ -1322,7 +1322,7 @@ public function isModuleFiltered($module) return true; } elseif ($show_type_modules == 'otherModules' && (in_array($module->name, $this->list_partners_modules) || in_array($module->name, $this->list_natives_modules))) { return true; - } elseif (strpos($show_type_modules, 'authorModules[') !== false) { + } elseif (str_contains($show_type_modules, 'authorModules[')) { // setting selected author in authors set $author_selected = substr(str_replace(array('authorModules[', "\'"), array('', "'"), $show_type_modules), 0, -1); $this->modules_authors[$author_selected] = 'selected'; diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 43838ccc89..0674488c9d 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -500,7 +500,7 @@ protected function _cleanMetaKeywords($keywords) protected function copyFromPost(&$object, $table) { parent::copyFromPost($object, $table); - if (get_class($object) != 'Product') { + if ($object::class != 'Product') { return; } @@ -1309,7 +1309,7 @@ public function processProductCustomization() { if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) { foreach ($_POST as $field => $value) { - if (strncmp($field, 'label_', 6) == 0 && !Validate::isLabel($value)) { + if (str_starts_with($field, 'label_') && !Validate::isLabel($value)) { $this->errors[] = Tools::displayError('The label fields defined are invalid.'); } } @@ -2536,7 +2536,7 @@ public function initContent($token = null) $this->fields_form = array(); // Check if Module - if (substr($this->tab_display, 0, 6) == 'Module') { + if (str_starts_with($this->tab_display, 'Module')) { $this->tab_display_module = strtolower(substr($this->tab_display, 6, Tools::strlen($this->tab_display) - 6)); $this->tab_display = 'Modules'; } @@ -2970,7 +2970,7 @@ public function getPreviewUrl(Product $product) if (!$product->active) { $admin_dir = dirname($_SERVER['PHP_SELF']); $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1); - $preview_url .= ((strpos($preview_url, '?') === false) ? '?' : '&').'adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id; + $preview_url .= ((!str_contains($preview_url, '?')) ? '?' : '&').'adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id; } return $preview_url; diff --git a/controllers/admin/AdminPaymentController.php b/controllers/admin/AdminPaymentController.php index 34fab2aabf..cc66457934 100644 --- a/controllers/admin/AdminPaymentController.php +++ b/controllers/admin/AdminPaymentController.php @@ -41,7 +41,7 @@ public function __construct() foreach ($modules as $module) { if ($module->tab == 'payments_gateways') { if ($module->id) { - if (!get_class($module) == 'SimpleXMLElement') { + if (!$module::class == 'SimpleXMLElement') { $module->country = array(); } $countries = DB::getInstance()->executeS(' @@ -53,7 +53,7 @@ public function __construct() $module->country[] = $country['id_country']; } - if (!get_class($module) == 'SimpleXMLElement') { + if (!$module::class == 'SimpleXMLElement') { $module->currency = array(); } $currencies = DB::getInstance()->executeS(' @@ -65,7 +65,7 @@ public function __construct() $module->currency[] = $currency['id_currency']; } - if (!get_class($module) == 'SimpleXMLElement') { + if (!$module::class == 'SimpleXMLElement') { $module->group = array(); } $groups = DB::getInstance()->executeS(' diff --git a/controllers/admin/AdminPerformanceController.php b/controllers/admin/AdminPerformanceController.php index 8748ca7af9..4c96a1ffcb 100644 --- a/controllers/admin/AdminPerformanceController.php +++ b/controllers/admin/AdminPerformanceController.php @@ -645,7 +645,7 @@ public function postProcess() } if (!empty($this->action)) { - Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this)); + Hook::exec('action'.static::class.ucfirst($this->action).'Before', array('controller' => $this)); } if (Tools::isSubmit('submitAddServer')) { if ($this->tabAccess['add'] === 1) { @@ -914,7 +914,7 @@ public function postProcess() } if ($redirectAdmin && (!isset($this->errors) || !count($this->errors))) { - Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => '')); + Hook::exec('action'.static::class.ucfirst($this->action).'After', array('controller' => $this, 'return' => '')); Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); } } diff --git a/controllers/admin/AdminPreferencesController.php b/controllers/admin/AdminPreferencesController.php index a97ec7b54c..6daff9dfb9 100644 --- a/controllers/admin/AdminPreferencesController.php +++ b/controllers/admin/AdminPreferencesController.php @@ -37,7 +37,7 @@ public function __construct() $this->table = 'configuration'; // Prevent classes which extend AdminPreferences to load useless data - if (get_class($this) == 'AdminPreferencesController') { + if (static::class == 'AdminPreferencesController') { $round_mode = array( array( 'value' => PS_ROUND_HALF_UP, diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 1664501e9b..352ffa43d6 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -589,7 +589,7 @@ public function processResetFilters($list_id = null) protected function copyFromPost(&$object, $table) { parent::copyFromPost($object, $table); - if (get_class($object) != 'Product') { + if ($object::class != 'Product') { return; } @@ -2588,7 +2588,7 @@ public function initContent($token = null) $this->fields_form = array(); // Check if Module - if (substr($this->tab_display, 0, 6) == 'Module') { + if (str_starts_with($this->tab_display, 'Module')) { $this->tab_display_module = strtolower(substr($this->tab_display, 6, Tools::strlen($this->tab_display) - 6)); $this->tab_display = 'Modules'; } @@ -3098,7 +3098,7 @@ public function getPreviewUrl(Product $product) if (!$product->active) { $admin_dir = dirname($_SERVER['PHP_SELF']); $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1); - $preview_url .= ((strpos($preview_url, '?') === false) ? '?' : '&').'adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id; + $preview_url .= ((!str_contains($preview_url, '?')) ? '?' : '&').'adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id; } return $preview_url; diff --git a/controllers/admin/AdminScenesController.php b/controllers/admin/AdminScenesController.php index ccd3f27932..5979708b66 100644 --- a/controllers/admin/AdminScenesController.php +++ b/controllers/admin/AdminScenesController.php @@ -224,7 +224,7 @@ public function initFieldsForm() $this->addJqueryPlugin('imgareaselect'); $this->addJs(_PS_JS_DIR_.'admin/scenes.js'); $image_to_map_desc .= '
'; + _THEME_SCENE_DIR_.$obj->id.'-scene_default.jpg?rand='.(int)random_int(0, mt_getrandmax()).'" />'; $image_to_map_desc .= '
'; + $image_to_map_desc .= '

'; } $img_alt_desc = ''; diff --git a/controllers/admin/AdminSearchController.php b/controllers/admin/AdminSearchController.php index ac47c445f4..483a552830 100644 --- a/controllers/admin/AdminSearchController.php +++ b/controllers/admin/AdminSearchController.php @@ -297,9 +297,9 @@ public function searchModule() $this->_list['modules'] = array(); $all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id); foreach ($all_modules as $module) { - if ((isset($module->name) && stripos($module->name, $this->query) !== false) - || (isset($module->displayName) && stripos($module->displayName, $this->query) !== false) - || (isset($module->description) && stripos($module->description, $this->query) !== false) + if ((isset($module->name) && stripos($module->name, (string) $this->query) !== false) + || (isset($module->displayName) && stripos($module->displayName, (string) $this->query) !== false) + || (isset($module->description) && stripos($module->description, (string) $this->query) !== false) ) { $module->linkto = 'index.php?tab=AdminModules&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name).'&token='.Tools::getAdminTokenLite('AdminModules'); $this->_list['modules'][] = $module; @@ -361,7 +361,7 @@ public function searchFeatures() $this->_list['features'] = array(); foreach ($_LANGADM as $key => $value) { - if (stripos($value, $this->query) !== false) { + if (stripos($value, (string) $this->query) !== false) { $value = stripslashes($value); $key = strtolower(substr($key, 0, -32)); if (in_array($key, array('AdminTab', 'index'))) { diff --git a/controllers/admin/AdminShopUrlController.php b/controllers/admin/AdminShopUrlController.php index c1a96de6d0..d74790888f 100644 --- a/controllers/admin/AdminShopUrlController.php +++ b/controllers/admin/AdminShopUrlController.php @@ -487,7 +487,7 @@ public function processUpdate() { $this->redirect_shop_url = false; $current_url = parse_url($_SERVER['REQUEST_URI']); - if (trim(dirname(dirname($current_url['path'])), '/') == trim($this->object->getBaseURI(), '/')) { + if (trim(dirname($current_url['path'], 2), '/') == trim($this->object->getBaseURI(), '/')) { $this->redirect_shop_url = true; } diff --git a/controllers/admin/AdminTaxesController.php b/controllers/admin/AdminTaxesController.php index ca2787e056..66c51e653a 100644 --- a/controllers/admin/AdminTaxesController.php +++ b/controllers/admin/AdminTaxesController.php @@ -145,7 +145,7 @@ public function displayDeleteLink($token, $id) } if (!array_key_exists('DeleteItem', self::$cache_lang)) { - self::$cache_lang['DeleteItem'] = $this->l('Delete item #', __CLASS__, true, false); + self::$cache_lang['DeleteItem'] = $this->l('Delete item #', self::class, true, false); } if (TaxRule::isTaxInUse($id)) { diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index 45ff88ae56..6243742da3 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -184,7 +184,7 @@ public function init() 'type' => 'file', 'name' => 'PS_FAVICON', 'tab' => 'icons', - 'thumb' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_FAVICON').(Tools::getValue('conf') ? sprintf('?%04d', rand(0, 9999)) : '')) + 'thumb' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_FAVICON').(Tools::getValue('conf') ? sprintf('?%04d', random_int(0, 9999)) : '')) ), 'PS_STORES_ICON' => array( 'title' => $this->l('Map icon'), @@ -1148,7 +1148,7 @@ public function processExportTheme() } foreach ($_POST as $key => $value) { - if (strncmp($key, 'modulesToExport_module', strlen('modulesToExport_module')) == 0) { + if (str_starts_with($key, 'modulesToExport_module')) { $this->to_export[] = $value; } } @@ -1470,10 +1470,10 @@ private function recurseCopy($src, $dst) mkdir($dst); } while (($file = readdir($dir)) !== false) { - if (strncmp($file, '.', 1) != 0) { + if (!str_starts_with($file, '.')) { if (is_dir($src.'/'.$file)) { self::recurseCopy($src.'/'.$file, $dst.'/'.$file); - } elseif (is_readable($src.'/'.$file) && $file != 'Thumbs.db' && $file != '.DS_Store' && substr($file, -1) != '~') { + } elseif (is_readable($src.'/'.$file) && $file != 'Thumbs.db' && $file != '.DS_Store' && !str_ends_with($file, '~')) { copy($src.'/'.$file, $dst.'/'.$file); } } @@ -1532,7 +1532,7 @@ public function processImportTheme() } } elseif (Tools::getValue('theme_archive_server') != '') { $filename = _PS_ALL_THEMES_DIR_.Tools::getValue('theme_archive_server'); - if (substr($filename, -4) != '.zip') { + if (!str_ends_with($filename, '.zip')) { $this->errors[] = $this->l('Only zip files are allowed'); } elseif (!copy($filename, $sandbox.Theme::UPLOADED_THEME_DIR_NAME.'.zip')) { $this->errors[] = $this->l('An error has occurred during the file copy.'); @@ -1831,7 +1831,7 @@ public function renderImportTheme() $theme_archive_server[] = '-'; foreach ($files as $file) { - if (is_file(_PS_ALL_THEMES_DIR_.$file) && substr(_PS_ALL_THEMES_DIR_.$file, -4) == '.zip') { + if (is_file(_PS_ALL_THEMES_DIR_.$file) && str_ends_with(_PS_ALL_THEMES_DIR_.$file, '.zip')) { $theme_archive_server[] = array( 'id' => basename(_PS_ALL_THEMES_DIR_.$file), 'name' => basename(_PS_ALL_THEMES_DIR_.$file) @@ -2538,7 +2538,7 @@ public function processThemeInstall() $this->modules_errors = array(); foreach ($shops as $id_shop) { foreach ($_POST as $key => $value) { - if (strncmp($key, 'to_install', strlen('to_install')) == 0) { + if (str_starts_with($key, 'to_install')) { $module = Module::getInstanceByName($value); if ($module) { $is_installed_success = true; @@ -2559,7 +2559,7 @@ public function processThemeInstall() unset($module_hook[$module->name]); } - } elseif (strncmp($key, 'to_enable', strlen('to_enable')) == 0) { + } elseif (str_starts_with($key, 'to_enable')) { $module = Module::getInstanceByName($value); if ($module) { $is_installed_success = true; @@ -2581,7 +2581,7 @@ public function processThemeInstall() unset($module_hook[$module->name]); } - } elseif (strncmp($key, 'to_disable', strlen('to_disable')) == 0) { + } elseif (str_starts_with($key, 'to_disable')) { $key_exploded = explode('_', $key); $id_shop_module = (int)substr($key_exploded[2], 4); diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index e56831c505..6e62f8de95 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -1021,7 +1021,7 @@ protected function findAndWriteTranslationsIntoFile($file_name, $files, $theme_n $content = file_get_contents($dir.$file); // Get file type - $type_file = substr($file, -4) == '.tpl' ? 'tpl' : 'php'; + $type_file = str_ends_with($file, '.tpl') ? 'tpl' : 'php'; // Parse this content $matches = Translate::userParseFile($content, $this->type_selected, $type_file, $module_name); @@ -1121,12 +1121,12 @@ protected function findAndFillTranslations($files, $theme_name, $module_name, $d $content = file_get_contents($file_path); // Module files can now be ignored by adding this string in a file - if (strpos($content, 'IGNORE_THIS_FILE_FOR_TRANSLATION') !== false) { + if (str_contains($content, 'IGNORE_THIS_FILE_FOR_TRANSLATION')) { continue; } // Get file type - $type_file = substr($file, -4) == '.tpl' ? 'tpl' : 'php'; + $type_file = str_ends_with($file, '.tpl') ? 'tpl' : 'php'; // Parse this content $matches = Translate::userParseFile($content, $this->type_selected, $type_file, $module_name); @@ -1675,7 +1675,7 @@ public function fileExists() $dir = $this->translations_informations[$this->type_selected]['dir']; $file = $this->translations_informations[$this->type_selected]['file']; - $$var = array(); + ${$var} = array(); if (!Tools::file_exists_cache($dir)) { if (!mkdir($dir, 0700)) { throw new PrestaShopException('Directory '.$dir.' cannot be created.'); @@ -1690,7 +1690,7 @@ public function fileExists() $this->displayWarning(Tools::displayError('This file must be writable:').' '.$dir.'/'.$file); } include($dir.DIRECTORY_SEPARATOR.$file); - return $$var; + return ${$var}; } public function displayToggleButton($closed = false) @@ -1829,9 +1829,9 @@ public function initFormBack() if (preg_match('/^(.*)\.php$/', $file) && Tools::file_exists_cache($file_path = $dir.$file) && !in_array($file, Translate::$ignore_folder)) { $prefix_key = basename($file); // -4 becomes -14 to remove the ending "Controller.php" from the filename - if (strpos($file, 'Controller.php') !== false) { + if (str_contains($file, 'Controller.php')) { $prefix_key = basename(substr($file, 0, -14)); - } elseif (strpos($file, 'Helper') !== false) { + } elseif (str_contains($file, 'Helper')) { $prefix_key = 'Helper'; } @@ -2649,7 +2649,7 @@ public function copyMailFilesForAllLanguages() if (!in_array($file, Translate::$ignore_folder)) { $files_to_copy_iso[] = array( "from" => $dir.$file, - "to" => str_replace((strpos($dir, _PS_CORE_DIR_) !== false) ? _PS_CORE_DIR_ : _PS_ROOT_DIR_, _PS_ROOT_DIR_.'/themes/'.$current_theme, $dir).$file + "to" => str_replace((str_contains($dir, _PS_CORE_DIR_)) ? _PS_CORE_DIR_ : _PS_ROOT_DIR_, _PS_ROOT_DIR_.'/themes/'.$current_theme, $dir).$file ); } } @@ -3061,7 +3061,7 @@ protected function theme_exists($theme) public static function getEmailHTML($email) { - if (defined('_PS_HOST_MODE_') && strpos($email, _PS_MAIL_DIR_) !== false) { + if (defined('_PS_HOST_MODE_') && str_contains($email, _PS_MAIL_DIR_)) { $email_file = $email; } elseif (__PS_BASE_URI__ != '/') { $email_file = str_replace(__PS_BASE_URI__, '', _PS_ROOT_DIR_.'/').$email; @@ -3072,7 +3072,7 @@ public static function getEmailHTML($email) $sanitizedFilePath = realpath($email_file); $permittedMailDir = realpath(_PS_MAIL_DIR_) . DIRECTORY_SEPARATOR; - if ($sanitizedFilePath === false || $permittedMailDir === false || strpos($sanitizedFilePath, $permittedMailDir) !== 0) { + if ($sanitizedFilePath === false || $permittedMailDir === false || !str_starts_with($sanitizedFilePath, $permittedMailDir)) { return false; } diff --git a/controllers/admin/AdminWebserviceController.php b/controllers/admin/AdminWebserviceController.php index 08f86468d3..dd33aabec0 100644 --- a/controllers/admin/AdminWebserviceController.php +++ b/controllers/admin/AdminWebserviceController.php @@ -275,7 +275,7 @@ protected function afterUpdate($object) public function checkForWarning() { - if (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) { + if (!str_contains($_SERVER['SERVER_SOFTWARE'], 'Apache')) { $this->warnings[] = $this->l('To avoid operating problems, please use an Apache server.'); if (function_exists('apache_get_modules')) { $apache_modules = apache_get_modules(); diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 91b583007a..fc329625cb 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -113,7 +113,7 @@ public function initContent() $key = Tools::safeOutput(Tools::getValue('key')); if (!empty($key)) { - $back .= (strpos($back, '?') !== false ? '&' : '?').'key='.$key; + $back .= (str_contains($back, '?') ? '&' : '?').'key='.$key; } // sanitize backurl for XSS protection @@ -514,8 +514,8 @@ protected function processSubmitAccount() $post_back = $_POST; // Preparing addresses foreach ($addresses_types as $addresses_type) { - $$addresses_type = new Address(); - $$addresses_type->id_customer = 1; + ${$addresses_type} = new Address(); + ${$addresses_type}->id_customer = 1; if ($addresses_type == 'address_invoice') { foreach ($_POST as $key => &$post) { @@ -525,12 +525,12 @@ protected function processSubmitAccount() } } - $this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController())); + $this->errors = array_unique(array_merge($this->errors, ${$addresses_type}->validateController())); if ($addresses_type == 'address_invoice') { $_POST = $post_back; } - if (!($country = new Country($$addresses_type->id_country)) || !Validate::isLoadedObject($country)) { + if (!($country = new Country(${$addresses_type}->id_country)) || !Validate::isLoadedObject($country)) { $this->errors[] = Tools::displayError('Country cannot be loaded with address->id_country'); } @@ -538,7 +538,7 @@ protected function processSubmitAccount() $this->errors[] = Tools::displayError('This country is not active.'); } - $postcode = $$addresses_type->postcode; + $postcode = ${$addresses_type}->postcode; /* Check zip code format */ if ($country->zip_code_format && !$country->checkZipCode($postcode)) { $this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))); @@ -550,21 +550,21 @@ protected function processSubmitAccount() if ($country->need_identification_number) { if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE')) { - $$addresses_type->dni = null; + ${$addresses_type}->dni = null; } elseif (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))) { $this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.'); } } elseif (!$country->need_identification_number) { - $$addresses_type->dni = null; + ${$addresses_type}->dni = null; } if (Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) { - if (!($country = new Country($$addresses_type->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country)) { + if (!($country = new Country(${$addresses_type}->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country)) { $this->errors[] = Tools::displayError('Country is invalid'); } } $contains_state = isset($country) && is_object($country) ? (int)$country->contains_states: 0; - $id_state = isset($$addresses_type) && is_object($$addresses_type) ? (int)$$addresses_type->id_state: 0; + $id_state = isset(${$addresses_type}) && is_object(${$addresses_type}) ? (int)${$addresses_type}->id_state: 0; if ((Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount')) && $contains_state && !$id_state) { $this->errors[] = Tools::displayError('This country requires you to choose a State.'); } @@ -613,7 +613,7 @@ protected function processSubmitAccount() $_POST['phone'] = $phoneAddress; foreach ($addresses_types as $addresses_type) { - $$addresses_type->id_customer = (int)$customer->id; + ${$addresses_type}->id_customer = (int)$customer->id; if ($addresses_type == 'address_invoice') { foreach ($_POST as $key => &$post) { if ($tmp = Tools::getValue($key.'_invoice')) { @@ -622,11 +622,11 @@ protected function processSubmitAccount() } } - $this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController())); + $this->errors = array_unique(array_merge($this->errors, ${$addresses_type}->validateController())); if ($addresses_type == 'address_invoice') { $_POST = $post_back; } - if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$$addresses_type->save()) { + if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !${$addresses_type}->save()) { $this->errors[] = Tools::displayError('An error occurred while creating your address.'); } } diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index ef4f509f75..226ccf52b8 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -1330,7 +1330,7 @@ protected function pictureUpload() $indexes = array_flip($authorized_file_fields); foreach ($_FILES as $field_name => $file) { if (in_array($field_name, $authorized_file_fields) && isset($file['tmp_name']) && !empty($file['tmp_name'])) { - $file_name = md5(uniqid(rand(), true)); + $file_name = md5(uniqid(random_int(0, mt_getrandmax()), true)); if ($error = ImageManager::validateUpload($file, (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE'))) { $this->errors[] = $error; } @@ -1390,7 +1390,7 @@ protected function formTargetFormat() { $customization_form_target = Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])); foreach ($_GET as $field => $value) { - if (strncmp($field, 'group_', 6) == 0) { + if (str_starts_with($field, 'group_')) { $customization_form_target = preg_replace('/&group_([[:digit:]]+)=([[:digit:]]+)/', '', $customization_form_target); } } diff --git a/controllers/front/SearchController.php b/controllers/front/SearchController.php index ebe5d78a58..5340959c1e 100644 --- a/controllers/front/SearchController.php +++ b/controllers/front/SearchController.php @@ -99,7 +99,7 @@ public function initContent() $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay); if (is_array($search['result'])) { foreach ($search['result'] as &$product) { - $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&').'search_query='.urlencode($query).'&results='.(int)$search['total']; + $product['link'] .= (!str_contains($product['link'], '?') ? '?' : '&').'search_query='.urlencode($query).'&results='.(int)$search['total']; } } diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 71a0be7ca4..52ad113665 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -534,7 +534,7 @@ public function hookTop($params) 'warning_num' => $warning_num, 'module_dir' => _MODULE_DIR_, 'current_page' => $current_page, - 'order_page' => (strpos($_SERVER['PHP_SELF'], 'order') !== false), + 'order_page' => (str_contains($_SERVER['PHP_SELF'], 'order')), 'blockcart_top' => (isset($params['blockcart_top']) && $params['blockcart_top']) ? true : false, )); $res = $this->getContentVars($params); diff --git a/modules/dashactivity/dashactivity.php b/modules/dashactivity/dashactivity.php index f9a36d348d..d9a375bc87 100644 --- a/modules/dashactivity/dashactivity.php +++ b/modules/dashactivity/dashactivity.php @@ -70,7 +70,7 @@ public function install() public function hookActionAdminControllerSetMedia() { - if (get_class($this->context->controller) == 'AdminDashboardController') { + if ($this->context->controller::class == 'AdminDashboardController') { if (method_exists($this->context->controller, 'addJquery')) { $this->context->controller->addJquery(); } @@ -113,21 +113,21 @@ public function hookDashboardData($params) if (Configuration::get('PS_DASHBOARD_SIMULATION')) { $days = (strtotime($params['date_to']) - strtotime($params['date_from'])) / 3600 / 24; - $online_visitor = rand(10, 50); - $visits = rand(200, 2000) * $days; + $online_visitor = random_int(10, 50); + $visits = random_int(200, 2000) * $days; return array( 'data_value' => array( - 'pending_orders' => round(rand(0, 5)), - 'return_exchanges' => round(rand(0, 5)), - 'abandoned_cart' => round(rand(5, 50)), - 'products_out_of_stock' => round(rand(1, 10)), - 'new_messages' => round(rand(1, 10) * $days), - 'new_customers' => round(rand(1, 5) * $days), + 'pending_orders' => round(random_int(0, 5)), + 'return_exchanges' => round(random_int(0, 5)), + 'abandoned_cart' => round(random_int(5, 50)), + 'products_out_of_stock' => round(random_int(1, 10)), + 'new_messages' => round(random_int(1, 10) * $days), + 'new_customers' => round(random_int(1, 5) * $days), 'online_visitor' => round($online_visitor), 'active_shopping_cart' => round($online_visitor / 10), - 'new_registrations' => round(rand(1, 5) * $days), - 'total_suscribers' => round(rand(200, 2000)), + 'new_registrations' => round(random_int(1, 5) * $days), + 'total_suscribers' => round(random_int(200, 2000)), 'visits' => round($visits), 'unique_visitors' => round($visits * 0.6), ), diff --git a/modules/dashavailability/dashavailability.php b/modules/dashavailability/dashavailability.php index 66965f2339..dce60962fa 100644 --- a/modules/dashavailability/dashavailability.php +++ b/modules/dashavailability/dashavailability.php @@ -54,7 +54,7 @@ public function install() public function hookActionAdminControllerSetMedia() { - if (get_class($this->context->controller) == 'AdminDashboardController') { + if ($this->context->controller::class == 'AdminDashboardController') { Media::addJsDef(array( 'avail_rooms_txt' => $this->l('Available Rooms'), )); @@ -95,7 +95,7 @@ public function hookDashboardData($params) $to = strtotime($dateFrom.'+'.$days.' days 23:59:59'); $data = array(); for ($date = $from; $date <= $to; $date = strtotime('+1 days', $date)) { - $availability_data['values'][] = array($date, round(rand(0, 20))); + $availability_data['values'][] = array($date, round(random_int(0, 20))); } } else { $availability_data = AdminStatsController::getAvailabilityLineChartData($days, $dateFrom, $params['id_hotel']); diff --git a/modules/dashgoals/dashgoals.php b/modules/dashgoals/dashgoals.php index 16bc46c17f..3dbe366046 100644 --- a/modules/dashgoals/dashgoals.php +++ b/modules/dashgoals/dashgoals.php @@ -123,7 +123,7 @@ public function uninstall() public function hookActionAdminControllerSetMedia() { - if (get_class($this->context->controller) == 'AdminDashboardController') { + if ($this->context->controller::class == 'AdminDashboardController') { Media::addJsDef(array( 'goal_set_txt' => $this->l('Goal Set'), 'goal_diff_txt' => $this->l('Goal Difference'), @@ -234,9 +234,9 @@ public function getChartData($year) $from = strtotime(date('Y-01-01 00:00:00')); $to = strtotime(date('Y-12-31 00:00:00')); for ($date = $from; $date <= $to; $date = strtotime('+1 day', $date)) { - $visits[$date] = round(rand(2000, 5000)); - $orders[$date] = round(rand(40, 100)); - $sales[$date] = round(rand(3000, 9000), 2); + $visits[$date] = round(random_int(2000, 5000)); + $orders[$date] = round(random_int(40, 100)); + $sales[$date] = round(random_int(3000, 9000), 2); } // Now we can calculate the value for every months diff --git a/modules/dashguestcycle/dashguestcycle.php b/modules/dashguestcycle/dashguestcycle.php index 6aae1cb46a..8906d1960b 100644 --- a/modules/dashguestcycle/dashguestcycle.php +++ b/modules/dashguestcycle/dashguestcycle.php @@ -133,16 +133,16 @@ private function getKpiValues($idHotel) $dateToday = date('Y-m-d'); if (Configuration::get('PS_DASHBOARD_SIMULATION')) { - $totalArrivals = rand(100, 1000); - $arrived = rand(0, $totalArrivals); - $totalDepartures = rand(100, 1000); - $departed = rand(0, $totalDepartures); - $newBookings = rand(10, 500); - $occupied = rand(10, 500); - $newMessages = rand(0, 20); - $cancelledBookings = rand(0, 20); - $totalAdults = rand(100, 1000); - $children = rand(0, $totalAdults); + $totalArrivals = random_int(100, 1000); + $arrived = random_int(0, $totalArrivals); + $totalDepartures = random_int(100, 1000); + $departed = random_int(0, $totalDepartures); + $newBookings = random_int(10, 500); + $occupied = random_int(10, 500); + $newMessages = random_int(0, 20); + $cancelledBookings = random_int(0, 20); + $totalAdults = random_int(100, 1000); + $children = random_int(0, $totalAdults); } else { $arrivalsData = AdminStatsController::getArrivalsByDate($dateToday, $idHotel); $departuresData = AdminStatsController::getDeparturesByDate($dateToday, $idHotel); diff --git a/modules/dashinsights/dashinsights.php b/modules/dashinsights/dashinsights.php index 0b0676a5cf..bd18ce7ee2 100644 --- a/modules/dashinsights/dashinsights.php +++ b/modules/dashinsights/dashinsights.php @@ -171,7 +171,7 @@ public function getRoomNightsData($dateFrom, $dateTo, $idHotel) ); foreach ($this->discreteDates as $discreteDate) { - $allHotelSeriesInfo['data'][$discreteDate['timestamp_from']] = rand(1, 100); + $allHotelSeriesInfo['data'][$discreteDate['timestamp_from']] = random_int(1, 100); } $seriesWiseRoomNights[] = $allHotelSeriesInfo; } else { // if one of the hotels is selected @@ -182,7 +182,7 @@ public function getRoomNightsData($dateFrom, $dateTo, $idHotel) $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); $currentHotelRoomNightsData = array(); foreach ($this->discreteDates as $discreteDate) { - $currentHotelRoomNightsData[$discreteDate['timestamp_from']] = rand(1, 100); + $currentHotelRoomNightsData[$discreteDate['timestamp_from']] = random_int(1, 100); } $currentHotelSeriesInfo = array( @@ -193,7 +193,7 @@ public function getRoomNightsData($dateFrom, $dateTo, $idHotel) // average series info $averageRoomNightsData = array(); foreach ($this->discreteDates as $discreteDate) { - $averageRoomNightsData[$discreteDate['timestamp_from']] = sprintf('%0.2f', rand(1, 10000) / 100); + $averageRoomNightsData[$discreteDate['timestamp_from']] = sprintf('%0.2f', random_int(1, 10000) / 100); } $averageSeriesInfo = array( @@ -279,7 +279,7 @@ public function getDaysOfTheWeekData($dateFrom, $dateTo, $idHotel) // 1 = SUN for ($i = 1; $i <= 7; $i++) { - $allHotelSeriesInfo['data'][$i] = round(rand(0, 100)); + $allHotelSeriesInfo['data'][$i] = round(random_int(0, 100)); } $seriesWiseDaysOfTheWeek[] = $allHotelSeriesInfo; @@ -291,7 +291,7 @@ public function getDaysOfTheWeekData($dateFrom, $dateTo, $idHotel) $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); $currentHotelDaysOfTheWeekData = array(); for ($i = 1; $i <= 7; $i++) { - $currentHotelDaysOfTheWeekData[$i] = round(rand(0, 100)); + $currentHotelDaysOfTheWeekData[$i] = round(random_int(0, 100)); } $currentHotelSeriesInfo = array( @@ -302,7 +302,7 @@ public function getDaysOfTheWeekData($dateFrom, $dateTo, $idHotel) // average series info $averageDaysOfTheWeekData = array(); for ($i = 1; $i <= 7; $i++) { - $averageDaysOfTheWeekData[$i] = sprintf('%0.2f', rand(1, 10000) / 100); + $averageDaysOfTheWeekData[$i] = sprintf('%0.2f', random_int(1, 10000) / 100); } $averageSeriesInfo = array( @@ -416,13 +416,13 @@ public function getLengthOfStayData($dateFrom, $dateTo, $idHotel) ); $roomsOccupied = array( - 7 => rand(1, 100), - 6 => rand(1, 100), - 5 => rand(1, 100), - 4 => rand(1, 100), - 3 => rand(1, 100), - 2 => rand(1, 100), - 1 => rand(1, 100), + 7 => random_int(1, 100), + 6 => random_int(1, 100), + 5 => random_int(1, 100), + 4 => random_int(1, 100), + 3 => random_int(1, 100), + 2 => random_int(1, 100), + 1 => random_int(1, 100), ); $totalOccupiedRooms = array_sum($roomsOccupied); foreach ($roomsOccupied as $key => $value) { @@ -434,13 +434,13 @@ public function getLengthOfStayData($dateFrom, $dateTo, $idHotel) } else { // if one of the hotels is selected // calculation for currently selected hotel $roomsOccupied = array( - 7 => rand(1, 100), - 6 => rand(1, 100), - 5 => rand(1, 100), - 4 => rand(1, 100), - 3 => rand(1, 100), - 2 => rand(1, 100), - 1 => rand(1, 100), + 7 => random_int(1, 100), + 6 => random_int(1, 100), + 5 => random_int(1, 100), + 4 => random_int(1, 100), + 3 => random_int(1, 100), + 2 => random_int(1, 100), + 1 => random_int(1, 100), ); $totalOccupiedRooms = array_sum($roomsOccupied); @@ -458,13 +458,13 @@ public function getLengthOfStayData($dateFrom, $dateTo, $idHotel) // calculation for other hotels average series info $roomsOccupied = array( - 7 => rand(1, 100), - 6 => rand(1, 100), - 5 => rand(1, 100), - 4 => rand(1, 100), - 3 => rand(1, 100), - 2 => rand(1, 100), - 1 => rand(1, 100), + 7 => random_int(1, 100), + 6 => random_int(1, 100), + 5 => random_int(1, 100), + 4 => random_int(1, 100), + 3 => random_int(1, 100), + 2 => random_int(1, 100), + 1 => random_int(1, 100), ); $totalOccupiedRooms = array_sum($roomsOccupied); diff --git a/modules/dashoccupancy/dashoccupancy.php b/modules/dashoccupancy/dashoccupancy.php index b6e667ca20..62b537ef6e 100644 --- a/modules/dashoccupancy/dashoccupancy.php +++ b/modules/dashoccupancy/dashoccupancy.php @@ -54,7 +54,7 @@ public function install() public function hookActionAdminControllerSetMedia() { - if (get_class($this->context->controller) == 'AdminDashboardController') { + if ($this->context->controller::class == 'AdminDashboardController') { $this->context->controller->addJs($this->_path.'views/js/'.$this->name.'.js'); $this->context->controller->addCSS($this->_path.'views/css/'.$this->name.'.css'); } @@ -69,11 +69,11 @@ public function hookDashboardData($params) { if (Configuration::get('PS_DASHBOARD_SIMULATION')) { $occupancyData = array(); - $occupancyData['count_total'] = sprintf('%02d', rand(0, 1000)); + $occupancyData['count_total'] = sprintf('%02d', random_int(0, 1000)); $tmp = $occupancyData['count_total']; - $occupancyData['count_occupied'] = sprintf('%02d', round(rand(0, $occupancyData['count_total']))); + $occupancyData['count_occupied'] = sprintf('%02d', round(random_int(0, $occupancyData['count_total']))); $tmp = $tmp - $occupancyData['count_occupied']; - $occupancyData['count_available'] = sprintf('%02d', round(rand(0, $tmp))); + $occupancyData['count_available'] = sprintf('%02d', round(random_int(0, $tmp))); $tmp = $tmp - $occupancyData['count_available']; $occupancyData['count_unavailable'] = sprintf('%02d', $tmp); } else { diff --git a/modules/dashperformance/dashperformance.php b/modules/dashperformance/dashperformance.php index f01f6c277a..30252330de 100644 --- a/modules/dashperformance/dashperformance.php +++ b/modules/dashperformance/dashperformance.php @@ -54,7 +54,7 @@ public function install() public function hookActionAdminControllerSetMedia() { - if (get_class($this->context->controller) == 'AdminDashboardController') { + if ($this->context->controller::class == 'AdminDashboardController') { $this->context->controller->addCSS($this->_path.'views/css/'.$this->name.'.css'); } } @@ -68,14 +68,14 @@ public function hookDashboardData($params) { $data = array(); if (Configuration::get('PS_DASHBOARD_SIMULATION')) { - $data['dp_average_daily_rate'] = Tools::displayPrice(sprintf('%0.2f', rand(100000, 1000000) / 100)); - $data['dp_total_revenue_per_available_room'] = Tools::displayPrice(sprintf('%0.2f', rand(pow(10, 5), pow(10, 6)) / 100)); - $data['dp_average_occupancy_rate'] = sprintf('%0.2f', rand(5000, 10000) / 100).'%'; - $data['dp_revenue_per_available_room'] = Tools::displayPrice(sprintf('%0.2f', rand(pow(10, 5), pow(10, 6)) / 100)); - $data['dp_gross_operating_profit_par'] = Tools::displayPrice(sprintf('%0.2f', rand(pow(10, 6), pow(10, 7)) / 100)); - $data['dp_average_length_of_stay'] = sprintf('%0.2f', rand(1, 500) / 100); - $data['dp_direct_revenue_ratio'] = sprintf('%0.2f', rand(4000, 8000) / 100).'%'; - $data['dp_cancellation_rate'] = sprintf('%0.2f', rand(1, 1000) / 100).'%'; + $data['dp_average_daily_rate'] = Tools::displayPrice(sprintf('%0.2f', random_int(100000, 1000000) / 100)); + $data['dp_total_revenue_per_available_room'] = Tools::displayPrice(sprintf('%0.2f', random_int(pow(10, 5), pow(10, 6)) / 100)); + $data['dp_average_occupancy_rate'] = sprintf('%0.2f', random_int(5000, 10000) / 100).'%'; + $data['dp_revenue_per_available_room'] = Tools::displayPrice(sprintf('%0.2f', random_int(pow(10, 5), pow(10, 6)) / 100)); + $data['dp_gross_operating_profit_par'] = Tools::displayPrice(sprintf('%0.2f', random_int(pow(10, 6), pow(10, 7)) / 100)); + $data['dp_average_length_of_stay'] = sprintf('%0.2f', random_int(1, 500) / 100); + $data['dp_direct_revenue_ratio'] = sprintf('%0.2f', random_int(4000, 8000) / 100).'%'; + $data['dp_cancellation_rate'] = sprintf('%0.2f', random_int(1, 1000) / 100).'%'; } else { $data['dp_average_daily_rate'] = Tools::displayPrice(AdminStatsController::getAverageDailyRate( $params['date_from'], diff --git a/modules/dashtrends/dashtrends.php b/modules/dashtrends/dashtrends.php index 084e3f1198..fe670cdb9d 100644 --- a/modules/dashtrends/dashtrends.php +++ b/modules/dashtrends/dashtrends.php @@ -65,7 +65,7 @@ public function install() public function hookActionAdminControllerSetMedia() { - if (get_class($this->context->controller) == 'AdminDashboardController') { + if ($this->context->controller::class == 'AdminDashboardController') { Media::addJsDef(array( 'date_txt' => $this->l('Date'), )); @@ -101,14 +101,14 @@ protected function getData($date_from, $date_to, $id_hotel) $from = strtotime($date_from.' 00:00:00'); $to = min(time(), strtotime($date_to.' 23:59:59')); for ($date = $from; $date <= $to; $date = strtotime('+1 day', $date)) { - $tmp_data['visits'][$date] = round(rand(100, 600)); - $tmp_data['conversion_rate'][$date] = rand(80, 250) / 100; - $tmp_data['average_cart_value'][$date] = round(rand(60, 10000), 2); + $tmp_data['visits'][$date] = round(random_int(100, 600)); + $tmp_data['conversion_rate'][$date] = random_int(80, 250) / 100; + $tmp_data['average_cart_value'][$date] = round(random_int(60, 10000), 2); $tmp_data['orders'][$date] = round($tmp_data['visits'][$date] * $tmp_data['conversion_rate'][$date] / 100); $tmp_data['total_paid_tax_excl'][$date] = $tmp_data['orders'][$date] * $tmp_data['average_cart_value'][$date]; - $tmp_data['total_purchases'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(50, 70) / 100; - $tmp_data['total_expenses'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(0, 10) / 100; - $tmp_data['total_refunds'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(0, 5) / 100; + $tmp_data['total_purchases'][$date] = $tmp_data['total_paid_tax_excl'][$date] * random_int(50, 70) / 100; + $tmp_data['total_expenses'][$date] = $tmp_data['total_paid_tax_excl'][$date] * random_int(0, 10) / 100; + $tmp_data['total_refunds'][$date] = $tmp_data['total_paid_tax_excl'][$date] * random_int(0, 5) / 100; } } else { $tmp_data['visits'] = AdminStatsController::getVisits(false, $date_from, $date_to, 'day'); @@ -261,15 +261,13 @@ protected function translateCompareData($normal, $compare) $translated_array = array(); foreach ($compare as $key => $date_array) { - $normal_min = key($normal[$key]); - end($normal[$key]); // move the internal pointer to the end of the array - $normal_max = key($normal[$key]); + $normal_min = key($normal[$key]); // move the internal pointer to the end of the array + $normal_max = array_key_last($normal[$key]); reset($normal[$key]); $normal_size = $normal_max - $normal_min; - $compare_min = key($compare[$key]); - end($compare[$key]); // move the internal pointer to the end of the array - $compare_max = key($compare[$key]); + $compare_min = key($compare[$key]); // move the internal pointer to the end of the array + $compare_max = array_key_last($compare[$key]); reset($compare[$key]); $compare_size = $compare_max - $compare_min; diff --git a/modules/graphnvd3/graphnvd3.php b/modules/graphnvd3/graphnvd3.php index a98d107bd8..b4a0300b2a 100644 --- a/modules/graphnvd3/graphnvd3.php +++ b/modules/graphnvd3/graphnvd3.php @@ -76,7 +76,7 @@ public static function hookGraphEngine($params, $drawer) { static $divid = 1; - if (strpos($params['width'], '%') !== false) { + if (str_contains($params['width'], '%')) { $params['width'] = (int)preg_replace('/\s*%\s*/', '', $params['width']).'%'; } else { $params['width'] = (int)$params['width'].'px'; diff --git a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php index da9693d928..6baab65a5f 100644 --- a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php +++ b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelAri.php @@ -160,7 +160,7 @@ public function manage() } fclose($postResource); - if (isset($inputXml) && strncmp($inputXml, 'xml=', 4) == 0) { + if (isset($inputXml) && str_starts_with($inputXml, 'xml=')) { // Now $inputXml has the post request XML. $inputXml = substr($inputXml, 4); } @@ -444,7 +444,7 @@ public function manage() // We have to create the json and xml response for request by ourself. So we need to check if data to be sent in xml or json // We have no way to check the output format from parent classed. So we used below code - if (get_class($this->objOutput->getObjectRender()) == 'WebserviceOutputJSON') { + if ($this->objOutput->getObjectRender()::class == 'WebserviceOutputJSON') { $this->getResponseJson($searchAriData, $dateWiseBreakdown); } else { $this->getResponseXml($searchAriData, $dateWiseBreakdown); diff --git a/modules/pagesnotfound/pagesnotfound.php b/modules/pagesnotfound/pagesnotfound.php index fe4ae762a2..8925427fe9 100644 --- a/modules/pagesnotfound/pagesnotfound.php +++ b/modules/pagesnotfound/pagesnotfound.php @@ -192,7 +192,7 @@ public function hookTop($params) return; } - if (get_class(Context::getContext()->controller) == 'PageNotFoundController') { + if (Context::getContext()->controller::class == 'PageNotFoundController') { $http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; if (empty($http_referer) || Validate::isAbsoluteUrl($http_referer)) { Db::getInstance()->execute( @@ -221,9 +221,5 @@ private function _normalizeDirectory($directory) function pnfSort($a, $b) { - if ($a['nb'] == $b['nb']) { - return 0; - } - - return ($a['nb'] > $b['nb']) ? -1 : 1; + return $b['nb'] <=> $a['nb']; } diff --git a/modules/qlocrontaskmanager/classes/QctmCronExpressionTranslator.php b/modules/qlocrontaskmanager/classes/QctmCronExpressionTranslator.php index 68e04abf4a..aac10d1700 100644 --- a/modules/qlocrontaskmanager/classes/QctmCronExpressionTranslator.php +++ b/modules/qlocrontaskmanager/classes/QctmCronExpressionTranslator.php @@ -97,7 +97,7 @@ public function getCronExpressionTranslation($expression) ); } - if (strpos($weekday, ',') !== false && $hasFixedTime && $dayMonthWildcard) { + if (str_contains($weekday, ',') && $hasFixedTime && $dayMonthWildcard) { return vsprintf( $this->module->l('Every %1$s at %2$s'), array($this->joinNames($weekday, 'weekdayName'), $this->hourLabel($hour, $minute)) @@ -118,7 +118,7 @@ public function getCronExpressionTranslation($expression) ); } - if (strpos($day, ',') !== false && $hasFixedTime && $monthWeekdayWildcard) { + if (str_contains($day, ',') && $hasFixedTime && $monthWeekdayWildcard) { return vsprintf( $this->module->l('On the %1$s of each month at %2$s'), array($this->joinOrdinals($day), $this->hourLabel($hour, $minute)) @@ -199,7 +199,7 @@ public function getCronExpressionTranslation($expression) $this->module->l('from the %1$s to the %2$s of the month'), array($this->ordinal($dm[1]), $this->ordinal($dm[2])) ); - } elseif (strpos($day, ',') !== false) { + } elseif (str_contains($day, ',')) { $conditions[] = vsprintf($this->module->l('on the %s of the month'), array($this->joinOrdinals($day))); } elseif ($this->isNumeric($day)) { $conditions[] = vsprintf($this->module->l('on the %s of the month'), array($this->ordinal($day))); @@ -219,7 +219,7 @@ public function getCronExpressionTranslation($expression) $this->module->l('%1$s through %2$s'), array($this->monthName($mm[1]), $this->monthName($mm[2])) ); - } elseif (strpos($month, ',') !== false) { + } elseif (str_contains($month, ',')) { $monthDesc = $this->joinNames($month, 'monthName'); } else { $monthDesc = $this->monthName($month); @@ -238,7 +238,7 @@ public function getCronExpressionTranslation($expression) $this->module->l('%1$s through %2$s'), array($this->weekdayName($wm[1]), $this->weekdayName($wm[2])) ); - } elseif (strpos($weekday, ',') !== false) { + } elseif (str_contains($weekday, ',')) { $weekdayDesc = $this->joinNames($weekday, 'weekdayName'); } else { $weekdayDesc = $this->weekdayName($weekday); diff --git a/modules/qlocrontaskmanager/controllers/admin/AdminCronTaskManagerController.php b/modules/qlocrontaskmanager/controllers/admin/AdminCronTaskManagerController.php index 30b4ee5b6a..0a7a3ecd9a 100644 --- a/modules/qlocrontaskmanager/controllers/admin/AdminCronTaskManagerController.php +++ b/modules/qlocrontaskmanager/controllers/admin/AdminCronTaskManagerController.php @@ -419,7 +419,7 @@ public function getNextRun($cronExpression, $row) try { $next = \Cron\CronExpression::factory($cronExpression)->getNextRunDate(); return $next->format('Y-m-d H:i:s'); - } catch (\Exception $e) { + } catch (\Exception) { return '-'; } } diff --git a/modules/qlocrontaskmanager/qlocrontaskmanager.php b/modules/qlocrontaskmanager/qlocrontaskmanager.php index 3cc49da794..fd6de78ab4 100644 --- a/modules/qlocrontaskmanager/qlocrontaskmanager.php +++ b/modules/qlocrontaskmanager/qlocrontaskmanager.php @@ -25,7 +25,7 @@ exit; } -require_once dirname(__FILE__).'/classes/QctmRequiredClasses.php'; +require_once __DIR__.'/classes/QctmRequiredClasses.php'; class QloCronTaskManager extends Module { @@ -206,7 +206,7 @@ public function isCrontabConfigured() $output = @shell_exec('crontab -l 2>/dev/null'); - return strpos((string) $output, 'qlocrontaskmanager/cron.php') !== false; + return str_contains((string) $output, 'qlocrontaskmanager/cron.php'); } public function hookActionModuleUninstallBefore($params) diff --git a/modules/qloduitkupayment/classes/QdpDuitkuServiceRequest.php b/modules/qloduitkupayment/classes/QdpDuitkuServiceRequest.php index 4e9c94161a..19273074b1 100644 --- a/modules/qloduitkupayment/classes/QdpDuitkuServiceRequest.php +++ b/modules/qloduitkupayment/classes/QdpDuitkuServiceRequest.php @@ -58,7 +58,6 @@ public static function makeRequest($endpoint, $method, $data = []) curl_setopt_array($curl, $options); $request = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - curl_close($curl); self::logResponse($request); $response = array(); diff --git a/modules/qloduitkupayment/controllers/front/return.php b/modules/qloduitkupayment/controllers/front/return.php index 0f9fbbd2dc..f592c17d57 100644 --- a/modules/qloduitkupayment/controllers/front/return.php +++ b/modules/qloduitkupayment/controllers/front/return.php @@ -135,7 +135,7 @@ public function initContent() } $this->module->logger->log('After Cart Validation in return.', FileLogger::DEBUG); - } catch (Exception $e) { + } catch (Exception) { Tools::redirect($this->context->link->getModuleLink('qloduitkupayment', 'error') . '?validation_err=1&id=' . $response['merchantOrderId']); } } else { diff --git a/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php b/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php index cc0ee01299..3e31838728 100644 --- a/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php +++ b/modules/qlopaypalcommerce/classes/WkPaypalCommerceHelper.php @@ -60,8 +60,6 @@ public static function getAccessToken() $response = curl_exec($curl); $err = curl_error($curl); - curl_close($curl); - if ($err) { throw new PrestaShopException(sprintf('cURL Error #: %s', $err)); } else { @@ -156,7 +154,6 @@ public static function createWebhookUrl($token) $response = curl_exec($curl); $err = curl_error($curl); - curl_close($curl); if ($err) { throw new PrestaShopException(sprintf('cURL Error #: %s', $err)); @@ -215,8 +212,6 @@ public static function deleteWebhookUrl() curl_exec($curl); $err = curl_error($curl); - curl_close($curl); - if ($err) { throw new PrestaShopException(sprintf('cURL Error #: %s', $err)); } @@ -255,8 +250,6 @@ public static function validateWebhookSig($postData) $response = curl_exec($curl); $err = curl_error($curl); - curl_close($curl); - if ($err) { throw new PrestaShopException(sprintf('cURL Error #: %s', $err)); } else { diff --git a/modules/qlopaypalcommerce/controllers/front/payment.php b/modules/qlopaypalcommerce/controllers/front/payment.php index 3795a5e751..af5e1d65ba 100644 --- a/modules/qlopaypalcommerce/controllers/front/payment.php +++ b/modules/qlopaypalcommerce/controllers/front/payment.php @@ -305,7 +305,7 @@ private function getOrderDetails() ); } - $timestamp = time().rand(100, 999); + $timestamp = time().random_int(100, 999); $currency = Currency::getCurrency((int) $cart->id_currency); $discountTI = $cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS); diff --git a/modules/qlopaypalcommerce/libs/Helpers/HttpHelper.php b/modules/qlopaypalcommerce/libs/Helpers/HttpHelper.php index f3c42b7ce8..5164ea3ce1 100644 --- a/modules/qlopaypalcommerce/libs/Helpers/HttpHelper.php +++ b/modules/qlopaypalcommerce/libs/Helpers/HttpHelper.php @@ -30,10 +30,6 @@ public function __construct() { $this->_initCurl(); } - public function __destruct() { - curl_close($this->_curl); - } - private function _initCurl() { if(!function_exists('curl_version')) { trigger_error("Curl not available", E_USER_ERROR); diff --git a/modules/sekeywords/sekeywords.php b/modules/sekeywords/sekeywords.php index f003bc4900..d33f78cc8d 100644 --- a/modules/sekeywords/sekeywords.php +++ b/modules/sekeywords/sekeywords.php @@ -89,7 +89,7 @@ public function uninstall() public function hookTop($params) { - if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], Tools::getHttpHost(false, false)) == 0) { + if (!isset($_SERVER['HTTP_REFERER']) || str_starts_with($_SERVER['HTTP_REFERER'], Tools::getHttpHost(false, false))) { return; } @@ -201,7 +201,7 @@ public function getKeywords($url) foreach ($result as $row) { $host =& $row['server']; $varname =& $row['getvar']; - if (strstr($parsed_url['host'], $host)) { + if (strstr($parsed_url['host'], (string) $host)) { $k_array = array(); preg_match('/[^a-zA-Z&]?'.$varname.'=.*\&'.'/U', $parsed_url['query'], $k_array); diff --git a/tools/mobile_detect/autoload.php b/tools/mobile_detect/autoload.php index fcc99b43e5..c32a3dd609 100644 --- a/tools/mobile_detect/autoload.php +++ b/tools/mobile_detect/autoload.php @@ -2,6 +2,21 @@ // autoload.php @generated by Composer +if (PHP_VERSION_ID < 50600) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, $err); + } elseif (!headers_sent()) { + echo $err; + } + } + throw new RuntimeException($err); +} + require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInita08d71f03337ee7858b0d26c24ffd06c::getLoader(); +return ComposerAutoloaderInitda04a58985381691b6d3de9dc943eed7::getLoader(); diff --git a/tools/mobile_detect/composer/ClassLoader.php b/tools/mobile_detect/composer/ClassLoader.php index afef3fa2ad..7824d8f7ea 100644 --- a/tools/mobile_detect/composer/ClassLoader.php +++ b/tools/mobile_detect/composer/ClassLoader.php @@ -42,35 +42,37 @@ */ class ClassLoader { - /** @var ?string */ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ private $vendorDir; // PSR-4 /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixLengthsPsr4 = array(); /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixDirsPsr4 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * @var array[] - * @psalm-var array> + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> */ private $prefixesPsr0 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr0 = array(); @@ -78,8 +80,7 @@ class ClassLoader private $useIncludePath = false; /** - * @var string[] - * @psalm-var array + * @var array */ private $classMap = array(); @@ -87,29 +88,29 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var bool[] - * @psalm-var array + * @var array */ private $missingClasses = array(); - /** @var ?string */ + /** @var string|null */ private $apcuPrefix; /** - * @var self[] + * @var array */ private static $registeredLoaders = array(); /** - * @param ?string $vendorDir + * @param string|null $vendorDir */ public function __construct($vendorDir = null) { $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); } /** - * @return string[] + * @return array> */ public function getPrefixes() { @@ -121,8 +122,7 @@ public function getPrefixes() } /** - * @return array[] - * @psalm-return array> + * @return array> */ public function getPrefixesPsr4() { @@ -130,8 +130,7 @@ public function getPrefixesPsr4() } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirs() { @@ -139,8 +138,7 @@ public function getFallbackDirs() } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirsPsr4() { @@ -148,8 +146,7 @@ public function getFallbackDirsPsr4() } /** - * @return string[] Array of classname => path - * @psalm-return array + * @return array Array of classname => path */ public function getClassMap() { @@ -157,8 +154,7 @@ public function getClassMap() } /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap + * @param array $classMap Class to filename map * * @return void */ @@ -175,24 +171,25 @@ public function addClassMap(array $classMap) * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - (array) $paths + $paths ); } @@ -201,19 +198,19 @@ public function add($prefix, $paths, $prepend = false) $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; + $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - (array) $paths + $paths ); } } @@ -222,9 +219,9 @@ public function add($prefix, $paths, $prepend = false) * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -232,17 +229,18 @@ public function add($prefix, $paths, $prepend = false) */ public function addPsr4($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - (array) $paths + $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -252,18 +250,18 @@ public function addPsr4($prefix, $paths, $prepend = false) throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; + $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - (array) $paths + $paths ); } } @@ -272,8 +270,8 @@ public function addPsr4($prefix, $paths, $prepend = false) * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories * * @return void */ @@ -290,8 +288,8 @@ public function set($prefix, $paths) * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -425,7 +423,8 @@ public function unregister() public function loadClass($class) { if ($file = $this->findFile($class)) { - includeFile($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } @@ -476,9 +475,9 @@ public function findFile($class) } /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. + * Returns the currently registered loaders keyed by their corresponding vendor directories. * - * @return self[] + * @return array */ public static function getRegisteredLoaders() { @@ -555,18 +554,26 @@ private function findFileWithExtension($class, $ext) return false; } -} -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - * @private - */ -function includeFile($file) -{ - include $file; + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } } diff --git a/tools/mobile_detect/composer/InstalledVersions.php b/tools/mobile_detect/composer/InstalledVersions.php index d50e0c9fcc..2052022fd8 100644 --- a/tools/mobile_detect/composer/InstalledVersions.php +++ b/tools/mobile_detect/composer/InstalledVersions.php @@ -21,15 +21,28 @@ * See also https://getcomposer.org/doc/07-runtime.md#installed-versions * * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final */ class InstalledVersions { + /** + * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to + * @internal + */ + private static $selfDir = null; + /** * @var mixed[]|null - * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null */ private static $installed; + /** + * @var bool + */ + private static $installedIsLocalDir; + /** * @var bool|null */ @@ -37,7 +50,7 @@ class InstalledVersions /** * @var array[] - * @psalm-var array}> + * @psalm-var array}> */ private static $installedByVendor = array(); @@ -96,7 +109,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; } } @@ -117,7 +130,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) */ public static function satisfies(VersionParser $parser, $packageName, $constraint) { - $constraint = $parser->parseConstraints($constraint); + $constraint = $parser->parseConstraints((string) $constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); @@ -241,7 +254,7 @@ public static function getInstallPath($packageName) /** * @return array - * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} */ public static function getRootPackage() { @@ -255,7 +268,7 @@ public static function getRootPackage() * * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. * @return array[] - * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} */ public static function getRawData() { @@ -278,7 +291,7 @@ public static function getRawData() * Returns the raw data of all installed.php which are currently loaded for custom implementations * * @return array[] - * @psalm-return list}> + * @psalm-return list}> */ public static function getAllRawData() { @@ -301,17 +314,35 @@ public static function getAllRawData() * @param array[] $data A vendor/composer/installed.php data set * @return void * - * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data */ public static function reload($data) { self::$installed = $data; self::$installedByVendor = array(); + + // when using reload, we disable the duplicate protection to ensure that self::$installed data is + // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, + // so we have to assume it does not, and that may result in duplicate data being returned when listing + // all installed packages for example + self::$installedIsLocalDir = false; + } + + /** + * @return string + */ + private static function getSelfDir() + { + if (self::$selfDir === null) { + self::$selfDir = strtr(__DIR__, '\\', '/'); + } + + return self::$selfDir; } /** * @return array[] - * @psalm-return list}> + * @psalm-return list}> */ private static function getInstalled() { @@ -320,17 +351,27 @@ private static function getInstalled() } $installed = array(); + $copiedLocalDir = false; if (self::$canGetVendors) { + $selfDir = self::getSelfDir(); foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + $vendorDir = strtr($vendorDir, '\\', '/'); if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + self::$installedByVendor[$vendorDir] = $required; + $installed[] = $required; + if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { + self::$installed = $required; + self::$installedIsLocalDir = true; } } + if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { + $copiedLocalDir = true; + } } } @@ -338,12 +379,17 @@ private static function getInstalled() // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; } else { self::$installed = array(); } } - $installed[] = self::$installed; + + if (self::$installed !== array() && !$copiedLocalDir) { + $installed[] = self::$installed; + } return $installed; } diff --git a/tools/mobile_detect/composer/autoload_classmap.php b/tools/mobile_detect/composer/autoload_classmap.php index b26f1b13b1..5315f8d961 100644 --- a/tools/mobile_detect/composer/autoload_classmap.php +++ b/tools/mobile_detect/composer/autoload_classmap.php @@ -2,9 +2,19 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', + 'Detection\\Cache\\Cache' => $vendorDir . '/mobiledetect/mobiledetectlib/src/Cache/Cache.php', + 'Detection\\Cache\\CacheException' => $vendorDir . '/mobiledetect/mobiledetectlib/src/Cache/CacheException.php', + 'Detection\\Cache\\CacheInvalidArgumentException' => $vendorDir . '/mobiledetect/mobiledetectlib/src/Cache/CacheInvalidArgumentException.php', + 'Detection\\Exception\\MobileDetectException' => $vendorDir . '/mobiledetect/mobiledetectlib/src/Exception/MobileDetectException.php', + 'Detection\\Exception\\MobileDetectExceptionCode' => $vendorDir . '/mobiledetect/mobiledetectlib/src/Exception/MobileDetectExceptionCode.php', + 'Detection\\MobileDetect' => $vendorDir . '/mobiledetect/mobiledetectlib/src/MobileDetect.php', + 'Detection\\MobileDetectStandalone' => $vendorDir . '/mobiledetect/mobiledetectlib/src/MobileDetectStandalone.php', + 'Psr\\SimpleCache\\CacheException' => $vendorDir . '/psr/simple-cache/src/CacheException.php', + 'Psr\\SimpleCache\\CacheInterface' => $vendorDir . '/psr/simple-cache/src/CacheInterface.php', + 'Psr\\SimpleCache\\InvalidArgumentException' => $vendorDir . '/psr/simple-cache/src/InvalidArgumentException.php', ); diff --git a/tools/mobile_detect/composer/autoload_namespaces.php b/tools/mobile_detect/composer/autoload_namespaces.php index b7fc0125db..15a2ff3ad6 100644 --- a/tools/mobile_detect/composer/autoload_namespaces.php +++ b/tools/mobile_detect/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/tools/mobile_detect/composer/autoload_psr4.php b/tools/mobile_detect/composer/autoload_psr4.php index 61df9249d5..1cf71bf771 100644 --- a/tools/mobile_detect/composer/autoload_psr4.php +++ b/tools/mobile_detect/composer/autoload_psr4.php @@ -2,11 +2,10 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( 'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'), - 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), 'Detection\\' => array($vendorDir . '/mobiledetect/mobiledetectlib/src'), ); diff --git a/tools/mobile_detect/composer/autoload_real.php b/tools/mobile_detect/composer/autoload_real.php index 6f65c4edc9..becfc45aba 100644 --- a/tools/mobile_detect/composer/autoload_real.php +++ b/tools/mobile_detect/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInita08d71f03337ee7858b0d26c24ffd06c +class ComposerAutoloaderInitda04a58985381691b6d3de9dc943eed7 { private static $loader; @@ -24,31 +24,12 @@ public static function getLoader() require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInita08d71f03337ee7858b0d26c24ffd06c', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInita08d71f03337ee7858b0d26c24ffd06c', 'loadClassLoader')); - - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInita08d71f03337ee7858b0d26c24ffd06c::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + spl_autoload_register(array('ComposerAutoloaderInitda04a58985381691b6d3de9dc943eed7', 'loadClassLoader'), true, true); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); + spl_autoload_unregister(array('ComposerAutoloaderInitda04a58985381691b6d3de9dc943eed7', 'loadClassLoader')); + + require __DIR__ . '/autoload_static.php'; + call_user_func(\Composer\Autoload\ComposerStaticInitda04a58985381691b6d3de9dc943eed7::getInitializer($loader)); $loader->register(true); diff --git a/tools/mobile_detect/composer/autoload_static.php b/tools/mobile_detect/composer/autoload_static.php index 2fbe672a96..b7d883efb9 100644 --- a/tools/mobile_detect/composer/autoload_static.php +++ b/tools/mobile_detect/composer/autoload_static.php @@ -4,13 +4,12 @@ namespace Composer\Autoload; -class ComposerStaticInita08d71f03337ee7858b0d26c24ffd06c +class ComposerStaticInitda04a58985381691b6d3de9dc943eed7 { public static $prefixLengthsPsr4 = array ( 'P' => array ( 'Psr\\SimpleCache\\' => 16, - 'Psr\\Cache\\' => 10, ), 'D' => array ( @@ -23,10 +22,6 @@ class ComposerStaticInita08d71f03337ee7858b0d26c24ffd06c array ( 0 => __DIR__ . '/..' . '/psr/simple-cache/src', ), - 'Psr\\Cache\\' => - array ( - 0 => __DIR__ . '/..' . '/psr/cache/src', - ), 'Detection\\' => array ( 0 => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src', @@ -35,14 +30,24 @@ class ComposerStaticInita08d71f03337ee7858b0d26c24ffd06c public static $classMap = array ( 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'Detection\\Cache\\Cache' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/Cache/Cache.php', + 'Detection\\Cache\\CacheException' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/Cache/CacheException.php', + 'Detection\\Cache\\CacheInvalidArgumentException' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/Cache/CacheInvalidArgumentException.php', + 'Detection\\Exception\\MobileDetectException' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/Exception/MobileDetectException.php', + 'Detection\\Exception\\MobileDetectExceptionCode' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/Exception/MobileDetectExceptionCode.php', + 'Detection\\MobileDetect' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/MobileDetect.php', + 'Detection\\MobileDetectStandalone' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/src/MobileDetectStandalone.php', + 'Psr\\SimpleCache\\CacheException' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheException.php', + 'Psr\\SimpleCache\\CacheInterface' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheInterface.php', + 'Psr\\SimpleCache\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/simple-cache/src/InvalidArgumentException.php', ); public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInita08d71f03337ee7858b0d26c24ffd06c::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInita08d71f03337ee7858b0d26c24ffd06c::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInita08d71f03337ee7858b0d26c24ffd06c::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitda04a58985381691b6d3de9dc943eed7::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitda04a58985381691b6d3de9dc943eed7::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitda04a58985381691b6d3de9dc943eed7::$classMap; }, null, ClassLoader::class); } diff --git a/tools/mobile_detect/composer/installed.json b/tools/mobile_detect/composer/installed.json index 0e07c18334..4fa04ddce7 100644 --- a/tools/mobile_detect/composer/installed.json +++ b/tools/mobile_detect/composer/installed.json @@ -2,32 +2,31 @@ "packages": [ { "name": "mobiledetect/mobiledetectlib", - "version": "4.8.09", - "version_normalized": "4.8.09.0", + "version": "4.11.0", + "version_normalized": "4.11.0.0", "source": { "type": "git", "url": "https://github.com/serbanghita/Mobile-Detect.git", - "reference": "a06fe2e546a06bb8c2639d6823d5250b2efb3209" + "reference": "ab39168b7556f44c11c80be1222b44b239f5c2e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/a06fe2e546a06bb8c2639d6823d5250b2efb3209", - "reference": "a06fe2e546a06bb8c2639d6823d5250b2efb3209", + "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/ab39168b7556f44c11c80be1222b44b239f5c2e4", + "reference": "ab39168b7556f44c11c80be1222b44b239f5c2e4", "shasum": "" }, "require": { - "php": ">=8.0", - "psr/cache": "^3.0", - "psr/simple-cache": "^3" + "php": ">=8.2", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^v3.65.0", - "phpbench/phpbench": "^1.2", - "phpstan/phpstan": "^1.12.x-dev", - "phpunit/phpunit": "^9.6.18", - "squizlabs/php_codesniffer": "^3.11.1" + "friendsofphp/php-cs-fixer": "3.95.1", + "phpbench/phpbench": "1.6.1", + "phpstan/phpstan": "2.1.47", + "phpunit/phpunit": "9.6.34", + "squizlabs/php_codesniffer": "3.13.5" }, - "time": "2024-12-10T15:32:06+00:00", + "time": "2026-05-24T12:32:40+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -58,7 +57,7 @@ ], "support": { "issues": "https://github.com/serbanghita/Mobile-Detect/issues", - "source": "https://github.com/serbanghita/Mobile-Detect/tree/4.8.09" + "source": "https://github.com/serbanghita/Mobile-Detect/tree/4.11.0" }, "funding": [ { @@ -68,58 +67,6 @@ ], "install-path": "../mobiledetect/mobiledetectlib" }, - { - "name": "psr/cache", - "version": "3.0.0", - "version_normalized": "3.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "shasum": "" - }, - "require": { - "php": ">=8.0.0" - }, - "time": "2021-02-03T23:26:27+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "support": { - "source": "https://github.com/php-fig/cache/tree/3.0.0" - }, - "install-path": "../psr/cache" - }, { "name": "psr/simple-cache", "version": "3.0.0", @@ -175,6 +122,6 @@ "install-path": "../psr/simple-cache" } ], - "dev": true, + "dev": false, "dev-package-names": [] } diff --git a/tools/mobile_detect/composer/installed.php b/tools/mobile_detect/composer/installed.php index 2aabf4d82b..a5ba0775dc 100644 --- a/tools/mobile_detect/composer/installed.php +++ b/tools/mobile_detect/composer/installed.php @@ -1,49 +1,40 @@ array( + 'name' => 'qloapps/mobile-detect-vendor-scratch', 'pretty_version' => '1.0.0+no-version-set', 'version' => '1.0.0.0', + 'reference' => null, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => NULL, - 'name' => '__root__', - 'dev' => true, + 'dev' => false, ), 'versions' => array( - '__root__' => array( - 'pretty_version' => '1.0.0+no-version-set', - 'version' => '1.0.0.0', - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'reference' => NULL, - 'dev_requirement' => false, - ), 'mobiledetect/mobiledetectlib' => array( - 'pretty_version' => '4.8.09', - 'version' => '4.8.09.0', + 'pretty_version' => '4.11.0', + 'version' => '4.11.0.0', + 'reference' => 'ab39168b7556f44c11c80be1222b44b239f5c2e4', 'type' => 'library', 'install_path' => __DIR__ . '/../mobiledetect/mobiledetectlib', 'aliases' => array(), - 'reference' => 'a06fe2e546a06bb8c2639d6823d5250b2efb3209', 'dev_requirement' => false, ), - 'psr/cache' => array( + 'psr/simple-cache' => array( 'pretty_version' => '3.0.0', 'version' => '3.0.0.0', + 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', - 'install_path' => __DIR__ . '/../psr/cache', + 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), - 'reference' => 'aa5030cfa5405eccfdcb1083ce040c2cb8d253bf', 'dev_requirement' => false, ), - 'psr/simple-cache' => array( - 'pretty_version' => '3.0.0', - 'version' => '3.0.0.0', + 'qloapps/mobile-detect-vendor-scratch' => array( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => null, 'type' => 'library', - 'install_path' => __DIR__ . '/../psr/simple-cache', + 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'dev_requirement' => false, ), ), diff --git a/tools/mobile_detect/composer/platform_check.php b/tools/mobile_detect/composer/platform_check.php index adfb472fbd..d32d90c6a9 100644 --- a/tools/mobile_detect/composer/platform_check.php +++ b/tools/mobile_detect/composer/platform_check.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 80000)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 80200)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.2.0". You are running ' . PHP_VERSION . '.'; } if ($issues) { diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/CHANGELOG.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/CHANGELOG.md index 8cfc364801..2379effcbc 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/CHANGELOG.md +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/CHANGELOG.md @@ -1,5 +1,62 @@ # Change log +# 4.11.0 + +## Security +- [x] **GHSA-mgj4-qjmw-v56v** — the bundled `Detection\Cache\Cache` is now bounded (default 1000 entries, FIFO eviction). Prevents unbounded in-memory growth when one `MobileDetect` instance is reused across many distinct User-Agents in a long-running PHP runtime (RoadRunner, Laravel Octane, FrankenPHP worker mode, Swoole, ReactPHP, queue workers). **Not applicable** to classic PHP-FPM / mod_php deployments — the cache dies with the request. Custom PSR-16 adapters (Redis, APCu, Memcached, Filesystem) are out of scope; their eviction policy is the operator's responsibility. + +## Added +- [x] `Detection\Cache\Cache::__construct(int $maxEntries = Cache::DEFAULT_MAX_ENTRIES)` — tune the in-memory cap via `new MobileDetect(new Cache($n))`. +- [x] `Cache::DEFAULT_MAX_ENTRIES` constant (1000) and `Cache::getMaxEntries()` accessor. + +## Changed +- [x] `README-EXAMPLES.md` "Long-Running Processes" — worker example now uses `clear()` (was `evictExpired()`, which is a no-op against fresh entries under the default 86 400 s TTL); added explicit note framing in-memory cache bounding as a systems-level concern with the bundled cap, and pointing operators at their own adapter's eviction for custom PSR-16 backends. +- [x] `Cache::evictExpired()` docblock — clarified that it bounds by *expiration*, not by *cardinality*. Method behavior is unchanged. + +# 4.10.0 + +## Changed +- [x] `Detection\Cache\Cache` method signatures widened to be Liskov-compatible with `psr/simple-cache` v1, v2, and v3 simultaneously. Resolves [#989](https://github.com/serbanghita/Mobile-Detect/issues/989) — the class no longer fatals at load time on hosts where another package has already registered an older `CacheInterface` (common in WordPress stacks). +- [x] `composer.json`: `psr/simple-cache` constraint widened to `^1.0 || ^2.0 || ^3.0`. +- [x] **Minimum PHP version raised to 8.2** in `composer.json` (was `>=8.0`). PHP 8.0 and 8.1 are both end-of-life and had already been dropped from CI in 4.9.0 because `phpbench/phpbench: 1.6.1` requires PHP ^8.2. + +## Added +- [x] `psr16-compat` CI matrix that verifies Cache remains LSP-compatible with every supported major of `psr/simple-cache` (1.x, 2.x, 3.x). + +## BC note +- Subclasses of `Detection\Cache\Cache` that overrode `get`/`set`/`has`/`delete`/`getMultiple`/`setMultiple`/`deleteMultiple` (or protected `checkKey`) with narrowed parameter types (e.g. `function get(string $key, …)`) will fatal at class load on this version. Drop the scalar type from the override, or widen to `mixed`, to restore LSP compatibility. + +# 4.9.0 + +## Added +- [x] Lenovo: broad `Lenovo TB` prefix match for modern tablets (#1013). +- [x] Samsung: 2025 tablet models (Tab S11, S10 Lite, A11). +- [x] `MobileDetect::VERSION_TYPE_STRING` and `VERSION_TYPE_FLOAT` constants promoted to `public` (#991). + +## Changed +- [x] Consistent late static binding for subclass extensibility (#1012). +- [x] Dropped PHP 8.0 and 8.1 from the CI matrix. + +## Fixed +- [x] PHP 8.4 compatibility: explicit type hints where the engine now requires them. +- [x] `Cache::getTimestamp()` method name typo (was `getTimeStamp`) (#1007). +- [x] Version regex now accepts multi-char pre-release suffixes. +- [x] Pinned composer dependencies to exact versions. +- [x] GitHub Actions workflow actions updated to their latest versions. + +# 4.8.10 + +## Fixed +- [x] `Cache::has()` now properly checks TTL expiration before returning `true` (PSR-16 compliance fix). Previously, `has()` returned `true` for expired items. + +## Added +- [x] `Cache::evictExpired()` method to manually clean up expired cache entries. Useful for long-running processes (CLI scripts, workers, daemons) to prevent memory growth. +- [x] Expanded test coverage for `Cache` class: added 17 new tests covering all if/else branches including custom defaults, DateInterval TTL, key validation edge cases, and expiration scenarios. +- [x] `README-EXAMPLES.md` with comprehensive usage examples including long-running processes, framework integration, and debugging. + +## Changed +- [x] `Cache::has()` now deletes expired items on check (lazy cleanup, consistent with `get()` behavior). + # 4.8.09 - [x] `sha1` is now the default fn for encoding cache keys. Using `base64` [was causing problems](https://github.com/serbanghita/Mobile-Detect/issues/974#issuecomment-2531597903) in Laravel. diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/CLAUDE.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/CLAUDE.md new file mode 100644 index 0000000000..d60e859dd1 --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/CLAUDE.md @@ -0,0 +1,67 @@ +# CLAUDE.md + +Whenever you find a new rule that applies to this project, add it to this file. + +## Project + +PHP library (`Detection\MobileDetect`) for detecting mobile devices/tablets via User-Agent strings and HTTP headers. Requires PHP >= 8.0. PSR-12 code style. + +## Branch & Release + +- Active branch: `4.x` (rolling — one branch per major). Always rebase into `4.x` (not `main` or `master`). Tags follow `..`. +- On new tag: update `@version` docblock + `$VERSION` property in `src/MobileDetect.php`, and `version` in `MobileDetect.json`. + +## Commands + +```bash +# Tests +vendor/bin/phpunit -v -c tests/phpunit.xml +vendor/bin/phpunit -v -c tests/phpunit.xml --filter testMethodName + +# Lint + static analysis +vendor/bin/phpcs +vendor/bin/php-cs-fixer fix +vendor/bin/phpstan analyse --memory-limit=1G --level 3 src tests + +# Benchmark (defaults live in /phpbench.json and per-method @Revs/@Iterations) +composer bench # aggregate report +composer bench:baseline # stores tag=baseline + phpbench-baseline.xml +composer bench:compare # runs with --ref=baseline, enforces 2% @Assert +# Advisory CI: .github/workflows/4.x-bench.yml runs on every PR to 4.x, +# uploads artifacts, and posts a PR comment. Does not block merge. +``` + +## Performance reviews + +Every time you run a performance review (ad-hoc benchmarking, before a release, +after touching a hot path, or at the end of a perf-oriented PR), **append a new +dated section to `PERFORMANCE.md`** using the template block at the bottom of +that file. Do not edit prior sections — they are a historical record for +regression comparison. + +Minimum contents per section: branch/commit, PHP image, host, phpbench config, +the full aggregate table (13 subjects today), and a short notes list +interpreting what's surprising or actionable in the numbers. + +## Architecture + +``` +src/ + MobileDetect.php # Core class: regex patterns, isMobile(), isTablet(), is(), version(), magic isXXXX() via __call + MobileDetectStandalone.php # Non-Composer wrapper (loads standalone/ autoloader) + Cache/Cache.php # In-memory PSR-16 cache with TTL + Exception/ # MobileDetectException + error codes +tests/ + providers/vendors/*.php # UA fixture arrays per vendor (Apple, Samsung, etc.) + UserAgentTest.php # Data-driven tests from vendor fixtures + MobileDetectGeneralTest.php # Core logic tests + CacheTest.php, MobileDetectWithCacheTest.php, MobileDetectExceptionTest.php + Benchmark/MobileDetectBench.php # PHPBench suite (PSR-4: DetectionTests\Benchmark) +``` + +## Key Patterns + +- Detection results are cached via PSR-16 (`CacheInterface`). Default: in-memory `Cache`. Cache keys use `sha1` by default. +- `$_SERVER` HTTP headers auto-initialized unless `autoInitOfHttpHeaders` config is `false`. +- CloudFront headers (`HTTP_CLOUDFRONT_IS_MOBILE_VIEWER`, etc.) are recognized for AWS detection. +- Magic `isXXXX()` calls dispatch through `__call` -> `is()` -> `match()` against static regex arrays (`$phoneDevices`, `$tabletDevices`, `$operatingSystems`, `$browsers`). diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/DOCKER-COMPOSE.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/DOCKER-COMPOSE.md new file mode 100644 index 0000000000..072779d162 --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/DOCKER-COMPOSE.md @@ -0,0 +1,90 @@ +# Docker Compose for Pre-Release Validation + +This document describes the Docker Compose setup for running all necessary checks before a release in a controlled PHP environment. + +## Architecture Overview + +``` +┌─────────────────────────────────────────────────────────────────────────┐ +│ SETUP SERVICE │ +│ (composer:latest) - Installs dependencies into ./vendor │ +└─────────────────────────────────────────────────────────────────────────┘ + │ + service_completed_successfully + │ + ┌───────────────────────────┼───────────────────────────┐ + ▼ ▼ ▼ +┌───────────────┐ ┌─────────────────┐ ┌─────────────────┐ +│ runUnitTests │ │ runPerfTests │ │ runLinting │ +│ (php:8.4+xdebug)│ │ (php:8.4-alpine)│ │ (php:8.4-alpine)│ +│ phpunit │ │ phpbench │ │ phpcs │ +└───────────────┘ └─────────────────┘ └─────────────────┘ + │ │ │ + │ │ ▼ + │ │ ┌─────────────────┐ + │ │ │ runQualityCheck │ + │ │ │ (php:8.4-alpine)│ + │ │ │ phpstan │ + │ │ └─────────────────┘ + │ │ │ + └───────────────────────────┴───────────────────────────┘ + │ + all services completed successfully + │ + ▼ + ┌─────────────────────┐ + │ runAll │ + │ Pre-release gate │ + └─────────────────────┘ + │ + ▼ + ┌─────────────────────┐ + │ generateJsonModel │ + │ export_to_json.php │ + └─────────────────────┘ +``` + +## Services + +| Service | Image | Purpose | +|---------|-------|---------| +| `setup` | composer:latest | Install dependencies | +| `runUnitTests` | alcohol/php:8.4-xdebug | PHPUnit tests with coverage | +| `runPerfTests` | php:8.4-alpine | PHPBench performance tests | +| `runLinting` | php:8.4-alpine | PHPCS code style checks + auto-fix | +| `runQualityCheck` | php:8.4-alpine | PHPStan static analysis | +| `runAll` | php:8.4-alpine | Pre-release validation gate | +| `generateJsonModel` | php:8.4-alpine | Export detection rules to JSON | + +## Usage + +### Run all pre-release checks + +```bash +docker compose -p mobile-detect up --build runAll +``` + +### Run individual services + +```bash +# Unit tests with coverage +docker compose -p mobile-detect up --build runUnitTests + +# Performance benchmarks +docker compose -p mobile-detect up --build runPerfTests + +# Code style linting +docker compose -p mobile-detect up --build runLinting + +# Static analysis +docker compose -p mobile-detect up --build runQualityCheck + +# Generate JSON model (runs after all checks pass) +docker compose -p mobile-detect up --build generateJsonModel +``` + +### Clean up + +```bash +docker compose -p mobile-detect down --volumes --remove-orphans +``` diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/KNOWN_LIMITATIONS.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/KNOWN_LIMITATIONS.md index 0f9666e149..74321e7682 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/KNOWN_LIMITATIONS.md +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/KNOWN_LIMITATIONS.md @@ -13,3 +13,8 @@ We cannot guarantee that they are using the class properly or if they provide th * Version `2.x` is made to be PHP 5.3 compatible because of the backward compatibility changes of PHP. * There are hundreds of devices launched every month, we cannot keep a 100% up-to-date detection rate. * The script cannot detect the viewport, pixel density or resolution of the screen since it's running server-side. +* **Full-page edge / proxy caches that don't key on User-Agent will defeat server-side detection.** When a CDN or page-cache plugin stores the rendered HTML and serves it to subsequent visitors without varying by `User-Agent`, the device class baked into the *first* cached response is delivered to everyone — PHP (and Mobile Detect) never run on a cache hit. This is an architectural property of full-page caches, not a bug in this library, and applies equally to any server-side branching (geo redirects, A/B tests, header-based locale, etc.). Known examples reported against this project: + * WP Engine *Edge Full Page Cache* — disable it on routes that branch on UA. See [#980](https://github.com/serbanghita/Mobile-Detect/issues/980). + * W3 Total Cache (WordPress plugin). See [#447](https://github.com/serbanghita/Mobile-Detect/issues/447). + * Cloudflare + Google Signed Exchanges (SXG). See [#945](https://github.com/serbanghita/Mobile-Detect/issues/945). + * Possible mitigations belong to the host/CDN config, not the library: disable the cache on UA-sensitive routes, add `Vary: User-Agent` if the CDN honors it, classify UA at the edge (Cloudflare Workers, Akamai EdgeWorkers, Vercel Middleware) and use the result as part of the cache key, or move device-specific logic client-side. diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/MobileDetect.json b/tools/mobile_detect/mobiledetect/mobiledetectlib/MobileDetect.json index c641602fe7..75f8010717 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/MobileDetect.json +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/MobileDetect.json @@ -1,5 +1,5 @@ { - "version": "4.8.09", + "version": "4.11.0", "headerMatch": { "HTTP_ACCEPT": { "matches": [ diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/PERFORMANCE.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/PERFORMANCE.md new file mode 100644 index 0000000000..bbec48136c --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/PERFORMANCE.md @@ -0,0 +1,63 @@ +# Performance log + +Each performance review appends a new section below, using the template at the +bottom of this file. Do not edit prior sections — they are a historical record. + +--- + +## 2026-04-24 — 4.x bench-suite overhaul + +- Branch / base: `4.x` @ `c91cc4b` +- PHP: `8.4-alpine` (linux/amd64), run via `docker compose -p mobile-detect up runPerfTests` +- Host: Apple Silicon, OrbStack +- PHPBench config: `iterations=10, revs=1000, warmup=2, retry_threshold=1` (percent; from `/phpbench.json`) +- Subjects: 13, Assertions: 13, Failures: 0, Errors: 0 + +| Subject | ops/s | rstdev | +|---|---:|---:| +| `benchMatchOnlyBestRegex` | 3,421,012 | ±0.51% | +| `benchMatchOnlyWorstRegex` | 2,338,811 | ±0.38% | +| `benchIsMobileCacheWarm` | 1,004,507 | ±0.42% | +| `benchIsTabletAgainstBestMatch` | 303,764 | ±0.52% | +| `benchIsIOS` | 99,981 | ±0.36% | +| `benchIsIpad` | 99,263 | ±0.35% | +| `benchIsSamsungTablet` | 76,596 | ±0.58% | +| `benchIsMobileCacheCold` | 69,089 | ±0.44% | +| `benchIsMobileAgainstBestMatch` | 68,982 | ±0.49% | +| `benchIsMobileCacheKeyFnCustomAgainstBestMatch` | 66,851 | ±0.52% | +| `benchIsSamsung` | 56,603 | ±0.53% | +| `benchIsTabletAgainstWorstMatch` | 19,776 | ±0.16% | +| `benchIsMobileAgainstWorstMatch` | 8,883 | ±0.30% | + +### Notes + +- The warm cache hit is ~15× faster than cold (1.00M vs 69k ops/s) — validates the cache-path split was worth adding, and confirms the PSR-16 cache actually short-circuits the regex loop on hit. +- Isolated `match()` runs at 2.3–3.4M ops/s; `isMobile()` on the same best-match UA runs 50× slower at 69k. So ~98% of an `isMobile()` call is *not* the regex — it's constructor + `$_SERVER` init + cache init/check + loop overhead. Cheap cache-key wins would be the highest-leverage optimization. +- The self-audit in `setUpMatchOnlyWorst` passed — `UA_KT107` still matches the last tablet key (currently `GenericTablet`). If a future release reorders tablet rules, the audit throws and this fixture needs refreshing. + +--- + +## Template (copy this block, do not fill it in-place) + +```md +## YYYY-MM-DD — + +- Branch / base: `` @ `` +- PHP: `` (), run via `` +- Host: +- PHPBench config: `iterations=N, revs=N, warmup=N, retry_threshold=N` (percent; from `/phpbench.json`) +- Subjects: N, Assertions: N, Failures: N, Errors: N + +| Subject | ops/s | rstdev | +|---|---:|---:| +| `benchFoo` | N | ±N% | +| ... | | | + +### Notes + +- Interpretation bullet 1 +- Interpretation bullet 2 +- Any self-audit / fixture / regression notes + +--- +``` diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/README-EXAMPLES.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/README-EXAMPLES.md new file mode 100644 index 0000000000..e1015a9dda --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/README-EXAMPLES.md @@ -0,0 +1,389 @@ +# MobileDetect Usage Examples + +This document provides code examples for common MobileDetect usage scenarios. + +## Basic Usage + +### Installation + +```bash +composer require mobiledetect/mobiledetectlib +``` + +### Simple Detection + +```php +use Detection\MobileDetect; + +$detect = new MobileDetect(); + +if ($detect->isMobile()) { + // Any mobile device (phones or tablets) +} + +if ($detect->isTablet()) { + // Tablets only +} + +if ($detect->isMobile() && !$detect->isTablet()) { + // Phones only +} +``` + +### Detect Specific Devices + +```php +use Detection\MobileDetect; + +$detect = new MobileDetect(); + +// Detect specific platforms +if ($detect->isiOS()) { + // iOS device +} + +if ($detect->isAndroidOS()) { + // Android device +} + +// Detect specific devices +if ($detect->isiPhone()) { + // iPhone +} + +if ($detect->isiPad()) { + // iPad +} + +if ($detect->isSamsung()) { + // Samsung device +} + +if ($detect->isSamsungTablet()) { + // Samsung tablet +} +``` + +### Detect Browsers + +```php +use Detection\MobileDetect; + +$detect = new MobileDetect(); + +if ($detect->isChrome()) { + // Chrome browser +} + +if ($detect->isSafari()) { + // Safari browser +} + +if ($detect->isFirefox()) { + // Firefox browser +} + +if ($detect->isOpera()) { + // Opera browser +} + +if ($detect->isEdge()) { + // Edge browser +} +``` + +### Get Version Information + +```php +use Detection\MobileDetect; + +$detect = new MobileDetect(); + +// Get version as string +$iOSVersion = $detect->version('iOS'); // e.g., "15_0" + +// Get version as float +$iOSVersion = $detect->version('iOS', 'float'); // e.g., 15.0 + +// Get browser versions +$chromeVersion = $detect->version('Chrome'); +$safariVersion = $detect->version('Safari'); +``` + +## Advanced Usage + +### Manual User-Agent Setting + +```php +use Detection\MobileDetect; + +// Disable auto-initialization for better performance +$detect = new MobileDetect(null, ['autoInitOfHttpHeaders' => false]); + +// Set User-Agent manually +$detect->setUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X)...'); + +if ($detect->isMobile()) { + // Handle mobile +} +``` + +### Custom HTTP Headers + +```php +use Detection\MobileDetect; + +$detect = new MobileDetect(); + +// Set custom headers (useful for proxy/CDN scenarios) +$detect->setHttpHeaders([ + 'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X)...', + 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml...', +]); +``` + +### Using the `is()` Method + +```php +use Detection\MobileDetect; + +$detect = new MobileDetect(); + +// Generic check using rule name +$detect->is('iOS'); // Same as $detect->isiOS() +$detect->is('iPhone'); // Same as $detect->isiPhone() +$detect->is('Chrome'); // Same as $detect->isChrome() +$detect->is('mobile'); // Same as $detect->isMobile() +$detect->is('tablet'); // Same as $detect->isTablet() +``` + +### Custom Cache Implementation + +```php +use Detection\MobileDetect; +use Detection\Cache\Cache; +use Psr\SimpleCache\CacheInterface; + +// Use any PSR-16 compatible cache +$redisCache = new YourRedisCacheAdapter(); + +$detect = new MobileDetect($redisCache); + +// Or tune the bundled in-memory cache's max entries +// (default is 1000; entries beyond the cap are evicted FIFO). +$detect = new MobileDetect(new Cache(5000)); +``` + +### Custom Cache Key Function + +```php +use Detection\MobileDetect; + +// Custom cache key with salt +$detect = new MobileDetect(null, [ + 'cacheKeyFn' => fn($key) => sha1($key . 'my-salt'), +]); + +// Or use a different hashing algorithm +$detect = new MobileDetect(null, [ + 'cacheKeyFn' => fn($key) => md5($key), +]); +``` + +### Custom Cache TTL + +```php +use Detection\MobileDetect; +use DateInterval; + +// TTL as integer (seconds) +$detect = new MobileDetect(null, [ + 'cacheTtl' => 3600, // 1 hour +]); + +// TTL as DateInterval +$detect = new MobileDetect(null, [ + 'cacheTtl' => new DateInterval('PT2H'), // 2 hours +]); +``` + +## Long-Running Processes + +When using MobileDetect in CLI scripts, workers, or daemons (RoadRunner, Laravel Octane, FrankenPHP worker mode, Swoole, +ReactPHP, queue workers) that reuse a single `MobileDetect` instance across many distinct User-Agents, +the in-memory cache would otherwise grow without bound. + +**Default-safe since 4.11.0**: the bundled `Detection\Cache\Cache` enforces a hard cap (1000 entries by default, FIFO eviction). +Tune via `new Cache($n)` for higher legitimate UA cardinality, or inject a different PSR-16 adapter (Redis, APCu, Memcached, Filesystem) — +that adapter's eviction policy is then the operator's responsibility. Note that `evictExpired()` only removes entries whose TTL has elapsed; +under the default 86 400 s TTL it does **not** bound cache size by cardinality. + +Use the `$maxEntries` cap (or `clear()`) for that. + +### Worker Example + +```php +use Detection\MobileDetect; +use Detection\Cache\Cache; + +$detect = new MobileDetect(); +$cache = $detect->getCache(); + +$iterationCount = 0; + +while ($userAgent = getNextUserAgentFromQueue()) { + $detect->setUserAgent($userAgent); + + $isMobile = $detect->isMobile(); + $isTablet = $detect->isTablet(); + + // Process the result... + processDevice($userAgent, $isMobile, $isTablet); + + $iterationCount++; + + // The bundled Cache is bounded by default (1000 entries, FIFO). + // Optionally reset it periodically as a belt-and-braces measure. + if ($iterationCount % 1000 === 0 && $cache instanceof Cache) { + $cache->clear(); + } +} +``` + +### Batch Processing Example + +```php +use Detection\MobileDetect; +use Detection\Cache\Cache; + +$detect = new MobileDetect(); + +// Process a large batch of User-Agents. The bundled Cache caps itself +// at 1000 entries by default, so memory stays bounded even if the file +// contains millions of unique UAs. +$userAgents = file('user-agents.txt', FILE_IGNORE_NEW_LINES); + +foreach ($userAgents as $index => $ua) { + $detect->setUserAgent($ua); + + $results[] = [ + 'ua' => $ua, + 'mobile' => $detect->isMobile(), + 'tablet' => $detect->isTablet(), + ]; +} + +// Optional: drop the cache entirely once the batch is done. +$cache = $detect->getCache(); +if ($cache instanceof Cache) { + $cache->clear(); +} +``` + +## Framework Integration + +### Laravel Middleware Example + +```php +namespace App\Http\Middleware; + +use Closure; +use Detection\MobileDetect; +use Illuminate\Http\Request; + +class DetectMobileDevice +{ + public function handle(Request $request, Closure $next) + { + $detect = new MobileDetect(); + + $request->attributes->set('is_mobile', $detect->isMobile()); + $request->attributes->set('is_tablet', $detect->isTablet()); + + return $next($request); + } +} +``` + +### Symfony Service Example + +```php +// config/services.yaml +services: + Detection\MobileDetect: + public: true +``` + +```php +// In a controller +use Detection\MobileDetect; + +class MyController +{ + public function index(MobileDetect $detect) + { + if ($detect->isMobile()) { + return $this->render('mobile/index.html.twig'); + } + + return $this->render('desktop/index.html.twig'); + } +} +``` + +## CloudFront Integration + +MobileDetect automatically recognizes Amazon CloudFront headers for device detection. + +```php +use Detection\MobileDetect; + +// When behind CloudFront with device detection enabled, +// these headers are automatically used: +// - HTTP_CLOUDFRONT_IS_MOBILE_VIEWER +// - HTTP_CLOUDFRONT_IS_TABLET_VIEWER +// - HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER + +$detect = new MobileDetect(); + +// Works automatically when CloudFront headers are present +if ($detect->isMobile()) { + // Mobile device detected via CloudFront +} +``` + +## Debugging + +### Get Matching Information + +```php +use Detection\MobileDetect; + +$detect = new MobileDetect(); +$detect->setUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X)...'); + +$detect->isMobile(); + +// Get the regex that matched +$matchingRegex = $detect->getMatchingRegex(); + +// Get the matches array +$matches = $detect->getMatchesArray(); +``` + +### Access Cache Directly + +```php +use Detection\MobileDetect; + +$detect = new MobileDetect(); + +// Get the cache instance +$cache = $detect->getCache(); + +// Check cached keys (for debugging) +if ($cache instanceof \Detection\Cache\Cache) { + $keys = $cache->getKeys(); + print_r($keys); +} +``` diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/README.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/README.md index ed31b5857e..1a117f2a36 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/README.md +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/README.md @@ -3,34 +3,37 @@ MobileDetect, PHP mobile detection class ======================================== -![Workflow status](https://img.shields.io/github/actions/workflow/status/serbanghita/Mobile-Detect/4.8.x-test.yml?style=flat-square) -![Latest tag](https://img.shields.io/github/v/tag/serbanghita/Mobile-Detect?filter=4.*&style=flat-square) -![Monthly Downloads](https://img.shields.io/packagist/dm/mobiledetect/mobiledetectlib?style=flat-square&label=installs) -![Total Downloads](https://img.shields.io/packagist/dt/mobiledetect/mobiledetectlib?style=flat-square&label=installs) -![MIT License](https://img.shields.io/packagist/l/mobiledetect/mobiledetectlib?style=flat-square) +[![Build status](https://img.shields.io/github/actions/workflow/status/serbanghita/Mobile-Detect/4.x-test.yml?branch=4.x&label=build&style=flat-square)](https://github.com/serbanghita/Mobile-Detect/actions/workflows/4.x-test.yml) +[![Latest stable version](https://img.shields.io/packagist/v/mobiledetect/mobiledetectlib?style=flat-square)](https://packagist.org/packages/mobiledetect/mobiledetectlib) +[![Latest tag](https://img.shields.io/github/v/tag/serbanghita/Mobile-Detect?filter=4.*&style=flat-square)](https://github.com/serbanghita/Mobile-Detect/tags) +[![Monthly Downloads](https://img.shields.io/packagist/dm/mobiledetect/mobiledetectlib?style=flat-square&label=installs)](https://packagist.org/packages/mobiledetect/mobiledetectlib/stats) +[![Total Downloads](https://img.shields.io/packagist/dt/mobiledetect/mobiledetectlib?style=flat-square&label=installs)](https://packagist.org/packages/mobiledetect/mobiledetectlib/stats) +[![MIT License](https://img.shields.io/packagist/l/mobiledetect/mobiledetectlib?style=flat-square)](https://github.com/serbanghita/Mobile-Detect/blob/4.x/LICENSE) Mobile Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment. ## Before you install -There are three versions of MobileDetect. -`4.8.x` is the main version that is ALWAYS going to be updated first. +MobileDetect is maintained on one rolling branch per major line. Tags follow the pattern `..` and always live on the matching branch. -| Version | Tests | Namespace | Code | PHP Version | Status | -|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|------------------------------------------------------------------|-------------|----------------------| -| 2.8.x | [![5x](https://img.shields.io/github/actions/workflow/status/serbanghita/Mobile-Detect/2.8.x-test.yml?style=flat-square)](https://github.com/serbanghita/Mobile-Detect/actions/workflows/test.yml) | `\Mobile_Detect` | [2.8](https://github.com/serbanghita/Mobile-Detect/tree/2.8.x) | \>=5.0,<7.0 | Deprecated | -| 3.74.x | [![7x](https://img.shields.io/github/actions/workflow/status/serbanghita/Mobile-Detect/3.74.x-test.yml?style=flat-square)](https://github.com/serbanghita/Mobile-Detect/actions/workflows/test.yml) | `Detection\MobileDetect` | [3.74](https://github.com/serbanghita/Mobile-Detect/tree/3.74.x) | \>=7.4,<8.0 | LTS | -| 4.8.x | [![7x](https://img.shields.io/github/actions/workflow/status/serbanghita/Mobile-Detect/4.8.x-test.yml?style=flat-square)](https://github.com/serbanghita/Mobile-Detect/actions/workflows/test.yml) | `Detection\MobileDetect` | [4.8](https://github.com/serbanghita/Mobile-Detect/tree/4.8.x) | \>=8.0 | Current, **Recommended** | +| Version | Tests | Namespace | Branch | PHP Version | Purpose | +|---------|-------|--------------------------|-----------------------------------------------------------------|--------------|--------------------------| +| 2.* | [![2.x tests](https://img.shields.io/github/actions/workflow/status/serbanghita/Mobile-Detect/2.x-test.yml?branch=2.x&style=flat-square)](https://github.com/serbanghita/Mobile-Detect/actions/workflows/2.x-test.yml) | `\Mobile_Detect` | [`2.x`](https://github.com/serbanghita/Mobile-Detect/tree/2.x) | \>=5.6,<7.0 | Deprecated | +| 3.* | [![3.x tests](https://img.shields.io/github/actions/workflow/status/serbanghita/Mobile-Detect/3.x-test.yml?branch=3.x&style=flat-square)](https://github.com/serbanghita/Mobile-Detect/actions/workflows/3.x-test.yml) | `Detection\MobileDetect` | [`3.x`](https://github.com/serbanghita/Mobile-Detect/tree/3.x) | \>=7.4,<8.0 | LTS | +| 4.* | [![4.x tests](https://img.shields.io/github/actions/workflow/status/serbanghita/Mobile-Detect/4.x-test.yml?branch=4.x&style=flat-square)](https://github.com/serbanghita/Mobile-Detect/actions/workflows/4.x-test.yml) | `Detection\MobileDetect` | [`4.x`](https://github.com/serbanghita/Mobile-Detect/tree/4.x) | \>=8.2 (since 4.10.0, previously \>=8.0) | Current, **Recommended** | ## 🤝 Supporting -If you are using Mobile Detect open-source package in your production apps, in presentation demos, hobby projects, school projects or so, you can sponsor my work by [donating a small amount :+1:](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mobiledetectlib%40gmail%2ecom&lc=US&item_name=Mobile%20Detect¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted). I'm currently paying for hosting and spend a lot of my family time to maintain the project and planning the future releases. I would highly appreciate any money donations. +If you are using Mobile Detect open-source package in your production apps, in presentation demos, hobby projects, +school projects or so, you can sponsor my work by [donating a small amount :+1:](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mobiledetectlib%40gmail%2ecom&lc=US&item_name=Mobile%20Detect¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted). + +I'm currently paying for domains, hosting and spend a lot of my family time to maintain the project and planning the future +releases. I would highly appreciate any money donations. Special thanks to: * the community :+1: for donations, submitting patches and issues -* the JetBrains team for the open-source licenses for [PHPStorm IDE](https://www.jetbrains.com/phpstorm/) * [Gitbook](https://www.gitbook.com/) team for the open-source license for their technical documentation tool. diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/RESEARCH.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/RESEARCH.md new file mode 100644 index 0000000000..e98948310a --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/RESEARCH.md @@ -0,0 +1,40 @@ +# Research Methodology for Adding New Device Models + +How to find new tablet (or phone) models from a vendor and add them to Mobile-Detect. + +## Step 1 -- Identify new models + +- Browse the vendor's website across regions to find new devices: + - Samsung: samsung.com/us/tablets/, samsung.com/uk/tablets/, samsung.com/global/ + - Check both the main Catalog section and the Support section for model codes +- Use GSMArena (gsmarena.com) -- search for e.g. `samsung galaxy tab` and filter by announcement year. Each device page lists all SM-XXXX model variants (Wi-Fi, LTE, 5G, regional suffixes like N, B, F) +- Check SamMobile (sammobile.com) for Samsung-specific coverage +- Cross-reference with the existing regex in `src/MobileDetect.php` (search for `SamsungTablet`) and test fixtures in `tests/providers/vendors/Samsung.php` to identify what's missing + +## Step 2 -- Find User-Agent strings + +- Search UA databases: user-agents.net, whatismybrowser.com, deviceatlas.com, udger.com +- Search for `"SM-XXXX" user agent` on the web +- Check Samsung's developer docs: https://developer.samsung.com/internet/user-agent-string-format.html +- If real UAs aren't available (device too new), construct them using the standard Chrome pattern: + ``` + Mozilla/5.0 (Linux; Android {version}; {model}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{version}.0.0.0 Safari/537.36 + ``` + Use the Android version the device ships with (from GSMArena specs) and a Chrome version contemporary to the device's release date. + +## Step 3 -- Add to codebase + +- Add model numbers to the appropriate regex array in `src/MobileDetect.php` (e.g., `$tabletDevices['SamsungTablet']`) +- Add test fixture entries in `tests/providers/vendors/{Vendor}.php` +- Run `vendor/bin/phpunit -v -c tests/phpunit.xml` to verify + +## Samsung model number conventions + +- `SM-T###` -- Standard Galaxy Tab series +- `SM-X###` -- Newer Galaxy Tab S / Tab A series (2022+) +- `SM-P###` -- Galaxy Tab with S Pen (Tab S6 Lite, etc.) +- Suffixes: no suffix = Wi-Fi, `B` = global 5G, `N` = Korean, `U` = US carrier, `F` = regional LTE variant + +## Note on User-Agent Reduction + +Chrome 110+ began rolling out UA reduction, replacing the device model name with `K`. Samsung Browser v24+ also uses `K`. However, many devices and browsers still send the full model number. The library's detection depends on model-number matching, so we continue to add model patterns. Long-term, Client Hints (`Sec-CH-UA-Model`) support may be needed. diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/composer.json b/tools/mobile_detect/mobiledetect/mobiledetectlib/composer.json index 8e5f05ea55..743a000698 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/composer.json +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/composer.json @@ -14,16 +14,15 @@ } ], "require": { - "php": ">=8.0", - "psr/simple-cache": "^3", - "psr/cache": "^3.0" + "php": ">=8.2", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^v3.65.0", - "phpunit/phpunit": "^9.6.18", - "squizlabs/php_codesniffer": "^3.11.1", - "phpbench/phpbench": "^1.2", - "phpstan/phpstan": "^1.12.x-dev" + "friendsofphp/php-cs-fixer": "3.95.1", + "phpunit/phpunit": "9.6.34", + "squizlabs/php_codesniffer": "3.13.5", + "phpbench/phpbench": "1.6.1", + "phpstan/phpstan": "2.1.47" }, "autoload": { "psr-4": { @@ -35,7 +34,21 @@ "DetectionTests\\": "tests/" } }, + "scripts": { + "bench": "phpbench run --report=aggregate", + "bench:baseline": "phpbench run --report=aggregate --tag=baseline --dump-file=phpbench-baseline.xml", + "bench:compare": "phpbench run --ref=baseline --report=aggregate" + }, "archive": { - "exclude": ["scripts"] + "exclude": [ + "scripts", + "tests", + "docs", + ".github", + ".editorconfig", + ".gitattributes", + "phpbench.json", + "phpbench-*.xml" + ] } } diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/docker-compose.yml b/tools/mobile_detect/mobiledetect/mobiledetectlib/docker-compose.yml index 2ff2cee3f4..bb206e50b5 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/docker-compose.yml +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/docker-compose.yml @@ -3,11 +3,16 @@ services: build: context: . dockerfile: ./docker/Dockerfile.setup + platform: linux/amd64 + volumes: + - ./vendor:/app/vendor + # Example: docker compose -p mobile-detect up --build runUnitTests runUnitTests: # Need xdebug from this image to run with coverage # https://hub.docker.com/r/alcohol/php/tags - image: alcohol/php:8.3-xdebug + image: alcohol/php:8.4-xdebug + platform: linux/amd64 depends_on: setup: condition: service_completed_successfully @@ -15,23 +20,26 @@ services: environment: XDEBUG_MODE: coverage command: > - /bin/sh -c "vendor/bin/phpunit -v -c tests/phpunit.xml --coverage-html ./coverage --strict-coverage --stop-on-risky" + /bin/sh -c "vendor/bin/phpunit -v -c tests/phpunit.xml --coverage-html .coverage --strict-coverage --stop-on-risky" volumes: - .:/app runPerfTests: - image: php:8.3-rc-alpine3.18 + image: php:8.4-alpine + platform: linux/amd64 depends_on: setup: condition: service_completed_successfully working_dir: /app + # Path/iterations/revs/warmup/retry-threshold come from /phpbench.json. command: > - /bin/sh -c "vendor/bin/phpbench run tests/benchmark/MobileDetectBench.php --retry-threshold=1 --iterations=10 --revs=1000 --report=aggregate" + /bin/sh -c "vendor/bin/phpbench run --report=aggregate" volumes: - .:/app runLinting: - image: php:8.3-rc-alpine3.18 + image: php:8.4-alpine + platform: linux/amd64 depends_on: setup: condition: service_completed_successfully @@ -41,18 +49,41 @@ services: volumes: - .:/app - generateModel: - image: php:8.3-rc-alpine3.18 + runQualityCheck: + image: php:8.4-alpine + platform: linux/amd64 depends_on: setup: condition: service_completed_successfully + working_dir: /app + command: > + /bin/sh -c "vendor/bin/phpstan analyse --debug --memory-limit=1G --level 3 src tests" + volumes: + - .:/app + + # Pre-release validation gate - runs all checks + # Usage: docker compose -p mobile-detect up --build runAll + runAll: + image: php:8.4-alpine + platform: linux/amd64 + depends_on: + runLinting: + condition: service_completed_successfully + runQualityCheck: + condition: service_completed_successfully runUnitTests: condition: service_completed_successfully runPerfTests: condition: service_completed_successfully - runLinting: - condition: service_completed_successfully + command: > + /bin/sh -c "echo '✅ All pre-release checks passed!'" + generateJsonModel: + image: php:8.4-alpine + platform: linux/amd64 + depends_on: + runAll: + condition: service_completed_successfully working_dir: /app command: > /bin/sh -c "php ./scripts/export_to_json.php" diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/docker/Dockerfile.setup b/tools/mobile_detect/mobiledetect/mobiledetectlib/docker/Dockerfile.setup index 41d1245091..2813c31fad 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/docker/Dockerfile.setup +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/docker/Dockerfile.setup @@ -2,8 +2,6 @@ FROM composer:latest AS build WORKDIR /app COPY . . COPY ./docker/build.sh . -RUN pwd -# Make the script executable SHELL ["/bin/bash", "-c"] RUN chmod +x build.sh -RUN ./build.sh +CMD ["./build.sh"] diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/docker/build.sh b/tools/mobile_detect/mobiledetect/mobiledetectlib/docker/build.sh index 1a0cde6a0d..a87f467bb7 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/docker/build.sh +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/docker/build.sh @@ -1,6 +1,7 @@ echo "Start building ..." -rm -rf vendor +rm -rf vendor/* rm -f composer.lock composer.phar set -xe # Install composer with dev dependencies so we can run tests. -composer install --dev +# Compose installs by default the dev dependencies. +composer install diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/phpbench.json b/tools/mobile_detect/mobiledetect/mobiledetectlib/phpbench.json deleted file mode 100644 index 0df230f5ad..0000000000 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/phpbench.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema":"./vendor/phpbench/phpbench/phpbench.schema.json", - "runner.bootstrap": "vendor/autoload.php" -} diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Cache/Cache.php b/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Cache/Cache.php index 0a08a612c9..ac87299ffe 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Cache/Cache.php +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Cache/Cache.php @@ -1,104 +1,324 @@ cache_db); + $this->maxEntries = $maxEntries; } /** - * @return array{string} + * @param string $key + * @param mixed $default + * @return mixed + * @throws CacheInvalidArgumentException */ - public function getKeys(): array + public function get($key, mixed $default = null): mixed { - return array_keys($this->cache_db); + $key = $this->checkKey($key); + + if (isset($this->cache[$key])) { + if ($this->cache[$key]['ttl'] === null || $this->cache[$key]['ttl'] > time()) { + return $this->cache[$key]['content']; + } + + $this->deleteSingle($key); + } + + return $default; } /** - * @throws CacheException + * @param string $key + * @param mixed $value + * @param int|DateInterval|null $ttl + * @throws CacheInvalidArgumentException */ - public function get(string $key, mixed $default = null): CacheItem|null + public function set($key, mixed $value, $ttl = null): bool { - if (empty($key)) { - throw new CacheException('Invalid cache key'); + $key = $this->checkKey($key); + $ttl = $this->checkTtl($ttl); + + // From https://www.php-fig.org/psr/psr-16/ "Definitions" -> "Expiration" + // If a negative or zero TTL is provided, the item MUST be deleted from the cache if it exists, as it is expired already. + if (is_int($ttl) && $ttl <= 0) { + $this->deleteSingle($key); + return false; } - return $this->cache_db[$key] ?? null; + $ttl = $this->getTTL($ttl); + + if ($ttl !== null) { + $ttl = (time() + $ttl); + } + + // FIFO eviction: if inserting a new key would exceed the cap, drop the oldest first. + // Overwriting an existing key never triggers eviction. + if (!isset($this->cache[$key]) && count($this->cache) >= $this->maxEntries) { + unset($this->cache[array_key_first($this->cache)]); + } + + $this->cache[$key] = ['ttl' => $ttl, 'content' => $value]; + + return true; } /** - * @throws CacheException + * @param string $key + * @throws CacheInvalidArgumentException */ - public function set(string $key, mixed $value, \DateInterval|int|null $ttl = null): bool + public function delete($key): bool { - if (empty($key)) { - throw new CacheException('Invalid cache key'); - } - $item = new CacheItem($key, $value); - $item->expiresAfter($ttl); - $this->cache_db[$key] = $item; + $key = $this->checkKey($key); + $this->deleteSingle($key); + return true; } - public function delete(string $key): bool + /** + * Deletes the cache item from memory. + */ + private function deleteSingle(string $key): void { - unset($this->cache_db[$key]); - return true; + unset($this->cache[$key]); } + /** @inheritdoc */ public function clear(): bool { - $this->cache_db = []; + $this->cache = []; + return true; } - public function getMultiple(iterable $keys, mixed $default = null): iterable + /** + * @param string $key + * @throws CacheInvalidArgumentException + */ + public function has($key): bool { - return array_reduce((array)$keys, function ($result, $key) { - $result[$key] = $this->get($key); - return $result; - }, []); + $key = $this->checkKey($key); + + if (isset($this->cache[$key])) { + if ($this->cache[$key]['ttl'] === null || $this->cache[$key]['ttl'] > time()) { + return true; + } + + $this->deleteSingle($key); + } + + return false; + } + + /** + * @param iterable $keys + * @param mixed $default + * @throws CacheInvalidArgumentException + */ + public function getMultiple($keys, mixed $default = null): iterable + { + $keys = $this->checkIterable($keys, 'keys'); + + $data = []; + foreach ($keys as $key) { + $data[$key] = $this->get($key, $default); + } + + return $data; } /** - * @param array $values - * @param \DateInterval|int|null $ttl - * @return bool - * @throws CacheException + * @param iterable $values + * @param int|DateInterval|null $ttl + * @throws CacheInvalidArgumentException */ - public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool + public function setMultiple($values, $ttl = null): bool { + $values = $this->checkIterable($values, 'values'); + $ttl = $this->checkTtl($ttl); + + $return = []; foreach ($values as $key => $value) { - $this->set($key, $value, $ttl); + $return[] = $this->set($key, $value, $ttl); } - return true; + + return $this->checkReturn($return); } - public function deleteMultiple(iterable $keys): bool + /** + * @param iterable $keys + * @throws CacheInvalidArgumentException + */ + public function deleteMultiple($keys): bool { + $keys = $this->checkIterable($keys, 'keys'); + foreach ($keys as $key) { - unset($this->cache_db[$key]); + $this->delete($key); } + return true; } - public function has(string $key): bool + /** + * @param mixed $key + * @throws CacheInvalidArgumentException + */ + protected function checkKey($key): string { - return isset($this->cache_db[$key]); + if (!is_string($key)) { + throw new CacheInvalidArgumentException('Cache key must be a string.'); + } + + if ($key === '' || !preg_match('/^[A-Za-z0-9_.]{1,64}$/', $key)) { + throw new CacheInvalidArgumentException("Invalid key: '$key'. Must be alphanumeric, can contain _ and . and can be maximum of 64 chars."); + } + + return $key; + } + + /** + * @param mixed $ttl + * @throws CacheInvalidArgumentException + */ + protected function checkTtl($ttl): int|DateInterval|null + { + if ($ttl !== null && !is_int($ttl) && !($ttl instanceof DateInterval)) { + throw new CacheInvalidArgumentException('TTL must be null, int, or DateInterval.'); + } + + return $ttl; + } + + /** + * @param mixed $iterable + * @return iterable + * @throws CacheInvalidArgumentException + */ + protected function checkIterable($iterable, string $argName): iterable + { + if (!is_iterable($iterable)) { + throw new CacheInvalidArgumentException(sprintf('%s must be iterable.', ucfirst($argName))); + } + + return $iterable; + } + + protected function getTTL(DateInterval|int|null $ttl): ?int + { + if ($ttl instanceof DateInterval) { + return (new DateTime())->add($ttl)->getTimestamp() - time(); + } + + // We treat 0 as a valid value. + if (is_int($ttl)) { + return $ttl; + } + + return null; + } + + /** + * @param bool[]|int[] $booleans + */ + protected function checkReturn(array $booleans): bool + { + foreach ($booleans as $boolean) { + if (!$boolean) { + return false; + } + } + + return true; + } + + /** + * Get all cache keys. + * + * @internal Needed for testing purposes. + * @return array{string} + */ + public function getKeys(): array + { + return array_keys($this->cache); + } + + /** + * Get the configured maximum number of cache entries. + */ + public function getMaxEntries(): int + { + return $this->maxEntries; + } + + /** + * Evict all expired items from the cache. + * + * Removes only entries whose TTL has already elapsed (`ttl <= time()`). + * Entries with a null TTL or a TTL still in the future are kept. + * + * This is bounded by *expiration*, not by *cardinality*: under the default + * cacheTtl of 86400 seconds, repeated calls during a single run typically + * evict zero entries. For cardinality bounding (the case that matters in + * long-running workers facing attacker-controlled keys) the in-memory + * Cache enforces a hard cap; see $maxEntries / the constructor. + * + * @return int Number of items evicted + */ + public function evictExpired(): int + { + $evicted = 0; + $now = time(); + + foreach ($this->cache as $key => $item) { + if ($item['ttl'] !== null && $item['ttl'] <= $now) { + unset($this->cache[$key]); + $evicted++; + } + } + + return $evicted; } } diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Cache/CacheException.php b/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Cache/CacheException.php index e23bcd8ac4..b90f0005d8 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Cache/CacheException.php +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Cache/CacheException.php @@ -1,16 +1,9 @@ true) - */ - protected bool|null $value = null; - /** - * @var DateTimeInterface|null - */ - public DateTimeInterface|null $expiresAt = null; - /** - * @var DateInterval|null - */ - public DateInterval|null $expiresAfter = null; - - public function __construct($key, $value = null) - { - $this->key = $key; - if (!is_null($value)) { - $this->value = $value; - } - } - - /** - * @return string - */ - public function getKey(): string - { - return $this->key; - } - - /** - * @return bool|null - */ - public function get(): ?bool - { - return $this->value; - } - - /** - * @return bool - */ - public function isHit(): bool - { - // Item never expires. - if ($this->expiresAt === null && $this->expiresAfter === null) { - return true; - } - - if (!is_null($this->expiresAt) && $this->expiresAt > new DateTime()) { - return true; - } - - if (!is_null($this->expiresAfter)) { - try { - $future_date = (new DateTime())->add($this->expiresAfter); - } catch (\Exception $e) { - return false; - } - - if ($future_date > new DateTime()) { - return true; - } - } - - return false; - } - - /** - * @param mixed $value - * @return $this - */ - public function set(mixed $value): static - { - $this->value = $value; - return $this; - } - - /** - * @param \DateTimeInterface|null $expiration - * @return $this - */ - public function expiresAt(?\DateTimeInterface $expiration): static - { - $this->expiresAt = $expiration instanceof \DateTime ? $expiration : null; - - return $this; - } - - /** - * @param int|\DateInterval|null $time - * @return $this - */ - public function expiresAfter(\DateInterval|int|null $time): static - { - $expiresAfter = null; - - if ($time instanceof \DateInterval) { - $expiresAfter = $time; - } elseif (is_int($time)) { - if ($time > 0) { - $expiresAfter = new \DateInterval("PT{$time}S"); - } - } - - $this->expiresAfter = $expiresAfter; - - return $this; - } -} diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Exception/MobileDetectException.php b/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Exception/MobileDetectException.php index 2667e9b9f7..c0209474bf 100644 --- a/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Exception/MobileDetectException.php +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/src/Exception/MobileDetectException.php @@ -1,5 +1,7 @@ * @author: Victor Stanciu (original author) * - * @version 4.8.09 + * @version 4.11.0 */ declare(strict_types=1); @@ -29,10 +29,11 @@ use BadMethodCallException; use Detection\Cache\Cache; use Detection\Cache\CacheException; +use Detection\Cache\CacheInvalidArgumentException; use Detection\Exception\MobileDetectException; -use Psr\Cache\CacheItemInterface; -use Psr\Cache\InvalidArgumentException; +use Detection\Exception\MobileDetectExceptionCode; use Psr\SimpleCache\CacheInterface; +use Psr\SimpleCache\InvalidArgumentException as PsrInvalidArgumentException; /** * Auto-generated isXXXX() magic methods. @@ -241,7 +242,7 @@ class MobileDetect /** * Stores the version number of the current release. */ - protected string $VERSION = '4.8.09'; + protected string $VERSION = '4.11.0'; protected array $config = [ // Auto-initialization on HTTP headers from $_SERVER['HTTP...'] @@ -268,12 +269,12 @@ class MobileDetect /** * A type for the version() method indicating a string return value. */ - private const VERSION_TYPE_STRING = 'text'; + public const VERSION_TYPE_STRING = 'text'; /** * A type for the version() method indicating a float return value. */ - private const VERSION_TYPE_FLOAT = 'float'; + public const VERSION_TYPE_FLOAT = 'float'; /** * The User-Agent HTTP header is stored in here. @@ -500,9 +501,12 @@ class MobileDetect // https://en.wikipedia.org/wiki/Pixel_C 'GoogleTablet' => 'Android.*Pixel C', 'SamsungTablet' => [ + 'SM-X926B|SM-X620|SM-X526B|SM-X520|SM-X626B|SM-X920|SM-X820|SM-X826B|SM-P625|SM-P620|SM-X306B|SM-T730|SM-T976B|SM-T875|SM-T575|SM-T545', + 'SM-X210R|SM-X216R|SM-X356B|SM-T860X|SM-T636B|SM-T509|SM-T503|SM-T720X|SM-T570|SM-T540|SM-T510X|SM-T830X|SM-T820X|SM-T710X|SM-T810X|SM-T365|SM-T550X|SM-T116', 'SM-X616B|SM-X610|SM-X516B|SM-X910|SM-X916B|SM-X816B|SM-X810|SM-X710|SM-X716B|SM-X510|SM-P619|SM-T225|SM-T225N|SM-T736B|SM-T505|SM-T733|SM-X205|SM-X210|SM-X216B', 'SM-X700|SM-X706|SM-X706B|SM-X706U|SM-X706N|SM-X800|SM-X806|SM-X806B|SM-X806U|SM-X806N|SM-X900|SM-X906|SM-X906B|SM-X906U|SM-X906N|SM-P613|SM-X110|SM-X115', 'SM-T970|SM-T380|SM-T5950|SM-T905|SM-T231|SM-T500|SM-T860|SM-T536|SM-T837A|SM-X200|SM-T220|SM-T870|SM-X906C', // SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a regular phone. + 'SM-X930|SM-X930N|SM-X936B|SM-X936N|SM-X730|SM-X736|SM-X736B|SM-X400|SM-X406|SM-X406B|SM-X230|SM-X236B|SM-X133|SM-X135|SM-X135F', 'SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V|SM-P610|SM-T290|SM-T515|SM-T590|SM-T595|SM-T725|SM-T817P|SM-P585N0|SM-T395|SM-T295|SM-T865|SM-P610N|SM-P615', 'SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU', 'SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715', @@ -560,7 +564,7 @@ class MobileDetect 'TB-X704L|TB-J606F|TB-X606F|TB-X306X|YT-J706X|TB128FU', 'YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X|TB-X704F|TB-X104F|TB3-X70F|TB-X705F|TB-8504F|TB3-X70L|TB3-710F', 'TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F', - 'Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)', + 'Lenovo TB|Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)', ], // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7', @@ -1043,6 +1047,14 @@ class MobileDetect /** * Construct an instance of this class. + * + * The bundled in-memory `Detection\Cache\Cache` is bounded by default + * (see `Cache::DEFAULT_MAX_ENTRIES`) to prevent unbounded growth in + * long-running PHP runtimes where one instance is reused across many + * distinct User-Agents (see GHSA-mgj4-qjmw-v56v). To tune the cap, pass + * `new Cache($n)` explicitly. To use a different backend (Redis, APCu, + * Memcached, Filesystem), inject any PSR-16 `CacheInterface`; the + * adapter's eviction policy is then the operator's responsibility. */ public function __construct( ?CacheInterface $cache = null, @@ -1082,16 +1094,16 @@ public function autoInitKnownHttpHeaders(): void // Go through known HTTP headers that we care about. // See "4.1.18. Protocol-Specific Meta-Variables" of http://www.faqs.org/rfcs/rfc3875.html $knownHttpHeaders = array_merge( - array_values(self::$knownUserAgentHttpHeaders), - array_keys(self::$knownMobilePositiveHeaders), - array_values(self::$knownCloudFrontHeaders) + array_values(static::$knownUserAgentHttpHeaders), + array_keys(static::$knownMobilePositiveHeaders), + array_values(static::$knownCloudFrontHeaders) ); // Did not iterate through global $_SERVER to find ['HTTP...'] header values // because it's very slow and on some servers it can have more than 50 worthless keys. -// $httpHeaders = array_filter($_SERVER, function ($key) { -// return str_starts_with($key, 'HTTP_'); -// }, ARRAY_FILTER_USE_KEY); + // $httpHeaders = array_filter($_SERVER, function ($key) { + // return str_starts_with($key, 'HTTP_'); + // }, ARRAY_FILTER_USE_KEY); $httpHeaders = []; foreach ($knownHttpHeaders as $headerName) { if (isset($_SERVER[$headerName])) { @@ -1137,10 +1149,10 @@ public function setHttpHeaders(array $httpHeaders = []): void // Override User-Agent string if 'Amazon Cloudfront' specific HTTP headers are present. if ( - $this->hasHttpHeader(self::$knownCloudFrontHeaders[0]) || - $this->hasHttpHeader(self::$knownCloudFrontHeaders[1]) + $this->hasHttpHeader(static::$knownCloudFrontHeaders[0]) || + $this->hasHttpHeader(static::$knownCloudFrontHeaders[1]) ) { - $this->setUserAgent(self::$cloudFrontUA); + $this->setUserAgent(static::$cloudFrontUA); } } @@ -1315,10 +1327,10 @@ public static function getBrowsers(): array */ public function getRules(): array { - static $rules; - - if (!$rules) { - $rules = array_merge( + static $rulesByClass = []; + $class = static::class; + if (!isset($rulesByClass[$class])) { + $rulesByClass[$class] = array_merge( static::$browsers, static::$operatingSystems, static::$phoneDevices, @@ -1326,7 +1338,7 @@ public function getRules(): array ); } - return $rules; + return $rulesByClass[$class]; } /** @@ -1370,15 +1382,13 @@ public function checkHttpHeadersForMobile(): bool /** * Magic overloading method. * - * @method boolean is[...]() * @param string $name * @param array $arguments * @return bool * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is' * @throws \Exception - * @throws InvalidArgumentException */ - public function __call(string $name, array $arguments) + public function __call(string $name, array $arguments): bool { // make sure the name starts with 'is', otherwise if (!str_starts_with($name, 'is')) { @@ -1399,7 +1409,7 @@ public function __call(string $name, array $arguments) public function isMobile(): bool { if (!$this->hasUserAgent()) { - throw new MobileDetectException('No valid user-agent has been set.'); + throw new MobileDetectException('No valid user-agent has been set.', MobileDetectExceptionCode::INVALID_USER_AGENT_ERR); } if ($this->isUserAgentEmpty()) { @@ -1411,16 +1421,12 @@ public function isMobile(): bool $cacheKey = $this->createCacheKey("mobile"); $cacheItem = $this->cache->get($cacheKey); if ($cacheItem !== null) { - if ($cacheItem instanceof CacheItemInterface) { - return $cacheItem->get(); - } else { - return $cacheItem; - } + return $cacheItem; } // Special case: Amazon CloudFront mobile viewer if ( - $this->getUserAgent() === self::$cloudFrontUA && + $this->getUserAgent() === static::$cloudFrontUA && $this->getHttpHeader('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER') === 'true' ) { $this->cache->set($cacheKey, true, $this->config['cacheTtl']); @@ -1435,8 +1441,8 @@ public function isMobile(): bool $this->cache->set($cacheKey, $result, $this->config['cacheTtl']); return $result; } - } catch (CacheException $e) { - throw new MobileDetectException("Cache problem in isMobile(): {$e->getMessage()}"); + } catch (CacheInvalidArgumentException | CacheException | PsrInvalidArgumentException $e) { + throw new MobileDetectException("Cache problem in isMobile(): {$e->getMessage()}", MobileDetectExceptionCode::IS_MOBILE_ERR, $e); } } @@ -1449,7 +1455,7 @@ public function isMobile(): bool public function isTablet(): bool { if (!$this->hasUserAgent()) { - throw new MobileDetectException('No user-agent has been set.'); + throw new MobileDetectException('No user-agent has been set.', MobileDetectExceptionCode::INVALID_USER_AGENT_ERR); } if ($this->isUserAgentEmpty()) { @@ -1461,16 +1467,12 @@ public function isTablet(): bool $cacheKey = $this->createCacheKey("tablet"); $cacheItem = $this->cache->get($cacheKey); if ($cacheItem !== null) { - if ($cacheItem instanceof CacheItemInterface) { - return $cacheItem->get(); - } else { - return $cacheItem; - } + return $cacheItem; } // Special case: Amazon CloudFront mobile viewer if ( - $this->getUserAgent() === self::$cloudFrontUA && + $this->getUserAgent() === static::$cloudFrontUA && $this->getHttpHeader('HTTP_CLOUDFRONT_IS_TABLET_VIEWER') === 'true' ) { $this->cache->set($cacheKey, true, $this->config['cacheTtl']); @@ -1488,27 +1490,27 @@ public function isTablet(): bool return true; } -// if (is_array($_regex)) { -// foreach ($_regex as $regexString) { -// $result = $this->match($regexString, $this->getUserAgent()); -// if ($result) { -// $this->cache->set($cacheKey, true, $this->config['cacheTtl']); -// return true; -// } -// } -// } else { -// // assume the regex is a "string" -// if ($this->match($_regex, $this->getUserAgent())) { -// $this->cache->set($cacheKey, true, $this->config['cacheTtl']); -// return true; -// } -// } + // if (is_array($_regex)) { + // foreach ($_regex as $regexString) { + // $result = $this->match($regexString, $this->getUserAgent()); + // if ($result) { + // $this->cache->set($cacheKey, true, $this->config['cacheTtl']); + // return true; + // } + // } + // } else { + // // assume the regex is a "string" + // if ($this->match($_regex, $this->getUserAgent())) { + // $this->cache->set($cacheKey, true, $this->config['cacheTtl']); + // return true; + // } + // } } $this->cache->set($cacheKey, false, $this->config['cacheTtl']); return false; - } catch (CacheException $e) { - throw new MobileDetectException("Cache problem in isTablet(): {$e->getMessage()}"); + } catch (CacheInvalidArgumentException | CacheException | PsrInvalidArgumentException $e) { + throw new MobileDetectException("Cache problem in isTablet(): {$e->getMessage()}", MobileDetectExceptionCode::IS_TABLET_ERR, $e); } } @@ -1522,7 +1524,7 @@ public function isTablet(): bool public function is(string $ruleName): bool { if (!$this->hasUserAgent()) { - throw new MobileDetectException('No user-agent has been set.'); + throw new MobileDetectException('No user-agent has been set.', MobileDetectExceptionCode::INVALID_USER_AGENT_ERR); } if ($this->isUserAgentEmpty()) { @@ -1534,11 +1536,7 @@ public function is(string $ruleName): bool $cacheKey = $this->createCacheKey($ruleName); $cacheItem = $this->cache->get($cacheKey); if ($cacheItem !== null) { - if ($cacheItem instanceof CacheItemInterface) { - return $cacheItem->get(); - } else { - return $cacheItem; - } + return $cacheItem; } $result = $this->matchUserAgentWithRule($ruleName); @@ -1546,8 +1544,8 @@ public function is(string $ruleName): bool // Cache save. $this->cache->set($cacheKey, $result, $this->config['cacheTtl']); return $result; - } catch (CacheException $e) { - throw new MobileDetectException("Cache problem in is(): {$e->getMessage()}"); + } catch (CacheInvalidArgumentException | CacheException | PsrInvalidArgumentException $e) { + throw new MobileDetectException("Cache problem in is(): {$e->getMessage()}", MobileDetectExceptionCode::IS_MAGIC_ERR, $e); } } @@ -1630,16 +1628,16 @@ protected function matchUserAgentWithRule(string $ruleName): bool $regexString = implode("|", $_rules[$ruleName]); } $result = $this->match($regexString, $this->getUserAgent()); -// if (is_array($_rules[$ruleName])) { -// foreach($_rules[$ruleName] as $ruleRegex) { -// $result = $this->match($ruleRegex, $this->getUserAgent()); -// if ($result) { -// return true; -// } -// } -// } else { -// $result = $this->match($_rules[$ruleName], $this->getUserAgent()); -// } + // if (is_array($_rules[$ruleName])) { + // foreach($_rules[$ruleName] as $ruleRegex) { + // $result = $this->match($ruleRegex, $this->getUserAgent()); + // if ($result) { + // return true; + // } + // } + // } else { + // $result = $this->match($_rules[$ruleName], $this->getUserAgent()); + // } } return $result; @@ -1654,11 +1652,11 @@ protected function matchUserAgentWithRule(string $ruleName): bool */ public function prepareVersionNo(string $ver): float { - $ver = str_replace(array('_', ' ', '/'), '.', $ver); + $ver = str_replace(['_', ' ', '/'], '.', $ver); $arrVer = explode('.', $ver, 2); if (isset($arrVer[1])) { - $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions. + $arrVer[1] = str_replace('.', '', $arrVer[1]); // @todo: treat strings versions. } return (float) implode('.', $arrVer); @@ -1688,7 +1686,7 @@ public function version(string $propertyName, string $type = self::VERSION_TYPE_ $type = self::VERSION_TYPE_STRING; } - $properties = self::getProperties(); + $properties = static::getProperties(); // Check if the property exists in the properties array. if (true === isset($properties[$propertyName])) { @@ -1697,7 +1695,7 @@ public function version(string $propertyName, string $type = self::VERSION_TYPE_ $properties[$propertyName] = (array) $properties[$propertyName]; foreach ($properties[$propertyName] as $propertyMatchString) { - $propertyPattern = str_replace('[VER]', self::VERSION_REGEX, $propertyMatchString); + $propertyPattern = str_replace('[VER]', static::VERSION_REGEX, $propertyMatchString); // Identify and extract the version. preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match); @@ -1711,12 +1709,15 @@ public function version(string $propertyName, string $type = self::VERSION_TYPE_ return false; } - public function getCache(): Cache + public function getCache(): CacheInterface { return $this->cache; } /** + * Creates the cache key string based on the defined fn. + * Function can be customized in the constructor. See `$config['cacheKeyFn']`. + * * @throws CacheException */ protected function createCacheKey(string $key): string diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/src/MobileDetectStandalone.php b/tools/mobile_detect/mobiledetect/mobiledetectlib/src/MobileDetectStandalone.php new file mode 100644 index 0000000000..17c2651e00 --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/src/MobileDetectStandalone.php @@ -0,0 +1,9 @@ + $dir . "/../src/Cache/Cache.php", + "Detection\Cache\CacheException" => $dir . "/../src/Cache/CacheException.php", + "Detection\Cache\CacheInvalidArgumentException" => $dir . "/../src/Cache/CacheInvalidArgumentException.php", + "Detection\Exception\MobileDetectException" => $dir . "/../src/Exception/MobileDetectException.php", + "Detection\Exception\MobileDetectExceptionCode" => $dir . "/../src/Exception/MobileDetectExceptionCode.php", + "Detection\MobileDetect" => $dir . "/../src/MobileDetect.php", + + // "psr/simple-cache" + "Psr\SimpleCache\CacheException" => $dir . "/deps/simple-cache/src/CacheException.php", + "Psr\SimpleCache\CacheInterface" => $dir . "/deps/simple-cache/src/CacheInterface.php", + "Psr\SimpleCache\InvalidArgumentException" => $dir . "/deps/simple-cache/src/InvalidArgumentException.php", + ]; + + $fileFound = $classMap[$class] ?? false; + + if ($fileFound) { + require $fileFound; + return true; + } + + return false; +}); diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/LICENSE.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/LICENSE.md new file mode 100644 index 0000000000..e49a7c85a1 --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) 2016 PHP Framework Interoperability Group + +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +> THE SOFTWARE. diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/README.md b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/README.md new file mode 100644 index 0000000000..43641d175c --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/README.md @@ -0,0 +1,8 @@ +PHP FIG Simple Cache PSR +======================== + +This repository holds all interfaces related to PSR-16. + +Note that this is not a cache implementation of its own. It is merely an interface that describes a cache implementation. See [the specification](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-16-simple-cache.md) for more details. + +You can find implementations of the specification by looking for packages providing the [psr/simple-cache-implementation](https://packagist.org/providers/psr/simple-cache-implementation) virtual package. diff --git a/tools/mobile_detect/psr/cache/composer.json b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/composer.json similarity index 56% rename from tools/mobile_detect/psr/cache/composer.json rename to tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/composer.json index 4b687971e4..f307a84568 100644 --- a/tools/mobile_detect/psr/cache/composer.json +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/composer.json @@ -1,7 +1,7 @@ { - "name": "psr/cache", - "description": "Common interface for caching libraries", - "keywords": ["psr", "psr-6", "cache"], + "name": "psr/simple-cache", + "description": "Common interfaces for simple caching", + "keywords": ["psr", "psr-16", "cache", "simple-cache", "caching"], "license": "MIT", "authors": [ { @@ -14,12 +14,12 @@ }, "autoload": { "psr-4": { - "Psr\\Cache\\": "src/" + "Psr\\SimpleCache\\": "src/" } }, "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "3.0.x-dev" } } } diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/src/CacheException.php b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/src/CacheException.php new file mode 100644 index 0000000000..f61b24c2b4 --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/src/CacheException.php @@ -0,0 +1,10 @@ + $keys A list of keys that can be obtained in a single operation. + * @param mixed $default Default value to return for keys that do not exist. + * + * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. + * + * @throws \Psr\SimpleCache\InvalidArgumentException + * MUST be thrown if $keys is neither an array nor a Traversable, + * or if any of the $keys are not a legal value. + */ + public function getMultiple(iterable $keys, mixed $default = null): iterable; + + /** + * Persists a set of key => value pairs in the cache, with an optional TTL. + * + * @param iterable $values A list of key => value pairs for a multiple-set operation. + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * the driver supports TTL then the library may set a default value + * for it or let the driver take care of that. + * + * @return bool True on success and false on failure. + * + * @throws \Psr\SimpleCache\InvalidArgumentException + * MUST be thrown if $values is neither an array nor a Traversable, + * or if any of the $values are not a legal value. + */ + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool; + + /** + * Deletes multiple cache items in a single operation. + * + * @param iterable $keys A list of string-based keys to be deleted. + * + * @return bool True if the items were successfully removed. False if there was an error. + * + * @throws \Psr\SimpleCache\InvalidArgumentException + * MUST be thrown if $keys is neither an array nor a Traversable, + * or if any of the $keys are not a legal value. + */ + public function deleteMultiple(iterable $keys): bool; + + /** + * Determines whether an item is present in the cache. + * + * NOTE: It is recommended that has() is only to be used for cache warming type purposes + * and not to be used within your live applications operations for get/set, as this method + * is subject to a race condition where your has() will return true and immediately after, + * another script can remove it making the state of your app out of date. + * + * @param string $key The cache item key. + * + * @return bool + * + * @throws \Psr\SimpleCache\InvalidArgumentException + * MUST be thrown if the $key string is not a legal value. + */ + public function has(string $key): bool; +} diff --git a/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/src/InvalidArgumentException.php b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/src/InvalidArgumentException.php new file mode 100644 index 0000000000..6a9524a20c --- /dev/null +++ b/tools/mobile_detect/mobiledetect/mobiledetectlib/standalone/deps/simple-cache/src/InvalidArgumentException.php @@ -0,0 +1,13 @@ + PDF issue - PR #855 + +6.10.1 (2025-11-21) + - cI: Add 8.5 to CI matrix - PR #836 + - Fix PHP 8.5 deprecation for xml_parser_free - PR #835 + - Fix bad text-align from HTML source - PR #833 + - Fix image on footer problems - PR #823 + - Preserving percentage gradient decimals and correctly clamp coordinates - PR #815 + - Enables compression for PDF/A - PR #820 + +6.10.0 (2025-05-27) + - Embedded files support (Factur-X 1.07 / ZUGFeRD 2.3) #789 + +6.9.5 (2025-05-27) + - Automatically add destinations from HTML code #804 + - Wrong default value when $table_el['old_cell_padding'] is missing #807 + - Fixed PHP warning when empty hash link for image exists in HTML #809 + - Fix for application of alpha component to SVG RGBA fills #810 + +6.9.4 (2025-05-13) + - Update donation link. + +6.9.3 (2025-04-20) + - New fix for "Deserialization of untrusted data" (check on valid protocols). + - Removed global phar configuration. + +6.9.2 (2025-04-18) + - Quick fix for "Deserialization of untrusted data" security vulnerability reported by Positive Technologies. + - Disable phar protocol globally. + +6.9.1 (2025-04-03) + - Fixed "Path Traversal" security vulnerability reported by Positive Technologies. + +6.9.0 (2025-03-30) + - Added PHP 8.4 testing. + - Removed tcpdf_import.php and tcpdf_parser.php files (for a parser check the tc-lib-pdf-parser project instead). + - Fix composer.json. + +6.8.2 (2025-01-26) + - Fix some annotation flags values. + - Remove examples from packaging. + +6.8.1 (2025-01-26) - UNTAGGED + - Check relative paths on SVG images. + +6.8.0 (2024-12-23) + - Requires PHP 7.1+ and curl extension. + - Escape error message. + - Use strict time-constant function to compare TCPDF-tag hashes. + - Add K_CURLOPTS config array to set custom cURL options (NOTE: some defaults have changed). + - Add some addTTFfont fixes from tc-lib-pdf-font. + 6.7.8 (2024-12-13) - Improve SVG detection by checking for (mandatory) namespace. - Use late state binding now that minimum PHP version is 5.5. @@ -1780,7 +1850,7 @@ addTOCPage(), endTOCPage(), addHTMLTOC(). 5.0.000 (2010-05-05) - - Method ImageSVG() was added to embedd SVG images (see example n. 58). Note that not all SVG images are supported. + - Method ImageSVG() was added to embed SVG images (see example n. 58). Note that not all SVG images are supported. - Method setRasterizeVectorImages() was added to enable/disable rasterization for vector images via ImageMagick library. - Method RoundedRectXY() was added. - Method PieSectorXY() was added. @@ -2507,7 +2577,7 @@ - A bug relative to fill color on next page was fixed. 4.2.007 (2008-11-12) - - The function setListIndentWidth() was added to set custom indentation widht for HTML lists. + - The function setListIndentWidth() was added to set custom indentation width for HTML lists. 4.2.006 (2008-11-06) - A bug relative to HTML justification was fixed. @@ -2701,7 +2771,7 @@ 4.0.011 (2008-07-23) - Font support was improved. - - The folder /fonts/utils contains new utilities and instructions for embedd font files. + - The folder /fonts/utils contains new utilities and instructions for embed font files. - Documentation was updated. 4.0.010 (2008-07-22) diff --git a/tools/tcpdf/LICENSE.TXT b/tools/tcpdf/LICENSE.TXT index ec7968a7e2..b85904e8bc 100644 --- a/tools/tcpdf/LICENSE.TXT +++ b/tools/tcpdf/LICENSE.TXT @@ -7,7 +7,7 @@ published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - 2002-2024 Nicola Asuni - Tecnick.com LTD + 2002-2026 Nicola Asuni - Tecnick.com LTD ********************************************************************** ********************************************************************** @@ -15,7 +15,7 @@ GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -184,7 +184,7 @@ Library. GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -828,7 +828,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -847,14 +847,14 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. ********************************************************************** ********************************************************************** diff --git a/tools/tcpdf/Makefile b/tools/tcpdf/Makefile new file mode 100644 index 0000000000..83c0df5c7a --- /dev/null +++ b/tools/tcpdf/Makefile @@ -0,0 +1,154 @@ +# Makefile +# +# @since 2026-04-21 +# @category Library +# @package TCPDF +# @author Nicola Asuni +# @copyright 2002-2026 Nicola Asuni - Tecnick.com LTD +# @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) +# @link https://github.com/tecnickcom/TCPDF +# +# This file is part of tcpdf software library. +# ---------------------------------------------------------------------------------------------------------------------- + +SHELL=/bin/bash +.SHELLFLAGS=-o pipefail -c + +# Project owner +OWNER=tecnickcom + +# Project vendor +VENDOR=${OWNER} + +# Project name +PROJECT=tcpdf + +# Project version (strip trailing line endings and accidental literal "\\n") +VERSION=$(shell sed -E 's/\\n$$//' VERSION | tr -d '\r\n') + +# Current directory +CURRENTDIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +# Target directory +TARGETDIR=$(CURRENTDIR)target + +# sed argument for in-place substitutions +SEDINPLACE=-i +ifeq ($(shell uname -s),Darwin) + SEDINPLACE=-i '' +endif + +# Default port number for the example server +PORT?=8971 + +# PHP binary +PHP=$(shell which php) + +# Composer executable +COMPOSER=$(PHP) -d "apc.enable_cli=0" $(shell which composer) + +# --- MAKE TARGETS --- + +# Display general help about this command +.PHONY: help +help: + @echo "" + @echo "$(PROJECT) Makefile." + @echo "The following commands are available:" + @echo "" + @awk '/^## /{desc=substr($$0,4)} /^\.PHONY:/{if(NF>1) {target=$$2; if(desc) printf " make %-15s: %s\n",target,desc; desc=""}}' Makefile + @echo "" + @echo "To test and build everything from scratch, use the shortcut:" + @echo " make x" + @echo "" + +# Alias for help target +.PHONY: all +all: help + +# Test and build everything from scratch +.PHONY: x +x: buildall + +## Test and build everything from scratch +.PHONY: buildall +buildall: deps + $(MAKE) qa + +## Delete vendor and generated directories +.PHONY: clean +clean: + rm -rf ./vendor ./tests/vendor $(TARGETDIR) ./build ./cache + +## Download dependencies for the library and test harness +.PHONY: deps +deps: ensuretarget + $(COMPOSER) install --no-interaction + @if [ -f ./tests/composer.json ]; then \ + $(COMPOSER) --working-dir=tests install --no-interaction; \ + fi + +## Generate source code documentation with Doctum if available +.PHONY: doc +doc: + @if [ -x ./vendor/bin/doctum ]; then \ + ./vendor/bin/doctum update ./scripts/doctum.php --force; \ + else \ + echo "Doctum is not installed. Run make deps first."; \ + exit 1; \ + fi + +## Create missing target directories for test and build artifacts +.PHONY: ensuretarget +ensuretarget: + mkdir -p $(TARGETDIR)/test + mkdir -p $(TARGETDIR)/report + mkdir -p $(TARGETDIR)/doc + +## Lint PHP files (syntax only) +.PHONY: lint +lint: + find . -type f -name '*.php' \ + -not -path './vendor/*' \ + -not -path './tests/vendor/*' \ + -print0 | xargs -0 -n1 -P4 $(PHP) -l > /dev/null + +## Run all checks +.PHONY: qa +qa: version ensuretarget lint test + +## Generate quality reports (not implemented in this legacy repository) +.PHONY: report +report: ensuretarget + @echo "No additional report target is configured for TCPDF." + +## Start the development server +.PHONY: server +server: + $(PHP) -t examples -S localhost:$(PORT) + +## Tag this git version +.PHONY: tag +tag: + git checkout main && \ + git tag -a ${VERSION} -m "Release ${VERSION}" && \ + git push origin --tags && \ + git pull + +## Run integration tests from tests/launch.sh +.PHONY: test +test: + XDEBUG_MODE=coverage sh ./tests/launch.sh + +## Set the code version from the VERSION file +.PHONY: version +version: + sed $(SEDINPLACE) -E "s#^([[:space:]]*private static [^=]+ = ')[^']*';#\1${VERSION}';#" include/tcpdf_static.php + sed $(SEDINPLACE) -E "1,170 s#^// Version[[:space:]]+: .*#// Version : ${VERSION}#" tcpdf.php + sed $(SEDINPLACE) -E "1,170 s#^ \* @version .*# * @version ${VERSION}#" tcpdf.php + +## Increase the version patch number +.PHONY: versionup +versionup: + echo ${VERSION} | gawk -F. '{printf("%d.%d.%d\n",$$1,$$2,(($$3+1)));}' > VERSION + $(MAKE) version diff --git a/tools/tcpdf/README.md b/tools/tcpdf/README.md index f59f663399..00ad81a188 100644 --- a/tools/tcpdf/README.md +++ b/tools/tcpdf/README.md @@ -1,83 +1,131 @@ # TCPDF -*PHP PDF Library* -[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-87ceeb.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations¤cy_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project) -*Please consider supporting this project by making a donation via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations¤cy_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project)* +> Legacy PDF engine for PHP. **Deprecated** and maintained for existing integrations. -* **category** Library -* **author** Nicola Asuni -* **copyright** 2002-2024 Nicola Asuni - Tecnick.com LTD -* **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) -* **link** http://www.tcpdf.org -* **source** https://github.com/tecnickcom/TCPDF +[![Latest Stable Version](https://poser.pugx.org/tecnickcom/tcpdf/version)](https://packagist.org/packages/tecnickcom/tcpdf) +[![License](https://poser.pugx.org/tecnickcom/tcpdf/license)](https://packagist.org/packages/tecnickcom/tcpdf) +[![Downloads](https://poser.pugx.org/tecnickcom/tcpdf/downloads)](https://packagist.org/packages/tecnickcom/tcpdf) +[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-87ceeb.svg)](https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ) +If TCPDF helps your business, please consider supporting development via [PayPal](https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ). -## NOTE -A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this library is in support only mode. +--- +## Deprecation Notice +TCPDF is **deprecated** and in **maintenance-only mode**. -## Description +Active feature development has moved to [tc-lib-pdf](https://github.com/tecnickcom/tc-lib-pdf), the modern and modular successor. -PHP library for generating PDF documents on-the-fly. +For new projects, use `tecnickcom/tc-lib-pdf`. This repository remains available for legacy systems and critical compatibility fixes. -### Main Features: -* no external libraries are required for the basic functions; -* all standard page formats, custom page formats, custom margins and units of measure; -* UTF-8 Unicode and Right-To-Left languages; -* TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1 and CID-0 fonts; -* font subsetting; -* methods to publish some XHTML + CSS code, Javascript and Forms; -* images, graphic (geometric figures) and transformation methods; -* supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/script/formats.php) -* 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extension, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417; -* JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Colors and Transparencies; -* automatic page header and footer management; -* document encryption up to 256 bit and digital signature certifications; -* transactions to UNDO commands; -* PDF annotations, including links, text and file attachments; -* text rendering modes (fill, stroke and clipping); -* multiple columns mode; -* no-write page regions; -* bookmarks, named destinations and table of content; -* text hyphenation; -* text stretching and spacing (tracking); -* automatic page break, line break and text alignments including justification; -* automatic page numbering and page groups; -* move and delete pages; -* page compression (requires php-zlib extension); -* XOBject Templates; -* Layers and object visibility. -* PDF/A-1b support. +### Migration Path -### Third party fonts: +- New projects: install `tecnickcom/tc-lib-pdf`. +- Existing TCPDF users: keep TCPDF for current production workloads and migrate in phases. +- Teams seeking modern architecture, Composer-first design, and stronger type-safety should prioritize `tc-lib-pdf`. -This library may include third party font files released with different licenses. +### Why Migrate to tc-lib-pdf -All the PHP files on the fonts directory are subject to the general TCPDF license (GNU-LGPLv3), -they do not contain any binary data but just a description of the general properties of a particular font. -These files can be also generated on the fly using the font utilities and TCPDF methods. +- Modern architecture: modular libraries and cleaner component boundaries improve maintainability. +- Better extensibility: new features are easier to add without patching a monolithic legacy core. +- Stronger tooling fit: modern package structure works better with static analysis, CI, and automated tests. +- Lower long-term risk: reduces technical debt tied to legacy APIs and supports ongoing PHP ecosystem evolution. +- Improved delivery speed: teams can implement and ship new PDF capabilities with less friction. -All the original binary TTF font files have been renamed for compatibility with TCPDF and compressed using the gzcompress PHP function that uses the ZLIB data format (.z files). +Migration still requires planning and regression checks to preserve rendering parity for existing documents. -The binary files (.z) that begins with the prefix "free" have been extracted from the GNU FreeFont collection (GNU-GPLv3). -The binary files (.z) that begins with the prefix "pdfa" have been derived from the GNU FreeFont, so they are subject to the same license. -For the details of Copyright, License and other information, please check the files inside the directory fonts/freefont-20120503 -Link : http://www.gnu.org/software/freefont/ +### Future Compatibility Possibility -The binary files (.z) that begins with the prefix "dejavu" have been extracted from the DejaVu fonts 2.33 (Bitstream) collection. -For the details of Copyright, License and other information, please check the files inside the directory fonts/dejavu-fonts-ttf-2.33 -Link : http://dejavu-fonts.org +As a long-term possibility, TCPDF could be refactored to use `tc-lib-pdf` internally as a backend while preserving a practical level of backward compatibility for existing TCPDF integrations. -The binary files (.z) that begins with the prefix "ae" have been extracted from the Arabeyes.org collection (GNU-GPLv2). -Link : http://projects.arabeyes.org/ +This is not part of a committed roadmap and there is no guarantee it will happen. It is documented here only as a potential direction that may be evaluated in the future. -### ICC profile: +--- -TCPDF includes the sRGB.icc profile from the icc-profiles-free Debian package: -https://packages.debian.org/source/stable/icc-profiles-free +## Overview +TCPDF is a pure-PHP library for generating PDF documents and barcodes directly in application code. -## Developer(s) Contact +It has been widely used across many PHP stacks and still provides a complete feature set for text rendering, page composition, graphics, signatures, forms, and standards-oriented output. -* Nicola Asuni +| | | +|---|---| +| **Package** | `tecnickcom/tcpdf` | +| **Author** | Nicola Asuni | +| **License** | [GNU LGPL v3](https://www.gnu.org/copyleft/lesser.html) (see [LICENSE.TXT](LICENSE.TXT)) | +| **Website** | | +| **Source** | | + +--- + +## Features + +### Text & Fonts +- UTF-8 Unicode and right-to-left (RTL) language support +- TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1, and CID-0 fonts +- Font subsetting +- Text hyphenation, stretching, spacing, and rendering modes (fill/stroke/clipping) +- Automatic line breaks, page breaks, and justification + +### Layout & Content +- Standard and custom page formats, margins, and measurement units +- XHTML + CSS rendering, JavaScript, and forms +- Automatic headers and footers +- Multi-column mode and no-write page regions +- Bookmarks, named destinations, and table of contents +- Automatic page numbering, page groups, move/delete pages, and undo transactions + +### Images, Graphics & Color +- Native JPEG, PNG, and SVG support +- Geometric drawing primitives and transformations +- Support for GD image formats (`GD`, `GD2`, `GD2PART`, `GIF`, `JPEG`, `PNG`, `BMP`, `XBM`, `XPM`) +- Additional formats via ImageMagick (when available) +- JPEG/PNG ICC profiles, grayscale/RGB/CMYK/spot colors, and transparencies + +### Security, Standards & Advanced Output +- Encryption up to 256-bit and digital signature certifications +- PDF annotations (links, text, and file attachments) +- 1D and 2D barcode support (including CODE 128, EAN/UPC, Datamatrix, QR Code, PDF417) +- XObject templates and layers with object visibility controls +- PDF/A-1b support + +--- + +## Requirements + +- PHP 7.1 or later +- `ext-curl` + +Optional extensions for richer output in some workflows: `gd`, `zlib`, `imagick`. + +--- + +## Third-Party Fonts + +This library may include third-party font files released under different licenses. + +PHP metadata files under [fonts](fonts) are covered by the TCPDF license (GNU LGPL v3). They contain font metadata and can also be generated using TCPDF font utilities. + +Original binary TTF files are renamed for compatibility and compressed with PHP `gzcompress` (the `.z` format). + +| Prefix | Source | License | +|---|---|---| +| `free*` | [GNU FreeFont](https://www.gnu.org/software/freefont/) | GNU GPL v3 | +| `pdfa*` | Derived from GNU FreeFont | GNU GPL v3 | +| `dejavu*` | [DejaVu Fonts](http://dejavu-fonts.org) | Bitstream/DejaVu terms | +| `ae*` | [Arabeyes.org](http://projects.arabeyes.org/) | GNU GPL v2 | + +For full details, see the bundled notices in the corresponding subdirectories under [fonts](fonts). + +--- + +## ICC Profile + +TCPDF includes `sRGB.icc` from the Debian [`icc-profiles-free`](https://packages.debian.org/source/stable/icc-profiles-free) package. + +--- + +## Contact + +Nicola Asuni diff --git a/tools/tcpdf/VERSION b/tools/tcpdf/VERSION index eed6de4bbb..060e73a63b 100644 --- a/tools/tcpdf/VERSION +++ b/tools/tcpdf/VERSION @@ -1 +1 @@ -6.7.8 +6.11.3 \ No newline at end of file diff --git a/tools/tcpdf/composer.json b/tools/tcpdf/composer.json new file mode 100644 index 0000000000..cc5904d207 --- /dev/null +++ b/tools/tcpdf/composer.json @@ -0,0 +1,75 @@ +{ + "name": "tecnickcom/tcpdf", + "type": "library", + "description": "Deprecated legacy PDF engine for PHP. For new projects use tecnickcom/tc-lib-pdf.", + "keywords": [ + "PDF", + "tcpdf", + "PDFD32000-2008", + "qrcode", + "datamatrix", + "pdf417", + "barcodes" + ], + "homepage": "https://tcpdf.org", + "license": "LGPL-3.0-or-later", + "authors": [ + { + "name": "Nicola Asuni", + "email": "info@tecnick.com", + "role": "lead" + } + ], + "require": { + "php": ">=7.1.0", + "ext-curl": "*" + }, + "suggest": { + "tecnickcom/tc-lib-pdf": "Modern replacement for TCPDF for new projects.", + "ext-gd": "Enables additional image handling in some workflows.", + "ext-imagick": "Enables additional image format support when available.", + "ext-zlib": "Recommended for compressed streams and related features." + }, + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "sort-packages": true + }, + "autoload": { + "classmap": [ + "config", + "include", + "tcpdf.php", + "tcpdf_barcodes_1d.php", + "tcpdf_barcodes_2d.php", + "include/tcpdf_colors.php", + "include/tcpdf_filters.php", + "include/tcpdf_font_data.php", + "include/tcpdf_fonts.php", + "include/tcpdf_images.php", + "include/tcpdf_static.php", + "include/barcodes/datamatrix.php", + "include/barcodes/pdf417.php", + "include/barcodes/qrcode.php" + ] + }, + "archive": { + "exclude": [ + "/.github", + "/.phpdoc", + "/examples", + "/scripts", + "/tests" + ] + }, + "support": { + "issues": "https://github.com/tecnickcom/TCPDF/issues", + "source": "https://github.com/tecnickcom/TCPDF" + }, + "funding": [ + { + "type": "paypal", + "url": "https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ" + } + ] +} diff --git a/tools/tcpdf/config/tcpdf_config.php b/tools/tcpdf/config/tcpdf_config.php index 9888a6778b..d430ee4d06 100644 --- a/tools/tcpdf/config/tcpdf_config.php +++ b/tools/tcpdf/config/tcpdf_config.php @@ -6,9 +6,9 @@ // // Description : Configuration file for TCPDF. // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2004-2014 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2004-2014 2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -23,7 +23,7 @@ // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see . +// along with TCPDF. If not, see . // // See LICENSE.TXT file for more information. //============================================================+ @@ -114,7 +114,7 @@ /** * Header description string. */ -define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); +define ('PDF_HEADER_STRING', "by2026 Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); /** * Document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]. diff --git a/tools/tcpdf/examples/barcodes/example_1d_html.php b/tools/tcpdf/examples/barcodes/example_1d_html.php deleted file mode 100644 index 6d3233bd62..0000000000 --- a/tools/tcpdf/examples/barcodes/example_1d_html.php +++ /dev/null @@ -1,57 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_1d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_1d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.000 - * @group barcode - * @group 1d - * @group html - * @group comparable - */ - -// include 1D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_1d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128'); - -// output the barcode as HTML object -echo $barcodeobj->getBarcodeHTML(2, 30, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_1d_png.php b/tools/tcpdf/examples/barcodes/example_1d_png.php deleted file mode 100644 index 02ed1660e8..0000000000 --- a/tools/tcpdf/examples/barcodes/example_1d_png.php +++ /dev/null @@ -1,56 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_1d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_1d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.000 - * @group barcode - * @group 1d - * @group png - */ - -// include 1D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_1d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128'); - -// output the barcode as PNG image -$barcodeobj->getBarcodePNG(2, 30, array(0,0,0)); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_1d_svg.php b/tools/tcpdf/examples/barcodes/example_1d_svg.php deleted file mode 100644 index 5e5ccfc355..0000000000 --- a/tools/tcpdf/examples/barcodes/example_1d_svg.php +++ /dev/null @@ -1,57 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_1d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_1d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.000 - * @group barcode - * @group 1d - * @group svg - * @group comparable - */ - -// include 1D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_1d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128'); - -// output the barcode as SVG image -$barcodeobj->getBarcodeSVG(2, 30, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_1d_svgi.php b/tools/tcpdf/examples/barcodes/example_1d_svgi.php deleted file mode 100644 index 8c65b669be..0000000000 --- a/tools/tcpdf/examples/barcodes/example_1d_svgi.php +++ /dev/null @@ -1,57 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_1d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_1d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.000 - * @group barcode - * @group 1d - * @group svg - * @group comparable - */ - -// include 1D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_1d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128'); - -// output the barcode as SVG inline code -echo $barcodeobj->getBarcodeSVGcode(2, 40, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_datamatrix_html.php b/tools/tcpdf/examples/barcodes/example_2d_datamatrix_html.php deleted file mode 100644 index e0d200cc74..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_datamatrix_html.php +++ /dev/null @@ -1,57 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group datamatrix - * @group html - * @group comparable - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'DATAMATRIX'); - -// output the barcode as HTML object -echo $barcodeobj->getBarcodeHTML(6, 6, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_datamatrix_png.php b/tools/tcpdf/examples/barcodes/example_2d_datamatrix_png.php deleted file mode 100644 index 35d344dac0..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_datamatrix_png.php +++ /dev/null @@ -1,56 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group datamatrix - * @group png - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'DATAMATRIX'); - -// output the barcode as PNG image -$barcodeobj->getBarcodePNG(6, 6, array(0,0,0)); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_datamatrix_svg.php b/tools/tcpdf/examples/barcodes/example_2d_datamatrix_svg.php deleted file mode 100644 index 10d0aa36a7..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_datamatrix_svg.php +++ /dev/null @@ -1,57 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group datamatrix - * @group svg - * @group comparable - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'DATAMATRIX'); - -// output the barcode as SVG image -$barcodeobj->getBarcodeSVG(6, 6, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_datamatrix_svgi.php b/tools/tcpdf/examples/barcodes/example_2d_datamatrix_svgi.php deleted file mode 100644 index 42627006f1..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_datamatrix_svgi.php +++ /dev/null @@ -1,57 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group datamatrix - * @group svg - * @group comparable - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'DATAMATRIX'); - -// output the barcode as SVG inline code -echo $barcodeobj->getBarcodeSVGcode(6, 6, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_pdf417_html.php b/tools/tcpdf/examples/barcodes/example_2d_pdf417_html.php deleted file mode 100644 index 3d8de31026..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_pdf417_html.php +++ /dev/null @@ -1,57 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group pdf417 - * @group html - * @group comparable - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'PDF417'); - -// output the barcode as HTML object -echo $barcodeobj->getBarcodeHTML(4, 4, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_pdf417_png.php b/tools/tcpdf/examples/barcodes/example_2d_pdf417_png.php deleted file mode 100644 index b7c95855a9..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_pdf417_png.php +++ /dev/null @@ -1,56 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group pdf417 - * @group png - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'PDF417'); - -// output the barcode as PNG image -$barcodeobj->getBarcodePNG(4, 4, array(0,0,0)); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_pdf417_svg.php b/tools/tcpdf/examples/barcodes/example_2d_pdf417_svg.php deleted file mode 100644 index 9017e5bcb8..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_pdf417_svg.php +++ /dev/null @@ -1,57 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group pdf417 - * @group svg - * @group comparable - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'PDF417'); - -// output the barcode as SVG image -$barcodeobj->getBarcodeSVG(4, 4, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_pdf417_svgi.php b/tools/tcpdf/examples/barcodes/example_2d_pdf417_svgi.php deleted file mode 100644 index 2075da7402..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_pdf417_svgi.php +++ /dev/null @@ -1,57 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group pdf417 - * @group svg - * @group comparable - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'PDF417'); - -// output the barcode as SVG inline code -echo $barcodeobj->getBarcodeSVGcode(4, 4, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_qrcode_html.php b/tools/tcpdf/examples/barcodes/example_2d_qrcode_html.php deleted file mode 100644 index 7c05f00f2d..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_qrcode_html.php +++ /dev/null @@ -1,56 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group qrcode - * @group html - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'QRCODE,H'); - -// output the barcode as HTML object -echo $barcodeobj->getBarcodeHTML(6, 6, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_qrcode_png.php b/tools/tcpdf/examples/barcodes/example_2d_qrcode_png.php deleted file mode 100644 index 75daa7c07d..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_qrcode_png.php +++ /dev/null @@ -1,56 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group qrcode - * @group png - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'QRCODE,H'); - -// output the barcode as PNG image -$barcodeobj->getBarcodePNG(6, 6, array(0,0,0)); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_qrcode_svg.php b/tools/tcpdf/examples/barcodes/example_2d_qrcode_svg.php deleted file mode 100644 index c104ca63fe..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_qrcode_svg.php +++ /dev/null @@ -1,56 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group qrcode - * @group svg - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'QRCODE,H'); - -// output the barcode as SVG image -$barcodeobj->getBarcodeSVG(6, 6, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/example_2d_qrcode_svgi.php b/tools/tcpdf/examples/barcodes/example_2d_qrcode_svgi.php deleted file mode 100644 index f31a10083b..0000000000 --- a/tools/tcpdf/examples/barcodes/example_2d_qrcode_svgi.php +++ /dev/null @@ -1,56 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : Example for tcpdf_barcodes_2d.php class -// -//============================================================+ - -/** - * @file - * Example for tcpdf_barcodes_2d.php class - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.009 - * @group barcode - * @group qrcode - * @group svg - */ - -// include 2D barcode class (search for installation path) -require_once(dirname(__FILE__).'/tcpdf_barcodes_2d_include.php'); - -// set the barcode content and type -$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'QRCODE,H'); - -// output the barcode as SVG inline code -echo $barcodeobj->getBarcodeSVGcode(6, 6, 'black'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/barcodes/tcpdf_barcodes_1d_include.php b/tools/tcpdf/examples/barcodes/tcpdf_barcodes_1d_include.php deleted file mode 100644 index 0add5ec6fb..0000000000 --- a/tools/tcpdf/examples/barcodes/tcpdf_barcodes_1d_include.php +++ /dev/null @@ -1,46 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -//============================================================+ - -/** - * Example of alternative configuration file for TCPDF. - * @author Nicola Asuni - * @package com.tecnick.tcpdf - * @version 4.9.005 - * @since 2004-10-27 - */ - -/** - * Define the following constant to ignore the default configuration file. - */ -define ('K_TCPDF_EXTERNAL_CONFIG', true); - -/** - * Installation path (/var/www/tcpdf/). - * By default it is automatically calculated but you can also set it as a fixed string to improve performances. - */ -//define ('K_PATH_MAIN', ''); - -/** - * URL path to tcpdf installation folder (http://localhost/tcpdf/). - * By default it is automatically set but you can also set it as a fixed string to improve performances. - */ -//define ('K_PATH_URL', ''); - -/** - * Path for PDF fonts. - * By default it is automatically set but you can also set it as a fixed string to improve performances. - */ -//define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/'); - -/** - * Default images directory. - * By default it is automatically set but you can also set it as a fixed string to improve performances. - */ -define ('K_PATH_IMAGES', dirname(__FILE__).'/../images/'); - -/** - * Deafult image logo used be the default Header() method. - * Please set here your own logo or an empty string to disable it. - */ -define ('PDF_HEADER_LOGO', 'tcpdf_logo.jpg'); - -/** - * Header logo image width in user units. - */ -define ('PDF_HEADER_LOGO_WIDTH', 30); - -/** - * Cache directory for temporary files (full path). - */ -define ('K_PATH_CACHE', sys_get_temp_dir().'/'); - -/** - * Generic name for a blank image. - */ -define ('K_BLANK_IMAGE', '_blank.png'); - -/** - * Page format. - */ -define ('PDF_PAGE_FORMAT', 'A4'); - -/** - * Page orientation (P=portrait, L=landscape). - */ -define ('PDF_PAGE_ORIENTATION', 'P'); - -/** - * Document creator. - */ -define ('PDF_CREATOR', 'TCPDF'); - -/** - * Document author. - */ -define ('PDF_AUTHOR', 'TCPDF'); - -/** - * Header title. - */ -define ('PDF_HEADER_TITLE', 'TCPDF Example'); - -/** - * Header description string. - */ -define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); - -/** - * Document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]. - */ -define ('PDF_UNIT', 'mm'); - -/** - * Header margin. - */ -define ('PDF_MARGIN_HEADER', 5); - -/** - * Footer margin. - */ -define ('PDF_MARGIN_FOOTER', 10); - -/** - * Top margin. - */ -define ('PDF_MARGIN_TOP', 27); - -/** - * Bottom margin. - */ -define ('PDF_MARGIN_BOTTOM', 25); - -/** - * Left margin. - */ -define ('PDF_MARGIN_LEFT', 15); - -/** - * Right margin. - */ -define ('PDF_MARGIN_RIGHT', 15); - -/** - * Default main font name. - */ -define ('PDF_FONT_NAME_MAIN', 'helvetica'); - -/** - * Default main font size. - */ -define ('PDF_FONT_SIZE_MAIN', 10); - -/** - * Default data font name. - */ -define ('PDF_FONT_NAME_DATA', 'helvetica'); - -/** - * Default data font size. - */ -define ('PDF_FONT_SIZE_DATA', 8); - -/** - * Default monospaced font name. - */ -define ('PDF_FONT_MONOSPACED', 'courier'); - -/** - * Ratio used to adjust the conversion of pixels to user units. - */ -define ('PDF_IMAGE_SCALE_RATIO', 1.25); - -/** - * Magnification factor for titles. - */ -define('HEAD_MAGNIFICATION', 1.1); - -/** - * Height of cell respect font height. - */ -define('K_CELL_HEIGHT_RATIO', 1.25); - -/** - * Title magnification respect main font size. - */ -define('K_TITLE_MAGNIFICATION', 1.3); - -/** - * Reduction factor for small font. - */ -define('K_SMALL_RATIO', 2/3); - -/** - * Set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language. - */ -define('K_THAI_TOPCHARS', true); - -/** - * If true allows to call TCPDF methods using HTML syntax - * IMPORTANT: For security reason, disable this feature if you are printing user HTML content. - */ -define('K_TCPDF_CALLS_IN_HTML', true); - -/** - * List of TCPDF methods that are allowed to be called using HTML syntax. - * Note: each method name must end with surrounded with | (pipe) character. - * The constant K_TCPDF_CALLS_IN_HTML must be set to true. - * IMPORTANT: For security reason, disable this feature if you are allowing user HTML content. - */ -define('K_ALLOWED_TCPDF_TAGS', '|AddPage|Rect|SetDrawColor|write1DBarcode|'); - -/** - * If true and PHP version is greater than 5, then the Error() method throw new exception instead of terminating the execution. - */ -define('K_TCPDF_THROW_EXCEPTION_ERROR', false); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/data/cert/tcpdf.crt b/tools/tcpdf/examples/data/cert/tcpdf.crt deleted file mode 100644 index f0491391cf..0000000000 --- a/tools/tcpdf/examples/data/cert/tcpdf.crt +++ /dev/null @@ -1,40 +0,0 @@ -Bag Attributes - localKeyID: 7B AB 1B 7A BE 4C 85 C0 1A A6 DC 59 3F 79 48 C3 93 38 68 9C -subject=/CN=TCPDF DEMO/O=TCPDF/OU=DEMO/emailAddress=you@example.com/C=IT -issuer=/CN=TCPDF DEMO/O=TCPDF/OU=DEMO/emailAddress=you@example.com/C=IT ------BEGIN CERTIFICATE----- -MIIC1TCCAj6gAwIBAgIKkehOL/XGkB5cjjANBgkqhkiG9w0BAQUFADBhMRMwEQYD -VQQDEwpUQ1BERiBERU1PMQ4wDAYDVQQKEwVUQ1BERjENMAsGA1UECxMEREVNTzEe -MBwGCSqGSIb3DQEJARYPeW91QGV4YW1wbGUuY29tMQswCQYDVQQGEwJJVDAeFw0w -OTA4MjExMjU0NDhaFw0xNDA4MjExMjU0NDhaMGExEzARBgNVBAMTClRDUERGIERF -TU8xDjAMBgNVBAoTBVRDUERGMQ0wCwYDVQQLEwRERU1PMR4wHAYJKoZIhvcNAQkB -Fg95b3VAZXhhbXBsZS5jb20xCzAJBgNVBAYTAklUMIGfMA0GCSqGSIb3DQEBAQUA -A4GNADCBiQKBgQDAqIL0uGKmTR98Lxx2vEEE1OGKkMXFo0JViitALe7Onhxxqx0H -XMUDKF5mvEVu1rcvh7/oAnAfrCuEpL/up3u1mQCgBE7WXBnFFE/AE3jCksh9OkS0 -Z0Xj9woN5bzxRDsGoPiOu/4xzk5qSEXt8jf2Ep90QuNkqLIRT4swAzpDbwIDAQAB -o4GTMIGQMDcGA1UdEgQwMC6gEQYDVQQDDApUQ1BERiBERU1PoAwGA1UECgwFVENQ -REagCwYDVQQLDARERU1PMDcGA1UdEQQwMC6gEQYDVQQDDApUQ1BERiBERU1PoAwG -A1UECgwFVENQREagCwYDVQQLDARERU1PMA8GCSqGSIb3LwEBCgQCBQAwCwYDVR0P -BAQDAgSQMA0GCSqGSIb3DQEBBQUAA4GBAEhTQfqX3ZNdHmpTLDbIj22RHXii2roE -OavCbu9WsHoWpva0qSd+yIoD594VHvYAd29sfzDfiN+7W0aiZfDhq5jpaSQMVlN8 -RGYMupbHY/+a9Gz1wqxnR84mlTtIkZVRYAhsfPwy6M1BEjdMqfdh9h40JIdkdjtb -8faTCfXPePWQ ------END CERTIFICATE----- -Bag Attributes - localKeyID: 7B AB 1B 7A BE 4C 85 C0 1A A6 DC 59 3F 79 48 C3 93 38 68 9C -Key Attributes: ------BEGIN RSA PRIVATE KEY----- -MIICXQIBAAKBgQDAqIL0uGKmTR98Lxx2vEEE1OGKkMXFo0JViitALe7Onhxxqx0H -XMUDKF5mvEVu1rcvh7/oAnAfrCuEpL/up3u1mQCgBE7WXBnFFE/AE3jCksh9OkS0 -Z0Xj9woN5bzxRDsGoPiOu/4xzk5qSEXt8jf2Ep90QuNkqLIRT4swAzpDbwIDAQAB -AoGAXc+wNMmz/5Z+RlIKYia44klmqbplEx+0JULqXI4BQsrqvs67i+I4bJkznoL+ -rEIRYSuQ3sCRKFsFtckjTGpxadnxkB+uwGKc6pZChv99BFX6HFR4hgBlT/BBRAQA -hMDlM2JIRr4S4SMVXR7MHwGMUf9mUeanGLR3ZWtU3aXJrIECQQD7OaYUVYNEEnM9 -uXyjm22CuHyqyEf5gb13sK0uQty67547yJTMUQZd/sQc9KGwhzBbhrob2LO2jAhh -S+f+NSRnAkEAxFHm3fMI5RgXmswxlGm4QW07a/Ueo7ZJG6xjTkFXluJhd+XHswRD -dQIO3zG9nGjNUoeMrPhXhPvKqFc2F9RDuQJAQBEGin74N77gxqfr4ik79y8nE8J5 -oGZ2s/RJZdfFRKLg3mwbjjNHhWb4Ck5UgZkoOt8TzRApXG8/n9hktE5HFwJBALur -M5AueO1Pl5kB489lNJ9OxUQRYUXMxpxuscuoCQwSwmv0O2+0/qtG2WKhUQnI4aYo -L+FV0YwtivBb1jj3T/kCQQDIWOxq8eRowdaMzvJpRUHFgMcf1AVZExKyrugwYOWd -KNsDxC4KaQOsPt8iT/Ulo4g/MJC0HolCOhWibKmR9Ayl ------END RSA PRIVATE KEY----- diff --git a/tools/tcpdf/examples/data/cert/tcpdf.fdf b/tools/tcpdf/examples/data/cert/tcpdf.fdf deleted file mode 100644 index a8f7c35d9a..0000000000 Binary files a/tools/tcpdf/examples/data/cert/tcpdf.fdf and /dev/null differ diff --git a/tools/tcpdf/examples/data/cert/tcpdf.p12 b/tools/tcpdf/examples/data/cert/tcpdf.p12 deleted file mode 100644 index 611f0dfb17..0000000000 Binary files a/tools/tcpdf/examples/data/cert/tcpdf.p12 and /dev/null differ diff --git a/tools/tcpdf/examples/data/chapter_demo_1.txt b/tools/tcpdf/examples/data/chapter_demo_1.txt deleted file mode 100644 index 4025de9303..0000000000 --- a/tools/tcpdf/examples/data/chapter_demo_1.txt +++ /dev/null @@ -1,19 +0,0 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc. - -Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa. - -Integer non sem eget neque mattis accumsan. Maecenas eu nisl mauris, sit amet interdum ipsum. In pharetra erat vel lectus venenatis elementum. Nulla non elit ligula, sit amet mollis urna. Morbi ut gravida est. Mauris tincidunt sem et turpis molestie malesuada. Curabitur vel nulla risus, sed mollis erat. Suspendisse vehicula accumsan purus nec varius. Donec fermentum lorem id felis sodales dictum. Quisque et dolor ipsum. Nam luctus consectetur dui vitae fermentum. Curabitur sodales consequat augue, id ultricies augue tempor ac. Aliquam ac magna id ipsum vehicula bibendum. Sed elementum congue tristique. Phasellus vel lorem eu lectus porta sodales. Etiam neque tortor, sagittis id pharetra quis, laoreet vel arcu. - -Cras quam mi, ornare laoreet laoreet vel, vehicula at lacus. Maecenas a lacus accumsan augue convallis sagittis sed quis odio. Morbi sit amet turpis diam, dictum convallis urna. Cras eget interdum augue. Cras eu nisi sit amet dolor faucibus porttitor. Suspendisse potenti. Nunc vitae dolor risus, at cursus libero. Suspendisse bibendum tellus non nibh hendrerit tristique. Mauris eget orci elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam porta libero non ante laoreet semper. Proin volutpat sodales mi, ac fermentum erat sagittis in. Vivamus at viverra felis. Ut pretium facilisis ante et pharetra. - -Nulla facilisi. Cras varius quam eget libero aliquam vitae tincidunt leo rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque a nisl massa, quis pretium urna. Proin vel porttitor tortor. Cras rhoncus congue velit in bibendum. Donec pharetra semper augue id lacinia. Quisque magna quam, hendrerit eu aliquam et, pellentesque ut tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas nulla quam, rutrum eu feugiat at, elementum eu libero. Maecenas ullamcorper leo et turpis rutrum ac laoreet eros faucibus. Phasellus condimentum lorem quis neque imperdiet quis molestie enim iaculis. Phasellus risus est, vestibulum ut convallis ultrices, dignissim nec erat. Etiam congue lobortis laoreet. Nulla ut neque sed velit dapibus semper. Quisque nec dolor id nibh eleifend iaculis. Vivamus vitae fermentum odio. Etiam malesuada quam in nulla aliquam sed convallis dui feugiat. - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc. - -Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa. - -Integer non sem eget neque mattis accumsan. Maecenas eu nisl mauris, sit amet interdum ipsum. In pharetra erat vel lectus venenatis elementum. Nulla non elit ligula, sit amet mollis urna. Morbi ut gravida est. Mauris tincidunt sem et turpis molestie malesuada. Curabitur vel nulla risus, sed mollis erat. Suspendisse vehicula accumsan purus nec varius. Donec fermentum lorem id felis sodales dictum. Quisque et dolor ipsum. Nam luctus consectetur dui vitae fermentum. Curabitur sodales consequat augue, id ultricies augue tempor ac. Aliquam ac magna id ipsum vehicula bibendum. Sed elementum congue tristique. Phasellus vel lorem eu lectus porta sodales. Etiam neque tortor, sagittis id pharetra quis, laoreet vel arcu. - -Cras quam mi, ornare laoreet laoreet vel, vehicula at lacus. Maecenas a lacus accumsan augue convallis sagittis sed quis odio. Morbi sit amet turpis diam, dictum convallis urna. Cras eget interdum augue. Cras eu nisi sit amet dolor faucibus porttitor. Suspendisse potenti. Nunc vitae dolor risus, at cursus libero. Suspendisse bibendum tellus non nibh hendrerit tristique. Mauris eget orci elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam porta libero non ante laoreet semper. Proin volutpat sodales mi, ac fermentum erat sagittis in. Vivamus at viverra felis. Ut pretium facilisis ante et pharetra. - -Nulla facilisi. Cras varius quam eget libero aliquam vitae tincidunt leo rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque a nisl massa, quis pretium urna. Proin vel porttitor tortor. Cras rhoncus congue velit in bibendum. Donec pharetra semper augue id lacinia. Quisque magna quam, hendrerit eu aliquam et, pellentesque ut tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas nulla quam, rutrum eu feugiat at, elementum eu libero. Maecenas ullamcorper leo et turpis rutrum ac laoreet eros faucibus. Phasellus condimentum lorem quis neque imperdiet quis molestie enim iaculis. Phasellus risus est, vestibulum ut convallis ultrices, dignissim nec erat. Etiam congue lobortis laoreet. Nulla ut neque sed velit dapibus semper. Quisque nec dolor id nibh eleifend iaculis. Vivamus vitae fermentum odio. Etiam malesuada quam in nulla aliquam sed convallis dui feugiat. diff --git a/tools/tcpdf/examples/data/chapter_demo_2.txt b/tools/tcpdf/examples/data/chapter_demo_2.txt deleted file mode 100644 index a0210ff020..0000000000 --- a/tools/tcpdf/examples/data/chapter_demo_2.txt +++ /dev/null @@ -1,23 +0,0 @@ -

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc.

- - - -

Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa.

- -

Integer non sem eget neque mattis accumsan. Maecenas eu nisl mauris, sit amet interdum ipsum. In pharetra erat vel lectus venenatis elementum. Nulla non elit ligula, sit amet mollis urna. Morbi ut gravida est. Mauris tincidunt sem et turpis molestie malesuada. Curabitur vel nulla risus, sed mollis erat. Suspendisse vehicula accumsan purus nec varius. Donec fermentum lorem id felis sodales dictum. Quisque et dolor ipsum. Nam luctus consectetur dui vitae fermentum. Curabitur sodales consequat augue, id ultricies augue tempor ac. Aliquam ac magna id ipsum vehicula bibendum. Sed elementum congue tristique. Phasellus vel lorem eu lectus porta sodales. Etiam neque tortor, sagittis id pharetra quis, laoreet vel arcu.

- -

Cras quam mi, ornare laoreet laoreet vel, vehicula at lacus. Maecenas a lacus accumsan augue convallis sagittis sed quis odio. Morbi sit amet turpis diam, dictum convallis urna. Cras eget interdum augue. Cras eu nisi sit amet dolor faucibus porttitor. Suspendisse potenti. Nunc vitae dolor risus, at cursus libero. Suspendisse bibendum tellus non nibh hendrerit tristique. Mauris eget orci elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam porta libero non ante laoreet semper. Proin volutpat sodales mi, ac fermentum erat sagittis in. Vivamus at viverra felis. Ut pretium facilisis ante et pharetra.

- -

Nulla facilisi. Cras varius quam eget libero aliquam vitae tincidunt leo rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque a nisl massa, quis pretium urna. Proin vel porttitor tortor. Cras rhoncus congue velit in bibendum. Donec pharetra semper augue id lacinia. Quisque magna quam, hendrerit eu aliquam et, pellentesque ut tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas nulla quam, rutrum eu feugiat at, elementum eu libero. Maecenas ullamcorper leo et turpis rutrum ac laoreet eros faucibus. Phasellus condimentum lorem quis neque imperdiet quis molestie enim iaculis. Phasellus risus est, vestibulum ut convallis ultrices, dignissim nec erat. Etiam congue lobortis laoreet. Nulla ut neque sed velit dapibus semper. Quisque nec dolor id nibh eleifend iaculis. Vivamus vitae fermentum odio. Etiam malesuada quam in nulla aliquam sed convallis dui feugiat.

- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc.

- - - -

Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa.

- -

Integer non sem eget neque mattis accumsan. Maecenas eu nisl mauris, sit amet interdum ipsum. In pharetra erat vel lectus venenatis elementum. Nulla non elit ligula, sit amet mollis urna. Morbi ut gravida est. Mauris tincidunt sem et turpis molestie malesuada. Curabitur vel nulla risus, sed mollis erat. Suspendisse vehicula accumsan purus nec varius. Donec fermentum lorem id felis sodales dictum. Quisque et dolor ipsum. Nam luctus consectetur dui vitae fermentum. Curabitur sodales consequat augue, id ultricies augue tempor ac. Aliquam ac magna id ipsum vehicula bibendum. Sed elementum congue tristique. Phasellus vel lorem eu lectus porta sodales. Etiam neque tortor, sagittis id pharetra quis, laoreet vel arcu.

- -

Cras quam mi, ornare laoreet laoreet vel, vehicula at lacus. Maecenas a lacus accumsan augue convallis sagittis sed quis odio. Morbi sit amet turpis diam, dictum convallis urna. Cras eget interdum augue. Cras eu nisi sit amet dolor faucibus porttitor. Suspendisse potenti. Nunc vitae dolor risus, at cursus libero. Suspendisse bibendum tellus non nibh hendrerit tristique. Mauris eget orci elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam porta libero non ante laoreet semper. Proin volutpat sodales mi, ac fermentum erat sagittis in. Vivamus at viverra felis. Ut pretium facilisis ante et pharetra.

- -

Nulla facilisi. Cras varius quam eget libero aliquam vitae tincidunt leo rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque a nisl massa, quis pretium urna. Proin vel porttitor tortor. Cras rhoncus congue velit in bibendum. Donec pharetra semper augue id lacinia. Quisque magna quam, hendrerit eu aliquam et, pellentesque ut tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas nulla quam, rutrum eu feugiat at, elementum eu libero. Maecenas ullamcorper leo et turpis rutrum ac laoreet eros faucibus. Phasellus condimentum lorem quis neque imperdiet quis molestie enim iaculis. Phasellus risus est, vestibulum ut convallis ultrices, dignissim nec erat. Etiam congue lobortis laoreet. Nulla ut neque sed velit dapibus semper. Quisque nec dolor id nibh eleifend iaculis. Vivamus vitae fermentum odio. Etiam malesuada quam in nulla aliquam sed convallis dui feugiat.

diff --git a/tools/tcpdf/examples/data/table_data_demo.txt b/tools/tcpdf/examples/data/table_data_demo.txt deleted file mode 100644 index 5a48a42e77..0000000000 --- a/tools/tcpdf/examples/data/table_data_demo.txt +++ /dev/null @@ -1,15 +0,0 @@ -Austria;Vienna;83859;8075 -Belgium;Brussels;30518;10192 -Denmark;Copenhagen;43094;5295 -Finland;Helsinki;304529;5147 -France;Paris;543965;58728 -Germany;Berlin;357022;82057 -Greece;Athens;131625;10511 -Ireland;Dublin;70723;3694 -Italy;Roma;301316;57563 -Luxembourg;Luxembourg;2586;424 -Netherlands;Amsterdam;41526;15654 -Portugal;Lisbon;91906;9957 -Spain;Madrid;504790;39348 -Sweden;Stockholm;410934;8839 -United Kingdom;London;243820;58862 diff --git a/tools/tcpdf/examples/data/utf8test.txt b/tools/tcpdf/examples/data/utf8test.txt deleted file mode 100644 index 291d4e7355..0000000000 --- a/tools/tcpdf/examples/data/utf8test.txt +++ /dev/null @@ -1,128 +0,0 @@ -Sentences that contain all letters commonly used in a language --------------------------------------------------------------- - -This file is UTF-8 encoded. - -Czech (cz) ---------- - - Příšerně žluťoučký kůň úpěl ďábelské ódy. - Hleď, toť přízračný kůň v mátožné póze šíleně úpí. - Zvlášť zákeřný učeň s ďolíčky běží podél zóny úlů. - Loď čeří kýlem tůň obzvlášť v Grónské úžině. - Ó, náhlý déšť již zvířil prach a čilá laň teď běží s houfcem gazel k úkrytům. - -Danish (da) ---------- - - Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen - Wolther spillede på xylofon. - (= Quiz contestants were eating strawbery with cream while Wolther - the circus clown played on xylophone.) - -German (de) ------------ - - Falsches Üben von Xylophonmusik quält jeden größeren Zwerg - (= Wrongful practicing of xylophone music tortures every larger dwarf) - - Zwölf Boxkämpfer jagten Eva quer über den Sylter Deich - (= Twelve boxing fighters hunted Eva across the dike of Sylt) - - Heizölrückstoßabdämpfung - (= fuel oil recoil absorber) - (jqvwxy missing, but all non-ASCII letters in one word) - -English (en) ------------- - - The quick brown fox jumps over the lazy dog - -Spanish (es) ------------- - - El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y - frío, añoraba a su querido cachorro. - (Contains every letter and every accent, but not every combination - of vowel + acute.) - -French (fr) ------------ - - Portez ce vieux whisky au juge blond qui fume sur son île intérieure, à - côté de l'alcôve ovoïde, où les bûches se consument dans l'âtre, ce - qui lui permet de penser à la cænogenèse de l'être dont il est question - dans la cause ambiguë entendue à Moÿ, dans un capharnaüm qui, - pense-t-il, diminue çà et là la qualité de son œuvre. - - l'île exiguë - Où l'obèse jury mûr - Fête l'haï volapük, - Âne ex aéquo au whist, - Ôtez ce vœu déçu. - - Le cœur déçu mais l'âme plutôt naïve, Louÿs rêva de crapaüter en - canoë au delà des îles, près du mälström où brûlent les novæ. - -Irish Gaelic (ga) ------------------ - - D'fhuascail Íosa, Úrmhac na hÓighe Beannaithe, pór Éava agus Ádhaimh - -Hungarian (hu) --------------- - - Árvíztűrő tükörfúrógép - (= flood-proof mirror-drilling machine, only all non-ASCII letters) - -Icelandic (is) --------------- - - Kæmi ný öxi hér ykist þjófum nú bæði víl og ádrepa - - Sævör grét áðan því úlpan var ónýt - (some ASCII letters missing) - -Greek (el) -------------- - - Γαζέες καὶ μυρτιὲς δὲν θὰ βρῶ πιὰ στὸ χρυσαφὶ ξέφωτο - (= No more shall I see acacias or myrtles in the golden clearing) - - Ξεσκεπάζω τὴν ψυχοφθόρα βδελυγμία - (= I uncover the soul-destroying abhorrence) - -Hebrew (iw) ------------ - - ? דג סקרן שט בים מאוכזב ולפתע מצא לו חברה איך הקליטה - -Polish (pl) ------------ - - Pchnąć w tę łódź jeża lub osiem skrzyń fig - (= To push a hedgehog or eight bins of figs in this boat) - - Zażółć gęślą jaźń - -Russian (ru) ------------- - - В чащах юга жил бы цитрус? Да, но фальшивый экземпляр! - (= Would a citrus live in the bushes of south? Yes, but only a fake one!) - -Thai (th) ---------- - - [--------------------------|------------------------] - ๏ เป็นมนุษย์สุดประเสริฐเลิศคุณค่า กว่าบรรดาฝูงสัตว์เดรัจฉาน - จงฝ่าฟันพัฒนาวิชาการ อย่าล้างผลาญฤๅเข่นฆ่าบีฑาใคร - ไม่ถือโทษโกรธแช่งซัดฮึดฮัดด่า หัดอภัยเหมือนกีฬาอัชฌาสัย - ปฏิบัติประพฤติกฎกำหนดใจ พูดจาให้จ๊ะๆ จ๋าๆ น่าฟังเอย ฯ - - [The copyright for the Thai example is owned by The Computer - Association of Thailand under the Royal Patronage of His Majesty the - King.] - -Please let me know if you find others! Special thanks to the people -from all over the world who contributed these sentences. diff --git a/tools/tcpdf/examples/example_001.php b/tools/tcpdf/examples/example_001.php deleted file mode 100644 index 82555e6b25..0000000000 --- a/tools/tcpdf/examples/example_001.php +++ /dev/null @@ -1,110 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 001'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128)); -$pdf->setFooterData(array(0,64,0), array(0,64,128)); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set default font subsetting mode -$pdf->setFontSubsetting(true); - -// Set font -// dejavusans is a UTF-8 Unicode font, if you only need to -// print standard ASCII chars, you can use core fonts like -// helvetica or times to reduce file size. -$pdf->setFont('dejavusans', '', 14, '', true); - -// Add a page -// This method has several options, check the source code documentation for more information. -$pdf->AddPage(); - -// set text shadow effect -$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); - -// Set some content to print -$html = <<Welcome to
 TCPDF ! -This is the first example of TCPDF library. -

This text is printed using the writeHTMLCell() method but you can also use: Multicell(), writeHTML(), Write(), Cell() and Text().

-

Please check the source code documentation and other examples for further information.

-

TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE MAKE A DONATION!

-EOD; - -// Print text using writeHTMLCell() -$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); - -// --------------------------------------------------------- - -// Close and output PDF document -// This method has several options, check the source code documentation for more information. -$pdf->Output('example_001.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_002.php b/tools/tcpdf/examples/example_002.php deleted file mode 100644 index f40a2014a3..0000000000 --- a/tools/tcpdf/examples/example_002.php +++ /dev/null @@ -1,91 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 002'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// remove default header/footer -$pdf->setPrintHeader(false); -$pdf->setPrintFooter(false); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', 'BI', 20); - -// add a page -$pdf->AddPage(); - -// set some text to print -$txt = <<Write(0, $txt, '', 0, 'C', true, 0, false, false, 0); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_002.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_003.php b/tools/tcpdf/examples/example_003.php deleted file mode 100644 index eeeb0c8d5e..0000000000 --- a/tools/tcpdf/examples/example_003.php +++ /dev/null @@ -1,122 +0,0 @@ -Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false); - // Set font - $this->setFont('helvetica', 'B', 20); - // Title - $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M'); - } - - // Page footer - public function Footer() { - // Position at 15 mm from bottom - $this->setY(-15); - // Set font - $this->setFont('helvetica', 'I', 8); - // Page number - $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); - } -} - -// create new PDF document -$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); - -// set document information -$pdf->setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 003'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', 'BI', 12); - -// add a page -$pdf->AddPage(); - -// set some text to print -$txt = <<Write(0, $txt, '', 0, 'C', true, 0, false, false, 0); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_003.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_004.php b/tools/tcpdf/examples/example_004.php deleted file mode 100644 index a1f69a5b90..0000000000 --- a/tools/tcpdf/examples/example_004.php +++ /dev/null @@ -1,123 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 004'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 004', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', '', 11); - -// add a page -$pdf->AddPage(); - -//Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M') - -// test Cell stretching -$pdf->Cell(0, 0, 'TEST CELL STRETCH: no stretch', 1, 1, 'C', 0, '', 0); -$pdf->Cell(0, 0, 'TEST CELL STRETCH: scaling', 1, 1, 'C', 0, '', 1); -$pdf->Cell(0, 0, 'TEST CELL STRETCH: force scaling', 1, 1, 'C', 0, '', 2); -$pdf->Cell(0, 0, 'TEST CELL STRETCH: spacing', 1, 1, 'C', 0, '', 3); -$pdf->Cell(0, 0, 'TEST CELL STRETCH: force spacing', 1, 1, 'C', 0, '', 4); - -$pdf->Ln(5); - -$pdf->Cell(45, 0, 'TEST CELL STRETCH: scaling', 1, 1, 'C', 0, '', 1); -$pdf->Cell(45, 0, 'TEST CELL STRETCH: force scaling', 1, 1, 'C', 0, '', 2); -$pdf->Cell(45, 0, 'TEST CELL STRETCH: spacing', 1, 1, 'C', 0, '', 3); -$pdf->Cell(45, 0, 'TEST CELL STRETCH: force spacing', 1, 1, 'C', 0, '', 4); - -$pdf->AddPage(); - -// example using general stretching and spacing - -for ($stretching = 90; $stretching <= 110; $stretching += 10) { - for ($spacing = -0.254; $spacing <= 0.254; $spacing += 0.254) { - - // set general stretching (scaling) value - $pdf->setFontStretching($stretching); - - // set general spacing value - $pdf->setFontSpacing($spacing); - - $pdf->Cell(0, 0, 'Stretching '.$stretching.'%, Spacing '.sprintf('%+.3F', $spacing).'mm, no stretch', 1, 1, 'C', 0, '', 0); - $pdf->Cell(0, 0, 'Stretching '.$stretching.'%, Spacing '.sprintf('%+.3F', $spacing).'mm, scaling', 1, 1, 'C', 0, '', 1); - $pdf->Cell(0, 0, 'Stretching '.$stretching.'%, Spacing '.sprintf('%+.3F', $spacing).'mm, force scaling', 1, 1, 'C', 0, '', 2); - $pdf->Cell(0, 0, 'Stretching '.$stretching.'%, Spacing '.sprintf('%+.3F', $spacing).'mm, spacing', 1, 1, 'C', 0, '', 3); - $pdf->Cell(0, 0, 'Stretching '.$stretching.'%, Spacing '.sprintf('%+.3F', $spacing).'mm, force spacing', 1, 1, 'C', 0, '', 4); - - $pdf->Ln(2); - } -} - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_004.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_005.php b/tools/tcpdf/examples/example_005.php deleted file mode 100644 index c27dfeac44..0000000000 --- a/tools/tcpdf/examples/example_005.php +++ /dev/null @@ -1,160 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 005'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 005', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', '', 10); - -// add a page -$pdf->AddPage(); - -// set cell padding -$pdf->setCellPaddings(1, 1, 1, 1); - -// set cell margins -$pdf->setCellMargins(1, 1, 1, 1); - -// set color for background -$pdf->setFillColor(255, 255, 127); - -// MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0) - -// set some text for example -$txt = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; - -// Multicell test -$pdf->MultiCell(55, 5, '[LEFT] '.$txt, 1, 'L', 1, 0, '', '', true); -$pdf->MultiCell(55, 5, '[RIGHT] '.$txt, 1, 'R', 0, 1, '', '', true); -$pdf->MultiCell(55, 5, '[CENTER] '.$txt, 1, 'C', 0, 0, '', '', true); -$pdf->MultiCell(55, 5, '[JUSTIFY] '.$txt."\n", 1, 'J', 1, 2, '' ,'', true); -$pdf->MultiCell(55, 5, '[DEFAULT] '.$txt, 1, '', 0, 1, '', '', true); - -$pdf->Ln(4); - -// set color for background -$pdf->setFillColor(220, 255, 220); - -// Vertical alignment -$pdf->MultiCell(55, 40, '[VERTICAL ALIGNMENT - TOP] '.$txt, 1, 'J', 1, 0, '', '', true, 0, false, true, 40, 'T'); -$pdf->MultiCell(55, 40, '[VERTICAL ALIGNMENT - MIDDLE] '.$txt, 1, 'J', 1, 0, '', '', true, 0, false, true, 40, 'M'); -$pdf->MultiCell(55, 40, '[VERTICAL ALIGNMENT - BOTTOM] '.$txt, 1, 'J', 1, 1, '', '', true, 0, false, true, 40, 'B'); - -$pdf->Ln(4); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// set color for background -$pdf->setFillColor(215, 235, 255); - -// set some text for example -$txt = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc. - -Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa.'; - -// print a blox of text using multicell() -$pdf->MultiCell(80, 5, $txt."\n", 1, 'J', 1, 1, '' ,'', true); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// AUTO-FITTING - -// set color for background -$pdf->setFillColor(255, 235, 235); - -// Fit text on cell by reducing font size -$pdf->MultiCell(55, 60, '[FIT CELL] '.$txt."\n", 1, 'J', 1, 1, 125, 145, true, 0, false, true, 60, 'M', true); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// CUSTOM PADDING - -// set color for background -$pdf->setFillColor(255, 255, 215); - -// set font -$pdf->setFont('helvetica', '', 8); - -// set cell padding -$pdf->setCellPaddings(2, 4, 6, 8); - -$txt = "CUSTOM PADDING:\nLeft=2, Top=4, Right=6, Bottom=8\nLorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue.\n"; - -$pdf->MultiCell(55, 5, $txt, 1, 'J', 1, 2, 125, 210, true); - -// move pointer to last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_005.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_006.php b/tools/tcpdf/examples/example_006.php deleted file mode 100644 index f2c7dbca71..0000000000 --- a/tools/tcpdf/examples/example_006.php +++ /dev/null @@ -1,347 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 006'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('dejavusans', '', 10); - -// add a page -$pdf->AddPage(); - -// writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='') -// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true) - -// create some HTML content -$html = '

HTML Example

-Some special characters: < € € € & è è © > \\slash \\\\double-slash \\\\\\triple-slash -

List

-List example: -
    -
  1. test alt attribute test image
  2. -
  3. bold text
  4. -
  5. italic text
  6. -
  7. underlined text
  8. -
  9. bbibiubib
  10. -
  11. link to http://www.tecnick.com
  12. -
  13. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
    Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.
  14. -
  15. SUBLIST -
      -
    1. row one -
        -
      • sublist
      • -
      -
    2. -
    3. row two
    4. -
    -
  16. -
  17. TEST line through
  18. -
  19. font + 3
  20. -
  21. small text normal small text normal subscript normal superscript normal
  22. -
-
-
Coffee
-
Black hot drink
-
Milk
-
White cold drink
-
-
IMAGES
-test alt attributetest alt attributetest alt attribute -
'; - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - - -// output some RTL HTML content -$html = '
The words “מזל [mazel] טוב [tov]” mean “Congratulations!”
'; -$pdf->writeHTML($html, true, false, true, false, ''); - -// test some inline CSS -$html = '

This is just an example of html code to demonstrate some supported CSS inline styles. -bold text -line-trough -underline and line-trough -color -background color -bold -xx-small -x-small -small -medium -large -x-large -xx-large -

'; - -$pdf->writeHTML($html, true, false, true, false, ''); - -// reset pointer to the last page -$pdf->lastPage(); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Print a table - -// add a page -$pdf->AddPage(); - -// create some HTML content -$subtable = '
ab
cd
'; - -$html = '

HTML TABLE:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#RIGHT alignLEFT align4A
1A1 example link column span. One two tree four five six seven eight nine ten.
line after br
small text normal subscript normal superscript normal bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
  1. first
    1. sublist
    2. sublist
  2. second
small small small small small small small small small small small small small small small small small small small small
4B
'.$subtable.'A2 € € € & è è
A2 € € € & è è
Red Yellow BG4C
1A2AA
2AB
2AC
4D
1B4E
1C2C3C4F
'; - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - -// Print some HTML Cells - -$html = 'red green blue
red green blue'; - -$pdf->setFillColor(255,255,0); - -$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'L', true); -$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 1, true, 'C', true); -$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'R', true); - -// reset pointer to the last page -$pdf->lastPage(); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Print a table - -// add a page -$pdf->AddPage(); - -// create some HTML content -$html = '

Image alignments on HTML table

- - - - - - - - -
'; - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - -// create some HTML content -$html = '

Embedded Images

- - - -
src="@..."
src="data..."
'; - -$data = base64_encode(file_get_contents("images/logo_example.png")); -$html = str_replace("@DATA1@", "@" . $data, $html); -$html = str_replace("@DATA2@", "data:image/png;base64," . $data, $html); - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - -// reset pointer to the last page -$pdf->lastPage(); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Print all HTML colors - -// add a page -$pdf->AddPage(); - -$textcolors = '

HTML Text Colors

'; -$bgcolors = '

HTML Background Colors

'; - -foreach(TCPDF_COLORS::$webcolor as $k => $v) { - $textcolors .= ''.$v.' '; - $bgcolors .= ''.$v.' '; -} - -// output the HTML content -$pdf->writeHTML($textcolors, true, false, true, false, ''); -$pdf->writeHTML($bgcolors, true, false, true, false, ''); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Test word-wrap - -// create some HTML content -$html = '
-

Various tests

-link to page 2
-thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword thisisanotherverylongword thisisaverylongword'; - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - -// Test fonts nesting -$html1 = 'Default Courier Helvetica Times dejavusans Times Helvetica Courier Default'; -$html2 = 'small text normal small text normal subscript normal superscript normal'; -$html3 = 'The quick brown fox jumps over the lazy dog.'; - -$html = $html1.'
'.$html2.'
'.$html3.'
'.$html3.'
'.$html2; - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// test pre tag - -// add a page -$pdf->AddPage(); - -$html = << -Hello World!
-Hello -
-
-int main() {
-    printf("HelloWorld");
-    return 0;
-}
-
-Monospace font, normal font, monospace font, normal font. -
-
DIV LEVEL 1
DIV LEVEL 2
DIV LEVEL 1
-
-SPAN LEVEL 1 SPAN LEVEL 2 SPAN LEVEL 1 -EOF; - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// test custom bullet points for list - -// add a page -$pdf->AddPage(); - -$html = <<Test custom bullet image for list items -
    -
  • test custom bullet image
  • -
  • test custom bullet image
  • -
  • test custom bullet image
  • -
  • test custom bullet image
  • -
      -EOF; - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_006.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_007.php b/tools/tcpdf/examples/example_007.php deleted file mode 100644 index 8edeb08a9e..0000000000 --- a/tools/tcpdf/examples/example_007.php +++ /dev/null @@ -1,117 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 007'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 007', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', '', 12); - -// add a page -$pdf->AddPage(); - -// create columns content -$left_column = 'LEFT COLUMN left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column'; - -$right_column = 'RIGHT COLUMN right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column'; - -// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true) - -// get current vertical position -$y = $pdf->getY(); - -// set color for background -$pdf->setFillColor(255, 255, 200); - -// set color for text -$pdf->setTextColor(0, 63, 127); - -// write the first column -$pdf->writeHTMLCell(80, '', '', $y, $left_column, 1, 0, 1, true, 'J', true); - -// set color for background -$pdf->setFillColor(215, 235, 255); - -// set color for text -$pdf->setTextColor(127, 31, 0); - -// write the second column -$pdf->writeHTMLCell(80, '', '', '', $right_column, 1, 1, 1, true, 'J', true); - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_007.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_008.php b/tools/tcpdf/examples/example_008.php deleted file mode 100644 index 2a3e716bd9..0000000000 --- a/tools/tcpdf/examples/example_008.php +++ /dev/null @@ -1,99 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 008'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 008', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set default font subsetting mode -$pdf->setFontSubsetting(true); - -// set font -$pdf->setFont('freeserif', '', 12); - -// add a page -$pdf->AddPage(); - -// get external file content -$utf8text = file_get_contents('data/utf8test.txt', false); - -// set color for text -$pdf->setTextColor(0, 63, 127); - -//Write($h, $txt, $link='', $fill=0, $align='', $ln=false, $stretch=0, $firstline=false, $firstblock=false, $maxh=0) - -// write the text -$pdf->Write(5, $utf8text, '', 0, '', false, 0, false, false, 0); - - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_008.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_009.php b/tools/tcpdf/examples/example_009.php deleted file mode 100644 index 1daf8ea7d8..0000000000 --- a/tools/tcpdf/examples/example_009.php +++ /dev/null @@ -1,148 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 009'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 009', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// ------------------------------------------------------------------- - -// add a page -$pdf->AddPage(); - -// set JPEG quality -$pdf->setJPEGQuality(75); - -// Image method signature: -// Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false) - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Example of Image from data stream ('PHP rules') -$imgdata = base64_decode('iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABlBMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDrEX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg=='); - -// The '@' character is used to indicate that follows an image data stream and not an image file name -$pdf->Image('@'.$imgdata); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Image example with resizing -$pdf->Image('images/image_demo.jpg', 15, 140, 75, 113, 'JPG', 'http://www.tcpdf.org', '', true, 150, '', false, false, 1, false, false, false); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// test fitbox with all alignment combinations - -$horizontal_alignments = array('L', 'C', 'R'); -$vertical_alignments = array('T', 'M', 'B'); - -$x = 15; -$y = 35; -$w = 30; -$h = 30; -// test all combinations of alignments -for ($i = 0; $i < 3; ++$i) { - $fitbox = $horizontal_alignments[$i].' '; - $x = 15; - for ($j = 0; $j < 3; ++$j) { - $fitbox[1] = $vertical_alignments[$j]; - $pdf->Rect($x, $y, $w, $h, 'F', array(), array(128,255,128)); - $pdf->Image('images/image_demo.jpg', $x, $y, $w, $h, 'JPG', '', '', false, 300, '', false, false, 0, $fitbox, false, false); - $x += 32; // new column - } - $y += 32; // new row -} - -$x = 115; -$y = 35; -$w = 25; -$h = 50; -for ($i = 0; $i < 3; ++$i) { - $fitbox = $horizontal_alignments[$i].' '; - $x = 115; - for ($j = 0; $j < 3; ++$j) { - $fitbox[1] = $vertical_alignments[$j]; - $pdf->Rect($x, $y, $w, $h, 'F', array(), array(128,255,255)); - $pdf->Image('images/image_demo.jpg', $x, $y, $w, $h, 'JPG', '', '', false, 300, '', false, false, 0, $fitbox, false, false); - $x += 27; // new column - } - $y += 52; // new row -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Stretching, position and alignment example - -$pdf->setXY(110, 200); -$pdf->Image('images/image_demo.jpg', '', '', 40, 40, '', '', 'T', false, 300, '', false, false, 1, false, false, false); -$pdf->Image('images/image_demo.jpg', '', '', 40, 40, '', '', '', false, 300, '', false, false, 1, false, false, false); - -// ------------------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_009.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_010.php b/tools/tcpdf/examples/example_010.php deleted file mode 100644 index b99ca22b22..0000000000 --- a/tools/tcpdf/examples/example_010.php +++ /dev/null @@ -1,152 +0,0 @@ -AddPage(); - // disable existing columns - $this->resetColumns(); - // print chapter title - $this->ChapterTitle($num, $title); - // set columns - $this->setEqualColumns(3, 57); - // print chapter body - $this->ChapterBody($file, $mode); - } - - /** - * Set chapter title - * @param int $num chapter number - * @param string $title chapter title - * @public - */ - public function ChapterTitle($num, $title) { - $this->setFont('helvetica', '', 14); - $this->setFillColor(200, 220, 255); - $this->Cell(180, 6, 'Chapter '.$num.' : '.$title, 0, 1, '', 1); - $this->Ln(4); - } - - /** - * Print chapter body - * @param string $file name of the file containing the chapter body - * @param boolean $mode if true the chapter body is in HTML, otherwise in simple text. - * @public - */ - public function ChapterBody($file, $mode=false) { - $this->selectColumn(); - // get esternal file content - $content = file_get_contents($file, false); - // set font - $this->setFont('times', '', 9); - $this->setTextColor(50, 50, 50); - // print content - if ($mode) { - // ------ HTML MODE ------ - $this->writeHTML($content, true, false, true, false, 'J'); - } else { - // ------ TEXT MODE ------ - $this->Write(0, $content, '', 0, 'J', true, 0, false, true, 0); - } - $this->Ln(); - } -} // end of extended class - -// --------------------------------------------------------- -// EXAMPLE -// --------------------------------------------------------- -// create new PDF document -$pdf = new MC_TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); - -// set document information -$pdf->setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 010'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 010', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// print TEXT -$pdf->PrintChapter(1, 'LOREM IPSUM [TEXT]', 'data/chapter_demo_1.txt', false); - -// print HTML -$pdf->PrintChapter(2, 'LOREM IPSUM [HTML]', 'data/chapter_demo_2.txt', true); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_010.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_011.php b/tools/tcpdf/examples/example_011.php deleted file mode 100644 index 8656eb9c99..0000000000 --- a/tools/tcpdf/examples/example_011.php +++ /dev/null @@ -1,141 +0,0 @@ -setFillColor(255, 0, 0); - $this->setTextColor(255); - $this->setDrawColor(128, 0, 0); - $this->setLineWidth(0.3); - $this->setFont('', 'B'); - // Header - $w = array(40, 35, 40, 45); - $num_headers = count($header); - for($i = 0; $i < $num_headers; ++$i) { - $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1); - } - $this->Ln(); - // Color and font restoration - $this->setFillColor(224, 235, 255); - $this->setTextColor(0); - $this->setFont(''); - // Data - $fill = 0; - foreach($data as $row) { - $this->Cell($w[0], 6, $row[0], 'LR', 0, 'L', $fill); - $this->Cell($w[1], 6, $row[1], 'LR', 0, 'L', $fill); - $this->Cell($w[2], 6, number_format($row[2]), 'LR', 0, 'R', $fill); - $this->Cell($w[3], 6, number_format($row[3]), 'LR', 0, 'R', $fill); - $this->Ln(); - $fill=!$fill; - } - $this->Cell(array_sum($w), 0, '', 'T'); - } -} - -// create new PDF document -$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); - -// set document information -$pdf->setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 011'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 011', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 12); - -// add a page -$pdf->AddPage(); - -// column titles -$header = array('Country', 'Capital', 'Area (sq km)', 'Pop. (thousands)'); - -// data loading -$data = $pdf->LoadData('data/table_data_demo.txt'); - -// print colored table -$pdf->ColoredTable($header, $data); - -// --------------------------------------------------------- - -// close and output PDF document -$pdf->Output('example_011.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_012.pdf b/tools/tcpdf/examples/example_012.pdf deleted file mode 100644 index eec8ee0cd9..0000000000 Binary files a/tools/tcpdf/examples/example_012.pdf and /dev/null differ diff --git a/tools/tcpdf/examples/example_012.php b/tools/tcpdf/examples/example_012.php deleted file mode 100644 index b8c03f4f19..0000000000 --- a/tools/tcpdf/examples/example_012.php +++ /dev/null @@ -1,207 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 012'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// disable header and footer -$pdf->setPrintHeader(false); -$pdf->setPrintFooter(false); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 10); - -// add a page -$pdf->AddPage(); - -$style = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => '10,20,5,10', 'phase' => 10, 'color' => array(255, 0, 0)); -$style2 = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0)); -$style3 = array('width' => 1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,10', 'color' => array(255, 0, 0)); -$style4 = array('L' => 0, - 'T' => array('width' => 0.25, 'cap' => 'butt', 'join' => 'miter', 'dash' => '20,10', 'phase' => 10, 'color' => array(100, 100, 255)), - 'R' => array('width' => 0.50, 'cap' => 'round', 'join' => 'miter', 'dash' => 0, 'color' => array(50, 50, 127)), - 'B' => array('width' => 0.75, 'cap' => 'square', 'join' => 'miter', 'dash' => '30,10,5,10')); -$style5 = array('width' => 0.25, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 64, 128)); -$style6 = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => '10,10', 'color' => array(0, 128, 0)); -$style7 = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 128, 0)); - -// Line -$pdf->Text(5, 4, 'Line examples'); -$pdf->Line(5, 10, 80, 30, $style); -$pdf->Line(5, 10, 5, 30, $style2); -$pdf->Line(5, 10, 80, 10, $style3); - -// Rect -$pdf->Text(100, 4, 'Rectangle examples'); -$pdf->Rect(100, 10, 40, 20, 'DF', $style4, array(220, 220, 200)); -$pdf->Rect(145, 10, 40, 20, 'D', array('all' => $style3)); - -// Curve -$pdf->Text(5, 34, 'Curve examples'); -$pdf->Curve(5, 40, 30, 55, 70, 45, 60, 75, '', $style6); -$pdf->Curve(80, 40, 70, 75, 150, 45, 100, 75, 'F', $style6); -$pdf->Curve(140, 40, 150, 55, 180, 45, 200, 75, 'DF', $style6, array(200, 220, 200)); - -// Circle and ellipse -$pdf->Text(5, 79, 'Circle and ellipse examples'); -$pdf->setLineStyle($style5); -$pdf->Circle(25,105,20); -$pdf->Circle(25,105,10, 90, 180, '', $style6); -$pdf->Circle(25,105,10, 270, 360, 'F'); -$pdf->Circle(25,105,10, 270, 360, 'C', $style6); - -$pdf->setLineStyle($style5); -$pdf->Ellipse(100,103,40,20); -$pdf->Ellipse(100,105,20,10, 0, 90, 180, '', $style6); -$pdf->Ellipse(100,105,20,10, 0, 270, 360, 'DF', $style6); - -$pdf->setLineStyle($style5); -$pdf->Ellipse(175,103,30,15,45); -$pdf->Ellipse(175,105,15,7.50, 45, 90, 180, '', $style6); -$pdf->Ellipse(175,105,15,7.50, 45, 270, 360, 'F', $style6, array(220, 200, 200)); - -// Polygon -$pdf->Text(5, 129, 'Polygon examples'); -$pdf->setLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); -$pdf->Polygon(array(5,135,45,135,15,165)); -$pdf->Polygon(array(60,135,80,135,80,155,70,165,50,155), 'DF', array($style6, $style7, $style7, 0, $style6), array(220, 200, 200)); -$pdf->Polygon(array(120,135,140,135,150,155,110,155), 'D', array($style6, 0, $style7, $style6)); -$pdf->Polygon(array(160,135,190,155,170,155,200,160,160,165), 'DF', array('all' => $style6), array(220, 220, 220)); - -// Polygonal Line -$pdf->setLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 164))); -$pdf->PolyLine(array(80,165,90,160,100,165,110,160,120,165,130,160,140,165), 'D', array(), array()); - -// Regular polygon -$pdf->Text(5, 169, 'Regular polygon examples'); -$pdf->setLineStyle($style5); -$pdf->RegularPolygon(20, 190, 15, 6, 0, 1, 'F'); -$pdf->RegularPolygon(55, 190, 15, 6); -$pdf->RegularPolygon(55, 190, 10, 6, 45, false, 'DF', array($style6, 0, $style7, 0, $style7, $style7)); -$pdf->RegularPolygon(90, 190, 15, 3, 0, true, 'DF', array('all' => $style5), array(200, 220, 200), 'F', array(255, 200, 200)); -$pdf->RegularPolygon(125, 190, 15, 4, 30, true, '', array('all' => $style5), array(), '', $style6); -$pdf->RegularPolygon(160, 190, 15, 10); - -// Star polygon -$pdf->Text(5, 209, 'Star polygon examples'); -$pdf->setLineStyle($style5); -$pdf->StarPolygon(20, 230, 15, 20, 3, 0, 1, 'F'); -$pdf->StarPolygon(55, 230, 15, 12, 5); -$pdf->StarPolygon(55, 230, 7, 12, 5, 45, false, 'DF', array('all' => $style7), array(220, 220, 200), 'F', array(255, 200, 200)); -$pdf->StarPolygon(90, 230, 15, 20, 6, 0, true, 'DF', array('all' => $style5), array(220, 220, 200), 'F', array(255, 200, 200)); -$pdf->StarPolygon(125, 230, 15, 5, 2, 30, true, '', array('all' => $style5), array(), '', $style6); -$pdf->StarPolygon(160, 230, 15, 10, 3); -$pdf->StarPolygon(160, 230, 7, 50, 26); - -// Rounded rectangle -$pdf->Text(5, 249, 'Rounded rectangle examples'); -$pdf->setLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); -$pdf->RoundedRect(5, 255, 40, 30, 3.50, '1111', 'DF'); -$pdf->RoundedRect(50, 255, 40, 30, 6.50, '1000'); -$pdf->RoundedRect(95, 255, 40, 30, 10.0, '1111', '', $style6); -$pdf->RoundedRect(140, 255, 40, 30, 8.0, '0101', 'DF', $style6, array(200, 200, 200)); - -// Arrows -$pdf->Text(185, 249, 'Arrows'); -$pdf->setLineStyle($style5); -$pdf->setFillColor(255, 0, 0); -$pdf->Arrow(200, 280, 185, 266, 0, 5, 15); -$pdf->Arrow(200, 280, 190, 263, 1, 5, 15); -$pdf->Arrow(200, 280, 195, 261, 2, 5, 15); -$pdf->Arrow(200, 280, 200, 260, 3, 5, 15); - -// - . - . - . - . - . - . - . - . - . - . - . - . - . - . - - -// ellipse - -// add a page -$pdf->AddPage(); - -$pdf->Cell(0, 0, 'Arc of Ellipse'); - -// center of ellipse -$xc=100; -$yc=100; - -// X Y axis -$pdf->setDrawColor(200, 200, 200); -$pdf->Line($xc-50, $yc, $xc+50, $yc); -$pdf->Line($xc, $yc-50, $xc, $yc+50); - -// ellipse axis -$pdf->setDrawColor(200, 220, 255); -$pdf->Line($xc-50, $yc-50, $xc+50, $yc+50); -$pdf->Line($xc-50, $yc+50, $xc+50, $yc-50); - -// ellipse -$pdf->setDrawColor(200, 255, 200); -$pdf->Ellipse($xc, $yc, 30, 15, 45, 0, 360, 'D', array(), array(), 2); - -// ellipse arc -$pdf->setDrawColor(255, 0, 0); -$pdf->Ellipse($xc, $yc, 30, 15, 45, 45, 90, 'D', array(), array(), 2); - - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_012.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_013.php b/tools/tcpdf/examples/example_013.php deleted file mode 100644 index 0430e8f595..0000000000 --- a/tools/tcpdf/examples/example_013.php +++ /dev/null @@ -1,231 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 013'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 013', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 20); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Graphic Transformations', '', 0, 'C', 1, 0, false, false, 0); - -// set font -$pdf->setFont('helvetica', '', 10); - -// --- Scaling --------------------------------------------- -$pdf->setDrawColor(200); -$pdf->setTextColor(200); -$pdf->Rect(50, 70, 40, 10, 'D'); -$pdf->Text(50, 66, 'Scale'); -$pdf->setDrawColor(0); -$pdf->setTextColor(0); -// Start Transformation -$pdf->StartTransform(); -// Scale by 150% centered by (50,80) which is the lower left corner of the rectangle -$pdf->ScaleXY(150, 50, 80); -$pdf->Rect(50, 70, 40, 10, 'D'); -$pdf->Text(50, 66, 'Scale'); -// Stop Transformation -$pdf->StopTransform(); - -// --- Translation ----------------------------------------- -$pdf->setDrawColor(200); -$pdf->setTextColor(200); -$pdf->Rect(125, 70, 40, 10, 'D'); -$pdf->Text(125, 66, 'Translate'); -$pdf->setDrawColor(0); -$pdf->setTextColor(0); -// Start Transformation -$pdf->StartTransform(); -// Translate 7 to the right, 5 to the bottom -$pdf->Translate(7, 5); -$pdf->Rect(125, 70, 40, 10, 'D'); -$pdf->Text(125, 66, 'Translate'); -// Stop Transformation -$pdf->StopTransform(); - -// --- Rotation -------------------------------------------- -$pdf->setDrawColor(200); -$pdf->setTextColor(200); -$pdf->Rect(70, 100, 40, 10, 'D'); -$pdf->Text(70, 96, 'Rotate'); -$pdf->setDrawColor(0); -$pdf->setTextColor(0); -// Start Transformation -$pdf->StartTransform(); -// Rotate 20 degrees counter-clockwise centered by (70,110) which is the lower left corner of the rectangle -$pdf->Rotate(20, 70, 110); -$pdf->Rect(70, 100, 40, 10, 'D'); -$pdf->Text(70, 96, 'Rotate'); -// Stop Transformation -$pdf->StopTransform(); - -// --- Skewing --------------------------------------------- -$pdf->setDrawColor(200); -$pdf->setTextColor(200); -$pdf->Rect(125, 100, 40, 10, 'D'); -$pdf->Text(125, 96, 'Skew'); -$pdf->setDrawColor(0); -$pdf->setTextColor(0); -// Start Transformation -$pdf->StartTransform(); -// skew 30 degrees along the x-axis centered by (125,110) which is the lower left corner of the rectangle -$pdf->SkewX(30, 125, 110); -$pdf->Rect(125, 100, 40, 10, 'D'); -$pdf->Text(125, 96, 'Skew'); -// Stop Transformation -$pdf->StopTransform(); - -// --- Mirroring horizontally ------------------------------ -$pdf->setDrawColor(200); -$pdf->setTextColor(200); -$pdf->Rect(70, 130, 40, 10, 'D'); -$pdf->Text(70, 126, 'MirrorH'); -$pdf->setDrawColor(0); -$pdf->setTextColor(0); -// Start Transformation -$pdf->StartTransform(); -// mirror horizontally with axis of reflection at x-position 70 (left side of the rectangle) -$pdf->MirrorH(70); -$pdf->Rect(70, 130, 40, 10, 'D'); -$pdf->Text(70, 126, 'MirrorH'); -// Stop Transformation -$pdf->StopTransform(); - -// --- Mirroring vertically -------------------------------- -$pdf->setDrawColor(200); -$pdf->setTextColor(200); -$pdf->Rect(125, 130, 40, 10, 'D'); -$pdf->Text(125, 126, 'MirrorV'); -$pdf->setDrawColor(0); -$pdf->setTextColor(0); -// Start Transformation -$pdf->StartTransform(); -// mirror vertically with axis of reflection at y-position 140 (bottom side of the rectangle) -$pdf->MirrorV(140); -$pdf->Rect(125, 130, 40, 10, 'D'); -$pdf->Text(125, 126, 'MirrorV'); -// Stop Transformation -$pdf->StopTransform(); - -// --- Point reflection ------------------------------------ -$pdf->setDrawColor(200); -$pdf->setTextColor(200); -$pdf->Rect(70, 160, 40, 10, 'D'); -$pdf->Text(70, 156, 'MirrorP'); -$pdf->setDrawColor(0); -$pdf->setTextColor(0); -// Start Transformation -$pdf->StartTransform(); -// point reflection at the lower left point of rectangle -$pdf->MirrorP(70,170); -$pdf->Rect(70, 160, 40, 10, 'D'); -$pdf->Text(70, 156, 'MirrorP'); -// Stop Transformation -$pdf->StopTransform(); - -// --- Mirroring against a straigth line described by a point (120, 120) and an angle -20° -$angle=-20; -$px=120; -$py=170; - -// just for visualisation: the straight line to mirror against - -$pdf->setDrawColor(200); -$pdf->Line($px-1,$py-1,$px+1,$py+1); -$pdf->Line($px-1,$py+1,$px+1,$py-1); -$pdf->StartTransform(); -$pdf->Rotate($angle, $px, $py); -$pdf->Line($px-5, $py, $px+60, $py); -$pdf->StopTransform(); - -$pdf->setDrawColor(200); -$pdf->setTextColor(200); -$pdf->Rect(125, 160, 40, 10, 'D'); -$pdf->Text(125, 156, 'MirrorL'); -$pdf->setDrawColor(0); -$pdf->setTextColor(0); -//Start Transformation -$pdf->StartTransform(); -//mirror against the straight line -$pdf->MirrorL($angle, $px, $py); -$pdf->Rect(125, 160, 40, 10, 'D'); -$pdf->Text(125, 156, 'MirrorL'); -//Stop Transformation -$pdf->StopTransform(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_013.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_014.php b/tools/tcpdf/examples/example_014.php deleted file mode 100644 index eac3f6aaff..0000000000 --- a/tools/tcpdf/examples/example_014.php +++ /dev/null @@ -1,197 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 014'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 014', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// IMPORTANT: disable font subsetting to allow users editing the document -$pdf->setFontSubsetting(false); - -// set font. 'helvetica' MUST be used to avoid a PHP notice from PHP 7.4+ -$pdf->setFont('helvetica', '', 10, '', false); - -// add a page -$pdf->AddPage(); - -/* -It is possible to create text fields, combo boxes, check boxes and buttons. -Fields are created at the current position and are given a name. -This name allows to manipulate them via JavaScript in order to perform some validation for instance. -*/ - -// set default form properties -$pdf->setFormDefaultProp(array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 200), 'strokeColor'=>array(255, 128, 128))); - -$pdf->setFont('helvetica', 'BI', 18); -$pdf->Cell(0, 5, 'Example of Form', 0, 1, 'C'); -$pdf->Ln(10); - -$pdf->setFont('helvetica', '', 12); - -// First name -$pdf->Cell(35, 5, 'First name:'); -$pdf->TextField('firstname', 50, 5); -$pdf->Ln(6); - -// Last name -$pdf->Cell(35, 5, 'Last name:'); -$pdf->TextField('lastname', 50, 5); -$pdf->Ln(6); - -// Gender -$pdf->Cell(35, 5, 'Gender:'); -$pdf->ComboBox('gender', 30, 5, array(array('', '-'), array('M', 'Male'), array('F', 'Female'))); -$pdf->Ln(6); - -// Drink -$pdf->Cell(35, 5, 'Drink:'); -//$pdf->RadioButton('drink', 5, array('readonly' => 'true'), array(), 'Water'); -$pdf->RadioButton('drink', 5, array(), array(), 'Water'); -$pdf->Cell(35, 5, 'Water'); -$pdf->Ln(6); -$pdf->Cell(35, 5, ''); -$pdf->RadioButton('drink', 5, array(), array(), 'Beer', true); -$pdf->Cell(35, 5, 'Beer'); -$pdf->Ln(6); -$pdf->Cell(35, 5, ''); -$pdf->RadioButton('drink', 5, array(), array(), 'Wine'); -$pdf->Cell(35, 5, 'Wine'); -$pdf->Ln(6); -$pdf->Cell(35, 5, ''); -$pdf->RadioButton('drink', 5, array(), array(), 'Milk'); -$pdf->Cell(35, 5, 'Milk'); -$pdf->Ln(10); - -// Newsletter -$pdf->Cell(35, 5, 'Newsletter:'); -$pdf->CheckBox('newsletter', 5, true, array(), array(), 'OK'); - -$pdf->Ln(10); -// Address -$pdf->Cell(35, 5, 'Address:'); -$pdf->TextField('address', 60, 18, array('multiline'=>true, 'lineWidth'=>0, 'borderStyle'=>'none'), array('v'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'dv'=>'Lorem ipsum dolor sit amet, consectetur adipiscing elit.')); -$pdf->Ln(19); - -// Listbox -$pdf->Cell(35, 5, 'List:'); -$pdf->ListBox('listbox', 60, 15, array('', 'item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7'), array('multipleSelection'=>'true')); -$pdf->Ln(20); - -// E-mail -$pdf->Cell(35, 5, 'E-mail:'); -$pdf->TextField('email', 50, 5); -$pdf->Ln(6); - -// Date of the day -$pdf->Cell(35, 5, 'Date:'); -$pdf->TextField('date', 30, 5, array(), array('v'=>date('Y-m-d'), 'dv'=>date('Y-m-d'))); -$pdf->Ln(10); - -$pdf->setX(50); - -// Button to validate and print -$pdf->Button('print', 30, 10, 'Print', 'Print()', array('lineWidth'=>2, 'borderStyle'=>'beveled', 'fillColor'=>array(128, 196, 255), 'strokeColor'=>array(64, 64, 64))); - -// Reset Button -$pdf->Button('reset', 30, 10, 'Reset', array('S'=>'ResetForm'), array('lineWidth'=>2, 'borderStyle'=>'beveled', 'fillColor'=>array(128, 196, 255), 'strokeColor'=>array(64, 64, 64))); - -// Submit Button -$pdf->Button('submit', 30, 10, 'Submit', array('S'=>'SubmitForm', 'F'=>'http://localhost/printvars.php', 'Flags'=>array('ExportFormat')), array('lineWidth'=>2, 'borderStyle'=>'beveled', 'fillColor'=>array(128, 196, 255), 'strokeColor'=>array(64, 64, 64))); - -// Form validation functions -$js = <<IncludeJS($js); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_014.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_015.php b/tools/tcpdf/examples/example_015.php deleted file mode 100644 index 416883bde9..0000000000 --- a/tools/tcpdf/examples/example_015.php +++ /dev/null @@ -1,164 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 015'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 015', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// Bookmark($txt, $level=0, $y=-1, $page='', $style='', $color=array(0,0,0)) - -// set font -$pdf->setFont('times', 'B', 20); - -// add a page -$pdf->AddPage(); - -// set a bookmark for the current position -$pdf->Bookmark('Chapter 1', 0, 0, '', 'B', array(0,64,128)); - -// print a line using Cell() -$pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L'); - -$pdf->setFont('times', 'I', 14); -$pdf->Write(0, 'You can set PDF Bookmarks using the Bookmark() method. -You can set PDF Named Destinations using the setDestination() method.'); - -$pdf->setFont('times', 'B', 20); - -// add other pages and bookmarks - -$pdf->AddPage(); -$pdf->Bookmark('Paragraph 1.1', 1, 0, '', '', array(0,0,0)); -$pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Paragraph 1.2', 1, 0, '', '', array(0,0,0)); -$pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0, '', 'I', array(0,0,0)); -$pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Paragraph 1.3', 1, 0, '', '', array(0,0,0)); -$pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L'); - -$pdf->AddPage(); -// add a named destination so you can open this document at this page using the link: "example_015.pdf#chapter2" -$pdf->setDestination('chapter2', 0, ''); -// add a bookmark that points to a named destination -$pdf->Bookmark('Chapter 2', 0, 0, '', 'BI', array(128,0,0), -1, '#chapter2'); -$pdf->Cell(0, 10, 'Chapter 2', 0, 1, 'L'); -$pdf->setFont('times', 'I', 14); -$pdf->Write(0, 'Once saved, you can open this document at this page using the link: "example_015.pdf#chapter2".'); - -$pdf->AddPage(); -$pdf->setDestination('chapter3', 0, ''); -$pdf->setFont('times', 'B', 20); -$pdf->Bookmark('Chapter 3', 0, 0, '', 'B', array(0,64,128)); -$pdf->Cell(0, 10, 'Chapter 3', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->setDestination('chapter4', 0, ''); -$pdf->setFont('times', 'B', 20); -$pdf->Bookmark('Chapter 4', 0, 0, '', 'B', array(0,64,128)); -$pdf->Cell(0, 10, 'Chapter 4', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Chapter 5', 0, 0, '', 'B', array(0,128,0)); -$pdf->Cell(0, 10, 'Chapter 5', 0, 1, 'L'); -$txt = 'Example of File Attachment. -Double click on the icon to open the attached file.'; -$pdf->setFont('helvetica', '', 10); -$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -// attach an external file TXT file -$pdf->Annotation(20, 50, 5, 5, 'TXT file', array('Subtype'=>'FileAttachment', 'Name' => 'PushPin', 'FS' => 'data/utf8test.txt')); - -// attach an external file -$pdf->Annotation(50, 50, 5, 5, 'PDF file', array('Subtype'=>'FileAttachment', 'Name' => 'PushPin', 'FS' => 'example_012.pdf')); - -// add a bookmark that points to an embedded file -// NOTE: prefix the file name with the * character for generic file and with % character for PDF file -$pdf->Bookmark('TXT file', 0, 0, '', 'B', array(128,0,255), -1, '*utf8test.txt'); - -// add a bookmark that points to an embedded file -// NOTE: prefix the file name with the * character for generic file and with % character for PDF file -$pdf->Bookmark('PDF file', 0, 0, '', 'B', array(128,0,255), -1, '%example_012.pdf'); - -// add a bookmark that points to an external URL -$pdf->Bookmark('External URL', 0, 0, '', 'B', array(0,0,255), -1, 'http://www.tcpdf.org'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_015.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_016.php b/tools/tcpdf/examples/example_016.php deleted file mode 100644 index f54a7463c6..0000000000 --- a/tools/tcpdf/examples/example_016.php +++ /dev/null @@ -1,136 +0,0 @@ -setProtection(array('print', 'copy'), '', null, 0, null); - -// Example with public-key -// To open the document you need to install the private key (tcpdf.p12) on the Acrobat Reader. The password is: 1234 -//$pdf->setProtection($permissions=array('print', 'copy'), $user_pass='', $owner_pass=null, $mode=1, $pubkeys=array(array('c' => 'file://../config/cert/tcpdf.crt', 'p' => array('print')))); - -// ********************************************************* - - -// set document information -$pdf->setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 016'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 016', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array('helvetica', '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array('helvetica', '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', '', 16); - -// add a page -$pdf->AddPage(); - -// set some text to print -$txt = <<Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_016.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_017.php b/tools/tcpdf/examples/example_017.php deleted file mode 100644 index 94f571b4d1..0000000000 --- a/tools/tcpdf/examples/example_017.php +++ /dev/null @@ -1,120 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 017'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 017', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 20); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of independent Multicell() columns', '', 0, 'L', true, 0, false, false, 0); - -$pdf->Ln(5); - -$pdf->setFont('times', '', 12); - -// create columns content -// create columns content -$left_column = '[LEFT COLUMN] left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column'."\n"; - -$right_column = '[RIGHT COLUMN] right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column'."\n"; - -// MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0) - -// set color for background -$pdf->setFillColor(255, 255, 200); - -// set color for text -$pdf->setTextColor(0, 63, 127); - -// write the first column -$pdf->MultiCell(80, 0, $left_column, 1, 'J', 1, 0, '', '', true, 0, false, true, 0); - -// set color for background -$pdf->setFillColor(215, 235, 255); - -// set color for text -$pdf->setTextColor(127, 31, 0); - -// write the second column -$pdf->MultiCell(80, 0, $right_column, 1, 'J', 1, 1, '', '', true, 0, false, true, 0); - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_017.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_018.php b/tools/tcpdf/examples/example_018.php deleted file mode 100644 index bacc94affd..0000000000 --- a/tools/tcpdf/examples/example_018.php +++ /dev/null @@ -1,130 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 018'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 018', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language dependent data: -$lg = Array(); -$lg['a_meta_charset'] = 'UTF-8'; -$lg['a_meta_dir'] = 'rtl'; -$lg['a_meta_language'] = 'fa'; -$lg['w_page'] = 'page'; - -// set some language-dependent strings (optional) -$pdf->setLanguageArray($lg); - -// --------------------------------------------------------- - -// set font -$pdf->setFont('dejavusans', '', 12); - -// add a page -$pdf->AddPage(); - -// Persian and English content -$htmlpersian = 'Persian example:
      سلام بالاخره مشکل PDF فارسی به طور کامل حل شد. اینم یک نمونش.
      مشکل حرف \"ژ\" در بعضی کلمات مانند کلمه ویژه نیز بر طرف شد.
      نگارش حروف لام و الف پشت سر هم نیز تصحیح شد.
      با تشکر از "Asuni Nicola" و محمد علی گل کار برای پشتیبانی زبان فارسی.'; -$pdf->WriteHTML($htmlpersian, true, 0, true, 0); - -// set LTR direction for english translation -$pdf->setRTL(false); - -$pdf->setFontSize(10); - -// print newline -$pdf->Ln(); - -// Persian and English content -$htmlpersiantranslation = 'Hi, At last Problem of Persian PDF Solved completely. This is a example for it.
      Problem of "jeh" letter in some word like "ویژه" (=special) fix too.
      The joining of laa and alf letter fix now.
      Special thanks to "Nicola Asuni" and "Mohamad Ali Golkar" for Persian support.
      '; -$pdf->WriteHTML($htmlpersiantranslation, true, 0, true, 0); - -// Restore RTL direction -$pdf->setRTL(true); - -// set font -$pdf->setFont('aefurat', '', 18); - -// print newline -$pdf->Ln(); - -// Arabic and English content -$pdf->Cell(0, 12, 'بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ',0,1,'C'); -$htmlcontent = 'تمَّ بِحمد الله حلّ مشكلة الكتابة باللغة العربية في ملفات الـPDF مع دعم الكتابة من اليمين إلى اليسار والحركَات .
      تم الحل بواسطة صالح المطرفي و Asuni Nicola . '; -$pdf->WriteHTML($htmlcontent, true, 0, true, 0); - -// set LTR direction for english translation -$pdf->setRTL(false); - -// print newline -$pdf->Ln(); - -$pdf->setFont('aealarabiya', '', 18); - -// Arabic and English content -$htmlcontent2 = 'This is Arabic "العربية" Example With TCPDF.'; -$pdf->WriteHTML($htmlcontent2, true, 0, true, 0); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_018.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_019.php b/tools/tcpdf/examples/example_019.php deleted file mode 100644 index f53a34eae6..0000000000 --- a/tools/tcpdf/examples/example_019.php +++ /dev/null @@ -1,100 +0,0 @@ -setDocInfoUnicode(true); - -// set document information -$pdf->setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni [€]'); -$pdf->setTitle('TCPDF Example 019'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 019', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language dependent data: -$lg = Array(); -$lg['a_meta_charset'] = 'ISO-8859-1'; -$lg['a_meta_dir'] = 'ltr'; -$lg['a_meta_language'] = 'en'; -$lg['w_page'] = 'page'; - -// set some language-dependent strings (optional) -$pdf->setLanguageArray($lg); - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 12); - -// add a page -$pdf->AddPage(); - -// set color for background -$pdf->setFillColor(200, 255, 200); - -$txt = 'An alternative configuration file is used on this example. -Check the definition of the K_TCPDF_EXTERNAL_CONFIG constant on the source code.'; - -// print some text -$pdf->MultiCell(0, 0, $txt."\n", 1, 'J', 1, 1, '', '', true, 0, false, true, 0); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_019.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_020.php b/tools/tcpdf/examples/example_020.php deleted file mode 100644 index 32c16eacb9..0000000000 --- a/tools/tcpdf/examples/example_020.php +++ /dev/null @@ -1,149 +0,0 @@ -getPage(); - $y_start = $this->GetY(); - - // write the left cell - $this->MultiCell(40, 0, $left, 1, 'R', 1, 2, '', '', true, 0); - - $page_end_1 = $this->getPage(); - $y_end_1 = $this->GetY(); - - $this->setPage($page_start); - - // write the right cell - $this->MultiCell(0, 0, $right, 1, 'J', 0, 1, $this->GetX() ,$y_start, true, 0); - - $page_end_2 = $this->getPage(); - $y_end_2 = $this->GetY(); - - // set the new row position by case - if (max($page_end_1,$page_end_2) == $page_start) { - $ynew = max($y_end_1, $y_end_2); - } elseif ($page_end_1 == $page_end_2) { - $ynew = max($y_end_1, $y_end_2); - } elseif ($page_end_1 > $page_end_2) { - $ynew = $y_end_1; - } else { - $ynew = $y_end_2; - } - - $this->setPage(max($page_end_1,$page_end_2)); - $this->setXY($this->GetX(),$ynew); - } - -} - -// create new PDF document -$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); - -// set document information -$pdf->setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 020'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 020', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 20); -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of text layout using Multicell()', '', 0, 'L', true, 0, false, false, 0); - -$pdf->Ln(5); - -$pdf->setFont('times', '', 9); - -//$pdf->setCellPadding(0); -//$pdf->setLineWidth(2); - -// set color for background -$pdf->setFillColor(255, 255, 200); - -$text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc. - -Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa.'; - -// print some rows just as example -for ($i = 0; $i < 10; ++$i) { - $pdf->MultiRow('Row '.($i+1), $text."\n"); -} - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_020.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_021.php b/tools/tcpdf/examples/example_021.php deleted file mode 100644 index 98ae49b1f6..0000000000 --- a/tools/tcpdf/examples/example_021.php +++ /dev/null @@ -1,93 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 021'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 021', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 9); - -// add a page -$pdf->AddPage(); - -// create some HTML content -$html = '

      Example of HTML text flow

      Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?

      A + B = C    ->    C - B = A    ->    C - A = B ->    A + B = C    ->    C - B = A    ->    C - A = B ->    A + B = C    ->    C - B = A    ->    C - A = B ->    A + B = C    ->    C - B = A    ->    C - A = B    ->    A + B = C    ->    C - B = A    ->    C - A = B ->    A + B = C    ->    C - B = A    ->    C - A = B ->    A + B = C    ->    C - B = A    ->    C - A = B ->    A + B = C    ->    C - B = A    ->    C - A = B

      BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined BoldItalicUnderlined'; - -// output the HTML content -$pdf->writeHTML($html, true, 0, true, 0); - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_021.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_022.php b/tools/tcpdf/examples/example_022.php deleted file mode 100644 index 416108a96e..0000000000 --- a/tools/tcpdf/examples/example_022.php +++ /dev/null @@ -1,148 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 022'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 022', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// check also the following methods: -// setDrawColorArray() -// setFillColorArray() -// setTextColorArray() - -// set font -$pdf->setFont('helvetica', 'B', 18); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of CMYK, RGB and Grayscale colours', '', 0, 'L', true, 0, false, false, 0); - -// define style for border -$border_style = array('all' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'phase' => 0)); - -// --- CMYK ------------------------------------------------ - -$pdf->setDrawColor(50, 0, 0, 0); -$pdf->setFillColor(100, 0, 0, 0); -$pdf->setTextColor(100, 0, 0, 0); -$pdf->Rect(30, 60, 30, 30, 'DF', $border_style); -$pdf->Text(30, 92, 'Cyan'); - -$pdf->setDrawColor(0, 50, 0, 0); -$pdf->setFillColor(0, 100, 0, 0); -$pdf->setTextColor(0, 100, 0, 0); -$pdf->Rect(70, 60, 30, 30, 'DF', $border_style); -$pdf->Text(70, 92, 'Magenta'); - -$pdf->setDrawColor(0, 0, 50, 0); -$pdf->setFillColor(0, 0, 100, 0); -$pdf->setTextColor(0, 0, 100, 0); -$pdf->Rect(110, 60, 30, 30, 'DF', $border_style); -$pdf->Text(110, 92, 'Yellow'); - -$pdf->setDrawColor(0, 0, 0, 50); -$pdf->setFillColor(0, 0, 0, 100); -$pdf->setTextColor(0, 0, 0, 100); -$pdf->Rect(150, 60, 30, 30, 'DF', $border_style); -$pdf->Text(150, 92, 'Black'); - -// --- RGB ------------------------------------------------- - -$pdf->setDrawColor(255, 127, 127); -$pdf->setFillColor(255, 0, 0); -$pdf->setTextColor(255, 0, 0); -$pdf->Rect(30, 110, 30, 30, 'DF', $border_style); -$pdf->Text(30, 142, 'Red'); - -$pdf->setDrawColor(127, 255, 127); -$pdf->setFillColor(0, 255, 0); -$pdf->setTextColor(0, 255, 0); -$pdf->Rect(70, 110, 30, 30, 'DF', $border_style); -$pdf->Text(70, 142, 'Green'); - -$pdf->setDrawColor(127, 127, 255); -$pdf->setFillColor(0, 0, 255); -$pdf->setTextColor(0, 0, 255); -$pdf->Rect(110, 110, 30, 30, 'DF', $border_style); -$pdf->Text(110, 142, 'Blue'); - -// --- GRAY ------------------------------------------------ - -$pdf->setDrawColor(191); -$pdf->setFillColor(127); -$pdf->setTextColor(127); -$pdf->Rect(30, 160, 30, 30, 'DF', $border_style); -$pdf->Text(30, 192, 'Gray'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_022.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_023.php b/tools/tcpdf/examples/example_023.php deleted file mode 100644 index 5a509efd93..0000000000 --- a/tools/tcpdf/examples/example_023.php +++ /dev/null @@ -1,115 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 023'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 023', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', 'BI', 14); - -// Start First Page Group -$pdf->startPageGroup(); - -// add a page -$pdf->AddPage(); - -// set some text to print -$txt = <<Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -// add second page -$pdf->AddPage(); -$pdf->Cell(0, 10, 'This is the second page of group 1', 0, 1, 'L'); - -// Start Second Page Group -$pdf->startPageGroup(); - -// add some pages -$pdf->AddPage(); -$pdf->Cell(0, 10, 'This is the first page of group 2', 0, 1, 'L'); -$pdf->AddPage(); -$pdf->Cell(0, 10, 'This is the second page of group 2', 0, 1, 'L'); -$pdf->AddPage(); -$pdf->Cell(0, 10, 'This is the third page of group 2', 0, 1, 'L'); -$pdf->AddPage(); -$pdf->Cell(0, 10, 'This is the fourth page of group 2', 0, 1, 'L'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_023.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_024.php b/tools/tcpdf/examples/example_024.php deleted file mode 100644 index f786b11238..0000000000 --- a/tools/tcpdf/examples/example_024.php +++ /dev/null @@ -1,142 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 024'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 024', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', '', 18); - -// add a page -$pdf->AddPage(); - -/* - * setVisibility() allows to restrict the rendering of some - * elements to screen or printout. This can be useful, for - * instance, to put a background image or color that will - * show on screen but won't print. - */ - -$txt = 'You can limit the visibility of PDF objects to screen or printer by using the setVisibility() method. -Check the print preview of this document to display the alternative text.'; - -$pdf->Write(0, $txt, '', 0, '', true, 0, false, false, 0); - -// change font size -$pdf->setFontSize(40); - -// change text color -$pdf->setTextColor(0,63,127); - -// set visibility only for screen -$pdf->setVisibility('screen'); - -// write something only for screen -$pdf->Write(0, '[This line is for display]', '', 0, 'C', true, 0, false, false, 0); - -// set visibility only for print -$pdf->setVisibility('print'); - -// change text color -$pdf->setTextColor(127,0,0); - -// write something only for print -$pdf->Write(0, '[This line is for printout]', '', 0, 'C', true, 0, false, false, 0); - -// restore visibility -$pdf->setVisibility('all'); - -// --------------------------------------------------------- - -// LAYERS - -// start a new layer -$pdf->startLayer('layer1', true, true); - -// change font size -$pdf->setFontSize(18); - -// change text color -$pdf->setTextColor(0,127,0); - -$txt = 'Using the startLayer() method you can group PDF objects into layers. -This text is on "layer1".'; - -// write something -$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -// close the current layer -$pdf->endLayer(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_024.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_025.php b/tools/tcpdf/examples/example_025.php deleted file mode 100644 index 9e441be9e8..0000000000 --- a/tools/tcpdf/examples/example_025.php +++ /dev/null @@ -1,120 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 025'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 025', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 12); - -// add a page -$pdf->AddPage(); - -$txt = 'You can set the transparency of PDF objects using the setAlpha() method.'; -$pdf->Write(0, $txt, '', 0, '', true, 0, false, false, 0); - -/* - * setAlpha() gives transparency support. You can set the - * alpha channel from 0 (fully transparent) to 1 (fully - * opaque). It applies to all elements (text, drawings, - * images). - */ - -$pdf->setLineWidth(2); - -// draw opaque red square -$pdf->setFillColor(255, 0, 0); -$pdf->setDrawColor(127, 0, 0); -$pdf->Rect(30, 40, 60, 60, 'DF'); - -// set alpha to semi-transparency -$pdf->setAlpha(0.5); - -// draw green square -$pdf->setFillColor(0, 255, 0); -$pdf->setDrawColor(0, 127, 0); -$pdf->Rect(50, 60, 60, 60, 'DF'); - -// draw blue square -$pdf->setFillColor(0, 0, 255); -$pdf->setDrawColor(0, 0, 127); -$pdf->Rect(70, 80, 60, 60, 'DF'); - -// draw jpeg image -$pdf->Image('images/image_demo.jpg', 90, 100, 60, 60, '', 'http://www.tcpdf.org', '', true, 72); - -// restore full opacity -$pdf->setAlpha(1); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_025.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_026.php b/tools/tcpdf/examples/example_026.php deleted file mode 100644 index 8cde97130d..0000000000 --- a/tools/tcpdf/examples/example_026.php +++ /dev/null @@ -1,146 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 026'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 026', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 22); - -// add a page -$pdf->AddPage(); - -// set color for text stroke -$pdf->setDrawColor(255,0,0); - - -$pdf->setTextRenderingMode($stroke=0, $fill=true, $clip=false); -$pdf->Write(0, 'Fill text', '', 0, '', true, 0, false, false, 0); - -$pdf->setTextRenderingMode($stroke=0.2, $fill=false, $clip=false); -$pdf->Write(0, 'Stroke text', '', 0, '', true, 0, false, false, 0); - -$pdf->setTextRenderingMode($stroke=0.2, $fill=true, $clip=false); -$pdf->Write(0, 'Fill, then stroke text', '', 0, '', true, 0, false, false, 0); - -$pdf->setTextRenderingMode($stroke=0, $fill=false, $clip=false); -$pdf->Write(0, 'Neither fill nor stroke text (invisible)', '', 0, '', true, 0, false, false, 0); - - -// * * * CLIPPING MODES * * * * * * * * * * * * * * * * * * - -$pdf->StartTransform(); -$pdf->setTextRenderingMode($stroke=0, $fill=true, $clip=true); -$pdf->Write(0, 'Fill text and add to path for clipping', '', 0, '', true, 0, false, false, 0); -$pdf->Image('images/image_demo.jpg', 15, 65, 170, 10, '', '', '', true, 72); -$pdf->StopTransform(); - -$pdf->StartTransform(); -$pdf->setTextRenderingMode($stroke=0.3, $fill=false, $clip=true); -$pdf->Write(0, 'Stroke text and add to path for clipping', '', 0, '', true, 0, false, false, 0); -$pdf->Image('images/image_demo.jpg', 15, 75, 170, 10, '', '', '', true, 72); -$pdf->StopTransform(); - -$pdf->StartTransform(); -$pdf->setTextRenderingMode($stroke=0.3, $fill=true, $clip=true); -$pdf->Write(0, 'Fill, then stroke text and add to path for clipping', '', 0, '', true, 0, false, false, 0); -$pdf->Image('images/image_demo.jpg', 15, 85, 170, 10, '', '', '', true, 72); -$pdf->StopTransform(); - -$pdf->StartTransform(); -$pdf->setTextRenderingMode($stroke=0, $fill=false, $clip=true); -$pdf->Write(0, 'Add text to path for clipping', '', 0, '', true, 0, false, false, 0); -$pdf->Image('images/image_demo.jpg', 15, 95, 170, 10, '', '', '', true, 72); -$pdf->StopTransform(); - -// reset text rendering mode -$pdf->setTextRenderingMode($stroke=0, $fill=true, $clip=false); - -// * * * HTML MODE * * * * * * * * * * * * * * * * * * * * * - -// The following attributes were added to HTML: -// stroke : stroke width -// strokecolor : stroke color -// fill : true (default) to fill the font, false otherwise - - -// create some HTML content with text rendering modes -$html = 'HTML Fill text
      '; -$html .= 'HTML Stroke text
      '; -$html .= 'HTML Fill, then stroke text
      '; -$html .= 'HTML Neither fill nor stroke text (invisible)
      '; - -// output the HTML content -$pdf->writeHTML($html, true, 0, true, 0); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_026.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_027.php b/tools/tcpdf/examples/example_027.php deleted file mode 100644 index d7399844a7..0000000000 --- a/tools/tcpdf/examples/example_027.php +++ /dev/null @@ -1,420 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 027'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 027', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set a barcode on the page footer -$pdf->setBarcode(date('Y-m-d H:i:s')); - -// set font -$pdf->setFont('helvetica', '', 11); - -// add a page -$pdf->AddPage(); - -// print a message -$txt = "You can also export 1D barcodes in other formats (PNG, SVG, HTML). Check the examples inside the barcodes directory.\n"; -$pdf->MultiCell(70, 50, $txt, 0, 'J', false, 1, 125, 30, true, 0, false, true, 0, 'T', false); -$pdf->setY(30); - -// ----------------------------------------------------------------------------- - -$pdf->setFont('helvetica', '', 10); - -// define barcode style -$style = array( - 'position' => '', - 'align' => 'C', - 'stretch' => false, - 'fitwidth' => true, - 'cellfitalign' => '', - 'border' => true, - 'hpadding' => 'auto', - 'vpadding' => 'auto', - 'fgcolor' => array(0,0,0), - 'bgcolor' => false, //array(255,255,255), - 'text' => true, - 'font' => 'helvetica', - 'fontsize' => 8, - 'stretchtext' => 4 -); - -// PRINT VARIOUS 1D BARCODES - -// CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. -$pdf->Cell(0, 0, 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9', 0, 1); -$pdf->write1DBarcode('CODE 39', 'C39', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// CODE 39 + CHECKSUM -$pdf->Cell(0, 0, 'CODE 39 + CHECKSUM', 0, 1); -$pdf->write1DBarcode('CODE 39 +', 'C39+', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// CODE 39 EXTENDED -$pdf->Cell(0, 0, 'CODE 39 EXTENDED', 0, 1); -$pdf->write1DBarcode('CODE 39 E', 'C39E', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// CODE 39 EXTENDED + CHECKSUM -$pdf->Cell(0, 0, 'CODE 39 EXTENDED + CHECKSUM', 0, 1); -$pdf->write1DBarcode('CODE 39 E+', 'C39E+', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// CODE 93 - USS-93 -$pdf->Cell(0, 0, 'CODE 93 - USS-93', 0, 1); -$pdf->write1DBarcode('TEST93', 'C93', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// Standard 2 of 5 -$pdf->Cell(0, 0, 'Standard 2 of 5', 0, 1); -$pdf->write1DBarcode('1234567', 'S25', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// Standard 2 of 5 + CHECKSUM -$pdf->Cell(0, 0, 'Standard 2 of 5 + CHECKSUM', 0, 1); -$pdf->write1DBarcode('1234567', 'S25+', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// Interleaved 2 of 5 -$pdf->Cell(0, 0, 'Interleaved 2 of 5', 0, 1); -$pdf->write1DBarcode('1234567', 'I25', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// Interleaved 2 of 5 + CHECKSUM -$pdf->Cell(0, 0, 'Interleaved 2 of 5 + CHECKSUM', 0, 1); -$pdf->write1DBarcode('1234567', 'I25+', '', '', '', 18, 0.4, $style, 'N'); - - -// add a page ---------- -$pdf->AddPage(); - -// CODE 128 AUTO -$pdf->Cell(0, 0, 'CODE 128 AUTO', 0, 1); -$pdf->write1DBarcode('CODE 128 AUTO', 'C128', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// CODE 128 A -$pdf->Cell(0, 0, 'CODE 128 A', 0, 1); -$pdf->write1DBarcode('CODE 128 A', 'C128A', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// CODE 128 B -$pdf->Cell(0, 0, 'CODE 128 B', 0, 1); -$pdf->write1DBarcode('CODE 128 B', 'C128B', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// CODE 128 C -$pdf->Cell(0, 0, 'CODE 128 C', 0, 1); -$pdf->write1DBarcode('0123456789', 'C128C', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// EAN 8 -$pdf->Cell(0, 0, 'EAN 8', 0, 1); -$pdf->write1DBarcode('1234567', 'EAN8', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// EAN 13 -$pdf->Cell(0, 0, 'EAN 13', 0, 1); -$pdf->write1DBarcode('1234567890128', 'EAN13', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// UPC-A -$pdf->Cell(0, 0, 'UPC-A', 0, 1); -$pdf->write1DBarcode('12345678901', 'UPCA', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// UPC-E -$pdf->Cell(0, 0, 'UPC-E', 0, 1); -$pdf->write1DBarcode('04210000526', 'UPCE', '', '', '', 18, 0.4, $style, 'N'); - -// add a page ---------- -$pdf->AddPage(); - -// 5-Digits UPC-Based Extension -$pdf->Cell(0, 0, '5-Digits UPC-Based Extension', 0, 1); -$pdf->write1DBarcode('51234', 'EAN5', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// 2-Digits UPC-Based Extension -$pdf->Cell(0, 0, '2-Digits UPC-Based Extension', 0, 1); -$pdf->write1DBarcode('34', 'EAN2', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// MSI -$pdf->Cell(0, 0, 'MSI', 0, 1); -$pdf->write1DBarcode('80523', 'MSI', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// MSI + CHECKSUM (module 11) -$pdf->Cell(0, 0, 'MSI + CHECKSUM (module 11)', 0, 1); -$pdf->write1DBarcode('80523', 'MSI+', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// CODABAR -$pdf->Cell(0, 0, 'CODABAR', 0, 1); -$pdf->write1DBarcode('123456789', 'CODABAR', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// CODE 11 -$pdf->Cell(0, 0, 'CODE 11', 0, 1); -$pdf->write1DBarcode('123-456-789', 'CODE11', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// PHARMACODE -$pdf->Cell(0, 0, 'PHARMACODE', 0, 1); -$pdf->write1DBarcode('789', 'PHARMA', '', '', '', 18, 0.4, $style, 'N'); - -$pdf->Ln(); - -// PHARMACODE TWO-TRACKS -$pdf->Cell(0, 0, 'PHARMACODE TWO-TRACKS', 0, 1); -$pdf->write1DBarcode('105', 'PHARMA2T', '', '', '', 18, 2, $style, 'N'); - -// add a page ---------- -$pdf->AddPage(); - -// IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 -$pdf->Cell(0, 0, 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200', 0, 1); -$pdf->write1DBarcode('01234567094987654321-01234567891', 'IMB', '', '', '', 15, 0.6, $style, 'N'); - -$pdf->Ln(); - -// POSTNET -$pdf->Cell(0, 0, 'POSTNET', 0, 1); -$pdf->write1DBarcode('98000', 'POSTNET', '', '', '', 15, 0.6, $style, 'N'); - -$pdf->Ln(); - -// PLANET -$pdf->Cell(0, 0, 'PLANET', 0, 1); -$pdf->write1DBarcode('98000', 'PLANET', '', '', '', 15, 0.6, $style, 'N'); - -$pdf->Ln(); - -// RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) -$pdf->Cell(0, 0, 'RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)', 0, 1); -$pdf->write1DBarcode('SN34RD1A', 'RMS4CC', '', '', '', 15, 0.6, $style, 'N'); - -$pdf->Ln(); - -// KIX (Klant index - Customer index) -$pdf->Cell(0, 0, 'KIX (Klant index - Customer index)', 0, 1); -$pdf->write1DBarcode('SN34RDX1A', 'KIX', '', '', '', 15, 0.6, $style, 'N'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TEST BARCODE ALIGNMENTS - -// add a page -$pdf->AddPage(); - -// set a background color -$style['bgcolor'] = array(255,255,240); -$style['fgcolor'] = array(127,0,0); - -// Left position -$style['position'] = 'L'; -$pdf->write1DBarcode('LEFT', 'C128A', '', '', '', 15, 0.4, $style, 'N'); - -$pdf->Ln(2); - -// Center position -$style['position'] = 'C'; -$pdf->write1DBarcode('CENTER', 'C128A', '', '', '', 15, 0.4, $style, 'N'); - -$pdf->Ln(2); - -// Right position -$style['position'] = 'R'; -$pdf->write1DBarcode('RIGHT', 'C128A', '', '', '', 15, 0.4, $style, 'N'); - -$pdf->Ln(2); -// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - -$style['fgcolor'] = array(0,127,0); -$style['position'] = ''; -$style['stretch'] = false; // disable stretch -$style['fitwidth'] = false; // disable fitwidth - -// Left alignment -$style['align'] = 'L'; -$pdf->write1DBarcode('LEFT', 'C128A', '', '', '', 15, 0.4, $style, 'N'); - -$pdf->Ln(2); - -// Center alignment -$style['align'] = 'C'; -$pdf->write1DBarcode('CENTER', 'C128A', '', '', '', 15, 0.4, $style, 'N'); - -$pdf->Ln(2); - -// Right alignment -$style['align'] = 'R'; -$pdf->write1DBarcode('RIGHT', 'C128A', '', '', '', 15, 0.4, $style, 'N'); - -$pdf->Ln(2); -// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - -$style['fgcolor'] = array(0,64,127); -$style['position'] = ''; -$style['stretch'] = false; // disable stretch -$style['fitwidth'] = true; // disable fitwidth - -// Left alignment -$style['cellfitalign'] = 'L'; -$pdf->write1DBarcode('LEFT', 'C128A', 105, '', 90, 15, 0.4, $style, 'N'); - -$pdf->Ln(2); - -// Center alignment -$style['cellfitalign'] = 'C'; -$pdf->write1DBarcode('CENTER', 'C128A', 105, '', 90, 15, 0.4, $style, 'N'); - -$pdf->Ln(2); - -// Right alignment -$style['cellfitalign'] = 'R'; -$pdf->write1DBarcode('RIGHT', 'C128A', 105, '', 90, 15, 0.4, $style, 'N'); - -$pdf->Ln(2); -// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - -$style['fgcolor'] = array(127,0,127); - -// Left alignment -$style['position'] = 'L'; -$pdf->write1DBarcode('LEFT', 'C128A', '', '', '', 15, 0.4, $style, 'N'); - -$pdf->Ln(2); - -// Center alignment -$style['position'] = 'C'; -$pdf->write1DBarcode('CENTER', 'C128A', '', '', '', 15, 0.4, $style, 'N'); - -$pdf->Ln(2); - -// Right alignment -$style['position'] = 'R'; -$pdf->write1DBarcode('RIGHT', 'C128A', '', '', '', 15, 0.4, $style, 'N'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TEST BARCODE STYLE - -// define barcode style -$style = array( - 'position' => '', - 'align' => '', - 'stretch' => true, - 'fitwidth' => false, - 'cellfitalign' => '', - 'border' => true, - 'hpadding' => 'auto', - 'vpadding' => 'auto', - 'fgcolor' => array(0,0,128), - 'bgcolor' => array(255,255,128), - 'text' => true, - 'label' => 'CUSTOM LABEL', - 'font' => 'helvetica', - 'fontsize' => 8, - 'stretchtext' => 4 -); - -// CODE 39 EXTENDED + CHECKSUM -$pdf->Cell(0, 0, 'CODE 39 EXTENDED + CHECKSUM', 0, 1); -$pdf->setLineStyle(array('width' => 1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0))); -$pdf->write1DBarcode('CODE 39 E+', 'C39E+', '', '', 120, 25, 0.4, $style, 'N'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_027.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_028.php b/tools/tcpdf/examples/example_028.php deleted file mode 100644 index 312de99ff3..0000000000 --- a/tools/tcpdf/examples/example_028.php +++ /dev/null @@ -1,140 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 028'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// remove default header/footer -$pdf->setPrintHeader(false); -$pdf->setPrintFooter(false); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(10, PDF_MARGIN_TOP, 10); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -$pdf->setDisplayMode('fullpage', 'SinglePage', 'UseNone'); - -// set font -$pdf->setFont('times', 'B', 20); - -$pdf->AddPage('P', 'A4'); -$pdf->Cell(0, 0, 'A4 PORTRAIT', 1, 1, 'C'); - -$pdf->AddPage('L', 'A4'); -$pdf->Cell(0, 0, 'A4 LANDSCAPE', 1, 1, 'C'); - -$pdf->AddPage('P', 'A5'); -$pdf->Cell(0, 0, 'A5 PORTRAIT', 1, 1, 'C'); - -$pdf->AddPage('L', 'A5'); -$pdf->Cell(0, 0, 'A5 LANDSCAPE', 1, 1, 'C'); - -$pdf->AddPage('P', 'A6'); -$pdf->Cell(0, 0, 'A6 PORTRAIT', 1, 1, 'C'); - -$pdf->AddPage('L', 'A6'); -$pdf->Cell(0, 0, 'A6 LANDSCAPE', 1, 1, 'C'); - -$pdf->AddPage('P', 'A7'); -$pdf->Cell(0, 0, 'A7 PORTRAIT', 1, 1, 'C'); - -$pdf->AddPage('L', 'A7'); -$pdf->Cell(0, 0, 'A7 LANDSCAPE', 1, 1, 'C'); - - -// --- test backward editing --- - - -$pdf->setPage(1, true); -$pdf->setY(50); -$pdf->Cell(0, 0, 'A4 test', 1, 1, 'C'); - -$pdf->setPage(2, true); -$pdf->setY(50); -$pdf->Cell(0, 0, 'A4 test', 1, 1, 'C'); - -$pdf->setPage(3, true); -$pdf->setY(50); -$pdf->Cell(0, 0, 'A5 test', 1, 1, 'C'); - -$pdf->setPage(4, true); -$pdf->setY(50); -$pdf->Cell(0, 0, 'A5 test', 1, 1, 'C'); - -$pdf->setPage(5, true); -$pdf->setY(50); -$pdf->Cell(0, 0, 'A6 test', 1, 1, 'C'); - -$pdf->setPage(6, true); -$pdf->setY(50); -$pdf->Cell(0, 0, 'A6 test', 1, 1, 'C'); - -$pdf->setPage(7, true); -$pdf->setY(40); -$pdf->Cell(0, 0, 'A7 test', 1, 1, 'C'); - -$pdf->setPage(8, true); -$pdf->setY(40); -$pdf->Cell(0, 0, 'A7 test', 1, 1, 'C'); - -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_028.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_029.php b/tools/tcpdf/examples/example_029.php deleted file mode 100644 index fd7b6d87e5..0000000000 --- a/tools/tcpdf/examples/example_029.php +++ /dev/null @@ -1,126 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 029'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 029', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set array for viewer preferences -$preferences = array( - 'HideToolbar' => true, - 'HideMenubar' => true, - 'HideWindowUI' => true, - 'FitWindow' => true, - 'CenterWindow' => true, - 'DisplayDocTitle' => true, - 'NonFullScreenPageMode' => 'UseNone', // UseNone, UseOutlines, UseThumbs, UseOC - 'ViewArea' => 'CropBox', // CropBox, BleedBox, TrimBox, ArtBox - 'ViewClip' => 'CropBox', // CropBox, BleedBox, TrimBox, ArtBox - 'PrintArea' => 'CropBox', // CropBox, BleedBox, TrimBox, ArtBox - 'PrintClip' => 'CropBox', // CropBox, BleedBox, TrimBox, ArtBox - 'PrintScaling' => 'AppDefault', // None, AppDefault - 'Duplex' => 'DuplexFlipLongEdge', // Simplex, DuplexFlipShortEdge, DuplexFlipLongEdge - 'PickTrayByPDFSize' => true, - 'PrintPageRange' => array(1,1,2,3), - 'NumCopies' => 2 -); - -// Check the example n. 60 for advanced page settings - -// set pdf viewer preferences -$pdf->setViewerPreferences($preferences); - -// set font -$pdf->setFont('times', '', 14); - -// add a page -$pdf->AddPage(); - -// print a line -$pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 1', 1, 1, 'C'); - -$pdf->Ln(5); - -$pdf->Write(0, 'You can use the setViewerPreferences() method to change viewer preferences.', '', 0, 'L', true, 0, false, false, 0); - -// add a page -$pdf->AddPage(); -// print a line -$pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 2', 0, 0, 'C'); - -// add a page -$pdf->AddPage(); -// print a line -$pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 3', 0, 0, 'C'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_029.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_030.php b/tools/tcpdf/examples/example_030.php deleted file mode 100644 index 4b57b7ac33..0000000000 --- a/tools/tcpdf/examples/example_030.php +++ /dev/null @@ -1,190 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 030'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 030', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 20); - -// --- first page ------------------------------------------ - -// add a page -$pdf->AddPage(); - -$pdf->Cell(0, 0, 'TCPDF Gradients', 0, 1, 'C', 0, '', 0, false, 'T', 'M'); - -// set colors for gradients (r,g,b) or (grey 0-255) -$red = array(255, 0, 0); -$blue = array(0, 0, 200); -$yellow = array(255, 255, 0); -$green = array(0, 255, 0); -$white = array(255); -$black = array(0); - -// set the coordinates x1,y1,x2,y2 of the gradient (see linear_gradient_coords.jpg) -$coords = array(0, 0, 1, 0); - -// paint a linear gradient -$pdf->LinearGradient(20, 45, 80, 80, $red, $blue, $coords); - -// write label -$pdf->Text(20, 130, 'LinearGradient()'); - -// set the coordinates fx,fy,cx,cy,r of the gradient (see radial_gradient_coords.jpg) -$coords = array(0.5, 0.5, 1, 1, 1.2); - -// paint a radial gradient -$pdf->RadialGradient(110, 45, 80, 80, $white, $black, $coords); - -// write label -$pdf->Text(110, 130, 'RadialGradient()'); - -// paint a coons patch mesh with default coordinates -$pdf->CoonsPatchMesh(20, 155, 80, 80, $yellow, $blue, $green, $red); - -// write label -$pdf->Text(20, 240, 'CoonsPatchMesh()'); - -// set the coordinates for the cubic Bézier points x1,y1 ... x12, y12 of the patch (see coons_patch_mesh_coords.jpg) -$coords = array( - 0.00,0.00, 0.33,0.20, //lower left - 0.67,0.00, 1.00,0.00, 0.80,0.33, //lower right - 0.80,0.67, 1.00,1.00, 0.67,0.80, //upper right - 0.33,1.00, 0.00,1.00, 0.20,0.67, //upper left - 0.00,0.33); //lower left -$coords_min = 0; //minimum value of the coordinates -$coords_max = 1; //maximum value of the coordinates - -// paint a coons patch gradient with the above coordinates -$pdf->CoonsPatchMesh(110, 155, 80, 80, $yellow, $blue, $green, $red, $coords, $coords_min, $coords_max); - -// write label -$pdf->Text(110, 240, 'CoonsPatchMesh()'); - -// --- second page ----------------------------------------- -$pdf->AddPage(); - -// first patch: f = 0 -$patch_array[0]['f'] = 0; -$patch_array[0]['points'] = array( - 0.00,0.00, 0.33,0.00, - 0.67,0.00, 1.00,0.00, 1.00,0.33, - 0.8,0.67, 1.00,1.00, 0.67,0.8, - 0.33,1.80, 0.00,1.00, 0.00,0.67, - 0.00,0.33); -$patch_array[0]['colors'][0] = array('r' => 255, 'g' => 255, 'b' => 0); -$patch_array[0]['colors'][1] = array('r' => 0, 'g' => 0, 'b' => 255); -$patch_array[0]['colors'][2] = array('r' => 0, 'g' => 255,'b' => 0); -$patch_array[0]['colors'][3] = array('r' => 255, 'g' => 0,'b' => 0); - -// second patch - above the other: f = 2 -$patch_array[1]['f'] = 2; -$patch_array[1]['points'] = array( - 0.00,1.33, - 0.00,1.67, 0.00,2.00, 0.33,2.00, - 0.67,2.00, 1.00,2.00, 1.00,1.67, - 1.5,1.33); -$patch_array[1]['colors'][0]=array('r' => 0, 'g' => 0, 'b' => 0); -$patch_array[1]['colors'][1]=array('r' => 255, 'g' => 0, 'b' => 255); - -// third patch - right of the above: f = 3 -$patch_array[2]['f'] = 3; -$patch_array[2]['points'] = array( - 1.33,0.80, - 1.67,1.50, 2.00,1.00, 2.00,1.33, - 2.00,1.67, 2.00,2.00, 1.67,2.00, - 1.33,2.00); -$patch_array[2]['colors'][0] = array('r' => 0, 'g' => 255, 'b' => 255); -$patch_array[2]['colors'][1] = array('r' => 0, 'g' => 0, 'b' => 0); - -// fourth patch - below the above, which means left(?) of the above: f = 1 -$patch_array[3]['f'] = 1; -$patch_array[3]['points'] = array( - 2.00,0.67, - 2.00,0.33, 2.00,0.00, 1.67,0.00, - 1.33,0.00, 1.00,0.00, 1.00,0.33, - 0.8,0.67); -$patch_array[3]['colors'][0] = array('r' => 0, 'g' => 0, 'b' => 0); -$patch_array[3]['colors'][1] = array('r' => 0, 'g' => 0, 'b' => 255); - -$coords_min = 0; -$coords_max = 2; - -$pdf->CoonsPatchMesh(10, 45, 190, 200, '', '', '', '', $patch_array, $coords_min, $coords_max); - -// write label -$pdf->Text(10, 250, 'CoonsPatchMesh()'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_030.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_031.php b/tools/tcpdf/examples/example_031.php deleted file mode 100644 index 354ffcd765..0000000000 --- a/tools/tcpdf/examples/example_031.php +++ /dev/null @@ -1,105 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 031'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 031', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 20); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of PieSector() method.'); - -$xc = 105; -$yc = 100; -$r = 50; - -$pdf->setFillColor(0, 0, 255); -$pdf->PieSector($xc, $yc, $r, 20, 120, 'FD', false, 0, 2); - -$pdf->setFillColor(0, 255, 0); -$pdf->PieSector($xc, $yc, $r, 120, 250, 'FD', false, 0, 2); - -$pdf->setFillColor(255, 0, 0); -$pdf->PieSector($xc, $yc, $r, 250, 20, 'FD', false, 0, 2); - -// write labels -$pdf->setTextColor(255,255,255); -$pdf->Text(105, 65, 'BLUE'); -$pdf->Text(60, 95, 'GREEN'); -$pdf->Text(120, 115, 'RED'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_031.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_032.php b/tools/tcpdf/examples/example_032.php deleted file mode 100644 index dbba89a035..0000000000 --- a/tools/tcpdf/examples/example_032.php +++ /dev/null @@ -1,93 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 032'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 032', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 12); - -$pdf->AddPage(); - -$html = << -NOTE: Please use SVG format for a better vector support. -EOD; - -// Print text using writeHTMLCell() -$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); - -$pdf->ImageEps('images/tcpdf_box.ai', 10, 40, 150, '', 'http://www.tcpdf.org', true, '', '', 0, false); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_032.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_033.php b/tools/tcpdf/examples/example_033.php deleted file mode 100644 index 3696e52054..0000000000 --- a/tools/tcpdf/examples/example_033.php +++ /dev/null @@ -1,107 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 033'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 033', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// add a page -$pdf->AddPage(); - -// set default font subsetting mode -$pdf->setFontSubsetting(false); - -$pdf->setFont('helvetica', 'B', 20); - -$pdf->Write(0, 'Font Types', '', 0, 'C', 1, 0, false, false, 0); - -$pdf->Ln(10); - -$pdf->setFont('times', '', 10); - -$pdf->MultiCell(80, 0, "[Core font] : Cras eros leo, porttitor porta, accumsan fermentum, ornare ac, est. Praesent dui lorem, imperdiet at, cursus sed, facilisis aliquam, nibh. Nulla accumsan nonummy diam. Donec tempus. Etiam posuere. Proin lectus. Donec purus. Duis in sem pretium urna feugiat vehicula. Ut suscipit velit eget massa. Nam nonummy, enim commodo euismod placerat, tortor elit tempus lectus, quis suscipit metus lorem blandit turpis.\n", 1, 'J', 0, 1, '', '', true, 0); - -$pdf->Ln(2); - -$pdf->setFont('dejavusans', '', 10); - -$pdf->MultiCell(80, 0, "[True Type Unicode font] : Cras eros leo, porttitor porta, accumsan fermentum, ornare ac, est. Praesent dui lorem, imperdiet at, cursus sed, facilisis aliquam, nibh. Nulla accumsan nonummy diam. Donec tempus. Etiam posuere. Proin lectus. Donec purus. Duis in sem pretium urna feugiat vehicula. Ut suscipit velit eget massa. Nam nonummy, enim commodo euismod placerat, tortor elit tempus lectus, quis suscipit metus lorem blandit turpis.\n", 1, 'J', 0, 1, '', '', true, 0); - -$pdf->Ln(2); - -$pdf->setFont('cid0jp', '', 9); - -$pdf->MultiCell(80, 0, "[CID-0 font] : Cras eros leo, porttitor porta, accumsan fermentum, ornare ac, est. Praesent dui lorem, imperdiet at, cursus sed, facilisis aliquam, nibh. Nulla accumsan nonummy diam. Donec tempus. Etiam posuere. Proin lectus. Donec purus. Duis in sem pretium urna feugiat vehicula. Ut suscipit velit eget massa. Nam nonummy, enim commodo euismod placerat, tortor elit tempus lectus, quis suscipit metus lorem blandit turpis.\n", 1, 'J', 0, 1, '', '', true, 0); - - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_033.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_034.php b/tools/tcpdf/examples/example_034.php deleted file mode 100644 index 29b1563981..0000000000 --- a/tools/tcpdf/examples/example_034.php +++ /dev/null @@ -1,98 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 034'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 034', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 20); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Image Clipping using geometric functions', '', 0, 'C', 1, 0, false, false, 0); - -//Start Graphic Transformation -$pdf->StartTransform(); - -// set clipping mask -$pdf->StarPolygon(105, 100, 30, 10, 3, 0, 1, 'CNZ'); - -// draw jpeg image to be clipped -$pdf->Image('images/image_demo.jpg', 75, 70, 60, 60, '', 'http://www.tcpdf.org', '', true, 72); - -//Stop Graphic Transformation -$pdf->StopTransform(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_034.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_035.php b/tools/tcpdf/examples/example_035.php deleted file mode 100644 index 78cf99337b..0000000000 --- a/tools/tcpdf/examples/example_035.php +++ /dev/null @@ -1,113 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 035'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 035', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', 'BI', 16); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of SetLineStyle() method', '', 0, 'L', true, 0, false, false, 0); - -$pdf->Ln(); - -$pdf->setLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 4, 'color' => array(255, 0, 0))); -$pdf->setFillColor(255,255,128); -$pdf->setTextColor(0,0,128); - -$text="DUMMY"; - -$pdf->Cell(0, 0, $text, 1, 1, 'L', 1, 0); - -$pdf->Ln(); - -$pdf->setLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 255))); -$pdf->setFillColor(255,255,0); -$pdf->setTextColor(0,0,255); -$pdf->MultiCell(60, 4, $text, 1, 'C', 1, 0); - -$pdf->setLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 255, 0))); -$pdf->setFillColor(0,0,255); -$pdf->setTextColor(255,255,0); -$pdf->MultiCell(60, 4, $text, 'TB', 'C', 1, 0); - -$pdf->setLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 255))); -$pdf->setFillColor(0,255,0); -$pdf->setTextColor(255,0,255); -$pdf->MultiCell(60, 4, $text, 1, 'C', 1, 1); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_035.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_036.php b/tools/tcpdf/examples/example_036.php deleted file mode 100644 index 195d13993d..0000000000 --- a/tools/tcpdf/examples/example_036.php +++ /dev/null @@ -1,91 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 036'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 036', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', '', 16); - -// add a page -$pdf->AddPage(); - -$txt = 'Example of Text Annotation. -Move your mouse over the yellow box or double click on it to display the annotation text.'; -$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -// text annotation -$pdf->Annotation(83, 27, 10, 10, "Text annotation example\naccented letters test: àèéìòù", array('Subtype'=>'Text', 'Name' => 'Comment', 'T' => 'title example', 'Subj' => 'example', 'C' => array(255, 255, 0))); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_036.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_037.php b/tools/tcpdf/examples/example_037.php deleted file mode 100644 index af705b4247..0000000000 --- a/tools/tcpdf/examples/example_037.php +++ /dev/null @@ -1,149 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 037'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 037', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 11); - -// add a page -$pdf->AddPage(); - -$html = '

      Example of Spot Colors

      Spot colors are single ink colors, rather than colors produced by four (CMYK), six (CMYKOG) or more inks in the printing process (process colors). They can be obtained by special vendors, but often the printers have found their own way of mixing inks to match defined colors.

      As long as no open standard for spot colours exists, TCPDF users will have to buy a colour book by one of the colour manufacturers and insert the values and names of spot colours directly into the $spotcolor array in include/tcpdf_colors.php file, or define them using the AddSpotColor() method.

      Common industry standard spot colors are:
      ANPA-COLOR, DIC, FOCOLTONE, GCMI, HKS, PANTONE, TOYO, TRUMATCH.'; - -// Print text using writeHTMLCell() -$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, 'J', true); - - -$pdf->setFont('helvetica', '', 10); - -// Define some new spot colors -// $c, $m, $y and $k (2nd, 3rd, 4th and 5th parameter) are the CMYK color components. -// AddSpotColor($name, $c, $m, $y, $k) - -$pdf->AddSpotColor('My TCPDF Dark Green', 100, 50, 80, 45); -$pdf->AddSpotColor('My TCPDF Light Yellow', 0, 0, 55, 0); -$pdf->AddSpotColor('My TCPDF Black', 0, 0, 0, 100); -$pdf->AddSpotColor('My TCPDF Red', 30, 100, 90, 10); -$pdf->AddSpotColor('My TCPDF Green', 100, 30, 100, 0); -$pdf->AddSpotColor('My TCPDF Blue', 100, 60, 10, 5); -$pdf->AddSpotColor('My TCPDF Yellow', 0, 20, 100, 0); - -// Select the spot color -// $tint (the second parameter) is the intensity of the color (0-100). -// setTextSpotColor($name, $tint=100) -// setDrawSpotColor($name, $tint=100) -// setFillSpotColor($name, $tint=100) - -$pdf->setTextSpotColor('My TCPDF Black', 100); -$pdf->setDrawSpotColor('My TCPDF Black', 100); - -$starty = 100; - -// print some spot colors - -$pdf->setFillSpotColor('My TCPDF Dark Green', 100); -$pdf->Rect(30, $starty, 40, 20, 'DF'); -$pdf->Text(73, $starty + 8, 'My TCPDF Dark Green'); - -$starty += 24; -$pdf->setFillSpotColor('My TCPDF Light Yellow', 100); -$pdf->Rect(30, $starty, 40, 20, 'DF'); -$pdf->Text(73, $starty + 8, 'My TCPDF Light Yellow'); - - -// --- default values defined on spotcolors.php --- - -$starty += 24; -$pdf->setFillSpotColor('My TCPDF Red', 100); -$pdf->Rect(30, $starty, 40, 20, 'DF'); -$pdf->Text(73, $starty + 8, 'My TCPDF Red'); - -$starty += 24; -$pdf->setFillSpotColor('My TCPDF Green', 100); -$pdf->Rect(30, $starty, 40, 20, 'DF'); -$pdf->Text(73, $starty + 8, 'My TCPDF Green'); - -$starty += 24; -$pdf->setFillSpotColor('My TCPDF Blue', 100); -$pdf->Rect(30, $starty, 40, 20, 'DF'); -$pdf->Text(73, $starty + 8, 'My TCPDF Blue'); - -$starty += 24; -$pdf->setFillSpotColor('My TCPDF Yellow', 100); -$pdf->Rect(30, $starty, 40, 20, 'DF'); -$pdf->Text(73, $starty + 8, 'My TCPDF Yellow'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_037.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_038.php b/tools/tcpdf/examples/example_038.php deleted file mode 100644 index 568610acaf..0000000000 --- a/tools/tcpdf/examples/example_038.php +++ /dev/null @@ -1,94 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 038'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 038', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 20); - -// add a page -$pdf->AddPage(); - -$txt = 'Example of CID-0 CJK unembedded font. -To display extended text you must have CJK fonts installed for your PDF reader:'; -$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -// set font -$pdf->setFont('cid0jp', '', 40); - -$txt = 'こんにちは世界'; -$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_038.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_039.php b/tools/tcpdf/examples/example_039.php deleted file mode 100644 index 0eabd08409..0000000000 --- a/tools/tcpdf/examples/example_039.php +++ /dev/null @@ -1,106 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 039'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 039', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// add a page -$pdf->AddPage(); - -// set font -$pdf->setFont('helvetica', 'B', 20); - -$pdf->Write(0, 'Example of HTML Justification', '', 0, 'L', true, 0, false, false, 0); - -// create some HTML content -$html = 'a abc abcdefghijkl (abcdef) abcdefg abcdefghi a ((abc)) abcd test alt attribute abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc \(abcd\) abcdef abcdefg abcdefghi a abc \\\(abcd\\\) abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg start a abc before yellow color after a abc abcd abcdef abcdefg abcdefghi a abc abcd end abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi a abc abcd abcdef abcdefg abcdefghi
      abcd abcdef abcdefg abcdefghi
      abcd abcde abcdef
      '; - -// set core font -$pdf->setFont('helvetica', '', 10); - -// output the HTML content -$pdf->writeHTML($html, true, 0, true, true); - -$pdf->Ln(); - -// set UTF-8 Unicode font -$pdf->setFont('dejavusans', '', 10); - -// output the HTML content -$pdf->writeHTML($html, true, 0, true, true); - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_039.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_040.php b/tools/tcpdf/examples/example_040.php deleted file mode 100644 index 970370807e..0000000000 --- a/tools/tcpdf/examples/example_040.php +++ /dev/null @@ -1,118 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 040'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 040', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set display mode -$pdf->setDisplayMode($zoom='fullpage', $layout='TwoColumnRight', $mode='UseNone'); - -// set pdf viewer preferences -$pdf->setViewerPreferences(array('Duplex' => 'DuplexFlipLongEdge')); - -// set booklet mode -$pdf->setBooklet(true, 10, 30); - -// set core font -$pdf->setFont('helvetica', '', 18); - -// add a page (left page) -$pdf->AddPage(); - -$pdf->Write(0, 'Example of booklet mode', '', 0, 'L', true, 0, false, false, 0); - -// print a line using Cell() -$pdf->Cell(0, 0, 'PAGE 1', 1, 1, 'C'); - - -// add a page (right page) -$pdf->AddPage(); - -// print a line using Cell() -$pdf->Cell(0, 0, 'PAGE 2', 1, 1, 'C'); - - -// add a page (left page) -$pdf->AddPage(); - -// print a line using Cell() -$pdf->Cell(0, 0, 'PAGE 3', 1, 1, 'C'); - -// add a page (right page) -$pdf->AddPage(); - -// print a line using Cell() -$pdf->Cell(0, 0, 'PAGE 4', 1, 1, 'C'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_040.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_041.php b/tools/tcpdf/examples/example_041.php deleted file mode 100644 index 68ba81c761..0000000000 --- a/tools/tcpdf/examples/example_041.php +++ /dev/null @@ -1,93 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 041'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 041', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', '', 16); - -// add a page -$pdf->AddPage(); - - -$txt = 'Example of File Attachment. -Double click on the icon to open the attached file.'; -$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -// attach an external file -$pdf->Annotation(85, 27, 5, 5, 'text file', array('Subtype'=>'FileAttachment', 'Name' => 'PushPin', 'FS' => 'data/utf8test.txt')); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_041.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_042.php b/tools/tcpdf/examples/example_042.php deleted file mode 100644 index 039e3e1b8f..0000000000 --- a/tools/tcpdf/examples/example_042.php +++ /dev/null @@ -1,104 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 042'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 042', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set JPEG quality -//$pdf->setJPEGQuality(75); - -$pdf->setFont('helvetica', '', 18); - -// add a page -$pdf->AddPage(); - -// create background text -$background_text = str_repeat('TCPDF test PNG Alpha Channel ', 50); -$pdf->MultiCell(0, 5, $background_text, 0, 'J', 0, 2, '', '', true, 0, false); - -// --- Method (A) ------------------------------------------ -// the Image() method recognizes the alpha channel embedded on the image: - -$pdf->Image('images/image_with_alpha.png', 50, 50, 100, '', '', 'http://www.tcpdf.org', '', false, 300); - -// --- Method (B) ------------------------------------------ -// provide image + separate 8-bit mask - -// first embed mask image (w, h, x and y will be ignored, the image will be scaled to the target image's size) -$mask = $pdf->Image('images/alpha.png', 50, 140, 100, '', '', '', '', false, 300, '', true); - -// embed image, masked with previously embedded mask -$pdf->Image('images/img.png', 50, 140, 100, '', '', 'http://www.tcpdf.org', '', false, 300, '', false, $mask); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_042.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_043.php b/tools/tcpdf/examples/example_043.php deleted file mode 100644 index d73e46a5f2..0000000000 --- a/tools/tcpdf/examples/example_043.php +++ /dev/null @@ -1,87 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 043'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 043', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 16); - -// add a page -$pdf->AddPage(); - -// Multicell test -$pdf->MultiCell(0, 0, 'DISK CACHING TEST: check the parameters of the class constructor.', 1, 'L', 0, 0, '', '', true); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_043.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_044.php b/tools/tcpdf/examples/example_044.php deleted file mode 100644 index 668ccc5c89..0000000000 --- a/tools/tcpdf/examples/example_044.php +++ /dev/null @@ -1,130 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 044'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 044', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 40); - -// print a line using Cell() -$pdf->AddPage(); -$pdf->Cell(0, 10, 'PAGE: A', 0, 1, 'L'); - -// add some vertical space -$pdf->Ln(10); - -// print some text -$pdf->setFont('times', 'I', 16); -$txt = 'TCPDF allows you to Copy, Move and Delete pages.'; -$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -$pdf->setFont('helvetica', 'B', 40); - -$pdf->AddPage(); -$pdf->Cell(0, 10, 'PAGE: B', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Cell(0, 10, 'PAGE: D', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Cell(0, 10, 'PAGE: E', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Cell(0, 10, 'PAGE: E-2', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Cell(0, 10, 'PAGE: F', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Cell(0, 10, 'PAGE: C', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Cell(0, 10, 'PAGE: G', 0, 1, 'L'); - -// Move page 7 to page 3 -$pdf->movePage(7, 3); - -// Delete page 6 -$pdf->deletePage(6); - -$pdf->AddPage(); -$pdf->Cell(0, 10, 'PAGE: H', 0, 1, 'L'); - -// copy the second page -$pdf->copyPage(2); - -// NOTE: to insert a page to a previous position, you can add a new page to the end of document and then move it using movePage(). - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_044.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_045.php b/tools/tcpdf/examples/example_045.php deleted file mode 100644 index a7f6137310..0000000000 --- a/tools/tcpdf/examples/example_045.php +++ /dev/null @@ -1,143 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 045'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 045', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', 'B', 20); - -// add a page -$pdf->AddPage(); - -// set a bookmark for the current position -$pdf->Bookmark('Chapter 1', 0, 0, '', 'B', array(0,64,128)); - -// print a line using Cell() -$pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L'); - -// Create a fixed link to the first page using the * character -$index_link = $pdf->AddLink(); -$pdf->setLink($index_link, 0, '*1'); -$pdf->Cell(0, 10, 'Link to INDEX', 0, 1, 'R', false, $index_link); - -$pdf->AddPage(); -$pdf->Bookmark('Paragraph 1.1', 1, 0, '', '', array(128,0,0)); -$pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Paragraph 1.2', 1, 0, '', '', array(128,0,0)); -$pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0, '', 'I', array(0,128,0)); -$pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Paragraph 1.3', 1, 0, '', '', array(128,0,0)); -$pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L'); - -// fixed link to the first page using the * character -$html = 'link to INDEX (page 1)'; -$pdf->writeHTML($html, true, false, true, false, ''); - - -// add some pages and bookmarks -for ($i = 2; $i < 12; $i++) { - $pdf->AddPage(); - $pdf->Bookmark('Chapter '.$i, 0, 0, '', 'B', array(0,64,128)); - $pdf->Cell(0, 10, 'Chapter '.$i, 0, 1, 'L'); -} - -// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - -// add a new page for TOC -$pdf->addTOCPage(); - -// write the TOC title -$pdf->setFont('times', 'B', 16); -$pdf->MultiCell(0, 0, 'Table Of Content', 0, 'C', 0, 1, '', '', true, 0); -$pdf->Ln(); - -$pdf->setFont('dejavusans', '', 12); - -// add a simple Table Of Content at first page -// (check the example n. 59 for the HTML version) -$pdf->addTOC(1, 'courier', '.', 'INDEX', 'B', array(128,0,0)); - -// end of TOC page -$pdf->endTOCPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_045.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_046.php b/tools/tcpdf/examples/example_046.php deleted file mode 100644 index 1071b54f0e..0000000000 --- a/tools/tcpdf/examples/example_046.php +++ /dev/null @@ -1,125 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 046'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 046', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 20); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of Text Hyphenation', '', 0, 'L', true, 0, false, false, 0); - -$pdf->Ln(10); - -/* -Unicode Data for SHY: - Name : SOFT HYPHEN, commonly abbreviated as SHY - HTML Entity (decimal): ­ - HTML Entity (hex): ­ - HTML Entity (named): ­ - How to type in Microsoft Windows: [Alt +00AD] or [Alt 0173] - UTF-8 (hex): 0xC2 0xAD (c2ad) -*/ - -/* -// You can automatically add SOFT HYPHENS to your text using -// the hyphenateText() method, but this requires either an -// hyphenation pattern array of a hyphenation pattern TEX file. -// You can download hyphenation TEX patterns from: -// http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/ - -// EXAMPLE: - -$html = 'On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.'; - -$hyphen_patterns = $pdf->getHyphenPatternsFromTEX('hyphens/hyph-en-gb.tex'); - -$html = $pdf->hyphenateText($html, $hyphen_patterns, array(), 1, 2, 1, 8); -*/ - - -// HTML text with soft hyphens (­) -$html = 'On the other hand, we de­nounce with righ­teous in­dig­na­tion and dis­like men who are so be­guiled and de­mo­r­al­ized by the charms of plea­sure of the mo­ment, so blind­ed by de­sire, that they can­not fore­see the pain and trou­ble that are bound to en­sue; and equal blame be­longs to those who fail in their du­ty through weak­ness of will, which is the same as say­ing through shrink­ing from toil and pain. Th­ese cas­es are per­fect­ly sim­ple and easy to distin­guish. In a free hour, when our pow­er of choice is un­tram­melled and when noth­ing pre­vents our be­ing able to do what we like best, ev­ery plea­sure is to be wel­comed and ev­ery pain avoid­ed. But in cer­tain cir­cum­s­tances and ow­ing to the claims of du­ty or the obli­ga­tions of busi­ness it will fre­quent­ly oc­cur that plea­sures have to be re­pu­di­at­ed and an­noy­ances ac­cept­ed. The wise man there­fore al­ways holds in th­ese mat­ters to this prin­ci­ple of se­lec­tion: he re­jects plea­sures to se­cure other greater plea­sures, or else he en­dures pains to avoid worse pains.'; - -$pdf->setFont('times', '', 10); -$pdf->setDrawColor(255,0,0); -$pdf->setTextColor(0,63,127); - -// print a cell -$pdf->writeHTMLCell(50, 0, '', '', $html, 1, 1, 0, true, 'J'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_046.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_047.php b/tools/tcpdf/examples/example_047.php deleted file mode 100644 index a6bd1f528a..0000000000 --- a/tools/tcpdf/examples/example_047.php +++ /dev/null @@ -1,119 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 047'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 047', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 16); - -// add a page -$pdf->AddPage(); - -$txt = 'Example of Transactions. -TCPDF allows you to undo some operations using the Transactions. -Check the source code for further information.'; -$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -$pdf->Ln(5); - -$pdf->setFont('times', '', 12); - -// start transaction -$pdf->startTransaction(); - -$pdf->Write(0, "LINE 1\n"); -$pdf->Write(0, "LINE 2\n"); - -// restarts transaction -$pdf->startTransaction(); - -$pdf->Write(0, "LINE 3\n"); -$pdf->Write(0, "LINE 4\n"); - -// rolls back to the last (re)start -$pdf = $pdf->rollbackTransaction(); - -$pdf->Write(0, "LINE 5\n"); -$pdf->Write(0, "LINE 6\n"); - -// start transaction -$pdf->startTransaction(); - -$pdf->Write(0, "LINE 7\n"); - -// commit transaction (actually just frees memory) -$pdf->commitTransaction(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_047.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_048.php b/tools/tcpdf/examples/example_048.php deleted file mode 100644 index b7226fe18b..0000000000 --- a/tools/tcpdf/examples/example_048.php +++ /dev/null @@ -1,316 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 048'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 048', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 20); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of HTML tables', '', 0, 'L', true, 0, false, false, 0); - -$pdf->setFont('helvetica', '', 8); - -// ----------------------------------------------------------------------------- - -$tbl = << - - COL 1 - ROW 1
      COLSPAN 3 - COL 2 - ROW 1 - COL 3 - ROW 1 - - - COL 2 - ROW 2 - COLSPAN 2
      text line
      text line
      text line
      text line - COL 3 - ROW 2 - - - COL 3 - ROW 3 - - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -$tbl = << - - COL 1 - ROW 1
      COLSPAN 3
      text line
      text line
      text line
      text line
      text line
      text line - COL 2 - ROW 1 - COL 3 - ROW 1 - - - COL 2 - ROW 2 - COLSPAN 2
      text line
      text line
      text line
      text line - COL 3 - ROW 2 - - - COL 3 - ROW 3 - - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -$tbl = << - - COL 1 - ROW 1
      COLSPAN 3
      text line
      text line
      text line
      text line
      text line
      text line - COL 2 - ROW 1 - COL 3 - ROW 1 - - - COL 2 - ROW 2 - COLSPAN 2
      text line
      text line
      text line
      text line - COL 3 - ROW 2
      text line
      text line - - - COL 3 - ROW 3 - - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -$tbl = << - -Left column -Heading Column Span 5 -Heading Column Span 9 - - -Rowspan 2
      This is some text that fills the table cell. -span 2 -span 2 -2 rows -Colspan 8 - - -1a -2a -1b -2b -1 -2 -3 -4 -5 -6 -7 -8 - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -// Table with rowspans and THEAD -$tbl = << - - - A - XXXX - XXXX - XXXX - XXXX - XXXX - - - B - XXXX - XXXX - XXXX - XXXX - XXXX - - - - 1. - XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX - XXXX
      XXXX - XXXX
      XXXX - XXXX - XXXX
      XXXX - - - 2. - XXXX
      XXXX - XXXX
      XXXX - XXXX
      XXXX - XXXX
      XXXX - - - XXXX
      XXXX
      XXXX
      XXXX - XXXX
      XXXX - XXXX
      XXXX - - - RRRRRR
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX - XXXX
      XXXX - XXXX
      XXXX - - - 3. - XXXX1
      XXXX - XXXX
      XXXX - XXXX
      XXXX - - - 4. - XXXX
      XXXX - XXXX
      XXXX - XXXX
      XXXX - XXXX
      XXXX - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -// NON-BREAKING TABLE (nobr="true") - -$tbl = << - - NON-BREAKING TABLE - - - 1-1 - 1-2 - 1-3 - - - 2-1 - 3-2 - 3-3 - - - 3-1 - 3-2 - 3-3 - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -// NON-BREAKING ROWS (nobr="true") - -$tbl = << - - NON-BREAKING ROWS - - - ROW 1
      COLUMN 1 - ROW 1
      COLUMN 2 - ROW 1
      COLUMN 3 - - - ROW 2
      COLUMN 1 - ROW 2
      COLUMN 2 - ROW 2
      COLUMN 3 - - - ROW 3
      COLUMN 1 - ROW 3
      COLUMN 2 - ROW 3
      COLUMN 3 - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_048.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_049.php b/tools/tcpdf/examples/example_049.php deleted file mode 100644 index c8a8186627..0000000000 --- a/tools/tcpdf/examples/example_049.php +++ /dev/null @@ -1,128 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 049'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 049', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 10); - -// add a page -$pdf->AddPage(); - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - -IMPORTANT: -If you are printing user-generated content, the tcpdf tag should be considered unsafe. -This tag is disabled by default by the K_TCPDF_CALLS_IN_HTML constant on TCPDF configuration file. -Please use this feature only if you are in control of the HTML content and you are sure that it does not contain any harmful code. - -For security reasons, the content of the TCPDF tag must be prepared and encoded with the serializeTCPDFtag() method (see the example below). - - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - - -$html = '

      Test TCPDF Methods in HTML

      -

      IMPORTANT:

      -If you are using user-generated content, the tcpdf tag should be considered unsafe.
      -Please use this feature only if you are in control of the HTML content and you are sure that it does not contain any harmful code.
      -This feature is disabled by default by the K_TCPDF_CALLS_IN_HTML constant on TCPDF configuration file.
      -

      write1DBarcode method in HTML

      '; - -$data = $pdf->serializeTCPDFtag('write1DBarcode', array('CODE 39', 'C39', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N')); -$html .= ''; - -$data = $pdf->serializeTCPDFtag('write1DBarcode', array('CODE 128', 'C128', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N')); -$html .= ''; - -$data = $pdf->serializeTCPDFtag('AddPage'); -$html .= '

      Graphic Functions

      '; - -$data = $pdf->serializeTCPDFtag('SetDrawColor', array(0)); -$html .= ''; - -$data = $pdf->serializeTCPDFtag('Rect', array(50, 50, 40, 10, 'DF', array(), array(0,128,255))); -$html .= ''; - - -// output the HTML content -$pdf->writeHTML($html, true, 0, true, 0); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_049.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_050.php b/tools/tcpdf/examples/example_050.php deleted file mode 100644 index 6bbb299e26..0000000000 --- a/tools/tcpdf/examples/example_050.php +++ /dev/null @@ -1,212 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 050'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 050', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// NOTE: 2D barcode algorithms must be implemented on 2dbarcode.php class file. - -// set font -$pdf->setFont('helvetica', '', 11); - -// add a page -$pdf->AddPage(); - -// print a message -$txt = "You can also export 2D barcodes in other formats (PNG, SVG, HTML). Check the examples inside the barcode directory.\n"; -$pdf->MultiCell(70, 50, $txt, 0, 'J', false, 1, 125, 30, true, 0, false, true, 0, 'T', false); - - -$pdf->setFont('helvetica', '', 10); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// set style for barcode -$style = array( - 'border' => true, - 'vpadding' => 'auto', - 'hpadding' => 'auto', - 'fgcolor' => array(0,0,0), - 'bgcolor' => false, //array(255,255,255) - 'module_width' => 1, // width of a single module in points - 'module_height' => 1 // height of a single module in points -); - -// write RAW 2D Barcode - -$code = '111011101110111,010010001000010,010011001110010,010010000010010,010011101110010'; -$pdf->write2DBarcode($code, 'RAW', 80, 30, 30, 20, $style, 'N'); - -// write RAW2 2D Barcode -$code = '[111011101110111][010010001000010][010011001110010][010010000010010][010011101110010]'; -$pdf->write2DBarcode($code, 'RAW2', 80, 60, 30, 20, $style, 'N'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// set style for barcode -$style = array( - 'border' => 2, - 'vpadding' => 'auto', - 'hpadding' => 'auto', - 'fgcolor' => array(0,0,0), - 'bgcolor' => false, //array(255,255,255) - 'module_width' => 1, // width of a single module in points - 'module_height' => 1 // height of a single module in points -); - -// QRCODE,L : QR-CODE Low error correction -$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,L', 20, 30, 50, 50, $style, 'N'); -$pdf->Text(20, 25, 'QRCODE L'); - -// QRCODE,M : QR-CODE Medium error correction -$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,M', 20, 90, 50, 50, $style, 'N'); -$pdf->Text(20, 85, 'QRCODE M'); - -// QRCODE,Q : QR-CODE Better error correction -$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,Q', 20, 150, 50, 50, $style, 'N'); -$pdf->Text(20, 145, 'QRCODE Q'); - -// QRCODE,H : QR-CODE Best error correction -$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', 20, 210, 50, 50, $style, 'N'); -$pdf->Text(20, 205, 'QRCODE H'); - -// ------------------------------------------------------------------- -// PDF417 (ISO/IEC 15438:2006) - -/* - - The $type parameter can be simple 'PDF417' or 'PDF417' followed by a - number of comma-separated options: - - 'PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6' - - Possible options are: - - a = aspect ratio (width/height); - e = error correction level (0-8); - - Macro Control Block options: - - t = total number of macro segments; - s = macro segment index (0-99998); - f = file ID; - o0 = File Name (text); - o1 = Segment Count (numeric); - o2 = Time Stamp (numeric); - o3 = Sender (text); - o4 = Addressee (text); - o5 = File Size (numeric); - o6 = Checksum (numeric). - - Parameters t, s and f are required for a Macro Control Block, all other parameters are optional. - To use a comma character ',' on text options, replace it with the character 255: "\xff". - -*/ - -$pdf->write2DBarcode('www.tcpdf.org', 'PDF417', 80, 90, 0, 30, $style, 'N'); -$pdf->Text(80, 85, 'PDF417 (ISO/IEC 15438:2006)'); - -// ------------------------------------------------------------------- -// DATAMATRIX (ISO/IEC 16022:2006) - -$pdf->write2DBarcode('http://www.tcpdf.org', 'DATAMATRIX', 80, 150, 50, 50, $style, 'N'); -$pdf->Text(80, 145, 'DATAMATRIX (ISO/IEC 16022:2006)'); - -// ------------------------------------------------------------------- - -// new style -$style = array( - 'border' => 2, - 'padding' => 'auto', - 'fgcolor' => array(0,0,255), - 'bgcolor' => array(255,255,64) -); - -// QRCODE,H : QR-CODE Best error correction -$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', 80, 210, 50, 50, $style, 'N'); -$pdf->Text(80, 205, 'QRCODE H - COLORED'); - -// new style -$style = array( - 'border' => false, - 'padding' => 0, - 'fgcolor' => array(128,0,0), - 'bgcolor' => false -); - -// QRCODE,H : QR-CODE Best error correction -$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', 140, 210, 50, 50, $style, 'N'); -$pdf->Text(140, 205, 'QRCODE H - NO PADDING'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_050.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_051.php b/tools/tcpdf/examples/example_051.php deleted file mode 100644 index c3a9ce2f24..0000000000 --- a/tools/tcpdf/examples/example_051.php +++ /dev/null @@ -1,148 +0,0 @@ -getBreakMargin(); - // get current auto-page-break mode - $auto_page_break = $this->AutoPageBreak; - // disable auto-page-break - $this->setAutoPageBreak(false, 0); - // set bacground image - $img_file = K_PATH_IMAGES.'image_demo.jpg'; - $this->Image($img_file, null, 0, 210, 297, '', '', '', false, 300, 'C', false, false, 0); - // restore auto-page-break status - $this->setAutoPageBreak($auto_page_break, $bMargin); - // set the starting point for the page content - $this->setPageMark(); - } -} - -// create new PDF document -$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); - -// set document information -$pdf->setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 051'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(0); -$pdf->setFooterMargin(0); - -// remove default footer -$pdf->setPrintFooter(false); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', '', 48); - -// add a page -$pdf->AddPage(); - -// Print a text -$html = ' PAGE 1  -

      You can set a full page background.

      '; -$pdf->writeHTML($html, true, false, true, false, ''); - - -// add a page -$pdf->AddPage(); - -// Print a text -$html = ' PAGE 2 '; -$pdf->writeHTML($html, true, false, true, false, ''); - -// --- example with background set on page --- - -// remove default header -$pdf->setPrintHeader(false); - -// add a page -$pdf->AddPage(); - - -// -- set new background --- - -// get the current page break margin -$bMargin = $pdf->getBreakMargin(); -// get current auto-page-break mode -$auto_page_break = $pdf->getAutoPageBreak(); -// disable auto-page-break -$pdf->setAutoPageBreak(false, 0); -// set bacground image -$img_file = K_PATH_IMAGES.'image_demo.jpg'; -$pdf->Image($img_file, null, 0, 210, 297, '', '', '', false, 300, 'C', false, false, 0); -// restore auto-page-break status -$pdf->setAutoPageBreak($auto_page_break, $bMargin); -// set the starting point for the page content -$pdf->setPageMark(); - - -// Print a text -$html = 'PAGE 3'; -$pdf->writeHTML($html, true, false, true, false, ''); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_051.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_052.php b/tools/tcpdf/examples/example_052.php deleted file mode 100644 index 10cfb2e4f8..0000000000 --- a/tools/tcpdf/examples/example_052.php +++ /dev/null @@ -1,123 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 052'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 052', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -/* -NOTES: - - To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt - - To export crt to p12: openssl pkcs12 -export -in tcpdf.crt -out tcpdf.p12 - - To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes -*/ - -// set certificate file -$certificate = 'file://data/cert/tcpdf.crt'; - -// set additional information -$info = array( - 'Name' => 'TCPDF', - 'Location' => 'Office', - 'Reason' => 'Testing TCPDF', - 'ContactInfo' => 'http://www.tcpdf.org', - ); - -// set document signature -$pdf->setSignature($certificate, $certificate, 'tcpdfdemo', '', 2, $info); - -// set font. 'helvetica' MUST be used to avoid a PHP notice from PHP 7.4+ -$pdf->setFont('helvetica', '', 12); - -// add a page -$pdf->AddPage(); - -// print a line of text -$text = 'This is a digitally signed document using the default (example) tcpdf.crt certificate.
      To validate this signature you have to load the tcpdf.fdf on the Arobat Reader to add the certificate to List of Trusted Identities.

      For more information check the source code of this example and the source code documentation for the setSignature() method.

      www.tcpdf.org'; -$pdf->writeHTML($text, true, 0, true, 0); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// *** set signature appearance *** - -// create content for signature (image and/or text) -$pdf->Image('images/tcpdf_signature.png', 180, 60, 15, 15, 'PNG'); - -// define active area for signature appearance -$pdf->setSignatureAppearance(180, 60, 15, 15); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// *** set an empty signature appearance *** -$pdf->addEmptySignatureAppearance(180, 80, 15, 15); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_052.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_053.php b/tools/tcpdf/examples/example_053.php deleted file mode 100644 index dbeb67e25a..0000000000 --- a/tools/tcpdf/examples/example_053.php +++ /dev/null @@ -1,110 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 053'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 053', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('times', '', 14); - -// add a page -$pdf->AddPage(); - -// print a some of text -$text = 'This is an example of JavaScript usage on PDF documents.

      For more information check the source code of this example, the source code documentation for the IncludeJS() method and the JavaScript for Acrobat API Reference guide.

      www.tcpdf.org'; -$pdf->writeHTML($text, true, 0, true, 0); - -// write some JavaScript code -$js = <<IncludeJS($js); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_053.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_054.php b/tools/tcpdf/examples/example_054.php deleted file mode 100644 index 3a5011d496..0000000000 --- a/tools/tcpdf/examples/example_054.php +++ /dev/null @@ -1,131 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 054'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 054', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// IMPORTANT: disable font subsetting to allow users editing the document -$pdf->setFontSubsetting(false); - -// set font. 'helvetica' MUST be used to avoid a PHP notice from PHP 7.4+ -$pdf->setFont('helvetica', '', 10, '', false); - -// add a page -$pdf->AddPage(); - -// create some HTML content -$html = <<XHTML Form Example -
      -
      -

      -

      -

      -
      -
      -

      - -

      - -


      -
      -
      -


      - - - - -
      -
      -EOD; - -// output the HTML content -$pdf->writeHTML($html, true, 0, true, 0); - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_054.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_055.php b/tools/tcpdf/examples/example_055.php deleted file mode 100644 index 0f50da0965..0000000000 --- a/tools/tcpdf/examples/example_055.php +++ /dev/null @@ -1,118 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 055'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 055', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 14); - -// array of font names -$core_fonts = array('courier', 'courierB', 'courierI', 'courierBI', 'helvetica', 'helveticaB', 'helveticaI', 'helveticaBI', 'times', 'timesB', 'timesI', 'timesBI', 'symbol', 'zapfdingbats'); - -// set fill color -$pdf->setFillColor(221,238,255); - -// create one HTML table for each core font -foreach($core_fonts as $font) { - // add a page - $pdf->AddPage(); - - // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M') - - // set font for title - $pdf->setFont('helvetica', 'B', 16); - - // print font name - $pdf->Cell(0, 10, 'FONT: '.$font, 1, 1, 'C', true, '', 0, false, 'T', 'M'); - - // set font for chars - $pdf->setFont($font, '', 16); - - // print each character - for ($i = 0; $i < 256; ++$i) { - if (($i > 0) AND (($i % 16) == 0)) { - $pdf->Ln(); - } - $pdf->Cell(11.25, 11.25, TCPDF_FONTS::unichr($i), 1, 0, 'C', false, '', 0, false, 'T', 'M'); - } - - $pdf->Ln(20); - - // print a pangram - $pdf->Cell(0, 0, 'The quick brown fox jumps over the lazy dog', 0, 1, 'C', false, '', 0, false, 'T', 'M'); -} - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_055.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_056.php b/tools/tcpdf/examples/example_056.php deleted file mode 100644 index 40ef2508bf..0000000000 --- a/tools/tcpdf/examples/example_056.php +++ /dev/null @@ -1,135 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 056'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 056', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 18); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of Registration Marks, Crop Marks and Color Bars', '', 0, 'L', true, 0, false, false, 0); - -$pdf->Ln(5); - -// color registration bars - -// A,W,R,G,B,C,M,Y,K,RGB,CMYK,ALL,ALLSPOT, -$pdf->colorRegistrationBar(50, 70, 40, 40, true, false, 'A,R,G,B,C,M,Y,K'); -$pdf->colorRegistrationBar(90, 70, 40, 40, true, true, 'A,R,G,B,C,M,Y,K'); -$pdf->colorRegistrationBar(50, 115, 80, 5, false, true, 'A,W,R,G,B,C,M,Y,K,ALL'); -$pdf->colorRegistrationBar(135, 70, 5, 50, false, false, 'A,W,R,G,B,C,M,Y,K,ALL'); - -// corner crop marks - -$pdf->cropMark(50, 70, 10, 10, 'TL'); -$pdf->cropMark(140, 70, 10, 10, 'TR'); -$pdf->cropMark(50, 120, 10, 10, 'BL'); -$pdf->cropMark(140, 120, 10, 10, 'BR'); - -// various crop marks - -$pdf->cropMark(95, 65, 5, 5, 'LEFT,TOP,RIGHT', array(255,0,0)); -$pdf->cropMark(95, 125, 5, 5, 'LEFT,BOTTOM,RIGHT', array(255,0,0)); - -$pdf->cropMark(45, 95, 5, 5, 'TL,BL', array(0,255,0)); -$pdf->cropMark(145, 95, 5, 5, 'TR,BR', array(0,255,0)); - -$pdf->cropMark(95, 140, 5, 5, 'A,D', array(0,0,255)); - -// registration marks - -$pdf->registrationMark(40, 60, 5, false); -$pdf->registrationMark(150, 60, 5, true, array(0,0,0), array(255,255,0)); -$pdf->registrationMark(40, 130, 5, true, array(0,0,0), array(255,255,0)); -$pdf->registrationMark(150, 130, 5, false, array(100,100,100,100,'All'), array(0,0,0,0,'None')); - -// test registration bar with spot colors - -$pdf->AddSpotColor('My TCPDF Dark Green', 100, 50, 80, 45); -$pdf->AddSpotColor('My TCPDF Light Yellow', 0, 0, 55, 0); -$pdf->AddSpotColor('My TCPDF Black', 0, 0, 0, 100); -$pdf->AddSpotColor('My TCPDF Red', 30, 100, 90, 10); -$pdf->AddSpotColor('My TCPDF Green', 100, 30, 100, 0); -$pdf->AddSpotColor('My TCPDF Blue', 100, 60, 10, 5); -$pdf->AddSpotColor('My TCPDF Yellow', 0, 20, 100, 0); - -$pdf->colorRegistrationBar(50, 150, 80, 10, false, true, 'ALLSPOT'); - -// CMYK registration mark -$pdf->registrationMarkCMYK(150, 155, 8); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_056.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_057.php b/tools/tcpdf/examples/example_057.php deleted file mode 100644 index c0bbe4af30..0000000000 --- a/tools/tcpdf/examples/example_057.php +++ /dev/null @@ -1,270 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 057'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 057', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 20); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of alignment options for Cell()', '', 0, 'L', true, 0, false, false, 0); - -$pdf->setFont('helvetica', '', 11); - -// set border width -$pdf->setLineWidth(0.7); - -// set color for cell border -$pdf->setDrawColor(0,128,255); - -$pdf->setCellHeightRatio(3); - -$pdf->setXY(15, 60); - -// text on center -$pdf->Cell(30, 0, 'Top-Center', 1, $ln=0, 'C', 0, '', 0, false, 'T', 'C'); -$pdf->Cell(30, 0, 'Center-Center', 1, $ln=0, 'C', 0, '', 0, false, 'C', 'C'); -$pdf->Cell(30, 0, 'Bottom-Center', 1, $ln=0, 'C', 0, '', 0, false, 'B', 'C'); -$pdf->Cell(30, 0, 'Ascent-Center', 1, $ln=0, 'C', 0, '', 0, false, 'A', 'C'); -$pdf->Cell(30, 0, 'Baseline-Center', 1, $ln=0, 'C', 0, '', 0, false, 'L', 'C'); -$pdf->Cell(30, 0, 'Descent-Center', 1, $ln=0, 'C', 0, '', 0, false, 'D', 'C'); - - -$pdf->setXY(15, 90); - -// text on top -$pdf->Cell(30, 0, 'Top-Top', 1, $ln=0, 'C', 0, '', 0, false, 'T', 'T'); -$pdf->Cell(30, 0, 'Center-Top', 1, $ln=0, 'C', 0, '', 0, false, 'C', 'T'); -$pdf->Cell(30, 0, 'Bottom-Top', 1, $ln=0, 'C', 0, '', 0, false, 'B', 'T'); -$pdf->Cell(30, 0, 'Ascent-Top', 1, $ln=0, 'C', 0, '', 0, false, 'A', 'T'); -$pdf->Cell(30, 0, 'Baseline-Top', 1, $ln=0, 'C', 0, '', 0, false, 'L', 'T'); -$pdf->Cell(30, 0, 'Descent-Top', 1, $ln=0, 'C', 0, '', 0, false, 'D', 'T'); - - -$pdf->setXY(15, 120); - -// text on bottom -$pdf->Cell(30, 0, 'Top-Bottom', 1, $ln=0, 'C', 0, '', 0, false, 'T', 'B'); -$pdf->Cell(30, 0, 'Center-Bottom', 1, $ln=0, 'C', 0, '', 0, false, 'C', 'B'); -$pdf->Cell(30, 0, 'Bottom-Bottom', 1, $ln=0, 'C', 0, '', 0, false, 'B', 'B'); -$pdf->Cell(30, 0, 'Ascent-Bottom', 1, $ln=0, 'C', 0, '', 0, false, 'A', 'B'); -$pdf->Cell(30, 0, 'Baseline-Bottom', 1, $ln=0, 'C', 0, '', 0, false, 'L', 'B'); -$pdf->Cell(30, 0, 'Descent-Bottom', 1, $ln=0, 'C', 0, '', 0, false, 'D', 'B'); - - -// draw some reference lines -$linestyle = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(255, 0, 0)); -$pdf->Line(15, 60, 195, 60, $linestyle); -$pdf->Line(15, 90, 195, 90, $linestyle); -$pdf->Line(15, 120, 195, 120, $linestyle); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// Print an image to explain cell measures - -$pdf->Image('images/tcpdf_cell.png', 15, 160, 100, 100, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false); -$legend = 'LEGEND: - -X: cell x top-left origin (top-right for RTL) -Y: cell y top-left origin (top-right for RTL) -CW: cell width -CH: cell height -LW: line width -NRL: normal line position -EXT: external line position -INT: internal line position -ML: margin left -MR: margin right -MT: margin top -MB: margin bottom -PL: padding left -PR: padding right -PT: padding top -PB: padding bottom -TW: text width -FA: font ascent -FB: font baseline -FD: font descent'; -$pdf->setFont('helvetica', '', 10); -$pdf->setCellHeightRatio(1.25); -$pdf->MultiCell(0, 0, $legend, 0, 'L', false, 1, 125, 160, true, 0, false, true, 0, 'T', false); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// CELL BORDERS - -// add a page -$pdf->AddPage(); - -$pdf->setFont('helvetica', 'B', 20); - -$pdf->Write(0, 'Example of borders for Cell()', '', 0, 'L', true, 0, false, false, 0); - -$pdf->setFont('helvetica', '', 11); - -// set border width -$pdf->setLineWidth(0.508); - -// set color for cell border -$pdf->setDrawColor(0,128,255); - -// set filling color -$pdf->setFillColor(255,255,128); - -// set cell height ratio -$pdf->setCellHeightRatio(3); - -$pdf->Cell(30, 0, '1', 1, 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'LTRB', 'LTRB', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'LTR', 'LTR', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'TRB', 'TRB', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'LRB', 'LRB', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'LTB', 'LTB', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'LT', 'LT', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'TR', 'TR', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'RB', 'RB', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'LB', 'LB', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'LR', 'LR', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'TB', 'TB', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'L', 'L', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'T', 'T', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'R', 'R', 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(2); -$pdf->Cell(30, 0, 'B', 'B', 1, 'C', 1, '', 0, false, 'T', 'C'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// ADVANCED SETTINGS FOR CELL BORDERS - -// add a page -$pdf->AddPage(); - -$pdf->setFont('helvetica', 'B', 20); - -$pdf->Write(0, 'Example of advanced border settings for Cell()', '', 0, 'L', true, 0, false, false, 0); - -$pdf->setFont('helvetica', '', 11); - -// set border width -$pdf->setLineWidth(1); - -// set color for cell border -$pdf->setDrawColor(0,128,255); - -// set filling color -$pdf->setFillColor(255,255,128); - -$border = array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0))); -$pdf->Cell(30, 0, 'LTRB', $border, 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(5); - -$border = array( -'L' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0)), -'R' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 255)), -'T' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 255, 0)), -'B' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 255))); -$pdf->Cell(30, 0, 'LTRB', $border, 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(5); - -$border = array('mode' => 'ext', 'LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0))); -$pdf->Cell(30, 0, 'LTRB EXT', $border, 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(5); - -$border = array('mode' => 'int', 'LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0))); -$pdf->Cell(30, 0, 'LTRB INT', $border, 1, 'C', 1, '', 0, false, 'T', 'C'); -$pdf->Ln(5); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_057.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_058.php b/tools/tcpdf/examples/example_058.php deleted file mode 100644 index 583228bbcf..0000000000 --- a/tools/tcpdf/examples/example_058.php +++ /dev/null @@ -1,97 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 058'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 058', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 10); - -// add a page -$pdf->AddPage(); - -// NOTE: Uncomment the following line to rasterize SVG image using the ImageMagick library. -//$pdf->setRasterizeVectorImages(true); - -$pdf->ImageSVG($file='images/testsvg.svg', $x=15, $y=30, $w='', $h='', $link='http://www.tcpdf.org', $align='', $palign='', $border=1, $fitonpage=false); - -$pdf->ImageSVG($file='images/tux.svg', $x=30, $y=100, $w='', $h=100, $link='', $align='', $palign='', $border=0, $fitonpage=false); - -$pdf->setFont('helvetica', '', 8); -$pdf->setY(195); -$txt = '© The copyright holder of the above Tux image is Larry Ewing, allows anyone to use it for any purpose, provided that the copyright holder is properly attributed. Redistribution, derivative work, commercial use, and all other use is permitted.'; -$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_058.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_059.php b/tools/tcpdf/examples/example_059.php deleted file mode 100644 index 6f05b2e8ed..0000000000 --- a/tools/tcpdf/examples/example_059.php +++ /dev/null @@ -1,193 +0,0 @@ -tocpage) { - // *** replace the following parent::Header() with your code for TOC page - parent::Header(); - } else { - // *** replace the following parent::Header() with your code for normal pages - parent::Header(); - } - } - - /** - * Overwrite Footer() method. - * @public - */ - public function Footer() { - if ($this->tocpage) { - // *** replace the following parent::Footer() with your code for TOC page - parent::Footer(); - } else { - // *** replace the following parent::Footer() with your code for normal pages - parent::Footer(); - } - } - -} // end of class - -// create new PDF document -$pdf = new TOC_TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); - -// set document information -$pdf->setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 059'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 059', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// set font -$pdf->setFont('helvetica', '', 10); - -// --------------------------------------------------------- - -// create some content ... - -// add a page -$pdf->AddPage(); - -// set a bookmark for the current position -$pdf->Bookmark('Chapter 1', 0, 0, '', 'B', array(0,64,128)); - -// print a line using Cell() -$pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Paragraph 1.1', 1, 0, '', '', array(128,0,0)); -$pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Paragraph 1.2', 1, 0, '', '', array(128,0,0)); -$pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0, '', 'I', array(0,128,0)); -$pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L'); - -$pdf->AddPage(); -$pdf->Bookmark('Paragraph 1.3', 1, 0, '', '', array(128,0,0)); -$pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L'); - -// add some pages and bookmarks -for ($i = 2; $i < 12; $i++) { - $pdf->AddPage(); - $pdf->Bookmark('Chapter '.$i, 0, 0, '', 'B', array(0,64,128)); - $pdf->Cell(0, 10, 'Chapter '.$i, 0, 1, 'L'); -} - - -// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - -// add a new page for TOC -$pdf->addTOCPage(); - -// write the TOC title and/or other elements on the TOC page -$pdf->setFont('times', 'B', 16); -$pdf->MultiCell(0, 0, 'Table Of Content', 0, 'C', 0, 1, '', '', true, 0); -$pdf->Ln(); -$pdf->setFont('helvetica', '', 10); - -// define styles for various bookmark levels -$bookmark_templates = array(); - -/* - * The key of the $bookmark_templates array represent the bookmark level (from 0 to n). - * The following templates will be replaced with proper content: - * #TOC_DESCRIPTION# this will be replaced with the bookmark description; - * #TOC_PAGE_NUMBER# this will be replaced with page number. - * - * NOTES: - * If you want to align the page number on the right you have to use a monospaced font like courier, otherwise you can left align using any font type. - * The following is just an example, you can get various styles by combining various HTML elements. - */ - -// A monospaced font for the page number is mandatory to get the right alignment -$bookmark_templates[0] = '
      #TOC_DESCRIPTION##TOC_PAGE_NUMBER#
      '; -$bookmark_templates[1] = '
       #TOC_DESCRIPTION##TOC_PAGE_NUMBER#
      '; -$bookmark_templates[2] = '
       #TOC_DESCRIPTION##TOC_PAGE_NUMBER#
      '; -// add other bookmark level templates here ... - -// add table of content at page 1 -// (check the example n. 45 for a text-only TOC -$pdf->addHTMLTOC(1, 'INDEX', $bookmark_templates, true, 'B', array(128,0,0)); - -// end of TOC page -$pdf->endTOCPage(); - -// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_059.pdf', 'D'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_060.php b/tools/tcpdf/examples/example_060.php deleted file mode 100644 index dcdd9cc22c..0000000000 --- a/tools/tcpdf/examples/example_060.php +++ /dev/null @@ -1,110 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 060'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 060', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// set font -$pdf->setFont('helvetica', '', 20); - -// --------------------------------------------------------- - -// set page format (read source code documentation for further information) -$page_format = array( - 'MediaBox' => array ('llx' => 0, 'lly' => 0, 'urx' => 210, 'ury' => 297), - 'CropBox' => array ('llx' => 0, 'lly' => 0, 'urx' => 210, 'ury' => 297), - 'BleedBox' => array ('llx' => 5, 'lly' => 5, 'urx' => 205, 'ury' => 292), - 'TrimBox' => array ('llx' => 10, 'lly' => 10, 'urx' => 200, 'ury' => 287), - 'ArtBox' => array ('llx' => 15, 'lly' => 15, 'urx' => 195, 'ury' => 282), - 'Dur' => 3, - 'trans' => array( - 'D' => 1.5, - 'S' => 'Split', - 'Dm' => 'V', - 'M' => 'O' - ), - 'Rotate' => 90, - 'PZ' => 1, -); - -// Check the example n. 29 for viewer preferences - -// add first page --- -$pdf->AddPage('P', $page_format, false, false); -$pdf->Cell(0, 12, 'First Page', 1, 1, 'C'); - -// add second page --- -$page_format['Rotate'] = 270; -$pdf->AddPage('P', $page_format, false, false); -$pdf->Cell(0, 12, 'Second Page', 1, 1, 'C'); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_060.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_061.php b/tools/tcpdf/examples/example_061.php deleted file mode 100644 index 607547dfce..0000000000 --- a/tools/tcpdf/examples/example_061.php +++ /dev/null @@ -1,267 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 061'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 061', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 10); - -// add a page -$pdf->AddPage(); - -/* NOTE: - * ********************************************************* - * You can load external XHTML using : - * - * $html = file_get_contents('/path/to/your/file.html'); - * - * External CSS files will be automatically loaded. - * Sometimes you need to fix the path of the external CSS. - * ********************************************************* - */ - -// define some HTML content with style -$html = << - - -

      Example of XHTML + CSS

      - -

      Example of paragraph with class selector. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc.

      - -

      Example of paragraph with ID selector. Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa.

      - -
      example of DIV with border and fill. -
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. -
      text-transform LOWERCASE Lorem ipsum dolor sit amet, consectetur adipiscing elit. -
      text-transform uppercase Lorem ipsum dolor sit amet, consectetur adipiscing elit. -
      text-transform cAPITALIZE Lorem ipsum dolor sit amet, consectetur adipiscing elit. -
      - -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      No.XXXXXXXX XXXXXXXXXXXX
      1.XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXXXXXX
      XXXX
      2.XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      3.XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      4.XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      XXXX
      -EOF; - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// add a page -$pdf->AddPage(); - -$html = ' -

      HTML TIPS & TRICKS

      - -

      REMOVE CELL PADDING

      -
      $pdf->setCellPadding(0);
      -This is used to remove any additional vertical space inside a single cell of text. - -

      REMOVE TAG TOP AND BOTTOM MARGINS

      -
      $tagvs = array(\'p\' => array(0 => array(\'h\' => 0, \'n\' => 0), 1 => array(\'h\' => 0, \'n\' => 0)));
      -$pdf->setHtmlVSpace($tagvs);
      -Since the CSS margin command is not yet implemented on TCPDF, you need to set the spacing of block tags using the following method. - -

      SET LINE HEIGHT

      -
      $pdf->setCellHeightRatio(1.25);
      -You can use the following method to fine tune the line height (the number is a percentage relative to font height). - -

      CHANGE THE PIXEL CONVERSION RATIO

      -
      $pdf->setImageScale(0.47);
      -This is used to adjust the conversion ratio between pixels and document units. Increase the value to get smaller objects.
      -Since you are using pixel unit, this method is important to set theright zoom factor.

      -Suppose that you want to print a web page larger 1024 pixels to fill all the available page width.
      -An A4 page is larger 210mm equivalent to 8.268 inches, if you subtract 13mm (0.512") of margins for each side, the remaining space is 184mm (7.244 inches).
      -The default resolution for a PDF document is 300 DPI (dots per inch), so you have 7.244 * 300 = 2173.2 dots (this is the maximum number of points you can print at 300 DPI for the given width).
      -The conversion ratio is approximatively 1024 / 2173.2 = 0.47 px/dots
      -If the web page is larger 1280 pixels, on the same A4 page the conversion ratio to use is 1280 / 2173.2 = 0.59 pixels/dots'; - -// output the HTML content -$pdf->writeHTML($html, true, false, true, false, ''); - -// reset pointer to the last page -$pdf->lastPage(); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_061.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_062.php b/tools/tcpdf/examples/example_062.php deleted file mode 100644 index d0bf89fe9f..0000000000 --- a/tools/tcpdf/examples/example_062.php +++ /dev/null @@ -1,142 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 062'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 062', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 20); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'XObject Templates', '', 0, 'C', 1, 0, false, false, 0); - -/* - * An XObject Template is a PDF block that is a self-contained - * description of any sequence of graphics objects (including path - * objects, text objects, and sampled images). - * An XObject Template may be painted multiple times, either on - * several pages or at several locations on the same page and produces - * the same results each time, subject only to the graphics state at - * the time it is invoked. - */ - - -// start a new XObject Template and set transparency group option -$template_id = $pdf->startTemplate(60, 60, true); - -// create Template content -// ................................................................... -//Start Graphic Transformation -$pdf->StartTransform(); - -// set clipping mask -$pdf->StarPolygon(30, 30, 29, 10, 3, 0, 1, 'CNZ'); - -// draw jpeg image to be clipped -$pdf->Image('images/image_demo.jpg', 0, 0, 60, 60, '', '', '', true, 72, '', false, false, 0, false, false, false); - -//Stop Graphic Transformation -$pdf->StopTransform(); - -$pdf->setXY(0, 0); - -$pdf->setFont('times', '', 40); - -$pdf->setTextColor(255, 0, 0); - -// print a text -$pdf->Cell(60, 60, 'Template', 0, 0, 'C', false, '', 0, false, 'T', 'M'); -// ................................................................... - -// end the current Template -$pdf->endTemplate(); - - -// print the selected Template various times using various transparencies - -$pdf->setAlpha(0.4); -$pdf->printTemplate($template_id, 15, 50, 20, 20, '', '', false); - -$pdf->setAlpha(0.6); -$pdf->printTemplate($template_id, 27, 62, 40, 40, '', '', false); - -$pdf->setAlpha(0.8); -$pdf->printTemplate($template_id, 55, 85, 60, 60, '', '', false); - -$pdf->setAlpha(1); -$pdf->printTemplate($template_id, 95, 125, 80, 80, '', '', false); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_062.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_063.php b/tools/tcpdf/examples/example_063.php deleted file mode 100644 index f68f4f90a6..0000000000 --- a/tools/tcpdf/examples/example_063.php +++ /dev/null @@ -1,133 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 063'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 063', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 16); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of Text Stretching and Spacing (tracking)', '', 0, 'L', true, 0, false, false, 0); -$pdf->Ln(5); - -// create several cells to display all cases of stretching and spacing combinations. - -$fonts = array('times', 'dejavuserif'); -$alignments = array('L' => 'LEFT', 'C' => 'CENTER', 'R' => 'RIGHT', 'J' => 'JUSTIFY'); - - -// Test all cases using direct stretching/spacing methods -foreach ($fonts as $fkey => $font) { - $pdf->setFont($font, '', 14); - foreach ($alignments as $align_mode => $align_name) { - for ($stretching = 90; $stretching <= 110; $stretching += 10) { - for ($spacing = -0.254; $spacing <= 0.254; $spacing += 0.254) { - $pdf->setFontStretching($stretching); - $pdf->setFontSpacing($spacing); - $txt = $align_name.' | Stretching = '.$stretching.'% | Spacing = '.sprintf('%+.3F', $spacing).'mm'; - $pdf->Cell(0, 0, $txt, 1, 1, $align_mode); - } - } - } - $pdf->AddPage(); -} - - -// Test all cases using CSS stretching/spacing properties -foreach ($fonts as $fkey => $font) { - $pdf->setFont($font, '', 11); - foreach ($alignments as $align_mode => $align_name) { - for ($stretching = 90; $stretching <= 110; $stretching += 10) { - for ($spacing = -0.254; $spacing <= 0.254; $spacing += 0.254) { - $html = ''.$align_name.' | Stretching = '.$stretching.'% | Spacing = '.sprintf('%+.3F', $spacing).'mm
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
      '; - $pdf->writeHTMLCell(0, 0, '', '', $html, 1, 1, false, true, $align_mode, false); - } - } - if (!(($fkey == 1) AND ($align_mode == 'J'))) { - $pdf->AddPage(); - } - } -} - - -// reset font stretching -$pdf->setFontStretching(100); - -// reset font spacing -$pdf->setFontSpacing(0); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_063.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_064.php b/tools/tcpdf/examples/example_064.php deleted file mode 100644 index 8efaf4fea0..0000000000 --- a/tools/tcpdf/examples/example_064.php +++ /dev/null @@ -1,178 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 064'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 064', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', '', 8); - - -// define some html content for testing -$txt = '

      TEST PAGE REGIONS: A no-write region is a portion of the page with a rectangular or trapezium shape that will not be covered when writing text or html code. A region is always aligned on the left or right side of the page ad is defined using a vertical segment. You can set multiple regions for the same page. You can combine several adjacent regions to approximate curved shapes. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc. -Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa. -Integer non sem eget neque mattis accumsan. Maecenas eu nisl mauris, sit amet interdum ipsum. In pharetra erat vel lectus venenatis elementum. Nulla non elit ligula, sit amet mollis urna. Morbi ut gravida est. Mauris tincidunt sem et turpis molestie malesuada. Curabitur vel nulla risus, sed mollis erat. Suspendisse vehicula accumsan purus nec varius. Donec fermentum lorem id felis sodales dictum. Quisque et dolor ipsum. Nam luctus consectetur dui vitae fermentum. Curabitur sodales consequat augue, id ultricies augue tempor ac. Aliquam ac magna id ipsum vehicula bibendum. Sed elementum congue tristique. Phasellus vel lorem eu lectus porta sodales. Etiam neque tortor, sagittis id pharetra quis, laoreet vel arcu. -Cras quam mi, ornare laoreet laoreet vel, vehicula at lacus. Maecenas a lacus accumsan augue convallis sagittis sed quis odio. Morbi sit amet turpis diam, dictum convallis urna. Cras eget interdum augue. Cras eu nisi sit amet dolor faucibus porttitor. Suspendisse potenti. Nunc vitae dolor risus, at cursus libero. Suspendisse bibendum tellus non nibh hendrerit tristique. Mauris eget orci elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam porta libero non ante laoreet semper. Proin volutpat sodales mi, ac fermentum erat sagittis in. Vivamus at viverra felis. Ut pretium facilisis ante et pharetra. -Nulla facilisi. Cras varius quam eget libero aliquam vitae tincidunt leo rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque a nisl massa, quis pretium urna. Proin vel porttitor tortor. Cras rhoncus congue velit in bibendum. Donec pharetra semper augue id lacinia. Quisque magna quam, hendrerit eu aliquam et, pellentesque ut tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas nulla quam, rutrum eu feugiat at, elementum eu libero. Maecenas ullamcorper leo et turpis rutrum ac laoreet eros faucibus. Phasellus condimentum lorem quis neque imperdiet quis molestie enim iaculis. Phasellus risus est, vestibulum ut convallis ultrices, dignissim nec erat. Etiam congue lobortis laoreet. Nulla ut neque sed velit dapibus semper. Quisque nec dolor id nibh eleifend iaculis. Vivamus vitae fermentum odio. Etiam malesuada quam in nulla aliquam sed convallis dui feugiat.

      '; - - -// add a page -$pdf->AddPage(); - -// print some graphic content -$pdf->Image('images/image_demo.jpg', 155, 30, 40, 40, 'JPG', '', '', true); -$pdf->Image('images/image_demo.jpg', 15, 230, 40, 40, 'JPG', '', '', true); - -// define some graphic styles -$styleA = array('width' => 0.254, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0)); -$styleB = array('width' => 0.254, 'cap' => 'butt', 'join' => 'miter', 'dash' => 3, 'color' => array(127, 127, 127)); -$pdf->setFillColor(220, 255, 220); - -// write a trapezoid with some information about no-write page regions -$pdf->Polygon(array(15,90, 57,90, 67,140, 15,140), 'DF', array($styleB, $styleA, $styleB, $styleB)); -$pdf->setXY(15, 90); -$pdf->Cell(42, 0, 'xt,yt', 0, 0, 'R', false, '', 0, false, 'T', 'T'); -$pdf->setXY(15, 140); -$pdf->Cell(52, 0, 'xb,yb', 0, 0, 'R', false, '', 0, false, 'B', 'B'); -$pdf->setXY(15, 115); -$pdf->Cell(40, 0, 'side', 0, 0, 'R', false, '', 0, false, 'B', 'B'); -$pdf->setLineStyle(array('width' => 0.254, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); -$pdf->Arrow(60, 115, 35, 115, 2, 5, 15); - -// write a trapezoid with some information about no-write page regions -$pdf->Polygon(array(145,130, 195,130, 195,180, 155,180), 'DF', array($styleB, $styleB, $styleB, $styleA)); -$pdf->setXY(145, 130); -$pdf->Cell(42, 0, 'xt,yt', 0, 0, 'L', false, '', 0, false, 'T', 'T'); -$pdf->setXY(155, 180); -$pdf->Cell(52, 0, 'xb,yb', 0, 0, 'L', false, '', 0, false, 'B', 'B'); -$pdf->setXY(160, 155); -$pdf->Cell(30, 0, 'side', 0, 0, 'L', false, '', 0, false, 'B', 'B'); -$pdf->setLineStyle(array('width' => 0.254, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); -$pdf->Arrow(155, 155, 180, 155, 2, 5, 15); - -// reset x,y position -$pdf->setXY(15, 30); - - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// define no-write page regions to avoid text overlapping images -/* - 'page' => page number or empy for current page - 'xt' => X top - 'yt' => Y top - 'yb' => Y bottom - 'side' => page side ('L' = left or 'R' = right) -*/ -$regions = array( -array('page' => '', 'xt' => 153, 'yt' => 30, 'xb' => 153, 'yb' => 70, 'side' => 'R'), -array('page' => '', 'xt' => 60, 'yt' => 90, 'xb' => 70, 'yb' => 140, 'side' => 'L'), -array('page' => '', 'xt' => 143, 'yt' => 130, 'xb' => 153, 'yb' => 180, 'side' => 'R'), -array('page' => '', 'xt' => 58, 'yt' => 230, 'xb' => 58, 'yb' => 270, 'side' => 'L') -); - -// set page regions, check also getPageRegions(), addPageRegion() and removePageRegion() -$pdf->setPageRegions($regions); - -// write html text -$pdf->writeHTML($txt, true, false, true, false, ''); - - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// set a circular no-write region on the second page -$regions = array( -array('page' => 2, 'xt' => 195, 'yt' => 110, 'xb' => 179.693, 'yb' => 113.045, 'side' => 'R'), -array('page' => 2, 'xt' => 179.693, 'yt' => 113.045, 'xb' => 166.716, 'yb' => 121.716, 'side' => 'R'), -array('page' => 2, 'xt' => 166.716, 'yt' => 121.716, 'xb' => 158.045, 'yb' => 134.693, 'side' => 'R'), -array('page' => 2, 'xt' => 158.045, 'yt' => 134.693, 'xb' => 155, 'yb' => 150, 'side' => 'R'), -array('page' => 2, 'xt' => 155, 'yt' => 150, 'xb' => 158.045, 'yb' => 165.307, 'side' => 'R'), -array('page' => 2, 'xt' => 158.045, 'yt' => 165.307, 'xb' => 166.716, 'yb' => 178.284, 'side' => 'R'), -array('page' => 2, 'xt' => 166.716, 'yt' => 178.284, 'xb' => 179.693, 'yb' => 186.955, 'side' => 'R'), -array('page' => 2, 'xt' => 179.693, 'yt' => 186.955, 'xb' => 195, 'yb' => 190, 'side' => 'R') -); -$pdf->setPageRegions($regions); - -$pdf->Polygon(array(195,110, 179.693,113.045, 166.716,121.716, 158.045,134.693, 155,150, 158.045,165.307, 166.716,178.284, 179.693,186.955, 195,190), 'DF'); - -$pdf->Ln(15); - -// define some html content for testing -$txt = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed imperdiet lectus. Phasellus quis velit velit, non condimentum quam. Sed neque urna, ultrices ac volutpat vel, laoreet vitae augue. Sed vel velit erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras eget velit nulla, eu sagittis elit. Nunc ac arcu est, in lobortis tellus. Praesent condimentum rhoncus sodales. In hac habitasse platea dictumst. Proin porta eros pharetra enim tincidunt dignissim nec vel dolor. Cras sapien elit, ornare ac dignissim eu, ultricies ac eros. Maecenas augue magna, ultrices a congue in, mollis eu nulla. Nunc venenatis massa at est eleifend faucibus. Vivamus sed risus lectus, nec interdum nunc. Fusce et felis vitae diam lobortis sollicitudin. Aenean tincidunt accumsan nisi, id vehicula quam laoreet elementum. Phasellus egestas interdum erat, et viverra ipsum ultricies ac. Praesent sagittis augue at augue volutpat eleifend. Cras nec orci neque. Mauris bibendum posuere blandit. Donec feugiat mollis dui sit amet pellentesque. Sed a enim justo. Donec tincidunt, nisl eget elementum aliquam, odio ipsum ultrices quam, eu porttitor ligula urna at lorem. Donec varius, eros et convallis laoreet, ligula tellus consequat felis, ut ornare metus tellus sodales velit. Duis sed diam ante. Ut rutrum malesuada massa, vitae consectetur ipsum rhoncus sed. Suspendisse potenti. Pellentesque a congue massa. Integer non sem eget neque mattis accumsan. Maecenas eu nisl mauris, sit amet interdum ipsum. In pharetra erat vel lectus venenatis elementum. Nulla non elit ligula, sit amet mollis urna. Morbi ut gravida est. Mauris tincidunt sem et turpis molestie malesuada. Curabitur vel nulla risus, sed mollis erat. Suspendisse vehicula accumsan purus nec varius. Donec fermentum lorem id felis sodales dictum. Quisque et dolor ipsum. Nam luctus consectetur dui vitae fermentum. Curabitur sodales consequat augue, id ultricies augue tempor ac. Aliquam ac magna id ipsum vehicula bibendum. Sed elementum congue tristique. Phasellus vel lorem eu lectus porta sodales. Etiam neque tortor, sagittis id pharetra quis, laoreet vel arcu. Cras quam mi, ornare laoreet laoreet vel, vehicula at lacus. Maecenas a lacus accumsan augue convallis sagittis sed quis odio. Morbi sit amet turpis diam, dictum convallis urna. Cras eget interdum augue. Cras eu nisi sit amet dolor faucibus porttitor. Suspendisse potenti. Nunc vitae dolor risus, at cursus libero. Suspendisse bibendum tellus non nibh hendrerit tristique. Mauris eget orci elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam porta libero non ante laoreet semper. Proin volutpat sodales mi, ac fermentum erat sagittis in. Vivamus at viverra felis. Ut pretium facilisis ante et pharetra. Nulla facilisi. Cras varius quam eget libero aliquam vitae tincidunt leo rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque a nisl massa, quis pretium urna. Proin vel porttitor tortor. Cras rhoncus congue velit in bibendum. Donec pharetra semper augue id lacinia. Quisque magna quam, hendrerit eu aliquam et, pellentesque ut tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas nulla quam, rutrum eu feugiat at, elementum eu libero. Maecenas ullamcorper leo et turpis rutrum ac laoreet eros faucibus. Phasellus condimentum lorem quis neque imperdiet quis molestie enim iaculis. Phasellus risus est, vestibulum ut convallis ultrices, dignissim nec erat. Etiam congue lobortis laoreet. Nulla ut neque sed velit dapibus semper. Quisque nec dolor id nibh eleifend iaculis. Vivamus vitae fermentum odio. Etiam malesuada quam in nulla aliquam sed convallis dui feugiat.'."\n"; - -// write text -$pdf->MultiCell(0, 0, $txt, 0, 'J', false, 1, '', '', true, 0, false, true, 0, 'T', false); - -// --------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_064.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_065.php b/tools/tcpdf/examples/example_065.php deleted file mode 100644 index 90794804c5..0000000000 --- a/tools/tcpdf/examples/example_065.php +++ /dev/null @@ -1,100 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 065'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 065', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set default font subsetting mode -$pdf->setFontSubsetting(true); - -// Set font -$pdf->setFont('helvetica', '', 14, '', true); - -// Add a page -// This method has several options, check the source code documentation for more information. -$pdf->AddPage(); - -// Set some content to print -$html = <<Example of  TCPDF  document in PDF/A-1b mode. -This document conforms to the standard PDF/A-1b (ISO 19005-1:2005). -

      Please check the source code documentation and other examples for further information (http://www.tcpdf.org).

      -

      TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE MAKE A DONATION!

      -EOD; - -// Print text using writeHTMLCell() -$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); - -// --------------------------------------------------------- - -// Close and output PDF document -// This method has several options, check the source code documentation for more information. -$pdf->Output('example_065.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/example_066.php b/tools/tcpdf/examples/example_066.php deleted file mode 100644 index 41b8b47298..0000000000 --- a/tools/tcpdf/examples/example_066.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @license LGPL-3.0 - */ - -/** - * Creates an example PDF/A-1b document using TCPDF - * - * @abstract TCPDF - Example: PDF/A-1b mode - * @author Nicola Asuni - * @since 2021-03-26 - * @group A-1b - * @group pdf - */ - -// Include the main TCPDF library (search for installation path). -require_once('tcpdf_include.php'); - -// create new PDF document -$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, true); - -// set document information -$pdf->setCreator(PDF_CREATOR); -$pdf->setAuthor('Nicola Asuni'); -$pdf->setTitle('TCPDF Example 066'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 066', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(true, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(__DIR__ . '/lang/eng.php')) { - require_once __DIR__ . '/lang/eng.php'; - - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set default font subsetting mode -$pdf->setFontSubsetting(true); - -// Set font -$pdf->setFont('helvetica', '', 14, '', true); - -// Add a page -// This method has several options, check the source code documentation for more information. -$pdf->AddPage(); - -// Set some content to print -$html = <<Example of  TCPDF  document in PDF/A-1b mode. -This document conforms to the standard PDF/A-1b (ISO 19005-1:2005). -

      Please check the source code documentation and other examples for further information (http://www.tcpdf.org).

      -HTML; - -// Print text using writeHTMLCell() -$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); - -// --------------------------------------------------------- - -// Close and output PDF document -// This method has several options, check the source code documentation for more information. -$pdf->Output('example_066.pdf', 'I'); diff --git a/tools/tcpdf/examples/example_067.php b/tools/tcpdf/examples/example_067.php deleted file mode 100644 index e0262bfde0..0000000000 --- a/tools/tcpdf/examples/example_067.php +++ /dev/null @@ -1,223 +0,0 @@ -setCreator(PDF_CREATOR); -$pdf->setAuthor('Owen Leibman'); -$pdf->setTitle('TCPDF Example 067'); -$pdf->setSubject('TCPDF Tutorial'); -$pdf->setKeywords('TCPDF, PDF, example, test, guide'); - -// set default header data -$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 067', PDF_HEADER_STRING); - -// set header and footer fonts -$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); -$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); - -// set default monospaced font -$pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); - -// set margins -$pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->setHeaderMargin(PDF_MARGIN_HEADER); -$pdf->setFooterMargin(PDF_MARGIN_FOOTER); - -// set auto page breaks -$pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); - -// set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - -// set some language-dependent strings (optional) -if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { - require_once(dirname(__FILE__).'/lang/eng.php'); - $pdf->setLanguageArray($l); -} - -// --------------------------------------------------------- - -// set font -$pdf->setFont('helvetica', 'B', 20); - -// add a page -$pdf->AddPage(); - -$pdf->Write(0, 'Example of HTML tables', '', 0, 'L', true, 0, false, false, 0); - -$pdf->setFont('helvetica', '', 8); - -// ----------------------------------------------------------------------------- - -$tbl = << - - COL 1 - ROW 1
      COLSPAN 3 - COL 2 - ROW 1 - COL 3 - ROW 1 - - - COL 2 - ROW 2 - COLSPAN 2
      text line
      text line
      text line
      text line - COL 3 - ROW 2 - - - COL 3 - ROW 3 - - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -$tbl = << - - COL 1 - ROW 1
      COLSPAN 3 - COL 2 - ROW 1 - COL 3 - ROW 1 - - - COL 2 - ROW 2 - COLSPAN 2
      text line
      text line
      text line
      text line - COL 3 - ROW 2 - - - COL 3 - ROW 3 - - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -$tbl = << - - COL 1 - ROW 1
      COLSPAN 3 - COL 2 - ROW 1 - COL 3 - ROW 1 - - - COL 2 - ROW 2 - COLSPAN 2
      text line
      text line
      text line
      text line - COL 3 - ROW 2 - - - COL 3 - ROW 3 - - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -$tbl = << - - COL 1 - ROW 1
      COLSPAN 3 - COL 2 - ROW 1 - COL 3 - ROW 1 - - - COL 2 - ROW 2 - COLSPAN 2
      text line
      text line
      text line
      text line - COL 3 - ROW 2 - - - COL 3 - ROW 3 - - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -$tbl = << - - COL 1 - ROW 1
      COLSPAN 3 - COL 2 - ROW 1 - COL 3 - ROW 1 - - - COL 2 - ROW 2 - COLSPAN 2
      text line
      text line
      text line
      text line - COL 3 - ROW 2 - - - COL 3 - ROW 3 - - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); - -// ----------------------------------------------------------------------------- - -// At medium thickness, which is what you get with only one -// setting for style, everything looks the same. -// Included just for completeness. -$tbl = << - - COL 1 - ROW 1
      COLSPAN 3 - COL 2 - ROW 1 - COL 3 - ROW 1 - - - COL 2 - ROW 2 - COLSPAN 2
      text line
      text line
      text line
      text line - COL 3 - ROW 2 - - - COL 3 - ROW 3 - - - -EOD; - -$pdf->writeHTML($tbl, true, false, false, false, ''); -// ----------------------------------------------------------------------------- - -//Close and output PDF document -$pdf->Output('example_067.pdf', 'I'); - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/examples/images/_blank.png b/tools/tcpdf/examples/images/_blank.png deleted file mode 100644 index 38f7b2fa56..0000000000 Binary files a/tools/tcpdf/examples/images/_blank.png and /dev/null differ diff --git a/tools/tcpdf/examples/images/alpha.png b/tools/tcpdf/examples/images/alpha.png deleted file mode 100644 index 4980117ded..0000000000 Binary files a/tools/tcpdf/examples/images/alpha.png and /dev/null differ diff --git a/tools/tcpdf/examples/images/image_demo.jpg b/tools/tcpdf/examples/images/image_demo.jpg deleted file mode 100644 index 262bce272c..0000000000 Binary files a/tools/tcpdf/examples/images/image_demo.jpg and /dev/null differ diff --git a/tools/tcpdf/examples/images/image_with_alpha.png b/tools/tcpdf/examples/images/image_with_alpha.png deleted file mode 100644 index f87dc9a1b2..0000000000 Binary files a/tools/tcpdf/examples/images/image_with_alpha.png and /dev/null differ diff --git a/tools/tcpdf/examples/images/img.png b/tools/tcpdf/examples/images/img.png deleted file mode 100644 index 2461637e3c..0000000000 Binary files a/tools/tcpdf/examples/images/img.png and /dev/null differ diff --git a/tools/tcpdf/examples/images/logo_example.gif b/tools/tcpdf/examples/images/logo_example.gif deleted file mode 100644 index 010b487d93..0000000000 Binary files a/tools/tcpdf/examples/images/logo_example.gif and /dev/null differ diff --git a/tools/tcpdf/examples/images/logo_example.jpg b/tools/tcpdf/examples/images/logo_example.jpg deleted file mode 100644 index 6d9b8fd807..0000000000 Binary files a/tools/tcpdf/examples/images/logo_example.jpg and /dev/null differ diff --git a/tools/tcpdf/examples/images/logo_example.png b/tools/tcpdf/examples/images/logo_example.png deleted file mode 100644 index a57be4ce96..0000000000 Binary files a/tools/tcpdf/examples/images/logo_example.png and /dev/null differ diff --git a/tools/tcpdf/examples/images/tcpdf_box.ai b/tools/tcpdf/examples/images/tcpdf_box.ai deleted file mode 100644 index 0c14846142..0000000000 --- a/tools/tcpdf/examples/images/tcpdf_box.ai +++ /dev/null @@ -1,214 +0,0 @@ -%!PS-Adobe-3.0 EPSF -%%Creator: Adobe Illustrator -%%BoundingBox: -7 0 487 327 -%%HiResBoundingBox: -6.66162 2.44007e-05 486.662 326.648 -%AI5_FileFormat 3 -%%EndComments -%%BeginProlog -%%EndProlog -%%BeginSetup -%%EndSetup -1 XR -%AI5_BeginLayer -1 1 1 1 0 0 -1 49 80 161 Lb -(New Layer) Ln -0.620000 0.580000 0.435000 0.996000 K -[] 0 d -1.402287 w -0 j -0 J -0.263000 0.290000 0.898000 0.263000 k -72.7885 255.643 m -277.08 286.778 L -425.478 260.993 L -408.269 190.301 L -113.504 181.247 L -113.504 181.247 72.9813 241.769 72.7885 255.643 C -b -0.620000 0.580000 0.435000 0.996000 K -1 j -0.094000 0.102000 0.369000 0.016000 k -423.247 259.914 m -240.217 207.097 L -240.635 0.701168 L -397.776 116.053 L -423.247 259.914 L -b -0.620000 0.580000 0.435000 0.996000 K -0.133000 0.141000 0.541000 0.035000 k -72.1745 254.207 m -240.217 207.097 L -240.561 0.783816 L -101.054 87.946 L -72.1745 254.207 L -b -0.047000 0.059000 0.184000 0.004000 k -423.247 259.914 m -308.187 51.1553 L -396.862 116.972 L -423.247 259.914 L -f -0.620000 0.580000 0.435000 0.996000 K -0 j -0.047000 0.059000 0.184000 0.004000 k -479.312 250.415 m -423.613 260.243 L -240.385 206.966 L -314.061 186.394 L -479.312 250.415 L -b -0.620000 0.580000 0.435000 0.996000 K -0.047000 0.059000 0.184000 0.004000 k -69.9121 254.273 m -237.965 207.131 L -163.618 164.537 L -0.687544 234.686 L -69.9121 254.273 L -b -0.620000 0.580000 0.435000 0.996000 K -0.047000 0.059000 0.184000 0.004000 k -242.971 319.299 m -275.613 286.233 L -72.5703 254.295 L -16.555 296.161 L -242.971 319.299 L -b -0.620000 0.580000 0.435000 0.996000 K -0.133000 0.141000 0.541000 0.035000 k -423.496 260.684 m -275.426 286.441 L -307.326 316.69 L -462.053 292.606 L -423.496 260.684 L -b -0.196000 0.227000 0.871000 0.106000 k -75.26 254.037 m -274.806 285.371 L -227.928 211.257 L -163.396 228.836 130.937 238.701 75.26 254.037 C -f -0.620000 0.580000 0.435000 0.996000 K -1 j -0.169000 0.314000 0.424000 0.094000 k -275.528 286.329 m -274.75 216.78 L -275.528 286.329 L -b -0.031000 0.949000 0.745000 0.729000 k -285.929 160.982 m -285.929 160.982 285.078 139.734 285.078 139.734 C -285.078 139.734 275.378 135.096 275.378 135.096 C -275.378 135.096 273.058 57.6061 273.058 57.6061 C -273.058 57.6061 257.133 47.3536 257.133 47.3536 C -257.133 47.3536 258.059 126.816 258.059 126.816 C -258.059 126.816 247.186 121.618 247.186 121.618 C -247.186 121.618 247.186 144.26 247.186 144.26 C -247.186 144.26 285.929 160.982 285.929 160.982 C -F -0.031000 0.949000 0.745000 0.729000 k -320.884 135.342 m -320.884 135.342 307.279 128.129 307.279 128.129 C -307.279 128.129 308.36 144.944 308.36 144.944 C -308.681 149.948 308.724 153.011 308.483 154.097 C -308.268 155.24 307.632 155.567 306.572 155.073 C -305.368 154.512 304.553 153.381 304.135 151.687 C -303.718 149.995 303.36 146.608 303.063 141.565 C -303.063 141.565 300.477 97.6864 300.477 97.6864 C -300.22 93.3298 300.208 90.6032 300.439 89.4791 C -300.668 88.3599 301.318 88.1316 302.385 88.7881 C -303.403 89.4149 304.103 90.4684 304.487 91.9528 C -304.894 93.4524 305.253 96.6211 305.567 101.497 C -305.567 101.497 306.297 112.86 306.297 112.86 C -306.297 112.86 319.718 120.438 319.718 120.438 C -319.718 120.438 319.446 116.964 319.446 116.964 C -318.734 107.862 317.873 101.293 316.856 97.1389 C -315.864 93.0164 314.026 88.8059 311.329 84.474 C -308.636 80.1307 305.421 76.743 301.646 74.2975 C -297.651 71.7096 294.365 70.7251 291.812 71.3887 C -289.213 72.064 287.545 74.2699 286.838 78.0362 C -286.121 81.8925 285.954 88.3297 286.349 97.4441 C -286.349 97.4441 287.575 125.751 287.575 125.751 C -287.89 133.007 288.277 138.586 288.737 142.421 C -289.202 146.323 290.251 150.369 291.883 154.544 C -293.54 158.732 295.716 162.4 298.394 165.529 C -301.078 168.689 304.052 170.959 307.296 172.342 C -311.621 174.188 315.02 174.154 317.521 172.296 C -319.974 170.473 321.427 167.541 321.911 163.514 C -322.39 159.578 322.275 153.119 321.579 144.225 C -321.579 144.225 320.884 135.342 320.884 135.342 C -F -0.031000 0.949000 0.745000 0.729000 k -*u -329.084 179.607 m -329.084 179.607 342.074 185.214 342.074 185.214 C -345.446 186.669 347.94 187.235 349.586 186.932 C -351.233 186.642 352.374 185.695 353.019 184.1 C -353.677 182.527 353.999 180.418 353.991 177.777 C -354.005 175.2 353.703 171.072 353.088 165.429 C -353.088 165.429 352.244 157.683 352.244 157.683 C -351.634 152.084 350.908 147.89 350.063 145.056 C -349.22 142.228 347.957 139.718 346.265 137.514 C -344.583 135.308 342.474 133.487 339.919 132.046 C -339.919 132.046 336.736 130.25 336.736 130.25 C -336.736 130.25 333.512 96.527 333.512 96.527 C -333.512 96.527 321.545 88.8222 321.545 88.8222 C -321.545 88.8222 329.084 179.607 329.084 179.607 C -F -340.42 168.795 m -340.42 168.795 338.184 145.407 338.184 145.407 C -338.526 145.552 338.82 145.69 339.068 145.822 C -340.172 146.404 340.98 147.319 341.498 148.568 C -342.038 149.863 342.473 152.174 342.805 155.518 C -342.805 155.518 343.55 163.014 343.55 163.014 C -343.863 166.167 343.82 168.111 343.416 168.832 C -343.011 169.557 342.015 169.547 340.42 168.795 C -F -*U -0.031000 0.949000 0.745000 0.729000 k -*u -359.204 192.607 m -359.204 192.607 367.556 196.212 367.556 196.212 C -372.753 198.454 376.114 199.414 377.734 199.14 C -379.351 198.877 380.446 197.777 381.03 195.854 C -381.608 193.948 381.815 191.642 381.655 188.934 C -381.502 186.28 380.88 180.934 379.804 172.981 C -379.804 172.981 375.968 144.653 375.968 144.653 C -375.021 137.654 374.236 132.926 373.604 130.399 C -372.993 127.921 372.216 125.786 371.268 123.986 C -370.323 122.215 369.243 120.698 368.023 119.43 C -366.801 118.187 365.012 116.807 362.638 115.279 C -362.638 115.279 349.593 106.88 349.593 106.88 C -349.593 106.88 359.204 192.607 359.204 192.607 C -F -368.395 181.985 m -368.395 181.985 361.644 126.918 361.644 126.918 C -363.113 127.815 364.084 128.947 364.566 130.32 C -365.053 131.727 365.629 135.077 366.301 140.416 C -366.301 140.416 370.368 172.752 370.368 172.752 C -370.86 176.666 371.12 179.163 371.145 180.223 C -371.168 181.285 371.006 181.972 370.654 182.282 C -370.306 182.629 369.555 182.531 368.395 181.985 C -F -*U -0.031000 0.949000 0.745000 0.729000 k -387.58 204.854 m -387.58 204.854 403.348 211.659 403.348 211.659 C -403.348 211.659 400.803 195.062 400.803 195.062 C -400.803 195.062 394.579 192.087 394.579 192.087 C -394.579 192.087 392.296 176.619 392.296 176.619 C -392.296 176.619 397.801 179.482 397.801 179.482 C -397.801 179.482 395.533 164.634 395.533 164.634 C -395.533 164.634 390.075 161.574 390.075 161.574 C -390.075 161.574 385.406 129.937 385.406 129.937 C -385.406 129.937 376.374 124.122 376.374 124.122 C -376.374 124.122 387.58 204.854 387.58 204.854 C -F -LB -%AI5_EndLayer-- -%AI5_BeginLayer -1 1 1 1 0 0 -1 49 80 161 Lb -(MasterLayer 1) Ln -LB -%AI5_EndLayer-- -%%Trailer -%%EOF diff --git a/tools/tcpdf/examples/images/tcpdf_box.svg b/tools/tcpdf/examples/images/tcpdf_box.svg deleted file mode 100644 index 8c29e64abe..0000000000 --- a/tools/tcpdf/examples/images/tcpdf_box.svg +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/tools/tcpdf/examples/images/tcpdf_cell.png b/tools/tcpdf/examples/images/tcpdf_cell.png deleted file mode 100644 index 2e3e92ccb5..0000000000 Binary files a/tools/tcpdf/examples/images/tcpdf_cell.png and /dev/null differ diff --git a/tools/tcpdf/examples/images/tcpdf_logo.jpg b/tools/tcpdf/examples/images/tcpdf_logo.jpg deleted file mode 100644 index 257f8fb6d9..0000000000 Binary files a/tools/tcpdf/examples/images/tcpdf_logo.jpg and /dev/null differ diff --git a/tools/tcpdf/examples/images/tcpdf_signature.png b/tools/tcpdf/examples/images/tcpdf_signature.png deleted file mode 100644 index 64caa51fec..0000000000 Binary files a/tools/tcpdf/examples/images/tcpdf_signature.png and /dev/null differ diff --git a/tools/tcpdf/examples/images/testsvg.svg b/tools/tcpdf/examples/images/testsvg.svg deleted file mode 100644 index fd8314e348..0000000000 --- a/tools/tcpdf/examples/images/testsvg.svg +++ /dev/null @@ -1,328 +0,0 @@ - - - - - TCPDF SVG EXAMPLE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - www.tcpdf.org - - - - - - - - SVG - diff --git a/tools/tcpdf/examples/images/tux.svg b/tools/tcpdf/examples/images/tux.svg deleted file mode 100644 index de8c869688..0000000000 --- a/tools/tcpdf/examples/images/tux.svg +++ /dev/null @@ -1,1487 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/tcpdf/examples/index.php b/tools/tcpdf/examples/index.php deleted file mode 100644 index d865689b11..0000000000 --- a/tools/tcpdf/examples/index.php +++ /dev/null @@ -1,117 +0,0 @@ -'; -?> - - - - - -TCPDF Examples - - - - - - - - -

      TCPDF Examples

      - -

      PDF

      - -
        -
      1. Simple PDF with default Header and Footer: [PDF]
      2. -
      3. Simple PDF without Header and Footer: [PDF]
      4. -
      5. Custom Header and Footer: [PDF]
      6. -
      7. Cell stretching: [PDF]
      8. -
      9. Multicell: [PDF]
      10. -
      11. WriteHTML and RTL support: [PDF]
      12. -
      13. Independent columns with WriteHTMLCell: [PDF]
      14. -
      15. External UTF-8 text file: [PDF]
      16. -
      17. Image: [PDF]
      18. -
      19. Multiple columns: [PDF]
      20. -
      21. Colored Tables: [PDF]
      22. -
      23. Graphic Functions: [PDF]
      24. -
      25. Graphic Transformations: [PDF]
      26. -
      27. Javascript and Forms: [PDF]
      28. -
      29. Bookmarks (Table of Content): [PDF]
      30. -
      31. Document Encryption: [PDF]
      32. -
      33. Independent columns with MultiCell: [PDF]
      34. -
      35. Persian and Arabic language on RTL document: [PDF]
      36. -
      37. Non unicode / Alternative config file: [PDF]
      38. -
      39. Multicell complex alignment: [PDF]
      40. -
      41. writeHTML alignment: [PDF]
      42. -
      43. CMYK colors: [PDF]
      44. -
      45. Page Groups: [PDF]
      46. -
      47. Object Visibility and Layers: [PDF]
      48. -
      49. Object Transparency: [PDF]
      50. -
      51. Text Rendering Modes and Text Clipping: [PDF]
      52. -
      53. 1D Barcodes: [PDF]
      54. -
      55. Multiple page formats: [PDF]
      56. -
      57. Set PDF viewer display preferences: [PDF]
      58. -
      59. Colour gradients: [PDF]
      60. -
      61. Pie Chart Graphic: [PDF]
      62. -
      63. EPS/AI vectorial image: [PDF]
      64. -
      65. Mixed font types (TrueType Unicode, core, CID-0): [PDF]
      66. -
      67. Clipping masks: [PDF]
      68. -
      69. Line styles with cells and multicells: [PDF]
      70. -
      71. Text Annotations: [PDF]
      72. -
      73. Spot Colors: [PDF]
      74. -
      75. NON-embedded CID-0 CJK font: [PDF]
      76. -
      77. HTML Justification: [PDF]
      78. -
      79. Booklet (double-sided pages): [PDF]
      80. -
      81. File attachment: [PDF]
      82. -
      83. Image with Alpha Channel Transparency: [PDF]
      84. -
      85. Disk caching: [PDF]
      86. -
      87. Move, Copy and Delete page: [PDF]
      88. -
      89. Table Of Content with Bookmarks: [PDF]
      90. -
      91. Text hyphenation: [PDF]
      92. -
      93. Transactions and UNDO: [PDF]
      94. -
      95. Table header and rowspan: [PDF]
      96. -
      97. TCPDF methods in HTML: [PDF]
      98. -
      99. 2D Barcode (QR-Code, Datamatrix ECC200 and PDF417): [PDF]
      100. -
      101. Full page background: [PDF]
      102. -
      103. Digital Signature Certification: [PDF]
      104. -
      105. Javascript functions: [PDF]
      106. -
      107. XHTML Form: [PDF]
      108. -
      109. Font Dump: [PDF]
      110. -
      111. Crop Marks and Registration Marks: [PDF]
      112. -
      113. Cell vertical alignments and borders: [PDF]
      114. -
      115. SVG Image: [PDF]
      116. -
      117. Table Of Content with HTML templates: [PDF]
      118. -
      119. Advanced page settings: [PDF]
      120. -
      121. XHTML + CSS: [PDF]
      122. -
      123. XObject Templates: [PDF]
      124. -
      125. Text stretching and spacing (tracking/kerning): [PDF]
      126. -
      127. No-write page regions: [PDF]
      128. -
      129. PDF/A-1b (ISO 19005-1:2005) document: [PDF]
      130. -
      131. Using WriteHTMLCell: [PDF]
      132. -
      133. Shorthand border styles including !important: [PDF]
      134. -
      - -

      Barcodes

      - -
        -
      1. 1D barcode HTML format [HTML]
      2. -
      3. 1D barcode PNG format [PNG]
      4. -
      5. 1D barcode SVG format [SVG]
      6. -
      7. 1D barcode SVG INLINE format [SVG INLINE]
      8. - -
      9. 2D datamatrix barcode HTML format [HTML]
      10. -
      11. 2D datamatrix barcode PNG format [PNG]
      12. -
      13. 2D datamatrix barcode SVG format [SVG]
      14. -
      15. 2D datamatrix barcode SVG INLINE format [SVG INLINE]
      16. - -
      17. 2D pdf417 barcode HTML format [HTML]
      18. -
      19. 2D pdf417 barcode PNG format [PNG]
      20. -
      21. 2D pdf417 barcode SVG format [SVG]
      22. -
      23. 2D pdf417 barcode SVG INLINE format [SVG INLINE]
      24. - -
      25. 2D qrcode barcode HTML format [HTML]
      26. -
      27. 2D qrcode barcode PNG format [PNG]
      28. -
      29. 2D qrcode barcode SVG format [SVG]
      30. -
      31. 2D qrcode barcode SVG INLINE format [SVG INLINE]
      32. -
      - - - diff --git a/tools/tcpdf/examples/lang/afr.php b/tools/tcpdf/examples/lang/afr.php deleted file mode 100644 index 367b7e87f0..0000000000 --- a/tools/tcpdf/examples/lang/afr.php +++ /dev/null @@ -1,44 +0,0 @@ - + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. diff --git a/tools/tcpdf/fonts/freefont-20100919/CREDITS b/tools/tcpdf/fonts/freefont-20100919/CREDITS index 0b69784b5f..e4a8b634e4 100644 --- a/tools/tcpdf/fonts/freefont-20100919/CREDITS +++ b/tools/tcpdf/fonts/freefont-20100919/CREDITS @@ -331,7 +331,7 @@ a set of TTF fonts for nine Indian scripts (Devanagari, Gujarati, Telugu, Tamil, Malayalam, Kannada, Bengali, Oriya, and Gurumukhi) under the GNU General Public License (GPL). You can download the fonts from the Free Software Foundation of India WWW site -(http://www.gnu.org.in/akruti-fonts/) or from the Akruti website. +(https://www.gnu.org.in/akruti-fonts/) or from the Akruti website. For any further information or assistance regarding these fonts, please contact mssridhar AT vsnl.com. diff --git a/tools/tcpdf/fonts/freefont-20120503/COPYING b/tools/tcpdf/fonts/freefont-20120503/COPYING index 94a9ed024d..ae0725d801 100644 --- a/tools/tcpdf/fonts/freefont-20120503/COPYING +++ b/tools/tcpdf/fonts/freefont-20120503/COPYING @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. diff --git a/tools/tcpdf/fonts/freefont-20120503/CREDITS b/tools/tcpdf/fonts/freefont-20120503/CREDITS index f4430ecf93..bc078aacc5 100644 --- a/tools/tcpdf/fonts/freefont-20120503/CREDITS +++ b/tools/tcpdf/fonts/freefont-20120503/CREDITS @@ -336,7 +336,7 @@ a set of TTF fonts for nine Indian scripts (Devanagari, Gujarati, Telugu, Tamil, Malayalam, Kannada, Bengali, Oriya, and Gurumukhi) under the GNU General Public License (GPL). You can download the fonts from the Free Software Foundation of India WWW site -(http://www.gnu.org.in/akruti-fonts/) or from the Akruti website. +(https://www.gnu.org.in/akruti-fonts/) or from the Akruti website. For any further information or assistance regarding these fonts, please contact mssridhar AT vsnl.com. diff --git a/tools/tcpdf/fonts/freefont-20120503/README b/tools/tcpdf/fonts/freefont-20120503/README index d83f4a945c..daf679e67c 100644 --- a/tools/tcpdf/fonts/freefont-20120503/README +++ b/tools/tcpdf/fonts/freefont-20120503/README @@ -30,7 +30,7 @@ FreeFont covers the following character ranges * geometrical shapes, box drawing * musical symbols, gaming symbols, miscellaneous symbols etc. -For more detail see +For more detail see Editing ------- @@ -108,7 +108,7 @@ Further information ------------------- Home page of GNU FreeFont: - http://www.gnu.org/software/freefont/ + https://www.gnu.org/software/freefont/ More information is at the main project page of Free UCS scalable fonts: http://savannah.gnu.org/projects/freefont/ diff --git a/tools/tcpdf/fonts/freefont-20120503/TROUBLESHOOTING b/tools/tcpdf/fonts/freefont-20120503/TROUBLESHOOTING index a7af222555..0639198ac9 100644 --- a/tools/tcpdf/fonts/freefont-20120503/TROUBLESHOOTING +++ b/tools/tcpdf/fonts/freefont-20120503/TROUBLESHOOTING @@ -27,7 +27,7 @@ a different font. First double-check that the font in question really contains the character in question. If you don't have font development software, this can be tricky. In the case of FreeFont, you can check if a given character -range is supported: +range is supported: Next double-check that your application (web browser, text editor, etc) has indeed been properly instructed to use the font. diff --git a/tools/tcpdf/include/barcodes/datamatrix.php b/tools/tcpdf/include/barcodes/datamatrix.php index d1cc6d2a90..77822fdf11 100644 --- a/tools/tcpdf/include/barcodes/datamatrix.php +++ b/tools/tcpdf/include/barcodes/datamatrix.php @@ -5,9 +5,9 @@ // Begin : 2010-06-07 // Last Update : 2014-05-06 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2010-2014 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2010-2014 2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -22,7 +22,7 @@ // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see . +// along with TCPDF. If not, see . // // See LICENSE.TXT file for more information. // ------------------------------------------------------------------- diff --git a/tools/tcpdf/include/barcodes/pdf417.php b/tools/tcpdf/include/barcodes/pdf417.php index bda24822ff..4c9a4b3d12 100644 --- a/tools/tcpdf/include/barcodes/pdf417.php +++ b/tools/tcpdf/include/barcodes/pdf417.php @@ -5,9 +5,9 @@ // Begin : 2010-06-03 // Last Update : 2014-04-25 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2010-2013 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2010-2013 2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -22,7 +22,7 @@ // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see . +// along with TCPDF. If not, see . // // See LICENSE.TXT file for more information. // ------------------------------------------------------------------- diff --git a/tools/tcpdf/include/barcodes/qrcode.php b/tools/tcpdf/include/barcodes/qrcode.php index 1a64a4cb59..72cbf15e8f 100644 --- a/tools/tcpdf/include/barcodes/qrcode.php +++ b/tools/tcpdf/include/barcodes/qrcode.php @@ -5,9 +5,9 @@ // Begin : 2010-03-22 // Last Update : 2012-07-25 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2010-2012 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2010-2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -22,7 +22,7 @@ // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see . +// along with TCPDF. If not, see . // // See LICENSE.TXT file for more information. // ------------------------------------------------------------------- diff --git a/tools/tcpdf/include/tcpdf_colors.php b/tools/tcpdf/include/tcpdf_colors.php index 5a51594c31..fc5aeb08f4 100644 --- a/tools/tcpdf/include/tcpdf_colors.php +++ b/tools/tcpdf/include/tcpdf_colors.php @@ -5,9 +5,9 @@ // Begin : 2002-04-09 // Last Update : 2014-04-25 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2002-2013 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2002-2013 2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -22,7 +22,7 @@ // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see . +// along with TCPDF. If not, see . // // See LICENSE.TXT file for more information. // ------------------------------------------------------------------- @@ -275,7 +275,7 @@ public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R' $color = strtolower($color); // check for javascript color array syntax if (strpos($color, '[') !== false) { - if (preg_match('/[\[][\"\'](t|g|rgb|cmyk)[\"\'][\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\]]/', $color, $m) > 0) { + if (preg_match('/[\[][\"\'](t|g|rgba|rgb|cmyk)[\"\'][\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\,]?([0-9\.]*+)[\]]/', $color, $m) > 0) { $returncolor = array(); switch ($m[1]) { case 'cmyk': { @@ -286,7 +286,8 @@ public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R' $returncolor['K'] = max(0, min(100, (floatval($m[5]) * 100))); break; } - case 'rgb': { + case 'rgb': + case 'rgba': { // RGB $returncolor['R'] = max(0, min(255, (floatval($m[2]) * 255))); $returncolor['G'] = max(0, min(255, (floatval($m[3]) * 255))); @@ -317,6 +318,25 @@ public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R' if (strlen($color) == 0) { return $defcol; } + // RGBA ARRAY + if (substr($color, 0, 4) == 'rgba') { + $codes = substr($color, 5); + $codes = str_replace(')', '', $codes); + $returncolor = explode(',', $codes); + // remove alpha component + array_pop($returncolor); + foreach ($returncolor as $key => $val) { + if (strpos($val, '%') > 0) { + // percentage + $returncolor[$key] = (255 * intval($val) / 100); + } else { + $returncolor[$key] = intval($val); /* floatize */ + } + // normalize value + $returncolor[$key] = max(0, min(255, $returncolor[$key])); + } + return $returncolor; + } // RGB ARRAY if (substr($color, 0, 3) == 'rgb') { $codes = substr($color, 4); diff --git a/tools/tcpdf/include/tcpdf_filters.php b/tools/tcpdf/include/tcpdf_filters.php index 3009cff7c7..96be66f5df 100644 --- a/tools/tcpdf/include/tcpdf_filters.php +++ b/tools/tcpdf/include/tcpdf_filters.php @@ -5,9 +5,9 @@ // Begin : 2011-05-23 // Last Update : 2014-04-25 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2011-2013 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2011-2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // diff --git a/tools/tcpdf/include/tcpdf_font_data.php b/tools/tcpdf/include/tcpdf_font_data.php index 974e72ec72..d7eae2f301 100644 --- a/tools/tcpdf/include/tcpdf_font_data.php +++ b/tools/tcpdf/include/tcpdf_font_data.php @@ -5,9 +5,9 @@ // Begin : 2008-01-01 // Last Update : 2013-04-01 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2008-2013 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2008-2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -22,7 +22,7 @@ // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see . +// along with TCPDF. If not, see . // // See LICENSE.TXT file for more information. // ------------------------------------------------------------------- diff --git a/tools/tcpdf/include/tcpdf_fonts.php b/tools/tcpdf/include/tcpdf_fonts.php index f4518d9ef8..1fc24f5af2 100644 --- a/tools/tcpdf/include/tcpdf_fonts.php +++ b/tools/tcpdf/include/tcpdf_fonts.php @@ -1,13 +1,13 @@ . +// along with TCPDF. If not, see . // // See LICENSE.TXT file for more information. // ------------------------------------------------------------------- @@ -42,7 +42,7 @@ * @class TCPDF_FONTS * Font methods for TCPDF library. * @package com.tecnick.tcpdf - * @version 1.1.0 + * @version 1.1.1 * @author Nicola Asuni - info@tecnick.com */ class TCPDF_FONTS { @@ -191,29 +191,30 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $ fclose($fp); // get font info $fmetric['Flags'] = $flags; - preg_match ('#/FullName[\s]*\(([^\)]*)#', $font, $matches); + preg_match ('#/FullName[\s]*+\(([^\)]*+)#', $font, $matches); $fmetric['name'] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $matches[1]); - preg_match('#/FontBBox[\s]*{([^}]*)#', $font, $matches); - $fmetric['bbox'] = trim($matches[1]); - $bv = explode(' ', $fmetric['bbox']); - $fmetric['Ascent'] = intval($bv[3]); - $fmetric['Descent'] = intval($bv[1]); - preg_match('#/ItalicAngle[\s]*([0-9\+\-]*)#', $font, $matches); + preg_match('#/FontBBox[\s]*+{([^}]*+)#', $font, $matches); + $rawbvl = explode(' ', trim($matches[1])); + $bvl = [(int) $rawbvl[0], (int) $rawbvl[1], (int) $rawbvl[2], (int) $rawbvl[3]]; + $fmetric['bbox'] = implode(' ', $bvl); + $fmetric['Ascent'] = $bvl[3]; + $fmetric['Descent'] = $bvl[1]; + preg_match('#/ItalicAngle[\s]*+([0-9\+\-]*+)#', $font, $matches); $fmetric['italicAngle'] = intval($matches[1]); if ($fmetric['italicAngle'] != 0) { $fmetric['Flags'] |= 64; } - preg_match('#/UnderlinePosition[\s]*([0-9\+\-]*)#', $font, $matches); + preg_match('#/UnderlinePosition[\s]*+([0-9\+\-]*+)#', $font, $matches); $fmetric['underlinePosition'] = intval($matches[1]); - preg_match('#/UnderlineThickness[\s]*([0-9\+\-]*)#', $font, $matches); + preg_match('#/UnderlineThickness[\s]*+([0-9\+\-]*+)#', $font, $matches); $fmetric['underlineThickness'] = intval($matches[1]); - preg_match('#/isFixedPitch[\s]*([^\s]*)#', $font, $matches); + preg_match('#/isFixedPitch[\s]*+([^\s]*+)#', $font, $matches); if ($matches[1] == 'true') { $fmetric['Flags'] |= 1; } // get internal map $imap = array(); - if (preg_match_all('#dup[\s]([0-9]+)[\s]*/([^\s]*)[\s]put#sU', $font, $fmap, PREG_SET_ORDER) > 0) { + if (preg_match_all('#dup[\s]([0-9]+)[\s]*+/([^\s]*+)[\s]put#sU', $font, $fmap, PREG_SET_ORDER) > 0) { foreach ($fmap as $v) { $imap[$v[2]] = $v[1]; } @@ -229,22 +230,22 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $ $eplain .= chr($chr ^ ($r >> 8)); $r = ((($chr + $r) * $c1 + $c2) % 65536); } - if (preg_match('#/ForceBold[\s]*([^\s]*)#', $eplain, $matches) > 0) { + if (preg_match('#/ForceBold[\s]*+([^\s]*+)#', $eplain, $matches) > 0) { if ($matches[1] == 'true') { $fmetric['Flags'] |= 0x40000; } } - if (preg_match('#/StdVW[\s]*\[([^\]]*)#', $eplain, $matches) > 0) { + if (preg_match('#/StdVW[\s]*+\[([^\]]*+)#', $eplain, $matches) > 0) { $fmetric['StemV'] = intval($matches[1]); } else { $fmetric['StemV'] = 70; } - if (preg_match('#/StdHW[\s]*\[([^\]]*)#', $eplain, $matches) > 0) { + if (preg_match('#/StdHW[\s]*+\[([^\]]*+)#', $eplain, $matches) > 0) { $fmetric['StemH'] = intval($matches[1]); } else { $fmetric['StemH'] = 30; } - if (preg_match('#/BlueValues[\s]*\[([^\]]*)#', $eplain, $matches) > 0) { + if (preg_match('#/BlueValues[\s]*+\[([^\]]*+)#', $eplain, $matches) > 0) { $bv = explode(' ', $matches[1]); if (count($bv) >= 6) { $v1 = intval($bv[2]); @@ -265,7 +266,7 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $ $fmetric['CapHeight'] = 700; } // get the number of random bytes at the beginning of charstrings - if (preg_match('#/lenIV[\s]*([0-9]*)#', $eplain, $matches) > 0) { + if (preg_match('#/lenIV[\s]*+([\d]*+)#', $eplain, $matches) > 0) { $lenIV = intval($matches[1]); } else { $lenIV = 4; @@ -273,7 +274,7 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $ $fmetric['Leading'] = 0; // get charstring data $eplain = substr($eplain, (strpos($eplain, '/CharStrings') + 1)); - preg_match_all('#/([A-Za-z0-9\.]*)[\s][0-9]+[\s]RD[\s](.*)[\s]ND#sU', $eplain, $matches, PREG_SET_ORDER); + preg_match_all('#/([A-Za-z0-9\.]*+)[\s][0-9]+[\s]RD[\s](.*)[\s]ND#sU', $eplain, $matches, PREG_SET_ORDER); if (!empty($enc) AND isset(TCPDF_FONT_DATA::$encmap[$enc])) { $enc_map = TCPDF_FONT_DATA::$encmap[$enc]; } else { @@ -1383,7 +1384,7 @@ public static function _getTrueTypeFontSubset($font, $subsetchars) { } // set checkSumAdjustment on head table $checkSumAdjustment = 0xB1B0AFBA - self::_getTTFtableChecksum($font, strlen($font)); - $font = substr($font, 0, $table['head']['offset'] + $offset + 8).pack('N', $checkSumAdjustment).substr($font, $table['head']['offset'] + $offset + 12); + $font = substr($font, 0, $table['head']['offset'] + $offset + 4).pack('N', $checkSumAdjustment).substr($font, $table['head']['offset'] + $offset + 8); return $font; } diff --git a/tools/tcpdf/include/tcpdf_images.php b/tools/tcpdf/include/tcpdf_images.php index 6f2860c60b..2d8b96e624 100644 --- a/tools/tcpdf/include/tcpdf_images.php +++ b/tools/tcpdf/include/tcpdf_images.php @@ -5,9 +5,9 @@ // Begin : 2002-08-03 // Last Update : 2014-11-15 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2002-2014 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2002-2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -126,7 +126,9 @@ public static function _toPNG($image, $tempfile) { // create temporary PNG image imagepng($image, $tempfile); // remove image from memory - imagedestroy($image); + if (PHP_VERSION_ID < 80000) { + imagedestroy($image); + } // get PNG image data $retvars = self::_parsepng($tempfile); // tidy up by removing temporary image @@ -145,7 +147,9 @@ public static function _toPNG($image, $tempfile) { */ public static function _toJPEG($image, $quality, $tempfile) { imagejpeg($image, $tempfile, $quality); - imagedestroy($image); + if (PHP_VERSION_ID < 80000) { + imagedestroy($image); + } $retvars = self::_parsejpeg($tempfile); // tidy up by removing temporary image unlink($tempfile); @@ -270,12 +274,12 @@ public static function _parsepng($file) { return 'pngalpha'; } if (ord(fread($f, 1)) != 0) { - // Unknown compression method + // Unknownn compression method fclose($f); return false; } if (ord(fread($f, 1)) != 0) { - // Unknown filter method + // Unknownn filter method fclose($f); return false; } @@ -327,7 +331,7 @@ public static function _parsepng($file) { } // get compression method if (ord(fread($f, 1)) != 0) { - // Unknown filter method + // Unknownn filter method fclose($f); return false; } diff --git a/tools/tcpdf/include/tcpdf_static.php b/tools/tcpdf/include/tcpdf_static.php index 16828944c8..86dbad577d 100644 --- a/tools/tcpdf/include/tcpdf_static.php +++ b/tools/tcpdf/include/tcpdf_static.php @@ -1,13 +1,13 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 1.1.2 + * @version 1.1.5 */ /** @@ -46,7 +46,7 @@ * Static methods used by the TCPDF class. * @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 1.1.1 + * @version 1.1.5 * @author Nicola Asuni - info@tecnick.com */ class TCPDF_STATIC { @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.7.8'; + private static $tcpdf_version = '6.11.3'; /** * String alias for total number of pages. @@ -106,6 +106,31 @@ class TCPDF_STATIC { */ public static $pageboxes = array('MediaBox', 'CropBox', 'BleedBox', 'TrimBox', 'ArtBox'); + /** + * Array of default cURL options for curl_setopt_array. + * + * @var array cURL options. + */ + protected const CURLOPT_DEFAULT = [ + CURLOPT_CONNECTTIMEOUT => 5, + CURLOPT_MAXREDIRS => 5, + CURLOPT_PROTOCOLS => CURLPROTO_HTTPS | CURLPROTO_HTTP | CURLPROTO_FTP | CURLPROTO_FTPS, + CURLOPT_SSL_VERIFYHOST => 2, + CURLOPT_SSL_VERIFYPEER => true, + CURLOPT_TIMEOUT => 30, + CURLOPT_USERAGENT => 'tcpdf', + ]; + + /** + * Array of fixed cURL options for curl_setopt_array. + * + * @var array cURL options. + */ + protected const CURLOPT_FIXED = [ + CURLOPT_FAILONERROR => true, + CURLOPT_RETURNTRANSFER => true, + ]; + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -467,7 +492,7 @@ public static function _AESnopad($key, $text) { * @param string $last_enc_key_c Reference to last RC4 computed key. * @return string encrypted text * @since 2.0.000 (2008-01-02) - * @author Klemen Vodopivec, Nicola Asuni + * @author Klemen Vodopivec,2026 Nicola Asuni * @public static */ public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c) { @@ -1823,26 +1848,24 @@ public static function fopenLocal($filename, $mode) { */ public static function url_exists($url) { $crs = curl_init(); - // encode query params in URL to get right response form the server - $url = self::encodeUrlQuery($url); - curl_setopt($crs, CURLOPT_URL, $url); - curl_setopt($crs, CURLOPT_NOBODY, true); - curl_setopt($crs, CURLOPT_FAILONERROR, true); - if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) { - curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true); - } - curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5); - curl_setopt($crs, CURLOPT_TIMEOUT, 30); - curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file'); - curl_setopt($crs, CURLOPT_MAXREDIRS, 5); - if (defined('CURLOPT_PROTOCOLS')) { - curl_setopt($crs, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP | CURLPROTO_FTP | CURLPROTO_FTPS); - } + $curlopts = []; + if ( + (ini_get('open_basedir') == '') + && (ini_get('safe_mode') === '' + || ini_get('safe_mode') === false) + ) { + $curlopts[CURLOPT_FOLLOWLOCATION] = true; + } + $curlopts = array_replace($curlopts, self::CURLOPT_DEFAULT); + $curlopts = array_replace($curlopts, K_CURLOPTS); + $curlopts = array_replace($curlopts, self::CURLOPT_FIXED); + $curlopts[CURLOPT_URL] = $url; + curl_setopt_array($crs, $curlopts); curl_exec($crs); $code = curl_getinfo($crs, CURLINFO_HTTP_CODE); - curl_close($crs); + if (PHP_VERSION_ID < 80000) { + curl_close($crs); + } return ($code == 200); } @@ -1960,23 +1983,23 @@ public static function fileGetContents($file) { ) { // try to get remote file data using cURL $crs = curl_init(); - curl_setopt($crs, CURLOPT_URL, $path); - curl_setopt($crs, CURLOPT_FAILONERROR, true); - curl_setopt($crs, CURLOPT_RETURNTRANSFER, true); - if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) { - curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true); - } - curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5); - curl_setopt($crs, CURLOPT_TIMEOUT, 30); - curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file'); - curl_setopt($crs, CURLOPT_MAXREDIRS, 5); - if (defined('CURLOPT_PROTOCOLS')) { - curl_setopt($crs, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP | CURLPROTO_FTP | CURLPROTO_FTPS); + $curlopts = []; + if ( + (ini_get('open_basedir') == '') + && (ini_get('safe_mode') === '' + || ini_get('safe_mode') === false) + ) { + $curlopts[CURLOPT_FOLLOWLOCATION] = true; } + $curlopts = array_replace($curlopts, self::CURLOPT_DEFAULT); + $curlopts = array_replace($curlopts, K_CURLOPTS); + $curlopts = array_replace($curlopts, self::CURLOPT_FIXED); + $curlopts[CURLOPT_URL] = $url; + curl_setopt_array($crs, $curlopts); $ret = curl_exec($crs); - curl_close($crs); + if (PHP_VERSION_ID < 80000) { + curl_close($crs); + } if ($ret !== false) { return $ret; } @@ -2633,7 +2656,6 @@ public static function getPageMode($mode='UseNone') { return $page_mode; } - } // END OF TCPDF_STATIC CLASS //============================================================+ diff --git a/tools/tcpdf/tcpdf.php b/tools/tcpdf/tcpdf.php index 3404c52b37..b369532dce 100644 --- a/tools/tcpdf/tcpdf.php +++ b/tools/tcpdf/tcpdf.php @@ -1,13 +1,13 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.7.8 + * @version 6.11.3 */ // TCPDF configuration @@ -128,7 +128,7 @@ * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.
      * @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 6.7.8 + * @version 6.11.3 * @author Nicola Asuni - info@tecnick.com * @IgnoreAnnotation("protected") * @IgnoreAnnotation("public") @@ -1131,7 +1131,7 @@ class TCPDF { protected $opencell = true; /** - * Array of files to embedd. + * Array of files to embed. * @protected * @since 4.4.000 (2008-12-07) */ @@ -1810,6 +1810,13 @@ class TCPDF { */ protected $custom_xmp_rdf = ''; + /** + * Custom XMP RDF pdfaextension data. + * @protected + * @since 6.9.0 (2025-02-11) + */ + protected $custom_xmp_rdf_pdfaExtension = ''; + /** * Overprint mode array. * (Check the "Entries in a Graphics State Parameter Dictionary" on PDF 32000-1:2008). @@ -2900,14 +2907,7 @@ public function setDisplayMode($zoom, $layout='SinglePage', $mode='UseNone') { * @since 1.4 */ public function setCompression($compress=true) { - $this->compress = false; - if (function_exists('gzcompress')) { - if ($compress) { - if ( !$this->pdfa_mode) { - $this->compress = true; - } - } - } + $this->compress = ($compress && function_exists('gzcompress')); } /** @@ -3007,6 +3007,7 @@ public function setAllowLocalFiles($allowLocalFiles) { public function Error($msg) { // unset all class variables $this->_destroy(true); + $msg = htmlspecialchars($msg, ENT_QUOTES, 'UTF-8'); if (defined('K_TCPDF_THROW_EXCEPTION_ERROR') AND !K_TCPDF_THROW_EXCEPTION_ERROR) { die('TCPDF ERROR: '.$msg); } else { @@ -4251,7 +4252,7 @@ protected function getFontsList() { * @param string $style Font style. Possible values are (case insensitive):
      • empty string: regular (default)
      • B: bold
      • I: italic
      • BI or IB: bold italic
      * @param string $fontfile The font definition file. By default, the name is built from the family and style, in lower case with no spaces. * @return array|false array containing the font data, or false in case of error. - * @param mixed $subset if true embedd only a subset of the font (stores only the information related to the used characters); if false embedd full font; if 'default' uses the default value set using setFontSubsetting(). This option is valid only for TrueTypeUnicode fonts. If you want to enable users to change the document, set this parameter to false. If you subset the font, the person who receives your PDF would need to have your same font in order to make changes to your PDF. The file size of the PDF would also be smaller because you are embedding only part of a font. + * @param mixed $subset if true embed only a subset of the font (stores only the information related to the used characters); if false embed full font; if 'default' uses the default value set using setFontSubsetting(). This option is valid only for TrueTypeUnicode fonts. If you want to enable users to change the document, set this parameter to false. If you subset the font, the person who receives your PDF would need to have your same font in order to make changes to your PDF. The file size of the PDF would also be smaller because you are embedding only part of a font. * @public * @since 1.5 * @see SetFont(), setFontSubsetting() @@ -4431,7 +4432,7 @@ public function AddFont($family, $style='', $fontfile='', $subset='default') { $this->Error('All fonts must be embedded in PDF/A mode!'); } } else { - $this->Error('Unknow font type: '.$type.''); + $this->Error('Unknown font type: '.$type.''); } // set name if unset if (empty($name)) { @@ -4521,7 +4522,7 @@ public function AddFont($family, $style='', $fontfile='', $subset='default') { * @param string $style Font style. Possible values are (case insensitive):
      • empty string: regular
      • B: bold
      • I: italic
      • U: underline
      • D: line through
      • O: overline
      or any combination. The default value is regular. Bold and italic styles do not apply to Symbol and ZapfDingbats basic fonts or other fonts when not defined. * @param float|null $size Font size in points. The default value is the current size. If no size has been specified since the beginning of the document, the value taken is 12 * @param string $fontfile The font definition file. By default, the name is built from the family and style, in lower case with no spaces. - * @param mixed $subset if true embedd only a subset of the font (stores only the information related to the used characters); if false embedd full font; if 'default' uses the default value set using setFontSubsetting(). This option is valid only for TrueTypeUnicode fonts. If you want to enable users to change the document, set this parameter to false. If you subset the font, the person who receives your PDF would need to have your same font in order to make changes to your PDF. The file size of the PDF would also be smaller because you are embedding only part of a font. + * @param mixed $subset if true embed only a subset of the font (stores only the information related to the used characters); if false embed full font; if 'default' uses the default value set using setFontSubsetting(). This option is valid only for TrueTypeUnicode fonts. If you want to enable users to change the document, set this parameter to false. If you subset the font, the person who receives your PDF would need to have your same font in order to make changes to your PDF. The file size of the PDF would also be smaller because you are embedding only part of a font. * @param boolean $out if true output the font size command, otherwise only set the font properties. * @author Nicola Asuni * @public @@ -4931,6 +4932,32 @@ public function Annotation($x, $y, $w, $h, $text, $opt=array('Subtype'=>'Text'), } } + /** + * Embed the attached files. + * @since 6.9.000 (2025-02-11) + * @public + */ + public function EmbedFile($opt) { + if (!$this->pdfa_mode || ($this->pdfa_mode && $this->pdfa_version == 3)) { + if ((($opt['Subtype'] == 'FileAttachment')) AND (!TCPDF_STATIC::empty_string($opt['FS'])) + AND (@TCPDF_STATIC::file_exists($opt['FS']) OR TCPDF_STATIC::isValidURL($opt['FS'])) + AND (!isset($this->embeddedfiles[basename($opt['FS'])]))) { + $this->embeddedfiles[basename($opt['FS'])] = array('f' => ++$this->n, 'n' => ++$this->n, 'file' => $opt['FS']); + } + } + } + + /** + * Embed the attached files. + * @since 6.9.000 (2025-02-11) + * @public + */ + public function EmbedFileFromString($filename, $content) { + if (!$this->pdfa_mode || ($this->pdfa_mode && $this->pdfa_version == 3)) { + $this->embeddedfiles[$filename] = array('f' => ++$this->n, 'n' => ++$this->n, 'content' => $content ); + } + } + /** * Embedd the attached files. * @since 4.4.000 (2008-12-07) @@ -4944,7 +4971,12 @@ protected function _putEmbeddedFiles() { } reset($this->embeddedfiles); foreach ($this->embeddedfiles as $filename => $filedata) { - $data = $this->getCachedFileContents($filedata['file']); + $data = false; + if (isset($filedata['file']) && !empty($filedata['file'])) { + $data = $this->getCachedFileContents($filedata['file']); + } elseif ($filedata['content'] && !empty($filedata['content'])) { + $data = $filedata['content']; + } if ($data !== FALSE) { $rawsize = strlen($data); if ($rawsize > 0) { @@ -4962,11 +4994,10 @@ protected function _putEmbeddedFiles() { $filter = ''; if ($this->compress) { $data = gzcompress($data); - $filter = ' /Filter /FlateDecode'; + $filter .= ' /Filter /FlateDecode'; } - if ($this->pdfa_version == 3) { - $filter = ' /Subtype /text#2Fxml'; + $filter .= ' /Subtype /text#2Fxml'; } $stream = $this->_getrawstream($data, $filedata['n']); @@ -6232,7 +6263,7 @@ public function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false, $ln= * @param array|null $cellpadding Internal cell padding, if empty uses default cell padding. * @param mixed $border Indicates if borders must be drawn around the cell. The value can be a number:
      • 0: no border (default)
      • 1: frame
      or a string containing some or all of the following characters (in any order):
      • L: left
      • T: top
      • R: right
      • B: bottom
      or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))) * @return float Return the minimal height needed for multicell method for printing the $txt param. - * @author Alexander Escalona Fern\E1ndez, Nicola Asuni + * @author Alexander Escalona Fern\E1ndez,2026 Nicola Asuni * @public * @since 4.5.011 */ @@ -6428,7 +6459,7 @@ public function Write($h, $txt, $link='', $fill=false, $align='', $ln=false, $st // replacement for SHY character (minus symbol) $shy_replacement = 45; $shy_replacement_char = TCPDF_FONTS::unichr($shy_replacement, $this->isunicode); - // widht for SHY replacement + // width for SHY replacement $shy_replacement_width = $this->GetCharWidth($shy_replacement); // page width $pw = $w = $this->w - $this->lMargin - $this->rMargin; @@ -6886,8 +6917,8 @@ protected function fitBlock($w, $h, $x, $y, $fitonpage=false) { // fallback to avoid division by zero $h = $h == 0 ? 1 : $h; $ratio_wh = ($w / $h); - if (($y + $h) > $this->PageBreakTrigger) { - $h = $this->PageBreakTrigger - $y; + if (($y + $h) > $this->PageBreakTrigger + $this->bMargin) { + $h = $this->PageBreakTrigger + $this->bMargin - $y; $w = ($h * $ratio_wh); } if ((!$this->rtl) AND (($x + $w) > ($this->w - $this->rMargin))) { @@ -6988,7 +7019,7 @@ public function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='', $ unset($imgdata); $imsize = @getimagesize($file); if ($imsize === FALSE) { - unlink($file); + $this->_unlink($file); $file = $original_file; } } @@ -7221,7 +7252,7 @@ public function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='', $ $tempname = TCPDF_STATIC::getObjFilename('img', $this->file_id); $img->writeImage($tempname); $info = TCPDF_IMAGES::_parsejpeg($tempname); - unlink($tempname); + $this->_unlink($tempname); $img->destroy(); } catch(Exception $e) { $info = false; @@ -7401,12 +7432,16 @@ protected function ImagePngAlpha($file, $x, $y, $wpx, $hpx, $w, $h, $type, $link } } imagepng($imgalpha, $tempfile_alpha); - imagedestroy($imgalpha); + if (PHP_VERSION_ID < 80000) { + imagedestroy($imgalpha); + } // extract image without alpha channel $imgplain = imagecreatetruecolor($wpx, $hpx); imagecopy($imgplain, $img, 0, 0, 0, 0, $wpx, $hpx); imagepng($imgplain, $tempfile_plain); - imagedestroy($imgplain); + if (PHP_VERSION_ID < 80000) { + imagedestroy($imgplain); + } $parsed = true; } catch (Exception $e) { // GD fails @@ -7848,7 +7883,7 @@ public function Output($name='doc.pdf', $dest='I') { * @since 4.5.016 (2009-02-24) */ public function _destroy($destroyall=false, $preserve_objcopy=false) { - if (isset(self::$cleaned_ids[$this->file_id])) { + if (isset($this->file_id) && isset(self::$cleaned_ids[$this->file_id])) { $destroyall = false; } if ($destroyall AND !$preserve_objcopy && isset($this->file_id)) { @@ -7857,15 +7892,16 @@ public function _destroy($destroyall=false, $preserve_objcopy=false) { if ($handle = @opendir(K_PATH_CACHE)) { while ( false !== ( $file_name = readdir( $handle ) ) ) { if (strpos($file_name, '__tcpdf_'.$this->file_id.'_') === 0) { - unlink(K_PATH_CACHE.$file_name); + $this->_unlink(K_PATH_CACHE.$file_name); } } closedir($handle); } if (isset($this->imagekeys)) { foreach($this->imagekeys as $file) { - if (strpos($file, K_PATH_CACHE) === 0 && TCPDF_STATIC::file_exists($file)) { - @unlink($file); + if ((strpos($file, K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_') === 0) + && TCPDF_STATIC::file_exists($file)) { + $this->_unlink($file); } } } @@ -8310,15 +8346,15 @@ protected function _putannotsobjs() { break; } case 'locked': { - $fval += 1 << 8; + $fval += 1 << 7; break; } case 'togglenoview': { - $fval += 1 << 9; + $fval += 1 << 8; break; } case 'lockedcontents': { - $fval += 1 << 10; + $fval += 1 << 9; break; } default: { @@ -8895,7 +8931,7 @@ protected function _putfonts() { $this->_out('<< /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.'] >>'."\n".'endobj'); } foreach ($this->FontFiles as $file => $info) { - // search and get font file to embedd + // search and get font file to embed $fontfile = TCPDF_FONTS::getFontFullPath($file, $info['fontdir']); if (!TCPDF_STATIC::empty_string($fontfile)) { $font = file_get_contents($fontfile); @@ -9110,9 +9146,9 @@ protected function _puttruetypeunicode($font) { $this->_newobj(); // Embed CIDToGIDMap // A specification of the mapping from CIDs to glyph indices - // search and get CTG font file to embedd + // search and get CTG font file to embed $ctgfile = strtolower($font['ctg']); - // search and get ctg font file to embedd + // search and get ctg font file to embed $fontfile = TCPDF_FONTS::getFontFullPath($ctgfile, $fontdir); if (TCPDF_STATIC::empty_string($fontfile)) { $this->Error('Font file not found: '.$ctgfile); @@ -9137,7 +9173,7 @@ protected function _puttruetypeunicode($font) { * A Type 0 CIDFont contains glyph descriptions based on the Adobe Type 1 font format * @param array $font font data * @protected - * @author Andrew Whitehead, Nicola Asuni, Yukihiro Nakadaira + * @author Andrew Whitehead,2026 Nicola Asuni, Yukihiro Nakadaira * @since 3.2.000 (2008-06-23) */ protected function _putcidfont0($font) { @@ -9628,6 +9664,17 @@ public function setExtraXMPRDF($xmp) { $this->custom_xmp_rdf = $xmp; } + /** + * Set additional XMP data to be added to the default XMP data for PDF/A extensions. + * IMPORTANT: This data is added as-is without controls, so you have to validate your data before using this method! + * @param string $xmp Custom XMP RDF data. + * @since 6.9.0 (2025-02-14) + * @public + */ + public function setExtraXMPPdfaextension($xmp) { + $this->custom_xmp_rdf_pdfaExtension = $xmp; + } + /** * Put XMP data object and return ID. * @return int The object ID. @@ -9762,6 +9809,7 @@ protected function _putXMP() { $xmp .= "\t\t\t\t\t\t\t".''."\n"; $xmp .= "\t\t\t\t\t\t".''."\n"; $xmp .= "\t\t\t\t\t".''."\n"; + $xmp .= $this->custom_xmp_rdf_pdfaExtension; $xmp .= "\t\t\t\t".''."\n"; $xmp .= "\t\t\t".''."\n"; $xmp .= "\t\t".''."\n"; @@ -9800,7 +9848,11 @@ protected function _putcatalog() { } // start catalog $oid = $this->_newobj(); - $out = '<< /Type /Catalog'; + $out = '<< '; + if (!empty($this->efnames)) { + $out .= ' /AF [ '. implode(' ', $this->efnames) .' ]'; + } + $out .= ' /Type /Catalog'; $out .= ' /Version /'.$this->PDFVersion; //$out .= ' /Extensions <<>>'; $out .= ' /Pages 1 0 R'; @@ -12275,7 +12327,7 @@ public function RoundedRectXY($x, $y, $w, $h, $rx, $ry, $round_corner='1111', $s * @param int $head_style (0 = draw only arrowhead arms, 1 = draw closed arrowhead, but no fill, 2 = closed and filled arrowhead, 3 = filled arrowhead) * @param float $arm_size length of arrowhead arms * @param int $arm_angle angle between an arm and the shaft - * @author Piotr Galecki, Nicola Asuni, Andy Meier + * @author Piotr Galecki,2026 Nicola Asuni, Andy Meier * @since 4.6.018 (2009-07-10) */ public function Arrow($x0, $y0, $x1, $y1, $head_style=0, $arm_size=5, $arm_angle=15) { @@ -12340,7 +12392,7 @@ public function Arrow($x0, $y0, $x1, $y1, $head_style=0, $arm_size=5, $arm_angle * @param float $x X position in user units of the destiantion on the selected page (default = -1 = current position;). * @return string|false Stripped named destination identifier or false in case of error. * @public - * @author Christian Deligant, Nicola Asuni + * @author Christian Deligant,2026 Nicola Asuni * @since 5.9.097 (2011-06-23) */ public function setDestination($name, $y=-1, $page='', $x=-1) { @@ -12393,7 +12445,7 @@ public function getDestination() { /** * Insert Named Destinations. * @protected - * @author Johannes G\FCntert, Nicola Asuni + * @author Johannes G\FCntert,2026 Nicola Asuni * @since 5.9.098 (2011-06-23) */ protected function _putdests() { @@ -12502,7 +12554,7 @@ protected function sortBookmarks() { /** * Create a bookmark PDF string. * @protected - * @author Olivier Plathey, Nicola Asuni + * @author Olivier Plathey,2026 Nicola Asuni * @since 2.1.002 (2008-02-12) */ protected function _putbookmarks() { @@ -12628,7 +12680,7 @@ protected function _putbookmarks() { * Adds a javascript * @param string $script Javascript code * @public - * @author Johannes G\FCntert, Nicola Asuni + * @author Johannes G\FCntert,2026 Nicola Asuni * @since 2.1.002 (2008-02-12) */ public function IncludeJS($script) { @@ -12657,7 +12709,7 @@ public function addJavascriptObject($script, $onload=false) { /** * Create a javascript PDF string. * @protected - * @author Johannes G\FCntert, Nicola Asuni + * @author Johannes G\FCntert,2026 Nicola Asuni * @since 2.1.002 (2008-02-12) */ protected function _putjavascript() { @@ -12715,7 +12767,7 @@ protected function _putjavascript() { * @param int $h height * @param array $prop javascript field properties. Possible values are described on official Javascript for Acrobat API reference. * @protected - * @author Denis Van Nuffelen, Nicola Asuni + * @author Denis Van Nuffelen,2026 Nicola Asuni * @since 2.1.002 (2008-02-12) */ protected function _addfield($type, $name, $x, $y, $w, $h, $prop) { @@ -14448,7 +14500,7 @@ public function registrationMarkCMYK($x, $y, $r) { * @param array $col1 first color (Grayscale, RGB or CMYK components). * @param array $col2 second color (Grayscale, RGB or CMYK components). * @param array $coords array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg). The default value is from left to right (x1=0, y1=0, x2=1, y2=0). - * @author Andreas W\FCrmser, Nicola Asuni + * @author Andreas W\FCrmser,2026 Nicola Asuni * @since 3.1.000 (2008-06-09) * @public */ @@ -14466,7 +14518,7 @@ public function LinearGradient($x, $y, $w, $h, $col1=array(), $col2=array(), $co * @param array $col1 first color (Grayscale, RGB or CMYK components). * @param array $col2 second color (Grayscale, RGB or CMYK components). * @param array $coords array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1, (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg). (fx, fy) should be inside the circle, otherwise some areas will not be defined. - * @author Andreas W\FCrmser, Nicola Asuni + * @author Andreas W\FCrmser,2026 Nicola Asuni * @since 3.1.000 (2008-06-09) * @public */ @@ -14489,7 +14541,7 @@ public function RadialGradient($x, $y, $w, $h, $col1=array(), $col2=array(), $co * @param array $coords_min minimum value used by the coordinates. If a coordinate's value is smaller than this it will be cut to coords_min. default: 0 * @param array $coords_max maximum value used by the coordinates. If a coordinate's value is greater than this it will be cut to coords_max. default: 1 * @param boolean $antialias A flag indicating whether to filter the shading function to prevent aliasing artifacts. - * @author Andreas W\FCrmser, Nicola Asuni + * @author Andreas W\FCrmser,2026 Nicola Asuni * @since 3.1.000 (2008-06-09) * @public */ @@ -14581,7 +14633,7 @@ public function CoonsPatchMesh($x, $y, $w, $h, $col1=array(), $col2=array(), $co * @param float $y ordinate of the top left corner of the rectangle. * @param float $w width of the rectangle. * @param float $h height of the rectangle. - * @author Andreas W\FCrmser, Nicola Asuni + * @author Andreas W\FCrmser,2026 Nicola Asuni * @since 3.1.000 (2008-06-09) * @protected */ @@ -14907,7 +14959,7 @@ function _putshaders() { * @param string $style Style of rendering. See the getPathPaintOperator() function for more information. * @param float $cw indicates whether to go clockwise (default: true). * @param float $o origin of angles (0 for 3 o'clock, 90 for noon, 180 for 9 o'clock, 270 for 6 o'clock). Default: 90. - * @author Maxime Delorme, Nicola Asuni + * @author Maxime Delorme,2026 Nicola Asuni * @since 3.1.000 (2008-06-09) * @public */ @@ -14928,7 +14980,7 @@ public function PieSector($xc, $yc, $r, $a, $b, $style='FD', $cw=true, $o=90) { * @param float $cw indicates whether to go clockwise. * @param float $o origin of angles (0 for 3 o'clock, 90 for noon, 180 for 9 o'clock, 270 for 6 o'clock). * @param integer $nc Number of curves used to draw a 90 degrees portion of arc. - * @author Maxime Delorme, Nicola Asuni + * @author Maxime Delorme,2026 Nicola Asuni * @since 3.1.000 (2008-06-09) * @public */ @@ -14972,7 +15024,7 @@ public function PieSectorXY($xc, $yc, $rx, $ry, $a, $b, $style='FD', $cw=false, * @param mixed $border Indicates if borders must be drawn around the cell. The value can be a number:
      • 0: no border (default)
      • 1: frame
      or a string containing some or all of the following characters (in any order):
      • L: left
      • T: top
      • R: right
      • B: bottom
      or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))) * @param boolean $fitonpage if true the image is resized to not exceed page dimensions. * @param boolean $fixoutvals if true remove values outside the bounding box. - * @author Valentin Schmidt, Nicola Asuni + * @author Valentin Schmidt,2026 Nicola Asuni * @since 3.1.000 (2008-06-09) * @public */ @@ -16396,7 +16448,7 @@ public function getHTMLFontUnits($val, $refsize=12, $parent_size=12, $defaultuni * @since 3.2.000 (2008-06-20) */ protected function getHtmlDomArray($html) { - // set inheritable properties fot the first void element + // set inheritable properties for the first void element // possible inheritable properties are: azimuth, border-collapse, border-spacing, caption-side, color, cursor, direction, empty-cells, font, font-family, font-stretch, font-size, font-size-adjust, font-style, font-variant, font-weight, letter-spacing, line-height, list-style, list-style-image, list-style-position, list-style-type, orphans, page, page-break-inside, quotes, speak, speak-header, text-align, text-indent, text-transform, volume, white-space, widows, word-spacing $dom = array( array( @@ -16862,7 +16914,7 @@ protected function getHtmlDomArray($html) { $dom[$key]['height'] = $dom[$key]['style']['height']; } // check for text alignment - if (isset($dom[$key]['style']['text-align'])) { + if (isset($dom[$key]['style']['text-align'][0])) { $dom[$key]['align'] = strtoupper($dom[$key]['style']['text-align'][0]); } // check for CSS border properties @@ -17259,7 +17311,7 @@ protected function unserializeTCPDFtag($data) { $hlen = intval(substr($data, 0, $hpos)); $hash = substr($data, $hpos + 1, $hlen); $encoded = substr($data, $hpos + 2 + $hlen); - if ($hash != $this->hashTCPDFtag($encoded)) { + if (!hash_equals( $this->hashTCPDFtag($encoded), $hash)) { $this->Error('Invalid parameters'); } return json_decode(urldecode($encoded), true); @@ -17425,6 +17477,9 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal } } if ($key == $maxel) break; + if ($dom[$key]['tag'] AND $dom[$key]['opening'] AND !empty($dom[$key]['attribute']['id'])) { + $this->setDestination($dom[$key]['attribute']['id']); + } if ($dom[$key]['tag'] AND isset($dom[$key]['attribute']['pagebreak'])) { // check for pagebreak if (($dom[$key]['attribute']['pagebreak'] == 'true') OR ($dom[$key]['attribute']['pagebreak'] == 'left') OR ($dom[$key]['attribute']['pagebreak'] == 'right')) { @@ -18867,6 +18922,29 @@ public function writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=fal unset($dom); } + /** + * Check if the path is relative. + * @param string $path path to check + * @return boolean true if the path is relative + * @protected + * @since 6.9.1 + */ + protected function isRelativePath($path) { + return (strpos(str_ireplace('%2E', '.', $this->unhtmlentities($path)), '..') !== false); + } + + /** + * Check if it contains a non-allowed external protocol. + * @param string $path path to check + * @return boolean true if the protocol is not allowed. + * @protected + * @since 6.9.3 + */ + protected function hasExtForbiddenProtocol($path) { + return ((strpos($path, '://') !== false) + && (preg_match('|^https?://|', $path) !== 1)); + } + /** * Process opening tags. * @param array $dom html dom array @@ -19059,13 +19137,15 @@ protected function openHTMLTagHandler($dom, $key, $cell) { } else if (preg_match('@^data:image/([^;]*);base64,(.*)@', $imgsrc, $reg)) { $imgsrc = '@'.base64_decode($reg[2]); $type = $reg[1]; - } elseif (strpos($imgsrc, '../') !== false) { + } elseif ($this->isRelativePath($imgsrc)) { // accessing parent folders is not allowed break; } elseif ( $this->allowLocalFiles && substr($imgsrc, 0, 7) === 'file://') { // get image type from a local file path $imgsrc = substr($imgsrc, 7); $type = TCPDF_IMAGES::getImageFileType($imgsrc); + } elseif ($this->hasExtForbiddenProtocol($imgsrc)) { + break; } else { if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) { // fix image path @@ -19124,7 +19204,7 @@ protected function openHTMLTagHandler($dom, $key, $cell) { $imglink = ''; if (isset($this->HREF['url']) AND !TCPDF_STATIC::empty_string($this->HREF['url'])) { $imglink = $this->HREF['url']; - if ($imglink[0] == '#') { + if ($imglink[0] == '#' AND isset($imglink[1]) AND is_numeric($imglink[1])) { // convert url to internal link $lnkdata = explode(',', $imglink); if (isset($lnkdata[0])) { @@ -19985,7 +20065,7 @@ protected function closeHTMLTagHandler($dom, $key, $cell, $maxbottomliney=0) { } } if (!$in_table_head) { // we are not inside a thead section - $this->cell_padding = isset($table_el['old_cell_padding']) ? $table_el['old_cell_padding'] : null; + $this->cell_padding = isset($table_el['old_cell_padding']) ? $table_el['old_cell_padding'] : array('T' => 0, 'R' => 0, 'B' => 0, 'L' => 0); // reset row height $this->resetLastH(); if (($this->page == ($this->numpages - 1)) AND ($this->pageopen[$this->numpages])) { @@ -23184,8 +23264,11 @@ public function ImageSVG($file, $x=null, $y=null, $w=0, $h=0, $link='', $align=' $error_message = sprintf('SVG Error: %s at line %d', xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser)); $this->Error($error_message); } - // free this XML parser - xml_parser_free($parser); + + // free this XML parser (does nothing in PHP >= 8.0) + if (function_exists('xml_parser_free') && PHP_VERSION_ID < 80000) { + xml_parser_free($parser); + } // >= PHP 7.0.0 "explicitly unset the reference to parser to avoid memory leaks" unset($parser); @@ -23416,7 +23499,8 @@ protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1 $gradient['coords'][4] /= $w; } elseif ($gradient['mode'] == 'percentage') { foreach($gradient['coords'] as $key => $val) { - $gradient['coords'][$key] = (intval($val) / 100); + $val = floatval($val) / 100; + $gradient['coords'][$key] = $val; if ($val < 0) { $gradient['coords'][$key] = 0; } elseif ($val > 1) { @@ -23452,6 +23536,8 @@ protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1 $fill_color = TCPDF_COLORS::convertHTMLColorToDec($svgstyle['fill'], $this->spot_colors); if ($svgstyle['fill-opacity'] != 1) { $this->setAlpha($this->alpha['CA'], 'Normal', $svgstyle['fill-opacity'], false); + } elseif (preg_match('/rgba\(\d+%?,\s*\d+%?,\s*\d+%?,\s*(\d+(?:\.\d+)?)\)/i', $svgstyle['fill'], $rgba_matches)) { + $this->setAlpha($this->alpha['CA'], 'Normal', $rgba_matches[1], false); } $this->setFillColorArray($fill_color); if ($svgstyle['fill-rule'] == 'evenodd') { @@ -23485,7 +23571,7 @@ protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1 if (preg_match('/font-family[\s]*:[\s]*([^\;\"]*)/si', $svgstyle['font'], $regs)) { $font_family = $this->getFontFamilyName($regs[1]); } else { - $font_family = $svgstyle['font-family']; + $font_family = $this->getFontFamilyName($svgstyle['font-family']); } if (preg_match('/font-size[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle['font'], $regs)) { $font_size = trim($regs[1]); @@ -23639,9 +23725,11 @@ protected function SVGPath($d, $style='') { } $params = array(); if (isset($val[2])) { - // get curve parameters - preg_match_all('/-?\d*\.?\d+/', trim($val[2]), $matches); - $rawparams = $matches[0]; + // get curve parameters, see https://github.com/tecnickcom/TCPDF/issues/767 + $rawparams = preg_split('/([\,\s]+)/si', trim($val[2])); + $rawparams = array_filter($rawparams, function($p) { + return trim($p) != ''; + }); $params = array(); foreach ($rawparams as $ck => $cp) { $params[$ck] = $this->getHTMLUnitToUnits($cp, 0, $this->svgunit, false); @@ -24338,6 +24426,7 @@ protected function startSVGElementHandler($parser, $name, $attribs, $ctm=array() } $this->StopTransform(); } + break; } case 'ellipse': { @@ -24466,6 +24555,9 @@ protected function startSVGElementHandler($parser, $name, $attribs, $ctm=array() $img = '@'.base64_decode(substr($img, strlen($m[0]))); } else { // fix image path + if ($this->isRelativePath($img) || $this->hasExtForbiddenProtocol($img)) { + break; + } if (!TCPDF_STATIC::empty_string($this->svgdir) AND (($img[0] == '.') OR (basename($img) == $img))) { // replace relative path with full server path $img = $this->svgdir.'/'.$img; @@ -24648,7 +24740,7 @@ protected function startSVGElementHandler($parser, $name, $attribs, $ctm=array() */ protected function endSVGElementHandler($parser, $name) { $name = $this->removeTagNamespace($name); - if ($this->svgdefsmode AND !in_array($name, array('defs', 'clipPath', 'linearGradient', 'radialGradient', 'stop'))) {; + if ($this->svgdefsmode AND !in_array($name, array('defs', 'clipPath', 'linearGradient', 'radialGradient', 'stop'))) { if (end($this->svgdefs) !== FALSE) { $last_svgdefs_id = key($this->svgdefs); if (isset($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'])) { @@ -24786,6 +24878,20 @@ protected function fileExists($file) return TCPDF_STATIC::file_exists($file); } + /** + * Wrapper for unlink with disabled protocols. + * @param string $file + * @return bool + */ + protected function _unlink($file) + { + if ((strpos($file, '://') !== false) && ((substr($file, 0, 7) !== 'file://') || (!$this->allowLocalFiles))) { + // forbidden protocol + return false; + } + return @unlink($file); + } + } // END OF TCPDF CLASS //============================================================+ diff --git a/tools/tcpdf/tcpdf_autoconfig.php b/tools/tcpdf/tcpdf_autoconfig.php index 2bcfccb82b..dd1404e094 100644 --- a/tools/tcpdf/tcpdf_autoconfig.php +++ b/tools/tcpdf/tcpdf_autoconfig.php @@ -3,11 +3,11 @@ // File name : tcpdf_autoconfig.php // Version : 1.1.1 // Begin : 2013-05-16 -// Last Update : 2014-12-18 +// Last Update : 2025-04-18 // Authors : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2011-2014 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2011-2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -37,9 +37,14 @@ * @file * Try to automatically configure some TCPDF constants if not defined. * @package com.tecnick.tcpdf - * @version 1.1.1 + * @version 1.2.1 */ +// Disable phar stream wrapper globally. +// if (in_array('phar', stream_get_wrappers(), true)) { +// stream_wrapper_unregister('phar'); +// } + // DOCUMENT_ROOT fix for IIS Webserver if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) { if(isset($_SERVER['SCRIPT_FILENAME'])) { @@ -149,7 +154,7 @@ } if (!defined('PDF_HEADER_STRING')) { - define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); + define ('PDF_HEADER_STRING', "by2026 Nicola Asuni - Tecnick.com\nwww.tcpdf.org"); } if (!defined('PDF_UNIT')) { @@ -201,7 +206,7 @@ } if (!defined('PDF_IMAGE_SCALE_RATIO')) { - define ('PDF_IMAGE_SCALE_RATIO', 1.25); + define ('PDF_IMAGE_SCALE_RATIO', 96/72); } if (!defined('HEAD_MAGNIFICATION')) { @@ -240,6 +245,11 @@ define('K_TIMEZONE', @date_default_timezone_get()); } +// Custom cURL options for curl_setopt_array. +if (!defined('K_CURLOPTS')) { + define('K_CURLOPTS', array()); +} + //============================================================+ // END OF FILE //============================================================+ diff --git a/tools/tcpdf/tcpdf_barcodes_1d.php b/tools/tcpdf/tcpdf_barcodes_1d.php index 45d35616c8..34cb6da17a 100644 --- a/tools/tcpdf/tcpdf_barcodes_1d.php +++ b/tools/tcpdf/tcpdf_barcodes_1d.php @@ -5,9 +5,9 @@ // Begin : 2008-06-09 // Last Update : 2014-10-20 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2008-2014 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2008-2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -22,7 +22,7 @@ // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see . +// along with TCPDF. If not, see . // // See LICENSE.TXT file for more information. // ------------------------------------------------------------------- @@ -234,7 +234,9 @@ public function getBarcodePngData($w=2, $h=30, $color=array(0,0,0)) { ob_start(); imagepng($png); $imagedata = ob_get_clean(); - imagedestroy($png); + if (PHP_VERSION_ID < 80000) { + imagedestroy($png); + } return $imagedata; } } diff --git a/tools/tcpdf/tcpdf_barcodes_2d.php b/tools/tcpdf/tcpdf_barcodes_2d.php index 730361bd8c..0e11636530 100644 --- a/tools/tcpdf/tcpdf_barcodes_2d.php +++ b/tools/tcpdf/tcpdf_barcodes_2d.php @@ -5,9 +5,9 @@ // Begin : 2009-04-07 // Last Update : 2014-05-20 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2009-2014 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2009-2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -22,7 +22,7 @@ // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with TCPDF. If not, see . +// along with TCPDF. If not, see . // // See LICENSE.TXT file for more information. // ------------------------------------------------------------------- @@ -238,7 +238,9 @@ public function getBarcodePngData($w=3, $h=3, $color=array(0,0,0)) { ob_start(); imagepng($png); $imagedata = ob_get_clean(); - imagedestroy($png); + if (PHP_VERSION_ID < 80000) { + imagedestroy($png); + } return $imagedata; } } diff --git a/tools/tcpdf/tcpdf_import.php b/tools/tcpdf/tcpdf_import.php deleted file mode 100644 index 57f9f4f4bd..0000000000 --- a/tools/tcpdf/tcpdf_import.php +++ /dev/null @@ -1,104 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : This is a PHP class extension of the TCPDF library to -// import existing PDF documents. -// -//============================================================+ - -/** - * @file - * !!! THIS CLASS IS UNDER DEVELOPMENT !!! - * This is a PHP class extension of the TCPDF (http://www.tcpdf.org) library to import existing PDF documents.
      - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.001 - */ - -// include the TCPDF class -require_once(dirname(__FILE__).'/tcpdf.php'); -// include PDF parser class -require_once(dirname(__FILE__).'/tcpdf_parser.php'); - -/** - * @class TCPDF_IMPORT - * !!! THIS CLASS IS UNDER DEVELOPMENT !!! - * PHP class extension of the TCPDF (http://www.tcpdf.org) library to import existing PDF documents.
      - * @package com.tecnick.tcpdf - * @brief PHP class extension of the TCPDF library to import existing PDF documents. - * @version 1.0.001 - * @author Nicola Asuni - info@tecnick.com - */ -class TCPDF_IMPORT extends TCPDF { - - /** - * Import an existing PDF document - * @param string $filename Filename of the PDF document to import. - * @return void - * @public - * @since 1.0.000 (2011-05-24) - */ - public function importPDF($filename) { - // load document - $rawdata = file_get_contents($filename); - if ($rawdata === false) { - $this->Error('Unable to get the content of the file: '.$filename); - } - // configuration parameters for parser - $cfg = array( - 'die_for_errors' => false, - 'ignore_filter_decoding_errors' => true, - 'ignore_missing_filter_decoders' => true, - ); - try { - // parse PDF data - $pdf = new TCPDF_PARSER($rawdata, $cfg); - } catch (Exception $e) { - die($e->getMessage()); - } - // get the parsed data - $data = $pdf->getParsedData(); - // release some memory - unset($rawdata); - - // ... - - - print_r($data); // DEBUG - - - unset($pdf); - } - -} // END OF CLASS - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/tcpdf_parser.php b/tools/tcpdf/tcpdf_parser.php deleted file mode 100644 index 4156230a38..0000000000 --- a/tools/tcpdf/tcpdf_parser.php +++ /dev/null @@ -1,815 +0,0 @@ -. -// -// See LICENSE.TXT file for more information. -// ------------------------------------------------------------------- -// -// Description : This is a PHP class for parsing PDF documents. -// -//============================================================+ - -/** - * @file - * This is a PHP class for parsing PDF documents.
      - * @package com.tecnick.tcpdf - * @author Nicola Asuni - * @version 1.0.15 - */ - -// include class for decoding filters -require_once(dirname(__FILE__).'/include/tcpdf_filters.php'); - -/** - * @class TCPDF_PARSER - * This is a PHP class for parsing PDF documents.
      - * @package com.tecnick.tcpdf - * @brief This is a PHP class for parsing PDF documents.. - * @version 1.0.15 - * @author Nicola Asuni - info@tecnick.com - */ -class TCPDF_PARSER { - - /** - * Raw content of the PDF document. - * @private - */ - private $pdfdata = ''; - - /** - * XREF data. - * @protected - */ - protected $xref = array(); - - /** - * Array of PDF objects. - * @protected - */ - protected $objects = array(); - - /** - * Class object for decoding filters. - * @private - */ - private $FilterDecoders; - - /** - * Array of configuration parameters. - * @private - */ - private $cfg = array( - 'die_for_errors' => false, - 'ignore_filter_decoding_errors' => true, - 'ignore_missing_filter_decoders' => true, - ); - -// ----------------------------------------------------------------------------- - - /** - * Parse a PDF document an return an array of objects. - * @param string $data PDF data to parse. - * @param array $cfg Array of configuration parameters: - * 'die_for_errors' : if true termitate the program execution in case of error, otherwise thows an exception; - * 'ignore_filter_decoding_errors' : if true ignore filter decoding errors; - * 'ignore_missing_filter_decoders' : if true ignore missing filter decoding errors. - * @public - * @since 1.0.000 (2011-05-24) - */ - public function __construct($data, $cfg=array()) { - if (empty($data)) { - $this->Error('Empty PDF data.'); - } - // find the pdf header starting position - if (($trimpos = strpos($data, '%PDF-')) === FALSE) { - $this->Error('Invalid PDF data: missing %PDF header.'); - } - // get PDF content string - $this->pdfdata = substr($data, $trimpos); - // get length - $pdflen = strlen($this->pdfdata); - // set configuration parameters - $this->setConfig($cfg); - // get xref and trailer data - $this->xref = $this->getXrefData(); - // parse all document objects - $this->objects = array(); - foreach ($this->xref['xref'] as $obj => $offset) { - if (!isset($this->objects[$obj]) AND ($offset > 0)) { - // decode objects with positive offset - $this->objects[$obj] = $this->getIndirectObject($obj, $offset, true); - } - } - // release some memory - unset($this->pdfdata); - $this->pdfdata = ''; - } - - /** - * Set the configuration parameters. - * @param array $cfg Array of configuration parameters: - * 'die_for_errors' : if true termitate the program execution in case of error, otherwise thows an exception; - * 'ignore_filter_decoding_errors' : if true ignore filter decoding errors; - * 'ignore_missing_filter_decoders' : if true ignore missing filter decoding errors. - * @public - */ - protected function setConfig($cfg) { - if (isset($cfg['die_for_errors'])) { - $this->cfg['die_for_errors'] = !!$cfg['die_for_errors']; - } - if (isset($cfg['ignore_filter_decoding_errors'])) { - $this->cfg['ignore_filter_decoding_errors'] = !!$cfg['ignore_filter_decoding_errors']; - } - if (isset($cfg['ignore_missing_filter_decoders'])) { - $this->cfg['ignore_missing_filter_decoders'] = !!$cfg['ignore_missing_filter_decoders']; - } - } - - /** - * Return an array of parsed PDF document objects. - * @return array Array of parsed PDF document objects. - * @public - * @since 1.0.000 (2011-06-26) - */ - public function getParsedData() { - return array($this->xref, $this->objects); - } - - /** - * Get Cross-Reference (xref) table and trailer data from PDF document data. - * @param int $offset xref offset (if know). - * @param array $xref previous xref array (if any). - * @return array containing xref and trailer data. - * @protected - * @since 1.0.000 (2011-05-24) - */ - protected function getXrefData($offset=0, $xref=array()) { - if ($offset == 0) { - // find last startxref - if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_SET_ORDER, $offset) == 0) { - $this->Error('Unable to find startxref'); - } - $matches = array_pop($matches); - $startxref = $matches[1]; - } elseif (strpos($this->pdfdata, 'xref', $offset) == $offset) { - // Already pointing at the xref table - $startxref = $offset; - } elseif (preg_match('/([0-9]+[\s][0-9]+[\s]obj)/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) { - // Cross-Reference Stream object - $startxref = $offset; - } elseif (preg_match('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) { - // startxref found - $startxref = $matches[1][0]; - } else { - $this->Error('Unable to find startxref'); - } - // check xref position - if (strpos($this->pdfdata, 'xref', $startxref) == $startxref) { - // Cross-Reference - $xref = $this->decodeXref($startxref, $xref); - } else { - // Cross-Reference Stream - $xref = $this->decodeXrefStream($startxref, $xref); - } - if (empty($xref)) { - $this->Error('Unable to find xref'); - } - return $xref; - } - - /** - * Decode the Cross-Reference section - * @param int $startxref Offset at which the xref section starts (position of the 'xref' keyword). - * @param array $xref Previous xref array (if any). - * @return array containing xref and trailer data. - * @protected - * @since 1.0.000 (2011-06-20) - */ - protected function decodeXref($startxref, $xref=array()) { - $startxref += 4; // 4 is the length of the word 'xref' - // skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP) - $offset = $startxref + strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $startxref); - // initialize object number - $obj_num = 0; - // search for cross-reference entries or subsection - while (preg_match('/([0-9]+)[\x20]([0-9]+)[\x20]?([nf]?)(\r\n|[\x20]?[\r\n])/', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) { - if ($matches[0][1] != $offset) { - // we are on another section - break; - } - $offset += strlen($matches[0][0]); - if ($matches[3][0] == 'n') { - // create unique object index: [object number]_[generation number] - $index = $obj_num.'_'.intval($matches[2][0]); - // check if object already exist - if (!isset($xref['xref'][$index])) { - // store object offset position - $xref['xref'][$index] = intval($matches[1][0]); - } - ++$obj_num; - } elseif ($matches[3][0] == 'f') { - ++$obj_num; - } else { - // object number (index) - $obj_num = intval($matches[1][0]); - } - } - // get trailer data - if (preg_match('/trailer[\s]*<<(.*)>>/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) { - $trailer_data = $matches[1][0]; - if (!isset($xref['trailer']) OR empty($xref['trailer'])) { - // get only the last updated version - $xref['trailer'] = array(); - // parse trailer_data - if (preg_match('/Size[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) { - $xref['trailer']['size'] = intval($matches[1]); - } - if (preg_match('/Root[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) { - $xref['trailer']['root'] = intval($matches[1]).'_'.intval($matches[2]); - } - if (preg_match('/Encrypt[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) { - $xref['trailer']['encrypt'] = intval($matches[1]).'_'.intval($matches[2]); - } - if (preg_match('/Info[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) { - $xref['trailer']['info'] = intval($matches[1]).'_'.intval($matches[2]); - } - if (preg_match('/ID[\s]*[\[][\s]*[<]([^>]*)[>][\s]*[<]([^>]*)[>]/i', $trailer_data, $matches) > 0) { - $xref['trailer']['id'] = array(); - $xref['trailer']['id'][0] = $matches[1]; - $xref['trailer']['id'][1] = $matches[2]; - } - } - if (preg_match('/Prev[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) { - // get previous xref - $xref = $this->getXrefData(intval($matches[1]), $xref); - } - } else { - $this->Error('Unable to find trailer'); - } - return $xref; - } - - /** - * Decode the Cross-Reference Stream section - * @param int $startxref Offset at which the xref section starts. - * @param array $xref Previous xref array (if any). - * @return array containing xref and trailer data. - * @protected - * @since 1.0.003 (2013-03-16) - */ - protected function decodeXrefStream($startxref, $xref=array()) { - // try to read Cross-Reference Stream - $xrefobj = $this->getRawObject($startxref); - $xrefcrs = $this->getIndirectObject($xrefobj[1], $startxref, true); - if (!isset($xref['trailer']) OR empty($xref['trailer'])) { - // get only the last updated version - $xref['trailer'] = array(); - $filltrailer = true; - } else { - $filltrailer = false; - } - if (!isset($xref['xref'])) { - $xref['xref'] = array(); - } - $valid_crs = false; - $columns = 0; - $sarr = $xrefcrs[0][1]; - if (!is_array($sarr)) { - $sarr = array(); - } - foreach ($sarr as $k => $v) { - if (($v[0] == '/') AND ($v[1] == 'Type') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == '/') AND ($sarr[($k +1)][1] == 'XRef'))) { - $valid_crs = true; - } elseif (($v[0] == '/') AND ($v[1] == 'Index') AND (isset($sarr[($k +1)]))) { - // first object number in the subsection - $index_first = intval($sarr[($k +1)][1][0][1]); - // number of entries in the subsection - $index_entries = intval($sarr[($k +1)][1][1][1]); - } elseif (($v[0] == '/') AND ($v[1] == 'Prev') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'numeric'))) { - // get previous xref offset - $prevxref = intval($sarr[($k +1)][1]); - } elseif (($v[0] == '/') AND ($v[1] == 'W') AND (isset($sarr[($k +1)]))) { - // number of bytes (in the decoded stream) of the corresponding field - $wb = array(); - $wb[0] = intval($sarr[($k +1)][1][0][1]); - $wb[1] = intval($sarr[($k +1)][1][1][1]); - $wb[2] = intval($sarr[($k +1)][1][2][1]); - } elseif (($v[0] == '/') AND ($v[1] == 'DecodeParms') AND (isset($sarr[($k +1)][1]))) { - $decpar = $sarr[($k +1)][1]; - foreach ($decpar as $kdc => $vdc) { - if (($vdc[0] == '/') AND ($vdc[1] == 'Columns') AND (isset($decpar[($kdc +1)]) AND ($decpar[($kdc +1)][0] == 'numeric'))) { - $columns = intval($decpar[($kdc +1)][1]); - } elseif (($vdc[0] == '/') AND ($vdc[1] == 'Predictor') AND (isset($decpar[($kdc +1)]) AND ($decpar[($kdc +1)][0] == 'numeric'))) { - $predictor = intval($decpar[($kdc +1)][1]); - } - } - } elseif ($filltrailer) { - if (($v[0] == '/') AND ($v[1] == 'Size') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'numeric'))) { - $xref['trailer']['size'] = $sarr[($k +1)][1]; - } elseif (($v[0] == '/') AND ($v[1] == 'Root') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'objref'))) { - $xref['trailer']['root'] = $sarr[($k +1)][1]; - } elseif (($v[0] == '/') AND ($v[1] == 'Info') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'objref'))) { - $xref['trailer']['info'] = $sarr[($k +1)][1]; - } elseif (($v[0] == '/') AND ($v[1] == 'Encrypt') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'objref'))) { - $xref['trailer']['encrypt'] = $sarr[($k +1)][1]; - } elseif (($v[0] == '/') AND ($v[1] == 'ID') AND (isset($sarr[($k +1)]))) { - $xref['trailer']['id'] = array(); - $xref['trailer']['id'][0] = $sarr[($k +1)][1][0][1]; - $xref['trailer']['id'][1] = $sarr[($k +1)][1][1][1]; - } - } - } - // decode data - if ($valid_crs AND isset($xrefcrs[1][3][0])) { - // number of bytes in a row - $rowlen = ($columns + 1); - // convert the stream into an array of integers - $sdata = unpack('C*', $xrefcrs[1][3][0]); - // split the rows - $sdata = array_chunk($sdata, $rowlen); - // initialize decoded array - $ddata = array(); - // initialize first row with zeros - $prev_row = array_fill (0, $rowlen, 0); - // for each row apply PNG unpredictor - foreach ($sdata as $k => $row) { - // initialize new row - $ddata[$k] = array(); - // get PNG predictor value - $predictor = (10 + $row[0]); - // for each byte on the row - for ($i=1; $i<=$columns; ++$i) { - // new index - $j = ($i - 1); - $row_up = $prev_row[$j]; - if ($i == 1) { - $row_left = 0; - $row_upleft = 0; - } else { - $row_left = $row[($i - 1)]; - $row_upleft = $prev_row[($j - 1)]; - } - switch ($predictor) { - case 10: { // PNG prediction (on encoding, PNG None on all rows) - $ddata[$k][$j] = $row[$i]; - break; - } - case 11: { // PNG prediction (on encoding, PNG Sub on all rows) - $ddata[$k][$j] = (($row[$i] + $row_left) & 0xff); - break; - } - case 12: { // PNG prediction (on encoding, PNG Up on all rows) - $ddata[$k][$j] = (($row[$i] + $row_up) & 0xff); - break; - } - case 13: { // PNG prediction (on encoding, PNG Average on all rows) - $ddata[$k][$j] = (($row[$i] + (($row_left + $row_up) / 2)) & 0xff); - break; - } - case 14: { // PNG prediction (on encoding, PNG Paeth on all rows) - // initial estimate - $p = ($row_left + $row_up - $row_upleft); - // distances - $pa = abs($p - $row_left); - $pb = abs($p - $row_up); - $pc = abs($p - $row_upleft); - $pmin = min($pa, $pb, $pc); - // return minimum distance - switch ($pmin) { - case $pa: { - $ddata[$k][$j] = (($row[$i] + $row_left) & 0xff); - break; - } - case $pb: { - $ddata[$k][$j] = (($row[$i] + $row_up) & 0xff); - break; - } - case $pc: { - $ddata[$k][$j] = (($row[$i] + $row_upleft) & 0xff); - break; - } - } - break; - } - default: { // PNG prediction (on encoding, PNG optimum) - $this->Error('Unknown PNG predictor'); - break; - } - } - } - $prev_row = $ddata[$k]; - } // end for each row - // complete decoding - $sdata = array(); - // for every row - foreach ($ddata as $k => $row) { - // initialize new row - $sdata[$k] = array(0, 0, 0); - if ($wb[0] == 0) { - // default type field - $sdata[$k][0] = 1; - } - $i = 0; // count bytes in the row - // for every column - for ($c = 0; $c < 3; ++$c) { - // for every byte on the column - for ($b = 0; $b < $wb[$c]; ++$b) { - if (isset($row[$i])) { - $sdata[$k][$c] += ($row[$i] << (($wb[$c] - 1 - $b) * 8)); - } - ++$i; - } - } - } - $ddata = array(); - // fill xref - if (isset($index_first)) { - $obj_num = $index_first; - } else { - $obj_num = 0; - } - foreach ($sdata as $k => $row) { - switch ($row[0]) { - case 0: { // (f) linked list of free objects - break; - } - case 1: { // (n) objects that are in use but are not compressed - // create unique object index: [object number]_[generation number] - $index = $obj_num.'_'.$row[2]; - // check if object already exist - if (!isset($xref['xref'][$index])) { - // store object offset position - $xref['xref'][$index] = $row[1]; - } - break; - } - case 2: { // compressed objects - // $row[1] = object number of the object stream in which this object is stored - // $row[2] = index of this object within the object stream - $index = $row[1].'_0_'.$row[2]; - $xref['xref'][$index] = -1; - break; - } - default: { // null objects - break; - } - } - ++$obj_num; - } - } // end decoding data - if (isset($prevxref)) { - // get previous xref - $xref = $this->getXrefData($prevxref, $xref); - } - return $xref; - } - - /** - * Get object type, raw value and offset to next object - * @param int $offset Object offset. - * @return array containing object type, raw value and offset to next object - * @protected - * @since 1.0.000 (2011-06-20) - */ - protected function getRawObject($offset=0) { - $objtype = ''; // object type to be returned - $objval = ''; // object value to be returned - // skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP) - $offset += strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $offset); - // get first char - $char = $this->pdfdata[$offset]; - // get object type - switch ($char) { - case '%': { // \x25 PERCENT SIGN - // skip comment and search for next token - $next = strcspn($this->pdfdata, "\r\n", $offset); - if ($next > 0) { - $offset += $next; - return $this->getRawObject($offset); - } - break; - } - case '/': { // \x2F SOLIDUS - // name object - $objtype = $char; - ++$offset; - if (preg_match('/^([^\x00\x09\x0a\x0c\x0d\x20\s\x28\x29\x3c\x3e\x5b\x5d\x7b\x7d\x2f\x25]+)/', substr($this->pdfdata, $offset, 256), $matches) == 1) { - $objval = $matches[1]; // unescaped value - $offset += strlen($objval); - } - break; - } - case '(': // \x28 LEFT PARENTHESIS - case ')': { // \x29 RIGHT PARENTHESIS - // literal string object - $objtype = $char; - ++$offset; - $strpos = $offset; - if ($char == '(') { - $open_bracket = 1; - while ($open_bracket > 0) { - if (!isset($this->pdfdata[$strpos])) { - break; - } - $ch = $this->pdfdata[$strpos]; - switch ($ch) { - case '\\': { // REVERSE SOLIDUS (5Ch) (Backslash) - // skip next character - ++$strpos; - break; - } - case '(': { // LEFT PARENHESIS (28h) - ++$open_bracket; - break; - } - case ')': { // RIGHT PARENTHESIS (29h) - --$open_bracket; - break; - } - } - ++$strpos; - } - $objval = substr($this->pdfdata, $offset, ($strpos - $offset - 1)); - $offset = $strpos; - } - break; - } - case '[': // \x5B LEFT SQUARE BRACKET - case ']': { // \x5D RIGHT SQUARE BRACKET - // array object - $objtype = $char; - ++$offset; - if ($char == '[') { - // get array content - $objval = array(); - do { - // get element - $element = $this->getRawObject($offset); - $offset = $element[2]; - $objval[] = $element; - } while ($element[0] != ']'); - // remove closing delimiter - array_pop($objval); - } - break; - } - case '<': // \x3C LESS-THAN SIGN - case '>': { // \x3E GREATER-THAN SIGN - if (isset($this->pdfdata[($offset + 1)]) AND ($this->pdfdata[($offset + 1)] == $char)) { - // dictionary object - $objtype = $char.$char; - $offset += 2; - if ($char == '<') { - // get array content - $objval = array(); - do { - // get element - $element = $this->getRawObject($offset); - $offset = $element[2]; - $objval[] = $element; - } while ($element[0] != '>>'); - // remove closing delimiter - array_pop($objval); - } - } else { - // hexadecimal string object - $objtype = $char; - ++$offset; - if (($char == '<') AND (preg_match('/^([0-9A-Fa-f\x09\x0a\x0c\x0d\x20]+)>/iU', substr($this->pdfdata, $offset), $matches) == 1)) { - // remove white space characters - $objval = strtr($matches[1], "\x09\x0a\x0c\x0d\x20", ''); - $offset += strlen($matches[0]); - } elseif (($endpos = strpos($this->pdfdata, '>', $offset)) !== FALSE) { - $offset = $endpos + 1; - } - } - break; - } - default: { - if (substr($this->pdfdata, $offset, 6) == 'endobj') { - // indirect object - $objtype = 'endobj'; - $offset += 6; - } elseif (substr($this->pdfdata, $offset, 4) == 'null') { - // null object - $objtype = 'null'; - $offset += 4; - $objval = 'null'; - } elseif (substr($this->pdfdata, $offset, 4) == 'true') { - // boolean true object - $objtype = 'boolean'; - $offset += 4; - $objval = 'true'; - } elseif (substr($this->pdfdata, $offset, 5) == 'false') { - // boolean false object - $objtype = 'boolean'; - $offset += 5; - $objval = 'false'; - } elseif (substr($this->pdfdata, $offset, 6) == 'stream') { - // start stream object - $objtype = 'stream'; - $offset += 6; - if (preg_match('/^([\r]?[\n])/isU', substr($this->pdfdata, $offset), $matches) == 1) { - $offset += strlen($matches[0]); - if (preg_match('/(endstream)[\x09\x0a\x0c\x0d\x20]/isU', substr($this->pdfdata, $offset), $matches, PREG_OFFSET_CAPTURE) == 1) { - $objval = substr($this->pdfdata, $offset, $matches[0][1]); - $offset += $matches[1][1]; - } - } - } elseif (substr($this->pdfdata, $offset, 9) == 'endstream') { - // end stream object - $objtype = 'endstream'; - $offset += 9; - } elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+R/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) { - // indirect object reference - $objtype = 'objref'; - $offset += strlen($matches[0]); - $objval = intval($matches[1]).'_'.intval($matches[2]); - } elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+obj/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) { - // object start - $objtype = 'obj'; - $objval = intval($matches[1]).'_'.intval($matches[2]); - $offset += strlen ($matches[0]); - } elseif (($numlen = strspn($this->pdfdata, '+-.0123456789', $offset)) > 0) { - // numeric object - $objtype = 'numeric'; - $objval = substr($this->pdfdata, $offset, $numlen); - $offset += $numlen; - } - break; - } - } - return array($objtype, $objval, $offset); - } - - /** - * Get content of indirect object. - * @param string $obj_ref Object number and generation number separated by underscore character. - * @param int $offset Object offset. - * @param boolean $decoding If true decode streams. - * @return array containing object data. - * @protected - * @since 1.0.000 (2011-05-24) - */ - protected function getIndirectObject($obj_ref, $offset=0, $decoding=true) { - $obj = explode('_', $obj_ref); - if (($obj === false) OR (count($obj) != 2)) { - $this->Error('Invalid object reference: '.$obj); - return; - } - $objref = $obj[0].' '.$obj[1].' obj'; - // ignore leading zeros - $offset += strspn($this->pdfdata, '0', $offset); - if (strpos($this->pdfdata, $objref, $offset) != $offset) { - // an indirect reference to an undefined object shall be considered a reference to the null object - return array('null', 'null', $offset); - } - // starting position of object content - $offset += strlen($objref); - // get array of object content - $objdata = array(); - $i = 0; // object main index - do { - $oldoffset = $offset; - // get element - $element = $this->getRawObject($offset); - $offset = $element[2]; - // decode stream using stream's dictionary information - if ($decoding AND ($element[0] == 'stream') AND (isset($objdata[($i - 1)][0])) AND ($objdata[($i - 1)][0] == '<<')) { - $element[3] = $this->decodeStream($objdata[($i - 1)][1], $element[1]); - } - $objdata[$i] = $element; - ++$i; - } while (($element[0] != 'endobj') AND ($offset != $oldoffset)); - // remove closing delimiter - array_pop($objdata); - // return raw object content - return $objdata; - } - - /** - * Get the content of object, resolving indect object reference if necessary. - * @param string $obj Object value. - * @return array containing object data. - * @protected - * @since 1.0.000 (2011-06-26) - */ - protected function getObjectVal($obj) { - if ($obj[0] == 'objref') { - // reference to indirect object - if (isset($this->objects[$obj[1]])) { - // this object has been already parsed - return $this->objects[$obj[1]]; - } elseif (isset($this->xref[$obj[1]])) { - // parse new object - $this->objects[$obj[1]] = $this->getIndirectObject($obj[1], $this->xref[$obj[1]], false); - return $this->objects[$obj[1]]; - } - } - return $obj; - } - - /** - * Decode the specified stream. - * @param array $sdic Stream's dictionary array. - * @param string $stream Stream to decode. - * @return array containing decoded stream data and remaining filters. - * @protected - * @since 1.0.000 (2011-06-22) - */ - protected function decodeStream($sdic, $stream) { - // get stream length and filters - $slength = strlen($stream); - if ($slength <= 0) { - return array('', array()); - } - $filters = array(); - foreach ($sdic as $k => $v) { - if ($v[0] == '/') { - if (($v[1] == 'Length') AND (isset($sdic[($k + 1)])) AND ($sdic[($k + 1)][0] == 'numeric')) { - // get declared stream length - $declength = intval($sdic[($k + 1)][1]); - if ($declength < $slength) { - $stream = substr($stream, 0, $declength); - $slength = $declength; - } - } elseif (($v[1] == 'Filter') AND (isset($sdic[($k + 1)]))) { - // resolve indirect object - $objval = $this->getObjectVal($sdic[($k + 1)]); - if ($objval[0] == '/') { - // single filter - $filters[] = $objval[1]; - } elseif ($objval[0] == '[') { - // array of filters - foreach ($objval[1] as $flt) { - if ($flt[0] == '/') { - $filters[] = $flt[1]; - } - } - } - } - } - } - // decode the stream - $remaining_filters = array(); - foreach ($filters as $filter) { - if (in_array($filter, TCPDF_FILTERS::getAvailableFilters())) { - try { - $stream = TCPDF_FILTERS::decodeFilter($filter, $stream); - } catch (Exception $e) { - $emsg = $e->getMessage(); - if ((($emsg[0] == '~') AND !$this->cfg['ignore_missing_filter_decoders']) - OR (($emsg[0] != '~') AND !$this->cfg['ignore_filter_decoding_errors'])) { - $this->Error($e->getMessage()); - } - } - } else { - // add missing filter to array - $remaining_filters[] = $filter; - } - } - return array($stream, $remaining_filters); - } - - /** - * Throw an exception or print an error message and die if the K_TCPDF_PARSER_THROW_EXCEPTION_ERROR constant is set to true. - * @param string $msg The error message - * @public - * @since 1.0.000 (2011-05-23) - */ - public function Error($msg) { - if ($this->cfg['die_for_errors']) { - die('TCPDF_PARSER ERROR: '.$msg); - } else { - throw new Exception('TCPDF_PARSER ERROR: '.$msg); - } - } - -} // END OF TCPDF_PARSER CLASS - -//============================================================+ -// END OF FILE -//============================================================+ diff --git a/tools/tcpdf/tools/tcpdf_addfont.php b/tools/tcpdf/tools/tcpdf_addfont.php index 2937c75646..e1a2b32e56 100755 --- a/tools/tcpdf/tools/tcpdf_addfont.php +++ b/tools/tcpdf/tools/tcpdf_addfont.php @@ -7,9 +7,9 @@ // Last Update : 2013-08-05 // Authors : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // Remi Collet -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2011-2013 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2011-2026 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // diff --git a/webservice/dispatcher.php b/webservice/dispatcher.php index 89568c9c5d..4bda5b02ea 100644 --- a/webservice/dispatcher.php +++ b/webservice/dispatcher.php @@ -67,7 +67,7 @@ } fclose($putresource); } -if (isset($input_xml) && strncmp($input_xml, 'xml=', 4) == 0) { +if (isset($input_xml) && str_starts_with($input_xml, 'xml=')) { $input_xml = substr($input_xml, 4); }