idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
11,400
public function getHeader ( $ keyName ) { $ headers = $ this -> getHeaders ( ) ; $ keyName = self :: normalizeHeaderKeyName ( $ keyName ) ; if ( array_key_exists ( $ keyName , $ headers ) ) { return $ headers [ $ keyName ] ; } return ; }
Get the value of the request header keyname .
11,401
public function getHeaders ( ) { $ headers = [ ] ; foreach ( $ this -> srv as $ k => $ v ) { $ headers [ self :: normalizeHeaderKeyName ( $ k ) ] = $ v ; } return $ headers ; }
Get the HTTP headers .
11,402
public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( CustomerCustomerGroupTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ ...
Performs a DELETE on the database given a CustomerCustomerGroup or Criteria object OR a primary key value .
11,403
public static function invokeSafe ( callable $ function , array $ args , callable $ onError ) { $ prev = \ set_error_handler ( static function ( $ severity , $ message , $ file ) use ( $ onError , & $ prev ) { if ( $ file === __FILE__ && $ onError ( $ message , $ severity ) !== false ) { return null ; } if ( $ prev ) {...
Invokes internal PHP function with own error handler .
11,404
public static function get ( $ key , $ default = "default" ) { if ( self :: $ config == array ( ) ) self :: load ( ) ; $ env = Kernel :: getEnvironment ( ) ; $ position = self :: $ config [ $ env ] ; $ token = strtok ( $ key , '.' ) ; while ( $ token !== false ) { $ nextToken = strtok ( '.' ) ; if ( ! isset ( $ positio...
Get a configuration entry
11,405
private function getMode ( $ tokens ) { switch ( $ tokens -> getQueryMode ( ) ) { case 'find' : return QueryBuilderResult :: RESULT_SELECT_MULTIPLE ; case 'get' : return QueryBuilderResult :: RESULT_SELECT_SINGLE ; case 'delete' : return QueryBuilderResult :: RESULT_DELETE ; } throw new DslSyntaxException ( 'No query c...
Get the result type for a MethodNameToken .
11,406
private function getFields ( $ tokens , $ namingConvention , $ class ) { $ fields = [ ] ; $ prefix = '' ; foreach ( $ tokens -> getTokens ( ) as $ token ) { if ( $ token instanceof ByToken ) { return $ prefix . $ this -> fieldsToSQL ( $ fields , $ class , $ namingConvention ) ; } if ( $ token instanceof AllToken ) { re...
Build the SQL string for the fields from a MethodNameToken
11,407
private function tokenToColumn ( $ token , $ namingConvention , $ class ) { $ property = null ; foreach ( $ class -> getProperties ( ) as $ prop ) { if ( strcasecmp ( $ token -> getSource ( ) , $ prop -> getName ( ) ) === 0 ) { $ property = $ prop ; break ; } } if ( $ property === null ) { throw new DslSyntaxException ...
Get the column name for a token .
11,408
public static function unflatten ( array $ array , $ delimiter = '.' ) { $ unflattenedArray = array ( ) ; foreach ( $ array as $ key => $ value ) { $ keyList = explode ( $ delimiter , $ key ) ; $ firstKey = array_shift ( $ keyList ) ; if ( sizeof ( $ keyList ) > 0 ) { $ subArray = static :: unflatten ( array ( implode ...
Unflattens a single stacked array back into a multidimensional array .
11,409
public function getCoupons ( $ code = null ) { $ requestData = new Get \ RequestData ( $ code ) ; $ request = new Get \ Request ( $ requestData ) ; $ apiResponse = $ this -> sendRequest ( $ request , Get \ ApiResponse :: class ) ; $ response = $ apiResponse -> getResponse ( ) ; foreach ( $ response -> getCoupons ( ) as...
Get the coupons .
11,410
public function checkCoupon ( $ code , $ articleNumber ) { $ requestData = new Check \ RequestData ( $ code , $ articleNumber ) ; $ request = new Check \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , Check \ ApiResponse :: class ) ; }
Check a coupon .
11,411
public function addStore ( $ storeName , $ builderName , array $ options = array ( ) ) { $ this -> storeRegistryBuilder -> addStore ( $ storeName , $ builderName , $ options ) ; }
Adds a store to the builder
11,412
private function dispenseToken ( ) { $ token = bin2hex ( random_bytes ( $ this -> config -> getTokenLength ( ) ) ) ; $ arr = array ( 'token' => $ token , 'expires' => time ( ) + $ this -> config -> getTokenTtl ( ) ) ; $ plain = Spyc :: YAMLDump ( $ arr ) ; $ encrypted = Encryption :: encrypt ( $ plain , $ this -> confi...
Dispenses a randomly generated authentication token .
11,413
private function validateToken ( $ token ) { if ( ! file_exists ( $ this -> config -> getSessionFileName ( ) ) ) { return false ; } $ encrypted = file_get_contents ( $ this -> config -> getSessionFileName ( ) ) ; $ plain = Encryption :: decrypt ( $ encrypted , $ this -> config -> getSecretKey ( ) ) ; $ file = Spyc :: Y...
Returns true if the given authentication token is valid otherwise returns false .
11,414
public function getCookieToken ( ) { if ( $ this -> cookieToken !== null ) { return $ this -> cookieToken ; } $ name = $ this -> config -> getCookieName ( ) ; $ plain = '' ; if ( isset ( $ _COOKIE [ $ name ] ) ) { $ encrypted = $ _COOKIE [ $ name ] ; $ plain = Encryption :: decrypt ( $ encrypted , $ this -> config -> g...
Decrypts the stored authentication token out of the authentication cookie and returns it .
11,415
public function setCookieToken ( $ token ) { $ this -> cookieToken = $ token ; $ encrypted = Encryption :: encrypt ( $ token , $ this -> config -> getSecretKey ( ) ) ; setcookie ( $ this -> config -> getCookieName ( ) , $ encrypted , time ( ) + $ this -> config -> getTokenTtl ( ) , '/' , '' , $ this -> config -> getCoo...
Encrypts an authentication token into the authentication cookie .
11,416
public function authenticate ( $ email , $ password ) { if ( $ this -> config -> getCookieSslOnly ( ) && ! isset ( $ _SERVER [ 'HTTPS' ] ) ) { echo 'Connection is insecure, login cannot proceed.' ; die ( ) ; } if ( $ this -> config -> getAdminEmail ( ) != $ email || ! Encryption :: verify ( $ password , $ this -> confi...
Authenticates the given e - mail address password pair .
11,417
public function isAuthenticated ( ) { $ authenticated = $ this -> validateToken ( $ this -> getCookieToken ( ) ) ; if ( $ authenticated ) { $ this -> setCookieToken ( $ this -> dispenseToken ( ) ) ; } return $ authenticated ; }
Checks whether or not the current user is authenticated .
11,418
public function logout ( ) { setcookie ( $ this -> config -> getCookieName ( ) , '' , time ( ) - 3600 ) ; unlink ( $ this -> config -> getSessionFileName ( ) ) ; }
Logs the currently authenticated user out .
11,419
public function getSourceModelName ( $ type = null ) { $ type = $ type ? : $ this -> source_type ; return source_model_name ( $ type , true ) ; }
Returns the source model name
11,420
public static function newWithType ( $ locale , $ type ) { $ nodeSource = new static ( ) ; $ sourceModel = $ nodeSource -> getNewSourceModel ( $ type ) ; $ nodeSource -> setTemporarySource ( $ sourceModel ) ; $ nodeSource -> setAttribute ( 'locale' , $ locale ) ; $ nodeSource -> setAttribute ( 'source_type' , $ type ) ...
Create new node source with locale and type
11,421
public function getSource ( ) { if ( ! is_null ( $ this -> tempSource ) ) { return $ this -> tempSource ; } if ( ! $ this -> isSourceRelationLoaded ( ) ) { $ this -> load ( 'source' ) ; } return $ this -> relations [ 'source' ] ; }
Getter for source data
11,422
protected function saveSource ( ) { if ( ! is_null ( $ this -> tempSource ) ) { $ saved = $ this -> source ( ) -> save ( $ this -> tempSource ) ; $ this -> load ( 'source' ) ; $ this -> flushTemporarySource ( ) ; return ! is_null ( $ saved ) ; } return $ this -> source -> save ( ) ; }
Saves the source model
11,423
public function setAttribute ( $ key , $ value ) { if ( $ this -> isBaseAttribute ( $ key ) ) { return parent :: setAttribute ( $ key , $ value ) ; } else { return $ this -> getSource ( ) -> setAttribute ( $ key , $ value ) ; } }
Sets a model attribute
11,424
public function setExtensionNodeId ( $ id , $ save = true ) { $ source = $ this -> getSource ( ) -> setNodeId ( $ id ) ; if ( $ save ) { $ source -> save ( ) ; } }
Sets the extension node id
11,425
protected function event ( HttpException $ event , Context $ context = null ) { $ code = $ event -> getCode ( ) ; if ( isset ( $ this -> events [ $ code ] ) ) { $ context -> error = $ event ; $ context -> response -> code = $ event -> getCode ( ) ; $ this -> logger -> debug ( 'kernel.event: http ' . $ code . ' event ra...
Handle http event
11,426
public function joinChannels ( $ dummy , EventQueueInterface $ queue ) { $ queue -> ircJoin ( $ this -> channels , $ this -> keys ) ; }
Joins the provided list of channels .
11,427
protected function getClient ( array $ auth ) { $ this -> cookieFile = storage_path ( ) . '/guzzlehttp/cookies/vonage/' . $ auth [ 'username' ] . '.txt' ; $ cookieJar = new FileCookieJar ( $ this -> cookieFile , true ) ; $ this -> client = new Client ( array ( 'base_uri' => $ this -> base_uri , 'cookies' => $ cookieJar...
Get the vonage client .
11,428
public function initialize ( AgaviContext $ context , array $ parameters = array ( ) ) { parent :: initialize ( $ context , $ parameters ) ; $ this -> plugin_dir = $ this -> getParameter ( 'plugin_dir' , $ this -> plugin_dir ) ; }
Initialize this Renderer .
11,429
public function compilerFactory ( ) { if ( class_exists ( 'Dwoo_Compiler' , false ) === false ) { include DWOO_DIRECTORY . 'Dwoo/Compiler.php' ; } $ compiler = Dwoo_Compiler :: compilerFactory ( ) ; $ compiler -> setAutoEscape ( ( bool ) $ this -> getParameter ( 'auto_escape' , false ) ) ; return $ compiler ; }
provides a custom compiler to the dwoo renderer with optional settings you can set in the agavi output_types . xml config file
11,430
protected function getEngine ( ) { if ( $ this -> dwoo ) { return $ this -> dwoo ; } if ( ! class_exists ( 'Dwoo' ) ) { if ( file_exists ( dirname ( __FILE__ ) . '/../../../dwooAutoload.php' ) ) { require dirname ( __FILE__ ) . '/../../../dwooAutoload.php' ; } else { require 'dwooAutoload.php' ; } } $ parentMode = file...
Grab a cleaned up dwoo instance .
11,431
public function render ( AgaviTemplateLayer $ layer , array & $ attributes = array ( ) , array & $ slots = array ( ) , array & $ moreAssigns = array ( ) ) { $ engine = $ this -> getEngine ( ) ; $ data = array ( ) ; if ( $ this -> extractVars ) { $ data = $ attributes ; } else { $ data [ $ this -> varName ] = & $ attrib...
Render the presentation and return the result .
11,432
public function execute ( ProjectDescriptor $ project ) { Dispatcher :: getInstance ( ) -> dispatch ( self :: EVENT_PRE_TRANSFORM , PreTransformEvent :: createInstance ( $ this ) -> setProject ( $ project ) ) ; $ transformations = $ this -> getTemplates ( ) -> getTransformations ( ) ; $ this -> initializeWriters ( $ pr...
Transforms the given project into a series of artifacts as provided by the templates .
11,433
public function generateFilename ( $ name ) { if ( substr ( $ name , - 4 ) == '.php' ) { $ name = substr ( $ name , 0 , - 4 ) ; } return trim ( str_replace ( array ( DIRECTORY_SEPARATOR , '\\' ) , '.' , trim ( $ name , DIRECTORY_SEPARATOR . '.' ) ) , '.' ) . '.html' ; }
Converts a source file name to the name used for generating the end result .
11,434
public function debug ( $ message ) { Dispatcher :: getInstance ( ) -> dispatch ( 'system.debug' , DebugEvent :: createInstance ( $ this ) -> setMessage ( $ message ) ) ; }
Dispatches a logging request to log a debug message .
11,435
private function initializeWriters ( ProjectDescriptor $ project , $ transformations ) { $ isInitialized = array ( ) ; foreach ( $ transformations as $ transformation ) { $ writerName = $ transformation -> getWriter ( ) ; if ( in_array ( $ writerName , $ isInitialized ) ) { continue ; } $ isInitialized [ ] = $ writerNa...
Initializes all writers that are used during this transformation .
11,436
private function initializeWriter ( WriterAbstract $ writer , ProjectDescriptor $ project ) { $ event = WriterInitializationEvent :: createInstance ( $ this ) -> setWriter ( $ writer ) ; Dispatcher :: getInstance ( ) -> dispatch ( self :: EVENT_PRE_INITIALIZATION , $ event ) ; if ( $ writer instanceof Initializable ) {...
Initializes the given writer using the provided project meta - data .
11,437
private function transformProject ( ProjectDescriptor $ project , $ transformations ) { foreach ( $ transformations as $ transformation ) { $ transformation -> setTransformer ( $ this ) ; $ this -> applyTransformationToProject ( $ transformation , $ project ) ; } }
Applies all given transformations to the provided project .
11,438
private function applyTransformationToProject ( Transformation $ transformation , ProjectDescriptor $ project ) { $ this -> log ( sprintf ( ' Writer %s %s on %s' , $ transformation -> getWriter ( ) , ( $ transformation -> getQuery ( ) ? ' using query "' . $ transformation -> getQuery ( ) . '"' : '' ) , $ transformatio...
Applies the given transformation to the provided project .
11,439
public function getFilterColumns ( FormView $ formView , int $ numColumns = 3 ) : array { $ columns = [ ] ; $ i = 0 ; foreach ( $ formView as $ formItem ) { $ columns [ $ i % $ numColumns ] [ ] = $ formItem ; ++ $ i ; } return $ columns ; }
Simple function to split form widgets in as many columns as wanted
11,440
public function get ( $ url , $ options = [ ] , $ body = null , $ raw = true ) { return $ this -> httpRequest ( 'GET' , $ this -> createUrl ( $ url , $ options ) , $ body , $ raw ) ; }
Performs GET HTTP request
11,441
public function head ( $ url , $ options = [ ] , $ body = null ) { return $ this -> httpRequest ( 'HEAD' , $ this -> createUrl ( $ url , $ options ) , $ body ) ; }
Performs HEAD HTTP request
11,442
public static function installRequiredFiles ( ) { $ htaccess = [ __DIR__ . '/../../../../../../app/.htaccess' , __DIR__ . '/../../../../../../src/.htaccess' , __DIR__ . '/../../../../../../web/.htaccess' , ] ; $ fileSystem = new Filesystem ( ) ; try { if ( false === $ fileSystem -> exists ( $ htaccess ) ) { $ fileSyste...
Static method that creates . htaccess files if they do not exist .
11,443
public function isUploadField ( $ key ) { return array_key_exists ( $ key , $ this -> uploadGetKeys ) || array_key_exists ( $ key , $ this -> uploadSetKeys ) ; }
Determine if a set mutator exists for an attribute .
11,444
public static function serve ( $ context = null ) { if ( empty ( $ context ) ) $ context = getenv ( 'ERDIKO_CONTEXT' ) ; $ routes = static :: getRoutes ( $ context ) ; Toro :: serve ( $ routes ) ; }
Serve your site Loads routes based off of context and serves up the current request
11,445
public static function getView ( $ viewName , $ data = null , $ templateRootFolder = null ) { $ view = new \ erdiko \ core \ View ( $ viewName , $ data ) ; if ( $ templateRootFolder !== null ) { $ view -> setTemplateRootFolder ( $ templateRootFolder ) ; } return $ view -> toHtml ( ) ; }
Load a view from the current theme with the given data
11,446
public static function getConfigFile ( $ filename ) { $ filename = addslashes ( $ filename ) ; if ( is_file ( $ filename ) ) { $ data = str_replace ( "\\" , "\\\\" , file_get_contents ( $ filename ) ) ; $ json = json_decode ( $ data , true ) ; if ( empty ( $ json ) ) { throw new \ Exception ( "Config file has a json pa...
Read JSON config file and return array
11,447
public static function getRoutes ( $ context = null ) { if ( $ context == null ) $ context = getenv ( 'ERDIKO_CONTEXT' ) ; $ file = ERDIKO_APP . "/config/{$context}/routes.json" ; $ applicationConfig = static :: getConfigFile ( $ file ) ; return $ applicationConfig [ 'routes' ] ; }
Get the compiled application routes from the config files
11,448
public static function log ( $ level , $ message , array $ context = array ( ) ) { if ( static :: $ _logObject == null ) { $ erdikoContext = getenv ( 'ERDIKO_CONTEXT' ) ; $ config = static :: getConfig ( "application" , $ erdikoContext ) ; $ logFiles = $ config [ "logs" ] [ "files" ] [ 0 ] ; $ logDir = $ config [ "logs...
log message to log file If you enter null for level it will default to debug
11,449
public static function getCache ( $ cacheType = "default" ) { $ context = getenv ( 'ERDIKO_CONTEXT' ) ; $ config = static :: getConfig ( "application" ) ; if ( isset ( $ config [ "cache" ] [ $ cacheType ] ) ) { $ cacheConfig = $ config [ "cache" ] [ $ cacheType ] ; $ class = "erdiko\core\cache\\" . $ cacheConfig [ "typ...
Get the configured cache instance using name
11,450
public static function initialize ( ) { $ paths = array_merge ( array_filter ( glob ( 'src/*' ) , 'is_dir' ) , array_filter ( glob ( 'src-*/*' ) , 'is_dir' ) , array_filter ( glob ( __DIR__ . '/../../*/src/*/' ) , 'is_dir' ) ) ; $ db_params = array ( "url" => Configuration :: get ( "database.uri" , "sqlite:///:memory:"...
Initialize the Doctrine database engine .
11,451
public static function getRepository ( ) { if ( self :: $ entity_manager == null ) self :: initialize ( ) ; return call_user_func_array ( array ( self :: $ entity_manager , "getRepository" ) , func_get_args ( ) ) ; }
Wrapper to the Doctrine2 getRepository function .
11,452
public static function find ( ) { if ( self :: $ entity_manager == null ) self :: initialize ( ) ; return call_user_func_array ( array ( self :: $ entity_manager , "find" ) , func_get_args ( ) ) ; }
Wrapper to the Doctrine2 find function .
11,453
public static function flush ( ) { if ( self :: $ entity_manager == null ) self :: initialize ( ) ; return call_user_func_array ( array ( self :: $ entity_manager , "flush" ) , func_get_args ( ) ) ; }
Wrapper to the Doctrine2 flush function .
11,454
public static function persist ( ) { if ( self :: $ entity_manager == null ) self :: initialize ( ) ; return call_user_func_array ( array ( self :: $ entity_manager , "persist" ) , func_get_args ( ) ) ; }
Wrapper to the Doctrine2 persist function .
11,455
public static function remove ( ) { if ( self :: $ entity_manager == null ) self :: initialize ( ) ; return call_user_func_array ( array ( self :: $ entity_manager , "remove" ) , func_get_args ( ) ) ; }
Wrapper to the Doctrine2 remove function .
11,456
public static function createQuery ( ) { if ( self :: $ entity_manager == null ) self :: initialize ( ) ; return call_user_func_array ( array ( self :: $ entity_manager , "createQuery" ) , func_get_args ( ) ) ; }
Wrapper to the Doctrine2 createQuery function .
11,457
public static function createQueryBuilder ( ) { if ( self :: $ entity_manager == null ) self :: initialize ( ) ; return call_user_func_array ( array ( self :: $ entity_manager , "createQueryBuilder" ) , func_get_args ( ) ) ; }
Wrapper to the Doctrine2 createQueryBuilder function .
11,458
public static function createNativeQuery ( ) { if ( self :: $ entity_manager == null ) self :: initialize ( ) ; return call_user_func_array ( array ( self :: $ entity_manager , "createNativeQuery" ) , func_get_args ( ) ) ; }
Wrapper to the Doctrine2 createNativeQuery function .
11,459
public static function getReference ( ) { if ( self :: $ entity_manager == null ) self :: initialize ( ) ; return call_user_func_array ( array ( self :: $ entity_manager , "getReference" ) , func_get_args ( ) ) ; }
Wrapper to the Doctrine2 getReference function .
11,460
private function _login ( $ id ) { if ( $ this -> check ( ) && $ id ) { $ this -> _authenticate ( $ id ) -> _user_info ( ) -> _init_dir ( true ) -> save_session ( ) ; } return $ this ; }
initialize and saves session
11,461
private function _user_info ( ) { if ( $ this -> get_id ( ) ) { if ( ! empty ( $ this -> get_session ( 'cfg' ) ) ) { $ this -> cfg = $ this -> get_session ( 'cfg' ) ; $ this -> id_group = $ this -> get_session ( 'id_group' ) ; } else if ( $ d = $ this -> db -> rselect ( $ this -> class_cfg [ 'tables' ] [ 'users' ] , ar...
Gathers all the information about a user and puts it in the session The user s table data can be sent as argument if it has already been fetched
11,462
private function _sess_info ( $ id_session = null ) { if ( ! str :: is_uid ( $ id_session ) ) { $ id_session = $ this -> get_id_session ( ) ; } else { $ cfg = $ this -> _get_session ( 'cfg' ) ; } if ( empty ( $ cfg ) && str :: is_uid ( $ id_session ) && ( $ id = $ this -> get_session ( 'id' ) ) && ( $ d = $ this -> db ...
Gathers all the information about the user s session The session s table data can be sent as argument if it has already been fetched
11,463
private function _retrieve_session ( ) { if ( ! $ this -> id ) { $ id_session = $ this -> get_id_session ( ) ; $ id = $ this -> get_session ( 'id' ) ; if ( $ id_session && $ id ) { $ this -> _sess_info ( $ id_session ) ; if ( isset ( $ this -> sess_cfg [ 'fingerprint' ] ) && ( $ this -> get_print ( $ this -> _get_sessi...
Retrieves all user info from its session and populates the object
11,464
private function _init_session ( ) { $ this -> session = user \ session :: get_instance ( ) ; if ( ! $ this -> session ) { $ this -> session = new user \ session ( ) ; } if ( $ id_session = $ this -> get_id_session ( ) ) { $ this -> sess_cfg = json_decode ( $ this -> db -> select_one ( $ this -> class_cfg [ 'tables' ] ...
Sets the user s session for the first time and creates the session s DB row
11,465
private function _set_session ( $ attr ) { if ( $ this -> session -> has ( self :: $ sn ) ) { $ args = \ func_get_args ( ) ; if ( ( \ count ( $ args ) === 2 ) && \ is_string ( $ args [ 0 ] ) ) { $ attr = [ $ args [ 0 ] => $ args [ 1 ] ] ; } foreach ( $ attr as $ key => $ val ) { if ( \ is_string ( $ key ) ) { $ this ->...
Sets the session part of the session
11,466
private function _get_session ( $ attr ) { if ( $ this -> session -> has ( self :: $ sn ) ) { return $ attr ? $ this -> session -> get ( self :: $ sn , $ attr ) : $ this -> session -> get ( self :: $ sn ) ; } }
Gets the session part of the session
11,467
private function _check_credentials ( $ params ) { if ( $ this -> check ( ) ) { $ f = & $ this -> class_cfg [ 'fields' ] ; if ( ! isset ( $ params [ $ f [ 'salt' ] ] ) ) { $ this -> set_error ( 11 ) ; } else { if ( ! $ this -> check_salt ( $ params [ $ f [ 'salt' ] ] ) ) { $ this -> set_error ( 17 ) ; } } if ( $ this -...
Checks the credentials of a user
11,468
private function _init_dir ( $ create = false ) { if ( \ defined ( 'BBN_DATA_PATH' ) && $ this -> get_id ( ) ) { $ this -> path = BBN_DATA_PATH . 'users/' . $ this -> get_id ( ) . '/' ; if ( ! \ defined ( 'BBN_USER_PATH' ) ) { define ( 'BBN_USER_PATH' , $ this -> path ) ; } if ( $ create ) { file \ dir :: create_path (...
If BBN_DATA_PATH is defined creates a directory and removes temp files
11,469
public function get_error ( ) { if ( $ this -> error ) { return [ 'code' => $ this -> error , 'text' => $ this -> class_cfg [ 'errors' ] [ $ this -> error ] ] ; } return false ; }
Returns the last known error and false if there was no error
11,470
protected function get_print ( string $ fp = null ) { if ( ! $ fp ) { $ fp = $ this -> _get_session ( 'fingerprint' ) ; } if ( $ fp ) { return sha1 ( $ this -> user_agent . $ this -> accept_lang . $ fp ) ; } return false ; }
Returns a print ie an identifier based on the user agent
11,471
protected function record_attempt ( ) { $ this -> cfg [ 'num_attempts' ] = isset ( $ this -> cfg [ 'num_attempts' ] ) ? $ this -> cfg [ 'num_attempts' ] + 1 : 1 ; $ this -> _set_session ( 'num_attempts' , $ this -> cfg [ 'num_attempts' ] ) ; $ this -> save_session ( ) ; return $ this ; }
Increment the num_attempt variable
11,472
public function get_cfg ( $ attr = '' ) { if ( $ this -> check ( ) ) { if ( ! $ this -> cfg ) { $ this -> cfg = $ this -> session -> get ( 'cfg' ) ; } if ( empty ( $ attr ) ) { return $ this -> cfg ; } if ( isset ( $ this -> cfg [ $ attr ] ) ) { return $ this -> cfg [ $ attr ] ; } return false ; } }
Returns the current user s configuration .
11,473
public function get_fields ( string $ table = '' ) : ? array { if ( ! empty ( $ this -> class_cfg ) ) { if ( $ table ) { return $ this -> class_cfg [ 'arch' ] [ $ table ] ?? null ; } return $ this -> class_cfg [ 'arch' ] ; } return null ; }
Returns the list of fields of the given table and if empty the list of fields for each table .
11,474
public function update_info ( array $ d ) { if ( $ this -> check_session ( ) ) { $ update = [ ] ; foreach ( $ d as $ key => $ val ) { if ( ( $ key !== $ this -> fields [ 'id' ] ) && ( $ key !== $ this -> fields [ 'cfg' ] ) && ( $ key !== 'auth' ) && ( $ key !== 'pass' ) && \ in_array ( $ key , $ this -> fields ) ) { $ ...
Changes the data in the user s table .
11,475
public function get_session ( $ attr = null ) { if ( $ this -> session -> has ( self :: $ un ) ) { return $ attr ? $ this -> session -> get ( self :: $ un , $ attr ) : $ this -> session -> get ( self :: $ un ) ; } }
Returns session property from the session s user array .
11,476
public function save_session ( ) : self { $ id_session = $ this -> get_id_session ( ) ; if ( $ id_session && $ this -> check ( ) ) { $ p = & $ this -> class_cfg [ 'arch' ] [ 'sessions' ] ; $ this -> db -> update ( $ this -> class_cfg [ 'tables' ] [ 'sessions' ] , [ $ p [ 'id_user' ] => $ this -> id , $ p [ 'sess_id' ] ...
Saves the session config in the database .
11,477
public function check_attempts ( ) : bool { if ( ! isset ( $ this -> cfg ) ) { return false ; } if ( isset ( $ this -> cfg [ 'num_attempts' ] ) && $ this -> cfg [ 'num_attempts' ] > $ this -> class_cfg [ 'max_attempts' ] ) { return false ; } return true ; }
Returns false if the max number of connections attempts has been reached
11,478
public function save_cfg ( ) { if ( $ this -> check ( ) ) { $ this -> db -> update ( $ this -> class_cfg [ 'tables' ] [ 'users' ] , [ $ this -> fields [ 'cfg' ] => json_encode ( $ this -> cfg ) ] , [ $ this -> fields [ 'id' ] => $ this -> id ] ) ; } return $ this ; }
Saves the user s config in the cfg field of the users table return connection
11,479
public function set_password ( $ old_pass , $ new_pass ) { if ( $ this -> auth ) { $ pwt = $ this -> class_cfg [ 'tables' ] [ 'passwords' ] ; $ pwa = $ this -> class_cfg [ 'arch' ] [ 'passwords' ] ; $ stored_pass = $ this -> db -> select_one ( $ pwt , $ pwa [ 'pass' ] , [ $ this -> class_cfg [ 'arch' ] [ 'passwords' ] ...
Change the password in the database after checking the current one
11,480
public function force_password ( $ pass , $ id ) { if ( $ this -> check ( ) ) { return $ this -> db -> insert ( $ this -> class_cfg [ 'tables' ] [ 'passwords' ] , [ $ this -> class_cfg [ 'arch' ] [ 'passwords' ] [ 'pass' ] => $ this -> _crypt ( $ pass ) , $ this -> class_cfg [ 'arch' ] [ 'passwords' ] [ 'id_user' ] => ...
Change the password in the database
11,481
public function get_name ( $ usr = null ) { if ( $ this -> auth ) { if ( \ is_null ( $ usr ) ) { $ usr = $ this -> get_session ( ) ; } else if ( str :: is_uid ( $ usr ) ) { $ mgr = $ this -> get_manager ( ) ; $ usr = $ mgr -> get_user ( $ usr ) ; } if ( isset ( $ usr [ $ this -> class_cfg [ 'show' ] ] ) ) { return $ us...
Returns the written name of this or a user
11,482
public static function get_active_metaplates ( ) { global $ post ; if ( empty ( $ post ) ) { return ; } $ metaplates = self :: get_registry ( ) ; $ meta_stack = array ( ) ; if ( is_array ( $ metaplates ) ) { foreach ( $ metaplates as $ metaplate_try ) { $ is_plate = self :: get_metaplate ( $ metaplate_try [ 'id' ] ) ; ...
Get the metaplates for the post
11,483
public static function get_custom_field_data ( $ post_id ) { global $ post ; if ( ! is_object ( $ post ) ) { $ post = get_post ( $ post_id ) ; } $ raw_data = get_post_meta ( $ post_id ) ; if ( ! is_array ( $ raw_data ) ) { return ; } $ template_data = array ( ) ; $ taxonomies = get_object_taxonomies ( $ post ) ; if ( !...
Merge in Custom field data meta and post data
11,484
public static function get_metaplate ( $ id ) { $ metaplates = self :: get_registry ( ) ; if ( array_key_exists ( $ id , $ metaplates ) ) { $ metaplate = get_option ( $ id ) ; } else { $ metaplate = self :: get_metaplate_id_by_slug ( $ id ) ; if ( is_string ( $ metaplate ) ) { $ metaplate = self :: get_metaplate ( $ me...
Get a metaplate by ID or slug
11,485
private static function code ( $ metaplate ) { foreach ( array ( 'html' , 'js' , 'css' ) as $ field ) { if ( isset ( $ metaplate [ $ field ] ) ) { if ( is_object ( $ metaplate [ $ field ] ) ) { $ value = $ metaplate [ $ field ] ; $ value = $ value -> code ; unset ( $ metaplate [ $ field ] ) ; $ metaplate [ $ field ] [ ...
Make sure the code fields are arrays not objects and are set
11,486
public static function get_metaplate_id_by_slug ( $ slug , $ metaplates = null ) { if ( is_null ( $ metaplates ) ) { $ metaplates = self :: get_registry ( ) ; } if ( is_array ( $ metaplates ) ) { $ search = wp_list_pluck ( $ metaplates , 'slug' ) ; return array_search ( $ slug , $ search ) ; } return false ; }
Get a metaplate s ID using its slug
11,487
public static function update_registry ( $ new_value , $ id ) { $ registry = self :: get_registry ( ) ; $ registry [ $ id ] = $ new_value ; return update_option ( self :: $ registry_option_name , $ registry ) ; }
Update registry of metaplates
11,488
public function whatProvides ( $ name , LinkConstraintInterface $ constraint = null , $ mustMatchName = false ) { $ key = ( ( int ) $ mustMatchName ) . $ constraint ; if ( isset ( $ this -> providerCache [ $ name ] [ $ key ] ) ) { return $ this -> providerCache [ $ name ] [ $ key ] ; } return $ this -> providerCache [ ...
Searches all packages providing the given package name and match the constraint
11,489
private function match ( $ candidate , $ name , LinkConstraintInterface $ constraint = null ) { $ candidateName = $ candidate -> getName ( ) ; $ candidateVersion = $ candidate -> getVersion ( ) ; $ isDev = $ candidate -> getStability ( ) === 'dev' ; $ isAlias = $ candidate instanceof AliasPackage ; if ( ! $ isDev && ! ...
Checks if the package matches the given constraint directly or through provided or replaced packages
11,490
public static function fromNode ( $ node , $ parent ) { if ( is_null ( $ node [ "value" ] ) ) return new Feature ( $ node , $ parent , $ node -> children ( ) ) ; else return new ValueFeature ( $ node , $ parent , $ node -> children ( ) ) ; }
Creates a feature from an XML node .
11,491
public static function findByName ( $ features , $ featureName , $ permissive = false ) { if ( $ permissive ) $ featureName = self :: _getPermissiveName ( $ featureName ) ; return fphp \ Helper \ _Array :: findByKey ( $ features , $ permissive ? "getPermissiveName" : "getName" , $ featureName ) ; }
Finds a feature by its name in a list of features . Permissive search ignores case and substitutes hyphens .
11,492
public static function GetItemInfo ( $ itemname , $ itemchunks ) { $ retval = "-" ; for ( $ i = 0 ; $ i < count ( $ itemchunks ) ; $ i ++ ) if ( strcasecmp ( $ itemchunks [ $ i ] , $ itemname ) == 0 ) $ retval = $ itemchunks [ $ i + 1 ] ; return $ retval ; }
A Helper Function . Returns Item Info from chunk .
11,493
public static function FontCodes ( $ text , $ advanced = TRUE , $ charset = 'utf-8' ) { $ text = htmlspecialchars ( $ text , ENT_QUOTES , $ charset ) ; $ basic_bbcode = array ( '[b]' , '[/b]' , '[i]' , '[/i]' , '[u]' , '[/u]' , '[B]' , '[/B]' , '[I]' , '[/I]' , '[U]' , '[/U]' , ) ; $ basic_html = array ( '<b>' , '</b>'...
Helper Function Convery SWAT4 Server font codes into html tags
11,494
public static function FixNickname ( $ nick ) { $ nick = str_replace ( '&' , '&amp;' , $ nick ) ; $ nick = str_replace ( '<' , '&lt;' , $ nick ) ; $ nick = str_replace ( '>' , '&gt;' , $ nick ) ; return $ nick ; }
Helper Function Returns fixed names for html .
11,495
public static function SortPlayers ( $ a , $ b , $ co , $ jak ) { if ( $ co == "name" ) { $ a2 = strtolower ( $ a [ 'name' ] ) ; $ b2 = strtolower ( $ b [ 'name' ] ) ; if ( $ a2 == $ b2 ) return 0 ; if ( ( ( $ jak == "+" ) && ( $ a2 > $ b2 ) ) || ( ( $ jak == "-" ) && ( $ a2 < $ b2 ) ) ) return 1 ; else return - 1 ; } ...
A Helper Function This function will sort players .
11,496
function LinkImageSort ( $ _by , $ sby , $ soby , $ soby2 , $ stitle ) { if ( $ _by == $ sby ) return <<<EOF <a href="{$_SERVER['PHP_SELF']}?sort={$soby}&amp;by={$sby}" class="formfont" onmouseover="if(document.getElementById('so{$sby}')){ document.getElementById('so{$sby}').src='./swat4query/images/server_{$soby}.gi...
Helper Function Can be used to created a link to sort data accordingly .
11,497
public function render ( $ delimiter = null , $ no_additions = false ) { $ delimiter = is_null ( $ delimiter ) ? config ( 'laravel-title.delimiter' ) : $ delimiter ; $ suffix = $ no_additions ? '' : config ( 'laravel-title.suffix' ) ; $ prefix = $ no_additions ? '' : config ( 'laravel-title.prefix' ) ; $ on_empty = $ n...
Implode all segments into one string .
11,498
public function make ( array $ segments , $ delimiter = ' - ' , $ suffix = '' , $ prefix = '' , $ on_empty = '' ) { $ result = implode ( $ delimiter , $ segments ) ; if ( $ this -> has ( ) ) { return $ prefix . $ result . $ suffix ; } else { return $ on_empty ; } }
Check if any segments added
11,499
public static function recursiveRemove ( $ path ) { if ( is_dir ( $ path ) ) { $ files = scandir ( $ path ) ; foreach ( $ files as $ file ) { if ( $ file != "." && $ file != ".." ) { self :: recursiveRemove ( "$path/$file" ) ; } } if ( ! rmdir ( $ path ) ) { throw new IOException ( "Cannot rmdir '$path'" , 0 , null , $...
rm - r path