@@ -1,39 +1,39 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$data = file_get_contents( __DIR__ . '/../providers.json' ); |
|
4 | -$data = json_decode( $data ); |
|
3 | +$data = file_get_contents(__DIR__ . '/../providers.json'); |
|
4 | +$data = json_decode($data); |
|
5 | 5 | |
6 | 6 | $providers = array(); |
7 | -foreach ( $data as $provider ) { |
|
8 | - $providers[ $provider->slug ] = $provider; |
|
7 | +foreach ($data as $provider) { |
|
8 | + $providers[$provider->slug] = $provider; |
|
9 | 9 | } |
10 | 10 | |
11 | -$data = file_get_contents( __DIR__ . '/../gateways.json' ); |
|
12 | -$gateways = json_decode( $data ); |
|
11 | +$data = file_get_contents(__DIR__ . '/../gateways.json'); |
|
12 | +$gateways = json_decode($data); |
|
13 | 13 | |
14 | -foreach ( $gateways as $gateway ) { |
|
15 | - if ( isset( $providers[ $gateway->provider ] ) ) { |
|
16 | - $provider = $providers[ $gateway->provider ]; |
|
14 | +foreach ($gateways as $gateway) { |
|
15 | + if (isset($providers[$gateway->provider])) { |
|
16 | + $provider = $providers[$gateway->provider]; |
|
17 | 17 | |
18 | - if ( ! isset( $provider->gateways ) ) { |
|
18 | + if ( ! isset($provider->gateways)) { |
|
19 | 19 | $provider->gateways = array(); |
20 | 20 | } |
21 | 21 | |
22 | - $provider->gateways[ $gateway->slug ] = $gateway; |
|
22 | + $provider->gateways[$gateway->slug] = $gateway; |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | 26 | ?> |
27 | 27 | | Provider | Name | |
28 | 28 | | -------- | ---- | |
29 | -<?php foreach ( $gateways as $gateway ) : ?> |
|
29 | +<?php foreach ($gateways as $gateway) : ?> |
|
30 | 30 | | <?php |
31 | 31 | |
32 | -if ( isset( $gateway->provider, $providers[ $gateway->provider ] ) ) { |
|
33 | - $provider = $providers[ $gateway->provider ]; |
|
32 | +if (isset($gateway->provider, $providers[$gateway->provider])) { |
|
33 | + $provider = $providers[$gateway->provider]; |
|
34 | 34 | |
35 | - if ( isset( $provider->url ) ) { |
|
36 | - printf( '[%s](%s)', $provider->name, $provider->url ); |
|
35 | + if (isset($provider->url)) { |
|
36 | + printf('[%s](%s)', $provider->name, $provider->url); |
|
37 | 37 | } else { |
38 | 38 | echo $provider->name; |
39 | 39 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | return; |
74 | 74 | } |
75 | - if ($element->nodeType == XML_COMMENT_NODE && !$withcomments) { |
|
75 | + if ($element->nodeType == XML_COMMENT_NODE && ! $withcomments) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | $tree->appendChild($dom->importNode($element, TRUE)); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $withcomments - boolean indicating wether or not to include comments in canonicalized form |
151 | 151 | */ |
152 | 152 | |
153 | -function C14NGeneral($element, $exclusive=FALSE, $withcomments=FALSE) { |
|
153 | +function C14NGeneral($element, $exclusive = FALSE, $withcomments = FALSE) { |
|
154 | 154 | /* IF PHP 5.2+ then use built in canonical functionality */ |
155 | 155 | $php_version = explode('.', PHP_VERSION); |
156 | 156 | if (($php_version[0] > 5) || ($php_version[0] == 5 && $php_version[1] >= 2)) { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | /* Must be element or document */ |
161 | - if (!$element instanceof DOMElement && !$element instanceof DOMDocument) { |
|
161 | + if ( ! $element instanceof DOMElement && ! $element instanceof DOMDocument) { |
|
162 | 162 | return NULL; |
163 | 163 | } |
164 | 164 | /* Currently only exclusive XML is supported */ |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | /* This variable contains the certificate thunbprint if we have loaded an X509-certificate. */ |
203 | 203 | private $X509Thumbprint = NULL; |
204 | 204 | |
205 | - public function __construct($type, $params=NULL) { |
|
205 | + public function __construct($type, $params = NULL) { |
|
206 | 206 | srand(); |
207 | 207 | switch ($type) { |
208 | 208 | case (XMLSecurityKey::TRIPLEDES_CBC): |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $this->cryptParams['library'] = 'openssl'; |
238 | 238 | $this->cryptParams['padding'] = OPENSSL_PKCS1_PADDING; |
239 | 239 | $this->cryptParams['method'] = 'http://www.w3.org/2001/04/xmlenc#rsa-1_5'; |
240 | - if (is_array($params) && !empty($params['type'])) { |
|
240 | + if (is_array($params) && ! empty($params['type'])) { |
|
241 | 241 | if ($params['type'] == 'public' || $params['type'] == 'private') { |
242 | 242 | $this->cryptParams['type'] = $params['type']; |
243 | 243 | break; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $this->cryptParams['padding'] = OPENSSL_PKCS1_OAEP_PADDING; |
251 | 251 | $this->cryptParams['method'] = 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p'; |
252 | 252 | $this->cryptParams['hash'] = NULL; |
253 | - if (is_array($params) && !empty($params['type'])) { |
|
253 | + if (is_array($params) && ! empty($params['type'])) { |
|
254 | 254 | if ($params['type'] == 'public' || $params['type'] == 'private') { |
255 | 255 | $this->cryptParams['type'] = $params['type']; |
256 | 256 | break; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $this->cryptParams['library'] = 'openssl'; |
263 | 263 | $this->cryptParams['method'] = 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'; |
264 | 264 | $this->cryptParams['padding'] = OPENSSL_PKCS1_PADDING; |
265 | - if (is_array($params) && !empty($params['type'])) { |
|
265 | + if (is_array($params) && ! empty($params['type'])) { |
|
266 | 266 | if ($params['type'] == 'public' || $params['type'] == 'private') { |
267 | 267 | $this->cryptParams['type'] = $params['type']; |
268 | 268 | break; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $this->cryptParams['method'] = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'; |
276 | 276 | $this->cryptParams['padding'] = OPENSSL_PKCS1_PADDING; |
277 | 277 | $this->cryptParams['digest'] = 'SHA256'; |
278 | - if (is_array($params) && !empty($params['type'])) { |
|
278 | + if (is_array($params) && ! empty($params['type'])) { |
|
279 | 279 | if ($params['type'] == 'public' || $params['type'] == 'private') { |
280 | 280 | $this->cryptParams['type'] = $params['type']; |
281 | 281 | break; |
@@ -299,14 +299,14 @@ discard block |
||
299 | 299 | * @return int|NULL The number of bytes in the key. |
300 | 300 | */ |
301 | 301 | public function getSymmetricKeySize() { |
302 | - if (!isset($this->cryptParams['keysize'])) { |
|
302 | + if ( ! isset($this->cryptParams['keysize'])) { |
|
303 | 303 | return NULL; |
304 | 304 | } |
305 | 305 | return $this->cryptParams['keysize']; |
306 | 306 | } |
307 | 307 | |
308 | 308 | public function generateSessionKey() { |
309 | - if (!isset($this->cryptParams['keysize'])) { |
|
309 | + if ( ! isset($this->cryptParams['keysize'])) { |
|
310 | 310 | throw new Exception('Unknown key size for type "' . $this->type . '".'); |
311 | 311 | } |
312 | 312 | $keysize = $this->cryptParams['keysize']; |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $inData = FALSE; |
346 | 346 | |
347 | 347 | foreach ($arCert AS $curData) { |
348 | - if (!$inData) { |
|
348 | + if ( ! $inData) { |
|
349 | 349 | if (strncmp($curData, '-----BEGIN CERTIFICATE', 22) == 0) { |
350 | 350 | $inData = TRUE; |
351 | 351 | } |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | - if (!empty($data)) { |
|
361 | + if ( ! empty($data)) { |
|
362 | 362 | return strtolower(sha1(base64_decode($data))); |
363 | 363 | } |
364 | 364 | |
365 | 365 | return NULL; |
366 | 366 | } |
367 | 367 | |
368 | - public function loadKey($key, $isFile=FALSE, $isCert = FALSE) { |
|
368 | + public function loadKey($key, $isFile = FALSE, $isCert = FALSE) { |
|
369 | 369 | if ($isFile) { |
370 | 370 | $this->key = file_get_contents($key); |
371 | 371 | } else { |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | if ($this->cryptParams['mode'] == MCRYPT_MODE_CBC) { |
414 | 414 | $bs = mcrypt_enc_get_block_size($td); |
415 | 415 | for ($datalen0 = $datalen = strlen($data); (($datalen % $bs) != ($bs - 1)); $datalen++) |
416 | - $data.=chr(rand(1, 127)); |
|
417 | - $data.=chr($datalen - $datalen0 + 1); |
|
416 | + $data .= chr(rand(1, 127)); |
|
417 | + $data .= chr($datalen - $datalen0 + 1); |
|
418 | 418 | } |
419 | 419 | $encrypted_data = $this->iv . mcrypt_generic($td, $data); |
420 | 420 | mcrypt_generic_deinit($td); |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | |
444 | 444 | private function encryptOpenSSL($data) { |
445 | 445 | if ($this->cryptParams['type'] == 'public') { |
446 | - if (!openssl_public_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) { |
|
446 | + if ( ! openssl_public_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) { |
|
447 | 447 | throw new Exception('Failure encrypting Data'); |
448 | 448 | return; |
449 | 449 | } |
450 | 450 | } else { |
451 | - if (!openssl_private_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) { |
|
451 | + if ( ! openssl_private_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) { |
|
452 | 452 | throw new Exception('Failure encrypting Data'); |
453 | 453 | return; |
454 | 454 | } |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | |
459 | 459 | private function decryptOpenSSL($data) { |
460 | 460 | if ($this->cryptParams['type'] == 'public') { |
461 | - if (!openssl_public_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) { |
|
461 | + if ( ! openssl_public_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) { |
|
462 | 462 | throw new Exception('Failure decrypting Data'); |
463 | 463 | return; |
464 | 464 | } |
465 | 465 | } else { |
466 | - if (!openssl_private_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) { |
|
466 | + if ( ! openssl_private_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) { |
|
467 | 467 | throw new Exception('Failure decrypting Data'); |
468 | 468 | return; |
469 | 469 | } |
@@ -473,10 +473,10 @@ discard block |
||
473 | 473 | |
474 | 474 | private function signOpenSSL($data) { |
475 | 475 | $algo = OPENSSL_ALGO_SHA1; |
476 | - if (!empty($this->cryptParams['digest'])) { |
|
476 | + if ( ! empty($this->cryptParams['digest'])) { |
|
477 | 477 | $algo = $this->cryptParams['digest']; |
478 | 478 | } |
479 | - if (!openssl_sign($data, $signature, $this->key, $algo)) { |
|
479 | + if ( ! openssl_sign($data, $signature, $this->key, $algo)) { |
|
480 | 480 | throw new Exception('Failure Signing Data: ' . openssl_error_string() . ' - ' . $algo); |
481 | 481 | return; |
482 | 482 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | |
486 | 486 | private function verifyOpenSSL($data, $signature) { |
487 | 487 | $algo = OPENSSL_ALGO_SHA1; |
488 | - if (!empty($this->cryptParams['digest'])) { |
|
488 | + if ( ! empty($this->cryptParams['digest'])) { |
|
489 | 489 | $algo = $this->cryptParams['digest']; |
490 | 490 | } |
491 | 491 | return openssl_verify($data, $signature, $this->key, $algo); |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | |
618 | 618 | $objenc = new XMLSecEnc(); |
619 | 619 | $objenc->setNode($element); |
620 | - if (!$objKey = $objenc->locateKey()) { |
|
620 | + if ( ! $objKey = $objenc->locateKey()) { |
|
621 | 621 | throw new Exception("Unable to locate algorithm for this Encrypted Key"); |
622 | 622 | } |
623 | 623 | $objKey->isEncrypted = TRUE; |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | } |
670 | 670 | |
671 | 671 | private function getXPathObj() { |
672 | - if (empty($this->xPathCtx) && !empty($this->sigNode)) { |
|
672 | + if (empty($this->xPathCtx) && ! empty($this->sigNode)) { |
|
673 | 673 | $xpath = new DOMXPath($this->sigNode->ownerDocument); |
674 | 674 | $xpath->registerNamespace('secdsig', XMLSecurityDSig::XMLDSIGNS); |
675 | 675 | $this->xPathCtx = $xpath; |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | return $this->xPathCtx; |
678 | 678 | } |
679 | 679 | |
680 | - static function generate_GUID($prefix='pfx') { |
|
680 | + static function generate_GUID($prefix = 'pfx') { |
|
681 | 681 | $uuid = md5(uniqid(rand(), true)); |
682 | 682 | $guid = $prefix . substr($uuid, 0, 8) . "-" . |
683 | 683 | substr($uuid, 8, 4) . "-" . |
@@ -704,12 +704,12 @@ discard block |
||
704 | 704 | return NULL; |
705 | 705 | } |
706 | 706 | |
707 | - public function createNewSignNode($name, $value=NULL) { |
|
707 | + public function createNewSignNode($name, $value = NULL) { |
|
708 | 708 | $doc = $this->sigNode->ownerDocument; |
709 | 709 | if ($this->prefix != null) { |
710 | 710 | $name = $this->prefix . ':' . $name; |
711 | 711 | } |
712 | - if (!is_null($value)) { |
|
712 | + if ( ! is_null($value)) { |
|
713 | 713 | $node = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, $name, $value); |
714 | 714 | } else { |
715 | 715 | $node = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, $name); |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | if ($sinfo = $nodeset->item(0)) { |
735 | 735 | $query = './' . $this->searchpfx . 'CanonicalizationMethod'; |
736 | 736 | $nodeset = $xpath->query($query, $sinfo); |
737 | - if (!($canonNode = $nodeset->item(0))) { |
|
737 | + if ( ! ($canonNode = $nodeset->item(0))) { |
|
738 | 738 | $canonNode = $this->createNewSignNode('CanonicalizationMethod'); |
739 | 739 | $sinfo->insertBefore($canonNode, $sinfo->firstChild); |
740 | 740 | } |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | } |
744 | 744 | } |
745 | 745 | |
746 | - private function canonicalizeData($node, $canonicalmethod, $arXPath=NULL, $prefixList=NULL) { |
|
746 | + private function canonicalizeData($node, $canonicalmethod, $arXPath = NULL, $prefixList = NULL) { |
|
747 | 747 | $exclusive = FALSE; |
748 | 748 | $withComments = FALSE; |
749 | 749 | switch ($canonicalmethod) { |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | /* Support PHP versions < 5.2 not containing C14N methods in DOM extension */ |
766 | 766 | $php_version = explode('.', PHP_VERSION); |
767 | 767 | if (($php_version[0] < 5) || ($php_version[0] == 5 && $php_version[1] < 2)) { |
768 | - if (!is_null($arXPath)) { |
|
768 | + if ( ! is_null($arXPath)) { |
|
769 | 769 | throw new Exception("PHP 5.2.0 or higher is required to perform XPath Transformations"); |
770 | 770 | } |
771 | 771 | return C14NGeneral($node, $exclusive, $withComments); |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | case 'http://www.w3.org/2001/10/xml-exc-c14n#': |
850 | 850 | case 'http://www.w3.org/2001/10/xml-exc-c14n#WithComments': |
851 | 851 | |
852 | - if (!$includeCommentNodes) { |
|
852 | + if ( ! $includeCommentNodes) { |
|
853 | 853 | /* We remove comment nodes by forcing it to use a canonicalization |
854 | 854 | * without comments. |
855 | 855 | */ |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $pfxlist = explode(" ", $pfx); |
867 | 867 | foreach ($pfxlist AS $pfx) { |
868 | 868 | $val = trim($pfx); |
869 | - if (!empty($val)) { |
|
869 | + if ( ! empty($val)) { |
|
870 | 870 | $arpfx[] = $val; |
871 | 871 | } |
872 | 872 | } |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | break; |
882 | 882 | case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315': |
883 | 883 | case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments': |
884 | - if (!$includeCommentNodes) { |
|
884 | + if ( ! $includeCommentNodes) { |
|
885 | 885 | /* We remove comment nodes by forcing it to use a canonicalization |
886 | 886 | * without comments. |
887 | 887 | */ |
@@ -965,13 +965,13 @@ discard block |
||
965 | 965 | $dataObject = $refNode->ownerDocument; |
966 | 966 | } |
967 | 967 | $data = $this->processTransforms($refNode, $dataObject, $includeCommentNodes); |
968 | - if (!$this->validateDigest($refNode, $data)) { |
|
968 | + if ( ! $this->validateDigest($refNode, $data)) { |
|
969 | 969 | return FALSE; |
970 | 970 | } |
971 | 971 | |
972 | 972 | if ($dataObject instanceof DOMNode) { |
973 | 973 | /* Add this node to the list of validated nodes. */ |
974 | - if (!empty($identifier)) { |
|
974 | + if ( ! empty($identifier)) { |
|
975 | 975 | $this->validatedNodes[$identifier] = $dataObject; |
976 | 976 | } else { |
977 | 977 | $this->validatedNodes[] = $dataObject; |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | |
1012 | 1012 | public function validateReference() { |
1013 | 1013 | $doc = $this->sigNode->ownerDocument; |
1014 | - if (!$doc->isSameNode($this->sigNode)) { |
|
1014 | + if ( ! $doc->isSameNode($this->sigNode)) { |
|
1015 | 1015 | $this->sigNode->parentNode->removeChild($this->sigNode); |
1016 | 1016 | } |
1017 | 1017 | $xpath = $this->getXPathObj(); |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | $this->validatedNodes = array(); |
1026 | 1026 | |
1027 | 1027 | foreach ($nodeset AS $refNode) { |
1028 | - if (!$this->processRefNode($refNode)) { |
|
1028 | + if ( ! $this->processRefNode($refNode)) { |
|
1029 | 1029 | /* Clear the list of validated nodes. */ |
1030 | 1030 | $this->validatedNodes = NULL; |
1031 | 1031 | throw new Exception("Reference validation failed"); |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | return TRUE; |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - private function addRefInternal($sinfoNode, $node, $algorithm, $arTransforms=NULL, $options=NULL) { |
|
1037 | + private function addRefInternal($sinfoNode, $node, $algorithm, $arTransforms = NULL, $options = NULL) { |
|
1038 | 1038 | $prefix = NULL; |
1039 | 1039 | $prefix_ns = NULL; |
1040 | 1040 | $id_name = 'Id'; |
@@ -1045,21 +1045,21 @@ discard block |
||
1045 | 1045 | $prefix = empty($options['prefix']) ? NULL : $options['prefix']; |
1046 | 1046 | $prefix_ns = empty($options['prefix_ns']) ? NULL : $options['prefix_ns']; |
1047 | 1047 | $id_name = empty($options['id_name']) ? 'Id' : $options['id_name']; |
1048 | - $overwrite_id = !isset($options['overwrite']) ? TRUE : (bool) $options['overwrite']; |
|
1049 | - $force_uri = !isset($options['force_uri']) ? FALSE : (bool) $options['force_uri']; |
|
1048 | + $overwrite_id = ! isset($options['overwrite']) ? TRUE : (bool) $options['overwrite']; |
|
1049 | + $force_uri = ! isset($options['force_uri']) ? FALSE : (bool) $options['force_uri']; |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | $attname = $id_name; |
1053 | - if (!empty($prefix)) { |
|
1053 | + if ( ! empty($prefix)) { |
|
1054 | 1054 | $attname = $prefix . ':' . $attname; |
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | $refNode = $this->createNewSignNode('Reference'); |
1058 | 1058 | $sinfoNode->appendChild($refNode); |
1059 | 1059 | |
1060 | - if (!$node instanceof DOMDocument) { |
|
1060 | + if ( ! $node instanceof DOMDocument) { |
|
1061 | 1061 | $uri = NULL; |
1062 | - if (!$overwrite_id) { |
|
1062 | + if ( ! $overwrite_id) { |
|
1063 | 1063 | $uri = $node->getAttributeNS($prefix_ns, $attname); |
1064 | 1064 | } |
1065 | 1065 | if (empty($uri)) { |
@@ -1079,12 +1079,12 @@ discard block |
||
1079 | 1079 | $transNode = $this->createNewSignNode('Transform'); |
1080 | 1080 | $transNodes->appendChild($transNode); |
1081 | 1081 | if (is_array($transform) && |
1082 | - (!empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116'])) && |
|
1083 | - (!empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['query']))) { |
|
1082 | + ( ! empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116'])) && |
|
1083 | + ( ! empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['query']))) { |
|
1084 | 1084 | $transNode->setAttribute('Algorithm', 'http://www.w3.org/TR/1999/REC-xpath-19991116'); |
1085 | 1085 | $XPathNode = $this->createNewSignNode('XPath', $transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['query']); |
1086 | 1086 | $transNode->appendChild($XPathNode); |
1087 | - if (!empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['namespaces'])) { |
|
1087 | + if ( ! empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['namespaces'])) { |
|
1088 | 1088 | foreach ($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['namespaces'] AS $prefix => $namespace) { |
1089 | 1089 | $XPathNode->setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:$prefix", $namespace); |
1090 | 1090 | } |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | $transNode->setAttribute('Algorithm', $transform); |
1094 | 1094 | } |
1095 | 1095 | } |
1096 | - } elseif (!empty($this->canonicalMethod)) { |
|
1096 | + } elseif ( ! empty($this->canonicalMethod)) { |
|
1097 | 1097 | $transNode = $this->createNewSignNode('Transform'); |
1098 | 1098 | $transNodes->appendChild($transNode); |
1099 | 1099 | $transNode->setAttribute('Algorithm', $this->canonicalMethod); |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | $refNode->appendChild($digestValue); |
1111 | 1111 | } |
1112 | 1112 | |
1113 | - public function addReference($node, $algorithm, $arTransforms=NULL, $options=NULL) { |
|
1113 | + public function addReference($node, $algorithm, $arTransforms = NULL, $options = NULL) { |
|
1114 | 1114 | if ($xpath = $this->getXPathObj()) { |
1115 | 1115 | $query = "./secdsig:SignedInfo"; |
1116 | 1116 | $nodeset = $xpath->query($query, $this->sigNode); |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | } |
1121 | 1121 | } |
1122 | 1122 | |
1123 | - public function addReferenceList($arNodes, $algorithm, $arTransforms=NULL, $options=NULL) { |
|
1123 | + public function addReferenceList($arNodes, $algorithm, $arTransforms = NULL, $options = NULL) { |
|
1124 | 1124 | if ($xpath = $this->getXPathObj()) { |
1125 | 1125 | $query = "./secdsig:SignedInfo"; |
1126 | 1126 | $nodeset = $xpath->query($query, $this->sigNode); |
@@ -1132,13 +1132,13 @@ discard block |
||
1132 | 1132 | } |
1133 | 1133 | } |
1134 | 1134 | |
1135 | - public function addObject($data, $mimetype=NULL, $encoding=NULL) { |
|
1135 | + public function addObject($data, $mimetype = NULL, $encoding = NULL) { |
|
1136 | 1136 | $objNode = $this->createNewSignNode('Object'); |
1137 | 1137 | $this->sigNode->appendChild($objNode); |
1138 | - if (!empty($mimetype)) { |
|
1138 | + if ( ! empty($mimetype)) { |
|
1139 | 1139 | $objNode->setAtribute('MimeType', $mimetype); |
1140 | 1140 | } |
1141 | - if (!empty($encoding)) { |
|
1141 | + if ( ! empty($encoding)) { |
|
1142 | 1142 | $objNode->setAttribute('Encoding', $encoding); |
1143 | 1143 | } |
1144 | 1144 | |
@@ -1152,11 +1152,11 @@ discard block |
||
1152 | 1152 | return $objNode; |
1153 | 1153 | } |
1154 | 1154 | |
1155 | - public function locateKey($node=NULL) { |
|
1155 | + public function locateKey($node = NULL) { |
|
1156 | 1156 | if (empty($node)) { |
1157 | 1157 | $node = $this->sigNode; |
1158 | 1158 | } |
1159 | - if (!$node instanceof DOMNode) { |
|
1159 | + if ( ! $node instanceof DOMNode) { |
|
1160 | 1160 | return NULL; |
1161 | 1161 | } |
1162 | 1162 | if ($doc = $node->ownerDocument) { |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | |
1224 | 1224 | } |
1225 | 1225 | |
1226 | - public function appendKey($objKey, $parent=NULL) { |
|
1226 | + public function appendKey($objKey, $parent = NULL) { |
|
1227 | 1227 | $objKey->serializeKey($parent); |
1228 | 1228 | } |
1229 | 1229 | |
@@ -1255,22 +1255,22 @@ discard block |
||
1255 | 1255 | return $this->insertSignature($parentNode, $beforeNode); |
1256 | 1256 | } |
1257 | 1257 | |
1258 | - static function get509XCert($cert, $isPEMFormat=TRUE) { |
|
1258 | + static function get509XCert($cert, $isPEMFormat = TRUE) { |
|
1259 | 1259 | $certs = XMLSecurityDSig::staticGet509XCerts($cert, $isPEMFormat); |
1260 | - if (!empty($certs)) { |
|
1260 | + if ( ! empty($certs)) { |
|
1261 | 1261 | return $certs[0]; |
1262 | 1262 | } |
1263 | 1263 | return ''; |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - static function staticGet509XCerts($certs, $isPEMFormat=TRUE) { |
|
1266 | + static function staticGet509XCerts($certs, $isPEMFormat = TRUE) { |
|
1267 | 1267 | if ($isPEMFormat) { |
1268 | 1268 | $data = ''; |
1269 | 1269 | $certlist = array(); |
1270 | 1270 | $arCert = explode("\n", $certs); |
1271 | 1271 | $inData = FALSE; |
1272 | 1272 | foreach ($arCert AS $curData) { |
1273 | - if (!$inData) { |
|
1273 | + if ( ! $inData) { |
|
1274 | 1274 | if (strncmp($curData, '-----BEGIN CERTIFICATE', 22) == 0) { |
1275 | 1275 | $inData = TRUE; |
1276 | 1276 | } |
@@ -1290,11 +1290,11 @@ discard block |
||
1290 | 1290 | } |
1291 | 1291 | } |
1292 | 1292 | |
1293 | - static function staticAdd509Cert($parentRef, $cert, $isPEMFormat=TRUE, $isURL=False, $xpath=NULL) { |
|
1293 | + static function staticAdd509Cert($parentRef, $cert, $isPEMFormat = TRUE, $isURL = False, $xpath = NULL) { |
|
1294 | 1294 | if ($isURL) { |
1295 | 1295 | $cert = file_get_contents($cert); |
1296 | 1296 | } |
1297 | - if (!$parentRef instanceof DOMElement) { |
|
1297 | + if ( ! $parentRef instanceof DOMElement) { |
|
1298 | 1298 | throw new Exception('Invalid parent Node parameter'); |
1299 | 1299 | } |
1300 | 1300 | $baseDoc = $parentRef->ownerDocument; |
@@ -1307,7 +1307,7 @@ discard block |
||
1307 | 1307 | $query = "./secdsig:KeyInfo"; |
1308 | 1308 | $nodeset = $xpath->query($query, $parentRef); |
1309 | 1309 | $keyInfo = $nodeset->item(0); |
1310 | - if (!$keyInfo) { |
|
1310 | + if ( ! $keyInfo) { |
|
1311 | 1311 | $inserted = FALSE; |
1312 | 1312 | $keyInfo = $baseDoc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:KeyInfo'); |
1313 | 1313 | |
@@ -1318,7 +1318,7 @@ discard block |
||
1318 | 1318 | $inserted = TRUE; |
1319 | 1319 | } |
1320 | 1320 | |
1321 | - if (!$inserted) { |
|
1321 | + if ( ! $inserted) { |
|
1322 | 1322 | $parentRef->appendChild($keyInfo); |
1323 | 1323 | } |
1324 | 1324 | } |
@@ -1337,13 +1337,13 @@ discard block |
||
1337 | 1337 | } |
1338 | 1338 | } |
1339 | 1339 | |
1340 | - public function add509Cert($cert, $isPEMFormat=TRUE, $isURL=False) { |
|
1340 | + public function add509Cert($cert, $isPEMFormat = TRUE, $isURL = False) { |
|
1341 | 1341 | if ($xpath = $this->getXPathObj()) { |
1342 | 1342 | self::staticAdd509Cert($this->sigNode, $cert, $isPEMFormat, $isURL, $xpath); |
1343 | 1343 | } |
1344 | 1344 | } |
1345 | 1345 | |
1346 | - function addKeyInfoAndName($keyName, $xpath=NULL) { |
|
1346 | + function addKeyInfoAndName($keyName, $xpath = NULL) { |
|
1347 | 1347 | |
1348 | 1348 | $baseDoc = $this->sigNode->ownerDocument; |
1349 | 1349 | |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | $query = "./secdsig:KeyInfo"; |
1356 | 1356 | $nodeset = $xpath->query($query, $this->sigNode); |
1357 | 1357 | $keyInfo = $nodeset->item(0); |
1358 | - if (!$keyInfo) { |
|
1358 | + if ( ! $keyInfo) { |
|
1359 | 1359 | $inserted = FALSE; |
1360 | 1360 | $keyInfo = $baseDoc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'KeyInfo'); |
1361 | 1361 | |
@@ -1365,7 +1365,7 @@ discard block |
||
1365 | 1365 | $sObject->parentNode->insertBefore($keyInfo, $sObject); |
1366 | 1366 | $inserted = TRUE; |
1367 | 1367 | } |
1368 | - if (!$inserted) { |
|
1368 | + if ( ! $inserted) { |
|
1369 | 1369 | $this->sigNode->appendChild($keyInfo); |
1370 | 1370 | } |
1371 | 1371 | } |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | } |
1416 | 1416 | |
1417 | 1417 | public function addReference($name, $node, $type) { |
1418 | - if (!$node instanceOf DOMNode) { |
|
1418 | + if ( ! $node instanceOf DOMNode) { |
|
1419 | 1419 | throw new Exception('$node is not of type DOMNode'); |
1420 | 1420 | } |
1421 | 1421 | $curencdoc = $this->encdoc; |
@@ -1432,12 +1432,12 @@ discard block |
||
1432 | 1432 | $this->rawNode = $node; |
1433 | 1433 | } |
1434 | 1434 | |
1435 | - public function encryptNode($objKey, $replace=TRUE) { |
|
1435 | + public function encryptNode($objKey, $replace = TRUE) { |
|
1436 | 1436 | $data = ''; |
1437 | 1437 | if (empty($this->rawNode)) { |
1438 | 1438 | throw new Exception('Node to encrypt has not been set'); |
1439 | 1439 | } |
1440 | - if (!$objKey instanceof XMLSecurityKey) { |
|
1440 | + if ( ! $objKey instanceof XMLSecurityKey) { |
|
1441 | 1441 | throw new Exception('Invalid Key'); |
1442 | 1442 | } |
1443 | 1443 | $doc = $this->rawNode->ownerDocument; |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | $nodeset = $xPath->query($query, $this->rawNode); |
1533 | 1533 | $node = $nodeset->item(0); |
1534 | 1534 | |
1535 | - if (!$node) { |
|
1535 | + if ( ! $node) { |
|
1536 | 1536 | return NULL; |
1537 | 1537 | } |
1538 | 1538 | |
@@ -1551,8 +1551,8 @@ discard block |
||
1551 | 1551 | * @params boolean $replace Whether we should replace the encrypted node in the XML document with the decrypted data. The default is TRUE. |
1552 | 1552 | * @return string|DOMElement The decrypted data. |
1553 | 1553 | */ |
1554 | - public function decryptNode($objKey, $replace=TRUE) { |
|
1555 | - if (!$objKey instanceof XMLSecurityKey) { |
|
1554 | + public function decryptNode($objKey, $replace = TRUE) { |
|
1555 | + if ( ! $objKey instanceof XMLSecurityKey) { |
|
1556 | 1556 | throw new Exception('Invalid Key'); |
1557 | 1557 | } |
1558 | 1558 | |
@@ -1594,8 +1594,8 @@ discard block |
||
1594 | 1594 | } |
1595 | 1595 | } |
1596 | 1596 | |
1597 | - public function encryptKey($srcKey, $rawKey, $append=TRUE) { |
|
1598 | - if ((!$srcKey instanceof XMLSecurityKey) || (!$rawKey instanceof XMLSecurityKey)) { |
|
1597 | + public function encryptKey($srcKey, $rawKey, $append = TRUE) { |
|
1598 | + if (( ! $srcKey instanceof XMLSecurityKey) || ( ! $rawKey instanceof XMLSecurityKey)) { |
|
1599 | 1599 | throw new Exception('Invalid Key'); |
1600 | 1600 | } |
1601 | 1601 | $strEncKey = base64_encode($srcKey->encryptData($rawKey->key)); |
@@ -1609,7 +1609,7 @@ discard block |
||
1609 | 1609 | } |
1610 | 1610 | $encMethod = $encKey->appendChild($this->encdoc->createElementNS(XMLSecEnc::XMLENCNS, 'xenc:EncryptionMethod')); |
1611 | 1611 | $encMethod->setAttribute('Algorithm', $srcKey->getAlgorith()); |
1612 | - if (!empty($srcKey->name)) { |
|
1612 | + if ( ! empty($srcKey->name)) { |
|
1613 | 1613 | $keyInfo = $encKey->appendChild($this->encdoc->createElementNS('http://www.w3.org/2000/09/xmldsig#', 'dsig:KeyInfo')); |
1614 | 1614 | $keyInfo->appendChild($this->encdoc->createElementNS('http://www.w3.org/2000/09/xmldsig#', 'dsig:KeyName', $srcKey->name)); |
1615 | 1615 | } |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | } |
1628 | 1628 | |
1629 | 1629 | public function decryptKey($encKey) { |
1630 | - if (!$encKey->isEncrypted) { |
|
1630 | + if ( ! $encKey->isEncrypted) { |
|
1631 | 1631 | throw new Exception("Key is not Encrypted"); |
1632 | 1632 | } |
1633 | 1633 | if (empty($encKey->key)) { |
@@ -1651,11 +1651,11 @@ discard block |
||
1651 | 1651 | return NULL; |
1652 | 1652 | } |
1653 | 1653 | |
1654 | - public function locateKey($node=NULL) { |
|
1654 | + public function locateKey($node = NULL) { |
|
1655 | 1655 | if (empty($node)) { |
1656 | 1656 | $node = $this->rawNode; |
1657 | 1657 | } |
1658 | - if (!$node instanceof DOMNode) { |
|
1658 | + if ( ! $node instanceof DOMNode) { |
|
1659 | 1659 | return NULL; |
1660 | 1660 | } |
1661 | 1661 | if ($doc = $node->ownerDocument) { |
@@ -1676,12 +1676,12 @@ discard block |
||
1676 | 1676 | return NULL; |
1677 | 1677 | } |
1678 | 1678 | |
1679 | - static function staticLocateKeyInfo($objBaseKey=NULL, $node=NULL) { |
|
1680 | - if (empty($node) || (!$node instanceof DOMNode)) { |
|
1679 | + static function staticLocateKeyInfo($objBaseKey = NULL, $node = NULL) { |
|
1680 | + if (empty($node) || ( ! $node instanceof DOMNode)) { |
|
1681 | 1681 | return NULL; |
1682 | 1682 | } |
1683 | 1683 | $doc = $node->ownerDocument; |
1684 | - if (!$doc) { |
|
1684 | + if ( ! $doc) { |
|
1685 | 1685 | return NULL; |
1686 | 1686 | } |
1687 | 1687 | |
@@ -1691,7 +1691,7 @@ discard block |
||
1691 | 1691 | $query = "./xmlsecdsig:KeyInfo"; |
1692 | 1692 | $nodeset = $xpath->query($query, $node); |
1693 | 1693 | $encmeth = $nodeset->item(0); |
1694 | - if (!$encmeth) { |
|
1694 | + if ( ! $encmeth) { |
|
1695 | 1695 | /* No KeyInfo in EncryptedData / EncryptedKey. */ |
1696 | 1696 | return $objBaseKey; |
1697 | 1697 | } |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | foreach ($encmeth->childNodes AS $child) { |
1700 | 1700 | switch ($child->localName) { |
1701 | 1701 | case 'KeyName': |
1702 | - if (!empty($objBaseKey)) { |
|
1702 | + if ( ! empty($objBaseKey)) { |
|
1703 | 1703 | $objBaseKey->name = $child->nodeValue; |
1704 | 1704 | } |
1705 | 1705 | break; |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | |
1743 | 1743 | $query = "//xmlsecenc:EncryptedKey[@Id='$id']"; |
1744 | 1744 | $keyElement = $xpath->query($query)->item(0); |
1745 | - if (!$keyElement) { |
|
1745 | + if ( ! $keyElement) { |
|
1746 | 1746 | throw new Exception("Unable to locate EncryptedKey with @Id='$id'."); |
1747 | 1747 | } |
1748 | 1748 | |
@@ -1764,7 +1764,7 @@ discard block |
||
1764 | 1764 | return $objBaseKey; |
1765 | 1765 | } |
1766 | 1766 | |
1767 | - public function locateKeyInfo($objBaseKey=NULL, $node=NULL) { |
|
1767 | + public function locateKeyInfo($objBaseKey = NULL, $node = NULL) { |
|
1768 | 1768 | if (empty($node)) { |
1769 | 1769 | $node = $this->rawNode; |
1770 | 1770 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | return; |
74 | 74 | } |
75 | - if ($element->nodeType == XML_COMMENT_NODE && !$withcomments) { |
|
75 | + if ($element->nodeType == XML_COMMENT_NODE && ! $withcomments) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | $tree->appendChild($dom->importNode($element, TRUE)); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $withcomments - boolean indicating wether or not to include comments in canonicalized form |
151 | 151 | */ |
152 | 152 | |
153 | -function C14NGeneral($element, $exclusive=FALSE, $withcomments=FALSE) { |
|
153 | +function C14NGeneral($element, $exclusive = FALSE, $withcomments = FALSE) { |
|
154 | 154 | /* IF PHP 5.2+ then use built in canonical functionality */ |
155 | 155 | $php_version = explode('.', PHP_VERSION); |
156 | 156 | if (($php_version[0] > 5) || ($php_version[0] == 5 && $php_version[1] >= 2)) { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | /* Must be element or document */ |
161 | - if (!$element instanceof DOMElement && !$element instanceof DOMDocument) { |
|
161 | + if ( ! $element instanceof DOMElement && ! $element instanceof DOMDocument) { |
|
162 | 162 | return NULL; |
163 | 163 | } |
164 | 164 | /* Currently only exclusive XML is supported */ |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | /* This variable contains the certificate thunbprint if we have loaded an X509-certificate. */ |
203 | 203 | private $X509Thumbprint = NULL; |
204 | 204 | |
205 | - public function __construct($type, $params=NULL) { |
|
205 | + public function __construct($type, $params = NULL) { |
|
206 | 206 | srand(); |
207 | 207 | switch ($type) { |
208 | 208 | case (XMLSecurityKey::TRIPLEDES_CBC): |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $this->cryptParams['library'] = 'openssl'; |
238 | 238 | $this->cryptParams['padding'] = OPENSSL_PKCS1_PADDING; |
239 | 239 | $this->cryptParams['method'] = 'http://www.w3.org/2001/04/xmlenc#rsa-1_5'; |
240 | - if (is_array($params) && !empty($params['type'])) { |
|
240 | + if (is_array($params) && ! empty($params['type'])) { |
|
241 | 241 | if ($params['type'] == 'public' || $params['type'] == 'private') { |
242 | 242 | $this->cryptParams['type'] = $params['type']; |
243 | 243 | break; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $this->cryptParams['padding'] = OPENSSL_PKCS1_OAEP_PADDING; |
251 | 251 | $this->cryptParams['method'] = 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p'; |
252 | 252 | $this->cryptParams['hash'] = NULL; |
253 | - if (is_array($params) && !empty($params['type'])) { |
|
253 | + if (is_array($params) && ! empty($params['type'])) { |
|
254 | 254 | if ($params['type'] == 'public' || $params['type'] == 'private') { |
255 | 255 | $this->cryptParams['type'] = $params['type']; |
256 | 256 | break; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $this->cryptParams['library'] = 'openssl'; |
263 | 263 | $this->cryptParams['method'] = 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'; |
264 | 264 | $this->cryptParams['padding'] = OPENSSL_PKCS1_PADDING; |
265 | - if (is_array($params) && !empty($params['type'])) { |
|
265 | + if (is_array($params) && ! empty($params['type'])) { |
|
266 | 266 | if ($params['type'] == 'public' || $params['type'] == 'private') { |
267 | 267 | $this->cryptParams['type'] = $params['type']; |
268 | 268 | break; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $this->cryptParams['method'] = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'; |
276 | 276 | $this->cryptParams['padding'] = OPENSSL_PKCS1_PADDING; |
277 | 277 | $this->cryptParams['digest'] = 'SHA256'; |
278 | - if (is_array($params) && !empty($params['type'])) { |
|
278 | + if (is_array($params) && ! empty($params['type'])) { |
|
279 | 279 | if ($params['type'] == 'public' || $params['type'] == 'private') { |
280 | 280 | $this->cryptParams['type'] = $params['type']; |
281 | 281 | break; |
@@ -299,14 +299,14 @@ discard block |
||
299 | 299 | * @return int|NULL The number of bytes in the key. |
300 | 300 | */ |
301 | 301 | public function getSymmetricKeySize() { |
302 | - if (!isset($this->cryptParams['keysize'])) { |
|
302 | + if ( ! isset($this->cryptParams['keysize'])) { |
|
303 | 303 | return NULL; |
304 | 304 | } |
305 | 305 | return $this->cryptParams['keysize']; |
306 | 306 | } |
307 | 307 | |
308 | 308 | public function generateSessionKey() { |
309 | - if (!isset($this->cryptParams['keysize'])) { |
|
309 | + if ( ! isset($this->cryptParams['keysize'])) { |
|
310 | 310 | throw new Exception('Unknown key size for type "' . $this->type . '".'); |
311 | 311 | } |
312 | 312 | $keysize = $this->cryptParams['keysize']; |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $inData = FALSE; |
346 | 346 | |
347 | 347 | foreach ($arCert AS $curData) { |
348 | - if (!$inData) { |
|
348 | + if ( ! $inData) { |
|
349 | 349 | if (strncmp($curData, '-----BEGIN CERTIFICATE', 22) == 0) { |
350 | 350 | $inData = TRUE; |
351 | 351 | } |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | - if (!empty($data)) { |
|
361 | + if ( ! empty($data)) { |
|
362 | 362 | return strtolower(sha1(base64_decode($data))); |
363 | 363 | } |
364 | 364 | |
365 | 365 | return NULL; |
366 | 366 | } |
367 | 367 | |
368 | - public function loadKey($key, $isFile=FALSE, $isCert = FALSE) { |
|
368 | + public function loadKey($key, $isFile = FALSE, $isCert = FALSE) { |
|
369 | 369 | if ($isFile) { |
370 | 370 | $this->key = file_get_contents($key); |
371 | 371 | } else { |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | if ($this->cryptParams['mode'] == MCRYPT_MODE_CBC) { |
414 | 414 | $bs = mcrypt_enc_get_block_size($td); |
415 | 415 | for ($datalen0 = $datalen = strlen($data); (($datalen % $bs) != ($bs - 1)); $datalen++) |
416 | - $data.=chr(rand(1, 127)); |
|
417 | - $data.=chr($datalen - $datalen0 + 1); |
|
416 | + $data .= chr(rand(1, 127)); |
|
417 | + $data .= chr($datalen - $datalen0 + 1); |
|
418 | 418 | } |
419 | 419 | $encrypted_data = $this->iv . mcrypt_generic($td, $data); |
420 | 420 | mcrypt_generic_deinit($td); |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | |
444 | 444 | private function encryptOpenSSL($data) { |
445 | 445 | if ($this->cryptParams['type'] == 'public') { |
446 | - if (!openssl_public_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) { |
|
446 | + if ( ! openssl_public_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) { |
|
447 | 447 | throw new Exception('Failure encrypting Data'); |
448 | 448 | return; |
449 | 449 | } |
450 | 450 | } else { |
451 | - if (!openssl_private_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) { |
|
451 | + if ( ! openssl_private_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) { |
|
452 | 452 | throw new Exception('Failure encrypting Data'); |
453 | 453 | return; |
454 | 454 | } |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | |
459 | 459 | private function decryptOpenSSL($data) { |
460 | 460 | if ($this->cryptParams['type'] == 'public') { |
461 | - if (!openssl_public_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) { |
|
461 | + if ( ! openssl_public_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) { |
|
462 | 462 | throw new Exception('Failure decrypting Data'); |
463 | 463 | return; |
464 | 464 | } |
465 | 465 | } else { |
466 | - if (!openssl_private_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) { |
|
466 | + if ( ! openssl_private_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) { |
|
467 | 467 | throw new Exception('Failure decrypting Data'); |
468 | 468 | return; |
469 | 469 | } |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $hash = hash('sha256', $data); |
477 | 477 | $t = '3031300d060960864801650304020105000420'; # sha256 |
478 | 478 | $t .= $hash; |
479 | - $pslen = $pinfo['bits']/8 - (strlen($t)/2 + 3); |
|
479 | + $pslen = $pinfo['bits'] / 8 - (strlen($t) / 2 + 3); |
|
480 | 480 | |
481 | 481 | $eb = '0001' . str_repeat('FF', $pslen) . '00' . $t; |
482 | 482 | $eb = pack('H*', $eb); |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | return openssl_private_encrypt($eb, $signature, $priv_key_id, OPENSSL_NO_PADDING); |
485 | 485 | } |
486 | 486 | |
487 | - function custom_openssl_verify ($data, &$signature, $priv_key_id, $signature_alg = 'sha256WithRSAEncryption') { |
|
487 | + function custom_openssl_verify($data, &$signature, $priv_key_id, $signature_alg = 'sha256WithRSAEncryption') { |
|
488 | 488 | $pinfo = openssl_pkey_get_details($priv_key_id); |
489 | 489 | $hash = hash('sha256', $data); |
490 | 490 | $t = '3031300d060960864801650304020105000420'; # sha256 |
491 | 491 | $t .= $hash; |
492 | - $pslen = $pinfo['bits']/8 - (strlen($t)/2 + 3); |
|
492 | + $pslen = $pinfo['bits'] / 8 - (strlen($t) / 2 + 3); |
|
493 | 493 | |
494 | 494 | $eb = '0001' . str_repeat('FF', $pslen) . '00' . $t; |
495 | 495 | $eb = pack('H*', $eb); |
@@ -499,12 +499,12 @@ discard block |
||
499 | 499 | |
500 | 500 | private function signOpenSSL($data) { |
501 | 501 | $algo = OPENSSL_ALGO_SHA1; |
502 | - if (!empty($this->cryptParams['digest'])) { |
|
502 | + if ( ! empty($this->cryptParams['digest'])) { |
|
503 | 503 | $algo = $this->cryptParams['digest']; |
504 | 504 | } |
505 | 505 | $signature = ''; |
506 | 506 | |
507 | - if (!$this->custom_openssl_sign($data, $signature, $this->key)) { |
|
507 | + if ( ! $this->custom_openssl_sign($data, $signature, $this->key)) { |
|
508 | 508 | throw new Exception('Failure Signing Data: ' . openssl_error_string() . ' - ' . $algo); |
509 | 509 | return; |
510 | 510 | } |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | |
514 | 514 | private function verifyOpenSSL($data, $signature) { |
515 | 515 | $algo = OPENSSL_ALGO_SHA1; |
516 | - if (!empty($this->cryptParams['digest'])) { |
|
516 | + if ( ! empty($this->cryptParams['digest'])) { |
|
517 | 517 | $algo = $this->cryptParams['digest']; |
518 | 518 | } |
519 | 519 | return $this->custom_openssl_verify($data, $signature, $this->key); |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | |
646 | 646 | $objenc = new XMLSecEnc(); |
647 | 647 | $objenc->setNode($element); |
648 | - if (!$objKey = $objenc->locateKey()) { |
|
648 | + if ( ! $objKey = $objenc->locateKey()) { |
|
649 | 649 | throw new Exception("Unable to locate algorithm for this Encrypted Key"); |
650 | 650 | } |
651 | 651 | $objKey->isEncrypted = TRUE; |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | private function getXPathObj() { |
700 | - if (empty($this->xPathCtx) && !empty($this->sigNode)) { |
|
700 | + if (empty($this->xPathCtx) && ! empty($this->sigNode)) { |
|
701 | 701 | $xpath = new DOMXPath($this->sigNode->ownerDocument); |
702 | 702 | $xpath->registerNamespace('secdsig', XMLSecurityDSig::XMLDSIGNS); |
703 | 703 | $this->xPathCtx = $xpath; |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | return $this->xPathCtx; |
706 | 706 | } |
707 | 707 | |
708 | - static function generate_GUID($prefix='pfx') { |
|
708 | + static function generate_GUID($prefix = 'pfx') { |
|
709 | 709 | $uuid = md5(uniqid(rand(), true)); |
710 | 710 | $guid = $prefix . substr($uuid, 0, 8) . "-" . |
711 | 711 | substr($uuid, 8, 4) . "-" . |
@@ -732,12 +732,12 @@ discard block |
||
732 | 732 | return NULL; |
733 | 733 | } |
734 | 734 | |
735 | - public function createNewSignNode($name, $value=NULL) { |
|
735 | + public function createNewSignNode($name, $value = NULL) { |
|
736 | 736 | $doc = $this->sigNode->ownerDocument; |
737 | 737 | if ($this->prefix != null) { |
738 | 738 | $name = $this->prefix . ':' . $name; |
739 | 739 | } |
740 | - if (!is_null($value)) { |
|
740 | + if ( ! is_null($value)) { |
|
741 | 741 | $node = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, $name, $value); |
742 | 742 | } else { |
743 | 743 | $node = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, $name); |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | if ($sinfo = $nodeset->item(0)) { |
763 | 763 | $query = './' . $this->searchpfx . 'CanonicalizationMethod'; |
764 | 764 | $nodeset = $xpath->query($query, $sinfo); |
765 | - if (!($canonNode = $nodeset->item(0))) { |
|
765 | + if ( ! ($canonNode = $nodeset->item(0))) { |
|
766 | 766 | $canonNode = $this->createNewSignNode('CanonicalizationMethod'); |
767 | 767 | $sinfo->insertBefore($canonNode, $sinfo->firstChild); |
768 | 768 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | } |
772 | 772 | } |
773 | 773 | |
774 | - private function canonicalizeData($node, $canonicalmethod, $arXPath=NULL, $prefixList=NULL) { |
|
774 | + private function canonicalizeData($node, $canonicalmethod, $arXPath = NULL, $prefixList = NULL) { |
|
775 | 775 | $exclusive = FALSE; |
776 | 776 | $withComments = FALSE; |
777 | 777 | switch ($canonicalmethod) { |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | /* Support PHP versions < 5.2 not containing C14N methods in DOM extension */ |
794 | 794 | $php_version = explode('.', PHP_VERSION); |
795 | 795 | if (($php_version[0] < 5) || ($php_version[0] == 5 && $php_version[1] < 2)) { |
796 | - if (!is_null($arXPath)) { |
|
796 | + if ( ! is_null($arXPath)) { |
|
797 | 797 | throw new Exception("PHP 5.2.0 or higher is required to perform XPath Transformations"); |
798 | 798 | } |
799 | 799 | return C14NGeneral($node, $exclusive, $withComments); |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | case 'http://www.w3.org/2001/10/xml-exc-c14n#': |
878 | 878 | case 'http://www.w3.org/2001/10/xml-exc-c14n#WithComments': |
879 | 879 | |
880 | - if (!$includeCommentNodes) { |
|
880 | + if ( ! $includeCommentNodes) { |
|
881 | 881 | /* We remove comment nodes by forcing it to use a canonicalization |
882 | 882 | * without comments. |
883 | 883 | */ |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | $pfxlist = explode(" ", $pfx); |
895 | 895 | foreach ($pfxlist AS $pfx) { |
896 | 896 | $val = trim($pfx); |
897 | - if (!empty($val)) { |
|
897 | + if ( ! empty($val)) { |
|
898 | 898 | $arpfx[] = $val; |
899 | 899 | } |
900 | 900 | } |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | break; |
910 | 910 | case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315': |
911 | 911 | case 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments': |
912 | - if (!$includeCommentNodes) { |
|
912 | + if ( ! $includeCommentNodes) { |
|
913 | 913 | /* We remove comment nodes by forcing it to use a canonicalization |
914 | 914 | * without comments. |
915 | 915 | */ |
@@ -993,13 +993,13 @@ discard block |
||
993 | 993 | $dataObject = $refNode->ownerDocument; |
994 | 994 | } |
995 | 995 | $data = $this->processTransforms($refNode, $dataObject, $includeCommentNodes); |
996 | - if (!$this->validateDigest($refNode, $data)) { |
|
996 | + if ( ! $this->validateDigest($refNode, $data)) { |
|
997 | 997 | return FALSE; |
998 | 998 | } |
999 | 999 | |
1000 | 1000 | if ($dataObject instanceof DOMNode) { |
1001 | 1001 | /* Add this node to the list of validated nodes. */ |
1002 | - if (!empty($identifier)) { |
|
1002 | + if ( ! empty($identifier)) { |
|
1003 | 1003 | $this->validatedNodes[$identifier] = $dataObject; |
1004 | 1004 | } else { |
1005 | 1005 | $this->validatedNodes[] = $dataObject; |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | |
1040 | 1040 | public function validateReference() { |
1041 | 1041 | $doc = $this->sigNode->ownerDocument; |
1042 | - if (!$doc->isSameNode($this->sigNode)) { |
|
1042 | + if ( ! $doc->isSameNode($this->sigNode)) { |
|
1043 | 1043 | $this->sigNode->parentNode->removeChild($this->sigNode); |
1044 | 1044 | } |
1045 | 1045 | $xpath = $this->getXPathObj(); |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | $this->validatedNodes = array(); |
1054 | 1054 | |
1055 | 1055 | foreach ($nodeset AS $refNode) { |
1056 | - if (!$this->processRefNode($refNode)) { |
|
1056 | + if ( ! $this->processRefNode($refNode)) { |
|
1057 | 1057 | /* Clear the list of validated nodes. */ |
1058 | 1058 | $this->validatedNodes = NULL; |
1059 | 1059 | throw new Exception("Reference validation failed"); |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | return TRUE; |
1063 | 1063 | } |
1064 | 1064 | |
1065 | - private function addRefInternal($sinfoNode, $node, $algorithm, $arTransforms=NULL, $options=NULL) { |
|
1065 | + private function addRefInternal($sinfoNode, $node, $algorithm, $arTransforms = NULL, $options = NULL) { |
|
1066 | 1066 | $prefix = NULL; |
1067 | 1067 | $prefix_ns = NULL; |
1068 | 1068 | $id_name = 'Id'; |
@@ -1073,21 +1073,21 @@ discard block |
||
1073 | 1073 | $prefix = empty($options['prefix']) ? NULL : $options['prefix']; |
1074 | 1074 | $prefix_ns = empty($options['prefix_ns']) ? NULL : $options['prefix_ns']; |
1075 | 1075 | $id_name = empty($options['id_name']) ? 'Id' : $options['id_name']; |
1076 | - $overwrite_id = !isset($options['overwrite']) ? TRUE : (bool) $options['overwrite']; |
|
1077 | - $force_uri = !isset($options['force_uri']) ? FALSE : (bool) $options['force_uri']; |
|
1076 | + $overwrite_id = ! isset($options['overwrite']) ? TRUE : (bool) $options['overwrite']; |
|
1077 | + $force_uri = ! isset($options['force_uri']) ? FALSE : (bool) $options['force_uri']; |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | $attname = $id_name; |
1081 | - if (!empty($prefix)) { |
|
1081 | + if ( ! empty($prefix)) { |
|
1082 | 1082 | $attname = $prefix . ':' . $attname; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | $refNode = $this->createNewSignNode('Reference'); |
1086 | 1086 | $sinfoNode->appendChild($refNode); |
1087 | 1087 | |
1088 | - if (!$node instanceof DOMDocument) { |
|
1088 | + if ( ! $node instanceof DOMDocument) { |
|
1089 | 1089 | $uri = NULL; |
1090 | - if (!$overwrite_id) { |
|
1090 | + if ( ! $overwrite_id) { |
|
1091 | 1091 | $uri = $node->getAttributeNS($prefix_ns, $attname); |
1092 | 1092 | } |
1093 | 1093 | if (empty($uri)) { |
@@ -1107,12 +1107,12 @@ discard block |
||
1107 | 1107 | $transNode = $this->createNewSignNode('Transform'); |
1108 | 1108 | $transNodes->appendChild($transNode); |
1109 | 1109 | if (is_array($transform) && |
1110 | - (!empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116'])) && |
|
1111 | - (!empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['query']))) { |
|
1110 | + ( ! empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116'])) && |
|
1111 | + ( ! empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['query']))) { |
|
1112 | 1112 | $transNode->setAttribute('Algorithm', 'http://www.w3.org/TR/1999/REC-xpath-19991116'); |
1113 | 1113 | $XPathNode = $this->createNewSignNode('XPath', $transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['query']); |
1114 | 1114 | $transNode->appendChild($XPathNode); |
1115 | - if (!empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['namespaces'])) { |
|
1115 | + if ( ! empty($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['namespaces'])) { |
|
1116 | 1116 | foreach ($transform['http://www.w3.org/TR/1999/REC-xpath-19991116']['namespaces'] AS $prefix => $namespace) { |
1117 | 1117 | $XPathNode->setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:$prefix", $namespace); |
1118 | 1118 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | $transNode->setAttribute('Algorithm', $transform); |
1122 | 1122 | } |
1123 | 1123 | } |
1124 | - } elseif (!empty($this->canonicalMethod)) { |
|
1124 | + } elseif ( ! empty($this->canonicalMethod)) { |
|
1125 | 1125 | $transNode = $this->createNewSignNode('Transform'); |
1126 | 1126 | $transNodes->appendChild($transNode); |
1127 | 1127 | $transNode->setAttribute('Algorithm', $this->canonicalMethod); |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | $refNode->appendChild($digestValue); |
1139 | 1139 | } |
1140 | 1140 | |
1141 | - public function addReference($node, $algorithm, $arTransforms=NULL, $options=NULL) { |
|
1141 | + public function addReference($node, $algorithm, $arTransforms = NULL, $options = NULL) { |
|
1142 | 1142 | if ($xpath = $this->getXPathObj()) { |
1143 | 1143 | $query = "./secdsig:SignedInfo"; |
1144 | 1144 | $nodeset = $xpath->query($query, $this->sigNode); |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | } |
1149 | 1149 | } |
1150 | 1150 | |
1151 | - public function addReferenceList($arNodes, $algorithm, $arTransforms=NULL, $options=NULL) { |
|
1151 | + public function addReferenceList($arNodes, $algorithm, $arTransforms = NULL, $options = NULL) { |
|
1152 | 1152 | if ($xpath = $this->getXPathObj()) { |
1153 | 1153 | $query = "./secdsig:SignedInfo"; |
1154 | 1154 | $nodeset = $xpath->query($query, $this->sigNode); |
@@ -1160,13 +1160,13 @@ discard block |
||
1160 | 1160 | } |
1161 | 1161 | } |
1162 | 1162 | |
1163 | - public function addObject($data, $mimetype=NULL, $encoding=NULL) { |
|
1163 | + public function addObject($data, $mimetype = NULL, $encoding = NULL) { |
|
1164 | 1164 | $objNode = $this->createNewSignNode('Object'); |
1165 | 1165 | $this->sigNode->appendChild($objNode); |
1166 | - if (!empty($mimetype)) { |
|
1166 | + if ( ! empty($mimetype)) { |
|
1167 | 1167 | $objNode->setAtribute('MimeType', $mimetype); |
1168 | 1168 | } |
1169 | - if (!empty($encoding)) { |
|
1169 | + if ( ! empty($encoding)) { |
|
1170 | 1170 | $objNode->setAttribute('Encoding', $encoding); |
1171 | 1171 | } |
1172 | 1172 | |
@@ -1180,11 +1180,11 @@ discard block |
||
1180 | 1180 | return $objNode; |
1181 | 1181 | } |
1182 | 1182 | |
1183 | - public function locateKey($node=NULL) { |
|
1183 | + public function locateKey($node = NULL) { |
|
1184 | 1184 | if (empty($node)) { |
1185 | 1185 | $node = $this->sigNode; |
1186 | 1186 | } |
1187 | - if (!$node instanceof DOMNode) { |
|
1187 | + if ( ! $node instanceof DOMNode) { |
|
1188 | 1188 | return NULL; |
1189 | 1189 | } |
1190 | 1190 | if ($doc = $node->ownerDocument) { |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - public function appendKey($objKey, $parent=NULL) { |
|
1254 | + public function appendKey($objKey, $parent = NULL) { |
|
1255 | 1255 | $objKey->serializeKey($parent); |
1256 | 1256 | } |
1257 | 1257 | |
@@ -1283,22 +1283,22 @@ discard block |
||
1283 | 1283 | return $this->insertSignature($parentNode, $beforeNode); |
1284 | 1284 | } |
1285 | 1285 | |
1286 | - static function get509XCert($cert, $isPEMFormat=TRUE) { |
|
1286 | + static function get509XCert($cert, $isPEMFormat = TRUE) { |
|
1287 | 1287 | $certs = XMLSecurityDSig::staticGet509XCerts($cert, $isPEMFormat); |
1288 | - if (!empty($certs)) { |
|
1288 | + if ( ! empty($certs)) { |
|
1289 | 1289 | return $certs[0]; |
1290 | 1290 | } |
1291 | 1291 | return ''; |
1292 | 1292 | } |
1293 | 1293 | |
1294 | - static function staticGet509XCerts($certs, $isPEMFormat=TRUE) { |
|
1294 | + static function staticGet509XCerts($certs, $isPEMFormat = TRUE) { |
|
1295 | 1295 | if ($isPEMFormat) { |
1296 | 1296 | $data = ''; |
1297 | 1297 | $certlist = array(); |
1298 | 1298 | $arCert = explode("\n", $certs); |
1299 | 1299 | $inData = FALSE; |
1300 | 1300 | foreach ($arCert AS $curData) { |
1301 | - if (!$inData) { |
|
1301 | + if ( ! $inData) { |
|
1302 | 1302 | if (strncmp($curData, '-----BEGIN CERTIFICATE', 22) == 0) { |
1303 | 1303 | $inData = TRUE; |
1304 | 1304 | } |
@@ -1318,11 +1318,11 @@ discard block |
||
1318 | 1318 | } |
1319 | 1319 | } |
1320 | 1320 | |
1321 | - static function staticAdd509Cert($parentRef, $cert, $isPEMFormat=TRUE, $isURL=False, $xpath=NULL) { |
|
1321 | + static function staticAdd509Cert($parentRef, $cert, $isPEMFormat = TRUE, $isURL = False, $xpath = NULL) { |
|
1322 | 1322 | if ($isURL) { |
1323 | 1323 | $cert = file_get_contents($cert); |
1324 | 1324 | } |
1325 | - if (!$parentRef instanceof DOMElement) { |
|
1325 | + if ( ! $parentRef instanceof DOMElement) { |
|
1326 | 1326 | throw new Exception('Invalid parent Node parameter'); |
1327 | 1327 | } |
1328 | 1328 | $baseDoc = $parentRef->ownerDocument; |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | $query = "./secdsig:KeyInfo"; |
1336 | 1336 | $nodeset = $xpath->query($query, $parentRef); |
1337 | 1337 | $keyInfo = $nodeset->item(0); |
1338 | - if (!$keyInfo) { |
|
1338 | + if ( ! $keyInfo) { |
|
1339 | 1339 | $inserted = FALSE; |
1340 | 1340 | $keyInfo = $baseDoc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:KeyInfo'); |
1341 | 1341 | |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | $inserted = TRUE; |
1347 | 1347 | } |
1348 | 1348 | |
1349 | - if (!$inserted) { |
|
1349 | + if ( ! $inserted) { |
|
1350 | 1350 | $parentRef->appendChild($keyInfo); |
1351 | 1351 | } |
1352 | 1352 | } |
@@ -1365,13 +1365,13 @@ discard block |
||
1365 | 1365 | } |
1366 | 1366 | } |
1367 | 1367 | |
1368 | - public function add509Cert($cert, $isPEMFormat=TRUE, $isURL=False) { |
|
1368 | + public function add509Cert($cert, $isPEMFormat = TRUE, $isURL = False) { |
|
1369 | 1369 | if ($xpath = $this->getXPathObj()) { |
1370 | 1370 | self::staticAdd509Cert($this->sigNode, $cert, $isPEMFormat, $isURL, $xpath); |
1371 | 1371 | } |
1372 | 1372 | } |
1373 | 1373 | |
1374 | - function addKeyInfoAndName($keyName, $xpath=NULL) { |
|
1374 | + function addKeyInfoAndName($keyName, $xpath = NULL) { |
|
1375 | 1375 | |
1376 | 1376 | $baseDoc = $this->sigNode->ownerDocument; |
1377 | 1377 | |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | $query = "./secdsig:KeyInfo"; |
1384 | 1384 | $nodeset = $xpath->query($query, $this->sigNode); |
1385 | 1385 | $keyInfo = $nodeset->item(0); |
1386 | - if (!$keyInfo) { |
|
1386 | + if ( ! $keyInfo) { |
|
1387 | 1387 | $inserted = FALSE; |
1388 | 1388 | $keyInfo = $baseDoc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'KeyInfo'); |
1389 | 1389 | |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | $sObject->parentNode->insertBefore($keyInfo, $sObject); |
1394 | 1394 | $inserted = TRUE; |
1395 | 1395 | } |
1396 | - if (!$inserted) { |
|
1396 | + if ( ! $inserted) { |
|
1397 | 1397 | $this->sigNode->appendChild($keyInfo); |
1398 | 1398 | } |
1399 | 1399 | } |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | } |
1444 | 1444 | |
1445 | 1445 | public function addReference($name, $node, $type) { |
1446 | - if (!$node instanceOf DOMNode) { |
|
1446 | + if ( ! $node instanceOf DOMNode) { |
|
1447 | 1447 | throw new Exception('$node is not of type DOMNode'); |
1448 | 1448 | } |
1449 | 1449 | $curencdoc = $this->encdoc; |
@@ -1460,12 +1460,12 @@ discard block |
||
1460 | 1460 | $this->rawNode = $node; |
1461 | 1461 | } |
1462 | 1462 | |
1463 | - public function encryptNode($objKey, $replace=TRUE) { |
|
1463 | + public function encryptNode($objKey, $replace = TRUE) { |
|
1464 | 1464 | $data = ''; |
1465 | 1465 | if (empty($this->rawNode)) { |
1466 | 1466 | throw new Exception('Node to encrypt has not been set'); |
1467 | 1467 | } |
1468 | - if (!$objKey instanceof XMLSecurityKey) { |
|
1468 | + if ( ! $objKey instanceof XMLSecurityKey) { |
|
1469 | 1469 | throw new Exception('Invalid Key'); |
1470 | 1470 | } |
1471 | 1471 | $doc = $this->rawNode->ownerDocument; |
@@ -1560,7 +1560,7 @@ discard block |
||
1560 | 1560 | $nodeset = $xPath->query($query, $this->rawNode); |
1561 | 1561 | $node = $nodeset->item(0); |
1562 | 1562 | |
1563 | - if (!$node) { |
|
1563 | + if ( ! $node) { |
|
1564 | 1564 | return NULL; |
1565 | 1565 | } |
1566 | 1566 | |
@@ -1579,8 +1579,8 @@ discard block |
||
1579 | 1579 | * @params boolean $replace Whether we should replace the encrypted node in the XML document with the decrypted data. The default is TRUE. |
1580 | 1580 | * @return string|DOMElement The decrypted data. |
1581 | 1581 | */ |
1582 | - public function decryptNode($objKey, $replace=TRUE) { |
|
1583 | - if (!$objKey instanceof XMLSecurityKey) { |
|
1582 | + public function decryptNode($objKey, $replace = TRUE) { |
|
1583 | + if ( ! $objKey instanceof XMLSecurityKey) { |
|
1584 | 1584 | throw new Exception('Invalid Key'); |
1585 | 1585 | } |
1586 | 1586 | |
@@ -1622,8 +1622,8 @@ discard block |
||
1622 | 1622 | } |
1623 | 1623 | } |
1624 | 1624 | |
1625 | - public function encryptKey($srcKey, $rawKey, $append=TRUE) { |
|
1626 | - if ((!$srcKey instanceof XMLSecurityKey) || (!$rawKey instanceof XMLSecurityKey)) { |
|
1625 | + public function encryptKey($srcKey, $rawKey, $append = TRUE) { |
|
1626 | + if (( ! $srcKey instanceof XMLSecurityKey) || ( ! $rawKey instanceof XMLSecurityKey)) { |
|
1627 | 1627 | throw new Exception('Invalid Key'); |
1628 | 1628 | } |
1629 | 1629 | $strEncKey = base64_encode($srcKey->encryptData($rawKey->key)); |
@@ -1637,7 +1637,7 @@ discard block |
||
1637 | 1637 | } |
1638 | 1638 | $encMethod = $encKey->appendChild($this->encdoc->createElementNS(XMLSecEnc::XMLENCNS, 'xenc:EncryptionMethod')); |
1639 | 1639 | $encMethod->setAttribute('Algorithm', $srcKey->getAlgorith()); |
1640 | - if (!empty($srcKey->name)) { |
|
1640 | + if ( ! empty($srcKey->name)) { |
|
1641 | 1641 | $keyInfo = $encKey->appendChild($this->encdoc->createElementNS('http://www.w3.org/2000/09/xmldsig#', 'dsig:KeyInfo')); |
1642 | 1642 | $keyInfo->appendChild($this->encdoc->createElementNS('http://www.w3.org/2000/09/xmldsig#', 'dsig:KeyName', $srcKey->name)); |
1643 | 1643 | } |
@@ -1655,7 +1655,7 @@ discard block |
||
1655 | 1655 | } |
1656 | 1656 | |
1657 | 1657 | public function decryptKey($encKey) { |
1658 | - if (!$encKey->isEncrypted) { |
|
1658 | + if ( ! $encKey->isEncrypted) { |
|
1659 | 1659 | throw new Exception("Key is not Encrypted"); |
1660 | 1660 | } |
1661 | 1661 | if (empty($encKey->key)) { |
@@ -1679,11 +1679,11 @@ discard block |
||
1679 | 1679 | return NULL; |
1680 | 1680 | } |
1681 | 1681 | |
1682 | - public function locateKey($node=NULL) { |
|
1682 | + public function locateKey($node = NULL) { |
|
1683 | 1683 | if (empty($node)) { |
1684 | 1684 | $node = $this->rawNode; |
1685 | 1685 | } |
1686 | - if (!$node instanceof DOMNode) { |
|
1686 | + if ( ! $node instanceof DOMNode) { |
|
1687 | 1687 | return NULL; |
1688 | 1688 | } |
1689 | 1689 | if ($doc = $node->ownerDocument) { |
@@ -1704,12 +1704,12 @@ discard block |
||
1704 | 1704 | return NULL; |
1705 | 1705 | } |
1706 | 1706 | |
1707 | - static function staticLocateKeyInfo($objBaseKey=NULL, $node=NULL) { |
|
1708 | - if (empty($node) || (!$node instanceof DOMNode)) { |
|
1707 | + static function staticLocateKeyInfo($objBaseKey = NULL, $node = NULL) { |
|
1708 | + if (empty($node) || ( ! $node instanceof DOMNode)) { |
|
1709 | 1709 | return NULL; |
1710 | 1710 | } |
1711 | 1711 | $doc = $node->ownerDocument; |
1712 | - if (!$doc) { |
|
1712 | + if ( ! $doc) { |
|
1713 | 1713 | return NULL; |
1714 | 1714 | } |
1715 | 1715 | |
@@ -1719,7 +1719,7 @@ discard block |
||
1719 | 1719 | $query = "./xmlsecdsig:KeyInfo"; |
1720 | 1720 | $nodeset = $xpath->query($query, $node); |
1721 | 1721 | $encmeth = $nodeset->item(0); |
1722 | - if (!$encmeth) { |
|
1722 | + if ( ! $encmeth) { |
|
1723 | 1723 | /* No KeyInfo in EncryptedData / EncryptedKey. */ |
1724 | 1724 | return $objBaseKey; |
1725 | 1725 | } |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | foreach ($encmeth->childNodes AS $child) { |
1728 | 1728 | switch ($child->localName) { |
1729 | 1729 | case 'KeyName': |
1730 | - if (!empty($objBaseKey)) { |
|
1730 | + if ( ! empty($objBaseKey)) { |
|
1731 | 1731 | $objBaseKey->name = $child->nodeValue; |
1732 | 1732 | } |
1733 | 1733 | break; |
@@ -1770,7 +1770,7 @@ discard block |
||
1770 | 1770 | |
1771 | 1771 | $query = "//xmlsecenc:EncryptedKey[@Id='$id']"; |
1772 | 1772 | $keyElement = $xpath->query($query)->item(0); |
1773 | - if (!$keyElement) { |
|
1773 | + if ( ! $keyElement) { |
|
1774 | 1774 | throw new Exception("Unable to locate EncryptedKey with @Id='$id'."); |
1775 | 1775 | } |
1776 | 1776 | |
@@ -1792,7 +1792,7 @@ discard block |
||
1792 | 1792 | return $objBaseKey; |
1793 | 1793 | } |
1794 | 1794 | |
1795 | - public function locateKeyInfo($objBaseKey=NULL, $node=NULL) { |
|
1795 | + public function locateKeyInfo($objBaseKey = NULL, $node = NULL) { |
|
1796 | 1796 | if (empty($node)) { |
1797 | 1797 | $node = $this->rawNode; |
1798 | 1798 | } |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | 'Open' => 'payment_pending', |
29 | 29 | ); |
30 | 30 | |
31 | -foreach ( $states as $meta_value => $post_status ) { |
|
32 | - $condition = empty( $meta_value ) ? 'IS NULL' : '= %s'; |
|
31 | +foreach ($states as $meta_value => $post_status) { |
|
32 | + $condition = empty($meta_value) ? 'IS NULL' : '= %s'; |
|
33 | 33 | |
34 | 34 | $query = " |
35 | 35 | UPDATE |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ; |
49 | 49 | "; |
50 | 50 | |
51 | - $query = $wpdb->prepare( $query, $post_status, $meta_value ); // WPCS: unprepared SQL ok. |
|
51 | + $query = $wpdb->prepare($query, $post_status, $meta_value); // WPCS: unprepared SQL ok. |
|
52 | 52 | |
53 | - $wpdb->query( $query ); // WPCS: unprepared SQL ok. |
|
53 | + $wpdb->query($query); // WPCS: unprepared SQL ok. |
|
54 | 54 | } |
@@ -15,16 +15,16 @@ |
||
15 | 15 | * @since 3.3.0 |
16 | 16 | */ |
17 | 17 | |
18 | -$license_md5 = get_option( 'pronamic_pay_license_key' ); |
|
18 | +$license_md5 = get_option('pronamic_pay_license_key'); |
|
19 | 19 | |
20 | -$url = add_query_arg( 'license', $license_md5, 'http://api.pronamic.eu/licenses/convert-md5/1.0/' ); |
|
20 | +$url = add_query_arg('license', $license_md5, 'http://api.pronamic.eu/licenses/convert-md5/1.0/'); |
|
21 | 21 | |
22 | -$result = wp_remote_get( $url ); |
|
22 | +$result = wp_remote_get($url); |
|
23 | 23 | |
24 | -if ( 200 === wp_remote_retrieve_response_code( $result ) ) { |
|
25 | - $body = wp_remote_retrieve_body( $result ); |
|
24 | +if (200 === wp_remote_retrieve_response_code($result)) { |
|
25 | + $body = wp_remote_retrieve_body($result); |
|
26 | 26 | |
27 | - if ( 32 === strlen( $body ) ) { |
|
28 | - update_option( 'pronamic_pay_license_key', $body ); |
|
27 | + if (32 === strlen($body)) { |
|
28 | + update_option('pronamic_pay_license_key', $body); |
|
29 | 29 | } |
30 | 30 | } |
@@ -32,10 +32,10 @@ |
||
32 | 32 | 'pronamic_ideal_key' => 'pronamic_pay_license_key', |
33 | 33 | ); |
34 | 34 | |
35 | -foreach ( $options as $key_old => $key_new ) { |
|
36 | - $value = get_option( $key_old ); |
|
35 | +foreach ($options as $key_old => $key_new) { |
|
36 | + $value = get_option($key_old); |
|
37 | 37 | |
38 | - if ( ! empty( $value ) ) { |
|
39 | - update_option( $key_new, $value ); |
|
38 | + if ( ! empty($value)) { |
|
39 | + update_option($key_new, $value); |
|
40 | 40 | } |
41 | 41 | } |
@@ -8,4 +8,4 @@ |
||
8 | 8 | * @package Pronamic\WordPress\Pay |
9 | 9 | */ |
10 | 10 | |
11 | -require dirname( __FILE__ ) . '/update-3.7.0.php'; |
|
11 | +require dirname(__FILE__) . '/update-3.7.0.php'; |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | // Check if there is not already an upgrade running |
19 | -if ( get_transient( 'pronamic_pay_upgrade_200' ) ) { |
|
19 | +if (get_transient('pronamic_pay_upgrade_200')) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | -set_transient( 'pronamic_pay_upgrade_200', true, 3600 ); // 60 minutes |
|
23 | +set_transient('pronamic_pay_upgrade_200', true, 3600); // 60 minutes |
|
24 | 24 | |
25 | 25 | // Upgrade |
26 | 26 | global $wpdb; |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | require_once ABSPATH . '/wp-admin/includes/upgrade.php'; |
29 | 29 | |
30 | 30 | $charset_collate = ''; |
31 | -if ( ! empty( $wpdb->charset ) ) { |
|
31 | +if ( ! empty($wpdb->charset)) { |
|
32 | 32 | $charset_collate = 'DEFAULT CHARACTER SET ' . $wpdb->charset; |
33 | 33 | } |
34 | -if ( ! empty( $wpdb->collate ) ) { |
|
34 | +if ( ! empty($wpdb->collate)) { |
|
35 | 35 | $charset_collate .= ' COLLATE ' . $wpdb->collate; |
36 | 36 | } |
37 | 37 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | PRIMARY KEY (id) |
78 | 78 | ) $charset_collate;"; |
79 | 79 | |
80 | -dbDelta( $sql ); |
|
80 | +dbDelta($sql); |
|
81 | 81 | |
82 | 82 | // Query |
83 | 83 | $query = " |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | |
95 | 95 | $have_configs = true; |
96 | 96 | |
97 | -while ( $have_configs ) { |
|
98 | - $configs = $wpdb->get_results( $query ); // WPCS: unprepared SQL ok. |
|
97 | +while ($have_configs) { |
|
98 | + $configs = $wpdb->get_results($query); // WPCS: unprepared SQL ok. |
|
99 | 99 | |
100 | - $have_configs = ! empty( $configs ); |
|
100 | + $have_configs = ! empty($configs); |
|
101 | 101 | |
102 | - foreach ( $configs as $config ) { |
|
103 | - $title = sprintf( __( 'Configuration %d', 'pronamic_ideal' ), $config->id ); |
|
102 | + foreach ($configs as $config) { |
|
103 | + $title = sprintf(__('Configuration %d', 'pronamic_ideal'), $config->id); |
|
104 | 104 | |
105 | 105 | // Post |
106 | 106 | $post = array( |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | 'post_status' => 'publish', |
110 | 110 | ); |
111 | 111 | |
112 | - $post_id = wp_insert_post( $post ); |
|
112 | + $post_id = wp_insert_post($post); |
|
113 | 113 | |
114 | - if ( $post_id ) { |
|
114 | + if ($post_id) { |
|
115 | 115 | $wpdb->update( |
116 | 116 | $config_table, |
117 | 117 | array( |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | // Meta |
128 | 128 | // We ignore (@) all notice of not existing properties |
129 | - $config_meta = json_decode( $config->meta ); |
|
129 | + $config_meta = json_decode($config->meta); |
|
130 | 130 | |
131 | 131 | $meta = array(); |
132 | 132 | |
@@ -147,18 +147,18 @@ discard block |
||
147 | 147 | $meta['ideal_private_certificate'] = $config->private_certificate; |
148 | 148 | |
149 | 149 | // OmniKassa |
150 | - if ( 'rabobank-omnikassa' === $config->variant_id ) { |
|
150 | + if ('rabobank-omnikassa' === $config->variant_id) { |
|
151 | 151 | $meta['omnikassa_merchant_id'] = $config->merchant_id; |
152 | 152 | $meta['omnikassa_secret_key'] = $config->hash_key; |
153 | 153 | |
154 | 154 | $key_version = @$config_meta->keyVersion; |
155 | 155 | // In Pronamic iDEAL v1.0 we stored the key version in the iDEAL sub ID |
156 | - $key_version = empty( $key_version ) ? $config->sub_id : $key_version; |
|
156 | + $key_version = empty($key_version) ? $config->sub_id : $key_version; |
|
157 | 157 | |
158 | 158 | $meta['omnikassa_key_version'] = $key_version; |
159 | 159 | |
160 | - unset( $meta['ideal_merchant_id'] ); |
|
161 | - unset( $meta['ideal_hash_key'] ); |
|
160 | + unset($meta['ideal_merchant_id']); |
|
161 | + unset($meta['ideal_hash_key']); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Buckaroo |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | $meta['common_name'] = @$config_meta->commonName; |
202 | 202 | $meta['email'] = @$config_meta->eMailAddress; |
203 | 203 | |
204 | - foreach ( $meta as $key => $value ) { |
|
205 | - if ( ! empty( $value ) ) { |
|
204 | + foreach ($meta as $key => $value) { |
|
205 | + if ( ! empty($value)) { |
|
206 | 206 | $meta_key = '_pronamic_gateway_' . $key; |
207 | 207 | |
208 | - update_post_meta( $post_id, $meta_key, $value ); |
|
208 | + update_post_meta($post_id, $meta_key, $value); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | |
227 | 227 | $config_ids_map = array(); |
228 | 228 | |
229 | -$config_ids = $wpdb->get_results( $query ); // WPCS: unprepared SQL ok. |
|
229 | +$config_ids = $wpdb->get_results($query); // WPCS: unprepared SQL ok. |
|
230 | 230 | |
231 | -foreach ( $config_ids as $config_id ) { |
|
232 | - $config_ids_map[ $config_id->id ] = $config_id->post_id; |
|
231 | +foreach ($config_ids as $config_id) { |
|
232 | + $config_ids_map[$config_id->id] = $config_id->post_id; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | KEY configuration_id (configuration_id) |
250 | 250 | ) $charset_collate;"; |
251 | 251 | |
252 | -dbDelta( $sql ); |
|
252 | +dbDelta($sql); |
|
253 | 253 | |
254 | 254 | // Query |
255 | 255 | $query = " |
@@ -266,22 +266,22 @@ discard block |
||
266 | 266 | |
267 | 267 | $have_feeds = true; |
268 | 268 | |
269 | -while ( $have_feeds ) { |
|
270 | - $feeds = $wpdb->get_results( $query ); // WPCS: unprepared SQL ok. |
|
269 | +while ($have_feeds) { |
|
270 | + $feeds = $wpdb->get_results($query); // WPCS: unprepared SQL ok. |
|
271 | 271 | |
272 | - $have_feeds = ! empty( $feeds ); |
|
272 | + $have_feeds = ! empty($feeds); |
|
273 | 273 | |
274 | - foreach ( $feeds as $feed ) { |
|
274 | + foreach ($feeds as $feed) { |
|
275 | 275 | // Post |
276 | 276 | $post = array( |
277 | - 'post_title' => sprintf( __( 'Payment Form %d', 'pronamic_ideal' ), $feed->id ), |
|
277 | + 'post_title' => sprintf(__('Payment Form %d', 'pronamic_ideal'), $feed->id), |
|
278 | 278 | 'post_type' => 'pronamic_pay_gf', |
279 | 279 | 'post_status' => 'publish', |
280 | 280 | ); |
281 | 281 | |
282 | - $post_id = wp_insert_post( $post ); |
|
282 | + $post_id = wp_insert_post($post); |
|
283 | 283 | |
284 | - if ( $post_id ) { |
|
284 | + if ($post_id) { |
|
285 | 285 | $wpdb->update( |
286 | 286 | $feeds_table, |
287 | 287 | array( |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | // We ignore (@) all notice of not existing properties |
299 | 299 | $meta = array(); |
300 | 300 | |
301 | - $feed_meta = json_decode( $feed->meta, true ); |
|
301 | + $feed_meta = json_decode($feed->meta, true); |
|
302 | 302 | |
303 | 303 | $meta['form_id'] = $feed->form_id; |
304 | - $meta['config_id'] = @$config_ids_map[ $feed->configuration_id ]; |
|
304 | + $meta['config_id'] = @$config_ids_map[$feed->configuration_id]; |
|
305 | 305 | $meta['is_active'] = $feed->is_active; |
306 | 306 | $meta['transaction_description'] = @$feed_meta['transactionDescription']; |
307 | 307 | $meta['delay_notification_ids'] = @$feed_meta['delayNotificationIds']; |
@@ -316,19 +316,19 @@ discard block |
||
316 | 316 | $meta['fields'] = @$feed_meta['fields']; |
317 | 317 | $meta['links'] = @$feed_meta['links']; |
318 | 318 | |
319 | - if ( is_array( $meta['links'] ) ) { |
|
320 | - foreach ( $meta['links'] as &$link ) { |
|
321 | - if ( isset( $link['pageId'] ) ) { |
|
319 | + if (is_array($meta['links'])) { |
|
320 | + foreach ($meta['links'] as &$link) { |
|
321 | + if (isset($link['pageId'])) { |
|
322 | 322 | $link['page_id'] = $link['pageId']; |
323 | 323 | } |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | - foreach ( $meta as $key => $value ) { |
|
328 | - if ( ! empty( $value ) ) { |
|
327 | + foreach ($meta as $key => $value) { |
|
328 | + if ( ! empty($value)) { |
|
329 | 329 | $meta_key = '_pronamic_pay_gf_' . $key; |
330 | 330 | |
331 | - update_post_meta( $post_id, $meta_key, $value ); |
|
331 | + update_post_meta($post_id, $meta_key, $value); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | PRIMARY KEY (id) |
367 | 367 | ) $charset_collate;"; |
368 | 368 | |
369 | -dbDelta( $sql ); |
|
369 | +dbDelta($sql); |
|
370 | 370 | |
371 | 371 | // We convert the payments in groups of 100 so not everything will load in memory at once. |
372 | 372 | $query = " |
@@ -383,24 +383,24 @@ discard block |
||
383 | 383 | |
384 | 384 | $have_payments = true; |
385 | 385 | |
386 | -while ( $have_payments ) { |
|
387 | - $payments = $wpdb->get_results( $query ); // WPCS: unprepared SQL ok. |
|
386 | +while ($have_payments) { |
|
387 | + $payments = $wpdb->get_results($query); // WPCS: unprepared SQL ok. |
|
388 | 388 | |
389 | - $have_payments = ! empty( $payments ); |
|
389 | + $have_payments = ! empty($payments); |
|
390 | 390 | |
391 | - foreach ( $payments as $payment ) { |
|
391 | + foreach ($payments as $payment) { |
|
392 | 392 | // Post |
393 | 393 | $post = array( |
394 | - 'post_title' => sprintf( __( 'Payment %d', 'pronamic_ideal' ), $payment->id ), |
|
395 | - 'post_date' => get_date_from_gmt( $payment->date_gmt ), |
|
394 | + 'post_title' => sprintf(__('Payment %d', 'pronamic_ideal'), $payment->id), |
|
395 | + 'post_date' => get_date_from_gmt($payment->date_gmt), |
|
396 | 396 | 'post_date_gmt' => $payment->date_gmt, |
397 | 397 | 'post_type' => 'pronamic_payment', |
398 | 398 | 'post_status' => 'publish', |
399 | 399 | ); |
400 | 400 | |
401 | - $post_id = wp_insert_post( $post ); |
|
401 | + $post_id = wp_insert_post($post); |
|
402 | 402 | |
403 | - if ( $post_id ) { |
|
403 | + if ($post_id) { |
|
404 | 404 | $wpdb->update( |
405 | 405 | $payments_table, |
406 | 406 | array( |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | |
416 | 416 | // Meta |
417 | 417 | $meta = array( |
418 | - 'config_id' => @$config_ids_map[ $payment->configuration_id ], |
|
418 | + 'config_id' => @$config_ids_map[$payment->configuration_id], |
|
419 | 419 | 'purchase_id' => $payment->purchase_id, |
420 | 420 | 'transaction_id' => $payment->transaction_id, |
421 | 421 | 'currency' => $payment->currency, |
@@ -435,11 +435,11 @@ discard block |
||
435 | 435 | 'email' => $payment->email, |
436 | 436 | ); |
437 | 437 | |
438 | - foreach ( $meta as $key => $value ) { |
|
439 | - if ( ! empty( $value ) ) { |
|
438 | + foreach ($meta as $key => $value) { |
|
439 | + if ( ! empty($value)) { |
|
440 | 440 | $meta_key = '_pronamic_payment_' . $key; |
441 | 441 | |
442 | - update_post_meta( $post_id, $meta_key, $value ); |
|
442 | + update_post_meta($post_id, $meta_key, $value); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | } |
@@ -470,13 +470,13 @@ discard block |
||
470 | 470 | 'pronamic_ideal_wpsc_configuration_id' => 'pronamic_pay_ideal_wpsc_config_id', |
471 | 471 | ); |
472 | 472 | |
473 | -foreach ( $options as $key_old => $key_new ) { |
|
474 | - $value = get_option( $key_old ); |
|
473 | +foreach ($options as $key_old => $key_new) { |
|
474 | + $value = get_option($key_old); |
|
475 | 475 | |
476 | - if ( ! empty( $value ) ) { |
|
477 | - $value_new = @$config_ids_map[ $value ]; |
|
476 | + if ( ! empty($value)) { |
|
477 | + $value_new = @$config_ids_map[$value]; |
|
478 | 478 | |
479 | - update_option( $key_new, $value_new ); |
|
479 | + update_option($key_new, $value_new); |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
@@ -489,23 +489,23 @@ discard block |
||
489 | 489 | $shopp_meta_table = $wpdb->prefix . 'shopp_meta'; |
490 | 490 | |
491 | 491 | // @see http://cube3x.com/2013/04/how-to-check-if-table-exists-in-wordpress-database/ |
492 | -if ( $shopp_meta_table === $wpdb->get_var( "SHOW TABLES LIKE '$shopp_meta_table';" ) ) { // WPCS: unprepared SQL ok. |
|
492 | +if ($shopp_meta_table === $wpdb->get_var("SHOW TABLES LIKE '$shopp_meta_table';")) { // WPCS: unprepared SQL ok. |
|
493 | 493 | $query = "SELECT id, value FROM $shopp_meta_table WHERE type = 'setting' AND name = 'Pronamic_Shopp_IDeal_GatewayModule';"; |
494 | 494 | |
495 | - $row = $wpdb->get_row( $query ); // WPCS: unprepared SQL ok. |
|
495 | + $row = $wpdb->get_row($query); // WPCS: unprepared SQL ok. |
|
496 | 496 | |
497 | - if ( $row ) { |
|
498 | - $settings = maybe_unserialize( $row->value ); |
|
497 | + if ($row) { |
|
498 | + $settings = maybe_unserialize($row->value); |
|
499 | 499 | |
500 | - if ( is_array( $settings ) && isset( $settings['pronamic_shopp_ideal_configuration'] ) ) { |
|
500 | + if (is_array($settings) && isset($settings['pronamic_shopp_ideal_configuration'])) { |
|
501 | 501 | $value = $settings['pronamic_shopp_ideal_configuration']; |
502 | 502 | |
503 | - $settings['config_id'] = @$config_ids_map[ $value ]; |
|
503 | + $settings['config_id'] = @$config_ids_map[$value]; |
|
504 | 504 | |
505 | 505 | $wpdb->update( |
506 | 506 | $shopp_meta_table, |
507 | 507 | array( |
508 | - 'value' => serialize( $settings ), |
|
508 | + 'value' => serialize($settings), |
|
509 | 509 | ), |
510 | 510 | array( |
511 | 511 | 'id' => $row->id, |
@@ -517,16 +517,16 @@ discard block |
||
517 | 517 | |
518 | 518 | // WooCommerce |
519 | 519 | // @see https://github.com/pronamic/wp-pronamic-ideal/blob/1.3.4/classes/Pronamic/WooCommerce/IDeal/IDealGateway.php#L42 |
520 | -$settings = get_option( 'woocommerce_pronamic_ideal_settings' ); |
|
520 | +$settings = get_option('woocommerce_pronamic_ideal_settings'); |
|
521 | 521 | |
522 | -if ( is_array( $settings ) && isset( $settings['configuration_id'] ) ) { |
|
522 | +if (is_array($settings) && isset($settings['configuration_id'])) { |
|
523 | 523 | $value = $settings['configuration_id']; |
524 | 524 | |
525 | - $settings['config_id'] = @$config_ids_map[ $value ]; |
|
525 | + $settings['config_id'] = @$config_ids_map[$value]; |
|
526 | 526 | |
527 | - unset( $settings['configuration_id'] ); |
|
527 | + unset($settings['configuration_id']); |
|
528 | 528 | |
529 | - update_option( 'woocommerce_pronamic_pay_ideal_settings', $settings ); |
|
529 | + update_option('woocommerce_pronamic_pay_ideal_settings', $settings); |
|
530 | 530 | } |
531 | 531 | |
532 | -delete_transient( 'pronamic_pay_upgrade_200' ); |
|
532 | +delete_transient('pronamic_pay_upgrade_200'); |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * @param int $post_id A payment post ID. |
18 | 18 | * @return Payment |
19 | 19 | */ |
20 | -function get_pronamic_payment( $post_id ) { |
|
21 | - $payment = new Payment( $post_id ); |
|
20 | +function get_pronamic_payment($post_id) { |
|
21 | + $payment = new Payment($post_id); |
|
22 | 22 | |
23 | 23 | return $payment; |
24 | 24 | } |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | * @param string $meta_value The Meta value to query for. |
31 | 31 | * @return Payment |
32 | 32 | */ |
33 | -function get_pronamic_payment_by_meta( $meta_key, $meta_value ) { |
|
33 | +function get_pronamic_payment_by_meta($meta_key, $meta_value) { |
|
34 | 34 | global $wpdb; |
35 | 35 | |
36 | 36 | $payment = null; |
37 | 37 | |
38 | - $db_query = $wpdb->prepare( " |
|
38 | + $db_query = $wpdb->prepare(" |
|
39 | 39 | SELECT |
40 | 40 | post_id |
41 | 41 | FROM |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | AND |
46 | 46 | meta_value = %s |
47 | 47 | ; |
48 | - ", $meta_key, $meta_value ); |
|
48 | + ", $meta_key, $meta_value); |
|
49 | 49 | |
50 | - $post_id = $wpdb->get_var( $db_query ); // WPCS: unprepared SQL ok. |
|
50 | + $post_id = $wpdb->get_var($db_query); // WPCS: unprepared SQL ok. |
|
51 | 51 | |
52 | - if ( $post_id ) { |
|
53 | - $payment = new Payment( $post_id ); |
|
52 | + if ($post_id) { |
|
53 | + $payment = new Payment($post_id); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return $payment; |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | * @param string $meta_value The Meta value to query for. |
64 | 64 | * @return array |
65 | 65 | */ |
66 | -function get_pronamic_payments_by_meta( $meta_key, $meta_value ) { |
|
66 | +function get_pronamic_payments_by_meta($meta_key, $meta_value) { |
|
67 | 67 | global $wpdb; |
68 | 68 | |
69 | 69 | $payments = array(); |
70 | 70 | |
71 | - $db_query = $wpdb->prepare( " |
|
71 | + $db_query = $wpdb->prepare(" |
|
72 | 72 | SELECT |
73 | 73 | post_id |
74 | 74 | FROM |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | ORDER BY |
81 | 81 | meta_id ASC |
82 | 82 | ; |
83 | - ", $meta_key, $meta_value ); |
|
83 | + ", $meta_key, $meta_value); |
|
84 | 84 | |
85 | - $results = $wpdb->get_results( $db_query ); // WPCS: unprepared SQL ok. |
|
85 | + $results = $wpdb->get_results($db_query); // WPCS: unprepared SQL ok. |
|
86 | 86 | |
87 | - foreach ( $results as $result ) { |
|
88 | - $payments[] = new Payment( $result->post_id ); |
|
87 | + foreach ($results as $result) { |
|
88 | + $payments[] = new Payment($result->post_id); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $payments; |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @param string $purchase_id The purchase ID to query for. |
98 | 98 | * @return Payment |
99 | 99 | */ |
100 | -function get_pronamic_payment_by_purchase_id( $purchase_id ) { |
|
101 | - return get_pronamic_payment_by_meta( '_pronamic_payment_purchase_id', $purchase_id ); |
|
100 | +function get_pronamic_payment_by_purchase_id($purchase_id) { |
|
101 | + return get_pronamic_payment_by_meta('_pronamic_payment_purchase_id', $purchase_id); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param string $entrance_code The entrance code to query for. |
109 | 109 | * @return Payment |
110 | 110 | */ |
111 | -function get_pronamic_payment_by_transaction_id( $transaction_id, $entrance_code = null ) { |
|
112 | - return get_pronamic_payment_by_meta( '_pronamic_payment_transaction_id', $transaction_id ); |
|
111 | +function get_pronamic_payment_by_transaction_id($transaction_id, $entrance_code = null) { |
|
112 | + return get_pronamic_payment_by_meta('_pronamic_payment_transaction_id', $transaction_id); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * @param int $post_id A subscription post ID. |
119 | 119 | * @return Subscription |
120 | 120 | */ |
121 | -function get_pronamic_subscription( $post_id ) { |
|
122 | - $subscription = new Subscription( $post_id ); |
|
121 | +function get_pronamic_subscription($post_id) { |
|
122 | + $subscription = new Subscription($post_id); |
|
123 | 123 | |
124 | 124 | return $subscription; |
125 | 125 | } |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | * @param string $meta_value The Meta value to query for. |
132 | 132 | * @return Subscription |
133 | 133 | */ |
134 | -function get_pronamic_subscription_by_meta( $meta_key, $meta_value ) { |
|
134 | +function get_pronamic_subscription_by_meta($meta_key, $meta_value) { |
|
135 | 135 | global $wpdb; |
136 | 136 | |
137 | 137 | $subscription = null; |
138 | 138 | |
139 | - $db_query = $wpdb->prepare( " |
|
139 | + $db_query = $wpdb->prepare(" |
|
140 | 140 | SELECT |
141 | 141 | post_id |
142 | 142 | FROM |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | AND |
147 | 147 | meta_value = %s |
148 | 148 | ; |
149 | - ", $meta_key, $meta_value ); |
|
149 | + ", $meta_key, $meta_value); |
|
150 | 150 | |
151 | - $post_id = $wpdb->get_var( $db_query ); // WPCS: unprepared SQL ok. |
|
151 | + $post_id = $wpdb->get_var($db_query); // WPCS: unprepared SQL ok. |
|
152 | 152 | |
153 | - if ( $post_id ) { |
|
154 | - $subscription = new Subscription( $post_id ); |
|
153 | + if ($post_id) { |
|
154 | + $subscription = new Subscription($post_id); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $subscription; |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | |
166 | 166 | global $pronamic_ideal; |
167 | 167 | |
168 | - foreach ( $pronamic_ideal->gateway_integrations as $integration ) { |
|
169 | - if ( isset( $pronamic_pay_providers[ $integration->provider ] ) ) { |
|
170 | - $provider =& $pronamic_pay_providers[ $integration->provider ]; |
|
168 | + foreach ($pronamic_ideal->gateway_integrations as $integration) { |
|
169 | + if (isset($pronamic_pay_providers[$integration->provider])) { |
|
170 | + $provider = & $pronamic_pay_providers[$integration->provider]; |
|
171 | 171 | |
172 | - if ( ! isset( $provider['integrations'] ) ) { |
|
172 | + if ( ! isset($provider['integrations'])) { |
|
173 | 173 | $provider['integrations'] = array(); |
174 | 174 | } |
175 | 175 | |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | * @param string $size A php.ini notation for nubmer to convert to an integer. |
189 | 189 | * @return int |
190 | 190 | */ |
191 | -function pronamic_pay_let_to_num( $size ) { |
|
192 | - $l = substr( $size, -1 ); |
|
193 | - $ret = substr( $size, 0, -1 ); |
|
191 | +function pronamic_pay_let_to_num($size) { |
|
192 | + $l = substr($size, -1); |
|
193 | + $ret = substr($size, 0, -1); |
|
194 | 194 | |
195 | - switch ( strtoupper( $l ) ) { |
|
195 | + switch (strtoupper($l)) { |
|
196 | 196 | case 'P': |
197 | 197 | $ret *= 1024; |
198 | 198 | // no break. |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | global $wp_locale; |
223 | 223 | |
224 | 224 | // Seperator. |
225 | - $separator = get_option( 'pronamic_pay_thousands_sep' ); |
|
225 | + $separator = get_option('pronamic_pay_thousands_sep'); |
|
226 | 226 | |
227 | 227 | // WordPress. |
228 | - if ( false === $separator ) { |
|
228 | + if (false === $separator) { |
|
229 | 229 | // WordPress locale number format was introduced in WordPress version 2.3. |
230 | 230 | // @see https://github.com/WordPress/WordPress/blob/2.3/wp-includes/locale.php#L90-L100. |
231 | 231 | $separator = $wp_locale->number_format['thousands_sep']; |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | global $wp_locale; |
244 | 244 | |
245 | 245 | // Seperator. |
246 | - $separator = get_option( 'pronamic_pay_decimal_sep' ); |
|
246 | + $separator = get_option('pronamic_pay_decimal_sep'); |
|
247 | 247 | |
248 | 248 | // WordPress. |
249 | - if ( false === $separator ) { |
|
249 | + if (false === $separator) { |
|
250 | 250 | // WordPress locale number format was introduced in WordPress version 2.3. |
251 | 251 | // @see https://github.com/WordPress/WordPress/blob/2.3/wp-includes/locale.php#L90-L100. |
252 | 252 | $separator = $wp_locale->number_format['decimal_point']; |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * @param string $page Pronamic Pay page identifier slug. |
264 | 264 | * @return int |
265 | 265 | */ |
266 | -function pronamic_pay_get_page_id( $page ) { |
|
267 | - $option = sprintf( 'pronamic_pay_%s_page_id', $page ); |
|
266 | +function pronamic_pay_get_page_id($page) { |
|
267 | + $option = sprintf('pronamic_pay_%s_page_id', $page); |
|
268 | 268 | |
269 | - return get_option( $option, -1 ); |
|
269 | + return get_option($option, -1); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -276,20 +276,20 @@ discard block |
||
276 | 276 | * @param int $post_id The post ID to update the specified meta data for. |
277 | 277 | * @param array $data The data array with meta keys/values. |
278 | 278 | */ |
279 | -function pronamic_pay_update_post_meta_data( $post_id, array $data ) { |
|
279 | +function pronamic_pay_update_post_meta_data($post_id, array $data) { |
|
280 | 280 | /* |
281 | 281 | * Post meta values are passed through the stripslashes() function |
282 | 282 | * upon being stored, so you will need to be careful when passing |
283 | 283 | * in values such as JSON that might include \ escaped characters. |
284 | 284 | */ |
285 | - $data = wp_slash( $data ); |
|
285 | + $data = wp_slash($data); |
|
286 | 286 | |
287 | 287 | // Meta. |
288 | - foreach ( $data as $key => $value ) { |
|
289 | - if ( isset( $value ) && '' !== $value ) { |
|
290 | - update_post_meta( $post_id, $key, $value ); |
|
288 | + foreach ($data as $key => $value) { |
|
289 | + if (isset($value) && '' !== $value) { |
|
290 | + update_post_meta($post_id, $key, $value); |
|
291 | 291 | } else { |
292 | - delete_post_meta( $post_id, $key ); |
|
292 | + delete_post_meta($post_id, $key); |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 | } |