idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
53,300
private function matchPair ( $ string , $ variable ) { if ( ! preg_match ( "|" . preg_quote ( $ this -> l_delim ) . 'loop ' . $ variable . preg_quote ( $ this -> r_delim ) . "(.+?)" . preg_quote ( $ this -> l_delim ) . 'end loop' . preg_quote ( $ this -> r_delim ) . "|s" , $ string , $ match ) ) { return false ; } retu...
Match loop pair
53,301
protected function generateTemplate ( ) { $ st_annotations = $ this -> extractAnnotations ( ) ; $ template = array ( ) ; $ counter = 0 ; $ section = null ; $ partial_template = $ this -> loadPartialTemplate ( 'main' ) ; foreach ( $ st_annotations as $ class => $ methods ) { foreach ( $ methods as $ name => $ docs ) { i...
Generate the content of the documentation
53,302
protected function generateSampleOutput ( $ st_params , $ counter ) { if ( ! isset ( $ st_params [ 'ApiReturn' ] ) ) { $ responseBody = '' ; } else { $ ret = [ ] ; $ partial_template = $ this -> loadPartialTemplate ( 'sampleReponseTpl' ) ; foreach ( $ st_params [ 'ApiReturn' ] as $ params ) { if ( in_array ( $ params [...
Generate the sample output
53,303
protected function generateHeadersTemplate ( $ id , $ st_params ) { if ( ! isset ( $ st_params [ 'ApiHeaders' ] ) ) { return ; } $ body = [ ] ; $ partial_template = $ this -> loadPartialTemplate ( 'paramContentTpl' ) ; foreach ( $ st_params [ 'ApiHeaders' ] as $ params ) { $ tr = array ( '{{ name }}' => $ params [ 'nam...
Generates the template for headers
53,304
protected function generateParamsTemplate ( $ id , $ st_params ) { if ( ! isset ( $ st_params [ 'ApiParams' ] ) ) { return ; } $ body = [ ] ; $ paramSampleBtnTpl = $ this -> loadPartialTemplate ( 'paramSampleBtnTpl' ) ; $ paramContentTpl = $ this -> loadPartialTemplate ( 'paramContentTpl' ) ; foreach ( $ st_params [ 'A...
Generates the template for parameters
53,305
private function generateBodyTemplate ( $ id , $ docs ) { if ( ! isset ( $ docs [ 'ApiBody' ] ) ) { return ; } $ body = $ docs [ 'ApiBody' ] [ 0 ] ; return strtr ( $ this -> loadPartialTemplate ( 'samplePostBodyTpl' ) , array ( '{{ elt_id }}' => $ id , '{{ body }}' => $ body [ 'sample' ] ) ) ; }
Generate POST body template
53,306
protected function generateSandboxForm ( $ st_params , $ counter ) { $ headers = [ ] ; $ params = [ ] ; $ sandboxFormInputTpl = $ this -> loadPartialTemplate ( 'sandboxFormInputTpl' ) ; if ( isset ( $ st_params [ 'ApiParams' ] ) && is_array ( $ st_params [ 'ApiParams' ] ) ) { foreach ( $ st_params [ 'ApiParams' ] as $ ...
Generate route paramteres form
53,307
public function renderJson ( ) { $ st_annotations = $ this -> extractAnnotations ( ) ; $ o_view = new JsonView ( ) ; $ o_view -> set ( 'annotations' , $ st_annotations ) ; $ o_view -> render ( ) ; }
Output the annotations in json format
53,308
public function set ( $ key , $ value , $ b_skipKey = false ) { if ( true === $ b_skipKey ) { $ this -> st_data = $ value ; } else { $ this -> st_data [ $ key ] = $ value ; } }
Set parameters to render
53,309
protected function registerConfig ( ) { $ this -> app -> singleton ( 'stripe.config' , function ( $ app ) { return $ app [ 'stripe' ] -> getConfig ( ) ; } ) ; $ this -> app -> alias ( 'stripe.config' , 'Cartalyst\Stripe\Config' ) ; $ this -> app -> alias ( 'stripe.config' , 'Cartalyst\Stripe\ConfigInterface' ) ; }
Register the config class .
53,310
public static function run ( Event $ event ) { $ io = $ event -> getIO ( ) ; $ composer = $ event -> getComposer ( ) ; $ instance = new static ( ) ; $ instance -> io = $ io ; $ instance -> composer = $ composer ; $ instance -> init ( ) ; $ instance -> onDependenciesChangedEvent ( ) ; }
Triggers the plugin s main functionality .
53,311
private function init ( ) { $ this -> cwd = getcwd ( ) ; $ this -> installedPaths = array ( ) ; $ this -> processExecutor = new ProcessExecutor ( $ this -> io ) ; $ this -> filesystem = new Filesystem ( $ this -> processExecutor ) ; }
Prepares the plugin so it s main functionality can be run .
53,312
public function onDependenciesChangedEvent ( ) { $ io = $ this -> io ; $ isVerbose = $ io -> isVerbose ( ) ; if ( $ isVerbose ) { $ io -> write ( sprintf ( '<info>%s</info>' , self :: MESSAGE_RUNNING_INSTALLER ) ) ; } if ( $ this -> isPHPCodeSnifferInstalled ( ) === true ) { $ this -> loadInstalledPaths ( ) ; $ install...
Entry point for post install and post update events .
53,313
private function loadInstalledPaths ( ) { if ( $ this -> isPHPCodeSnifferInstalled ( ) === true ) { $ this -> processExecutor -> execute ( sprintf ( 'phpcs --config-show %s' , self :: PHPCS_CONFIG_KEY ) , $ output , $ this -> composer -> getConfig ( ) -> get ( 'bin-dir' ) ) ; $ phpcsInstalledPaths = str_replace ( self ...
Load all paths from PHP_CodeSniffer into an array .
53,314
private function saveInstalledPaths ( ) { if ( count ( $ this -> installedPaths ) !== 0 ) { $ paths = implode ( ',' , $ this -> installedPaths ) ; $ arguments = array ( '--config-set' , self :: PHPCS_CONFIG_KEY , $ paths ) ; $ configMessage = sprintf ( 'PHP CodeSniffer Config <info>%s</info> <comment>set to</comment> <...
Save all coding standard paths back into PHP_CodeSniffer
53,315
private function cleanInstalledPaths ( ) { $ changes = false ; foreach ( $ this -> installedPaths as $ key => $ path ) { $ alternativePath = realpath ( $ this -> getPHPCodeSnifferInstallPath ( ) . DIRECTORY_SEPARATOR . $ path ) ; if ( ( is_dir ( $ path ) === false || is_readable ( $ path ) === false ) && ( is_dir ( $ a...
Iterate trough all known paths and check if they are still valid .
53,316
private function getPHPCodingStandardPackages ( ) { $ codingStandardPackages = array_filter ( $ this -> composer -> getRepositoryManager ( ) -> getLocalRepository ( ) -> getPackages ( ) , function ( PackageInterface $ package ) { if ( $ package instanceof AliasPackage ) { return false ; } return $ package -> getType ( ...
Iterates through Composers local repository looking for valid Coding Standard packages .
53,317
private function getPHPCodeSnifferPackage ( $ versionConstraint = null ) { $ packages = $ this -> composer -> getRepositoryManager ( ) -> getLocalRepository ( ) -> findPackages ( self :: PACKAGE_NAME , $ versionConstraint ) ; return array_shift ( $ packages ) ; }
Searches for the installed PHP_CodeSniffer Composer package
53,318
private function getMaxDepth ( ) { $ maxDepth = 3 ; $ extra = $ this -> composer -> getPackage ( ) -> getExtra ( ) ; if ( array_key_exists ( self :: KEY_MAX_DEPTH , $ extra ) ) { $ maxDepth = $ extra [ self :: KEY_MAX_DEPTH ] ; $ minDepth = $ this -> getMinDepth ( ) ; if ( is_int ( $ maxDepth ) === false || $ maxDepth ...
Determines the maximum search depth when searching for Coding Standards .
53,319
public static function getReportArray ( ) { $ composerArray = self :: getComposerArray ( ) ; $ packages = self :: getPackagesAndDependencies ( $ composerArray [ 'require' ] ) ; $ version = self :: getDecomposerVersion ( $ composerArray , $ packages ) ; $ reportArray [ 'Server Environment' ] = self :: getServerEnv ( ) ;...
Get the Decomposer system report as a PHP array
53,320
public static function getPackagesAndDependencies ( $ packagesArray ) { foreach ( $ packagesArray as $ key => $ value ) { $ packageFile = base_path ( "/vendor/{$key}/composer.json" ) ; if ( $ key !== 'php' && file_exists ( $ packageFile ) ) { $ json2 = file_get_contents ( $ packageFile ) ; $ dependenciesArray = json_de...
Get Installed packages & their Dependencies
53,321
public static function getLaravelEnv ( $ decomposerVersion ) { return array_merge ( [ 'version' => App :: version ( ) , 'timezone' => config ( 'app.timezone' ) , 'debug_mode' => config ( 'app.debug' ) , 'storage_dir_writable' => is_writable ( base_path ( 'storage' ) ) , 'cache_dir_writable' => is_writable ( base_path (...
Get Laravel environment details
53,322
private static function getPackagesArray ( $ composerRequireArray ) { $ packagesArray = self :: getPackagesAndDependencies ( $ composerRequireArray ) ; foreach ( $ packagesArray as $ packageArray ) { $ packages [ $ packageArray [ 'name' ] ] = $ packageArray [ 'version' ] ; } return $ packages ; }
Get Installed packages & their version numbers as an associative array
53,323
public static function getDecomposerVersion ( $ composerArray , $ packages ) { if ( isset ( $ composerArray [ 'require' ] [ self :: PACKAGE_NAME ] ) ) { return $ composerArray [ 'require' ] [ self :: PACKAGE_NAME ] ; } if ( isset ( $ composerArray [ 'require-dev' ] [ self :: PACKAGE_NAME ] ) ) { return $ composerArray ...
Get current installed Decomposer version
53,324
private static function folderSize ( $ dir ) { $ size = 0 ; foreach ( glob ( rtrim ( $ dir , '/' ) . '/*' , GLOB_NOSORT ) as $ each ) { $ size += is_file ( $ each ) ? filesize ( $ each ) : self :: folderSize ( $ each ) ; } return $ size ; }
Get the laravel app s size
53,325
private static function sizeFormat ( $ bytes ) { $ kb = 1024 ; $ mb = $ kb * 1024 ; $ gb = $ mb * 1024 ; $ tb = $ gb * 1024 ; if ( ( $ bytes >= 0 ) && ( $ bytes < $ kb ) ) { return $ bytes . ' B' ; } elseif ( ( $ bytes >= $ kb ) && ( $ bytes < $ mb ) ) { return ceil ( $ bytes / $ kb ) . ' KB' ; } elseif ( ( $ bytes >= ...
Format the app s size in correct units
53,326
protected function getClient ( array $ auth ) { $ endpoint = sprintf ( 'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s' , $ auth [ 'account-name' ] , $ auth [ 'api-key' ] ) ; return ServicesBuilder :: getInstance ( ) -> createBlobService ( $ endpoint ) ; }
Get the azure client .
53,327
protected function getCacheConfig ( string $ name ) { $ cache = $ this -> config -> get ( $ this -> getConfigName ( ) . '.cache' ) ; if ( ! is_array ( $ config = array_get ( $ cache , $ name ) ) && ! $ config ) { throw new InvalidArgumentException ( "Cache [$name] not configured." ) ; } $ config [ 'name' ] = $ name ; r...
Get the cache configuration .
53,328
protected function getAdapter ( AdapterInterface $ client , array $ config ) { $ file = array_get ( $ config , 'file' , 'flysystem.json' ) ; $ ttl = array_get ( $ config , 'ttl' ) ; return new Adapter ( $ client , $ file , $ ttl ) ; }
Get the adapter cache adapter .
53,329
protected function getAdapter ( Store $ client , array $ config ) { $ key = array_get ( $ config , 'key' , 'flysystem' ) ; $ ttl = array_get ( $ config , 'ttl' ) ; return new IlluminateCache ( $ client , $ key , $ ttl ) ; }
Get the illuminate cache adapter .
53,330
public function connect ( array $ config ) { $ auth = $ this -> getAuth ( $ config ) ; $ client = $ this -> getClient ( $ auth ) ; return $ this -> getAdapter ( $ client ) ; }
Establish an adapter connection .
53,331
protected function getClient ( array $ auth ) { $ client = new OpenStackRackspace ( $ auth [ 'endpoint' ] , [ 'username' => $ auth [ 'username' ] , 'apiKey' => $ auth [ 'apiKey' ] , ] ) ; $ urlType = array_get ( $ auth , 'internal' , false ) ? 'internalURL' : 'publicURL' ; return $ client -> objectStoreService ( 'cloud...
Get the rackspace client .
53,332
protected function getAdapter ( array $ config ) { $ path = $ config [ 'path' ] ; $ writeFlags = array_get ( $ config , 'write_flags' , LOCK_EX ) ; $ linkHandling = array_get ( $ config , 'link_handling' , Local :: DISALLOW_LINKS ) ; $ permissions = array_get ( $ config , 'permissions' , [ ] ) ; return new Local ( $ pa...
Get the local adapter .
53,333
protected function getAdapter ( MongoClient $ client , array $ config ) { $ fs = $ client -> selectDB ( $ config [ 'database' ] ) -> getGridFS ( ) ; return new GridFSAdapter ( $ fs ) ; }
Get the gridfs adapter .
53,334
public function save ( ) { $ contents = $ this -> getForStorage ( ) ; if ( $ this -> ttl !== null ) { $ this -> client -> put ( $ this -> key , $ contents , $ this -> ttl ) ; } else { $ this -> client -> forever ( $ this -> key , $ contents ) ; } }
Store the cache .
53,335
protected function registerCacheFactory ( ) { $ this -> app -> singleton ( 'flysystem.cachefactory' , function ( Container $ app ) { $ cache = $ app [ 'cache' ] ; return new CacheFactory ( $ cache ) ; } ) ; $ this -> app -> alias ( 'flysystem.cachefactory' , CacheFactory :: class ) ; }
Register the cache factory class .
53,336
protected function registerFlysystemFactory ( ) { $ this -> app -> singleton ( 'flysystem.factory' , function ( Container $ app ) { $ adapter = $ app [ 'flysystem.adapterfactory' ] ; $ cache = $ app [ 'flysystem.cachefactory' ] ; return new FlysystemFactory ( $ adapter , $ cache ) ; } ) ; $ this -> app -> alias ( 'flys...
Register the flysystem factory class .
53,337
public function make ( array $ config , FlysystemManager $ manager ) { $ adapter = $ this -> createAdapter ( $ config ) ; if ( is_array ( $ cache = array_get ( $ config , 'cache' , false ) ) ) { $ adapter = new CachedAdapter ( $ adapter , $ this -> createCache ( $ cache , $ manager ) ) ; } $ options = $ this -> getOpti...
Make a new flysystem instance .
53,338
protected function getOptions ( array $ config ) { $ options = [ ] ; if ( $ visibility = array_get ( $ config , 'visibility' ) ) { $ options [ 'visibility' ] = $ visibility ; } if ( $ pirate = array_get ( $ config , 'pirate' ) ) { $ options [ 'disable_asserts' ] = $ pirate ; } return $ options ; }
Get the flysystem options .
53,339
public static function message ( $ message = null , $ newLine = true ) { if ( ! static :: enableTool ( ) or ! $ message ) return ; static :: $ performance -> message ( $ message , $ newLine ) ; }
Set a message associated with the point
53,340
public function totalTimeAndMemory ( $ pointStack ) { $ max_time = 0 ; $ max_memory = 0 ; foreach ( array_slice ( $ pointStack , 2 ) as $ point ) { $ max_time += $ point -> getDifferenceTime ( ) ; $ max_memory += $ point -> getDifferenceMemory ( ) ; } return new CalculateTotalHolder ( $ max_time , $ max_memory , memory...
Calculate total memory
53,341
protected function checkQueryType ( ) { if ( strtolower ( substr ( $ this -> query , 0 , 6 ) ) == 'select' ) $ this -> queryType = 'select' ; elseif ( strtolower ( substr ( $ this -> query , 0 , 6 ) ) == 'insert' ) $ this -> queryType = 'insert' ; elseif ( strtolower ( substr ( $ this -> query , 0 , 6 ) ) == 'delete' )...
Set query type
53,342
public function finish ( $ multiplePointLabel = null ) { $ this -> finishLastPoint ( ) ; if ( $ multiplePointLabel ) { if ( ! isset ( $ this -> multiPointStack [ $ multiplePointLabel ] ) ) throw new \ InvalidArgumentException ( "Can't finish multiple point '" . $ multiplePointLabel . "'." ) ; $ point = $ this -> multiP...
Finish measuring point X
53,343
public function results ( ) { $ this -> finishLastPoint ( ) ; $ this -> finishAllMultiplePoints ( ) ; $ this -> presenter -> displayResultsTrigger ( $ this -> pointStack ) ; return $ this -> export ( ) ; }
Return test results
53,344
protected function finishLastPoint ( ) { $ stopTime = microtime ( true ) ; if ( $ this -> currentPoint ) { $ point = $ this -> currentPoint ; if ( $ point -> isActive ( ) ) { $ this -> setQueryLogItemsToPoint ( $ point ) ; $ this -> checkAndSetMessageInToLabel ( $ point ) ; $ point -> setStopTime ( $ stopTime ) ; $ poi...
Finish all point in the stack
53,345
protected function checkIfPointLabelExists ( $ label , $ isMultiPoint ) { $ labelExists = false ; $ stack = ( $ isMultiPoint ) ? $ this -> multiPointStack : $ this -> pointStack ; foreach ( $ stack as $ point ) { if ( $ point -> getLabel ( ) == $ label ) { $ labelExists = true ; break ; } } if ( $ labelExists ) throw n...
Check if label already exists
53,346
protected function preload ( ) { $ this -> point ( Point :: POINT_PRELOAD ) ; $ this -> point ( Point :: POINT_MULTIPLE_PRELOAD , true ) ; $ this -> finish ( POINT :: POINT_MULTIPLE_PRELOAD ) ; $ this -> point ( Point :: POINT_CALIBRATE ) ; }
Preload wil setup te point class
53,347
protected function setConfigQueryLogState ( ) { if ( ! is_null ( $ this -> config -> queryLogState ) ) return ; if ( $ this -> config -> isQueryLog ( ) ) { $ this -> config -> queryLogState = false ; if ( ! class_exists ( '\Illuminate\Support\Facades\DB' ) ) return ; try { \ Illuminate \ Support \ Facades \ DB :: liste...
Check if query log is possible
53,348
protected function setQueryLogItemsToPoint ( Point $ point ) { if ( $ this -> config -> queryLogState !== true ) return ; $ point -> setQueryLog ( $ this -> queryLogStack ) ; $ this -> queryLogStack = [ ] ; }
Move query log items to point
53,349
protected function checkAndSetMessageInToLabel ( Point $ point ) { if ( ! $ this -> messageToLabel ) return ; $ point -> setLabel ( $ point -> getLabel ( ) . " - " . $ this -> messageToLabel ) ; $ this -> messageToLabel = '' ; }
Update point label with message
53,350
public function setCache ( array $ data ) { $ handle = $ this -> handle ; $ rows = $ handle -> query ( 'SELECT created FROM `' . $ this -> config [ 'table' ] . '`' ) ; if ( ! $ rows || $ rows -> rowCount ( ) === 0 ) { $ this -> write ( $ handle , $ data ) ; } else { foreach ( $ rows as $ row ) { if ( ( time ( ) - strto...
Writes cache data into the database
53,351
private function connect ( ) { if ( ! $ this -> config [ 'wrapper' ] || ! $ this -> config [ 'user' ] || ! $ this -> config [ 'password' ] || ! $ this -> config [ 'table' ] ) { throw new \ Exception ( 'Insufficient connection parameters' ) ; } try { $ handle = new \ PDO ( $ this -> config [ 'wrapper' ] , $ this -> conf...
Connect to database and return a handle
53,352
public function update ( ) { $ ok = true ; $ ok = $ this -> updateFile ( self :: FILENAME_RULES ) ; if ( $ ok ) $ ok = $ this -> updateFile ( self :: FILENAME_CONVERTER ) ; return $ ok ; }
Perform a Rule and Converter update if necessary
53,353
private function updateFile ( $ filename ) { $ file_contents = $ this -> fetchUrl ( self :: DOWNLOAD_BASE_URL . $ filename ) ; if ( $ file_contents === false ) return false ; if ( sha1 ( $ file_contents ) != $ this -> getCurrentFileHash ( $ filename ) ) { try { throw new Exception ( "PHPIDS-Update: SHA1-hash of the dow...
Download current file and replaces local
53,354
private function getCurrentFileHash ( $ filename ) { if ( ! empty ( $ hash_cache [ $ filename ] ) ) { return $ hash_cache [ $ filename ] ; } $ url = self :: HASH_BASE_URL . $ filename ; $ hash_response = $ this -> fetchUrl ( $ url ) ; if ( $ hash_response === false ) return false ; $ hash = trim ( $ hash_response ) ; i...
Retreive current SHA - 1 hash from php - ids . org
53,355
private function getLocalFileHash ( $ filename ) { $ path = $ this -> phpids_base . $ filename ; if ( file_exists ( $ path ) ) { return sha1_file ( $ path ) ; } else { return false ; } }
Generate SHA - 1 hash for local files
53,356
public function isRulesUpdated ( ) { if ( $ this -> getCurrentFileHash ( self :: FILENAME_RULES ) == $ this -> getLocalFileHash ( self :: FILENAME_RULES ) ) { return true ; } else { return false ; } }
Compare local and remote version of ids rules .
53,357
public function isConverterUpdated ( ) { if ( $ this -> getCurrentFileHash ( self :: FILENAME_CONVERTER ) == $ this -> getLocalFileHash ( self :: FILENAME_CONVERTER ) ) { return true ; } else { return false ; } }
Compare local and remote version of ids converter .
53,358
public function isWritable ( ) { if ( file_exists ( $ this -> phpids_base . self :: FILENAME_RULES ) && is_writable ( $ this -> phpids_base . self :: FILENAME_RULES ) && file_exists ( $ this -> phpids_base . self :: FILENAME_CONVERTER ) && is_writable ( $ this -> phpids_base . self :: FILENAME_CONVERTER ) ) { return tr...
Check for existing rules and converter and for write permissions
53,359
public function showVersionStatus ( ) { $ update_needed = false ; $ output = "<table class='tableBorder'>" ; $ output .= "<tr><td class='tableHead' colspan='2'>IDS Version</td></tr>" ; $ output .= "<tr><td class='tableCell' valign='top'>Filter:</td>\n<td class='tableCell'>" ; if ( $ this -> isRulesUpdated ( ) ) { $ out...
Show version status table
53,360
private function addFiltersFromArray ( array $ filters ) { foreach ( $ filters as $ filter ) { $ id = $ filter [ 'id' ] ; $ rule = $ filter [ 'rule' ] ; $ impact = $ filter [ 'impact' ] ; $ tags = $ filter [ 'tags' ] ; $ description = $ filter [ 'description' ] ; $ this -> addFilter ( new \ IDS \ Filter ( $ id , $ rule...
This functions adds an array of filters to the IDS_Storage object . Each entry within the array is expected to be an simple array containing all parts of the filter .
53,361
private function idslog ( $ result , $ reaction = 0 ) { $ user = $ this -> controller -> Session -> read ( 'User.id' ) ? $ this -> controller -> Session -> read ( 'User.id' ) : 0 ; $ ip = ( $ _SERVER [ 'SERVER_ADDR' ] != '127.0.0.1' ) ? $ _SERVER [ 'SERVER_ADDR' ] : ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ? $ ...
This function writes an entry about the intrusion to the intrusion database
53,362
public function getImpact ( ) { if ( ! $ this -> impact ) { $ this -> impact = 0 ; foreach ( $ this -> filters as $ filter ) { $ this -> impact += $ filter -> getImpact ( ) ; } } return $ this -> impact ; }
Returns calculated impact
53,363
public function getTags ( ) { foreach ( $ this -> getFilters ( ) as $ filter ) { $ this -> tags = array_merge ( $ this -> tags , $ filter -> getTags ( ) ) ; } return $ this -> tags = array_values ( array_unique ( $ this -> tags ) ) ; }
Returns affected tags
53,364
public static function convertFromCommented ( $ value ) { if ( preg_match ( '/(?:\<!-| , $ value ) ) { $ pattern = array ( '/(?:(?:<!)(?:(?:--(?:[^-]*(?:-[^-]+)*)--\s*)*)(?:>))/ms' , '/(?:(?:\/\*\/*[^\/\*]*)+\*\/)/ms' , '/(?:--[^-]*-)/ms' ) ; $ converted = preg_replace ( $ pattern , ';' , $ value ) ; $ value .= "\n" . ...
Check for comments and erases them if available
53,365
public static function convertFromSQLHex ( $ value ) { $ matches = array ( ) ; if ( preg_match_all ( '/(?:(?:\A|[^\d])0x[a-f\d]{3,}[a-f\d]*)+/im' , $ value , $ matches ) ) { foreach ( $ matches [ 0 ] as $ match ) { $ converted = '' ; foreach ( str_split ( $ match , 2 ) as $ hex_index ) { if ( preg_match ( '/[a-f\d]{2,3...
Converts SQLHEX to plain text
53,366
public static function convertFromSQLKeywords ( $ value ) { $ pattern = array ( '/(?:is\s+null)|(like\s+null)|' . '(?:(?:^|\W)in[+\s]*\([\s\d"]+[^()]*\))/ims' ) ; $ value = preg_replace ( $ pattern , '"=0' , $ value ) ; $ value = preg_replace ( '/[^\w\)]+\s*like\s*[^\w\s]+/ims' , '1" OR "1"' , $ value ) ; $ value = pre...
Converts basic SQL keywords and obfuscations
53,367
public static function convertFromNestedBase64 ( $ value ) { $ matches = array ( ) ; preg_match_all ( '/(?:^|[,&?])\s*([a-z0-9]{50,}=*)(?:\W|$)/im' , $ value , $ matches ) ; foreach ( $ matches [ 1 ] as $ item ) { if ( isset ( $ item ) && ! preg_match ( '/[a-f0-9]{32}/i' , $ item ) ) { $ base64_item = base64_decode ( $...
This method matches and translates base64 strings and fragments used in data URIs
53,368
public static function convertFromXML ( $ value ) { $ converted = strip_tags ( $ value ) ; if ( ! $ converted || $ converted === $ value ) { return $ value ; } else { return $ value . "\n" . $ converted ; } }
Strip XML patterns
53,369
public static function convertFromConcatenated ( $ value ) { if ( $ value != preg_replace ( '/(\w)\\\/' , "$1" , $ value ) ) { $ value .= preg_replace ( '/(\w)\\\/' , "$1" , $ value ) ; } $ compare = stripslashes ( $ value ) ; $ pattern = array ( '/(?:<\/\w+>\+<\w+>)/s' , '/(?:":\d+[^"[]+")/s' , '/(?:"?"\+\w+\+")/s' , ...
Converts basic concatenations
53,370
public static function convertFromProprietaryEncodings ( $ value ) { $ value = preg_replace ( '/<!\[CDATA\[(\W+)\]\]>/im' , '$1' , $ value ) ; $ value = preg_replace ( '/(\w)\"(s)/m' , '$1$2' , $ value ) ; $ value = preg_replace ( '/^"([^"=\\!><~]+)"$/' , '$1' , $ value ) ; $ value = preg_replace ( '/{[\w-]{8,9}\}(?:\{...
This method collects and decodes proprietary encoding types
53,371
public static function runCentrifuge ( $ value , Monitor $ monitor = null ) { $ threshold = 3.49 ; if ( strlen ( $ value ) > 25 ) { $ tmp_value = preg_replace ( '/\s{4}|==$/m' , null , $ value ) ; $ tmp_value = preg_replace ( '/\s{4}|[\p{L}\d\+\-=,.%()]{8,}/m' , 'aaa' , $ tmp_value ) ; $ tmp_value = preg_replace ( '/([...
This method is the centrifuge prototype
53,372
public function getTags ( ) { if ( ! $ this -> tags ) { $ this -> tags = array ( ) ; foreach ( $ this -> events as $ event ) { $ this -> tags = array_merge ( $ this -> tags , $ event -> getTags ( ) ) ; } $ this -> tags = array_values ( array_unique ( $ this -> tags ) ) ; } return $ this -> tags ; }
Returns list of affected tags
53,373
public function getImpact ( ) { if ( ! $ this -> impact ) { $ this -> impact = 0 ; foreach ( $ this -> events as $ event ) { $ this -> impact += $ event -> getImpact ( ) ; } } return $ this -> impact ; }
Returns total impact
53,374
public function getUsersAction ( ParamFetcherInterface $ paramFetcher ) { $ supporedCriteria = [ 'enabled' => '' , ] ; $ page = $ paramFetcher -> get ( 'page' ) ; $ limit = $ paramFetcher -> get ( 'count' ) ; $ sort = $ paramFetcher -> get ( 'orderBy' ) ; $ criteria = array_intersect_key ( $ paramFetcher -> all ( ) , $...
Returns a paginated list of users .
53,375
public function postUserGroupAction ( $ userId , $ groupId ) { $ user = $ this -> getUser ( $ userId ) ; $ group = $ this -> getGroup ( $ groupId ) ; if ( $ user -> hasGroup ( $ group ) ) { return FOSRestView :: create ( [ 'error' => sprintf ( 'User "%s" already has group "%s"' , $ userId , $ groupId ) , ] , 400 ) ; } ...
Attach a group to a user .
53,376
public function deleteUserGroupAction ( $ userId , $ groupId ) { $ user = $ this -> getUser ( $ userId ) ; $ group = $ this -> getGroup ( $ groupId ) ; if ( ! $ user -> hasGroup ( $ group ) ) { return FOSRestView :: create ( [ 'error' => sprintf ( 'User "%s" has not group "%s"' , $ userId , $ groupId ) , ] , 400 ) ; } ...
Detach a group to a user .
53,377
protected function handleWriteUser ( $ request , $ id = null ) { $ user = $ id ? $ this -> getUser ( $ id ) : null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_user_api_form_user' , $ user , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $...
Write an User this method is used by both POST and PUT action methods .
53,378
public function getGroupsAction ( ParamFetcherInterface $ paramFetcher ) { $ supportedFilters = [ 'enabled' => '' , ] ; $ page = $ paramFetcher -> get ( 'page' ) ; $ limit = $ paramFetcher -> get ( 'count' ) ; $ sort = $ paramFetcher -> get ( 'orderBy' ) ; $ criteria = array_intersect_key ( $ paramFetcher -> all ( ) , ...
Returns a paginated list of groups .
53,379
protected function handleWriteGroup ( $ request , $ id = null ) { $ groupClassName = $ this -> groupManager -> getClass ( ) ; $ group = $ id ? $ this -> getGroup ( $ id ) : new $ groupClassName ( '' ) ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_user_api_form_group' , $ group , [ 'csrf_protection' =...
Write a Group this method is used by both POST and PUT action methods .
53,380
static function generate ( int $ workerID = 1 , int $ processID = 0 ) { if ( $ workerID > 31 || $ workerID < 0 ) { throw new \ InvalidArgumentException ( 'Worker ID is out of range' ) ; } if ( $ processID > 31 || $ processID < 0 ) { throw new \ InvalidArgumentException ( 'Process ID is out of range' ) ; } $ time = \ mi...
Generates a new snowflake .
53,381
function getShardID ( int $ shardCount ) { if ( \ PHP_INT_SIZE === 4 ) { $ time = \ base_convert ( \ substr ( $ this -> binary , 0 , 42 ) , 2 , 10 ) ; $ shard = ( int ) \ bcmod ( $ time , ( ( string ) $ shardCount ) ) ; return $ shard ; } else { $ time = $ this -> value >> 22 ; return ( $ time % $ shardCount ) ; } }
Compute the shard ID from the snowflake .
53,382
function getCurrentApplication ( ) { $ url = \ CharlotteDunois \ Yasmin \ HTTP \ APIEndpoints :: ENDPOINTS [ 'currentOAuthApplication' ] ; return $ this -> api -> makeRequest ( 'GET' , $ url , array ( ) ) ; }
Gets the current OAuth application .
53,383
function clear ( ) { $ this -> limited = true ; $ this -> resetTime = \ INF ; while ( $ item = \ array_shift ( $ this -> queue ) ) { unset ( $ item ) ; } while ( $ bucket = \ array_shift ( $ this -> ratelimits ) ) { unset ( $ bucket ) ; } $ this -> limited = false ; $ this -> resetTime = 0 ; }
Clears all buckets and the queue .
53,384
function makeRequest ( string $ method , string $ endpoint , array $ options ) { $ request = new \ CharlotteDunois \ Yasmin \ HTTP \ APIRequest ( $ this , $ method , $ endpoint , $ options ) ; return $ this -> add ( $ request ) ; }
Makes an API request .
53,385
function add ( \ CharlotteDunois \ Yasmin \ HTTP \ APIRequest $ apirequest ) { return ( new \ React \ Promise \ Promise ( function ( callable $ resolve , callable $ reject ) use ( $ apirequest ) { $ apirequest -> deferred = new \ React \ Promise \ Deferred ( ) ; $ apirequest -> deferred -> promise ( ) -> done ( $ resol...
Adds an APIRequest to the queue .
53,386
protected function processDelayed ( ) { $ offset = ( float ) $ this -> client -> getOption ( 'http.restTimeOffset' , 0.0 ) ; if ( $ offset > 0.0 ) { $ this -> client -> addTimer ( $ offset , function ( ) { $ this -> process ( ) ; } ) ; return ; } $ this -> process ( ) ; }
Processes the queue delayed depends on rest time offset .
53,387
protected function process ( ) { if ( $ this -> limited ) { if ( \ microtime ( true ) < $ this -> resetTime ) { $ this -> client -> addTimer ( ( $ this -> resetTime - \ microtime ( true ) ) , function ( ) { $ this -> process ( ) ; } ) ; return ; } $ this -> limited = false ; $ this -> remaining = ( $ this -> limit ? $ ...
Processes the queue .
53,388
protected function processItem ( $ item ) { if ( $ item instanceof \ CharlotteDunois \ Yasmin \ Interfaces \ RatelimitBucketInterface ) { if ( $ item -> isBusy ( ) ) { $ this -> queue [ ] = $ item ; foreach ( $ this -> queue as $ qitem ) { if ( ! ( $ qitem instanceof \ CharlotteDunois \ Yasmin \ Interfaces \ RatelimitB...
Processes a queue item .
53,389
protected function extractFromBucket ( \ CharlotteDunois \ Yasmin \ Interfaces \ RatelimitBucketInterface $ item ) { if ( $ item -> size ( ) > 0 ) { $ meta = $ item -> getMeta ( ) ; if ( $ meta instanceof \ React \ Promise \ ExtendedPromiseInterface ) { return $ meta -> then ( function ( $ data ) use ( & $ item ) { if ...
Extracts an item from a ratelimit bucket .
53,390
protected function execute ( \ CharlotteDunois \ Yasmin \ HTTP \ APIRequest $ item ) { $ endpoint = $ this -> getRatelimitEndpoint ( $ item ) ; $ ratelimit = null ; if ( ! empty ( $ endpoint ) ) { $ ratelimit = $ this -> getRatelimitBucket ( $ endpoint ) ; $ ratelimit -> setBusy ( true ) ; } $ this -> client -> emit ( ...
Executes an API Request .
53,391
function getRatelimitEndpoint ( \ CharlotteDunois \ Yasmin \ HTTP \ APIRequest $ request ) { $ endpoint = $ request -> getEndpoint ( ) ; if ( $ request -> isReactionEndpoint ( ) ) { \ preg_match ( '/channels\/(\d+)\/messages\/(\d+)\/reactions\/.*/' , $ endpoint , $ matches ) ; return 'channels/' . $ matches [ 1 ] . '/m...
Turns an endpoint path to the ratelimit path .
53,392
protected function getRatelimitBucket ( string $ endpoint ) { if ( empty ( $ this -> ratelimits [ $ endpoint ] ) ) { $ bucket = $ this -> bucketName ; $ this -> ratelimits [ $ endpoint ] = new $ bucket ( $ this , $ endpoint ) ; } return $ this -> ratelimits [ $ endpoint ] ; }
Gets the ratelimit bucket for the specific endpoint .
53,393
function extractRatelimit ( \ Psr \ Http \ Message \ ResponseInterface $ response ) { $ date = ( new \ DateTime ( $ response -> getHeader ( 'Date' ) [ 0 ] ) ) -> getTimestamp ( ) ; $ limit = ( $ response -> hasHeader ( 'X-RateLimit-Limit' ) ? ( ( int ) $ response -> getHeader ( 'X-RateLimit-Limit' ) [ 0 ] ) : null ) ; ...
Extracts ratelimits from a response .
53,394
function handleRatelimit ( \ Psr \ Http \ Message \ ResponseInterface $ response , ? \ CharlotteDunois \ Yasmin \ Interfaces \ RatelimitBucketInterface $ ratelimit = null , bool $ isReactionEndpoint = false ) { \ extract ( $ this -> extractRatelimit ( $ response ) ) ; if ( $ isReactionEndpoint && ! empty ( $ resetTime ...
Handles ratelimits .
53,395
function handleRatelimit ( ? int $ limit , ? int $ remaining , ? float $ resetTime ) { if ( $ limit === null && $ remaining === null && $ resetTime === null ) { $ this -> remaining ++ ; return ; } $ this -> limit = $ limit ?? $ this -> limit ; $ this -> remaining = $ remaining ?? $ this -> remaining ; $ this -> resetTi...
Sets the ratelimits from the response .
53,396
function push ( \ CharlotteDunois \ Yasmin \ HTTP \ APIRequest $ request ) { $ this -> queue [ ] = $ request ; return $ this ; }
Pushes a new request into the queue .
53,397
function getEvent ( string $ name ) { if ( isset ( $ this -> wsevents [ $ name ] ) ) { return $ this -> wsevents [ $ name ] ; } throw new \ Exception ( 'Unable to find WS event' ) ; }
Returns a WS event .
53,398
function register ( string $ name , string $ class ) { if ( ! \ in_array ( 'CharlotteDunois\Yasmin\Interfaces\WSEventInterface' , \ class_implements ( $ class ) ) ) { throw new \ RuntimeException ( 'Specified event class does not implement interface' ) ; } $ this -> wsevents [ $ name ] = new $ class ( $ this -> wshandl...
Registers an event .
53,399
function createInvite ( array $ options = array ( ) ) { $ data = array ( 'max_uses' => ( $ options [ 'maxUses' ] ?? 0 ) , 'temporary' => ( $ options [ 'temporary' ] ?? false ) , 'unique' => ( $ options [ 'unique' ] ?? false ) ) ; if ( isset ( $ options [ 'maxAge' ] ) ) { $ data [ 'max_age' ] = $ options [ 'maxAge' ] ; ...
Creates an invite . Resolves with an instance of Invite .