idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
44,500
public function putFile ( $ file , $ contents ) { $ this -> mkdir ( dirname ( $ file ) ) ; file_put_contents ( $ file , $ contents ) ; }
Put contents into a file .
44,501
public function deleteTemporaryFiles ( ) { $ this -> progress ( '--- Delete temporary files' ) ; $ this -> config -> get ( 'deletable' ) -> each ( function ( $ directory ) { if ( file_exists ( $ directory = $ this -> dataDir ( $ directory ) ) ) { $ this -> deleteDirectory ( $ directory ) ; } } ) ; }
Delete uneeded data files .
44,502
public function call ( $ name , $ arguments ) { if ( $ value = $ this -> cache -> get ( $ cacheKey = $ this -> cache -> makeKey ( [ $ name , $ arguments ] ) ) ) { return $ value ; } $ result = call_user_func_array ( [ $ this , $ name ] , $ arguments ) ; if ( $ this -> config -> get ( 'hydrate.before' ) ) { $ result = $...
Call a method currencies collection .
44,503
public function loadCountries ( ) { $ this -> countriesJson = $ this -> loadCountriesJson ( ) ; $ overload = $ this -> helper -> loadJsonFiles ( $ this -> helper -> dataDir ( 'countries/overload' ) ) -> mapWithKeys ( function ( $ country , $ code ) { return [ upper ( $ code ) => $ country ] ; } ) ; $ this -> countriesJ...
Load countries .
44,504
public function loadCountriesJson ( ) { $ data = $ this -> helper -> loadJson ( $ fileName = $ this -> helper -> dataDir ( 'countries/default/_all_countries.json' ) ) ; if ( $ data -> isEmpty ( ) ) { throw new \ Exception ( "Could not load countries from {$fileName}" ) ; } return $ data ; }
Load countries json file .
44,505
public function loadCurrenciesForCountry ( $ code ) { $ currencies = $ this -> helper -> loadJson ( $ this -> helper -> dataDir ( 'currencies/default/' . strtolower ( $ code ) . '.json' ) ) ; return $ currencies ; }
Load currency json file .
44,506
public function currencies ( ) { $ currencies = $ this -> helper -> loadJsonFiles ( $ this -> helper -> dataDir ( 'currencies/default' ) ) -> mapWithKeys ( function ( $ country , $ code ) { return [ upper ( $ code ) => $ country ] ; } ) ; $ overload = $ this -> helper -> loadJsonFiles ( $ this -> helper -> dataDir ( 'c...
Get all currencies .
44,507
public function makeAllFlags ( $ country ) { return [ 'sprite' => '<span class="flag flag-' . ( $ cca3 = strtolower ( $ country [ 'cca3' ] ) ) . '"></span>' , 'flag-icon' => '<span class="flag-icon flag-icon-' . ( $ iso_a2 = strtolower ( $ country [ 'iso_a2' ] ) ) . '"></span>' , 'flag-icon-squared' => '<span class="fl...
Make flags array for a coutry .
44,508
public function getGeometry ( $ country ) { return $ this -> helper -> loadFile ( $ this -> helper -> dataDir ( 'geo/' . strtolower ( $ country ) . '.geo.json' ) ) ; }
Get country geometry .
44,509
public function getTopology ( $ country ) { return $ this -> helper -> loadFile ( $ this -> helper -> dataDir ( 'topo/' . strtolower ( $ country ) . '.topo.json' ) ) ; }
Get country topology .
44,510
public function findTimezones ( $ countryCode ) { return $ this -> helper -> loadJson ( $ this -> helper -> dataDir ( 'timezones/countries/default/' . strtolower ( $ countryCode ) . '.json' ) ) ; }
Find a country timezone .
44,511
protected function addNode ( DOMElement $ element , $ key , $ value ) { if ( $ this -> replaceSpacesByUnderScoresInKeyNames ) { $ key = str_replace ( ' ' , '_' , $ key ) ; } $ child = $ this -> document -> createElement ( $ key ) ; $ element -> appendChild ( $ child ) ; $ this -> convertElement ( $ child , $ value ) ; ...
Add node .
44,512
protected function addCollectionNode ( DOMElement $ element , $ value ) { if ( $ element -> childNodes -> length === 0 && $ element -> attributes -> length === 0 ) { $ this -> convertElement ( $ element , $ value ) ; return ; } $ child = $ this -> document -> createElement ( $ element -> tagName ) ; $ element -> parent...
Add collection node .
44,513
protected function isArrayAllKeySequential ( $ value ) { if ( ! is_array ( $ value ) ) { return false ; } if ( count ( $ value ) <= 0 ) { return true ; } return array_unique ( array_map ( 'is_int' , array_keys ( $ value ) ) ) === [ true ] ; }
Check if array are all sequential .
44,514
protected function createRootElement ( $ rootElement ) { if ( is_string ( $ rootElement ) ) { $ rootElementName = $ rootElement ? : 'root' ; return $ this -> document -> createElement ( $ rootElementName ) ; } $ rootElementName = $ rootElement [ 'rootElementName' ] ?? 'root' ; $ element = $ this -> document -> createEl...
Create the root element .
44,515
public static function config ( $ config ) { foreach ( $ config as $ key => $ value ) { self :: $ config [ $ key ] = $ value ; } if ( isset ( $ config [ 'ShopUrl' ] ) ) { self :: setAdminUrl ( ) ; } if ( isset ( $ config [ 'AllowedTimePerCall' ] ) ) { static :: $ timeAllowedForEachApiCall = $ config [ 'AllowedTimePerCa...
Configure the SDK client
44,516
public static function setAdminUrl ( ) { $ shopUrl = self :: $ config [ 'ShopUrl' ] ; $ shopUrl = preg_replace ( '#^https?://|/$#' , '' , $ shopUrl ) ; if ( isset ( self :: $ config [ 'ApiKey' ] ) && isset ( self :: $ config [ 'Password' ] ) ) { $ apiKey = self :: $ config [ 'ApiKey' ] ; $ apiPassword = self :: $ confi...
Set the admin url based on the configured shop url
44,517
public static function checkApiCallLimit ( $ firstCallWait = false ) { $ timeToWait = 0 ; if ( static :: $ microtimeOfLastApiCall == null ) { if ( $ firstCallWait ) { $ timeToWait = static :: $ timeAllowedForEachApiCall ; } } else { $ now = microtime ( true ) ; $ timeSinceLastCall = $ now - static :: $ microtimeOfLastA...
Maintain maximum 2 calls per second to the API
44,518
protected static function init ( $ url , $ httpHeaders = array ( ) ) { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; $ headers = array ( ) ; foreach ( $ httpHeaders as $ key => $ value ) { $ headers [ ] = "$key: $value" ; } curl_setopt ( $ ch , C...
Initialize the curl resource
44,519
public static function get ( $ url , $ httpHeaders = array ( ) ) { $ ch = self :: init ( $ url , $ httpHeaders ) ; return self :: processRequest ( $ ch ) ; }
Implement a GET request and return output
44,520
public static function put ( $ url , $ data , $ httpHeaders = array ( ) ) { $ ch = self :: init ( $ url , $ httpHeaders ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , 'PUT' ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ data ) ; return self :: processRequest ( $ ch ) ; }
Implement a PUT request and return output
44,521
public static function delete ( $ url , $ httpHeaders = array ( ) ) { $ ch = self :: init ( $ url , $ httpHeaders ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , 'DELETE' ) ; return self :: processRequest ( $ ch ) ; }
Implement a DELETE request and return output
44,522
protected static function processRequest ( $ ch ) { while ( 1 ) { $ output = curl_exec ( $ ch ) ; self :: $ lastHttpCode = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; if ( self :: $ lastHttpCode != 429 ) { break ; } usleep ( 500000 ) ; } if ( curl_errno ( $ ch ) ) { throw new Exception \ CurlException ( curl_errno ( $...
Execute a request release the resource and return output
44,523
public function get ( $ urlParams = array ( ) , $ url = null , $ dataKey = null ) { if ( ! $ url ) $ url = $ this -> generateUrl ( $ urlParams ) ; $ response = HttpRequestJson :: get ( $ url , $ this -> httpHeaders ) ; if ( ! $ dataKey ) $ dataKey = $ this -> id ? $ this -> resourceKey : $ this -> pluralizeKey ( ) ; re...
Generate a HTTP GET request and return results as an array
44,524
public function count ( $ urlParams = array ( ) ) { if ( ! $ this -> countEnabled ) { throw new SdkException ( "Count is not available for " . $ this -> getResourceName ( ) ) ; } $ url = $ this -> generateUrl ( $ urlParams , 'count' ) ; return $ this -> get ( array ( ) , $ url , 'count' ) ; }
Get count for the number of resources available
44,525
public function search ( $ query ) { if ( ! $ this -> searchEnabled ) { throw new SdkException ( "Search is not available for " . $ this -> getResourceName ( ) ) ; } if ( ! is_array ( $ query ) ) $ query = array ( 'query' => $ query ) ; $ url = $ this -> generateUrl ( $ query , 'search' ) ; return $ this -> get ( array...
Search within the resouce
44,526
public function post ( $ dataArray , $ url = null , $ wrapData = true ) { if ( ! $ url ) $ url = $ this -> generateUrl ( ) ; if ( $ wrapData && ! empty ( $ dataArray ) ) $ dataArray = $ this -> wrapData ( $ dataArray ) ; $ response = HttpRequestJson :: post ( $ url , $ dataArray , $ this -> httpHeaders ) ; return $ thi...
Call POST method to create a new resource
44,527
public function delete ( $ urlParams = array ( ) , $ url = null ) { if ( ! $ url ) $ url = $ this -> generateUrl ( $ urlParams ) ; $ response = HttpRequestJson :: delete ( $ url , $ this -> httpHeaders ) ; return $ this -> processResponse ( $ response ) ; }
Call DELETE method to delete an existing resource
44,528
protected function wrapData ( $ dataArray , $ dataKey = null ) { if ( ! $ dataKey ) $ dataKey = $ this -> getResourcePostKey ( ) ; return array ( $ dataKey => $ dataArray ) ; }
Wrap data array with resource key
44,529
protected function castString ( $ array ) { if ( is_string ( $ array ) ) return $ array ; $ string = '' ; $ i = 0 ; foreach ( $ array as $ key => $ val ) { $ string .= ( $ i === $ key ? '' : "$key - " ) . $ this -> castString ( $ val ) . ', ' ; $ i ++ ; } $ string = rtrim ( $ string , ', ' ) ; return $ string ; }
Convert an array to string
44,530
public function processResponse ( $ responseArray , $ dataKey = null ) { if ( $ responseArray === null ) { $ httpOK = 200 ; $ httpCreated = 201 ; $ httpCode = CurlRequest :: $ lastHttpCode ; if ( $ httpCode != null && $ httpCode != $ httpOK && $ httpCode != $ httpCreated ) { throw new Exception \ CurlException ( "Reque...
Process the request response
44,531
public static function verifyShopifyRequest ( ) { $ data = $ _GET ; if ( ! isset ( ShopifySDK :: $ config [ 'SharedSecret' ] ) ) { throw new SdkException ( "Please provide SharedSecret while configuring the SDK client." ) ; } $ sharedSecret = ShopifySDK :: $ config [ 'SharedSecret' ] ; if ( isset ( $ data [ 'hmac' ] ) ...
Verify if the request is made from shopify using hmac hash value
44,532
public static function createAuthRequest ( $ scopes , $ redirectUrl = null , $ state = null , $ options = null , $ return = false ) { $ config = ShopifySDK :: $ config ; if ( ! isset ( $ config [ 'ShopUrl' ] ) || ! isset ( $ config [ 'ApiKey' ] ) ) { throw new SdkException ( "ShopUrl and ApiKey are required for authent...
Redirect the user to the authorization page to allow the app access to the shop
44,533
public function disable ( ) { $ url = $ this -> generateUrl ( array ( ) , 'disable' ) ; $ dataArray = array ( 'id' => $ this -> id , ) ; return $ this -> post ( $ dataArray , $ url ) ; }
Disable a gift card . Disabling a gift card is permanent and cannot be undone .
44,534
protected static function prepareRequest ( $ httpHeaders = array ( ) , $ dataArray = array ( ) ) { self :: $ postDataJSON = json_encode ( $ dataArray ) ; self :: $ httpHeaders = $ httpHeaders ; if ( ! empty ( $ dataArray ) ) { self :: $ httpHeaders [ 'Content-type' ] = 'application/json' ; self :: $ httpHeaders [ 'Cont...
Prepare the data and request headers before making the call
44,535
public static function get ( $ url , $ httpHeaders = array ( ) ) { self :: prepareRequest ( $ httpHeaders ) ; $ response = CurlRequest :: get ( $ url , self :: $ httpHeaders ) ; return self :: processResponse ( $ response ) ; }
Implement a GET request and return json decoded output
44,536
public static function post ( $ url , $ dataArray , $ httpHeaders = array ( ) ) { self :: prepareRequest ( $ httpHeaders , $ dataArray ) ; $ response = CurlRequest :: post ( $ url , self :: $ postDataJSON , self :: $ httpHeaders ) ; return self :: processResponse ( $ response ) ; }
Implement a POST request and return json decoded output
44,537
public static function delete ( $ url , $ httpHeaders = array ( ) ) { self :: prepareRequest ( $ httpHeaders ) ; $ response = CurlRequest :: delete ( $ url , self :: $ httpHeaders ) ; return self :: processResponse ( $ response ) ; }
Implement a DELETE request and return json decoded output
44,538
public static function parseFileXML ( $ filepath , $ entityId = null , $ desiredNameIdFormat = null , $ desiredSSOBinding = OneLogin_Saml2_Constants :: BINDING_HTTP_REDIRECT , $ desiredSLOBinding = OneLogin_Saml2_Constants :: BINDING_HTTP_REDIRECT ) { $ metadataInfo = array ( ) ; try { if ( file_exists ( $ filepath ) )...
Get IdP Metadata Info from File
44,539
public static function injectIntoSettings ( $ settings , $ metadataInfo ) { if ( isset ( $ metadataInfo [ 'idp' ] ) && isset ( $ settings [ 'idp' ] ) ) { if ( isset ( $ metadataInfo [ 'idp' ] [ 'x509certMulti' ] ) && ! empty ( $ metadataInfo [ 'idp' ] [ 'x509certMulti' ] ) && isset ( $ settings [ 'idp' ] [ 'x509cert' ]...
Inject metadata info into php - saml settings array
44,540
public function getIssuer ( ) { $ issuer = null ; $ issuerNodes = $ this -> _query ( '/samlp:LogoutResponse/saml:Issuer' ) ; if ( $ issuerNodes -> length == 1 ) { $ issuer = $ issuerNodes -> item ( 0 ) -> textContent ; } return $ issuer ; }
Gets the Issuer of the Logout Response .
44,541
public function getStatus ( ) { $ entries = $ this -> _query ( '/samlp:LogoutResponse/samlp:Status/samlp:StatusCode' ) ; if ( $ entries -> length != 1 ) { return null ; } $ status = $ entries -> item ( 0 ) -> getAttribute ( 'Value' ) ; return $ status ; }
Gets the Status of the Logout Response .
44,542
public function isValid ( $ requestId = null , $ retrieveParametersFromServer = false ) { $ this -> _error = null ; try { $ idpData = $ this -> _settings -> getIdPData ( ) ; $ idPEntityId = $ idpData [ 'entityId' ] ; if ( $ this -> _settings -> isStrict ( ) ) { $ security = $ this -> _settings -> getSecurityData ( ) ; ...
Determines if the SAML LogoutResponse is valid
44,543
public function build ( $ inResponseTo ) { $ spData = $ this -> _settings -> getSPData ( ) ; $ idpData = $ this -> _settings -> getIdPData ( ) ; $ this -> id = OneLogin_Saml2_Utils :: generateUniqueID ( ) ; $ issueInstant = OneLogin_Saml2_Utils :: parseTime2SAML ( time ( ) ) ; $ spEntityId = htmlspecialchars ( $ spData...
Generates a Logout Response object .
44,544
public function getResponse ( $ deflate = null ) { $ subject = $ this -> _logoutResponse ; if ( is_null ( $ deflate ) ) { $ deflate = $ this -> _settings -> shouldCompressResponses ( ) ; } if ( $ deflate ) { $ subject = gzdeflate ( $ this -> _logoutResponse ) ; } return base64_encode ( $ subject ) ; }
Returns a Logout Response object .
44,545
public function validateTimestamps ( ) { $ rootNode = $ this -> _document ; $ timestampNodes = $ rootNode -> getElementsByTagName ( 'Conditions' ) ; for ( $ i = 0 ; $ i < $ timestampNodes -> length ; $ i ++ ) { $ nbAttribute = $ timestampNodes -> item ( $ i ) -> attributes -> getNamedItem ( "NotBefore" ) ; $ naAttribut...
Verify that the document is still valid according
44,546
public function checkStatus ( ) { $ status = OneLogin_Saml2_Utils :: getStatus ( $ this -> document ) ; if ( isset ( $ status [ 'code' ] ) && $ status [ 'code' ] !== OneLogin_Saml2_Constants :: STATUS_SUCCESS ) { $ explodedCode = explode ( ':' , $ status [ 'code' ] ) ; $ printableCode = array_pop ( $ explodedCode ) ; $...
Checks if the Status is success
44,547
public function getAudiences ( ) { $ audiences = array ( ) ; $ entries = $ this -> _queryAssertion ( '/saml:Conditions/saml:AudienceRestriction/saml:Audience' ) ; foreach ( $ entries as $ entry ) { $ value = trim ( $ entry -> textContent ) ; if ( ! empty ( $ value ) ) { $ audiences [ ] = $ value ; } } return array_uniq...
Gets the audiences .
44,548
public function getNameIdData ( ) { $ encryptedIdDataEntries = $ this -> _queryAssertion ( '/saml:Subject/saml:EncryptedID/xenc:EncryptedData' ) ; if ( $ encryptedIdDataEntries -> length == 1 ) { $ encryptedData = $ encryptedIdDataEntries -> item ( 0 ) ; $ key = $ this -> _settings -> getSPkey ( ) ; $ seckey = new XMLS...
Gets the NameID Data provided by the SAML response from the IdP .
44,549
public function getNameId ( ) { $ nameIdvalue = null ; $ nameIdData = $ this -> getNameIdData ( ) ; if ( ! empty ( $ nameIdData ) && isset ( $ nameIdData [ 'Value' ] ) ) { $ nameIdvalue = $ nameIdData [ 'Value' ] ; } return $ nameIdvalue ; }
Gets the NameID provided by the SAML response from the IdP .
44,550
public function getNameIdFormat ( ) { $ nameIdFormat = null ; $ nameIdData = $ this -> getNameIdData ( ) ; if ( ! empty ( $ nameIdData ) && isset ( $ nameIdData [ 'Format' ] ) ) { $ nameIdFormat = $ nameIdData [ 'Format' ] ; } return $ nameIdFormat ; }
Gets the NameID Format provided by the SAML response from the IdP .
44,551
public function getNameIdNameQualifier ( ) { $ nameIdNameQualifier = null ; $ nameIdData = $ this -> getNameIdData ( ) ; if ( ! empty ( $ nameIdData ) && isset ( $ nameIdData [ 'NameQualifier' ] ) ) { $ nameIdNameQualifier = $ nameIdData [ 'NameQualifier' ] ; } return $ nameIdNameQualifier ; }
Gets the NameID NameQualifier provided by the SAML response from the IdP .
44,552
public function getSessionNotOnOrAfter ( ) { $ notOnOrAfter = null ; $ entries = $ this -> _queryAssertion ( '/saml:AuthnStatement[@SessionNotOnOrAfter]' ) ; if ( $ entries -> length !== 0 ) { $ notOnOrAfter = OneLogin_Saml2_Utils :: parseSAML2Time ( $ entries -> item ( 0 ) -> getAttribute ( 'SessionNotOnOrAfter' ) ) ;...
Gets the SessionNotOnOrAfter from the AuthnStatement . Could be used to set the local session expiration
44,553
public function getSessionIndex ( ) { $ sessionIndex = null ; $ entries = $ this -> _queryAssertion ( '/saml:AuthnStatement[@SessionIndex]' ) ; if ( $ entries -> length !== 0 ) { $ sessionIndex = $ entries -> item ( 0 ) -> getAttribute ( 'SessionIndex' ) ; } return $ sessionIndex ; }
Gets the SessionIndex from the AuthnStatement . Could be used to be stored in the local session in order to be used in a future Logout Request that the SP could send to the SP to set what specific session must be deleted
44,554
public function validateSignedElements ( $ signedElements ) { if ( count ( $ signedElements ) > 2 ) { return false ; } $ responseTag = '{' . OneLogin_Saml2_Constants :: NS_SAMLP . '}Response' ; $ assertionTag = '{' . OneLogin_Saml2_Constants :: NS_SAML . '}Assertion' ; $ ocurrence = array_count_values ( $ signedElement...
Verifies that the document has the expected signed nodes .
44,555
public function getRedirectUrl ( $ returnTo = null ) { $ settings = $ this -> auth -> getSettings ( ) ; $ authnRequest = new OneLogin_Saml2_AuthnRequest ( $ settings ) ; $ parameters = array ( 'SAMLRequest' => $ authnRequest -> getRequest ( ) ) ; if ( ! empty ( $ returnTo ) ) { $ parameters [ 'RelayState' ] = $ returnT...
Obtains the SSO URL containing the AuthRequest message deflated .
44,556
public function getRequest ( $ deflate = null ) { $ subject = $ this -> _logoutRequest ; if ( is_null ( $ deflate ) ) { $ deflate = $ this -> _settings -> shouldCompressRequests ( ) ; } if ( $ deflate ) { $ subject = gzdeflate ( $ this -> _logoutRequest ) ; } return base64_encode ( $ subject ) ; }
Returns the Logout Request defated base64encoded unsigned
44,557
public static function getNameIdData ( $ request , $ key = null ) { if ( $ request instanceof DOMDocument ) { $ dom = $ request ; } else { $ dom = new DOMDocument ( ) ; $ dom = OneLogin_Saml2_Utils :: loadXML ( $ dom , $ request ) ; } $ encryptedEntries = OneLogin_Saml2_Utils :: query ( $ dom , '/samlp:LogoutRequest/sa...
Gets the NameID Data of the the Logout Request .
44,558
public static function getNameId ( $ request , $ key = null ) { $ nameId = self :: getNameIdData ( $ request , $ key ) ; return $ nameId [ 'Value' ] ; }
Gets the NameID of the Logout Request .
44,559
public static function getIssuer ( $ request ) { if ( $ request instanceof DOMDocument ) { $ dom = $ request ; } else { $ dom = new DOMDocument ( ) ; $ dom = OneLogin_Saml2_Utils :: loadXML ( $ dom , $ request ) ; } $ issuer = null ; $ issuerNodes = OneLogin_Saml2_Utils :: query ( $ dom , '/samlp:LogoutRequest/saml:Iss...
Gets the Issuer of the Logout Request .
44,560
public function isValid ( $ retrieveParametersFromServer = false ) { $ this -> _error = null ; try { $ dom = new DOMDocument ( ) ; $ dom = OneLogin_Saml2_Utils :: loadXML ( $ dom , $ this -> _logoutRequest ) ; $ idpData = $ this -> _settings -> getIdPData ( ) ; $ idPEntityId = $ idpData [ 'entityId' ] ; if ( $ this -> ...
Checks if the Logout Request recieved is valid .
44,561
private function _loadPaths ( ) { $ basePath = dirname ( dirname ( __DIR__ ) ) . '/' ; $ this -> _paths = array ( 'base' => $ basePath , 'config' => $ basePath , 'cert' => $ basePath . 'certs/' , 'lib' => $ basePath . 'lib/' , 'extlib' => $ basePath . 'extlib/' ) ; if ( defined ( 'ONELOGIN_CUSTOMPATH' ) ) { $ this -> _...
Sets the paths of the different folders
44,562
private function _loadSettingsFromArray ( $ settings ) { if ( isset ( $ settings [ 'sp' ] ) ) { $ this -> _sp = $ settings [ 'sp' ] ; } if ( isset ( $ settings [ 'idp' ] ) ) { $ this -> _idp = $ settings [ 'idp' ] ; } $ errors = $ this -> checkSettings ( $ settings ) ; if ( empty ( $ errors ) ) { $ this -> _errors = ar...
Loads settings info from a settings Array
44,563
private function _loadSettingsFromFile ( ) { $ filename = $ this -> getConfigPath ( ) . 'settings.php' ; if ( ! file_exists ( $ filename ) ) { throw new OneLogin_Saml2_Error ( 'Settings file not found: %s' , OneLogin_Saml2_Error :: SETTINGS_FILE_NOT_FOUND , array ( $ filename ) ) ; } include $ filename ; $ advancedFile...
Loads settings info from the settings file
44,564
public function checkSettings ( $ settings ) { assert ( 'is_array($settings)' ) ; if ( ! is_array ( $ settings ) || empty ( $ settings ) ) { $ errors = array ( 'invalid_syntax' ) ; } else { $ errors = array ( ) ; if ( ! $ this -> _spValidationOnly ) { $ idpErrors = $ this -> checkIdPSettings ( $ settings ) ; $ errors =...
Checks the settings info .
44,565
public function checkCompressionSettings ( $ settings ) { $ errors = array ( ) ; if ( isset ( $ settings [ 'compress' ] ) ) { if ( ! is_array ( $ settings [ 'compress' ] ) ) { $ errors [ ] = "invalid_syntax" ; } else if ( isset ( $ settings [ 'compress' ] [ 'requests' ] ) && $ settings [ 'compress' ] [ 'requests' ] !==...
Checks the compression settings info .
44,566
public function checkSPCerts ( ) { $ key = $ this -> getSPkey ( ) ; $ cert = $ this -> getSPcert ( ) ; return ( ! empty ( $ key ) && ! empty ( $ cert ) ) ; }
Checks if the x509 certs of the SP exists and are valid .
44,567
public function getSPkey ( ) { $ key = null ; if ( isset ( $ this -> _sp [ 'privateKey' ] ) && ! empty ( $ this -> _sp [ 'privateKey' ] ) ) { $ key = $ this -> _sp [ 'privateKey' ] ; } else { $ keyFile = $ this -> _paths [ 'cert' ] . 'sp.key' ; if ( file_exists ( $ keyFile ) ) { $ key = file_get_contents ( $ keyFile ) ...
Returns the x509 private key of the SP .
44,568
public function getSPcert ( ) { $ cert = null ; if ( isset ( $ this -> _sp [ 'x509cert' ] ) && ! empty ( $ this -> _sp [ 'x509cert' ] ) ) { $ cert = $ this -> _sp [ 'x509cert' ] ; } else { $ certFile = $ this -> _paths [ 'cert' ] . 'sp.crt' ; if ( file_exists ( $ certFile ) ) { $ cert = file_get_contents ( $ certFile )...
Returns the x509 public cert of the SP .
44,569
public function validateMetadata ( $ xml ) { assert ( 'is_string($xml)' ) ; $ errors = array ( ) ; $ res = OneLogin_Saml2_Utils :: validateXML ( $ xml , 'saml-schema-metadata-2.0.xsd' , $ this -> _debug ) ; if ( ! $ res instanceof DOMDocument ) { $ errors [ ] = $ res ; } else { $ dom = $ res ; $ element = $ dom -> docu...
Validates an XML SP Metadata .
44,570
public function formatIdPCert ( ) { if ( isset ( $ this -> _idp [ 'x509cert' ] ) ) { $ this -> _idp [ 'x509cert' ] = OneLogin_Saml2_Utils :: formatCert ( $ this -> _idp [ 'x509cert' ] ) ; } }
Formats the IdP cert .
44,571
public function formatIdPCertMulti ( ) { if ( isset ( $ this -> _idp [ 'x509certMulti' ] ) ) { if ( isset ( $ this -> _idp [ 'x509certMulti' ] [ 'signing' ] ) ) { foreach ( $ this -> _idp [ 'x509certMulti' ] [ 'signing' ] as $ i => $ cert ) { $ this -> _idp [ 'x509certMulti' ] [ 'signing' ] [ $ i ] = OneLogin_Saml2_Uti...
Formats the Multple IdP certs .
44,572
public function formatSPKey ( ) { if ( isset ( $ this -> _sp [ 'privateKey' ] ) ) { $ this -> _sp [ 'privateKey' ] = OneLogin_Saml2_Utils :: formatPrivateKey ( $ this -> _sp [ 'privateKey' ] ) ; } }
Formats the SP private key .
44,573
public function getRequest ( $ deflate = null ) { $ subject = $ this -> _authnRequest ; if ( is_null ( $ deflate ) ) { $ deflate = $ this -> _settings -> shouldCompressRequests ( ) ; } if ( $ deflate ) { $ subject = gzdeflate ( $ this -> _authnRequest ) ; } $ base64Request = base64_encode ( $ subject ) ; return $ base6...
Returns deflated base64 encoded unsigned AuthnRequest .
44,574
public static function t ( $ msg , $ args = array ( ) ) { assert ( 'is_string($msg)' ) ; if ( extension_loaded ( 'gettext' ) ) { bindtextdomain ( "phptoolkit" , dirname ( dirname ( __DIR__ ) ) . '/locale' ) ; textdomain ( 'phptoolkit' ) ; $ translatedMsg = gettext ( $ msg ) ; } else { $ translatedMsg = $ msg ; } if ( !...
Translates any string . Accepts args
44,575
public static function validateXML ( $ xml , $ schema , $ debug = false ) { assert ( 'is_string($xml) || $xml instanceof DOMDocument' ) ; assert ( 'is_string($schema)' ) ; libxml_clear_errors ( ) ; libxml_use_internal_errors ( true ) ; if ( $ xml instanceof DOMDocument ) { $ dom = $ xml ; } else { $ dom = new DOMDocume...
This function attempts to validate an XML string against the specified schema .
44,576
public static function getStringBetween ( $ str , $ start , $ end ) { $ str = ' ' . $ str ; $ ini = strpos ( $ str , $ start ) ; if ( $ ini == 0 ) { return '' ; } $ ini += strlen ( $ start ) ; $ len = strpos ( $ str , $ end , $ ini ) - $ ini ; return substr ( $ str , $ ini , $ len ) ; }
Extracts a substring between 2 marks
44,577
public static function getSelfURLNoQuery ( ) { $ selfURLNoQuery = self :: getSelfURLhost ( ) ; $ infoWithBaseURLPath = self :: buildWithBaseURLPath ( $ _SERVER [ 'SCRIPT_NAME' ] ) ; if ( ! empty ( $ infoWithBaseURLPath ) ) { $ selfURLNoQuery .= $ infoWithBaseURLPath ; } else { $ selfURLNoQuery .= $ _SERVER [ 'SCRIPT_NA...
Returns the URL of the current host + current view .
44,578
public static function getSelfRoutedURLNoQuery ( ) { $ selfURLhost = self :: getSelfURLhost ( ) ; $ route = '' ; if ( ! empty ( $ _SERVER [ 'REQUEST_URI' ] ) ) { $ route = $ _SERVER [ 'REQUEST_URI' ] ; if ( ! empty ( $ _SERVER [ 'QUERY_STRING' ] ) ) { $ route = str_replace ( $ _SERVER [ 'QUERY_STRING' ] , '' , $ route ...
Returns the routed URL of the current host + current view .
44,579
protected static function buildWithBaseURLPath ( $ info ) { $ result = '' ; $ baseURLPath = self :: getBaseURLPath ( ) ; if ( ! empty ( $ baseURLPath ) ) { $ result = $ baseURLPath ; if ( ! empty ( $ info ) ) { $ path = explode ( '/' , $ info ) ; $ extractedInfo = array_pop ( $ path ) ; if ( ! empty ( $ extractedInfo )...
Returns the part of the URL with the BaseURLPath .
44,580
public static function getExpireTime ( $ cacheDuration = null , $ validUntil = null ) { $ expireTime = null ; if ( $ cacheDuration !== null ) { $ expireTime = self :: parseDuration ( $ cacheDuration , time ( ) ) ; } if ( $ validUntil !== null ) { if ( is_int ( $ validUntil ) ) { $ validUntilTime = $ validUntil ; } else...
Compares 2 dates and returns the earliest .
44,581
public static function query ( $ dom , $ query , $ context = null ) { $ xpath = new DOMXPath ( $ dom ) ; $ xpath -> registerNamespace ( 'samlp' , OneLogin_Saml2_Constants :: NS_SAMLP ) ; $ xpath -> registerNamespace ( 'saml' , OneLogin_Saml2_Constants :: NS_SAML ) ; $ xpath -> registerNamespace ( 'ds' , OneLogin_Saml2_...
Extracts nodes from the DOMDocument .
44,582
public static function calculateX509Fingerprint ( $ x509cert , $ alg = 'sha1' ) { assert ( 'is_string($x509cert)' ) ; $ arCert = explode ( "\n" , $ x509cert ) ; $ data = '' ; $ inData = false ; foreach ( $ arCert as $ curData ) { if ( ! $ inData ) { if ( strncmp ( $ curData , '-----BEGIN CERTIFICATE' , 22 ) == 0 ) { $ ...
Calculates the fingerprint of a x509cert .
44,583
public static function generateNameId ( $ value , $ spnq , $ format = null , $ cert = null , $ nq = null ) { $ doc = new DOMDocument ( ) ; $ nameId = $ doc -> createElement ( 'saml:NameID' ) ; if ( isset ( $ spnq ) ) { $ nameId -> setAttribute ( 'SPNameQualifier' , $ spnq ) ; } if ( isset ( $ nq ) ) { $ nameId -> setAt...
Generates a nameID .
44,584
public static function getStatus ( $ dom ) { $ status = array ( ) ; $ statusEntry = self :: query ( $ dom , '/samlp:Response/samlp:Status' ) ; if ( $ statusEntry -> length != 1 ) { throw new OneLogin_Saml2_ValidationError ( "Missing Status on response" , OneLogin_Saml2_ValidationError :: MISSING_STATUS ) ; } $ codeEntr...
Gets Status from a Response .
44,585
public static function validateBinarySign ( $ messageType , $ getData , $ idpData , $ retrieveParametersFromServer = false ) { if ( ! isset ( $ getData [ 'SigAlg' ] ) ) { $ signAlg = XMLSecurityKey :: RSA_SHA1 ; } else { $ signAlg = $ getData [ 'SigAlg' ] ; } if ( $ retrieveParametersFromServer ) { $ signedQuery = $ me...
Validates a binary signature
44,586
public function redirectTo ( $ url = '' , $ parameters = array ( ) , $ stay = false ) { assert ( 'is_string($url)' ) ; assert ( 'is_array($parameters)' ) ; if ( empty ( $ url ) && isset ( $ _REQUEST [ 'RelayState' ] ) ) { $ url = $ _REQUEST [ 'RelayState' ] ; } return OneLogin_Saml2_Utils :: redirect ( $ url , $ parame...
Redirects the user to the url past by parameter or to the url that we defined in our SSO Request .
44,587
public function getAttribute ( $ name ) { assert ( 'is_string($name)' ) ; $ value = null ; if ( isset ( $ this -> _attributes [ $ name ] ) ) { return $ this -> _attributes [ $ name ] ; } return $ value ; }
Returns the requested SAML attribute
44,588
public function getAttributeWithFriendlyName ( $ friendlyName ) { assert ( 'is_string($friendlyName)' ) ; $ value = null ; if ( isset ( $ this -> _attributesWithFriendlyName [ $ friendlyName ] ) ) { return $ this -> _attributesWithFriendlyName [ $ friendlyName ] ; } return $ value ; }
Returns the requested SAML attribute indexed by FriendlyName
44,589
public function getSLOResponseUrl ( ) { $ idpData = $ this -> _settings -> getIdPData ( ) ; if ( isset ( $ idpData [ 'singleLogoutService' ] ) && isset ( $ idpData [ 'singleLogoutService' ] [ 'responseUrl' ] ) ) { return $ idpData [ 'singleLogoutService' ] [ 'responseUrl' ] ; } return $ this -> getSLOurl ( ) ; }
Gets the SLO response url .
44,590
public function createMonthlySubscription ( $ token , $ amount , $ description ) { $ data = [ 'PROFILESTARTDATE' => Carbon :: now ( ) -> toAtomString ( ) , 'DESC' => $ description , 'BILLINGPERIOD' => 'Month' , 'BILLINGFREQUENCY' => 1 , 'AMT' => $ amount , 'CURRENCYCODE' => $ this -> currency , ] ; return $ this -> cre...
Create recurring subscription on monthly basis .
44,591
private function setConfig ( array $ config = [ ] ) { if ( function_exists ( 'config' ) ) { $ this -> setApiCredentials ( config ( 'paypal' ) ) ; } elseif ( ! empty ( $ config ) ) { $ this -> setApiCredentials ( $ config ) ; } $ this -> setRequestData ( ) ; }
Function To Set PayPal API Configuration .
44,592
private function setDefaultValues ( ) { if ( empty ( $ this -> paymentAction ) ) { $ this -> paymentAction = 'Sale' ; } if ( empty ( $ this -> locale ) ) { $ this -> locale = 'en_US' ; } if ( empty ( $ this -> validateSSL ) ) { $ this -> validateSSL = false ; } }
Set default values for configuration .
44,593
public function setApiCredentials ( $ credentials ) { $ this -> setApiEnvironment ( $ credentials ) ; $ this -> setApiProviderConfiguration ( $ credentials ) ; $ this -> setCurrency ( $ credentials [ 'currency' ] ) ; $ this -> setBillingType ( $ credentials [ 'billing_type' ] ) ; $ this -> setHttpClientConfiguration ( ...
Set PayPal API Credentials .
44,594
private function setApiEnvironment ( $ credentials ) { if ( empty ( $ credentials [ 'mode' ] ) || ! in_array ( $ credentials [ 'mode' ] , [ 'sandbox' , 'live' ] ) ) { $ this -> mode = 'live' ; } else { $ this -> mode = $ credentials [ 'mode' ] ; } }
Set API environment to be used by PayPal .
44,595
private function setApiProviderConfiguration ( $ credentials ) { collect ( $ credentials [ $ this -> mode ] ) -> map ( function ( $ value , $ key ) { $ this -> config [ $ key ] = $ value ; } ) ; $ this -> config [ 'signature' ] = empty ( $ this -> config [ 'certificate' ] ) ? $ this -> config [ 'secret' ] : $ this -> c...
Set configuration details for the provider .
44,596
private function setApiProvider ( $ credentials ) { if ( $ this instanceof \ Srmklive \ PayPal \ Services \ AdaptivePayments ) { $ this -> setAdaptivePaymentsOptions ( ) ; } elseif ( $ this instanceof \ Srmklive \ PayPal \ Services \ ExpressCheckout ) { $ this -> setExpressCheckoutOptions ( $ credentials ) ; } else { t...
Determines which API provider should be used .
44,597
protected function setRequestData ( array $ data = [ ] ) { if ( ( $ this -> post instanceof Collection ) && ( ! $ this -> post -> isEmpty ( ) ) ) { unset ( $ this -> post ) ; } $ this -> post = new Collection ( $ data ) ; return $ this -> post ; }
Setup request data to be sent to PayPal .
44,598
public function setCurrency ( $ currency = 'USD' ) { $ allowedCurrencies = [ 'AUD' , 'BRL' , 'CAD' , 'CZK' , 'DKK' , 'EUR' , 'HKD' , 'HUF' , 'ILS' , 'INR' , 'JPY' , 'MYR' , 'MXN' , 'NOK' , 'NZD' , 'PHP' , 'PLN' , 'GBP' , 'SGD' , 'SEK' , 'CHF' , 'TWD' , 'THB' , 'USD' , 'RUB' ] ; if ( ! in_array ( $ currency , $ allowedC...
Function to set currency .
44,599
public function setBillingType ( $ billingType = 'MerchantInitiatedBilling' ) { $ allowedBillingTypes = [ 'MerchantInitiatedBilling' , 'MerchantInitiatedBillingSingleAgreement' , 'RecurringPayments' ] ; if ( $ billingType != null && ! in_array ( $ billingType , $ allowedBillingTypes ) ) { throw new \ Exception ( 'Billi...
Function to set billing type .