@@ -56,15 +56,15 @@ discard block |
||
| 56 | 56 | <?php |
| 57 | 57 | switch ($_GET[act]) { |
| 58 | 58 | |
| 59 | - default: |
|
| 59 | + default: |
|
| 60 | 60 | |
| 61 | - $fdate = date('Y-m-01'); |
|
| 62 | - $ldate = date('Y-m-d'); |
|
| 61 | + $fdate = date('Y-m-01'); |
|
| 62 | + $ldate = date('Y-m-d'); |
|
| 63 | 63 | |
| 64 | - $prd = date('Y-m'); |
|
| 64 | + $prd = date('Y-m'); |
|
| 65 | 65 | |
| 66 | - $userid = $_SESSION['userid']; |
|
| 67 | - ?> |
|
| 66 | + $userid = $_SESSION['userid']; |
|
| 67 | + ?> |
|
| 68 | 68 | |
| 69 | 69 | <div class=""> |
| 70 | 70 | |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | <div class="col-md-9 col-sm-9 col-xs-9 form-group"> |
| 102 | 102 | <select name="jenis_transaksi" class="form-control"> |
| 103 | 103 | <?php |
| 104 | - $query = mysql_query('SELECT * FROM jenis_transaksi ORDER BY id_jenis_transaksi'); |
|
| 105 | - if ($query && mysql_num_rows($query) > 0) { |
|
| 106 | - while ($row = mysql_fetch_object($query)) { |
|
| 107 | - echo '<option value="'.$row->id_jenis_transaksi.'"'; |
|
| 108 | - if ($row->id_jenis_transaksi == '1') { |
|
| 109 | - echo ' selected'; |
|
| 104 | + $query = mysql_query('SELECT * FROM jenis_transaksi ORDER BY id_jenis_transaksi'); |
|
| 105 | + if ($query && mysql_num_rows($query) > 0) { |
|
| 106 | + while ($row = mysql_fetch_object($query)) { |
|
| 107 | + echo '<option value="'.$row->id_jenis_transaksi.'"'; |
|
| 108 | + if ($row->id_jenis_transaksi == '1') { |
|
| 109 | + echo ' selected'; |
|
| 110 | + } |
|
| 111 | + echo '>'.$row->jenis_transaksi.'</option>'; |
|
| 110 | 112 | } |
| 111 | - echo '>'.$row->jenis_transaksi.'</option>'; |
|
| 112 | 113 | } |
| 113 | - } |
|
| 114 | - ?> |
|
| 114 | + ?> |
|
| 115 | 115 | </select> |
| 116 | 116 | </div> |
| 117 | 117 | |
@@ -124,30 +124,30 @@ discard block |
||
| 124 | 124 | <div class="col-md-9 col-sm-9 col-xs-9 form-group"> |
| 125 | 125 | <label class="control-label"> |
| 126 | 126 | <?php |
| 127 | - echo"<input type=radio name='printto' value='1' class='flat' checked>  Preview  </label>"; |
|
| 128 | - echo"<input type=radio name='printto' value='2' class='flat'>  Print</label> "; |
|
| 129 | - ?> |
|
| 127 | + echo"<input type=radio name='printto' value='1' class='flat' checked>  Preview  </label>"; |
|
| 128 | + echo"<input type=radio name='printto' value='2' class='flat'>  Print</label> "; |
|
| 129 | + ?> |
|
| 130 | 130 | </label> |
| 131 | 131 | </div> |
| 132 | 132 | |
| 133 | 133 | <?php |
| 134 | 134 | |
| 135 | - $module = '?module='.$_GET['module']; |
|
| 136 | - $tampil = mysql_query("SELECT id_modul as id FROM modul WHERE link='".$module."'"); |
|
| 137 | - $r = mysql_fetch_array($tampil); |
|
| 135 | + $module = '?module='.$_GET['module']; |
|
| 136 | + $tampil = mysql_query("SELECT id_modul as id FROM modul WHERE link='".$module."'"); |
|
| 137 | + $r = mysql_fetch_array($tampil); |
|
| 138 | 138 | |
| 139 | - echo"<input type='hidden' name='report_id' id='report_id' value=".$r[id].'>'; |
|
| 140 | - echo"<input type='hidden' name='module' value=".$_GET[module].'>'; |
|
| 141 | - ?> |
|
| 139 | + echo"<input type='hidden' name='report_id' id='report_id' value=".$r[id].'>'; |
|
| 140 | + echo"<input type='hidden' name='module' value=".$_GET[module].'>'; |
|
| 141 | + ?> |
|
| 142 | 142 | </form> |
| 143 | 143 | |
| 144 | 144 | </div> |
| 145 | 145 | <?php for ($i = 0; $i <= 20; $i++) { |
| 146 | - ?> |
|
| 147 | - <br /> |
|
| 148 | - <?php |
|
| 149 | - } |
|
| 150 | 146 | ?> |
| 147 | + <br /> |
|
| 148 | + <?php |
|
| 149 | + } |
|
| 150 | + ?> |
|
| 151 | 151 | </div> |
| 152 | 152 | |
| 153 | 153 | |
@@ -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 0; |
| 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 false; |
| 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 0; |
| 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 0; |
| 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 | |
@@ -531,11 +531,11 @@ discard block |
||
| 531 | 531 | do { |
| 532 | 532 | $prev = $version; |
| 533 | 533 | $bits = $this->estimateBitStreamSize($prev); |
| 534 | - $version = QRspec::getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
| 535 | - if ($version < 0) { |
|
| 534 | + $version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
| 535 | + if ($version<0) { |
|
| 536 | 536 | return 0; |
| 537 | 537 | } |
| 538 | - } while ($version > $prev); |
|
| 538 | + } while ($version>$prev); |
|
| 539 | 539 | |
| 540 | 540 | return $version; |
| 541 | 541 | } |
@@ -546,31 +546,31 @@ discard block |
||
| 546 | 546 | $payload = $bits - 4 - QRspec::lengthIndicator($mode, $version); |
| 547 | 547 | switch ($mode) { |
| 548 | 548 | case QR_MODE_NUM: |
| 549 | - $chunks = (int) ($payload / 10); |
|
| 549 | + $chunks = (int)($payload / 10); |
|
| 550 | 550 | $remain = $payload - $chunks * 10; |
| 551 | 551 | $size = $chunks * 3; |
| 552 | - if ($remain >= 7) { |
|
| 552 | + if ($remain>=7) { |
|
| 553 | 553 | $size += 2; |
| 554 | - } elseif ($remain >= 4) { |
|
| 554 | + } elseif ($remain>=4) { |
|
| 555 | 555 | $size += 1; |
| 556 | 556 | } |
| 557 | 557 | break; |
| 558 | 558 | case QR_MODE_AN: |
| 559 | - $chunks = (int) ($payload / 11); |
|
| 559 | + $chunks = (int)($payload / 11); |
|
| 560 | 560 | $remain = $payload - $chunks * 11; |
| 561 | 561 | $size = $chunks * 2; |
| 562 | - if ($remain >= 6) { |
|
| 562 | + if ($remain>=6) { |
|
| 563 | 563 | $size++; |
| 564 | 564 | } |
| 565 | 565 | break; |
| 566 | 566 | case QR_MODE_8: |
| 567 | - $size = (int) ($payload / 8); |
|
| 567 | + $size = (int)($payload / 8); |
|
| 568 | 568 | break; |
| 569 | 569 | case QR_MODE_KANJI: |
| 570 | - $size = (int) (($payload / 13) * 2); |
|
| 570 | + $size = (int)(($payload / 13) * 2); |
|
| 571 | 571 | break; |
| 572 | 572 | case QR_MODE_STRUCTURE: |
| 573 | - $size = (int) ($payload / 8); |
|
| 573 | + $size = (int)($payload / 8); |
|
| 574 | 574 | break; |
| 575 | 575 | default: |
| 576 | 576 | $size = 0; |
@@ -578,10 +578,10 @@ discard block |
||
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | $maxsize = QRspec::maximumWords($mode, $version); |
| 581 | - if ($size < 0) { |
|
| 581 | + if ($size<0) { |
|
| 582 | 582 | $size = 0; |
| 583 | 583 | } |
| 584 | - if ($size > $maxsize) { |
|
| 584 | + if ($size>$maxsize) { |
|
| 585 | 585 | $size = $maxsize; |
| 586 | 586 | } |
| 587 | 587 | |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | foreach ($this->items as $item) { |
| 597 | 597 | $bits = $item->encodeBitStream($this->version); |
| 598 | 598 | |
| 599 | - if ($bits < 0) { |
|
| 599 | + if ($bits<0) { |
|
| 600 | 600 | return 0; |
| 601 | 601 | } |
| 602 | 602 | |
@@ -610,22 +610,22 @@ discard block |
||
| 610 | 610 | public function convertData() |
| 611 | 611 | { |
| 612 | 612 | $ver = $this->estimateVersion(); |
| 613 | - if ($ver > $this->getVersion()) { |
|
| 613 | + if ($ver>$this->getVersion()) { |
|
| 614 | 614 | $this->setVersion($ver); |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - for (; ;) { |
|
| 617 | + for (;;) { |
|
| 618 | 618 | $bits = $this->createBitStream(); |
| 619 | 619 | |
| 620 | - if ($bits < 0) { |
|
| 620 | + if ($bits<0) { |
|
| 621 | 621 | return 0; |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - $ver = QRspec::getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
| 625 | - if ($ver < 0) { |
|
| 624 | + $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
| 625 | + if ($ver<0) { |
|
| 626 | 626 | throw new Exception('WRONG VERSION'); |
| 627 | 627 | return 0; |
| 628 | - } elseif ($ver > $this->getVersion()) { |
|
| 628 | + } elseif ($ver>$this->getVersion()) { |
|
| 629 | 629 | $this->setVersion($ver); |
| 630 | 630 | } else { |
| 631 | 631 | break; |
@@ -642,35 +642,35 @@ discard block |
||
| 642 | 642 | $maxwords = QRspec::getDataLength($this->version, $this->level); |
| 643 | 643 | $maxbits = $maxwords * 8; |
| 644 | 644 | |
| 645 | - if ($maxbits == $bits) { |
|
| 645 | + if ($maxbits==$bits) { |
|
| 646 | 646 | return 0; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - if ($maxbits - $bits < 5) { |
|
| 649 | + if ($maxbits - $bits<5) { |
|
| 650 | 650 | return $bstream->appendNum($maxbits - $bits, 0); |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | $bits += 4; |
| 654 | - $words = (int) (($bits + 7) / 8); |
|
| 654 | + $words = (int)(($bits + 7) / 8); |
|
| 655 | 655 | |
| 656 | 656 | $padding = new QRbitstream(); |
| 657 | 657 | $ret = $padding->appendNum($words * 8 - $bits + 4, 0); |
| 658 | 658 | |
| 659 | - if ($ret < 0) { |
|
| 659 | + if ($ret<0) { |
|
| 660 | 660 | return $ret; |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | $padlen = $maxwords - $words; |
| 664 | 664 | |
| 665 | - if ($padlen > 0) { |
|
| 665 | + if ($padlen>0) { |
|
| 666 | 666 | $padbuf = []; |
| 667 | - for ($i = 0; $i < $padlen; $i++) { |
|
| 667 | + for ($i = 0; $i<$padlen; $i++) { |
|
| 668 | 668 | $padbuf[$i] = ($i & 1) ? 0x11 : 0xec; |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | $ret = $padding->appendBytes($padlen, $padbuf); |
| 672 | 672 | |
| 673 | - if ($ret < 0) { |
|
| 673 | + if ($ret<0) { |
|
| 674 | 674 | return $ret; |
| 675 | 675 | } |
| 676 | 676 | } |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | //---------------------------------------------------------------------- |
| 684 | 684 | public function mergeBitStream() |
| 685 | 685 | { |
| 686 | - if ($this->convertData() < 0) { |
|
| 686 | + if ($this->convertData()<0) { |
|
| 687 | 687 | return; |
| 688 | 688 | } |
| 689 | 689 | |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | foreach ($this->items as $item) { |
| 693 | 693 | $ret = $bstream->append($item->bstream); |
| 694 | - if ($ret < 0) { |
|
| 694 | + if ($ret<0) { |
|
| 695 | 695 | return; |
| 696 | 696 | } |
| 697 | 697 | } |
@@ -704,12 +704,12 @@ discard block |
||
| 704 | 704 | { |
| 705 | 705 | $bstream = $this->mergeBitStream(); |
| 706 | 706 | |
| 707 | - if ($bstream == null) { |
|
| 707 | + if ($bstream==null) { |
|
| 708 | 708 | return; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | $ret = $this->appendPaddingBit($bstream); |
| 712 | - if ($ret < 0) { |
|
| 712 | + if ($ret<0) { |
|
| 713 | 713 | return; |
| 714 | 714 | } |
| 715 | 715 | |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | public function getByteStream() |
| 721 | 721 | { |
| 722 | 722 | $bstream = $this->getBitStream(); |
| 723 | - if ($bstream == null) { |
|
| 723 | + if ($bstream==null) { |
|
| 724 | 724 | return; |
| 725 | 725 | } |
| 726 | 726 | |
@@ -47,27 +47,27 @@ discard block |
||
| 47 | 47 | //---------------------------------------------------------------------- |
| 48 | 48 | public static function isdigitat($str, $pos) |
| 49 | 49 | { |
| 50 | - if ($pos >= strlen($str)) { |
|
| 50 | + if ($pos>=strlen($str)) { |
|
| 51 | 51 | return false; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - return (ord($str[$pos]) >= ord('0')) && (ord($str[$pos]) <= ord('9')); |
|
| 54 | + return (ord($str[$pos])>=ord('0')) && (ord($str[$pos])<=ord('9')); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | //---------------------------------------------------------------------- |
| 58 | 58 | public static function isalnumat($str, $pos) |
| 59 | 59 | { |
| 60 | - if ($pos >= strlen($str)) { |
|
| 60 | + if ($pos>=strlen($str)) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - return QRinput::lookAnTable(ord($str[$pos])) >= 0; |
|
| 64 | + return QRinput::lookAnTable(ord($str[$pos]))>=0; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | //---------------------------------------------------------------------- |
| 68 | 68 | public function identifyMode($pos) |
| 69 | 69 | { |
| 70 | - if ($pos >= strlen($this->dataStr)) { |
|
| 70 | + if ($pos>=strlen($this->dataStr)) { |
|
| 71 | 71 | return QR_MODE_NUL; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | return QR_MODE_NUM; |
| 78 | 78 | } elseif (self::isalnumat($this->dataStr, $pos)) { |
| 79 | 79 | return QR_MODE_AN; |
| 80 | - } elseif ($this->modeHint == QR_MODE_KANJI) { |
|
| 81 | - if ($pos + 1 < strlen($this->dataStr)) { |
|
| 80 | + } elseif ($this->modeHint==QR_MODE_KANJI) { |
|
| 81 | + if ($pos + 1<strlen($this->dataStr)) { |
|
| 82 | 82 | $d = $this->dataStr[$pos + 1]; |
| 83 | 83 | $word = (ord($c) << 8) | ord($d); |
| 84 | - if (($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) { |
|
| 84 | + if (($word>=0x8140 && $word<=0x9ffc) || ($word>=0xe040 && $word<=0xebbf)) { |
|
| 85 | 85 | return QR_MODE_KANJI; |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -103,25 +103,25 @@ discard block |
||
| 103 | 103 | $run = $p; |
| 104 | 104 | $mode = $this->identifyMode($p); |
| 105 | 105 | |
| 106 | - if ($mode == QR_MODE_8) { |
|
| 106 | + if ($mode==QR_MODE_8) { |
|
| 107 | 107 | $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln |
| 108 | 108 | + QRinput::estimateBitsMode8(1) // + 4 + l8 |
| 109 | 109 | - QRinput::estimateBitsMode8($run + 1); // - 4 - l8 |
| 110 | - if ($dif > 0) { |
|
| 110 | + if ($dif>0) { |
|
| 111 | 111 | return $this->eat8(); |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | - if ($mode == QR_MODE_AN) { |
|
| 114 | + if ($mode==QR_MODE_AN) { |
|
| 115 | 115 | $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln |
| 116 | 116 | + QRinput::estimateBitsModeAn(1) // + 4 + la |
| 117 | 117 | - QRinput::estimateBitsModeAn($run + 1); // - 4 - la |
| 118 | - if ($dif > 0) { |
|
| 118 | + if ($dif>0) { |
|
| 119 | 119 | return $this->eatAn(); |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); |
| 124 | - if ($ret < 0) { |
|
| 124 | + if ($ret<0) { |
|
| 125 | 125 | return -1; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln |
| 148 | 148 | - QRinput::estimateBitsModeAn($q); // - 4 - la |
| 149 | 149 | |
| 150 | - if ($dif < 0) { |
|
| 150 | + if ($dif<0) { |
|
| 151 | 151 | break; |
| 152 | 152 | } else { |
| 153 | 153 | $p = $q; |
@@ -163,13 +163,13 @@ discard block |
||
| 163 | 163 | $dif = QRinput::estimateBitsModeAn($run) + 4 + $la |
| 164 | 164 | + QRinput::estimateBitsMode8(1) // + 4 + l8 |
| 165 | 165 | - QRinput::estimateBitsMode8($run + 1); // - 4 - l8 |
| 166 | - if ($dif > 0) { |
|
| 166 | + if ($dif>0) { |
|
| 167 | 167 | return $this->eat8(); |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); |
| 172 | - if ($ret < 0) { |
|
| 172 | + if ($ret<0) { |
|
| 173 | 173 | return -1; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -181,12 +181,12 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | $p = 0; |
| 183 | 183 | |
| 184 | - while ($this->identifyMode($p) == QR_MODE_KANJI) { |
|
| 184 | + while ($this->identifyMode($p)==QR_MODE_KANJI) { |
|
| 185 | 185 | $p += 2; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); |
| 189 | - if ($ret < 0) { |
|
| 189 | + if ($ret<0) { |
|
| 190 | 190 | return -1; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -202,12 +202,12 @@ discard block |
||
| 202 | 202 | $p = 1; |
| 203 | 203 | $dataStrLen = strlen($this->dataStr); |
| 204 | 204 | |
| 205 | - while ($p < $dataStrLen) { |
|
| 205 | + while ($p<$dataStrLen) { |
|
| 206 | 206 | $mode = $this->identifyMode($p); |
| 207 | - if ($mode == QR_MODE_KANJI) { |
|
| 207 | + if ($mode==QR_MODE_KANJI) { |
|
| 208 | 208 | break; |
| 209 | 209 | } |
| 210 | - if ($mode == QR_MODE_NUM) { |
|
| 210 | + if ($mode==QR_MODE_NUM) { |
|
| 211 | 211 | $q = $p; |
| 212 | 212 | while (self::isdigitat($this->dataStr, $q)) { |
| 213 | 213 | $q++; |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | $dif = QRinput::estimateBitsMode8($p) // + 4 + l8 |
| 216 | 216 | + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln |
| 217 | 217 | - QRinput::estimateBitsMode8($q); // - 4 - l8 |
| 218 | - if ($dif < 0) { |
|
| 218 | + if ($dif<0) { |
|
| 219 | 219 | break; |
| 220 | 220 | } else { |
| 221 | 221 | $p = $q; |
| 222 | 222 | } |
| 223 | - } elseif ($mode == QR_MODE_AN) { |
|
| 223 | + } elseif ($mode==QR_MODE_AN) { |
|
| 224 | 224 | $q = $p; |
| 225 | 225 | while (self::isalnumat($this->dataStr, $q)) { |
| 226 | 226 | $q++; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $dif = QRinput::estimateBitsMode8($p) // + 4 + l8 |
| 229 | 229 | + QRinput::estimateBitsModeAn($q - $p) + 4 + $la |
| 230 | 230 | - QRinput::estimateBitsMode8($q); // - 4 - l8 |
| 231 | - if ($dif < 0) { |
|
| 231 | + if ($dif<0) { |
|
| 232 | 232 | break; |
| 233 | 233 | } else { |
| 234 | 234 | $p = $q; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $run = $p; |
| 242 | 242 | $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); |
| 243 | 243 | |
| 244 | - if ($ret < 0) { |
|
| 244 | + if ($ret<0) { |
|
| 245 | 245 | return -1; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -251,8 +251,8 @@ discard block |
||
| 251 | 251 | //---------------------------------------------------------------------- |
| 252 | 252 | public function splitString() |
| 253 | 253 | { |
| 254 | - while (strlen($this->dataStr) > 0) { |
|
| 255 | - if ($this->dataStr == '') { |
|
| 254 | + while (strlen($this->dataStr)>0) { |
|
| 255 | + if ($this->dataStr=='') { |
|
| 256 | 256 | return 0; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
| 263 | 263 | case QR_MODE_AN: $length = $this->eatAn(); break; |
| 264 | 264 | case QR_MODE_KANJI: |
| 265 | - if ($mode == QR_MODE_KANJI) { |
|
| 265 | + if ($mode==QR_MODE_KANJI) { |
|
| 266 | 266 | $length = $this->eatKanji(); |
| 267 | 267 | } else { |
| 268 | 268 | $length = $this->eat8(); |
@@ -272,10 +272,10 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - if ($length == 0) { |
|
| 275 | + if ($length==0) { |
|
| 276 | 276 | return 0; |
| 277 | 277 | } |
| 278 | - if ($length < 0) { |
|
| 278 | + if ($length<0) { |
|
| 279 | 279 | return -1; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -289,12 +289,12 @@ discard block |
||
| 289 | 289 | $stringLen = strlen($this->dataStr); |
| 290 | 290 | $p = 0; |
| 291 | 291 | |
| 292 | - while ($p < $stringLen) { |
|
| 292 | + while ($p<$stringLen) { |
|
| 293 | 293 | $mode = $this->identifyMode(substr($this->dataStr, $p)); |
| 294 | - if ($mode == QR_MODE_KANJI) { |
|
| 294 | + if ($mode==QR_MODE_KANJI) { |
|
| 295 | 295 | $p += 2; |
| 296 | 296 | } else { |
| 297 | - if (ord($this->dataStr[$p]) >= ord('a') && ord($this->dataStr[$p]) <= ord('z')) { |
|
| 297 | + if (ord($this->dataStr[$p])>=ord('a') && ord($this->dataStr[$p])<=ord('z')) { |
|
| 298 | 298 | $this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32); |
| 299 | 299 | } |
| 300 | 300 | $p++; |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | //---------------------------------------------------------------------- |
| 308 | 308 | public static function splitStringToQRinput($string, QRinput $input, $modeHint, $casesensitive = true) |
| 309 | 309 | { |
| 310 | - if (is_null($string) || $string == '\0' || $string == '') { |
|
| 310 | + if (is_null($string) || $string=='\0' || $string=='') { |
|
| 311 | 311 | throw new Exception('empty string!!!'); |
| 312 | 312 | } |
| 313 | 313 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | public static function set(&$srctab, $x, $y, $repl, $replLen = false) |
| 94 | 94 | { |
| 95 | - $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false) ? substr($repl, 0, $replLen) : $repl, $x, ($replLen !== false) ? $replLen : strlen($repl)); |
|
| 95 | + $srctab[$y] = substr_replace($srctab[$y], ($replLen!==false) ? substr($repl, 0, $replLen) : $repl, $x, ($replLen!==false) ? $replLen : strlen($repl)); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $len = count($frame); |
| 148 | 148 | foreach ($frame as &$frameLine) { |
| 149 | - for ($i = 0; $i < $len; $i++) { |
|
| 149 | + for ($i = 0; $i<$len; $i++) { |
|
| 150 | 150 | $frameLine[$i] = (ord($frameLine[$i]) & 1) ? '1' : '0'; |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | $eccLevel = 'L'; |
| 167 | 167 | |
| 168 | - if (count($mode) > 1) { |
|
| 168 | + if (count($mode)>1) { |
|
| 169 | 169 | $eccLevel = $mode[1]; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | foreach ($qrTab as $line) { |
| 180 | 180 | $arrAdd = []; |
| 181 | 181 | foreach (str_split($line) as $char) { |
| 182 | - $arrAdd[] = ($char == '1') ? 1 : 0; |
|
| 182 | + $arrAdd[] = ($char=='1') ? 1 : 0; |
|
| 183 | 183 | } |
| 184 | 184 | $barcode_array['bcode'][] = $arrAdd; |
| 185 | 185 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | self::markTime('before_build_cache'); |
| 200 | 200 | |
| 201 | 201 | $mask = new QRmask(); |
| 202 | - for ($a = 1; $a <= QRSPEC_VERSION_MAX; $a++) { |
|
| 202 | + for ($a = 1; $a<=QRSPEC_VERSION_MAX; $a++) { |
|
| 203 | 203 | $frame = QRspec::newFrame($a); |
| 204 | 204 | if (QR_IMAGE) { |
| 205 | 205 | $fileName = QR_CACHE_DIR.'frame_'.$a.'.png'; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | $width = count($frame); |
| 210 | 210 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
| 211 | - for ($maskNo = 0; $maskNo < 8; $maskNo++) { |
|
| 211 | + for ($maskNo = 0; $maskNo<8; $maskNo++) { |
|
| 212 | 212 | $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -219,9 +219,9 @@ discard block |
||
| 219 | 219 | //---------------------------------------------------------------------- |
| 220 | 220 | public static function log($outfile, $err) |
| 221 | 221 | { |
| 222 | - if (QR_LOG_DIR !== false) { |
|
| 223 | - if ($err != '') { |
|
| 224 | - if ($outfile !== false) { |
|
| 222 | + if (QR_LOG_DIR!==false) { |
|
| 223 | + if ($err!='') { |
|
| 224 | + if ($outfile!==false) { |
|
| 225 | 225 | file_put_contents(QR_LOG_DIR.basename($outfile).'-errors.txt', date('Y-m-d H:i:s').': '.$err, FILE_APPEND); |
| 226 | 226 | } else { |
| 227 | 227 | file_put_contents(QR_LOG_DIR.'errors.txt', date('Y-m-d H:i:s').': '.$err, FILE_APPEND); |
@@ -234,8 +234,8 @@ discard block |
||
| 234 | 234 | public static function dumpMask($frame) |
| 235 | 235 | { |
| 236 | 236 | $width = count($frame); |
| 237 | - for ($y = 0; $y < $width; $y++) { |
|
| 238 | - for ($x = 0; $x < $width; $x++) { |
|
| 237 | + for ($y = 0; $y<$width; $y++) { |
|
| 238 | + for ($x = 0; $x<$width; $x++) { |
|
| 239 | 239 | echo ord($frame[$y][$x]).','; |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | public static function markTime($markerId) |
| 246 | 246 | { |
| 247 | 247 | list($usec, $sec) = explode(' ', microtime()); |
| 248 | - $time = ((float) $usec + (float) $sec); |
|
| 248 | + $time = ((float)$usec + (float)$sec); |
|
| 249 | 249 | |
| 250 | 250 | if (!isset($GLOBALS['qr_time_bench'])) { |
| 251 | 251 | $GLOBALS['qr_time_bench'] = []; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | <tbody>'; |
| 269 | 269 | |
| 270 | 270 | foreach ($GLOBALS['qr_time_bench'] as $markerId=>$thisTime) { |
| 271 | - if ($p > 0) { |
|
| 271 | + if ($p>0) { |
|
| 272 | 272 | echo '<tr><th style="text-align:right">till '.$markerId.': </th><td>'.number_format($thisTime - $lastTime, 6).'s</td></tr>'; |
| 273 | 273 | } else { |
| 274 | 274 | $startTime = $thisTime; |
@@ -417,9 +417,9 @@ discard block |
||
| 417 | 417 | //---------------------------------------------------------------------- |
| 418 | 418 | public static function getMinimumVersion($size, $level) |
| 419 | 419 | { |
| 420 | - for ($i = 1; $i <= QRSPEC_VERSION_MAX; $i++) { |
|
| 420 | + for ($i = 1; $i<=QRSPEC_VERSION_MAX; $i++) { |
|
| 421 | 421 | $words = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level]; |
| 422 | - if ($words >= $size) { |
|
| 422 | + if ($words>=$size) { |
|
| 423 | 423 | return $i; |
| 424 | 424 | } |
| 425 | 425 | } |
@@ -439,13 +439,13 @@ discard block |
||
| 439 | 439 | //---------------------------------------------------------------------- |
| 440 | 440 | public static function lengthIndicator($mode, $version) |
| 441 | 441 | { |
| 442 | - if ($mode == QR_MODE_STRUCTURE) { |
|
| 442 | + if ($mode==QR_MODE_STRUCTURE) { |
|
| 443 | 443 | return 0; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - if ($version <= 9) { |
|
| 446 | + if ($version<=9) { |
|
| 447 | 447 | $l = 0; |
| 448 | - } elseif ($version <= 26) { |
|
| 448 | + } elseif ($version<=26) { |
|
| 449 | 449 | $l = 1; |
| 450 | 450 | } else { |
| 451 | 451 | $l = 2; |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | //---------------------------------------------------------------------- |
| 458 | 458 | public static function maximumWords($mode, $version) |
| 459 | 459 | { |
| 460 | - if ($mode == QR_MODE_STRUCTURE) { |
|
| 460 | + if ($mode==QR_MODE_STRUCTURE) { |
|
| 461 | 461 | return 3; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if ($version <= 9) { |
|
| 464 | + if ($version<=9) { |
|
| 465 | 465 | $l = 0; |
| 466 | - } elseif ($version <= 26) { |
|
| 466 | + } elseif ($version<=26) { |
|
| 467 | 467 | $l = 1; |
| 468 | 468 | } else { |
| 469 | 469 | $l = 2; |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | $bits = self::$lengthTableBits[$mode][$l]; |
| 473 | 473 | $words = (1 << $bits) - 1; |
| 474 | 474 | |
| 475 | - if ($mode == QR_MODE_KANJI) { |
|
| 475 | + if ($mode==QR_MODE_KANJI) { |
|
| 476 | 476 | $words *= 2; // the number of bytes is required |
| 477 | 477 | } |
| 478 | 478 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | |
| 533 | 533 | public static function getEccSpec($version, $level, array &$spec) |
| 534 | 534 | { |
| 535 | - if (count($spec) < 5) { |
|
| 535 | + if (count($spec)<5) { |
|
| 536 | 536 | $spec = [0, 0, 0, 0, 0]; |
| 537 | 537 | } |
| 538 | 538 | |
@@ -541,16 +541,16 @@ discard block |
||
| 541 | 541 | $data = self::getDataLength($version, $level); |
| 542 | 542 | $ecc = self::getECCLength($version, $level); |
| 543 | 543 | |
| 544 | - if ($b2 == 0) { |
|
| 544 | + if ($b2==0) { |
|
| 545 | 545 | $spec[0] = $b1; |
| 546 | - $spec[1] = (int) ($data / $b1); |
|
| 547 | - $spec[2] = (int) ($ecc / $b1); |
|
| 546 | + $spec[1] = (int)($data / $b1); |
|
| 547 | + $spec[2] = (int)($ecc / $b1); |
|
| 548 | 548 | $spec[3] = 0; |
| 549 | 549 | $spec[4] = 0; |
| 550 | 550 | } else { |
| 551 | 551 | $spec[0] = $b1; |
| 552 | - $spec[1] = (int) ($data / ($b1 + $b2)); |
|
| 553 | - $spec[2] = (int) ($ecc / ($b1 + $b2)); |
|
| 552 | + $spec[1] = (int)($data / ($b1 + $b2)); |
|
| 553 | + $spec[2] = (int)($ecc / ($b1 + $b2)); |
|
| 554 | 554 | $spec[3] = $b2; |
| 555 | 555 | $spec[4] = $spec[1] + 1; |
| 556 | 556 | } |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | $yStart = $oy - 2; |
| 598 | 598 | $xStart = $ox - 2; |
| 599 | 599 | |
| 600 | - for ($y = 0; $y < 5; $y++) { |
|
| 600 | + for ($y = 0; $y<5; $y++) { |
|
| 601 | 601 | QRstr::set($frame, $xStart, $yStart + $y, $finder[$y]); |
| 602 | 602 | } |
| 603 | 603 | } |
@@ -605,18 +605,18 @@ discard block |
||
| 605 | 605 | //---------------------------------------------------------------------- |
| 606 | 606 | public static function putAlignmentPattern($version, &$frame, $width) |
| 607 | 607 | { |
| 608 | - if ($version < 2) { |
|
| 608 | + if ($version<2) { |
|
| 609 | 609 | return; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | $d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0]; |
| 613 | - if ($d < 0) { |
|
| 613 | + if ($d<0) { |
|
| 614 | 614 | $w = 2; |
| 615 | 615 | } else { |
| 616 | - $w = (int) (($width - self::$alignmentPattern[$version][0]) / $d + 2); |
|
| 616 | + $w = (int)(($width - self::$alignmentPattern[$version][0]) / $d + 2); |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - if ($w * $w - 3 == 1) { |
|
| 619 | + if ($w * $w - 3==1) { |
|
| 620 | 620 | $x = self::$alignmentPattern[$version][0]; |
| 621 | 621 | $y = self::$alignmentPattern[$version][0]; |
| 622 | 622 | self::putAlignmentMarker($frame, $x, $y); |
@@ -625,16 +625,16 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | $cx = self::$alignmentPattern[$version][0]; |
| 628 | - for ($x = 1; $x < $w - 1; $x++) { |
|
| 628 | + for ($x = 1; $x<$w - 1; $x++) { |
|
| 629 | 629 | self::putAlignmentMarker($frame, 6, $cx); |
| 630 | 630 | self::putAlignmentMarker($frame, $cx, 6); |
| 631 | 631 | $cx += $d; |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | $cy = self::$alignmentPattern[$version][0]; |
| 635 | - for ($y = 0; $y < $w - 1; $y++) { |
|
| 635 | + for ($y = 0; $y<$w - 1; $y++) { |
|
| 636 | 636 | $cx = self::$alignmentPattern[$version][0]; |
| 637 | - for ($x = 0; $x < $w - 1; $x++) { |
|
| 637 | + for ($x = 0; $x<$w - 1; $x++) { |
|
| 638 | 638 | self::putAlignmentMarker($frame, $cx, $cy); |
| 639 | 639 | $cx += $d; |
| 640 | 640 | } |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | //---------------------------------------------------------------------- |
| 661 | 661 | public static function getVersionPattern($version) |
| 662 | 662 | { |
| 663 | - if ($version < 7 || $version > QRSPEC_VERSION_MAX) { |
|
| 663 | + if ($version<7 || $version>QRSPEC_VERSION_MAX) { |
|
| 664 | 664 | return 0; |
| 665 | 665 | } |
| 666 | 666 | |
@@ -679,11 +679,11 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | public static function getFormatInfo($mask, $level) |
| 681 | 681 | { |
| 682 | - if ($mask < 0 || $mask > 7) { |
|
| 682 | + if ($mask<0 || $mask>7) { |
|
| 683 | 683 | return 0; |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - if ($level < 0 || $level > 3) { |
|
| 686 | + if ($level<0 || $level>3) { |
|
| 687 | 687 | return 0; |
| 688 | 688 | } |
| 689 | 689 | |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | "\xc1\xc1\xc1\xc1\xc1\xc1\xc1", |
| 715 | 715 | ]; |
| 716 | 716 | |
| 717 | - for ($y = 0; $y < 7; $y++) { |
|
| 717 | + for ($y = 0; $y<7; $y++) { |
|
| 718 | 718 | QRstr::set($frame, $ox, $oy + $y, $finder[$y]); |
| 719 | 719 | } |
| 720 | 720 | } |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | // Separator |
| 735 | 735 | $yOffset = $width - 7; |
| 736 | 736 | |
| 737 | - for ($y = 0; $y < 7; $y++) { |
|
| 737 | + for ($y = 0; $y<7; $y++) { |
|
| 738 | 738 | $frame[$y][7] = "\xc0"; |
| 739 | 739 | $frame[$y][$width - 8] = "\xc0"; |
| 740 | 740 | $frame[$yOffset][7] = "\xc0"; |
@@ -754,14 +754,14 @@ discard block |
||
| 754 | 754 | |
| 755 | 755 | $yOffset = $width - 8; |
| 756 | 756 | |
| 757 | - for ($y = 0; $y < 8; $y++, $yOffset++) { |
|
| 757 | + for ($y = 0; $y<8; $y++, $yOffset++) { |
|
| 758 | 758 | $frame[$y][8] = "\x84"; |
| 759 | 759 | $frame[$yOffset][8] = "\x84"; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | // Timing pattern |
| 763 | 763 | |
| 764 | - for ($i = 1; $i < $width - 15; $i++) { |
|
| 764 | + for ($i = 1; $i<$width - 15; $i++) { |
|
| 765 | 765 | $frame[6][7 + $i] = chr(0x90 | ($i & 1)); |
| 766 | 766 | $frame[7 + $i][6] = chr(0x90 | ($i & 1)); |
| 767 | 767 | } |
@@ -770,21 +770,21 @@ discard block |
||
| 770 | 770 | self::putAlignmentPattern($version, $frame, $width); |
| 771 | 771 | |
| 772 | 772 | // Version information |
| 773 | - if ($version >= 7) { |
|
| 773 | + if ($version>=7) { |
|
| 774 | 774 | $vinf = self::getVersionPattern($version); |
| 775 | 775 | |
| 776 | 776 | $v = $vinf; |
| 777 | 777 | |
| 778 | - for ($x = 0; $x < 6; $x++) { |
|
| 779 | - for ($y = 0; $y < 3; $y++) { |
|
| 778 | + for ($x = 0; $x<6; $x++) { |
|
| 779 | + for ($y = 0; $y<3; $y++) { |
|
| 780 | 780 | $frame[($width - 11) + $y][$x] = chr(0x88 | ($v & 1)); |
| 781 | 781 | $v = $v >> 1; |
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | $v = $vinf; |
| 786 | - for ($y = 0; $y < 6; $y++) { |
|
| 787 | - for ($x = 0; $x < 3; $x++) { |
|
| 786 | + for ($y = 0; $y<6; $y++) { |
|
| 787 | + for ($x = 0; $x<3; $x++) { |
|
| 788 | 788 | $frame[$y][$x + ($width - 11)] = chr(0x88 | ($v & 1)); |
| 789 | 789 | $v = $v >> 1; |
| 790 | 790 | } |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | //---------------------------------------------------------------------- |
| 859 | 859 | public static function newFrame($version) |
| 860 | 860 | { |
| 861 | - if ($version < 1 || $version > QRSPEC_VERSION_MAX) { |
|
| 861 | + if ($version<1 || $version>QRSPEC_VERSION_MAX) { |
|
| 862 | 862 | return; |
| 863 | 863 | } |
| 864 | 864 | |
@@ -965,11 +965,11 @@ discard block |
||
| 965 | 965 | { |
| 966 | 966 | $image = self::image($frame, $pixelPerPoint, $outerFrame, $back_color, $fore_color); |
| 967 | 967 | |
| 968 | - if ($filename === false) { |
|
| 968 | + if ($filename===false) { |
|
| 969 | 969 | header('Content-type: image/png'); |
| 970 | 970 | imagepng($image); |
| 971 | 971 | } else { |
| 972 | - if ($saveandprint === true) { |
|
| 972 | + if ($saveandprint===true) { |
|
| 973 | 973 | imagepng($image, $filename); |
| 974 | 974 | header('Content-type: image/png'); |
| 975 | 975 | imagepng($image); |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | { |
| 987 | 987 | $image = self::image($frame, $pixelPerPoint, $outerFrame); |
| 988 | 988 | |
| 989 | - if ($filename === false) { |
|
| 989 | + if ($filename===false) { |
|
| 990 | 990 | header('Content-type: image/jpeg'); |
| 991 | 991 | imagejpeg($image, null, $q); |
| 992 | 992 | } else { |
@@ -1022,9 +1022,9 @@ discard block |
||
| 1022 | 1022 | |
| 1023 | 1023 | imagefill($base_image, 0, 0, $col[0]); |
| 1024 | 1024 | |
| 1025 | - for ($y = 0; $y < $h; $y++) { |
|
| 1026 | - for ($x = 0; $x < $w; $x++) { |
|
| 1027 | - if ($frame[$y][$x] == '1') { |
|
| 1025 | + for ($y = 0; $y<$h; $y++) { |
|
| 1026 | + for ($x = 0; $x<$w; $x++) { |
|
| 1027 | + if ($frame[$y][$x]=='1') { |
|
| 1028 | 1028 | imagesetpixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]); |
| 1029 | 1029 | } |
| 1030 | 1030 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | { |
| 1081 | 1081 | $setData = array_slice($data, 0, $size); |
| 1082 | 1082 | |
| 1083 | - if (count($setData) < $size) { |
|
| 1083 | + if (count($setData)<$size) { |
|
| 1084 | 1084 | $setData = array_merge($setData, array_fill(0, $size - count($setData), 0)); |
| 1085 | 1085 | } |
| 1086 | 1086 | |
@@ -1099,24 +1099,24 @@ discard block |
||
| 1099 | 1099 | public function encodeModeNum($version) |
| 1100 | 1100 | { |
| 1101 | 1101 | try { |
| 1102 | - $words = (int) ($this->size / 3); |
|
| 1102 | + $words = (int)($this->size / 3); |
|
| 1103 | 1103 | $bs = new QRbitstream(); |
| 1104 | 1104 | |
| 1105 | 1105 | $val = 0x1; |
| 1106 | 1106 | $bs->appendNum(4, $val); |
| 1107 | 1107 | $bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size); |
| 1108 | 1108 | |
| 1109 | - for ($i = 0; $i < $words; $i++) { |
|
| 1109 | + for ($i = 0; $i<$words; $i++) { |
|
| 1110 | 1110 | $val = (ord($this->data[$i * 3]) - ord('0')) * 100; |
| 1111 | 1111 | $val += (ord($this->data[$i * 3 + 1]) - ord('0')) * 10; |
| 1112 | 1112 | $val += (ord($this->data[$i * 3 + 2]) - ord('0')); |
| 1113 | 1113 | $bs->appendNum(10, $val); |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | - if ($this->size - $words * 3 == 1) { |
|
| 1116 | + if ($this->size - $words * 3==1) { |
|
| 1117 | 1117 | $val = ord($this->data[$words * 3]) - ord('0'); |
| 1118 | 1118 | $bs->appendNum(4, $val); |
| 1119 | - } elseif ($this->size - $words * 3 == 2) { |
|
| 1119 | + } elseif ($this->size - $words * 3==2) { |
|
| 1120 | 1120 | $val = (ord($this->data[$words * 3]) - ord('0')) * 10; |
| 1121 | 1121 | $val += (ord($this->data[$words * 3 + 1]) - ord('0')); |
| 1122 | 1122 | $bs->appendNum(7, $val); |
@@ -1134,15 +1134,15 @@ discard block |
||
| 1134 | 1134 | public function encodeModeAn($version) |
| 1135 | 1135 | { |
| 1136 | 1136 | try { |
| 1137 | - $words = (int) ($this->size / 2); |
|
| 1137 | + $words = (int)($this->size / 2); |
|
| 1138 | 1138 | $bs = new QRbitstream(); |
| 1139 | 1139 | |
| 1140 | 1140 | $bs->appendNum(4, 0x02); |
| 1141 | 1141 | $bs->appendNum(QRspec::lengthIndicator(QR_MODE_AN, $version), $this->size); |
| 1142 | 1142 | |
| 1143 | - for ($i = 0; $i < $words; $i++) { |
|
| 1144 | - $val = (int) QRinput::lookAnTable(ord($this->data[$i * 2])) * 45; |
|
| 1145 | - $val += (int) QRinput::lookAnTable(ord($this->data[$i * 2 + 1])); |
|
| 1143 | + for ($i = 0; $i<$words; $i++) { |
|
| 1144 | + $val = (int)QRinput::lookAnTable(ord($this->data[$i * 2])) * 45; |
|
| 1145 | + $val += (int)QRinput::lookAnTable(ord($this->data[$i * 2 + 1])); |
|
| 1146 | 1146 | |
| 1147 | 1147 | $bs->appendNum(11, $val); |
| 1148 | 1148 | } |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | $bs->appendNum(4, 0x4); |
| 1170 | 1170 | $bs->appendNum(QRspec::lengthIndicator(QR_MODE_8, $version), $this->size); |
| 1171 | 1171 | |
| 1172 | - for ($i = 0; $i < $this->size; $i++) { |
|
| 1172 | + for ($i = 0; $i<$this->size; $i++) { |
|
| 1173 | 1173 | $bs->appendNum(8, ord($this->data[$i])); |
| 1174 | 1174 | } |
| 1175 | 1175 | |
@@ -1188,11 +1188,11 @@ discard block |
||
| 1188 | 1188 | $bs = new QRbitrtream(); |
| 1189 | 1189 | |
| 1190 | 1190 | $bs->appendNum(4, 0x8); |
| 1191 | - $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int) ($this->size / 2)); |
|
| 1191 | + $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int)($this->size / 2)); |
|
| 1192 | 1192 | |
| 1193 | - for ($i = 0; $i < $this->size; $i += 2) { |
|
| 1193 | + for ($i = 0; $i<$this->size; $i += 2) { |
|
| 1194 | 1194 | $val = (ord($this->data[$i]) << 8) | ord($this->data[$i + 1]); |
| 1195 | - if ($val <= 0x9ffc) { |
|
| 1195 | + if ($val<=0x9ffc) { |
|
| 1196 | 1196 | $val -= 0x8140; |
| 1197 | 1197 | } else { |
| 1198 | 1198 | $val -= 0xc140; |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | { |
| 1237 | 1237 | $bits = 0; |
| 1238 | 1238 | |
| 1239 | - if ($version == 0) { |
|
| 1239 | + if ($version==0) { |
|
| 1240 | 1240 | $version = 1; |
| 1241 | 1241 | } |
| 1242 | 1242 | |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | |
| 1253 | 1253 | $l = QRspec::lengthIndicator($this->mode, $version); |
| 1254 | 1254 | $m = 1 << $l; |
| 1255 | - $num = (int) (($this->size + $m - 1) / $m); |
|
| 1255 | + $num = (int)(($this->size + $m - 1) / $m); |
|
| 1256 | 1256 | |
| 1257 | 1257 | $bits += $num * (4 + $l); |
| 1258 | 1258 | |
@@ -1266,7 +1266,7 @@ discard block |
||
| 1266 | 1266 | unset($this->bstream); |
| 1267 | 1267 | $words = QRspec::maximumWords($this->mode, $version); |
| 1268 | 1268 | |
| 1269 | - if ($this->size > $words) { |
|
| 1269 | + if ($this->size>$words) { |
|
| 1270 | 1270 | $st1 = new self($this->mode, $words, $this->data); |
| 1271 | 1271 | $st2 = new self($this->mode, $this->size - $words, array_slice($this->data, $words)); |
| 1272 | 1272 | |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | break; |
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | - if ($ret < 0) { |
|
| 1296 | + if ($ret<0) { |
|
| 1297 | 1297 | return 0; |
| 1298 | 1298 | } |
| 1299 | 1299 | } |
@@ -1317,7 +1317,7 @@ discard block |
||
| 1317 | 1317 | //---------------------------------------------------------------------- |
| 1318 | 1318 | public function __construct($version = 0, $level = QR_ECLEVEL_L) |
| 1319 | 1319 | { |
| 1320 | - if ($version < 0 || $version > QRSPEC_VERSION_MAX || $level > QR_ECLEVEL_H) { |
|
| 1320 | + if ($version<0 || $version>QRSPEC_VERSION_MAX || $level>QR_ECLEVEL_H) { |
|
| 1321 | 1321 | throw new Exception('Invalid version no'); |
| 1322 | 1322 | return false; |
| 1323 | 1323 | } |
@@ -1335,7 +1335,7 @@ discard block |
||
| 1335 | 1335 | //---------------------------------------------------------------------- |
| 1336 | 1336 | public function setVersion($version) |
| 1337 | 1337 | { |
| 1338 | - if ($version < 0 || $version > QRSPEC_VERSION_MAX) { |
|
| 1338 | + if ($version<0 || $version>QRSPEC_VERSION_MAX) { |
|
| 1339 | 1339 | throw new Exception('Invalid version no'); |
| 1340 | 1340 | return 0; |
| 1341 | 1341 | } |
@@ -1354,7 +1354,7 @@ discard block |
||
| 1354 | 1354 | //---------------------------------------------------------------------- |
| 1355 | 1355 | public function setErrorCorrectionLevel($level) |
| 1356 | 1356 | { |
| 1357 | - if ($level > QR_ECLEVEL_H) { |
|
| 1357 | + if ($level>QR_ECLEVEL_H) { |
|
| 1358 | 1358 | throw new Exception('Invalid ECLEVEL'); |
| 1359 | 1359 | return 0; |
| 1360 | 1360 | } |
@@ -1387,11 +1387,11 @@ discard block |
||
| 1387 | 1387 | |
| 1388 | 1388 | public function insertStructuredAppendHeader($size, $index, $parity) |
| 1389 | 1389 | { |
| 1390 | - if ($size > MAX_STRUCTURED_SYMBOLS) { |
|
| 1390 | + if ($size>MAX_STRUCTURED_SYMBOLS) { |
|
| 1391 | 1391 | throw new Exception('insertStructuredAppendHeader wrong size'); |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | - if ($index <= 0 || $index > MAX_STRUCTURED_SYMBOLS) { |
|
| 1394 | + if ($index<=0 || $index>MAX_STRUCTURED_SYMBOLS) { |
|
| 1395 | 1395 | throw new Exception('insertStructuredAppendHeader wrong index'); |
| 1396 | 1396 | } |
| 1397 | 1397 | |
@@ -1413,8 +1413,8 @@ discard block |
||
| 1413 | 1413 | $parity = 0; |
| 1414 | 1414 | |
| 1415 | 1415 | foreach ($this->items as $item) { |
| 1416 | - if ($item->mode != QR_MODE_STRUCTURE) { |
|
| 1417 | - for ($i = $item->size - 1; $i >= 0; $i--) { |
|
| 1416 | + if ($item->mode!=QR_MODE_STRUCTURE) { |
|
| 1417 | + for ($i = $item->size - 1; $i>=0; $i--) { |
|
| 1418 | 1418 | $parity ^= $item->data[$i]; |
| 1419 | 1419 | } |
| 1420 | 1420 | } |
@@ -1426,8 +1426,8 @@ discard block |
||
| 1426 | 1426 | //---------------------------------------------------------------------- |
| 1427 | 1427 | public static function checkModeNum($size, $data) |
| 1428 | 1428 | { |
| 1429 | - for ($i = 0; $i < $size; $i++) { |
|
| 1430 | - if ((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))) { |
|
| 1429 | + for ($i = 0; $i<$size; $i++) { |
|
| 1430 | + if ((ord($data[$i])<ord('0')) || (ord($data[$i])>ord('9'))) { |
|
| 1431 | 1431 | return false; |
| 1432 | 1432 | } |
| 1433 | 1433 | } |
@@ -1438,7 +1438,7 @@ discard block |
||
| 1438 | 1438 | //---------------------------------------------------------------------- |
| 1439 | 1439 | public static function estimateBitsModeNum($size) |
| 1440 | 1440 | { |
| 1441 | - $w = (int) $size / 3; |
|
| 1441 | + $w = (int)$size / 3; |
|
| 1442 | 1442 | $bits = $w * 10; |
| 1443 | 1443 | |
| 1444 | 1444 | switch ($size - $w * 3) { |
@@ -1470,14 +1470,14 @@ discard block |
||
| 1470 | 1470 | //---------------------------------------------------------------------- |
| 1471 | 1471 | public static function lookAnTable($c) |
| 1472 | 1472 | { |
| 1473 | - return ($c > 127) ? -1 : self::$anTable[$c]; |
|
| 1473 | + return ($c>127) ? -1 : self::$anTable[$c]; |
|
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | //---------------------------------------------------------------------- |
| 1477 | 1477 | public static function checkModeAn($size, $data) |
| 1478 | 1478 | { |
| 1479 | - for ($i = 0; $i < $size; $i++) { |
|
| 1480 | - if (self::lookAnTable(ord($data[$i])) == -1) { |
|
| 1479 | + for ($i = 0; $i<$size; $i++) { |
|
| 1480 | + if (self::lookAnTable(ord($data[$i]))==-1) { |
|
| 1481 | 1481 | return false; |
| 1482 | 1482 | } |
| 1483 | 1483 | } |
@@ -1488,7 +1488,7 @@ discard block |
||
| 1488 | 1488 | //---------------------------------------------------------------------- |
| 1489 | 1489 | public static function estimateBitsModeAn($size) |
| 1490 | 1490 | { |
| 1491 | - $w = (int) ($size / 2); |
|
| 1491 | + $w = (int)($size / 2); |
|
| 1492 | 1492 | $bits = $w * 11; |
| 1493 | 1493 | |
| 1494 | 1494 | if ($size & 1) { |
@@ -1507,7 +1507,7 @@ discard block |
||
| 1507 | 1507 | //---------------------------------------------------------------------- |
| 1508 | 1508 | public function estimateBitsModeKanji($size) |
| 1509 | 1509 | { |
| 1510 | - return (int) (($size / 2) * 13); |
|
| 1510 | + return (int)(($size / 2) * 13); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | //---------------------------------------------------------------------- |
@@ -1517,11 +1517,11 @@ discard block |
||
| 1517 | 1517 | return false; |
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | - for ($i = 0; $i < $size; $i += 2) { |
|
| 1520 | + for ($i = 0; $i<$size; $i += 2) { |
|
| 1521 | 1521 | $val = (ord($data[$i]) << 8) | ord($data[$i + 1]); |
| 1522 | - if ($val < 0x8140 |
|
| 1523 | - || ($val > 0x9ffc && $val < 0xe040) |
|
| 1524 | - || $val > 0xebbf) { |
|
| 1522 | + if ($val<0x8140 |
|
| 1523 | + || ($val>0x9ffc && $val<0xe040) |
|
| 1524 | + || $val>0xebbf) { |
|
| 1525 | 1525 | return false; |
| 1526 | 1526 | } |
| 1527 | 1527 | } |
@@ -1535,7 +1535,7 @@ discard block |
||
| 1535 | 1535 | |
| 1536 | 1536 | public static function check($mode, $size, $data) |
| 1537 | 1537 | { |
| 1538 | - if ($size <= 0) { |
|
| 1538 | + if ($size<=0) { |
|
| 1539 | 1539 | return false; |
| 1540 | 1540 | } |
| 1541 | 1541 | |
@@ -1572,11 +1572,11 @@ discard block |
||
| 1572 | 1572 | do { |
| 1573 | 1573 | $prev = $version; |
| 1574 | 1574 | $bits = $this->estimateBitStreamSize($prev); |
| 1575 | - $version = QRspec::getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
| 1576 | - if ($version < 0) { |
|
| 1575 | + $version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
| 1576 | + if ($version<0) { |
|
| 1577 | 1577 | return 0; |
| 1578 | 1578 | } |
| 1579 | - } while ($version > $prev); |
|
| 1579 | + } while ($version>$prev); |
|
| 1580 | 1580 | |
| 1581 | 1581 | return $version; |
| 1582 | 1582 | } |
@@ -1587,31 +1587,31 @@ discard block |
||
| 1587 | 1587 | $payload = $bits - 4 - QRspec::lengthIndicator($mode, $version); |
| 1588 | 1588 | switch ($mode) { |
| 1589 | 1589 | case QR_MODE_NUM: |
| 1590 | - $chunks = (int) ($payload / 10); |
|
| 1590 | + $chunks = (int)($payload / 10); |
|
| 1591 | 1591 | $remain = $payload - $chunks * 10; |
| 1592 | 1592 | $size = $chunks * 3; |
| 1593 | - if ($remain >= 7) { |
|
| 1593 | + if ($remain>=7) { |
|
| 1594 | 1594 | $size += 2; |
| 1595 | - } elseif ($remain >= 4) { |
|
| 1595 | + } elseif ($remain>=4) { |
|
| 1596 | 1596 | $size += 1; |
| 1597 | 1597 | } |
| 1598 | 1598 | break; |
| 1599 | 1599 | case QR_MODE_AN: |
| 1600 | - $chunks = (int) ($payload / 11); |
|
| 1600 | + $chunks = (int)($payload / 11); |
|
| 1601 | 1601 | $remain = $payload - $chunks * 11; |
| 1602 | 1602 | $size = $chunks * 2; |
| 1603 | - if ($remain >= 6) { |
|
| 1603 | + if ($remain>=6) { |
|
| 1604 | 1604 | $size++; |
| 1605 | 1605 | } |
| 1606 | 1606 | break; |
| 1607 | 1607 | case QR_MODE_8: |
| 1608 | - $size = (int) ($payload / 8); |
|
| 1608 | + $size = (int)($payload / 8); |
|
| 1609 | 1609 | break; |
| 1610 | 1610 | case QR_MODE_KANJI: |
| 1611 | - $size = (int) (($payload / 13) * 2); |
|
| 1611 | + $size = (int)(($payload / 13) * 2); |
|
| 1612 | 1612 | break; |
| 1613 | 1613 | case QR_MODE_STRUCTURE: |
| 1614 | - $size = (int) ($payload / 8); |
|
| 1614 | + $size = (int)($payload / 8); |
|
| 1615 | 1615 | break; |
| 1616 | 1616 | default: |
| 1617 | 1617 | $size = 0; |
@@ -1619,10 +1619,10 @@ discard block |
||
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | $maxsize = QRspec::maximumWords($mode, $version); |
| 1622 | - if ($size < 0) { |
|
| 1622 | + if ($size<0) { |
|
| 1623 | 1623 | $size = 0; |
| 1624 | 1624 | } |
| 1625 | - if ($size > $maxsize) { |
|
| 1625 | + if ($size>$maxsize) { |
|
| 1626 | 1626 | $size = $maxsize; |
| 1627 | 1627 | } |
| 1628 | 1628 | |
@@ -1637,7 +1637,7 @@ discard block |
||
| 1637 | 1637 | foreach ($this->items as $item) { |
| 1638 | 1638 | $bits = $item->encodeBitStream($this->version); |
| 1639 | 1639 | |
| 1640 | - if ($bits < 0) { |
|
| 1640 | + if ($bits<0) { |
|
| 1641 | 1641 | return 0; |
| 1642 | 1642 | } |
| 1643 | 1643 | |
@@ -1651,22 +1651,22 @@ discard block |
||
| 1651 | 1651 | public function convertData() |
| 1652 | 1652 | { |
| 1653 | 1653 | $ver = $this->estimateVersion(); |
| 1654 | - if ($ver > $this->getVersion()) { |
|
| 1654 | + if ($ver>$this->getVersion()) { |
|
| 1655 | 1655 | $this->setVersion($ver); |
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | - for (; ;) { |
|
| 1658 | + for (;;) { |
|
| 1659 | 1659 | $bits = $this->createBitStream(); |
| 1660 | 1660 | |
| 1661 | - if ($bits < 0) { |
|
| 1661 | + if ($bits<0) { |
|
| 1662 | 1662 | return 0; |
| 1663 | 1663 | } |
| 1664 | 1664 | |
| 1665 | - $ver = QRspec::getMinimumVersion((int) (($bits + 7) / 8), $this->level); |
|
| 1666 | - if ($ver < 0) { |
|
| 1665 | + $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
|
| 1666 | + if ($ver<0) { |
|
| 1667 | 1667 | throw new Exception('WRONG VERSION'); |
| 1668 | 1668 | return 0; |
| 1669 | - } elseif ($ver > $this->getVersion()) { |
|
| 1669 | + } elseif ($ver>$this->getVersion()) { |
|
| 1670 | 1670 | $this->setVersion($ver); |
| 1671 | 1671 | } else { |
| 1672 | 1672 | break; |
@@ -1683,35 +1683,35 @@ discard block |
||
| 1683 | 1683 | $maxwords = QRspec::getDataLength($this->version, $this->level); |
| 1684 | 1684 | $maxbits = $maxwords * 8; |
| 1685 | 1685 | |
| 1686 | - if ($maxbits == $bits) { |
|
| 1686 | + if ($maxbits==$bits) { |
|
| 1687 | 1687 | return 0; |
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | - if ($maxbits - $bits < 5) { |
|
| 1690 | + if ($maxbits - $bits<5) { |
|
| 1691 | 1691 | return $bstream->appendNum($maxbits - $bits, 0); |
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | 1694 | $bits += 4; |
| 1695 | - $words = (int) (($bits + 7) / 8); |
|
| 1695 | + $words = (int)(($bits + 7) / 8); |
|
| 1696 | 1696 | |
| 1697 | 1697 | $padding = new QRbitstream(); |
| 1698 | 1698 | $ret = $padding->appendNum($words * 8 - $bits + 4, 0); |
| 1699 | 1699 | |
| 1700 | - if ($ret < 0) { |
|
| 1700 | + if ($ret<0) { |
|
| 1701 | 1701 | return $ret; |
| 1702 | 1702 | } |
| 1703 | 1703 | |
| 1704 | 1704 | $padlen = $maxwords - $words; |
| 1705 | 1705 | |
| 1706 | - if ($padlen > 0) { |
|
| 1706 | + if ($padlen>0) { |
|
| 1707 | 1707 | $padbuf = []; |
| 1708 | - for ($i = 0; $i < $padlen; $i++) { |
|
| 1708 | + for ($i = 0; $i<$padlen; $i++) { |
|
| 1709 | 1709 | $padbuf[$i] = ($i & 1) ? 0x11 : 0xec; |
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | $ret = $padding->appendBytes($padlen, $padbuf); |
| 1713 | 1713 | |
| 1714 | - if ($ret < 0) { |
|
| 1714 | + if ($ret<0) { |
|
| 1715 | 1715 | return $ret; |
| 1716 | 1716 | } |
| 1717 | 1717 | } |
@@ -1724,7 +1724,7 @@ discard block |
||
| 1724 | 1724 | //---------------------------------------------------------------------- |
| 1725 | 1725 | public function mergeBitStream() |
| 1726 | 1726 | { |
| 1727 | - if ($this->convertData() < 0) { |
|
| 1727 | + if ($this->convertData()<0) { |
|
| 1728 | 1728 | return; |
| 1729 | 1729 | } |
| 1730 | 1730 | |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | |
| 1733 | 1733 | foreach ($this->items as $item) { |
| 1734 | 1734 | $ret = $bstream->append($item->bstream); |
| 1735 | - if ($ret < 0) { |
|
| 1735 | + if ($ret<0) { |
|
| 1736 | 1736 | return; |
| 1737 | 1737 | } |
| 1738 | 1738 | } |
@@ -1745,12 +1745,12 @@ discard block |
||
| 1745 | 1745 | { |
| 1746 | 1746 | $bstream = $this->mergeBitStream(); |
| 1747 | 1747 | |
| 1748 | - if ($bstream == null) { |
|
| 1748 | + if ($bstream==null) { |
|
| 1749 | 1749 | return; |
| 1750 | 1750 | } |
| 1751 | 1751 | |
| 1752 | 1752 | $ret = $this->appendPaddingBit($bstream); |
| 1753 | - if ($ret < 0) { |
|
| 1753 | + if ($ret<0) { |
|
| 1754 | 1754 | return; |
| 1755 | 1755 | } |
| 1756 | 1756 | |
@@ -1761,7 +1761,7 @@ discard block |
||
| 1761 | 1761 | public function getByteStream() |
| 1762 | 1762 | { |
| 1763 | 1763 | $bstream = $this->getBitStream(); |
| 1764 | - if ($bstream == null) { |
|
| 1764 | + if ($bstream==null) { |
|
| 1765 | 1765 | return; |
| 1766 | 1766 | } |
| 1767 | 1767 | |
@@ -1822,7 +1822,7 @@ discard block |
||
| 1822 | 1822 | $bstream->allocate($bits); |
| 1823 | 1823 | |
| 1824 | 1824 | $mask = 1 << ($bits - 1); |
| 1825 | - for ($i = 0; $i < $bits; $i++) { |
|
| 1825 | + for ($i = 0; $i<$bits; $i++) { |
|
| 1826 | 1826 | if ($num & $mask) { |
| 1827 | 1827 | $bstream->data[$i] = 1; |
| 1828 | 1828 | } else { |
@@ -1841,9 +1841,9 @@ discard block |
||
| 1841 | 1841 | $bstream->allocate($size * 8); |
| 1842 | 1842 | $p = 0; |
| 1843 | 1843 | |
| 1844 | - for ($i = 0; $i < $size; $i++) { |
|
| 1844 | + for ($i = 0; $i<$size; $i++) { |
|
| 1845 | 1845 | $mask = 0x80; |
| 1846 | - for ($j = 0; $j < 8; $j++) { |
|
| 1846 | + for ($j = 0; $j<8; $j++) { |
|
| 1847 | 1847 | if ($data[$i] & $mask) { |
| 1848 | 1848 | $bstream->data[$p] = 1; |
| 1849 | 1849 | } else { |
@@ -1864,11 +1864,11 @@ discard block |
||
| 1864 | 1864 | return 0; |
| 1865 | 1865 | } |
| 1866 | 1866 | |
| 1867 | - if ($arg->size() == 0) { |
|
| 1867 | + if ($arg->size()==0) { |
|
| 1868 | 1868 | return 0; |
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | - if ($this->size() == 0) { |
|
| 1871 | + if ($this->size()==0) { |
|
| 1872 | 1872 | $this->data = $arg->data; |
| 1873 | 1873 | |
| 1874 | 1874 | return 0; |
@@ -1882,7 +1882,7 @@ discard block |
||
| 1882 | 1882 | //---------------------------------------------------------------------- |
| 1883 | 1883 | public function appendNum($bits, $num) |
| 1884 | 1884 | { |
| 1885 | - if ($bits == 0) { |
|
| 1885 | + if ($bits==0) { |
|
| 1886 | 1886 | return 0; |
| 1887 | 1887 | } |
| 1888 | 1888 | |
@@ -1901,7 +1901,7 @@ discard block |
||
| 1901 | 1901 | //---------------------------------------------------------------------- |
| 1902 | 1902 | public function appendBytes($size, $data) |
| 1903 | 1903 | { |
| 1904 | - if ($size == 0) { |
|
| 1904 | + if ($size==0) { |
|
| 1905 | 1905 | return 0; |
| 1906 | 1906 | } |
| 1907 | 1907 | |
@@ -1922,18 +1922,18 @@ discard block |
||
| 1922 | 1922 | { |
| 1923 | 1923 | $size = $this->size(); |
| 1924 | 1924 | |
| 1925 | - if ($size == 0) { |
|
| 1925 | + if ($size==0) { |
|
| 1926 | 1926 | return []; |
| 1927 | 1927 | } |
| 1928 | 1928 | |
| 1929 | - $data = array_fill(0, (int) (($size + 7) / 8), 0); |
|
| 1930 | - $bytes = (int) ($size / 8); |
|
| 1929 | + $data = array_fill(0, (int)(($size + 7) / 8), 0); |
|
| 1930 | + $bytes = (int)($size / 8); |
|
| 1931 | 1931 | |
| 1932 | 1932 | $p = 0; |
| 1933 | 1933 | |
| 1934 | - for ($i = 0; $i < $bytes; $i++) { |
|
| 1934 | + for ($i = 0; $i<$bytes; $i++) { |
|
| 1935 | 1935 | $v = 0; |
| 1936 | - for ($j = 0; $j < 8; $j++) { |
|
| 1936 | + for ($j = 0; $j<8; $j++) { |
|
| 1937 | 1937 | $v = $v << 1; |
| 1938 | 1938 | $v |= $this->data[$p]; |
| 1939 | 1939 | $p++; |
@@ -1943,7 +1943,7 @@ discard block |
||
| 1943 | 1943 | |
| 1944 | 1944 | if ($size & 7) { |
| 1945 | 1945 | $v = 0; |
| 1946 | - for ($j = 0; $j < ($size & 7); $j++) { |
|
| 1946 | + for ($j = 0; $j<($size & 7); $j++) { |
|
| 1947 | 1947 | $v = $v << 1; |
| 1948 | 1948 | $v |= $this->data[$p]; |
| 1949 | 1949 | $p++; |
@@ -2005,27 +2005,27 @@ discard block |
||
| 2005 | 2005 | //---------------------------------------------------------------------- |
| 2006 | 2006 | public static function isdigitat($str, $pos) |
| 2007 | 2007 | { |
| 2008 | - if ($pos >= strlen($str)) { |
|
| 2008 | + if ($pos>=strlen($str)) { |
|
| 2009 | 2009 | return false; |
| 2010 | 2010 | } |
| 2011 | 2011 | |
| 2012 | - return (ord($str[$pos]) >= ord('0')) && (ord($str[$pos]) <= ord('9')); |
|
| 2012 | + return (ord($str[$pos])>=ord('0')) && (ord($str[$pos])<=ord('9')); |
|
| 2013 | 2013 | } |
| 2014 | 2014 | |
| 2015 | 2015 | //---------------------------------------------------------------------- |
| 2016 | 2016 | public static function isalnumat($str, $pos) |
| 2017 | 2017 | { |
| 2018 | - if ($pos >= strlen($str)) { |
|
| 2018 | + if ($pos>=strlen($str)) { |
|
| 2019 | 2019 | return false; |
| 2020 | 2020 | } |
| 2021 | 2021 | |
| 2022 | - return QRinput::lookAnTable(ord($str[$pos])) >= 0; |
|
| 2022 | + return QRinput::lookAnTable(ord($str[$pos]))>=0; |
|
| 2023 | 2023 | } |
| 2024 | 2024 | |
| 2025 | 2025 | //---------------------------------------------------------------------- |
| 2026 | 2026 | public function identifyMode($pos) |
| 2027 | 2027 | { |
| 2028 | - if ($pos >= strlen($this->dataStr)) { |
|
| 2028 | + if ($pos>=strlen($this->dataStr)) { |
|
| 2029 | 2029 | return QR_MODE_NUL; |
| 2030 | 2030 | } |
| 2031 | 2031 | |
@@ -2035,11 +2035,11 @@ discard block |
||
| 2035 | 2035 | return QR_MODE_NUM; |
| 2036 | 2036 | } elseif (self::isalnumat($this->dataStr, $pos)) { |
| 2037 | 2037 | return QR_MODE_AN; |
| 2038 | - } elseif ($this->modeHint == QR_MODE_KANJI) { |
|
| 2039 | - if ($pos + 1 < strlen($this->dataStr)) { |
|
| 2038 | + } elseif ($this->modeHint==QR_MODE_KANJI) { |
|
| 2039 | + if ($pos + 1<strlen($this->dataStr)) { |
|
| 2040 | 2040 | $d = $this->dataStr[$pos + 1]; |
| 2041 | 2041 | $word = (ord($c) << 8) | ord($d); |
| 2042 | - if (($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) { |
|
| 2042 | + if (($word>=0x8140 && $word<=0x9ffc) || ($word>=0xe040 && $word<=0xebbf)) { |
|
| 2043 | 2043 | return QR_MODE_KANJI; |
| 2044 | 2044 | } |
| 2045 | 2045 | } |
@@ -2061,25 +2061,25 @@ discard block |
||
| 2061 | 2061 | $run = $p; |
| 2062 | 2062 | $mode = $this->identifyMode($p); |
| 2063 | 2063 | |
| 2064 | - if ($mode == QR_MODE_8) { |
|
| 2064 | + if ($mode==QR_MODE_8) { |
|
| 2065 | 2065 | $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln |
| 2066 | 2066 | + QRinput::estimateBitsMode8(1) // + 4 + l8 |
| 2067 | 2067 | - QRinput::estimateBitsMode8($run + 1); // - 4 - l8 |
| 2068 | - if ($dif > 0) { |
|
| 2068 | + if ($dif>0) { |
|
| 2069 | 2069 | return $this->eat8(); |
| 2070 | 2070 | } |
| 2071 | 2071 | } |
| 2072 | - if ($mode == QR_MODE_AN) { |
|
| 2072 | + if ($mode==QR_MODE_AN) { |
|
| 2073 | 2073 | $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln |
| 2074 | 2074 | + QRinput::estimateBitsModeAn(1) // + 4 + la |
| 2075 | 2075 | - QRinput::estimateBitsModeAn($run + 1); // - 4 - la |
| 2076 | - if ($dif > 0) { |
|
| 2076 | + if ($dif>0) { |
|
| 2077 | 2077 | return $this->eatAn(); |
| 2078 | 2078 | } |
| 2079 | 2079 | } |
| 2080 | 2080 | |
| 2081 | 2081 | $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); |
| 2082 | - if ($ret < 0) { |
|
| 2082 | + if ($ret<0) { |
|
| 2083 | 2083 | return 0; |
| 2084 | 2084 | } |
| 2085 | 2085 | |
@@ -2105,7 +2105,7 @@ discard block |
||
| 2105 | 2105 | + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln |
| 2106 | 2106 | - QRinput::estimateBitsModeAn($q); // - 4 - la |
| 2107 | 2107 | |
| 2108 | - if ($dif < 0) { |
|
| 2108 | + if ($dif<0) { |
|
| 2109 | 2109 | break; |
| 2110 | 2110 | } else { |
| 2111 | 2111 | $p = $q; |
@@ -2121,13 +2121,13 @@ discard block |
||
| 2121 | 2121 | $dif = QRinput::estimateBitsModeAn($run) + 4 + $la |
| 2122 | 2122 | + QRinput::estimateBitsMode8(1) // + 4 + l8 |
| 2123 | 2123 | - QRinput::estimateBitsMode8($run + 1); // - 4 - l8 |
| 2124 | - if ($dif > 0) { |
|
| 2124 | + if ($dif>0) { |
|
| 2125 | 2125 | return $this->eat8(); |
| 2126 | 2126 | } |
| 2127 | 2127 | } |
| 2128 | 2128 | |
| 2129 | 2129 | $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); |
| 2130 | - if ($ret < 0) { |
|
| 2130 | + if ($ret<0) { |
|
| 2131 | 2131 | return 0; |
| 2132 | 2132 | } |
| 2133 | 2133 | |
@@ -2139,12 +2139,12 @@ discard block |
||
| 2139 | 2139 | { |
| 2140 | 2140 | $p = 0; |
| 2141 | 2141 | |
| 2142 | - while ($this->identifyMode($p) == QR_MODE_KANJI) { |
|
| 2142 | + while ($this->identifyMode($p)==QR_MODE_KANJI) { |
|
| 2143 | 2143 | $p += 2; |
| 2144 | 2144 | } |
| 2145 | 2145 | |
| 2146 | 2146 | $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); |
| 2147 | - if ($ret < 0) { |
|
| 2147 | + if ($ret<0) { |
|
| 2148 | 2148 | return 0; |
| 2149 | 2149 | } |
| 2150 | 2150 | |
@@ -2160,12 +2160,12 @@ discard block |
||
| 2160 | 2160 | $p = 1; |
| 2161 | 2161 | $dataStrLen = strlen($this->dataStr); |
| 2162 | 2162 | |
| 2163 | - while ($p < $dataStrLen) { |
|
| 2163 | + while ($p<$dataStrLen) { |
|
| 2164 | 2164 | $mode = $this->identifyMode($p); |
| 2165 | - if ($mode == QR_MODE_KANJI) { |
|
| 2165 | + if ($mode==QR_MODE_KANJI) { |
|
| 2166 | 2166 | break; |
| 2167 | 2167 | } |
| 2168 | - if ($mode == QR_MODE_NUM) { |
|
| 2168 | + if ($mode==QR_MODE_NUM) { |
|
| 2169 | 2169 | $q = $p; |
| 2170 | 2170 | while (self::isdigitat($this->dataStr, $q)) { |
| 2171 | 2171 | $q++; |
@@ -2173,12 +2173,12 @@ discard block |
||
| 2173 | 2173 | $dif = QRinput::estimateBitsMode8($p) // + 4 + l8 |
| 2174 | 2174 | + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln |
| 2175 | 2175 | - QRinput::estimateBitsMode8($q); // - 4 - l8 |
| 2176 | - if ($dif < 0) { |
|
| 2176 | + if ($dif<0) { |
|
| 2177 | 2177 | break; |
| 2178 | 2178 | } else { |
| 2179 | 2179 | $p = $q; |
| 2180 | 2180 | } |
| 2181 | - } elseif ($mode == QR_MODE_AN) { |
|
| 2181 | + } elseif ($mode==QR_MODE_AN) { |
|
| 2182 | 2182 | $q = $p; |
| 2183 | 2183 | while (self::isalnumat($this->dataStr, $q)) { |
| 2184 | 2184 | $q++; |
@@ -2186,7 +2186,7 @@ discard block |
||
| 2186 | 2186 | $dif = QRinput::estimateBitsMode8($p) // + 4 + l8 |
| 2187 | 2187 | + QRinput::estimateBitsModeAn($q - $p) + 4 + $la |
| 2188 | 2188 | - QRinput::estimateBitsMode8($q); // - 4 - l8 |
| 2189 | - if ($dif < 0) { |
|
| 2189 | + if ($dif<0) { |
|
| 2190 | 2190 | break; |
| 2191 | 2191 | } else { |
| 2192 | 2192 | $p = $q; |
@@ -2199,7 +2199,7 @@ discard block |
||
| 2199 | 2199 | $run = $p; |
| 2200 | 2200 | $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); |
| 2201 | 2201 | |
| 2202 | - if ($ret < 0) { |
|
| 2202 | + if ($ret<0) { |
|
| 2203 | 2203 | return 0; |
| 2204 | 2204 | } |
| 2205 | 2205 | |
@@ -2209,8 +2209,8 @@ discard block |
||
| 2209 | 2209 | //---------------------------------------------------------------------- |
| 2210 | 2210 | public function splitString() |
| 2211 | 2211 | { |
| 2212 | - while (strlen($this->dataStr) > 0) { |
|
| 2213 | - if ($this->dataStr == '') { |
|
| 2212 | + while (strlen($this->dataStr)>0) { |
|
| 2213 | + if ($this->dataStr=='') { |
|
| 2214 | 2214 | return 0; |
| 2215 | 2215 | } |
| 2216 | 2216 | |
@@ -2220,7 +2220,7 @@ discard block |
||
| 2220 | 2220 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
| 2221 | 2221 | case QR_MODE_AN: $length = $this->eatAn(); break; |
| 2222 | 2222 | case QR_MODE_KANJI: |
| 2223 | - if ($mode == QR_MODE_KANJI) { |
|
| 2223 | + if ($mode==QR_MODE_KANJI) { |
|
| 2224 | 2224 | $length = $this->eatKanji(); |
| 2225 | 2225 | } else { |
| 2226 | 2226 | $length = $this->eat8(); |
@@ -2230,10 +2230,10 @@ discard block |
||
| 2230 | 2230 | |
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | - if ($length == 0) { |
|
| 2233 | + if ($length==0) { |
|
| 2234 | 2234 | return 0; |
| 2235 | 2235 | } |
| 2236 | - if ($length < 0) { |
|
| 2236 | + if ($length<0) { |
|
| 2237 | 2237 | return 0; |
| 2238 | 2238 | } |
| 2239 | 2239 | |
@@ -2247,12 +2247,12 @@ discard block |
||
| 2247 | 2247 | $stringLen = strlen($this->dataStr); |
| 2248 | 2248 | $p = 0; |
| 2249 | 2249 | |
| 2250 | - while ($p < $stringLen) { |
|
| 2250 | + while ($p<$stringLen) { |
|
| 2251 | 2251 | $mode = $this->identifyMode(substr($this->dataStr, $p)); |
| 2252 | - if ($mode == QR_MODE_KANJI) { |
|
| 2252 | + if ($mode==QR_MODE_KANJI) { |
|
| 2253 | 2253 | $p += 2; |
| 2254 | 2254 | } else { |
| 2255 | - if (ord($this->dataStr[$p]) >= ord('a') && ord($this->dataStr[$p]) <= ord('z')) { |
|
| 2255 | + if (ord($this->dataStr[$p])>=ord('a') && ord($this->dataStr[$p])<=ord('z')) { |
|
| 2256 | 2256 | $this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32); |
| 2257 | 2257 | } |
| 2258 | 2258 | $p++; |
@@ -2265,7 +2265,7 @@ discard block |
||
| 2265 | 2265 | //---------------------------------------------------------------------- |
| 2266 | 2266 | public static function splitStringToQRinput($string, QRinput $input, $modeHint, $casesensitive = true) |
| 2267 | 2267 | { |
| 2268 | - if (is_null($string) || $string == '\0' || $string == '') { |
|
| 2268 | + if (is_null($string) || $string=='\0' || $string=='') { |
|
| 2269 | 2269 | throw new Exception('empty string!!!'); |
| 2270 | 2270 | } |
| 2271 | 2271 | |
@@ -2327,7 +2327,7 @@ discard block |
||
| 2327 | 2327 | //---------------------------------------------------------------------- |
| 2328 | 2328 | public function modnn($x) |
| 2329 | 2329 | { |
| 2330 | - while ($x >= $this->nn) { |
|
| 2330 | + while ($x>=$this->nn) { |
|
| 2331 | 2331 | $x -= $this->nn; |
| 2332 | 2332 | $x = ($x >> $this->mm) + ($x & $this->nn); |
| 2333 | 2333 | } |
@@ -2345,19 +2345,19 @@ discard block |
||
| 2345 | 2345 | $rs = null; |
| 2346 | 2346 | |
| 2347 | 2347 | // Check parameter ranges |
| 2348 | - if ($symsize < 0 || $symsize > 8) { |
|
| 2348 | + if ($symsize<0 || $symsize>8) { |
|
| 2349 | 2349 | return $rs; |
| 2350 | 2350 | } |
| 2351 | - if ($fcr < 0 || $fcr >= (1 << $symsize)) { |
|
| 2351 | + if ($fcr<0 || $fcr>=(1 << $symsize)) { |
|
| 2352 | 2352 | return $rs; |
| 2353 | 2353 | } |
| 2354 | - if ($prim <= 0 || $prim >= (1 << $symsize)) { |
|
| 2354 | + if ($prim<=0 || $prim>=(1 << $symsize)) { |
|
| 2355 | 2355 | return $rs; |
| 2356 | 2356 | } |
| 2357 | - if ($nroots < 0 || $nroots >= (1 << $symsize)) { |
|
| 2357 | + if ($nroots<0 || $nroots>=(1 << $symsize)) { |
|
| 2358 | 2358 | return $rs; |
| 2359 | 2359 | } // Can't have more roots than symbol values! |
| 2360 | - if ($pad < 0 || $pad >= ((1 << $symsize) - 1 - $nroots)) { |
|
| 2360 | + if ($pad<0 || $pad>=((1 << $symsize) - 1 - $nroots)) { |
|
| 2361 | 2361 | return $rs; |
| 2362 | 2362 | } // Too much padding |
| 2363 | 2363 | |
@@ -2378,7 +2378,7 @@ discard block |
||
| 2378 | 2378 | $rs->alpha_to[$A0] = 0; // alpha**-inf = 0 |
| 2379 | 2379 | $sr = 1; |
| 2380 | 2380 | |
| 2381 | - for ($i = 0; $i < $rs->nn; $i++) { |
|
| 2381 | + for ($i = 0; $i<$rs->nn; $i++) { |
|
| 2382 | 2382 | $rs->index_of[$sr] = $i; |
| 2383 | 2383 | $rs->alpha_to[$i] = $sr; |
| 2384 | 2384 | $sr <<= 1; |
@@ -2388,7 +2388,7 @@ discard block |
||
| 2388 | 2388 | $sr &= $rs->nn; |
| 2389 | 2389 | } |
| 2390 | 2390 | |
| 2391 | - if ($sr != 1) { |
|
| 2391 | + if ($sr!=1) { |
|
| 2392 | 2392 | // field generator polynomial is not primitive! |
| 2393 | 2393 | $rs = null; |
| 2394 | 2394 | |
@@ -2404,17 +2404,17 @@ discard block |
||
| 2404 | 2404 | $rs->gfpoly = $gfpoly; |
| 2405 | 2405 | |
| 2406 | 2406 | /* Find prim-th root of 1, used in decoding */ |
| 2407 | - for ($iprim = 1; ($iprim % $prim) != 0; $iprim += $rs->nn); // intentional empty-body loop! |
|
| 2407 | + for ($iprim = 1; ($iprim % $prim)!=0; $iprim += $rs->nn); // intentional empty-body loop! |
|
| 2408 | 2408 | |
| 2409 | - $rs->iprim = (int) ($iprim / $prim); |
|
| 2409 | + $rs->iprim = (int)($iprim / $prim); |
|
| 2410 | 2410 | $rs->genpoly[0] = 1; |
| 2411 | 2411 | |
| 2412 | - for ($i = 0, $root = $fcr * $prim; $i < $nroots; $i++, $root += $prim) { |
|
| 2412 | + for ($i = 0, $root = $fcr * $prim; $i<$nroots; $i++, $root += $prim) { |
|
| 2413 | 2413 | $rs->genpoly[$i + 1] = 1; |
| 2414 | 2414 | |
| 2415 | 2415 | // Multiply rs->genpoly[] by @**(root + x) |
| 2416 | - for ($j = $i; $j > 0; $j--) { |
|
| 2417 | - if ($rs->genpoly[$j] != 0) { |
|
| 2416 | + for ($j = $i; $j>0; $j--) { |
|
| 2417 | + if ($rs->genpoly[$j]!=0) { |
|
| 2418 | 2418 | $rs->genpoly[$j] = $rs->genpoly[$j - 1] ^ $rs->alpha_to[$rs->modnn($rs->index_of[$rs->genpoly[$j]] + $root)]; |
| 2419 | 2419 | } else { |
| 2420 | 2420 | $rs->genpoly[$j] = $rs->genpoly[$j - 1]; |
@@ -2425,7 +2425,7 @@ discard block |
||
| 2425 | 2425 | } |
| 2426 | 2426 | |
| 2427 | 2427 | // convert rs->genpoly[] to index form for quicker encoding |
| 2428 | - for ($i = 0; $i <= $nroots; $i++) { |
|
| 2428 | + for ($i = 0; $i<=$nroots; $i++) { |
|
| 2429 | 2429 | $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
| 2430 | 2430 | } |
| 2431 | 2431 | |
@@ -2449,23 +2449,23 @@ discard block |
||
| 2449 | 2449 | |
| 2450 | 2450 | $parity = array_fill(0, $NROOTS, 0); |
| 2451 | 2451 | |
| 2452 | - for ($i = 0; $i < ($NN - $NROOTS - $PAD); $i++) { |
|
| 2452 | + for ($i = 0; $i<($NN - $NROOTS - $PAD); $i++) { |
|
| 2453 | 2453 | $feedback = $INDEX_OF[$data[$i] ^ $parity[0]]; |
| 2454 | - if ($feedback != $A0) { |
|
| 2454 | + if ($feedback!=$A0) { |
|
| 2455 | 2455 | // feedback term is non-zero |
| 2456 | 2456 | |
| 2457 | 2457 | // This line is unnecessary when GENPOLY[NROOTS] is unity, as it must |
| 2458 | 2458 | // always be for the polynomials constructed by init_rs() |
| 2459 | 2459 | $feedback = $this->modnn($NN - $GENPOLY[$NROOTS] + $feedback); |
| 2460 | 2460 | |
| 2461 | - for ($j = 1; $j < $NROOTS; $j++) { |
|
| 2461 | + for ($j = 1; $j<$NROOTS; $j++) { |
|
| 2462 | 2462 | $parity[$j] ^= $ALPHA_TO[$this->modnn($feedback + $GENPOLY[$NROOTS - $j])]; |
| 2463 | 2463 | } |
| 2464 | 2464 | } |
| 2465 | 2465 | |
| 2466 | 2466 | // Shift |
| 2467 | 2467 | array_shift($parity); |
| 2468 | - if ($feedback != $A0) { |
|
| 2468 | + if ($feedback!=$A0) { |
|
| 2469 | 2469 | array_push($parity, $ALPHA_TO[$this->modnn($feedback + $GENPOLY[0])]); |
| 2470 | 2470 | } else { |
| 2471 | 2471 | array_push($parity, 0); |
@@ -2484,22 +2484,22 @@ discard block |
||
| 2484 | 2484 | public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
| 2485 | 2485 | { |
| 2486 | 2486 | foreach (self::$items as $rs) { |
| 2487 | - if ($rs->pad != $pad) { |
|
| 2487 | + if ($rs->pad!=$pad) { |
|
| 2488 | 2488 | continue; |
| 2489 | 2489 | } |
| 2490 | - if ($rs->nroots != $nroots) { |
|
| 2490 | + if ($rs->nroots!=$nroots) { |
|
| 2491 | 2491 | continue; |
| 2492 | 2492 | } |
| 2493 | - if ($rs->mm != $symsize) { |
|
| 2493 | + if ($rs->mm!=$symsize) { |
|
| 2494 | 2494 | continue; |
| 2495 | 2495 | } |
| 2496 | - if ($rs->gfpoly != $gfpoly) { |
|
| 2496 | + if ($rs->gfpoly!=$gfpoly) { |
|
| 2497 | 2497 | continue; |
| 2498 | 2498 | } |
| 2499 | - if ($rs->fcr != $fcr) { |
|
| 2499 | + if ($rs->fcr!=$fcr) { |
|
| 2500 | 2500 | continue; |
| 2501 | 2501 | } |
| 2502 | - if ($rs->prim != $prim) { |
|
| 2502 | + if ($rs->prim!=$prim) { |
|
| 2503 | 2503 | continue; |
| 2504 | 2504 | } |
| 2505 | 2505 | |
@@ -2562,7 +2562,7 @@ discard block |
||
| 2562 | 2562 | $blacks = 0; |
| 2563 | 2563 | $format = QRspec::getFormatInfo($mask, $level); |
| 2564 | 2564 | |
| 2565 | - for ($i = 0; $i < 8; $i++) { |
|
| 2565 | + for ($i = 0; $i<8; $i++) { |
|
| 2566 | 2566 | if ($format & 1) { |
| 2567 | 2567 | $blacks += 2; |
| 2568 | 2568 | $v = 0x85; |
@@ -2571,7 +2571,7 @@ discard block |
||
| 2571 | 2571 | } |
| 2572 | 2572 | |
| 2573 | 2573 | $frame[8][$width - 1 - $i] = chr($v); |
| 2574 | - if ($i < 6) { |
|
| 2574 | + if ($i<6) { |
|
| 2575 | 2575 | $frame[$i][8] = chr($v); |
| 2576 | 2576 | } else { |
| 2577 | 2577 | $frame[$i + 1][8] = chr($v); |
@@ -2579,7 +2579,7 @@ discard block |
||
| 2579 | 2579 | $format = $format >> 1; |
| 2580 | 2580 | } |
| 2581 | 2581 | |
| 2582 | - for ($i = 0; $i < 7; $i++) { |
|
| 2582 | + for ($i = 0; $i<7; $i++) { |
|
| 2583 | 2583 | if ($format & 1) { |
| 2584 | 2584 | $blacks += 2; |
| 2585 | 2585 | $v = 0x85; |
@@ -2588,7 +2588,7 @@ discard block |
||
| 2588 | 2588 | } |
| 2589 | 2589 | |
| 2590 | 2590 | $frame[$width - 7 + $i][8] = chr($v); |
| 2591 | - if ($i == 0) { |
|
| 2591 | + if ($i==0) { |
|
| 2592 | 2592 | $frame[8][7] = chr($v); |
| 2593 | 2593 | } else { |
| 2594 | 2594 | $frame[8][6 - $i] = chr($v); |
@@ -2623,7 +2623,7 @@ discard block |
||
| 2623 | 2623 | |
| 2624 | 2624 | public function mask4($x, $y) |
| 2625 | 2625 | { |
| 2626 | - return (((int) ($y / 2)) + ((int) ($x / 3))) & 1; |
|
| 2626 | + return (((int)($y / 2)) + ((int)($x / 3))) & 1; |
|
| 2627 | 2627 | } |
| 2628 | 2628 | |
| 2629 | 2629 | public function mask5($x, $y) |
@@ -2646,13 +2646,13 @@ discard block |
||
| 2646 | 2646 | { |
| 2647 | 2647 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
| 2648 | 2648 | |
| 2649 | - for ($y = 0; $y < $width; $y++) { |
|
| 2650 | - for ($x = 0; $x < $width; $x++) { |
|
| 2649 | + for ($y = 0; $y<$width; $y++) { |
|
| 2650 | + for ($x = 0; $x<$width; $x++) { |
|
| 2651 | 2651 | if (ord($frame[$y][$x]) & 0x80) { |
| 2652 | 2652 | $bitMask[$y][$x] = 0; |
| 2653 | 2653 | } else { |
| 2654 | 2654 | $maskFunc = call_user_func([$this, 'mask'.$maskNo], $x, $y); |
| 2655 | - $bitMask[$y][$x] = ($maskFunc == 0) ? 1 : 0; |
|
| 2655 | + $bitMask[$y][$x] = ($maskFunc==0) ? 1 : 0; |
|
| 2656 | 2656 | } |
| 2657 | 2657 | } |
| 2658 | 2658 | } |
@@ -2713,12 +2713,12 @@ discard block |
||
| 2713 | 2713 | |
| 2714 | 2714 | $d = $s; |
| 2715 | 2715 | |
| 2716 | - for ($y = 0; $y < $width; $y++) { |
|
| 2717 | - for ($x = 0; $x < $width; $x++) { |
|
| 2718 | - if ($bitMask[$y][$x] == 1) { |
|
| 2719 | - $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int) $bitMask[$y][$x]); |
|
| 2716 | + for ($y = 0; $y<$width; $y++) { |
|
| 2717 | + for ($x = 0; $x<$width; $x++) { |
|
| 2718 | + if ($bitMask[$y][$x]==1) { |
|
| 2719 | + $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]); |
|
| 2720 | 2720 | } |
| 2721 | - $b += (int) (ord($d[$y][$x]) & 1); |
|
| 2721 | + $b += (int)(ord($d[$y][$x]) & 1); |
|
| 2722 | 2722 | } |
| 2723 | 2723 | } |
| 2724 | 2724 | |
@@ -2740,20 +2740,20 @@ discard block |
||
| 2740 | 2740 | { |
| 2741 | 2741 | $demerit = 0; |
| 2742 | 2742 | |
| 2743 | - for ($i = 0; $i < $length; $i++) { |
|
| 2744 | - if ($this->runLength[$i] >= 5) { |
|
| 2743 | + for ($i = 0; $i<$length; $i++) { |
|
| 2744 | + if ($this->runLength[$i]>=5) { |
|
| 2745 | 2745 | $demerit += (N1 + ($this->runLength[$i] - 5)); |
| 2746 | 2746 | } |
| 2747 | 2747 | if ($i & 1) { |
| 2748 | - if (($i >= 3) && ($i < ($length - 2)) && ($this->runLength[$i] % 3 == 0)) { |
|
| 2749 | - $fact = (int) ($this->runLength[$i] / 3); |
|
| 2750 | - if (($this->runLength[$i - 2] == $fact) && |
|
| 2751 | - ($this->runLength[$i - 1] == $fact) && |
|
| 2752 | - ($this->runLength[$i + 1] == $fact) && |
|
| 2753 | - ($this->runLength[$i + 2] == $fact)) { |
|
| 2754 | - if (($this->runLength[$i - 3] < 0) || ($this->runLength[$i - 3] >= (4 * $fact))) { |
|
| 2748 | + if (($i>=3) && ($i<($length - 2)) && ($this->runLength[$i] % 3==0)) { |
|
| 2749 | + $fact = (int)($this->runLength[$i] / 3); |
|
| 2750 | + if (($this->runLength[$i - 2]==$fact) && |
|
| 2751 | + ($this->runLength[$i - 1]==$fact) && |
|
| 2752 | + ($this->runLength[$i + 1]==$fact) && |
|
| 2753 | + ($this->runLength[$i + 2]==$fact)) { |
|
| 2754 | + if (($this->runLength[$i - 3]<0) || ($this->runLength[$i - 3]>=(4 * $fact))) { |
|
| 2755 | 2755 | $demerit += N3; |
| 2756 | - } elseif ((($i + 3) >= $length) || ($this->runLength[$i + 3] >= (4 * $fact))) { |
|
| 2756 | + } elseif ((($i + 3)>=$length) || ($this->runLength[$i + 3]>=(4 * $fact))) { |
|
| 2757 | 2757 | $demerit += N3; |
| 2758 | 2758 | } |
| 2759 | 2759 | } |
@@ -2770,18 +2770,18 @@ discard block |
||
| 2770 | 2770 | $head = 0; |
| 2771 | 2771 | $demerit = 0; |
| 2772 | 2772 | |
| 2773 | - for ($y = 0; $y < $width; $y++) { |
|
| 2773 | + for ($y = 0; $y<$width; $y++) { |
|
| 2774 | 2774 | $head = 0; |
| 2775 | 2775 | $this->runLength[0] = 1; |
| 2776 | 2776 | |
| 2777 | 2777 | $frameY = $frame[$y]; |
| 2778 | 2778 | |
| 2779 | - if ($y > 0) { |
|
| 2779 | + if ($y>0) { |
|
| 2780 | 2780 | $frameYM = $frame[$y - 1]; |
| 2781 | 2781 | } |
| 2782 | 2782 | |
| 2783 | - for ($x = 0; $x < $width; $x++) { |
|
| 2784 | - if (($x > 0) && ($y > 0)) { |
|
| 2783 | + for ($x = 0; $x<$width; $x++) { |
|
| 2784 | + if (($x>0) && ($y>0)) { |
|
| 2785 | 2785 | $b22 = ord($frameY[$x]) & ord($frameY[$x - 1]) & ord($frameYM[$x]) & ord($frameYM[$x - 1]); |
| 2786 | 2786 | $w22 = ord($frameY[$x]) | ord($frameY[$x - 1]) | ord($frameYM[$x]) | ord($frameYM[$x - 1]); |
| 2787 | 2787 | |
@@ -2789,11 +2789,11 @@ discard block |
||
| 2789 | 2789 | $demerit += N2; |
| 2790 | 2790 | } |
| 2791 | 2791 | } |
| 2792 | - if (($x == 0) && (ord($frameY[$x]) & 1)) { |
|
| 2792 | + if (($x==0) && (ord($frameY[$x]) & 1)) { |
|
| 2793 | 2793 | $this->runLength[0] = -1; |
| 2794 | 2794 | $head = 1; |
| 2795 | 2795 | $this->runLength[$head] = 1; |
| 2796 | - } elseif ($x > 0) { |
|
| 2796 | + } elseif ($x>0) { |
|
| 2797 | 2797 | if ((ord($frameY[$x]) ^ ord($frameY[$x - 1])) & 1) { |
| 2798 | 2798 | $head++; |
| 2799 | 2799 | $this->runLength[$head] = 1; |
@@ -2806,16 +2806,16 @@ discard block |
||
| 2806 | 2806 | $demerit += $this->calcN1N3($head + 1); |
| 2807 | 2807 | } |
| 2808 | 2808 | |
| 2809 | - for ($x = 0; $x < $width; $x++) { |
|
| 2809 | + for ($x = 0; $x<$width; $x++) { |
|
| 2810 | 2810 | $head = 0; |
| 2811 | 2811 | $this->runLength[0] = 1; |
| 2812 | 2812 | |
| 2813 | - for ($y = 0; $y < $width; $y++) { |
|
| 2814 | - if ($y == 0 && (ord($frame[$y][$x]) & 1)) { |
|
| 2813 | + for ($y = 0; $y<$width; $y++) { |
|
| 2814 | + if ($y==0 && (ord($frame[$y][$x]) & 1)) { |
|
| 2815 | 2815 | $this->runLength[0] = -1; |
| 2816 | 2816 | $head = 1; |
| 2817 | 2817 | $this->runLength[$head] = 1; |
| 2818 | - } elseif ($y > 0) { |
|
| 2818 | + } elseif ($y>0) { |
|
| 2819 | 2819 | if ((ord($frame[$y][$x]) ^ ord($frame[$y - 1][$x])) & 1) { |
| 2820 | 2820 | $head++; |
| 2821 | 2821 | $this->runLength[$head] = 1; |
@@ -2840,9 +2840,9 @@ discard block |
||
| 2840 | 2840 | |
| 2841 | 2841 | $checked_masks = [0, 1, 2, 3, 4, 5, 6, 7]; |
| 2842 | 2842 | |
| 2843 | - if (QR_FIND_FROM_RANDOM !== false) { |
|
| 2843 | + if (QR_FIND_FROM_RANDOM!==false) { |
|
| 2844 | 2844 | $howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9); |
| 2845 | - for ($i = 0; $i < $howManuOut; $i++) { |
|
| 2845 | + for ($i = 0; $i<$howManuOut; $i++) { |
|
| 2846 | 2846 | $remPos = rand(0, count($checked_masks) - 1); |
| 2847 | 2847 | unset($checked_masks[$remPos]); |
| 2848 | 2848 | $checked_masks = array_values($checked_masks); |
@@ -2858,11 +2858,11 @@ discard block |
||
| 2858 | 2858 | $blacks = 0; |
| 2859 | 2859 | $blacks = $this->makeMaskNo($i, $width, $frame, $mask); |
| 2860 | 2860 | $blacks += $this->writeFormatInformation($width, $mask, $i, $level); |
| 2861 | - $blacks = (int) (100 * $blacks / ($width * $width)); |
|
| 2862 | - $demerit = (int) ((int) (abs($blacks - 50) / 5) * N4); |
|
| 2861 | + $blacks = (int)(100 * $blacks / ($width * $width)); |
|
| 2862 | + $demerit = (int)((int)(abs($blacks - 50) / 5) * N4); |
|
| 2863 | 2863 | $demerit += $this->evaluateSymbol($width, $mask); |
| 2864 | 2864 | |
| 2865 | - if ($demerit < $minDemerit) { |
|
| 2865 | + if ($demerit<$minDemerit) { |
|
| 2866 | 2866 | $minDemerit = $demerit; |
| 2867 | 2867 | $bestMask = $mask; |
| 2868 | 2868 | $bestMaskNum = $i; |
@@ -2955,7 +2955,7 @@ discard block |
||
| 2955 | 2955 | $this->blocks = QRspec::rsBlockNum($spec); |
| 2956 | 2956 | |
| 2957 | 2957 | $ret = $this->init($spec); |
| 2958 | - if ($ret < 0) { |
|
| 2958 | + if ($ret<0) { |
|
| 2959 | 2959 | throw new Exception('block alloc error'); |
| 2960 | 2960 | return; |
| 2961 | 2961 | } |
@@ -2973,7 +2973,7 @@ discard block |
||
| 2973 | 2973 | $blockNo = 0; |
| 2974 | 2974 | $dataPos = 0; |
| 2975 | 2975 | $eccPos = 0; |
| 2976 | - for ($i = 0; $i < QRspec::rsBlockNum1($spec); $i++) { |
|
| 2976 | + for ($i = 0; $i<QRspec::rsBlockNum1($spec); $i++) { |
|
| 2977 | 2977 | $ecc = array_slice($this->ecccode, $eccPos); |
| 2978 | 2978 | $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs); |
| 2979 | 2979 | $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc); |
@@ -2983,7 +2983,7 @@ discard block |
||
| 2983 | 2983 | $blockNo++; |
| 2984 | 2984 | } |
| 2985 | 2985 | |
| 2986 | - if (QRspec::rsBlockNum2($spec) == 0) { |
|
| 2986 | + if (QRspec::rsBlockNum2($spec)==0) { |
|
| 2987 | 2987 | return 0; |
| 2988 | 2988 | } |
| 2989 | 2989 | |
@@ -2991,11 +2991,11 @@ discard block |
||
| 2991 | 2991 | $el = QRspec::rsEccCodes2($spec); |
| 2992 | 2992 | $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); |
| 2993 | 2993 | |
| 2994 | - if ($rs == null) { |
|
| 2994 | + if ($rs==null) { |
|
| 2995 | 2995 | return 0; |
| 2996 | 2996 | } |
| 2997 | 2997 | |
| 2998 | - for ($i = 0; $i < QRspec::rsBlockNum2($spec); $i++) { |
|
| 2998 | + for ($i = 0; $i<QRspec::rsBlockNum2($spec); $i++) { |
|
| 2999 | 2999 | $ecc = array_slice($this->ecccode, $eccPos); |
| 3000 | 3000 | $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs); |
| 3001 | 3001 | $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc); |
@@ -3013,14 +3013,14 @@ discard block |
||
| 3013 | 3013 | { |
| 3014 | 3014 | $ret; |
| 3015 | 3015 | |
| 3016 | - if ($this->count < $this->dataLength) { |
|
| 3016 | + if ($this->count<$this->dataLength) { |
|
| 3017 | 3017 | $row = $this->count % $this->blocks; |
| 3018 | 3018 | $col = $this->count / $this->blocks; |
| 3019 | - if ($col >= $this->rsblocks[0]->dataLength) { |
|
| 3019 | + if ($col>=$this->rsblocks[0]->dataLength) { |
|
| 3020 | 3020 | $row += $this->b1; |
| 3021 | 3021 | } |
| 3022 | 3022 | $ret = $this->rsblocks[$row]->data[$col]; |
| 3023 | - } elseif ($this->count < $this->dataLength + $this->eccLength) { |
|
| 3023 | + } elseif ($this->count<$this->dataLength + $this->eccLength) { |
|
| 3024 | 3024 | $row = ($this->count - $this->dataLength) % $this->blocks; |
| 3025 | 3025 | $col = ($this->count - $this->dataLength) / $this->blocks; |
| 3026 | 3026 | $ret = $this->rsblocks[$row]->ecc[$col]; |
@@ -3044,10 +3044,10 @@ discard block |
||
| 3044 | 3044 | //---------------------------------------------------------------------- |
| 3045 | 3045 | public function encodeMask(QRinput $input, $mask) |
| 3046 | 3046 | { |
| 3047 | - if ($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) { |
|
| 3047 | + if ($input->getVersion()<0 || $input->getVersion()>QRSPEC_VERSION_MAX) { |
|
| 3048 | 3048 | throw new Exception('wrong version'); |
| 3049 | 3049 | } |
| 3050 | - if ($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) { |
|
| 3050 | + if ($input->getErrorCorrectionLevel()>QR_ECLEVEL_H) { |
|
| 3051 | 3051 | throw new Exception('wrong level'); |
| 3052 | 3052 | } |
| 3053 | 3053 | |
@@ -3065,12 +3065,12 @@ discard block |
||
| 3065 | 3065 | } |
| 3066 | 3066 | |
| 3067 | 3067 | // inteleaved data and ecc codes |
| 3068 | - for ($i = 0; $i < $raw->dataLength + $raw->eccLength; $i++) { |
|
| 3068 | + for ($i = 0; $i<$raw->dataLength + $raw->eccLength; $i++) { |
|
| 3069 | 3069 | $code = $raw->getCode(); |
| 3070 | 3070 | $bit = 0x80; |
| 3071 | - for ($j = 0; $j < 8; $j++) { |
|
| 3071 | + for ($j = 0; $j<8; $j++) { |
|
| 3072 | 3072 | $addr = $filler->next(); |
| 3073 | - $filler->setFrameAt($addr, 0x02 | (($bit & $code) != 0)); |
|
| 3073 | + $filler->setFrameAt($addr, 0x02 | (($bit & $code)!=0)); |
|
| 3074 | 3074 | $bit = $bit >> 1; |
| 3075 | 3075 | } |
| 3076 | 3076 | } |
@@ -3081,7 +3081,7 @@ discard block |
||
| 3081 | 3081 | |
| 3082 | 3082 | // remainder bits |
| 3083 | 3083 | $j = QRspec::getRemainder($version); |
| 3084 | - for ($i = 0; $i < $j; $i++) { |
|
| 3084 | + for ($i = 0; $i<$j; $i++) { |
|
| 3085 | 3085 | $addr = $filler->next(); |
| 3086 | 3086 | $filler->setFrameAt($addr, 0x02); |
| 3087 | 3087 | } |
@@ -3091,7 +3091,7 @@ discard block |
||
| 3091 | 3091 | |
| 3092 | 3092 | // masking |
| 3093 | 3093 | $maskObj = new QRmask(); |
| 3094 | - if ($mask < 0) { |
|
| 3094 | + if ($mask<0) { |
|
| 3095 | 3095 | if (QR_FIND_BEST_MASK) { |
| 3096 | 3096 | $masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel()); |
| 3097 | 3097 | } else { |
@@ -3101,7 +3101,7 @@ discard block |
||
| 3101 | 3101 | $masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel()); |
| 3102 | 3102 | } |
| 3103 | 3103 | |
| 3104 | - if ($masked == null) { |
|
| 3104 | + if ($masked==null) { |
|
| 3105 | 3105 | return; |
| 3106 | 3106 | } |
| 3107 | 3107 | |
@@ -3123,18 +3123,18 @@ discard block |
||
| 3123 | 3123 | //---------------------------------------------------------------------- |
| 3124 | 3124 | public function encodeString8bit($string, $version, $level) |
| 3125 | 3125 | { |
| 3126 | - if (string == null) { |
|
| 3126 | + if (string==null) { |
|
| 3127 | 3127 | throw new Exception('empty string!'); |
| 3128 | 3128 | return; |
| 3129 | 3129 | } |
| 3130 | 3130 | |
| 3131 | 3131 | $input = new QRinput($version, $level); |
| 3132 | - if ($input == null) { |
|
| 3132 | + if ($input==null) { |
|
| 3133 | 3133 | return; |
| 3134 | 3134 | } |
| 3135 | 3135 | |
| 3136 | 3136 | $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string)); |
| 3137 | - if ($ret < 0) { |
|
| 3137 | + if ($ret<0) { |
|
| 3138 | 3138 | unset($input); |
| 3139 | 3139 | |
| 3140 | 3140 | return; |
@@ -3146,18 +3146,18 @@ discard block |
||
| 3146 | 3146 | //---------------------------------------------------------------------- |
| 3147 | 3147 | public function encodeString($string, $version, $level, $hint, $casesensitive) |
| 3148 | 3148 | { |
| 3149 | - if ($hint != QR_MODE_8 && $hint != QR_MODE_KANJI) { |
|
| 3149 | + if ($hint!=QR_MODE_8 && $hint!=QR_MODE_KANJI) { |
|
| 3150 | 3150 | throw new Exception('bad hint'); |
| 3151 | 3151 | return; |
| 3152 | 3152 | } |
| 3153 | 3153 | |
| 3154 | 3154 | $input = new QRinput($version, $level); |
| 3155 | - if ($input == null) { |
|
| 3155 | + if ($input==null) { |
|
| 3156 | 3156 | return; |
| 3157 | 3157 | } |
| 3158 | 3158 | |
| 3159 | 3159 | $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive); |
| 3160 | - if ($ret < 0) { |
|
| 3160 | + if ($ret<0) { |
|
| 3161 | 3161 | return; |
| 3162 | 3162 | } |
| 3163 | 3163 | |
@@ -3243,7 +3243,7 @@ discard block |
||
| 3243 | 3243 | public function next() |
| 3244 | 3244 | { |
| 3245 | 3245 | do { |
| 3246 | - if ($this->bit == -1) { |
|
| 3246 | + if ($this->bit==-1) { |
|
| 3247 | 3247 | $this->bit = 0; |
| 3248 | 3248 | |
| 3249 | 3249 | return ['x'=>$this->x, 'y'=>$this->y]; |
@@ -3253,7 +3253,7 @@ discard block |
||
| 3253 | 3253 | $y = $this->y; |
| 3254 | 3254 | $w = $this->width; |
| 3255 | 3255 | |
| 3256 | - if ($this->bit == 0) { |
|
| 3256 | + if ($this->bit==0) { |
|
| 3257 | 3257 | $x--; |
| 3258 | 3258 | $this->bit++; |
| 3259 | 3259 | } else { |
@@ -3262,28 +3262,28 @@ discard block |
||
| 3262 | 3262 | $this->bit--; |
| 3263 | 3263 | } |
| 3264 | 3264 | |
| 3265 | - if ($this->dir < 0) { |
|
| 3266 | - if ($y < 0) { |
|
| 3265 | + if ($this->dir<0) { |
|
| 3266 | + if ($y<0) { |
|
| 3267 | 3267 | $y = 0; |
| 3268 | 3268 | $x -= 2; |
| 3269 | 3269 | $this->dir = 1; |
| 3270 | - if ($x == 6) { |
|
| 3270 | + if ($x==6) { |
|
| 3271 | 3271 | $x--; |
| 3272 | 3272 | $y = 9; |
| 3273 | 3273 | } |
| 3274 | 3274 | } |
| 3275 | 3275 | } else { |
| 3276 | - if ($y == $w) { |
|
| 3276 | + if ($y==$w) { |
|
| 3277 | 3277 | $y = $w - 1; |
| 3278 | 3278 | $x -= 2; |
| 3279 | 3279 | $this->dir = -1; |
| 3280 | - if ($x == 6) { |
|
| 3280 | + if ($x==6) { |
|
| 3281 | 3281 | $x--; |
| 3282 | 3282 | $y -= 8; |
| 3283 | 3283 | } |
| 3284 | 3284 | } |
| 3285 | 3285 | } |
| 3286 | - if ($x < 0 || $y < 0) { |
|
| 3286 | + if ($x<0 || $y<0) { |
|
| 3287 | 3287 | return; |
| 3288 | 3288 | } |
| 3289 | 3289 | |
@@ -3378,7 +3378,7 @@ discard block |
||
| 3378 | 3378 | |
| 3379 | 3379 | QRtools::markTime('after_encode'); |
| 3380 | 3380 | |
| 3381 | - if ($outfile !== false) { |
|
| 3381 | + if ($outfile!==false) { |
|
| 3382 | 3382 | file_put_contents($outfile, implode("\n", QRtools::binarize($code->data))); |
| 3383 | 3383 | } else { |
| 3384 | 3384 | return QRtools::binarize($code->data); |
@@ -3394,11 +3394,11 @@ discard block |
||
| 3394 | 3394 | $err = ob_get_contents(); |
| 3395 | 3395 | ob_end_clean(); |
| 3396 | 3396 | |
| 3397 | - if ($err != '') { |
|
| 3397 | + if ($err!='') { |
|
| 3398 | 3398 | QRtools::log($outfile, $err); |
| 3399 | 3399 | } |
| 3400 | 3400 | |
| 3401 | - $maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin)); |
|
| 3401 | + $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin)); |
|
| 3402 | 3402 | |
| 3403 | 3403 | QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin, $saveandprint, $this->back_color, $this->fore_color); |
| 3404 | 3404 | } catch (Exception $e) { |
@@ -3415,11 +3415,11 @@ discard block |
||
| 3415 | 3415 | $err = ob_get_contents(); |
| 3416 | 3416 | ob_end_clean(); |
| 3417 | 3417 | |
| 3418 | - if ($err != '') { |
|
| 3418 | + if ($err!='') { |
|
| 3419 | 3419 | QRtools::log($outfile, $err); |
| 3420 | 3420 | } |
| 3421 | 3421 | |
| 3422 | - $maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin)); |
|
| 3422 | + $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin)); |
|
| 3423 | 3423 | |
| 3424 | 3424 | QRvect::eps($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin, $saveandprint, $this->back_color, $this->fore_color, $this->cmyk); |
| 3425 | 3425 | } catch (Exception $e) { |
@@ -3436,11 +3436,11 @@ discard block |
||
| 3436 | 3436 | $err = ob_get_contents(); |
| 3437 | 3437 | ob_end_clean(); |
| 3438 | 3438 | |
| 3439 | - if ($err != '') { |
|
| 3439 | + if ($err!='') { |
|
| 3440 | 3440 | QRtools::log($outfile, $err); |
| 3441 | 3441 | } |
| 3442 | 3442 | |
| 3443 | - $maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin)); |
|
| 3443 | + $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin)); |
|
| 3444 | 3444 | |
| 3445 | 3445 | QRvect::svg($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin, $saveandprint, $this->back_color, $this->fore_color); |
| 3446 | 3446 | } catch (Exception $e) { |
@@ -3483,12 +3483,12 @@ discard block |
||
| 3483 | 3483 | { |
| 3484 | 3484 | $vect = self::vectEPS($frame, $pixelPerPoint, $outerFrame, $back_color, $fore_color, $cmyk); |
| 3485 | 3485 | |
| 3486 | - if ($filename === false) { |
|
| 3486 | + if ($filename===false) { |
|
| 3487 | 3487 | header('Content-Type: application/postscript'); |
| 3488 | 3488 | header('Content-Disposition: filename="qrcode.eps"'); |
| 3489 | 3489 | echo $vect; |
| 3490 | 3490 | } else { |
| 3491 | - if ($saveandprint === true) { |
|
| 3491 | + if ($saveandprint===true) { |
|
| 3492 | 3492 | QRtools::save($vect, $filename); |
| 3493 | 3493 | header('Content-Type: application/postscript'); |
| 3494 | 3494 | header('Content-Disposition: filename="qrcode.eps"'); |
@@ -3564,9 +3564,9 @@ discard block |
||
| 3564 | 3564 | |
| 3565 | 3565 | // Convert the matrix into pixels |
| 3566 | 3566 | |
| 3567 | - for ($i = 0; $i < $h; $i++) { |
|
| 3568 | - for ($j = 0; $j < $w; $j++) { |
|
| 3569 | - if ($frame[$i][$j] == '1') { |
|
| 3567 | + for ($i = 0; $i<$h; $i++) { |
|
| 3568 | + for ($j = 0; $j<$w; $j++) { |
|
| 3569 | + if ($frame[$i][$j]=='1') { |
|
| 3570 | 3570 | $y = $h - 1 - $i; |
| 3571 | 3571 | $x = $j; |
| 3572 | 3572 | $output .= $x.' '.$y.' 1 1 F'."\n"; |
@@ -3584,12 +3584,12 @@ discard block |
||
| 3584 | 3584 | { |
| 3585 | 3585 | $vect = self::vectSVG($frame, $pixelPerPoint, $outerFrame, $back_color, $fore_color); |
| 3586 | 3586 | |
| 3587 | - if ($filename === false) { |
|
| 3587 | + if ($filename===false) { |
|
| 3588 | 3588 | header('Content-Type: image/svg+xml'); |
| 3589 | 3589 | //header('Content-Disposition: attachment, filename="qrcode.svg"'); |
| 3590 | 3590 | echo $vect; |
| 3591 | 3591 | } else { |
| 3592 | - if ($saveandprint === true) { |
|
| 3592 | + if ($saveandprint===true) { |
|
| 3593 | 3593 | QRtools::save($vect, $filename); |
| 3594 | 3594 | header('Content-Type: image/svg+xml'); |
| 3595 | 3595 | //header('Content-Disposition: filename="'.$filename.'"'); |
@@ -3634,9 +3634,9 @@ discard block |
||
| 3634 | 3634 | |
| 3635 | 3635 | // Convert the matrix into pixels |
| 3636 | 3636 | |
| 3637 | - for ($i = 0; $i < $h; $i++) { |
|
| 3638 | - for ($j = 0; $j < $w; $j++) { |
|
| 3639 | - if ($frame[$i][$j] == '1') { |
|
| 3637 | + for ($i = 0; $i<$h; $i++) { |
|
| 3638 | + for ($j = 0; $j<$w; $j++) { |
|
| 3639 | + if ($frame[$i][$j]=='1') { |
|
| 3640 | 3640 | $y = ($i + $outerFrame) * $pixelPerPoint; |
| 3641 | 3641 | $x = ($j + $outerFrame) * $pixelPerPoint; |
| 3642 | 3642 | $output .= '<use x="'.$x.'" y="'.$y.'" xlink:href="#p" />'."\n"; |