idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
44,800
protected function getOptionsFromConfig ( Config $ config ) { $ options = [ ] ; foreach ( static :: $ metaOptions as $ option ) { if ( ! $ config -> has ( $ option ) ) { continue ; } $ options [ static :: $ metaMap [ $ option ] ] = $ config -> get ( $ option ) ; } if ( $ visibility = $ config -> get ( 'visibility' ) ) ...
Retrieve options from a Config instance . done
44,801
public function createProvider ( $ class , array $ options , $ redirectUri , array $ redirectParams = [ ] , array $ collaborators = [ ] ) { $ redirectUri = $ this -> generator -> generate ( $ redirectUri , $ redirectParams , UrlGeneratorInterface :: ABSOLUTE_URL ) ; $ options [ 'redirectUri' ] = $ redirectUri ; return ...
Creates a provider of the given class .
44,802
public function getClient ( $ key ) { if ( ! isset ( $ this -> serviceMap [ $ key ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'There is no OAuth2 client called "%s". Available are: %s' , $ key , implode ( ', ' , array_keys ( $ this -> serviceMap ) ) ) ) ; } return $ this -> container -> get ( $ this -> ser...
Easy accessor for client objects .
44,803
public function load ( array $ configs , ContainerBuilder $ container ) { $ processor = new Processor ( ) ; $ configuration = new Configuration ( ) ; $ config = $ processor -> processConfiguration ( $ configuration , $ configs ) ; $ loader = new XmlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/c...
Load the bundle configuration .
44,804
public function getAccessToken ( ) { if ( ! $ this -> isStateless ) { $ expectedState = $ this -> getSession ( ) -> get ( self :: OAUTH2_SESSION_STATE_KEY ) ; $ actualState = $ this -> getCurrentRequest ( ) -> query -> get ( 'state' ) ; if ( ! $ actualState || ( $ actualState !== $ expectedState ) ) { throw new Invalid...
Call this after the user is redirected back to get the access token .
44,805
public function setRefreshToken ( $ refreshToken = null ) { $ this -> refreshToken = null === $ refreshToken ? bin2hex ( openssl_random_pseudo_bytes ( 64 ) ) : $ refreshToken ; return $ this ; }
Set refreshToken .
44,806
public function process ( ContainerBuilder $ container ) { $ config = $ container -> getExtensionConfig ( 'gesdinet_jwt_refresh_token' ) [ 0 ] ; if ( ! class_exists ( 'Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass' ) && ( isset ( $ config [ 'manager_type' ] ) && 'mongodb' === st...
Process Doctrine mappings based on gesdinet_jwt_refresh_token . manager_type and gesdinet_jwt_refresh_token . refresh_token_class config parameters . Depending on the value of manager_type Doctrine s ORM or ODM mappings will be used . If refresh_token_class parameter contains user - defined entity RefreshToken will be ...
44,807
public function markEntityToUpload ( $ entity , $ fileInfo ) { if ( is_object ( $ fileInfo ) && $ fileInfo instanceof UploadedFile ) { $ fileInfoClass = $ this -> fileInfoClass ; $ fileInfo = new $ fileInfoClass ( $ fileInfo ) ; } $ this -> listener -> addEntityFileInfo ( $ entity , $ fileInfo ) ; }
This method marks an entity to be uploaded as soon as the flush method of your object manager is called . After calling this method the file info you passed is set for this entity in the listener . This is all it takes to upload a file for an entity in the Uploadable extension .
44,808
public function setTimeRange ( $ from , $ to ) { $ fromDate = date ( 'Y-m-d H:i:s' , ( int ) $ from ) ; $ toDate = date ( 'Y-m-d H:i:s' , ( int ) $ to ) ; $ this -> where ( array ( "time > '$fromDate'" , "time < '$toDate'" ) ) ; return $ this ; }
Set s the time range to select data from
44,809
public function create ( RetentionPolicy $ retentionPolicy = null , $ createIfNotExists = false ) { if ( $ createIfNotExists ) { trigger_error ( 'The $createIfNotExists parameter to Database::create is deprecated' , E_USER_DEPRECATED ) ; } try { $ query = sprintf ( 'CREATE DATABASE "%s"' , $ this -> name ) ; $ this -> ...
Create this database
44,810
public function writePoints ( array $ points , $ precision = self :: PRECISION_NANOSECONDS , $ retentionPolicy = null ) { $ payload = array_map ( function ( Point $ point ) { return ( string ) $ point ; } , $ points ) ; return $ this -> writePayload ( $ payload , $ precision , $ retentionPolicy ) ; }
Write points into InfluxDB using the current driver . This is the recommended method for inserting data into InfluxDB .
44,811
private function escapeCharacters ( array $ arr , $ escapeValues ) { $ returnArr = [ ] ; foreach ( $ arr as $ key => $ value ) { $ returnArr [ $ this -> addSlashes ( $ key ) ] = $ escapeValues ? $ this -> addSlashes ( $ value ) : $ value ; } return $ returnArr ; }
Escapes invalid characters in both the array key and optionally the array value
44,812
public function write ( $ data = null ) { $ this -> response = $ this -> httpClient -> post ( $ this -> parameters [ 'url' ] , $ this -> getRequestParameters ( $ data ) ) ; }
Send the data
44,813
public function isSuccess ( ) { $ statuscode = $ this -> response -> getStatusCode ( ) ; if ( ! in_array ( $ statuscode , [ 200 , 204 ] , true ) ) { throw new Exception ( 'HTTP Code ' . $ statuscode . ' ' . $ this -> response -> getBody ( ) ) ; } return true ; }
Should return if sending the data was successful
44,814
protected function createStream ( ) { $ host = sprintf ( 'udp://%s:%d' , $ this -> config [ 'host' ] , $ this -> config [ 'port' ] ) ; $ this -> stream = @ stream_socket_client ( $ host ) ; }
Create the resource stream
44,815
public static function serve ( ) { $ output = new NullOutput ( ) ; $ daux = new Daux ( Daux :: LIVE_MODE , $ output ) ; $ daux -> initializeConfiguration ( ) ; $ class = $ daux -> getProcessorClass ( ) ; if ( ! empty ( $ class ) ) { $ daux -> setProcessor ( new $ class ( $ daux , $ output , 0 ) ) ; } $ daux -> getParam...
Serve the documentation
44,816
private function getTemporaryFile ( $ postfix ) { $ sysFileName = tempnam ( sys_get_temp_dir ( ) , 'daux' ) ; if ( $ sysFileName === false ) { throw new \ RuntimeException ( "Could not create temporary file" ) ; } $ newFileName = $ sysFileName . $ postfix ; if ( $ sysFileName == $ newFileName ) { return $ sysFileName ;...
Create a temporary file with the file suffix for mime type detection .
44,817
public function handle ( ) { $ this -> params = $ this -> getParams ( ) ; $ request = substr ( $ this -> request -> getRequestUri ( ) , strlen ( $ this -> request -> getBaseUrl ( ) ) + 1 ) ; if ( substr ( $ request , 0 , 7 ) == 'themes/' ) { return $ this -> serveTheme ( substr ( $ request , 6 ) ) ; } if ( $ request ==...
Handle an incoming request
44,818
public function serveTheme ( $ request ) { $ file = $ this -> getParams ( ) -> getThemesPath ( ) . $ request ; if ( file_exists ( $ file ) ) { return new RawPage ( $ file ) ; } throw new NotFoundException ; }
Handle a request on custom themes
44,819
protected function escaped ( $ url ) { $ url = trim ( $ url ) ; $ url = preg_replace ( '~[^\\pL0-9_]+~u' , '-' , $ url ) ; $ url = trim ( $ url , "-" ) ; $ url = iconv ( "utf-8" , "ASCII//TRANSLIT//IGNORE" , $ url ) ; $ url = preg_replace ( '~[^-a-zA-Z0-9_]+~' , '' , $ url ) ; return $ url ; }
Get an escaped version of the link
44,820
public function generate ( $ headings ) { $ root = $ previous = new RootEntry ( ) ; foreach ( $ headings as $ heading ) { if ( $ heading -> getLevel ( ) < $ previous -> getLevel ( ) ) { $ parent = $ previous ; do { $ parent = $ parent -> getParent ( ) ; } while ( $ heading -> getLevel ( ) <= $ parent -> getLevel ( ) &&...
Make a tree of the list of headings
44,821
protected function setNull ( Heading $ object , $ property ) { $ prop = new \ ReflectionProperty ( get_class ( $ object ) , $ property ) ; $ prop -> setAccessible ( true ) ; $ prop -> setValue ( $ object , null ) ; }
Set the specified property to null on the object .
44,822
public function getAttribute ( $ key = null ) { if ( $ this -> attributes === null ) { $ this -> parseAttributes ( ) ; } if ( is_null ( $ key ) ) { return $ this -> attributes ; } if ( ! array_key_exists ( $ key , $ this -> attributes ) ) { return null ; } return $ this -> attributes [ $ key ] ; }
Get one or all attributes for the content
44,823
public function seekFirstPage ( ) { if ( $ this instanceof self ) { $ index_key = $ this -> getConfig ( ) [ 'index_key' ] ; if ( isset ( $ this -> children [ $ index_key ] ) ) { return $ this -> children [ $ index_key ] ; } foreach ( $ this -> children as $ node_key => $ node ) { if ( $ node instanceof Content ) { retu...
Seek the first available page from descendants
44,824
public function hasContent ( ) { foreach ( $ this -> getEntries ( ) as $ node ) { if ( $ node instanceof Content ) { return true ; } elseif ( $ node instanceof self ) { if ( $ node -> hasContent ( ) ) { return true ; } } } return false ; }
Used when creating the navigation . Hides folders without showable content
44,825
public static function copyRecursive ( $ source , $ destination ) { if ( ! is_dir ( $ destination ) ) { mkdir ( $ destination ) ; } $ dir = opendir ( $ source ) ; if ( ! $ dir ) { throw new RuntimeException ( "Cannot copy '$source' to '$destination'" ) ; } while ( false !== ( $ file = readdir ( $ dir ) ) ) { if ( $ fil...
Copy files recursively
44,826
public function getParents ( ) { $ parents = [ ] ; if ( $ this -> parent && ! $ this -> parent instanceof Root ) { $ parents = $ this -> parent -> getParents ( ) ; $ parents [ ] = $ this -> parent ; } return $ parents ; }
Return all parents starting with the root
44,827
public function getRelativePath ( ) { $ root = $ this ; while ( $ root -> getParent ( ) != null ) { $ root = $ root -> getParent ( ) ; } return substr ( $ this -> path , strlen ( $ root -> getPath ( ) ) + 1 ) ; }
Get the path to the file from the root of the documentation
44,828
private function generateRecursive ( Directory $ tree , $ output_dir , $ params , $ output , $ width , $ index_pages , $ base_url = '' ) { DauxHelper :: rebaseConfiguration ( $ params , $ base_url ) ; if ( $ base_url !== '' && empty ( $ params [ 'entry_page' ] ) ) { $ params [ 'entry_page' ] = $ tree -> getFirstPage ( ...
Recursively generate the documentation
44,829
public function getConfigurationOverride ( $ path ) { $ validPath = DauxHelper :: findLocation ( $ path , $ this -> local_base , 'DAUX_CONFIGURATION' , 'file' ) ; if ( $ validPath === null ) { return null ; } if ( ! $ validPath ) { throw new Exception ( 'The configuration override file does not exist. Check the path ag...
Get the file requested for configuration overrides
44,830
protected function loadBaseConfiguration ( ) { $ this -> options = new Config ( ) ; $ this -> options -> merge ( [ 'docs_directory' => 'docs' , 'valid_content_extensions' => [ 'md' , 'markdown' ] , 'mode' => $ this -> mode , 'local_base' => $ this -> local_base , 'templates' => 'templates' , 'index_key' => 'index.html'...
Load and validate the global configuration
44,831
public function generateTree ( ) { $ this -> options [ 'valid_content_extensions' ] = $ this -> getContentExtensions ( ) ; $ this -> tree = new Root ( $ this -> getParams ( ) ) ; Builder :: build ( $ this -> tree , $ this -> options [ 'ignore' ] ) ; if ( $ this -> options -> isMultilanguage ( ) ) { foreach ( $ this -> ...
Generate the tree that will be used
44,832
public function getContentExtensions ( ) { if ( ! empty ( $ this -> validExtensions ) ) { return $ this -> validExtensions ; } return $ this -> validExtensions = $ this -> getContentTypeHandler ( ) -> getContentExtensions ( ) ; }
Get all content file extensions
44,833
public function getClient ( ) { $ options = [ 'base_uri' => $ this -> base_url . 'rest/api/' , 'auth' => [ $ this -> user , $ this -> pass ] , ] ; return new Client ( $ options ) ; }
This method is public due to test purposes
44,834
protected function handleError ( BadResponseException $ e ) { $ request = $ e -> getRequest ( ) ; $ response = $ e -> getResponse ( ) ; $ level = floor ( $ response -> getStatusCode ( ) / 100 ) ; if ( $ level == '4' ) { $ label = 'Client error response' ; } elseif ( $ level == '5' ) { $ label = 'Server error response' ...
The standard error message from guzzle is quite poor in informations this will give little bit more sense to it and return it
44,835
public static function rebaseConfiguration ( Config $ config , $ base_url ) { if ( $ config [ 'base_url' ] == $ base_url && ! empty ( $ config [ 'theme' ] ) ) { return ; } $ config [ 'base_url' ] = $ config [ 'base_page' ] = $ base_url ; $ config [ 'theme' ] = static :: getTheme ( $ config , $ base_url ) ; $ config [ '...
Set a new base_url for the configuration
44,836
public static function getFilenames ( Config $ config , $ part ) { $ extensions = implode ( '|' , array_map ( 'preg_quote' , $ config [ 'valid_content_extensions' ] ) ) . '|html' ; $ raw = preg_replace ( '/(.*)?\\.(' . $ extensions . ')$/' , '$1' , $ part ) ; $ raw = Builder :: removeSortingInformations ( $ raw ) ; ret...
Get the possible output file names for a source file .
44,837
public static function getFile ( $ tree , $ request ) { $ request = explode ( '/' , $ request ) ; foreach ( $ request as $ node ) { if ( ! $ tree instanceof Directory ) { return false ; } if ( $ node == '.' ) { continue ; } if ( $ node == '..' ) { $ tree = $ tree -> getParent ( ) ; continue ; } $ node = urldecode ( $ n...
Locate a file in the tree . Returns the file if found or false
44,838
public function merge ( $ newValues , $ override = true ) { foreach ( $ newValues as $ key => $ value ) { if ( ! array_key_exists ( $ key , $ this ) ) { $ this [ $ key ] = $ value ; continue ; } if ( $ override === false ) { continue ; } if ( is_array ( $ this [ $ key ] ) && is_array ( $ value ) ) { $ this [ $ key ] = ...
Merge an array into the object
44,839
public function getContentExtensions ( ) { $ extensions = [ ] ; foreach ( $ this -> types as $ type ) { $ extensions = array_merge ( $ extensions , $ type -> getExtensions ( ) ) ; } return array_unique ( $ extensions ) ; }
Get all valid content file extensions
44,840
public function getType ( Content $ node ) { $ path = $ node -> getPath ( ) ? : $ node -> getName ( ) ; $ extension = pathinfo ( $ path , PATHINFO_EXTENSION ) ; foreach ( $ this -> types as $ type ) { if ( in_array ( $ extension , $ type -> getExtensions ( ) ) ) { return $ type ; } } throw new \ RuntimeException ( "no ...
Get the ContentType able to handle this node
44,841
private function createImageTag ( $ filename , $ attributes ) { $ img = '<ac:image' ; foreach ( $ attributes as $ name => $ value ) { if ( $ name == 'style' ) { $ re = '/float:\s*?(left|right);?/' ; if ( preg_match ( $ re , $ value , $ matches ) ) { $ img .= ' ac:align="' . $ matches [ 1 ] . '"' ; $ value = preg_replac...
Create an image tag for the specified filename
44,842
public static function build ( $ node , $ ignore ) { if ( ( $ it = new \ FilesystemIterator ( $ node -> getPath ( ) ) ) == false ) { return ; } if ( $ node instanceof Root ) { $ ignore [ 'files' ] [ ] = 'config.json' ; } foreach ( $ it as $ file ) { if ( static :: isIgnored ( $ file , $ ignore ) ) { continue ; } if ( $...
Build the initial tree
44,843
public static function sortTree ( Directory $ current ) { $ current -> sort ( ) ; foreach ( $ current -> getEntries ( ) as $ entry ) { if ( $ entry instanceof Directory ) { Builder :: sortTree ( $ entry ) ; } } }
Sort the tree recursively
44,844
public static function finalizeTree ( Directory $ current , $ prev = null ) { foreach ( $ current -> getEntries ( ) as $ entry ) { if ( $ entry instanceof Directory ) { $ prev = Builder :: finalizeTree ( $ entry , $ prev ) ; } elseif ( $ entry instanceof Content ) { if ( $ prev ) { $ prev -> setNext ( $ entry ) ; $ ent...
Calculate next and previous for all pages
44,845
public function verify ( string $ otp , ? int $ counter = null , ? int $ window = null ) : bool { Assertion :: greaterOrEqualThan ( $ counter , 0 , 'The counter must be at least 0.' ) ; if ( null === $ counter ) { $ counter = $ this -> getCounter ( ) ; } elseif ( $ counter < $ this -> getCounter ( ) ) { return false ; ...
If the counter is not provided the OTP is verified at the actual counter .
44,846
public static function loadFromProvisioningUri ( string $ uri ) : OTPInterface { $ parsed_url = parse_url ( $ uri ) ; Assertion :: isArray ( $ parsed_url , 'Not a valid OTP provisioning URI' ) ; self :: checkData ( $ parsed_url ) ; $ otp = self :: createOTP ( $ parsed_url ) ; self :: populateOTP ( $ otp , $ parsed_url ...
This method is the unique public method of the class . It can load a provisioning Uri and convert it into an OTP object .
44,847
public static function create ( ? string $ secret = null , int $ period = 30 , string $ digest = 'sha1' , int $ digits = 6 , int $ epoch = 0 ) : self { return new self ( $ secret , $ period , $ digest , $ digits , $ epoch ) ; }
TOTP constructor .
44,848
public function getAccessToken ( $ oauth_verifier = null ) { $ parameters = [ ] ; if ( ! empty ( $ oauth_verifier ) ) { $ parameters [ 'oauth_verifier' ] = $ oauth_verifier ; } parent :: request ( 'GET' , parent :: url ( $ this -> tconfig [ 'ACCESS_TOKEN_URL' ] , '' ) , $ parameters ) ; $ response = $ this -> response ...
Get an access token for a logged in user
44,849
protected function setForgottenDefaults ( ) { $ this -> repairConfigValue ( 'bcrypt_cost' , 10 ) ; $ this -> repairConfigValue ( 'cookie_name' , 'phpauth_session_cookie' ) ; $ this -> repairConfigValue ( 'verify_password_min_length' , 3 ) ; $ this -> repairConfigValue ( 'verify_email_min_length' , 5 ) ; $ this -> repai...
Danger foreseen is half avoided .
44,850
protected function repairConfigValue ( $ setting , $ default_value ) { if ( ! isset ( $ this -> config [ $ setting ] ) ) $ this -> config [ $ setting ] = $ default_value ; }
Set configuration value if it is not present .
44,851
public function activate ( $ activate_token ) { $ return [ 'error' ] = true ; $ block_status = $ this -> isBlocked ( ) ; if ( $ block_status == "block" ) { $ return [ 'message' ] = $ this -> __lang ( "user_blocked" ) ; return $ return ; } if ( strlen ( $ activate_token ) !== self :: TOKEN_LENGTH ) { $ this -> addAttemp...
Activates a user s account
44,852
public function logout ( $ hash ) { if ( strlen ( $ hash ) != self :: HASH_LENGTH ) { return false ; } $ this -> isAuthenticated = false ; $ this -> currentuser = null ; return $ this -> deleteSession ( $ hash ) ; }
Logs out the session identified by hash
44,853
public function logoutAll ( $ uid ) { $ this -> isAuthenticated = false ; $ this -> currentuser = null ; return $ this -> deleteExistingSessions ( $ uid ) ; }
Logs out of all sessions for specified uid
44,854
public function getUID ( $ email ) { $ query = "SELECT id FROM {$this->config->table_users} WHERE email = :email" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_prepared -> execute ( [ 'email' => $ email ] ) ; if ( $ query_prepared -> rowCount ( ) == 0 ) { return false ; } return $ query_prepared -...
Gets UID for a given email address return int
44,855
protected function addSession ( $ uid , $ remember ) { $ ip = $ this -> getIp ( ) ; $ user = $ this -> getBaseUser ( $ uid ) ; if ( ! $ user ) { return false ; } $ data [ 'hash' ] = sha1 ( $ this -> config -> site_key . microtime ( ) ) ; $ agent = isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ? $ _SERVER [ 'HTTP_USER_AGENT...
Creates a session for a specified user id
44,856
protected function deleteExistingSessions ( $ uid ) { $ query = "DELETE FROM {$this->config->table_sessions} WHERE uid = :uid" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_prepared -> execute ( [ 'uid' => $ uid ] ) ; return $ query_prepared -> rowCount ( ) > 0 ; }
Removes all existing sessions for a given UID
44,857
protected function deleteSession ( $ hash ) { $ query = "DELETE FROM {$this->config->table_sessions} WHERE hash = :hash" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_prepared -> execute ( [ 'hash' => $ hash ] ) ; return $ query_prepared -> rowCount ( ) == 1 ; }
Removes a session based on hash
44,858
public function checkSession ( $ hash ) { $ ip = $ this -> getIp ( ) ; $ block_status = $ this -> isBlocked ( ) ; if ( $ block_status == "block" ) { $ return [ 'message' ] = $ this -> __lang ( "user_blocked" ) ; return false ; } if ( strlen ( $ hash ) != self :: HASH_LENGTH ) { return false ; } $ query = "SELECT id, ui...
Function to check if a session is valid
44,859
public function getSessionUID ( $ hash ) { $ query = "SELECT uid FROM {$this->config->table_sessions} WHERE hash = :hash" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_params = [ 'hash' => $ hash ] ; $ query_prepared -> execute ( $ query_params ) ; if ( $ query_prepared -> rowCount ( ) == 0 ) { re...
Retrieves the UID associated with a given session hash
44,860
public function isEmailTaken ( $ email ) { $ query = "SELECT count(*) FROM {$this->config->table_users} WHERE email = :email" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_prepared -> execute ( [ 'email' => $ email ] ) ; if ( $ query_prepared -> fetchColumn ( ) == 0 ) { return false ; } return tru...
Checks if an email is already in use
44,861
public function isEmailBanned ( $ email ) { if ( ! $ this -> dbh -> query ( "SHOW TABLES LIKE '{$this->config->table_emails_banned}'" ) -> fetchAll ( ) ) { return false ; } ; $ query = "SELECT count(*) FROM {$this->config->table_emails_banned} WHERE domain = :domain" ; $ query_prepared = $ this -> dbh -> prepare ( $ qu...
Checks if an email is banned
44,862
protected function addUser ( $ email , $ password , $ params = [ ] , & $ use_email_activation ) { $ return [ 'error' ] = true ; $ query = "INSERT INTO {$this->config->table_users} (isactive) VALUES (0)" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; if ( ! $ query_prepared -> execute ( ) ) { $ return [ 'me...
Adds a new user to database
44,863
protected function getBaseUser ( $ uid ) { $ query = "SELECT email, password, isactive FROM {$this->config->table_users} WHERE id = :id" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_prepared -> execute ( [ 'id' => $ uid ] ) ; $ data = $ query_prepared -> fetch ( \ PDO :: FETCH_ASSOC ) ; if ( ! $ ...
Gets basic user data for a given UID and returns an array
44,864
public function deleteUser ( $ uid , $ password , $ captcha_response = null ) { $ return [ 'error' ] = true ; $ block_status = $ this -> isBlocked ( ) ; if ( $ block_status == "verify" ) { if ( $ this -> checkCaptcha ( $ captcha_response ) == false ) { $ return [ 'message' ] = $ this -> __lang ( "user_verify_failed" ) ...
Allows a user to delete their account
44,865
public function deleteUserForced ( $ uid ) { $ return [ 'error' ] = true ; $ query = "DELETE FROM {$this->config->table_users} WHERE id = :uid" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; if ( ! $ query_prepared -> execute ( [ 'uid' => $ uid ] ) ) { $ return [ 'message' ] = $ this -> __lang ( "system_er...
Force delete user without password or captcha verification .
44,866
public function getRequest ( $ key , $ type ) { $ return [ 'error' ] = true ; $ query = "SELECT id, uid, expire FROM {$this->config->table_requests} WHERE token = ? AND type = ?" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_prepared -> execute ( [ $ key , $ type ] ) ; if ( $ query_prepared -> row...
Returns request data if key is valid
44,867
protected function deleteRequest ( $ id ) { $ query = "DELETE FROM {$this->config->table_requests} WHERE id = :id" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; return $ query_prepared -> execute ( [ 'id' => $ id ] ) ; }
Deletes request from database
44,868
protected function validatePassword ( $ password ) { $ state [ 'error' ] = true ; if ( strlen ( $ password ) < ( int ) $ this -> config -> verify_password_min_length ) { $ state [ 'message' ] = $ this -> __lang ( "password_short" ) ; return $ state ; } $ state [ 'error' ] = false ; return $ state ; }
Verifies that a password is greater than minimal length
44,869
protected function validateEmail ( $ email ) { $ state [ 'error' ] = true ; if ( strlen ( $ email ) < ( int ) $ this -> config -> verify_email_min_length ) { $ state [ 'message' ] = $ this -> __lang ( "email_short" , ( int ) $ this -> config -> verify_email_min_length ) ; return $ state ; } elseif ( strlen ( $ email ) ...
Verifies that an email is valid
44,870
public function resendActivation ( $ email , $ use_email_activation = null ) { $ state [ 'error' ] = true ; $ block_status = $ this -> isBlocked ( ) ; if ( $ block_status == "block" ) { $ state [ 'message' ] = $ this -> __lang ( "user_blocked" ) ; return $ state ; } if ( $ use_email_activation == null ) { $ state [ 'me...
Recreates activation email for a given email and sends
44,871
public function changeEmail ( $ uid , $ email , $ password , $ captcha = null ) { $ return [ 'error' ] = true ; $ block_status = $ this -> isBlocked ( ) ; if ( $ block_status == "verify" ) { if ( $ this -> checkCaptcha ( $ captcha ) == false ) { $ return [ 'message' ] = $ this -> __lang ( "user_verify_failed" ) ; retur...
Changes a user s email
44,872
public function isBlocked ( ) { $ ip = $ this -> getIp ( ) ; $ this -> deleteAttempts ( $ ip , false ) ; $ query = "SELECT count(*) FROM {$this->config->table_attempts} WHERE ip = :ip" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_prepared -> execute ( [ 'ip' => $ ip ] ) ; $ attempts = $ query_pre...
Informs if a user is locked out
44,873
protected function addAttempt ( ) { $ ip = $ this -> getIp ( ) ; $ attempt_expiredate = date ( "Y-m-d H:i:s" , strtotime ( $ this -> config -> attack_mitigation_time ) ) ; $ query = "INSERT INTO {$this->config->table_attempts} (ip, expiredate) VALUES (:ip, :expiredate)" ; $ query_prepared = $ this -> dbh -> prepare ( $...
Adds an attempt to database
44,874
protected function deleteAttempts ( $ ip , $ all = false ) { $ query = ( $ all ) ? "DELETE FROM {$this->config->table_attempts} WHERE ip = :ip" : "DELETE FROM {$this->config->table_attempts} WHERE ip = :ip AND NOW() > expiredate " ; $ sth = $ this -> dbh -> prepare ( $ query ) ; return $ sth -> execute ( [ 'ip' => $ ip...
Deletes all attempts for a given IP from database
44,875
public function getRandomKey ( $ length = self :: TOKEN_LENGTH ) { $ chars = "A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6Q7R8S9T0U1V2W3X4Y5Z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6" ; $ key = "" ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ key .= $ chars { mt_rand ( 0 , strlen ( $ chars ) - 1 ) } ; } return $ key ...
Returns a random string of a specified length
44,876
protected function getIp ( ) { if ( getenv ( 'HTTP_CLIENT_IP' ) ) { $ ipAddress = getenv ( 'HTTP_CLIENT_IP' ) ; } elseif ( getenv ( 'HTTP_X_FORWARDED_FOR' ) ) { $ ipAddress = getenv ( 'HTTP_X_FORWARDED_FOR' ) ; } elseif ( getenv ( 'HTTP_X_FORWARDED' ) ) { $ ipAddress = getenv ( 'HTTP_X_FORWARDED' ) ; } elseif ( getenv ...
Returns IP address
44,877
public function getCurrentSessionHash ( ) { return isset ( $ _COOKIE [ $ this -> config -> cookie_name ] ) ? $ _COOKIE [ $ this -> config -> cookie_name ] : false ; }
Returns current session hash
44,878
public function isLogged ( ) { if ( $ this -> isAuthenticated === false ) { $ this -> isAuthenticated = $ this -> checkSession ( $ this -> getCurrentSessionHash ( ) ) ; } return $ this -> isAuthenticated ; }
Returns is user logged in
44,879
public function comparePasswords ( $ userid , $ password_for_check ) { $ query = "SELECT password FROM {$this->config->table_users} WHERE id = ?" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_prepared -> execute ( [ $ userid ] ) ; $ data = $ query_prepared -> fetch ( \ PDO :: FETCH_ASSOC ) ; if ( ...
Compare user s password with given password
44,880
public function password_verify_with_rehash ( $ password , $ hash , $ uid ) { if ( ! password_verify ( $ password , $ hash ) ) { return false ; } if ( password_needs_rehash ( $ hash , PASSWORD_DEFAULT , [ 'cost' => $ this -> config -> bcrypt_cost ] ) ) { $ hash = $ this -> getHash ( $ password ) ; $ query = "UPDATE {$t...
Check if users password needs to be rehashed
44,881
public function __lang ( $ key , ... $ args ) { $ string = array_key_exists ( $ key , $ this -> messages_dictionary ) ? $ this -> messages_dictionary [ $ key ] : $ key ; return ( func_num_args ( ) > 1 ) ? vsprintf ( $ string , $ args ) : $ string ; }
Translates key - message to defined language using substitutional params
44,882
public function do_SendMail ( $ email , $ type , $ key ) { $ return = [ 'error' => true ] ; $ mail = new PHPMailer ( ) ; try { if ( $ this -> config -> smtp ) { if ( $ this -> config -> smtp_debug ) { $ mail -> SMTPDebug = $ this -> config -> smtp_debug ; } $ mail -> isSMTP ( ) ; $ mail -> Host = $ this -> config -> sm...
Send email via PHPMailer
44,883
public function getCurrentSessionUserInfo ( ) { $ ts = $ this -> config -> table_sessions ; $ tu = $ this -> config -> table_users ; $ query = " SELECT {$ts}.uid, {$ts}.expiredate, {$ts}.ip, {$tu}.email, {$tu}.username FROM {$ts}, {$tu} WHERE hash = :hash AND {$ts}.uid = {$tu}.id" ; $ query = $ this -> dbh -> prepar...
Return current user sesssion info
44,884
public function register ( array $ credentials , $ callback = null ) { if ( $ callback !== null && ! $ callback instanceof Closure && ! is_bool ( $ callback ) ) { throw new InvalidArgumentException ( 'You must provide a closure or a boolean.' ) ; } $ this -> fireEvent ( 'sentinel.registering' , $ credentials ) ; $ vali...
Registers a user . You may provide a callback to occur before the user is saved or provide a true boolean as a shortcut to activation .
44,885
public function check ( ) { if ( $ this -> user !== null ) { return $ this -> user ; } if ( ! $ code = $ this -> persistences -> check ( ) ) { return false ; } if ( ! $ user = $ this -> persistences -> findUserByPersistenceCode ( $ code ) ) { return false ; } if ( ! $ this -> cycleCheckpoints ( 'check' , $ user ) ) { r...
Checks to see if a user is logged in .
44,886
public function forceAuthenticate ( $ credentials , $ remember = false ) { return $ this -> bypassCheckpoints ( function ( $ sentinel ) use ( $ credentials , $ remember ) { return $ sentinel -> authenticate ( $ credentials , $ remember ) ; } ) ; }
Forces an authentication to bypass checkpoints .
44,887
public function getRequestCredentials ( ) { if ( $ this -> requestCredentials === null ) { $ this -> requestCredentials = function ( ) { $ credentials = [ ] ; if ( isset ( $ _SERVER [ 'PHP_AUTH_USER' ] ) ) { $ credentials [ 'login' ] = $ _SERVER [ 'PHP_AUTH_USER' ] ; } if ( isset ( $ _SERVER [ 'PHP_AUTH_PW' ] ) ) { $ c...
Returns the request credentials .
44,888
public function getBasicResponse ( ) { if ( $ this -> basicResponse === null ) { $ this -> basicResponse = function ( ) { if ( headers_sent ( ) ) { throw new RuntimeException ( 'Attempting basic auth after headers have already been sent.' ) ; } header ( 'WWW-Authenticate: Basic' ) ; header ( 'HTTP/1.0 401 Unauthorized'...
Sends a response when HTTP basic authentication fails .
44,889
public function bypassCheckpoints ( Closure $ callback , $ checkpoints = [ ] ) { $ originalCheckpoints = $ this -> checkpoints ; $ activeCheckpoints = [ ] ; foreach ( array_keys ( $ originalCheckpoints ) as $ checkpoint ) { if ( $ checkpoints && ! in_array ( $ checkpoint , $ checkpoints ) ) { $ activeCheckpoints [ $ ch...
Pass a closure to Sentinel to bypass checkpoints .
44,890
protected function cycleCheckpoints ( $ method , UserInterface $ user = null , $ halt = true ) { if ( ! $ this -> checkpointsStatus ) { return true ; } foreach ( $ this -> checkpoints as $ checkpoint ) { $ response = $ checkpoint -> { $ method } ( $ user ) ; if ( $ response === false && $ halt === true ) { return false...
Cycles through all the registered checkpoints for a user . Checkpoints may throw their own exceptions however if just one returns false the cycle fails .
44,891
public function getUser ( $ check = true ) { if ( $ check === true && $ this -> user === null ) { $ this -> check ( ) ; } return $ this -> user ; }
Returns the currently logged in user lazily checking for it .
44,892
protected function getUserMethods ( ) { if ( empty ( $ this -> userMethods ) ) { $ users = $ this -> getUserRepository ( ) ; $ methods = get_class_methods ( $ users ) ; $ this -> userMethods = array_diff ( $ methods , [ '__construct' ] ) ; } return $ this -> userMethods ; }
Returns all accessible methods on the associated user repository .
44,893
protected function checkActivation ( UserInterface $ user ) { $ completed = $ this -> activations -> completed ( $ user ) ; if ( ! $ completed ) { $ exception = new NotActivatedException ( 'Your account has not been activated yet.' ) ; $ exception -> setUser ( $ user ) ; throw $ exception ; } }
Checks the activation status of the given user .
44,894
protected function registerCookie ( ) { $ this -> app -> singleton ( 'sentinel.cookie' , function ( $ app ) { return new IlluminateCookie ( $ app [ 'request' ] , $ app [ 'cookie' ] , $ app [ 'config' ] -> get ( 'cartalyst.sentinel.cookie' ) ) ; } ) ; }
Registers the cookie .
44,895
protected function registerRoles ( ) { $ this -> app -> singleton ( 'sentinel.roles' , function ( $ app ) { $ config = $ app [ 'config' ] -> get ( 'cartalyst.sentinel.roles' ) ; return new IlluminateRoleRepository ( $ config [ 'model' ] ) ; } ) ; }
Registers the roles .
44,896
protected function registerActivations ( ) { $ this -> app -> singleton ( 'sentinel.activations' , function ( $ app ) { $ config = $ app [ 'config' ] -> get ( 'cartalyst.sentinel.activations' ) ; return new IlluminateActivationRepository ( $ config [ 'model' ] , $ config [ 'expires' ] ) ; } ) ; }
Registers the activations .
44,897
protected function registerThrottleCheckpoint ( ) { $ this -> registerThrottling ( ) ; $ this -> app -> singleton ( 'sentinel.checkpoint.throttle' , function ( $ app ) { return new ThrottleCheckpoint ( $ app [ 'sentinel.throttling' ] , $ app [ 'request' ] -> getClientIp ( ) ) ; } ) ; }
Registers the throttle checkpoint .
44,898
protected function sweep ( $ repository , array $ lottery ) { if ( $ this -> configHitsLottery ( $ lottery ) ) { try { $ repository -> removeExpired ( ) ; } catch ( Exception $ e ) { } } }
Sweep expired codes .
44,899
protected function setUserResolver ( ) { $ this -> app -> rebinding ( 'request' , function ( $ app , $ request ) { $ request -> setUserResolver ( function ( ) use ( $ app ) { return $ app [ 'sentinel' ] -> getUser ( ) ; } ) ; } ) ; }
Sets the user resolver on the request class .