@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | class OneLogin_Saml2_Metadata |
9 | 9 | { |
10 | - const TIME_VALID = 172800; // 2 days |
|
10 | + const TIME_VALID = 172800; // 2 days |
|
11 | 11 | const TIME_CACHED = 604800; // 1 week |
12 | 12 | |
13 | 13 | /** |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | { |
28 | 28 | |
29 | 29 | if (!isset($validUntil)) { |
30 | - $validUntil = time() + self::TIME_VALID; |
|
30 | + $validUntil = time() + self::TIME_VALID; |
|
31 | 31 | } |
32 | - $validUntilTime = gmdate('Y-m-d\TH:i:s\Z', $validUntil); |
|
32 | + $validUntilTime = gmdate('Y-m-d\TH:i:s\Z', $validUntil); |
|
33 | 33 | |
34 | 34 | if (!isset($cacheDuration)) { |
35 | 35 | $cacheDuration = self::TIME_CACHED; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $attrCsDesc = ''; |
104 | 104 | if (isset($sp['attributeConsumingService']['serviceDescription'])) { |
105 | 105 | $attrCsDesc = sprintf( |
106 | - ' <md:ServiceDescription xml:lang="en">%s</md:ServiceDescription>' . PHP_EOL, |
|
106 | + ' <md:ServiceDescription xml:lang="en">%s</md:ServiceDescription>'.PHP_EOL, |
|
107 | 107 | $sp['attributeConsumingService']['serviceDescription'] |
108 | 108 | ); |
109 | 109 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $attribute['attributeValue'] = array($attribute['attributeValue']); |
131 | 131 | } |
132 | 132 | foreach ($attribute['attributeValue'] as $attrValue) { |
133 | - $reqAttrAuxStr .=<<<ATTRIBUTEVALUE |
|
133 | + $reqAttrAuxStr .= <<<ATTRIBUTEVALUE |
|
134 | 134 | |
135 | 135 | <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">{$attrValue}</saml:AttributeValue> |
136 | 136 | ATTRIBUTEVALUE; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $reqAttrAuxStr .= "\n </md:RequestedAttribute>"; |
139 | 139 | } |
140 | 140 | |
141 | - $requestedAttributeData[] = $requestedAttributeStr . $reqAttrAuxStr; |
|
141 | + $requestedAttributeData[] = $requestedAttributeStr.$reqAttrAuxStr; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | $requestedAttributeStr = implode(PHP_EOL, $requestedAttributeData); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | if (!$xml) { |
207 | 207 | throw new Exception('Error parsing metadata'); |
208 | 208 | } |
209 | - } catch (Exception $e) { |
|
209 | + }catch (Exception $e) { |
|
210 | 210 | throw new Exception('Error parsing metadata. '.$e->getMessage()); |
211 | 211 | } |
212 | 212 |
@@ -376,7 +376,7 @@ |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | return true; |
379 | - } catch (Exception $e) { |
|
379 | + }catch (Exception $e) { |
|
380 | 380 | $this->_error = $e->getMessage(); |
381 | 381 | $debug = $this->_settings->isDebugActive(); |
382 | 382 | if ($debug) { |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | } |
399 | 399 | } |
400 | 400 | return true; |
401 | - } catch (Exception $e) { |
|
401 | + }catch (Exception $e) { |
|
402 | 402 | $this->_error = $e->getMessage(); |
403 | 403 | $debug = $this->_settings->isDebugActive(); |
404 | 404 | if ($debug) { |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | |
737 | 737 | $attributeValues = array(); |
738 | 738 | foreach ($entry->childNodes as $childNode) { |
739 | - $tagName = ($childNode->prefix ? $childNode->prefix.':' : '') . 'AttributeValue'; |
|
739 | + $tagName = ($childNode->prefix ? $childNode->prefix.':' : '').'AttributeValue'; |
|
740 | 740 | if ($childNode->nodeType == XML_ELEMENT_NODE && $childNode->tagName === $tagName) { |
741 | 741 | $attributeValues[] = $childNode->nodeValue; |
742 | 742 | } |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | $xpath->registerNamespace('xenc', OneLogin_Saml2_Constants::NS_XENC); |
962 | 962 | |
963 | 963 | $assertionNode = '/samlp:Response/saml:Assertion'; |
964 | - $signatureQuery = $assertionNode . '/ds:Signature/ds:SignedInfo/ds:Reference'; |
|
964 | + $signatureQuery = $assertionNode.'/ds:Signature/ds:SignedInfo/ds:Reference'; |
|
965 | 965 | $assertionReferenceNode = $xpath->query($signatureQuery)->item(0); |
966 | 966 | if (!$assertionReferenceNode) { |
967 | 967 | // is the response signed as a whole? |
@@ -974,9 +974,9 @@ discard block |
||
974 | 974 | } else { |
975 | 975 | $id = substr($responseReferenceNode->attributes->getNamedItem('URI')->nodeValue, 1); |
976 | 976 | } |
977 | - $nameQuery = "/samlp:Response[@ID='$id']/saml:Assertion" . $assertionXpath; |
|
977 | + $nameQuery = "/samlp:Response[@ID='$id']/saml:Assertion".$assertionXpath; |
|
978 | 978 | } else { |
979 | - $nameQuery = "/samlp:Response/saml:Assertion" . $assertionXpath; |
|
979 | + $nameQuery = "/samlp:Response/saml:Assertion".$assertionXpath; |
|
980 | 980 | } |
981 | 981 | } else { |
982 | 982 | $uri = $assertionReferenceNode->attributes->getNamedItem('URI')->nodeValue; |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | } else { |
986 | 986 | $id = substr($assertionReferenceNode->attributes->getNamedItem('URI')->nodeValue, 1); |
987 | 987 | } |
988 | - $nameQuery = $assertionNode."[@ID='$id']" . $assertionXpath; |
|
988 | + $nameQuery = $assertionNode."[@ID='$id']".$assertionXpath; |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | return $xpath->query($nameQuery); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function setStrict($value) |
157 | 157 | { |
158 | - if (! (is_bool($value))) { |
|
158 | + if (!(is_bool($value))) { |
|
159 | 159 | throw new OneLogin_Saml2_Error( |
160 | 160 | 'Invalid value passed to setStrict()', |
161 | 161 | OneLogin_Saml2_Error::SETTINGS_INVALID_SYNTAX |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | $security = $this->_settings->getSecurityData(); |
271 | 271 | if (isset($security['logoutResponseSigned']) && $security['logoutResponseSigned']) { |
272 | - $signature = $this->buildResponseSignature($logoutResponse, isset($parameters['RelayState'])? $parameters['RelayState']: null, $security['signatureAlgorithm']); |
|
272 | + $signature = $this->buildResponseSignature($logoutResponse, isset($parameters['RelayState']) ? $parameters['RelayState'] : null, $security['signatureAlgorithm']); |
|
273 | 273 | $parameters['SigAlg'] = $security['signatureAlgorithm']; |
274 | 274 | $parameters['Signature'] = $signature; |
275 | 275 | } |
@@ -579,13 +579,13 @@ discard block |
||
579 | 579 | if (isset($relayState)) { |
580 | 580 | $msg .= '&RelayState='.rawurlencode($relayState); |
581 | 581 | } |
582 | - $msg .= '&SigAlg=' . rawurlencode($signAlgorithm); |
|
582 | + $msg .= '&SigAlg='.rawurlencode($signAlgorithm); |
|
583 | 583 | } else { |
584 | 584 | $msg = 'SAMLRequest='.urlencode($samlRequest); |
585 | 585 | if (isset($relayState)) { |
586 | 586 | $msg .= '&RelayState='.urlencode($relayState); |
587 | 587 | } |
588 | - $msg .= '&SigAlg=' . urlencode($signAlgorithm); |
|
588 | + $msg .= '&SigAlg='.urlencode($signAlgorithm); |
|
589 | 589 | } |
590 | 590 | $signature = $objKey->signData($msg); |
591 | 591 | return base64_encode($signature); |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | if (isset($relayState)) { |
623 | 623 | $msg .= '&RelayState='.rawurlencode($relayState); |
624 | 624 | } |
625 | - $msg .= '&SigAlg=' . rawurlencode($signAlgorithm); |
|
625 | + $msg .= '&SigAlg='.rawurlencode($signAlgorithm); |
|
626 | 626 | } else { |
627 | 627 | $msg = 'SAMLResponse='.urlencode($samlResponse); |
628 | 628 | if (isset($relayState)) { |
629 | 629 | $msg .= '&RelayState='.urlencode($relayState); |
630 | 630 | } |
631 | - $msg .= '&SigAlg=' . urlencode($signAlgorithm); |
|
631 | + $msg .= '&SigAlg='.urlencode($signAlgorithm); |
|
632 | 632 | } |
633 | 633 | $signature = $objKey->signData($msg); |
634 | 634 | return base64_encode($signature); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } else { |
38 | 38 | throw new Exception(curl_error($ch), curl_errno($ch)); |
39 | 39 | } |
40 | - } catch (Exception $e) { |
|
40 | + }catch (Exception $e) { |
|
41 | 41 | } |
42 | 42 | return $metadataInfo; |
43 | 43 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $data = file_get_contents($filepath); |
64 | 64 | $metadataInfo = self::parseXML($data, $entityId); |
65 | 65 | } |
66 | - } catch (Exception $e) { |
|
66 | + }catch (Exception $e) { |
|
67 | 67 | } |
68 | 68 | return $metadataInfo; |
69 | 69 | } |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | |
96 | 96 | $customIdPStr = ''; |
97 | 97 | if (!empty($entityId)) { |
98 | - $customIdPStr = '[@entityID="' . $entityId . '"]'; |
|
98 | + $customIdPStr = '[@entityID="'.$entityId.'"]'; |
|
99 | 99 | } |
100 | - $idpDescryptorXPath = '//md:EntityDescriptor' . $customIdPStr . '/md:IDPSSODescriptor'; |
|
100 | + $idpDescryptorXPath = '//md:EntityDescriptor'.$customIdPStr.'/md:IDPSSODescriptor'; |
|
101 | 101 | |
102 | 102 | $idpDescriptorNodes = OneLogin_Saml2_Utils::query($dom, $idpDescryptorXPath); |
103 | 103 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
182 | - } catch (Exception $e) { |
|
182 | + }catch (Exception $e) { |
|
183 | 183 | throw new Exception('Error parsing metadata. '.$e->getMessage()); |
184 | 184 | } |
185 | 185 |
@@ -184,7 +184,7 @@ |
||
184 | 184 | } |
185 | 185 | } |
186 | 186 | return true; |
187 | - } catch (Exception $e) { |
|
187 | + }catch (Exception $e) { |
|
188 | 188 | $this->_error = $e->getMessage(); |
189 | 189 | $debug = $this->_settings->isDebugActive(); |
190 | 190 | if ($debug) { |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | - $schemaFile = dirname(__FILE__).'/schemas/' . $schema; |
|
127 | + $schemaFile = dirname(__FILE__).'/schemas/'.$schema; |
|
128 | 128 | $oldEntityLoader = libxml_disable_entity_loader(false); |
129 | 129 | $res = $dom->schemaValidate($schemaFile); |
130 | 130 | libxml_disable_entity_loader($oldEntityLoader); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public static function getStringBetween($str, $start, $end) |
222 | 222 | { |
223 | - $str = ' ' . $str; |
|
223 | + $str = ' '.$str; |
|
224 | 224 | $ini = strpos($str, $start); |
225 | 225 | |
226 | 226 | if ($ini == 0) { |
@@ -249,13 +249,13 @@ discard block |
||
249 | 249 | assert('is_array($parameters)'); |
250 | 250 | |
251 | 251 | if (substr($url, 0, 1) === '/') { |
252 | - $url = self::getSelfURLhost() . $url; |
|
252 | + $url = self::getSelfURLhost().$url; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /* Verify that the URL is to a http or https site. */ |
256 | 256 | if (!preg_match('@^https?:\/\/@i', $url)) { |
257 | 257 | throw new OneLogin_Saml2_Error( |
258 | - 'Redirect to invalid URL: ' . $url, |
|
258 | + 'Redirect to invalid URL: '.$url, |
|
259 | 259 | OneLogin_Saml2_Error::REDIRECT_INVALID_URL |
260 | 260 | ); |
261 | 261 | } |
@@ -274,17 +274,17 @@ discard block |
||
274 | 274 | } else if (is_array($value)) { |
275 | 275 | $param = ""; |
276 | 276 | foreach ($value as $val) { |
277 | - $param .= urlencode($name) . "[]=" . urlencode($val). '&'; |
|
277 | + $param .= urlencode($name)."[]=".urlencode($val).'&'; |
|
278 | 278 | } |
279 | 279 | if (!empty($param)) { |
280 | 280 | $param = substr($param, 0, -1); |
281 | 281 | } |
282 | 282 | } else { |
283 | - $param = urlencode($name) . '=' . urlencode($value); |
|
283 | + $param = urlencode($name).'='.urlencode($value); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | if (!empty($param)) { |
287 | - $url .= $paramPrefix . $param; |
|
287 | + $url .= $paramPrefix.$param; |
|
288 | 288 | $paramPrefix = '&'; |
289 | 289 | } |
290 | 290 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | header('Pragma: no-cache'); |
297 | 297 | header('Cache-Control: no-cache, must-revalidate'); |
298 | - header('Location: ' . $url); |
|
298 | + header('Location: '.$url); |
|
299 | 299 | exit(); |
300 | 300 | } |
301 | 301 | |
@@ -376,10 +376,10 @@ discard block |
||
376 | 376 | $portnumber = self::getSelfPort(); |
377 | 377 | |
378 | 378 | if (isset($portnumber) && ($portnumber != '80') && ($portnumber != '443')) { |
379 | - $port = ':' . $portnumber; |
|
379 | + $port = ':'.$portnumber; |
|
380 | 380 | } |
381 | 381 | |
382 | - return $protocol."://" . $currenthost . $port; |
|
382 | + return $protocol."://".$currenthost.$port; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | } else if ($baseurlpath == '/') { |
401 | 401 | self::$_baseurlpath = '/'; |
402 | 402 | } else { |
403 | - self::$_baseurlpath = '/' . trim($baseurlpath, '/') . '/'; |
|
403 | + self::$_baseurlpath = '/'.trim($baseurlpath, '/').'/'; |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | $route = $infoWithBaseURLPath; |
571 | 571 | } |
572 | 572 | |
573 | - $selfRoutedURLNoQuery = $selfURLhost . $route; |
|
573 | + $selfRoutedURLNoQuery = $selfURLhost.$route; |
|
574 | 574 | return $selfRoutedURLNoQuery; |
575 | 575 | } |
576 | 576 | |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | $requestURI = $infoWithBaseURLPath; |
599 | 599 | } |
600 | 600 | |
601 | - return $selfURLhost . $requestURI; |
|
601 | + return $selfURLhost.$requestURI; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | /** |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | */ |
646 | 646 | public static function generateUniqueID() |
647 | 647 | { |
648 | - return 'ONELOGIN_' . sha1(uniqid(mt_rand(), true)); |
|
648 | + return 'ONELOGIN_'.sha1(uniqid(mt_rand(), true)); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -682,10 +682,10 @@ discard block |
||
682 | 682 | /* We use a very strict regex to parse the timestamp. */ |
683 | 683 | $exp1 = '/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)'; |
684 | 684 | $exp2 = 'T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.\\d+)?Z$/D'; |
685 | - if (preg_match($exp1 . $exp2, $time, $matches) == 0) { |
|
685 | + if (preg_match($exp1.$exp2, $time, $matches) == 0) { |
|
686 | 686 | throw new Exception( |
687 | - 'Invalid SAML2 timestamp passed to' . |
|
688 | - ' parseSAML2Time: ' . $time |
|
687 | + 'Invalid SAML2 timestamp passed to'. |
|
688 | + ' parseSAML2Time: '.$time |
|
689 | 689 | ); |
690 | 690 | } |
691 | 691 | |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | /* Parse the duration. We use a very strict pattern. */ |
730 | 730 | $durationRegEx = '#^(-?)P(?:(?:(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?)|(?:(\\d+)W))$#D'; |
731 | 731 | if (!preg_match($durationRegEx, $duration, $matches)) { |
732 | - throw new Exception('Invalid ISO 8601 duration: ' . $duration); |
|
732 | + throw new Exception('Invalid ISO 8601 duration: '.$duration); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | $durYears = (empty($matches[2]) ? 0 : (int)$matches[2]); |
@@ -1091,9 +1091,9 @@ discard block |
||
1091 | 1091 | |
1092 | 1092 | if ($inputKeyAlgo !== $symKeyInfoAlgo) { |
1093 | 1093 | throw new OneLogin_Saml2_ValidationError( |
1094 | - 'Algorithm mismatch between input key and key used to encrypt ' . |
|
1095 | - ' the symmetric key for the message. Key was: ' . |
|
1096 | - var_export($inputKeyAlgo, true) . '; message was: ' . |
|
1094 | + 'Algorithm mismatch between input key and key used to encrypt '. |
|
1095 | + ' the symmetric key for the message. Key was: '. |
|
1096 | + var_export($inputKeyAlgo, true).'; message was: '. |
|
1097 | 1097 | var_export($symKeyInfoAlgo, true), |
1098 | 1098 | OneLogin_Saml2_ValidationError::KEY_ALGORITHM_ERROR |
1099 | 1099 | ); |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | if ($keySize === null) { |
1106 | 1106 | // To protect against "key oracle" attacks |
1107 | 1107 | throw new OneLogin_Saml2_ValidationError( |
1108 | - 'Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, true), |
|
1108 | + 'Unknown key size for encryption algorithm: '.var_export($symmetricKey->type, true), |
|
1109 | 1109 | OneLogin_Saml2_ValidationError::KEY_ALGORITHM_ERROR |
1110 | 1110 | ); |
1111 | 1111 | } |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | $encryptedKey = $encKey->getCipherValue(); |
1116 | 1116 | $pkey = openssl_pkey_get_details($symmetricKeyInfo->key); |
1117 | 1117 | $pkey = sha1(serialize($pkey), true); |
1118 | - $key = sha1($encryptedKey . $pkey, true); |
|
1118 | + $key = sha1($encryptedKey.$pkey, true); |
|
1119 | 1119 | |
1120 | 1120 | /* Make sure that the key has the correct length. */ |
1121 | 1121 | if (strlen($key) > $keySize) { |
@@ -1129,8 +1129,8 @@ discard block |
||
1129 | 1129 | $symKeyAlgo = $symmetricKey->getAlgorithm(); |
1130 | 1130 | if ($inputKeyAlgo !== $symKeyAlgo) { |
1131 | 1131 | throw new OneLogin_Saml2_ValidationError( |
1132 | - 'Algorithm mismatch between input key and key in message. ' . |
|
1133 | - 'Key was: ' . var_export($inputKeyAlgo, true) . '; message was: ' . |
|
1132 | + 'Algorithm mismatch between input key and key in message. '. |
|
1133 | + 'Key was: '.var_export($inputKeyAlgo, true).'; message was: '. |
|
1134 | 1134 | var_export($symKeyAlgo, true), |
1135 | 1135 | OneLogin_Saml2_ValidationError::KEY_ALGORITHM_ERROR |
1136 | 1136 | ); |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | $objXMLSecDSig->add509Cert($cert, true); |
1244 | 1244 | |
1245 | 1245 | $insertBefore = $rootNode->firstChild; |
1246 | - $messageTypes = array('AuthnRequest', 'Response', 'LogoutRequest','LogoutResponse'); |
|
1246 | + $messageTypes = array('AuthnRequest', 'Response', 'LogoutRequest', 'LogoutResponse'); |
|
1247 | 1247 | if (in_array($rootNode->localName, $messageTypes)) { |
1248 | 1248 | $issuerNodes = self::query($dom, '/'.$rootNode->tagName.'/saml:Issuer'); |
1249 | 1249 | if ($issuerNodes->length == 1) { |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | |
1310 | 1310 | try { |
1311 | 1311 | $retVal = $objXMLSecDSig->validateReference(); |
1312 | - } catch (Exception $e) { |
|
1312 | + }catch (Exception $e) { |
|
1313 | 1313 | throw $e; |
1314 | 1314 | } |
1315 | 1315 | |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | if ($signAlg != XMLSecurityKey::RSA_SHA1) { |
1402 | 1402 | try { |
1403 | 1403 | $objKey = OneLogin_Saml2_Utils::castKey($objKey, $signAlg, 'public'); |
1404 | - } catch (Exception $e) { |
|
1404 | + }catch (Exception $e) { |
|
1405 | 1405 | $ex = new OneLogin_Saml2_ValidationError( |
1406 | 1406 | "Invalid signAlg in the recieved ".$strMessageType, |
1407 | 1407 | OneLogin_Saml2_ValidationError::INVALID_SIGNATURE |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $mod_strings = return_module_language($sugar_config['default_language'], 'Leads'); |
49 | 49 | |
50 | -$app_list_strings['record_type_module'] = array('Contact'=>'Contacts', 'Account'=>'Accounts', 'Opportunity'=>'Opportunities', 'Case'=>'Cases', 'Note'=>'Notes', 'Call'=>'Calls', 'Email'=>'Emails', 'Meeting'=>'Meetings', 'Task'=>'Tasks', 'Lead'=>'Leads','Bug'=>'Bugs', |
|
50 | +$app_list_strings['record_type_module'] = array('Contact'=>'Contacts', 'Account'=>'Accounts', 'Opportunity'=>'Opportunities', 'Case'=>'Cases', 'Note'=>'Notes', 'Call'=>'Calls', 'Email'=>'Emails', 'Meeting'=>'Meetings', 'Task'=>'Tasks', 'Lead'=>'Leads', 'Bug'=>'Bugs', |
|
51 | 51 | |
52 | 52 | ); |
53 | 53 | |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | if (isset($_POST['campaign_id']) && !empty($_POST['campaign_id'])) { |
62 | 62 | //adding the client ip address |
63 | 63 | $_POST['client_id_address'] = query_client_ip(); |
64 | - $campaign_id=$_POST['campaign_id']; |
|
64 | + $campaign_id = $_POST['campaign_id']; |
|
65 | 65 | $campaign = new Campaign(); |
66 | 66 | $campaign_id = $campaign->db->quote($_POST['campaign_id']); |
67 | - if(!isValidId($campaign_id)) { |
|
67 | + if (!isValidId($campaign_id)) { |
|
68 | 68 | throw new RuntimeException('Invalid ID requested in Lead Capture'); |
69 | 69 | } |
70 | 70 | $camp_query = "select name,id from campaigns where id='$campaign_id'"; |
71 | 71 | $camp_query .= " and deleted=0"; |
72 | - $camp_result=$campaign->db->query($camp_query); |
|
72 | + $camp_result = $campaign->db->query($camp_query); |
|
73 | 73 | $camp_data = $campaign->db->fetchByAssoc($camp_result); |
74 | 74 | // Bug 41292 - have to select marketing_id for new lead |
75 | 75 | $db = DBManagerFactory::getInstance(); |
76 | 76 | $marketing = new EmailMarketing(); |
77 | 77 | $marketing_query = $marketing->create_new_list_query( |
78 | 78 | 'date_start desc, date_modified desc', |
79 | - "campaign_id = '{$campaign_id}' and status = 'active' and date_start < " . $db->convert('', 'today'), |
|
79 | + "campaign_id = '{$campaign_id}' and status = 'active' and date_start < ".$db->convert('', 'today'), |
|
80 | 80 | array('id') |
81 | 81 | ); |
82 | 82 | $marketing_result = $db->limitQuery($marketing_query, 0, 1, true); |
@@ -87,22 +87,22 @@ discard block |
||
87 | 87 | $current_user->retrieve($_REQUEST['assigned_user_id']); |
88 | 88 | } |
89 | 89 | |
90 | - if(isset($camp_data) && $camp_data != null ){ |
|
90 | + if (isset($camp_data) && $camp_data != null) { |
|
91 | 91 | $leadForm = new LeadFormBase(); |
92 | 92 | $lead = new Lead(); |
93 | 93 | $prefix = ''; |
94 | - if(!empty($_POST['prefix'])){ |
|
94 | + if (!empty($_POST['prefix'])) { |
|
95 | 95 | $prefix = $_POST['prefix']; |
96 | 96 | } |
97 | 97 | |
98 | - if(empty($lead->id)) { |
|
98 | + if (empty($lead->id)) { |
|
99 | 99 | $lead->id = create_guid(); |
100 | 100 | $lead->new_with_id = true; |
101 | 101 | } |
102 | 102 | $GLOBALS['check_notify'] = true; |
103 | 103 | |
104 | 104 | //bug: 47574 - make sure, that webtolead_email1 field has same required attribute as email1 field |
105 | - if(isset($lead->required_fields['email1'])){ |
|
105 | + if (isset($lead->required_fields['email1'])) { |
|
106 | 106 | $lead->required_fields['webtolead_email1'] = $lead->required_fields['email1']; |
107 | 107 | } |
108 | 108 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | // checkRequired needs a major overhaul before it works for web to lead forms. |
119 | 119 | $lead = $leadForm->handleSave($prefix, false, false, false, $lead); |
120 | 120 | |
121 | - if(!empty($lead)){ |
|
121 | + if (!empty($lead)) { |
|
122 | 122 | |
123 | 123 | //create campaign log |
124 | 124 | $camplog = new CampaignLog(); |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | $camplog->related_type = $lead->module_dir; |
128 | 128 | $camplog->activity_type = "lead"; |
129 | 129 | $camplog->target_type = $lead->module_dir; |
130 | - $campaign_log->activity_date=$timedate->now(); |
|
131 | - $camplog->target_id = $lead->id; |
|
132 | - if(isset($marketing_data['id'])) |
|
130 | + $campaign_log->activity_date = $timedate->now(); |
|
131 | + $camplog->target_id = $lead->id; |
|
132 | + if (isset($marketing_data['id'])) |
|
133 | 133 | { |
134 | 134 | $camplog->marketing_id = $marketing_data['id']; |
135 | 135 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | $lead->load_relationship('campaigns'); |
161 | 161 | $lead->campaigns->add($camplog->id); |
162 | - if(!empty($GLOBALS['check_notify'])) { |
|
162 | + if (!empty($GLOBALS['check_notify'])) { |
|
163 | 163 | $lead->save($GLOBALS['check_notify']); |
164 | 164 | } |
165 | 165 | else { |
@@ -168,47 +168,47 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | //in case there are forms out there still using email_opt_out |
171 | - if(isset($_POST['webtolead_email_opt_out']) || isset($_POST['email_opt_out'])){ |
|
171 | + if (isset($_POST['webtolead_email_opt_out']) || isset($_POST['email_opt_out'])) { |
|
172 | 172 | |
173 | - if(isset ($lead->email1) && !empty($lead->email1)){ |
|
173 | + if (isset ($lead->email1) && !empty($lead->email1)) { |
|
174 | 174 | $sea = new SugarEmailAddress(); |
175 | - $sea->AddUpdateEmailAddress($lead->email1,0,1); |
|
175 | + $sea->AddUpdateEmailAddress($lead->email1, 0, 1); |
|
176 | 176 | } |
177 | - if(isset ($lead->email2) && !empty($lead->email2)){ |
|
177 | + if (isset ($lead->email2) && !empty($lead->email2)) { |
|
178 | 178 | $sea = new SugarEmailAddress(); |
179 | - $sea->AddUpdateEmailAddress($lead->email2,0,1); |
|
179 | + $sea->AddUpdateEmailAddress($lead->email2, 0, 1); |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | } |
183 | - if(isset($_POST['redirect_url']) && !empty($_POST['redirect_url'])){ |
|
183 | + if (isset($_POST['redirect_url']) && !empty($_POST['redirect_url'])) { |
|
184 | 184 | // Get the redirect url, and make sure the query string is not too long |
185 | 185 | $redirect_url = $_POST['redirect_url']; |
186 | 186 | $query_string = ''; |
187 | 187 | $first_char = '&'; |
188 | - if(strpos($redirect_url, '?') === FALSE){ |
|
188 | + if (strpos($redirect_url, '?') === FALSE) { |
|
189 | 189 | $first_char = '?'; |
190 | 190 | } |
191 | 191 | $first_iteration = true; |
192 | 192 | $get_and_post = array_merge($_GET, $_POST); |
193 | - foreach($get_and_post as $param => $value) { |
|
193 | + foreach ($get_and_post as $param => $value) { |
|
194 | 194 | |
195 | - if($param == 'redirect_url' && $param == 'submit') |
|
195 | + if ($param == 'redirect_url' && $param == 'submit') |
|
196 | 196 | continue; |
197 | 197 | |
198 | - if($first_iteration){ |
|
198 | + if ($first_iteration) { |
|
199 | 199 | $first_iteration = false; |
200 | 200 | $query_string .= $first_char; |
201 | 201 | } |
202 | - else{ |
|
202 | + else { |
|
203 | 203 | $query_string .= "&"; |
204 | 204 | } |
205 | 205 | $query_string .= "{$param}=".urlencode($value); |
206 | 206 | } |
207 | - if(empty($lead)) { |
|
208 | - if($first_iteration){ |
|
207 | + if (empty($lead)) { |
|
208 | + if ($first_iteration) { |
|
209 | 209 | $query_string .= $first_char; |
210 | 210 | } |
211 | - else{ |
|
211 | + else { |
|
212 | 212 | $query_string .= "&"; |
213 | 213 | } |
214 | 214 | $query_string .= "error=1"; |
@@ -219,22 +219,22 @@ discard block |
||
219 | 219 | |
220 | 220 | // Check if the headers have been sent, or if the redirect url is greater than 2083 characters (IE max URL length) |
221 | 221 | // and use a javascript form submission if that is the case. |
222 | - if(headers_sent() || strlen($redirect_url) > 2083){ |
|
223 | - echo '<html ' . get_language_header() . '><head><title>SugarCRM</title></head><body>'; |
|
224 | - echo '<form name="redirect" action="' .$_POST['redirect_url']. '" method="GET">'; |
|
222 | + if (headers_sent() || strlen($redirect_url) > 2083) { |
|
223 | + echo '<html '.get_language_header().'><head><title>SugarCRM</title></head><body>'; |
|
224 | + echo '<form name="redirect" action="'.$_POST['redirect_url'].'" method="GET">'; |
|
225 | 225 | |
226 | - foreach($_POST as $param => $value) { |
|
227 | - if($param != 'redirect_url' ||$param != 'submit') { |
|
226 | + foreach ($_POST as $param => $value) { |
|
227 | + if ($param != 'redirect_url' || $param != 'submit') { |
|
228 | 228 | echo '<input type="hidden" name="'.$param.'" value="'.$value.'">'; |
229 | 229 | } |
230 | 230 | } |
231 | - if(empty($lead)) { |
|
231 | + if (empty($lead)) { |
|
232 | 232 | echo '<input type="hidden" name="error" value="1">'; |
233 | 233 | } |
234 | 234 | echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>'; |
235 | 235 | echo '</body></html>'; |
236 | 236 | } |
237 | - else{ |
|
237 | + else { |
|
238 | 238 | $header_URL = "Location: {$redirect_url}"; |
239 | 239 | |
240 | 240 | SugarApplication::headerRedirect($header_URL); |
@@ -242,26 +242,26 @@ discard block |
||
242 | 242 | die(); |
243 | 243 | } |
244 | 244 | } |
245 | - else{ |
|
245 | + else { |
|
246 | 246 | echo $mod_strings['LBL_THANKS_FOR_SUBMITTING']; |
247 | 247 | } |
248 | 248 | sugar_cleanup(); |
249 | 249 | // die to keep code from running into redirect case below |
250 | 250 | die(); |
251 | 251 | } |
252 | - else{ |
|
252 | + else { |
|
253 | 253 | echo $mod_strings['LBL_SERVER_IS_CURRENTLY_UNAVAILABLE']; |
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | 257 | if (!empty($_POST['redirect'])) { |
258 | - if(headers_sent()){ |
|
259 | - echo '<html ' . get_language_header() . '><head><title>SugarCRM</title></head><body>'; |
|
260 | - echo '<form name="redirect" action="' .$_POST['redirect']. '" method="GET">'; |
|
258 | + if (headers_sent()) { |
|
259 | + echo '<html '.get_language_header().'><head><title>SugarCRM</title></head><body>'; |
|
260 | + echo '<form name="redirect" action="'.$_POST['redirect'].'" method="GET">'; |
|
261 | 261 | echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>'; |
262 | 262 | echo '</body></html>'; |
263 | 263 | } |
264 | - else{ |
|
264 | + else { |
|
265 | 265 | $header_URL = "Location: {$_POST['redirect']}"; |
266 | 266 | SugarApplication::headerRedirect($header_URL); |
267 | 267 | die(); |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $_POST['client_id_address'] = query_client_ip(); |
61 | 61 | $campaign = new Campaign(); |
62 | 62 | $campaign_id = $campaign->db->quote($_POST['campaign_id']); |
63 | - if(!isValidId($campaign_id)) { |
|
63 | + if (!isValidId($campaign_id)) { |
|
64 | 64 | throw new RuntimeException('Invalid ID requested in Person Capture'); |
65 | 65 | } |
66 | 66 | $camp_query = "select name,id from campaigns where id='$campaign_id'"; |