From b0948269a689c5ab08c5b6e00066bf9c9e6a9838 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 13 Sep 2019 11:13:56 +0200
Subject: [PATCH 1/2] Fix Array and string offset access syntax with curly
braces is deprecated
---
include/tcpdf_filters.php | 6 +--
include/tcpdf_images.php | 2 +-
tcpdf.php | 4 +-
tcpdf_barcodes_1d.php | 108 +++++++++++++++++++-------------------
tcpdf_parser.php | 6 +--
5 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/include/tcpdf_filters.php b/include/tcpdf_filters.php
index dfb80c5d..3bb89c09 100644
--- a/include/tcpdf_filters.php
+++ b/include/tcpdf_filters.php
@@ -279,7 +279,7 @@ public static function decodeFilterLZWDecode($data) {
// convert string to binary string
$bitstring = '';
for ($i = 0; $i < $data_length; ++$i) {
- $bitstring .= sprintf('%08b', ord($data{$i}));
+ $bitstring .= sprintf('%08b', ord($data[$i]));
}
// get the number of bits
$data_length = strlen($bitstring);
@@ -376,7 +376,7 @@ public static function decodeFilterRunLengthDecode($data) {
$i = 0;
while($i < $data_length) {
// get current byte value
- $byte = ord($data{$i});
+ $byte = ord($data[$i]);
if ($byte == 128) {
// a length value of 128 denote EOD
break;
@@ -389,7 +389,7 @@ public static function decodeFilterRunLengthDecode($data) {
} else {
// if length is in the range 129 to 255,
// the following single byte shall be copied 257 - length (2 to 128) times during decompression
- $decoded .= str_repeat($data{($i + 1)}, (257 - $byte));
+ $decoded .= str_repeat($data[($i + 1)], (257 - $byte));
// move to next block
$i += 2;
}
diff --git a/include/tcpdf_images.php b/include/tcpdf_images.php
index 86b3c20d..5e504f21 100644
--- a/include/tcpdf_images.php
+++ b/include/tcpdf_images.php
@@ -311,7 +311,7 @@ public static function _parsepng($file) {
if ($n > 0) {
$trns = array();
for ($i = 0; $i < $n; ++ $i) {
- $trns[] = ord($t{$i});
+ $trns[] = ord($t[$i]);
}
}
}
diff --git a/tcpdf.php b/tcpdf.php
index a1b4c1c0..d18294a7 100644
--- a/tcpdf.php
+++ b/tcpdf.php
@@ -16897,10 +16897,10 @@ protected function getHtmlDomArray($html) {
if (($dom[$key]['value'] == 'pre') OR ($dom[$key]['value'] == 'tt')) {
$dom[$key]['fontname'] = $this->default_monospaced_font;
}
- if (!empty($dom[$key]['value']) AND ($dom[$key]['value'][0] == 'h') AND (intval($dom[$key]['value']{1}) > 0) AND (intval($dom[$key]['value']{1}) < 7)) {
+ if (!empty($dom[$key]['value']) AND ($dom[$key]['value'][0] == 'h') AND (intval($dom[$key]['value'][1]) > 0) AND (intval($dom[$key]['value'][1]) < 7)) {
// headings h1, h2, h3, h4, h5, h6
if (!isset($dom[$key]['attribute']['size']) AND !isset($dom[$key]['style']['font-size'])) {
- $headsize = (4 - intval($dom[$key]['value']{1})) * 2;
+ $headsize = (4 - intval($dom[$key]['value'][1])) * 2;
$dom[$key]['fontsize'] = $dom[0]['fontsize'] + $headsize;
}
if (!isset($dom[$key]['style']['font-weight'])) {
diff --git a/tcpdf_barcodes_1d.php b/tcpdf_barcodes_1d.php
index 0c389aeb..78bfc5b5 100644
--- a/tcpdf_barcodes_1d.php
+++ b/tcpdf_barcodes_1d.php
@@ -453,7 +453,7 @@ protected function barcode_code39($code, $extended=false, $checksum=false) {
$k = 0;
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
- $char = $code{$i};
+ $char = $code[$i];
if(!isset($chr[$char])) {
// invalid character
return false;
@@ -464,7 +464,7 @@ protected function barcode_code39($code, $extended=false, $checksum=false) {
} else {
$t = false; // space
}
- $w = $chr[$char]{$j};
+ $w = $chr[$char][$j];
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
@@ -520,10 +520,10 @@ protected function encode_code39_ext($code) {
$code_ext = '';
$clen = strlen($code);
for ($i = 0 ; $i < $clen; ++$i) {
- if (ord($code{$i}) > 127) {
+ if (ord($code[$i]) > 127) {
return false;
}
- $code_ext .= $encode[$code{$i}];
+ $code_ext .= $encode[$code[$i]];
}
return $code_ext;
}
@@ -543,7 +543,7 @@ protected function checksum_code39($code) {
$sum = 0;
$clen = strlen($code);
for ($i = 0 ; $i < $clen; ++$i) {
- $k = array_keys($chars, $code{$i});
+ $k = array_keys($chars, $code[$i]);
$sum += $k[0];
}
$j = ($sum % 43);
@@ -643,10 +643,10 @@ protected function barcode_code93($code) {
$code_ext = '';
$clen = strlen($code);
for ($i = 0 ; $i < $clen; ++$i) {
- if (ord($code{$i}) > 127) {
+ if (ord($code[$i]) > 127) {
return false;
}
- $code_ext .= $encode[$code{$i}];
+ $code_ext .= $encode[$code[$i]];
}
// checksum
$code_ext .= $this->checksum_code93($code_ext);
@@ -656,7 +656,7 @@ protected function barcode_code93($code) {
$k = 0;
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
- $char = ord($code{$i});
+ $char = ord($code[$i]);
if(!isset($chr[$char])) {
// invalid character
return false;
@@ -667,7 +667,7 @@ protected function barcode_code93($code) {
} else {
$t = false; // space
}
- $w = $chr[$char]{$j};
+ $w = $chr[$char][$j];
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
@@ -699,7 +699,7 @@ protected function checksum_code93($code) {
$p = 1;
$check = 0;
for ($i = ($len - 1); $i >= 0; --$i) {
- $k = array_keys($chars, $code{$i});
+ $k = array_keys($chars, $code[$i]);
$check += ($k[0] * $p);
++$p;
if ($p > 20) {
@@ -713,7 +713,7 @@ protected function checksum_code93($code) {
$p = 1;
$check = 0;
for ($i = $len; $i >= 0; --$i) {
- $k = array_keys($chars, $code{$i});
+ $k = array_keys($chars, $code[$i]);
$check += ($k[0] * $p);
++$p;
if ($p > 15) {
@@ -738,11 +738,11 @@ protected function checksum_s25($code) {
$len = strlen($code);
$sum = 0;
for ($i = 0; $i < $len; $i+=2) {
- $sum += $code{$i};
+ $sum += $code[$i];
}
$sum *= 3;
for ($i = 1; $i < $len; $i+=2) {
- $sum += ($code{$i});
+ $sum += ($code[$i]);
}
$r = $sum % 10;
if($r > 0) {
@@ -783,7 +783,7 @@ protected function barcode_msi($code, $checksum=false) {
$p = 2;
$check = 0;
for ($i = ($clen - 1); $i >= 0; --$i) {
- $check += (hexdec($code{$i}) * $p);
+ $check += (hexdec($code[$i]) * $p);
++$p;
if ($p > 7) {
$p = 2;
@@ -798,7 +798,7 @@ protected function barcode_msi($code, $checksum=false) {
$seq = '110'; // left guard
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
- $digit = $code{$i};
+ $digit = $code[$i];
if (!isset($chr[$digit])) {
// invalid character
return false;
@@ -841,7 +841,7 @@ protected function barcode_s25($code, $checksum=false) {
$seq = '11011010';
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
- $digit = $code{$i};
+ $digit = $code[$i];
if (!isset($chr[$digit])) {
// invalid character
return false;
@@ -867,8 +867,8 @@ protected function binseq_to_array($seq, $bararray) {
$k = 0;
for ($i = 0; $i < $len; ++$i) {
$w += 1;
- if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
- if ($seq{$i} == '1') {
+ if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq[$i] != $seq[($i+1)]))) {
+ if ($seq[$i] == '1') {
$t = true; // bar
} else {
$t = false; // space
@@ -919,8 +919,8 @@ protected function barcode_i25($code, $checksum=false) {
$k = 0;
$clen = strlen($code);
for ($i = 0; $i < $clen; $i = ($i + 2)) {
- $char_bar = $code{$i};
- $char_space = $code{$i+1};
+ $char_bar = $code[$i];
+ $char_space = $code[$i+1];
if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) {
// invalid character
return false;
@@ -929,7 +929,7 @@ protected function barcode_i25($code, $checksum=false) {
$seq = '';
$chrlen = strlen($chr[$char_bar]);
for ($s = 0; $s < $chrlen; $s++){
- $seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s};
+ $seq .= $chr[$char_bar][$s] . $chr[$char_space][$s];
}
$seqlen = strlen($seq);
for ($j = 0; $j < $seqlen; ++$j) {
@@ -938,7 +938,7 @@ protected function barcode_i25($code, $checksum=false) {
} else {
$t = false; // space
}
- $w = $seq{$j};
+ $w = $seq[$j];
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
@@ -1085,7 +1085,7 @@ protected function barcode_c128($code, $type='') {
case 'A': { // MODE A
$startid = 103;
for ($i = 0; $i < $len; ++$i) {
- $char = $code{$i};
+ $char = $code[$i];
$char_id = ord($char);
if (($char_id >= 241) AND ($char_id <= 244)) {
$code_data[] = $fnc_a[$char_id];
@@ -1100,7 +1100,7 @@ protected function barcode_c128($code, $type='') {
case 'B': { // MODE B
$startid = 104;
for ($i = 0; $i < $len; ++$i) {
- $char = $code{$i};
+ $char = $code[$i];
$char_id = ord($char);
if (($char_id >= 241) AND ($char_id <= 244)) {
$code_data[] = $fnc_b[$char_id];
@@ -1124,7 +1124,7 @@ protected function barcode_c128($code, $type='') {
return false;
}
for ($i = 0; $i < $len; $i+=2) {
- $chrnum = $code{$i}.$code{$i+1};
+ $chrnum = $code[$i].$code[$i+1];
if (preg_match('/([0-9]{2})/', $chrnum) > 0) {
$code_data[] = intval($chrnum);
} else {
@@ -1180,7 +1180,7 @@ protected function barcode_c128($code, $type='') {
}
}
for ($i = 0; $i < $seq[2]; ++$i) {
- $char = $seq[1]{$i};
+ $char = $seq[1][$i];
$char_id = ord($char);
if (($char_id >= 241) AND ($char_id <= 244)) {
$code_data[] = $fnc_a[$char_id];
@@ -1223,7 +1223,7 @@ protected function barcode_c128($code, $type='') {
}
}
for ($i = 0; $i < $seq[2]; ++$i) {
- $char = $seq[1]{$i};
+ $char = $seq[1][$i];
$char_id = ord($char);
if (($char_id >= 241) AND ($char_id <= 244)) {
$code_data[] = $fnc_b[$char_id];
@@ -1240,7 +1240,7 @@ protected function barcode_c128($code, $type='') {
$code_data[] = 99;
}
for ($i = 0; $i < $seq[2]; $i+=2) {
- $chrnum = $seq[1]{$i}.$seq[1]{$i+1};
+ $chrnum = $seq[1][$i].$seq[1][$i+1];
$code_data[] = intval($chrnum);
}
break;
@@ -1271,7 +1271,7 @@ protected function barcode_c128($code, $type='') {
} else {
$t = false; // space
}
- $w = $seq{$j};
+ $w = $seq[$j];
$bararray['bcode'][] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
}
@@ -1337,14 +1337,14 @@ protected function barcode_eanupc($code, $len=13) {
// calculate check digit
$sum_a = 0;
for ($i = 1; $i < $data_len; $i+=2) {
- $sum_a += $code{$i};
+ $sum_a += $code[$i];
}
if ($len > 12) {
$sum_a *= 3;
}
$sum_b = 0;
for ($i = 0; $i < $data_len; $i+=2) {
- $sum_b += ($code{$i});
+ $sum_b += ($code[$i]);
}
if ($len < 13) {
$sum_b *= 3;
@@ -1356,7 +1356,7 @@ protected function barcode_eanupc($code, $len=13) {
if ($code_len == $data_len) {
// add check digit
$code .= $r;
- } elseif ($r !== intval($code{$data_len})) {
+ } elseif ($r !== intval($code[$data_len])) {
// wrong checkdigit
return false;
}
@@ -1467,7 +1467,7 @@ protected function barcode_eanupc($code, $len=13) {
$bararray = array('code' => $upce_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$p = $upce_parities[$code[1]][$r];
for ($i = 0; $i < 6; ++$i) {
- $seq .= $codes[$p[$i]][$upce_code{$i}];
+ $seq .= $codes[$p[$i]][$upce_code[$i]];
}
$seq .= '010101'; // right guard bar
} else {
@@ -1475,17 +1475,17 @@ protected function barcode_eanupc($code, $len=13) {
$half_len = intval(ceil($len / 2));
if ($len == 8) {
for ($i = 0; $i < $half_len; ++$i) {
- $seq .= $codes['A'][$code{$i}];
+ $seq .= $codes['A'][$code[$i]];
}
} else {
$p = $parities[$code[0]];
for ($i = 1; $i < $half_len; ++$i) {
- $seq .= $codes[$p[$i-1]][$code{$i}];
+ $seq .= $codes[$p[$i-1]][$code[$i]];
}
}
$seq .= '01010'; // center guard bar
for ($i = $half_len; $i < $len; ++$i) {
- $seq .= $codes['C'][$code{$i}];
+ $seq .= $codes['C'][$code[$i]];
}
$seq .= '101'; // right guard bar
}
@@ -1493,8 +1493,8 @@ protected function barcode_eanupc($code, $len=13) {
$w = 0;
for ($i = 0; $i < $clen; ++$i) {
$w += 1;
- if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
- if ($seq{$i} == '1') {
+ if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq[$i] != $seq[$i+1]))) {
+ if ($seq[$i] == '1') {
$t = true; // bar
} else {
$t = false; // space
@@ -1578,7 +1578,7 @@ protected function barcode_eanext($code, $len=5) {
$seq .= $codes[$p[0]][$code[0]];
for ($i = 1; $i < $len; ++$i) {
$seq .= '01'; // separator
- $seq .= $codes[$p[$i]][$code{$i}];
+ $seq .= $codes[$p[$i]][$code[$i]];
}
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
return $this->binseq_to_array($seq, $bararray);
@@ -1629,7 +1629,7 @@ protected function barcode_postnet($code, $planet=false) {
// calculate checksum
$sum = 0;
for ($i = 0; $i < $len; ++$i) {
- $sum += intval($code{$i});
+ $sum += intval($code[$i]);
}
$chkd = ($sum % 10);
if($chkd > 0) {
@@ -1643,7 +1643,7 @@ protected function barcode_postnet($code, $planet=false) {
$bararray['maxw'] += 2;
for ($i = 0; $i < $len; ++$i) {
for ($j = 0; $j < 5; ++$j) {
- $h = $barlen[$code{$i}][$j];
+ $h = $barlen[$code[$i]][$j];
$p = floor(1 / $h);
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
@@ -1756,8 +1756,8 @@ protected function barcode_rms4cc($code, $kix=false) {
$row = 0;
$col = 0;
for ($i = 0; $i < $len; ++$i) {
- $row += $checktable[$code{$i}][0];
- $col += $checktable[$code{$i}][1];
+ $row += $checktable[$code[$i]][0];
+ $col += $checktable[$code[$i]][1];
}
$row %= 6;
$col %= 6;
@@ -1774,7 +1774,7 @@ protected function barcode_rms4cc($code, $kix=false) {
}
for ($i = 0; $i < $len; ++$i) {
for ($j = 0; $j < 4; ++$j) {
- switch ($barmode[$code{$i}][$j]) {
+ switch ($barmode[$code[$i]][$j]) {
case 1: {
$p = 0;
$h = 2;
@@ -1846,17 +1846,17 @@ protected function barcode_codabar($code) {
$code = 'A'.strtoupper($code).'A';
$len = strlen($code);
for ($i = 0; $i < $len; ++$i) {
- if (!isset($chr[$code{$i}])) {
+ if (!isset($chr[$code[$i]])) {
return false;
}
- $seq = $chr[$code{$i}];
+ $seq = $chr[$code[$i]];
for ($j = 0; $j < 8; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
- $w = $seq{$j};
+ $w = $seq[$j];
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
@@ -1896,7 +1896,7 @@ protected function barcode_code11($code) {
$p = 1;
$check = 0;
for ($i = ($len - 1); $i >= 0; --$i) {
- $digit = $code{$i};
+ $digit = $code[$i];
if ($digit == '-') {
$dval = 10;
} else {
@@ -1918,7 +1918,7 @@ protected function barcode_code11($code) {
$p = 1;
$check = 0;
for ($i = $len; $i >= 0; --$i) {
- $digit = $code{$i};
+ $digit = $code[$i];
if ($digit == '-') {
$dval = 10;
} else {
@@ -1937,17 +1937,17 @@ protected function barcode_code11($code) {
$code = 'S'.$code.'S';
$len += 3;
for ($i = 0; $i < $len; ++$i) {
- if (!isset($chr[$code{$i}])) {
+ if (!isset($chr[$code[$i]])) {
return false;
}
- $seq = $chr[$code{$i}];
+ $seq = $chr[$code[$i]];
for ($j = 0; $j < 6; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
- $w = $seq{$j};
+ $w = $seq[$j];
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
@@ -2016,7 +2016,7 @@ protected function barcode_pharmacode2t($code) {
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
$len = strlen($seq);
for ($i = 0; $i < $len; ++$i) {
- switch ($seq{$i}) {
+ switch ($seq[$i]) {
case '1': {
$p = 1;
$h = 1;
@@ -2255,7 +2255,7 @@ public function hex_to_dec($hex) {
$bitval = 1;
$len = strlen($hex);
for($pos = ($len - 1); $pos >= 0; --$pos) {
- $dec = bcadd($dec, bcmul(hexdec($hex{$pos}), $bitval));
+ $dec = bcadd($dec, bcmul(hexdec($hex[$pos]), $bitval));
$bitval = bcmul($bitval, 16);
}
return $dec;
diff --git a/tcpdf_parser.php b/tcpdf_parser.php
index 780ec212..bd3d719c 100644
--- a/tcpdf_parser.php
+++ b/tcpdf_parser.php
@@ -531,10 +531,10 @@ protected function getRawObject($offset=0) {
if ($char == '(') {
$open_bracket = 1;
while ($open_bracket > 0) {
- if (!isset($this->pdfdata{$strpos})) {
+ if (!isset($this->pdfdata[$strpos])) {
break;
}
- $ch = $this->pdfdata{$strpos};
+ $ch = $this->pdfdata[$strpos];
switch ($ch) {
case '\\': { // REVERSE SOLIDUS (5Ch) (Backslash)
// skip next character
@@ -578,7 +578,7 @@ protected function getRawObject($offset=0) {
}
case '<': // \x3C LESS-THAN SIGN
case '>': { // \x3E GREATER-THAN SIGN
- if (isset($this->pdfdata{($offset + 1)}) AND ($this->pdfdata{($offset + 1)} == $char)) {
+ if (isset($this->pdfdata[($offset + 1)]) AND ($this->pdfdata[($offset + 1)] == $char)) {
// dictionary object
$objtype = $char.$char;
$offset += 2;
From e2deae00e5ac436560667d6afe1fe2bac3ec8859 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 13 Sep 2019 11:23:30 +0200
Subject: [PATCH 2/2] fix PHP Warning: chr() expects parameter 1 to be int
---
include/tcpdf_fonts.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php
index 9242ca4b..218fb6df 100644
--- a/include/tcpdf_fonts.php
+++ b/include/tcpdf_fonts.php
@@ -1664,6 +1664,7 @@ public static function getFontRefSize($size, $refsize=12) {
* @public static
*/
public static function unichr($c, $unicode=true) {
+ $c = intval($c);
if (!$unicode) {
return chr($c);
} elseif ($c <= 0x7F) {