@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | <script type="text/javascript"> |
8 | 8 | |
9 | -<?php for ($i = 1; $i <= 100; $i++) { |
|
9 | +<?php for ($i = 1; $i<=100; $i++) { |
|
10 | 10 | ?> |
11 | 11 | |
12 | 12 | function Getstatus<?php echo $i; ?>(str) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | -<?php for ($i = 1; $i <= 100; $i++) { |
|
29 | +<?php for ($i = 1; $i<=100; $i++) { |
|
30 | 30 | ?> |
31 | 31 | |
32 | 32 | <script> |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | default: |
92 | 92 | |
93 | - if ($_SESSION['outlet'] == '0') { |
|
93 | + if ($_SESSION['outlet']=='0') { |
|
94 | 94 | $d_outlet = '%'; |
95 | 95 | } else { |
96 | 96 | $d_outlet = $_SESSION['outlet']; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if ($_GET['ioutlet']) { |
100 | 100 | $outlet = $_GET['ioutlet']; |
101 | 101 | } else { |
102 | - if ($_SESSION['outlet'] == '0') { |
|
102 | + if ($_SESSION['outlet']=='0') { |
|
103 | 103 | $outlet = '1'; |
104 | 104 | } else { |
105 | 105 | $outlet = $_SESSION['outlet']; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | $query = mysql_query('SELECT * FROM periode '); |
110 | 110 | |
111 | - if ($query && mysql_num_rows($query) == 1) { |
|
111 | + if ($query && mysql_num_rows($query)==1) { |
|
112 | 112 | $data = mysql_fetch_object($query); |
113 | 113 | } |
114 | 114 | |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | |
183 | 183 | $query = mysql_query("SELECT * FROM outlet where id_outlet like '$d_outlet' ORDER BY id_outlet"); |
184 | 184 | |
185 | - if ($query && mysql_num_rows($query) > 0) { |
|
185 | + if ($query && mysql_num_rows($query)>0) { |
|
186 | 186 | while ($row = mysql_fetch_object($query)) { |
187 | 187 | echo '<option value="'.$row->id_outlet.'"'; |
188 | 188 | |
189 | - if ($row->id_outlet == $outlet) { |
|
189 | + if ($row->id_outlet==$outlet) { |
|
190 | 190 | echo ' selected'; |
191 | 191 | } |
192 | 192 | |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | |
211 | 211 | $query = mysql_query('SELECT * FROM status ORDER BY id_status'); |
212 | 212 | |
213 | - if ($query && mysql_num_rows($query) > 0) { |
|
213 | + if ($query && mysql_num_rows($query)>0) { |
|
214 | 214 | while ($row = mysql_fetch_object($query)) { |
215 | 215 | echo '<option value="'.$row->id_status.'"'; |
216 | 216 | |
217 | - if ($row->id_status == $status) { |
|
217 | + if ($row->id_status==$status) { |
|
218 | 218 | echo ' selected'; |
219 | 219 | } |
220 | 220 | |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | |
288 | 288 | $pj = mysql_num_rows($pjSQL); |
289 | 289 | |
290 | - if ($iprd == $prd) { |
|
290 | + if ($iprd==$prd) { |
|
291 | 291 | $disabled = ''; |
292 | 292 | } else { |
293 | 293 | $disabled = 'disabled'; |
294 | 294 | } |
295 | 295 | |
296 | - if ($pj == 0) { |
|
296 | + if ($pj==0) { |
|
297 | 297 | $disabled1 = 'disabled'; |
298 | 298 | } else { |
299 | 299 | $disabled1 = ''; |
@@ -443,11 +443,11 @@ discard block |
||
443 | 443 | |
444 | 444 | $query = mysql_query('SELECT * FROM status ORDER BY id_status'); |
445 | 445 | |
446 | - if ($query && mysql_num_rows($query) > 0) { |
|
446 | + if ($query && mysql_num_rows($query)>0) { |
|
447 | 447 | while ($row = mysql_fetch_object($query)) { |
448 | 448 | echo '<option value="'.$row->id_status.'"'; |
449 | 449 | |
450 | - if ($row->id_status == $r[status_diskon]) { |
|
450 | + if ($row->id_status==$r[status_diskon]) { |
|
451 | 451 | echo ' selected'; |
452 | 452 | } |
453 | 453 |
@@ -330,13 +330,13 @@ discard block |
||
330 | 330 | while ($r = mysql_fetch_array($tampil)) { |
331 | 331 | $tgl = date('d/m/Y', strtotime($r['tanggal'])); |
332 | 332 | |
333 | - if ($r['status'] == '0') { |
|
333 | + if ($r['status']=='0') { |
|
334 | 334 | $istatus = 'Baru'; |
335 | - } elseif ($r['status'] == '1') { |
|
335 | + } elseif ($r['status']=='1') { |
|
336 | 336 | $istatus = 'Disetujui'; |
337 | - } elseif ($r['status'] == '2') { |
|
337 | + } elseif ($r['status']=='2') { |
|
338 | 338 | $istatus = 'Ditolak'; |
339 | - } elseif ($r['status'] == '9') { |
|
339 | + } elseif ($r['status']=='9') { |
|
340 | 340 | $istatus = 'Posting'; |
341 | 341 | } else { |
342 | 342 | $istatus = 'Dibatalkan'; |
@@ -358,11 +358,11 @@ discard block |
||
358 | 358 | |
359 | 359 | echo"<td style='text-align:center;'>"; |
360 | 360 | |
361 | - if ($r_edit == 'Y') { |
|
361 | + if ($r_edit=='Y') { |
|
362 | 362 | echo"<a href='?module=$module&id_module=$id&act=save&ID=$ID' title='Update'><span class='icon'><i class='fa fa-pencil'></i></span></a>"; |
363 | 363 | } |
364 | 364 | |
365 | - if ($r_delete == 'Y' and $r['status'] == '0') { |
|
365 | + if ($r_delete=='Y' and $r['status']=='0') { |
|
366 | 366 | echo"<a href='modul/mod_$module/aksi_$module.php?module=$module&act=hapus&id=$ID&id_module=$id&id_module=$id' onClick=\"return confirm('Hapus Data ?')\" title='Hapus $nmmodule'><span class='icon'><i class='fa fa-trash'></i></span></a>"; |
367 | 367 | } else { |
368 | 368 | echo"<i class='fa fa-trash'></i></span>"; |
@@ -503,13 +503,13 @@ discard block |
||
503 | 503 | |
504 | 504 | <button type="button" onClick="location.href='<?php echo"?module=$module&id_module=$id_module&act=ubah&prd=$prd¬rans=$notrans&kode=$kode&outlet=$outlet"; ?>'" |
505 | 505 | |
506 | - class="btn btn-success" <?php if ($status != '0') { |
|
506 | + class="btn btn-success" <?php if ($status!='0') { |
|
507 | 507 | echo 'disabled'; |
508 | 508 | } ?>>Ubah</button> |
509 | 509 | |
510 | 510 | |
511 | 511 | |
512 | - <?php if ($status == '0') { |
|
512 | + <?php if ($status=='0') { |
|
513 | 513 | ?> |
514 | 514 | |
515 | 515 | <?php |
@@ -591,11 +591,11 @@ discard block |
||
591 | 591 | |
592 | 592 | $query = mysql_query('SELECT * FROM shift WHERE aktif = "Y" ORDER BY id_shift'); |
593 | 593 | |
594 | - if ($query && mysql_num_rows($query) > 0) { |
|
594 | + if ($query && mysql_num_rows($query)>0) { |
|
595 | 595 | while ($row = mysql_fetch_object($query)) { |
596 | 596 | echo '<option value="'.$row->id_shift.'"'; |
597 | 597 | |
598 | - if ($row->id_shift == $shift) { |
|
598 | + if ($row->id_shift==$shift) { |
|
599 | 599 | echo ' selected'; |
600 | 600 | } |
601 | 601 | |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | |
749 | 749 | <button type="button" onClick="location.href='<?php echo"?module=$module&id_module=$id_module&act=ubah&k_ID=$k_ID"; ?>'" |
750 | 750 | |
751 | - class="btn btn-success" <?php if ($status != '0') { |
|
751 | + class="btn btn-success" <?php if ($status!='0') { |
|
752 | 752 | echo 'disabled'; |
753 | 753 | } ?>>Ubah</button> |
754 | 754 | |
@@ -815,11 +815,11 @@ discard block |
||
815 | 815 | |
816 | 816 | $query = mysql_query('SELECT * FROM shift WHERE aktif = "Y" ORDER BY shift'); |
817 | 817 | |
818 | - if ($query && mysql_num_rows($query) > 0) { |
|
818 | + if ($query && mysql_num_rows($query)>0) { |
|
819 | 819 | while ($row = mysql_fetch_object($query)) { |
820 | 820 | echo '<option value="'.$row->id_shift.'"'; |
821 | 821 | |
822 | - if ($row->id_shift == $shift) { |
|
822 | + if ($row->id_shift==$shift) { |
|
823 | 823 | echo ' selected'; |
824 | 824 | } |
825 | 825 | |
@@ -925,11 +925,11 @@ discard block |
||
925 | 925 | |
926 | 926 | $query = mysql_query('SELECT * FROM jenis_transaksi WHERE aktif = "Y" ORDER BY id_jenis_transaksi'); |
927 | 927 | |
928 | - if ($query && mysql_num_rows($query) > 0) { |
|
928 | + if ($query && mysql_num_rows($query)>0) { |
|
929 | 929 | while ($row = mysql_fetch_object($query)) { |
930 | 930 | echo '<option value="'.$row->id_jenis_transaksi.'"'; |
931 | 931 | |
932 | - if ($row->id_jenis_transaksi == @$data->id_jenis_transaksi) { |
|
932 | + if ($row->id_jenis_transaksi==@$data->id_jenis_transaksi) { |
|
933 | 933 | echo ' selected'; |
934 | 934 | } |
935 | 935 | |
@@ -970,11 +970,11 @@ discard block |
||
970 | 970 | |
971 | 971 | $query = mysql_query('SELECT * FROM jenis_pembayaran WHERE aktif = "Y" ORDER BY id_jenis_pembayaran'); |
972 | 972 | |
973 | - if ($query && mysql_num_rows($query) > 0) { |
|
973 | + if ($query && mysql_num_rows($query)>0) { |
|
974 | 974 | while ($row = mysql_fetch_object($query)) { |
975 | 975 | echo '<option value="'.$row->id_jenis_pembayaran.'"'; |
976 | 976 | |
977 | - if ($row->id_jenis_pembayaran == @$data->id_jenis_pembayaran) { |
|
977 | + if ($row->id_jenis_pembayaran==@$data->id_jenis_pembayaran) { |
|
978 | 978 | echo ' selected'; |
979 | 979 | } |
980 | 980 | |
@@ -997,11 +997,11 @@ discard block |
||
997 | 997 | |
998 | 998 | $query = mysql_query('SELECT * FROM penjamin WHERE aktif = "Y" ORDER BY id_penjamin'); |
999 | 999 | |
1000 | - if ($query && mysql_num_rows($query) > 0) { |
|
1000 | + if ($query && mysql_num_rows($query)>0) { |
|
1001 | 1001 | while ($row = mysql_fetch_object($query)) { |
1002 | 1002 | echo '<option value="'.$row->id_penjamin.'"'; |
1003 | 1003 | |
1004 | - if ($row->id_penjamin == @$data->id_penjamin) { |
|
1004 | + if ($row->id_penjamin==@$data->id_penjamin) { |
|
1005 | 1005 | echo ' selected'; |
1006 | 1006 | } |
1007 | 1007 | |
@@ -1133,11 +1133,11 @@ discard block |
||
1133 | 1133 | |
1134 | 1134 | echo" <td style='text-align:center;'>"; |
1135 | 1135 | |
1136 | - if ($r_edit == 'Y') { |
|
1136 | + if ($r_edit=='Y') { |
|
1137 | 1137 | echo"<a href='?module=$module&id_module=$_GET[id_module]&act=edit&k_ID=$k_ID&d_id=$d_id' title='Update'><span class='btn btn-success btn-xs'><i class='fa fa-pencil'></i></span></a>"; |
1138 | 1138 | } |
1139 | 1139 | |
1140 | - if ($r_delete == 'Y') { |
|
1140 | + if ($r_delete=='Y') { |
|
1141 | 1141 | echo"<a href='modul/mod_$module/aksi_$module.php?module=$module&id_module=$_GET[id_module]&act=dhapus&id=$d_id&k_ID=$k_ID' onClick=\"return confirm('Hapus Data ?')\" title='Hapus $nmmodule'><span class='btn btn-danger btn-xs'><i class='fa fa-trash'></i></span></a>"; |
1142 | 1142 | } |
1143 | 1143 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | |
1218 | 1218 | $jml = mysql_num_rows($dsql); |
1219 | 1219 | |
1220 | - if ($jml > 0) { |
|
1220 | + if ($jml>0) { |
|
1221 | 1221 | |
1222 | 1222 | // $readonly = 'readonly'; |
1223 | 1223 | |
@@ -1341,11 +1341,11 @@ discard block |
||
1341 | 1341 | |
1342 | 1342 | $query = mysql_query('SELECT * FROM shift WHERE aktif = "Y" ORDER BY shift'); |
1343 | 1343 | |
1344 | - if ($query && mysql_num_rows($query) > 0) { |
|
1344 | + if ($query && mysql_num_rows($query)>0) { |
|
1345 | 1345 | while ($row = mysql_fetch_object($query)) { |
1346 | 1346 | echo '<option value="'.$row->id_shift.'"'; |
1347 | 1347 | |
1348 | - if ($row->id_shift == $shift) { |
|
1348 | + if ($row->id_shift==$shift) { |
|
1349 | 1349 | echo ' selected'; |
1350 | 1350 | } |
1351 | 1351 | |
@@ -1635,11 +1635,11 @@ discard block |
||
1635 | 1635 | |
1636 | 1636 | $query = mysql_query('SELECT * FROM shift WHERE aktif = "Y" ORDER BY shift'); |
1637 | 1637 | |
1638 | - if ($query && mysql_num_rows($query) > 0) { |
|
1638 | + if ($query && mysql_num_rows($query)>0) { |
|
1639 | 1639 | while ($row = mysql_fetch_object($query)) { |
1640 | 1640 | echo '<option value="'.$row->id_shift.'"'; |
1641 | 1641 | |
1642 | - if ($row->id_shift == $shift) { |
|
1642 | + if ($row->id_shift==$shift) { |
|
1643 | 1643 | echo ' selected'; |
1644 | 1644 | } |
1645 | 1645 | |
@@ -1748,7 +1748,7 @@ discard block |
||
1748 | 1748 | |
1749 | 1749 | $jumlah = number_format($d['jumlah'], 0, '.', ''); |
1750 | 1750 | |
1751 | - if ($jid == $d_id) { |
|
1751 | + if ($jid==$d_id) { |
|
1752 | 1752 | echo '<form action="modul/mod_'.$module.'/aksi_'.$module.'.php?module='.$module.'&act=add method="post" name="formData" enctype="multipart/form-data">'; |
1753 | 1753 | |
1754 | 1754 | echo '<input type="hidden" name="module" value="'.$module.'" />'; |
@@ -1781,9 +1781,9 @@ discard block |
||
1781 | 1781 | |
1782 | 1782 | $query = mysql_query('SELECT * FROM jenis_transaksi WHERE aktif = "Y" ORDER BY id_jenis_transaksi'); |
1783 | 1783 | |
1784 | - if ($query && mysql_num_rows($query) > 0) { |
|
1784 | + if ($query && mysql_num_rows($query)>0) { |
|
1785 | 1785 | while ($row = mysql_fetch_object($query)) { |
1786 | - $selected = ($row->id_jenis_transaksi == @$d['id_jenis_transaksi']) ? 'selected' : ''; |
|
1786 | + $selected = ($row->id_jenis_transaksi==@$d['id_jenis_transaksi']) ? 'selected' : ''; |
|
1787 | 1787 | printf('<option value="%s" %s>%s</option>', $row->id_jenis_transaksi, $selected, $row->jenis_transaksi); |
1788 | 1788 | } |
1789 | 1789 | } |
@@ -1806,9 +1806,9 @@ discard block |
||
1806 | 1806 | |
1807 | 1807 | $query = mysql_query('SELECT * FROM jenis_pembayaran WHERE aktif = "Y" ORDER BY id_jenis_pembayaran'); |
1808 | 1808 | |
1809 | - if ($query && mysql_num_rows($query) > 0) { |
|
1809 | + if ($query && mysql_num_rows($query)>0) { |
|
1810 | 1810 | while ($row = mysql_fetch_object($query)) { |
1811 | - $selected = ($row->id_jenis_pembayaran == @$d['id_jenis_pembayaran']) ? 'selected' : ''; |
|
1811 | + $selected = ($row->id_jenis_pembayaran==@$d['id_jenis_pembayaran']) ? 'selected' : ''; |
|
1812 | 1812 | printf('<option value="%s" %s>%s</option>', $row->id_jenis_pembayaran, $selected, $row->jenis_pembayaran); |
1813 | 1813 | } |
1814 | 1814 | } |
@@ -1824,9 +1824,9 @@ discard block |
||
1824 | 1824 | |
1825 | 1825 | $query = mysql_query('SELECT * FROM penjamin WHERE aktif = "Y" ORDER BY id_penjamin'); |
1826 | 1826 | |
1827 | - if ($query && mysql_num_rows($query) > 0) { |
|
1827 | + if ($query && mysql_num_rows($query)>0) { |
|
1828 | 1828 | while ($row = mysql_fetch_object($query)) { |
1829 | - $selected = ($row->id_penjamin == @$d['id_penjamin']) ? 'selected' : ''; |
|
1829 | + $selected = ($row->id_penjamin==@$d['id_penjamin']) ? 'selected' : ''; |
|
1830 | 1830 | printf('<option value="%s" %s>%s</option>', $row->id_penjamin, $selected, $row->penjamin); |
1831 | 1831 | } |
1832 | 1832 | } |
@@ -1901,11 +1901,11 @@ discard block |
||
1901 | 1901 | |
1902 | 1902 | echo" <td style='text-align:center;'>"; |
1903 | 1903 | |
1904 | - if ($r_edit == 'Y') { |
|
1904 | + if ($r_edit=='Y') { |
|
1905 | 1905 | echo"<span class='btn btn-success btn-sm' disabled><i class='fa fa-pencil'></i></span>"; |
1906 | 1906 | } |
1907 | 1907 | |
1908 | - if ($r_delete == 'Y') { |
|
1908 | + if ($r_delete=='Y') { |
|
1909 | 1909 | echo"<span class='btn btn-danger btn-sm' disabled><i class='fa fa-trash'></i></span>"; |
1910 | 1910 | } |
1911 | 1911 |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | global $char128asc, $char128wid; |
39 | 39 | $w = $char128wid[$sum = 104]; // START symbol |
40 | 40 | $onChar = 1; |
41 | - for ($x = 0; $x < strlen($text); $x++) { // GO THRU TEXT GET LETTERS |
|
42 | - if (!(($pos = strpos($char128asc, $text[$x])) === false)) { // SKIP NOT FOUND CHARS |
|
41 | + for ($x = 0; $x<strlen($text); $x++) { // GO THRU TEXT GET LETTERS |
|
42 | + if (!(($pos = strpos($char128asc, $text[$x]))===false)) { // SKIP NOT FOUND CHARS |
|
43 | 43 | $w .= $char128wid[$pos]; |
44 | 44 | $sum += $onChar++ * $pos; |
45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $w .= $char128wid[$sum % 103].$char128wid[106]; //Check Code, then END |
48 | 48 | //Part 2, Write rows |
49 | 49 | $html = '<table cellpadding=0 cellspacing=0><tr>'; |
50 | - for ($x = 0; $x < strlen($w); $x += 2) { // code 128 widths: black border, then white space |
|
50 | + for ($x = 0; $x<strlen($w); $x += 2) { // code 128 widths: black border, then white space |
|
51 | 51 | $html .= "<td><div class=\"b128\" style=\"border-left-width:{$w[$x]};width:{$w[$x + 1]}\"></div>"; |
52 | 52 | } |
53 | 53 |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | */ |
278 | 278 | function str_split($string, $split_length = 1) |
279 | 279 | { |
280 | - if ((strlen($string) > $split_length) or (!$split_length)) { |
|
280 | + if ((strlen($string)>$split_length) or (!$split_length)) { |
|
281 | 281 | do { |
282 | 282 | $c = strlen($string); |
283 | 283 | $parts[] = substr($string, 0, $split_length); |
284 | 284 | $string = substr($string, $split_length); |
285 | - } while ($string !== false); |
|
285 | + } while ($string!==false); |
|
286 | 286 | } else { |
287 | 287 | $parts = [$string]; |
288 | 288 | } |
@@ -632,18 +632,18 @@ discard block |
||
632 | 632 | public function __construct($code, $eclevel = 'L') |
633 | 633 | { |
634 | 634 | $barcode_array = []; |
635 | - if ((is_null($code)) or ($code == '\0') or ($code == '')) { |
|
635 | + if ((is_null($code)) or ($code=='\0') or ($code=='')) { |
|
636 | 636 | return false; |
637 | 637 | } |
638 | 638 | // set error correction level |
639 | 639 | $this->level = array_search($eclevel, ['L', 'M', 'Q', 'H']); |
640 | - if ($this->level === false) { |
|
640 | + if ($this->level===false) { |
|
641 | 641 | $this->level = QR_ECLEVEL_L; |
642 | 642 | } |
643 | - if (($this->hint != QR_MODE_8B) and ($this->hint != QR_MODE_KJ)) { |
|
643 | + if (($this->hint!=QR_MODE_8B) and ($this->hint!=QR_MODE_KJ)) { |
|
644 | 644 | return false; |
645 | 645 | } |
646 | - if (($this->version < 0) or ($this->version > QRSPEC_VERSION_MAX)) { |
|
646 | + if (($this->version<0) or ($this->version>QRSPEC_VERSION_MAX)) { |
|
647 | 647 | return false; |
648 | 648 | } |
649 | 649 | $this->items = []; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | foreach ($qrTab as $line) { |
657 | 657 | $arrAdd = []; |
658 | 658 | foreach (str_split($line) as $char) { |
659 | - $arrAdd[] = ($char == '1') ? 1 : 0; |
|
659 | + $arrAdd[] = ($char=='1') ? 1 : 0; |
|
660 | 660 | } |
661 | 661 | $barcode_array['bcode'][] = $arrAdd; |
662 | 662 | } |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | $len = count($frame); |
686 | 686 | // the frame is square (width = height) |
687 | 687 | foreach ($frame as &$frameLine) { |
688 | - for ($i = 0; $i < $len; $i++) { |
|
688 | + for ($i = 0; $i<$len; $i++) { |
|
689 | 689 | $frameLine[$i] = (ord($frameLine[$i]) & 1) ? '1' : '0'; |
690 | 690 | } |
691 | 691 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $this->toUpper(); |
706 | 706 | } |
707 | 707 | $ret = $this->splitString(); |
708 | - if ($ret < 0) { |
|
708 | + if ($ret<0) { |
|
709 | 709 | return; |
710 | 710 | } |
711 | 711 | $this->encodeMask(-1); |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | $this->ecccode = array_fill(0, $this->eccLength, 0); |
731 | 731 | $this->blocks = $this->rsBlockNum($spec); |
732 | 732 | $ret = $this->init($spec); |
733 | - if ($ret < 0) { |
|
733 | + if ($ret<0) { |
|
734 | 734 | return; |
735 | 735 | } |
736 | 736 | $this->count = 0; |
@@ -741,24 +741,24 @@ discard block |
||
741 | 741 | $this->dir = -1; |
742 | 742 | $this->bit = -1; |
743 | 743 | // inteleaved data and ecc codes |
744 | - for ($i = 0; $i < ($this->dataLength + $this->eccLength); $i++) { |
|
744 | + for ($i = 0; $i<($this->dataLength + $this->eccLength); $i++) { |
|
745 | 745 | $code = $this->getCode(); |
746 | 746 | $bit = 0x80; |
747 | - for ($j = 0; $j < 8; $j++) { |
|
747 | + for ($j = 0; $j<8; $j++) { |
|
748 | 748 | $addr = $this->getNextPosition(); |
749 | - $this->setFrameAt($addr, 0x02 | (($bit & $code) != 0)); |
|
749 | + $this->setFrameAt($addr, 0x02 | (($bit & $code)!=0)); |
|
750 | 750 | $bit = $bit >> 1; |
751 | 751 | } |
752 | 752 | } |
753 | 753 | // remainder bits |
754 | 754 | $j = $this->getRemainder($this->version); |
755 | - for ($i = 0; $i < $j; $i++) { |
|
755 | + for ($i = 0; $i<$j; $i++) { |
|
756 | 756 | $addr = $this->getNextPosition(); |
757 | 757 | $this->setFrameAt($addr, 0x02); |
758 | 758 | } |
759 | 759 | // masking |
760 | 760 | $this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0); |
761 | - if ($mask < 0) { |
|
761 | + if ($mask<0) { |
|
762 | 762 | if (QR_FIND_BEST_MASK) { |
763 | 763 | $masked = $this->mask($this->width, $this->frame, $this->level); |
764 | 764 | } else { |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | } else { |
768 | 768 | $masked = $this->makeMask($this->width, $this->frame, $mask, $this->level); |
769 | 769 | } |
770 | - if ($masked == null) { |
|
770 | + if ($masked==null) { |
|
771 | 771 | return; |
772 | 772 | } |
773 | 773 | $this->data = $masked; |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | protected function getNextPosition() |
809 | 809 | { |
810 | 810 | do { |
811 | - if ($this->bit == -1) { |
|
811 | + if ($this->bit==-1) { |
|
812 | 812 | $this->bit = 0; |
813 | 813 | |
814 | 814 | return ['x'=>$this->x, 'y'=>$this->y]; |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | $x = $this->x; |
817 | 817 | $y = $this->y; |
818 | 818 | $w = $this->width; |
819 | - if ($this->bit == 0) { |
|
819 | + if ($this->bit==0) { |
|
820 | 820 | $x--; |
821 | 821 | $this->bit++; |
822 | 822 | } else { |
@@ -824,28 +824,28 @@ discard block |
||
824 | 824 | $y += $this->dir; |
825 | 825 | $this->bit--; |
826 | 826 | } |
827 | - if ($this->dir < 0) { |
|
828 | - if ($y < 0) { |
|
827 | + if ($this->dir<0) { |
|
828 | + if ($y<0) { |
|
829 | 829 | $y = 0; |
830 | 830 | $x -= 2; |
831 | 831 | $this->dir = 1; |
832 | - if ($x == 6) { |
|
832 | + if ($x==6) { |
|
833 | 833 | $x--; |
834 | 834 | $y = 9; |
835 | 835 | } |
836 | 836 | } |
837 | 837 | } else { |
838 | - if ($y == $w) { |
|
838 | + if ($y==$w) { |
|
839 | 839 | $y = $w - 1; |
840 | 840 | $x -= 2; |
841 | 841 | $this->dir = -1; |
842 | - if ($x == 6) { |
|
842 | + if ($x==6) { |
|
843 | 843 | $x--; |
844 | 844 | $y -= 8; |
845 | 845 | } |
846 | 846 | } |
847 | 847 | } |
848 | - if (($x < 0) or ($y < 0)) { |
|
848 | + if (($x<0) or ($y<0)) { |
|
849 | 849 | return; |
850 | 850 | } |
851 | 851 | $this->x = $x; |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | $dataPos = 0; |
876 | 876 | $eccPos = 0; |
877 | 877 | $endfor = $this->rsBlockNum1($spec); |
878 | - for ($i = 0; $i < $endfor; $i++) { |
|
878 | + for ($i = 0; $i<$endfor; $i++) { |
|
879 | 879 | $ecc = array_slice($this->ecccode, $eccPos); |
880 | 880 | $this->rsblocks[$blockNo] = []; |
881 | 881 | $this->rsblocks[$blockNo]['dataLength'] = $dl; |
@@ -888,17 +888,17 @@ discard block |
||
888 | 888 | $eccPos += $el; |
889 | 889 | $blockNo++; |
890 | 890 | } |
891 | - if ($this->rsBlockNum2($spec) == 0) { |
|
891 | + if ($this->rsBlockNum2($spec)==0) { |
|
892 | 892 | return 0; |
893 | 893 | } |
894 | 894 | $dl = $this->rsDataCodes2($spec); |
895 | 895 | $el = $this->rsEccCodes2($spec); |
896 | 896 | $rs = $this->init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); |
897 | - if ($rs == null) { |
|
897 | + if ($rs==null) { |
|
898 | 898 | return -1; |
899 | 899 | } |
900 | 900 | $endfor = $this->rsBlockNum2($spec); |
901 | - for ($i = 0; $i < $endfor; $i++) { |
|
901 | + for ($i = 0; $i<$endfor; $i++) { |
|
902 | 902 | $ecc = array_slice($this->ecccode, $eccPos); |
903 | 903 | $this->rsblocks[$blockNo] = []; |
904 | 904 | $this->rsblocks[$blockNo]['dataLength'] = $dl; |
@@ -922,14 +922,14 @@ discard block |
||
922 | 922 | */ |
923 | 923 | protected function getCode() |
924 | 924 | { |
925 | - if ($this->count < $this->dataLength) { |
|
925 | + if ($this->count<$this->dataLength) { |
|
926 | 926 | $row = $this->count % $this->blocks; |
927 | 927 | $col = $this->count / $this->blocks; |
928 | - if ($col >= $this->rsblocks[0]['dataLength']) { |
|
928 | + if ($col>=$this->rsblocks[0]['dataLength']) { |
|
929 | 929 | $row += $this->b1; |
930 | 930 | } |
931 | 931 | $ret = $this->rsblocks[$row]['data'][$col]; |
932 | - } elseif ($this->count < $this->dataLength + $this->eccLength) { |
|
932 | + } elseif ($this->count<$this->dataLength + $this->eccLength) { |
|
933 | 933 | $row = ($this->count - $this->dataLength) % $this->blocks; |
934 | 934 | $col = ($this->count - $this->dataLength) / $this->blocks; |
935 | 935 | $ret = $this->rsblocks[$row]['ecc'][$col]; |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | { |
960 | 960 | $blacks = 0; |
961 | 961 | $format = $this->getFormatInfo($mask, $level); |
962 | - for ($i = 0; $i < 8; $i++) { |
|
962 | + for ($i = 0; $i<8; $i++) { |
|
963 | 963 | if ($format & 1) { |
964 | 964 | $blacks += 2; |
965 | 965 | $v = 0x85; |
@@ -967,14 +967,14 @@ discard block |
||
967 | 967 | $v = 0x84; |
968 | 968 | } |
969 | 969 | $frame[8][$width - 1 - $i] = chr($v); |
970 | - if ($i < 6) { |
|
970 | + if ($i<6) { |
|
971 | 971 | $frame[$i][8] = chr($v); |
972 | 972 | } else { |
973 | 973 | $frame[$i + 1][8] = chr($v); |
974 | 974 | } |
975 | 975 | $format = $format >> 1; |
976 | 976 | } |
977 | - for ($i = 0; $i < 7; $i++) { |
|
977 | + for ($i = 0; $i<7; $i++) { |
|
978 | 978 | if ($format & 1) { |
979 | 979 | $blacks += 2; |
980 | 980 | $v = 0x85; |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | $v = 0x84; |
983 | 983 | } |
984 | 984 | $frame[$width - 7 + $i][8] = chr($v); |
985 | - if ($i == 0) { |
|
985 | + if ($i==0) { |
|
986 | 986 | $frame[8][7] = chr($v); |
987 | 987 | } else { |
988 | 988 | $frame[8][6 - $i] = chr($v); |
@@ -1055,7 +1055,7 @@ discard block |
||
1055 | 1055 | */ |
1056 | 1056 | protected function mask4($x, $y) |
1057 | 1057 | { |
1058 | - return (((int) ($y / 2)) + ((int) ($x / 3))) & 1; |
|
1058 | + return (((int)($y / 2)) + ((int)($x / 3))) & 1; |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | /** |
@@ -1109,13 +1109,13 @@ discard block |
||
1109 | 1109 | protected function generateMaskNo($maskNo, $width, $frame) |
1110 | 1110 | { |
1111 | 1111 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
1112 | - for ($y = 0; $y < $width; $y++) { |
|
1113 | - for ($x = 0; $x < $width; $x++) { |
|
1112 | + for ($y = 0; $y<$width; $y++) { |
|
1113 | + for ($x = 0; $x<$width; $x++) { |
|
1114 | 1114 | if (ord($frame[$y][$x]) & 0x80) { |
1115 | 1115 | $bitMask[$y][$x] = 0; |
1116 | 1116 | } else { |
1117 | 1117 | $maskFunc = call_user_func([$this, 'mask'.$maskNo], $x, $y); |
1118 | - $bitMask[$y][$x] = ($maskFunc == 0) ? 1 : 0; |
|
1118 | + $bitMask[$y][$x] = ($maskFunc==0) ? 1 : 0; |
|
1119 | 1119 | } |
1120 | 1120 | } |
1121 | 1121 | } |
@@ -1143,12 +1143,12 @@ discard block |
||
1143 | 1143 | return; |
1144 | 1144 | } |
1145 | 1145 | $d = $s; |
1146 | - for ($y = 0; $y < $width; $y++) { |
|
1147 | - for ($x = 0; $x < $width; $x++) { |
|
1148 | - if ($bitMask[$y][$x] == 1) { |
|
1149 | - $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int) $bitMask[$y][$x]); |
|
1146 | + for ($y = 0; $y<$width; $y++) { |
|
1147 | + for ($x = 0; $x<$width; $x++) { |
|
1148 | + if ($bitMask[$y][$x]==1) { |
|
1149 | + $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]); |
|
1150 | 1150 | } |
1151 | - $b += (int) (ord($d[$y][$x]) & 1); |
|
1151 | + $b += (int)(ord($d[$y][$x]) & 1); |
|
1152 | 1152 | } |
1153 | 1153 | } |
1154 | 1154 | |
@@ -1184,20 +1184,20 @@ discard block |
||
1184 | 1184 | protected function calcN1N3($length) |
1185 | 1185 | { |
1186 | 1186 | $demerit = 0; |
1187 | - for ($i = 0; $i < $length; $i++) { |
|
1188 | - if ($this->runLength[$i] >= 5) { |
|
1187 | + for ($i = 0; $i<$length; $i++) { |
|
1188 | + if ($this->runLength[$i]>=5) { |
|
1189 | 1189 | $demerit += (N1 + ($this->runLength[$i] - 5)); |
1190 | 1190 | } |
1191 | 1191 | if ($i & 1) { |
1192 | - if (($i >= 3) and ($i < ($length - 2)) and ($this->runLength[$i] % 3 == 0)) { |
|
1193 | - $fact = (int) ($this->runLength[$i] / 3); |
|
1194 | - if (($this->runLength[$i - 2] == $fact) |
|
1195 | - and ($this->runLength[$i - 1] == $fact) |
|
1196 | - and ($this->runLength[$i + 1] == $fact) |
|
1197 | - and ($this->runLength[$i + 2] == $fact)) { |
|
1198 | - if (($this->runLength[$i - 3] < 0) or ($this->runLength[$i - 3] >= (4 * $fact))) { |
|
1192 | + if (($i>=3) and ($i<($length - 2)) and ($this->runLength[$i] % 3==0)) { |
|
1193 | + $fact = (int)($this->runLength[$i] / 3); |
|
1194 | + if (($this->runLength[$i - 2]==$fact) |
|
1195 | + and ($this->runLength[$i - 1]==$fact) |
|
1196 | + and ($this->runLength[$i + 1]==$fact) |
|
1197 | + and ($this->runLength[$i + 2]==$fact)) { |
|
1198 | + if (($this->runLength[$i - 3]<0) or ($this->runLength[$i - 3]>=(4 * $fact))) { |
|
1199 | 1199 | $demerit += N3; |
1200 | - } elseif ((($i + 3) >= $length) or ($this->runLength[$i + 3] >= (4 * $fact))) { |
|
1200 | + } elseif ((($i + 3)>=$length) or ($this->runLength[$i + 3]>=(4 * $fact))) { |
|
1201 | 1201 | $demerit += N3; |
1202 | 1202 | } |
1203 | 1203 | } |
@@ -1220,26 +1220,26 @@ discard block |
||
1220 | 1220 | { |
1221 | 1221 | $head = 0; |
1222 | 1222 | $demerit = 0; |
1223 | - for ($y = 0; $y < $width; $y++) { |
|
1223 | + for ($y = 0; $y<$width; $y++) { |
|
1224 | 1224 | $head = 0; |
1225 | 1225 | $this->runLength[0] = 1; |
1226 | 1226 | $frameY = $frame[$y]; |
1227 | - if ($y > 0) { |
|
1227 | + if ($y>0) { |
|
1228 | 1228 | $frameYM = $frame[$y - 1]; |
1229 | 1229 | } |
1230 | - for ($x = 0; $x < $width; $x++) { |
|
1231 | - if (($x > 0) and ($y > 0)) { |
|
1230 | + for ($x = 0; $x<$width; $x++) { |
|
1231 | + if (($x>0) and ($y>0)) { |
|
1232 | 1232 | $b22 = ord($frameY[$x]) & ord($frameY[$x - 1]) & ord($frameYM[$x]) & ord($frameYM[$x - 1]); |
1233 | 1233 | $w22 = ord($frameY[$x]) | ord($frameY[$x - 1]) | ord($frameYM[$x]) | ord($frameYM[$x - 1]); |
1234 | 1234 | if (($b22 | ($w22 ^ 1)) & 1) { |
1235 | 1235 | $demerit += N2; |
1236 | 1236 | } |
1237 | 1237 | } |
1238 | - if (($x == 0) and (ord($frameY[$x]) & 1)) { |
|
1238 | + if (($x==0) and (ord($frameY[$x]) & 1)) { |
|
1239 | 1239 | $this->runLength[0] = -1; |
1240 | 1240 | $head = 1; |
1241 | 1241 | $this->runLength[$head] = 1; |
1242 | - } elseif ($x > 0) { |
|
1242 | + } elseif ($x>0) { |
|
1243 | 1243 | if ((ord($frameY[$x]) ^ ord($frameY[$x - 1])) & 1) { |
1244 | 1244 | $head++; |
1245 | 1245 | $this->runLength[$head] = 1; |
@@ -1250,15 +1250,15 @@ discard block |
||
1250 | 1250 | } |
1251 | 1251 | $demerit += $this->calcN1N3($head + 1); |
1252 | 1252 | } |
1253 | - for ($x = 0; $x < $width; $x++) { |
|
1253 | + for ($x = 0; $x<$width; $x++) { |
|
1254 | 1254 | $head = 0; |
1255 | 1255 | $this->runLength[0] = 1; |
1256 | - for ($y = 0; $y < $width; $y++) { |
|
1257 | - if (($y == 0) and (ord($frame[$y][$x]) & 1)) { |
|
1256 | + for ($y = 0; $y<$width; $y++) { |
|
1257 | + if (($y==0) and (ord($frame[$y][$x]) & 1)) { |
|
1258 | 1258 | $this->runLength[0] = -1; |
1259 | 1259 | $head = 1; |
1260 | 1260 | $this->runLength[$head] = 1; |
1261 | - } elseif ($y > 0) { |
|
1261 | + } elseif ($y>0) { |
|
1262 | 1262 | if ((ord($frame[$y][$x]) ^ ord($frame[$y - 1][$x])) & 1) { |
1263 | 1263 | $head++; |
1264 | 1264 | $this->runLength[$head] = 1; |
@@ -1288,9 +1288,9 @@ discard block |
||
1288 | 1288 | $bestMaskNum = 0; |
1289 | 1289 | $bestMask = []; |
1290 | 1290 | $checked_masks = [0, 1, 2, 3, 4, 5, 6, 7]; |
1291 | - if (QR_FIND_FROM_RANDOM !== false) { |
|
1291 | + if (QR_FIND_FROM_RANDOM!==false) { |
|
1292 | 1292 | $howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9); |
1293 | - for ($i = 0; $i < $howManuOut; $i++) { |
|
1293 | + for ($i = 0; $i<$howManuOut; $i++) { |
|
1294 | 1294 | $remPos = rand(0, count($checked_masks) - 1); |
1295 | 1295 | unset($checked_masks[$remPos]); |
1296 | 1296 | $checked_masks = array_values($checked_masks); |
@@ -1303,10 +1303,10 @@ discard block |
||
1303 | 1303 | $blacks = 0; |
1304 | 1304 | $blacks = $this->makeMaskNo($i, $width, $frame, $mask); |
1305 | 1305 | $blacks += $this->writeFormatInformation($width, $mask, $i, $level); |
1306 | - $blacks = (int) (100 * $blacks / ($width * $width)); |
|
1307 | - $demerit = (int) ((int) (abs($blacks - 50) / 5) * N4); |
|
1306 | + $blacks = (int)(100 * $blacks / ($width * $width)); |
|
1307 | + $demerit = (int)((int)(abs($blacks - 50) / 5) * N4); |
|
1308 | 1308 | $demerit += $this->evaluateSymbol($width, $mask); |
1309 | - if ($demerit < $minDemerit) { |
|
1309 | + if ($demerit<$minDemerit) { |
|
1310 | 1310 | $minDemerit = $demerit; |
1311 | 1311 | $bestMask = $mask; |
1312 | 1312 | $bestMaskNum = $i; |
@@ -1330,11 +1330,11 @@ discard block |
||
1330 | 1330 | */ |
1331 | 1331 | protected function isdigitat($str, $pos) |
1332 | 1332 | { |
1333 | - if ($pos >= strlen($str)) { |
|
1333 | + if ($pos>=strlen($str)) { |
|
1334 | 1334 | return false; |
1335 | 1335 | } |
1336 | 1336 | |
1337 | - return (ord($str[$pos]) >= ord('0')) && (ord($str[$pos]) <= ord('9')); |
|
1337 | + return (ord($str[$pos])>=ord('0')) && (ord($str[$pos])<=ord('9')); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | /** |
@@ -1347,11 +1347,11 @@ discard block |
||
1347 | 1347 | */ |
1348 | 1348 | protected function isalnumat($str, $pos) |
1349 | 1349 | { |
1350 | - if ($pos >= strlen($str)) { |
|
1350 | + if ($pos>=strlen($str)) { |
|
1351 | 1351 | return false; |
1352 | 1352 | } |
1353 | 1353 | |
1354 | - return $this->lookAnTable(ord($str[$pos])) >= 0; |
|
1354 | + return $this->lookAnTable(ord($str[$pos]))>=0; |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | /** |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | */ |
1364 | 1364 | protected function identifyMode($pos) |
1365 | 1365 | { |
1366 | - if ($pos >= strlen($this->dataStr)) { |
|
1366 | + if ($pos>=strlen($this->dataStr)) { |
|
1367 | 1367 | return QR_MODE_NL; |
1368 | 1368 | } |
1369 | 1369 | $c = $this->dataStr[$pos]; |
@@ -1371,11 +1371,11 @@ discard block |
||
1371 | 1371 | return QR_MODE_NM; |
1372 | 1372 | } elseif ($this->isalnumat($this->dataStr, $pos)) { |
1373 | 1373 | return QR_MODE_AN; |
1374 | - } elseif ($this->hint == QR_MODE_KJ) { |
|
1375 | - if ($pos + 1 < strlen($this->dataStr)) { |
|
1374 | + } elseif ($this->hint==QR_MODE_KJ) { |
|
1375 | + if ($pos + 1<strlen($this->dataStr)) { |
|
1376 | 1376 | $d = $this->dataStr[$pos + 1]; |
1377 | 1377 | $word = (ord($c) << 8) | ord($d); |
1378 | - if (($word >= 0x8140 && $word <= 0x9ffc) or ($word >= 0xe040 && $word <= 0xebbf)) { |
|
1378 | + if (($word>=0x8140 && $word<=0x9ffc) or ($word>=0xe040 && $word<=0xebbf)) { |
|
1379 | 1379 | return QR_MODE_KJ; |
1380 | 1380 | } |
1381 | 1381 | } |
@@ -1398,19 +1398,19 @@ discard block |
||
1398 | 1398 | } |
1399 | 1399 | $run = $p; |
1400 | 1400 | $mode = $this->identifyMode($p); |
1401 | - if ($mode == QR_MODE_8B) { |
|
1401 | + if ($mode==QR_MODE_8B) { |
|
1402 | 1402 | $dif = $this->estimateBitsModeNum($run) + 4 + $ln |
1403 | 1403 | + $this->estimateBitsMode8(1) // + 4 + l8 |
1404 | 1404 | - $this->estimateBitsMode8($run + 1); // - 4 - l8 |
1405 | - if ($dif > 0) { |
|
1405 | + if ($dif>0) { |
|
1406 | 1406 | return $this->eat8(); |
1407 | 1407 | } |
1408 | 1408 | } |
1409 | - if ($mode == QR_MODE_AN) { |
|
1409 | + if ($mode==QR_MODE_AN) { |
|
1410 | 1410 | $dif = $this->estimateBitsModeNum($run) + 4 + $ln |
1411 | 1411 | + $this->estimateBitsModeAn(1) // + 4 + la |
1412 | 1412 | - $this->estimateBitsModeAn($run + 1); // - 4 - la |
1413 | - if ($dif > 0) { |
|
1413 | + if ($dif>0) { |
|
1414 | 1414 | return $this->eatAn(); |
1415 | 1415 | } |
1416 | 1416 | } |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | $dif = $this->estimateBitsModeAn($p) // + 4 + la |
1439 | 1439 | + $this->estimateBitsModeNum($q - $p) + 4 + $ln |
1440 | 1440 | - $this->estimateBitsModeAn($q); // - 4 - la |
1441 | - if ($dif < 0) { |
|
1441 | + if ($dif<0) { |
|
1442 | 1442 | break; |
1443 | 1443 | } else { |
1444 | 1444 | $p = $q; |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | $dif = $this->estimateBitsModeAn($run) + 4 + $la |
1453 | 1453 | + $this->estimateBitsMode8(1) // + 4 + l8 |
1454 | 1454 | - $this->estimateBitsMode8($run + 1); // - 4 - l8 |
1455 | - if ($dif > 0) { |
|
1455 | + if ($dif>0) { |
|
1456 | 1456 | return $this->eat8(); |
1457 | 1457 | } |
1458 | 1458 | } |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | protected function eatKanji() |
1470 | 1470 | { |
1471 | 1471 | $p = 0; |
1472 | - while ($this->identifyMode($p) == QR_MODE_KJ) { |
|
1472 | + while ($this->identifyMode($p)==QR_MODE_KJ) { |
|
1473 | 1473 | $p += 2; |
1474 | 1474 | } |
1475 | 1475 | $this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr)); |
@@ -1488,12 +1488,12 @@ discard block |
||
1488 | 1488 | $ln = $this->lengthIndicator(QR_MODE_NM, $this->version); |
1489 | 1489 | $p = 1; |
1490 | 1490 | $dataStrLen = strlen($this->dataStr); |
1491 | - while ($p < $dataStrLen) { |
|
1491 | + while ($p<$dataStrLen) { |
|
1492 | 1492 | $mode = $this->identifyMode($p); |
1493 | - if ($mode == QR_MODE_KJ) { |
|
1493 | + if ($mode==QR_MODE_KJ) { |
|
1494 | 1494 | break; |
1495 | 1495 | } |
1496 | - if ($mode == QR_MODE_NM) { |
|
1496 | + if ($mode==QR_MODE_NM) { |
|
1497 | 1497 | $q = $p; |
1498 | 1498 | while ($this->isdigitat($this->dataStr, $q)) { |
1499 | 1499 | $q++; |
@@ -1501,12 +1501,12 @@ discard block |
||
1501 | 1501 | $dif = $this->estimateBitsMode8($p) // + 4 + l8 |
1502 | 1502 | + $this->estimateBitsModeNum($q - $p) + 4 + $ln |
1503 | 1503 | - $this->estimateBitsMode8($q); // - 4 - l8 |
1504 | - if ($dif < 0) { |
|
1504 | + if ($dif<0) { |
|
1505 | 1505 | break; |
1506 | 1506 | } else { |
1507 | 1507 | $p = $q; |
1508 | 1508 | } |
1509 | - } elseif ($mode == QR_MODE_AN) { |
|
1509 | + } elseif ($mode==QR_MODE_AN) { |
|
1510 | 1510 | $q = $p; |
1511 | 1511 | while ($this->isalnumat($this->dataStr, $q)) { |
1512 | 1512 | $q++; |
@@ -1514,7 +1514,7 @@ discard block |
||
1514 | 1514 | $dif = $this->estimateBitsMode8($p) // + 4 + l8 |
1515 | 1515 | + $this->estimateBitsModeAn($q - $p) + 4 + $la |
1516 | 1516 | - $this->estimateBitsMode8($q); // - 4 - l8 |
1517 | - if ($dif < 0) { |
|
1517 | + if ($dif<0) { |
|
1518 | 1518 | break; |
1519 | 1519 | } else { |
1520 | 1520 | $p = $q; |
@@ -1534,8 +1534,8 @@ discard block |
||
1534 | 1534 | */ |
1535 | 1535 | protected function splitString() |
1536 | 1536 | { |
1537 | - while (strlen($this->dataStr) > 0) { |
|
1538 | - if ($this->dataStr == '') { |
|
1537 | + while (strlen($this->dataStr)>0) { |
|
1538 | + if ($this->dataStr=='') { |
|
1539 | 1539 | return 0; |
1540 | 1540 | } |
1541 | 1541 | $mode = $this->identifyMode(0); |
@@ -1549,7 +1549,7 @@ discard block |
||
1549 | 1549 | break; |
1550 | 1550 | } |
1551 | 1551 | case QR_MODE_KJ: { |
1552 | - if ($hint == QR_MODE_KJ) { |
|
1552 | + if ($hint==QR_MODE_KJ) { |
|
1553 | 1553 | $length = $this->eatKanji(); |
1554 | 1554 | } else { |
1555 | 1555 | $length = $this->eat8(); |
@@ -1561,10 +1561,10 @@ discard block |
||
1561 | 1561 | break; |
1562 | 1562 | } |
1563 | 1563 | } |
1564 | - if ($length == 0) { |
|
1564 | + if ($length==0) { |
|
1565 | 1565 | return 0; |
1566 | 1566 | } |
1567 | - if ($length < 0) { |
|
1567 | + if ($length<0) { |
|
1568 | 1568 | return -1; |
1569 | 1569 | } |
1570 | 1570 | $this->dataStr = substr($this->dataStr, $length); |
@@ -1578,12 +1578,12 @@ discard block |
||
1578 | 1578 | { |
1579 | 1579 | $stringLen = strlen($this->dataStr); |
1580 | 1580 | $p = 0; |
1581 | - while ($p < $stringLen) { |
|
1581 | + while ($p<$stringLen) { |
|
1582 | 1582 | $mode = $this->identifyMode(substr($this->dataStr, $p), $this->hint); |
1583 | - if ($mode == QR_MODE_KJ) { |
|
1583 | + if ($mode==QR_MODE_KJ) { |
|
1584 | 1584 | $p += 2; |
1585 | 1585 | } else { |
1586 | - if ((ord($this->dataStr[$p]) >= ord('a')) and (ord($this->dataStr[$p]) <= ord('z'))) { |
|
1586 | + if ((ord($this->dataStr[$p])>=ord('a')) and (ord($this->dataStr[$p])<=ord('z'))) { |
|
1587 | 1587 | $this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32); |
1588 | 1588 | } |
1589 | 1589 | $p++; |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | protected function newInputItem($mode, $size, $data, $bstream = null) |
1611 | 1611 | { |
1612 | 1612 | $setData = array_slice($data, 0, $size); |
1613 | - if (count($setData) < $size) { |
|
1613 | + if (count($setData)<$size) { |
|
1614 | 1614 | $setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0)); |
1615 | 1615 | } |
1616 | 1616 | if (!$this->check($mode, $size, $setData)) { |
@@ -1635,21 +1635,21 @@ discard block |
||
1635 | 1635 | */ |
1636 | 1636 | protected function encodeModeNum($inputitem, $version) |
1637 | 1637 | { |
1638 | - $words = (int) ($inputitem['size'] / 3); |
|
1638 | + $words = (int)($inputitem['size'] / 3); |
|
1639 | 1639 | $inputitem['bstream'] = []; |
1640 | 1640 | $val = 0x1; |
1641 | 1641 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); |
1642 | 1642 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_NM, $version), $inputitem['size']); |
1643 | - for ($i = 0; $i < $words; $i++) { |
|
1643 | + for ($i = 0; $i<$words; $i++) { |
|
1644 | 1644 | $val = (ord($inputitem['data'][$i * 3]) - ord('0')) * 100; |
1645 | 1645 | $val += (ord($inputitem['data'][$i * 3 + 1]) - ord('0')) * 10; |
1646 | 1646 | $val += (ord($inputitem['data'][$i * 3 + 2]) - ord('0')); |
1647 | 1647 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 10, $val); |
1648 | 1648 | } |
1649 | - if ($inputitem['size'] - $words * 3 == 1) { |
|
1649 | + if ($inputitem['size'] - $words * 3==1) { |
|
1650 | 1650 | $val = ord($inputitem['data'][$words * 3]) - ord('0'); |
1651 | 1651 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); |
1652 | - } elseif (($inputitem['size'] - ($words * 3)) == 2) { |
|
1652 | + } elseif (($inputitem['size'] - ($words * 3))==2) { |
|
1653 | 1653 | $val = (ord($inputitem['data'][$words * 3]) - ord('0')) * 10; |
1654 | 1654 | $val += (ord($inputitem['data'][$words * 3 + 1]) - ord('0')); |
1655 | 1655 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val); |
@@ -1668,13 +1668,13 @@ discard block |
||
1668 | 1668 | */ |
1669 | 1669 | protected function encodeModeAn($inputitem, $version) |
1670 | 1670 | { |
1671 | - $words = (int) ($inputitem['size'] / 2); |
|
1671 | + $words = (int)($inputitem['size'] / 2); |
|
1672 | 1672 | $inputitem['bstream'] = []; |
1673 | 1673 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x02); |
1674 | 1674 | $inputitem['bstream'] = $this->appendNum(v, $this->lengthIndicator(QR_MODE_AN, $version), $inputitem['size']); |
1675 | - for ($i = 0; $i < $words; $i++) { |
|
1676 | - $val = (int) $this->lookAnTable(ord($inputitem['data'][$i * 2])) * 45; |
|
1677 | - $val += (int) $this->lookAnTable(ord($inputitem['data'][$i * 2 + 1])); |
|
1675 | + for ($i = 0; $i<$words; $i++) { |
|
1676 | + $val = (int)$this->lookAnTable(ord($inputitem['data'][$i * 2])) * 45; |
|
1677 | + $val += (int)$this->lookAnTable(ord($inputitem['data'][$i * 2 + 1])); |
|
1678 | 1678 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val); |
1679 | 1679 | } |
1680 | 1680 | if ($inputitem['size'] & 1) { |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | $inputitem['bstream'] = []; |
1699 | 1699 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4); |
1700 | 1700 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_8B, $version), $inputitem['size']); |
1701 | - for ($i = 0; $i < $inputitem['size']; $i++) { |
|
1701 | + for ($i = 0; $i<$inputitem['size']; $i++) { |
|
1702 | 1702 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][$i])); |
1703 | 1703 | } |
1704 | 1704 | |
@@ -1717,10 +1717,10 @@ discard block |
||
1717 | 1717 | { |
1718 | 1718 | $inputitem['bstream'] = []; |
1719 | 1719 | $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8); |
1720 | - $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int) ($inputitem['size'] / 2)); |
|
1721 | - for ($i = 0; $i < $inputitem['size']; $i += 2) { |
|
1720 | + $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int)($inputitem['size'] / 2)); |
|
1721 | + for ($i = 0; $i<$inputitem['size']; $i += 2) { |
|
1722 | 1722 | $val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i + 1]); |
1723 | - if ($val <= 0x9ffc) { |
|
1723 | + if ($val<=0x9ffc) { |
|
1724 | 1724 | $val -= 0x8140; |
1725 | 1725 | } else { |
1726 | 1726 | $val -= 0xc140; |
@@ -1763,7 +1763,7 @@ discard block |
||
1763 | 1763 | { |
1764 | 1764 | $inputitem['bstream'] = []; |
1765 | 1765 | $words = $this->maximumWords($inputitem['mode'], $version); |
1766 | - if ($inputitem['size'] > $words) { |
|
1766 | + if ($inputitem['size']>$words) { |
|
1767 | 1767 | $st1 = $this->newInputItem($inputitem['mode'], $words, $inputitem['data']); |
1768 | 1768 | $st2 = $this->newInputItem($inputitem['mode'], $inputitem['size'] - $words, array_slice($inputitem['data'], $words)); |
1769 | 1769 | $st1 = $this->encodeBitStream($st1, $version); |
@@ -1836,10 +1836,10 @@ discard block |
||
1836 | 1836 | */ |
1837 | 1837 | protected function insertStructuredAppendHeader($items, $size, $index, $parity) |
1838 | 1838 | { |
1839 | - if ($size > MAX_STRUCTURED_SYMBOLS) { |
|
1839 | + if ($size>MAX_STRUCTURED_SYMBOLS) { |
|
1840 | 1840 | return -1; |
1841 | 1841 | } |
1842 | - if (($index <= 0) or ($index > MAX_STRUCTURED_SYMBOLS)) { |
|
1842 | + if (($index<=0) or ($index>MAX_STRUCTURED_SYMBOLS)) { |
|
1843 | 1843 | return -1; |
1844 | 1844 | } |
1845 | 1845 | $buf = [$size, $index, $parity]; |
@@ -1860,8 +1860,8 @@ discard block |
||
1860 | 1860 | { |
1861 | 1861 | $parity = 0; |
1862 | 1862 | foreach ($items as $item) { |
1863 | - if ($item['mode'] != QR_MODE_ST) { |
|
1864 | - for ($i = $item['size'] - 1; $i >= 0; $i--) { |
|
1863 | + if ($item['mode']!=QR_MODE_ST) { |
|
1864 | + for ($i = $item['size'] - 1; $i>=0; $i--) { |
|
1865 | 1865 | $parity ^= $item['data'][$i]; |
1866 | 1866 | } |
1867 | 1867 | } |
@@ -1880,8 +1880,8 @@ discard block |
||
1880 | 1880 | */ |
1881 | 1881 | protected function checkModeNum($size, $data) |
1882 | 1882 | { |
1883 | - for ($i = 0; $i < $size; $i++) { |
|
1884 | - if ((ord($data[$i]) < ord('0')) or (ord($data[$i]) > ord('9'))) { |
|
1883 | + for ($i = 0; $i<$size; $i++) { |
|
1884 | + if ((ord($data[$i])<ord('0')) or (ord($data[$i])>ord('9'))) { |
|
1885 | 1885 | return false; |
1886 | 1886 | } |
1887 | 1887 | } |
@@ -1898,7 +1898,7 @@ discard block |
||
1898 | 1898 | */ |
1899 | 1899 | protected function estimateBitsModeNum($size) |
1900 | 1900 | { |
1901 | - $w = (int) $size / 3; |
|
1901 | + $w = (int)$size / 3; |
|
1902 | 1902 | $bits = $w * 10; |
1903 | 1903 | switch ($size - $w * 3) { |
1904 | 1904 | case 1: { |
@@ -1926,7 +1926,7 @@ discard block |
||
1926 | 1926 | */ |
1927 | 1927 | protected function lookAnTable($c) |
1928 | 1928 | { |
1929 | - return ($c > 127) ? -1 : $this->anTable[$c]; |
|
1929 | + return ($c>127) ? -1 : $this->anTable[$c]; |
|
1930 | 1930 | } |
1931 | 1931 | |
1932 | 1932 | /** |
@@ -1939,8 +1939,8 @@ discard block |
||
1939 | 1939 | */ |
1940 | 1940 | protected function checkModeAn($size, $data) |
1941 | 1941 | { |
1942 | - for ($i = 0; $i < $size; $i++) { |
|
1943 | - if ($this->lookAnTable(ord($data[$i])) == -1) { |
|
1942 | + for ($i = 0; $i<$size; $i++) { |
|
1943 | + if ($this->lookAnTable(ord($data[$i]))==-1) { |
|
1944 | 1944 | return false; |
1945 | 1945 | } |
1946 | 1946 | } |
@@ -1957,7 +1957,7 @@ discard block |
||
1957 | 1957 | */ |
1958 | 1958 | protected function estimateBitsModeAn($size) |
1959 | 1959 | { |
1960 | - $w = (int) ($size / 2); |
|
1960 | + $w = (int)($size / 2); |
|
1961 | 1961 | $bits = $w * 11; |
1962 | 1962 | if ($size & 1) { |
1963 | 1963 | $bits += 6; |
@@ -1987,7 +1987,7 @@ discard block |
||
1987 | 1987 | */ |
1988 | 1988 | protected function estimateBitsModeKanji($size) |
1989 | 1989 | { |
1990 | - return (int) (($size / 2) * 13); |
|
1990 | + return (int)(($size / 2) * 13); |
|
1991 | 1991 | } |
1992 | 1992 | |
1993 | 1993 | /** |
@@ -2003,9 +2003,9 @@ discard block |
||
2003 | 2003 | if ($size & 1) { |
2004 | 2004 | return false; |
2005 | 2005 | } |
2006 | - for ($i = 0; $i < $size; $i += 2) { |
|
2006 | + for ($i = 0; $i<$size; $i += 2) { |
|
2007 | 2007 | $val = (ord($data[$i]) << 8) | ord($data[$i + 1]); |
2008 | - if (($val < 0x8140) or (($val > 0x9ffc) and ($val < 0xe040)) or ($val > 0xebbf)) { |
|
2008 | + if (($val<0x8140) or (($val>0x9ffc) and ($val<0xe040)) or ($val>0xebbf)) { |
|
2009 | 2009 | return false; |
2010 | 2010 | } |
2011 | 2011 | } |
@@ -2024,7 +2024,7 @@ discard block |
||
2024 | 2024 | */ |
2025 | 2025 | protected function check($mode, $size, $data) |
2026 | 2026 | { |
2027 | - if ($size <= 0) { |
|
2027 | + if ($size<=0) { |
|
2028 | 2028 | return false; |
2029 | 2029 | } |
2030 | 2030 | switch ($mode) { |
@@ -2062,7 +2062,7 @@ discard block |
||
2062 | 2062 | protected function estimateBitStreamSize($items, $version) |
2063 | 2063 | { |
2064 | 2064 | $bits = 0; |
2065 | - if ($version == 0) { |
|
2065 | + if ($version==0) { |
|
2066 | 2066 | $version = 1; |
2067 | 2067 | } |
2068 | 2068 | foreach ($items as $item) { |
@@ -2092,7 +2092,7 @@ discard block |
||
2092 | 2092 | } |
2093 | 2093 | $l = $this->lengthIndicator($item['mode'], $version); |
2094 | 2094 | $m = 1 << $l; |
2095 | - $num = (int) (($item['size'] + $m - 1) / $m); |
|
2095 | + $num = (int)(($item['size'] + $m - 1) / $m); |
|
2096 | 2096 | $bits += $num * (4 + $l); |
2097 | 2097 | } |
2098 | 2098 | |
@@ -2113,11 +2113,11 @@ discard block |
||
2113 | 2113 | do { |
2114 | 2114 | $prev = $version; |
2115 | 2115 | $bits = $this->estimateBitStreamSize($items, $prev); |
2116 | - $version = $this->getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
2117 | - if ($version < 0) { |
|
2116 | + $version = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
2117 | + if ($version<0) { |
|
2118 | 2118 | return -1; |
2119 | 2119 | } |
2120 | - } while ($version > $prev); |
|
2120 | + } while ($version>$prev); |
|
2121 | 2121 | |
2122 | 2122 | return $version; |
2123 | 2123 | } |
@@ -2136,35 +2136,35 @@ discard block |
||
2136 | 2136 | $payload = $bits - 4 - $this->lengthIndicator($mode, $version); |
2137 | 2137 | switch ($mode) { |
2138 | 2138 | case QR_MODE_NM: { |
2139 | - $chunks = (int) ($payload / 10); |
|
2139 | + $chunks = (int)($payload / 10); |
|
2140 | 2140 | $remain = $payload - $chunks * 10; |
2141 | 2141 | $size = $chunks * 3; |
2142 | - if ($remain >= 7) { |
|
2142 | + if ($remain>=7) { |
|
2143 | 2143 | $size += 2; |
2144 | - } elseif ($remain >= 4) { |
|
2144 | + } elseif ($remain>=4) { |
|
2145 | 2145 | $size += 1; |
2146 | 2146 | } |
2147 | 2147 | break; |
2148 | 2148 | } |
2149 | 2149 | case QR_MODE_AN: { |
2150 | - $chunks = (int) ($payload / 11); |
|
2150 | + $chunks = (int)($payload / 11); |
|
2151 | 2151 | $remain = $payload - $chunks * 11; |
2152 | 2152 | $size = $chunks * 2; |
2153 | - if ($remain >= 6) { |
|
2153 | + if ($remain>=6) { |
|
2154 | 2154 | $size++; |
2155 | 2155 | } |
2156 | 2156 | break; |
2157 | 2157 | } |
2158 | 2158 | case QR_MODE_8B: { |
2159 | - $size = (int) ($payload / 8); |
|
2159 | + $size = (int)($payload / 8); |
|
2160 | 2160 | break; |
2161 | 2161 | } |
2162 | 2162 | case QR_MODE_KJ: { |
2163 | - $size = (int) (($payload / 13) * 2); |
|
2163 | + $size = (int)(($payload / 13) * 2); |
|
2164 | 2164 | break; |
2165 | 2165 | } |
2166 | 2166 | case QR_MODE_ST: { |
2167 | - $size = (int) ($payload / 8); |
|
2167 | + $size = (int)($payload / 8); |
|
2168 | 2168 | break; |
2169 | 2169 | } |
2170 | 2170 | default: { |
@@ -2173,10 +2173,10 @@ discard block |
||
2173 | 2173 | } |
2174 | 2174 | } |
2175 | 2175 | $maxsize = $this->maximumWords($mode, $version); |
2176 | - if ($size < 0) { |
|
2176 | + if ($size<0) { |
|
2177 | 2177 | $size = 0; |
2178 | 2178 | } |
2179 | - if ($size > $maxsize) { |
|
2179 | + if ($size>$maxsize) { |
|
2180 | 2180 | $size = $maxsize; |
2181 | 2181 | } |
2182 | 2182 | |
@@ -2212,20 +2212,20 @@ discard block |
||
2212 | 2212 | protected function convertData($items) |
2213 | 2213 | { |
2214 | 2214 | $ver = $this->estimateVersion($items); |
2215 | - if ($ver > $this->version) { |
|
2215 | + if ($ver>$this->version) { |
|
2216 | 2216 | $this->version = $ver; |
2217 | 2217 | } |
2218 | - for (; ;) { |
|
2218 | + for (;;) { |
|
2219 | 2219 | $cbs = $this->createBitStream($items); |
2220 | 2220 | $items = $cbs[0]; |
2221 | 2221 | $bits = $cbs[1]; |
2222 | - if ($bits < 0) { |
|
2222 | + if ($bits<0) { |
|
2223 | 2223 | return -1; |
2224 | 2224 | } |
2225 | - $ver = $this->getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
2226 | - if ($ver < 0) { |
|
2225 | + $ver = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
2226 | + if ($ver<0) { |
|
2227 | 2227 | return -1; |
2228 | - } elseif ($ver > $this->version) { |
|
2228 | + } elseif ($ver>$this->version) { |
|
2229 | 2229 | $this->version = $ver; |
2230 | 2230 | } else { |
2231 | 2231 | break; |
@@ -2247,20 +2247,20 @@ discard block |
||
2247 | 2247 | $bits = count($bstream); |
2248 | 2248 | $maxwords = $this->getDataLength($this->version, $this->level); |
2249 | 2249 | $maxbits = $maxwords * 8; |
2250 | - if ($maxbits == $bits) { |
|
2250 | + if ($maxbits==$bits) { |
|
2251 | 2251 | return 0; |
2252 | 2252 | } |
2253 | - if ($maxbits - $bits < 5) { |
|
2253 | + if ($maxbits - $bits<5) { |
|
2254 | 2254 | return $this->appendNum($bstream, $maxbits - $bits, 0); |
2255 | 2255 | } |
2256 | 2256 | $bits += 4; |
2257 | - $words = (int) (($bits + 7) / 8); |
|
2257 | + $words = (int)(($bits + 7) / 8); |
|
2258 | 2258 | $padding = []; |
2259 | 2259 | $padding = $this->appendNum($padding, $words * 8 - $bits + 4, 0); |
2260 | 2260 | $padlen = $maxwords - $words; |
2261 | - if ($padlen > 0) { |
|
2261 | + if ($padlen>0) { |
|
2262 | 2262 | $padbuf = []; |
2263 | - for ($i = 0; $i < $padlen; $i++) { |
|
2263 | + for ($i = 0; $i<$padlen; $i++) { |
|
2264 | 2264 | $padbuf[$i] = ($i & 1) ? 0x11 : 0xec; |
2265 | 2265 | } |
2266 | 2266 | $padding = $this->appendBytes($padding, $padlen, $padbuf); |
@@ -2343,7 +2343,7 @@ discard block |
||
2343 | 2343 | { |
2344 | 2344 | $bstream = $this->allocate($bits); |
2345 | 2345 | $mask = 1 << ($bits - 1); |
2346 | - for ($i = 0; $i < $bits; $i++) { |
|
2346 | + for ($i = 0; $i<$bits; $i++) { |
|
2347 | 2347 | if ($num & $mask) { |
2348 | 2348 | $bstream[$i] = 1; |
2349 | 2349 | } else { |
@@ -2367,9 +2367,9 @@ discard block |
||
2367 | 2367 | { |
2368 | 2368 | $bstream = $this->allocate($size * 8); |
2369 | 2369 | $p = 0; |
2370 | - for ($i = 0; $i < $size; $i++) { |
|
2370 | + for ($i = 0; $i<$size; $i++) { |
|
2371 | 2371 | $mask = 0x80; |
2372 | - for ($j = 0; $j < 8; $j++) { |
|
2372 | + for ($j = 0; $j<8; $j++) { |
|
2373 | 2373 | if ($data[$i] & $mask) { |
2374 | 2374 | $bstream[$p] = 1; |
2375 | 2375 | } else { |
@@ -2393,10 +2393,10 @@ discard block |
||
2393 | 2393 | */ |
2394 | 2394 | protected function appendBitstream($bitstream, $append) |
2395 | 2395 | { |
2396 | - if ((!is_array($append)) or (count($append) == 0)) { |
|
2396 | + if ((!is_array($append)) or (count($append)==0)) { |
|
2397 | 2397 | return $bitstream; |
2398 | 2398 | } |
2399 | - if (count($bitstream) == 0) { |
|
2399 | + if (count($bitstream)==0) { |
|
2400 | 2400 | return $append; |
2401 | 2401 | } |
2402 | 2402 | |
@@ -2414,7 +2414,7 @@ discard block |
||
2414 | 2414 | */ |
2415 | 2415 | protected function appendNum($bitstream, $bits, $num) |
2416 | 2416 | { |
2417 | - if ($bits == 0) { |
|
2417 | + if ($bits==0) { |
|
2418 | 2418 | return 0; |
2419 | 2419 | } |
2420 | 2420 | $b = $this->newFromNum($bits, $num); |
@@ -2433,7 +2433,7 @@ discard block |
||
2433 | 2433 | */ |
2434 | 2434 | protected function appendBytes($bitstream, $size, $data) |
2435 | 2435 | { |
2436 | - if ($size == 0) { |
|
2436 | + if ($size==0) { |
|
2437 | 2437 | return 0; |
2438 | 2438 | } |
2439 | 2439 | $b = $this->newFromBytes($size, $data); |
@@ -2451,15 +2451,15 @@ discard block |
||
2451 | 2451 | protected function bitstreamToByte($bstream) |
2452 | 2452 | { |
2453 | 2453 | $size = count($bstream); |
2454 | - if ($size == 0) { |
|
2454 | + if ($size==0) { |
|
2455 | 2455 | return []; |
2456 | 2456 | } |
2457 | - $data = array_fill(0, (int) (($size + 7) / 8), 0); |
|
2458 | - $bytes = (int) ($size / 8); |
|
2457 | + $data = array_fill(0, (int)(($size + 7) / 8), 0); |
|
2458 | + $bytes = (int)($size / 8); |
|
2459 | 2459 | $p = 0; |
2460 | - for ($i = 0; $i < $bytes; $i++) { |
|
2460 | + for ($i = 0; $i<$bytes; $i++) { |
|
2461 | 2461 | $v = 0; |
2462 | - for ($j = 0; $j < 8; $j++) { |
|
2462 | + for ($j = 0; $j<8; $j++) { |
|
2463 | 2463 | $v = $v << 1; |
2464 | 2464 | $v |= $bstream[$p]; |
2465 | 2465 | $p++; |
@@ -2468,7 +2468,7 @@ discard block |
||
2468 | 2468 | } |
2469 | 2469 | if ($size & 7) { |
2470 | 2470 | $v = 0; |
2471 | - for ($j = 0; $j < ($size & 7); $j++) { |
|
2471 | + for ($j = 0; $j<($size & 7); $j++) { |
|
2472 | 2472 | $v = $v << 1; |
2473 | 2473 | $v |= $bstream[$p]; |
2474 | 2474 | $p++; |
@@ -2496,7 +2496,7 @@ discard block |
||
2496 | 2496 | */ |
2497 | 2497 | protected function qrstrset($srctab, $x, $y, $repl, $replLen = false) |
2498 | 2498 | { |
2499 | - $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false) ? substr($repl, 0, $replLen) : $repl, $x, ($replLen !== false) ? $replLen : strlen($repl)); |
|
2499 | + $srctab[$y] = substr_replace($srctab[$y], ($replLen!==false) ? substr($repl, 0, $replLen) : $repl, $x, ($replLen!==false) ? $replLen : strlen($repl)); |
|
2500 | 2500 | |
2501 | 2501 | return $srctab; |
2502 | 2502 | } |
@@ -2561,9 +2561,9 @@ discard block |
||
2561 | 2561 | */ |
2562 | 2562 | protected function getMinimumVersion($size, $level) |
2563 | 2563 | { |
2564 | - for ($i = 1; $i <= QRSPEC_VERSION_MAX; $i++) { |
|
2564 | + for ($i = 1; $i<=QRSPEC_VERSION_MAX; $i++) { |
|
2565 | 2565 | $words = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level]; |
2566 | - if ($words >= $size) { |
|
2566 | + if ($words>=$size) { |
|
2567 | 2567 | return $i; |
2568 | 2568 | } |
2569 | 2569 | } |
@@ -2581,12 +2581,12 @@ discard block |
||
2581 | 2581 | */ |
2582 | 2582 | protected function lengthIndicator($mode, $version) |
2583 | 2583 | { |
2584 | - if ($mode == QR_MODE_ST) { |
|
2584 | + if ($mode==QR_MODE_ST) { |
|
2585 | 2585 | return 0; |
2586 | 2586 | } |
2587 | - if ($version <= 9) { |
|
2587 | + if ($version<=9) { |
|
2588 | 2588 | $l = 0; |
2589 | - } elseif ($version <= 26) { |
|
2589 | + } elseif ($version<=26) { |
|
2590 | 2590 | $l = 1; |
2591 | 2591 | } else { |
2592 | 2592 | $l = 2; |
@@ -2605,19 +2605,19 @@ discard block |
||
2605 | 2605 | */ |
2606 | 2606 | protected function maximumWords($mode, $version) |
2607 | 2607 | { |
2608 | - if ($mode == QR_MODE_ST) { |
|
2608 | + if ($mode==QR_MODE_ST) { |
|
2609 | 2609 | return 3; |
2610 | 2610 | } |
2611 | - if ($version <= 9) { |
|
2611 | + if ($version<=9) { |
|
2612 | 2612 | $l = 0; |
2613 | - } elseif ($version <= 26) { |
|
2613 | + } elseif ($version<=26) { |
|
2614 | 2614 | $l = 1; |
2615 | 2615 | } else { |
2616 | 2616 | $l = 2; |
2617 | 2617 | } |
2618 | 2618 | $bits = $this->lengthTableBits[$mode][$l]; |
2619 | 2619 | $words = (1 << $bits) - 1; |
2620 | - if ($mode == QR_MODE_KJ) { |
|
2620 | + if ($mode==QR_MODE_KJ) { |
|
2621 | 2621 | $words *= 2; // the number of bytes is required |
2622 | 2622 | } |
2623 | 2623 | |
@@ -2635,23 +2635,23 @@ discard block |
||
2635 | 2635 | */ |
2636 | 2636 | protected function getEccSpec($version, $level, $spec) |
2637 | 2637 | { |
2638 | - if (count($spec) < 5) { |
|
2638 | + if (count($spec)<5) { |
|
2639 | 2639 | $spec = [0, 0, 0, 0, 0]; |
2640 | 2640 | } |
2641 | 2641 | $b1 = $this->eccTable[$version][$level][0]; |
2642 | 2642 | $b2 = $this->eccTable[$version][$level][1]; |
2643 | 2643 | $data = $this->getDataLength($version, $level); |
2644 | 2644 | $ecc = $this->getECCLength($version, $level); |
2645 | - if ($b2 == 0) { |
|
2645 | + if ($b2==0) { |
|
2646 | 2646 | $spec[0] = $b1; |
2647 | - $spec[1] = (int) ($data / $b1); |
|
2648 | - $spec[2] = (int) ($ecc / $b1); |
|
2647 | + $spec[1] = (int)($data / $b1); |
|
2648 | + $spec[2] = (int)($ecc / $b1); |
|
2649 | 2649 | $spec[3] = 0; |
2650 | 2650 | $spec[4] = 0; |
2651 | 2651 | } else { |
2652 | 2652 | $spec[0] = $b1; |
2653 | - $spec[1] = (int) ($data / ($b1 + $b2)); |
|
2654 | - $spec[2] = (int) ($ecc / ($b1 + $b2)); |
|
2653 | + $spec[1] = (int)($data / ($b1 + $b2)); |
|
2654 | + $spec[2] = (int)($ecc / ($b1 + $b2)); |
|
2655 | 2655 | $spec[3] = $b2; |
2656 | 2656 | $spec[4] = $spec[1] + 1; |
2657 | 2657 | } |
@@ -2680,7 +2680,7 @@ discard block |
||
2680 | 2680 | ]; |
2681 | 2681 | $yStart = $oy - 2; |
2682 | 2682 | $xStart = $ox - 2; |
2683 | - for ($y = 0; $y < 5; $y++) { |
|
2683 | + for ($y = 0; $y<5; $y++) { |
|
2684 | 2684 | $frame = $this->qrstrset($frame, $xStart, $yStart + $y, $finder[$y]); |
2685 | 2685 | } |
2686 | 2686 | |
@@ -2698,16 +2698,16 @@ discard block |
||
2698 | 2698 | */ |
2699 | 2699 | protected function putAlignmentPattern($version, $frame, $width) |
2700 | 2700 | { |
2701 | - if ($version < 2) { |
|
2701 | + if ($version<2) { |
|
2702 | 2702 | return $frame; |
2703 | 2703 | } |
2704 | 2704 | $d = $this->alignmentPattern[$version][1] - $this->alignmentPattern[$version][0]; |
2705 | - if ($d < 0) { |
|
2705 | + if ($d<0) { |
|
2706 | 2706 | $w = 2; |
2707 | 2707 | } else { |
2708 | - $w = (int) (($width - $this->alignmentPattern[$version][0]) / $d + 2); |
|
2708 | + $w = (int)(($width - $this->alignmentPattern[$version][0]) / $d + 2); |
|
2709 | 2709 | } |
2710 | - if ($w * $w - 3 == 1) { |
|
2710 | + if ($w * $w - 3==1) { |
|
2711 | 2711 | $x = $this->alignmentPattern[$version][0]; |
2712 | 2712 | $y = $this->alignmentPattern[$version][0]; |
2713 | 2713 | $frame = $this->putAlignmentMarker($frame, $x, $y); |
@@ -2716,15 +2716,15 @@ discard block |
||
2716 | 2716 | } |
2717 | 2717 | $cx = $this->alignmentPattern[$version][0]; |
2718 | 2718 | $wo = $w - 1; |
2719 | - for ($x = 1; $x < $wo; $x++) { |
|
2719 | + for ($x = 1; $x<$wo; $x++) { |
|
2720 | 2720 | $frame = $this->putAlignmentMarker($frame, 6, $cx); |
2721 | 2721 | $frame = $this->putAlignmentMarker($frame, $cx, 6); |
2722 | 2722 | $cx += $d; |
2723 | 2723 | } |
2724 | 2724 | $cy = $this->alignmentPattern[$version][0]; |
2725 | - for ($y = 0; $y < $wo; $y++) { |
|
2725 | + for ($y = 0; $y<$wo; $y++) { |
|
2726 | 2726 | $cx = $this->alignmentPattern[$version][0]; |
2727 | - for ($x = 0; $x < $wo; $x++) { |
|
2727 | + for ($x = 0; $x<$wo; $x++) { |
|
2728 | 2728 | $frame = $this->putAlignmentMarker($frame, $cx, $cy); |
2729 | 2729 | $cx += $d; |
2730 | 2730 | } |
@@ -2743,7 +2743,7 @@ discard block |
||
2743 | 2743 | */ |
2744 | 2744 | protected function getVersionPattern($version) |
2745 | 2745 | { |
2746 | - if (($version < 7) or ($version > QRSPEC_VERSION_MAX)) { |
|
2746 | + if (($version<7) or ($version>QRSPEC_VERSION_MAX)) { |
|
2747 | 2747 | return 0; |
2748 | 2748 | } |
2749 | 2749 | |
@@ -2760,10 +2760,10 @@ discard block |
||
2760 | 2760 | */ |
2761 | 2761 | protected function getFormatInfo($mask, $level) |
2762 | 2762 | { |
2763 | - if (($mask < 0) or ($mask > 7)) { |
|
2763 | + if (($mask<0) or ($mask>7)) { |
|
2764 | 2764 | return 0; |
2765 | 2765 | } |
2766 | - if (($level < 0) or ($level > 3)) { |
|
2766 | + if (($level<0) or ($level>3)) { |
|
2767 | 2767 | return 0; |
2768 | 2768 | } |
2769 | 2769 | |
@@ -2791,7 +2791,7 @@ discard block |
||
2791 | 2791 | "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", |
2792 | 2792 | "\xc1\xc1\xc1\xc1\xc1\xc1\xc1", |
2793 | 2793 | ]; |
2794 | - for ($y = 0; $y < 7; $y++) { |
|
2794 | + for ($y = 0; $y<7; $y++) { |
|
2795 | 2795 | $frame = $this->qrstrset($frame, $ox, ($oy + $y), $finder[$y]); |
2796 | 2796 | } |
2797 | 2797 | |
@@ -2816,7 +2816,7 @@ discard block |
||
2816 | 2816 | $frame = $this->putFinderPattern($frame, 0, $width - 7); |
2817 | 2817 | // Separator |
2818 | 2818 | $yOffset = $width - 7; |
2819 | - for ($y = 0; $y < 7; $y++) { |
|
2819 | + for ($y = 0; $y<7; $y++) { |
|
2820 | 2820 | $frame[$y][7] = "\xc0"; |
2821 | 2821 | $frame[$y][$width - 8] = "\xc0"; |
2822 | 2822 | $frame[$yOffset][7] = "\xc0"; |
@@ -2831,31 +2831,31 @@ discard block |
||
2831 | 2831 | $frame = $this->qrstrset($frame, 0, 8, $setPattern); |
2832 | 2832 | $frame = $this->qrstrset($frame, $width - 8, 8, $setPattern, 8); |
2833 | 2833 | $yOffset = $width - 8; |
2834 | - for ($y = 0; $y < 8; ++$y, ++$yOffset) { |
|
2834 | + for ($y = 0; $y<8; ++$y, ++$yOffset) { |
|
2835 | 2835 | $frame[$y][8] = "\x84"; |
2836 | 2836 | $frame[$yOffset][8] = "\x84"; |
2837 | 2837 | } |
2838 | 2838 | // Timing pattern |
2839 | 2839 | $wo = $width - 15; |
2840 | - for ($i = 1; $i < $wo; $i++) { |
|
2840 | + for ($i = 1; $i<$wo; $i++) { |
|
2841 | 2841 | $frame[6][7 + $i] = chr(0x90 | ($i & 1)); |
2842 | 2842 | $frame[7 + $i][6] = chr(0x90 | ($i & 1)); |
2843 | 2843 | } |
2844 | 2844 | // Alignment pattern |
2845 | 2845 | $frame = $this->putAlignmentPattern($version, $frame, $width); |
2846 | 2846 | // Version information |
2847 | - if ($version >= 7) { |
|
2847 | + if ($version>=7) { |
|
2848 | 2848 | $vinf = $this->getVersionPattern($version); |
2849 | 2849 | $v = $vinf; |
2850 | - for ($x = 0; $x < 6; $x++) { |
|
2851 | - for ($y = 0; $y < 3; $y++) { |
|
2850 | + for ($x = 0; $x<6; $x++) { |
|
2851 | + for ($y = 0; $y<3; $y++) { |
|
2852 | 2852 | $frame[($width - 11) + $y][$x] = chr(0x88 | ($v & 1)); |
2853 | 2853 | $v = $v >> 1; |
2854 | 2854 | } |
2855 | 2855 | } |
2856 | 2856 | $v = $vinf; |
2857 | - for ($y = 0; $y < 6; $y++) { |
|
2858 | - for ($x = 0; $x < 3; $x++) { |
|
2857 | + for ($y = 0; $y<6; $y++) { |
|
2858 | + for ($x = 0; $x<3; $x++) { |
|
2859 | 2859 | $frame[$y][$x + ($width - 11)] = chr(0x88 | ($v & 1)); |
2860 | 2860 | $v = $v >> 1; |
2861 | 2861 | } |
@@ -2876,7 +2876,7 @@ discard block |
||
2876 | 2876 | */ |
2877 | 2877 | protected function newFrame($version) |
2878 | 2878 | { |
2879 | - if (($version < 1) or ($version > QRSPEC_VERSION_MAX)) { |
|
2879 | + if (($version<1) or ($version>QRSPEC_VERSION_MAX)) { |
|
2880 | 2880 | return; |
2881 | 2881 | } |
2882 | 2882 | if (!isset($this->frames[$version])) { |
@@ -3016,8 +3016,8 @@ discard block |
||
3016 | 3016 | protected function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
3017 | 3017 | { |
3018 | 3018 | foreach ($this->rsitems as $rs) { |
3019 | - if (($rs['pad'] != $pad) or ($rs['nroots'] != $nroots) or ($rs['mm'] != $symsize) |
|
3020 | - or ($rs['gfpoly'] != $gfpoly) or ($rs['fcr'] != $fcr) or ($rs['prim'] != $prim)) { |
|
3019 | + if (($rs['pad']!=$pad) or ($rs['nroots']!=$nroots) or ($rs['mm']!=$symsize) |
|
3020 | + or ($rs['gfpoly']!=$gfpoly) or ($rs['fcr']!=$fcr) or ($rs['prim']!=$prim)) { |
|
3021 | 3021 | continue; |
3022 | 3022 | } |
3023 | 3023 | |
@@ -3043,7 +3043,7 @@ discard block |
||
3043 | 3043 | */ |
3044 | 3044 | protected function modnn($rs, $x) |
3045 | 3045 | { |
3046 | - while ($x >= $rs['nn']) { |
|
3046 | + while ($x>=$rs['nn']) { |
|
3047 | 3047 | $x -= $rs['nn']; |
3048 | 3048 | $x = ($x >> $rs['mm']) + ($x & $rs['nn']); |
3049 | 3049 | } |
@@ -3068,19 +3068,19 @@ discard block |
||
3068 | 3068 | // Based on Reed solomon encoder by Phil Karn, KA9Q (GNU-LGPLv2) |
3069 | 3069 | $rs = null; |
3070 | 3070 | // Check parameter ranges |
3071 | - if (($symsize < 0) or ($symsize > 8)) { |
|
3071 | + if (($symsize<0) or ($symsize>8)) { |
|
3072 | 3072 | return $rs; |
3073 | 3073 | } |
3074 | - if (($fcr < 0) or ($fcr >= (1 << $symsize))) { |
|
3074 | + if (($fcr<0) or ($fcr>=(1 << $symsize))) { |
|
3075 | 3075 | return $rs; |
3076 | 3076 | } |
3077 | - if (($prim <= 0) or ($prim >= (1 << $symsize))) { |
|
3077 | + if (($prim<=0) or ($prim>=(1 << $symsize))) { |
|
3078 | 3078 | return $rs; |
3079 | 3079 | } |
3080 | - if (($nroots < 0) or ($nroots >= (1 << $symsize))) { |
|
3080 | + if (($nroots<0) or ($nroots>=(1 << $symsize))) { |
|
3081 | 3081 | return $rs; |
3082 | 3082 | } |
3083 | - if (($pad < 0) or ($pad >= ((1 << $symsize) - 1 - $nroots))) { |
|
3083 | + if (($pad<0) or ($pad>=((1 << $symsize) - 1 - $nroots))) { |
|
3084 | 3084 | return $rs; |
3085 | 3085 | } |
3086 | 3086 | $rs = []; |
@@ -3096,7 +3096,7 @@ discard block |
||
3096 | 3096 | $rs['index_of'][0] = $A0; // log(zero) = -inf |
3097 | 3097 | $rs['alpha_to'][$A0] = 0; // alpha**-inf = 0 |
3098 | 3098 | $sr = 1; |
3099 | - for ($i = 0; $i < $rs['nn']; $i++) { |
|
3099 | + for ($i = 0; $i<$rs['nn']; $i++) { |
|
3100 | 3100 | $rs['index_of'][$sr] = $i; |
3101 | 3101 | $rs['alpha_to'][$i] = $sr; |
3102 | 3102 | $sr <<= 1; |
@@ -3105,7 +3105,7 @@ discard block |
||
3105 | 3105 | } |
3106 | 3106 | $sr &= $rs['nn']; |
3107 | 3107 | } |
3108 | - if ($sr != 1) { |
|
3108 | + if ($sr!=1) { |
|
3109 | 3109 | // field generator polynomial is not primitive! |
3110 | 3110 | return; |
3111 | 3111 | } |
@@ -3116,17 +3116,17 @@ discard block |
||
3116 | 3116 | $rs['nroots'] = $nroots; |
3117 | 3117 | $rs['gfpoly'] = $gfpoly; |
3118 | 3118 | // Find prim-th root of 1, used in decoding |
3119 | - for ($iprim = 1; ($iprim % $prim) != 0; $iprim += $rs['nn']) { |
|
3119 | + for ($iprim = 1; ($iprim % $prim)!=0; $iprim += $rs['nn']) { |
|
3120 | 3120 | // intentional empty-body loop! |
3121 | 3121 | } |
3122 | - $rs['iprim'] = (int) ($iprim / $prim); |
|
3122 | + $rs['iprim'] = (int)($iprim / $prim); |
|
3123 | 3123 | $rs['genpoly'][0] = 1; |
3124 | 3124 | |
3125 | - for ($i = 0, $root = $fcr * $prim; $i < $nroots; $i++, $root += $prim) { |
|
3125 | + for ($i = 0, $root = $fcr * $prim; $i<$nroots; $i++, $root += $prim) { |
|
3126 | 3126 | $rs['genpoly'][$i + 1] = 1; |
3127 | 3127 | // Multiply rs->genpoly[] by @**(root + x) |
3128 | - for ($j = $i; $j > 0; $j--) { |
|
3129 | - if ($rs['genpoly'][$j] != 0) { |
|
3128 | + for ($j = $i; $j>0; $j--) { |
|
3129 | + if ($rs['genpoly'][$j]!=0) { |
|
3130 | 3130 | $rs['genpoly'][$j] = $rs['genpoly'][$j - 1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)]; |
3131 | 3131 | } else { |
3132 | 3132 | $rs['genpoly'][$j] = $rs['genpoly'][$j - 1]; |
@@ -3136,7 +3136,7 @@ discard block |
||
3136 | 3136 | $rs['genpoly'][0] = $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][0]] + $root)]; |
3137 | 3137 | } |
3138 | 3138 | // convert rs->genpoly[] to index form for quicker encoding |
3139 | - for ($i = 0; $i <= $nroots; $i++) { |
|
3139 | + for ($i = 0; $i<=$nroots; $i++) { |
|
3140 | 3140 | $rs['genpoly'][$i] = $rs['index_of'][$rs['genpoly'][$i]]; |
3141 | 3141 | } |
3142 | 3142 | |
@@ -3166,20 +3166,20 @@ discard block |
||
3166 | 3166 | $PAD = &$rs['pad']; // the number of pad symbols in a block |
3167 | 3167 | $A0 = &$NN; |
3168 | 3168 | $parity = array_fill(0, $NROOTS, 0); |
3169 | - for ($i = 0; $i < ($NN - $NROOTS - $PAD); $i++) { |
|
3169 | + for ($i = 0; $i<($NN - $NROOTS - $PAD); $i++) { |
|
3170 | 3170 | $feedback = $INDEX_OF[$data[$i] ^ $parity[0]]; |
3171 | - if ($feedback != $A0) { |
|
3171 | + if ($feedback!=$A0) { |
|
3172 | 3172 | // feedback term is non-zero |
3173 | 3173 | // This line is unnecessary when GENPOLY[NROOTS] is unity, as it must |
3174 | 3174 | // always be for the polynomials constructed by init_rs() |
3175 | 3175 | $feedback = $this->modnn($rs, $NN - $GENPOLY[$NROOTS] + $feedback); |
3176 | - for ($j = 1; $j < $NROOTS; $j++) { |
|
3176 | + for ($j = 1; $j<$NROOTS; $j++) { |
|
3177 | 3177 | $parity[$j] ^= $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[($NROOTS - $j)])]; |
3178 | 3178 | } |
3179 | 3179 | } |
3180 | 3180 | // Shift |
3181 | 3181 | array_shift($parity); |
3182 | - if ($feedback != $A0) { |
|
3182 | + if ($feedback!=$A0) { |
|
3183 | 3183 | array_push($parity, $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[0])]); |
3184 | 3184 | } else { |
3185 | 3185 | array_push($parity, 0); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | $setData = array_slice($data, 0, $size); |
41 | 41 | |
42 | - if (count($setData) < $size) { |
|
42 | + if (count($setData)<$size) { |
|
43 | 43 | $setData = array_merge($setData, array_fill(0, $size - count($setData), 0)); |
44 | 44 | } |
45 | 45 | |
@@ -58,24 +58,24 @@ discard block |
||
58 | 58 | public function encodeModeNum($version) |
59 | 59 | { |
60 | 60 | try { |
61 | - $words = (int) ($this->size / 3); |
|
61 | + $words = (int)($this->size / 3); |
|
62 | 62 | $bs = new QRbitstream(); |
63 | 63 | |
64 | 64 | $val = 0x1; |
65 | 65 | $bs->appendNum(4, $val); |
66 | 66 | $bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size); |
67 | 67 | |
68 | - for ($i = 0; $i < $words; $i++) { |
|
68 | + for ($i = 0; $i<$words; $i++) { |
|
69 | 69 | $val = (ord($this->data[$i * 3]) - ord('0')) * 100; |
70 | 70 | $val += (ord($this->data[$i * 3 + 1]) - ord('0')) * 10; |
71 | 71 | $val += (ord($this->data[$i * 3 + 2]) - ord('0')); |
72 | 72 | $bs->appendNum(10, $val); |
73 | 73 | } |
74 | 74 | |
75 | - if ($this->size - $words * 3 == 1) { |
|
75 | + if ($this->size - $words * 3==1) { |
|
76 | 76 | $val = ord($this->data[$words * 3]) - ord('0'); |
77 | 77 | $bs->appendNum(4, $val); |
78 | - } elseif ($this->size - $words * 3 == 2) { |
|
78 | + } elseif ($this->size - $words * 3==2) { |
|
79 | 79 | $val = (ord($this->data[$words * 3]) - ord('0')) * 10; |
80 | 80 | $val += (ord($this->data[$words * 3 + 1]) - ord('0')); |
81 | 81 | $bs->appendNum(7, $val); |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | public function encodeModeAn($version) |
94 | 94 | { |
95 | 95 | try { |
96 | - $words = (int) ($this->size / 2); |
|
96 | + $words = (int)($this->size / 2); |
|
97 | 97 | $bs = new QRbitstream(); |
98 | 98 | |
99 | 99 | $bs->appendNum(4, 0x02); |
100 | 100 | $bs->appendNum(QRspec::lengthIndicator(QR_MODE_AN, $version), $this->size); |
101 | 101 | |
102 | - for ($i = 0; $i < $words; $i++) { |
|
103 | - $val = (int) QRinput::lookAnTable(ord($this->data[$i * 2])) * 45; |
|
104 | - $val += (int) QRinput::lookAnTable(ord($this->data[$i * 2 + 1])); |
|
102 | + for ($i = 0; $i<$words; $i++) { |
|
103 | + $val = (int)QRinput::lookAnTable(ord($this->data[$i * 2])) * 45; |
|
104 | + $val += (int)QRinput::lookAnTable(ord($this->data[$i * 2 + 1])); |
|
105 | 105 | |
106 | 106 | $bs->appendNum(11, $val); |
107 | 107 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $bs->appendNum(4, 0x4); |
129 | 129 | $bs->appendNum(QRspec::lengthIndicator(QR_MODE_8, $version), $this->size); |
130 | 130 | |
131 | - for ($i = 0; $i < $this->size; $i++) { |
|
131 | + for ($i = 0; $i<$this->size; $i++) { |
|
132 | 132 | $bs->appendNum(8, ord($this->data[$i])); |
133 | 133 | } |
134 | 134 | |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | $bs = new QRbitrtream(); |
148 | 148 | |
149 | 149 | $bs->appendNum(4, 0x8); |
150 | - $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int) ($this->size / 2)); |
|
150 | + $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int)($this->size / 2)); |
|
151 | 151 | |
152 | - for ($i = 0; $i < $this->size; $i += 2) { |
|
152 | + for ($i = 0; $i<$this->size; $i += 2) { |
|
153 | 153 | $val = (ord($this->data[$i]) << 8) | ord($this->data[$i + 1]); |
154 | - if ($val <= 0x9ffc) { |
|
154 | + if ($val<=0x9ffc) { |
|
155 | 155 | $val -= 0x8140; |
156 | 156 | } else { |
157 | 157 | $val -= 0xc140; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | { |
196 | 196 | $bits = 0; |
197 | 197 | |
198 | - if ($version == 0) { |
|
198 | + if ($version==0) { |
|
199 | 199 | $version = 1; |
200 | 200 | } |
201 | 201 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | |
212 | 212 | $l = QRspec::lengthIndicator($this->mode, $version); |
213 | 213 | $m = 1 << $l; |
214 | - $num = (int) (($this->size + $m - 1) / $m); |
|
214 | + $num = (int)(($this->size + $m - 1) / $m); |
|
215 | 215 | |
216 | 216 | $bits += $num * (4 + $l); |
217 | 217 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | unset($this->bstream); |
226 | 226 | $words = QRspec::maximumWords($this->mode, $version); |
227 | 227 | |
228 | - if ($this->size > $words) { |
|
228 | + if ($this->size>$words) { |
|
229 | 229 | $st1 = new self($this->mode, $words, $this->data); |
230 | 230 | $st2 = new self($this->mode, $this->size - $words, array_slice($this->data, $words)); |
231 | 231 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | break; |
253 | 253 | } |
254 | 254 | |
255 | - if ($ret < 0) { |
|
255 | + if ($ret<0) { |
|
256 | 256 | return -1; |
257 | 257 | } |
258 | 258 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | //---------------------------------------------------------------------- |
277 | 277 | public function __construct($version = 0, $level = QR_ECLEVEL_L) |
278 | 278 | { |
279 | - if ($version < 0 || $version > QRSPEC_VERSION_MAX || $level > QR_ECLEVEL_H) { |
|
279 | + if ($version<0 || $version>QRSPEC_VERSION_MAX || $level>QR_ECLEVEL_H) { |
|
280 | 280 | throw new Exception('Invalid version no'); |
281 | 281 | return; |
282 | 282 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | //---------------------------------------------------------------------- |
295 | 295 | public function setVersion($version) |
296 | 296 | { |
297 | - if ($version < 0 || $version > QRSPEC_VERSION_MAX) { |
|
297 | + if ($version<0 || $version>QRSPEC_VERSION_MAX) { |
|
298 | 298 | throw new Exception('Invalid version no'); |
299 | 299 | return -1; |
300 | 300 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | //---------------------------------------------------------------------- |
314 | 314 | public function setErrorCorrectionLevel($level) |
315 | 315 | { |
316 | - if ($level > QR_ECLEVEL_H) { |
|
316 | + if ($level>QR_ECLEVEL_H) { |
|
317 | 317 | throw new Exception('Invalid ECLEVEL'); |
318 | 318 | return -1; |
319 | 319 | } |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | |
347 | 347 | public function insertStructuredAppendHeader($size, $index, $parity) |
348 | 348 | { |
349 | - if ($size > MAX_STRUCTURED_SYMBOLS) { |
|
349 | + if ($size>MAX_STRUCTURED_SYMBOLS) { |
|
350 | 350 | throw new Exception('insertStructuredAppendHeader wrong size'); |
351 | 351 | } |
352 | 352 | |
353 | - if ($index <= 0 || $index > MAX_STRUCTURED_SYMBOLS) { |
|
353 | + if ($index<=0 || $index>MAX_STRUCTURED_SYMBOLS) { |
|
354 | 354 | throw new Exception('insertStructuredAppendHeader wrong index'); |
355 | 355 | } |
356 | 356 | |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | $parity = 0; |
373 | 373 | |
374 | 374 | foreach ($this->items as $item) { |
375 | - if ($item->mode != QR_MODE_STRUCTURE) { |
|
376 | - for ($i = $item->size - 1; $i >= 0; $i--) { |
|
375 | + if ($item->mode!=QR_MODE_STRUCTURE) { |
|
376 | + for ($i = $item->size - 1; $i>=0; $i--) { |
|
377 | 377 | $parity ^= $item->data[$i]; |
378 | 378 | } |
379 | 379 | } |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | //---------------------------------------------------------------------- |
386 | 386 | public static function checkModeNum($size, $data) |
387 | 387 | { |
388 | - for ($i = 0; $i < $size; $i++) { |
|
389 | - if ((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))) { |
|
388 | + for ($i = 0; $i<$size; $i++) { |
|
389 | + if ((ord($data[$i])<ord('0')) || (ord($data[$i])>ord('9'))) { |
|
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | } |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | //---------------------------------------------------------------------- |
398 | 398 | public static function estimateBitsModeNum($size) |
399 | 399 | { |
400 | - $w = (int) $size / 3; |
|
400 | + $w = (int)$size / 3; |
|
401 | 401 | $bits = $w * 10; |
402 | 402 | |
403 | 403 | switch ($size - $w * 3) { |
@@ -429,14 +429,14 @@ discard block |
||
429 | 429 | //---------------------------------------------------------------------- |
430 | 430 | public static function lookAnTable($c) |
431 | 431 | { |
432 | - return ($c > 127) ? -1 : self::$anTable[$c]; |
|
432 | + return ($c>127) ? -1 : self::$anTable[$c]; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | //---------------------------------------------------------------------- |
436 | 436 | public static function checkModeAn($size, $data) |
437 | 437 | { |
438 | - for ($i = 0; $i < $size; $i++) { |
|
439 | - if (self::lookAnTable(ord($data[$i])) == -1) { |
|
438 | + for ($i = 0; $i<$size; $i++) { |
|
439 | + if (self::lookAnTable(ord($data[$i]))==-1) { |
|
440 | 440 | return false; |
441 | 441 | } |
442 | 442 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | //---------------------------------------------------------------------- |
448 | 448 | public static function estimateBitsModeAn($size) |
449 | 449 | { |
450 | - $w = (int) ($size / 2); |
|
450 | + $w = (int)($size / 2); |
|
451 | 451 | $bits = $w * 11; |
452 | 452 | |
453 | 453 | if ($size & 1) { |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | //---------------------------------------------------------------------- |
467 | 467 | public function estimateBitsModeKanji($size) |
468 | 468 | { |
469 | - return (int) (($size / 2) * 13); |
|
469 | + return (int)(($size / 2) * 13); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | //---------------------------------------------------------------------- |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | return false; |
477 | 477 | } |
478 | 478 | |
479 | - for ($i = 0; $i < $size; $i += 2) { |
|
479 | + for ($i = 0; $i<$size; $i += 2) { |
|
480 | 480 | $val = (ord($data[$i]) << 8) | ord($data[$i + 1]); |
481 | - if ($val < 0x8140 |
|
482 | - || ($val > 0x9ffc && $val < 0xe040) |
|
483 | - || $val > 0xebbf) { |
|
481 | + if ($val<0x8140 |
|
482 | + || ($val>0x9ffc && $val<0xe040) |
|
483 | + || $val>0xebbf) { |
|
484 | 484 | return false; |
485 | 485 | } |
486 | 486 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | public static function check($mode, $size, $data) |
496 | 496 | { |
497 | - if ($size <= 0) { |
|
497 | + if ($size<=0) { |
|
498 | 498 | return false; |
499 | 499 | } |
500 | 500 | |
@@ -532,11 +532,11 @@ discard block |
||
532 | 532 | do { |
533 | 533 | $prev = $version; |
534 | 534 | $bits = $this->estimateBitStreamSize($prev); |
535 | - $version = QRspec::getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
536 | - if ($version < 0) { |
|
535 | + $version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
536 | + if ($version<0) { |
|
537 | 537 | return -1; |
538 | 538 | } |
539 | - } while ($version > $prev); |
|
539 | + } while ($version>$prev); |
|
540 | 540 | |
541 | 541 | return $version; |
542 | 542 | } |
@@ -547,31 +547,31 @@ discard block |
||
547 | 547 | $payload = $bits - 4 - QRspec::lengthIndicator($mode, $version); |
548 | 548 | switch ($mode) { |
549 | 549 | case QR_MODE_NUM: |
550 | - $chunks = (int) ($payload / 10); |
|
550 | + $chunks = (int)($payload / 10); |
|
551 | 551 | $remain = $payload - $chunks * 10; |
552 | 552 | $size = $chunks * 3; |
553 | - if ($remain >= 7) { |
|
553 | + if ($remain>=7) { |
|
554 | 554 | $size += 2; |
555 | - } elseif ($remain >= 4) { |
|
555 | + } elseif ($remain>=4) { |
|
556 | 556 | $size += 1; |
557 | 557 | } |
558 | 558 | break; |
559 | 559 | case QR_MODE_AN: |
560 | - $chunks = (int) ($payload / 11); |
|
560 | + $chunks = (int)($payload / 11); |
|
561 | 561 | $remain = $payload - $chunks * 11; |
562 | 562 | $size = $chunks * 2; |
563 | - if ($remain >= 6) { |
|
563 | + if ($remain>=6) { |
|
564 | 564 | $size++; |
565 | 565 | } |
566 | 566 | break; |
567 | 567 | case QR_MODE_8: |
568 | - $size = (int) ($payload / 8); |
|
568 | + $size = (int)($payload / 8); |
|
569 | 569 | break; |
570 | 570 | case QR_MODE_KANJI: |
571 | - $size = (int) (($payload / 13) * 2); |
|
571 | + $size = (int)(($payload / 13) * 2); |
|
572 | 572 | break; |
573 | 573 | case QR_MODE_STRUCTURE: |
574 | - $size = (int) ($payload / 8); |
|
574 | + $size = (int)($payload / 8); |
|
575 | 575 | break; |
576 | 576 | default: |
577 | 577 | $size = 0; |
@@ -579,10 +579,10 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | $maxsize = QRspec::maximumWords($mode, $version); |
582 | - if ($size < 0) { |
|
582 | + if ($size<0) { |
|
583 | 583 | $size = 0; |
584 | 584 | } |
585 | - if ($size > $maxsize) { |
|
585 | + if ($size>$maxsize) { |
|
586 | 586 | $size = $maxsize; |
587 | 587 | } |
588 | 588 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | foreach ($this->items as $item) { |
598 | 598 | $bits = $item->encodeBitStream($this->version); |
599 | 599 | |
600 | - if ($bits < 0) { |
|
600 | + if ($bits<0) { |
|
601 | 601 | return -1; |
602 | 602 | } |
603 | 603 | |
@@ -611,22 +611,22 @@ discard block |
||
611 | 611 | public function convertData() |
612 | 612 | { |
613 | 613 | $ver = $this->estimateVersion(); |
614 | - if ($ver > $this->getVersion()) { |
|
614 | + if ($ver>$this->getVersion()) { |
|
615 | 615 | $this->setVersion($ver); |
616 | 616 | } |
617 | 617 | |
618 | - for (; ;) { |
|
618 | + for (;;) { |
|
619 | 619 | $bits = $this->createBitStream(); |
620 | 620 | |
621 | - if ($bits < 0) { |
|
621 | + if ($bits<0) { |
|
622 | 622 | return -1; |
623 | 623 | } |
624 | 624 | |
625 | - $ver = QRspec::getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
626 | - if ($ver < 0) { |
|
625 | + $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
626 | + if ($ver<0) { |
|
627 | 627 | throw new Exception('WRONG VERSION'); |
628 | 628 | return -1; |
629 | - } elseif ($ver > $this->getVersion()) { |
|
629 | + } elseif ($ver>$this->getVersion()) { |
|
630 | 630 | $this->setVersion($ver); |
631 | 631 | } else { |
632 | 632 | break; |
@@ -643,35 +643,35 @@ discard block |
||
643 | 643 | $maxwords = QRspec::getDataLength($this->version, $this->level); |
644 | 644 | $maxbits = $maxwords * 8; |
645 | 645 | |
646 | - if ($maxbits == $bits) { |
|
646 | + if ($maxbits==$bits) { |
|
647 | 647 | return 0; |
648 | 648 | } |
649 | 649 | |
650 | - if ($maxbits - $bits < 5) { |
|
650 | + if ($maxbits - $bits<5) { |
|
651 | 651 | return $bstream->appendNum($maxbits - $bits, 0); |
652 | 652 | } |
653 | 653 | |
654 | 654 | $bits += 4; |
655 | - $words = (int) (($bits + 7) / 8); |
|
655 | + $words = (int)(($bits + 7) / 8); |
|
656 | 656 | |
657 | 657 | $padding = new QRbitstream(); |
658 | 658 | $ret = $padding->appendNum($words * 8 - $bits + 4, 0); |
659 | 659 | |
660 | - if ($ret < 0) { |
|
660 | + if ($ret<0) { |
|
661 | 661 | return $ret; |
662 | 662 | } |
663 | 663 | |
664 | 664 | $padlen = $maxwords - $words; |
665 | 665 | |
666 | - if ($padlen > 0) { |
|
666 | + if ($padlen>0) { |
|
667 | 667 | $padbuf = []; |
668 | - for ($i = 0; $i < $padlen; $i++) { |
|
668 | + for ($i = 0; $i<$padlen; $i++) { |
|
669 | 669 | $padbuf[$i] = ($i & 1) ? 0x11 : 0xec; |
670 | 670 | } |
671 | 671 | |
672 | 672 | $ret = $padding->appendBytes($padlen, $padbuf); |
673 | 673 | |
674 | - if ($ret < 0) { |
|
674 | + if ($ret<0) { |
|
675 | 675 | return $ret; |
676 | 676 | } |
677 | 677 | } |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | //---------------------------------------------------------------------- |
685 | 685 | public function mergeBitStream() |
686 | 686 | { |
687 | - if ($this->convertData() < 0) { |
|
687 | + if ($this->convertData()<0) { |
|
688 | 688 | return; |
689 | 689 | } |
690 | 690 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | |
693 | 693 | foreach ($this->items as $item) { |
694 | 694 | $ret = $bstream->append($item->bstream); |
695 | - if ($ret < 0) { |
|
695 | + if ($ret<0) { |
|
696 | 696 | return; |
697 | 697 | } |
698 | 698 | } |
@@ -705,12 +705,12 @@ discard block |
||
705 | 705 | { |
706 | 706 | $bstream = $this->mergeBitStream(); |
707 | 707 | |
708 | - if ($bstream == null) { |
|
708 | + if ($bstream==null) { |
|
709 | 709 | return; |
710 | 710 | } |
711 | 711 | |
712 | 712 | $ret = $this->appendPaddingBit($bstream); |
713 | - if ($ret < 0) { |
|
713 | + if ($ret<0) { |
|
714 | 714 | return; |
715 | 715 | } |
716 | 716 | |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | public function getByteStream() |
722 | 722 | { |
723 | 723 | $bstream = $this->getBitStream(); |
724 | - if ($bstream == null) { |
|
724 | + if ($bstream==null) { |
|
725 | 725 | return; |
726 | 726 | } |
727 | 727 |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | global $char128asc, $char128wid; |
39 | 39 | $w = $char128wid[$sum = 104]; // START symbol |
40 | 40 | $onChar = 1; |
41 | - for ($x = 0; $x < strlen($text); $x++) { // GO THRU TEXT GET LETTERS |
|
42 | - if (!(($pos = strpos($char128asc, $text[$x])) === false)) { // SKIP NOT FOUND CHARS |
|
41 | + for ($x = 0; $x<strlen($text); $x++) { // GO THRU TEXT GET LETTERS |
|
42 | + if (!(($pos = strpos($char128asc, $text[$x]))===false)) { // SKIP NOT FOUND CHARS |
|
43 | 43 | $w .= $char128wid[$pos]; |
44 | 44 | $sum += $onChar++ * $pos; |
45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $w .= $char128wid[$sum % 103].$char128wid[106]; //Check Code, then END |
48 | 48 | //Part 2, Write rows |
49 | 49 | $html = '<table cellpadding=0 cellspacing=0><tr>'; |
50 | - for ($x = 0; $x < strlen($w); $x += 2) { // code 128 widths: black border, then white space |
|
50 | + for ($x = 0; $x<strlen($w); $x += 2) { // code 128 widths: black border, then white space |
|
51 | 51 | $html .= "<td><div class=\"b128\" style=\"border-left-width:{$w[$x]};width:{$w[$x + 1]}\"></div>"; |
52 | 52 | } |
53 | 53 |