idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
53,900
public static function getProvider ( String $ connectionId = null ) : PlatformProvider { if ( $ connectionId == null ) { $ connectionId = Repository :: $ staticConnectionId ; } return self :: getInstance ( $ connectionId ) -> provider ; }
Returns current provider .
53,901
protected function prepare_merge_vars ( array $ notifications ) { $ merge_vars = array ( ) ; foreach ( $ notifications as $ notification ) { $ merge = array ( 'rcpt' => $ notification -> get_recipient ( ) -> user_email , 'vars' => array ( ) ) ; foreach ( $ notification -> get_tags ( ) as $ tag => $ val ) { $ tag = str_replace ( array ( '{' , '}' ) , '' , $ tag ) ; $ merge [ 'vars' ] [ ] = array ( 'name' => $ tag , 'content' => $ val ) ; } $ merge_vars [ ] = $ merge ; } return $ merge_vars ; }
Prepare merge vars for the API .
53,902
protected function prepare_to ( array $ notifications ) { $ tos = array ( ) ; foreach ( $ notifications as $ notification ) { $ to = $ notification -> get_recipient ( ) ; $ tos [ ] = array ( 'email' => $ to -> user_email , 'name' => "{$to->first_name} {$to->last_name}" , 'type' => 'to' ) ; } return $ tos ; }
Prepare the to array for the API .
53,903
public function getAlert ( $ namespace ) { $ messagesToPrint = $ this -> getView ( ) -> plugin ( 'flash_messenger' ) -> render ( $ namespace ) ; if ( empty ( $ messagesToPrint ) ) { return null ; } $ alert = $ this -> getView ( ) -> plugin ( 'sxb_alert' ) -> __invoke ( $ messagesToPrint ) ; if ( in_array ( $ namespace , $ this -> availableNamespaces ) ) { if ( PluginFlashMessenger :: NAMESPACE_DEFAULT === $ namespace ) { $ namespace = PluginFlashMessenger :: NAMESPACE_INFO ; } $ alert -> $ namespace ( ) ; } if ( $ this -> isBlock ) { $ alert -> block ( ) ; } return $ alert ; }
Get the Alert objects containing the messages that are registered on the flash messenger .
53,904
public function block ( $ enabled = null ) { if ( is_null ( $ enabled ) ) { $ enabled = ! $ this -> isBlock ; } $ this -> isBlock = $ enabled ; return $ this ; }
Toggle the display mode for each alert to block .
53,905
public function setNamespaces ( $ namespaces ) { if ( is_string ( $ namespaces ) ) { $ this -> namespaces = array ( $ namespaces ) ; } elseif ( is_array ( $ namespaces ) ) { $ this -> namespaces = $ namespaces ; } else { throw new Exception \ InvalidArgumentException ( "Invalid argument, expected a string or array. Got " . gettype ( $ namespaces ) . "." ) ; } return $ this ; }
Set the namespace that should be displayed
53,906
public static function set ( $ key , $ value = null , $ expiration = null ) { if ( ! self :: $ instance ) { return null ; } self :: $ instance -> cache -> set ( $ key , $ value , $ expiration ) ; return self :: $ instance ; }
set wrapper for caching
53,907
public function iClickOnTheElement ( $ locator ) { $ session = $ this -> getSession ( ) ; $ element = $ session -> getPage ( ) -> find ( 'css' , $ locator ) ; PHPUnit_Framework_Assert :: assertNotNull ( $ element , sprintf ( 'Could not evaluate CSS selector: "%s"' , $ locator ) ) ; $ this -> getSession ( ) -> executeScript ( "$('#" . $ element -> getAttribute ( 'id' ) . "').click()" ) ; $ element -> click ( ) ; }
Click on the element with the provided xpath query
53,908
public function setResponseCacheParameters ( Response $ response , $ maxAge , $ status = CacheableInterface :: CACHE_PRIVATE , $ hasEsi = false ) { $ this -> setResponseStatus ( $ response , $ status ) ; $ this -> setResponseMaxAge ( $ response , $ status , $ maxAge , $ hasEsi ) ; return $ response ; }
Set response cache headers
53,909
protected function setResponseStatus ( Response $ response , $ status ) { if ( CacheableInterface :: CACHE_PUBLIC == $ status ) { $ response -> setPublic ( ) ; } else { $ response -> setPrivate ( ) ; } }
Set response status
53,910
protected function setResponseMaxAge ( Response $ response , $ status , $ maxAge , $ hasEsi ) { if ( - 1 === $ maxAge ) { $ maxAge = 2629743 ; } if ( true === $ hasEsi && CacheableInterface :: CACHE_PUBLIC == $ status ) { $ response -> setSharedMaxAge ( $ maxAge ) ; } else { $ response -> setMaxAge ( $ maxAge ) ; } }
Set response max age
53,911
function setRHandler ( $ resOrigin ) { if ( ! is_resource ( $ resOrigin ) ) throw new \ InvalidArgumentException ( sprintf ( 'This is not valid stream resource. given: "%s"' , is_object ( $ resOrigin ) ? get_class ( $ resOrigin ) : gettype ( $ resOrigin ) ) ) ; $ this -> rHandler = $ resOrigin ; return $ this ; }
Set Original Resource Handler
53,912
protected function assertMetaData ( ) { if ( ! is_resource ( $ this -> rHandler ) ) throw new \ Exception ( 'Resource not still available, it might be closed.' ) ; $ this -> _metaData = stream_get_meta_data ( $ this -> rHandler ) ; }
Live Tracking of Data
53,913
function getMetaKey ( $ key , $ default = null ) { $ this -> assertMetaData ( ) ; if ( isset ( $ this -> _metaData [ $ key ] ) ) return $ this -> _metaData [ $ key ] ; return $ default ; }
Get Meta Key Value
53,914
function getAccessType ( ) { if ( ! $ this -> _c__accMode instanceof AccessMode ) $ this -> _c__accMode = new AccessMode ; $ this -> assertMetaData ( ) ; $ mode = $ this -> getMetaKey ( 'mode' ) ; if ( $ mode !== null ) $ this -> _c__accMode -> fromString ( $ mode ) ; return $ this -> _c__accMode ; }
The Type Mode Of Access Required For This Stream
53,915
function isSeekable ( ) { $ this -> assertMetaData ( ) ; if ( $ this -> getMetaKey ( 'wrapper_type' ) ) { if ( false === $ pos = ftell ( $ this -> rHandler ) ) throw new \ RuntimeException ( 'Unable to determine stream position' ) ; try { if ( - 1 === @ fseek ( $ this -> rHandler , $ pos , SEEK_SET ) ) return false ; } catch ( \ Exception $ e ) { return false ; } } return ( bool ) $ this -> getMetaKey ( 'seekable' ) ; }
Whether The Current Stream Can Be seeked?
53,916
public function analyze ( $ directory ) { if ( ! $ this -> fileSystem -> exists ( $ directory ) || ! $ this -> fileSystem -> isDirectory ( $ directory ) ) { throw new InvalidPathException ( $ directory . ' is not a valid directory.' ) ; } $ structure = $ this -> fileSystem -> allFiles ( $ directory ) ; $ newStructure = [ ] ; foreach ( $ structure as $ path ) { $ type = ( $ this -> fileSystem -> isFile ( $ path ) ) ? 'file' : 'dir' ; $ newStructure [ ] = [ 'path' => $ this -> normalizePath ( $ path -> getRelativePathName ( ) ) , 'type' => $ type , 'origin' => $ this -> normalizePath ( $ path -> getRealPath ( ) ) , 'home' => $ this -> normalizePath ( substr ( $ path -> getRealPath ( ) , 0 , ( - 1 * strlen ( $ path -> getRelativePathName ( ) ) ) ) ) ] ; } return $ newStructure ; }
The directory to analyze .
53,917
public function setTagOptions ( $ tag , array $ options ) { $ this -> tagOptions [ $ tag ] = $ options ; $ this -> keyTagParamsComposite = null ; }
set tag option defaults .
53,918
public function getTagOptions ( $ tag , $ options ) { return isset ( $ this -> tagOptions [ $ tag ] ) ? $ this -> tagOptions [ $ tag ] : array ( ) ; }
get tag option defaults .
53,919
public function Tag ( $ tag , $ instance , array $ options = null ) { if ( isset ( $ options [ 'cacheHandler' ] ) ) { if ( isset ( $ this -> cacheHandlers [ $ options [ 'cacheHandler' ] ] ) ) { $ handler = $ this -> cacheHandlers [ $ options [ 'cacheHandler' ] ] ; } else { trigger_error ( "KeyRing Tag requested but that cache handler was not provided during construction of keyring" , E_USER_ERROR ) ; } } else { $ handler = $ this -> cacheHandlers [ $ this -> defaultCacheHandler ] ; } $ version = isset ( $ options [ 'version' ] ) ? $ options [ 'version' ] : null ; $ prefix = isset ( $ options [ 'prefix' ] ) ? $ options [ 'prefix' ] : $ this -> defaultPrefix ; if ( isset ( $ options [ 'type' ] ) ) { switch ( strtolower ( $ options [ 'type' ] ) ) { case 'standard' : $ tag = new FragmentedKeys \ Tag \ Standard ( $ tag , $ instance , $ version , $ handler , $ prefix ) ; break ; case 'constant' : $ tag = new FragmentedKeys \ Tag \ Constant ( $ tag , $ instance , $ version , $ handler , $ prefix ) ; break ; } } return $ tag ; }
Factory Method that retuns a Tag with specified cache handler etc .
53,920
public function getComment ( ) { $ postParameterBag = $ this -> request -> query ; $ commentId = $ postParameterBag -> get ( 'comment_id' ) ; if ( empty ( $ commentId ) ) { return new JsonResponse ( [ 'status' => 'Error' , 'message' => 'Some query parameters are missing' , ] , 400 ) ; } $ commentReference = new CommentUUID ( $ commentId ) ; $ comment = $ this -> commentRepository -> findComment ( $ commentReference ) -> getFirstComment ( ) ; if ( ! $ comment instanceof Comment ) { return new JsonResponse ( [ 'status' => 'Error' , 'message' => 'Comment not found' , ] , 404 ) ; } return new JsonResponse ( [ 'comment' => $ comment -> toArray ( ) , 'user' => $ this -> userCredentialsProvider -> toArray ( ) , ] , 200 ) ; }
Get one comment by id
53,921
public function changeCommentState ( ) { $ userIsAllowed = $ this -> userCredentialsProvider -> isAllowed ( ) ; if ( ! $ userIsAllowed ) { return new JsonResponse ( [ 'status' => 'Error' , 'message' => 'The user is not allowed to do this' , ] , 401 ) ; } $ userIsModerator = $ this -> userCredentialsProvider -> isModerator ( ) ; if ( ! $ userIsModerator ) { return new JsonResponse ( [ 'status' => 'Error' , 'message' => 'User must have the moderator role' , ] , 401 ) ; } $ sourceUUID = $ this -> getSourceUUID ( ) ; if ( empty ( $ sourceUUID ) ) { return new JsonResponse ( [ 'status' => 'Error' , 'message' => 'Source UUID header must be defined' , ] , 400 ) ; } $ postParameterBag = $ this -> request -> request ; $ newState = $ postParameterBag -> get ( 'new_state' ) ; $ commentId = $ postParameterBag -> get ( 'comment_id' ) ; if ( empty ( $ newState ) || empty ( $ commentId ) ) { return new JsonResponse ( [ 'status' => 'Error' , 'message' => 'Some query parameters are missing' , ] , 400 ) ; } $ comment = $ this -> commentRepository -> findComment ( new CommentUUID ( $ commentId ) ) -> getFirstComment ( ) ; if ( ! $ comment instanceof Comment ) { return new JsonResponse ( [ 'status' => 'Error' , 'message' => 'Comment not found' , ] , 404 ) ; } $ comment -> setState ( ( int ) $ newState ) ; $ this -> commentRepository -> addComment ( $ comment ) ; $ this -> flushRepository ( ) ; return new JsonResponse ( [ 'status' => 'OK' , 'comment' => $ comment -> toArray ( ) , 'user' => $ this -> userCredentialsProvider -> toArray ( ) , ] , 200 ) ; }
Admin comment .
53,922
private function setEditableInComment ( Comment $ comment , string $ authorUUID ) { if ( $ authorUUID === $ comment -> getAuthorUUID ( ) ) { $ comment -> setEditable ( true ) ; } }
Set editable value inside comment .
53,923
public static function normalizeHeader ( MessageInterface $ message , $ header ) { $ h = $ message -> getHeaderAsArray ( $ header ) ; for ( $ i = 0 , $ total = count ( $ h ) ; $ i < $ total ; $ i ++ ) { if ( strpos ( $ h [ $ i ] , ',' ) === false ) { continue ; } foreach ( preg_split ( '/,(?=([^"]*"[^"]*")*[^"]*$)/' , $ h [ $ i ] ) as $ v ) { $ h [ ] = trim ( $ v ) ; } unset ( $ h [ $ i ] ) ; } return $ h ; }
Converts an array of header values that may contain comma separated headers into an array of headers with no comma separated values .
53,924
public function getConnection ( mysqltcs $ client , $ host , $ user , $ password , $ name , $ key = "" , $ cert = "" , $ ca = "" ) { $ clientKey = array_search ( $ client , $ this -> clients ) ; if ( $ clientKey !== false ) { throw new MysqlConnectionException ( "The client has already a connection, it must be removed before" ) ; } $ clientKey = count ( $ this -> clients ) ; $ this -> connections [ $ clientKey ] = $ this -> findConnection ( $ host , $ user , $ password , $ name , $ key , $ cert , $ ca ) ; $ this -> clients [ $ clientKey ] = $ client ; return $ this -> connections [ $ clientKey ] ; }
Get a connection ; new or old we don t know this
53,925
private function findConnection ( $ host , $ user , $ password , $ name , $ key = "" , $ cert = "" , $ ca = "" ) { $ newConnection = new MysqlConnection ( $ host , $ user , $ password , $ name , $ key , $ cert , $ ca ) ; foreach ( $ this -> connections as $ connection ) { if ( $ connection -> equals ( $ newConnection ) ) { return $ connection ; } } $ newConnection -> connect ( ) ; return $ newConnection ; }
Get a connection if it exists otherwise it creates a new one
53,926
public function connect ( ) { $ socket = $ this -> createSocket ( $ this -> connection -> getHostname ( ) , $ this -> connection -> getPort ( ) , $ this -> throttle ) ; $ this -> setSocket ( $ socket ) ; }
Creates and binds the Socket .
53,927
protected function setLogIn ( ) { if ( $ this -> isLogged ( ) ) { return ; } fire_callbacks ( $ this -> loggedInCallbacks , $ this ) ; $ this -> loggedIn = true ; }
Changes the state of the Client to Logged in Fires the callbacks .
53,928
public function whenLogged ( $ callback ) { $ this -> loggedInCallbacks [ ] = $ callback ; if ( $ this -> isLogged ( ) ) { fire_callbacks ( $ this -> loggedInCallbacks , $ this ) ; } }
Adds the callback function to the loggedInCallbacks list If client is already logged in then the function is called .
53,929
public function joinChat ( $ name ) { if ( ! starts_with ( $ name , '#' ) ) { $ name = "#$name" ; } if ( array_key_exists ( $ name , $ this -> chats ) ) { return $ this -> chats [ $ name ] ; } \ Logger :: info ( "Joining Chat $name" ) ; $ chat = new Chat ( $ this , $ name ) ; $ this -> chats [ $ name ] = $ chat ; return $ chat ; }
Creates and returns a chat instance .
53,930
public function getChat ( $ name ) { if ( ! starts_with ( $ name , '#' ) ) { $ name = "#$name" ; } if ( array_key_exists ( $ name , $ this -> chats ) ) { return $ this -> chats [ $ name ] ; } }
Returns Chat instance or null .
53,931
public function command ( $ code , $ value ) { $ command = strtoupper ( $ code ) . " $value" . PHP_EOL ; $ this -> socket -> send ( $ command ) ; }
Sends a command .
53,932
public function rawcommand ( $ command ) { if ( preg_match ( '/(.+)[\n]$/' , $ command ) ) { $ this -> socket -> send ( $ command ) ; } else { $ this -> socket -> send ( $ command . PHP_EOL ) ; } }
Sends a raw command .
53,933
public function run ( ) { $ this -> command ( 'PASS' , $ this -> connection -> getPassword ( ) ) ; $ this -> command ( 'NICK' , $ this -> connection -> getNickname ( ) ) ; $ this -> grantAll ( ) ; $ this -> setLogIn ( ) ; $ this -> dispatch ( 'tweech.authenticated' , new Event ( ) ) ; $ ticker = new Ticker ( $ this ) ; $ ticker -> run ( ) ; $ chatreader = new ChatReader ( $ this ) ; $ chatreader -> handleSockets ( ) ; $ chatreader -> run ( ) ; }
Runs the Client Authenticates requests membership starts reading messages .
53,934
public static function factory ( array $ definition ) : ? Constraint { if ( ! isset ( $ definition [ 'class' ] ) ) { throw new BadDefinitionException ( 'The constraint could not be constructed.' ) ; } $ class = $ definition [ 'class' ] ; $ rule = isset ( $ definition [ 'rule' ] ) ? $ definition [ 'rule' ] : null ; $ error_message = isset ( $ definition [ 'error_message' ] ) ? $ definition [ 'error_message' ] : null ; return new $ class ( $ rule , $ error_message ) ; }
Create a constraint according to the passed definition array . The definition must contain a class which is the fully qualified name of the constraint class . Optionally it can also contain a rule value appropriate for the constraint class in question and an error message to override the default error message .
53,935
public function reportError ( ) : void { if ( isset ( $ this -> validator ) ) { $ this -> validator -> reportError ( $ this -> error_message ) ; } }
Send the error to the validator if one is set
53,936
public function setOrigin ( array $ origin ) { $ this -> origin = array_replace ( $ this -> origin , array_intersect_key ( $ origin , $ this -> origin ) ) ; return $ this ; }
Define FormattedImage origin .
53,937
public function loadPackage ( $ directory ) { if ( ! $ this -> files -> exists ( $ directory ) ) { throw new InvalidPathException ( "The directory {$directory} does not exist." ) ; } if ( ! $ this -> files -> exists ( $ directory . '/composer.json' ) ) { throw new InvalidPathException ( "There is no composer.json file in {$directory}" ) ; } if ( ! $ this -> files -> exists ( $ directory . '/_newup' ) ) { throw new InvalidPathException ( "There is no _newup directory in {$directory}" ) ; } if ( ! $ this -> files -> exists ( $ directory . '/_newup/Package.php' ) ) { throw new InvalidPathException ( "A Package.php file must be present in in \"_newup\" directory." ) ; } $ package = Package :: fromFile ( $ directory . '/composer.json' , user_config ( 'configuration.strictComposerValues' , true ) ) ; $ namespace = package_vendor_namespace ( $ package -> getVendor ( ) , $ package -> getPackage ( ) , true ) ; add_psr4 ( $ namespace , $ directory . '/_newup' ) ; if ( ! class_exists ( $ namespace . 'Package' , true ) ) { throw new NewUpException ( "A valid reachable class named 'Package' must be defined." ) ; } if ( ! is_subclass_of ( $ namespace . 'Package' , BasePackageTemplate :: class ) ) { throw new NewUpException ( "The 'Package' class must extend " . BasePackageTemplate :: class ) ; } return $ namespace . 'Package' ; }
Loads a package from a given directory .
53,938
public function downloadProcessedImage ( ProcessedImage $ processedImage , $ savePath ) { $ url = $ processedImage -> fileUrls [ 0 ] ; if ( $ this -> accessToken != null ) { $ url .= "?access_token=" . $ this -> accessToken -> token ( ) ; } self :: downloadImage ( $ url , $ savePath ) ; }
Download the given ProcessedImage and save it to the given path .
53,939
public static function downloadImage ( $ url , $ savePath ) { try { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; $ data = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; $ file = fopen ( $ savePath , "w+" ) ; fputs ( $ file , $ data ) ; fclose ( $ file ) ; } catch ( \ Exception $ e ) { throw new UnknownServerErrorException ( "Failed to retrieve your image" ) ; } }
Download the given image url and save it to the given path .
53,940
public function getLastVideosFromUser ( $ user_name , $ count = 100 ) { $ contentDetails = $ this -> query ( 'channels' , array ( 'part' => 'contentDetails' , 'forUsername' => $ user_name , ) ) ; if ( $ contentDetails ) { $ playlistId = $ contentDetails [ 'items' ] [ 0 ] [ 'contentDetails' ] [ 'relatedPlaylists' ] [ 'uploads' ] ; return $ this -> query ( 'playlistItems' , array ( 'part' => 'snippet' , 'playlistId' => $ playlistId , 'count' => $ count ) ) ; } return null ; }
Retourne la liste des derniers statuts d une page
53,941
public function presentInfos ( ) { $ a = new \ stdClass ( ) ; $ a -> id = $ this -> getId ( ) ; $ a -> avatar = $ this -> presentAvatar ( ) ; $ a -> name = $ this -> presentName ( ) ; $ a -> email = $ this -> presentEmail ( ) ; $ a -> description = $ this -> presentDescription ( ) ; $ a -> permalink = $ this -> presentLink ( ) ; $ a -> site = $ this -> presentSite ( ) ; return $ a ; }
Return a object with author information
53,942
public function group ( $ typeId , $ group = null , $ code = null ) { return $ this -> processor -> group ( $ this , $ typeId , $ group , $ code ) ; }
change group of translations
53,943
public function groupFailed ( $ error = null ) { $ message = is_null ( $ error ) ? trans ( 'Unable to change translation group.' ) : $ error ; app ( 'antares.messages' ) -> add ( 'error' , $ message ) ; return redirect ( ) -> back ( ) ; }
response when group has not been changed
53,944
public function updateSuccessfull ( $ type , $ code ) { $ message = trans ( 'antares/translations::messages.update_success' ) ; return $ this -> redirectWithMessage ( handles ( 'antares::translations/index/' . $ type . '/' . $ code ) , $ message ) ; }
when update completed successfully
53,945
public function updateFailed ( $ type , $ code ) { $ message = trans ( 'antares/translations::messages.update_failed' ) ; return $ this -> redirectWithMessage ( handles ( 'antares::translations/index/' . $ type ) , $ message , 'error' ) ; }
when update has failed
53,946
public function Create ( $ exclude = array ( ) ) { if ( ! $ this -> iget ( 'value' ) ) { $ this -> iset ( 'value' , 1 + ( int ) $ this -> getValue ( array ( 'select' => 'MAX(value)' , 'where' => array ( array ( 'module_id' , $ this -> iget ( 'module_id' ) ) ) ) ) ) ; } return parent :: Create ( $ exclude ) ; }
Create the object
53,947
public static function rsaPublicEncrypt ( $ str , $ publicKeyPath , $ padding = OPENSSL_PKCS1_PADDING , $ format = self :: FORMAT_HEX ) { openssl_public_encrypt ( trim ( $ str ) , $ cryrted , openssl_get_publickey ( file_get_contents ( $ publicKeyPath ) ) , $ padding ) ; $ cryrted = trim ( $ cryrted ) ; switch ( $ format ) { case self :: FORMAT_HEX : return bin2hex ( $ cryrted ) ; case self :: FORMAT_BASE64 : return EncodeHelper :: base64Encode ( $ cryrted ) ; } return bin2hex ( $ cryrted ) ; }
RSA Public Encrypt
53,948
public static function rsaPrivateDecrypt ( $ str , $ privateKeyPath , $ passPhrase = '' , $ padding = OPENSSL_PKCS1_PADDING , $ format = self :: FORMAT_HEX ) { $ str = trim ( $ str ) ; switch ( $ format ) { case self :: FORMAT_HEX : $ str = hex2bin ( $ str ) ; break ; case self :: FORMAT_BASE64 : $ str = EncodeHelper :: base64Decode ( $ str ) ; break ; default : $ str = hex2bin ( $ str ) ; } openssl_private_decrypt ( $ str , $ decrypted , openssl_get_privatekey ( file_get_contents ( $ privateKeyPath ) , $ passPhrase ) , $ padding ) ; return trim ( $ decrypted ) ; }
RSA Private Decrypt
53,949
public static function rsaPrivateEncrypt ( $ str , $ privateKeyPath , $ passPhrase = '' , $ padding = OPENSSL_PKCS1_PADDING , $ format = self :: FORMAT_HEX ) { openssl_private_encrypt ( trim ( $ str ) , $ cryrted , openssl_get_privatekey ( file_get_contents ( $ privateKeyPath ) , $ passPhrase ) , $ padding ) ; $ cryrted = trim ( $ cryrted ) ; switch ( $ format ) { case self :: FORMAT_HEX : return bin2hex ( $ cryrted ) ; case self :: FORMAT_BASE64 : return EncodeHelper :: base64Encode ( $ cryrted ) ; } return bin2hex ( $ cryrted ) ; }
RSA Private Encrypt
53,950
public static function rsaPublicDecrypt ( $ str , $ publicKeyPath , $ padding = OPENSSL_PKCS1_PADDING , $ format = self :: FORMAT_HEX ) { $ str = trim ( $ str ) ; switch ( $ format ) { case self :: FORMAT_HEX : $ str = hex2bin ( $ str ) ; break ; case self :: FORMAT_BASE64 : $ str = EncodeHelper :: base64Decode ( $ str ) ; break ; default : $ str = hex2bin ( $ str ) ; } openssl_public_decrypt ( $ str , $ decrypted , openssl_get_publickey ( file_get_contents ( $ publicKeyPath ) ) , $ padding ) ; return trim ( $ decrypted ) ; }
RSA Public Decrypt
53,951
public static function opensslVerify ( $ str , $ sinature , $ publicKeyPath , $ algo = OPENSSL_ALGO_SHA1 , $ format = self :: FORMAT_HEX ) { $ publicKey = openssl_pkey_get_public ( file_get_contents ( $ publicKeyPath ) ) ; $ sinature = trim ( $ sinature ) ; switch ( $ format ) { case self :: FORMAT_HEX : $ sinature = hex2bin ( $ sinature ) ; break ; case self :: FORMAT_BASE64 : $ sinature = EncodeHelper :: base64Decode ( $ sinature ) ; break ; default : $ sinature = hex2bin ( $ sinature ) ; } $ res = openssl_verify ( trim ( $ str ) , $ sinature , $ publicKey , $ algo ) ; openssl_free_key ( $ publicKey ) ; if ( $ res == 1 ) { return true ; } return false ; }
RSA Verify Sign
53,952
public function getExtraPropertiesFor ( $ interface ) { if ( ! $ this -> isInterfaceAvailable ( $ interface ) ) { throw new InvalidArgumentException ( 'Unknown interface: ' . $ interface ) ; } $ interfaceRelation = self :: relation [ $ interface ] ; if ( ! isset ( $ interfaceRelation [ 'extraProperties' ] ) ) { throw new InvalidArgumentException ( 'Interface: ' . $ interface . ' does not support extra properties.' ) ; } return $ interfaceRelation [ 'extraProperties' ] ; }
Get extra properties for an interface
53,953
public static function generate_options ( $ root = null ) { if ( $ root === null ) { $ root = static :: query ( ) -> where ( 'id' , 1 ) -> get_one ( ) ; } $ return = [ ] ; if ( $ root ) { foreach ( $ root -> children ( ) -> get ( ) as $ model ) { if ( $ model -> has_children ( ) ) { $ return [ $ model -> name ] = static :: generate_options ( $ model ) ; } else { $ return [ $ model -> id ] = $ model -> name ; } } } return $ return ; }
Generates an option array for forms
53,954
private function findCssFiles ( $ path ) { $ data = [ ] ; foreach ( Utils \ Finder :: findFiles ( '*.css' ) -> from ( $ path ) as $ row ) { $ data [ ] = $ row -> getPathname ( ) ; } return $ data ; }
Search for CSS files .
53,955
private function applyCssRules ( $ files , $ name ) { $ css = '' ; foreach ( $ files as $ file ) { $ css .= file_get_contents ( $ file ) ; } $ contents = file_put_contents ( $ name , $ this -> rules -> rules ( $ css ) ) ; return $ contents ; }
Apply CSS rules .
53,956
public function run ( ) { if ( ! is_dir ( $ this -> path ) ) { $ message = 'The directory with CSS files was not found.' ; } elseif ( ! $ this -> findCssFiles ( $ this -> path ) ) { $ message = 'The directory does not contain any CSS files.' ; } else { $ this -> applyCssRules ( $ this -> findCssFiles ( $ this -> path ) , $ this -> filename ) ; $ file = 'CSS file: ' . $ this -> filename . ' size: ' . filesize ( $ this -> filename ) . ' Bytes were generated.' ; } return print isset ( $ file ) ? $ file : $ message ; }
Start minimization .
53,957
public function add ( $ class , $ file ) { $ class = $ this -> normalizeClassName ( $ class ) ; if ( $ this -> has ( $ class ) ) { if ( ( $ localFile = $ this -> getFileFor ( $ class ) ) !== $ file ) { throw new ClassAlreadyRegisteredException ( $ class , $ localFile ) ; } } $ this -> classes [ $ class ] = $ file ; return $ this ; }
Add a class entry .
53,958
protected function _family ( ) { $ arr = array ( ) ; $ int_code = $ this -> _unicode ( ) -> value ; foreach ( self :: $ arr_blocks as $ b ) { if ( $ int_code >= $ b [ 'start' ] && $ int_code <= $ b [ 'end' ] ) { $ arr = range ( $ b [ 'start' ] , $ b [ 'end' ] ) ; foreach ( $ arr as $ k => $ v ) { $ arr [ $ k ] = new self ( new N ( $ v ) ) ; } break ; } } if ( count ( $ arr ) ) { return new A ( $ arr ) ; } throw new \ Exception ( 'Invalid character, it is unavailable in any unicode block.' ) ; }
For current character gets all characters of its unicode block .
53,959
protected function _unicode ( ) { $ str_unicode = '' ; $ this -> __get ( 'bytes' ) ; $ this -> col_bytes -> rewind ( ) ; $ int_nb_bytes = count ( $ this -> col_bytes ) ; foreach ( $ this -> col_bytes as $ k => $ src ) { if ( is_string ( $ src ) ) { $ str_bin = ( string ) decbin ( hexdec ( $ src ) ) ; } else { $ str_bin = ( string ) decbin ( $ src -> value ) ; } if ( $ int_nb_bytes > 1 ) { if ( $ k == 0 ) { $ str_unicode .= substr ( $ str_bin , $ int_nb_bytes + 1 ) ; } else { $ str_unicode .= substr ( $ str_bin , 2 ) ; } } else { $ str_unicode .= substr ( $ str_bin , 0 ) ; } } return new N ( bindec ( $ str_unicode ) ) ; }
Get unicode code point for the current character .
53,960
public function httpCode ( $ http_code = 200 , $ protocol = 'HTTP/1.1' ) { $ http_code = intval ( $ http_code ) ; $ status_str = HttpHelper :: get_status_code_message ( $ http_code ) ; if ( $ status_str ) { header ( implode ( ' ' , [ $ protocol , $ http_code , $ status_str ] ) ) ; } }
Send Http Code
53,961
public function setIniPath ( string $ iniPath ) : string { $ this -> iniPath = $ iniPath ? '-c ' . $ iniPath : '' ; return $ this -> iniPath ; }
Set path to php . ini file .
53,962
public function setDirectives ( array $ directives ) : string { $ this -> directives = '' ; foreach ( $ directives as $ key => $ value ) { $ this -> directives .= ' -d ' . $ key ; if ( $ value !== null ) { $ this -> directives .= '=' . $ value ; } } return trim ( $ this -> directives ) ; }
Set custom ini directives to pass to the server .
53,963
public function start ( ) : int { $ cmd = $ this -> getStartCmd ( ) ; exec ( $ cmd , $ output , $ ret ) ; if ( $ ret !== 0 ) { throw new Exception ( 'Error staring build-in server.' ) ; } $ this -> pid = ( int ) $ output [ 0 ] ; usleep ( 100000 ) ; return $ this -> pid ; }
Start web server .
53,964
public function stop ( ) { if ( $ this -> pid ) { exec ( 'kill ' . $ this -> pid , $ output , $ ret ) ; if ( $ ret !== 0 ) { throw new Exception ( 'Error stopping build-in server.' ) ; } $ this -> pid = null ; } }
Stop web server .
53,965
public function getStartCmd ( ) : string { $ cmdFormat = 'php -S %s:%d -t %s %s >/dev/null 2>&1 & echo $!' ; return sprintf ( $ cmdFormat , $ this -> host , $ this -> port , $ this -> docRoot , $ this -> directives , $ this -> iniPath ) ; }
Get command for starting build in HTTP server .
53,966
public function transform ( ) { $ this -> resListCallBack = $ this -> listCallBack -> map ( function ( $ call ) { return new HttpCallBack ( $ call [ 'method' ] , $ call [ 'path' ] , $ call [ 'fn' ] ) ; } ) ; }
Transformar de un array a una lista de objetos .
53,967
public function rutes ( ) { $ this -> resList = $ this -> resListCallBack -> map ( function ( HttpCallBack $ call ) { return new HttpCallBack ( $ call -> getMethod ( ) , $ this -> actual . $ call -> getPath ( ) , $ call -> getFn ( ) ) ; } ) ; }
Transformar las rutas segun la configuracion .
53,968
public function init ( $ config = [ ] ) { if ( isset ( $ config [ 'session_cache' ] ) ) { $ session_type = $ config [ 'session_cache' ] ; } else { $ session_type = $ config [ 'cache_type' ] ; } $ param = new \ stdClass ( ) ; $ param -> type = ( string ) $ session_type ; $ param -> credentials = ( ( $ s = Config :: get ( 'session_cache_settings' ) == '' ) ? Config :: get ( 'cache_settings' ) : $ s ) ; $ this -> engine = CacheManager :: getInstance ( $ param ) ; if ( ! $ this -> engine || ! $ this -> engine -> isConnected ( ) ) return false ; return true ; }
init method to add tables or other needed behaviour
53,969
public function session_read ( $ sessionId ) { $ this -> sessionId = ( string ) $ sessionId ; $ this -> sessionData = $ this -> engine -> get ( $ this -> sessionKey . $ sessionId ) ; if ( ! $ this -> sessionData ) { $ this -> sessionData = [ ] ; } return $ this -> sessionData ; }
reads a specific session
53,970
public function session_write ( $ sessionId , $ sessionData ) { $ sessionData = ( ! $ sessionData || ! is_array ( $ sessionData ) ) ? [ ] : $ sessionData ; $ this -> sessionData = ( ! $ this -> sessionData ) ? [ ] : $ this -> sessionData ; $ this -> sessionData = array_merge ( $ sessionData , $ this -> sessionData ) ; $ this -> engine -> set ( $ this -> sessionKey . $ sessionId , $ this -> sessionData , $ this -> sessionLifeTime ) ; return true ; }
writes a specific session
53,971
public function prepareHacks ( $ fileNames , $ pathNames ) { if ( $ dirs = ini_get ( 'include_path' ) ) { $ pathNames = array_unique ( array_filter ( array_merge ( $ pathNames , explode ( PATH_SEPARATOR , $ dirs ) ) ) ) ; } foreach ( $ fileNames as $ file ) { if ( null === ( $ fileName = $ this -> resolveFile ( $ file , $ pathNames ) ) ) { $ this -> logger -> error ( 'Custom class loader hack {file} not found and has been ignored.' , array ( 'file' => $ file ) ) ; return ; } $ this -> handleHackFile ( $ fileName ) ; } }
Prepare the loader functions .
53,972
public function prepareLegacyHack ( ) { $ logger = $ this -> logger ; $ this -> enumLoader -> add ( function ( $ class ) use ( $ logger ) { if ( substr ( $ class , 0 , 7 ) !== 'Contao\\' ) { try { class_exists ( 'Contao\\' . $ class ) ; } catch ( ParentClassNotFoundException $ exception ) { return null ; } if ( EnumeratingClassLoader :: isLoaded ( 'Contao\\' . $ class ) && ! EnumeratingClassLoader :: isLoaded ( $ class ) ) { class_alias ( 'Contao\\' . $ class , $ class ) ; $ logger -> warning ( 'Loaded class {class} as {alias} from deprecated Contao hack. ' . 'Please specify a custom loader hack if you want to keep this class loaded.' , array ( 'class' => 'Contao\\' . $ class , 'alias' => $ class ) ) ; return true ; } } return null ; } , 'contao.hack' ) ; }
Prepare the Version 1 . 0 compatible Contao class loader hack .
53,973
private function handleHackFile ( $ fileName ) { $ logger = $ this -> logger ; $ previous = spl_autoload_functions ( ) ; include $ fileName ; $ found = $ this -> determineRegisteredAutoLoader ( $ previous ) ; foreach ( $ found as $ index => $ loader ) { $ hackName = basename ( $ fileName ) . '.' . $ index ; $ this -> enumLoader -> add ( $ this -> compileHack ( $ loader , $ hackName ) , $ hackName ) ; } $ logger -> debug ( 'Custom class loader hack {file} loaded {count} auto load functions.' , array ( 'file' => $ fileName , 'count' => count ( $ found ) ) ) ; }
Handle a hack file entry .
53,974
private function resolveFile ( $ fileName , $ pathNames ) { foreach ( $ pathNames as $ pathName ) { if ( file_exists ( $ file = $ pathName . DIRECTORY_SEPARATOR . $ fileName ) ) { return $ file ; } } return null ; }
Resolve the passed file name .
53,975
private function determineRegisteredAutoLoader ( $ previous ) { $ found = array ( ) ; $ after = spl_autoload_functions ( ) ; foreach ( $ after as $ loader ) { if ( ! in_array ( $ loader , $ previous ) ) { spl_autoload_unregister ( $ loader ) ; $ found [ ] = $ loader ; } } return $ found ; }
Determine the auto load functions registered .
53,976
private function compileHack ( $ loader , $ hackName ) { $ logger = $ this -> logger ; return function ( $ class ) use ( $ loader , $ hackName , $ logger ) { if ( call_user_func ( $ loader , $ class ) ) { $ logger -> debug ( 'Custom class loader hack {hackName} loaded {class}.' , array ( 'hackName' => $ hackName , 'class' => $ class ) ) ; return $ hackName ; } if ( EnumeratingClassLoader :: isLoaded ( $ class ) ) { $ logger -> warning ( 'Hack {hackName} appears to have loaded {class} but did return null. It SHOULD return true.' , array ( 'hackName' => $ hackName , 'class' => $ class ) ) ; return $ hackName ; } return null ; } ; }
Compile a hack function .
53,977
protected function registerEntityValidator ( Repository $ config ) { $ this -> app -> singleton ( Factories \ EntityValidationFactory :: class , function ( $ app ) use ( $ config ) { $ factory = new Factories \ EntityValidationFactory ( $ app -> make ( Factories \ HydratorFactory :: class ) , $ app [ 'validator' ] ) ; foreach ( $ config -> get ( 'doctrine_validation.mappings' ) as $ entity => $ rules ) { $ factory -> addEntityRulesMapping ( $ entity , $ app -> make ( $ rules ) ) ; } return $ factory ; } ) ; }
Registers the entity validation mappings
53,978
public function applyAttributes ( array $ attributes ) : ComponentInterface { if ( count ( $ attributes ) > 0 ) { foreach ( $ attributes as $ name => $ value ) { $ this -> setAttribute ( $ name , $ value ) ; } } return $ this ; }
Set up a list of attributes in the form attribute_name = > attribute_value
53,979
protected function getAttributeCode ( ) : string { $ code = '' ; if ( count ( $ this -> getAllAttributes ( ) ) > 0 ) { foreach ( $ this -> getAllAttributes ( ) as $ name => $ value ) { $ code .= " $name=\"$value\"" ; } } return $ code ; }
Returns the attributes html code like id = my_el class = my_class
53,980
protected function getForgeIdServer ( $ servers , $ server_name ) { $ found_server = $ this -> searchServer ( $ servers , 'name' , $ server_name ) ; return $ found_server -> first ( ) ? $ found_server -> first ( ) -> forge_id : null ; }
Get forge id server from server name .
53,981
protected function getForgeName ( $ servers , $ server_id ) { $ found_server = $ this -> searchServer ( $ servers , 'forge_id' , $ server_id ) ; return $ found_server -> first ( ) ? $ found_server -> first ( ) -> name : null ; }
Get forge name from forge id .
53,982
protected function serverIpAddress ( $ servers , $ server_id ) { $ found_server = $ this -> searchServer ( $ servers , 'forge_id' , $ server_id ) ; return $ found_server -> first ( ) ? $ found_server -> first ( ) -> ipAddress : null ; }
Get server ip addres by forge server id .
53,983
protected function searchServer ( $ servers , $ property , $ value ) { return collect ( $ servers ) -> filter ( function ( $ server ) use ( $ property , $ value ) { return $ server -> $ property == $ value ; } ) ; }
Search server by property with a specific value .
53,984
function newUser ( $ fullname , $ credential , array $ identifiers , array $ meta = null ) { $ args = [ 'fullname' => $ fullname , 'credential' => $ credential , 'meta' => $ meta , ] + $ identifiers ; $ response = $ this -> call ( new Command \ Register ( $ args ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Register New User
53,985
function getAccountInfoByUid ( $ uid ) { $ response = $ this -> call ( new Command \ AccountInfo ( $ uid , Command \ AccountInfo :: TYPE_UID ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Get User Account Info By Username
53,986
function listAccountsInfoByUIDs ( array $ uids ) { $ response = $ this -> call ( new Command \ ListAccountsInfo ( $ uids ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
List Users Profile Info By UIDs
53,987
function getAccountInfoByUsername ( $ username ) { $ response = $ this -> call ( new Command \ AccountInfo ( $ username , Command \ AccountInfo :: TYPE_USERNAME ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Get User Account Info By UID
53,988
function confirmValidation ( $ validationHash , array $ codes ) { $ response = $ this -> call ( new Command \ Recover \ Validate ( $ validationHash , $ codes ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Validation Confirm Registration
53,989
function resendAuthCode ( $ validationHash , $ identifierType ) { $ response = $ this -> call ( new Command \ Recover \ ResendCode ( $ validationHash , $ identifierType ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Resend Auth Code To Medium By Identifier Type
53,990
function checkIdentifierGivenToAnyUser ( array $ identifiers ) { $ response = $ this -> call ( new Command \ Members \ Exists ( $ identifiers ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Check That Identifiers Is Given To Any User?
53,991
function whoisIdentifier ( $ type , $ value ) { $ response = $ this -> call ( new Command \ Members \ Whois ( $ type , $ value ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; if ( $ response -> getResponseCode ( ) === 204 ) return null ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Retrieve uid + basic profile from given identifier
53,992
function validateUserIdentifier ( $ userId , $ identifierName ) { $ response = $ this -> call ( new Command \ Members \ ValidateUserIdentifier ( $ userId , $ identifierName ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Request For Identifier Validation
53,993
function getMyAccountInfo ( array $ options = null ) { $ cmd = new Command \ Me \ AccountInfo ; if ( $ options !== null ) $ cmd -> with ( $ cmd :: parseWith ( $ options ) ) ; $ response = $ this -> call ( $ cmd ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Get Token Owner Account Information
53,994
function changeMyPassword ( $ newPassword , $ currentPassword = null ) { $ response = $ this -> call ( new Command \ Me \ ChangePassword ( $ newPassword , $ currentPassword ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; if ( $ currentPassword !== null ) return true ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Change My Password Determined By Token Owner
53,995
function changeMyIdentity ( array $ changedIdentities ) { $ response = $ this -> call ( new Command \ Me \ ChangeIdentity ( $ changedIdentities ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; $ r = ( $ r instanceof iDataEntity ) ? $ r -> get ( 'result' ) : $ r ; return $ r ; }
Change Identifier such as Email Mobile etc ...
53,996
public function init ( ) { parent :: init ( ) ; if ( empty ( $ this -> attachementClass ) ) { throw new \ yii \ base \ Exception ( "attachementClass is required!" ) ; } $ this -> _organizer = Yii :: $ app -> czaHelper -> folderOrganizer ; Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; $ this -> tempPath = Yii :: getAlias ( $ this -> tempPath ) ; if ( ! is_dir ( $ this -> tempPath ) ) { FileHelper :: createDirectory ( $ this -> tempPath , $ this -> dirMode , true ) ; } }
Initializes the action and ensures the temp path exists .
53,997
public function locate ( $ name , $ currentPath = null , $ first = true ) { foreach ( $ this -> locators as $ locator ) { if ( $ locator -> supports ( $ name ) ) { return $ locator -> locate ( $ name , $ currentPath , $ first ) ; } } throw new InvalidArgumentException ( sprintf ( 'The file "%s" could not be found.' , $ name ) ) ; }
Returns a full path for a given file name .
53,998
public function sendActivationMail ( $ user ) { if ( $ user -> activated || ! $ this -> shouldSend ( $ user ) ) { return ; } $ userToken = $ this -> createActivation ( $ user ) ; $ user -> notify ( new ConfirmEmailNotification ( $ userToken ) ) ; }
sends activation code to users upon registration
53,999
public function pluck ( $ key , $ default = null ) { $ value = $ this -> get ( $ key , $ default ) ; $ this -> remove ( $ key ) ; return $ value ; }
Retrieve a value and then remove it .