idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
47,700 | public function writeProxyClassCache ( ) { $ parameters = array ( 'proxyNameSpace' => $ this -> getProxyNameSpace ( ) , 'proxyClassName' => $ this -> proxyClass , 'shortClassName' => $ this -> getShortClassName ( ) , 'originalClassName' => $ this -> class , ) ; $ proxyClassDefinition = $ this -> render ( $ this -> temp... | Writes the proxy class definition into a cache file . |
47,701 | public function loadProxyClass ( ) { if ( ! $ this -> cacheFileExists ( ) || $ this -> debug ) { $ this -> writeProxyClassCache ( ) ; } if ( ! $ this -> isProxyLoaded ( ) ) { require $ this -> proxyClassCacheFilename ; } return $ this ; } | Loads the proxy class for usage . |
47,702 | protected function render ( $ filepath , $ data = NULL ) { if ( ! file_exists ( $ filepath ) ) { throw new \ RuntimeException ( "View cannot render `$filepath` because the template does not exist" ) ; } $ data = $ this -> getData ( ) ; $ contentType = 'application/octet-stream' ; if ( isset ( $ data [ "CONTENT_TYPE" ] ... | Render - > Download file . |
47,703 | public function getRelativePath ( string $ fromDir , string $ to ) : string { if ( strpos ( $ to , 'data://' ) === 0 ) { return $ to ; } list ( $ fromStreamWrapper , $ fromDirPath ) = $ this -> splitStreamWrapperAndPath ( $ fromDir ) ; list ( $ toStreamWrapper , $ toPath ) = $ this -> splitStreamWrapperAndPath ( $ to )... | Gets the relative path from the first path to the second path . |
47,704 | public function resolveRelativePath ( string $ basePath , string $ relativePath ) : string { if ( strpos ( $ relativePath , 'data://' ) === 0 ) { return $ relativePath ; } list ( $ basePathStreamWrapper , $ basePath ) = $ this -> splitStreamWrapperAndPath ( $ basePath ) ; list ( $ relativeStreamWrapper , $ relativePath... | Combines the two paths and resolves .. and . relative traversals . |
47,705 | protected function isHTML ( ) { if ( function_exists ( 'headers_list' ) && $ headers = headers_list ( ) ) { foreach ( ( array ) $ headers as $ header ) { $ header = strtolower ( $ header ) ; if ( strpos ( $ header , 'content-type:' ) === 0 && ! strpos ( $ header , 'text/html' ) ) { return false ; } } } return true ; } | Whether the page is a plain old HTML . |
47,706 | public function minify ( ) { if ( $ this -> isHTML ( ) && class_exists ( 'Minify_HTML' ) ) { $ page = ob_get_contents ( ) ; ob_clean ( ) ; echo Minify_HTML :: minify ( $ page ) ; } } | Minifies the HTML page . |
47,707 | protected function pgsqlConnectionString ( ) { return $ this -> driver . ':host=' . $ this -> host . ';port=' . $ this -> port . ';dbname=' . $ this -> dbname . ';user=' . $ this -> user . ';password=' . $ this -> password ; } | pgsqlConnectionString Postgres connection string |
47,708 | protected function setProperties ( array $ properties = [ ] ) { foreach ( $ properties as $ name => $ value ) { if ( property_exists ( $ this , $ name ) ) { $ this -> $ name = $ value ; } else { trigger_error ( sprintf ( 'unknown property "%s" for "%s"' , $ name , get_class ( $ this ) ) , E_USER_WARNING ) ; } } } | Set properties trigger warning if unknown property found |
47,709 | public function config ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ key => $ value ) { $ this -> config ( $ key , $ value ) ; } return true ; } if ( isset ( $ value ) ) { $ this -> container [ 'settings' ] [ $ name ] = $ value ; } if ( ! isset ( $ this -> container [ 'settings' ] [ $... | Configure application settings |
47,710 | public function make ( $ className ) { $ reflection = new \ ReflectionClass ( $ className ) ; $ constructor = $ reflection -> getConstructor ( ) ; if ( is_null ( $ constructor ) ) { return new $ className ; } $ dependencies = [ ] ; $ parameters = $ reflection -> getConstructor ( ) -> getParameters ( ) ; foreach ( $ par... | Makes an instance of a class |
47,711 | private function runAction ( ) { $ url = $ this -> request -> url ( ) ; $ action = $ this -> router -> getAction ( $ url ) ; if ( $ action [ 'filter' ] ) { $ filter = $ this -> router -> performFilter ( $ action [ 'filter' ] ) ; } if ( ! isset ( $ action ) || ! is_string ( $ action [ 'class' ] ) || ! class_exists ( $ a... | Setups a database connection for models |
47,712 | private function returnValidationErrorResponse ( $ e ) { return $ this -> response -> error ( $ e -> getCode ( ) , $ e -> getMessage ( ) , [ 'error' => [ 'errors' => $ e -> getErrors ( ) ] ] ) ; } | Returns a validation error response |
47,713 | private function returnDatabaseErrorResponse ( $ e ) { $ info = $ this -> config ( 'debug.queries' ) ? [ 'error' => [ 'errors' => $ this -> db -> statement -> errorInfo ( ) , 'last_query' => $ this -> db -> lastQuery ( ) ] ] : [ ] ; return $ this -> response -> error ( 500 , 'Database error' , $ info ) ; } | Returns a database error response |
47,714 | private function returnGeneralErrorResponse ( $ e ) { $ backtrace = $ this -> config ( 'debug.backtrace' ) ? [ 'error' => [ 'backtrace' => $ e -> getTrace ( ) ] ] : [ ] ; return $ this -> response -> error ( $ e -> getCode ( ) , $ e -> getMessage ( ) , $ backtrace ) ; } | Returns a generic error response |
47,715 | public function updateCountry ( Country $ country , $ andFlush = true ) { $ this -> objectManager -> persist ( $ country ) ; if ( $ andFlush ) { $ this -> objectManager -> flush ( ) ; } } | Updates a Country . |
47,716 | public function refreshCountry ( Country $ country ) { $ refreshedCountry = $ this -> findCountryBy ( array ( 'id' => $ country -> getId ( ) ) ) ; if ( null === $ refreshedCountry ) { throw new UsernameNotFoundException ( sprintf ( 'User with ID "%d" could not be reloaded.' , $ country -> getId ( ) ) ) ; } return $ ref... | Refreshed a Country by Country Instance |
47,717 | public function finalizeConfig ( ) : void { if ( $ this -> locked ) { return ; } if ( null === $ this -> valueComparator ) { foreach ( $ this -> supportedValueTypes as $ type => $ supported ) { if ( $ supported && isset ( class_implements ( $ type ) [ RequiresComparatorValueHolder :: class ] ) ) { throw new InvalidConf... | Finalize the configuration and mark config as locked . |
47,718 | public static function to ( ? string $ path = '/' , ? int $ code = null ) { $ redirect = new Redirect ; $ redirect -> url = $ path ; if ( $ code !== null ) { $ redirect -> code = $ code ; return $ redirect -> send ( ) ; } return $ redirect ; } | Redirect to path |
47,719 | public static function back ( ? int $ code = null ) { if ( isset ( getallheaders ( ) [ 'Referer' ] ) ) { return Redirect :: to ( getallheaders ( ) [ 'Referer' ] , $ code ) ; } return new Redirect ( '/' ) ; } | Redirect back to the previous page |
47,720 | public function route ( string $ name , ? array $ parameters = [ ] , ? int $ code = null ) { $ this -> url = Route :: url ( $ name , $ parameters ) ; if ( $ code !== null ) { $ this -> code = $ code ; return $ this -> send ( ) ; } return $ this ; } | Redirect to route |
47,721 | public function with ( string $ name , $ value , ? int $ code = null ) { $ this -> with = array_merge ( [ $ name => $ value ] , $ this -> with ) ; if ( $ code != null ) { $ this -> code = $ code ; return $ this -> send ( ) ; } return $ this ; } | Attach variables with redirect |
47,722 | public function old ( array $ value , ? int $ code = null ) { $ this -> with = array_merge ( [ 'form.old' => $ value ] , $ this -> with ) ; if ( $ code != null ) { $ this -> code = $ code ; return $ this -> send ( ) ; } return $ this ; } | Attach old variables with redirect |
47,723 | public function return ( ? int $ code = null , ? string $ path = null ) { $ info = ( ( isset ( $ _SERVER [ 'PATH_INFO' ] ) ? $ _SERVER [ 'PATH_INFO' ] : '/' ) === '/' ? '' : $ _SERVER [ 'PATH_INFO' ] ) ; if ( $ info !== '' ) $ path = '?url=' . $ info ; if ( count ( $ _GET ) > 0 ) { $ path .= '&' . $ _SERVER [ 'QUERY_ST... | Allow redirect to return to current url |
47,724 | public function add ( $ comment ) { $ comments = $ this -> session -> get ( 'comments' , [ ] ) ; $ comments [ ] = $ comment ; $ this -> session -> set ( 'comments' , $ comments ) ; } | Add a new comment . |
47,725 | public function onKernelController ( FilterControllerEvent $ event ) { $ controller = $ event -> getController ( ) ; if ( ! is_array ( $ controller ) ) { return ; } $ fullpath = $ event -> getRequest ( ) -> get ( 'fullpath' ) ; if ( $ fullpath != '' && $ fullpath [ mb_strlen ( $ fullpath ) - 1 ] == '/' ) { $ fullpath =... | OnKernelControler event filter Try to find the page into database . |
47,726 | protected function setOptions ( array $ options ) { $ whitelist = array ( 'save_path' , 'name' , 'save_handler' , 'auto_start' , 'gc_probability' , 'gc_divisor' , 'gc_maxlifetime' , 'serialize_handler' , 'cookie_lifetime' , 'cookie_path' , 'cookie_domain' , 'cookie_secure' , 'cookie_httponly' , 'use_cookies' , 'use_onl... | Sets session options . |
47,727 | final public function importHTML ( $ html ) { $ tmp_doc = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ tmp_doc -> loadHTML ( $ html ) ; $ nodes = array ( ) ; foreach ( $ tmp_doc -> documentElement -> childNodes as $ node ) { array_push ( $ nodes , $ node ) ; $ this -> appendChild ( $ this -> ownerDocument -> importNode ( ... | Import HTML into a DOMElement |
47,728 | protected function getSet ( array $ queryParts ) { if ( isset ( $ queryParts [ 'set' ] ) && ! empty ( $ queryParts [ 'set' ] ) ) { $ updates = array ( ) ; foreach ( $ queryParts [ 'set' ] as $ k => $ v ) { $ updates [ ] = sprintf ( '%s = %s' , $ this -> quoteIdentifier ( $ k ) , $ this -> quote ( $ v ) ) ; } return 'SE... | Prepare the SET part of the MySQL query . |
47,729 | protected function getTable ( array $ queryParts ) { if ( isset ( $ queryParts [ 'table' ] ) ) { $ from = ( isset ( $ queryParts [ 'fields' ] ) && ! empty ( $ queryParts [ 'fields' ] ) ) || strtoupper ( $ queryParts [ 'type' ] ) === 'DELETE' ? 'FROM ' : '' ; if ( is_a ( $ queryParts [ 'table' ] , 'Database\Table' ) ) {... | Prepare the table name for use in the MySQL query . |
47,730 | protected function getJoins ( array $ queryParts ) { $ result = null ; if ( isset ( $ queryParts [ 'join' ] ) && ! empty ( $ queryParts [ 'join' ] ) ) { $ result = [ ] ; foreach ( $ queryParts [ 'join' ] as $ join ) { $ piece = trim ( $ join [ 0 ] . ' JOIN' ) . ' ' ; $ piece .= is_a ( $ join [ 1 ] , 'Database\Table' ) ... | Prepare the joins for use in the MySQL query . |
47,731 | private function formatWhere ( $ where , $ operator = 'AND' ) { if ( is_string ( $ where ) ) { return $ where ; } $ fullWhere = [ ] ; if ( is_array ( $ where ) ) { foreach ( $ where as $ key => $ value ) { $ fullWhere [ ] = sprintf ( '%s = %s' , $ this -> quoteIdentifier ( $ key ) , $ this -> quote ( $ value ) ) ; } } ... | Format the where clause of a MySQL query from a mixed range of types . |
47,732 | protected function getWhere ( array $ queryParts ) { if ( ! isset ( $ queryParts [ 'where' ] ) || empty ( $ queryParts [ 'where' ] ) ) { return null ; } $ where = array ( ) ; foreach ( $ queryParts [ 'where' ] as $ w ) { $ where [ ] = $ this -> formatWhere ( $ w ) ; } return 'WHERE ' . implode ( ' AND ' , $ where ) ; } | Prepare the where clause for use in the MySQL query . |
47,733 | protected function getGroup ( array $ queryParts ) { if ( isset ( $ queryParts [ 'group' ] ) ) { $ group = [ ] ; foreach ( $ queryParts [ 'group' ] as $ column ) { $ group [ ] = $ this -> quoteIdentifier ( $ column ) ; } return 'GROUP BY ' . implode ( ', ' , $ group ) ; } return null ; } | Prepare the group for use in the MySQL query . |
47,734 | protected function getOrder ( array $ queryParts ) { if ( isset ( $ queryParts [ 'order' ] ) ) { $ order = [ ] ; foreach ( $ queryParts [ 'order' ] as $ array ) { $ order [ ] = $ this -> quoteIdentifier ( $ array [ 0 ] ) . ( strtolower ( $ array [ 1 ] ) === 'asc' ? ' ASC' : ' DESC' ) ; } return 'ORDER BY ' . implode ( ... | Prepare the order for use in the MySQL query . |
47,735 | protected function getLimit ( array $ queryParts ) { if ( isset ( $ queryParts [ 'limit' ] ) && ! empty ( $ queryParts [ 'limit' ] ) ) { $ limit = [ ] ; foreach ( $ queryParts [ 'limit' ] as $ int ) { $ limit [ ] = ( int ) $ int ; } return 'LIMIT ' . implode ( ', ' , $ limit ) ; } return null ; } | Prepare the limit for use in the MySQL query . |
47,736 | public function buildQuery ( QueryAbstract $ query ) { $ queryParts = $ query -> getQueryParts ( ) ; return implode ( ' ' , array_filter ( [ $ queryParts [ 'type' ] , $ this -> getFields ( $ queryParts ) , $ this -> getTable ( $ queryParts ) , $ this -> getSet ( $ queryParts ) , $ this -> getValues ( $ queryParts ) , $... | Build a query string from a QueryAbstract |
47,737 | public function offsetUnset ( $ offset ) { unset ( $ this -> map [ $ offset ] ) ; $ this -> origin = $ this -> map -> keys ( ) ; return $ this ; } | ArrayAccess . Deletes the given key offset . |
47,738 | protected function castToArray ( & $ subject ) { if ( is_array ( $ subject ) === false ) { if ( Arr :: accessible ( $ subject ) === false ) { $ subject = new Collection ( $ subject ) ; } $ subject = $ subject instanceof Arrayable ? $ subject -> toArray ( ) : ( array ) $ subject ; } return $ this ; } | Because of the enumerable ways non - arrays can act like arrays we create a Collection which has useful normalizer functions and return that as an array . |
47,739 | protected function defineKeys ( & $ subject , array $ attributes , $ value = null ) { foreach ( $ attributes as $ attribute ) { $ subject [ $ attribute ] = $ value ; } return $ this ; } | Define the given array of attributes as keys in the given subject . |
47,740 | protected function pushAttributes ( & $ subject , array $ attributes , bool $ unique = true ) { foreach ( $ attributes as $ attribute ) { if ( $ unique === false || in_array ( $ attribute , $ subject ) === false ) { $ subject [ ] = $ attribute ; } } return $ this ; } | Push the given array of attributes to the given subject . |
47,741 | public static function passwordHash ( string $ text ) : ? string { return password_hash ( $ text , self :: PASSWORD_CRYPT_ALGO , [ 'cost' => self :: PASSWORD_CRYPT_COST ] ) ; } | Generate password hash using php password_hash with predefined algo |
47,742 | public static function passwordVerify ( string $ password , string $ hash ) : bool { return ( Str :: length ( $ hash ) > 0 && password_verify ( $ password , $ hash ) ) ; } | Verify password to hash equality |
47,743 | public static function randomString ( int $ length ) : string { try { $ rand = bin2hex ( random_bytes ( $ length ) ) ; $ rand = substr ( $ rand , 0 , $ length ) ; } catch ( \ Exception $ ce ) { $ rand = Str :: randomLatinNumeric ( $ length ) ; } return $ rand ; } | Generate random string with numbers from secure function random_bytes |
47,744 | public function runAction ( ) { $ request = $ this -> getRequest ( ) ; $ serviceParameters = array ( ) ; foreach ( $ this -> paramsToTest as $ params ) { foreach ( $ params as $ param ) { if ( $ result = $ request -> getParam ( $ param ) ) { $ serviceParameters [ $ params [ 0 ] ] = $ result ; continue ; } } } $ runner ... | Runs all tests and sets the exit code |
47,745 | public function transform ( $ entities ) { if ( is_null ( $ entities ) || count ( $ entities ) === 0 ) { return [ ] ; } $ data = [ ] ; $ accessor = PropertyAccess :: createPropertyAccessor ( ) ; foreach ( $ entities as $ entity ) { $ text = is_null ( $ this -> textProperty ) ? ( string ) $ entity : $ accessor -> getVal... | Transform initial entities to array |
47,746 | private function setHeaders ( $ headers ) { $ headers = explode ( PHP_EOL , $ headers ) ; foreach ( $ headers as $ header ) { $ header = explode ( ': ' , $ header ) ; if ( ! is_array ( $ header ) && count ( $ header ) === 1 ) { continue ; } $ type = strtolower ( array_shift ( $ header ) ) ; $ value = implode ( ': ' , $... | Parse and store the headers |
47,747 | function Save ( ) { if ( ! $ this -> rights ) { $ this -> rights = new BackendContentRights ( ) ; } $ this -> rights -> SetCreateIn ( $ this -> Value ( 'CreateIn' ) ) ; $ this -> rights -> SetEdit ( $ this -> Value ( 'Edit' ) ) ; $ this -> rights -> SetMove ( $ this -> Value ( 'Move' ) ) ; $ this -> rights -> SetRemove... | Saves the content rights |
47,748 | public function getAncestorsNames ( ) { $ names = [ ] ; if ( $ this -> hasParent ( ) ) { $ names = $ this -> getParent ( ) -> getAncestorsNames ( ) ; } $ names [ ] = $ this -> getName ( ) ; return $ names ; } | Get all ancestors names . It includes the name of the object itself . |
47,749 | public function getDescendants ( ) { $ descendants = [ ] ; if ( $ this -> hasChildren ( ) ) { foreach ( $ this -> getChildren ( ) as $ child ) { $ childDescendants = $ child -> hasChildren ( ) ? $ child -> getDescendants ( ) : [ ] ; $ descendants = ArrayUtils :: merge ( $ descendants , ArrayUtils :: merge ( [ $ child ]... | Get all descendants . |
47,750 | public function getUsers ( ) { if ( $ this -> users === null ) { $ this -> setUsers ( $ this -> userRepository -> getAllByEnvironment ( $ this ) ) ; } return $ this -> users ; } | Get Users . |
47,751 | public function getCurrentRevision ( ) { if ( $ this -> currentRevision === null ) { $ this -> setCurrentRevision ( $ this -> revisionRepository -> getCurrentByEnvironment ( $ this ) ) ; } return $ this -> currentRevision ; } | Get CurrentRevision . |
47,752 | public function getLastReleasedRevision ( ) { if ( $ this -> lastReleasedRevision === null ) { $ this -> setLastReleasedRevision ( $ this -> revisionRepository -> getLastReleasedByEnvironment ( $ this ) ) ; } return $ this -> lastReleasedRevision ; } | Get LastReleasedRevision . |
47,753 | public function getReleasedRevisions ( ) { if ( $ this -> releasedRevisions === null ) { $ this -> setReleasedRevisions ( $ this -> revisionRepository -> getAllReleasedByEnvironment ( $ this ) ) ; } return $ this -> releasedRevisions ; } | Get ReleasedRevisions . |
47,754 | public function load ( Target $ target , array $ subjects , Service $ service ) : Acl { $ key = $ this -> buildKey ( $ target , $ subjects ) ; if ( ! isset ( $ this -> cache [ $ key ] ) ) { $ acl = $ this -> delegate -> load ( $ target , $ subjects , $ service ) ; $ this -> cache [ $ key ] = $ acl ; } return $ this -> ... | Loads the ACL for a Target . |
47,755 | public function loadAll ( array $ targets , array $ subjects , Service $ service ) : array { $ acls = [ ] ; if ( $ this -> delegate instanceof MultiStrategy ) { $ oids = array_merge ( $ targets ) ; foreach ( $ targets as $ i => $ target ) { if ( ! ( $ target instanceof Target ) ) { throw new \ InvalidArgumentException ... | Loads the ACLs for several Targets . |
47,756 | protected function buildKey ( Target $ target , array $ subjects ) : string { $ key = ( string ) $ target ; foreach ( $ subjects as $ subject ) { if ( ! ( $ subject instanceof Subject ) ) { throw new \ InvalidArgumentException ( "Only instances of Subject are permitted in the subjects argument" ) ; } $ key .= ";{$subje... | Generates the key to use for caching the ACL . |
47,757 | public static function getSelfURL ( ) { $ selfURLhost = self :: getSelfURLhost ( ) ; $ requestURI = '' ; if ( ! empty ( $ _SERVER [ 'REQUEST_URI' ] ) ) { $ requestURI = $ _SERVER [ 'REQUEST_URI' ] ; if ( $ requestURI [ 0 ] !== '/' ) { if ( preg_match ( '#^https?://[^/]*(/.*)#i' , $ requestURI , $ matches ) ) { $ reques... | Returns the URL of the current host + current view + query . |
47,758 | public static function castKey ( XMLSecurityKey $ key , $ algorithm , $ type = 'public' ) { assert ( 'is_string($algorithm)' ) ; assert ( '$type === "public" || $type === "private"' ) ; if ( $ key -> type === $ algorithm ) { return $ key ; } if ( ! OneLogin_Saml2_Utils :: isSupportedSigningAlgorithm ( $ algorithm ) ) {... | Converts a XMLSecurityKey to the correct algorithm . |
47,759 | protected function equality ( $ comparison , $ operand ) { return $ this -> expr -> addCondition ( new Operator \ Equality ( $ this , $ comparison , $ this -> expr -> value ( $ operand ) ) ) ; } | Add a comparison to the current expression . |
47,760 | public static function labels ( $ q ) { $ e = explode ( '.' , $ q ) ; $ r = '' ; for ( $ i = 0 , $ s = sizeof ( $ e ) ; $ i < $ s ; ++ $ i ) { $ r .= chr ( strlen ( $ e [ $ i ] ) ) . $ e [ $ i ] ; } if ( static :: binarySubstr ( $ r , - 1 ) !== "\x00" ) { $ r .= "\x00" ; } return $ r ; } | Build structure of labels . |
47,761 | public static function parseLabels ( & $ data , $ orig = null ) { $ str = '' ; while ( strlen ( $ data ) > 0 ) { $ l = ord ( $ data [ 0 ] ) ; if ( $ l >= 192 ) { $ pos = static :: bytes2int ( chr ( $ l - 192 ) . static :: binarySubstr ( $ data , 1 , 1 ) ) ; $ data = static :: binarySubstr ( $ data , 2 ) ; $ ref = stati... | Parse structure of labels . |
47,762 | public static function LV ( $ str , $ len = 1 , $ lrev = false ) { $ l = static :: i2b ( $ len , strlen ( $ str ) ) ; if ( $ lrev ) { $ l = strrev ( $ l ) ; } return $ l . $ str ; } | Build length - value binary snippet . |
47,763 | public static function getByte ( & $ p ) { $ r = static :: bytes2int ( $ p { 0 } ) ; $ p = static :: binarySubstr ( $ p , 1 ) ; return ( int ) $ r ; } | Parse byte and remove it . |
47,764 | public static function getString ( & $ str ) { $ p = strpos ( $ str , "\x00" ) ; if ( $ p === false ) { return '' ; } $ r = static :: binarySubstr ( $ str , 0 , $ p ) ; $ str = static :: binarySubstr ( $ str , $ p + 1 ) ; return $ r ; } | Parse null - terminated string . |
47,765 | public static function getLV ( & $ p , $ l = 1 , $ nul = false , $ lrev = false ) { $ s = static :: b2i ( static :: binarySubstr ( $ p , 0 , $ l ) , ! ! $ lrev ) ; $ p = static :: binarySubstr ( $ p , $ l ) ; if ( $ s == 0 ) { return '' ; } $ r = '' ; if ( strlen ( $ p ) < $ s ) { echo ( "getLV error: buf length (" . s... | Parse length - value structure . |
47,766 | public static function int2bytes ( $ len , $ int = 0 , $ l = false ) { $ hexstr = dechex ( $ int ) ; if ( $ len === null ) { if ( strlen ( $ hexstr ) % 2 ) { $ hexstr = "0" . $ hexstr ; } } else { $ hexstr = str_repeat ( '0' , $ len * 2 - strlen ( $ hexstr ) ) . $ hexstr ; } $ bytes = strlen ( $ hexstr ) / 2 ; $ bin = ... | Converts integer to binary string . |
47,767 | public static function bytes2int ( $ str , $ l = false ) { if ( $ l ) { $ str = strrev ( $ str ) ; } $ dec = 0 ; $ len = strlen ( $ str ) ; for ( $ i = 0 ; $ i < $ len ; ++ $ i ) { $ dec += ord ( static :: binarySubstr ( $ str , $ i , 1 ) ) * pow ( 0x100 , $ len - $ i - 1 ) ; } return $ dec ; } | Convert bytes into integer . |
47,768 | public static function bitmap2bytes ( $ bitmap , $ checkLen = 0 ) { $ r = '' ; $ bitmap = str_pad ( $ bitmap , ceil ( strlen ( $ bitmap ) / 8 ) * 8 , '0' , STR_PAD_LEFT ) ; for ( $ i = 0 , $ n = strlen ( $ bitmap ) / 8 ; $ i < $ n ; ++ $ i ) { $ r .= chr ( ( int ) bindec ( static :: binarySubstr ( $ bitmap , $ i * 8 , ... | Convert bitmap into bytes . |
47,769 | protected static function binarySubstr ( $ s , $ p , $ len = null ) { if ( $ len === null ) { $ ret = substr ( $ s , $ p ) ; } else { $ ret = substr ( $ s , $ p , $ len ) ; } if ( $ ret === false ) { $ ret = '' ; } return $ ret ; } | Binary Substring . |
47,770 | public function getHeaders ( ) { $ h = array ( ) ; if ( ! empty ( $ this -> timeout ) ) $ h [ 'Refresh' ] = $ this -> timeout . '; url=' . $ this -> url ; else $ h [ 'Location' ] = ( string ) $ this -> url ; return $ h ; } | Return the redirection headers |
47,771 | public function getHelp ( \ Erebot \ Interfaces \ Event \ Base \ TextMessage $ event , \ Erebot \ Interfaces \ TextWrapper $ words ) { if ( $ event instanceof \ Erebot \ Interfaces \ Event \ Base \ PrivateMessage ) { $ target = $ event -> getSource ( ) ; $ chan = null ; } else { $ target = $ chan = $ event -> getChan (... | Provides help about this module . |
47,772 | public function getAvailableLists ( ) { if ( self :: $ cache !== null ) { return array_keys ( self :: $ cache ) ; } $ lists = array ( ) ; foreach ( self :: $ paths as $ path ) { $ files = scandir ( $ path ) ; foreach ( $ files as $ file ) { if ( substr ( $ file , - 7 ) == '.sqlite' ) { $ name = strtolower ( substr ( $ ... | Returns the names of available lists . |
47,773 | protected static function filterLists ( $ lists , $ policy ) { $ res = array ( ) ; foreach ( $ lists as $ name => $ path ) { if ( ( bool ) preg_match ( $ policy , $ name ) ) { $ res [ $ name ] = $ path ; } } return $ res ; } | Given a mapping of wordlists names with their path and a policy returns the same mapping with only those entries whose name matches the policy . |
47,774 | public static function registerPath ( $ path ) { $ path = realpath ( $ path ) ; if ( ! in_array ( $ path , self :: $ paths ) ) { self :: $ paths [ ] = $ path ; self :: $ cache = null ; } } | Registers a new path containing wordlists . |
47,775 | public function getList ( $ list ) { if ( isset ( self :: $ refs [ $ list ] ) ) { self :: $ refs [ $ list ] [ 'counter' ] ++ ; return \ Erebot \ Module \ Wordlists \ Proxy ( self :: $ refs [ $ list ] [ 'instance' ] ) ; } $ lists = $ this -> getAvailableLists ( ) ; if ( ! in_array ( $ list , $ lists ) ) { throw new \ Er... | Returns a list of words . |
47,776 | public function releaseList ( \ Erebot \ Module \ Wordlists \ Wordlist $ list ) { $ nameType = \ Erebot \ Module \ Wordlists \ Wordlist :: METADATA_NAME ; $ name = $ list -> getMetadata ( $ nameType ) ; if ( ! isset ( self :: $ refs [ $ name ] ) ) { throw new \ Erebot \ NotFoundException ( 'No such list' ) ; } if ( -- ... | Releases a wordlist . |
47,777 | public function handle ( $ file ) { if ( ! $ mime = $ this -> getMimeForEmit ( $ file -> getExtension ( ) ) ) { return $ file ; } if ( ! $ file_loc = $ file -> getLocation ( ) ) { return $ file ; } $ file -> setMime ( $ mime ) ; $ file -> setFound ( ) ; $ fp = fopen ( $ file_loc , 'r' ) ; $ file -> setResource ( $ fp )... | handles a file with proper extension such as gif js etc . |
47,778 | public function addMimeType ( $ mimetype ) { $ mimetypes = $ this -> getMimeType ( true ) ; if ( is_string ( $ mimetype ) ) { $ mimetype = explode ( ',' , $ mimetype ) ; } elseif ( ! is_array ( $ mimetype ) ) { throw new Zend_Validate_Exception ( "Invalid options to validator provided" ) ; } if ( isset ( $ mimetype [ '... | Adds the mimetypes |
47,779 | static function titleCase ( $ string , $ delimiter = '' ) { return implode ( $ delimiter , array_map ( 'ucfirst' , self :: getWords ( $ string , true ) ) ) ; } | Converts a given string to title case |
47,780 | static function getWords ( $ string , $ lowercase = false ) { $ string = self :: clean ( $ string , ' ' ) ; $ string = preg_replace ( '/(.)([A-Z])([a-z])/' , '$1 $2$3' , $ string ) ; $ string = preg_replace ( '/([a-z])([A-Z])/' , '$1 $2' , $ string ) ; $ string = preg_replace ( '/([0-9])([^0-9])/' , '$1 $2' , $ string ... | Returns array of the words in a string |
47,781 | static function plural ( $ string ) { $ plural = array ( array ( '/(quiz)$/i' , "$1zes" ) , array ( '/^(ox)$/i' , "$1en" ) , array ( '/([m|l])ouse$/i' , "$1ice" ) , array ( '/(matr|vert|ind)ix|ex$/i' , "$1ices" ) , array ( '/(x|ch|ss|sh)$/i' , "$1es" ) , array ( '/([^aeiouy]|qu)y$/i' , "$1ies" ) , array ( '/([^aeiouy]|... | Returns the plural version of the given word . If the plural version is the same then this method will simply add an s to the end of the word . |
47,782 | public function handle ( $ file ) { foreach ( $ this -> view_extensions as $ ext => $ handler ) { if ( $ file -> exists ( $ ext ) ) { $ file = $ file -> withExtension ( $ ext ) ; $ file -> setMime ( $ handler [ 1 ] ) ; $ file -> setFound ( ) ; $ handle = $ handler [ 0 ] ; if ( ! is_callable ( $ handle ) ) { $ handle = ... | handles text type file such as html php text and md . |
47,783 | protected function dummy ( ) { $ this -> evaluatePhp ( null ) ; $ this -> markToHtml ( null ) ; $ this -> textToPre ( null ) ; } | dummy method to call private methods which are judged as unused methods . |
47,784 | public function size ( ) : int { if ( $ this -> bufSize == null ) { $ this -> bufSize = strlen ( $ this -> buf ) ; } return $ this -> bufSize ; } | Returns the current size of the buffer . |
47,785 | public function getInlineSvg ( $ filename , $ params = [ ] ) { $ fullPath = $ this -> assetDir . $ filename ; if ( ! file_exists ( $ fullPath ) ) { throw new \ Exception ( sprintf ( 'Cannot find svg file: "%s"' , $ fullPath ) ) ; } $ svgString = file_get_contents ( $ fullPath ) ; $ hasAttr = array_key_exists ( 'attr' ,... | Get an inline svg . |
47,786 | public function routeRequest ( \ Slab \ Components \ SystemInterface $ system ) { $ this -> determineSelectedRoute ( ) ; if ( ! empty ( $ this -> selectedRoute ) ) { return $ this -> selectedRoute ; } if ( ! empty ( $ this -> routeNameMap [ '404' ] ) ) { return $ this -> routeNameMap [ '404' ] ; } return null ; } | Route the request |
47,787 | private function validateRequestURI ( & $ requestURI ) { if ( $ requestURI != '/' && substr ( $ requestURI , - 1 ) == '/' ) { $ url = rtrim ( $ requestURI , '/' ) ; if ( php_sapi_name ( ) === 'cli' ) { exit ( "Please ensure the URL you typed in does not have a trailing backslash.\n" ) ; } header ( "Location: " . $ url ... | Make sure the request URI fits how we want it to |
47,788 | private function getPathInfo ( ) { $ requestURI = ! empty ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : '' ; $ this -> validateRequestURI ( $ requestURI ) ; if ( empty ( $ requestURI ) ) { return ; } $ request = $ requestURI ; $ this -> fullRequest = $ this -> currentRequest = $ request ; $ this -> ad... | Gets the path info and parses out the segment structure |
47,789 | private function checkForTrailingSlashRedirect ( ) { if ( ! empty ( $ this -> segments ) && empty ( $ this -> segments [ count ( $ this -> segments ) - 1 ] ) ) { array_pop ( $ this -> segments ) ; $ newUrl = $ this -> baseHREF . '/' . implode ( '/' , $ this -> segments ) ; header ( "Location: " . $ newUrl ) ; exit ( ) ... | Checks for a trailing slash or something in the url |
47,790 | public function getRoutingTable ( ) { if ( $ this -> enableCache && ! empty ( $ this -> cacheInterface ) ) { return $ this -> fetchRoutingTableFromCache ( ) ; } return $ this -> fetchRoutingTable ( ) ; } | Get the routing table from cache or otherwise |
47,791 | private function fetchRoutingTable ( ) { $ this -> routes = $ this -> loadRoutingTable ( ) ; if ( ! empty ( $ this -> routes ) ) { $ this -> traverseRouteListAndBuildMap ( ) ; } return $ this -> routes ; } | Fetch the routing table without caching |
47,792 | private function fetchRoutingTableFromCache ( ) { $ this -> routes = $ this -> cacheInterface -> get ( 'Routing_Table' ) ; if ( empty ( $ this -> routes ) ) { $ this -> routes = $ this -> loadRoutingTable ( ) ; } if ( ! empty ( $ this -> routes ) ) { $ this -> traverseRouteListAndBuildMap ( ) ; } return $ this -> route... | Fetch the routing table using the default cache provider |
47,793 | private function traverseRouteListAndBuildMap ( $ currentNode = null ) { if ( empty ( $ currentNode ) ) { $ this -> traverseRouteListAndBuildMap ( $ this -> routes ) ; return ; } if ( is_array ( $ currentNode ) ) { foreach ( $ currentNode as $ node ) { $ this -> traverseRouteListAndBuildMap ( $ node ) ; } return ; } if... | Traverses the list of routes and builds a name - > route map reference list |
47,794 | public function loadRoutingTable ( ) { if ( empty ( $ this -> routeFiles ) || ! is_array ( $ this -> routeFiles ) ) { if ( ! empty ( $ this -> log ) ) { $ this -> log -> error ( "Missing configuration option routeFiles, or route file list in improper format." ) ; } return false ; } $ routeTable = array ( ) ; foreach ( ... | Load routing table from files |
47,795 | private function loadRouteFile ( & $ routeTable , $ fileName ) { libxml_use_internal_errors ( true ) ; $ xml = simplexml_load_file ( $ fileName ) ; if ( empty ( $ xml ) ) { $ errorMessage = "Failed to parse XML route file: " . $ fileName . "" ; foreach ( libxml_get_errors ( ) as $ error ) { $ errorMessage .= "\n" . $ e... | Load an XML route file from a fully qualified path name |
47,796 | public function determineSelectedRoute ( ) { if ( empty ( $ this -> routes ) ) { $ this -> getRoutingTable ( ) ; } if ( empty ( $ this -> segments ) ) { $ this -> segments = array ( '/' ) ; } $ currentLevel = & $ this -> routes ; $ index = 0 ; $ isRoot = true ; foreach ( $ this -> segments as $ segment ) { $ segmentIsI... | Determine the actually selected route from URL params |
47,797 | public function getRouteByName ( $ routeName ) { if ( ! empty ( $ this -> routeNameMap [ $ routeName ] ) ) { return $ this -> routeNameMap [ $ routeName ] ; } return null ; } | Gets a route by name |
47,798 | public static function createFromArray ( $ array , $ unparsed = [ ] ) { $ nyaaMeta = new NyaaMeta ( ) ; foreach ( $ array as $ key => $ value ) { $ nyaaMeta -> set ( $ key , $ value ) ; } $ nyaaMeta -> setUnparsed ( $ unparsed ) ; return $ nyaaMeta ; } | Creates a new NyaaMeta instance from array |
47,799 | public static function solveIndicator ( $ data ) { $ normData = strtolower ( trim ( $ data ) ) ; foreach ( self :: $ indicators as $ key => $ tests ) { foreach ( $ tests as $ test ) { if ( $ test [ 0 ] == '/' && preg_match ( $ test , $ normData ) ) { return [ $ key , $ normData ] ; } elseif ( $ normData === $ test ) { ... | Solves what type of data an indicator is |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.