idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
19,900
function _errorHandler ( $ errNo , $ errMsg , $ errFile , $ errLine , $ errCont ) { $ errType = $ this -> _getErrorTypes ( ) ; $ errorMessage = $ errType [ $ errNo ] . "\t\"" . trim ( $ errMsg ) . "\"\t" . $ errFile . ' ' . 'Line:' . $ errLine ; if ( self :: $ _config [ 'errors' ] [ 'logAll' ] ) { error_log ( 'JBDump:' . $ errorMessage ) ; } if ( ! ( error_reporting ( ) & $ errNo ) || error_reporting ( ) == 0 || ( int ) ini_get ( 'display_errors' ) == 0 ) { if ( self :: $ _config [ 'errors' ] [ 'logHidden' ] ) { $ errorMessage = date ( self :: DATE_FORMAT , time ( ) ) . ' ' . $ errorMessage . PHP_EOL ; $ logPath = self :: $ _config [ 'log' ] [ 'path' ] . '/' . self :: $ _config [ 'log' ] [ 'file' ] . '_error_' . date ( 'Y.m.d' ) . '.log' ; error_log ( $ errorMessage , 3 , $ logPath ) ; } return false ; } $ errFile = $ this -> _getRalativePath ( $ errFile ) ; $ result = array ( 'file' => $ errFile . ' : ' . $ errLine , 'type' => $ errType [ $ errNo ] . ' (' . $ errNo . ')' , 'message' => $ errMsg , ) ; if ( self :: $ _config [ 'errors' ] [ 'context' ] ) { $ result [ 'context' ] = $ errCont ; } if ( self :: $ _config [ 'errors' ] [ 'errorBacktrace' ] ) { $ trace = debug_backtrace ( ) ; unset ( $ trace [ 0 ] ) ; $ result [ 'backtrace' ] = $ this -> convertTrace ( $ trace ) ; } if ( $ this -> _isLiteMode ( ) ) { $ errorInfo = array ( 'message' => $ result [ 'type' ] . ' / ' . $ result [ 'message' ] , 'file' => $ result [ 'file' ] ) ; $ this -> _dumpRenderLite ( $ errorInfo , '* ' . $ errType [ $ errNo ] ) ; } else { $ desc = '<b style="color:red;">*</b> ' . $ errType [ $ errNo ] . ' / ' . $ this -> _htmlChars ( $ result [ 'message' ] ) ; $ this -> dump ( $ result , $ desc ) ; } return true ; }
Error handler for PHP errors
19,901
public static function errors ( ) { $ result = array ( ) ; $ result [ 'error_reporting' ] = error_reporting ( ) ; $ errTypes = self :: _getErrorTypes ( ) ; foreach ( $ errTypes as $ errTypeKey => $ errTypeName ) { if ( $ result [ 'error_reporting' ] & $ errTypeKey ) { $ result [ 'show_types' ] [ ] = $ errTypeName . ' (' . $ errTypeKey . ')' ; } } return self :: i ( ) -> dump ( $ result , '! errors info !' ) ; }
Information about current PHP reporting
19,902
public static function isAjax ( ) { if ( isset ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) == 'xmlhttprequest' ) { return true ; } elseif ( self :: isCli ( ) ) { return true ; } elseif ( function_exists ( 'apache_request_headers' ) ) { $ headers = apache_request_headers ( ) ; foreach ( $ headers as $ key => $ value ) { if ( strtolower ( $ key ) == 'x-requested-with' && strtolower ( $ value ) == 'xmlhttprequest' ) { return true ; } } } elseif ( isset ( $ _REQUEST [ 'ajax' ] ) && $ _REQUEST [ 'ajax' ] ) { return true ; } elseif ( isset ( $ _REQUEST [ 'AJAX' ] ) && $ _REQUEST [ 'AJAX' ] ) { return true ; } return false ; }
Check is current HTTP request is ajax
19,903
public static function mail ( $ text , $ subject = null , $ to = null ) { if ( ! self :: isDebug ( ) ) { return false ; } $ _this = self :: i ( ) ; if ( empty ( $ subject ) ) { $ subject = self :: $ _config [ 'mail' ] [ 'subject' ] ; } if ( empty ( $ to ) ) { $ to = isset ( self :: $ _config [ 'mail' ] [ 'to' ] ) ? self :: $ _config [ 'mail' ] [ 'to' ] : 'jbdump@' . $ _SERVER [ 'HTTP_HOST' ] ; } if ( is_array ( $ to ) ) { $ to = implode ( ', ' , $ to ) ; } $ message = array ( ) ; $ message [ ] = '<html><body>' ; $ message [ ] = '<p><b>JBDump mail from ' . '<a href="http://' . $ _SERVER [ 'HTTP_HOST' ] . '">' . $ _SERVER [ 'HTTP_HOST' ] . '</a>' . '</b></p>' ; $ message [ ] = '<p><b>Date</b>: ' . date ( DATE_RFC822 , time ( ) ) . '</p>' ; $ message [ ] = '<p><b>IP</b>: ' . self :: getClientIP ( ) . '</p>' ; $ message [ ] = '<b>Debug message</b>: <pre>' . print_r ( $ text , true ) . '</pre>' ; $ message [ ] = '</body></html>' ; $ message = wordwrap ( implode ( PHP_EOL , $ message ) , 70 ) ; $ headers = array ( ) ; $ headers [ ] = 'MIME-Version: 1.0' ; $ headers [ ] = 'Content-type: text/html; charset=utf-8' ; $ headers [ ] = 'To: ' . $ to ; $ headers [ ] = 'From: JBDump debug <jbdump@' . $ _SERVER [ 'HTTP_HOST' ] . '>' ; $ headers [ ] = 'X-Mailer: JBDump v' . self :: VERSION ; $ headers = implode ( "\r\n" , $ headers ) ; $ result = mail ( $ to , $ subject , $ message , $ headers ) ; if ( self :: $ _config [ 'mail' ] [ 'log' ] ) { $ _this -> log ( array ( 'email' => $ to , 'subject' => $ subject , 'message' => $ message , 'headers' => $ headers , 'result' => $ result ) , 'JBDump::mail' ) ; } return $ result ; }
Send message mail
19,904
public static function sql ( $ query , $ sqlName = 'SQL Query' , $ nl2br = false ) { if ( defined ( '_JEXEC' ) ) { $ config = new JConfig ( ) ; $ prefix = $ config -> dbprefix ; $ query = str_replace ( '#__' , $ prefix , $ query ) ; } if ( class_exists ( 'JBDump_SqlFormatter' ) ) { $ sqlHtml = JBDump_SqlFormatter :: format ( $ query ) ; return self :: i ( ) -> dump ( $ sqlHtml , $ sqlName . '::html' ) ; } return self :: i ( ) -> dump ( $ query , $ sqlName . '::html' ) ; }
Highlight SQL query
19,905
protected function _jsonEncode ( $ in , $ indent = 0 ) { $ out = '' ; foreach ( $ in as $ key => $ value ) { $ out .= str_repeat ( " " , $ indent + 1 ) ; $ out .= json_encode ( ( string ) $ key ) . ': ' ; if ( is_object ( $ value ) || is_array ( $ value ) ) { $ out .= $ this -> _jsonEncode ( $ value , $ indent + 1 ) ; } else { $ out .= json_encode ( $ value ) ; } $ out .= "," . PHP_EOL ; } if ( ! empty ( $ out ) ) { $ out = substr ( $ out , 0 , - 2 ) ; } $ out = "{" . PHP_EOL . $ out . PHP_EOL . str_repeat ( " " , $ indent ) . "}" ; return $ out ; }
Do the real json encoding adding human readability . Supports automatic indenting with tabs
19,906
protected function process ( array $ stmts ) { $ this -> msg ( 'Adding "vatid" column to fe_users tables' , 0 ) ; $ this -> status ( '' ) ; foreach ( $ stmts as $ table => $ stmt ) { $ this -> msg ( sprintf ( 'Checking "%1$s" table' , $ table ) , 1 ) ; if ( $ this -> schema -> tableExists ( $ table ) === true && $ this -> schema -> columnExists ( $ table , 'vatid' ) === false ) { $ this -> execute ( $ stmt ) ; $ this -> status ( 'added' ) ; } else { $ this -> status ( 'OK' ) ; } } }
Add column vatid to fe_users tables .
19,907
public static function getJson ( $ file , $ assoc = true ) { if ( ! extension_loaded ( 'json' ) ) { throw new \ Exception ( 'The JSON extension is not loaded.' ) ; } if ( ! file_exists ( $ file ) ) { throw new \ InvalidArgumentException ( htmlspecialchars ( "The $file file is missing." ) ) ; } if ( strrchr ( $ file , '.' ) != '.json' ) { throw new \ InvalidArgumentException ( htmlspecialchars ( "The $file is not in JSON format." ) ) ; } if ( ( $ json = file_get_contents ( $ file ) ) === null ) { throw new \ Exception ( htmlspecialchars ( "The $file file is not readable." ) ) ; } if ( ( $ return = json_decode ( $ json , $ assoc ) ) === null ) { throw new \ Exception ( htmlspecialchars ( "The JSON $file file is invalid." ) ) ; } return $ return ; }
Lit un fichier de type JSON et retourne un tableau associatif .
19,908
public function link ( $ destination , array $ params = array ( ) ) { if ( ( $ pos = strrpos ( $ destination , '#' ) ) !== FALSE ) { $ fragment = substr ( $ destination , $ pos ) ; $ destination = substr ( $ destination , 0 , $ pos ) ; } else { $ fragment = '' ; } if ( strncmp ( $ destination , '//' , 2 ) === 0 ) { $ absoluteUrl = TRUE ; $ destination = substr ( $ destination , 2 ) ; } else { $ absoluteUrl = FALSE ; } $ pos = strrpos ( $ destination , ':' ) ; $ presenter = substr ( $ destination , 0 , $ pos ) ; if ( $ pos + 1 < strlen ( $ destination ) ) { $ params [ 'action' ] = substr ( $ destination , $ pos + 1 ) ; } $ request = new Nette \ Application \ Request ( $ presenter , 'GET' , $ params ) ; $ url = $ this -> router -> constructUrl ( $ request , $ this -> refUrl ) ; if ( $ url === NULL ) { throw new InvalidLinkException ( "Router failed to create link to '$destination'." ) ; } if ( ! $ absoluteUrl && strncmp ( $ url , $ this -> refUrlHost , strlen ( $ this -> refUrlHost ) ) === 0 ) { $ url = substr ( $ url , strlen ( $ this -> refUrlHost ) ) ; } if ( $ fragment ) { $ url .= $ fragment ; } return $ url ; }
Creates link .
19,909
protected function generateRequestHeaders ( $ verb , $ resourceType , $ resourceId , $ isQuery = false , $ contentLength = 0 , array $ extraHeaders = [ ] ) { $ xMsDate = gmdate ( 'D, d M Y H:i:s T' ) ; $ headers = [ 'Accept: application/json' , 'User-Agent: ' . static :: USER_AGENT , 'Cache-Control: no-cache' , 'x-ms-date: ' . $ xMsDate , 'x-ms-version: ' . $ this -> apiVersion , 'Authorization: ' . $ this -> generateAuthHeader ( $ verb , $ xMsDate , $ resourceType , $ resourceId ) ] ; if ( in_array ( $ verb , [ Verbs :: POST , Verbs :: PUT ] ) ) { $ headers [ ] = 'Content-Length: ' . $ contentLength ; if ( $ isQuery === true ) { $ headers [ ] = 'Content-Type: application/query+json' ; $ headers [ ] = 'x-ms-documentdb-isquery: True' ; } else { $ headers [ ] = 'Content-Type: application/json' ; } } return array_merge ( $ headers , $ extraHeaders ) ; }
Generates request headers based on request options .
19,910
private function generateAuthHeader ( $ verb , $ xMsDate , $ resourceType , $ resourceId ) { $ master = 'master' ; $ token = '1.0' ; $ key = base64_decode ( $ this -> key ) ; $ stringToSign = strtolower ( $ verb ) . "\n" . strtolower ( $ resourceType ) . "\n" . $ resourceId . "\n" . strtolower ( $ xMsDate ) . "\n" . "\n" ; $ sig = base64_encode ( hash_hmac ( 'sha256' , $ stringToSign , $ key , true ) ) ; return urlencode ( "type=$master&ver=$token&sig=$sig" ) ; }
Generates the request Authorization header .
19,911
public function getParent ( $ id ) { $ dataItem = $ this -> get ( $ id ) ; $ queryBuilder = $ this -> driver -> getSelectQueryBuilder ( ) ; $ queryBuilder -> andWhere ( $ this -> driver -> getUniqueId ( ) . " = " . $ dataItem -> getAttribute ( $ this -> getParentField ( ) ) ) ; $ statement = $ queryBuilder -> execute ( ) ; $ rows = array ( $ statement -> fetch ( ) ) ; $ hasResults = count ( $ rows ) > 0 ; $ parent = null ; if ( $ hasResults ) { $ this -> driver -> prepareResults ( $ rows ) ; $ parent = $ rows [ 0 ] ; } return $ parent ; }
Get parent by child ID
19,912
public function save ( $ item , $ autoUpdate = true ) { $ result = null ; $ this -> allowSave = true ; if ( isset ( $ this -> events [ self :: EVENT_ON_BEFORE_SAVE ] ) ) { $ this -> secureEval ( $ this -> events [ self :: EVENT_ON_BEFORE_SAVE ] , array ( 'item' => & $ item ) ) ; } if ( $ this -> allowSave ) { $ result = $ this -> getDriver ( ) -> save ( $ item , $ autoUpdate ) ; } if ( isset ( $ this -> events [ self :: EVENT_ON_AFTER_SAVE ] ) ) { $ this -> secureEval ( $ this -> events [ self :: EVENT_ON_AFTER_SAVE ] , array ( 'item' => & $ item ) ) ; } return $ result ; }
Save data item
19,913
public function isOracle ( ) { static $ r ; if ( is_null ( $ r ) ) { $ r = $ this -> driver -> getPlatformName ( ) == self :: ORACLE_PLATFORM ; } return $ r ; }
Is oralce platform
19,914
public function isSqlite ( ) { static $ r ; if ( is_null ( $ r ) ) { $ r = $ this -> driver -> getPlatformName ( ) == self :: SQLITE_PLATFORM ; } return $ r ; }
Is SQLite platform
19,915
public function isPostgres ( ) { static $ r ; if ( is_null ( $ r ) ) { $ r = $ this -> driver -> getPlatformName ( ) == self :: POSTGRESQL_PLATFORM ; } return $ r ; }
Is postgres platform
19,916
public function getTypes ( ) { $ list = array ( ) ; $ reflectionClass = new \ ReflectionClass ( __CLASS__ ) ; foreach ( $ reflectionClass -> getConstants ( ) as $ k => $ v ) { if ( strrpos ( $ k , "_PLATFORM" ) > 0 ) { $ list [ ] = $ v ; } } return $ list ; }
Get driver types
19,917
public function getTroughMapping ( $ mappingId , $ id ) { $ config = $ this -> mapping [ $ mappingId ] ; $ dataStoreService = $ this -> container -> get ( "data.source" ) ; $ externalDataStore = $ dataStoreService -> get ( $ config [ "externalDataStore" ] ) ; $ externalDriver = $ externalDataStore -> getDriver ( ) ; $ internalFieldName = null ; $ externalFieldName = null ; if ( isset ( $ config [ 'internalId' ] ) ) { $ internalFieldName = $ config [ 'internalId' ] ; } if ( isset ( $ config [ 'externalId' ] ) ) { $ externalFieldName = $ config [ 'externalId' ] ; } if ( isset ( $ config [ 'internalFieldName' ] ) ) { $ internalFieldName = $ config [ 'internalFieldName' ] ; } if ( isset ( $ config [ 'relatedFieldName' ] ) ) { $ externalFieldName = $ config [ 'relatedFieldName' ] ; } if ( ! $ externalDriver instanceof DoctrineBaseDriver ) { throw new Exception ( 'This kind of externalDriver can\'t get relations' ) ; } $ criteria = $ this -> get ( $ id ) -> getAttribute ( $ internalFieldName ) ; return $ externalDriver -> getByCriteria ( $ criteria , $ externalFieldName ) ; }
Get related objects through mapping
19,918
public function deleteMultiple ( $ keys ) { foreach ( $ keys as $ key ) { $ this -> object -> remove ( $ this -> prefix . $ key ) ; } }
Removes the cache entries identified by the given keys .
19,919
public function deleteByTags ( array $ tags ) { foreach ( $ tags as $ tag ) { $ this -> object -> flushByTag ( $ this -> prefix . $ tag ) ; } }
Removes the cache entries identified by the given tags .
19,920
public function clear ( ) { if ( $ this -> prefix ) { $ this -> object -> flushByTag ( $ this -> prefix . 'siteid' ) ; } else { $ this -> object -> flush ( ) ; } }
Removes all entries for the current site from the cache .
19,921
public function getFile ( $ file = null , $ md5 = null ) { Splash :: log ( ) -> trace ( ) ; if ( defined ( 'SPLASH_DEBUG' ) && ! empty ( SPLASH_DEBUG ) ) { $ filePath = dirname ( __DIR__ ) . "/Resources/files/" . $ file ; if ( is_file ( $ filePath ) ) { $ file = $ this -> readFile ( $ filePath , $ md5 ) ; return is_array ( $ file ) ? $ file : false ; } $ imgPath = dirname ( __DIR__ ) . "/Resources/img/" . $ file ; if ( is_file ( $ imgPath ) ) { $ file = $ this -> readFile ( $ imgPath , $ md5 ) ; return is_array ( $ file ) ? $ file : false ; } } $ params = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; $ params -> file = $ file ; $ params -> md5 = $ md5 ; Splash :: ws ( ) -> addTask ( SPL_F_GETFILE , $ params , Splash :: trans ( "MsgSchRemoteReadFile" , ( string ) $ file ) ) ; $ response = Splash :: ws ( ) -> call ( SPL_S_FILE ) ; return Splash :: ws ( ) -> getNextResult ( $ response ) ; }
Read a file from Splash Server
19,922
public function isFile ( $ path = null , $ md5 = null ) { if ( empty ( $ path ) ) { return Splash :: log ( ) -> err ( "ErrFileFileMissing" , __FUNCTION__ ) ; } if ( empty ( dirname ( $ path ) ) ) { return Splash :: log ( ) -> err ( "ErrFileDirMissing" , __FUNCTION__ ) ; } if ( empty ( $ md5 ) ) { return Splash :: log ( ) -> err ( "ErrFileMd5Missing" , __FUNCTION__ ) ; } if ( ! is_dir ( dirname ( $ path ) ) ) { return Splash :: log ( ) -> war ( "ErrFileDirNoExists" , __FUNCTION__ , dirname ( $ path ) ) ; } if ( ! is_file ( $ path ) ) { return Splash :: log ( ) -> war ( "ErrFileNoExists" , __FUNCTION__ , $ path ) ; } if ( md5_file ( $ path ) != $ md5 ) { return Splash :: log ( ) -> war ( "ErrFileNoExists" , __FUNCTION__ , $ path ) ; } Splash :: log ( ) -> deb ( "Splash - Get File Infos : File " . $ path . " exists." ) ; $ infos = array ( ) ; $ owner = posix_getpwuid ( ( int ) fileowner ( $ path ) ) ; $ infos [ "owner" ] = $ owner [ "name" ] ; $ infos [ "readable" ] = is_readable ( $ path ) ; $ infos [ "writable" ] = is_writable ( $ path ) ; $ infos [ "mtime" ] = filemtime ( $ path ) ; $ infos [ "modified" ] = date ( "F d Y H:i:s." , ( int ) $ infos [ "mtime" ] ) ; $ infos [ "md5" ] = md5_file ( $ path ) ; $ infos [ "size" ] = filesize ( $ path ) ; return $ infos ; }
Check whether if a file exists or not
19,923
public function readFile ( $ path = null , $ md5 = null ) { if ( empty ( $ path ) ) { return Splash :: log ( ) -> err ( "ErrFileFileMissing" , __FUNCTION__ ) ; } if ( empty ( dirname ( $ path ) ) ) { return Splash :: log ( ) -> err ( "ErrFileDirMissing" , __FUNCTION__ ) ; } if ( empty ( $ md5 ) ) { return Splash :: log ( ) -> err ( "ErrFileMd5Missing" , __FUNCTION__ ) ; } if ( ! is_dir ( dirname ( $ path ) ) ) { return Splash :: log ( ) -> war ( "ErrFileDirNoExists" , __FUNCTION__ , dirname ( $ path ) ) ; } if ( ! is_file ( $ path ) || ! is_readable ( $ path ) ) { return Splash :: log ( ) -> war ( "ErrFileReadable" , __FUNCTION__ , $ path ) ; } if ( md5_file ( $ path ) != $ md5 ) { return Splash :: log ( ) -> war ( "ErrFileNoExists" , __FUNCTION__ , $ path ) ; } $ filehandle = fopen ( $ path , "rb" ) ; if ( false == $ filehandle ) { return Splash :: log ( ) -> err ( "ErrFileRead" , __FUNCTION__ , $ path ) ; } $ infos = array ( ) ; $ infos [ "filename" ] = basename ( $ path ) ; $ infos [ "raw" ] = base64_encode ( ( string ) fread ( $ filehandle , ( int ) filesize ( $ path ) ) ) ; fclose ( $ filehandle ) ; $ infos [ "md5" ] = md5_file ( $ path ) ; $ infos [ "size" ] = filesize ( $ path ) ; Splash :: log ( ) -> deb ( "MsgFileRead" , __FUNCTION__ , basename ( $ path ) ) ; return $ infos ; }
Read a file from local filesystem
19,924
public function readFileContents ( $ fileName = null ) { if ( empty ( $ fileName ) ) { return Splash :: log ( ) -> err ( "ErrFileFileMissing" ) ; } if ( ! is_file ( $ fileName ) ) { return Splash :: log ( ) -> err ( "ErrFileNoExists" , $ fileName ) ; } if ( ! is_readable ( $ fileName ) ) { return Splash :: log ( ) -> err ( "ErrFileReadable" , $ fileName ) ; } Splash :: log ( ) -> deb ( "MsgFileRead" , $ fileName ) ; return base64_encode ( ( string ) file_get_contents ( $ fileName ) ) ; }
Read a file contents from local filesystem & encode it to base64 format
19,925
public function writeFile ( $ dir = null , $ file = null , $ md5 = null , $ raw = null ) { if ( ! $ this -> isWriteValidInputs ( $ dir , $ file , $ md5 , $ raw ) ) { return false ; } $ fullpath = $ dir . $ file ; if ( ! is_dir ( ( string ) $ dir ) ) { mkdir ( ( string ) $ dir , 0775 , true ) ; } if ( ! is_dir ( ( string ) $ dir ) ) { Splash :: log ( ) -> war ( "ErrFileDirNoExists" , __FUNCTION__ , $ dir ) ; } if ( is_file ( $ fullpath ) ) { Splash :: log ( ) -> deb ( "MsgFileExists" , __FUNCTION__ , $ file ) ; if ( $ md5 === md5_file ( $ fullpath ) ) { return true ; } if ( ! is_writable ( ( string ) $ fullpath ) ) { return Splash :: log ( ) -> err ( "ErrFileWriteable" , __FUNCTION__ , $ file ) ; } } $ filehandle = fopen ( $ fullpath , 'w' ) ; if ( false == $ filehandle ) { return Splash :: log ( ) -> war ( "ErrFileOpen" , __FUNCTION__ , $ fullpath ) ; } fwrite ( $ filehandle , ( string ) base64_decode ( ( string ) $ raw , true ) ) ; fclose ( $ filehandle ) ; clearstatcache ( ) ; if ( $ md5 !== md5_file ( $ fullpath ) ) { return Splash :: log ( ) -> err ( "ErrFileWrite" , __FUNCTION__ , $ file ) ; } return true ; }
Write a file on local filesystem
19,926
public function deleteFile ( $ path = null , $ md5 = null ) { $ fPath = ( string ) $ path ; if ( empty ( dirname ( $ fPath ) ) ) { return Splash :: log ( ) -> err ( "ErrFileDirMissing" , __FUNCTION__ ) ; } if ( empty ( basename ( $ fPath ) ) ) { return Splash :: log ( ) -> err ( "ErrFileFileMissing" , __FUNCTION__ ) ; } if ( empty ( $ md5 ) ) { return Splash :: log ( ) -> err ( "ErrFileMd5Missing" , __FUNCTION__ ) ; } if ( ! is_dir ( dirname ( $ fPath ) ) ) { Splash :: log ( ) -> war ( "ErrFileDirNoExists" , __FUNCTION__ , dirname ( $ fPath ) ) ; } if ( is_file ( $ fPath ) && ( md5_file ( $ fPath ) === $ md5 ) ) { Splash :: log ( ) -> deb ( "MsgFileExists" , __FUNCTION__ , basename ( $ fPath ) ) ; if ( unlink ( $ fPath ) ) { return Splash :: log ( ) -> deb ( "MsgFileDeleted" , __FUNCTION__ , basename ( $ fPath ) ) ; } return Splash :: log ( ) -> err ( "ErrFileDeleted" , __FUNCTION__ , basename ( $ fPath ) ) ; } return true ; }
Delete a file exists or not
19,927
private function isWriteValidInputs ( $ dir = null , $ file = null , $ md5 = null , $ raw = null ) { if ( empty ( $ dir ) ) { return Splash :: log ( ) -> err ( "ErrFileDirMissing" , __FUNCTION__ ) ; } if ( empty ( $ file ) ) { return Splash :: log ( ) -> err ( "ErrFileFileMissing" , __FUNCTION__ ) ; } if ( empty ( $ md5 ) ) { return Splash :: log ( ) -> err ( "ErrFileMd5Missing" , __FUNCTION__ ) ; } if ( empty ( $ raw ) ) { return Splash :: log ( ) -> err ( "ErrFileRawMissing" , __FUNCTION__ ) ; } return true ; }
Verify Write Inputs are Conform to Expected
19,928
protected function checkPaymentTransactionStatus ( PaymentTransaction $ paymentTransaction ) { if ( ! $ paymentTransaction -> isFinished ( ) ) { throw new ValidationException ( 'Only finished payment transaction can be used for create-card-ref-id' ) ; } if ( ! $ paymentTransaction -> getPayment ( ) -> isPaid ( ) ) { throw new ValidationException ( "Can not use new payment for create-card-ref-id. Execute 'sale' or 'preauth' query first" ) ; } }
Check if payment transaction is finished and payment is not new .
19,929
protected function parseReponse ( $ response ) { if ( empty ( $ response ) ) { throw new ResponseException ( 'PaynetEasy response is empty' ) ; } $ responseFields = array ( ) ; parse_str ( $ response , $ responseFields ) ; return new Response ( $ responseFields ) ; }
Parse PaynetEasy response from string to Response object
19,930
protected function getUrl ( Request $ request ) { if ( strpos ( $ request -> getApiMethod ( ) , 'sync-' ) === 0 ) { $ apiMethod = 'sync/' . substr ( $ request -> getApiMethod ( ) , strlen ( 'sync-' ) ) ; } else { $ apiMethod = $ request -> getApiMethod ( ) ; } if ( strlen ( $ request -> getEndPointGroup ( ) ) > 0 ) { $ endPoint = "group/{$request->getEndPointGroup()}" ; } else { $ endPoint = ( string ) $ request -> getEndPoint ( ) ; } return "{$request->getGatewayUrl()}/{$apiMethod}/{$endPoint}" ; }
Returns url for payment method based on request data
19,931
public function generateToken ( $ token_length = 30 , $ prefix = '' ) { $ token_length = $ token_length - strlen ( $ prefix ) ; if ( $ token_length < 0 ) { throw new Exception ( "Prefix is too long" , 1 ) ; } $ token = "" ; while ( ( $ len = strlen ( $ token ) ) < $ token_length ) { $ remaining_len = $ token_length - $ len ; $ bytes = random_bytes ( $ remaining_len ) ; $ token .= substr ( str_replace ( [ '/' , '+' , '=' ] , '' , base64_encode ( $ bytes ) ) , 0 , $ remaining_len ) ; } return $ prefix . $ token ; }
generates a secure random string
19,932
static public function validateByRule ( $ value , $ rule , $ failOnError = true ) { $ valid = false ; switch ( $ rule ) { case self :: EMAIL : { $ valid = filter_var ( $ value , FILTER_VALIDATE_EMAIL ) ; break ; } case self :: IP : { $ valid = filter_var ( $ value , FILTER_VALIDATE_IP ) ; break ; } case self :: URL : { $ valid = filter_var ( $ value , FILTER_VALIDATE_URL ) ; break ; } case self :: MONTH : { $ valid = in_array ( $ value , range ( 1 , 12 ) ) ; break ; } case self :: COUNTRY : { $ valid = RegionFinder :: hasCountryByCode ( $ value ) ; break ; } case self :: STATE : { $ valid = RegionFinder :: hasStateByCode ( $ value ) ; break ; } default : { if ( isset ( static :: $ ruleRegExps [ $ rule ] ) ) { $ valid = static :: validateByRegExp ( $ value , static :: $ ruleRegExps [ $ rule ] , $ failOnError ) ; } else { $ valid = static :: validateByRegExp ( $ value , $ rule , $ failOnError ) ; } } } if ( $ valid !== false ) { return true ; } elseif ( $ failOnError === true ) { throw new ValidationException ( "Value '{$value}' does not match rule '{$rule}'" ) ; } else { return false ; } }
Validates value by given rule . Rule can be one of Validator constants or regExp .
19,933
public function create ( $ fieldType , $ fieldId = null , $ fieldName = null ) { if ( ! empty ( $ this -> new ) ) { $ this -> commit ( ) ; } $ this -> new = null ; $ this -> new = new ArrayObject ( $ this -> empty , ArrayObject :: ARRAY_AS_PROPS ) ; $ this -> new -> type = $ fieldType ; if ( ! is_null ( $ fieldId ) ) { $ this -> identifier ( $ fieldId ) ; } if ( ! is_null ( $ fieldName ) ) { $ this -> name ( $ fieldName ) ; } return $ this ; }
Create a new Field Definition with default parameters
19,934
public function identifier ( $ fieldId ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> id = $ fieldId ; } return $ this ; }
Set Current New Field Identifier
19,935
public function inList ( $ listName ) { if ( empty ( $ listName ) ) { return $ this ; } if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> id = $ this -> new -> id . LISTSPLIT . $ listName ; $ this -> new -> type = $ this -> new -> type . LISTSPLIT . SPL_T_LIST ; } return $ this ; }
Update Current New Field set as it inside a list
19,936
public function isReadOnly ( $ isReadOnly = true ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } elseif ( $ isReadOnly ) { $ this -> new -> read = true ; $ this -> new -> write = false ; } return $ this ; }
Update Current New Field set as Read Only Field
19,937
public function isWriteOnly ( $ isWriteOnly = true ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } elseif ( $ isWriteOnly ) { $ this -> new -> read = false ; $ this -> new -> write = true ; } return $ this ; }
Update Current New Field set as Write Only Field
19,938
public function isRequired ( $ isRequired = true ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> required = ( bool ) $ isRequired ; } return $ this ; }
Update Current New Field set as required for creation
19,939
public function setPreferRead ( ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> syncmode = self :: MODE_READ ; } return $ this ; }
Signify Server Current New Field Prefer ReadOnly Mode
19,940
public function setPreferWrite ( ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> syncmode = self :: MODE_WRITE ; } return $ this ; }
Signify Server Current New Field Prefer WriteOnly Mode
19,941
public function setPreferNone ( ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> syncmode = self :: MODE_NONE ; } return $ this ; }
Signify Server Current New Field Prefer No Sync Mode
19,942
public function association ( ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { if ( ! empty ( $ this -> new -> asso ) ) { $ this -> new -> asso = null ; } if ( ! empty ( func_get_args ( ) ) ) { $ this -> new -> asso = func_get_args ( ) ; } } return $ this ; }
Update Current New Field set list of associated fields
19,943
public function isListed ( $ isListed = true ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> inlist = ( bool ) $ isListed ; } return $ this ; }
Update Current New Field set as available in objects list
19,944
public function isLogged ( $ isLogged = true ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> log = ( bool ) $ isLogged ; } return $ this ; }
Update Current New Field set as recommended for logging
19,945
public function microData ( $ itemType , $ itemProp ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> itemtype = $ itemType ; $ this -> new -> itemprop = $ itemProp ; $ this -> setTag ( $ itemProp . IDSPLIT . $ itemType ) ; } return $ this ; }
Update Current New Field set its meta informations for autolinking
19,946
public function addOptions ( $ fieldOptions ) { foreach ( $ fieldOptions as $ type => $ value ) { $ this -> addOption ( $ type , $ value ) ; } return $ this ; }
Add New Options Array for Current Field
19,947
public function addOption ( $ type , $ value = true ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } elseif ( empty ( $ type ) ) { Splash :: log ( ) -> err ( "Field Option Type Cannot be Empty" ) ; } else { $ this -> new -> options [ $ type ] = $ value ; } return $ this ; }
Add New Option for Current Field
19,948
public function setDefaultLanguage ( $ isoCode ) { if ( ! is_string ( $ isoCode ) || ( strlen ( $ isoCode ) < 2 ) ) { Splash :: log ( ) -> err ( "Default Language ISO Code is Invalid" ) ; return $ this ; } $ this -> dfLanguage = $ isoCode ; return $ this ; }
Select Default Language for Field List
19,949
public function setMultilang ( $ isoCode ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; return $ this ; } if ( ! is_string ( $ isoCode ) || ( strlen ( $ isoCode ) < 2 ) ) { Splash :: log ( ) -> err ( "Language ISO Code is Invalid" ) ; return $ this ; } if ( ! in_array ( $ this -> new -> type , array ( SPL_T_VARCHAR , SPL_T_TEXT ) , true ) ) { Splash :: log ( ) -> err ( "ErrFieldsWrongLang" ) ; Splash :: log ( ) -> err ( "Received: " . $ this -> new -> type ) ; return $ this ; } $ this -> addOption ( "language" , $ isoCode ) ; if ( $ isoCode != $ this -> dfLanguage ) { $ this -> identifier ( $ this -> new -> id . "_" . $ isoCode ) ; if ( ! empty ( $ this -> new -> itemtype ) ) { $ this -> microData ( $ this -> new -> itemtype . "/" . $ isoCode , $ this -> new -> itemprop ) ; } } return $ this ; }
Configure Current Field with Multilangual Options
19,950
public function seachtByTag ( $ fieldList , $ fieldTag ) { if ( ! count ( $ fieldList ) ) { return false ; } if ( empty ( $ fieldTag ) ) { return false ; } foreach ( $ fieldList as $ field ) { if ( $ field [ "tag" ] == $ fieldTag ) { return $ field ; } } return false ; }
Seach for a Field by unik tag
19,951
public function seachtById ( $ fieldList , $ fieldId ) { if ( ! count ( $ fieldList ) ) { return false ; } if ( empty ( $ fieldId ) ) { return false ; } foreach ( $ fieldList as $ field ) { if ( $ field [ "id" ] == $ fieldId ) { return $ field ; } } return false ; }
Seach for a Field by id
19,952
private function setTag ( $ fieldTag ) { if ( empty ( $ this -> new ) ) { Splash :: log ( ) -> err ( "ErrFieldsNoNew" ) ; } else { $ this -> new -> tag = md5 ( $ fieldTag ) ; } return $ this ; }
Update Current New Field set its unik tag for autolinking
19,953
private function validate ( $ field ) { if ( empty ( $ field -> type ) || ! is_string ( $ field -> type ) ) { return Splash :: log ( ) -> err ( "ErrFieldsNoType" ) ; } if ( empty ( $ field -> id ) || ! is_string ( $ field -> id ) ) { return Splash :: log ( ) -> err ( "ErrFieldsNoId" ) ; } if ( $ field -> id !== preg_replace ( '/[^a-zA-Z0-9-_@]/u' , '' , $ field -> id ) ) { Splash :: log ( ) -> war ( "ErrFieldsInvalidId" , $ field -> id ) ; return false ; } if ( empty ( $ field -> name ) || ! is_string ( $ field -> name ) ) { return Splash :: log ( ) -> err ( "ErrFieldsNoName" ) ; } if ( empty ( $ field -> desc ) || ! is_string ( $ field -> desc ) ) { return Splash :: log ( ) -> err ( "ErrFieldsNoDesc" ) ; } return true ; }
Validate Field Definition
19,954
public function postSubmit ( ) { $ rules = [ 'first_name' => 'required' , 'last_name' => 'required' , 'email' => 'required' , 'message' => 'required' , ] ; $ input = Binput :: only ( array_keys ( $ rules ) ) ; $ val = Validator :: make ( $ input , $ rules ) ; if ( $ val -> fails ( ) ) { return Redirect :: to ( $ this -> path ) -> withInput ( ) -> withErrors ( $ val ) ; } $ this -> throttler -> hit ( ) ; Mailer :: send ( $ input [ 'first_name' ] , $ input [ 'last_name' ] , $ input [ 'email' ] , $ input [ 'message' ] ) ; return Redirect :: to ( '/' ) -> with ( 'success' , 'Your message was sent successfully. Thank you for contacting us.' ) ; }
Submit the contact form .
19,955
public function EncodeString ( $ str , $ encoding = 'base64' ) { $ encoded = '' ; switch ( strtolower ( $ encoding ) ) { case 'base64' : $ encoded = chunk_split ( base64_encode ( $ str ) , 76 , $ this -> LE ) ; break ; case '7bit' : case '8bit' : $ encoded = $ this -> FixEOL ( $ str ) ; if ( substr ( $ encoded , - ( strlen ( $ this -> LE ) ) ) != $ this -> LE ) { $ encoded .= $ this -> LE ; } break ; case 'binary' : $ encoded = $ str ; break ; case 'quoted-printable' : $ encoded = $ this -> EncodeQP ( $ str ) ; break ; default : $ this -> SetError ( $ this -> Lang ( 'encoding' ) . $ encoding ) ; break ; } return $ encoded ; }
Encodes string to requested format . Returns an empty string on failure .
19,956
public static function _mime_types ( $ ext = '' ) { $ mimes = array ( 'hqx' => 'application/mac-binhex40' , 'cpt' => 'application/mac-compactpro' , 'doc' => 'application/msword' , 'bin' => 'application/macbinary' , 'dms' => 'application/octet-stream' , 'lha' => 'application/octet-stream' , 'lzh' => 'application/octet-stream' , 'exe' => 'application/octet-stream' , 'class' => 'application/octet-stream' , 'psd' => 'application/octet-stream' , 'so' => 'application/octet-stream' , 'sea' => 'application/octet-stream' , 'dll' => 'application/octet-stream' , 'oda' => 'application/oda' , 'pdf' => 'application/pdf' , 'ai' => 'application/postscript' , 'eps' => 'application/postscript' , 'ps' => 'application/postscript' , 'smi' => 'application/smil' , 'smil' => 'application/smil' , 'mif' => 'application/vnd.mif' , 'xls' => 'application/vnd.ms-excel' , 'ppt' => 'application/vnd.ms-powerpoint' , 'wbxml' => 'application/vnd.wap.wbxml' , 'wmlc' => 'application/vnd.wap.wmlc' , 'dcr' => 'application/x-director' , 'dir' => 'application/x-director' , 'dxr' => 'application/x-director' , 'dvi' => 'application/x-dvi' , 'gtar' => 'application/x-gtar' , 'php' => 'application/x-httpd-php' , 'php4' => 'application/x-httpd-php' , 'php3' => 'application/x-httpd-php' , 'phtml' => 'application/x-httpd-php' , 'phps' => 'application/x-httpd-php-source' , 'js' => 'application/x-javascript' , 'swf' => 'application/x-shockwave-flash' , 'sit' => 'application/x-stuffit' , 'tar' => 'application/x-tar' , 'tgz' => 'application/x-tar' , 'xhtml' => 'application/xhtml+xml' , 'xht' => 'application/xhtml+xml' , 'zip' => 'application/zip' , 'mid' => 'audio/midi' , 'midi' => 'audio/midi' , 'mpga' => 'audio/mpeg' , 'mp2' => 'audio/mpeg' , 'mp3' => 'audio/mpeg' , 'aif' => 'audio/x-aiff' , 'aiff' => 'audio/x-aiff' , 'aifc' => 'audio/x-aiff' , 'ram' => 'audio/x-pn-realaudio' , 'rm' => 'audio/x-pn-realaudio' , 'rpm' => 'audio/x-pn-realaudio-plugin' , 'ra' => 'audio/x-realaudio' , 'rv' => 'video/vnd.rn-realvideo' , 'wav' => 'audio/x-wav' , 'bmp' => 'image/bmp' , 'gif' => 'image/gif' , 'jpeg' => 'image/jpeg' , 'jpg' => 'image/jpeg' , 'jpe' => 'image/jpeg' , 'png' => 'image/png' , 'tiff' => 'image/tiff' , 'tif' => 'image/tiff' , 'css' => 'text/css' , 'html' => 'text/html' , 'htm' => 'text/html' , 'shtml' => 'text/html' , 'txt' => 'text/plain' , 'text' => 'text/plain' , 'log' => 'text/plain' , 'rtx' => 'text/richtext' , 'rtf' => 'text/rtf' , 'xml' => 'text/xml' , 'xsl' => 'text/xml' , 'mpeg' => 'video/mpeg' , 'mpg' => 'video/mpeg' , 'mpe' => 'video/mpeg' , 'qt' => 'video/quicktime' , 'mov' => 'video/quicktime' , 'avi' => 'video/x-msvideo' , 'movie' => 'video/x-sgi-movie' , 'doc' => 'application/msword' , 'word' => 'application/msword' , 'xl' => 'application/excel' , 'eml' => 'message/rfc822' , ) ; return ( ! isset ( $ mimes [ strtolower ( $ ext ) ] ) ) ? 'application/octet-stream' : $ mimes [ strtolower ( $ ext ) ] ; }
Gets the MIME type of the embedded or inline image
19,957
public function StartTLS ( ) { $ this -> error = null ; if ( ! $ this -> connected ( ) ) { $ this -> error = array ( "error" => "Called StartTLS() without being connected" ) ; return false ; } fputs ( $ this -> smtp_conn , "STARTTLS" . $ this -> CRLF ) ; $ rply = $ this -> get_lines ( ) ; $ code = substr ( $ rply , 0 , 3 ) ; if ( $ this -> do_debug >= 2 ) { echo "SMTP -> FROM SERVER:" . $ rply . $ this -> CRLF . '<br />' ; } if ( $ code != 220 ) { $ this -> error = array ( "error" => "STARTTLS not accepted from server" , "smtp_code" => $ code , "smtp_msg" => substr ( $ rply , 4 ) ) ; if ( $ this -> do_debug >= 1 ) { echo "SMTP -> ERROR: " . $ this -> error [ "error" ] . ": " . $ rply . $ this -> CRLF . '<br />' ; } return false ; } if ( ! stream_socket_enable_crypto ( $ this -> smtp_conn , true , STREAM_CRYPTO_METHOD_TLS_CLIENT ) ) { return false ; } return true ; }
Initiate a TLS communication with the server .
19,958
public function Close ( ) { $ this -> error = null ; $ this -> helo_rply = null ; if ( ! empty ( $ this -> smtp_conn ) ) { fclose ( $ this -> smtp_conn ) ; $ this -> smtp_conn = 0 ; } }
Closes the socket and cleans up the state of the class . It is not considered good to use this function without first trying to use QUIT .
19,959
static protected function registerAnnotations ( ) { if ( self :: $ annotationsRegistered === false ) { AnnotationRegistry :: registerFile ( __DIR__ . '/../Annotation/ResourceIdentifier.php' ) ; AnnotationRegistry :: registerFile ( __DIR__ . '/../Annotation/Relationship.php' ) ; AnnotationRegistry :: registerFile ( __DIR__ . '/../Annotation/Attribute.php' ) ; AnnotationRegistry :: registerFile ( __DIR__ . '/../Annotation/Link.php' ) ; self :: $ annotationsRegistered = true ; } }
Register annotation classes . Supports a medieval - aged way of autoloading for the Doctrine Annotation library .
19,960
protected function createLink ( LinkAnnotation $ annotation ) : Link { if ( ! preg_match ( self :: RESOURCE_PATTERN , $ annotation -> resource , $ matches ) ) { throw new \ LogicException ( sprintf ( 'Invalid resource definition: "%s"' , $ annotation -> resource ) ) ; } $ link = new Link ( $ annotation -> name , $ matches [ 'repository' ] , $ matches [ 'link' ] ) ; $ link -> setParameters ( $ annotation -> parameters ) ; $ link -> setMetadata ( $ annotation -> metadata ) ; return $ link ; }
Create link by link s annotation
19,961
public function isValidLocalClass ( ) { $ className = SPLASH_CLASS_PREFIX . '\\Local' ; if ( isset ( $ this -> ValidLocalClass [ $ className ] ) ) { return $ this -> ValidLocalClass [ $ className ] ; } $ this -> ValidLocalClass [ $ className ] = false ; if ( false == class_exists ( $ className ) ) { return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrLocalClass' , $ className ) ) ; } try { $ class = new $ className ( ) ; if ( ! ( $ class instanceof LocalClassInterface ) ) { return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrLocalInterface' , $ className , LocalClassInterface :: class ) ) ; } } catch ( Exception $ exc ) { echo $ exc -> getMessage ( ) ; return Splash :: log ( ) -> err ( $ exc -> getMessage ( ) ) ; } $ this -> ValidLocalClass [ $ className ] = true ; return $ this -> ValidLocalClass [ $ className ] ; }
Verify Local Core Class Exists & Is Valid
19,962
public function isValidLocalParameterArray ( $ input ) { if ( ! is_array ( $ input ) ) { return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrorCfgNotAnArray' , get_class ( $ input ) ) ) ; } if ( ! array_key_exists ( 'WsIdentifier' , $ input ) ) { return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrWsNoId' ) ) ; } if ( ! array_key_exists ( 'WsEncryptionKey' , $ input ) ) { return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrWsNoKey' ) ) ; } return true ; }
Verify Local Core Parameters are Valid
19,963
public function isValidServerInfos ( ) { $ infos = Splash :: ws ( ) -> getServerInfos ( ) ; if ( ! is_a ( $ infos , 'ArrayObject' ) ) { return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrInfosNotArrayObject' , get_class ( $ infos ) ) ) ; } if ( defined ( 'SPLASH_DEBUG' ) && ! empty ( SPLASH_DEBUG ) ) { Splash :: log ( ) -> war ( 'Host : ' . $ infos [ 'ServerHost' ] ) ; Splash :: log ( ) -> war ( 'Path : ' . $ infos [ 'ServerPath' ] ) ; } if ( ! isset ( $ infos [ 'ServerHost' ] ) || empty ( $ infos [ 'ServerHost' ] ) ) { Splash :: log ( ) -> err ( Splash :: trans ( 'ErrEmptyServerHost' ) ) ; return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrEmptyServerHostDesc' ) ) ; } if ( ! isset ( $ infos [ 'ServerPath' ] ) || empty ( $ infos [ 'ServerPath' ] ) ) { Splash :: log ( ) -> err ( Splash :: trans ( 'ErrEmptyServerPath' ) ) ; return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrEmptyServerPathDesc' ) ) ; } $ this -> isLocalInstallation ( $ infos ) ; return true ; }
Verify Webserver Informations are Valid
19,964
public function isLocalInstallation ( $ infos ) { if ( false !== strpos ( $ infos [ 'ServerHost' ] , 'localhost' ) ) { Splash :: log ( ) -> war ( Splash :: trans ( 'WarIsLocalhostServer' ) ) ; } elseif ( false !== strpos ( $ infos [ 'ServerIP' ] , '127.0.0.1' ) ) { Splash :: log ( ) -> war ( Splash :: trans ( 'WarIsLocalhostServer' ) ) ; } if ( 'https' === Splash :: input ( 'REQUEST_SCHEME' ) ) { Splash :: log ( ) -> war ( Splash :: trans ( 'WarIsHttpsServer' ) ) ; } }
Verify Webserver is a LocalHost
19,965
public function isValidObject ( $ objectType ) { if ( isset ( $ this -> ValidLocalObject [ $ objectType ] ) ) { return $ this -> ValidLocalObject [ $ objectType ] ; } $ this -> ValidLocalObject [ $ objectType ] = false ; if ( ! $ this -> isValidLocalClass ( ) ) { return false ; } if ( ! ( Splash :: local ( ) instanceof ObjectsProviderInterface ) ) { if ( ! $ this -> isValidObjectFile ( $ objectType ) ) { return false ; } } if ( ! $ this -> isValidObjectClass ( $ objectType ) ) { return false ; } $ this -> ValidLocalObject [ $ objectType ] = true ; return true ; }
Verify this parameter is a valid object type name
19,966
public function isValidObjectId ( $ objectId ) { if ( is_null ( $ objectId ) ) { return Splash :: log ( ) -> err ( 'ErrEmptyObjectId' ) ; } if ( ! is_string ( $ objectId ) && ! is_numeric ( $ objectId ) ) { return Splash :: log ( ) -> err ( 'ErrWrongObjectId' ) ; } if ( is_numeric ( $ objectId ) && ( $ objectId < 0 ) ) { return Splash :: log ( ) -> err ( 'ErrNegObjectId' ) ; } return Splash :: log ( ) -> deb ( 'MsgObjectIdOk' ) ; }
Verify Object Identifier
19,967
public function isValidObjectFieldsList ( $ fieldsList ) { if ( ! is_array ( $ fieldsList ) && ! ( $ fieldsList instanceof ArrayObject ) ) { return Splash :: log ( ) -> err ( 'ErrWrongFieldList' ) ; } if ( empty ( $ fieldsList ) ) { return Splash :: log ( ) -> err ( 'ErrEmptyFieldList' ) ; } return Splash :: log ( ) -> deb ( 'MsgFieldListOk' ) ; }
Verify Object Field List
19,968
public function isValidWidget ( $ widgetType ) { if ( isset ( $ this -> ValidLocalWidget [ $ widgetType ] ) ) { return $ this -> ValidLocalWidget [ $ widgetType ] ; } $ this -> ValidLocalWidget [ $ widgetType ] = false ; if ( ! $ this -> isValidLocalClass ( ) ) { return false ; } if ( ! ( Splash :: local ( ) instanceof WidgetsProviderInterface ) ) { if ( ! $ this -> isValidWidgetFile ( $ widgetType ) ) { return false ; } } if ( ! $ this -> isValidWidgetClass ( $ widgetType ) ) { return false ; } $ this -> ValidLocalWidget [ $ widgetType ] = true ; return true ; }
Verify this parameter is a valid widget type name
19,969
public function isValidLocalPath ( ) { if ( ! isset ( $ this -> ValidLocalPath ) ) { $ path = Splash :: getLocalPath ( ) ; if ( is_null ( $ path ) || ! is_dir ( $ path ) ) { $ this -> ValidLocalPath = false ; return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrLocalPath' , ( string ) $ path ) ) ; } $ this -> ValidLocalPath = true ; } return $ this -> ValidLocalPath ; }
Verify Local Path Exists
19,970
public function isValidPHPVersion ( ) { if ( version_compare ( PHP_VERSION , '5.6.0' ) < 0 ) { return Splash :: log ( ) -> err ( 'PHP : Your PHP version is too low to use Splash (' . PHP_VERSION . '). PHP >5.6 is Requiered.' ) ; } return Splash :: log ( ) -> msg ( 'PHP : Your PHP version is compatible with Splash (' . PHP_VERSION . ')' ) ; }
Verify PHP Version is Compatible .
19,971
public function isValidPHPExtensions ( ) { $ extensions = array ( 'xml' , 'soap' , 'curl' ) ; foreach ( $ extensions as $ extension ) { if ( ! extension_loaded ( $ extension ) ) { return Splash :: log ( ) -> err ( 'PHP :' . $ extension . ' PHP Extension is required to use Splash PHP Module.' ) ; } } return Splash :: log ( ) -> msg ( 'PHP : Required PHP Extension are installed (' . implode ( ', ' , $ extensions ) . ')' ) ; }
Verify PHP Required are Installed & Active
19,972
public function isValidSOAPMethod ( ) { if ( ! in_array ( Splash :: configuration ( ) -> WsMethod , array ( 'SOAP' , 'NuSOAP' ) , true ) ) { return Splash :: log ( ) -> err ( 'Config : Your selected an unknown SOAP Method (' . Splash :: configuration ( ) -> WsMethod . ').' ) ; } return Splash :: log ( ) -> msg ( 'Config : SOAP Method is Ok (' . Splash :: configuration ( ) -> WsMethod . ').' ) ; }
Verify WebService Library is Valid .
19,973
public function isValidConfigurator ( $ className ) { if ( false == class_exists ( $ className ) ) { return Splash :: log ( ) -> err ( 'Configurator Class Not Found: ' . $ className ) ; } try { $ class = new $ className ( ) ; if ( ! ( $ class instanceof ConfiguratorInterface ) ) { return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrLocalInterface' , $ className , ConfiguratorInterface :: class ) ) ; } } catch ( Exception $ exc ) { echo $ exc -> getMessage ( ) ; return Splash :: log ( ) -> err ( $ exc -> getMessage ( ) ) ; } return true ; }
Verify Given Class Is a Valid Splash Configurator
19,974
private function isValidObjectFile ( $ objectType ) { if ( false == $ this -> isValidLocalPath ( ) ) { return false ; } $ filename = Splash :: getLocalPath ( ) . '/Objects/' . $ objectType . '.php' ; if ( false == file_exists ( $ filename ) ) { $ msg = 'Local Object File Not Found.</br>' ; $ msg .= 'Current Filename : ' . $ filename . '' ; return Splash :: log ( ) -> err ( $ msg ) ; } return true ; }
Verify a Local Object File is Valid .
19,975
private function isValidObjectClass ( $ objectType ) { if ( Splash :: local ( ) instanceof ObjectsProviderInterface ) { $ className = get_class ( Splash :: local ( ) -> object ( $ objectType ) ) ; } else { $ className = SPLASH_CLASS_PREFIX . '\\Objects\\' . $ objectType ; } if ( false == class_exists ( $ className ) ) { return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrLocalClass' , $ objectType ) ) ; } if ( false == $ this -> isValidLocalFunction ( 'getIsDisabled' , $ className ) ) { return false ; } if ( Splash :: configurator ( ) -> isDisabled ( $ objectType , $ className :: getIsDisabled ( ) ) ) { return false ; } return is_subclass_of ( $ className , ObjectInterface :: class ) ; }
Verify Availability of a Local Object Class .
19,976
private function isValidWidgetFile ( $ widgetType ) { if ( false == $ this -> isValidLocalPath ( ) ) { return false ; } $ filename = Splash :: getLocalPath ( ) . '/Widgets/' . $ widgetType . '.php' ; if ( false == file_exists ( $ filename ) ) { $ msg = 'Local Widget File Not Found.</br>' ; $ msg .= 'Current Filename : ' . $ filename . '' ; return Splash :: log ( ) -> err ( $ msg ) ; } return true ; }
Verify a Local Widget File is Valid .
19,977
private function isValidWidgetClass ( $ widgetType ) { if ( Splash :: local ( ) instanceof WidgetsProviderInterface ) { $ className = get_class ( Splash :: local ( ) -> widget ( $ widgetType ) ) ; } else { $ className = SPLASH_CLASS_PREFIX . '\\Widgets\\' . $ widgetType ; } if ( false == class_exists ( $ className ) ) { return Splash :: log ( ) -> err ( Splash :: trans ( 'ErrLocalClass' , $ widgetType ) ) ; } if ( false == $ this -> isValidLocalFunction ( 'getIsDisabled' , $ className ) ) { $ this -> ValidLocalWidget [ $ widgetType ] = false ; return false ; } if ( $ className :: getIsDisabled ( ) ) { $ this -> ValidLocalWidget [ $ widgetType ] = false ; return false ; } return is_subclass_of ( $ className , WidgetInterface :: class ) ; }
Verify Availability of a Local Widget Class .
19,978
protected function instantiateCallback ( $ callbackClass , $ callbackType ) { if ( ! is_a ( $ callbackClass , static :: $ callbackInterface , true ) ) { throw new RuntimeException ( "Callback class '{$callbackClass}' does not implements '" . static :: $ callbackInterface . "' interface." ) ; } return new $ callbackClass ( $ callbackType ) ; }
Method check callback class and return new callback object
19,979
public function getTableGeomType ( $ tableName , $ schema = null ) { $ connection = $ this -> connection ; if ( strpos ( $ tableName , '.' ) ) { list ( $ schema , $ tableName ) = explode ( '.' , $ tableName ) ; } $ _schema = $ schema ? $ connection -> quote ( $ schema ) : 'current_schema()' ; $ type = $ connection -> query ( "SELECT \"type\" FROM geometry_columns WHERE f_table_schema = " . $ _schema . " AND f_table_name = " . $ connection -> quote ( $ tableName ) ) -> fetchColumn ( ) ; return $ type ; }
Get table geom type
19,980
public function getLastInsertId ( ) { $ connection = $ this -> getConnection ( ) ; $ id = $ connection -> lastInsertId ( ) ; if ( $ id < 1 ) { $ fullTableName = $ this -> tableName ; $ fullUniqueIdName = $ connection -> quoteIdentifier ( $ this -> getUniqueId ( ) ) ; $ sql = "SELECT $fullUniqueIdName FROM $fullTableName LIMIT 1 OFFSET (SELECT count($fullUniqueIdName)-1 FROM $fullTableName )" ; $ id = $ connection -> fetchColumn ( $ sql ) ; } return $ id ; }
Get last insert id
19,981
public function getNodeFromGeom ( $ waysVerticesTableName , $ waysGeomFieldName , $ ewkt , $ transformTo = null , $ idKey = "id" ) { $ db = $ this -> getConnection ( ) ; $ geom = "ST_GeometryFromText('" . $ db -> quote ( $ ewkt ) . "')" ; if ( $ transformTo ) { $ geom = "ST_TRANSFORM($geom, $transformTo)" ; } return $ db -> fetchColumn ( "SELECT {$db->quoteIdentifier($idKey)}, ST_Distance({$db->quoteIdentifier($waysGeomFieldName)}, $geom) AS distance FROM {$db->quoteIdentifier($waysVerticesTableName)} ORDER BY distance ASC LIMIT 1" ) ; }
Get nearest node to given geometry
19,982
public function routeBetweenNodes ( $ waysTableName , $ waysGeomFieldName , $ startNodeId , $ endNodeId , $ srid , $ directedGraph = false , $ hasReverseCost = false ) { $ db = $ this -> getConnection ( ) ; $ waysTableName = $ db -> quoteIdentifier ( $ waysTableName ) ; $ geomFieldName = $ db -> quoteIdentifier ( $ waysGeomFieldName ) ; $ directedGraph = $ directedGraph ? 'TRUE' : 'FALSE' ; $ hasReverseCost = $ hasReverseCost && $ directedGraph ? 'TRUE' : 'FALSE' ; $ results = $ db -> query ( "SELECT route.seq as orderId, route.id1 as startNodeId, route.id2 as endNodeId, route.cost as distance, ST_AsEWKT ($waysTableName.$geomFieldName) AS geom FROM pgr_dijkstra ( 'SELECT gid AS id, source, target, length AS cost FROM $waysTableName', $startNodeId, $endNodeId, $directedGraph, $hasReverseCost ) AS route LEFT JOIN $waysTableName ON route.id2 = $waysTableName.gid" ) -> fetchAll ( ) ; return $ this -> prepareResults ( $ results , $ srid ) ; }
Route between nodes
19,983
public function all ( string $ country = 'MY' , ? Query $ query = null ) : Response { return $ this -> send ( 'GET' , "insurer/{$country}" , $ this -> getApiHeaders ( ) , $ this -> buildHttpQuery ( $ query ) ) ; }
Get all available insurer by country .
19,984
public function getById ( $ id , $ srid = null ) { $ rows = $ this -> getSelectQueryBuilder ( $ srid ) -> where ( $ this -> getUniqueId ( ) . " = :id" ) -> setParameter ( 'id' , $ id ) -> execute ( ) -> fetchAll ( ) ; $ this -> prepareResults ( $ rows , $ srid ) ; return reset ( $ rows ) ; }
Get feature by ID and SRID
19,985
public function search ( array $ criteria = array ( ) ) { $ maxResults = isset ( $ criteria [ 'maxResults' ] ) ? intval ( $ criteria [ 'maxResults' ] ) : self :: MAX_RESULTS ; $ intersect = isset ( $ criteria [ 'intersectGeometry' ] ) ? $ criteria [ 'intersectGeometry' ] : null ; $ returnType = isset ( $ criteria [ 'returnType' ] ) ? $ criteria [ 'returnType' ] : null ; $ srid = isset ( $ criteria [ 'srid' ] ) ? $ criteria [ 'srid' ] : $ this -> getSrid ( ) ; $ where = isset ( $ criteria [ 'where' ] ) ? $ criteria [ 'where' ] : null ; $ queryBuilder = $ this -> getSelectQueryBuilder ( $ srid ) ; $ connection = $ queryBuilder -> getConnection ( ) ; $ whereConditions = array ( ) ; if ( $ intersect ) { $ geometry = BaseDriver :: roundGeometry ( $ intersect , 2 ) ; $ whereConditions [ ] = $ this -> getDriver ( ) -> getIntersectCondition ( $ geometry , $ this -> geomField , $ srid , $ this -> getSrid ( ) ) ; } if ( ! empty ( $ this -> sqlFilter ) ) { $ securityContext = $ this -> container -> get ( "security.context" ) ; $ user = $ securityContext -> getUser ( ) ; $ sqlFilter = strtr ( $ this -> sqlFilter , array ( ':userName' => $ user -> getUsername ( ) ) ) ; $ whereConditions [ ] = $ sqlFilter ; } if ( $ where ) { $ whereConditions [ ] = $ where ; } if ( isset ( $ criteria [ "source" ] ) && isset ( $ criteria [ "distance" ] ) ) { $ whereConditions [ ] = "ST_DWithin(t." . $ this -> getGeomField ( ) . "," . $ connection -> quote ( $ criteria [ "source" ] ) . "," . $ criteria [ 'distance' ] . ')' ; } if ( count ( $ whereConditions ) ) { $ queryBuilder -> where ( join ( " AND " , $ whereConditions ) ) ; } $ queryBuilder -> setMaxResults ( $ maxResults ) ; $ statement = $ queryBuilder -> execute ( ) ; $ rows = $ statement -> fetchAll ( ) ; $ hasResults = count ( $ rows ) > 0 ; if ( $ hasResults ) { $ this -> prepareResults ( $ rows , $ srid ) ; } if ( $ returnType == "FeatureCollection" ) { $ rows = $ this -> toFeatureCollection ( $ rows ) ; } return $ rows ; }
Search feature by criteria
19,986
public function getTableSequenceName ( ) { $ connection = $ this -> getConnection ( ) ; $ result = $ connection -> fetchColumn ( "SELECT column_default from information_schema.columns where table_name='" . $ this -> getTableName ( ) . "' and column_name='" . $ this -> getUniqueId ( ) . "'" ) ; $ result = explode ( "'" , $ result ) ; return $ result [ 0 ] ; }
Get sequence name
19,987
public function getFileUri ( $ fieldName = null ) { $ path = self :: UPLOAD_DIR_NAME . "/" . $ this -> getTableName ( ) ; if ( $ fieldName ) { $ path .= "/" . $ fieldName ; } foreach ( $ this -> getFileInfo ( ) as $ fileInfo ) { if ( isset ( $ fileInfo [ "field" ] ) && isset ( $ fileInfo [ "uri" ] ) && $ fieldName == $ fileInfo [ "field" ] ) { $ path = $ fileInfo [ "uri" ] ; break ; } } return $ path ; }
Get files directory relative to base upload directory
19,988
public function getFilePath ( $ fieldName = null , $ createPath = true ) { $ path = realpath ( AppComponent :: getUploadsDir ( $ this -> container ) ) . "/" . $ this -> getFileUri ( $ fieldName ) ; foreach ( $ this -> getFileInfo ( ) as $ fileInfo ) { if ( isset ( $ fileInfo [ "field" ] ) && isset ( $ fileInfo [ "path" ] ) && $ fieldName == $ fileInfo [ "field" ] ) { $ path = $ fileInfo [ "path" ] ; break ; } } if ( $ createPath && ! is_dir ( $ path ) ) { mkdir ( $ path , 0775 , true ) ; } return $ path ; }
Get files base path
19,989
public function genFilePath ( $ fieldName = null ) { $ id = $ this -> countFiles ( $ fieldName ) + 1 ; $ src = null ; $ path = null ; while ( 1 ) { $ path = $ id ; $ src = $ this -> getFilePath ( $ fieldName ) . "/" . $ path ; if ( ! file_exists ( $ src ) ) { break ; } $ id ++ ; } return array ( "src" => $ src , "path" => $ path ) ; }
Generate unique file name for a field .
19,990
private function countFiles ( $ fieldName = null ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ this -> getFilePath ( $ fieldName ) ) ; return count ( $ finder ) ; }
Count files in the field directory
19,991
public function routeBetweenGeom ( $ sourceGeom , $ targetGeom ) { $ driver = $ this -> getDriver ( ) ; $ srid = $ this -> getSrid ( ) ; $ sourceNode = $ driver -> getNodeFromGeom ( $ this -> waysVerticesTableName , $ this -> waysGeomFieldName , $ sourceGeom , $ srid , 'id' ) ; $ targetNode = $ driver -> getNodeFromGeom ( $ this -> waysVerticesTableName , $ this -> waysGeomFieldName , $ targetGeom , $ srid , 'id' ) ; return $ driver -> routeBetweenNodes ( $ this -> waysVerticesTableName , $ this -> waysGeomFieldName , $ sourceNode , $ targetNode , $ srid ) ; }
Get route nodes between geometries
19,992
public function getByIds ( $ ids , $ prepareResults = true ) { $ queryBuilder = $ this -> getSelectQueryBuilder ( ) ; $ connection = $ queryBuilder -> getConnection ( ) ; $ rows = $ queryBuilder -> where ( $ queryBuilder -> expr ( ) -> in ( $ this -> getUniqueId ( ) , array_map ( function ( $ id ) use ( $ connection ) { return $ connection -> quote ( $ id ) ; } , $ ids ) ) ) -> execute ( ) -> fetchAll ( ) ; if ( $ prepareResults ) { $ this -> prepareResults ( $ rows ) ; } return $ rows ; }
Get by ID list
19,993
public function getConfiguration ( $ key = null ) { return isset ( $ this -> _args [ $ key ] ) ? $ this -> _args [ $ key ] : null ; }
Get feature type configuration by key name
19,994
public function export ( array & $ rows ) { $ config = $ this -> getConfiguration ( 'export' ) ; $ fieldNames = isset ( $ config [ 'fields' ] ) ? $ config [ 'fields' ] : null ; $ result = array ( ) ; if ( $ fieldNames ) { foreach ( $ rows as & $ row ) { $ exportRow = array ( ) ; foreach ( $ fieldNames as $ fieldName => $ fieldCode ) { $ exportRow [ $ fieldName ] = $ this -> evaluateField ( $ row , $ fieldCode ) ; } $ result [ ] = $ exportRow ; } } else { $ result = & $ rows ; } return $ result ; }
Export by ID s
19,995
public function getConsoleLog ( $ clean = false ) { $ result = null ; $ result .= $ this -> getConsole ( $ this -> err , ' - Error => ' , self :: CMD_COLOR_ERR ) ; $ result .= $ this -> getConsole ( $ this -> war , ' - Warning => ' , self :: CMD_COLOR_WAR ) ; $ result .= $ this -> getConsole ( $ this -> msg , ' - Messages => ' , self :: CMD_COLOR_MSG ) ; $ result .= $ this -> getConsole ( $ this -> deb , ' - Debug => ' , self :: CMD_COLOR_DEB ) ; $ result .= "\e[0m" ; if ( $ clean ) { $ this -> cleanLog ( ) ; } return $ result ; }
Return All WebServer current Log WebServer in Console Colored format
19,996
private function getConsole ( $ msgArray , $ title = '' , $ color = 0 ) { $ result = '' ; if ( ( is_array ( $ msgArray ) || $ msgArray instanceof Countable ) && count ( $ msgArray ) ) { foreach ( $ msgArray as $ txt ) { $ result .= self :: getConsoleLine ( $ txt , $ title , $ color ) ; } } return $ result ; }
Return All WebServer current Log WebServer Console Colored format
19,997
protected function processAttributeToResource ( $ object , ResourceObject $ resource , Attribute $ definition ) { $ name = $ definition -> getName ( ) ; $ getter = $ definition -> getGetter ( ) ; $ value = $ object -> $ getter ( ) ; if ( $ value === null && ! $ definition -> getProcessNull ( ) ) { return ; } $ value = $ this -> typeManager -> toResource ( $ definition , $ value ) ; $ resource -> setAttribute ( $ name , $ value ) ; }
Process attribute to resource mapping
19,998
protected function processResourceToAttribute ( $ object , ResourceObject $ resource , Attribute $ definition ) { $ name = $ definition -> getName ( ) ; if ( ! $ resource -> hasAttribute ( $ name ) ) { return ; } $ value = $ resource -> getAttribute ( $ name ) ; if ( $ value === null && ! $ definition -> getProcessNull ( ) ) { return ; } $ value = $ this -> typeManager -> fromResource ( $ definition , $ value ) ; $ setter = $ definition -> getSetter ( ) ; $ object -> $ setter ( $ value ) ; }
Process resource to attribute mapping
19,999
private static function _parse_form_attributes ( $ attributes , $ default ) { if ( is_array ( $ attributes ) ) { foreach ( $ default as $ key => $ val ) { if ( isset ( $ attributes [ $ key ] ) ) { $ default [ $ key ] = $ attributes [ $ key ] ; unset ( $ attributes [ $ key ] ) ; } } if ( count ( $ attributes ) > 0 ) { $ default = array_merge ( $ default , $ attributes ) ; } } $ att = '' ; foreach ( $ default as $ key => $ val ) { if ( $ key == 'value' ) { $ val = self :: form_prep ( $ val , $ default [ 'name' ] ) ; } $ att .= $ key . '="' . $ val . '" ' ; } return $ att ; }
Parse the form attributes