idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
25,100
public static function prettyFormatLocation ( $ locationInfo , $ newline = "\n" , $ includeExtra = false ) { if ( $ locationInfo === false ) { return Piwik :: translate ( 'General_Unknown' ) ; } $ lines = array ( ) ; if ( ! empty ( $ locationInfo [ self :: LATITUDE_KEY ] ) && ! empty ( $ locationInfo [ self :: LONGITUD...
Returns a prettified location result .
25,101
private static function getTrackingCookie ( ) { $ cookie_name = @ Config :: getInstance ( ) -> Tracker [ 'cookie_name' ] ; $ cookie_path = @ Config :: getInstance ( ) -> Tracker [ 'cookie_path' ] ; return new Cookie ( $ cookie_name , null , $ cookie_path ) ; }
Get tracking cookie
25,102
public function _prepare ( $ sql ) { $ connection = $ this -> _adapter -> getConnection ( ) ; $ this -> _stmt = @ db2_prepare ( $ connection , $ sql ) ; if ( ! $ this -> _stmt ) { throw new Zend_Db_Statement_Db2_Exception ( db2_stmt_errormsg ( ) , db2_stmt_error ( ) ) ; } }
Prepare a statement handle .
25,103
public function filter ( $ table ) { foreach ( $ table -> getRows ( ) as $ key => $ row ) { $ params = array ( ) ; foreach ( $ this -> columnsToFilter as $ column ) { $ params [ ] = $ row -> getColumn ( $ column ) ; } $ params = array_merge ( $ params , $ this -> functionParams ) ; if ( call_user_func_array ( $ this ->...
Filters the given data table
25,104
public function shouldExecuteTask ( $ taskName ) { $ forceTaskExecution = ( defined ( 'DEBUG_FORCE_SCHEDULED_TASKS' ) && DEBUG_FORCE_SCHEDULED_TASKS ) ; if ( $ forceTaskExecution ) { return true ; } return $ this -> taskHasBeenScheduledOnce ( $ taskName ) && time ( ) >= $ this -> timetable [ $ taskName ] ; }
Checks if the task should be executed
25,105
public static function check ( $ name , $ value , $ validators ) { foreach ( $ validators as $ validator ) { try { $ validator -> validate ( $ value ) ; } catch ( \ Exception $ e ) { throw new Exception ( strip_tags ( $ name ) . ': ' . $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } } }
Lets you easily check a value against multiple validators .
25,106
public function render ( ) { @ Common :: stripHeader ( 'Pragma' ) ; @ Common :: stripHeader ( 'Expires' ) ; @ Common :: sendHeader ( 'Content-Type: text/html; charset=UTF-8' ) ; @ Common :: sendHeader ( 'Cache-Control: must-revalidate' ) ; @ Common :: sendHeader ( 'X-Frame-Options: deny' ) ; $ error = htmlspecialchars ...
Outputs the data .
25,107
public static function factory ( $ classId ) { $ className = static :: getClassNameFromClassId ( $ classId ) ; if ( ! class_exists ( $ className ) ) { self :: sendPlainHeader ( ) ; throw new Exception ( static :: getInvalidClassIdExceptionMessage ( $ classId ) ) ; } return new $ className ; }
Creates a new instance of a class using a string ID .
25,108
public function saveLanguage ( ) { $ language = Common :: getRequestVar ( 'language' ) ; if ( DbHelper :: isInstalled ( ) ) { $ this -> checkTokenInUrl ( ) ; } LanguagesManager :: setLanguageForSession ( $ language ) ; Url :: redirectToReferrer ( ) ; }
anonymous = in the session authenticated user = in the session
25,109
public static function getIpFromHeader ( ) { $ general = Config :: getInstance ( ) -> General ; $ clientHeaders = @ $ general [ 'proxy_client_headers' ] ; if ( ! is_array ( $ clientHeaders ) ) { $ clientHeaders = array ( ) ; } $ default = '0.0.0.0' ; if ( isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) ) { $ default = $ _SERVER ...
Returns the most accurate IP address available for the current user in IPv4 format . This could be the proxy client s IP address .
25,110
public static function getNonProxyIpFromHeader ( $ default , $ proxyHeaders ) { $ proxyIps = array ( ) ; $ config = Config :: getInstance ( ) -> General ; if ( isset ( $ config [ 'proxy_ips' ] ) ) { $ proxyIps = $ config [ 'proxy_ips' ] ; } if ( ! is_array ( $ proxyIps ) ) { $ proxyIps = array ( ) ; } $ proxyIps [ ] = ...
Returns a non - proxy IP address from header .
25,111
public static function getFirstIpFromList ( $ csv , $ excludedIps = null ) { $ p = strrpos ( $ csv , ',' ) ; if ( $ p !== false ) { $ elements = explode ( ',' , $ csv ) ; foreach ( $ elements as $ ipString ) { $ element = trim ( Common :: sanitizeInputValue ( $ ipString ) ) ; if ( empty ( $ element ) ) { continue ; } $...
Returns the last IP address in a comma separated list subject to an optional exclusion list .
25,112
public function removeMessage ( $ id ) { if ( ! $ this -> _protocol -> store ( array ( Zend_Mail_Storage :: FLAG_DELETED ) , $ id , null , '+' ) ) { throw new Zend_Mail_Storage_Exception ( 'cannot set deleted flag' ) ; } if ( ! $ this -> _protocol -> expunge ( ) ) { throw new Zend_Mail_Storage_Exception ( 'message mark...
Remove a message from server . If you re doing that from a web enviroment you should be careful and use a uniqueid as parameter if possible to identify the message .
25,113
protected function checkIfNoDataForGeoIpReport ( ViewDataTable $ view ) { $ view -> config -> filters [ ] = function ( $ dataTable ) use ( $ view ) { if ( $ dataTable -> getRowsCount ( ) == 1 && $ dataTable -> getFirstRow ( ) -> getColumn ( 'label' ) == Piwik :: translate ( 'General_Unknown' ) ) { $ footerMessage = Piw...
Checks if a datatable for a view is empty and if so displays a message in the footer telling users to configure GeoIP .
25,114
private function getArchiveTablesToPurge ( ) { $ toRemoveDate = Date :: factory ( 'today' ) -> subMonth ( 1 + $ this -> deleteReportsOlderThan ) ; $ oldNumericTables = array ( ) ; $ oldBlobTables = array ( ) ; foreach ( DbHelper :: getTablesInstalled ( ) as $ table ) { $ type = ArchiveTableCreator :: getTypeFromTableNa...
Utility function that finds every archive table whose reports are considered old .
25,115
private function getBlobTableWhereExpr ( $ oldNumericTables , $ table ) { $ where = "" ; if ( ! empty ( $ this -> reportPeriodsToKeep ) ) { $ where = "period NOT IN (" . implode ( ',' , $ this -> reportPeriodsToKeep ) . ")" ; if ( ! $ this -> keepSegmentReports ) { $ this -> findSegmentArchives ( $ oldNumericTables ) ;...
Returns SQL WHERE expression used to find reports that should be purged .
25,116
private function findSegmentArchives ( $ numericTables ) { if ( ! is_null ( $ this -> segmentArchiveIds ) || empty ( $ numericTables ) ) { return ; } foreach ( $ numericTables as $ table ) { $ tableDate = ArchiveTableCreator :: getDateFromTableName ( $ table ) ; $ maxIdArchive = Db :: fetchOne ( "SELECT MAX(idarchive) ...
If we re going to keep segmented reports we need to know which archives are for segments . This info is only in the numeric tables so we must query them .
25,117
public static function make ( $ settings , $ metricsToKeep ) { return new ReportsPurger ( $ settings [ 'delete_reports_older_than' ] , $ settings [ 'delete_reports_keep_basic_metrics' ] == 1 , self :: getReportPeriodsToKeep ( $ settings ) , $ settings [ 'delete_reports_keep_segment_reports' ] == 1 , $ metricsToKeep , $...
Utility function . Creates a new instance of ReportsPurger with the supplied array of settings .
25,118
public function isVisitNew ( VisitProperties $ visitProperties , Request $ request ) { $ isKnown = $ request -> getMetadata ( 'CoreHome' , 'isVisitorKnown' ) ; if ( ! $ isKnown ) { return true ; } $ isLastActionInTheSameVisit = $ this -> isLastActionInTheSameVisit ( $ visitProperties , $ request ) ; if ( ! $ isLastActi...
Determines if the tracker if the current action should be treated as the start of a new visit or an action in an existing visit .
25,119
protected function isLastActionInTheSameVisit ( VisitProperties $ visitProperties , Request $ request ) { $ lastActionTime = $ visitProperties -> getProperty ( 'visit_last_action_time' ) ; return isset ( $ lastActionTime ) && false !== $ lastActionTime && ( $ lastActionTime > ( $ request -> getCurrentTimestamp ( ) - $ ...
Returns true if the last action was done during the last 30 minutes
25,120
private function wasLastActionNotToday ( VisitProperties $ visitProperties , Request $ request ) { $ lastActionTime = $ visitProperties -> getProperty ( 'visit_last_action_time' ) ; if ( empty ( $ lastActionTime ) ) { return false ; } $ idSite = $ request -> getIdSite ( ) ; $ timezone = $ this -> getTimezoneForSite ( $...
Returns true if the last action was not today .
25,121
public function getLastQueryProfile ( ) { if ( empty ( $ this -> _queryProfiles ) ) { return false ; } end ( $ this -> _queryProfiles ) ; return current ( $ this -> _queryProfiles ) ; }
Get the Zend_Db_Profiler_Query object for the last query that was run regardless if it has ended or not . If the query has not ended its end time will be null . If no queries have been profiled false is returned .
25,122
public function setMagicFile ( $ file ) { if ( empty ( $ file ) ) { $ this -> _magicfile = null ; } else if ( ! ( class_exists ( 'finfo' , false ) ) ) { $ this -> _magicfile = null ; throw new Zend_Validate_Exception ( 'Magicfile can not be set. There is no finfo extension installed' ) ; } else if ( ! is_file ( $ file ...
Sets the magicfile to use if null the MAGIC constant from php is used if the MAGIC file is errorous no file will be set
25,123
public function getMimeType ( $ asArray = false ) { $ asArray = ( bool ) $ asArray ; $ mimetype = ( string ) $ this -> _mimetype ; if ( $ asArray ) { $ mimetype = explode ( ',' , $ mimetype ) ; } return $ mimetype ; }
Returns the set mimetypes
25,124
protected function getCustomThemeLoader ( Plugin $ theme ) { $ pluginsDir = Manager :: getPluginDirectory ( $ theme -> getPluginName ( ) ) ; $ themeDir = $ pluginsDir . '/templates/' ; if ( ! file_exists ( $ themeDir ) ) { return false ; } $ themeLoader = new Twig_Loader_Filesystem ( array ( $ themeDir ) , PIWIK_DOCUME...
create template loader for a custom theme
25,125
protected static function toCanonicalForm ( $ config , $ key = 'operand' ) { if ( ! is_array ( $ config ) ) { return array ( $ key => $ config ) ; } elseif ( array_key_exists ( 'operator' , $ config ) || array_key_exists ( 'operand' , $ config ) ) { return $ config ; } elseif ( 1 == count ( $ config ) ) { return array ...
Converts configuration data to a canonical associative array form
25,126
public function setConfig ( $ config ) { if ( 0 == count ( $ config ) ) { throw new HTML_QuickForm2_InvalidArgumentException ( 'Compare Rule requires an argument to compare with' ) ; } $ config = self :: toCanonicalForm ( $ config ) ; $ config += array ( 'operator' => '===' ) ; if ( ! in_array ( $ config [ 'operator' ]...
Sets the comparison operator and operand to compare to
25,127
private function getAgeArchiveOrg ( $ domain ) { $ response = $ this -> getUrl ( 'https://archive.org/wayback/available?timestamp=19900101&url=' . urlencode ( $ domain ) ) ; $ data = json_decode ( $ response , true ) ; if ( empty ( $ data [ "archived_snapshots" ] [ "closest" ] [ "timestamp" ] ) ) { return 0 ; } return ...
Returns the domain age archive . org lists for the current url
25,128
private function getAgeWhoIs ( $ domain ) { $ data = $ this -> getUrl ( 'https://www.who.is/whois/' . urlencode ( $ domain ) ) ; preg_match ( '#(?:Creation Date|Created On|created|Registered on)\.*:\s*([ \ta-z0-9\/\-:\.]+)#si' , $ data , $ p ) ; if ( ! empty ( $ p [ 1 ] ) ) { $ value = strtotime ( trim ( $ p [ 1 ] ) ) ...
Returns the domain age who . is lists for the current url
25,129
public function createResponse ( ) { if ( empty ( $ this -> headers ) ) { throw new \ RuntimeException ( 'No headers have been received' ) ; } $ startLine = explode ( ' ' , array_shift ( $ this -> headers ) , 3 ) ; $ headers = \ GuzzleHttp \ headers_from_lines ( $ this -> headers ) ; $ normalizedKeys = \ GuzzleHttp \ n...
Attach a response to the easy handle based on the received headers .
25,130
private function transfer ( RequestInterface $ request , array $ options ) { if ( isset ( $ options [ 'save_to' ] ) ) { $ options [ 'sink' ] = $ options [ 'save_to' ] ; unset ( $ options [ 'save_to' ] ) ; } if ( isset ( $ options [ 'exceptions' ] ) ) { $ options [ 'http_errors' ] = $ options [ 'exceptions' ] ; unset ( ...
Transfers the given request and applies request options .
25,131
public static function cookies ( ) { return function ( callable $ handler ) { return function ( $ request , array $ options ) use ( $ handler ) { if ( empty ( $ options [ 'cookies' ] ) ) { return $ handler ( $ request , $ options ) ; } elseif ( ! ( $ options [ 'cookies' ] instanceof CookieJarInterface ) ) { throw new \...
Middleware that adds cookies to requests .
25,132
public static function history ( & $ container ) { if ( ! is_array ( $ container ) && ! $ container instanceof \ ArrayAccess ) { throw new \ InvalidArgumentException ( 'history container must be an array or object implementing ArrayAccess' ) ; } return function ( callable $ handler ) use ( & $ container ) { return func...
Middleware that pushes history data to an ArrayAccess container .
25,133
public static function tap ( callable $ before = null , callable $ after = null ) { return function ( callable $ handler ) use ( $ before , $ after ) { return function ( $ request , array $ options ) use ( $ handler , $ before , $ after ) { if ( $ before ) { $ before ( $ request , $ options ) ; } $ response = $ handler...
Middleware that invokes a callback before and after sending a request .
25,134
public static function retry ( callable $ decider , callable $ delay = null ) { return function ( callable $ handler ) use ( $ decider , $ delay ) { return new RetryMiddleware ( $ decider , $ handler , $ delay ) ; } ; }
Middleware that retries requests based on the boolean result of invoking the provided decider function .
25,135
public function getHandlerStat ( $ stat ) { return isset ( $ this -> handlerStats [ $ stat ] ) ? $ this -> handlerStats [ $ stat ] : null ; }
Get a specific handler statistic from the handler by name .
25,136
public static function create ( callable $ handler = null ) { $ stack = new self ( $ handler ? : choose_handler ( ) ) ; $ stack -> push ( Middleware :: httpErrors ( ) , 'http_errors' ) ; $ stack -> push ( Middleware :: redirect ( ) , 'allow_redirects' ) ; $ stack -> push ( Middleware :: cookies ( ) , 'cookies' ) ; $ st...
Creates a default handler stack that can be used by clients .
25,137
public function unshift ( callable $ middleware , $ name = null ) { array_unshift ( $ this -> stack , [ $ middleware , $ name ] ) ; $ this -> cached = null ; }
Unshift a middleware to the bottom of the stack .
25,138
public function push ( callable $ middleware , $ name = '' ) { $ this -> stack [ ] = [ $ middleware , $ name ] ; $ this -> cached = null ; }
Push a middleware to the top of the stack .
25,139
public function after ( $ findName , callable $ middleware , $ withName = '' ) { $ this -> splice ( $ findName , $ withName , $ middleware , false ) ; }
Add a middleware after another middleware by name .
25,140
public function remove ( $ remove ) { $ this -> cached = null ; $ idx = is_callable ( $ remove ) ? 0 : 1 ; $ this -> stack = array_values ( array_filter ( $ this -> stack , function ( $ tuple ) use ( $ idx , $ remove ) { return $ tuple [ $ idx ] !== $ remove ; } ) ) ; }
Remove a middleware by instance or name from the stack .
25,141
private function debugCallable ( $ fn ) { if ( is_string ( $ fn ) ) { return "callable({$fn})" ; } if ( is_array ( $ fn ) ) { return is_string ( $ fn [ 0 ] ) ? "callable({$fn[0]}::{$fn[1]})" : "callable(['" . get_class ( $ fn [ 0 ] ) . "', '{$fn[1]}'])" ; } return 'callable(' . spl_object_hash ( $ fn ) . ')' ; }
Provides a debug string for a given callable .
25,142
private function drain ( StreamInterface $ source , StreamInterface $ sink , $ contentLength ) { Psr7 \ copy_to_stream ( $ source , $ sink , ( strlen ( $ contentLength ) > 0 && ( int ) $ contentLength > 0 ) ? ( int ) $ contentLength : - 1 ) ; $ sink -> seek ( 0 ) ; $ source -> close ( ) ; return $ sink ; }
Drains the source stream into the sink client option .
25,143
public static function batch ( ClientInterface $ client , $ requests , array $ options = [ ] ) { $ res = [ ] ; self :: cmpCallback ( $ options , 'fulfilled' , $ res ) ; self :: cmpCallback ( $ options , 'rejected' , $ res ) ; $ pool = new static ( $ client , $ requests , $ options ) ; $ pool -> promise ( ) -> wait ( ) ...
Sends multiple requests concurrently and returns an array of responses and exceptions that uses the same ordering as the provided requests .
25,144
public function matchesPath ( $ requestPath ) { $ cookiePath = $ this -> getPath ( ) ; if ( $ cookiePath === '/' || $ cookiePath == $ requestPath ) { return true ; } if ( 0 !== strpos ( $ requestPath , $ cookiePath ) ) { return false ; } if ( substr ( $ cookiePath , - 1 , 1 ) === '/' ) { return true ; } return substr (...
Check if the cookie matches a path value .
25,145
public static function createWithMiddleware ( array $ queue = null , callable $ onFulfilled = null , callable $ onRejected = null ) { return HandlerStack :: create ( new self ( $ queue , $ onFulfilled , $ onRejected ) ) ; }
Creates a new MockHandler that uses the default handler stack list of middlewares .
25,146
public function append ( ) { foreach ( func_get_args ( ) as $ value ) { if ( $ value instanceof ResponseInterface || $ value instanceof \ Exception || $ value instanceof PromiseInterface || is_callable ( $ value ) ) { $ this -> queue [ ] = $ value ; } else { throw new \ InvalidArgumentException ( 'Expected a response o...
Adds one or more variadic requests exceptions callables or promises to the queue .
25,147
public static function wrapSync ( callable $ default , callable $ sync ) { return function ( RequestInterface $ request , array $ options ) use ( $ default , $ sync ) { return empty ( $ options [ RequestOptions :: SYNCHRONOUS ] ) ? $ default ( $ request , $ options ) : $ sync ( $ request , $ options ) ; } ; }
Sends synchronous requests to a specific handler while sending all other requests to another handler .
25,148
public static function wrapStreaming ( callable $ default , callable $ streaming ) { return function ( RequestInterface $ request , array $ options ) use ( $ default , $ streaming ) { return empty ( $ options [ 'stream' ] ) ? $ default ( $ request , $ options ) : $ streaming ( $ request , $ options ) ; } ; }
Sends streaming requests to a streaming compatible handler while sending all other requests to a default handler .
25,149
public function debug ( $ message ) { $ prefix = date ( 'c' ) . ': ' ; if ( $ this -> sections ) { $ prefix .= '[' . end ( $ this -> sections ) . '] ' ; } fwrite ( STDERR , $ prefix . $ message . "\n" ) ; }
Prints a debug message to STDERR bound to the current section .
25,150
public function deepCopy ( $ from , $ to ) { if ( ! is_file ( $ from ) ) { throw new \ InvalidArgumentException ( "File not found: {$from}" ) ; } $ to = str_replace ( '//' , '/' , $ this -> stageDir . '/' . $ to ) ; $ dir = dirname ( $ to ) ; if ( ! is_dir ( $ dir ) ) { if ( ! mkdir ( $ dir , 0777 , true ) ) { throw ne...
Copies a file and creates the destination directory if needed .
25,151
public function recursiveCopy ( $ sourceDir , $ destDir , $ extensions = array ( 'php' ) ) { if ( ! realpath ( $ sourceDir ) ) { throw new \ InvalidArgumentException ( "$sourceDir not found" ) ; } if ( ! $ extensions ) { throw new \ InvalidArgumentException ( '$extensions is empty!' ) ; } $ sourceDir = realpath ( $ sou...
Recursively copy one folder to another .
25,152
public function exec ( $ command ) { $ this -> debug ( "Executing: $command" ) ; $ output = $ returnValue = null ; exec ( $ command , $ output , $ returnValue ) ; if ( $ returnValue != 0 ) { throw new \ RuntimeException ( 'Error executing command: ' . $ command . ' : ' . implode ( "\n" , $ output ) ) ; } return implode...
Execute a command and throw an exception if the return code is not 0 .
25,153
public function createAutoloader ( $ files = array ( ) , $ filename = 'autoloader.php' ) { $ sourceDir = realpath ( $ this -> stageDir ) ; $ iter = new \ RecursiveDirectoryIterator ( $ sourceDir ) ; $ iter = new \ RecursiveIteratorIterator ( $ iter ) ; $ this -> startSection ( 'autoloader' ) ; $ this -> debug ( 'Creati...
Creates a class - map autoloader to the staging directory in a file named autoloader . php
25,154
private function createStub ( $ dest , $ autoloaderFilename = 'autoloader.php' ) { $ this -> startSection ( 'stub' ) ; $ this -> debug ( "Creating phar stub at $dest" ) ; $ alias = basename ( $ dest ) ; $ constName = str_replace ( '.phar' , '' , strtoupper ( $ alias ) ) . '_PHAR' ; $ stub = "<?php\n" ; $ stub .= "defin...
Creates a default stub for the phar that includeds the generated autoloader .
25,155
public function createPhar ( $ dest , $ stub = null , $ autoloaderFilename = 'autoloader.php' ) { $ this -> startSection ( 'phar' ) ; $ this -> debug ( "Creating phar file at $dest" ) ; $ this -> createDirIfNeeded ( dirname ( $ dest ) ) ; $ phar = new \ Phar ( $ dest , 0 , basename ( $ dest ) ) ; $ phar -> buildFromDir...
Creates a phar that automatically registers an autoloader .
25,156
public function createZip ( $ dest ) { $ this -> startSection ( 'zip' ) ; $ this -> debug ( "Creating a zip file at $dest" ) ; $ this -> createDirIfNeeded ( dirname ( $ dest ) ) ; chdir ( $ this -> stageDir ) ; $ this -> exec ( "zip -r $dest ./" ) ; $ this -> debug ( " > Created at $dest" ) ; chdir ( __DIR__ ) ; $ thi...
Creates a zip file containing the staged files of your project .
25,157
public static function finish ( callable $ handler , EasyHandle $ easy , CurlFactoryInterface $ factory ) { if ( isset ( $ easy -> options [ 'on_stats' ] ) ) { self :: invokeStats ( $ easy ) ; } if ( ! $ easy -> response || $ easy -> errno ) { return self :: finishError ( $ handler , $ easy , $ factory ) ; } $ factory ...
Completes a cURL transaction either returning a response promise or a rejected promise .
25,158
private function removeHeader ( $ name , array & $ options ) { foreach ( array_keys ( $ options [ '_headers' ] ) as $ key ) { if ( ! strcasecmp ( $ key , $ name ) ) { unset ( $ options [ '_headers' ] [ $ key ] ) ; return ; } } }
Remove a header from the options array .
25,159
public function tick ( ) { if ( $ this -> delays ) { $ currentTime = \ GuzzleHttp \ _current_time ( ) ; foreach ( $ this -> delays as $ id => $ delay ) { if ( $ currentTime >= $ delay ) { unset ( $ this -> delays [ $ id ] ) ; curl_multi_add_handle ( $ this -> _mh , $ this -> handles [ $ id ] [ 'easy' ] -> handle ) ; } ...
Ticks the curl event loop .
25,160
private function cancel ( $ id ) { if ( ! isset ( $ this -> handles [ $ id ] ) ) { return false ; } $ handle = $ this -> handles [ $ id ] [ 'easy' ] -> handle ; unset ( $ this -> delays [ $ id ] , $ this -> handles [ $ id ] ) ; curl_multi_remove_handle ( $ this -> _mh , $ handle ) ; curl_close ( $ handle ) ; return tru...
Cancels a handle from sending and removes references to it .
25,161
public static function fromArray ( array $ cookies , $ domain ) { $ cookieJar = new self ( ) ; foreach ( $ cookies as $ name => $ value ) { $ cookieJar -> setCookie ( new SetCookie ( [ 'Domain' => $ domain , 'Name' => $ name , 'Value' => $ value , 'Discard' => true ] ) ) ; } return $ cookieJar ; }
Create a new Cookie jar from an associative array and domain .
25,162
public function getCookieByName ( $ name ) { if ( $ name === null ) { return null ; } foreach ( $ this -> cookies as $ cookie ) { if ( $ cookie -> getName ( ) !== null && strcasecmp ( $ cookie -> getName ( ) , $ name ) === 0 ) { return $ cookie ; } } }
Finds and returns the cookie based on the name
25,163
private static function obfuscateUri ( $ uri ) { $ userInfo = $ uri -> getUserInfo ( ) ; if ( false !== ( $ pos = strpos ( $ userInfo , ':' ) ) ) { return $ uri -> withUserInfo ( substr ( $ userInfo , 0 , $ pos ) , '***' ) ; } return $ uri ; }
Obfuscates URI if there is an username and a password present
25,164
protected function load ( ) { if ( ! isset ( $ _SESSION [ $ this -> sessionKey ] ) ) { return ; } $ data = json_decode ( $ _SESSION [ $ this -> sessionKey ] , true ) ; if ( is_array ( $ data ) ) { foreach ( $ data as $ cookie ) { $ this -> setCookie ( new SetCookie ( $ cookie ) ) ; } } elseif ( strlen ( $ data ) ) { th...
Load the contents of the client session into the data array
25,165
public function clockwork ( $ id ) { $ request = [ 'op' => 'get' , 'id' => $ id , ] ; $ openHandler = new OpenHandler ( $ this -> debugbar ) ; $ data = $ openHandler -> handle ( $ request , false , false ) ; $ converter = new Converter ( ) ; $ output = $ converter -> convert ( json_decode ( $ data , true ) ) ; return r...
Return Clockwork output
25,166
public function delete ( $ key , $ tags = '' ) { $ cache = app ( 'cache' ) ; if ( ! empty ( $ tags ) ) { $ tags = json_decode ( $ tags , true ) ; $ cache = $ cache -> tags ( $ tags ) ; } else { unset ( $ tags ) ; } $ success = $ cache -> forget ( $ key ) ; return response ( ) -> json ( compact ( 'success' ) ) ; }
Forget a cache key
25,167
protected function fileIsInExcludedPath ( $ file ) { $ excludedPaths = [ '/vendor/laravel/framework/src/Illuminate/Database' , '/vendor/laravel/framework/src/Illuminate/Events' , '/vendor/barryvdh/laravel-debugbar' , ] ; $ normalizedPath = str_replace ( '\\' , '/' , $ file ) ; foreach ( $ excludedPaths as $ excludedPat...
Check if the given file is to be excluded from analysis
25,168
protected function findMiddlewareFromFile ( $ file ) { $ filename = pathinfo ( $ file , PATHINFO_FILENAME ) ; foreach ( $ this -> middleware as $ alias => $ class ) { if ( strpos ( $ class , $ filename ) !== false ) { return $ alias ; } } }
Find the middleware alias from the file .
25,169
protected function findViewFromHash ( $ hash ) { $ finder = app ( 'view' ) -> getFinder ( ) ; if ( isset ( $ this -> reflection [ 'viewfinderViews' ] ) ) { $ property = $ this -> reflection [ 'viewfinderViews' ] ; } else { $ reflection = new \ ReflectionClass ( $ finder ) ; $ property = $ reflection -> getProperty ( 'v...
Find the template name from the hash .
25,170
public function collectTransactionEvent ( $ event , $ connection ) { $ source = [ ] ; if ( $ this -> findSource ) { try { $ source = $ this -> findSource ( ) ; } catch ( \ Exception $ e ) { } } $ this -> queries [ ] = [ 'query' => $ event , 'type' => 'transaction' , 'bindings' => [ ] , 'time' => 0 , 'source' => $ sourc...
Collect a database transaction event .
25,171
protected function filter ( $ meta , $ filters ) { foreach ( $ filters as $ key => $ value ) { if ( ! isset ( $ meta [ $ key ] ) || fnmatch ( $ value , $ meta [ $ key ] ) === false ) { return false ; } } return true ; }
Filter the metadata for matches .
25,172
protected function getCompiledFiles ( ) { if ( $ this -> app && class_exists ( 'Illuminate\Foundation\Console\OptimizeCommand' ) ) { $ reflector = new \ ReflectionClass ( 'Illuminate\Foundation\Console\OptimizeCommand' ) ; $ path = dirname ( $ reflector -> getFileName ( ) ) . '/Optimize/config.php' ; if ( file_exists (...
Get the files that are going to be compiled so they aren t as important .
25,173
public function js ( ) { $ renderer = $ this -> debugbar -> getJavascriptRenderer ( ) ; $ content = $ renderer -> dumpAssetsToString ( 'js' ) ; $ response = new Response ( $ content , 200 , [ 'Content-Type' => 'text/javascript' , ] ) ; return $ this -> cacheResponse ( $ response ) ; }
Return the javascript for the Debugbar
25,174
private function exportValue ( $ value , $ depth = 1 , $ deep = false ) { if ( $ value instanceof \ __PHP_Incomplete_Class ) { return sprintf ( '__PHP_Incomplete_Class(%s)' , $ this -> getClassNameFromIncomplete ( $ value ) ) ; } if ( is_object ( $ value ) ) { if ( $ value instanceof \ DateTimeInterface ) { return spri...
Converts a PHP value to a string .
25,175
public function isEnabled ( ) { if ( $ this -> enabled === null ) { $ config = $ this -> app [ 'config' ] ; $ configEnabled = value ( $ config -> get ( 'debugbar.enabled' ) ) ; if ( $ configEnabled === null ) { $ configEnabled = $ config -> get ( 'app.debug' ) ; } $ this -> enabled = $ configEnabled && ! $ this -> app ...
Check if the Debugbar is enabled
25,176
public function addMessage ( $ message , $ label = 'info' ) { if ( $ this -> hasCollector ( 'messages' ) ) { $ collector = $ this -> getCollector ( 'messages' ) ; $ collector -> addMessage ( $ message , $ label ) ; } }
Adds a message to the MessagesCollector
25,177
protected function addServerTimingHeaders ( Response $ response ) { if ( $ this -> hasCollector ( 'time' ) ) { $ collector = $ this -> getCollector ( 'time' ) ; $ headers = [ ] ; foreach ( $ collector -> collect ( ) [ 'measures' ] as $ k => $ m ) { $ headers [ ] = sprintf ( '%d=%F; "%s"' , $ k , $ m [ 'duration' ] * 10...
Add Server - Timing headers for the TimeData collector
25,178
public function escapeBindings ( $ bindings ) { foreach ( $ bindings as & $ binding ) { $ binding = htmlentities ( $ binding , ENT_QUOTES , 'UTF-8' , false ) ; } return $ bindings ; }
Make the bindings safe for outputting .
25,179
public function formatSource ( $ source ) { if ( ! is_object ( $ source ) ) { return '' ; } $ parts = [ ] ; if ( $ source -> namespace ) { $ parts [ 'namespace' ] = $ source -> namespace . '::' ; } $ parts [ 'name' ] = $ source -> name ; $ parts [ 'line' ] = ':' . $ source -> line ; return implode ( $ parts ) ; }
Format a source object .
25,180
protected function displayRoutes ( array $ routes ) { $ this -> table -> setHeaders ( $ this -> headers ) -> setRows ( $ routes ) ; $ this -> table -> render ( $ this -> getOutput ( ) ) ; }
Display the route information on the console .
25,181
protected function makeUriRelativeTo ( $ uri , $ root ) { if ( ! $ root ) { return $ uri ; } if ( is_array ( $ uri ) ) { $ uris = [ ] ; foreach ( $ uri as $ u ) { $ uris [ ] = $ this -> makeUriRelativeTo ( $ u , $ root ) ; } return $ uris ; } if ( substr ( $ uri , 0 , 1 ) === '/' || preg_match ( '/^([a-zA-Z]+:\/\/|[a-z...
Makes a URI relative to another
25,182
function get_margin_height ( ) { $ style = $ this -> get_parent ( ) -> get_style ( ) ; $ font = $ style -> font_family ; $ size = $ style -> font_size ; return ( $ style -> line_height / ( $ size > 0 ? $ size : 1 ) ) * $ this -> _dompdf -> getFontMetrics ( ) -> getFontHeight ( $ font , $ size ) ; }
Vertical margins & padding do not apply to text frames
25,183
function recalculate_width ( ) { $ style = $ this -> get_style ( ) ; $ text = $ this -> get_text ( ) ; $ size = $ style -> font_size ; $ font = $ style -> font_family ; $ word_spacing = ( float ) $ style -> length_in_pt ( $ style -> word_spacing ) ; $ char_spacing = ( float ) $ style -> length_in_pt ( $ style -> letter...
Recalculate the text width
25,184
function split_text ( $ offset ) { if ( $ offset == 0 ) { return null ; } $ split = $ this -> _frame -> get_node ( ) -> splitText ( $ offset ) ; $ deco = $ this -> copy ( $ split ) ; $ p = $ this -> get_parent ( ) ; $ p -> insert_child_after ( $ deco , $ this , false ) ; if ( $ p instanceof Inline ) { $ p -> split ( $ ...
split the text in this frame at the offset specified . The remaining text is added a sibling frame following this one and is returned .
25,185
public function loadHtmlFile ( $ file ) { $ this -> saveLocale ( ) ; if ( ! $ this -> protocol && ! $ this -> baseHost && ! $ this -> basePath ) { list ( $ this -> protocol , $ this -> baseHost , $ this -> basePath ) = Helpers :: explode_url ( $ file ) ; } $ protocol = strtolower ( $ this -> protocol ) ; if ( ! in_arra...
Loads an HTML file Parse errors are stored in the global array _dompdf_warnings .
25,186
public function add_info ( $ label , $ value ) { $ canvas = $ this -> getCanvas ( ) ; if ( ! is_null ( $ canvas ) ) { $ canvas -> add_info ( $ label , $ value ) ; } }
Add meta information to the PDF after rendering
25,187
private function write_log ( ) { $ log_output_file = $ this -> getOptions ( ) -> getLogOutputFile ( ) ; if ( ! $ log_output_file || ! is_writable ( $ log_output_file ) ) { return ; } $ frames = Frame :: $ ID_COUNTER ; $ memory = memory_get_peak_usage ( true ) / 1024 ; $ time = ( microtime ( true ) - $ this -> startTime...
Writes the output buffer in the log file
25,188
public function setPaper ( $ size , $ orientation = "portrait" ) { $ this -> paperSize = $ size ; $ this -> paperOrientation = $ orientation ; return $ this ; }
Sets the paper size & orientation
25,189
public function getPaperSize ( $ paperSize = null ) { $ size = $ paperSize !== null ? $ paperSize : $ this -> paperSize ; if ( is_array ( $ size ) ) { return $ size ; } else if ( isset ( Adapter \ CPDF :: $ PAPER_SIZES [ mb_strtolower ( $ size ) ] ) ) { return Adapter \ CPDF :: $ PAPER_SIZES [ mb_strtolower ( $ size ) ...
Gets the paper size
25,190
public function setDefaultView ( $ defaultView , $ options ) { $ this -> defaultView = $ defaultView ; $ this -> defaultViewOptions = $ options ; return $ this ; }
Sets the default view
25,191
public function setCallbacks ( $ callbacks ) { if ( is_array ( $ callbacks ) ) { $ this -> callbacks = array ( ) ; foreach ( $ callbacks as $ c ) { if ( is_array ( $ c ) && isset ( $ c [ 'event' ] ) && isset ( $ c [ 'f' ] ) ) { $ event = $ c [ 'event' ] ; $ f = $ c [ 'f' ] ; if ( is_callable ( $ f ) && is_string ( $ ev...
Sets callbacks for events like rendering of pages and elements . The callbacks array contains arrays with event set to begin_page end_page begin_frame or end_frame and f set to a function or object plus method to be called .
25,192
protected function _parse_quotes ( ) { $ re = '/(\'[^\']*\')|(\"[^\"]*\")/' ; $ quotes = $ this -> _frame -> get_style ( ) -> quotes ; if ( ! preg_match_all ( $ re , "$quotes" , $ matches , PREG_SET_ORDER ) ) { return null ; } $ quotes_array = array ( ) ; foreach ( $ matches as $ _quote ) { $ quotes_array [ ] = $ this ...
Parses a CSS quotes property
25,193
protected function _check_callbacks ( $ event , $ frame ) { if ( ! isset ( $ this -> _callbacks ) ) { $ dompdf = $ this -> _frame -> get_dompdf ( ) ; $ this -> _callbacks = $ dompdf -> get_callbacks ( ) ; $ this -> _canvas = $ dompdf -> get_canvas ( ) ; } if ( is_array ( $ this -> _callbacks ) && isset ( $ this -> _cal...
Check for callbacks that need to be performed when a given event gets triggered on a page
25,194
protected function o_toUnicode ( $ id , $ action ) { switch ( $ action ) { case 'new' : $ this -> objects [ $ id ] = array ( 't' => 'toUnicode' ) ; break ; case 'add' : break ; case 'out' : $ ordering = '(UCS)' ; $ registry = '(Adobe)' ; if ( $ this -> encrypted ) { $ this -> encryptInit ( $ id ) ; $ ordering = $ this ...
A toUnicode section needed for unicode fonts
25,195
protected function o_cidSystemInfo ( $ id , $ action ) { switch ( $ action ) { case 'new' : $ this -> objects [ $ id ] = array ( 't' => 'cidSystemInfo' ) ; break ; case 'add' : break ; case 'out' : $ ordering = '(UCS)' ; $ registry = '(Adobe)' ; if ( $ this -> encrypted ) { $ this -> encryptInit ( $ id ) ; $ ordering =...
CID system info section needed for unicode fonts
25,196
protected function o_action ( $ id , $ action , $ options = '' ) { if ( $ action !== 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : if ( is_array ( $ options ) ) { $ this -> objects [ $ id ] = array ( 't' => 'action' , 'info' => $ options , 'type' => $ options [ 'type' ] ) ; } else ...
an action object used to link to URLS initially
25,197
function md5_16 ( $ string ) { $ tmp = md5 ( $ string ) ; $ out = '' ; for ( $ i = 0 ; $ i <= 30 ; $ i = $ i + 2 ) { $ out .= chr ( hexdec ( substr ( $ tmp , $ i , 2 ) ) ) ; } return $ out ; }
calculate the 16 byte version of the 128 bit md5 digest of the string
25,198
function encryptInit ( $ id ) { $ tmp = $ this -> encryptionKey ; $ hex = dechex ( $ id ) ; if ( mb_strlen ( $ hex , '8bit' ) < 6 ) { $ hex = substr ( '000000' , 0 , 6 - mb_strlen ( $ hex , '8bit' ) ) . $ hex ; } $ tmp .= chr ( hexdec ( substr ( $ hex , 4 , 2 ) ) ) . chr ( hexdec ( substr ( $ hex , 2 , 2 ) ) ) . chr ( ...
initialize the encryption for processing a particular object
25,199
function ARC4_init ( $ key = '' ) { $ this -> arc4 = '' ; if ( mb_strlen ( $ key , '8bit' ) == 0 ) { return ; } $ k = '' ; while ( mb_strlen ( $ k , '8bit' ) < 256 ) { $ k .= $ key ; } $ k = substr ( $ k , 0 , 256 ) ; for ( $ i = 0 ; $ i < 256 ; $ i ++ ) { $ this -> arc4 .= chr ( $ i ) ; } $ j = 0 ; for ( $ i = 0 ; $ i...
initialize the ARC4 encryption