idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
57,300
public function runParser ( $ res , $ req , $ key = null ) { if ( $ this -> _parser !== null ) { self :: debug ( 'run parser: ' , $ req -> getRawUrl ( ) ) ; if ( $ this -> _parser instanceof ParseInterface ) { $ this -> _parser -> parse ( $ res , $ req , $ key ) ; } else { call_user_func ( $ this -> _parser , $ res , $ req , $ key ) ; } } }
Run parse handler
57,301
public function head ( $ url , $ params = [ ] ) { if ( is_array ( $ url ) ) { return $ this -> mhead ( $ url , $ params ) ; } return $ this -> exec ( $ this -> buildRequest ( 'HEAD' , $ url , $ params ) ) ; }
Shortcut of HEAD request
57,302
public function get ( $ url , $ params = [ ] ) { if ( is_array ( $ url ) ) { return $ this -> mget ( $ url , $ params ) ; } return $ this -> exec ( $ this -> buildRequest ( 'GET' , $ url , $ params ) ) ; }
Shortcut of GET request
57,303
public function delete ( $ url , $ params = [ ] ) { if ( is_array ( $ url ) ) { return $ this -> mdelete ( $ url , $ params ) ; } return $ this -> exec ( $ this -> buildRequest ( 'DELETE' , $ url , $ params ) ) ; }
Shortcut of DELETE request
57,304
public function post ( $ url , $ params = [ ] ) { $ req = $ url instanceof Request ? $ url : $ this -> buildRequest ( 'POST' , $ url ) ; foreach ( $ params as $ key => $ value ) { $ req -> addPostField ( $ key , $ value ) ; } return $ this -> exec ( $ req ) ; }
Shortcut of POST request
57,305
public function put ( $ url , $ content = '' ) { $ req = $ url instanceof Request ? $ url : $ this -> buildRequest ( 'PUT' , $ url ) ; $ req -> setBody ( $ content ) ; return $ this -> exec ( $ req ) ; }
Shortcut of PUT request
57,306
public function getJson ( $ url , $ params = [ ] ) { $ req = $ this -> buildRequest ( 'GET' , $ url , $ params ) ; $ req -> setHeader ( 'accept' , 'application/json' ) ; $ res = $ this -> exec ( $ req ) ; return $ res === false ? false : $ res -> getJson ( ) ; }
Shortcut of GET restful request as json format
57,307
protected function buildRequest ( $ method , $ url , $ params = [ ] ) { if ( count ( $ params ) > 0 ) { $ url .= strpos ( $ url , '?' ) === false ? '?' : '&' ; $ url .= http_build_query ( $ params ) ; } return new Request ( $ url , $ method ) ; }
Build a http request
57,308
protected function buildRequests ( $ method , $ urls , $ params = [ ] ) { $ reqs = [ ] ; foreach ( $ urls as $ key => $ url ) { $ reqs [ $ key ] = $ this -> buildRequest ( $ method , $ url , $ params ) ; } return $ reqs ; }
Build multiple http requests
57,309
public function generate ( array $ ast ) : string { $ this -> traverser -> traverse ( $ ast ) ; $ generatedCode = parent :: generate ( $ ast ) ; $ className = trim ( $ this -> visitor -> getNamespace ( ) . '\\' . $ this -> visitor -> getName ( ) , '\\' ) ; $ fileName = $ this -> fileLocator -> getGeneratedClassFileName ( $ className ) ; $ tmpFileName = $ fileName . '.' . uniqid ( '' , true ) ; file_put_contents ( $ tmpFileName , "<?php\n\n" . $ generatedCode ) ; rename ( $ tmpFileName , $ fileName ) ; return $ generatedCode ; }
Write generated code to disk and return the class code
57,310
public function notification ( string $ method , array $ parameters ) { if ( $ this -> isSingleRequest ) { $ this -> units = [ ] ; } $ this -> units [ ] = new Notification ( $ method , $ parameters ) ; if ( $ this -> isSingleRequest ) { $ this -> execute ( new InvokeSpec ( $ this -> units , true ) ) ; return null ; } return $ this ; }
Make notification request
57,311
public function batchExecute ( ) { $ results = $ this -> execute ( new InvokeSpec ( $ this -> units , false ) ) -> getResults ( ) ; $ callMap = [ ] ; foreach ( $ this -> units as $ index => $ unit ) { $ callMap [ $ unit -> getRawId ( ) ] = $ index ; } if ( count ( $ results ) !== count ( $ this -> units ) ) { throw new InvalidResponseException ( ) ; } $ resultSequence = [ ] ; foreach ( $ results as $ result ) { if ( $ result instanceof Result ) { $ resultSequence [ $ callMap [ $ result -> getId ( ) ] ] = $ result -> getResult ( ) ; } elseif ( $ result instanceof Error ) { $ resultSequence [ $ callMap [ $ result -> getId ( ) ] ] = $ this -> serverErrorMode === self :: ERRMODE_EXCEPTION ? $ result -> getBaseException ( ) : null ; } } ksort ( $ resultSequence ) ; $ this -> units = [ ] ; return $ resultSequence ; }
Execute batch request
57,312
protected function getTotal ( $ VisitorsID ) { $ VisitorsTotalVisitCount = 0 ; $ VisitorsTotalHitCount = 0 ; if ( $ VisitorsID ) { $ objVisitorsTotalCount = \ Database :: getInstance ( ) -> prepare ( "SELECT SUM(visitors_visit) AS SUMV, SUM(visitors_hit) AS SUMH FROM tl_visitors_counter WHERE vid=?" ) -> execute ( $ VisitorsID ) ; if ( $ objVisitorsTotalCount -> numRows > 0 ) { $ objVisitorsTotalCount -> next ( ) ; $ VisitorsTotalVisitCount = ( $ objVisitorsTotalCount -> SUMV === null ) ? 0 : $ objVisitorsTotalCount -> SUMV ; $ VisitorsTotalHitCount = ( $ objVisitorsTotalCount -> SUMH === null ) ? 0 : $ objVisitorsTotalCount -> SUMH ; } } return array ( 'VisitorsTotalVisitCount' => $ this -> getFormattedNumber ( $ VisitorsTotalVisitCount , 0 ) , 'VisitorsTotalHitCount' => $ this -> getFormattedNumber ( $ VisitorsTotalHitCount , 0 ) ) ; }
Total Hits und Visits
57,313
protected function getSearchEngine ( $ VisitorsKatID ) { $ VisitorsSearchEngines = array ( ) ; $ VisitorsSearchEngineKeywords = array ( ) ; $ day60 = mktime ( 0 , 0 , 0 , date ( "m" ) - 2 , date ( "d" ) , date ( "Y" ) ) ; $ objVisitors = \ Database :: getInstance ( ) -> prepare ( "SELECT tl_visitors.id AS id FROM tl_visitors LEFT JOIN tl_visitors_category ON (tl_visitors_category.id=tl_visitors.pid) WHERE tl_visitors.pid=? AND published=? ORDER BY id" ) -> limit ( 1 ) -> execute ( $ VisitorsKatID , 1 ) ; if ( $ objVisitors -> numRows > 0 ) { $ objVisitors -> next ( ) ; $ VisitorsID = $ objVisitors -> id ; $ objVisitorsSearchEngines = \ Database :: getInstance ( ) -> prepare ( "SELECT `visitors_searchengine`, count(*) as anz FROM `tl_visitors_searchengines` WHERE `vid`=? AND `tstamp` > ? GROUP BY 1 ORDER BY anz DESC" ) -> limit ( 20 ) -> execute ( $ VisitorsID , $ day60 ) ; if ( $ objVisitorsSearchEngines -> numRows > 0 ) { while ( $ objVisitorsSearchEngines -> next ( ) ) { if ( 'Generic' == $ objVisitorsSearchEngines -> visitors_searchengine ) { $ objVisitorsSearchEngines -> visitors_searchengine = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'tl_visitors_stat' ] [ 'searchengine_unknown' ] ; } $ VisitorsSearchEngines [ ] = array ( $ objVisitorsSearchEngines -> visitors_searchengine , $ objVisitorsSearchEngines -> anz ) ; } } $ objVisitorsSearchEngineKeywords = \ Database :: getInstance ( ) -> prepare ( "SELECT `visitors_searchengine`, lower(`visitors_keywords`) AS keyword, count(*) AS anz FROM `tl_visitors_searchengines` WHERE `vid`=? AND `tstamp` > ? GROUP BY 1,2 ORDER BY anz DESC" ) -> limit ( 20 ) -> execute ( $ VisitorsID , $ day60 ) ; if ( $ objVisitorsSearchEngineKeywords -> numRows > 0 ) { while ( $ objVisitorsSearchEngineKeywords -> next ( ) ) { if ( 'notdefined' == $ objVisitorsSearchEngineKeywords -> keyword ) { $ objVisitorsSearchEngineKeywords -> keyword = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'tl_visitors_stat' ] [ 'not_defined' ] ; } if ( 'Generic' == $ objVisitorsSearchEngineKeywords -> visitors_searchengine ) { $ objVisitorsSearchEngineKeywords -> visitors_searchengine = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'tl_visitors_stat' ] [ 'searchengine_unknown' ] ; } $ VisitorsSearchEngineKeywords [ ] = array ( $ objVisitorsSearchEngineKeywords -> visitors_searchengine , $ objVisitorsSearchEngineKeywords -> keyword , $ objVisitorsSearchEngineKeywords -> anz ) ; } } } if ( 0 == count ( $ VisitorsSearchEngines ) && 0 == count ( $ VisitorsSearchEngineKeywords ) ) { return false ; } return array ( 'SearchEngines' => $ VisitorsSearchEngines , 'SearchEngineKeywords' => $ VisitorsSearchEngineKeywords ) ; }
TOP 20 SearchEngine
57,314
protected function getReferrerTop ( $ VisitorsID ) { $ topNo = 30 ; $ VisitorsReferrerTop = array ( ) ; if ( $ VisitorsID ) { $ objVisitorsReferrerTop = \ Database :: getInstance ( ) -> prepare ( "SELECT `visitors_referrer_dns`, count(`id`) AS SUMRT FROM tl_visitors_referrer WHERE vid=? GROUP BY `visitors_referrer_dns` ORDER BY SUMRT DESC, visitors_referrer_dns ASC" ) -> limit ( $ topNo ) -> execute ( $ VisitorsID ) ; if ( $ objVisitorsReferrerTop -> numRows > 0 ) { while ( $ objVisitorsReferrerTop -> next ( ) ) { if ( $ objVisitorsReferrerTop -> visitors_referrer_dns !== '-' ) { $ VisitorsReferrerTop [ ] = array ( $ objVisitorsReferrerTop -> visitors_referrer_dns , $ objVisitorsReferrerTop -> SUMRT , $ VisitorsID ) ; } else { $ VisitorsReferrerTop [ ] = array ( '- (' . $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'tl_visitors_stat' ] [ 'referrer_direct' ] . ')' , $ objVisitorsReferrerTop -> SUMRT , 0 ) ; } } } } return $ VisitorsReferrerTop ; }
TOP 30 Referrer
57,315
protected function parseDateVisitors ( $ language = 'en' , $ intTstamp = null , $ prefix = '' ) { switch ( $ language ) { case 'de' : $ strModified = $ prefix . 'd.m.Y' ; break ; case 'en' : $ strModified = $ prefix . 'Y-m-d' ; break ; default : $ strModified = $ prefix . $ GLOBALS [ 'TL_CONFIG' ] [ 'dateFormat' ] ; break ; } if ( is_null ( $ intTstamp ) ) { $ strDate = date ( $ strModified ) ; } elseif ( ! is_numeric ( $ intTstamp ) ) { return '' ; } else { $ strDate = \ Date :: parse ( $ strModified , $ intTstamp ) ; } return $ strDate ; }
Timestamp nach Datum in deutscher oder internationaler Schreibweise
57,316
protected function getVisitorCategoriesByUsergroups ( ) { $ arrVisitorCats = array ( ) ; $ objVisitorCat = \ Database :: getInstance ( ) -> prepare ( "SELECT `id` , `title` , `visitors_stat_protected` , `visitors_stat_groups` FROM tl_visitors_category WHERE 1 ORDER BY title " ) -> execute ( ) ; while ( $ objVisitorCat -> next ( ) ) { if ( true === $ this -> isUserInVisitorStatGroups ( $ objVisitorCat -> visitors_stat_groups , ( bool ) $ objVisitorCat -> visitors_stat_protected ) ) { $ arrVisitorCats [ ] = array ( 'id' => $ objVisitorCat -> id , 'title' => $ objVisitorCat -> title ) ; } } if ( 0 == count ( $ arrVisitorCats ) ) { $ arrVisitorCats [ ] = array ( 'id' => '0' , 'title' => '---------' ) ; } return $ arrVisitorCats ; }
Get visitor categories by usergroups
57,317
protected function isUserInVisitorStatGroups ( $ visitors_stat_groups , $ visitors_stat_protected ) { if ( true === $ this -> User -> isAdmin ) { return true ; } if ( false === $ visitors_stat_protected ) { return true ; } if ( 0 == strlen ( $ visitors_stat_groups ) ) { return false ; } foreach ( deserialize ( $ visitors_stat_groups ) as $ id => $ groupid ) { if ( true === $ this -> User -> isMemberOf ( $ groupid ) ) { return true ; } } return false ; }
Check if User member of group in visitor statistik groups
57,318
public static function getIdentifier ( string $ name ) : string { return str_replace ( '.' , '' , uniqid ( preg_match ( static :: VALID_IDENTIFIER_FORMAT , $ name ) ? $ name : static :: DEFAULT_IDENTIFIER , true ) ) ; }
Generates a valid unique identifier from the given name
57,319
public function findHashed ( Query $ query , array $ options ) { $ field = $ this -> _config [ 'field' ] ; if ( ! $ field ) { return $ query ; } $ idField = $ this -> _primaryKey ; $ query -> formatResults ( function ( $ results ) use ( $ field , $ idField ) { $ newResult = [ ] ; $ results -> each ( function ( $ row , $ key ) use ( $ field , $ idField , & $ newResult ) { if ( ! empty ( $ row [ $ idField ] ) ) { $ row [ $ field ] = $ this -> encodeId ( $ row [ $ idField ] ) ; if ( $ row instanceof EntityInterface ) { $ row -> setDirty ( $ field , false ) ; } $ newResult [ ] = $ row ; } elseif ( is_string ( $ row ) ) { $ newResult [ $ this -> encodeId ( $ key ) ] = $ row ; } else { $ newResult [ ] = $ row ; } } ) ; return new Collection ( $ newResult ) ; } ) ; if ( ! empty ( $ options [ static :: HID ] ) ) { $ id = $ this -> decodeHashid ( $ options [ static :: HID ] ) ; $ query -> where ( [ $ idField => $ id ] ) ; } $ first = $ this -> _config [ 'findFirst' ] === true ? 'first' : $ this -> _config [ 'findFirst' ] ; if ( ! $ first || ! empty ( $ options [ 'noFirst' ] ) ) { return $ query ; } return $ query -> first ( ) ; }
Custom finder for hashids field .
57,320
public function spacy_entities ( $ text , $ lang = 'en' ) { $ data = $ this -> post_call ( '/spacy/entities' , [ 'text' => $ text , 'lang' => $ lang ] ) ; return ( ! empty ( $ data [ 'entities' ] ) ) ? $ data [ 'entities' ] : null ; }
Spacy . io Entity Extraction
57,321
public function afinn_sentiment ( $ text , $ lang = 'en' ) { $ data = $ this -> post_call ( '/afinn' , [ 'text' => $ text , 'lang' => $ lang ] ) ; return ( isset ( $ data [ 'afinn' ] ) ) ? $ data [ 'afinn' ] : null ; }
AFINN Sentiment Analysis
57,322
public function summarize ( $ text , $ word_count = null ) { $ data = $ this -> post_call ( '/gensim/summarize' , [ 'text' => $ text , 'word_count' => $ word_count ] ) ; return ( ! empty ( $ data [ 'summarize' ] ) ) ? $ data [ 'summarize' ] : null ; }
Summarize long text
57,323
public function newspaper_html ( $ html ) { $ data = $ this -> post_call ( '/newspaper' , [ 'html' => $ html ] ) ; return ( ! empty ( $ data [ 'newspaper' ] ) ) ? $ data [ 'newspaper' ] : null ; }
Article Extraction from HTML
57,324
public function newspaper ( $ url ) { $ data = $ this -> get_call ( '/newspaper' , [ 'url' => $ url ] ) ; return ( ! empty ( $ data [ 'newspaper' ] ) ) ? $ data [ 'newspaper' ] : null ; }
Article Extraction from URL
57,325
public function readability ( $ url ) { $ data = $ this -> get_call ( '/readability' , [ 'url' => $ url ] ) ; return ( ! empty ( $ data [ 'readability' ] ) ) ? $ data [ 'readability' ] : null ; }
Readability Article Extraction from URL
57,326
public function readability_html ( $ html ) { $ data = $ this -> post_call ( '/readability' , [ 'html' => $ html ] ) ; return ( ! empty ( $ data [ 'readability' ] ) ) ? $ data [ 'readability' ] : null ; }
Readability Article Extraction from HTML
57,327
public function sentiment ( $ text , $ language = null ) { $ data = $ this -> post_call ( '/polyglot/sentiment' , [ 'text' => $ text , 'lang' => $ language ] ) ; return ( isset ( $ data [ 'sentiment' ] ) ) ? $ data [ 'sentiment' ] : null ; }
Sentiment Analysis by Polyglot
57,328
public function neighbours ( $ word , $ lang = 'en' ) { $ data = $ this -> get_call ( '/polyglot/neighbours' , [ 'word' => $ word , 'lang' => $ lang ] ) ; return ( ! empty ( $ data [ 'neighbours' ] ) ) ? $ data [ 'neighbours' ] : null ; }
Get neighbouring words
57,329
public function polyglot_entities ( $ text , $ language = null ) { $ data = $ this -> post_call ( '/polyglot/entities' , [ 'text' => $ text , 'lang' => $ language ] ) ; $ this -> msg ( $ data ) ; return new \ Web64 \ Nlp \ Classes \ PolyglotResponse ( $ data [ 'polyglot' ] ) ; }
Get entities and sentiment analysis of text
57,330
public function language ( $ text ) { $ data = $ this -> post_call ( '/langid' , [ 'text' => $ text ] ) ; if ( isset ( $ data [ 'langid' ] ) && isset ( $ data [ 'langid' ] [ 'language' ] ) ) { if ( $ data [ 'langid' ] [ 'language' ] == 'nn' || $ data [ 'langid' ] [ 'language' ] == 'nb' ) return 'no' ; return $ data [ 'langid' ] [ 'language' ] ; } return null ; }
Get language code for text
57,331
private function chooseHost ( ) { $ random_a = $ this -> api_hosts ; shuffle ( $ random_a ) ; foreach ( $ random_a as $ api_url ) { $ this -> msg ( "chooseHost() - Testing: $api_url " ) ; $ content = @ file_get_contents ( $ api_url ) ; if ( empty ( $ content ) ) { $ this -> msg ( $ content ) ; $ this -> msg ( "- Ignoring failed API URL: $api_url " ) ; } else { $ this -> api_url = $ api_url ; $ this -> msg ( "- Working API URL: $api_url" ) ; return true ; } $ this -> msg ( $ content ) ; } return false ; }
find working host
57,332
public function updateCMSFields ( FieldList $ fields ) { $ fields -> removeByName ( 'Metadata' ) ; $ fields -> addFieldToTab ( 'Root.Main' , TextAreaField :: create ( 'MetaDescription' , _t ( 'JonoM\ShareCare\ShareCareSummary.SummaryTitle' , 'Content summary' ) ) -> setDescription ( _t ( 'JonoM\ShareCare\ShareCareSummary.SummaryDescription' , 'Summarise the content of this page. This will be used for search engine results and social media so make it enticing.' ) ) -> setAttribute ( 'placeholder' , $ this -> owner -> getDefaultOGDescription ( ) ) -> setRows ( 2 ) , 'Content' ) ; $ imgFieldDescription = _t ( 'JonoM\ShareCare\ShareCareSummary.ImageDescription' , 'Choose an image to represent this page in listings and on social media.' ) ; if ( ! $ this -> owner -> MetaImageID && $ this -> owner -> isPublished ( ) ) { $ imgFieldDescription .= " <i style=\"color:#ec720f\">" . _t ( 'JonoM\ShareCare\ShareCareSummary.ImageDescriptionNotEmpty' , 'For best results, please don\'t leave this empty.' ) . "</i>" ; } $ fields -> addFieldToTab ( 'Root.Main' , UploadField :: create ( 'MetaImage' , _t ( 'JonoM\ShareCare\ShareCareSummary.ImageTitle' , 'Summary image' ) ) -> setAllowedFileCategories ( 'image' ) -> setAllowedMaxFileNumber ( 1 ) -> setDescription ( $ imgFieldDescription ) , 'Content' ) ; }
Add and re - arrange CMS fields for streamlined summary editing .
57,333
public function leaveNode ( Node $ node ) { $ filter = $ this -> filter ; if ( ! $ node instanceof ClassMethod || null === ( $ filterResult = $ filter ( $ node ) ) ) { return null ; } if ( false === $ filterResult ) { return false ; } $ node -> stmts = array ( new Throw_ ( new New_ ( new FullyQualified ( 'BadMethodCallException' ) , array ( new Arg ( new String_ ( 'Method is disabled' ) ) ) ) ) ) ; return $ node ; }
Replaces the given node if it is a class method and matches according to the given callback
57,334
public function isDomain ( $ host ) { $ dnsResult = false ; $ dnsResult = @ dns_get_record ( \ Idna :: encode ( $ host ) , DNS_ANY ) ; if ( $ dnsResult ) { ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , ': True' ) ; return true ; } ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , ': False' ) ; return false ; }
Check if Domain valid
57,335
public function updateCMSFields ( FieldList $ fields ) { $ msg = _t ( 'JonoM\ShareCare\ShareCare.CMSMessage' , 'When this page is shared by people on social media it will look something like this:' ) ; $ tab = 'Root.' . _t ( 'JonoM\ShareCare\ShareCare.TabName' , 'Share' ) ; if ( $ msg ) { $ fields -> addFieldToTab ( $ tab , new LiteralField ( 'ShareCareMessage' , '<div class="message notice"><p>' . $ msg . '</p></div>' ) ) ; } $ fields -> addFieldToTab ( $ tab , new LiteralField ( 'ShareCarePreview' , $ this -> owner -> RenderWith ( 'ShareCarePreview' , array ( 'IncludeTwitter' => self :: config ( ) -> get ( 'twitter_card' ) , 'IncludePinterest' => self :: config ( ) -> get ( 'pinterest' ) ) ) ) ) ; }
Add a Social Media tab with a preview of share appearance to the CMS .
57,336
public function FacebookShareLink ( ) { if ( ! $ this -> owner -> hasMethod ( 'AbsoluteLink' ) ) { return false ; } $ pageURL = rawurlencode ( $ this -> owner -> AbsoluteLink ( ) ) ; return ( $ pageURL ) ? "https://www.facebook.com/sharer/sharer.php?u=$pageURL" : false ; }
Generate a URL to share this content on Facebook .
57,337
public function EmailShareLink ( ) { if ( ! $ this -> owner -> hasMethod ( 'AbsoluteLink' ) ) { return false ; } $ pageURL = $ this -> owner -> AbsoluteLink ( ) ; $ subject = rawurlencode ( _t ( 'JonoM\ShareCare\ShareCare.EmailSubject' , 'Thought you might like this' ) ) ; $ body = rawurlencode ( _t ( 'JonoM\ShareCare\ShareCare.EmailBody' , 'Thought of you when I found this: {URL}' , array ( 'URL' => $ pageURL ) ) ) ; return ( $ pageURL ) ? "mailto:?subject=$subject&body=$body" : false ; }
Generate a mailto URL to share this content via Email .
57,338
public static function logMessage ( $ strMessage , $ strLog = null ) { if ( $ strLog === null ) { $ strLog = 'prod-' . date ( 'Y-m-d' ) . '.log' ; } else { $ strLog = 'prod-' . date ( 'Y-m-d' ) . '-' . $ strLog . '.log' ; } $ strLogsDir = null ; if ( ( $ container = \ System :: getContainer ( ) ) !== null ) { $ strLogsDir = $ container -> getParameter ( 'kernel.logs_dir' ) ; } if ( ! $ strLogsDir ) { $ strLogsDir = TL_ROOT . '/var/logs' ; } error_log ( sprintf ( "[%s] %s\n" , date ( 'd-M-Y H:i:s' ) , $ strMessage ) , 3 , $ strLogsDir . '/' . $ strLog ) ; }
Wrapper for old log_message
57,339
public static function useSocks5 ( $ host , $ port = 1080 , $ user = null , $ pass = null ) { if ( $ host === null ) { self :: $ _socks5 = [ ] ; } else { self :: $ _socks5 = [ 'conn' => 'tcp://' . $ host . ':' . $ port ] ; if ( $ user !== null && $ pass !== null ) { self :: $ _socks5 [ 'user' ] = $ user ; self :: $ _socks5 [ 'pass' ] = $ pass ; } } }
Set socks5 proxy server
57,340
public static function connect ( $ conn , $ arg = null ) { $ obj = null ; if ( ! isset ( self :: $ _objs [ $ conn ] ) ) { self :: $ _objs [ $ conn ] = [ ] ; } foreach ( self :: $ _objs [ $ conn ] as $ tmp ) { if ( ! ( $ tmp -> flag & self :: FLAG_BUSY ) ) { Client :: debug ( 'reuse conn \'' , $ tmp -> conn , '\': ' , $ tmp -> sock ) ; $ obj = $ tmp ; break ; } } if ( $ obj === null && count ( self :: $ _objs [ $ conn ] ) < Client :: $ maxBurst ) { $ obj = new self ( $ conn ) ; self :: $ _objs [ $ conn ] [ ] = $ obj ; Client :: debug ( 'create conn \'' , $ conn , '\'' ) ; } if ( $ obj !== null ) { $ obj -> arg = $ arg ; if ( $ obj -> flag & self :: FLAG_OPENED ) { $ obj -> flag |= self :: FLAG_REUSED ; } else { if ( ! $ obj -> openSock ( ) ) { return false ; } } $ obj -> flag |= self :: FLAG_BUSY ; $ obj -> outBuf = null ; $ obj -> outLen = 0 ; } return $ obj ; }
Create connection with built - in pool .
57,341
public function addWriteData ( $ buf ) { if ( $ this -> outBuf === null ) { $ this -> outBuf = $ buf ; } else { $ this -> outBuf .= $ buf ; } }
Append writing cache
57,342
public function proxyRead ( ) { $ proxyState = $ this -> proxyState ; Client :: debug ( 'proxy readState: ' , $ proxyState ) ; if ( $ proxyState === 2 ) { $ buf = $ this -> read ( 2 ) ; if ( $ buf === "\x05\x00" ) { $ this -> proxyState = 5 ; } elseif ( $ buf === "\x05\x02" ) { $ this -> proxyState = 3 ; } } elseif ( $ proxyState === 4 ) { $ buf = $ this -> read ( 2 ) ; if ( $ buf === "\x01\x00" ) { $ this -> proxyState = 5 ; } } elseif ( $ proxyState === 6 ) { $ buf = $ this -> read ( 10 ) ; if ( substr ( $ buf , 0 , 4 ) === "\x05\x00\x00\x01" ) { $ this -> proxyState = 0 ; } } return $ proxyState !== $ this -> proxyState ; }
Read data for proxy communication
57,343
public function proxyWrite ( ) { Client :: debug ( 'proxy writeState: ' , $ this -> proxyState ) ; if ( $ this -> proxyState === 1 ) { $ buf = isset ( self :: $ _socks5 [ 'user' ] ) ? "\x05\x01\x02" : "\x05\x01\x00" ; $ this -> proxyState ++ ; return $ this -> write ( $ buf ) ; } elseif ( $ this -> proxyState === 3 ) { if ( ! isset ( self :: $ _socks5 [ 'user' ] ) ) { return false ; } $ buf = chr ( 0x01 ) . chr ( strlen ( self :: $ _socks5 [ 'user' ] ) ) . self :: $ _socks5 [ 'user' ] . chr ( strlen ( self :: $ _socks5 [ 'pass' ] ) ) . self :: $ _socks5 [ 'pass' ] ; $ this -> proxyState ++ ; return $ this -> write ( $ buf ) ; } elseif ( $ this -> proxyState === 5 ) { $ pa = parse_url ( $ this -> conn ) ; $ buf = "\x05\x01\x00\x01" . pack ( 'Nn' , ip2long ( $ pa [ 'host' ] ) , isset ( $ pa [ 'port' ] ) ? $ pa [ 'port' ] : 80 ) ; $ this -> proxyState ++ ; return $ this -> write ( $ buf ) ; } else { return false ; } }
Write data for proxy communication
57,344
protected function newBaseQueryBuilder ( ) { $ conn = $ this -> getConnection ( ) ; $ grammar = $ conn -> getQueryGrammar ( ) ; return new QueryCacheBuilder ( $ this -> queryCache ( ) , $ conn , $ grammar , $ conn -> getPostProcessor ( ) ) ; }
Overrides the default QueryBuilder to inject the Cache methods .
57,345
public function delete ( ) { if ( $ this -> getCacheBusting ( ) ) { $ this -> queryCache ( ) -> flush ( $ this -> getTable ( ) ) ; } return parent :: delete ( ) ; }
Flushes the cache on deletes .
57,346
protected function visitorCheckReferrer ( $ vid ) { if ( $ this -> _HitCounted === true ) { if ( $ this -> _PF === false ) { $ ModuleVisitorReferrer = new ModuleVisitorReferrer ( ) ; $ ModuleVisitorReferrer -> checkReferrer ( ) ; $ ReferrerDNS = $ ModuleVisitorReferrer -> getReferrerDNS ( ) ; $ ReferrerFull = $ ModuleVisitorReferrer -> getReferrerFull ( ) ; if ( $ ReferrerDNS != 'o' && $ ReferrerDNS != 'w' ) { $ arrSet = array ( 'vid' => $ vid , 'tstamp' => time ( ) , 'visitors_referrer_dns' => $ ReferrerDNS , 'visitors_referrer_full' => $ ReferrerFull ) ; \ Database :: getInstance ( ) -> prepare ( "INSERT INTO tl_visitors_referrer %s" ) -> set ( $ arrSet ) -> execute ( ) ; $ CleanTime = mktime ( 0 , 0 , 0 , date ( "m" ) - 4 , date ( "d" ) , date ( "Y" ) ) ; \ Database :: getInstance ( ) -> prepare ( "DELETE FROM tl_visitors_referrer WHERE tstamp < ? AND vid = ?" ) -> execute ( $ CleanTime , $ vid ) ; } } } }
Check for Referrer
57,347
protected function visitorGetPageType ( $ objPage ) { $ PageId = $ objPage -> id ; $ page_type = self :: PAGE_TYPE_NORMAL ; if ( $ objPage -> protected == 1 ) { $ this -> import ( 'FrontendUser' , 'User' ) ; if ( ! $ this -> User -> authenticate ( ) ) { $ page_type = self :: PAGE_TYPE_FORBIDDEN ; ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'PageType: ' . $ page_type ) ; return $ page_type ; } } if ( ! isset ( $ _GET [ 'items' ] ) && \ Config :: get ( 'useAutoItem' ) && isset ( $ _GET [ 'auto_item' ] ) ) { \ Input :: setGet ( 'items' , \ Input :: get ( 'auto_item' ) ) ; } if ( ! \ Input :: get ( 'items' ) ) { ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'PageType: ' . $ page_type ) ; return $ page_type ; } if ( \ Input :: get ( 'items' ) && \ Database :: getInstance ( ) -> tableExists ( 'tl_news' ) ) { $ objReaderPage = \ Database :: getInstance ( ) -> prepare ( "SELECT id FROM tl_news_archive WHERE jumpTo=?" ) -> limit ( 1 ) -> execute ( $ PageId ) ; if ( $ objReaderPage -> numRows > 0 ) { $ page_type = self :: PAGE_TYPE_NEWS ; } } if ( \ Input :: get ( 'items' ) && \ Database :: getInstance ( ) -> tableExists ( 'tl_faq_category' ) ) { $ objReaderPage = \ Database :: getInstance ( ) -> prepare ( "SELECT id FROM tl_faq_category WHERE jumpTo=?" ) -> limit ( 1 ) -> execute ( $ PageId ) ; if ( $ objReaderPage -> numRows > 0 ) { $ page_type = self :: PAGE_TYPE_FAQ ; } } if ( \ Input :: get ( 'items' ) && \ Database :: getInstance ( ) -> tableExists ( 'tl_iso_product' ) ) { $ strAlias = \ Input :: get ( 'items' ) ; ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'Get items: ' . print_r ( $ strAlias , true ) ) ; $ objReaderPage = \ Database :: getInstance ( ) -> prepare ( "SELECT id FROM tl_iso_product WHERE alias=?" ) -> limit ( 1 ) -> execute ( $ strAlias ) ; if ( $ objReaderPage -> numRows > 0 ) { $ page_type = self :: PAGE_TYPE_ISOTOPE ; } } ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'PageType: ' . $ page_type ) ; return $ page_type ; }
Get Page - Type
57,348
protected function visitorGetPageIdByType ( $ PageId , $ PageType , $ PageAlias ) { if ( $ PageType == self :: PAGE_TYPE_NORMAL ) { ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'PageIdNormal: ' . $ PageId ) ; return $ PageId ; } if ( $ PageType == self :: PAGE_TYPE_FORBIDDEN ) { ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'PageIdNormal over 403: ' . $ PageId ) ; return $ PageId ; } $ uri = $ _SERVER [ 'REQUEST_URI' ] ; $ alias = '' ; $ urlSuffix = \ System :: getContainer ( ) -> getParameter ( 'contao.url_suffix' ) ; if ( substr ( $ uri , - strlen ( $ urlSuffix ) ) == $ urlSuffix ) { $ alias = substr ( $ uri , strrpos ( $ uri , '/' ) + 1 , - strlen ( $ urlSuffix ) ) ; if ( false === $ alias ) { ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'PageIdReaderSelf: ' . $ PageId ) ; return $ PageId ; } } else { $ alias = substr ( $ uri , strrpos ( $ uri , '/' ) + 1 ) ; } ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'Alias: ' . $ alias ) ; if ( $ PageType == self :: PAGE_TYPE_NEWS ) { $ objNews = \ Database :: getInstance ( ) -> prepare ( "SELECT id FROM tl_news WHERE alias=?" ) -> limit ( 1 ) -> execute ( $ alias ) ; if ( $ objNews -> numRows > 0 ) { ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'PageIdNews: ' . $ objNews -> id ) ; return $ objNews -> id ; } } if ( $ PageType == self :: PAGE_TYPE_FAQ ) { $ objFaq = \ Database :: getInstance ( ) -> prepare ( "SELECT id FROM tl_faq WHERE alias=?" ) -> limit ( 1 ) -> execute ( $ alias ) ; if ( $ objFaq -> numRows > 0 ) { ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'PageIdFaq: ' . $ objFaq -> id ) ; return $ objFaq -> id ; } } if ( $ PageType == self :: PAGE_TYPE_ISOTOPE ) { $ objIsotope = \ Database :: getInstance ( ) -> prepare ( "SELECT id FROM tl_iso_product WHERE alias=?" ) -> limit ( 1 ) -> execute ( $ alias ) ; if ( $ objIsotope -> numRows > 0 ) { ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'PageIdIsotope: ' . $ objIsotope -> id ) ; return $ objIsotope -> id ; } } ModuleVisitorLog :: writeLog ( __METHOD__ , __LINE__ , 'Unknown PageType: ' . $ PageType ) ; }
Get Page - ID by Page - Type
57,349
public function setHeader ( $ key , $ value = null , $ toLower = true ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ k => $ v ) { $ this -> setHeader ( $ k , $ v ) ; } } else { if ( $ toLower === true ) { $ key = strtolower ( $ key ) ; } if ( $ value === null ) { unset ( $ this -> _headers [ $ key ] ) ; } else { $ this -> _headers [ $ key ] = $ value ; } } }
Set http header or headers
57,350
public function addHeader ( $ key , $ value = null , $ toLower = true ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ k => $ v ) { $ this -> addHeader ( $ k , $ v ) ; } } else { if ( $ value !== null ) { if ( $ toLower === true ) { $ key = strtolower ( $ key ) ; } if ( ! isset ( $ this -> _headers [ $ key ] ) ) { $ this -> _headers [ $ key ] = $ value ; } else { if ( is_array ( $ this -> _headers [ $ key ] ) ) { $ this -> _headers [ $ key ] [ ] = $ value ; } else { $ this -> _headers [ $ key ] = [ $ this -> _headers [ $ key ] , $ value ] ; } } } } }
Add http header or headers
57,351
public function getHeader ( $ key = null , $ toLower = true ) { if ( $ key === null ) { return $ this -> _headers ; } if ( $ toLower === true ) { $ key = strtolower ( $ key ) ; } return isset ( $ this -> _headers [ $ key ] ) ? $ this -> _headers [ $ key ] : null ; }
Get a http header or all http headers
57,352
public function hasHeader ( $ key , $ toLower = true ) { if ( $ toLower === true ) { $ key = strtolower ( $ key ) ; } return isset ( $ this -> _headers [ $ key ] ) ; }
Check HTTP header is set or not
57,353
public function setRawCookie ( $ key , $ value , $ expires = null , $ domain = '-' , $ path = '/' ) { $ domain = strtolower ( $ domain ) ; if ( substr ( $ domain , 0 , 1 ) === '.' ) { $ domain = substr ( $ domain , 1 ) ; } if ( ! isset ( $ this -> _cookies [ $ domain ] ) ) { $ this -> _cookies [ $ domain ] = [ ] ; } if ( ! isset ( $ this -> _cookies [ $ domain ] [ $ path ] ) ) { $ this -> _cookies [ $ domain ] [ $ path ] = [ ] ; } $ list = & $ this -> _cookies [ $ domain ] [ $ path ] ; if ( $ value === null || $ value === '' || ( $ expires !== null && $ expires < time ( ) ) ) { unset ( $ list [ $ key ] ) ; } else { $ list [ $ key ] = [ 'value' => $ value , 'expires' => $ expires ] ; } }
Set a raw cookie
57,354
public function clearCookie ( $ domain = '-' , $ path = null ) { if ( $ domain === null ) { $ this -> _cookies = [ ] ; } else { $ domain = strtolower ( $ domain ) ; if ( $ path === null ) { unset ( $ this -> _cookies [ $ domain ] ) ; } else { if ( isset ( $ this -> _cookies [ $ domain ] ) ) { unset ( $ this -> _cookies [ $ domain ] [ $ path ] ) ; } } } }
Clean all cookies
57,355
public function getCookie ( $ key , $ domain = '-' ) { $ domain = strtolower ( $ domain ) ; if ( $ key === null ) { $ cookies = [ ] ; } while ( true ) { if ( isset ( $ this -> _cookies [ $ domain ] ) ) { foreach ( $ this -> _cookies [ $ domain ] as $ path => $ list ) { if ( $ key === null ) { $ cookies = array_merge ( $ list , $ cookies ) ; } else { if ( isset ( $ list [ $ key ] ) ) { return rawurldecode ( $ list [ $ key ] [ 'value' ] ) ; } } } } if ( ( $ pos = strpos ( $ domain , '.' , 1 ) ) === false ) { break ; } $ domain = substr ( $ domain , $ pos ) ; } return $ key === null ? $ cookies : null ; }
Get cookie value
57,356
public function applyCookie ( $ req ) { $ host = $ req -> getHeader ( 'host' ) ; $ path = $ req -> getUrlParam ( 'path' ) ; $ cookies = $ this -> fetchCookieToSend ( $ host , $ path ) ; if ( $ this !== $ req ) { $ cookies = array_merge ( $ cookies , $ req -> fetchCookieToSend ( $ host , $ path ) ) ; } $ req -> setHeader ( 'cookie' , null ) ; foreach ( array_chunk ( array_values ( $ cookies ) , 3 ) as $ chunk ) { $ req -> addHeader ( 'cookie' , implode ( '; ' , $ chunk ) ) ; } }
Apply cookies for request
57,357
public function fetchCookieToSend ( $ host , $ path ) { $ now = time ( ) ; $ host = strtolower ( $ host ) ; $ cookies = [ ] ; $ domains = [ '-' , $ host ] ; while ( strlen ( $ host ) > 1 && ( $ pos = strpos ( $ host , '.' , 1 ) ) !== false ) { $ host = substr ( $ host , $ pos + 1 ) ; $ domains [ ] = $ host ; } foreach ( $ domains as $ domain ) { if ( ! isset ( $ this -> _cookies [ $ domain ] ) ) { continue ; } foreach ( $ this -> _cookies [ $ domain ] as $ _path => $ list ) { if ( ! strncmp ( $ _path , $ path , strlen ( $ _path ) ) && ( substr ( $ _path , - 1 , 1 ) === '/' || substr ( $ path , strlen ( $ _path ) , 1 ) === '/' ) ) { foreach ( $ list as $ k => $ v ) { if ( ! isset ( $ cookies [ $ k ] ) && ( $ v [ 'expires' ] === null || $ v [ 'expires' ] > $ now ) ) { $ cookies [ $ k ] = $ k . '=' . $ v [ 'value' ] ; } } } } } return $ cookies ; }
Fetch cookies to be sent
57,358
public function setWidth ( $ width ) { if ( ! is_int ( $ width ) ) { throw new \ Exception ( "Falscher Dateityp (" . gettype ( $ width ) . ") integer expected!" ) ; } $ this -> width = $ width ; return true ; }
Breite des Diagramms setzen
57,359
public static function createDefault ( string $ class ) : Rule { $ rule = new Rule ( $ class ) ; $ reflection = new \ ReflectionClass ( $ class ) ; $ properties = $ reflection -> getProperties ( ) ; foreach ( $ properties as $ property ) { $ rule -> assign ( $ property -> getName ( ) , $ property -> getName ( ) ) ; } return $ rule ; }
Create rule with one - to - one mapping
57,360
public function assign ( string $ property , string $ key ) { $ this -> doAssign ( $ property , $ key ) ; return $ this ; }
Simple property - key pair assigning
57,361
public function assignConstructor ( string $ property , string $ key , callable $ fx ) { $ this -> doAssign ( $ property , $ key ) ; $ this -> constructors [ $ property ] = $ fx ; return $ this ; }
Assign property constructor
57,362
public function assignSerializer ( string $ property , string $ key , callable $ fx ) { $ this -> doAssign ( $ property , $ key ) ; $ this -> serializers [ $ property ] = $ fx ; return $ this ; }
Assign property serializer
57,363
public function handle ( string $ path = null , ContainerInterface $ di = null ) { if ( $ this -> mount ) { $ len = strlen ( $ this -> mount ) ; if ( substr ( $ path , 0 , $ len ) == $ this -> mount ) { $ path = ltrim ( substr ( $ path , $ len ) , "/" ) ; } } try { $ handler = new RouteHandler ( ) ; return $ handler -> handle ( $ this -> methodMatched , $ path , $ this -> handler , $ this -> arguments , $ di ) ; } catch ( ConfigurationException $ e ) { throw new ConfigurationException ( $ e -> getMessage ( ) . " Route matched method='{$this->methodMatched}', mount='{$this->mount}', path='$path', handler='" . ( is_string ( $ this -> handler ) ? "$this->handler" : "array/object" ) . "'." ) ; } }
Handle the action for the route .
57,364
public function getMatchedPath ( ) { $ path = $ this -> pathMatched ; if ( $ this -> mount ) { $ len = strlen ( $ this -> mount ) ; if ( substr ( $ path , 0 , $ len ) == $ this -> mount ) { $ path = ltrim ( substr ( $ path , $ len ) , "/" ) ; } } return $ path ; }
Get the matched basename of the path its the part without the mount point .
57,365
public function getHandlerType ( ContainerInterface $ di = null ) : string { $ handler = new RouteHandler ( ) ; return $ handler -> getHandlerType ( $ this -> handler , $ di ) ; }
Get the handler type as a informative string .
57,366
public function redirect ( $ url ) { if ( ( $ this -> status === 301 || $ this -> status === 302 ) && ( $ this -> hasHeader ( 'location' ) ) ) { return ; } $ this -> numRedirected -- ; $ this -> status = 302 ; $ this -> setHeader ( 'location' , $ url ) ; }
Redirect to another url This method can be used in request callback .
57,367
public function getJson ( ) { if ( stripos ( $ this -> getHeader ( 'content-type' ) , '/json' ) !== false ) { return json_decode ( $ this -> body , true ) ; } else { return false ; } }
Get json response data
57,368
public function publishSlides ( ) { $ slides = SlideImage :: get ( ) ; $ ct = 0 ; foreach ( $ this -> getSlides ( ) as $ slide ) { if ( $ slide -> ShowSlide == 1 ) { if ( ! $ slide -> Name ) { $ slide -> Name = "No Name" ; } $ slide -> writeToStage ( 'Stage' ) ; $ slide -> publishRecursive ( ) ; ++ $ ct ; } } static :: write_message ( $ ct . " SlideImages updated" ) ; }
mark all ProductDetail records as ShowInMenus = 0 .
57,369
public static function spawn ( $ cmd , $ cwd = null , LoggerInterface $ logger = null ) { return new self ( $ cmd , $ cwd , $ logger ) ; }
Spawn a new instance of Expect for the given command . You can optionally specify a working directory and a PSR compatible logger to use .
57,370
public function expect ( $ output , $ timeout = self :: DEFAULT_TIMEOUT ) { $ this -> steps [ ] = [ self :: EXPECT , $ output , $ timeout ] ; return $ this ; }
Register a step to expect the given text to show up on stdout . Expect will block and keep checking the stdout buffer until your expectation shows up or the timeout is reached whichever comes first .
57,371
public function send ( $ input ) { if ( stripos ( strrev ( $ input ) , PHP_EOL ) === false ) { $ input = $ input . PHP_EOL ; } $ this -> steps [ ] = [ self :: SEND , $ input ] ; return $ this ; }
Register a step to send the given text on stdin . A newline is added to each string to simulate pressing enter .
57,372
public function run ( ) { $ this -> createProcess ( ) ; foreach ( $ this -> steps as $ step ) { if ( $ step [ 0 ] === self :: EXPECT ) { $ expectation = $ step [ 1 ] ; $ timeout = $ step [ 2 ] ; $ this -> waitForExpectedResponse ( $ expectation , $ timeout ) ; } else { $ input = $ step [ 1 ] ; $ this -> sendInput ( $ input ) ; } } $ this -> closeProcess ( ) ; }
Run the process and execute the registered steps . The program will block until the steps are completed or a timeout occurs .
57,373
private function createProcess ( ) { $ descriptorSpec = [ [ 'pipe' , 'r' ] , [ 'pipe' , 'w' ] , [ 'pipe' , 'r' ] ] ; $ this -> process = proc_open ( $ this -> cmd , $ descriptorSpec , $ this -> pipes , $ this -> cwd ) ; if ( ! is_resource ( $ this -> process ) ) { throw new \ RuntimeException ( 'Could not create the process.' ) ; } }
Create the process .
57,374
private function waitForExpectedResponse ( $ expectation , $ timeout ) { $ response = null ; $ lastLoggedResponse = null ; $ buffer = '' ; $ start = time ( ) ; stream_set_blocking ( $ this -> pipes [ 1 ] , false ) ; while ( true ) { if ( time ( ) - $ start >= $ timeout ) { throw new ProcessTimeoutException ( ) ; } if ( feof ( $ this -> pipes [ 1 ] ) ) { throw new UnexpectedEOFException ( ) ; } if ( ! $ this -> isRunning ( ) ) { throw new ProcessTerminatedException ( ) ; } $ buffer .= fread ( $ this -> pipes [ 1 ] , 4096 ) ; $ response = static :: trimAnswer ( $ buffer ) ; if ( $ response !== '' && $ response !== $ lastLoggedResponse ) { $ lastLoggedResponse = $ response ; $ this -> logger -> info ( "Expected '{$expectation}', got '{$response}'" ) ; } if ( fnmatch ( $ expectation , $ response ) ) { return ; } } }
Wait for the given response to show on stdout .
57,375
private function isRunning ( ) { if ( ! is_resource ( $ this -> process ) ) { return false ; } $ status = proc_get_status ( $ this -> process ) ; return $ status [ 'running' ] ; }
Determine if the process is running .
57,376
public function generate ( array $ ast ) : string { $ code = parent :: generate ( $ ast ) ; if ( ! $ this -> canEval ) { $ fileName = sys_get_temp_dir ( ) . '/EvaluatingGeneratorStrategy.php.tmp.' . uniqid ( '' , true ) ; file_put_contents ( $ fileName , "<?php\n" . $ code ) ; require $ fileName ; unlink ( $ fileName ) ; return $ code ; } eval ( $ code ) ; return $ code ; }
Evaluates the generated code before returning it
57,377
public function setUrl ( $ url ) { $ this -> _rawUrl = $ url ; if ( strncasecmp ( $ url , 'http://' , 7 ) && strncasecmp ( $ url , 'https://' , 8 ) && isset ( $ _SERVER [ 'HTTP_HOST' ] ) ) { if ( substr ( $ url , 0 , 1 ) != '/' ) { $ url = substr ( $ _SERVER [ 'SCRIPT_NAME' ] , 0 , strrpos ( $ _SERVER [ 'SCRIPT_NAME' ] , '/' ) + 1 ) . $ url ; } $ url = 'http://' . $ _SERVER [ 'HTTP_HOST' ] . $ url ; } $ this -> _url = str_replace ( '&amp;' , '&' , $ url ) ; $ this -> _urlParams = null ; }
Set request URL Relative url will be converted to full url by adding host and protocol .
57,378
public function getUrlParams ( ) { if ( $ this -> _urlParams === null ) { $ pa = @ parse_url ( $ this -> getUrl ( ) ) ; $ pa [ 'scheme' ] = isset ( $ pa [ 'scheme' ] ) ? strtolower ( $ pa [ 'scheme' ] ) : 'http' ; if ( $ pa [ 'scheme' ] !== 'http' && $ pa [ 'scheme' ] !== 'https' ) { return false ; } if ( ! isset ( $ pa [ 'host' ] ) ) { return false ; } if ( ! isset ( $ pa [ 'path' ] ) ) { $ pa [ 'path' ] = '/' ; } if ( isset ( $ pa [ 'user' ] ) && isset ( $ pa [ 'pass' ] ) ) { $ this -> applyBasicAuth ( $ pa [ 'user' ] , $ pa [ 'pass' ] ) ; } $ port = isset ( $ pa [ 'port' ] ) ? intval ( $ pa [ 'port' ] ) : ( $ pa [ 'scheme' ] === 'https' ? 443 : 80 ) ; $ pa [ 'ip' ] = $ this -> hasHeader ( 'x-server-ip' ) ? $ this -> getHeader ( 'x-server-ip' ) : self :: getIp ( $ pa [ 'host' ] ) ; $ pa [ 'conn' ] = ( $ pa [ 'scheme' ] === 'https' ? 'ssl' : 'tcp' ) . '://' . $ pa [ 'ip' ] . ':' . $ port ; if ( ! $ this -> hasHeader ( 'host' ) ) { $ this -> setHeader ( 'host' , strtolower ( $ pa [ 'host' ] ) ) ; } else { $ pa [ 'host' ] = $ this -> getHeader ( 'host' ) ; } $ this -> _urlParams = $ pa ; } return $ this -> _urlParams ; }
Get url parameters
57,379
public function getUrlParam ( $ key ) { $ pa = $ this -> getUrlParams ( ) ; return isset ( $ pa [ $ key ] ) ? $ pa [ $ key ] : null ; }
Get url parameter by key
57,380
public function getBody ( ) { $ body = '' ; if ( $ this -> _method === 'POST' || $ this -> _method === 'PUT' ) { if ( $ this -> _body === null ) { $ this -> _body = $ this -> getPostBody ( ) ; } $ this -> setHeader ( 'content-length' , strlen ( $ this -> _body ) ) ; $ body = $ this -> _body . Client :: CRLF ; } return $ body ; }
Get http request body Appending post fields and files .
57,381
public function setBody ( $ body ) { $ this -> _body = $ body ; $ this -> setHeader ( 'content-length' , $ body === null ? null : strlen ( $ body ) ) ; }
Set http request body
57,382
public function setJsonBody ( $ data ) { $ body = json_encode ( $ data , JSON_UNESCAPED_UNICODE ) ; $ this -> setHeader ( 'content-type' , 'application/json' ) ; $ this -> setBody ( $ body ) ; }
Set http request body as Json
57,383
public function addPostField ( $ key , $ value ) { $ this -> setMethod ( 'POST' ) ; $ this -> setBody ( null ) ; if ( ! is_array ( $ value ) ) { $ this -> _postFields [ $ key ] = strval ( $ value ) ; } else { $ value = $ this -> formatArrayField ( $ value ) ; foreach ( $ value as $ k => $ v ) { $ k = $ key . '[' . $ k . ']' ; $ this -> _postFields [ $ k ] = $ v ; } } }
Add field for the request use POST
57,384
public function addPostFile ( $ key , $ file , $ content = null ) { $ this -> setMethod ( 'POST' ) ; $ this -> setBody ( null ) ; if ( $ content === null && is_file ( $ file ) ) { $ content = @ file_get_contents ( $ file ) ; } $ this -> _postFiles [ $ key ] = [ basename ( $ file ) , $ content ] ; }
Add file to be uploaded for request use POST
57,385
protected function getPostBody ( ) { $ data = '' ; if ( count ( $ this -> _postFiles ) > 0 ) { $ boundary = md5 ( $ this -> _rawUrl . microtime ( ) ) ; foreach ( $ this -> _postFields as $ k => $ v ) { $ data .= '--' . $ boundary . Client :: CRLF . 'Content-Disposition: form-data; name="' . $ k . '"' . Client :: CRLF . Client :: CRLF . $ v . Client :: CRLF ; } foreach ( $ this -> _postFiles as $ k => $ v ) { $ ext = strtolower ( substr ( $ v [ 0 ] , strrpos ( $ v [ 0 ] , '.' ) + 1 ) ) ; $ type = isset ( self :: $ _mimes [ $ ext ] ) ? self :: $ _mimes [ $ ext ] : 'application/octet-stream' ; $ data .= '--' . $ boundary . Client :: CRLF . 'Content-Disposition: form-data; name="' . $ k . '"; filename="' . $ v [ 0 ] . '"' . Client :: CRLF . 'Content-Type: ' . $ type . Client :: CRLF . 'Content-Transfer-Encoding: binary' . Client :: CRLF . Client :: CRLF . $ v [ 1 ] . Client :: CRLF ; } $ data .= '--' . $ boundary . '--' . Client :: CRLF ; $ this -> setHeader ( 'content-type' , 'multipart/form-data; boundary=' . $ boundary ) ; } else { if ( count ( $ this -> _postFields ) > 0 ) { foreach ( $ this -> _postFields as $ k => $ v ) { $ data .= '&' . rawurlencode ( $ k ) . '=' . rawurlencode ( $ v ) ; } $ data = substr ( $ data , 1 ) ; $ this -> setHeader ( 'content-type' , 'application/x-www-form-urlencoded' ) ; } } return $ data ; }
Combine request body from post fields & files
57,386
protected static function getIp ( $ host ) { if ( ! isset ( self :: $ _dns [ $ host ] ) ) { self :: $ _dns [ $ host ] = gethostbyname ( $ host ) ; } return self :: $ _dns [ $ host ] ; }
get ip address
57,387
protected function reduceVersion ( ) { if ( $ this -> _version === self :: VERSION_UNKNOWN ) { return ; } if ( stripos ( $ this -> _version , '.' ) !== false ) { $ this -> _version = substr ( $ this -> _version , 0 , stripos ( $ this -> _version , '.' ) + 2 ) ; } }
Modify version for compatibility
57,388
protected function checkBrowserVivaldi ( ) { if ( stripos ( $ this -> _agent , 'Vivaldi' ) !== false ) { $ aresult = explode ( '/' , stristr ( $ this -> _agent , 'Vivaldi' ) ) ; $ aversion = explode ( ' ' , $ aresult [ 1 ] ) ; $ this -> setVersion ( $ aversion [ 0 ] ) ; $ this -> setBrowser ( self :: BROWSER_VIVALDI ) ; return true ; } return false ; }
Determine if the browser is Vivaldi or not
57,389
protected function checkBrowserQtWebBrowser ( ) { if ( stripos ( $ this -> _agent , 'QtWebEngine' ) !== false ) { $ aresult = explode ( '/' , stristr ( $ this -> _agent , 'QtWebEngine' ) ) ; $ aversion = explode ( '.' , $ aresult [ 1 ] ) ; $ this -> setVersion ( $ aversion [ 0 ] ) ; $ this -> setBrowser ( self :: BROWSER_QTWEB ) ; return true ; } return false ; }
Determine if the browser is QtWebBrowser or not
57,390
protected function checkBrowserTOnline ( ) { if ( stripos ( $ this -> _agent , 'T-Online Browser' ) !== false ) { $ this -> setBrowser ( self :: BROWSER_TONLINE ) ; return true ; } return false ; }
Determine if the browser is T - Online Browser or not add by BugBuster
57,391
protected function checkBrowserAndroidHTCDesire ( ) { if ( stripos ( $ this -> _agent , 'Android' ) !== false ) { if ( stripos ( $ this -> _agent , 'HTC_DesireHD' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_DESIRE_HD ) ; return true ; } if ( stripos ( $ this -> _agent , 'HTC Desire Z' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_DESIRE_Z ) ; return true ; } if ( stripos ( $ this -> _agent , 'HTC_DesireS' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_DESIRE_S ) ; return true ; } if ( stripos ( $ this -> _agent , 'HTC_Desire' ) !== false || stripos ( $ this -> _agent , 'HTC Desire' ) !== false || stripos ( $ this -> _agent , 'Desire_A8181' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_DESIRE ) ; return true ; } } return false ; }
Determine if the browser is Android and HTC Desire or not add by BugBuster
57,392
protected function checkBrowserAndroidHTCMagic ( ) { if ( stripos ( $ this -> _agent , 'Android' ) !== false ) { if ( stripos ( $ this -> _agent , 'HTC Magic' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_MAGIC ) ; return true ; } } return false ; }
Determine if the browser is Android and HTC Magic or not add by BugBuster
57,393
protected function checkBrowserAndroidHTCWildfire ( ) { if ( stripos ( $ this -> _agent , 'Android' ) !== false ) { if ( stripos ( $ this -> _agent , 'HTC_WildfireS_A510e' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_WILDFIRES_A510E ) ; return true ; } } return false ; }
Determine if the browser is Android and HTC WildfireS A510e or not add by BugBuster
57,394
protected function checkBrowserAndroidHTCSensation ( ) { if ( stripos ( $ this -> _agent , 'Android' ) !== false || stripos ( $ this -> _agent , 'Macintosh' ) !== false ) { if ( stripos ( $ this -> _agent , 'HTC_SensationXE' ) !== false || stripos ( $ this -> _agent , 'HTC Sensation XE' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_SENSATION_XE ) ; return true ; } if ( stripos ( $ this -> _agent , 'HTC_SensationXL' ) !== false || stripos ( $ this -> _agent , 'HTC Sensation XL' ) !== false || stripos ( $ this -> _agent , 'HTC_Runnymede' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_SENSATION_XL ) ; return true ; } if ( stripos ( $ this -> _agent , 'HTC_Sensation_Z710' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_SENSATION_Z710 ) ; return true ; } if ( stripos ( $ this -> _agent , 'HTC Sensation' ) !== false || stripos ( $ this -> _agent , 'HTC_Sensation' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_HTC_SENSATION ) ; return true ; } } return false ; }
Determine if the browser is Android and HTC Sensation or not add by BugBuster
57,395
protected function checkBrowserChromePlus ( ) { if ( stripos ( $ this -> _agent , 'ChromePlus' ) !== false ) { $ aresult = explode ( '/' , stristr ( $ this -> _agent , 'ChromePlus' ) ) ; $ aversion = explode ( ' ' , $ aresult [ 1 ] ) ; $ this -> setVersion ( $ aversion [ 0 ] ) ; $ this -> setBrowser ( self :: BROWSER_CHROME_PLUS ) ; return true ; } return false ; }
Determine if the browser is ChromePlus or not add by BugBuster
57,396
protected function checkBrowserMaxthon ( ) { if ( stripos ( $ this -> _agent , 'Maxthon' ) !== false ) { $ aresult = explode ( '/' , stristr ( $ this -> _agent , 'Maxthon' ) ) ; $ aversion = explode ( ' ' , $ aresult [ 1 ] ) ; $ this -> setVersion ( $ aversion [ 0 ] ) ; $ this -> setBrowser ( self :: BROWSER_COOL_MAXTHON ) ; return true ; } return false ; }
Determine if the browser is Maxthon or not add by BugBuster
57,397
protected function checkBrowserHTTPRequest2 ( ) { if ( stripos ( $ this -> _agent , 'HTTP_Request2' ) !== false ) { $ aversion = explode ( '/' , stristr ( $ this -> _agent , 'HTTP_Request2' ) ) ; $ this -> setVersion ( $ aversion [ 1 ] ) ; $ this -> setBrowser ( self :: BROWSER_HTTP_REQUEST2 ) ; return true ; } return false ; }
Determine if the browser is Pear HTTP_Request2 or not add by BugBuster
57,398
protected function checkBrowserAndroidAcerA500 ( ) { if ( stripos ( $ this -> _agent , 'Android' ) !== false ) { if ( stripos ( $ this -> _agent , 'A500 Build' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_ACER_A500 ) ; return true ; } } return false ; }
Determine if the browser is an Acer Iconia A500 Tablet or not add by BugBuster
57,399
protected function checkBrowserAndroidAcerA501 ( ) { if ( stripos ( $ this -> _agent , 'Android' ) !== false ) { if ( stripos ( $ this -> _agent , 'A501 Build' ) !== false ) { $ this -> setVersion ( self :: VERSION_UNKNOWN ) ; $ this -> setMobile ( true ) ; $ this -> setBrowser ( self :: BROWSER_ACER_A501 ) ; return true ; } } return false ; }
Determine if the browser is an Acer A501 Tablet or not add by BugBuster