@@ -90,7 +90,7 @@ |
||
| 90 | 90 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
| 91 | 91 | if(stripos($content_type, 'multipart') === 0) { |
| 92 | 92 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
| 93 | - }else{ |
|
| 93 | + } else{ |
|
| 94 | 94 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -162,7 +162,7 @@ |
||
| 162 | 162 | protected function parse(){ |
| 163 | 163 | if ($this->header === null) { |
| 164 | 164 | $body = $this->findHeaders(); |
| 165 | - }else{ |
|
| 165 | + } else{ |
|
| 166 | 166 | $body = $this->raw; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | if($value === null) { |
| 81 | 81 | if(isset(self::$config[$part])) { |
| 82 | 82 | $value = self::$config[$part]; |
| 83 | - }else{ |
|
| 83 | + } else{ |
|
| 84 | 84 | break; |
| 85 | 85 | } |
| 86 | - }else{ |
|
| 86 | + } else{ |
|
| 87 | 87 | if(isset($value[$part])) { |
| 88 | 88 | $value = $value[$part]; |
| 89 | - }else{ |
|
| 89 | + } else{ |
|
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -232,11 +232,15 @@ discard block |
||
| 232 | 232 | $arrays = func_get_args(); |
| 233 | 233 | $base = array_shift($arrays); |
| 234 | 234 | |
| 235 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
| 235 | + if(!is_array($base)) { |
|
| 236 | + $base = empty($base) ? array() : array($base); |
|
| 237 | + } |
|
| 236 | 238 | |
| 237 | 239 | foreach($arrays as $append) { |
| 238 | 240 | |
| 239 | - if(!is_array($append)) $append = array($append); |
|
| 241 | + if(!is_array($append)) { |
|
| 242 | + $append = array($append); |
|
| 243 | + } |
|
| 240 | 244 | |
| 241 | 245 | foreach($append as $key => $value) { |
| 242 | 246 | |
@@ -248,7 +252,9 @@ discard block |
||
| 248 | 252 | if(is_array($value) or is_array($base[$key])) { |
| 249 | 253 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]); |
| 250 | 254 | } else if(is_numeric($key)) { |
| 251 | - if(!in_array($value, $base)) $base[] = $value; |
|
| 255 | + if(!in_array($value, $base)) { |
|
| 256 | + $base[] = $value; |
|
| 257 | + } |
|
| 252 | 258 | } else { |
| 253 | 259 | $base[$key] = $value; |
| 254 | 260 | } |
@@ -130,20 +130,20 @@ discard block |
||
| 130 | 130 | if(isset($this->attributes[$name]) && $strict === false) { |
| 131 | 131 | if ($this->attributize) { |
| 132 | 132 | $this->attributes[$name]->add($value, true); |
| 133 | - }else{ |
|
| 133 | + } else{ |
|
| 134 | 134 | if(isset($this->attributes[$name])) { |
| 135 | 135 | if (is_array($this->attributes[$name]) == false) { |
| 136 | 136 | $this->attributes[$name] = [$this->attributes[$name], $value]; |
| 137 | - }else{ |
|
| 137 | + } else{ |
|
| 138 | 138 | $this->attributes[$name][] = $value; |
| 139 | 139 | } |
| 140 | - }else{ |
|
| 140 | + } else{ |
|
| 141 | 141 | $this->attributes[$name] = $value; |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | - }elseif($this->attributize == false){ |
|
| 144 | + } elseif($this->attributize == false){ |
|
| 145 | 145 | $this->attributes[$name] = $value; |
| 146 | - }else{ |
|
| 146 | + } else{ |
|
| 147 | 147 | $this->attributes[$name] = new Attribute($name, $value); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | if ($prev_header !== null) { |
| 255 | 255 | $headers[$prev_header][] = $line; |
| 256 | 256 | } |
| 257 | - }elseif (substr($line, 0, 1) === " ") { |
|
| 257 | + } elseif (substr($line, 0, 1) === " ") { |
|
| 258 | 258 | $line = substr($line, 1); |
| 259 | 259 | $line = trim(rtrim($line)); |
| 260 | 260 | if ($prev_header !== null) { |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | if (is_array($headers[$prev_header])) { |
| 265 | 265 | $headers[$prev_header][] = $line; |
| 266 | - }else{ |
|
| 266 | + } else{ |
|
| 267 | 267 | $headers[$prev_header] .= $line; |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | - }else{ |
|
| 270 | + } else{ |
|
| 271 | 271 | if (($pos = strpos($line, ":")) > 0) { |
| 272 | 272 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
| 273 | 273 | $key = str_replace("-", "_", $key); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $value = trim(rtrim(substr($line, $pos + 1))); |
| 276 | 276 | if (isset($headers[$key])) { |
| 277 | 277 | $headers[$key][] = $value; |
| 278 | - }else{ |
|
| 278 | + } else{ |
|
| 279 | 279 | $headers[$key] = [$value]; |
| 280 | 280 | } |
| 281 | 281 | $prev_header = $key; |
@@ -284,7 +284,9 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | foreach($headers as $key => $values) { |
| 287 | - if (isset($imap_headers[$key])) continue; |
|
| 287 | + if (isset($imap_headers[$key])) { |
|
| 288 | + continue; |
|
| 289 | + } |
|
| 288 | 290 | $value = null; |
| 289 | 291 | switch($key){ |
| 290 | 292 | case 'from': |
@@ -421,9 +423,9 @@ discard block |
||
| 421 | 423 | return EncodingAliases::get($parameter->value, $this->fallback_encoding); |
| 422 | 424 | } |
| 423 | 425 | } |
| 424 | - }elseif (property_exists($structure, 'charset')) { |
|
| 426 | + } elseif (property_exists($structure, 'charset')) { |
|
| 425 | 427 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
| 426 | - }elseif (is_string($structure) === true){ |
|
| 428 | + } elseif (is_string($structure) === true){ |
|
| 427 | 429 | return mb_detect_encoding($structure); |
| 428 | 430 | } |
| 429 | 431 | |
@@ -470,9 +472,9 @@ discard block |
||
| 470 | 472 | } |
| 471 | 473 | } |
| 472 | 474 | } |
| 473 | - }elseif($decoder === 'iconv' && $is_utf8_base) { |
|
| 475 | + } elseif($decoder === 'iconv' && $is_utf8_base) { |
|
| 474 | 476 | $value = iconv_mime_decode($value); |
| 475 | - }elseif($is_utf8_base){ |
|
| 477 | + } elseif($is_utf8_base){ |
|
| 476 | 478 | $value = mb_decode_mimeheader($value); |
| 477 | 479 | } |
| 478 | 480 | |
@@ -505,7 +507,9 @@ discard block |
||
| 505 | 507 | * Try to extract the priority from a given raw header string |
| 506 | 508 | */ |
| 507 | 509 | private function findPriority() { |
| 508 | - if(($priority = $this->get("x_priority")) === null) return; |
|
| 510 | + if(($priority = $this->get("x_priority")) === null) { |
|
| 511 | + return; |
|
| 512 | + } |
|
| 509 | 513 | switch((int)"$priority"){ |
| 510 | 514 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 511 | 515 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -652,7 +656,7 @@ discard block |
||
| 652 | 656 | foreach ($this->attributes as $key => $value) { |
| 653 | 657 | if (is_array($value)) { |
| 654 | 658 | $value = implode(", ", $value); |
| 655 | - }else{ |
|
| 659 | + } else{ |
|
| 656 | 660 | $value = (string)$value; |
| 657 | 661 | } |
| 658 | 662 | // Only parse strings and don't parse any attributes like the user-agent |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | if(strtolower(substr($method, 0, 3)) === 'get') { |
| 301 | 301 | $name = Str::snake(substr($method, 3)); |
| 302 | 302 | return $this->get($name); |
| 303 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 303 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 304 | 304 | $name = Str::snake(substr($method, 3)); |
| 305 | 305 | |
| 306 | 306 | if(in_array($name, array_keys($this->attributes))) { |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | if ($this->getFlags()->get("seen") == null) { |
| 507 | 507 | $this->unsetFlag("Seen"); |
| 508 | 508 | } |
| 509 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
| 509 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
| 510 | 510 | $this->setFlag("Seen"); |
| 511 | 511 | } |
| 512 | 512 | } |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | private function fetchPart(Part $part) { |
| 551 | 551 | if ($part->isAttachment()) { |
| 552 | 552 | $this->fetchAttachment($part); |
| 553 | - }else{ |
|
| 553 | + } else{ |
|
| 554 | 554 | $encoding = $this->getEncoding($part); |
| 555 | 555 | |
| 556 | 556 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | |
| 576 | 576 | if (isset($this->bodies[$subtype])) { |
| 577 | 577 | $this->bodies[$subtype] .= "\n".$content; |
| 578 | - }else{ |
|
| 578 | + } else{ |
|
| 579 | 579 | $this->bodies[$subtype] = $content; |
| 580 | 580 | } |
| 581 | 581 | } |
@@ -746,9 +746,9 @@ discard block |
||
| 746 | 746 | return EncodingAliases::get($parameter->value); |
| 747 | 747 | } |
| 748 | 748 | } |
| 749 | - }elseif (property_exists($structure, 'charset')){ |
|
| 749 | + } elseif (property_exists($structure, 'charset')){ |
|
| 750 | 750 | return EncodingAliases::get($structure->charset); |
| 751 | - }elseif (is_string($structure) === true){ |
|
| 751 | + } elseif (is_string($structure) === true){ |
|
| 752 | 752 | return mb_detect_encoding($structure); |
| 753 | 753 | } |
| 754 | 754 | |
@@ -935,13 +935,15 @@ discard block |
||
| 935 | 935 | * @throws MessageHeaderFetchingException |
| 936 | 936 | */ |
| 937 | 937 | protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
| 938 | - if($expunge) $this->client->expunge(); |
|
| 938 | + if($expunge) { |
|
| 939 | + $this->client->expunge(); |
|
| 940 | + } |
|
| 939 | 941 | |
| 940 | 942 | $this->client->openFolder($folder->path); |
| 941 | 943 | |
| 942 | 944 | if ($this->sequence === IMAP::ST_UID) { |
| 943 | 945 | $sequence_id = $next_uid; |
| 944 | - }else{ |
|
| 946 | + } else{ |
|
| 945 | 947 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
| 946 | 948 | } |
| 947 | 949 | |
@@ -964,7 +966,9 @@ discard block |
||
| 964 | 966 | */ |
| 965 | 967 | public function delete($expunge = true) { |
| 966 | 968 | $status = $this->setFlag("Deleted"); |
| 967 | - if($expunge) $this->client->expunge(); |
|
| 969 | + if($expunge) { |
|
| 970 | + $this->client->expunge(); |
|
| 971 | + } |
|
| 968 | 972 | |
| 969 | 973 | $event = $this->getEvent("message", "deleted"); |
| 970 | 974 | $event::dispatch($this); |
@@ -984,7 +988,9 @@ discard block |
||
| 984 | 988 | */ |
| 985 | 989 | public function restore($expunge = true) { |
| 986 | 990 | $status = $this->unsetFlag("Deleted"); |
| 987 | - if($expunge) $this->client->expunge(); |
|
| 991 | + if($expunge) { |
|
| 992 | + $this->client->expunge(); |
|
| 993 | + } |
|
| 988 | 994 | |
| 989 | 995 | $event = $this->getEvent("message", "restored"); |
| 990 | 996 | $event::dispatch($this); |
@@ -1412,7 +1418,7 @@ discard block |
||
| 1412 | 1418 | if ($this->getSequence() === IMAP::ST_UID) { |
| 1413 | 1419 | $this->setUid($uid); |
| 1414 | 1420 | $this->setMsglist($msglist); |
| 1415 | - }else{ |
|
| 1421 | + } else{ |
|
| 1416 | 1422 | $this->setMsgn($uid, $msglist); |
| 1417 | 1423 | } |
| 1418 | 1424 | } |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | if(!iban_verify_checksum($iban)) { |
| 33 | 33 | return false; |
| 34 | 34 | } |
| 35 | - } |
|
| 36 | - else { |
|
| 35 | + } else { |
|
| 37 | 36 | return false; |
| 38 | 37 | } |
| 39 | 38 | |
@@ -489,8 +488,7 @@ discard block |
||
| 489 | 488 | for($i=0;$i<strlen($incorrect_iban);$i++) { |
| 490 | 489 | if(!isset($char_freqs[substr($incorrect_iban,$i,1)])) { |
| 491 | 490 | $char_freqs[substr($incorrect_iban,$i,1)] = 1; |
| 492 | - } |
|
| 493 | - else { |
|
| 491 | + } else { |
|
| 494 | 492 | $char_freqs[substr($incorrect_iban,$i,1)]++; |
| 495 | 493 | } |
| 496 | 494 | } |
@@ -693,20 +691,27 @@ discard block |
||
| 693 | 691 | $w1 = $wi[($i_size1 - $i) % 10]; |
| 694 | 692 | $sigma += ($i1 * $w1) % 11; |
| 695 | 693 | } |
| 696 | - if($bModify) return str_replace('?', $hash_map[($sigma % 11)], $vString); |
|
| 697 | - else return $hash_map[($sigma % 11)]; |
|
| 698 | -} |
|
| 694 | + if($bModify) { |
|
| 695 | + return str_replace('?', $hash_map[($sigma % 11)], $vString); |
|
| 696 | + } else { |
|
| 697 | + return $hash_map[($sigma % 11)]; |
|
| 698 | + } |
|
| 699 | + } |
|
| 699 | 700 | |
| 700 | 701 | # ISO7064 MOD97-10 (Bosnia, etc.) |
| 701 | 702 | # (Credit: Adapted from https://github.com/stvkoch/ISO7064-Mod-97-10/blob/master/ISO7064Mod97_10.php) |
| 702 | 703 | function _iso7064_mod97_10($str) { |
| 703 | 704 | $ai=1; |
| 704 | 705 | $ch = ord($str[strlen($str)-1]) - 48; |
| 705 | - if($ch < 0 || $ch > 9) return false; |
|
| 706 | + if($ch < 0 || $ch > 9) { |
|
| 707 | + return false; |
|
| 708 | + } |
|
| 706 | 709 | $check=$ch; |
| 707 | 710 | for($i=strlen($str)-2;$i>=0;$i--) { |
| 708 | 711 | $ch = ord($str[$i]) - 48; |
| 709 | - if ($ch < 0 || $ch > 9) return false; |
|
| 712 | + if ($ch < 0 || $ch > 9) { |
|
| 713 | + return false; |
|
| 714 | + } |
|
| 710 | 715 | $ai=($ai*10)%97; |
| 711 | 716 | $check+= ($ai * ((int)$ch)); |
| 712 | 717 | } |
@@ -723,11 +728,9 @@ discard block |
||
| 723 | 728 | $expected_nationalchecksum = $bban_less_checksum % 97; |
| 724 | 729 | if($mode=='find') { |
| 725 | 730 | return $expected_nationalchecksum; |
| 726 | - } |
|
| 727 | - elseif($mode=='set') { |
|
| 731 | + } elseif($mode=='set') { |
|
| 728 | 732 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 729 | - } |
|
| 730 | - elseif($mode=='verify') { |
|
| 733 | + } elseif($mode=='verify') { |
|
| 731 | 734 | return ($nationalchecksum == $expected_nationalchecksum); |
| 732 | 735 | } |
| 733 | 736 | } |
@@ -735,15 +738,21 @@ discard block |
||
| 735 | 738 | # MOD11 helper function for the Spanish (ES) IBAN national checksum implementation |
| 736 | 739 | # (Credit: @dem3trio, code lifted from Spanish Wikipedia at https://es.wikipedia.org/wiki/C%C3%B3digo_cuenta_cliente) |
| 737 | 740 | function _iban_nationalchecksum_implementation_es_mod11_helper($numero) { |
| 738 | - if(strlen($numero)!=10) return "?"; |
|
| 741 | + if(strlen($numero)!=10) { |
|
| 742 | + return "?"; |
|
| 743 | + } |
|
| 739 | 744 | $cifras = Array(1,2,4,8,5,10,9,7,3,6); |
| 740 | 745 | $chequeo=0; |
| 741 | 746 | for($i=0; $i<10; $i++) { |
| 742 | 747 | $chequeo += substr($numero,$i,1) * $cifras[$i]; |
| 743 | 748 | } |
| 744 | 749 | $chequeo = 11 - ($chequeo % 11); |
| 745 | - if ($chequeo == 11) $chequeo = 0; |
|
| 746 | - if ($chequeo == 10) $chequeo = 1; |
|
| 750 | + if ($chequeo == 11) { |
|
| 751 | + $chequeo = 0; |
|
| 752 | + } |
|
| 753 | + if ($chequeo == 10) { |
|
| 754 | + $chequeo = 1; |
|
| 755 | + } |
|
| 747 | 756 | return $chequeo; |
| 748 | 757 | } |
| 749 | 758 | |
@@ -762,11 +771,9 @@ discard block |
||
| 762 | 771 | $expected_nationalchecksum .= _iban_nationalchecksum_implementation_es_mod11_helper($account_less_checksum); |
| 763 | 772 | if($mode=='find') { |
| 764 | 773 | return $expected_nationalchecksum; |
| 765 | - } |
|
| 766 | - elseif($mode=='set') { |
|
| 774 | + } elseif($mode=='set') { |
|
| 767 | 775 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 768 | - } |
|
| 769 | - elseif($mode=='verify') { |
|
| 776 | + } elseif($mode=='verify') { |
|
| 770 | 777 | return ($nationalchecksum == $expected_nationalchecksum); |
| 771 | 778 | } |
| 772 | 779 | } |
@@ -783,13 +790,11 @@ discard block |
||
| 783 | 790 | for ($i=0; $i < strlen($bban); $i++) { |
| 784 | 791 | if(is_numeric($bban[$i])) { |
| 785 | 792 | $allNumbers .= $bban[$i]; |
| 786 | - } |
|
| 787 | - else { |
|
| 793 | + } else { |
|
| 788 | 794 | $letter = strtoupper($bban[$i]); |
| 789 | 795 | if(array_key_exists($letter, $conversion)) { |
| 790 | 796 | $allNumbers .= $conversion[$letter]; |
| 791 | - } |
|
| 792 | - else { |
|
| 797 | + } else { |
|
| 793 | 798 | return null; |
| 794 | 799 | } |
| 795 | 800 | } |
@@ -874,11 +879,9 @@ discard block |
||
| 874 | 879 | # return |
| 875 | 880 | if($mode=='find') { |
| 876 | 881 | return $expected_nationalchecksum; |
| 877 | - } |
|
| 878 | - elseif($mode=='set') { |
|
| 882 | + } elseif($mode=='set') { |
|
| 879 | 883 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 880 | - } |
|
| 881 | - elseif($mode=='verify') { |
|
| 884 | + } elseif($mode=='verify') { |
|
| 882 | 885 | return (iban_get_nationalchecksum_part($iban) == $expected_nationalchecksum); |
| 883 | 886 | } |
| 884 | 887 | } |
@@ -909,15 +912,12 @@ discard block |
||
| 909 | 912 | # mod10 (ie. rounding at 10, such that 10 = 0, 11 = 1, etc.) |
| 910 | 913 | $calculated_checksum = ($nationalchecksum + $remainder)%10; |
| 911 | 914 | if($mode == 'find') { |
| 912 | - if($remainder == 0) { return $nationalchecksum; } |
|
| 913 | - else { |
|
| 915 | + if($remainder == 0) { return $nationalchecksum; } else { |
|
| 914 | 916 | return $calculated_checksum; |
| 915 | 917 | } |
| 916 | - } |
|
| 917 | - elseif($mode == 'set') { |
|
| 918 | + } elseif($mode == 'set') { |
|
| 918 | 919 | return _iban_nationalchecksum_set($iban,$calculated_checksum); |
| 919 | - } |
|
| 920 | - elseif($mode == 'verify') { |
|
| 920 | + } elseif($mode == 'verify') { |
|
| 921 | 921 | if($remainder == 0) { return true; } |
| 922 | 922 | return false; |
| 923 | 923 | } |
@@ -958,11 +958,9 @@ discard block |
||
| 958 | 958 | # return |
| 959 | 959 | if($mode=='find') { |
| 960 | 960 | return $expected_nationalchecksum; |
| 961 | - } |
|
| 962 | - elseif($mode=='set') { |
|
| 961 | + } elseif($mode=='set') { |
|
| 963 | 962 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 964 | - } |
|
| 965 | - elseif($mode=='verify') { |
|
| 963 | + } elseif($mode=='verify') { |
|
| 966 | 964 | return (iban_get_nationalchecksum_part($iban) == $expected_nationalchecksum); |
| 967 | 965 | } |
| 968 | 966 | } |
@@ -981,11 +979,9 @@ discard block |
||
| 981 | 979 | # return |
| 982 | 980 | if($mode=='find') { |
| 983 | 981 | return $expected_nationalchecksum; |
| 984 | - } |
|
| 985 | - elseif($mode=='set') { |
|
| 982 | + } elseif($mode=='set') { |
|
| 986 | 983 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 987 | - } |
|
| 988 | - elseif($mode=='verify') { |
|
| 984 | + } elseif($mode=='verify') { |
|
| 989 | 985 | return (iban_get_nationalchecksum_part($iban) == $expected_nationalchecksum); |
| 990 | 986 | } |
| 991 | 987 | } |
@@ -1005,11 +1001,9 @@ discard block |
||
| 1005 | 1001 | # return |
| 1006 | 1002 | if($mode=='find') { |
| 1007 | 1003 | return $expected_nationalchecksum; |
| 1008 | - } |
|
| 1009 | - elseif($mode=='set') { |
|
| 1004 | + } elseif($mode=='set') { |
|
| 1010 | 1005 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 1011 | - } |
|
| 1012 | - elseif($mode=='verify') { |
|
| 1006 | + } elseif($mode=='verify') { |
|
| 1013 | 1007 | return (iban_get_nationalchecksum_part($iban) == $expected_nationalchecksum); |
| 1014 | 1008 | } |
| 1015 | 1009 | } |
@@ -1068,14 +1062,12 @@ discard block |
||
| 1068 | 1062 | $remainder = $checksum % 11; |
| 1069 | 1063 | if($mode=='verify') { |
| 1070 | 1064 | return ($remainder==0); # we return the result of mod11, if 0 it's good |
| 1071 | - } |
|
| 1072 | - elseif($mode=='set') { |
|
| 1065 | + } elseif($mode=='set') { |
|
| 1073 | 1066 | if($remainder==0) { |
| 1074 | 1067 | return $iban; # we return as expected if the checksum is ok |
| 1075 | 1068 | } |
| 1076 | 1069 | return ''; # we return unimplemented if the checksum is bad |
| 1077 | - } |
|
| 1078 | - elseif($mode=='find') { |
|
| 1070 | + } elseif($mode=='find') { |
|
| 1079 | 1071 | return ''; # does not make sense for this 0-digit checksum |
| 1080 | 1072 | } |
| 1081 | 1073 | } |
@@ -1090,11 +1082,9 @@ discard block |
||
| 1090 | 1082 | $expected_nationalchecksum = _iso7064_mod97_10_generated($bban_less_checksum); |
| 1091 | 1083 | if($mode=='find') { |
| 1092 | 1084 | return $expected_nationalchecksum; |
| 1093 | - } |
|
| 1094 | - elseif($mode=='set') { |
|
| 1085 | + } elseif($mode=='set') { |
|
| 1095 | 1086 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 1096 | - } |
|
| 1097 | - elseif($mode=='verify') { |
|
| 1087 | + } elseif($mode=='verify') { |
|
| 1098 | 1088 | return ($nationalchecksum == $expected_nationalchecksum); |
| 1099 | 1089 | } |
| 1100 | 1090 | } |
@@ -1154,11 +1144,9 @@ discard block |
||
| 1154 | 1144 | $expected_nationalchecksum = _iso7064_mod97_10_generated($bban_less_checksum); |
| 1155 | 1145 | if($mode=='find') { |
| 1156 | 1146 | return $expected_nationalchecksum; |
| 1157 | - } |
|
| 1158 | - elseif($mode=='set') { |
|
| 1147 | + } elseif($mode=='set') { |
|
| 1159 | 1148 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 1160 | - } |
|
| 1161 | - elseif($mode=='verify') { |
|
| 1149 | + } elseif($mode=='verify') { |
|
| 1162 | 1150 | return ($nationalchecksum == $expected_nationalchecksum); |
| 1163 | 1151 | } |
| 1164 | 1152 | } |
@@ -1173,11 +1161,9 @@ discard block |
||
| 1173 | 1161 | $expected_nationalchecksum = _iso7064_mod97_10_generated($bban_less_checksum); |
| 1174 | 1162 | if($mode=='find') { |
| 1175 | 1163 | return $expected_nationalchecksum; |
| 1176 | - } |
|
| 1177 | - elseif($mode=='set') { |
|
| 1164 | + } elseif($mode=='set') { |
|
| 1178 | 1165 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 1179 | - } |
|
| 1180 | - elseif($mode=='verify') { |
|
| 1166 | + } elseif($mode=='verify') { |
|
| 1181 | 1167 | return ($nationalchecksum == $expected_nationalchecksum); |
| 1182 | 1168 | } |
| 1183 | 1169 | } |
@@ -1260,11 +1246,9 @@ discard block |
||
| 1260 | 1246 | $expected_nationalchecksum = _italian($bban_less_checksum); |
| 1261 | 1247 | if($mode=='find') { |
| 1262 | 1248 | return $expected_nationalchecksum; |
| 1263 | - } |
|
| 1264 | - elseif($mode=='set') { |
|
| 1249 | + } elseif($mode=='set') { |
|
| 1265 | 1250 | return _iban_nationalchecksum_set($iban,$expected_nationalchecksum); |
| 1266 | - } |
|
| 1267 | - elseif($mode=='verify') { |
|
| 1251 | + } elseif($mode=='verify') { |
|
| 1268 | 1252 | return (iban_get_nationalchecksum_part($iban) == $expected_nationalchecksum); |
| 1269 | 1253 | } |
| 1270 | 1254 | } |
@@ -61,7 +61,6 @@ |
||
| 61 | 61 | function_exists('json_format') ? json_format($json) : json_encode($json) |
| 62 | 62 | )) { |
| 63 | 63 | echo 'Done. Check '.realpath($fileName).' file.'; |
| 64 | -} |
|
| 65 | -else { |
|
| 64 | +} else { |
|
| 66 | 65 | echo 'Failed to write '.realpath($fileName).' to disk.'; |
| 67 | 66 | } |
@@ -48,35 +48,51 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | |
| 50 | 50 | // include class for decoding filters |
| 51 | -if (defined('TCPDF_PATH')) require_once(constant('TCPDF_PATH').'/include/tcpdf_filters.php'); |
|
| 52 | -else require_once(dirname(__FILE__).'/../tecnickcom/tcpdf/include/tcpdf_filters.php'); |
|
| 51 | +if (defined('TCPDF_PATH')) { |
|
| 52 | + require_once(constant('TCPDF_PATH').'/include/tcpdf_filters.php'); |
|
| 53 | +} else { |
|
| 54 | + require_once(dirname(__FILE__).'/../tecnickcom/tcpdf/include/tcpdf_filters.php'); |
|
| 55 | +} |
|
| 53 | 56 | |
| 54 | -if (!defined ('PDF_TYPE_NULL')) |
|
| 57 | +if (!defined ('PDF_TYPE_NULL')) { |
|
| 55 | 58 | define ('PDF_TYPE_NULL', 0); |
| 56 | -if (!defined ('PDF_TYPE_NUMERIC')) |
|
| 59 | +} |
|
| 60 | +if (!defined ('PDF_TYPE_NUMERIC')) { |
|
| 57 | 61 | define ('PDF_TYPE_NUMERIC', 1); |
| 58 | -if (!defined ('PDF_TYPE_TOKEN')) |
|
| 62 | +} |
|
| 63 | +if (!defined ('PDF_TYPE_TOKEN')) { |
|
| 59 | 64 | define ('PDF_TYPE_TOKEN', 2); |
| 60 | -if (!defined ('PDF_TYPE_HEX')) |
|
| 65 | +} |
|
| 66 | +if (!defined ('PDF_TYPE_HEX')) { |
|
| 61 | 67 | define ('PDF_TYPE_HEX', 3); |
| 62 | -if (!defined ('PDF_TYPE_STRING')) |
|
| 68 | +} |
|
| 69 | +if (!defined ('PDF_TYPE_STRING')) { |
|
| 63 | 70 | define ('PDF_TYPE_STRING', 4); |
| 64 | -if (!defined ('PDF_TYPE_DICTIONARY')) |
|
| 71 | +} |
|
| 72 | +if (!defined ('PDF_TYPE_DICTIONARY')) { |
|
| 65 | 73 | define ('PDF_TYPE_DICTIONARY', 5); |
| 66 | -if (!defined ('PDF_TYPE_ARRAY')) |
|
| 74 | +} |
|
| 75 | +if (!defined ('PDF_TYPE_ARRAY')) { |
|
| 67 | 76 | define ('PDF_TYPE_ARRAY', 6); |
| 68 | -if (!defined ('PDF_TYPE_OBJDEC')) |
|
| 77 | +} |
|
| 78 | +if (!defined ('PDF_TYPE_OBJDEC')) { |
|
| 69 | 79 | define ('PDF_TYPE_OBJDEC', 7); |
| 70 | -if (!defined ('PDF_TYPE_OBJREF')) |
|
| 80 | +} |
|
| 81 | +if (!defined ('PDF_TYPE_OBJREF')) { |
|
| 71 | 82 | define ('PDF_TYPE_OBJREF', 8); |
| 72 | -if (!defined ('PDF_TYPE_OBJECT')) |
|
| 83 | +} |
|
| 84 | +if (!defined ('PDF_TYPE_OBJECT')) { |
|
| 73 | 85 | define ('PDF_TYPE_OBJECT', 9); |
| 74 | -if (!defined ('PDF_TYPE_STREAM')) |
|
| 86 | +} |
|
| 87 | +if (!defined ('PDF_TYPE_STREAM')) { |
|
| 75 | 88 | define ('PDF_TYPE_STREAM', 10); |
| 76 | -if (!defined ('PDF_TYPE_BOOLEAN')) |
|
| 89 | +} |
|
| 90 | +if (!defined ('PDF_TYPE_BOOLEAN')) { |
|
| 77 | 91 | define ('PDF_TYPE_BOOLEAN', 11); |
| 78 | -if (!defined ('PDF_TYPE_REAL')) |
|
| 92 | +} |
|
| 93 | +if (!defined ('PDF_TYPE_REAL')) { |
|
| 79 | 94 | define ('PDF_TYPE_REAL', 12); |
| 95 | +} |
|
| 80 | 96 | |
| 81 | 97 | /** |
| 82 | 98 | * @class tcpdi_parser |
@@ -245,8 +261,9 @@ discard block |
||
| 245 | 261 | */ |
| 246 | 262 | public function getPDFVersion() { |
| 247 | 263 | preg_match('/\d\.\d/', substr($this->pdfdata, 0, 16), $m); |
| 248 | - if (isset($m[0])) |
|
| 249 | - $this->pdfVersion = $m[0]; |
|
| 264 | + if (isset($m[0])) { |
|
| 265 | + $this->pdfVersion = $m[0]; |
|
| 266 | + } |
|
| 250 | 267 | return $this->pdfVersion; |
| 251 | 268 | } |
| 252 | 269 | |
@@ -1186,16 +1203,18 @@ discard block |
||
| 1186 | 1203 | // parent object. |
| 1187 | 1204 | if (isset ($obj[1][1]['/Resources'])) { |
| 1188 | 1205 | $res = $obj[1][1]['/Resources']; |
| 1189 | - if ($res[0] == PDF_TYPE_OBJECT) |
|
| 1190 | - return $res[1]; |
|
| 1206 | + if ($res[0] == PDF_TYPE_OBJECT) { |
|
| 1207 | + return $res[1]; |
|
| 1208 | + } |
|
| 1191 | 1209 | return $res; |
| 1192 | 1210 | } else { |
| 1193 | 1211 | if (!isset ($obj[1][1]['/Parent'])) { |
| 1194 | 1212 | return false; |
| 1195 | 1213 | } else { |
| 1196 | 1214 | $res = $this->_getPageResources($obj[1][1]['/Parent']); |
| 1197 | - if ($res[0] == PDF_TYPE_OBJECT) |
|
| 1198 | - return $res[1]; |
|
| 1215 | + if ($res[0] == PDF_TYPE_OBJECT) { |
|
| 1216 | + return $res[1]; |
|
| 1217 | + } |
|
| 1199 | 1218 | return $res; |
| 1200 | 1219 | } |
| 1201 | 1220 | } |
@@ -1295,8 +1314,9 @@ discard block |
||
| 1295 | 1314 | public function getPageBox($page, $box_index, $k) { |
| 1296 | 1315 | $page = $this->getObjectVal($page); |
| 1297 | 1316 | $box = null; |
| 1298 | - if (isset($page[1][1][$box_index])) |
|
| 1299 | - $box =& $page[1][1][$box_index]; |
|
| 1317 | + if (isset($page[1][1][$box_index])) { |
|
| 1318 | + $box =& $page[1][1][$box_index]; |
|
| 1319 | + } |
|
| 1300 | 1320 | |
| 1301 | 1321 | if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) { |
| 1302 | 1322 | $tmp_box = $this->getObjectVal($box); |
@@ -1364,16 +1384,18 @@ discard block |
||
| 1364 | 1384 | $obj = $this->getObjectVal($obj); |
| 1365 | 1385 | if (isset ($obj[1][1]['/Rotate'])) { |
| 1366 | 1386 | $res = $this->getObjectVal($obj[1][1]['/Rotate']); |
| 1367 | - if (isset($res[0]) && $res[0] == PDF_TYPE_OBJECT) |
|
| 1368 | - return $res[1]; |
|
| 1387 | + if (isset($res[0]) && $res[0] == PDF_TYPE_OBJECT) { |
|
| 1388 | + return $res[1]; |
|
| 1389 | + } |
|
| 1369 | 1390 | return $res; |
| 1370 | 1391 | } else { |
| 1371 | 1392 | if (!isset ($obj[1][1]['/Parent'])) { |
| 1372 | 1393 | return false; |
| 1373 | 1394 | } else { |
| 1374 | 1395 | $res = $this->_getPageRotation($obj[1][1]['/Parent']); |
| 1375 | - if (isset($res[0]) && $res[0] == PDF_TYPE_OBJECT) |
|
| 1376 | - return $res[1]; |
|
| 1396 | + if (isset($res[0]) && $res[0] == PDF_TYPE_OBJECT) { |
|
| 1397 | + return $res[1]; |
|
| 1398 | + } |
|
| 1377 | 1399 | return $res; |
| 1378 | 1400 | } |
| 1379 | 1401 | } |
@@ -79,17 +79,22 @@ discard block |
||
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ($this->page <= 0) |
|
| 83 | - $this->error("You have to add a page to fpdf first!"); |
|
| 82 | + if ($this->page <= 0) { |
|
| 83 | + $this->error("You have to add a page to fpdf first!"); |
|
| 84 | + } |
|
| 84 | 85 | |
| 85 | - if ($x == null) |
|
| 86 | - $x = 0; |
|
| 87 | - if ($y == null) |
|
| 88 | - $y = 0; |
|
| 89 | - if ($w == null) |
|
| 90 | - $w = $this->w; |
|
| 91 | - if ($h == null) |
|
| 92 | - $h = $this->h; |
|
| 86 | + if ($x == null) { |
|
| 87 | + $x = 0; |
|
| 88 | + } |
|
| 89 | + if ($y == null) { |
|
| 90 | + $y = 0; |
|
| 91 | + } |
|
| 92 | + if ($w == null) { |
|
| 93 | + $w = $this->w; |
|
| 94 | + } |
|
| 95 | + if ($h == null) { |
|
| 96 | + $h = $this->h; |
|
| 97 | + } |
|
| 93 | 98 | |
| 94 | 99 | // Save settings |
| 95 | 100 | $this->tpl++; |
@@ -165,8 +170,9 @@ discard block |
||
| 165 | 170 | $this->FontSize = $tpl['o_FontSize']; |
| 166 | 171 | |
| 167 | 172 | $fontkey = $this->FontFamily . $this->FontStyle; |
| 168 | - if ($fontkey) |
|
| 169 | - $this->CurrentFont =& $this->fonts[$fontkey]; |
|
| 173 | + if ($fontkey) { |
|
| 174 | + $this->CurrentFont =& $this->fonts[$fontkey]; |
|
| 175 | + } |
|
| 170 | 176 | |
| 171 | 177 | return $this->tpl; |
| 172 | 178 | } else { |
@@ -192,11 +198,13 @@ discard block |
||
| 192 | 198 | * @retrun array The height and width of the template |
| 193 | 199 | */ |
| 194 | 200 | function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { |
| 195 | - if ($this->page <= 0) |
|
| 196 | - $this->error('You have to add a page first!'); |
|
| 201 | + if ($this->page <= 0) { |
|
| 202 | + $this->error('You have to add a page first!'); |
|
| 203 | + } |
|
| 197 | 204 | |
| 198 | - if (!isset($this->tpls[$tplidx])) |
|
| 199 | - $this->error('Template does not exist!'); |
|
| 205 | + if (!isset($this->tpls[$tplidx])) { |
|
| 206 | + $this->error('Template does not exist!'); |
|
| 207 | + } |
|
| 200 | 208 | |
| 201 | 209 | if ($this->_intpl) { |
| 202 | 210 | $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; |
@@ -206,10 +214,12 @@ discard block |
||
| 206 | 214 | $w = $tpl['w']; |
| 207 | 215 | $h = $tpl['h']; |
| 208 | 216 | |
| 209 | - if ($_x == null) |
|
| 210 | - $_x = 0; |
|
| 211 | - if ($_y == null) |
|
| 212 | - $_y = 0; |
|
| 217 | + if ($_x == null) { |
|
| 218 | + $_x = 0; |
|
| 219 | + } |
|
| 220 | + if ($_y == null) { |
|
| 221 | + $_y = 0; |
|
| 222 | + } |
|
| 213 | 223 | |
| 214 | 224 | $_x += $tpl['x']; |
| 215 | 225 | $_y += $tpl['y']; |
@@ -249,8 +259,9 @@ discard block |
||
| 249 | 259 | * @return array The height and width of the template |
| 250 | 260 | */ |
| 251 | 261 | function getTemplateSize($tplidx, $_w = 0, $_h = 0) { |
| 252 | - if (!isset($this->tpls[$tplidx])) |
|
| 253 | - return false; |
|
| 262 | + if (!isset($this->tpls[$tplidx])) { |
|
| 263 | + return false; |
|
| 264 | + } |
|
| 254 | 265 | |
| 255 | 266 | $tpl =& $this->tpls[$tplidx]; |
| 256 | 267 | $w = $tpl['w']; |
@@ -261,10 +272,12 @@ discard block |
||
| 261 | 272 | $_h = $h; |
| 262 | 273 | } |
| 263 | 274 | |
| 264 | - if($_w == 0) |
|
| 265 | - $_w = $_h * $w / $h; |
|
| 266 | - if($_h == 0) |
|
| 267 | - $_h = $_w * $h / $w; |
|
| 275 | + if($_w == 0) { |
|
| 276 | + $_w = $_h * $w / $h; |
|
| 277 | + } |
|
| 278 | + if($_h == 0) { |
|
| 279 | + $_h = $_w * $h / $w; |
|
| 280 | + } |
|
| 268 | 281 | |
| 269 | 282 | return array("w" => $_w, "h" => $_h); |
| 270 | 283 | } |
@@ -323,8 +336,9 @@ discard block |
||
| 323 | 336 | return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); |
| 324 | 337 | } |
| 325 | 338 | |
| 326 | - if ($this->_intpl) |
|
| 327 | - $this->Error('Adding pages in templates isn\'t possible!'); |
|
| 339 | + if ($this->_intpl) { |
|
| 340 | + $this->Error('Adding pages in templates isn\'t possible!'); |
|
| 341 | + } |
|
| 328 | 342 | |
| 329 | 343 | parent::AddPage($orientation, $format); |
| 330 | 344 | } |
@@ -338,8 +352,9 @@ discard block |
||
| 338 | 352 | return call_user_func_array(array($this, 'TCPDF::Link'), $args); |
| 339 | 353 | } |
| 340 | 354 | |
| 341 | - if ($this->_intpl) |
|
| 342 | - $this->Error('Using links in templates aren\'t possible!'); |
|
| 355 | + if ($this->_intpl) { |
|
| 356 | + $this->Error('Using links in templates aren\'t possible!'); |
|
| 357 | + } |
|
| 343 | 358 | |
| 344 | 359 | parent::Link($x, $y, $w, $h, $link); |
| 345 | 360 | } |
@@ -350,8 +365,9 @@ discard block |
||
| 350 | 365 | return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); |
| 351 | 366 | } |
| 352 | 367 | |
| 353 | - if ($this->_intpl) |
|
| 354 | - $this->Error('Adding links in templates aren\'t possible!'); |
|
| 368 | + if ($this->_intpl) { |
|
| 369 | + $this->Error('Adding links in templates aren\'t possible!'); |
|
| 370 | + } |
|
| 355 | 371 | return parent::AddLink(); |
| 356 | 372 | } |
| 357 | 373 | |
@@ -361,8 +377,9 @@ discard block |
||
| 361 | 377 | return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); |
| 362 | 378 | } |
| 363 | 379 | |
| 364 | - if ($this->_intpl) |
|
| 365 | - $this->Error('Setting links in templates aren\'t possible!'); |
|
| 380 | + if ($this->_intpl) { |
|
| 381 | + $this->Error('Setting links in templates aren\'t possible!'); |
|
| 382 | + } |
|
| 366 | 383 | parent::SetLink($link, $y, $page); |
| 367 | 384 | } |
| 368 | 385 | |
@@ -402,8 +419,9 @@ discard block |
||
| 402 | 419 | $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
| 403 | 420 | if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { |
| 404 | 421 | $this->_out('/Font <<'); |
| 405 | - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) |
|
| 406 | - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
|
| 422 | + foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) { |
|
| 423 | + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
|
| 424 | + } |
|
| 407 | 425 | $this->_out('>>'); |
| 408 | 426 | } |
| 409 | 427 | if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || |
@@ -411,12 +429,14 @@ discard block |
||
| 411 | 429 | { |
| 412 | 430 | $this->_out('/XObject <<'); |
| 413 | 431 | if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { |
| 414 | - foreach($this->_res['tpl'][$tplidx]['images'] as $image) |
|
| 415 | - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
|
| 432 | + foreach($this->_res['tpl'][$tplidx]['images'] as $image) { |
|
| 433 | + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
|
| 434 | + } |
|
| 416 | 435 | } |
| 417 | 436 | if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { |
| 418 | - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) |
|
| 419 | - $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); |
|
| 437 | + foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) { |
|
| 438 | + $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); |
|
| 439 | + } |
|
| 420 | 440 | } |
| 421 | 441 | $this->_out('>>'); |
| 422 | 442 | } |