idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
59,900 | protected function createForDriver ( $ driver , array $ config = [ ] ) { if ( isset ( $ this -> customCreators [ $ driver ] ) ) { return $ this -> callCustom ( $ driver , compact ( 'config' ) ) ; } if ( $ binding = $ this -> getBindingKeyForDriver ( $ driver ) ) { return $ this -> resolveBinding ( $ binding , compact (... | Create a new driver instance for the given driver . |
59,901 | protected function callCustom ( $ key , array $ parameters = [ ] ) { return $ this -> app -> call ( $ this -> customCreators [ $ key ] , $ parameters ) ; } | Call a custom creator . |
59,902 | protected function getBindingKeyForDriver ( $ driver ) { if ( class_exists ( $ driver ) ) { return $ driver ; } if ( $ this -> app -> bound ( $ key = "hashid.driver.$driver" ) ) { return $ key ; } } | Get the binding key for the driver . |
59,903 | protected function resolveBinding ( $ key , array $ parameters = [ ] ) { if ( $ this -> app -> isShared ( $ key ) ) { return $ this -> app -> make ( $ key ) ; } $ makeWith = method_exists ( $ this -> app , 'makeWith' ) ? 'makeWith' : 'make' ; return $ this -> app -> $ makeWith ( $ key , $ parameters ) ; } | Resolve the given binding from the container . |
59,904 | protected function generateOptimusNumbers ( $ times = 1 , $ prime = null ) { $ prime = $ prime ? : null ; $ result = [ ] ; for ( $ i = 0 ; $ i < $ times ; $ i ++ ) { $ result [ ] = Energon :: generate ( $ prime ) ; } return $ result ; } | Generate Optimus numbers . |
59,905 | protected function generateRandomAlphabets ( $ times = 1 , $ characters = null ) { $ characters = $ characters ? : $ this -> defaultCharacters ; $ result = [ ] ; for ( $ i = 0 ; $ i < $ times ; $ i ++ ) { $ result [ ] = str_shuffle ( count_chars ( $ characters , 3 ) ) ; } return $ result ; } | Generate random alphabets . |
59,906 | public static function unpackSample ( $ sampleBinary , $ bitDepth = null ) { if ( $ bitDepth === null ) { $ bitDepth = strlen ( $ sampleBinary ) * 8 ; } switch ( $ bitDepth ) { case 8 : return ord ( $ sampleBinary ) ; case 16 : $ data = unpack ( 'v' , $ sampleBinary ) ; $ sample = $ data [ 1 ] ; if ( $ sample >= 0x8000... | Unpacks a single binary sample to numeric value . |
59,907 | public static function packSample ( $ sample , $ bitDepth ) { switch ( $ bitDepth ) { case 8 : return chr ( $ sample ) ; case 16 : if ( $ sample < 0 ) { $ sample += 0x10000 ; } return pack ( 'v' , $ sample ) ; case 24 : if ( $ sample < 0 ) { $ sample += 0x1000000 ; } return pack ( 'C3' , $ sample & 0xff , ( $ sample >>... | Packs a single numeric sample to binary . |
59,908 | public static function unpackSampleBlock ( $ sampleBlock , $ bitDepth , $ numChannels = null ) { $ sampleBytes = $ bitDepth / 8 ; if ( $ numChannels === null ) { $ numChannels = strlen ( $ sampleBlock ) / $ sampleBytes ; } $ samples = array ( ) ; for ( $ i = 0 ; $ i < $ numChannels ; $ i ++ ) { $ sampleBinary = substr ... | Unpacks a binary sample block to numeric values . |
59,909 | public static function packSampleBlock ( $ samples , $ bitDepth ) { $ sampleBlock = '' ; foreach ( $ samples as $ sample ) { $ sampleBlock .= self :: packSample ( $ sample , $ bitDepth ) ; } return $ sampleBlock ; } | Packs an array of numeric channel samples to a binary sample block . |
59,910 | public function getDataSubchunk ( ) { if ( ! $ this -> _dataSize_valid ) { $ this -> setDataSize ( ) ; } return pack ( 'N' , 0x64617461 ) . pack ( 'V' , $ this -> getDataSize ( ) ) . $ this -> _samples . ( $ this -> getDataSize ( ) & 1 ? chr ( 0 ) : '' ) ; } | Construct wav DATA chunk . |
59,911 | public function save ( $ filename ) { $ fp = @ fopen ( $ filename , 'w+b' ) ; if ( ! is_resource ( $ fp ) ) { throw new WavFileException ( 'Failed to open "' . $ filename . '" for writing.' ) ; } fwrite ( $ fp , $ this -> makeHeader ( ) ) ; fwrite ( $ fp , $ this -> getDataSubchunk ( ) ) ; fclose ( $ fp ) ; return $ th... | Save the wav data to a file . |
59,912 | public function openWav ( $ filename , $ readData = true ) { if ( ! file_exists ( $ filename ) ) { throw new WavFileException ( 'Failed to open "' . $ filename . '". File not found.' ) ; } elseif ( ! is_readable ( $ filename ) ) { throw new WavFileException ( 'Failed to open "' . $ filename . '". File is not readable.'... | Reads a wav header and data from a file . |
59,913 | public function setWavData ( & $ data , $ free = true ) { if ( is_resource ( $ this -> _fp ) ) $ this -> closeWav ( ) ; $ this -> _fp = @ fopen ( 'php://memory' , 'w+b' ) ; if ( ! is_resource ( $ this -> _fp ) ) { throw new WavFileException ( 'Failed to open memory stream to write wav data. Use openWav() instead.' ) ; ... | Set the wav file data and properties from a wav file in a string . |
59,914 | protected function readWav ( $ readData = true ) { if ( ! is_resource ( $ this -> _fp ) ) { throw new WavFileException ( 'No wav file open. Use openWav() first.' ) ; } try { $ this -> readWavHeader ( ) ; } catch ( WavFileException $ ex ) { $ this -> closeWav ( ) ; throw $ ex ; } if ( $ readData ) return $ this -> readW... | Read wav file from a stream . |
59,915 | public function readWavData ( $ dataOffset = 0 , $ dataSize = null ) { if ( ! is_resource ( $ this -> _fp ) ) { throw new WavFileException ( 'No wav file open. Use openWav() first.' ) ; } if ( $ dataOffset < 0 || $ dataOffset % $ this -> getBlockAlign ( ) > 0 ) { throw new WavFileException ( 'Invalid data offset. Has t... | Read the wav data from the file into the buffer . |
59,916 | public function getSampleBlock ( $ blockNum ) { if ( ! $ this -> _dataSize_valid ) { $ this -> setDataSize ( ) ; } $ offset = $ blockNum * $ this -> _blockAlign ; if ( $ offset + $ this -> _blockAlign > $ this -> _dataSize || $ offset < 0 ) { return null ; } return substr ( $ this -> _samples , $ offset , $ this -> _bl... | Return a single sample block from the file . |
59,917 | public function getSampleValue ( $ blockNum , $ channelNum ) { if ( $ channelNum < 1 || $ channelNum > $ this -> _numChannels ) { throw new WavFileException ( 'Channel number is out of range.' ) ; } if ( ! $ this -> _dataSize_valid ) { $ this -> setDataSize ( ) ; } $ sampleBytes = $ this -> _bitsPerSample / 8 ; $ offse... | Get a float sample value for a specific sample block and channel number . |
59,918 | public function insertSilence ( $ duration = 1.0 ) { $ numSamples = ( int ) ( $ this -> getSampleRate ( ) * abs ( $ duration ) ) ; $ numChannels = $ this -> getNumChannels ( ) ; $ data = str_repeat ( self :: packSample ( $ this -> getZeroAmplitude ( ) , $ this -> getBitsPerSample ( ) ) , $ numSamples * $ numChannels ) ... | Add silence to the wav file . |
59,919 | public function generateNoise ( $ duration = 1.0 , $ percent = 100 ) { $ numChannels = $ this -> getNumChannels ( ) ; $ numSamples = $ this -> getSampleRate ( ) * $ duration ; $ minAmp = $ this -> getMinAmplitude ( ) ; $ maxAmp = $ this -> getMaxAmplitude ( ) ; $ bitDepth = $ this -> getBitsPerSample ( ) ; for ( $ s = ... | Generate noise at the end of the wav for the specified duration and volume . |
59,920 | public function convertBitsPerSample ( $ bitsPerSample ) { if ( $ this -> getBitsPerSample ( ) == $ bitsPerSample ) { return $ this ; } $ tempWav = new WavFile ( $ this -> getNumChannels ( ) , $ this -> getSampleRate ( ) , $ bitsPerSample ) ; $ tempWav -> filter ( array ( self :: FILTER_MIX => $ this ) , 0 , $ this -> ... | Convert sample data to different bits per sample . |
59,921 | public function displayInfo ( ) { $ s = "File Size: %u\n" . "Chunk Size: %u\n" . "fmt Subchunk Size: %u\n" . "Extended fmt Size: %u\n" . "fact Subchunk Size: %u\n" . "Data Offset: %u\n" . "Data Size: %u\n" . "Audio Format: %s\n" . "Audio SubFormat: %s\n" . "Channels: %u\n" . "Channel Mask: 0x%s\n" . "Sample Rate: %u\n"... | Output information about the wav object . |
59,922 | public static function checkByCaptchaId ( $ id , $ value , array $ options = array ( ) ) { $ opts = array ( 'captchaId' => $ id , 'no_session' => true , 'use_database' => true ) ; if ( sizeof ( $ options ) > 0 ) $ opts = array_merge ( $ options , $ opts ) ; $ si = new self ( $ opts ) ; if ( $ si -> openDatabase ( ) ) {... | Validate a captcha code input against a captcha ID |
59,923 | public function show ( $ background_image = '' ) { set_error_handler ( array ( & $ this , 'errorHandler' ) ) ; if ( $ background_image != '' && is_readable ( $ background_image ) ) { $ this -> bgimg = $ background_image ; } $ this -> doImage ( ) ; } | Generates a new challenge and serves a captcha image . |
59,924 | protected function doImage ( ) { if ( $ this -> use_transparent_text == true || $ this -> bgimg != '' || function_exists ( 'imagecreatetruecolor' ) ) { $ imagecreate = 'imagecreatetruecolor' ; } else { $ imagecreate = 'imagecreate' ; } $ this -> im = $ imagecreate ( $ this -> image_width , $ this -> image_height ) ; if... | The main image drawing routing responsible for constructing the entire image and serving it |
59,925 | protected function allocateColors ( ) { $ this -> gdbgcolor = imagecolorallocate ( $ this -> im , $ this -> image_bg_color -> r , $ this -> image_bg_color -> g , $ this -> image_bg_color -> b ) ; $ alpha = intval ( $ this -> text_transparency_percentage / 100 * 127 ) ; if ( $ this -> use_transparent_text == true ) { $ ... | Allocate the colors to be used for the image |
59,926 | protected function setBackground ( ) { imagefilledrectangle ( $ this -> im , 0 , 0 , $ this -> image_width , $ this -> image_height , $ this -> gdbgcolor ) ; if ( $ this -> perturbation > 0 ) { imagefilledrectangle ( $ this -> tmpimg , 0 , 0 , $ this -> image_width * $ this -> iscale , $ this -> image_height * $ this -... | The the background color or background image to be used |
59,927 | protected function getBackgroundFromDirectory ( ) { $ images = array ( ) ; if ( ( $ dh = opendir ( $ this -> background_directory ) ) !== false ) { while ( ( $ file = readdir ( $ dh ) ) !== false ) { if ( preg_match ( '/(jpg|gif|png)$/i' , $ file ) ) $ images [ ] = $ file ; } closedir ( $ dh ) ; if ( sizeof ( $ images ... | Scan the directory for a background image to use |
59,928 | public function createCode ( ) { $ this -> code = false ; switch ( $ this -> captcha_type ) { case self :: SI_CAPTCHA_MATHEMATIC : { do { $ signs = array ( '+' , '-' , 'x' ) ; $ left = mt_rand ( 1 , 10 ) ; $ right = mt_rand ( 1 , 5 ) ; $ sign = $ signs [ mt_rand ( 0 , 2 ) ] ; switch ( $ sign ) { case 'x' : $ c = $ left... | This method generates a new captcha code . |
59,929 | protected function drawLines ( ) { for ( $ line = 0 ; $ line < $ this -> num_lines ; ++ $ line ) { $ x = $ this -> image_width * ( 1 + $ line ) / ( $ this -> num_lines + 1 ) ; $ x += ( 0.5 - $ this -> frand ( ) ) * $ this -> image_width / $ this -> num_lines ; $ y = mt_rand ( $ this -> image_height * 0.1 , $ this -> im... | Draws distorted lines on the image |
59,930 | protected function drawNoise ( ) { if ( $ this -> noise_level > 10 ) { $ noise_level = 10 ; } else { $ noise_level = $ this -> noise_level ; } $ t0 = microtime ( true ) ; $ noise_level *= M_LOG2E ; for ( $ x = 1 ; $ x < $ this -> image_width ; $ x += 20 ) { for ( $ y = 1 ; $ y < $ this -> image_height ; $ y += 20 ) { f... | Draws random noise on the image |
59,931 | protected function addSignature ( ) { $ bbox = imagettfbbox ( 10 , 0 , $ this -> signature_font , $ this -> image_signature ) ; $ textlen = $ bbox [ 2 ] - $ bbox [ 0 ] ; $ x = $ this -> image_width - $ textlen - 5 ; $ y = $ this -> image_height - 3 ; imagettftext ( $ this -> im , 10 , 0 , $ x , $ y , $ this -> gdsignat... | Print signature text on image |
59,932 | protected function output ( ) { if ( $ this -> canSendHeaders ( ) || $ this -> send_headers == false ) { if ( $ this -> send_headers ) { header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ) ; header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . "GMT" ) ; header ( "Cache-Control: no-store, no-cache, must-revalidate... | Sends the appropriate image and cache headers and outputs image to the browser |
59,933 | protected function getAudibleCode ( ) { $ letters = array ( ) ; $ code = $ this -> getCode ( true , true ) ; if ( empty ( $ code ) || empty ( $ code [ 'code' ] ) ) { if ( strlen ( $ this -> display_value ) > 0 ) { $ code = array ( 'code' => $ this -> display_value , 'display' => $ this -> display_value ) ; } else { $ t... | Generates an audio captcha in WAV format |
59,934 | protected function readCodeFromFile ( $ numWords = 1 ) { $ strtolower_func = 'strtolower' ; $ mb_support = false ; if ( ! empty ( $ this -> wordlist_file_encoding ) ) { if ( ! extension_loaded ( 'mbstring' ) ) { trigger_error ( "wordlist_file_encoding option set, but PHP does not have mbstring support" , E_USER_WARNING... | Gets a captcha code from a file containing a list of words . |
59,935 | protected function generateCode ( ) { $ code = '' ; for ( $ i = 1 , $ cslen = $ this -> strlen ( $ this -> charset ) ; $ i <= $ this -> code_length ; ++ $ i ) { $ code .= $ this -> substr ( $ this -> charset , mt_rand ( 0 , $ cslen - 1 ) , 1 ) ; } return $ code ; } | Generates a random captcha code from the set character set |
59,936 | protected function validate ( ) { if ( ! is_string ( $ this -> code ) || strlen ( $ this -> code ) == 0 ) { $ code = $ this -> getCode ( true ) ; } else { $ code = $ this -> code ; } if ( is_array ( $ code ) ) { if ( ! empty ( $ code ) ) { $ ctime = $ code [ 'time' ] ; $ code = $ code [ 'code' ] ; $ this -> _timeToSolv... | Validate a code supplied by the user |
59,937 | protected function getAudioData ( ) { if ( $ this -> no_session != true ) { if ( isset ( $ _SESSION [ 'securimage_code_audio' ] [ $ this -> namespace ] ) ) { return $ _SESSION [ 'securimage_code_audio' ] [ $ this -> namespace ] ; } } if ( $ this -> use_database ) { $ this -> openDatabase ( ) ; $ code = $ this -> getCod... | Gets audio file contents from the session or database |
59,938 | protected function saveCodeToDatabase ( ) { $ success = false ; $ this -> openDatabase ( ) ; if ( $ this -> use_database && $ this -> pdo_conn ) { $ id = $ this -> getCaptchaId ( false ) ; $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ; if ( empty ( $ id ) ) { $ id = $ ip ; } $ time = time ( ) ; $ code = $ this -> code ; $ code_d... | Saves the CAPTCHA data to the configured database . |
59,939 | protected function saveAudioToDatabase ( $ data ) { $ success = false ; $ this -> openDatabase ( ) ; if ( $ this -> use_database && $ this -> pdo_conn ) { $ id = $ this -> getCaptchaId ( false ) ; $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ; $ ns = $ this -> namespace ; if ( empty ( $ id ) ) { $ id = $ ip ; } $ query = "UPDATE... | Saves CAPTCHA audio to the configured database |
59,940 | protected function openDatabase ( ) { $ this -> pdo_conn = false ; if ( $ this -> use_database ) { $ pdo_extension = 'PDO_' . strtoupper ( $ this -> database_driver ) ; if ( ! extension_loaded ( $ pdo_extension ) ) { trigger_error ( "Database support is turned on in Securimage, but the chosen extension $pdo_extension i... | Opens a connection to the configured database . |
59,941 | protected function getDsn ( ) { $ dsn = sprintf ( '%s:' , $ this -> database_driver ) ; switch ( $ this -> database_driver ) { case self :: SI_DRIVER_SQLITE3 : $ dsn .= $ this -> database_file ; break ; case self :: SI_DRIVER_MYSQL : case self :: SI_DRIVER_PGSQL : if ( empty ( $ this -> database_host ) ) { throw new Ex... | Get the PDO DSN string for connecting to the database |
59,942 | protected function checkTablesExist ( ) { $ table = $ this -> pdo_conn -> quote ( $ this -> database_table ) ; switch ( $ this -> database_driver ) { case self :: SI_DRIVER_SQLITE3 : $ query = "SELECT COUNT(id) FROM $table" ; break ; case self :: SI_DRIVER_MYSQL : $ query = "SHOW TABLES LIKE $table" ; break ; case self... | Checks if the necessary database tables for storing captcha codes exist |
59,943 | protected function createDatabaseTables ( ) { $ queries = array ( ) ; switch ( $ this -> database_driver ) { case self :: SI_DRIVER_SQLITE3 : $ queries [ ] = "CREATE TABLE \"{$this->database_table}\" ( id VARCHAR(40), namespace VARCHAR(32) NOT NULL, ... | Create the necessary databaes table for storing captcha codes . |
59,944 | protected function getCodeFromDatabase ( ) { $ code = '' ; if ( $ this -> use_database == true && $ this -> pdo_conn ) { if ( Securimage :: $ _captchaId !== null ) { $ query = "SELECT * FROM {$this->database_table} WHERE id = ?" ; $ stmt = $ this -> pdo_conn -> prepare ( $ query ) ; $ result = $ stmt -> execute ( array... | Retrieves a stored code from the database for based on the captchaId or IP address if captcha ID not used . |
59,945 | protected function clearCodeFromDatabase ( ) { if ( $ this -> pdo_conn ) { $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ; $ ns = $ this -> pdo_conn -> quote ( $ this -> namespace ) ; $ id = Securimage :: $ _captchaId ; if ( empty ( $ id ) ) { $ id = $ ip ; } $ id = $ this -> pdo_conn -> quote ( $ id ) ; $ query = sprintf ( "DELE... | Remove a stored code from the database based on captchaId or IP address . |
59,946 | protected function isCodeExpired ( $ creation_time ) { $ expired = true ; if ( ! is_numeric ( $ this -> expiry_time ) || $ this -> expiry_time < 1 ) { $ expired = false ; } else if ( time ( ) - $ creation_time < $ this -> expiry_time ) { $ expired = false ; } return $ expired ; } | Checks to see if the captcha code has expired and can no longer be used . |
59,947 | public function getRandomNoiseFile ( ) { $ return = false ; if ( ( $ dh = opendir ( $ this -> audio_noise_path ) ) !== false ) { $ list = array ( ) ; while ( ( $ file = readdir ( $ dh ) ) !== false ) { if ( $ file == '.' || $ file == '..' ) continue ; if ( strtolower ( substr ( $ file , - 4 ) ) != '.wav' ) continue ; $... | Gets and returns the path to a random noise file from the audio noise directory . |
59,948 | protected function getSoxEffectChain ( $ numEffects = 2 ) { $ effectsList = array ( 'bend' , 'chorus' , 'overdrive' , 'pitch' , 'reverb' , 'tempo' , 'tremolo' ) ; $ effects = array_rand ( $ effectsList , $ numEffects ) ; $ outEffects = array ( ) ; if ( ! is_array ( $ effects ) ) $ effects = array ( $ effects ) ; foreac... | Get a random effect or chain of effects to apply to a segment of the audio file . |
59,949 | protected function getSoxNoiseData ( $ duration , $ numChannels , $ sampleRate , $ bitRate ) { $ shapes = array ( 'sine' , 'square' , 'triangle' , 'sawtooth' , 'trapezium' ) ; $ steps = array ( ':' , '+' , '/' , '-' ) ; $ selShapes = array_rand ( $ shapes , 2 ) ; $ selSteps = array_rand ( $ steps , 2 ) ; $ sweep0 = arr... | This function is not yet used . |
59,950 | protected function wavToMp3 ( $ data ) { if ( ! file_exists ( self :: $ lame_binary_path ) || ! is_executable ( self :: $ lame_binary_path ) ) { throw new Exception ( 'Lame binary "' . $ this -> lame_binary_path . '" does not exist or is not executable' ) ; } $ size = strlen ( $ data ) ; $ descriptors = array ( 0 => ar... | Convert WAV data to MP3 using the Lame MP3 encoder binary |
59,951 | protected function initColor ( $ color , $ default ) { if ( $ color == null ) { return new Securimage_Color ( $ default ) ; } else if ( is_string ( $ color ) ) { try { return new Securimage_Color ( $ color ) ; } catch ( Exception $ e ) { return new Securimage_Color ( $ default ) ; } } else if ( is_array ( $ color ) && ... | Convert an html color code to a Securimage_Color |
59,952 | public function errorHandler ( $ errno , $ errstr , $ errfile = '' , $ errline = 0 , $ errcontext = array ( ) ) { $ level = error_reporting ( ) ; if ( $ level == 0 || ( $ level & $ errno ) == 0 ) { return true ; } return false ; } | The error handling function used when outputting captcha image or audio . |
59,953 | protected function constructRGB ( $ red , $ green , $ blue ) { if ( $ red < 0 ) $ red = 0 ; if ( $ red > 255 ) $ red = 255 ; if ( $ green < 0 ) $ green = 0 ; if ( $ green > 255 ) $ green = 255 ; if ( $ blue < 0 ) $ blue = 0 ; if ( $ blue > 255 ) $ blue = 255 ; $ this -> r = $ red ; $ this -> g = $ green ; $ this -> b =... | Construct from an rgb triplet |
59,954 | protected function constructHTML ( $ color ) { if ( strlen ( $ color ) == 3 ) { $ red = str_repeat ( substr ( $ color , 0 , 1 ) , 2 ) ; $ green = str_repeat ( substr ( $ color , 1 , 1 ) , 2 ) ; $ blue = str_repeat ( substr ( $ color , 2 , 1 ) , 2 ) ; } else { $ red = substr ( $ color , 0 , 2 ) ; $ green = substr ( $ co... | Construct from an html hex color code |
59,955 | public function load_plugin_menu ( $ package_name , $ menu_data , bool $ require_affiliation = false ) { $ this -> validate_menu ( $ package_name , $ menu_data ) ; if ( isset ( $ menu_data [ 'permission' ] ) ) { if ( is_array ( $ menu_data [ 'permission' ] ) ) { foreach ( $ menu_data [ 'permission' ] as $ menu_permissi... | Load menus from any registered plugins . |
59,956 | public function validate_menu ( $ package_name , $ menu_data ) { if ( ! is_string ( $ package_name ) ) throw new PackageMenuBuilderException ( 'Package root menu items should be named by string type' ) ; if ( ! is_array ( $ menu_data ) ) throw new PackageMenuBuilderException ( 'Package menu data should be defined in an... | The actual menu validation logic . |
59,957 | public static function handle ( $ message , $ category = null ) { SecurityLog :: create ( [ 'message' => $ message , 'category' => $ category , 'user_id' => auth ( ) -> user ( ) ? auth ( ) -> user ( ) -> id : null , ] ) ; } | Write an entry in the security log . |
59,958 | public function handleProviderCallback ( Socialite $ social ) { $ eve_data = $ social -> driver ( 'eveonline' ) -> user ( ) ; if ( auth ( ) -> check ( ) && auth ( ) -> user ( ) -> id == $ eve_data -> character_id ) return redirect ( ) -> route ( 'home' ) -> with ( 'error' , 'You cannot add yourself. Did you forget to c... | Obtain the user information from Eve Online . |
59,959 | private function findOrCreateUser ( SocialiteUser $ eve_user ) : User { if ( $ existing = User :: find ( $ eve_user -> character_id ) ) { if ( $ existing -> character_owner_hash !== $ eve_user -> character_owner_hash ) { $ existing -> group_id = auth ( ) -> check ( ) ? auth ( ) -> user ( ) -> group -> id : Group :: cre... | Check if a user exists in the database else create and return the User object . |
59,960 | public function loginUser ( User $ user ) : bool { if ( ! $ user -> active ) { event ( 'security.log' , [ 'Login for ' . $ user -> name . ' refused due to a disabled account' , 'authentication' , ] ) ; return false ; } auth ( ) -> login ( $ user , true ) ; return true ; } | Login the user ensuring that a group is attached . |
59,961 | public static function handle ( LoginEvent $ event ) { $ event -> user -> last_login_source = Request :: getClientIp ( ) ; $ event -> user -> last_login = new DateTime ( ) ; $ event -> user -> save ( ) ; $ event -> user -> login_history ( ) -> save ( new UserLoginHistory ( [ 'source' => Request :: getClientIp ( ) , 'us... | Update the last login values and write a new login history item . |
59,962 | public function add_view_composers ( ) { $ this -> app [ 'view' ] -> composer ( [ 'web::includes.header' , 'web::includes.sidebar' , ] , User :: class ) ; $ this -> app [ 'view' ] -> composer ( [ 'web::includes.footer' , ] , Esi :: class ) ; $ this -> app [ 'view' ] -> composer ( 'web::includes.sidebar' , Sidebar :: cl... | Add the view composers . This allows us to make data available in views without repeating any of the code . |
59,963 | public function add_middleware ( $ router ) { $ router -> aliasMiddleware ( 'auth' , Authenticate :: class ) ; $ router -> aliasMiddleware ( 'requirements' , Requirements :: class ) ; $ router -> aliasMiddleware ( 'locale' , Locale :: class ) ; $ router -> aliasMiddleware ( 'registration.status' , RegistrationAllowed :... | Include the middleware needed . |
59,964 | public function add_events ( ) { $ this -> app -> events -> listen ( LoginEvent :: class , Login :: class ) ; $ this -> app -> events -> listen ( LogoutEvent :: class , Logout :: class ) ; $ this -> app -> events -> listen ( Attempting :: class , Attempt :: class ) ; $ this -> app -> events -> listen ( 'security.log' ,... | Register the custom events that may fire for this package . |
59,965 | public function configure_horizon ( ) { Horizon :: auth ( function ( $ request ) { if ( is_null ( $ request -> user ( ) ) ) return false ; return $ request -> user ( ) -> has ( 'queue_manager' , false ) ; } ) ; $ balancing_mode = filter_var ( env ( self :: QUEUE_BALANCING_MODE , false ) , FILTER_VALIDATE_BOOLEAN , FILT... | Configure Horizon . |
59,966 | public function register_services ( ) { $ this -> app -> singleton ( 'Laravel\Socialite\Contracts\Factory' , function ( $ app ) { return new SocialiteManager ( $ app ) ; } ) ; $ eveonline = $ this -> app -> make ( 'Laravel\Socialite\Contracts\Factory' ) ; $ eveonline -> extend ( 'eveonline' , function ( $ app ) use ( $... | Register external services used in this package . |
59,967 | private function configure_api ( ) { $ current_annotations = config ( 'l5-swagger.paths.annotations' ) ; if ( ! is_array ( $ current_annotations ) ) $ current_annotations = [ $ current_annotations ] ; config ( [ 'l5-swagger.paths.annotations' => array_unique ( array_merge ( $ current_annotations , [ __DIR__ . '/Models'... | Update Laravel 5 Swagger annotation path . |
59,968 | public static function handle ( LogoutEvent $ event ) { if ( ! $ event -> user ) return ; $ event -> user -> login_history ( ) -> save ( new UserLoginHistory ( [ 'source' => Request :: getClientIp ( ) , 'user_agent' => Request :: header ( 'User-Agent' ) , 'action' => 'logout' , ] ) ) ; $ message = 'User logged out from... | Write a logout history item for this user . |
59,969 | public function checkLoginToken ( string $ token ) { if ( $ token != cache ( 'admin_login_token' ) ) abort ( 404 ) ; $ user = User :: whereName ( 'admin' ) -> first ( ) ; if ( is_null ( $ user ) ) return redirect ( ) -> route ( 'auth.login' ) -> withErrors ( 'The Admin user does not exist. Re-run the seat:admin:login c... | Login using the cached admin user token . |
59,970 | private function resolveFactionIDs ( Collection $ ids ) { $ names = UniverseName :: whereIn ( 'entity_id' , $ ids -> flatten ( ) -> toArray ( ) ) -> get ( ) -> map ( function ( $ entity ) { return collect ( [ 'id' => $ entity -> entity_id , 'name' => $ entity -> name , 'category' => $ entity -> category , ] ) ; } ) ; r... | Resolve received sets of ids with the help of chrFactions table map the resolved names cache the results and return unresolved ids . |
59,971 | private function resolveInternalCharacterIDs ( Collection $ ids ) { $ names = CharacterInfo :: whereIn ( 'character_id' , $ ids -> flatten ( ) -> toArray ( ) ) -> get ( ) -> map ( function ( $ character ) { return collect ( [ 'id' => $ character -> character_id , 'name' => $ character -> name , 'category' => 'character... | Resolve received sets of ids with the help of character_infos table map the resolved names cache the results and return unresolved ids . |
59,972 | private function resolveInternalCorporationIDs ( Collection $ ids ) { $ names = CorporationInfo :: whereIn ( 'corporation_id' , $ ids -> flatten ( ) -> toArray ( ) ) -> get ( ) -> map ( function ( $ corporation ) { return collect ( [ 'id' => $ corporation -> corporation_id , 'name' => $ corporation -> name , 'category'... | Resolve received sets of ids with the help of corporation_infos table map the resolved names cache the results and return unresolved ids . |
59,973 | private function resolveIDsfromESI ( Collection $ ids , $ eseye ) { try { $ eseye -> setVersion ( 'v3' ) ; $ eseye -> setBody ( $ ids -> flatten ( ) -> toArray ( ) ) ; $ names = $ eseye -> invoke ( 'post' , '/universe/names/' ) ; collect ( $ names ) -> each ( function ( $ name ) { cache ( [ $ this -> prefix . $ name ->... | Resolve given set of ids with the help of eseye client and ESI using a boolean algorithm if one of the ids in the collection of ids is invalid . If name could be resolved save the name to universe_names table . |
59,974 | private function cacheIDsAndReturnUnresolvedIDs ( Collection $ names , Collection $ ids ) : Collection { $ names -> each ( function ( $ name ) { cache ( [ $ this -> prefix . $ name [ 'id' ] => $ name [ 'name' ] ] , carbon ( ) -> addCentury ( ) ) ; $ this -> response [ $ name [ 'id' ] ] = $ name [ 'name' ] ; UniverseNam... | Cache and save resolved IDs . Return unresolved collection of ids . |
59,975 | public function hasAny ( array $ permissions , bool $ need_affiliation = true ) : bool { foreach ( $ permissions as $ permission ) if ( $ this -> has ( $ permission , $ need_affiliation ) ) return true ; return false ; } | Checks if the user has any of the required permissions . |
59,976 | public function hasSuperUser ( ) { $ permissions = $ this -> getAllPermissions ( ) ; foreach ( $ permissions as $ permission ) if ( $ permission === 'superuser' ) return true ; return false ; } | Determine of the current user has the superuser permission . |
59,977 | public function getAllPermissions ( ) { $ permissions = [ ] ; $ roles = $ this -> group -> roles ( ) -> with ( 'permissions' ) -> get ( ) ; foreach ( $ roles as $ role ) { foreach ( $ role -> permissions as $ permission ) { if ( ! $ permission -> pivot -> not ) array_push ( $ permissions , $ permission -> title ) ; } }... | Return an array of all the of the permissions that the user has . |
59,978 | public function hasRole ( $ role_name ) { if ( $ this -> hasSuperUser ( ) ) return true ; foreach ( $ this -> group -> roles as $ role ) if ( $ role -> title == $ role_name ) return true ; return false ; } | Determine if the current user has a specific role . |
59,979 | public function getCompleteRole ( int $ role_id = null ) { $ roles = RoleModel :: with ( 'permissions' , 'groups' , 'affiliations' ) ; if ( ! is_null ( $ role_id ) ) { $ roles = $ roles -> where ( 'id' , $ role_id ) -> first ( ) ; if ( ! $ roles ) abort ( 404 ) ; return $ roles ; } return $ roles -> get ( ) ; } | Return everything related to the Role with eager loading . |
59,980 | public function removeRoleByTitle ( string $ title ) { $ role = RoleModel :: where ( 'title' , $ title ) -> first ( ) ; $ this -> removeRole ( $ role -> id ) ; } | Remove a role by title . |
59,981 | public function giveRolePermissions ( $ role_id , array $ permissions , bool $ inverse ) { foreach ( $ permissions as $ key => $ permission_name ) $ this -> giveRolePermission ( $ role_id , $ permission_name , $ inverse ) ; } | Give a role many permissions . |
59,982 | public function giveRolePermission ( int $ role_id , string $ permission_name , bool $ inverse ) { $ role = $ this -> getRole ( $ role_id ) ; $ permission = PermissionModel :: firstOrNew ( [ 'title' => $ permission_name , ] ) ; if ( ! $ role -> permissions -> contains ( $ permission -> id ) ) $ role -> permissions ( ) ... | Give a Role a permission . |
59,983 | public function removePermissionFromRole ( int $ permission_id , int $ role_id ) { $ role = $ this -> getRole ( $ role_id ) ; $ role -> permissions ( ) -> detach ( $ permission_id ) ; } | Remove a permission from a Role . |
59,984 | public function giveGroupsRole ( array $ group_ids , int $ role_id ) { foreach ( $ group_ids as $ group_id ) { $ group = Group :: where ( 'id' , $ group_id ) -> first ( ) ; $ this -> giveGroupRole ( $ group -> id , $ role_id ) ; } } | Give an array of group_ids a role . |
59,985 | public function giveGroupRole ( int $ group_id , int $ role_id ) { $ group = Group :: find ( $ group_id ) ; $ role = RoleModel :: firstOrNew ( [ 'id' => $ role_id ] ) ; if ( ! $ role -> groups -> contains ( $ group_id ) ) { $ role -> groups ( ) -> save ( $ group ) ; event ( new UserGroupRoleAdded ( $ group_id , $ role ... | Give a group a Role . |
59,986 | public function removeGroupFromRole ( int $ group_id , int $ role_id ) { $ role = $ this -> getRole ( $ role_id ) ; if ( $ role -> groups ( ) -> detach ( $ group_id ) > 0 ) event ( new UserGroupRoleRemoved ( $ group_id , $ role ) ) ; } | Remove a group from a role . |
59,987 | public function postPackagesCheck ( PackageVersionCheck $ request ) { $ packagist_url = sprintf ( 'https://packagist.org/packages/%s/%s.json' , $ request -> input ( 'vendor' ) , $ request -> input ( 'package' ) ) ; $ response = ( new Client ( ) ) -> request ( 'GET' , $ packagist_url ) ; if ( $ response -> getStatusCode... | Determine if a package is or not outdated . |
59,988 | public function postPackagesChangelog ( PackageChangelog $ request ) { $ changelog_uri = $ request -> input ( 'uri' ) ; $ changelog_body = $ request -> input ( 'body' ) ; $ changelog_tag = $ request -> input ( 'tag' ) ; if ( ! is_null ( $ changelog_body ) && ! is_null ( $ changelog_tag ) ) return $ this -> getChangelog... | Return the changelog based on provided parameters . |
59,989 | private function getPluginsMetadataList ( ) : stdClass { app ( ) -> loadDeferredProviders ( ) ; $ providers = array_keys ( app ( ) -> getLoadedProviders ( ) ) ; $ packages = ( object ) [ 'core' => collect ( ) , 'plugins' => collect ( ) , ] ; foreach ( $ providers as $ class ) { $ provider = app ( ) -> getProvider ( $ c... | Compute a list of provider class which are implementing SeAT package structure . |
59,990 | private function getChangelogFromApi ( string $ uri , string $ body_attribute , string $ tag_attribute ) : string { try { return cache ( ) -> remember ( $ this -> getChangelogCacheKey ( $ uri ) , 30 , function ( ) use ( $ uri , $ body_attribute , $ tag_attribute ) { $ changelog = '' ; $ client = new Client ( ) ; $ resp... | Return a rendered changelog based on the provided release API endpoint . |
59,991 | private function getChangelogFromFile ( string $ uri ) { try { return cache ( ) -> remember ( $ this -> getChangelogCacheKey ( $ uri ) , 30 , function ( ) use ( $ uri ) { $ client = new Client ( ) ; $ response = $ client -> request ( 'GET' , $ uri ) ; $ parser = new Parsedown ( ) ; $ parser -> setSafeMode ( true ) ; re... | Return parsed markdown from the file located at the provided URI . |
59,992 | private function parseHeaders ( array $ headers ) { $ this -> raw_headers = $ headers ; $ headers = array_map ( function ( $ value ) { if ( ! is_array ( $ value ) ) return $ value ; return implode ( ';' , $ value ) ; } , $ headers ) ; $ this -> headers = $ headers ; $ this -> hasHeader ( 'X-Esi-Error-Limit-Remain' ) ? ... | Parse an array of header key value pairs . |
59,993 | public function expired ( ) : bool { if ( $ this -> expires ( ) -> lte ( carbon ( ) -> now ( $ this -> expires ( ) -> timezoneName ) ) ) return true ; return false ; } | Determine if this containers data should be considered expired . |
59,994 | private function refreshToken ( ) { $ response = $ this -> httpRequest ( 'post' , $ this -> sso_base . '/token/?grant_type=refresh_token&refresh_token=' . $ this -> authentication -> refresh_token , [ 'Authorization' => 'Basic ' . base64_encode ( $ this -> authentication -> client_id . ':' . $ this -> authentication ->... | Refresh the Access token that we have in the EsiAccess container . |
59,995 | public function setVersion ( string $ version ) { if ( substr ( $ version , 0 , 1 ) !== '/' ) $ version = '/' . $ version ; $ this -> version = $ version ; return $ this ; } | Set the version of the API endpoints base URI . |
59,996 | public static function getName ( $ oidString , $ loadFromWeb = true ) { switch ( $ oidString ) { case self :: RSA_ENCRYPTION : return 'RSA Encryption' ; case self :: MD5_WITH_RSA_ENCRYPTION : return 'MD5 with RSA Encryption' ; case self :: SHA1_WITH_RSA_SIGNATURE : return 'SHA-1 with RSA Signature' ; case self :: PKCS9... | Returns the name of the given object identifier . |
59,997 | protected static function parseOid ( & $ binaryData , & $ offsetIndex , $ octetsToRead ) { $ oid = '' ; while ( $ octetsToRead > 0 ) { $ octets = '' ; do { if ( 0 === $ octetsToRead ) { throw new ParserException ( 'Malformed ASN.1 Object Identifier' , $ offsetIndex - 1 ) ; } $ octetsToRead -- ; $ octet = $ binaryData [... | Parses an object identifier except for the first octet which is parsed differently . This way relative object identifiers can also be parsed using this . |
59,998 | public function getBinary ( ) { $ result = $ this -> getIdentifier ( ) ; $ result .= $ this -> createLengthPart ( ) ; $ result .= $ this -> getEncodedValue ( ) ; return $ result ; } | Encode this object using DER encoding . |
59,999 | public static function create ( $ val ) { if ( self :: $ _prefer ) { switch ( self :: $ _prefer ) { case 'gmp' : $ ret = new BigIntegerGmp ( ) ; break ; case 'bcmath' : $ ret = new BigIntegerBcmath ( ) ; break ; default : throw new \ UnexpectedValueException ( 'Unknown number implementation: ' . self :: $ _prefer ) ; }... | Create a BigInteger instance based off the base 10 string or an integer . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.