| @@ -1588,7 +1588,7 @@ discard block | ||
| 1588 | 1588 | * | 
| 1589 | 1589 | * @param array ref $root | 
| 1590 | 1590 | * @param string $path | 
| 1591 | - * @param object $asn1 | |
| 1591 | + * @param ASN1 $asn1 | |
| 1592 | 1592 | * @access private | 
| 1593 | 1593 | */ | 
| 1594 | 1594 | function _mapInExtensions(&$root, $path, $asn1) | 
| @@ -1638,7 +1638,7 @@ discard block | ||
| 1638 | 1638 | * | 
| 1639 | 1639 | * @param array ref $root | 
| 1640 | 1640 | * @param string $path | 
| 1641 | - * @param object $asn1 | |
| 1641 | + * @param ASN1 $asn1 | |
| 1642 | 1642 | * @access private | 
| 1643 | 1643 | */ | 
| 1644 | 1644 | function _mapOutExtensions(&$root, $path, $asn1) | 
| @@ -168,6 +168,7 @@ | ||
| 168 | 168 | |
| 169 | 169 | /** | 
| 170 | 170 | * Builds a string to be encoded in a QR code | 
| 171 | + * @param string $label | |
| 171 | 172 | */ | 
| 172 | 173 | public function getQRText($label, $secret) | 
| 173 | 174 |      { | 
| @@ -26,25 +26,30 @@ discard block | ||
| 26 | 26 |      { | 
| 27 | 27 | $this->issuer = $issuer; | 
| 28 | 28 | |
| 29 | - if (!is_int($digits) || $digits <= 0) | |
| 30 | -            throw new TwoFactorAuthException('Digits must be int > 0'); | |
| 29 | +        if (!is_int($digits) || $digits <= 0) { | |
| 30 | +                    throw new TwoFactorAuthException('Digits must be int > 0'); | |
| 31 | + } | |
| 31 | 32 | $this->digits = $digits; | 
| 32 | 33 | |
| 33 | - if (!is_int($period) || $period <= 0) | |
| 34 | -            throw new TwoFactorAuthException('Period must be int > 0'); | |
| 34 | +        if (!is_int($period) || $period <= 0) { | |
| 35 | +                    throw new TwoFactorAuthException('Period must be int > 0'); | |
| 36 | + } | |
| 35 | 37 | $this->period = $period; | 
| 36 | 38 | |
| 37 | 39 | $algorithm = strtolower(trim($algorithm)); | 
| 38 | - if (!in_array($algorithm, self::$_supportedalgos)) | |
| 39 | -            throw new TwoFactorAuthException('Unsupported algorithm: '.$algorithm); | |
| 40 | +        if (!in_array($algorithm, self::$_supportedalgos)) { | |
| 41 | +                    throw new TwoFactorAuthException('Unsupported algorithm: '.$algorithm); | |
| 42 | + } | |
| 40 | 43 | $this->algorithm = $algorithm; | 
| 41 | 44 | |
| 42 | 45 | // Set default QR Code provider if none was specified | 
| 43 | - if ($qrcodeprovider == null) | |
| 44 | - $qrcodeprovider = new Providers\Qr\GoogleQRCodeProvider(); | |
| 46 | +        if ($qrcodeprovider == null) { | |
| 47 | + $qrcodeprovider = new Providers\Qr\GoogleQRCodeProvider(); | |
| 48 | + } | |
| 45 | 49 | |
| 46 | - if (!($qrcodeprovider instanceof Providers\Qr\IQRCodeProvider)) | |
| 47 | -            throw new TwoFactorAuthException('QRCodeProvider must implement IQRCodeProvider'); | |
| 50 | +        if (!($qrcodeprovider instanceof Providers\Qr\IQRCodeProvider)) { | |
| 51 | +                    throw new TwoFactorAuthException('QRCodeProvider must implement IQRCodeProvider'); | |
| 52 | + } | |
| 48 | 53 | |
| 49 | 54 | $this->qrcodeprovider = $qrcodeprovider; | 
| 50 | 55 | |
| @@ -80,11 +85,14 @@ discard block | ||
| 80 | 85 |      { | 
| 81 | 86 | $secret = ''; | 
| 82 | 87 | $bytes = ceil($bits / 5); //We use 5 bits of each byte (since we have a 32-character 'alphabet' / BASE32) | 
| 83 | - if ($requirecryptosecure && !$this->rngprovider->isCryptographicallySecure()) | |
| 84 | -            throw new TwoFactorAuthException('RNG provider is not cryptographically secure'); | |
| 88 | +        if ($requirecryptosecure && !$this->rngprovider->isCryptographicallySecure()) { | |
| 89 | +                    throw new TwoFactorAuthException('RNG provider is not cryptographically secure'); | |
| 90 | + } | |
| 85 | 91 | $rnd = $this->rngprovider->getRandomBytes($bytes); | 
| 86 | - for ($i = 0; $i < $bytes; $i++) | |
| 87 | - $secret .= self::$_base32[ord($rnd[$i]) & 31]; //Mask out left 3 bits for 0-31 values | |
| 92 | +        for ($i = 0; $i < $bytes; $i++) { | |
| 93 | + $secret .= self::$_base32[ord($rnd[$i]) & 31]; | |
| 94 | + } | |
| 95 | + //Mask out left 3 bits for 0-31 values | |
| 88 | 96 | return $secret; | 
| 89 | 97 | } | 
| 90 | 98 | |
| @@ -181,23 +189,28 @@ discard block | ||
| 181 | 189 | |
| 182 | 190 | private function base32Decode($value) | 
| 183 | 191 |      { | 
| 184 | - if (strlen($value) == 0) return ''; | |
| 192 | +        if (strlen($value) == 0) { | |
| 193 | + return ''; | |
| 194 | + } | |
| 185 | 195 | |
| 186 | -        if (preg_match('/[^'.preg_quote(self::$_base32dict).']/', $value) !== 0) | |
| 187 | -            throw new TwoFactorAuthException('Invalid base32 string'); | |
| 196 | +        if (preg_match('/[^'.preg_quote(self::$_base32dict).']/', $value) !== 0) { | |
| 197 | +                    throw new TwoFactorAuthException('Invalid base32 string'); | |
| 198 | + } | |
| 188 | 199 | |
| 189 | 200 | $buffer = ''; | 
| 190 | 201 | foreach (str_split($value) as $char) | 
| 191 | 202 |          { | 
| 192 | - if ($char !== '=') | |
| 193 | - $buffer .= str_pad(decbin(self::$_base32lookup[$char]), 5, 0, STR_PAD_LEFT); | |
| 203 | +            if ($char !== '=') { | |
| 204 | + $buffer .= str_pad(decbin(self::$_base32lookup[$char]), 5, 0, STR_PAD_LEFT); | |
| 205 | + } | |
| 194 | 206 | } | 
| 195 | 207 | $length = strlen($buffer); | 
| 196 | 208 | $blocks = trim(chunk_split(substr($buffer, 0, $length - ($length % 8)), 8, ' ')); | 
| 197 | 209 | |
| 198 | 210 | $output = ''; | 
| 199 | -        foreach (explode(' ', $blocks) as $block) | |
| 200 | - $output .= chr(bindec(str_pad($block, 8, 0, STR_PAD_RIGHT))); | |
| 211 | +        foreach (explode(' ', $blocks) as $block) { | |
| 212 | + $output .= chr(bindec(str_pad($block, 8, 0, STR_PAD_RIGHT))); | |
| 213 | + } | |
| 201 | 214 | |
| 202 | 215 | return $output; | 
| 203 | 216 | } | 
| @@ -76,6 +76,7 @@ | ||
| 76 | 76 | * @throws Ex\EnvironmentIsBrokenException | 
| 77 | 77 | * @throws Ex\WrongKeyOrModifiedCiphertextException | 
| 78 | 78 | * | 
| 79 | + * @param string $password | |
| 79 | 80 | * @return Key | 
| 80 | 81 | */ | 
| 81 | 82 | public function unlockKey($password) | 
| @@ -150,6 +150,9 @@ | ||
| 150 | 150 | return array($hi, $lo); | 
| 151 | 151 | } | 
| 152 | 152 | |
| 153 | + /** | |
| 154 | + * @param string $tag | |
| 155 | + */ | |
| 153 | 156 |  	function get_table_pos($tag) { | 
| 154 | 157 | $offset = $this->tables[$tag]['offset']; | 
| 155 | 158 | $length = $this->tables[$tag]['length']; | 
| @@ -90,12 +90,15 @@ discard block | ||
| 90 | 90 | $this->descent = 0; | 
| 91 | 91 | $this->TTCFonts = array(); | 
| 92 | 92 | $this->version = $version = $this->read_ulong(); | 
| 93 | - if ($version == 0x4F54544F) | |
| 94 | -			die("Postscript outlines are not supported"); | |
| 95 | - if ($version == 0x74746366) | |
| 96 | -			die("ERROR - TrueType Fonts Collections not supported"); | |
| 97 | - if (!in_array($version, array(0x00010000, 0x74727565))) | |
| 98 | -			die("Not a TrueType font: version=".$version); | |
| 93 | +		if ($version == 0x4F54544F) { | |
| 94 | +					die("Postscript outlines are not supported"); | |
| 95 | + } | |
| 96 | +		if ($version == 0x74746366) { | |
| 97 | +					die("ERROR - TrueType Fonts Collections not supported"); | |
| 98 | + } | |
| 99 | +		if (!in_array($version, array(0x00010000, 0x74727565))) { | |
| 100 | +					die("Not a TrueType font: version=".$version); | |
| 101 | + } | |
| 99 | 102 | $this->readTableDirectory(); | 
| 100 | 103 | $this->extractInfo(); | 
| 101 | 104 | fclose($this->fh); | 
| @@ -319,13 +322,16 @@ discard block | ||
| 319 | 322 | $nameId = $this->read_ushort(); | 
| 320 | 323 | $length = $this->read_ushort(); | 
| 321 | 324 | $offset = $this->read_ushort(); | 
| 322 | - if (!in_array($nameId, $K)) continue; | |
| 325 | +				if (!in_array($nameId, $K)) { | |
| 326 | + continue; | |
| 327 | + } | |
| 323 | 328 | $N = ''; | 
| 324 | 329 |  				if ($platformId == 3 && $encodingId == 1 && $languageId == 0x409) { // Microsoft, Unicode, US English, PS Name | 
| 325 | 330 | $opos = $this->_pos; | 
| 326 | 331 | $this->seek($string_data_offset + $offset); | 
| 327 | - if ($length % 2 != 0) | |
| 328 | -						die("PostScript name is UTF-16BE string of odd length"); | |
| 332 | +					if ($length % 2 != 0) { | |
| 333 | +											die("PostScript name is UTF-16BE string of odd length"); | |
| 334 | + } | |
| 329 | 335 | $length /= 2; | 
| 330 | 336 | $N = ''; | 
| 331 | 337 |  					while ($length > 0) { | 
| @@ -344,19 +350,23 @@ discard block | ||
| 344 | 350 |  				if ($N && $names[$nameId] == '') { | 
| 345 | 351 | $names[$nameId] = $N; | 
| 346 | 352 | $nameCount -= 1; | 
| 347 | - if ($nameCount == 0) break; | |
| 353 | +					if ($nameCount == 0) { | |
| 354 | + break; | |
| 355 | + } | |
| 348 | 356 | } | 
| 349 | 357 | } | 
| 350 | - if ($names[6]) | |
| 351 | - $psName = $names[6]; | |
| 352 | - else if ($names[4]) | |
| 353 | -				$psName = preg_replace('/ /', '-', $names[4]); | |
| 354 | - else if ($names[1]) | |
| 355 | -				$psName = preg_replace('/ /', '-', $names[1]); | |
| 356 | - else | |
| 357 | - $psName = ''; | |
| 358 | - if (!$psName) | |
| 359 | -				die("Could not find PostScript font name"); | |
| 358 | +			if ($names[6]) { | |
| 359 | + $psName = $names[6]; | |
| 360 | +			} else if ($names[4]) { | |
| 361 | +							$psName = preg_replace('/ /', '-', $names[4]); | |
| 362 | +			} else if ($names[1]) { | |
| 363 | +							$psName = preg_replace('/ /', '-', $names[1]); | |
| 364 | +			} else { | |
| 365 | + $psName = ''; | |
| 366 | + } | |
| 367 | +			if (!$psName) { | |
| 368 | +							die("Could not find PostScript font name"); | |
| 369 | + } | |
| 360 | 370 | $this->name = $psName; | 
| 361 | 371 |  			if ($names[1]) { $this->familyName = $names[1]; } else { $this->familyName = $psName; } | 
| 362 | 372 |  			if ($names[2]) { $this->styleName = $names[2]; } else { $this->styleName = 'Regular'; } | 
| @@ -420,21 +430,27 @@ discard block | ||
| 420 | 430 | $this->skip(26); | 
| 421 | 431 | $sTypoAscender = $this->read_short(); | 
| 422 | 432 | $sTypoDescender = $this->read_short(); | 
| 423 | - if (!$this->ascent) $this->ascent = ($sTypoAscender * $scale); | |
| 424 | - if (!$this->descent) $this->descent = ($sTypoDescender * $scale); | |
| 433 | +			if (!$this->ascent) { | |
| 434 | + $this->ascent = ($sTypoAscender * $scale); | |
| 435 | + } | |
| 436 | +			if (!$this->descent) { | |
| 437 | + $this->descent = ($sTypoDescender * $scale); | |
| 438 | + } | |
| 425 | 439 |  			if ($version > 1) { | 
| 426 | 440 | $this->skip(16); | 
| 427 | 441 | $sCapHeight = $this->read_short(); | 
| 428 | 442 | $this->capHeight = ($sCapHeight * $scale); | 
| 429 | - } | |
| 430 | -			else { | |
| 443 | +			} else { | |
| 431 | 444 | $this->capHeight = $this->ascent; | 
| 432 | 445 | } | 
| 433 | - } | |
| 434 | -		else { | |
| 446 | +		} else { | |
| 435 | 447 | $usWeightClass = 500; | 
| 436 | - if (!$this->ascent) $this->ascent = ($yMax * $scale); | |
| 437 | - if (!$this->descent) $this->descent = ($yMin * $scale); | |
| 448 | +			if (!$this->ascent) { | |
| 449 | + $this->ascent = ($yMax * $scale); | |
| 450 | + } | |
| 451 | +			if (!$this->descent) { | |
| 452 | + $this->descent = ($yMin * $scale); | |
| 453 | + } | |
| 438 | 454 | $this->capHeight = $this->ascent; | 
| 439 | 455 | } | 
| 440 | 456 | $this->stemV = 50 + intval(pow(($usWeightClass / 65.0), 2)); | 
| @@ -451,12 +467,15 @@ discard block | ||
| 451 | 467 | |
| 452 | 468 | $this->flags = 4; | 
| 453 | 469 | |
| 454 | - if ($this->italicAngle != 0) | |
| 455 | - $this->flags = $this->flags | 64; | |
| 456 | - if ($usWeightClass >= 600) | |
| 457 | - $this->flags = $this->flags | 262144; | |
| 458 | - if ($isFixedPitch) | |
| 459 | - $this->flags = $this->flags | 1; | |
| 470 | +		if ($this->italicAngle != 0) { | |
| 471 | + $this->flags = $this->flags | 64; | |
| 472 | + } | |
| 473 | +		if ($usWeightClass >= 600) { | |
| 474 | + $this->flags = $this->flags | 262144; | |
| 475 | + } | |
| 476 | +		if ($isFixedPitch) { | |
| 477 | + $this->flags = $this->flags | 1; | |
| 478 | + } | |
| 460 | 479 | |
| 461 | 480 | /////////////////////////////////// | 
| 462 | 481 | // hhea - Horizontal header table | 
| @@ -495,14 +514,17 @@ discard block | ||
| 495 | 514 |  			if (($platformID == 3 && $encodingID == 1) || $platformID == 0) { // Microsoft, Unicode | 
| 496 | 515 | $format = $this->get_ushort($cmap_offset + $offset); | 
| 497 | 516 |  				if ($format == 4) { | 
| 498 | - if (!$unicode_cmap_offset) $unicode_cmap_offset = $cmap_offset + $offset; | |
| 517 | +					if (!$unicode_cmap_offset) { | |
| 518 | + $unicode_cmap_offset = $cmap_offset + $offset; | |
| 519 | + } | |
| 499 | 520 | break; | 
| 500 | 521 | } | 
| 501 | 522 | } | 
| 502 | 523 | $this->seek($save_pos); | 
| 503 | 524 | } | 
| 504 | - if (!$unicode_cmap_offset) | |
| 505 | -			die('Font ('.$this->filename.') does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)'); | |
| 525 | +		if (!$unicode_cmap_offset) { | |
| 526 | +					die('Font ('.$this->filename.') does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)'); | |
| 527 | + } | |
| 506 | 528 | |
| 507 | 529 | |
| 508 | 530 | $glyphToChar = array(); | 
| @@ -586,8 +608,9 @@ discard block | ||
| 586 | 608 | $this->seek($save_pos); | 
| 587 | 609 | } | 
| 588 | 610 | |
| 589 | - if (!$unicode_cmap_offset) | |
| 590 | -			die('Font ('.$this->filename.') does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)'); | |
| 611 | +		if (!$unicode_cmap_offset) { | |
| 612 | +					die('Font ('.$this->filename.') does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)'); | |
| 613 | + } | |
| 591 | 614 | |
| 592 | 615 | |
| 593 | 616 | $glyphToChar = array(); | 
| @@ -772,10 +795,12 @@ discard block | ||
| 772 | 795 | $glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos; | 
| 773 | 796 |  			if ($glyfLength < $this->maxStrLenRead) { | 
| 774 | 797 | $data = substr($glyphData, $glyphPos, $glyphLen); | 
| 775 | - } | |
| 776 | -			else { | |
| 777 | - if ($glyphLen > 0) $data = $this->get_chunk($glyfOffset + $glyphPos, $glyphLen); | |
| 778 | - else $data = ''; | |
| 798 | +			} else { | |
| 799 | +				if ($glyphLen > 0) { | |
| 800 | + $data = $this->get_chunk($glyfOffset + $glyphPos, $glyphLen); | |
| 801 | +				} else { | |
| 802 | + $data = ''; | |
| 803 | + } | |
| 779 | 804 | } | 
| 780 | 805 | |
| 781 | 806 |  			if ($glyphLen > 0) { | 
| @@ -821,8 +846,7 @@ discard block | ||
| 821 | 846 |  		if ((($pos + 1) >> 1) > 0xFFFF) { | 
| 822 | 847 | $indexToLocFormat = 1; // long format | 
| 823 | 848 |  			foreach ($offsets AS $offset) { $locastr .= pack("N", $offset); } | 
| 824 | - } | |
| 825 | -		else { | |
| 849 | +		} else { | |
| 826 | 850 | $indexToLocFormat = 0; // short format | 
| 827 | 851 |  			foreach ($offsets AS $offset) { $locastr .= pack("n", ($offset / 2)); } | 
| 828 | 852 | } | 
| @@ -928,14 +952,12 @@ discard block | ||
| 928 | 952 |  		if (($numberOfHMetrics * 4) < $this->maxStrLenRead) { | 
| 929 | 953 | $data = $this->get_chunk($start, ($numberOfHMetrics * 4)); | 
| 930 | 954 |  			$arr = unpack("n*", $data); | 
| 931 | - } | |
| 932 | -		else { $this->seek($start); } | |
| 955 | +		} else { $this->seek($start); } | |
| 933 | 956 |  		for ($glyph = 0; $glyph < $numberOfHMetrics; $glyph++) { | 
| 934 | 957 | |
| 935 | 958 |  			if (($numberOfHMetrics * 4) < $this->maxStrLenRead) { | 
| 936 | 959 | $aw = $arr[($glyph * 2) + 1]; | 
| 937 | - } | |
| 938 | -			else { | |
| 960 | +			} else { | |
| 939 | 961 | $aw = $this->read_ushort(); | 
| 940 | 962 | $lsb = $this->read_ushort(); | 
| 941 | 963 | } | 
| @@ -993,8 +1015,7 @@ discard block | ||
| 993 | 1015 |  		if ($gid < $numberOfHMetrics) { | 
| 994 | 1016 | $this->seek($start + ($gid * 4)); | 
| 995 | 1017 | $hm = fread($this->fh, 4); | 
| 996 | - } | |
| 997 | -		else { | |
| 1018 | +		} else { | |
| 998 | 1019 | $this->seek($start + (($numberOfHMetrics - 1) * 4)); | 
| 999 | 1020 | $hm = fread($this->fh, 2); | 
| 1000 | 1021 | $this->seek($start + ($numberOfHMetrics * 2) + ($gid * 2)); | 
| @@ -1016,16 +1037,15 @@ discard block | ||
| 1016 | 1037 |  			for ($n = 0; $n <= $numGlyphs; $n++) { | 
| 1017 | 1038 | $this->glyphPos[] = ($arr[$n + 1] * 2); | 
| 1018 | 1039 | } | 
| 1019 | - } | |
| 1020 | -		else if ($indexToLocFormat == 1) { | |
| 1040 | +		} else if ($indexToLocFormat == 1) { | |
| 1021 | 1041 | $data = $this->get_chunk($start, ($numGlyphs * 4) + 4); | 
| 1022 | 1042 |  			$arr = unpack("N*", $data); | 
| 1023 | 1043 |  			for ($n = 0; $n <= $numGlyphs; $n++) { | 
| 1024 | 1044 | $this->glyphPos[] = ($arr[$n + 1]); | 
| 1025 | 1045 | } | 
| 1046 | +		} else { | |
| 1047 | +					die('Unknown location table format '.$indexToLocFormat); | |
| 1026 | 1048 | } | 
| 1027 | - else | |
| 1028 | -			die('Unknown location table format '.$indexToLocFormat); | |
| 1029 | 1049 | } | 
| 1030 | 1050 | |
| 1031 | 1051 | |
| @@ -1057,17 +1077,18 @@ discard block | ||
| 1057 | 1077 |  		for ($n = 0; $n < $segCount; $n++) { | 
| 1058 | 1078 | $endpoint = ($endCount[$n] + 1); | 
| 1059 | 1079 |  			for ($unichar = $startCount[$n]; $unichar < $endpoint; $unichar++) { | 
| 1060 | - if ($idRangeOffset[$n] == 0) | |
| 1061 | - $glyph = ($unichar + $idDelta[$n]) & 0xFFFF; | |
| 1062 | -				else { | |
| 1080 | +				if ($idRangeOffset[$n] == 0) { | |
| 1081 | + $glyph = ($unichar + $idDelta[$n]) & 0xFFFF; | |
| 1082 | +				} else { | |
| 1063 | 1083 | $offset = ($unichar - $startCount[$n]) * 2 + $idRangeOffset[$n]; | 
| 1064 | 1084 | $offset = $idRangeOffset_start + 2 * $n + $offset; | 
| 1065 | - if ($offset >= $limit) | |
| 1066 | - $glyph = 0; | |
| 1067 | -					else { | |
| 1085 | +					if ($offset >= $limit) { | |
| 1086 | + $glyph = 0; | |
| 1087 | +					} else { | |
| 1068 | 1088 | $glyph = $this->get_ushort($offset); | 
| 1069 | - if ($glyph != 0) | |
| 1070 | - $glyph = ($glyph + $idDelta[$n]) & 0xFFFF; | |
| 1089 | +						if ($glyph != 0) { | |
| 1090 | + $glyph = ($glyph + $idDelta[$n]) & 0xFFFF; | |
| 1091 | + } | |
| 1071 | 1092 | } | 
| 1072 | 1093 | } | 
| 1073 | 1094 | $charToGlyph[$unichar] = $glyph; | 
| @@ -1098,8 +1119,7 @@ discard block | ||
| 1098 | 1119 | // Header | 
| 1099 | 1120 |  		if (_TTF_MAC_HEADER) { | 
| 1100 | 1121 |  			$stm .= (pack("Nnnnn", 0x74727565, $numTables, $searchRange, $entrySelector, $rangeShift)); // Mac | 
| 1101 | - } | |
| 1102 | -		else { | |
| 1122 | +		} else { | |
| 1103 | 1123 |  			$stm .= (pack("Nnnnn", 0x00010000, $numTables, $searchRange, $entrySelector, $rangeShift)); // Windows | 
| 1104 | 1124 | } | 
| 1105 | 1125 | |
| @@ -164,6 +164,7 @@ | ||
| 164 | 164 | |
| 165 | 165 | /** | 
| 166 | 166 | * Get MD5 as binary string | 
| 167 | + * @param string $string | |
| 167 | 168 | */ | 
| 168 | 169 | function _md5_16($string) | 
| 169 | 170 |      { | 
| @@ -1331,6 +1331,9 @@ | ||
| 1331 | 1331 | } | 
| 1332 | 1332 | } | 
| 1333 | 1333 | |
| 1334 | +/** | |
| 1335 | + * @param string $size | |
| 1336 | + */ | |
| 1334 | 1337 | function _getpagesize($size) | 
| 1335 | 1338 |  { | 
| 1336 | 1339 | if (is_string($size)) | 
| @@ -108,26 +108,28 @@ discard block | ||
| 108 | 108 |      if (defined('FPDF_FONTPATH')) | 
| 109 | 109 |      { | 
| 110 | 110 | $this->fontpath = FPDF_FONTPATH; | 
| 111 | - if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\') | |
| 112 | - $this->fontpath .= '/'; | |
| 111 | +        if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\') { | |
| 112 | + $this->fontpath .= '/'; | |
| 113 | + } | |
| 114 | +    } elseif (is_dir(dirname(__FILE__).'/font')) { | |
| 115 | + $this->fontpath = dirname(__FILE__).'/font/'; | |
| 116 | +    } else { | |
| 117 | + $this->fontpath = ''; | |
| 113 | 118 | } | 
| 114 | - elseif (is_dir(dirname(__FILE__).'/font')) | |
| 115 | - $this->fontpath = dirname(__FILE__).'/font/'; | |
| 116 | - else | |
| 117 | - $this->fontpath = ''; | |
| 118 | 119 | // Core fonts | 
| 119 | 120 |      $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats'); | 
| 120 | 121 | // Scale factor | 
| 121 | - if ($unit == 'pt') | |
| 122 | - $this->k = 1; | |
| 123 | - elseif ($unit == 'mm') | |
| 124 | - $this->k = 72 / 25.4; | |
| 125 | - elseif ($unit == 'cm') | |
| 126 | - $this->k = 72 / 2.54; | |
| 127 | - elseif ($unit == 'in') | |
| 128 | - $this->k = 72; | |
| 129 | - else | |
| 130 | -        $this->Error('Incorrect unit: '.$unit); | |
| 122 | +    if ($unit == 'pt') { | |
| 123 | + $this->k = 1; | |
| 124 | +    } elseif ($unit == 'mm') { | |
| 125 | + $this->k = 72 / 25.4; | |
| 126 | +    } elseif ($unit == 'cm') { | |
| 127 | + $this->k = 72 / 2.54; | |
| 128 | +    } elseif ($unit == 'in') { | |
| 129 | + $this->k = 72; | |
| 130 | +    } else { | |
| 131 | +            $this->Error('Incorrect unit: '.$unit); | |
| 132 | + } | |
| 131 | 133 | // Page sizes | 
| 132 | 134 |      $this->StdPageSizes = array('a3'=>array(841.89, 1190.55), 'a4'=>array(595.28, 841.89), 'a5'=>array(420.94, 595.28), | 
| 133 | 135 | 'letter'=>array(612, 792), 'legal'=>array(612, 1008)); | 
| @@ -141,15 +143,14 @@ discard block | ||
| 141 | 143 | $this->DefOrientation = 'P'; | 
| 142 | 144 | $this->w = $size[0]; | 
| 143 | 145 | $this->h = $size[1]; | 
| 144 | - } | |
| 145 | - elseif ($orientation == 'l' || $orientation == 'landscape') | |
| 146 | + } elseif ($orientation == 'l' || $orientation == 'landscape') | |
| 146 | 147 |      { | 
| 147 | 148 | $this->DefOrientation = 'L'; | 
| 148 | 149 | $this->w = $size[1]; | 
| 149 | 150 | $this->h = $size[0]; | 
| 151 | +    } else { | |
| 152 | +            $this->Error('Incorrect orientation: '.$orientation); | |
| 150 | 153 | } | 
| 151 | - else | |
| 152 | -        $this->Error('Incorrect orientation: '.$orientation); | |
| 153 | 154 | $this->CurOrientation = $this->DefOrientation; | 
| 154 | 155 | $this->wPt = $this->w * $this->k; | 
| 155 | 156 | $this->hPt = $this->h * $this->k; | 
| @@ -189,9 +190,10 @@ discard block | ||
| 189 | 190 |  { | 
| 190 | 191 | // Set left margin | 
| 191 | 192 | $this->lMargin = $margin; | 
| 192 | - if ($this->page > 0 && $this->x < $margin) | |
| 193 | - $this->x = $margin; | |
| 194 | -} | |
| 193 | +    if ($this->page > 0 && $this->x < $margin) { | |
| 194 | + $this->x = $margin; | |
| 195 | + } | |
| 196 | + } | |
| 195 | 197 | |
| 196 | 198 | function SetTopMargin($margin) | 
| 197 | 199 |  { | 
| @@ -222,15 +224,17 @@ discard block | ||
| 222 | 224 | function SetDisplayMode($zoom, $layout='default') | 
| 223 | 225 |  { | 
| 224 | 226 | // Set display mode in viewer | 
| 225 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) | |
| 226 | - $this->ZoomMode = $zoom; | |
| 227 | - else | |
| 228 | -        $this->Error('Incorrect zoom display mode: '.$zoom); | |
| 229 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') | |
| 230 | - $this->LayoutMode = $layout; | |
| 231 | - else | |
| 232 | -        $this->Error('Incorrect layout display mode: '.$layout); | |
| 233 | -} | |
| 227 | +    if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) { | |
| 228 | + $this->ZoomMode = $zoom; | |
| 229 | +    } else { | |
| 230 | +            $this->Error('Incorrect zoom display mode: '.$zoom); | |
| 231 | + } | |
| 232 | +    if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') { | |
| 233 | + $this->LayoutMode = $layout; | |
| 234 | +    } else { | |
| 235 | +            $this->Error('Incorrect layout display mode: '.$layout); | |
| 236 | + } | |
| 237 | + } | |
| 234 | 238 | |
| 235 | 239 | /** | 
| 236 | 240 | * @param boolean $compress | 
| @@ -238,49 +242,55 @@ discard block | ||
| 238 | 242 | function SetCompression($compress) | 
| 239 | 243 |  { | 
| 240 | 244 | // Set page compression | 
| 241 | -    if (function_exists('gzcompress')) | |
| 242 | - $this->compress = $compress; | |
| 243 | - else | |
| 244 | - $this->compress = false; | |
| 245 | -} | |
| 245 | +    if (function_exists('gzcompress')) { | |
| 246 | + $this->compress = $compress; | |
| 247 | +    } else { | |
| 248 | + $this->compress = false; | |
| 249 | + } | |
| 250 | + } | |
| 246 | 251 | |
| 247 | 252 | function SetTitle($title, $isUTF8 = false) | 
| 248 | 253 |  { | 
| 249 | 254 | // Title of document | 
| 250 | - if ($isUTF8) | |
| 251 | - $title = $this->_UTF8toUTF16($title); | |
| 255 | +    if ($isUTF8) { | |
| 256 | + $title = $this->_UTF8toUTF16($title); | |
| 257 | + } | |
| 252 | 258 | $this->title = $title; | 
| 253 | 259 | } | 
| 254 | 260 | |
| 255 | 261 | function SetSubject($subject, $isUTF8 = false) | 
| 256 | 262 |  { | 
| 257 | 263 | // Subject of document | 
| 258 | - if ($isUTF8) | |
| 259 | - $subject = $this->_UTF8toUTF16($subject); | |
| 264 | +    if ($isUTF8) { | |
| 265 | + $subject = $this->_UTF8toUTF16($subject); | |
| 266 | + } | |
| 260 | 267 | $this->subject = $subject; | 
| 261 | 268 | } | 
| 262 | 269 | |
| 263 | 270 | function SetAuthor($author, $isUTF8 = false) | 
| 264 | 271 |  { | 
| 265 | 272 | // Author of document | 
| 266 | - if ($isUTF8) | |
| 267 | - $author = $this->_UTF8toUTF16($author); | |
| 273 | +    if ($isUTF8) { | |
| 274 | + $author = $this->_UTF8toUTF16($author); | |
| 275 | + } | |
| 268 | 276 | $this->author = $author; | 
| 269 | 277 | } | 
| 270 | 278 | |
| 271 | 279 | function SetKeywords($keywords, $isUTF8 = false) | 
| 272 | 280 |  { | 
| 273 | 281 | // Keywords of document | 
| 274 | - if ($isUTF8) | |
| 275 | - $keywords = $this->_UTF8toUTF16($keywords); | |
| 282 | +    if ($isUTF8) { | |
| 283 | + $keywords = $this->_UTF8toUTF16($keywords); | |
| 284 | + } | |
| 276 | 285 | $this->keywords = $keywords; | 
| 277 | 286 | } | 
| 278 | 287 | |
| 279 | 288 | function SetCreator($creator, $isUTF8 = false) | 
| 280 | 289 |  { | 
| 281 | 290 | // Creator of document | 
| 282 | - if ($isUTF8) | |
| 283 | - $creator = $this->_UTF8toUTF16($creator); | |
| 291 | +    if ($isUTF8) { | |
| 292 | + $creator = $this->_UTF8toUTF16($creator); | |
| 293 | + } | |
| 284 | 294 | $this->creator = $creator; | 
| 285 | 295 | } | 
| 286 | 296 | |
| @@ -305,10 +315,12 @@ discard block | ||
| 305 | 315 | function Close() | 
| 306 | 316 |  { | 
| 307 | 317 | // Terminate document | 
| 308 | - if ($this->state == 3) | |
| 309 | - return; | |
| 310 | - if ($this->page == 0) | |
| 311 | - $this->AddPage(); | |
| 318 | +    if ($this->state == 3) { | |
| 319 | + return; | |
| 320 | + } | |
| 321 | +    if ($this->page == 0) { | |
| 322 | + $this->AddPage(); | |
| 323 | + } | |
| 312 | 324 | // Page footer | 
| 313 | 325 | $this->InFooter = true; | 
| 314 | 326 | $this->Footer(); | 
| @@ -322,8 +334,9 @@ discard block | ||
| 322 | 334 | function AddPage($orientation = '', $size = '') | 
| 323 | 335 |  { | 
| 324 | 336 | // Start a new page | 
| 325 | - if ($this->state == 0) | |
| 326 | - $this->Open(); | |
| 337 | +    if ($this->state == 0) { | |
| 338 | + $this->Open(); | |
| 339 | + } | |
| 327 | 340 | $family = $this->FontFamily; | 
| 328 | 341 | $style = $this->FontStyle.($this->underline ? 'U' : ''); | 
| 329 | 342 | $fontsize = $this->FontSizePt; | 
| @@ -349,15 +362,18 @@ discard block | ||
| 349 | 362 | $this->LineWidth = $lw; | 
| 350 | 363 |      $this->_out(sprintf('%.2F w', $lw * $this->k)); | 
| 351 | 364 | // Set font | 
| 352 | - if ($family) | |
| 353 | - $this->SetFont($family, $style, $fontsize); | |
| 365 | +    if ($family) { | |
| 366 | + $this->SetFont($family, $style, $fontsize); | |
| 367 | + } | |
| 354 | 368 | // Set colors | 
| 355 | 369 | $this->DrawColor = $dc; | 
| 356 | - if ($dc != '0 G') | |
| 357 | - $this->_out($dc); | |
| 370 | +    if ($dc != '0 G') { | |
| 371 | + $this->_out($dc); | |
| 372 | + } | |
| 358 | 373 | $this->FillColor = $fc; | 
| 359 | - if ($fc != '0 g') | |
| 360 | - $this->_out($fc); | |
| 374 | +    if ($fc != '0 g') { | |
| 375 | + $this->_out($fc); | |
| 376 | + } | |
| 361 | 377 | $this->TextColor = $tc; | 
| 362 | 378 | $this->ColorFlag = $cf; | 
| 363 | 379 | // Page header | 
| @@ -371,8 +387,9 @@ discard block | ||
| 371 | 387 |          $this->_out(sprintf('%.2F w', $lw * $this->k)); | 
| 372 | 388 | } | 
| 373 | 389 | // Restore font | 
| 374 | - if ($family) | |
| 375 | - $this->SetFont($family, $style, $fontsize); | |
| 390 | +    if ($family) { | |
| 391 | + $this->SetFont($family, $style, $fontsize); | |
| 392 | + } | |
| 376 | 393 | // Restore colors | 
| 377 | 394 | if ($this->DrawColor != $dc) | 
| 378 | 395 |      { | 
| @@ -498,23 +515,23 @@ discard block | ||
| 498 | 515 | // Add a TrueType, OpenType or Type1 font | 
| 499 | 516 | $family = strtolower($family); | 
| 500 | 517 | $style = strtoupper($style); | 
| 501 | - if($style=='IB') | |
| 502 | - $style='BI'; | |
| 518 | +    if($style=='IB') { | |
| 519 | + $style='BI'; | |
| 520 | + } | |
| 503 | 521 |      if($file=='') { | 
| 504 | 522 |          if ($uni) { | 
| 505 | 523 |          $file = str_replace(' ','',$family).strtolower($style).'.ttf'; | 
| 506 | - } | |
| 507 | -        else { | |
| 524 | +        } else { | |
| 508 | 525 |          $file = str_replace(' ','',$family).strtolower($style).'.php'; | 
| 509 | 526 | } | 
| 510 | 527 | } | 
| 511 | 528 | $fontkey = $family.$style; | 
| 512 | - if(isset($this->fonts[$fontkey])) | |
| 513 | - return; | |
| 529 | +    if(isset($this->fonts[$fontkey])) { | |
| 530 | + return; | |
| 531 | + } | |
| 514 | 532 | |
| 515 | 533 |      if ($uni) { | 
| 516 | -        if (defined("_SYSTEM_TTFONTS") && file_exists(_SYSTEM_TTFONTS.$file )) { $ttffilename = _SYSTEM_TTFONTS.$file ; } | |
| 517 | -        else { $ttffilename = $this->_getfontpath().'unifont/'.$file ; } | |
| 534 | +        if (defined("_SYSTEM_TTFONTS") && file_exists(_SYSTEM_TTFONTS.$file )) { $ttffilename = _SYSTEM_TTFONTS.$file ; } else { $ttffilename = $this->_getfontpath().'unifont/'.$file ; } | |
| 518 | 535 | $unifilename = $this->_getfontpath().'unifont/'.strtolower(substr($file ,0,(strpos($file ,'.')))); | 
| 519 | 536 | $name = ''; | 
| 520 | 537 | $originalsize = 0; | 
| @@ -563,22 +580,21 @@ discard block | ||
| 563 | 580 | @unlink($unifilename.'.cw127.php'); | 
| 564 | 581 | } | 
| 565 | 582 | unset($ttf); | 
| 566 | - } | |
| 567 | -        else { | |
| 583 | +        } else { | |
| 568 | 584 | $cw = @file_get_contents($unifilename.'.cw.dat'); | 
| 569 | 585 | } | 
| 570 | 586 | $i = count($this->fonts) + 1; | 
| 571 | - if (!empty($this->AliasNbPages)) | |
| 572 | - $sbarr = range(0, 57); | |
| 573 | - else | |
| 574 | - $sbarr = range(0, 32); | |
| 587 | +        if (!empty($this->AliasNbPages)) { | |
| 588 | + $sbarr = range(0, 57); | |
| 589 | +        } else { | |
| 590 | + $sbarr = range(0, 32); | |
| 591 | + } | |
| 575 | 592 |          $this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'ttffile'=>$ttffile, 'fontkey'=>$fontkey, 'subset'=>$sbarr, 'unifilename'=>$unifilename); | 
| 576 | 593 | |
| 577 | 594 |          $this->FontFiles[$fontkey] = array('length1'=>$originalsize, 'type'=>"TTF", 'ttffile'=>$ttffile); | 
| 578 | 595 |          $this->FontFiles[$file] = array('type'=>"TTF"); | 
| 579 | 596 | unset($cw); | 
| 580 | - } | |
| 581 | -    else { | |
| 597 | +    } else { | |
| 582 | 598 | $info = $this->_loadfont($file); | 
| 583 | 599 | $info['i'] = count($this->fonts) + 1; | 
| 584 | 600 | if (!empty($info['diff'])) | 
| @@ -595,10 +611,11 @@ discard block | ||
| 595 | 611 | if (!empty($info['file'])) | 
| 596 | 612 |          { | 
| 597 | 613 | // Embedded font | 
| 598 | - if ($info['type'] == 'TrueType') | |
| 599 | -                $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); | |
| 600 | - else | |
| 601 | -                $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); | |
| 614 | +            if ($info['type'] == 'TrueType') { | |
| 615 | +                            $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); | |
| 616 | +            } else { | |
| 617 | +                            $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); | |
| 618 | + } | |
| 602 | 619 | } | 
| 603 | 620 | $this->fonts[$fontkey] = $info; | 
| 604 | 621 | } | 
| @@ -660,22 +677,24 @@ discard block | ||
| 660 | 677 | $this->FontSizePt = $size; | 
| 661 | 678 | $this->FontSize = $size / $this->k; | 
| 662 | 679 | $this->CurrentFont = &$this->fonts[$fontkey]; | 
| 663 | -    if ($this->fonts[$fontkey]['type'] == 'TTF') { $this->unifontSubset = true; } | |
| 664 | -    else { $this->unifontSubset = false; } | |
| 665 | - if ($this->page > 0) | |
| 666 | -        $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); | |
| 667 | -} | |
| 680 | +    if ($this->fonts[$fontkey]['type'] == 'TTF') { $this->unifontSubset = true; } else { $this->unifontSubset = false; } | |
| 681 | +    if ($this->page > 0) { | |
| 682 | +            $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); | |
| 683 | + } | |
| 684 | + } | |
| 668 | 685 | |
| 669 | 686 | function SetFontSize($size) | 
| 670 | 687 |  { | 
| 671 | 688 | // Set font size in points | 
| 672 | - if ($this->FontSizePt == $size) | |
| 673 | - return; | |
| 689 | +    if ($this->FontSizePt == $size) { | |
| 690 | + return; | |
| 691 | + } | |
| 674 | 692 | $this->FontSizePt = $size; | 
| 675 | 693 | $this->FontSize = $size / $this->k; | 
| 676 | - if ($this->page > 0) | |
| 677 | -        $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); | |
| 678 | -} | |
| 694 | +    if ($this->page > 0) { | |
| 695 | +            $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); | |
| 696 | + } | |
| 697 | + } | |
| 679 | 698 | |
| 680 | 699 | function AddLink() | 
| 681 | 700 |  { | 
| @@ -688,10 +707,12 @@ discard block | ||
| 688 | 707 | function SetLink($link, $y = 0, $page = -1) | 
| 689 | 708 |  { | 
| 690 | 709 | // Set destination of internal link | 
| 691 | - if ($y == -1) | |
| 692 | - $y = $this->y; | |
| 693 | - if ($page == -1) | |
| 694 | - $page = $this->page; | |
| 710 | +    if ($y == -1) { | |
| 711 | + $y = $this->y; | |
| 712 | + } | |
| 713 | +    if ($page == -1) { | |
| 714 | + $page = $this->page; | |
| 715 | + } | |
| 695 | 716 | $this->links[$link] = array($page, $y); | 
| 696 | 717 | } | 
| 697 | 718 | |
| @@ -711,16 +732,19 @@ discard block | ||
| 711 | 732 | if ($this->unifontSubset) | 
| 712 | 733 |      { | 
| 713 | 734 |          $txt2 = '('.$this->_escape($this->UTF8ToUTF16BE($txt, false)).')'; | 
| 714 | - foreach ($this->UTF8StringToArray($txt) as $uni) | |
| 715 | - $this->CurrentFont['subset'][$uni] = $uni; | |
| 735 | +        foreach ($this->UTF8StringToArray($txt) as $uni) { | |
| 736 | + $this->CurrentFont['subset'][$uni] = $uni; | |
| 737 | + } | |
| 738 | +    } else { | |
| 739 | +            $txt2 = '('.$this->_escape($txt).')'; | |
| 716 | 740 | } | 
| 717 | - else | |
| 718 | -        $txt2 = '('.$this->_escape($txt).')'; | |
| 719 | 741 |      $s = sprintf('BT %.2F %.2F Td %s Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $txt2); | 
| 720 | - if ($this->underline && $txt != '') | |
| 721 | - $s .= ' '.$this->_dounderline($x, $y, $txt); | |
| 722 | - if ($this->ColorFlag) | |
| 723 | - $s = 'q '.$this->TextColor.' '.$s.' Q'; | |
| 742 | +    if ($this->underline && $txt != '') { | |
| 743 | + $s .= ' '.$this->_dounderline($x, $y, $txt); | |
| 744 | + } | |
| 745 | +    if ($this->ColorFlag) { | |
| 746 | + $s = 'q '.$this->TextColor.' '.$s.' Q'; | |
| 747 | + } | |
| 724 | 748 | $this->_out($s); | 
| 725 | 749 | } | 
| 726 | 750 | |
| @@ -752,45 +776,54 @@ discard block | ||
| 752 | 776 |              $this->_out(sprintf('%.3F Tw', $ws * $k)); | 
| 753 | 777 | } | 
| 754 | 778 | } | 
| 755 | - if ($w == 0) | |
| 756 | - $w = $this->w - $this->rMargin - $this->x; | |
| 779 | +    if ($w == 0) { | |
| 780 | + $w = $this->w - $this->rMargin - $this->x; | |
| 781 | + } | |
| 757 | 782 | $s = ''; | 
| 758 | 783 | if ($fill || $border == 1) | 
| 759 | 784 |      { | 
| 760 | - if ($fill) | |
| 761 | - $op = ($border == 1) ? 'B' : 'f'; | |
| 762 | - else | |
| 763 | - $op = 'S'; | |
| 785 | +        if ($fill) { | |
| 786 | + $op = ($border == 1) ? 'B' : 'f'; | |
| 787 | +        } else { | |
| 788 | + $op = 'S'; | |
| 789 | + } | |
| 764 | 790 |          $s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op); | 
| 765 | 791 | } | 
| 766 | 792 | if (is_string($border)) | 
| 767 | 793 |      { | 
| 768 | 794 | $x = $this->x; | 
| 769 | 795 | $y = $this->y; | 
| 770 | - if (strpos($border, 'L') !== false) | |
| 771 | -            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k); | |
| 772 | - if (strpos($border, 'T') !== false) | |
| 773 | -            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k); | |
| 774 | - if (strpos($border, 'R') !== false) | |
| 775 | -            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); | |
| 776 | - if (strpos($border, 'B') !== false) | |
| 777 | -            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); | |
| 796 | +        if (strpos($border, 'L') !== false) { | |
| 797 | +                    $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k); | |
| 798 | + } | |
| 799 | +        if (strpos($border, 'T') !== false) { | |
| 800 | +                    $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k); | |
| 801 | + } | |
| 802 | +        if (strpos($border, 'R') !== false) { | |
| 803 | +                    $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); | |
| 804 | + } | |
| 805 | +        if (strpos($border, 'B') !== false) { | |
| 806 | +                    $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); | |
| 807 | + } | |
| 778 | 808 | } | 
| 779 | 809 | if ($txt !== '') | 
| 780 | 810 |      { | 
| 781 | - if ($align == 'R') | |
| 782 | - $dx = $w - $this->cMargin - $this->GetStringWidth($txt); | |
| 783 | - elseif ($align == 'C') | |
| 784 | - $dx = ($w - $this->GetStringWidth($txt)) / 2; | |
| 785 | - else | |
| 786 | - $dx = $this->cMargin; | |
| 787 | - if ($this->ColorFlag) | |
| 788 | - $s .= 'q '.$this->TextColor.' '; | |
| 811 | +        if ($align == 'R') { | |
| 812 | + $dx = $w - $this->cMargin - $this->GetStringWidth($txt); | |
| 813 | +        } elseif ($align == 'C') { | |
| 814 | + $dx = ($w - $this->GetStringWidth($txt)) / 2; | |
| 815 | +        } else { | |
| 816 | + $dx = $this->cMargin; | |
| 817 | + } | |
| 818 | +        if ($this->ColorFlag) { | |
| 819 | + $s .= 'q '.$this->TextColor.' '; | |
| 820 | + } | |
| 789 | 821 | |
| 790 | 822 | // If multibyte, Tw has no effect - do word spacing using an adjustment before each space | 
| 791 | 823 |          if ($this->ws && $this->unifontSubset) { | 
| 792 | - foreach ($this->UTF8StringToArray($txt) as $uni) | |
| 793 | - $this->CurrentFont['subset'][$uni] = $uni; | |
| 824 | +            foreach ($this->UTF8StringToArray($txt) as $uni) { | |
| 825 | + $this->CurrentFont['subset'][$uni] = $uni; | |
| 826 | + } | |
| 794 | 827 |              $space = $this->_escape($this->UTF8ToUTF16BE(' ', false)); | 
| 795 | 828 |              $s .= sprintf('BT 0 Tw %.2F %.2F Td [', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k); | 
| 796 | 829 |              $t = explode(' ', $txt); | 
| @@ -806,55 +839,63 @@ discard block | ||
| 806 | 839 | } | 
| 807 | 840 | $s .= '] TJ'; | 
| 808 | 841 | $s .= ' ET'; | 
| 809 | - } | |
| 810 | -        else { | |
| 842 | +        } else { | |
| 811 | 843 | if ($this->unifontSubset) | 
| 812 | 844 |              { | 
| 813 | 845 |                  $txt2 = '('.$this->_escape($this->UTF8ToUTF16BE($txt, false)).')'; | 
| 814 | - foreach ($this->UTF8StringToArray($txt) as $uni) | |
| 815 | - $this->CurrentFont['subset'][$uni] = $uni; | |
| 846 | +                foreach ($this->UTF8StringToArray($txt) as $uni) { | |
| 847 | + $this->CurrentFont['subset'][$uni] = $uni; | |
| 848 | + } | |
| 849 | +            } else { | |
| 850 | +                            $txt2 = '('.str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))).')'; | |
| 816 | 851 | } | 
| 817 | - else | |
| 818 | -                $txt2 = '('.str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))).')'; | |
| 819 | 852 |              $s .= sprintf('BT %.2F %.2F Td %s Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txt2); | 
| 820 | 853 | } | 
| 821 | - if ($this->underline) | |
| 822 | - $s .= ' '.$this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt); | |
| 823 | - if ($this->ColorFlag) | |
| 824 | - $s .= ' Q'; | |
| 825 | - if ($link) | |
| 826 | - $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link); | |
| 854 | +        if ($this->underline) { | |
| 855 | + $s .= ' '.$this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt); | |
| 856 | + } | |
| 857 | +        if ($this->ColorFlag) { | |
| 858 | + $s .= ' Q'; | |
| 859 | + } | |
| 860 | +        if ($link) { | |
| 861 | + $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link); | |
| 862 | + } | |
| 863 | + } | |
| 864 | +    if ($s) { | |
| 865 | + $this->_out($s); | |
| 827 | 866 | } | 
| 828 | - if ($s) | |
| 829 | - $this->_out($s); | |
| 830 | 867 | $this->lasth = $h; | 
| 831 | 868 | if ($ln > 0) | 
| 832 | 869 |      { | 
| 833 | 870 | // Go to next line | 
| 834 | 871 | $this->y += $h; | 
| 835 | - if ($ln == 1) | |
| 836 | - $this->x = $this->lMargin; | |
| 872 | +        if ($ln == 1) { | |
| 873 | + $this->x = $this->lMargin; | |
| 874 | + } | |
| 875 | +    } else { | |
| 876 | + $this->x += $w; | |
| 877 | + } | |
| 837 | 878 | } | 
| 838 | - else | |
| 839 | - $this->x += $w; | |
| 840 | -} | |
| 841 | 879 | |
| 842 | 880 | function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false) | 
| 843 | 881 |  { | 
| 844 | 882 | // Output text with automatic or explicit line breaks | 
| 845 | 883 | $cw = &$this->CurrentFont['cw']; | 
| 846 | - if ($w == 0) | |
| 847 | - $w = $this->w - $this->rMargin - $this->x; | |
| 884 | +    if ($w == 0) { | |
| 885 | + $w = $this->w - $this->rMargin - $this->x; | |
| 886 | + } | |
| 848 | 887 | $wmax = ($w - 2 * $this->cMargin); | 
| 849 | 888 |      $s = str_replace("\r", '', $txt); | 
| 850 | 889 |      if ($this->unifontSubset) { | 
| 851 | 890 | $nb = mb_strlen($s, 'utf-8'); | 
| 852 | - while ($nb > 0 && mb_substr($s, $nb - 1, 1, 'utf-8') == "\n") $nb--; | |
| 853 | - } | |
| 854 | -    else { | |
| 855 | - $nb = strlen($s); | |
| 856 | - if ($nb > 0 && $s[$nb - 1] == "\n") | |
| 891 | +        while ($nb > 0 && mb_substr($s, $nb - 1, 1, 'utf-8') == "\n") { | |
| 857 | 892 | $nb--; | 
| 893 | + } | |
| 894 | +    } else { | |
| 895 | + $nb = strlen($s); | |
| 896 | +        if ($nb > 0 && $s[$nb - 1] == "\n") { | |
| 897 | + $nb--; | |
| 898 | + } | |
| 858 | 899 | } | 
| 859 | 900 | $b = 0; | 
| 860 | 901 | if ($border) | 
| @@ -864,14 +905,15 @@ discard block | ||
| 864 | 905 | $border = 'LTRB'; | 
| 865 | 906 | $b = 'LRT'; | 
| 866 | 907 | $b2 = 'LR'; | 
| 867 | - } | |
| 868 | - else | |
| 908 | + } else | |
| 869 | 909 |          { | 
| 870 | 910 | $b2 = ''; | 
| 871 | - if (strpos($border, 'L') !== false) | |
| 872 | - $b2 .= 'L'; | |
| 873 | - if (strpos($border, 'R') !== false) | |
| 874 | - $b2 .= 'R'; | |
| 911 | +            if (strpos($border, 'L') !== false) { | |
| 912 | + $b2 .= 'L'; | |
| 913 | + } | |
| 914 | +            if (strpos($border, 'R') !== false) { | |
| 915 | + $b2 .= 'R'; | |
| 916 | + } | |
| 875 | 917 | $b = (strpos($border, 'T') !== false) ? $b2.'T' : $b2; | 
| 876 | 918 | } | 
| 877 | 919 | } | 
| @@ -886,8 +928,7 @@ discard block | ||
| 886 | 928 | // Get next character | 
| 887 | 929 |          if ($this->unifontSubset) { | 
| 888 | 930 | $c = mb_substr($s, $i, 1, 'UTF-8'); | 
| 889 | - } | |
| 890 | -        else { | |
| 931 | +        } else { | |
| 891 | 932 | $c = $s[$i]; | 
| 892 | 933 | } | 
| 893 | 934 | if ($c == "\n") | 
| @@ -900,8 +941,7 @@ discard block | ||
| 900 | 941 | } | 
| 901 | 942 |              if ($this->unifontSubset) { | 
| 902 | 943 | $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), $b, 2, $align, $fill); | 
| 903 | - } | |
| 904 | -            else { | |
| 944 | +            } else { | |
| 905 | 945 | $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); | 
| 906 | 946 | } | 
| 907 | 947 | $i++; | 
| @@ -910,8 +950,9 @@ discard block | ||
| 910 | 950 | $l = 0; | 
| 911 | 951 | $ns = 0; | 
| 912 | 952 | $nl++; | 
| 913 | - if ($border && $nl == 2) | |
| 914 | - $b = $b2; | |
| 953 | +            if ($border && $nl == 2) { | |
| 954 | + $b = $b2; | |
| 955 | + } | |
| 915 | 956 | continue; | 
| 916 | 957 | } | 
| 917 | 958 | if ($c == ' ') | 
| @@ -921,16 +962,16 @@ discard block | ||
| 921 | 962 | $ns++; | 
| 922 | 963 | } | 
| 923 | 964 | |
| 924 | -        if ($this->unifontSubset) { $l += $this->GetStringWidth($c); } | |
| 925 | -        else { $l += $cw[$c] * $this->FontSize / 1000; } | |
| 965 | +        if ($this->unifontSubset) { $l += $this->GetStringWidth($c); } else { $l += $cw[$c] * $this->FontSize / 1000; } | |
| 926 | 966 | |
| 927 | 967 | if ($l > $wmax) | 
| 928 | 968 |          { | 
| 929 | 969 | // Automatic line break | 
| 930 | 970 | if ($sep == -1) | 
| 931 | 971 |              { | 
| 932 | - if ($i == $j) | |
| 933 | - $i++; | |
| 972 | +                if ($i == $j) { | |
| 973 | + $i++; | |
| 974 | + } | |
| 934 | 975 | if ($this->ws > 0) | 
| 935 | 976 |                  { | 
| 936 | 977 | $this->ws = 0; | 
| @@ -938,12 +979,10 @@ discard block | ||
| 938 | 979 | } | 
| 939 | 980 |                  if ($this->unifontSubset) { | 
| 940 | 981 | $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), $b, 2, $align, $fill); | 
| 941 | - } | |
| 942 | -                else { | |
| 982 | +                } else { | |
| 943 | 983 | $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); | 
| 944 | 984 | } | 
| 945 | - } | |
| 946 | - else | |
| 985 | + } else | |
| 947 | 986 |              { | 
| 948 | 987 | if ($align == 'J') | 
| 949 | 988 |                  { | 
| @@ -952,8 +991,7 @@ discard block | ||
| 952 | 991 | } | 
| 953 | 992 |                  if ($this->unifontSubset) { | 
| 954 | 993 | $this->Cell($w, $h, mb_substr($s, $j, $sep - $j, 'UTF-8'), $b, 2, $align, $fill); | 
| 955 | - } | |
| 956 | -                else { | |
| 994 | +                } else { | |
| 957 | 995 | $this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill); | 
| 958 | 996 | } | 
| 959 | 997 | $i = $sep + 1; | 
| @@ -963,11 +1001,12 @@ discard block | ||
| 963 | 1001 | $l = 0; | 
| 964 | 1002 | $ns = 0; | 
| 965 | 1003 | $nl++; | 
| 966 | - if ($border && $nl == 2) | |
| 967 | - $b = $b2; | |
| 1004 | +            if ($border && $nl == 2) { | |
| 1005 | + $b = $b2; | |
| 1006 | + } | |
| 1007 | +        } else { | |
| 1008 | + $i++; | |
| 968 | 1009 | } | 
| 969 | - else | |
| 970 | - $i++; | |
| 971 | 1010 | } | 
| 972 | 1011 | // Last chunk | 
| 973 | 1012 | if ($this->ws > 0) | 
| @@ -975,12 +1014,12 @@ discard block | ||
| 975 | 1014 | $this->ws = 0; | 
| 976 | 1015 |          $this->_out('0 Tw'); | 
| 977 | 1016 | } | 
| 978 | - if ($border && strpos($border, 'B') !== false) | |
| 979 | - $b .= 'B'; | |
| 1017 | +    if ($border && strpos($border, 'B') !== false) { | |
| 1018 | + $b .= 'B'; | |
| 1019 | + } | |
| 980 | 1020 |      if ($this->unifontSubset) { | 
| 981 | 1021 | $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), $b, 2, $align, $fill); | 
| 982 | - } | |
| 983 | -    else { | |
| 1022 | +    } else { | |
| 984 | 1023 | $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); | 
| 985 | 1024 | } | 
| 986 | 1025 | $this->x = $this->lMargin; | 
| @@ -1013,8 +1052,7 @@ discard block | ||
| 1013 | 1052 | // Get next character | 
| 1014 | 1053 |          if ($this->unifontSubset) { | 
| 1015 | 1054 | $c = mb_substr($s, $i, 1, 'UTF-8'); | 
| 1016 | - } | |
| 1017 | -        else { | |
| 1055 | +        } else { | |
| 1018 | 1056 | $c = $s[$i]; | 
| 1019 | 1057 | } | 
| 1020 | 1058 | if ($c == "\n") | 
| @@ -1022,8 +1060,7 @@ discard block | ||
| 1022 | 1060 | // Explicit line break | 
| 1023 | 1061 |              if ($this->unifontSubset) { | 
| 1024 | 1062 | $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), 0, 2, '', 0, $link); | 
| 1025 | - } | |
| 1026 | -            else { | |
| 1063 | +            } else { | |
| 1027 | 1064 | $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link); | 
| 1028 | 1065 | } | 
| 1029 | 1066 | $i++; | 
| @@ -1039,11 +1076,11 @@ discard block | ||
| 1039 | 1076 | $nl++; | 
| 1040 | 1077 | continue; | 
| 1041 | 1078 | } | 
| 1042 | - if ($c == ' ') | |
| 1043 | - $sep = $i; | |
| 1079 | +        if ($c == ' ') { | |
| 1080 | + $sep = $i; | |
| 1081 | + } | |
| 1044 | 1082 | |
| 1045 | -        if ($this->unifontSubset) { $l += $this->GetStringWidth($c); } | |
| 1046 | -        else { $l += $cw[$c] * $this->FontSize / 1000; } | |
| 1083 | +        if ($this->unifontSubset) { $l += $this->GetStringWidth($c); } else { $l += $cw[$c] * $this->FontSize / 1000; } | |
| 1047 | 1084 | |
| 1048 | 1085 | if ($l > $wmax) | 
| 1049 | 1086 |          { | 
| @@ -1061,21 +1098,19 @@ discard block | ||
| 1061 | 1098 | $nl++; | 
| 1062 | 1099 | continue; | 
| 1063 | 1100 | } | 
| 1064 | - if ($i == $j) | |
| 1065 | - $i++; | |
| 1101 | +                if ($i == $j) { | |
| 1102 | + $i++; | |
| 1103 | + } | |
| 1066 | 1104 |                  if ($this->unifontSubset) { | 
| 1067 | 1105 | $this->Cell($w, $h, mb_substr($s, $j, $i - $j, 'UTF-8'), 0, 2, '', 0, $link); | 
| 1068 | - } | |
| 1069 | -                else { | |
| 1106 | +                } else { | |
| 1070 | 1107 | $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link); | 
| 1071 | 1108 | } | 
| 1072 | - } | |
| 1073 | - else | |
| 1109 | + } else | |
| 1074 | 1110 |              { | 
| 1075 | 1111 |                  if ($this->unifontSubset) { | 
| 1076 | 1112 | $this->Cell($w, $h, mb_substr($s, $j, $sep - $j, 'UTF-8'), 0, 2, '', 0, $link); | 
| 1077 | - } | |
| 1078 | -                else { | |
| 1113 | +                } else { | |
| 1079 | 1114 | $this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link); | 
| 1080 | 1115 | } | 
| 1081 | 1116 | $i = $sep + 1; | 
| @@ -1199,11 +1234,12 @@ discard block | ||
| 1199 | 1234 | function SetX($x) | 
| 1200 | 1235 |  { | 
| 1201 | 1236 | // Set x position | 
| 1202 | - if ($x >= 0) | |
| 1203 | - $this->x = $x; | |
| 1204 | - else | |
| 1205 | - $this->x = $this->w + $x; | |
| 1206 | -} | |
| 1237 | +    if ($x >= 0) { | |
| 1238 | + $this->x = $x; | |
| 1239 | +    } else { | |
| 1240 | + $this->x = $this->w + $x; | |
| 1241 | + } | |
| 1242 | + } | |
| 1207 | 1243 | |
| 1208 | 1244 | function GetY() | 
| 1209 | 1245 |  { | 
| @@ -1215,11 +1251,12 @@ discard block | ||
| 1215 | 1251 |  { | 
| 1216 | 1252 | // Set y position and reset x | 
| 1217 | 1253 | $this->x = $this->lMargin; | 
| 1218 | - if ($y >= 0) | |
| 1219 | - $this->y = $y; | |
| 1220 | - else | |
| 1221 | - $this->y = $this->h + $y; | |
| 1222 | -} | |
| 1254 | +    if ($y >= 0) { | |
| 1255 | + $this->y = $y; | |
| 1256 | +    } else { | |
| 1257 | + $this->y = $this->h + $y; | |
| 1258 | + } | |
| 1259 | + } | |
| 1223 | 1260 | |
| 1224 | 1261 | function SetXY($x, $y) | 
| 1225 | 1262 |  { | 
| @@ -1231,8 +1268,9 @@ discard block | ||
| 1231 | 1268 | function Output($name = '', $dest = '') | 
| 1232 | 1269 |  { | 
| 1233 | 1270 | // Output PDF to some destination | 
| 1234 | - if ($this->state < 3) | |
| 1235 | - $this->Close(); | |
| 1271 | +    if ($this->state < 3) { | |
| 1272 | + $this->Close(); | |
| 1273 | + } | |
| 1236 | 1274 | $dest = strtoupper($dest); | 
| 1237 | 1275 | if ($dest == '') | 
| 1238 | 1276 |      { | 
| @@ -1271,8 +1309,9 @@ discard block | ||
| 1271 | 1309 | case 'F': | 
| 1272 | 1310 | // Save to local file | 
| 1273 | 1311 | $f = fopen($name, 'wb'); | 
| 1274 | - if (!$f) | |
| 1275 | -                $this->Error('Unable to create output file: '.$name); | |
| 1312 | +            if (!$f) { | |
| 1313 | +                            $this->Error('Unable to create output file: '.$name); | |
| 1314 | + } | |
| 1276 | 1315 | fwrite($f, $this->buffer, strlen($this->buffer)); | 
| 1277 | 1316 | fclose($f); | 
| 1278 | 1317 | break; | 
| @@ -1293,18 +1332,22 @@ discard block | ||
| 1293 | 1332 | function _dochecks() | 
| 1294 | 1333 |  { | 
| 1295 | 1334 | // Check availability of %F | 
| 1296 | -    if (sprintf('%.1F', 1.0) != '1.0') | |
| 1297 | -        $this->Error('This version of PHP is not supported'); | |
| 1335 | +    if (sprintf('%.1F', 1.0) != '1.0') { | |
| 1336 | +            $this->Error('This version of PHP is not supported'); | |
| 1337 | + } | |
| 1298 | 1338 | // Check availability of mbstring | 
| 1299 | -    if (!function_exists('mb_strlen')) | |
| 1300 | -        $this->Error('mbstring extension is not available'); | |
| 1339 | +    if (!function_exists('mb_strlen')) { | |
| 1340 | +            $this->Error('mbstring extension is not available'); | |
| 1341 | + } | |
| 1301 | 1342 | // Check mbstring overloading | 
| 1302 | -    if (ini_get('mbstring.func_overload') & 2) | |
| 1303 | -        $this->Error('mbstring overloading must be disabled'); | |
| 1343 | +    if (ini_get('mbstring.func_overload') & 2) { | |
| 1344 | +            $this->Error('mbstring overloading must be disabled'); | |
| 1345 | + } | |
| 1304 | 1346 | // Ensure runtime magic quotes are disabled | 
| 1305 | - if (get_magic_quotes_runtime()) | |
| 1306 | - @set_magic_quotes_runtime(0); | |
| 1307 | -} | |
| 1347 | +    if (get_magic_quotes_runtime()) { | |
| 1348 | + @set_magic_quotes_runtime(0); | |
| 1349 | + } | |
| 1350 | + } | |
| 1308 | 1351 | |
| 1309 | 1352 | function _getfontpath() | 
| 1310 | 1353 |  { | 
| @@ -1315,8 +1358,9 @@ discard block | ||
| 1315 | 1358 |  { | 
| 1316 | 1359 | if (PHP_SAPI != 'cli') | 
| 1317 | 1360 |      { | 
| 1318 | - if (headers_sent($file, $line)) | |
| 1319 | -            $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); | |
| 1361 | +        if (headers_sent($file, $line)) { | |
| 1362 | +                    $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); | |
| 1363 | + } | |
| 1320 | 1364 | } | 
| 1321 | 1365 | if (ob_get_length()) | 
| 1322 | 1366 |      { | 
| @@ -1336,17 +1380,18 @@ discard block | ||
| 1336 | 1380 | if (is_string($size)) | 
| 1337 | 1381 |      { | 
| 1338 | 1382 | $size = strtolower($size); | 
| 1339 | - if (!isset($this->StdPageSizes[$size])) | |
| 1340 | -            $this->Error('Unknown page size: '.$size); | |
| 1383 | +        if (!isset($this->StdPageSizes[$size])) { | |
| 1384 | +                    $this->Error('Unknown page size: '.$size); | |
| 1385 | + } | |
| 1341 | 1386 | $a = $this->StdPageSizes[$size]; | 
| 1342 | 1387 | return array($a[0] / $this->k, $a[1] / $this->k); | 
| 1343 | - } | |
| 1344 | - else | |
| 1388 | + } else | |
| 1345 | 1389 |      { | 
| 1346 | - if ($size[0] > $size[1]) | |
| 1347 | - return array($size[1], $size[0]); | |
| 1348 | - else | |
| 1349 | - return $size; | |
| 1390 | +        if ($size[0] > $size[1]) { | |
| 1391 | + return array($size[1], $size[0]); | |
| 1392 | +        } else { | |
| 1393 | + return $size; | |
| 1394 | + } | |
| 1350 | 1395 | } | 
| 1351 | 1396 | } | 
| 1352 | 1397 | |
| @@ -1363,14 +1408,16 @@ discard block | ||
| 1363 | 1408 | $this->y = $this->tMargin; | 
| 1364 | 1409 | $this->FontFamily = ''; | 
| 1365 | 1410 | // Check page size and orientation | 
| 1366 | - if ($orientation == '') | |
| 1367 | - $orientation = $this->DefOrientation; | |
| 1368 | - else | |
| 1369 | - $orientation = strtoupper($orientation[0]); | |
| 1370 | - if ($size == '') | |
| 1371 | - $size = $this->DefPageSize; | |
| 1372 | - else | |
| 1373 | - $size = $this->_getpagesize($size); | |
| 1411 | +    if ($orientation == '') { | |
| 1412 | + $orientation = $this->DefOrientation; | |
| 1413 | +    } else { | |
| 1414 | + $orientation = strtoupper($orientation[0]); | |
| 1415 | + } | |
| 1416 | +    if ($size == '') { | |
| 1417 | + $size = $this->DefPageSize; | |
| 1418 | +    } else { | |
| 1419 | + $size = $this->_getpagesize($size); | |
| 1420 | + } | |
| 1374 | 1421 | if ($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1]) | 
| 1375 | 1422 |      { | 
| 1376 | 1423 | // New size or orientation | 
| @@ -1389,9 +1436,10 @@ discard block | ||
| 1389 | 1436 | $this->CurOrientation = $orientation; | 
| 1390 | 1437 | $this->CurPageSize = $size; | 
| 1391 | 1438 | } | 
| 1392 | - if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1]) | |
| 1393 | - $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); | |
| 1394 | -} | |
| 1439 | +    if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1]) { | |
| 1440 | + $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); | |
| 1441 | + } | |
| 1442 | + } | |
| 1395 | 1443 | |
| 1396 | 1444 | function _endpage() | 
| 1397 | 1445 |  { | 
| @@ -1406,8 +1454,9 @@ discard block | ||
| 1406 | 1454 | // Load a font definition file from the font directory | 
| 1407 | 1455 | include($this->fontpath.$font); | 
| 1408 | 1456 | $a = get_defined_vars(); | 
| 1409 | - if (!isset($a['name'])) | |
| 1410 | -        $this->Error('Could not include font definition file'); | |
| 1457 | +    if (!isset($a['name'])) { | |
| 1458 | +            $this->Error('Could not include font definition file'); | |
| 1459 | + } | |
| 1411 | 1460 | return $a; | 
| 1412 | 1461 | } | 
| 1413 | 1462 | |
| @@ -1443,15 +1492,13 @@ discard block | ||
| 1443 | 1492 | $c3 = ord($s[$i++]); | 
| 1444 | 1493 | $res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2)); | 
| 1445 | 1494 | $res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F)); | 
| 1446 | - } | |
| 1447 | - elseif ($c1 >= 192) | |
| 1495 | + } elseif ($c1 >= 192) | |
| 1448 | 1496 |          { | 
| 1449 | 1497 | // 2-byte character | 
| 1450 | 1498 | $c2 = ord($s[$i++]); | 
| 1451 | 1499 | $res .= chr(($c1 & 0x1C) >> 2); | 
| 1452 | 1500 | $res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F)); | 
| 1453 | - } | |
| 1454 | - else | |
| 1501 | + } else | |
| 1455 | 1502 |          { | 
| 1456 | 1503 | // Single-byte character | 
| 1457 | 1504 | $res .= "\0".chr($c1); | 
| @@ -1473,16 +1520,19 @@ discard block | ||
| 1473 | 1520 |  { | 
| 1474 | 1521 | // Extract info from a JPEG file | 
| 1475 | 1522 | $a = getimagesize($file); | 
| 1476 | - if (!$a) | |
| 1477 | -        $this->Error('Missing or incorrect image file: '.$file); | |
| 1478 | - if ($a[2] != 2) | |
| 1479 | -        $this->Error('Not a JPEG file: '.$file); | |
| 1480 | - if (!isset($a['channels']) || $a['channels'] == 3) | |
| 1481 | - $colspace = 'DeviceRGB'; | |
| 1482 | - elseif ($a['channels'] == 4) | |
| 1483 | - $colspace = 'DeviceCMYK'; | |
| 1484 | - else | |
| 1485 | - $colspace = 'DeviceGray'; | |
| 1523 | +    if (!$a) { | |
| 1524 | +            $this->Error('Missing or incorrect image file: '.$file); | |
| 1525 | + } | |
| 1526 | +    if ($a[2] != 2) { | |
| 1527 | +            $this->Error('Not a JPEG file: '.$file); | |
| 1528 | + } | |
| 1529 | +    if (!isset($a['channels']) || $a['channels'] == 3) { | |
| 1530 | + $colspace = 'DeviceRGB'; | |
| 1531 | +    } elseif ($a['channels'] == 4) { | |
| 1532 | + $colspace = 'DeviceCMYK'; | |
| 1533 | +    } else { | |
| 1534 | + $colspace = 'DeviceGray'; | |
| 1535 | + } | |
| 1486 | 1536 | $bpc = isset($a['bits']) ? $a['bits'] : 8; | 
| 1487 | 1537 | $data = file_get_contents($file); | 
| 1488 | 1538 |      return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); | 
| @@ -1495,8 +1545,9 @@ discard block | ||
| 1495 | 1545 |  { | 
| 1496 | 1546 | // Extract info from a PNG file | 
| 1497 | 1547 | $f = fopen($file, 'rb'); | 
| 1498 | - if (!$f) | |
| 1499 | -        $this->Error('Can\'t open image file: '.$file); | |
| 1548 | +    if (!$f) { | |
| 1549 | +            $this->Error('Can\'t open image file: '.$file); | |
| 1550 | + } | |
| 1500 | 1551 | $info = $this->_parsepngstream($f, $file); | 
| 1501 | 1552 | fclose($f); | 
| 1502 | 1553 | return $info; | 
| @@ -1505,33 +1556,40 @@ discard block | ||
| 1505 | 1556 | function _parsepngstream($f, $file) | 
| 1506 | 1557 |  { | 
| 1507 | 1558 | // Check signature | 
| 1508 | - if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) | |
| 1509 | -        $this->Error('Not a PNG file: '.$file); | |
| 1559 | +    if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { | |
| 1560 | +            $this->Error('Not a PNG file: '.$file); | |
| 1561 | + } | |
| 1510 | 1562 | |
| 1511 | 1563 | // Read header chunk | 
| 1512 | 1564 | $this->_readstream($f, 4); | 
| 1513 | - if ($this->_readstream($f, 4) != 'IHDR') | |
| 1514 | -        $this->Error('Incorrect PNG file: '.$file); | |
| 1565 | +    if ($this->_readstream($f, 4) != 'IHDR') { | |
| 1566 | +            $this->Error('Incorrect PNG file: '.$file); | |
| 1567 | + } | |
| 1515 | 1568 | $w = $this->_readint($f); | 
| 1516 | 1569 | $h = $this->_readint($f); | 
| 1517 | 1570 | $bpc = ord($this->_readstream($f, 1)); | 
| 1518 | - if ($bpc > 8) | |
| 1519 | -        $this->Error('16-bit depth not supported: '.$file); | |
| 1571 | +    if ($bpc > 8) { | |
| 1572 | +            $this->Error('16-bit depth not supported: '.$file); | |
| 1573 | + } | |
| 1520 | 1574 | $ct = ord($this->_readstream($f, 1)); | 
| 1521 | - if ($ct == 0 || $ct == 4) | |
| 1522 | - $colspace = 'DeviceGray'; | |
| 1523 | - elseif ($ct == 2 || $ct == 6) | |
| 1524 | - $colspace = 'DeviceRGB'; | |
| 1525 | - elseif ($ct == 3) | |
| 1526 | - $colspace = 'Indexed'; | |
| 1527 | - else | |
| 1528 | -        $this->Error('Unknown color type: '.$file); | |
| 1529 | - if (ord($this->_readstream($f, 1)) != 0) | |
| 1530 | -        $this->Error('Unknown compression method: '.$file); | |
| 1531 | - if (ord($this->_readstream($f, 1)) != 0) | |
| 1532 | -        $this->Error('Unknown filter method: '.$file); | |
| 1533 | - if (ord($this->_readstream($f, 1)) != 0) | |
| 1534 | -        $this->Error('Interlacing not supported: '.$file); | |
| 1575 | +    if ($ct == 0 || $ct == 4) { | |
| 1576 | + $colspace = 'DeviceGray'; | |
| 1577 | +    } elseif ($ct == 2 || $ct == 6) { | |
| 1578 | + $colspace = 'DeviceRGB'; | |
| 1579 | +    } elseif ($ct == 3) { | |
| 1580 | + $colspace = 'Indexed'; | |
| 1581 | +    } else { | |
| 1582 | +            $this->Error('Unknown color type: '.$file); | |
| 1583 | + } | |
| 1584 | +    if (ord($this->_readstream($f, 1)) != 0) { | |
| 1585 | +            $this->Error('Unknown compression method: '.$file); | |
| 1586 | + } | |
| 1587 | +    if (ord($this->_readstream($f, 1)) != 0) { | |
| 1588 | +            $this->Error('Unknown filter method: '.$file); | |
| 1589 | + } | |
| 1590 | +    if (ord($this->_readstream($f, 1)) != 0) { | |
| 1591 | +            $this->Error('Interlacing not supported: '.$file); | |
| 1592 | + } | |
| 1535 | 1593 | $this->_readstream($f, 4); | 
| 1536 | 1594 | $dp = '/Predictor 15 /Colors '.($colspace == 'DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; | 
| 1537 | 1595 | |
| @@ -1548,44 +1606,45 @@ discard block | ||
| 1548 | 1606 | // Read palette | 
| 1549 | 1607 | $pal = $this->_readstream($f, $n); | 
| 1550 | 1608 | $this->_readstream($f, 4); | 
| 1551 | - } | |
| 1552 | - elseif ($type == 'tRNS') | |
| 1609 | + } elseif ($type == 'tRNS') | |
| 1553 | 1610 |          { | 
| 1554 | 1611 | // Read transparency info | 
| 1555 | 1612 | $t = $this->_readstream($f, $n); | 
| 1556 | - if ($ct == 0) | |
| 1557 | - $trns = array(ord(substr($t, 1, 1))); | |
| 1558 | - elseif ($ct == 2) | |
| 1559 | - $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1))); | |
| 1560 | - else | |
| 1613 | +            if ($ct == 0) { | |
| 1614 | + $trns = array(ord(substr($t, 1, 1))); | |
| 1615 | +            } elseif ($ct == 2) { | |
| 1616 | + $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1))); | |
| 1617 | + } else | |
| 1561 | 1618 |              { | 
| 1562 | 1619 | $pos = strpos($t, chr(0)); | 
| 1563 | - if ($pos !== false) | |
| 1564 | - $trns = array($pos); | |
| 1620 | +                if ($pos !== false) { | |
| 1621 | + $trns = array($pos); | |
| 1622 | + } | |
| 1565 | 1623 | } | 
| 1566 | 1624 | $this->_readstream($f, 4); | 
| 1567 | - } | |
| 1568 | - elseif ($type == 'IDAT') | |
| 1625 | + } elseif ($type == 'IDAT') | |
| 1569 | 1626 |          { | 
| 1570 | 1627 | // Read image data block | 
| 1571 | 1628 | $data .= $this->_readstream($f, $n); | 
| 1572 | 1629 | $this->_readstream($f, 4); | 
| 1630 | +        } elseif ($type == 'IEND') { | |
| 1631 | + break; | |
| 1632 | +        } else { | |
| 1633 | + $this->_readstream($f, $n + 4); | |
| 1573 | 1634 | } | 
| 1574 | - elseif ($type == 'IEND') | |
| 1575 | - break; | |
| 1576 | - else | |
| 1577 | - $this->_readstream($f, $n + 4); | |
| 1578 | 1635 | } | 
| 1579 | 1636 | while ($n); | 
| 1580 | 1637 | |
| 1581 | - if ($colspace == 'Indexed' && empty($pal)) | |
| 1582 | -        $this->Error('Missing palette in '.$file); | |
| 1638 | +    if ($colspace == 'Indexed' && empty($pal)) { | |
| 1639 | +            $this->Error('Missing palette in '.$file); | |
| 1640 | + } | |
| 1583 | 1641 |      $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns); | 
| 1584 | 1642 | if ($ct >= 4) | 
| 1585 | 1643 |      { | 
| 1586 | 1644 | // Extract alpha channel | 
| 1587 | -        if (!function_exists('gzuncompress')) | |
| 1588 | -            $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); | |
| 1645 | +        if (!function_exists('gzuncompress')) { | |
| 1646 | +                    $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); | |
| 1647 | + } | |
| 1589 | 1648 | $data = gzuncompress($data); | 
| 1590 | 1649 | $color = ''; | 
| 1591 | 1650 | $alpha = ''; | 
| @@ -1619,8 +1678,9 @@ discard block | ||
| 1619 | 1678 | unset($data); | 
| 1620 | 1679 | $data = gzcompress($color); | 
| 1621 | 1680 | $info['smask'] = gzcompress($alpha); | 
| 1622 | - if ($this->PDFVersion < '1.4') | |
| 1623 | - $this->PDFVersion = '1.4'; | |
| 1681 | +        if ($this->PDFVersion < '1.4') { | |
| 1682 | + $this->PDFVersion = '1.4'; | |
| 1683 | + } | |
| 1624 | 1684 | } | 
| 1625 | 1685 | $info['data'] = $data; | 
| 1626 | 1686 | return $info; | 
| @@ -1633,13 +1693,15 @@ discard block | ||
| 1633 | 1693 | while ($n > 0 && !feof($f)) | 
| 1634 | 1694 |      { | 
| 1635 | 1695 | $s = fread($f, $n); | 
| 1636 | - if ($s === false) | |
| 1637 | -            $this->Error('Error while reading stream'); | |
| 1696 | +        if ($s === false) { | |
| 1697 | +                    $this->Error('Error while reading stream'); | |
| 1698 | + } | |
| 1638 | 1699 | $n -= strlen($s); | 
| 1639 | 1700 | $res .= $s; | 
| 1640 | 1701 | } | 
| 1641 | - if ($n > 0) | |
| 1642 | -        $this->Error('Unexpected end of stream'); | |
| 1702 | +    if ($n > 0) { | |
| 1703 | +            $this->Error('Unexpected end of stream'); | |
| 1704 | + } | |
| 1643 | 1705 | return $res; | 
| 1644 | 1706 | } | 
| 1645 | 1707 | |
| @@ -1653,13 +1715,16 @@ discard block | ||
| 1653 | 1715 | function _parsegif($file) | 
| 1654 | 1716 |  { | 
| 1655 | 1717 | // Extract info from a GIF file (via PNG conversion) | 
| 1656 | -    if (!function_exists('imagepng')) | |
| 1657 | -        $this->Error('GD extension is required for GIF support'); | |
| 1658 | -    if (!function_exists('imagecreatefromgif')) | |
| 1659 | -        $this->Error('GD has no GIF read support'); | |
| 1718 | +    if (!function_exists('imagepng')) { | |
| 1719 | +            $this->Error('GD extension is required for GIF support'); | |
| 1720 | + } | |
| 1721 | +    if (!function_exists('imagecreatefromgif')) { | |
| 1722 | +            $this->Error('GD has no GIF read support'); | |
| 1723 | + } | |
| 1660 | 1724 | $im = imagecreatefromgif($file); | 
| 1661 | - if (!$im) | |
| 1662 | -        $this->Error('Missing or incorrect image file: '.$file); | |
| 1725 | +    if (!$im) { | |
| 1726 | +            $this->Error('Missing or incorrect image file: '.$file); | |
| 1727 | + } | |
| 1663 | 1728 | imageinterlace($im, 0); | 
| 1664 | 1729 |      $f = @fopen('php://temp', 'rb+'); | 
| 1665 | 1730 | if ($f) | 
| @@ -1673,15 +1738,16 @@ discard block | ||
| 1673 | 1738 | rewind($f); | 
| 1674 | 1739 | $info = $this->_parsepngstream($f, $file); | 
| 1675 | 1740 | fclose($f); | 
| 1676 | - } | |
| 1677 | - else | |
| 1741 | + } else | |
| 1678 | 1742 |      { | 
| 1679 | 1743 | // Use temporary file | 
| 1680 | 1744 |          $tmp = tempnam('.', 'gif'); | 
| 1681 | - if (!$tmp) | |
| 1682 | -            $this->Error('Unable to create a temporary file'); | |
| 1683 | - if (!imagepng($im, $tmp)) | |
| 1684 | -            $this->Error('Error while saving to temporary file'); | |
| 1745 | +        if (!$tmp) { | |
| 1746 | +                    $this->Error('Unable to create a temporary file'); | |
| 1747 | + } | |
| 1748 | +        if (!imagepng($im, $tmp)) { | |
| 1749 | +                    $this->Error('Error while saving to temporary file'); | |
| 1750 | + } | |
| 1685 | 1751 | imagedestroy($im); | 
| 1686 | 1752 | $info = $this->_parsepng($tmp); | 
| 1687 | 1753 | unlink($tmp); | 
| @@ -1707,11 +1773,12 @@ discard block | ||
| 1707 | 1773 | function _out($s) | 
| 1708 | 1774 |  { | 
| 1709 | 1775 | // Add a line to the document | 
| 1710 | - if ($this->state == 2) | |
| 1711 | - $this->pages[$this->page] .= $s."\n"; | |
| 1712 | - else | |
| 1713 | - $this->buffer .= $s."\n"; | |
| 1714 | -} | |
| 1776 | +    if ($this->state == 2) { | |
| 1777 | + $this->pages[$this->page] .= $s."\n"; | |
| 1778 | +    } else { | |
| 1779 | + $this->buffer .= $s."\n"; | |
| 1780 | + } | |
| 1781 | + } | |
| 1715 | 1782 | |
| 1716 | 1783 | function _putpages() | 
| 1717 | 1784 |  { | 
| @@ -1721,18 +1788,19 @@ discard block | ||
| 1721 | 1788 | // Replace number of pages in fonts using subsets | 
| 1722 | 1789 | $alias = $this->UTF8ToUTF16BE($this->AliasNbPages, false); | 
| 1723 | 1790 |          $r = $this->UTF8ToUTF16BE("$nb", false); | 
| 1724 | - for ($n = 1; $n <= $nb; $n++) | |
| 1725 | - $this->pages[$n] = str_replace($alias, $r, $this->pages[$n]); | |
| 1791 | +        for ($n = 1; $n <= $nb; $n++) { | |
| 1792 | + $this->pages[$n] = str_replace($alias, $r, $this->pages[$n]); | |
| 1793 | + } | |
| 1726 | 1794 | // Now repeat for no pages in non-subset fonts | 
| 1727 | - for ($n = 1; $n <= $nb; $n++) | |
| 1728 | - $this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]); | |
| 1795 | +        for ($n = 1; $n <= $nb; $n++) { | |
| 1796 | + $this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]); | |
| 1797 | + } | |
| 1729 | 1798 | } | 
| 1730 | 1799 | if ($this->DefOrientation == 'P') | 
| 1731 | 1800 |      { | 
| 1732 | 1801 | $wPt = $this->DefPageSize[0] * $this->k; | 
| 1733 | 1802 | $hPt = $this->DefPageSize[1] * $this->k; | 
| 1734 | - } | |
| 1735 | - else | |
| 1803 | + } else | |
| 1736 | 1804 |      { | 
| 1737 | 1805 | $wPt = $this->DefPageSize[1] * $this->k; | 
| 1738 | 1806 | $hPt = $this->DefPageSize[0] * $this->k; | 
| @@ -1744,8 +1812,9 @@ discard block | ||
| 1744 | 1812 | $this->_newobj(); | 
| 1745 | 1813 |          $this->_out('<</Type /Page'); | 
| 1746 | 1814 |          $this->_out('/Parent 1 0 R'); | 
| 1747 | - if (isset($this->PageSizes[$n])) | |
| 1748 | -            $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1])); | |
| 1815 | +        if (isset($this->PageSizes[$n])) { | |
| 1816 | +                    $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1])); | |
| 1817 | + } | |
| 1749 | 1818 |          $this->_out('/Resources 2 0 R'); | 
| 1750 | 1819 | if (isset($this->PageLinks[$n])) | 
| 1751 | 1820 |          { | 
| @@ -1755,9 +1824,9 @@ discard block | ||
| 1755 | 1824 |              { | 
| 1756 | 1825 |                  $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]); | 
| 1757 | 1826 | $annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; | 
| 1758 | - if (is_string($pl[4])) | |
| 1759 | - $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; | |
| 1760 | - else | |
| 1827 | +                if (is_string($pl[4])) { | |
| 1828 | + $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; | |
| 1829 | + } else | |
| 1761 | 1830 |                  { | 
| 1762 | 1831 | $l = $this->links[$pl[4]]; | 
| 1763 | 1832 | $h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; | 
| @@ -1766,8 +1835,9 @@ discard block | ||
| 1766 | 1835 | } | 
| 1767 | 1836 | $this->_out($annots.']'); | 
| 1768 | 1837 | } | 
| 1769 | - if ($this->PDFVersion > '1.3') | |
| 1770 | -            $this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); | |
| 1838 | +        if ($this->PDFVersion > '1.3') { | |
| 1839 | +                    $this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); | |
| 1840 | + } | |
| 1771 | 1841 |          $this->_out('/Contents '.($this->n + 1).' 0 R>>'); | 
| 1772 | 1842 |          $this->_out('endobj'); | 
| 1773 | 1843 | // Page content | 
| @@ -1889,18 +1959,21 @@ discard block | ||
| 1889 | 1959 | $this->_newobj(); | 
| 1890 | 1960 | $cw = &$font['cw']; | 
| 1891 | 1961 | $s = '['; | 
| 1892 | - for ($i = 32; $i <= 255; $i++) | |
| 1893 | - $s .= $cw[chr($i)].' '; | |
| 1962 | +            for ($i = 32; $i <= 255; $i++) { | |
| 1963 | + $s .= $cw[chr($i)].' '; | |
| 1964 | + } | |
| 1894 | 1965 | $this->_out($s.']'); | 
| 1895 | 1966 |              $this->_out('endobj'); | 
| 1896 | 1967 | // Descriptor | 
| 1897 | 1968 | $this->_newobj(); | 
| 1898 | 1969 | $s = '<</Type /FontDescriptor /FontName /'.$name; | 
| 1899 | - foreach ($font['desc'] as $k=>$v) | |
| 1900 | - $s .= ' /'.$k.' '.$v; | |
| 1970 | +            foreach ($font['desc'] as $k=>$v) { | |
| 1971 | + $s .= ' /'.$k.' '.$v; | |
| 1972 | + } | |
| 1901 | 1973 | $file = $font['file']; | 
| 1902 | - if ($file) | |
| 1903 | - $s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; | |
| 1974 | +            if ($file) { | |
| 1975 | + $s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; | |
| 1976 | + } | |
| 1904 | 1977 | $this->_out($s.'>>'); | 
| 1905 | 1978 |              $this->_out('endobj'); | 
| 1906 | 1979 | } | 
| @@ -2019,14 +2092,14 @@ discard block | ||
| 2019 | 2092 | $this->_putstream($fontstream); | 
| 2020 | 2093 |              $this->_out('endobj'); | 
| 2021 | 2094 | unset($ttf); | 
| 2022 | - } | |
| 2023 | - else | |
| 2095 | + } else | |
| 2024 | 2096 |          { | 
| 2025 | 2097 | // Allow for additional types | 
| 2026 | 2098 | $this->fonts[$k]['n'] = $this->n + 1; | 
| 2027 | 2099 | $mtd = '_put'.strtolower($type); | 
| 2028 | - if (!method_exists($this, $mtd)) | |
| 2029 | -                $this->Error('Unsupported font type: '.$type); | |
| 2100 | +            if (!method_exists($this, $mtd)) { | |
| 2101 | +                            $this->Error('Unsupported font type: '.$type); | |
| 2102 | + } | |
| 2030 | 2103 | $this->$mtd($font); | 
| 2031 | 2104 | } | 
| 2032 | 2105 | } | 
| @@ -2058,8 +2131,7 @@ discard block | ||
| 2058 | 2131 | $cw127 .= '$rangeid='.$rangeid.";\n"; | 
| 2059 | 2132 | $cw127 .= '$prevcid='.$prevcid.";\n"; | 
| 2060 | 2133 | $cw127 .= '$prevwidth='.$prevwidth.";\n"; | 
| 2061 | -                if ($interval) { $cw127 .= '$interval=true'.";\n"; } | |
| 2062 | -                else { $cw127 .= '$interval=false'.";\n"; } | |
| 2134 | +                if ($interval) { $cw127 .= '$interval=true'.";\n"; } else { $cw127 .= '$interval=false'.";\n"; } | |
| 2063 | 2135 | $cw127 .= '$range='.var_export($range, true).";\n"; | 
| 2064 | 2136 | $cw127 .= "?>"; | 
| 2065 | 2137 | fwrite($fh, $cw127, strlen($cw127)); | 
| @@ -2113,21 +2185,17 @@ discard block | ||
| 2113 | 2185 |              if (isset($range[$k]['interval'])) { unset($range[$k]['interval']); } | 
| 2114 | 2186 | $range[$prevk] = array_merge($range[$prevk], $range[$k]); | 
| 2115 | 2187 | unset($range[$k]); | 
| 2116 | - } | |
| 2117 | -        else { $prevk = $k; } | |
| 2188 | +        } else { $prevk = $k; } | |
| 2118 | 2189 | $nextk = $k + $cws; | 
| 2119 | 2190 |          if (isset($ws['interval'])) { | 
| 2120 | -            if ($cws > 3) { $prevint = true; } | |
| 2121 | -            else { $prevint = false; } | |
| 2191 | +            if ($cws > 3) { $prevint = true; } else { $prevint = false; } | |
| 2122 | 2192 | unset($range[$k]['interval']); | 
| 2123 | 2193 | --$nextk; | 
| 2124 | - } | |
| 2125 | -        else { $prevint = false; } | |
| 2194 | +        } else { $prevint = false; } | |
| 2126 | 2195 | } | 
| 2127 | 2196 | $w = ''; | 
| 2128 | 2197 |      foreach ($range as $k => $ws) { | 
| 2129 | -        if (count(array_count_values($ws)) == 1) { $w .= ' '.$k.' '.($k + count($ws) - 1).' '.$ws[0]; } | |
| 2130 | -        else { $w .= ' '.$k.' [ '.implode(' ', $ws).' ]'."\n"; } | |
| 2198 | +        if (count(array_count_values($ws)) == 1) { $w .= ' '.$k.' '.($k + count($ws) - 1).' '.$ws[0]; } else { $w .= ' '.$k.' [ '.implode(' ', $ws).' ]'."\n"; } | |
| 2131 | 2199 | } | 
| 2132 | 2200 |      $this->_out('/W ['.$w.' ]'); | 
| 2133 | 2201 | } | 
| @@ -2150,28 +2218,33 @@ discard block | ||
| 2150 | 2218 |      $this->_out('/Subtype /Image'); | 
| 2151 | 2219 |      $this->_out('/Width '.$info['w']); | 
| 2152 | 2220 |      $this->_out('/Height '.$info['h']); | 
| 2153 | - if ($info['cs'] == 'Indexed') | |
| 2154 | -        $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]'); | |
| 2155 | - else | |
| 2221 | +    if ($info['cs'] == 'Indexed') { | |
| 2222 | +            $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]'); | |
| 2223 | + } else | |
| 2156 | 2224 |      { | 
| 2157 | 2225 |          $this->_out('/ColorSpace /'.$info['cs']); | 
| 2158 | - if ($info['cs'] == 'DeviceCMYK') | |
| 2159 | -            $this->_out('/Decode [1 0 1 0 1 0 1 0]'); | |
| 2226 | +        if ($info['cs'] == 'DeviceCMYK') { | |
| 2227 | +                    $this->_out('/Decode [1 0 1 0 1 0 1 0]'); | |
| 2228 | + } | |
| 2160 | 2229 | } | 
| 2161 | 2230 |      $this->_out('/BitsPerComponent '.$info['bpc']); | 
| 2162 | - if (isset($info['f'])) | |
| 2163 | -        $this->_out('/Filter /'.$info['f']); | |
| 2164 | - if (isset($info['dp'])) | |
| 2165 | -        $this->_out('/DecodeParms <<'.$info['dp'].'>>'); | |
| 2231 | +    if (isset($info['f'])) { | |
| 2232 | +            $this->_out('/Filter /'.$info['f']); | |
| 2233 | + } | |
| 2234 | +    if (isset($info['dp'])) { | |
| 2235 | +            $this->_out('/DecodeParms <<'.$info['dp'].'>>'); | |
| 2236 | + } | |
| 2166 | 2237 | if (isset($info['trns']) && is_array($info['trns'])) | 
| 2167 | 2238 |      { | 
| 2168 | 2239 | $trns = ''; | 
| 2169 | - for ($i = 0; $i < count($info['trns']); $i++) | |
| 2170 | - $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; | |
| 2240 | +        for ($i = 0; $i < count($info['trns']); $i++) { | |
| 2241 | + $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; | |
| 2242 | + } | |
| 2171 | 2243 |          $this->_out('/Mask ['.$trns.']'); | 
| 2172 | 2244 | } | 
| 2173 | - if (isset($info['smask'])) | |
| 2174 | -        $this->_out('/SMask '.($this->n + 1).' 0 R'); | |
| 2245 | +    if (isset($info['smask'])) { | |
| 2246 | +            $this->_out('/SMask '.($this->n + 1).' 0 R'); | |
| 2247 | + } | |
| 2175 | 2248 |      $this->_out('/Length '.strlen($info['data']).'>>'); | 
| 2176 | 2249 | $this->_putstream($info['data']); | 
| 2177 | 2250 |      $this->_out('endobj'); | 
| @@ -2196,9 +2269,10 @@ discard block | ||
| 2196 | 2269 | |
| 2197 | 2270 | function _putxobjectdict() | 
| 2198 | 2271 |  { | 
| 2199 | - foreach ($this->images as $image) | |
| 2200 | -        $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); | |
| 2201 | -} | |
| 2272 | +    foreach ($this->images as $image) { | |
| 2273 | +            $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); | |
| 2274 | + } | |
| 2275 | + } | |
| 2202 | 2276 | |
| 2203 | 2277 | function _putresourcedict() | 
| 2204 | 2278 |  { | 
| @@ -2229,16 +2303,21 @@ discard block | ||
| 2229 | 2303 | function _putinfo() | 
| 2230 | 2304 |  { | 
| 2231 | 2305 |      $this->_out('/Producer '.$this->_textstring('tFPDF '.tFPDF_VERSION)); | 
| 2232 | - if (!empty($this->title)) | |
| 2233 | -        $this->_out('/Title '.$this->_textstring($this->title)); | |
| 2234 | - if (!empty($this->subject)) | |
| 2235 | -        $this->_out('/Subject '.$this->_textstring($this->subject)); | |
| 2236 | - if (!empty($this->author)) | |
| 2237 | -        $this->_out('/Author '.$this->_textstring($this->author)); | |
| 2238 | - if (!empty($this->keywords)) | |
| 2239 | -        $this->_out('/Keywords '.$this->_textstring($this->keywords)); | |
| 2240 | - if (!empty($this->creator)) | |
| 2241 | -        $this->_out('/Creator '.$this->_textstring($this->creator)); | |
| 2306 | +    if (!empty($this->title)) { | |
| 2307 | +            $this->_out('/Title '.$this->_textstring($this->title)); | |
| 2308 | + } | |
| 2309 | +    if (!empty($this->subject)) { | |
| 2310 | +            $this->_out('/Subject '.$this->_textstring($this->subject)); | |
| 2311 | + } | |
| 2312 | +    if (!empty($this->author)) { | |
| 2313 | +            $this->_out('/Author '.$this->_textstring($this->author)); | |
| 2314 | + } | |
| 2315 | +    if (!empty($this->keywords)) { | |
| 2316 | +            $this->_out('/Keywords '.$this->_textstring($this->keywords)); | |
| 2317 | + } | |
| 2318 | +    if (!empty($this->creator)) { | |
| 2319 | +            $this->_out('/Creator '.$this->_textstring($this->creator)); | |
| 2320 | + } | |
| 2242 | 2321 |      $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); | 
| 2243 | 2322 | } | 
| 2244 | 2323 | |
| @@ -2246,21 +2325,23 @@ discard block | ||
| 2246 | 2325 |  { | 
| 2247 | 2326 |      $this->_out('/Type /Catalog'); | 
| 2248 | 2327 |      $this->_out('/Pages 1 0 R'); | 
| 2249 | - if ($this->ZoomMode == 'fullpage') | |
| 2250 | -        $this->_out('/OpenAction [3 0 R /Fit]'); | |
| 2251 | - elseif ($this->ZoomMode == 'fullwidth') | |
| 2252 | -        $this->_out('/OpenAction [3 0 R /FitH null]'); | |
| 2253 | - elseif ($this->ZoomMode == 'real') | |
| 2254 | -        $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); | |
| 2255 | - elseif (!is_string($this->ZoomMode)) | |
| 2256 | -        $this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F', $this->ZoomMode / 100).']'); | |
| 2257 | - if ($this->LayoutMode == 'single') | |
| 2258 | -        $this->_out('/PageLayout /SinglePage'); | |
| 2259 | - elseif ($this->LayoutMode == 'continuous') | |
| 2260 | -        $this->_out('/PageLayout /OneColumn'); | |
| 2261 | - elseif ($this->LayoutMode == 'two') | |
| 2262 | -        $this->_out('/PageLayout /TwoColumnLeft'); | |
| 2263 | -} | |
| 2328 | +    if ($this->ZoomMode == 'fullpage') { | |
| 2329 | +            $this->_out('/OpenAction [3 0 R /Fit]'); | |
| 2330 | +    } elseif ($this->ZoomMode == 'fullwidth') { | |
| 2331 | +            $this->_out('/OpenAction [3 0 R /FitH null]'); | |
| 2332 | +    } elseif ($this->ZoomMode == 'real') { | |
| 2333 | +            $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); | |
| 2334 | +    } elseif (!is_string($this->ZoomMode)) { | |
| 2335 | +            $this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F', $this->ZoomMode / 100).']'); | |
| 2336 | + } | |
| 2337 | +    if ($this->LayoutMode == 'single') { | |
| 2338 | +            $this->_out('/PageLayout /SinglePage'); | |
| 2339 | +    } elseif ($this->LayoutMode == 'continuous') { | |
| 2340 | +            $this->_out('/PageLayout /OneColumn'); | |
| 2341 | +    } elseif ($this->LayoutMode == 'two') { | |
| 2342 | +            $this->_out('/PageLayout /TwoColumnLeft'); | |
| 2343 | + } | |
| 2344 | + } | |
| 2264 | 2345 | |
| 2265 | 2346 | function _putheader() | 
| 2266 | 2347 |  { | 
| @@ -2296,8 +2377,9 @@ discard block | ||
| 2296 | 2377 |      $this->_out('xref'); | 
| 2297 | 2378 |      $this->_out('0 '.($this->n + 1)); | 
| 2298 | 2379 |      $this->_out('0000000000 65535 f '); | 
| 2299 | - for ($i = 1; $i <= $this->n; $i++) | |
| 2300 | -        $this->_out(sprintf('%010d 00000 n ', $this->offsets[$i])); | |
| 2380 | +    for ($i = 1; $i <= $this->n; $i++) { | |
| 2381 | +            $this->_out(sprintf('%010d 00000 n ', $this->offsets[$i])); | |
| 2382 | + } | |
| 2301 | 2383 | // Trailer | 
| 2302 | 2384 |      $this->_out('trailer'); | 
| 2303 | 2385 |      $this->_out('<<'); | 
| @@ -2327,18 +2409,19 @@ discard block | ||
| 2327 | 2409 |      for ($i = 0; $i < $len; $i++) { | 
| 2328 | 2410 | $uni = -1; | 
| 2329 | 2411 | $h = ord($str[$i]); | 
| 2330 | - if ( $h <= 0x7F ) | |
| 2331 | - $uni = $h; | |
| 2332 | -        elseif ( $h >= 0xC2 ) { | |
| 2333 | - if ( ($h <= 0xDF) && ($i < $len -1) ) | |
| 2334 | - $uni = ($h & 0x1F) << 6 | (ord($str[++$i]) & 0x3F); | |
| 2335 | - elseif ( ($h <= 0xEF) && ($i < $len -2) ) | |
| 2336 | - $uni = ($h & 0x0F) << 12 | (ord($str[++$i]) & 0x3F) << 6 | |
| 2412 | +        if ( $h <= 0x7F ) { | |
| 2413 | + $uni = $h; | |
| 2414 | +        } elseif ( $h >= 0xC2 ) { | |
| 2415 | +            if ( ($h <= 0xDF) && ($i < $len -1) ) { | |
| 2416 | + $uni = ($h & 0x1F) << 6 | (ord($str[++$i]) & 0x3F); | |
| 2417 | +            } elseif ( ($h <= 0xEF) && ($i < $len -2) ) { | |
| 2418 | + $uni = ($h & 0x0F) << 12 | (ord($str[++$i]) & 0x3F) << 6 | |
| 2337 | 2419 | | (ord($str[++$i]) & 0x3F); | 
| 2338 | - elseif ( ($h <= 0xF4) && ($i < $len -3) ) | |
| 2339 | - $uni = ($h & 0x0F) << 18 | (ord($str[++$i]) & 0x3F) << 12 | |
| 2420 | +            } elseif ( ($h <= 0xF4) && ($i < $len -3) ) { | |
| 2421 | + $uni = ($h & 0x0F) << 18 | (ord($str[++$i]) & 0x3F) << 12 | |
| 2340 | 2422 | | (ord($str[++$i]) & 0x3F) << 6 | 
| 2341 | 2423 | | (ord($str[++$i]) & 0x3F); | 
| 2424 | + } | |
| 2342 | 2425 | } | 
| 2343 | 2426 |      if ($uni >= 0) { | 
| 2344 | 2427 | $out[] = $uni; | 
| @@ -340,7 +340,7 @@ | ||
| 340 | 340 | * to the self::$_e[] table. | 
| 341 | 341 | * This is only used in the F() function | 
| 342 | 342 | * | 
| 343 | - * @param array $r 32 bit binary, each bit in an array element | |
| 343 | + * @param string $r 32 bit binary, each bit in an array element | |
| 344 | 344 | * @return string 48 bit binary string | 
| 345 | 345 | */ | 
| 346 | 346 | private function e($r) | 
| @@ -201,10 +201,11 @@ discard block | ||
| 201 | 201 |  		{ | 
| 202 | 202 | $l[$n] = $r[$n - 1]; | 
| 203 | 203 | |
| 204 | - if ($this->operation() == parent::DECRYPT) | |
| 205 | - $f = $this->F($r[$n - 1], $this->sub_keys[16 - $n]); | |
| 206 | - else | |
| 207 | - $f = $this->F($r[$n - 1], $this->sub_keys[$n - 1]); | |
| 204 | +			if ($this->operation() == parent::DECRYPT) { | |
| 205 | + $f = $this->F($r[$n - 1], $this->sub_keys[16 - $n]); | |
| 206 | +			} else { | |
| 207 | + $f = $this->F($r[$n - 1], $this->sub_keys[$n - 1]); | |
| 208 | + } | |
| 208 | 209 | |
| 209 | 210 | // XOR F with Ln | 
| 210 | 211 | $r[$n] = $this->xorBin($l[$n - 1], $f); | 
| @@ -240,8 +241,9 @@ discard block | ||
| 240 | 241 | $binkey = parent::str2Bin($this->key()); | 
| 241 | 242 | |
| 242 | 243 | // reduce the key down to 56bits based on table $_pc1 | 
| 243 | - for ($i = 0; $i < 56; ++$i) | |
| 244 | - $pc1m[$i] = $binkey[self::$_pc1[$i] - 1]; | |
| 244 | +		for ($i = 0; $i < 56; ++$i) { | |
| 245 | + $pc1m[$i] = $binkey[self::$_pc1[$i] - 1]; | |
| 246 | + } | |
| 245 | 247 | |
| 246 | 248 | // split $pc1m in half (C0 and D0) | 
| 247 | 249 | $c[0] = array_slice($pc1m, 0, 28); | 
| @@ -270,8 +272,9 @@ discard block | ||
| 270 | 272 | // of these. | 
| 271 | 273 | $CnDn = array_merge($c[$i], $d[$i]); | 
| 272 | 274 | $this->sub_keys[$i - 1] = ""; | 
| 273 | - for ($j = 0; $j < 48; ++$j) | |
| 274 | - $this->sub_keys[$i - 1] .= $CnDn[self::$_pc2[$j] - 1]; | |
| 275 | +			for ($j = 0; $j < 48; ++$j) { | |
| 276 | + $this->sub_keys[$i - 1] .= $CnDn[self::$_pc2[$j] - 1]; | |
| 277 | + } | |
| 275 | 278 | } | 
| 276 | 279 | |
| 277 | 280 | // the sub_keys are created, we are done with the key permutation | 
| @@ -303,8 +306,9 @@ discard block | ||
| 303 | 306 | $ip = ""; | 
| 304 | 307 | |
| 305 | 308 | // loop through the 64 bit block, ordering it occording to $_ip | 
| 306 | - for ($i = 0; $i < 64; ++$i) | |
| 307 | - $ip .= $text[self::$_ip[$i] - 1]; | |
| 309 | +		for ($i = 0; $i < 64; ++$i) { | |
| 310 | + $ip .= $text[self::$_ip[$i] - 1]; | |
| 311 | + } | |
| 308 | 312 | |
| 309 | 313 | return $ip; | 
| 310 | 314 | } | 
| @@ -346,8 +350,9 @@ discard block | ||
| 346 | 350 | private function e($r) | 
| 347 | 351 |  	{ | 
| 348 | 352 | $e = ""; | 
| 349 | - for ($i = 0; $i < 48; ++$i) | |
| 350 | - $e .= $r[self::$_e[$i] - 1]; | |
| 353 | +		for ($i = 0; $i < 48; ++$i) { | |
| 354 | + $e .= $r[self::$_e[$i] - 1]; | |
| 355 | + } | |
| 351 | 356 | |
| 352 | 357 | return $e; | 
| 353 | 358 | } | 
| @@ -402,8 +407,9 @@ discard block | ||
| 402 | 407 | private function p($s) | 
| 403 | 408 |  	{ | 
| 404 | 409 | $p = ""; | 
| 405 | - for ($i = 0; $i < 32; ++$i) | |
| 406 | - $p .= $s[self::$_p[$i] - 1]; | |
| 410 | +		for ($i = 0; $i < 32; ++$i) { | |
| 411 | + $p .= $s[self::$_p[$i] - 1]; | |
| 412 | + } | |
| 407 | 413 | |
| 408 | 414 | return $p; | 
| 409 | 415 | } | 
| @@ -420,8 +426,9 @@ discard block | ||
| 420 | 426 | private function fp($bin) | 
| 421 | 427 |  	{ | 
| 422 | 428 | $fp = ""; | 
| 423 | - for ($i = 0; $i < 64; ++$i) | |
| 424 | - $fp .= $bin[self::$_fp[$i] - 1]; | |
| 429 | +		for ($i = 0; $i < 64; ++$i) { | |
| 430 | + $fp .= $bin[self::$_fp[$i] - 1]; | |
| 431 | + } | |
| 425 | 432 | |
| 426 | 433 | return $fp; | 
| 427 | 434 | } | 
| @@ -232,10 +232,10 @@ discard block | ||
| 232 | 232 | * | 
| 233 | 233 | * Unicode multi-byte character safe | 
| 234 | 234 | * | 
| 235 | - * @param plaintext source text to be encrypted | |
| 235 | + * @param plaintext string text to be encrypted | |
| 236 | 236 | * @param password the password to use to generate a key | 
| 237 | - * @param nBits number of bits to be used in the key (128, 192, or 256) | |
| 238 | - * @return encrypted text | |
| 237 | + * @param nBits integer of bits to be used in the key (128, 192, or 256) | |
| 238 | + * @return string text | |
| 239 | 239 | */ | 
| 240 | 240 | public static function encrypt($plaintext, $password, $nBits) | 
| 241 | 241 |      { | 
| @@ -315,8 +315,8 @@ discard block | ||
| 315 | 315 | * | 
| 316 | 316 | * @param ciphertext source text to be decrypted | 
| 317 | 317 | * @param password the password to use to generate a key | 
| 318 | - * @param nBits number of bits to be used in the key (128, 192, or 256) | |
| 319 | - * @return decrypted text | |
| 318 | + * @param nBits integer of bits to be used in the key (128, 192, or 256) | |
| 319 | + * @return string text | |
| 320 | 320 | */ | 
| 321 | 321 | public static function decrypt($ciphertext, $password, $nBits) | 
| 322 | 322 |      { | 
| @@ -352,8 +352,7 @@ discard block | ||
| 352 | 352 | |
| 353 | 353 | $x++; | 
| 354 | 354 | } | 
| 355 | - } | |
| 356 | -            else if ($GLOBALS['request'][1] == "userpw") { | |
| 355 | +            } else if ($GLOBALS['request'][1] == "userpw") { | |
| 357 | 356 | /* | 
| 358 | 357 | * READ USER ITEMS | 
| 359 | 358 | */ | 
| @@ -437,8 +436,7 @@ discard block | ||
| 437 | 436 | |
| 438 | 437 | $x++; | 
| 439 | 438 | } | 
| 440 | - } | |
| 441 | -            else if ($GLOBALS['request'][1] == "userfolders") { | |
| 439 | +            } else if ($GLOBALS['request'][1] == "userfolders") { | |
| 442 | 440 | /* | 
| 443 | 441 | * READ USER FOLDERS | 
| 444 | 442 | * Sends back a list of folders | 
| @@ -481,8 +479,7 @@ discard block | ||
| 481 | 479 | } | 
| 482 | 480 | } | 
| 483 | 481 | } | 
| 484 | - } | |
| 485 | -            elseif ($GLOBALS['request'][1] == "items") { | |
| 482 | +            } elseif ($GLOBALS['request'][1] == "items") { | |
| 486 | 483 | /* | 
| 487 | 484 | * READ ITEMS asked | 
| 488 | 485 | */ | 
| @@ -829,8 +826,11 @@ discard block | ||
| 829 | 826 |                                  "SELECT `id` FROM ".prefix_table("roles_title")." WHERE title = %s", | 
| 830 | 827 | $role | 
| 831 | 828 | ); | 
| 832 | - if (empty($rolesList)) $rolesList = $tmp['id']; | |
| 833 | - else $rolesList .= ";".$tmp['id']; | |
| 829 | +                            if (empty($rolesList)) { | |
| 830 | + $rolesList = $tmp['id']; | |
| 831 | +                            } else { | |
| 832 | + $rolesList .= ";".$tmp['id']; | |
| 833 | + } | |
| 834 | 834 | } | 
| 835 | 835 | |
| 836 | 836 | // Add user in DB | 
| @@ -1925,11 +1925,21 @@ discard block | ||
| 1925 | 1925 | |
| 1926 | 1926 | // init | 
| 1927 | 1927 | $pwgen->setLength($params[0]); | 
| 1928 | - if ($params[1] === "1") $pwgen->setSecure(true); | |
| 1929 | - if ($params[2] === "1") $pwgen->setNumerals(true); | |
| 1930 | - if ($params[3] === "1") $pwgen->setCapitalize(true); | |
| 1931 | - if ($params[4] === "1") $pwgen->setAmbiguous(true); | |
| 1932 | - if ($params[5] === "1" && $params[6] === "1") $pwgen->setSymbols(true); | |
| 1928 | +                if ($params[1] === "1") { | |
| 1929 | + $pwgen->setSecure(true); | |
| 1930 | + } | |
| 1931 | +                if ($params[2] === "1") { | |
| 1932 | + $pwgen->setNumerals(true); | |
| 1933 | + } | |
| 1934 | +                if ($params[3] === "1") { | |
| 1935 | + $pwgen->setCapitalize(true); | |
| 1936 | + } | |
| 1937 | +                if ($params[4] === "1") { | |
| 1938 | + $pwgen->setAmbiguous(true); | |
| 1939 | + } | |
| 1940 | +                if ($params[5] === "1" && $params[6] === "1") { | |
| 1941 | + $pwgen->setSymbols(true); | |
| 1942 | + } | |
| 1933 | 1943 | |
| 1934 | 1944 | // generate and send back (generate in base64 if symbols are asked) | 
| 1935 | 1945 |                  if ($params[6] === "1") { |