idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
19,800
protected function includedResourcesToArray ( ) : array { $ data = [ ] ; foreach ( $ this -> includedResources as $ resource ) { $ data [ ] = $ resource -> toArray ( ) ; } return $ data ; }
Cast included resources to an array
19,801
public function getContents ( ) { $ this -> valideAttach ( ) -> valideRead ( ) ; if ( ( $ stream = stream_get_contents ( $ this -> stream ) ) === false ) { throw new \ RuntimeException ( 'An error occurred while reading the stream.' ) ; } return $ stream ; }
Renvoie le contenu restant .
19,802
public function toArray ( ) { return [ 'id' => $ this -> id , 'filename' => $ this -> filename , 'filetype' => $ this -> filetype , 'filesize' => $ this -> filesize , 'tags' => $ this -> tags , 'preview_url' => $ this -> previewUrl ( ) , 'url' => $ this -> downloadUrl ( ) ] ; }
Array Representation used for APIs
19,803
private static function detectFilePath ( $ params ) { if ( isset ( $ params -> path ) && ! empty ( $ params -> path ) ) { return $ params -> path ; } if ( isset ( $ params -> file ) && ! empty ( $ params -> file ) ) { return $ params -> path ; } return false ; }
Detect File Path from Parameters .
19,804
public static function images ( ) { if ( isset ( self :: $ ImagesHelper ) ) { return self :: $ ImagesHelper ; } self :: $ ImagesHelper = new ImagesHelper ( ) ; return self :: $ ImagesHelper ; }
Get a singleton List Helper Class
19,805
protected function process ( $ value , string $ type ) { if ( $ type === 'integer' ) { return ( int ) $ value ; } if ( $ type === 'float' ) { return ( float ) $ value ; } if ( $ type === 'boolean' ) { return ( bool ) $ value ; } return ( string ) $ value ; }
Process native type
19,806
public static function commit ( $ objectType , $ local = null , $ action = null , $ user = '' , $ comment = '' ) { self :: log ( ) -> trace ( ) ; if ( false == Splash :: object ( $ objectType ) ) { return true ; } $ params = self :: getCommitParameters ( $ objectType , $ local , $ action , $ user , $ comment ) ; static :: $ commited [ ] = $ params ; if ( ! self :: isCommitAllowed ( $ objectType , $ local , $ action ) ) { return true ; } Splash :: ws ( ) -> addTask ( SPL_F_COMMIT , $ params , Splash :: trans ( 'MsgSchRemoteCommit' , ( string ) $ action , $ objectType , ( string ) Splash :: count ( $ local ) ) ) ; $ response = self :: ws ( ) -> call ( SPL_S_OBJECTS ) ; return self :: isCommitSuccess ( $ response ) ; }
Submit an Update for a Local Object
19,807
private static function getCommitParameters ( $ objectType , $ local = null , $ action = null , $ user = '' , $ comment = '' ) { $ params = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; $ params -> type = $ objectType ; $ params -> id = $ local ; $ params -> action = $ action ; $ params -> user = $ user ; $ params -> comment = $ comment ; return $ params ; }
Build Call Parameters Array
19,808
private static function isCommitAllowed ( $ objectType , $ local = null , $ action = null ) { if ( is_array ( $ local ) ) { foreach ( $ local as $ value ) { if ( Splash :: object ( $ objectType ) -> isLocked ( $ value ) ) { return false ; } } } else { if ( Splash :: object ( $ objectType ) -> isLocked ( $ local ) ) { return false ; } } if ( ( SPL_A_CREATE === $ action ) && Splash :: object ( $ objectType ) -> isLocked ( ) ) { return false ; } return ! self :: isTravisMode ( $ objectType , $ local , $ action ) ; }
Check if Commit is Allowed Local Object
19,809
private static function isTravisMode ( $ objectType , $ local , $ action = null ) { if ( empty ( Splash :: input ( 'SPLASH_TRAVIS' ) ) ) { return false ; } $ objectIds = is_array ( $ local ) ? implode ( '|' , $ local ) : $ local ; self :: log ( ) -> war ( 'Module Commit Skipped (' . $ objectType . ', ' . $ action . ', ' . $ objectIds . ')' ) ; return true ; }
Check if Commit we Are in Travis Mode
19,810
public function merge ( self $ definition ) { if ( $ this -> type === null && $ definition -> hasType ( ) ) { $ this -> type = $ definition -> getType ( ) ; } $ this -> mergeLinks ( $ definition ) ; $ this -> mergeAttributes ( $ definition ) ; $ this -> mergeRelationships ( $ definition ) ; }
Merge a definition into this one
19,811
public static function encode ( $ objectType , $ objectId ) { if ( empty ( $ objectType ) ) { return false ; } if ( empty ( $ objectId ) ) { return false ; } return $ objectId . IDSPLIT . $ objectType ; }
Create an Object Identifier String
19,812
public static function load ( $ fieldData , $ objectClass = null ) { $ objectType = self :: objectType ( $ fieldData ) ; $ objectId = self :: objectId ( $ fieldData ) ; if ( ! $ objectType || ! $ objectId ) { return null ; } $ splashObject = Splash :: object ( $ objectType ) ; if ( empty ( $ splashObject ) ) { return null ; } if ( ! in_array ( IntelParserTrait :: class , class_uses ( $ splashObject ) , true ) ) { return null ; } if ( ! method_exists ( $ splashObject , 'load' ) ) { return null ; } $ remoteObject = $ splashObject -> load ( $ objectId ) ; if ( ! $ remoteObject ) { return null ; } if ( ! empty ( $ objectClass ) && ! ( $ remoteObject instanceof $ objectClass ) ) { return null ; } return $ remoteObject ; }
Load a Target Remote Object using Splash Object Field Data
19,813
protected function getMime ( UploadedFileInterface $ upload ) { $ file = $ upload -> getStream ( ) -> getMetadata ( 'uri' ) ; return ( new \ finfo ( FILEINFO_MIME_TYPE ) ) -> file ( $ file ) ; }
Retourne le mimetype du fichier .
19,814
protected function getExtension ( UploadedFileInterface $ upload ) { $ filename = $ filename = $ upload -> getClientFilename ( ) ; return strtolower ( pathinfo ( $ filename , PATHINFO_EXTENSION ) ) ; }
Retourne l extension du fichier .
19,815
public static function edcode ( $ string , $ operation , $ key = 'ePHP' ) { $ key_length = strlen ( $ key ) ; $ string = $ operation == 'DECODE' ? \ ePHP \ Misc \ Func :: safe_b64decode ( $ string ) : substr ( md5 ( $ string . $ key ) , 0 , 8 ) . $ string ; $ string_length = strlen ( $ string ) ; $ rndkey = $ box = array ( ) ; $ result = '' ; for ( $ i = 0 ; $ i <= 255 ; $ i ++ ) { $ rndkey [ $ i ] = ord ( $ key [ $ i % $ key_length ] ) ; $ box [ $ i ] = $ i ; } for ( $ j = $ i = 0 ; $ i < 256 ; $ i ++ ) { $ j = ( $ j + $ box [ $ i ] + $ rndkey [ $ i ] ) % 256 ; $ tmp = $ box [ $ i ] ; $ box [ $ i ] = $ box [ $ j ] ; $ box [ $ j ] = $ tmp ; } for ( $ a = $ j = $ i = 0 ; $ i < $ string_length ; $ i ++ ) { $ a = ( $ a + 1 ) % 256 ; $ j = ( $ j + $ box [ $ a ] ) % 256 ; $ tmp = $ box [ $ a ] ; $ box [ $ a ] = $ box [ $ j ] ; $ box [ $ j ] = $ tmp ; $ result .= chr ( ord ( $ string [ $ i ] ) ^ ( $ box [ ( $ box [ $ a ] + $ box [ $ j ] ) % 256 ] ) ) ; } if ( $ operation == 'DECODE' ) { if ( substr ( $ result , 0 , 8 ) == substr ( md5 ( substr ( $ result , 8 ) . $ key ) , 0 , 8 ) ) { return substr ( $ result , 8 ) ; } else { return '' ; } } else { return \ ePHP \ Misc \ Func :: safe_b64encode ( $ result ) ; } }
Others encode or decode
19,816
protected function setHeader ( $ key , $ value ) { if ( SERVER_MODE === 'swoole' ) { $ GLOBALS [ '__$response' ] -> header ( $ key , $ value ) ; } else { if ( ! headers_sent ( ) ) { header ( $ key . ': ' . $ value ) ; } } }
Set response header
19,817
protected function redirect ( $ url , $ code = 302 ) { if ( ! headers_sent ( ) ) { if ( SERVER_MODE === 'swoole' ) { $ GLOBALS [ '__$response' ] -> status ( $ code ) ; } else if ( $ code == 301 ) { header ( 'HTTP/1.1 301 Moved Permanently' ) ; } else { header ( 'HTTP/1.1 302 Found' ) ; } $ this -> setHeader ( "Location" , $ url ) ; $ this -> stopRun ( ) ; } else { echo '<html><head><meta charset="UTF-8" /><title></title></head><body>' ; echo '<script>window.location.href="' . $ url . '";</script></body></html>' ; $ this -> stopRun ( ) ; } }
Redirect to url Compatible swoole mode server container
19,818
public static function init ( $ name ) { if ( empty ( self :: $ instance [ $ name ] ) || ! self :: $ instance [ $ name ] instanceof self ) { self :: $ instance [ $ name ] = new self ( ) ; self :: $ instance [ $ name ] -> queue = new \ SplQueue ( ) ; } return self :: $ instance [ $ name ] ; }
Dynamically handle calls to the class .
19,819
public function orderBy ( $ orderBy = NULL ) { if ( isset ( $ orderBy ) ) { $ this -> setOrderBy ( $ orderBy ) ; return $ this ; } return $ this -> getOrderBy ( ) ; }
Retained for backward compatibility
19,820
protected function getDimensions ( UploadedFileInterface $ upload ) { $ dimension = getimagesize ( $ upload -> getStream ( ) -> getMetadata ( 'uri' ) ) ; return [ 'width' => $ dimension [ 0 ] , 'height' => $ dimension [ 1 ] ] ; }
Retourne les dimensions d une image .
19,821
private function validMimeImage ( $ extension , $ mimes ) { if ( is_array ( $ mimes ) ) { foreach ( $ mimes as $ mime ) { if ( ! strstr ( $ mime , 'image/' ) ) { throw new \ InvalidArgumentException ( htmlspecialchars ( "The extension $extension is not an image extension." ) ) ; } } } else { if ( ! strstr ( $ mimes , 'image/' ) ) { throw new \ InvalidArgumentException ( htmlspecialchars ( "The extension $extension is not an image extension." ) ) ; } } }
Valide si un mimetype est celui d une image .
19,822
protected static function addLogToFile ( $ message , $ logType = 'Unknown' ) { if ( 0 == Splash :: configuration ( ) -> Logging ) { return true ; } $ logfile = dirname ( __DIR__ ) . '/splash.log' ; if ( defined ( 'SPLASH_DIR' ) && realpath ( SPLASH_DIR ) ) { $ logfile = realpath ( SPLASH_DIR ) . '/splash.log' ; } $ filefd = @ fopen ( $ logfile , 'a+' ) ; if ( $ filefd ) { $ message = date ( 'Y-m-d H:i:s' ) . ' ' . sprintf ( '%-15s' , $ logType ) . $ message ; fwrite ( $ filefd , $ message . "\n" ) ; fclose ( $ filefd ) ; @ chmod ( $ logfile , 0604 ) ; } return true ; }
Add a message to Log File
19,823
protected static function addLogBlockToFile ( $ msgArray , $ logType = 'Unknown' ) { if ( false == Splash :: configuration ( ) -> Logging ) { return true ; } if ( ( is_array ( $ msgArray ) || $ msgArray instanceof Countable ) && count ( $ msgArray ) ) { foreach ( $ msgArray as $ message ) { self :: addLogToFile ( utf8_decode ( html_entity_decode ( $ message ) ) , $ logType ) ; } } return true ; }
Add a Messages Block to Log File
19,824
public function render ( ) { $ percentage = ( double ) ( $ this -> value / $ this -> total ) ; $ progress = floor ( $ percentage * $ this -> size ) ; $ output = "\r[" . str_repeat ( '=' , $ progress ) ; if ( $ progress < $ this -> size ) { $ output .= ">" . str_repeat ( ' ' , $ this -> size - $ progress ) ; } else { $ output .= '=' ; } $ output .= sprintf ( '] %s%% %s/%s' , round ( $ percentage * 100 , 0 ) , $ this -> value , $ this -> total ) ; if ( $ this -> showRemainingTime ) { $ speed = ( time ( ) - $ this -> startTime ) / $ this -> value ; $ remaining = number_format ( round ( $ speed * ( $ this -> total - $ this -> value ) , 2 ) , 2 ) ; $ output .= " - $remaining sec remaining" ; } return $ output ; }
Generates the text to write for the current values
19,825
public function write ( ) { if ( $ this -> textWriter === null ) { throw new ConsoleException ( 'No TextWriter object specified' ) ; } $ this -> textWriter -> write ( $ this -> render ( ) ) ; return $ this ; }
Writes the rendered progress bar to the text writer
19,826
private function getConfigPath ( ) { $ cfg = Splash :: configuration ( ) ; $ cfgPath = Splash :: getLocalPath ( ) . "/configuration.json" ; if ( isset ( $ cfg -> ConfiguratorPath ) && is_string ( $ cfg -> ConfiguratorPath ) ) { $ cfgPath = $ cfg -> ConfiguratorPath ; } Splash :: log ( ) -> deb ( "Try Loading Custom Configuration From: " . $ cfgPath ) ; if ( ! is_file ( $ cfgPath ) ) { return false ; } return $ cfgPath ; }
Get Json Configuration File Path
19,827
private function getConfigArray ( $ cfgPath ) { if ( ! is_file ( $ cfgPath ) ) { return false ; } $ rawJson = file_get_contents ( $ cfgPath ) ; if ( ! is_string ( $ rawJson ) ) { return false ; } $ json = json_decode ( $ rawJson , true ) ; if ( ! is_array ( $ json ) ) { Splash :: log ( ) -> war ( "Invalid Json Configuration. Overrides Skipped!" ) ; return false ; } Splash :: log ( ) -> deb ( "Loaded Custom Configuration From: " . $ cfgPath ) ; return $ json ; }
Load Configuration File
19,828
public function has ( $ key ) { if ( ! is_string ( $ key ) ) { throw new \ InvalidArgumentException ( htmlspecialchars ( "Get function only accepts strings. Input was: $key." ) ) ; } return isset ( $ this -> services [ $ key ] ) || isset ( $ this -> instances [ $ key ] ) ; }
Si le service existe .
19,829
protected function loadHooks ( array $ services ) { foreach ( $ services as $ service => $ value ) { if ( ! isset ( $ value [ 'hooks' ] ) ) { continue ; } foreach ( $ value [ 'hooks' ] as $ key => $ hook ) { $ this -> hooks [ $ key ] [ $ service ] = $ hook ; } } }
Charge les hooks contenus dans les services .
19,830
public function getHtmlListItem ( $ message , $ type = null ) { switch ( $ type ) { case 'Error' : $ color = '#FF3300' ; $ text = '&nbsp;KO&nbsp;' ; break ; case 'Warning' : $ color = '#FF9933' ; $ text = '&nbsp;WAR&nbsp;' ; break ; default : $ color = '#006600' ; $ text = '&nbsp;OK&nbsp;' ; break ; } return '[<font color="' . $ color . '">' . $ text . '</font>]&nbsp;&nbsp;&nbsp;' . $ message . PHP_EOL . '</br>' ; }
Return WebServer Log Item in Html Checklist format
19,831
public function get ( $ name ) { if ( ! isset ( $ this -> storeList [ $ name ] ) ) { $ configs = $ this -> getDataStoreDeclarations ( ) ; $ this -> storeList [ $ name ] = new DataStore ( $ this -> container , $ configs [ $ name ] ) ; } return $ this -> storeList [ $ name ] ; }
Get store by name
19,832
public function setEndPoint ( $ endPoint ) { if ( strlen ( $ this -> getEndPointGroup ( ) ) > 0 ) { throw new RuntimeException ( "End point group has been already set. You can set either end point or end point group." ) ; } $ this -> endPoint = ( int ) $ endPoint ; return $ this ; }
Set merchant end point
19,833
function setEndPointGroup ( $ endPointGroup ) { if ( strlen ( $ this -> getEndPoint ( ) ) > 0 ) { throw new RuntimeException ( "End point has been already set. You can set either end point or end point group." ) ; } $ this -> endPointGroup = ( int ) $ endPointGroup ; }
Get merchant end point group
19,834
public function setGatewayUrl ( $ gatewayUrl , $ gatewayMode ) { $ this -> checkGatewayMode ( $ gatewayMode ) ; switch ( $ gatewayMode ) { case self :: GATEWAY_MODE_SANDBOX : { $ this -> setGatewayUrlSandbox ( $ gatewayUrl ) ; break ; } case self :: GATEWAY_MODE_PRODUCTION : { $ this -> setGatewayUrlProduction ( $ gatewayUrl ) ; break ; } } return $ this ; }
Set gateway url for different gateway modes
19,835
public function getGatewayUrl ( ) { switch ( $ this -> getGatewayMode ( ) ) { case self :: GATEWAY_MODE_SANDBOX : { return $ this -> getGatewayUrlSandbox ( ) ; } case self :: GATEWAY_MODE_PRODUCTION : { return $ this -> getGatewayUrlProduction ( ) ; } default : { throw new RuntimeException ( 'You must set gatewayMode property first' ) ; } } }
Get gateway url for current gateway mode
19,836
static public function getValue ( $ object , $ propertyPath , $ failOnError = true ) { if ( ! is_object ( $ object ) ) { throw new RuntimeException ( 'Object expected, ' . gettype ( $ object ) . ' given' ) ; } if ( strpos ( $ propertyPath , '.' ) === false ) { return static :: getByGetter ( $ object , $ propertyPath , $ failOnError ) ; } list ( $ firstPropertyPath , $ pathRest ) = explode ( '.' , $ propertyPath , 2 ) ; $ firstObject = static :: getByGetter ( $ object , $ firstPropertyPath , $ failOnError ) ; if ( is_object ( $ firstObject ) ) { return static :: getValue ( $ firstObject , $ pathRest , $ failOnError ) ; } elseif ( $ failOnError === true ) { throw new RuntimeException ( "Object expected for property path '{$firstPropertyPath}', '" . gettype ( $ firstObject ) . "' given" ) ; } }
Get property value by property path .
19,837
static public function setValue ( $ object , $ propertyPath , $ propertyValue , $ failOnError = true ) { if ( ! is_object ( $ object ) ) { throw new RuntimeException ( 'Object expected, ' . gettype ( $ object ) . ' given' ) ; } if ( strpos ( $ propertyPath , '.' ) === false ) { return static :: setBySetter ( $ object , $ propertyPath , $ propertyValue , $ failOnError ) ; } list ( $ firstPropertyPath , $ pathRest ) = explode ( '.' , $ propertyPath , 2 ) ; $ firstObject = static :: getByGetter ( $ object , $ firstPropertyPath , $ failOnError ) ; if ( is_object ( $ firstObject ) ) { return static :: setValue ( $ firstObject , $ pathRest , $ propertyValue , $ failOnError ) ; } elseif ( $ failOnError === true ) { throw new RuntimeException ( "Object expected for property path '{$firstPropertyPath}', '" . gettype ( $ firstObject ) . "' given" ) ; } }
Set property value by property path .
19,838
static protected function getByGetter ( $ object , $ propertyName , $ failOnUnknownGetter ) { $ getter = array ( $ object , 'get' . $ propertyName ) ; if ( is_callable ( $ getter ) ) { return call_user_func ( $ getter ) ; } elseif ( $ failOnUnknownGetter === true ) { throw new RuntimeException ( "Unknown getter for property '{$propertyName}'" ) ; } }
Get property value by property name
19,839
static protected function setBySetter ( $ object , $ propertyName , $ propertyValue , $ failOnUnknownGetter ) { $ setter = array ( $ object , 'set' . $ propertyName ) ; if ( is_callable ( $ setter ) ) { return call_user_func ( $ setter , $ propertyValue ) ; } elseif ( $ failOnUnknownGetter === true ) { throw new RuntimeException ( "Unknown setter for property '{$propertyName}'" ) ; } }
Set property value by property name
19,840
protected function _clear_var ( ) { $ this -> field = array ( ) ; $ this -> limit = '' ; $ this -> skip = '' ; $ this -> where = array ( ) ; $ this -> orderby = array ( ) ; $ this -> data = array ( ) ; }
Clear unused variable
19,841
protected function createIdentifierCollectionRelationship ( $ object , RelationshipDefinition $ definition , MappingContext $ context ) : IdentifierCollectionRelationship { $ relationship = new IdentifierCollectionRelationship ( ) ; $ collection = $ object -> { $ definition -> getGetter ( ) } ( ) ; $ dataLimit = $ definition -> getDataLimit ( ) ; if ( $ dataLimit > 0 ) { $ collection = new \ LimitIterator ( $ collection , 0 , $ dataLimit ) ; } $ mapper = $ context -> getMapper ( ) ; foreach ( $ collection as $ relatedObject ) { $ resource = $ mapper -> toResourceIdentifier ( $ relatedObject ) ; $ relationship -> addIdentifier ( $ resource ) ; } return $ relationship ; }
Create relationship contains a collection of resource - identifiers
19,842
public function createItem ( array $ values = [ ] ) { $ values [ 'customer.siteid' ] = $ this -> getContext ( ) -> getLocale ( ) -> getSiteId ( ) ; return $ this -> createItemBase ( $ values ) ; }
Creates a new empty item instance
19,843
public function deleteItems ( array $ ids ) { $ path = 'mshop/customer/manager/typo3/delete' ; $ this -> deleteItemsBase ( $ ids , $ path , false , 'uid' ) ; $ manager = $ this -> getObject ( ) -> getSubManager ( 'address' ) ; $ search = $ manager -> createSearch ( ) -> setSlice ( 0 , 0x7fffffff ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'customer.address.parentid' , $ ids ) ) ; $ manager -> deleteItems ( array_keys ( $ manager -> searchItems ( $ search ) ) ) ; $ manager = $ this -> getObject ( ) -> getSubManager ( 'lists' ) ; $ search = $ manager -> createSearch ( ) -> setSlice ( 0 , 0x7fffffff ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'customer.lists.parentid' , $ ids ) ) ; $ manager -> deleteItems ( array_keys ( $ manager -> searchItems ( $ search ) ) ) ; $ manager = $ this -> getObject ( ) -> getSubManager ( 'property' ) ; $ search = $ manager -> createSearch ( ) -> setSlice ( 0 , 0x7fffffff ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'customer.property.parentid' , $ ids ) ) ; $ manager -> deleteItems ( array_keys ( $ manager -> searchItems ( $ search ) ) ) ; }
Deletes a customer item object from the permanent storage .
19,844
public function getSubManager ( $ manager , $ name = null ) { return $ this -> getSubManagerBase ( 'customer' , $ manager , ( $ name === null ? 'Typo3' : $ name ) ) ; }
Returns a new manager for customer extensions
19,845
protected function getPasswordHelper ( ) { if ( $ this -> helper ) { return $ this -> helper ; } $ classname = \ Aimeos \ MShop \ Common \ Helper \ Password \ Typo3 :: class ; if ( class_exists ( $ classname ) === false ) { throw new \ Aimeos \ MShop \ Exception ( sprintf ( 'Class "%1$s" not available' , $ classname ) ) ; } $ context = $ this -> getContext ( ) ; $ object = ( method_exists ( $ context , 'getHasherTypo3' ) ? $ context -> getHasherTypo3 ( ) : null ) ; $ helper = new $ classname ( array ( 'object' => $ object ) ) ; return $ this -> helper = self :: checkClass ( \ Aimeos \ MShop \ Common \ Helper \ Password \ Iface :: class , $ helper ) ; }
Returns a password helper object based on the configuration .
19,846
public static function i ( $ options = array ( ) ) { static $ instance ; if ( ! isset ( $ instance ) ) { $ instance = new self ( $ options ) ; if ( self :: $ _config [ 'profiler' ] [ 'showStart' ] ) { self :: mark ( 'jbdump::start' ) ; } } return $ instance ; }
Returns the global JBDump object only creating it if it doesn t already exist
19,847
public static function showErrors ( $ reportLevel = - 1 ) { if ( ! self :: isDebug ( ) ) { return false ; } if ( $ reportLevel === null || $ reportLevel === false ) { return false ; } if ( $ reportLevel != 0 ) { error_reporting ( $ reportLevel ) ; ini_set ( 'error_reporting' , $ reportLevel ) ; ini_set ( 'display_errors' , 1 ) ; ini_set ( 'display_startup_errors' , 1 ) ; } else { error_reporting ( 0 ) ; ini_set ( 'error_reporting' , 0 ) ; ini_set ( 'display_errors' , 0 ) ; ini_set ( 'display_startup_errors' , 0 ) ; } return true ; }
Force show PHP error messages
19,848
public static function maxTime ( $ time = 600 ) { if ( ! self :: isDebug ( ) ) { return false ; } ini_set ( 'max_execution_time' , $ time ) ; set_time_limit ( $ time ) ; return self :: i ( ) ; }
Set max execution time
19,849
public function setParams ( $ data , $ section = null ) { if ( $ section ) { $ newData = array ( $ section => $ data ) ; $ data = $ newData ; unset ( $ newData ) ; } if ( isset ( $ data [ 'errors' ] [ 'reporting' ] ) ) { $ this -> showErrors ( $ data [ 'errors' ] [ 'reporting' ] ) ; } if ( ! isset ( $ data [ 'root' ] ) && ! self :: $ _config [ 'root' ] ) { $ data [ 'root' ] = $ _SERVER [ 'DOCUMENT_ROOT' ] ; } if ( isset ( $ data [ 'log' ] [ 'path' ] ) && $ data [ 'log' ] [ 'path' ] ) { $ this -> _logPath = $ data [ 'log' ] [ 'path' ] ; } elseif ( ! self :: $ _config [ 'log' ] [ 'path' ] || ! $ this -> _logPath ) { $ this -> _logPath = dirname ( __FILE__ ) . self :: DS . 'logs' ; } $ logFile = 'jbdump' ; if ( isset ( $ data [ 'log' ] [ 'file' ] ) && $ data [ 'log' ] [ 'file' ] ) { $ logFile = $ data [ 'log' ] [ 'file' ] ; } elseif ( ! self :: $ _config [ 'log' ] [ 'file' ] || ! $ this -> _logfile ) { $ logFile = 'jbdump' ; } $ this -> _logfile = $ this -> _logPath . self :: DS . $ logFile . '_' . date ( 'Y.m.d' ) . '.log.php' ; foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ keyInner => $ valueInner ) { if ( ! isset ( self :: $ _config [ $ key ] ) ) { self :: $ _config [ $ key ] = array ( ) ; } self :: $ _config [ $ key ] [ $ keyInner ] = $ valueInner ; } } else { self :: $ _config [ $ key ] = $ value ; } } return $ this ; }
Set debug parameters
19,850
public static function ip ( ) { if ( ! self :: isDebug ( ) ) { return false ; } $ ip = self :: getClientIP ( ) ; $ data = array ( 'ip' => $ ip , 'host' => gethostbyaddr ( $ ip ) , 'source' => '$_SERVER["' . self :: getClientIP ( true ) . '"]' , 'inet_pton' => inet_pton ( $ ip ) , 'ip2long' => ip2long ( $ ip ) , ) ; return self :: i ( ) -> dump ( $ data , '! my IP = ' . $ ip . ' !' ) ; }
Show client IP
19,851
public static function memory ( $ formated = true ) { if ( ! self :: isDebug ( ) ) { return false ; } $ memory = self :: i ( ) -> _getMemory ( ) ; if ( $ formated ) { $ memory = self :: i ( ) -> _formatSize ( $ memory ) ; } return self :: i ( ) -> dump ( $ memory , '! memory !' ) ; }
Show current usage memory in filesize format
19,852
public static function functions ( $ showInternal = false ) { if ( ! self :: isDebug ( ) ) { return false ; } $ functions = get_defined_functions ( ) ; if ( $ showInternal ) { $ functions = $ functions [ 'internal' ] ; $ type = 'internal' ; } else { $ functions = $ functions [ 'user' ] ; $ type = 'user' ; } return self :: i ( ) -> dump ( $ functions , '! functions (' . $ type . ') !' ) ; }
Show defined functions
19,853
public static function defines ( $ showAll = false ) { if ( ! self :: isDebug ( ) ) { return false ; } $ defines = get_defined_constants ( true ) ; if ( ! $ showAll ) { $ defines = ( isset ( $ defines [ 'user' ] ) ) ? $ defines [ 'user' ] : array ( ) ; } return self :: i ( ) -> dump ( $ defines , '! defines !' ) ; }
Show defined constants
19,854
public static function extensions ( $ zend = false ) { if ( ! self :: isDebug ( ) ) { return false ; } return self :: i ( ) -> dump ( get_loaded_extensions ( $ zend ) , '! extensions ' . ( $ zend ? '(Zend)' : '' ) . ' !' ) ; }
Show loaded PHP extensions
19,855
public static function headers ( ) { if ( ! self :: isDebug ( ) ) { return false ; } if ( function_exists ( 'apache_request_headers' ) ) { $ data = array ( 'Request' => apache_request_headers ( ) , 'Response' => apache_response_headers ( ) , 'List' => headers_list ( ) ) ; } else { $ data = array ( 'List' => headers_list ( ) ) ; } if ( headers_sent ( $ filename , $ linenum ) ) { $ data [ 'Sent' ] = 'Headers already sent in ' . self :: i ( ) -> _getRalativePath ( $ filename ) . ':' . $ linenum ; } else { $ data [ 'Sent' ] = false ; } return self :: i ( ) -> dump ( $ data , '! headers !' ) ; }
Show HTTP headers
19,856
public static function path ( ) { if ( ! self :: isDebug ( ) ) { return false ; } $ result = array ( 'get_include_path' => explode ( PATH_SEPARATOR , trim ( get_include_path ( ) , PATH_SEPARATOR ) ) , '$_SERVER[PATH]' => explode ( PATH_SEPARATOR , trim ( $ _SERVER [ 'PATH' ] , PATH_SEPARATOR ) ) ) ; return self :: i ( ) -> dump ( $ result , '! paths !' ) ; }
Show included and system paths
19,857
public static function json ( $ json , $ name = '...' ) { if ( ! self :: isDebug ( ) ) { return false ; } $ jsonData = json_decode ( $ json ) ; $ result = self :: i ( ) -> _jsonEncode ( $ jsonData ) ; return self :: i ( ) -> dump ( $ result , $ name ) ; }
Convert JSON format to human readability
19,858
public static function timestamp ( $ timestamp = null ) { if ( ! self :: isDebug ( ) ) { return false ; } $ date = date ( DATE_RFC822 , $ timestamp ) ; return self :: i ( ) -> dump ( $ date , $ timestamp . ' sec = ' ) ; }
Convert timestamp to normal date in DATE_RFC822 format
19,859
public static function locale ( ) { if ( ! self :: isDebug ( ) ) { return false ; } ob_start ( ) ; @ system ( 'locale -a' ) ; $ locale = explode ( PHP_EOL , trim ( ob_get_contents ( ) ) ) ; ob_end_clean ( ) ; $ result = array ( 'list' => $ locale , 'conv' => @ localeconv ( ) ) ; return self :: i ( ) -> dump ( $ result , '! locale info !' ) ; }
Find all locale in system list - only for linux like systems
19,860
public static function timezone ( ) { if ( ! self :: isDebug ( ) ) { return false ; } $ data = date_default_timezone_get ( ) ; return self :: i ( ) -> dump ( $ data , '! timezone !' ) ; }
Show date default timezone
19,861
public static function print_r ( $ var , $ varname = '...' , $ params = array ( ) ) { if ( ! self :: isDebug ( ) ) { return false ; } $ output = print_r ( $ var , true ) ; $ _this = self :: i ( ) ; $ _this -> _dumpRenderHtml ( $ output , $ varname , $ params ) ; return $ _this ; }
Wrapper for PHP print_r function
19,862
public static function phpArray ( $ var , $ varname = 'varName' , $ isReturn = false ) { if ( ! self :: isDebug ( ) ) { return false ; } $ output = JBDump_array2php :: toString ( $ var , $ varname ) ; if ( $ isReturn ) { return $ output ; } $ _this = self :: i ( ) ; $ _this -> _dumpRenderHtml ( $ output , $ varname , $ params ) ; return $ _this ; }
Render variable as phpArray
19,863
public static function var_dump ( $ var , $ varname = '...' , $ params = array ( ) ) { if ( ! self :: isDebug ( ) ) { return false ; } ob_start ( ) ; var_dump ( $ var ) ; $ output = ob_get_clean ( ) ; $ _this = self :: i ( ) ; $ output = preg_replace ( "/\]\=\>\n(\s+)/m" , "] => " , $ output ) ; $ output = $ _this -> _htmlChars ( $ output ) ; $ _this -> _dumpRenderHtml ( $ output , $ varname . '::html' , $ params ) ; return $ _this ; }
Wrapper for PHP var_dump function
19,864
public static function trace ( $ trace = null , $ addObject = false ) { if ( ! self :: isDebug ( ) ) { return false ; } $ _this = self :: i ( ) ; $ trace = $ trace ? $ trace : debug_backtrace ( $ addObject ) ; unset ( $ trace [ 0 ] ) ; $ result = $ _this -> convertTrace ( $ trace , $ addObject ) ; return $ _this -> dump ( $ result , '! backtrace !' ) ; }
Get system backtrace in formated view
19,865
public static function extInfo ( $ extensionName ) { $ result = self :: _getExtension ( $ extensionName ) ; if ( $ result ) { $ extensionName = $ result [ 'name' ] ; } return self :: i ( ) -> dump ( $ result , '! extension (' . $ extensionName . ') !' ) ; }
Dump all info about extension
19,866
public static function pathInfo ( $ file ) { $ result = self :: _pathInfo ( $ file ) ; return self :: i ( ) -> dump ( $ result , '! pathInfo (' . $ file . ') !' ) ; }
Dump all file info
19,867
public static function funcInfo ( $ functionName ) { $ result = self :: _getFunction ( $ functionName ) ; if ( $ result ) { $ functionName = $ result [ 'name' ] ; } return self :: i ( ) -> dump ( $ result , '! function (' . $ functionName . ') !' ) ; }
Dump all info about function
19,868
public static function microtime ( ) { $ _this = self :: i ( ) ; if ( ! $ _this -> isDebug ( ) ) { return false ; } $ data = $ _this -> _microtime ( ) ; return $ _this -> dump ( $ data , '! current microtime !' ) ; }
Show current microtime
19,869
public static function mark ( $ label = '' ) { $ _this = self :: i ( ) ; if ( ! $ _this -> isDebug ( ) ) { return false ; } $ current = $ _this -> _microtime ( ) - $ _this -> _start ; $ memory = self :: _getMemory ( ) ; $ trace = debug_backtrace ( ) ; $ markInfo = array ( 'time' => $ current , 'timeDiff' => $ current - $ _this -> _prevTime , 'memory' => $ memory , 'memoryDiff' => $ memory - $ _this -> _prevMemory , 'trace' => $ _this -> _getSourcePath ( $ trace , true ) , 'label' => $ label , ) ; $ _this -> _bufferInfo [ ] = $ markInfo ; if ( ( int ) self :: $ _config [ 'profiler' ] [ 'render' ] & self :: PROFILER_RENDER_FILE ) { $ _this -> log ( self :: _profilerFormatMark ( $ markInfo ) , 'mark #' ) ; } $ _this -> _prevTime = $ current ; $ _this -> _prevMemory = $ memory ; return $ _this ; }
Output a time mark The mark is returned as text current profiler status
19,870
public function profiler ( $ mode = 1 ) { if ( $ this -> isDebug ( ) && count ( $ this -> _bufferInfo ) > 2 && $ mode ) { $ mode = ( int ) $ mode ; if ( $ mode && self :: isAjax ( ) ) { if ( $ mode & self :: PROFILER_RENDER_TOTAL ) { $ this -> _profilerRenderTotal ( ) ; } } else { if ( $ mode & self :: PROFILER_RENDER_TABLE ) { $ this -> _profilerRenderTable ( ) ; } if ( $ mode & self :: PROFILER_RENDER_CHART ) { $ this -> _profilerRenderChart ( ) ; } if ( $ mode & self :: PROFILER_RENDER_TOTAL ) { $ this -> _profilerRenderTotal ( ) ; } if ( $ mode & self :: PROFILER_RENDER_ECHO ) { $ this -> _profilerRenderEcho ( ) ; } } } }
Show profiler result
19,871
protected static function _profilerFormatMemory ( $ memoryBytes , $ addMeasure = false ) { $ bytes = round ( $ memoryBytes / 1024 / 1024 , 3 ) ; if ( $ addMeasure ) { $ bytes .= ' MB' ; } return $ bytes ; }
Convert profiler memory value to usability view
19,872
protected static function _profilerFormatTime ( $ time , $ addMeasure = false , $ round = 0 ) { $ time = round ( $ time * 1000 , $ round ) ; if ( $ addMeasure ) { $ time .= ' ms' ; } return $ time ; }
Convert profiler time value to usability view
19,873
protected static function _profilerFormatMark ( array $ mark ) { return sprintf ( "%0.3f sec (+%.3f); %0.3f MB (%s%0.3f) - %s" , ( float ) $ mark [ 'time' ] , ( float ) $ mark [ 'timeDiff' ] , ( $ mark [ 'memory' ] / 1024 / 1024 ) , ( $ mark [ 'memoryDiff' ] / 1024 / 1024 >= 0 ) ? '+' : '' , ( $ mark [ 'memoryDiff' ] / 1024 / 1024 ) , $ mark [ 'label' ] ) ; }
Convert profiler mark to string
19,874
protected function _profilerRenderTotal ( ) { reset ( $ this -> _bufferInfo ) ; $ first = current ( $ this -> _bufferInfo ) ; $ last = end ( $ this -> _bufferInfo ) ; $ memoryPeak = memory_get_peak_usage ( true ) ; $ memoryDeltas = $ timeDeltas = array ( ) ; foreach ( $ this -> _bufferInfo as $ oneMark ) { $ memoryDeltas [ ] = $ oneMark [ 'memoryDiff' ] ; $ timeDeltas [ ] = $ oneMark [ 'timeDiff' ] ; } $ totalInfo = array ( ) ; $ totalInfo [ ] = '- Points: ' . count ( $ this -> _bufferInfo ) ; $ totalInfo [ ] = '-------- Time (ms)' ; $ totalInfo [ ] = '- Max delta, msec: ' . self :: _profilerFormatTime ( max ( $ timeDeltas ) ) ; $ totalInfo [ ] = '- Min delta, msec: ' . self :: _profilerFormatTime ( min ( $ timeDeltas ) ) ; $ totalInfo [ ] = '- Total delta, msec: ' . self :: _profilerFormatTime ( ( $ last [ 'time' ] - $ first [ 'time' ] ) ) ; $ totalInfo [ ] = '- Limit, sec: ' . ini_get ( 'max_execution_time' ) ; $ totalInfo [ ] = '-------- Memory (MB)' ; $ totalInfo [ ] = '- Max delta: ' . self :: _profilerFormatMemory ( max ( $ memoryDeltas ) ) ; $ totalInfo [ ] = '- Min delta: ' . self :: _profilerFormatMemory ( min ( $ memoryDeltas ) ) ; $ totalInfo [ ] = '- Usage on peak: ' . $ this -> _formatSize ( $ memoryPeak ) . ' (' . $ memoryPeak . ')' ; $ totalInfo [ ] = '- Total delta: ' . self :: _profilerFormatMemory ( $ last [ 'memory' ] - $ first [ 'memory' ] ) ; $ totalInfo [ ] = '- Limit: ' . ini_get ( 'memory_limit' ) ; if ( self :: isAjax ( ) ) { $ this -> _dumpRenderLog ( $ totalInfo , 'Profiler total' ) ; } else { $ totalInfo = PHP_EOL . "\t" . implode ( PHP_EOL . "\t" , $ totalInfo ) . PHP_EOL ; $ this -> _dumpRenderLite ( $ totalInfo , '! <b>profiler total info</b> !' ) ; } }
Profiler render - total info
19,875
protected function _profilerRenderFile ( ) { $ this -> log ( '-------------------------------------------------------' , 'Profiler start' ) ; foreach ( $ this -> _bufferInfo as $ key => $ mark ) { $ this -> log ( self :: _profilerFormatMark ( $ mark ) ) ; } $ this -> log ( '-------------------------------------------------------' , 'Profiler end' ) ; }
Profile render - to log file
19,876
protected function _profilerRenderEcho ( ) { $ output = PHP_EOL ; foreach ( $ this -> _bufferInfo as $ key => $ mark ) { $ output .= "\t" . self :: _profilerFormatMark ( $ mark ) . PHP_EOL ; } $ this -> _dumpRenderLite ( $ output , '! profiler !' ) ; }
Profile render - echo lite
19,877
protected function _dumpRenderHtml ( $ data , $ varname = '...' , $ params = array ( ) ) { $ this -> _currentDepth = 0 ; $ this -> _initAssets ( ) ; if ( isset ( $ params [ 'trace' ] ) ) { $ this -> _trace = $ params [ 'trace' ] ; } else { $ this -> _trace = debug_backtrace ( ) ; } $ text = $ this -> _getSourceFunction ( $ this -> _trace ) ; $ path = $ this -> _getSourcePath ( $ this -> _trace ) ; ?> <div id="jbdump"> <ul class="jbnode"> <?php $ this -> _dump ( $ data , $ varname ) ; ?> <li class="jbfooter"> <div class="jbversion"> <a href=" <?php echo $ this -> _site ; ?> " target="_blank">JBDump v <?php echo self :: VERSION ; ?> </a> </div> <?php if ( self :: $ _config [ 'showCall' ] ) : ?> <div class="jbpath"> <?php echo $ text . ' ' . $ path ; ?> </div> <?php endif ; ?> </li> </ul> </div> <?php }
Dump render - HTML
19,878
protected function _dumpRenderLite ( $ data , $ varname = '...' , $ params = array ( ) ) { if ( is_bool ( $ data ) ) { $ data = $ data ? 'TRUE' : 'FALSE' ; } elseif ( is_null ( $ data ) ) { $ data = 'NULL' ; } if ( is_string ( $ data ) && strlen ( $ data ) == 0 ) { $ printrOut = '""' ; } else { $ printrOut = print_r ( $ data , true ) ; } if ( ! self :: isCli ( ) ) { $ printrOut = $ this -> _htmlChars ( $ printrOut ) ; } if ( self :: isAjax ( ) ) { $ printrOut = str_replace ( '] =&gt;' , '] =>' , $ printrOut ) ; } $ output = array ( ) ; if ( ! self :: isCli ( ) ) { $ output [ ] = '<pre>------------------------------' . PHP_EOL ; } $ output [ ] = $ varname . ' = ' ; $ output [ ] = rtrim ( $ printrOut , PHP_EOL ) ; if ( ! self :: isCli ( ) ) { $ output [ ] = PHP_EOL . '------------------------------</pre>' . PHP_EOL ; } else { $ output [ ] = PHP_EOL ; } if ( ! self :: isAjax ( ) ) { echo '<pre class="jbdump" style="text-align: left;">' . implode ( '' , $ output ) . '</pre>' . PHP_EOL ; } else { echo implode ( '' , $ output ) ; } }
Dump render - Lite mode
19,879
public static function hash ( $ data ) { $ result = array ( ) ; foreach ( hash_algos ( ) as $ algoritm ) { $ result [ $ algoritm ] = hash ( $ algoritm , $ data , false ) ; } return self :: i ( ) -> dump ( $ result , '! hash !' ) ; }
Get all available hash from data
19,880
protected static function _getMemory ( ) { if ( function_exists ( 'memory_get_usage' ) ) { return memory_get_usage ( ) ; } else { $ output = array ( ) ; $ pid = getmypid ( ) ; if ( substr ( PHP_OS , 0 , 3 ) == 'WIN' ) { @ exec ( 'tasklist /FI "PID eq ' . $ pid . '" /FO LIST' , $ output ) ; if ( ! isset ( $ output [ 5 ] ) ) { $ output [ 5 ] = null ; } return ( int ) substr ( $ output [ 5 ] , strpos ( $ output [ 5 ] , ':' ) + 1 ) ; } else { @ exec ( "ps -o rss -p $pid" , $ output ) ; return $ output [ 1 ] * 1024 ; } } }
Get current usage memory
19,881
protected function _dump ( $ data , $ name = '...' ) { $ varType = strtolower ( getType ( $ data ) ) ; $ advType = false ; if ( $ varType == 'string' && preg_match ( '#(.*)::(.*)#' , $ name , $ matches ) ) { $ matches [ 2 ] = trim ( strToLower ( $ matches [ 2 ] ) ) ; if ( $ this -> _strlen ( $ matches [ 2 ] ) > 0 ) { $ advType = $ matches [ 2 ] ; } $ name = $ matches [ 1 ] ; } if ( $ this -> _strlen ( $ name ) > 80 ) { $ name = substr ( $ name , 0 , 80 ) . '...' ; } if ( $ varType == 'null' ) { $ this -> _null ( $ name ) ; } elseif ( $ varType == 'boolean' ) { $ this -> _boolean ( $ data , $ name , $ advType ) ; } elseif ( $ varType == 'integer' ) { $ this -> _integer ( $ data , $ name , $ advType ) ; } elseif ( $ varType == 'double' ) { $ this -> _float ( $ data , $ name , $ advType ) ; } elseif ( $ varType == 'string' ) { $ this -> _string ( $ data , $ name , $ advType ) ; } elseif ( $ varType == 'array' ) { if ( $ this -> _currentDepth <= self :: $ _config [ 'dump' ] [ 'maxDepth' ] ) { $ this -> _currentDepth ++ ; $ this -> _array ( $ data , $ name , $ advType ) ; $ this -> _currentDepth -- ; } else { $ this -> _maxDepth ( $ data , $ name , $ advType ) ; } } elseif ( $ varType == 'object' ) { if ( $ this -> _currentDepth <= self :: $ _config [ 'dump' ] [ 'maxDepth' ] ) { $ this -> _currentDepth ++ ; if ( get_class ( $ data ) == 'Closure' ) { $ this -> _closure ( $ data , $ name , $ advType ) ; } else { $ this -> _object ( $ data , $ name , $ advType ) ; } $ this -> _currentDepth -- ; } else { $ this -> _maxDepth ( $ data , $ name ) ; } } elseif ( $ varType == 'resource' ) { $ this -> _resource ( $ data , $ name , $ advType ) ; } else { $ this -> _undefined ( $ data , $ name , $ advType ) ; } return $ this ; }
Maps type variable to a function
19,882
protected function _vars ( $ data , $ isExpanded = false ) { $ _is_object = is_object ( $ data ) ; ?> <div class="jbnest" style=" <?php echo $ isExpanded ? 'display:block' : 'display:none' ; ?> "> <ul class="jbnode"> <?php $ keys = ( $ _is_object ) ? array_keys ( @ get_object_vars ( $ data ) ) : array_keys ( $ data ) ; if ( self :: $ _config [ 'sort' ] [ 'object' ] && $ _is_object ) { sort ( $ keys ) ; } elseif ( self :: $ _config [ 'sort' ] [ 'array' ] ) { sort ( $ keys ) ; } foreach ( $ keys as $ key ) { $ value = null ; if ( $ _is_object && property_exists ( $ data , $ key ) ) { $ value = $ data -> $ key ; } else { if ( is_array ( $ data ) && array_key_exists ( $ key , $ data ) ) { $ value = $ data [ $ key ] ; } } $ this -> _dump ( $ value , $ key ) ; } if ( $ _is_object && self :: $ _config [ 'dump' ] [ 'showMethods' ] ) { if ( $ methods = $ this -> _getMethods ( $ data ) ) { $ this -> _dump ( $ methods , '&lt;! methods of "' . get_class ( $ data ) . '" !&gt;' ) ; } } ?> </ul> </div> <?php }
Render HTML for object and array
19,883
protected function _resource ( $ data , $ name ) { $ data = get_resource_type ( $ data ) ; $ this -> _renderNode ( 'Resource' , $ name , $ data ) ; }
Render HTML for resource type
19,884
protected function _strlen ( $ string ) { $ encoding = function_exists ( 'mb_detect_encoding' ) ? mb_detect_encoding ( $ string ) : false ; return $ encoding ? mb_strlen ( $ string , $ encoding ) : strlen ( $ string ) ; }
Get valid string length
19,885
protected function _string ( $ data , $ name , $ advType = '' ) { $ dataLength = $ this -> _strlen ( $ data ) ; $ _extra = false ; if ( $ advType == 'html' ) { $ _extra = true ; $ _ = 'HTML Code' ; $ data = '<pre class="jbpreview">' . $ data . '</pre>' ; } elseif ( $ advType == 'source' ) { $ data = trim ( $ data ) ; if ( $ data && strpos ( $ data , '<?' ) !== 0 ) { $ _ = 'PHP Code' ; $ _extra = true ; $ data = "<?php" . PHP_EOL . PHP_EOL . $ data ; $ data = '<pre class="jbpreview">' . highlight_string ( $ data , true ) . '</pre>' ; } else { $ _ = '// code not found' ; $ data = null ; } } else { $ _ = $ data ; if ( ! ( strpos ( $ data , "\r" ) === false && strpos ( $ data , "\n" ) === false && strpos ( $ data , " " ) === false && strpos ( $ data , "\t" ) === false ) ) { $ _extra = true ; } else { $ _extra = false ; } if ( $ this -> _strlen ( $ data ) ) { if ( $ this -> _strlen ( $ data ) > self :: $ _config [ 'dump' ] [ 'stringLength' ] ) { if ( function_exists ( 'mb_substr' ) ) { $ _ = mb_substr ( $ data , 0 , self :: $ _config [ 'dump' ] [ 'stringLength' ] - 3 ) . '...' ; } else { $ _ = substr ( $ data , 0 , self :: $ _config [ 'dump' ] [ 'stringLength' ] - 3 ) . '...' ; } $ _extra = true ; } $ _ = $ this -> _htmlChars ( $ _ ) ; $ data = '<textarea readonly="readonly" class="jbpreview">' . $ this -> _htmlChars ( $ data ) . '</textarea>' ; } } ?> <li class="jbchild"> <div class="jbelement <?php echo $ _extra ? ' jbexpand' : '' ; ?> " <?php if ( $ _extra ) { ?> onClick="jbdump.toggle(this);" <?php } ?> > <span class="jbname"> <?php echo $ name ; ?> </span> (<span class="jbtype jbtype-string">String</span>, <?php echo $ dataLength ; ?> ) <span class="jbvalue"> <?php echo $ _ ; ?> </span> </div> <?php if ( $ _extra ) { ?> <div class="jbnest" style="display:none;"> <ul class="jbnode"> <li class="jbchild"> <?php echo $ data ; ?> </li> </ul> </div> <?php } ?> </li> <?php }
Render HTML for string type
19,886
protected function _array ( array $ data , $ name ) { $ isExpanded = $ this -> _isExpandedLevel ( ) ; if ( 0 === strpos ( $ name , '&lt;! methods of "' ) ) { $ isExpanded = false ; } ?> <li class="jbchild"> <div class="jbelement <?php echo count ( ( array ) $ data ) > 0 ? ' jbexpand' : '' ; ?> <?= $ isExpanded ? 'jbopened' : '' ; ?> " <?php if ( count ( ( array ) $ data ) > 0 ) { ?> onClick="jbdump.toggle(this);" <?php } ?> > <span class="jbname"> <?php echo $ name ; ?> </span> (<span class="jbtype jbtype-array">Array</span>, <?php echo count ( ( array ) $ data ) ; ?> ) </div> <?php if ( count ( ( array ) $ data ) ) { $ this -> _vars ( $ data , $ isExpanded ) ; } ?> </li> <?php }
Render HTML for array type
19,887
protected function _object ( $ data , $ name ) { static $ objectIdList = array ( ) ; $ objectId = spl_object_hash ( $ data ) ; if ( ! isset ( $ objectIdList [ $ objectId ] ) ) { $ objectIdList [ $ objectId ] = count ( $ objectIdList ) ; } $ count = count ( @ get_object_vars ( $ data ) ) ; $ isExpand = $ count > 0 || self :: $ _config [ 'dump' ] [ 'showMethods' ] ; $ isExpanded = $ this -> _isExpandedLevel ( ) ; ?> <li class="jbchild"> <div class="jbelement <?php echo $ isExpand ? ' jbexpand' : '' ; ?> <?= $ isExpanded ? 'jbopened' : '' ; ?> " <?php if ( $ isExpand ) { ?> onClick="jbdump.toggle(this);" <?php } ?> > <span class="jbname" title="splHash= <?php echo $ objectId ; ?> "> <?php echo $ name ; ?> </span> ( <span class="jbtype jbtype-object"> <?php echo get_class ( $ data ) ; ?> </span> <span style="text-decoration: underline;" title="splHash= <?php echo $ objectId ; ?> ">id: <?php echo $ objectIdList [ $ objectId ] ; ?> </span>, l: <?php echo $ count ; ?> ) </div> <?php if ( $ isExpand ) { $ this -> _vars ( $ data , $ isExpanded ) ; } ?> <?php }
Render HTML for object type
19,888
protected function _closure ( $ data , $ name ) { $ isExpanded = $ this -> _isExpandedLevel ( ) ; ?> <li class="jbchild"> <div class="jbelement <?php echo count ( ( array ) $ data ) > 0 ? ' jbexpand' : '' ; ?> <?= $ isExpanded ? 'jbopened' : '' ; ?> " <?php if ( count ( ( array ) $ data ) > 0 ) { ?> onClick="jbdump.toggle(this);" <?php } ?> > <span class="jbname"> <?php echo $ name ; ?> </span> (<span class="jbtype jbtype-closure">Closure</span>) <span class="jbvalue"> <?php echo get_class ( $ data ) ; ?> </span> </div> <?php $ this -> _vars ( $ this -> _getFunction ( $ data ) , $ isExpanded ) ; ?> </li> <?php }
Render HTML for closure type
19,889
protected function _renderNode ( $ type , $ name , $ data ) { $ typeAlias = str_replace ( ' ' , '-' , strtolower ( $ type ) ) ; ?> <li class="jbchild"> <div class="jbelement"> <span class="jbname"> <?php echo $ name ; ?> </span> (<span class="jbtype jbtype- <?php echo $ typeAlias ; ?> "> <?php echo $ type ; ?> </span>) <span class="jbvalue"> <?php echo $ data ; ?> </span> </div> </li> <?php }
Render HTML for undefined variable
19,890
public static function getClientIP ( $ getSource = false ) { if ( ! empty ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) ) { $ ip = $ _SERVER [ 'HTTP_CLIENT_IP' ] ; $ source = 'HTTP_CLIENT_IP' ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_X_REAL_IP' ] ) ) { $ ip = $ _SERVER [ 'HTTP_X_REAL_IP' ] ; $ source = 'HTTP_X_REAL_IP' ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { $ ip = $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; $ source = 'HTTP_X_FORWARDED_FOR' ; } elseif ( ! empty ( $ _SERVER [ 'REMOTE_ADDR' ] ) ) { $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ; $ source = 'REMOTE_ADDR' ; } else { $ ip = '0.0.0.0' ; $ source = 'undefined' ; } if ( $ getSource ) { return $ source ; } else { return $ ip ; } }
Get the IP number of differnt ways
19,891
protected function _getRalativePath ( $ path ) { if ( $ path ) { $ rootPath = str_replace ( array ( '/' , '\\' ) , '/' , self :: $ _config [ 'root' ] ) ; $ path = str_replace ( array ( '/' , '\\' ) , '/' , $ path ) ; $ path = str_replace ( $ rootPath , '/' , $ path ) ; $ path = str_replace ( '//' , '/' , $ path ) ; $ path = trim ( $ path , '/' ) ; } return $ path ; }
Get relative path from absolute
19,892
protected function _getOneTrace ( $ info , $ addObject = false ) { $ _this = self :: i ( ) ; $ _tmp = array ( ) ; if ( isset ( $ info [ 'file' ] ) ) { $ _tmp [ 'file' ] = $ _this -> _getRalativePath ( $ info [ 'file' ] ) . ' : ' . $ info [ 'line' ] ; } else { $ info [ 'file' ] = false ; } if ( $ info [ 'function' ] != 'include' && $ info [ 'function' ] != 'include_once' && $ info [ 'function' ] != 'require' && $ info [ 'function' ] != 'require_once' ) { if ( isset ( $ info [ 'type' ] ) && isset ( $ info [ 'class' ] ) ) { $ _tmp [ 'func' ] = $ info [ 'class' ] . ' ' . $ info [ 'type' ] . ' ' . $ info [ 'function' ] . '()' ; } else { $ _tmp [ 'func' ] = $ info [ 'function' ] . '()' ; } $ args = isset ( $ info [ 'args' ] ) ? $ info [ 'args' ] : array ( ) ; if ( self :: $ _config [ 'showArgs' ] || $ addObject ) { $ _tmp [ 'args' ] = isset ( $ info [ 'args' ] ) ? $ info [ 'args' ] : array ( ) ; } else { $ _tmp [ 'count_args' ] = count ( $ args ) ; } } else { $ _tmp [ 'func' ] = $ info [ 'function' ] ; } if ( isset ( $ info [ 'object' ] ) && ( self :: $ _config [ 'showArgs' ] || $ addObject ) ) { $ _tmp [ 'obj' ] = $ info [ 'object' ] ; } return $ _tmp ; }
Get formated one trace info
19,893
protected static function _formatSize ( $ bytes ) { $ exp = 0 ; $ value = 0 ; $ symbol = array ( 'B' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ) ; if ( $ bytes > 0 ) { $ exp = floor ( log ( $ bytes ) / log ( 1024 ) ) ; $ value = ( $ bytes / pow ( 1024 , floor ( $ exp ) ) ) ; } return sprintf ( '%.2f ' . $ symbol [ $ exp ] , $ value ) ; }
Convert filesize to formated string
19,894
protected function _getSourceFunction ( $ trace ) { $ lastTrace = $ this -> _getLastTrace ( $ trace ) ; if ( isset ( $ lastTrace [ 'function' ] ) || isset ( $ lastTrace [ 'class' ] ) ) { $ args = '' ; if ( isset ( $ lastTrace [ 'args' ] ) ) { $ args = '( ' . count ( $ lastTrace [ 'args' ] ) . ' args' . ' )' ; } if ( isset ( $ lastTrace [ 'class' ] ) ) { $ function = $ lastTrace [ 'class' ] . ' ' . $ lastTrace [ 'type' ] . ' ' . $ lastTrace [ 'function' ] . ' ' . $ args ; } else { $ function = $ lastTrace [ 'function' ] . ' ' . $ args ; } return 'Function: ' . $ function . '<br />' ; } return '' ; }
Get last function name and it params from backtrace
19,895
protected function _getSourcePath ( $ trace , $ fileOnly = false ) { $ path = '' ; $ currentTrace = $ this -> _getLastTrace ( $ trace ) ; if ( isset ( $ currentTrace [ 'file' ] ) ) { $ path = $ this -> _getRalativePath ( $ currentTrace [ 'file' ] ) ; if ( $ fileOnly && $ path ) { $ path = pathinfo ( $ path , PATHINFO_BASENAME ) ; } if ( isset ( $ currentTrace [ 'line' ] ) && $ path ) { $ path = $ path . ':' . $ currentTrace [ 'line' ] ; } } if ( ! $ path ) { $ path = 'undefined:0' ; } return $ path ; }
Get last source path from backtrace
19,896
protected function _getLastTrace ( $ trace ) { $ curFile = pathinfo ( __FILE__ , PATHINFO_BASENAME ) ; $ curFileLength = $ this -> _strlen ( $ curFile ) ; $ meta = array ( ) ; $ j = 0 ; for ( $ i = 0 ; $ trace && $ i < sizeof ( $ trace ) ; $ i ++ ) { $ j = $ i ; if ( isset ( $ trace [ $ i ] [ 'class' ] ) && isset ( $ trace [ $ i ] [ 'file' ] ) && ( $ trace [ $ i ] [ 'class' ] == 'JBDump' ) && ( substr ( $ trace [ $ i ] [ 'file' ] , - $ curFileLength , $ curFileLength ) == $ curFile ) ) { } elseif ( isset ( $ trace [ $ i ] [ 'class' ] ) && isset ( $ trace [ $ i + 1 ] [ 'file' ] ) && isset ( $ trace [ $ i ] [ 'file' ] ) && $ trace [ $ i ] [ 'class' ] == 'JBDump' && ( substr ( $ trace [ $ i ] [ 'file' ] , - $ curFileLength , $ curFileLength ) == $ curFile ) ) { } elseif ( isset ( $ trace [ $ i ] [ 'file' ] ) && ( substr ( $ trace [ $ i ] [ 'file' ] , - $ curFileLength , $ curFileLength ) == $ curFile ) ) { } else { $ meta [ 'file' ] = isset ( $ trace [ $ i ] [ 'file' ] ) ? $ trace [ $ i ] [ 'file' ] : '' ; $ meta [ 'line' ] = isset ( $ trace [ $ i ] [ 'line' ] ) ? $ trace [ $ i ] [ 'line' ] : '' ; break ; } } if ( isset ( $ trace [ $ j + 1 ] ) ) { $ result = $ trace [ $ j + 1 ] ; $ result [ 'line' ] = $ meta [ 'line' ] ; $ result [ 'file' ] = $ meta [ 'file' ] ; } else { $ result = $ meta ; } return $ result ; }
Get Last trace info
19,897
protected function _getMethods ( $ object ) { if ( is_string ( $ object ) ) { $ className = $ object ; } else { $ className = get_class ( $ object ) ; } $ methods = get_class_methods ( $ className ) ; if ( self :: $ _config [ 'sort' ] [ 'methods' ] ) { sort ( $ methods ) ; } return $ methods ; }
Get object methods
19,898
public function convertTrace ( $ trace , $ addObject = false ) { $ result = array ( ) ; if ( is_array ( $ trace ) ) { foreach ( $ trace as $ key => $ info ) { $ oneTrace = self :: i ( ) -> _getOneTrace ( $ info , $ addObject ) ; $ file = 'undefined' ; if ( isset ( $ oneTrace [ 'file' ] ) ) { $ file = $ oneTrace [ 'file' ] ; } $ result [ '#' . ( $ key - 1 ) . ' ' . $ oneTrace [ 'func' ] ] = $ file ; } } return $ result ; }
Convert trace information to readable
19,899
protected static function _getErrorTypes ( ) { $ errType = array ( E_ERROR => 'Error' , E_WARNING => 'Warning' , E_PARSE => 'Parsing Error' , E_NOTICE => 'Notice' , E_CORE_ERROR => 'Core Error' , E_CORE_WARNING => 'Core Warning' , E_COMPILE_ERROR => 'Compile Error' , E_COMPILE_WARNING => 'Compile Warning' , E_USER_ERROR => 'User Error' , E_USER_WARNING => 'User Warning' , E_USER_NOTICE => 'User Notice' , E_STRICT => 'Runtime Notice' , E_RECOVERABLE_ERROR => 'Catchable Fatal Error' , ) ; if ( defined ( 'E_DEPRECATED' ) ) { $ errType [ E_DEPRECATED ] = 'Deprecated' ; $ errType [ E_USER_DEPRECATED ] = 'User Deprecated' ; } $ errType [ E_ALL ] = 'All errors' ; return $ errType ; }
Get PHP error types