idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
11,700
public function render ( string $ templatePrefix , array $ data ) : string { $ formLayout = $ this -> layoutManager -> getDefaultLayout ( ) ; if ( $ formLayout instanceof HorizontalFormLayout ) { $ templateName = $ templatePrefix . '_horizontal' ; } else { $ templateName = $ templatePrefix . '_default' ; } $ template =...
Generate the form view .
11,701
public function prepare ( Template $ template ) : void { $ formLayout = $ this -> layoutManager -> getDefaultLayout ( ) ; if ( $ formLayout instanceof HorizontalFormLayout ) { $ template -> labelColClass = $ formLayout -> getLabelColumnClass ( ) ; $ template -> colClass = $ formLayout -> getColumnClass ( ) ; $ template...
Prepare the template by adding grid related classes .
11,702
protected function hasUserVoted ( $ vote ) { $ dql = "SELECT count(v.id) FROM CsnCms\Entity\Vote v LEFT JOIN v.usersVoted u WHERE v.id = ?0 AND u.id =?1" ; $ query = $ this -> entityManager -> createQuery ( $ dql ) ; $ voteId = $ vote -> getId ( ) ; $ user = $ this -> getView ( ) -> identity ( ) ; $ hasUserVoted = - 1 ...
Checks if the current user has already voted for the entity
11,703
public function isValidMime ( ) { $ extension = strtolower ( pathinfo ( $ this -> tmpFile [ 'name' ] , PATHINFO_EXTENSION ) ) ; if ( ! $ extension || ! $ this -> tmpFile [ 'tmp_name' ] ) { return true ; } $ expectedMimes = $ this -> getExpectedMimeTypes ( $ this -> tmpFile ) ; if ( empty ( $ expectedMimes ) ) { throw n...
Check if the temporary file has a valid MIME type for it s extension .
11,704
public function getExpectedMimeTypes ( $ file ) { $ extension = strtolower ( pathinfo ( $ file [ 'name' ] , PATHINFO_EXTENSION ) ) ; if ( ! class_exists ( 'finfo' ) ) { throw new MimeUploadValidatorException ( 'PHP extension finfo is not loaded' ) ; } $ expectedMimes = array ( ) ; $ knownMimes = Config :: inst ( ) -> g...
Fetches an array of valid mimetypes .
11,705
public function compareMime ( $ first , $ second ) { return preg_replace ( $ this -> filterPattern , '' , $ first ) === preg_replace ( $ this -> filterPattern , '' , $ second ) ; }
Check two MIME types roughly match eachother .
11,706
public function getViewPath ( ) { if ( ! $ this -> base ) { return $ this -> view ; } return rtrim ( $ this -> base , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . ltrim ( $ this -> view , DIRECTORY_SEPARATOR ) ; }
Returns the full path to the view .
11,707
public function requireView ( ) { if ( ! $ this -> view ) { return '' ; } extract ( $ this -> vars ) ; ob_start ( ) ; require $ this -> getViewPath ( ) ; return ob_get_clean ( ) ; }
Requires the view in its own scope with etracted variables and returns the buffered output .
11,708
public function sendHeaders ( ) { foreach ( $ this -> headers as $ args ) { $ func = array_shift ( $ args ) ; call_user_func_array ( $ func , $ args ) ; } }
Outputs the buffered calls to header setcookie etc .
11,709
public static function connect ( $ config = array ( ) ) { $ ldap_check = self :: checkLDAPExtension ( ) ; if ( self :: iserror ( $ ldap_check ) ) { return $ ldap_check ; } @ $ obj = new Net_LDAP2 ( $ config ) ; $ err = $ obj -> bind ( ) ; if ( self :: isError ( $ err ) ) { return $ err ; } return $ obj ; }
Configure Net_LDAP2 connect and bind
11,710
protected function setConfig ( $ config ) { if ( ! is_array ( $ config ) ) { return ; } foreach ( $ config as $ k => $ v ) { if ( isset ( $ this -> _config [ $ k ] ) ) { $ this -> _config [ $ k ] = $ v ; } else { switch ( $ k ) { case "dn" : $ this -> _config [ "binddn" ] = $ v ; break ; case "password" : $ this -> _co...
Sets the internal configuration array
11,711
public function bind ( $ dn = null , $ password = null ) { if ( is_null ( $ dn ) ) { $ dn = $ this -> _config [ "binddn" ] ; } if ( is_null ( $ password ) ) { $ password = $ this -> _config [ "bindpw" ] ; } if ( $ this -> _link === false ) { $ olddn = $ this -> _config [ "binddn" ] ; $ oldpw = $ this -> _config [ "bind...
Bind or rebind to the ldap - server
11,712
protected function performReconnect ( ) { if ( $ this -> _link !== false ) { return true ; } $ current_error = new PEAR_Error ( 'Unknown connection error' ) ; sleep ( $ this -> _config [ 'current_backoff' ] ) ; $ this -> _down_host_list = array ( ) ; $ msg = $ this -> performConnect ( ) ; if ( self :: isError ( $ msg )...
Reconnect to the ldap - server .
11,713
public function startTLS ( ) { $ rootDSE = $ this -> rootDse ( ) ; if ( self :: isError ( $ rootDSE ) ) { } else { $ supported_extensions = $ rootDSE -> getValue ( 'supportedExtension' ) ; if ( self :: isError ( $ supported_extensions ) ) { } else { if ( ! in_array ( '1.3.6.1.4.1.1466.20037' , $ supported_extensions ) ...
Starts an encrypted session
11,714
public function add ( $ entry ) { if ( ! $ entry instanceof Net_LDAP2_Entry ) { return PEAR :: raiseError ( 'Parameter to Net_LDAP2::add() must be a Net_LDAP2_Entry object.' ) ; } $ foo = 0 ; while ( true ) { $ link = $ this -> getLink ( ) ; if ( $ link === false ) { return PEAR :: raiseError ( "Could not add entry " ....
Add a new entryobject to a directory .
11,715
public function delete ( $ dn , $ recursive = false ) { if ( $ dn instanceof Net_LDAP2_Entry ) { $ dn = $ dn -> dn ( ) ; } if ( false === is_string ( $ dn ) ) { return PEAR :: raiseError ( "Parameter is not a string nor an entry object!" ) ; } if ( $ recursive ) { $ result = @ ldap_list ( $ this -> _link , $ dn , '(obj...
Delete an entry from the directory
11,716
public function modify ( $ entry , $ parms = array ( ) ) { if ( is_string ( $ entry ) ) { $ entry = $ this -> getEntry ( $ entry ) ; if ( self :: isError ( $ entry ) ) { return $ entry ; } } if ( ! $ entry instanceof Net_LDAP2_Entry ) { return PEAR :: raiseError ( "Parameter is not a string nor an entry object!" ) ; } ...
Modify an ldapentry directly on the server
11,717
public function setOption ( $ option , $ value ) { if ( $ this -> _link ) { if ( defined ( $ option ) ) { if ( @ ldap_set_option ( $ this -> _link , constant ( $ option ) , $ value ) ) { return true ; } else { $ err = @ ldap_errno ( $ this -> _link ) ; if ( $ err ) { $ msg = @ ldap_err2str ( $ err ) ; } else { $ err = ...
Set an LDAP option
11,718
public function getOption ( $ option ) { if ( $ this -> _link ) { if ( defined ( $ option ) ) { if ( @ ldap_get_option ( $ this -> _link , constant ( $ option ) , $ value ) ) { return $ value ; } else { $ err = @ ldap_errno ( $ this -> _link ) ; if ( $ err ) { $ msg = @ ldap_err2str ( $ err ) ; } else { $ err = NET_LDA...
Get an LDAP option value
11,719
public function getLDAPVersion ( ) { if ( $ this -> _link ) { $ version = $ this -> getOption ( "LDAP_OPT_PROTOCOL_VERSION" ) ; } else { $ version = $ this -> _config [ 'version' ] ; } return $ version ; }
Get the LDAP_PROTOCOL_VERSION that is used on the connection .
11,720
public function setLDAPVersion ( $ version = 0 , $ force = false ) { if ( ! $ version ) { $ version = $ this -> _config [ 'version' ] ; } if ( ! $ force ) { $ rootDSE = $ this -> rootDse ( ) ; if ( $ rootDSE instanceof Net_LDAP2_Error ) { return $ rootDSE ; } else { $ supported_versions = $ rootDSE -> getValue ( 'suppo...
Set the LDAP_PROTOCOL_VERSION that is used on the connection .
11,721
public function dnExists ( $ dn ) { if ( PEAR :: isError ( $ dn ) ) { return $ dn ; } if ( $ dn instanceof Net_LDAP2_Entry ) { $ dn = $ dn -> dn ( ) ; } if ( false === is_string ( $ dn ) ) { return PEAR :: raiseError ( 'Parameter $dn is not a string nor an entry object!' ) ; } $ s_opts = array ( 'scope' => 'base' , 'si...
Tells if a DN does exist in the directory
11,722
public function getEntry ( $ dn , $ attr = array ( ) ) { if ( ! is_array ( $ attr ) ) { $ attr = array ( $ attr ) ; } $ result = $ this -> search ( $ dn , '(objectClass=*)' , array ( 'scope' => 'base' , 'attributes' => $ attr ) ) ; if ( self :: isError ( $ result ) ) { return $ result ; } elseif ( $ result -> count ( )...
Get a specific entry based on the DN
11,723
public function move ( $ entry , $ newdn , $ target_ldap = null ) { if ( is_string ( $ entry ) ) { $ entry_o = $ this -> getEntry ( $ entry ) ; } else { $ entry_o = $ entry ; } if ( ! $ entry_o instanceof Net_LDAP2_Entry ) { return PEAR :: raiseError ( 'Parameter $entry is expected to be a Net_LDAP2_Entry object! (If D...
Rename or move an entry
11,724
public function copy ( $ entry , $ newdn ) { if ( ! $ entry instanceof Net_LDAP2_Entry ) { return PEAR :: raiseError ( 'Parameter $entry is expected to be a Net_LDAP2_Entry object!' ) ; } $ newentry = Net_LDAP2_Entry :: createFresh ( $ newdn , $ entry -> getValues ( ) ) ; $ result = $ this -> add ( $ newentry ) ; if ( ...
Copy an entry to a new location
11,725
public static function errorMessage ( $ errorcode ) { $ errorMessages = array ( 0x00 => "LDAP_SUCCESS" , 0x01 => "LDAP_OPERATIONS_ERROR" , 0x02 => "LDAP_PROTOCOL_ERROR" , 0x03 => "LDAP_TIMELIMIT_EXCEEDED" , 0x04 => "LDAP_SIZELIMIT_EXCEEDED" , 0x05 => "LDAP_COMPARE_FALSE" , 0x06 => "LDAP_COMPARE_TRUE" , 0x07 => "LDAP_AU...
Returns the string for an ldap errorcode .
11,726
public function rootDse ( $ attrs = null ) { if ( $ attrs !== null && ! is_array ( $ attrs ) ) { return PEAR :: raiseError ( 'Parameter $attr is expected to be an array!' ) ; } $ attrs_signature = serialize ( $ attrs ) ; if ( true || ! array_key_exists ( $ attrs_signature , $ this -> _rootDSE_cache ) ) { $ rootdse = Ne...
Gets a rootDSE object
11,727
public function schema ( $ dn = null ) { if ( $ this -> _schema === null ) { if ( $ this -> _schema_cache ) { $ cached_schema = $ this -> _schema_cache -> loadSchema ( ) ; if ( $ cached_schema instanceof Net_LDAP2_Error ) { return $ cached_schema ; } else { if ( $ cached_schema instanceof Net_LDAP2_Schema ) { $ this ->...
Get a schema object
11,728
public function init ( ) { if ( ! Yii :: $ app -> has ( 'bugsnag' ) ) { throw new InvalidConfigException ( 'BugsnagAsset requires Bugsnag component to be enabled' ) ; } if ( ! in_array ( $ this -> version , [ 2 , 3 ] ) ) { throw new InvalidConfigException ( 'Bugsnag javascript only supports version 2 or 3' ) ; } $ this...
Initiates Bugsnag javascript registration
11,729
private function registerJavascript ( ) { $ filePath = '//d2wy8f7a9ursnm.cloudfront.net/bugsnag-' . $ this -> version . '.js' ; if ( ! $ this -> useCdn ) { $ this -> sourcePath = '@bower/bugsnag/src' ; $ filePath = 'bugsnag.js' ; if ( ! file_exists ( Yii :: getAlias ( $ this -> sourcePath . '/' . $ filePath ) ) ) { thr...
Registers Bugsnag JavaScript to page
11,730
public function getCharacter ( $ morse ) { $ key = strtr ( $ morse , '.-' , '01' ) ; return isset ( $ this -> reversedTable [ $ key ] ) ? $ this -> reversedTable [ $ key ] : false ; }
Get character for given morse code
11,731
public static function createParameters ( ) { $ database = parse_url ( getenv ( 'DATABASE_URL' ) ) ; putenv ( sprintf ( 'SYMFONY__DATABASE_HOST=%s' , $ database [ 'host' ] ) ) ; putenv ( sprintf ( 'SYMFONY__DATABASE_PORT=%s' , $ database [ 'port' ] ) ) ; putenv ( sprintf ( 'SYMFONY__DATABASE_USER=%s' , $ database [ 'us...
Creates parameters .
11,732
private function showControls ( ) { $ jsClassName = 'js-audio-widget-action' ; foreach ( $ this -> settings [ 'controls' ] as $ key => $ value ) { if ( $ value ) { $ cssClassName = 'audio-widget-' . $ key ; $ options [ 'class' ] = $ cssClassName . ' ' . $ jsClassName ; $ options [ 'data-action' ] = $ key ; echo Html ::...
Show widget controls
11,733
private function setSettingsForJs ( ) { if ( ArrayHelper :: keyExists ( 'fileUrl' , $ this -> settings , false ) && ! empty ( $ this -> settings [ 'fileUrl' ] ) ) { $ this -> widgetSettings [ 'fileUrl' ] = $ this -> settings [ 'fileUrl' ] ; } else { throw new ElementNotFound ( 'fileUrl was not set' ) ; } if ( ArrayHelp...
Set settings for js widget
11,734
private function registerWidgetScripts ( ) { $ view = $ this -> getView ( ) ; $ asset = Yii :: $ container -> get ( Asset :: className ( ) ) ; $ asset :: register ( $ view ) ; $ this -> widgetSettings = Json :: encode ( $ this -> widgetSettings ) ; $ view -> registerJs ( "var audioWidget = new AudioWidget(" . $ this ->...
Register widget asset
11,735
final public function call ( $ providerName ) { $ configProviderClass = "SMSFactory\\Config\\$providerName" ; $ providerClass = "SMSFactory\\Providers\\$providerName" ; if ( class_exists ( $ providerClass ) === true ) { return new $ providerClass ( new $ configProviderClass ( $ this -> config [ $ providerName ] ) ) ; }...
Get SMS provider
11,736
public function useRotatingFiles ( $ level = Logger :: DEBUG , $ filename = null ) { $ filename || $ filename = $ this -> name . '.log' ; $ path = $ this -> settings [ 'directory' ] . '/' . $ filename ; $ this -> monolog -> pushHandler ( $ handler = new Handler \ RotatingFileHandler ( $ path , 5 , $ level ) ) ; $ handl...
Register a rotating file log handler .
11,737
public function register ( Container $ container ) { $ settings = $ container -> get ( 'settings' ) ; if ( ! isset ( $ settings [ 'logger' ] ) ) { throw new InvalidArgumentException ( 'Logger configuration not found' ) ; } $ basename = isset ( $ settings [ 'basename' ] ) ? $ settings [ 'basename' ] : 'slim-app' ; $ con...
Register this monolog provider with a Pimple container
11,738
public static function fromSignatureData ( string $ data , AlgorithmIdentifierType $ algo ) : Signature { if ( $ algo instanceof RSASignatureAlgorithmIdentifier ) { return RSASignature :: fromSignatureString ( $ data ) ; } if ( $ algo instanceof ECSignatureAlgorithmIdentifier ) { return ECSignature :: fromDER ( $ data ...
Get signature object by signature data and used algorithm .
11,739
protected function addLinkArgument ( $ func , $ args ) { if ( ! isset ( $ this -> link_arg [ $ func ] ) ) { return $ args ; } if ( count ( $ args ) >= $ this -> link_arg [ $ func ] ) { return $ args ; } $ args [ ] = $ this -> link ; return $ args ; }
Given a MySQL function name and an array of arguments adds the link identifier to the end of the arguments if one is needed .
11,740
protected function lazyConnect ( $ func ) { if ( $ this -> link ) { return ; } if ( ! isset ( $ this -> link_arg [ $ func ] ) ) { return ; } $ this -> link = mysql_connect ( $ this -> server , $ this -> username , $ this -> password , $ this -> new_link , $ this -> client_flags ) ; if ( ! $ this -> link ) { throw new R...
Given a MySQL function name connects to the server if there is no link and identifier and one is needed .
11,741
public function loadSchema ( ) { $ return = false ; if ( file_exists ( $ this -> config [ 'path' ] ) ) { $ cache_maxage = filemtime ( $ this -> config [ 'path' ] ) + $ this -> config [ 'max_age' ] ; if ( time ( ) <= $ cache_maxage || $ this -> config [ 'max_age' ] == 0 ) { $ return = unserialize ( file_get_contents ( $...
Return the schema object from the cache
11,742
public function reorder ( $ middle = true ) { $ result = 0 ; \ Yii :: $ app -> getDb ( ) -> transaction ( function ( ) use ( & $ result , $ middle ) { $ list = $ this -> getQueryInternal ( ) -> select ( $ this -> owner -> primaryKey ( ) ) -> orderBy ( [ $ this -> sortAttribute => SORT_ASC ] ) -> asArray ( ) -> all ( ) ...
Reorders items with values of sortAttribute begin from zero .
11,743
public function privateKey ( ) : PrivateKey { $ algo = $ this -> algorithmIdentifier ( ) ; switch ( $ algo -> oid ( ) ) { case AlgorithmIdentifier :: OID_RSA_ENCRYPTION : return RSA \ RSAPrivateKey :: fromDER ( $ this -> _privateKeyData ) ; case AlgorithmIdentifier :: OID_EC_PUBLIC_KEY : $ pk = EC \ ECPrivateKey :: fro...
Get private key .
11,744
protected function parseBody ( array $ body ) { $ jobs = [ ] ; if ( ! empty ( $ body ) ) { if ( is_string ( $ body [ 0 ] ) ) { foreach ( $ body as $ element ) { $ jobs [ ] = [ 'id' => $ element ] ; } } else { $ keyValueResponse = new KeyValueResponse ( ) ; $ keyValueResponse -> setCommand ( $ this -> command ) ; foreac...
Parse main body
11,745
private static function _versionToEKB ( int $ version ) : int { static $ lut ; if ( $ version > 255 ) { return $ version ; } if ( ! isset ( $ lut ) ) { $ lut = array_flip ( self :: EKB_TABLE ) ; } return $ lut [ $ version ] ; }
Translate version number to number of effective key bits .
11,746
public function toMorse ( $ text ) { $ text = strtoupper ( $ text ) ; $ words = preg_split ( '#\s+#' , $ text ) ; $ morse = array_map ( [ $ this , 'morseWord' ] , $ words ) ; return implode ( $ this -> wordSeparator , $ morse ) ; }
Translate the given text to morse code
11,747
public function fromMorse ( $ morse ) { $ morse = str_replace ( $ this -> invalidCharacterReplacement . ' ' , '' , $ morse ) ; $ words = explode ( $ this -> wordSeparator , $ morse ) ; $ morse = array_map ( [ $ this , 'translateMorseWord' ] , $ words ) ; return implode ( ' ' , $ morse ) ; }
Translate the given morse code to text
11,748
private function translateMorseWord ( $ morse ) { $ morseChars = explode ( ' ' , $ morse ) ; $ characters = array_map ( [ $ this , 'translateMorseCharacter' ] , $ morseChars ) ; return implode ( '' , $ characters ) ; }
Translate a morse word to text
11,749
private function morseWord ( $ word ) { $ chars = $ this -> strSplit ( $ word ) ; $ morse = array_map ( [ $ this , 'morseCharacter' ] , $ chars ) ; return implode ( ' ' , $ morse ) ; }
Return the morse code for this word
11,750
private function morseCharacter ( $ char ) { if ( ! isset ( $ this -> table [ $ char ] ) ) { return $ this -> invalidCharacterReplacement ; } return $ this -> table -> getMorse ( $ char ) ; }
Return the morse code for this character
11,751
public static function fromCoordinates ( $ x , $ y , $ named_curve = null , $ bits = null ) : ECPublicKey { if ( ! isset ( $ bits ) && isset ( $ named_curve ) ) { $ bits = self :: _curveSize ( $ named_curve ) ; } $ mlen = null ; if ( isset ( $ bits ) ) { $ mlen = ( int ) ceil ( $ bits / 8 ) ; } $ x_os = ECConversion ::...
Initialize from curve point coordinates .
11,752
public function curvePointOctets ( ) : array { if ( $ this -> isCompressed ( ) ) { throw new \ RuntimeException ( "EC point compression not supported." ) ; } $ str = substr ( $ this -> _ecPoint , 1 ) ; list ( $ x , $ y ) = str_split ( $ str , ( int ) floor ( strlen ( $ str ) / 2 ) ) ; return [ $ x , $ y ] ; }
Get curve point coordinates in octet string representation .
11,753
public static function fromPEM ( PEM $ pem ) { switch ( $ pem -> type ( ) ) { case PEM :: TYPE_RSA_PUBLIC_KEY : return RSA \ RSAPublicKey :: fromDER ( $ pem -> data ( ) ) ; case PEM :: TYPE_PUBLIC_KEY : return PublicKeyInfo :: fromPEM ( $ pem ) -> publicKey ( ) ; } throw new \ UnexpectedValueException ( "PEM type " . $...
Initialize public key from PEM .
11,754
public function count ( IlluminateModel $ model ) { if ( ! $ model instanceof CounterCacheable ) { Log :: error ( sprintf ( '[%s] Model [%s] does not implement CounterCacheable.' , __CLASS__ , get_class ( $ model ) ) ) ; throw new NotCounterCacheableException ( sprintf ( 'Model [%s] does not implement CounterCacheable....
Perform counter caching on model .
11,755
public function countAll ( IlluminateModel $ model ) { $ entities = $ model -> get ( ) ; if ( ! $ entities -> isEmpty ( ) ) { Log :: error ( sprintf ( '[%s] No entities found of model [%s]' , __CLASS__ , get_class ( $ model ) ) ) ; throw new NoEntitiesFoundException ( sprintf ( 'No entities found of model [%s]' , get_c...
Perform counter caching on all entities of model .
11,756
protected function updateCount ( IlluminateModel $ model , IlluminateRelation $ relation , $ counterCacheConditions , $ foreignKey , $ counterCacheColumnName ) { $ relationTableName = $ relation -> getModel ( ) -> getTable ( ) ; $ countQuery = $ model -> newQuery ( ) -> select ( DB :: raw ( sprintf ( 'COUNT(%s.id)' , $...
Update counter cache column .
11,757
public function entries ( ) { $ entries = array ( ) ; if ( false === $ this -> _entry_cache ) { while ( $ entry = $ this -> shiftEntry ( ) ) { $ entries [ ] = $ entry ; } $ this -> _entry_cache = $ entries ; } return $ this -> _entry_cache ; }
Returns an array of entry objects .
11,758
public function shiftEntry ( ) { if ( is_null ( $ this -> _entry ) ) { if ( ! $ this -> _entry = @ ldap_first_entry ( $ this -> _link , $ this -> _search ) ) { $ false = false ; return $ false ; } $ entry = Net_LDAP2_Entry :: createConnected ( $ this -> _ldap , $ this -> _entry ) ; if ( $ entry instanceof PEAR_Error ) ...
Get the next entry in the searchresult from LDAP server .
11,759
public function popEntry ( ) { if ( false === $ this -> _entry_cache ) { $ this -> _entry_cache = $ this -> entries ( ) ; } $ return = array_pop ( $ this -> _entry_cache ) ; return ( null === $ return ) ? false : $ return ; }
Retrieve the next entry in the searchresult but starting from last entry
11,760
public function sorted_as_struct ( $ attrs = array ( 'cn' ) , $ order = SORT_ASC ) { if ( ! is_array ( $ attrs ) ) { return PEAR :: raiseError ( "Sorting failed: Parameterlist must be an array!" ) ; } if ( $ order != SORT_ASC && $ order != SORT_DESC ) { return PEAR :: raiseError ( "Sorting failed: sorting direction not...
Return entries sorted as array
11,761
public function sorted ( $ attrs = array ( 'cn' ) , $ order = SORT_ASC ) { $ return = array ( ) ; $ sorted = $ this -> sorted_as_struct ( $ attrs , $ order ) ; if ( PEAR :: isError ( $ sorted ) ) { return $ sorted ; } foreach ( $ sorted as $ key => $ row ) { $ entry = $ this -> _ldap -> getEntry ( $ row [ 'dn' ] , $ th...
Return entries sorted as objects
11,762
public function as_struct ( ) { $ return = array ( ) ; $ entries = $ this -> entries ( ) ; foreach ( $ entries as $ entry ) { $ attrs = array ( ) ; $ entry_attributes = $ entry -> attributes ( ) ; foreach ( $ entry_attributes as $ attr_name ) { $ attr_values = $ entry -> getValue ( $ attr_name , 'all' ) ; if ( ! is_arr...
Return entries as array
11,763
public function count ( ) { if ( ! $ this -> _search ) { return 0 ; } if ( $ this -> _count_cache === null ) { $ this -> _count_cache = @ ldap_count_entries ( $ this -> _link , $ this -> _search ) ; } return $ this -> _count_cache ; }
Returns the number of entries in the searchresult
11,764
public function onBuildContextConfig ( BuildContextConfig $ command ) : void { $ context = $ command -> getContext ( ) ; if ( ! $ context instanceof ThemeContext ) { return ; } $ theme = ThemeModel :: findByPk ( $ context -> getThemeId ( ) ) ; if ( ! $ theme ) { return ; } $ templateConfig = [ ] ; $ templateConfig = $ ...
Build the context config .
11,765
private function buildGravatarConfig ( ThemeModel $ theme , array $ config ) : array { $ file = FilesModel :: findByPk ( $ theme -> bs_gravatar_default ) ; if ( $ file ) { $ config [ 'gravatar' ] [ 'default' ] = Environment :: get ( 'base' ) . $ file -> path ; } if ( $ theme -> bs_gravatar_size ) { $ config [ 'gravatar...
Build the gravatar config .
11,766
public function Connected ( ) { if ( ! empty ( $ this -> smtp_conn ) ) { $ sock_status = socket_get_status ( $ this -> smtp_conn ) ; if ( $ sock_status [ "eof" ] ) { if ( $ this -> do_debug >= 1 ) { $ this -> edebug ( "SMTP -> NOTICE:" . $ this -> CRLF . "EOF caught while checking if connected" ) ; } $ this -> Close ( ...
Returns true if connected to a server otherwise false
11,767
public function create ( $ path , array $ data ) { $ data = array_merge ( $ data , [ 'path' => $ path ] ) ; return File :: create ( $ data ) ; }
Creates a new record for a semi - permanent uploaded file .
11,768
public function delete ( $ id , $ unlink = true ) { if ( ! ( $ file = $ this -> findById ( $ id ) ) ) { return true ; } if ( FileFacade :: exists ( $ file -> path ) ) { FileFacade :: delete ( $ file -> path ) ; } return $ file -> delete ( ) ; }
Deletes an uploaded file .
11,769
public function cleanup ( ) { $ fileIds = File :: query ( ) -> where ( 'created_at' , '<' , Carbon :: now ( ) -> subMinutes ( $ this -> getGarbageAgeInMinutes ( ) ) ) -> pluck ( 'id' ) ; if ( ! count ( $ fileIds ) ) { return 0 ; } $ success = 0 ; foreach ( $ fileIds as $ fileId ) { $ success += ( int ) $ this -> delete...
Cleans up old upload records and files .
11,770
private function calculateNodePriority ( Node $ node , $ currentNodeId ) { $ priority = $ node -> getJobCount ( ) ; if ( $ node -> getId ( ) === $ currentNodeId ) { $ margin = 1 + $ this -> marginToSwitch ; $ priority = $ priority * $ margin ; } $ disquePriority = $ node -> getPriority ( ) ; if ( $ disquePriority < Nod...
Calculate the node priority from its job count stick to the current node
11,771
public function generateUrl ( $ email , $ size = null , $ default = null ) { if ( $ size == null ) { $ size = $ this -> environment -> getConfig ( ) -> get ( [ 'templates' , 'gravatar' , 'size' ] ) ; } if ( $ default == null ) { $ default = $ this -> environment -> getConfig ( ) -> get ( [ 'templates' , 'gravatar' , 'd...
Generate the gravatar url .
11,772
public function getAssetPath ( string $ sourcePath ) { $ manifest = $ this -> readFile ( ) ; $ path = $ this -> pathHelper -> prefix ( $ sourcePath ) ; if ( ! array_key_exists ( $ path , $ manifest ) ) { throw new Exception ( "Unable to locate path '{$path}' in Mix manifest." ) ; } return $ this -> urlHelper -> getUrl ...
Get mapped asset path from manifest file
11,773
protected function getFile ( ) { $ path = $ this -> directory . '/' . self :: MANIFEST_FILENAME ; $ file = $ this -> pathHelper -> getPublicPath ( $ path , true ) ; return $ file ; }
Get manifest file
11,774
protected function readFile ( ) { $ file = $ this -> getFile ( ) ; $ raw = $ this -> ioHelper -> getFileContents ( $ file ) ; return $ this -> jsonHelper -> decode ( $ raw ) ; }
Read & decode contents of manifest file
11,775
public static function algoForAsymmetricCrypto ( AsymmetricCryptoAlgorithmIdentifier $ crypto_algo , HashAlgorithmIdentifier $ hash_algo ) : SignatureAlgorithmIdentifier { switch ( $ crypto_algo -> oid ( ) ) { case AlgorithmIdentifier :: OID_RSA_ENCRYPTION : $ oid = self :: _oidForRSA ( $ hash_algo ) ; break ; case Alg...
Get signature algorithm identifier of given asymmetric cryptographic type utilizing given hash algorithm .
11,776
private static function _oidForRSA ( HashAlgorithmIdentifier $ hash_algo ) : string { if ( ! array_key_exists ( $ hash_algo -> oid ( ) , self :: MAP_RSA_OID ) ) { throw new \ UnexpectedValueException ( sprintf ( "No RSA signature algorithm for %s." , $ hash_algo -> name ( ) ) ) ; } return self :: MAP_RSA_OID [ $ hash_a...
Get RSA signature algorithm OID for the given hash algorithm identifier .
11,777
private static function _oidForEC ( HashAlgorithmIdentifier $ hash_algo ) : string { if ( ! array_key_exists ( $ hash_algo -> oid ( ) , self :: MAP_EC_OID ) ) { throw new \ UnexpectedValueException ( sprintf ( "No EC signature algorithm for %s." , $ hash_algo -> name ( ) ) ) ; } return self :: MAP_EC_OID [ $ hash_algo ...
Get EC signature algorithm OID for the given hash algorithm identifier .
11,778
public function serialize ( ) { return serialize ( array ( $ this -> name , $ this -> value , $ this -> code , $ this -> line ) ) ; }
Serializes the token .
11,779
public function unserialize ( $ serialized ) { list ( $ this -> name , $ this -> value , $ this -> code , $ this -> line ) = unserialize ( $ serialized ) ; }
Unserializes the token
11,780
public function withInitializationVector ( $ iv ) : self { $ this -> _checkIVSize ( $ iv ) ; $ obj = clone $ this ; $ obj -> _initializationVector = $ iv ; return $ obj ; }
Get copy of the object with given initialization vector .
11,781
public function getNormalizedValidationRules ( ) { $ rules = json_decode ( $ this -> get ( 'validation' ) , true ) ; if ( ! is_string ( $ rules ) && ! is_array ( $ rules ) ) { return null ; } return $ rules ; }
Returns validation rules as string or array . Anything else will return null .
11,782
public function loadSchema ( ) { if ( ! isset ( $ _SESSION ) ) { return new Net_LDAP2_Error ( __CLASS__ . ": No PHP Session initialized." . " This cache needs an open PHP session." ) ; } if ( array_key_exists ( __CLASS__ , $ _SESSION ) && $ _SESSION [ __CLASS__ ] instanceof Net_LDAP2_SchemaCache ) { return $ _SESSION [...
Load schema from session
11,783
public function getClass ( string $ oid ) { if ( array_key_exists ( $ oid , self :: MAP_OID_TO_CLASS ) ) { return self :: MAP_OID_TO_CLASS [ $ oid ] ; } foreach ( $ this -> _additionalProviders as $ provider ) { if ( $ provider -> supportsOID ( $ oid ) ) { return $ provider -> getClassByOID ( $ oid ) ; } } return null ...
Get the name of a class that implements algorithm identifier for given OID .
11,784
public function parse ( Sequence $ seq ) : AlgorithmIdentifier { $ oid = $ seq -> at ( 0 ) -> asObjectIdentifier ( ) -> oid ( ) ; $ params = $ seq -> has ( 1 ) ? $ seq -> at ( 1 ) : null ; $ cls = $ this -> getClass ( $ oid ) ; if ( $ cls ) { return $ cls :: fromASN1Params ( $ params ) ; } return new GenericAlgorithmId...
Parse AlgorithmIdentifier from an ASN . 1 sequence .
11,785
public static function fetch ( $ ldap , $ attrs = null ) { if ( ! $ ldap instanceof Net_LDAP2 ) { return PEAR :: raiseError ( "Unable to fetch Schema: Parameter \$ldap must be a Net_LDAP2 object!" ) ; } if ( is_array ( $ attrs ) && count ( $ attrs ) > 0 ) { $ attributes = $ attrs ; } else { $ attributes = array ( 'vend...
Fetches a RootDSE object from an LDAP connection
11,786
protected function checkAttr ( $ values , $ attr ) { if ( ! is_array ( $ values ) ) $ values = array ( $ values ) ; foreach ( $ values as $ value ) { if ( ! @ in_array ( $ value , $ this -> get_value ( $ attr , 'all' ) ) ) { return false ; } } return true ; }
Checks for existance of value in attribute
11,787
protected function fixPath ( $ path ) { $ len = strlen ( $ this -> front ) ; if ( substr ( $ path , 0 , $ len ) == $ this -> front ) { $ path = substr ( $ path , $ len ) ; } return '/' . ltrim ( $ path , '/' ) ; }
Fixes the incoming URL path to strip the front controller script name .
11,788
protected function fixFileRoute ( $ route ) { if ( ! $ this -> pages_dir ) { throw new RuntimeException ( 'No pages directory specified.' ) ; } $ page = realpath ( $ this -> pages_dir . $ route ) ; if ( $ this -> pageExists ( $ page ) ) { return $ page ; } if ( $ this -> isFileRoute ( $ this -> not_found_route ) ) { re...
Fixes a file route specification by finding the real path to see if it exists in the pages directory and is readable .
11,789
protected function pageExists ( $ file ) { $ file = str_replace ( DIRECTORY_SEPARATOR , '/' , $ file ) ; return $ file != '' && substr ( $ file , 0 , strlen ( $ this -> pages_dir ) ) == $ this -> pages_dir && file_exists ( $ file ) && is_readable ( $ file ) ; }
Does the pages directory have a matching readable file?
11,790
public static function fromDER ( string $ data ) : RSAPublicKey { return self :: fromASN1 ( UnspecifiedType :: fromDER ( $ data ) -> asSequence ( ) ) ; }
Initialize from DER data .
11,791
public static function escape_dn_value ( $ values = array ( ) ) { if ( ! is_array ( $ values ) ) { $ values = array ( $ values ) ; } foreach ( $ values as $ key => $ val ) { $ val = str_replace ( '\\' , '\\\\' , $ val ) ; $ val = str_replace ( ',' , '\,' , $ val ) ; $ val = str_replace ( '+' , '\+' , $ val ) ; $ val = ...
Escapes a DN value according to RFC 2253
11,792
public static function escape_filter_value ( $ values = array ( ) ) { if ( ! is_array ( $ values ) ) { $ values = array ( $ values ) ; } foreach ( $ values as $ key => $ val ) { $ val = str_replace ( '\\' , '\5c' , $ val ) ; $ val = str_replace ( '*' , '\2a' , $ val ) ; $ val = str_replace ( '(' , '\28' , $ val ) ; $ v...
Escapes the given VALUES according to RFC 2254 so that they can be safely used in LDAP filters .
11,793
public static function asc2hex32 ( $ string ) { for ( $ i = 0 ; $ i < strlen ( $ string ) ; $ i ++ ) { $ char = substr ( $ string , $ i , 1 ) ; if ( ord ( $ char ) < 32 ) { $ hex = dechex ( ord ( $ char ) ) ; if ( strlen ( $ hex ) == 1 ) $ hex = '0' . $ hex ; $ string = str_replace ( $ char , '\\' . $ hex , $ string ) ...
Converts all ASCII chars < 32 to \ HEX
11,794
public static function split_rdn_multival ( $ rdn ) { $ rdns = preg_split ( '/(?<!\\\\)\+/' , $ rdn ) ; $ rdns = self :: correct_dn_splitting ( $ rdns , '+' ) ; return array_values ( $ rdns ) ; }
Split an multivalued RDN value into an Array
11,795
public static function split_attribute_string ( $ attr , $ extended = false , $ withDelim = false ) { if ( $ withDelim ) $ withDelim = PREG_SPLIT_DELIM_CAPTURE ; if ( ! $ extended ) { return preg_split ( '/(?<!\\\\)(=)/' , $ attr , 2 , $ withDelim ) ; } else { return preg_split ( '/(?<!\\\\)(>=|<=|>|<|~=|=)/' , $ attr ...
Splits an attribute = value syntax into an array
11,796
protected static function correct_dn_splitting ( $ dn = array ( ) , $ separator = ',' ) { foreach ( $ dn as $ key => $ dn_value ) { $ dn_value = $ dn [ $ key ] ; if ( ! preg_match ( '/.+(?<!\\\\)=.+/' , $ dn_value ) ) { unset ( $ dn [ $ key ] ) ; if ( array_key_exists ( $ key - 1 , $ dn ) ) { $ dn [ $ key - 1 ] = $ dn ...
Corrects splitting of dn parts
11,797
public function editAction ( ) { $ id = $ this -> params ( ) -> fromRoute ( 'id' ) ; if ( ! $ id ) { return $ this -> redirect ( ) -> toRoute ( 'csn-cms/default' , array ( 'controller' => 'category' , 'action' => 'index' ) ) ; } $ entityManager = $ this -> getServiceLocator ( ) -> get ( 'doctrine.entitymanager.orm_defa...
U - update
11,798
public function grabFromConfig ( $ parameter ) { if ( ! isset ( $ this -> config [ $ parameter ] ) ) { throw new ModuleConfigException ( get_class ( $ this ) , sprintf ( 'Parameter "%s" is not specified in module\'s configurations.' , $ parameter ) ) ; } return $ this -> config [ $ parameter ] ; }
Retrieves value for configuration param with the passed in name .
11,799
public function connect ( ) { if ( $ this -> connection -> isConnected ( ) && ! empty ( $ this -> hello ) ) { return $ this -> hello ; } $ this -> connectToTheNode ( ) ; $ this -> authenticateWithPassword ( ) ; try { $ this -> sayHello ( ) ; } catch ( ResponseException $ e ) { $ message = $ e -> getMessage ( ) ; if ( s...
Connect to the node and return the HELLO response