sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
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 @param mixed $data json data
entailment
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 @param string $key field name. @param mixed $value field value, array supported.
entailment
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 @param string $key field name. @param string $file file path to be uploaded. @param string $content file content, default to null and read from file.
entailment
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 @return string request body content
entailment
protected static function getIp($host) { if (!isset(self::$_dns[$host])) { self::$_dns[$host] = gethostbyname($host); } return self::$_dns[$host]; }
get ip address
entailment
private function formatArrayField($arr, $pk = null) { $ret = []; foreach ($arr as $k => $v) { if ($pk !== null) { $k = $pk . $k; } if (is_array($v)) { $ret = array_merge($ret, $this->formatArrayField($v, $k . '][')); } else { $ret[$k] = $v; } } return $ret; }
format array field (convert N-DIM(n>=2) array => 2-DIM array)
entailment
public function run() { /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('mod_visitors_be_stat_details_referrer'); $objTemplate->theme = \Backend::getTheme(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['systemMessages']); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->visitorsbecss = VISITORS_BE_CSS; if ( is_null( \Input::get('tl_vid',true) ) ) { $objTemplate->messages = $GLOBALS['TL_LANG']['tl_visitors_referrer']['no_referrer']; return $objTemplate->getResponse(); } // <h1 class="main_headline">'.$GLOBALS['TL_LANG']['tl_visitors_referrer']['details_for'].': '.\Idna::decode(str_rot13($this->Input->get('tl_referrer',true))).'</h1> $objTemplate->messages = ' <div class="tl_listing_container list_view"> <table cellpadding="0" cellspacing="0" summary="Table lists records" class="mod_visitors_be_table_version"> <tbody> <tr> <td style="padding-left: 2px;" class="tl_folder_tlist">'.$GLOBALS['TL_LANG']['tl_visitors_referrer']['visitor_referrer'].'</td> <td style="width: 145px; padding-left: 2px;" class="tl_folder_tlist">'.$GLOBALS['TL_LANG']['tl_visitors_referrer']['visitor_referrer_last_seen'].'</td> <td style="width: 80px; padding-left: 2px; text-align: center;" class="tl_folder_tlist">'.$GLOBALS['TL_LANG']['tl_visitors_referrer']['number'].'</td> </tr>'; /*$objDetails = \Database::getInstance()->prepare("SELECT `visitors_referrer_full`, count(id) as ANZ" . " FROM `tl_visitors_referrer`" . " WHERE `visitors_referrer_dns` = ?" . " AND `vid` = ?" . " GROUP BY 1 ORDER BY 2 DESC")*/ $objDetails = \Database::getInstance() ->prepare("SELECT visitors_referrer_full, count(id) as ANZ, max(tstamp) as maxtstamp FROM tl_visitors_referrer WHERE visitors_referrer_dns = ? AND vid = ? GROUP BY 1 ORDER BY 2 DESC") ->execute(str_rot13(\Input::get('tl_referrer',true)),\Input::get('tl_vid',true)); $intRows = $objDetails->numRows; if ($intRows > 0) { while ($objDetails->next()) { $objTemplate->messages .= ' <tr> <td class="tl_file_list" style="padding-left: 2px; text-align: left;">'.rawurldecode(htmlspecialchars(\Idna::decode($objDetails->visitors_referrer_full))).'</td> <td class="tl_file_list" style="padding-left: 2px; text-align: left;">'.date($GLOBALS['TL_CONFIG']['datimFormat'],$objDetails->maxtstamp).'</td> <td class="tl_file_list" style="text-align: center;">'.$objDetails->ANZ.'</td> </tr>'; } } else { $objTemplate->messages .= ' <tr> <td colspan="3">'.$GLOBALS['TL_LANG']['tl_visitors_referrer']['no_data'].'</td> </tr>'; } $objTemplate->messages .= ' <tr> <td colspan="3">&nbsp;</td> </tr> </tbody> </table> </div>'; return $objTemplate->getResponse(); }
Run the controller and parse the template @return Response
entailment
public function send(string $request): string { $stream = fopen(trim($this->url), 'rb', false, $this->buildContext($request)); if (!is_resource($stream)) { throw new ConnectionFailureException('Unable to establish a connection'); } $this->headers = $this->getDefaultHeaders(); return stream_get_contents($stream); }
Send request @param string $request @return string
entailment
protected function determine() { $this->checkPlatform(); $this->checkBrowsers(); $this->checkForAol(); $this->reduceVersion(); //modified for compatibility $this->checkPlatformVersion(); //add BugBuster }
Protected routine to calculate and determine what the browser is in use (including platform)
entailment
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
entailment
protected function checkBrowsers() { return ( // well-known, well-used // Special Notes: // (1) Opera must be checked before FireFox due to the odd // user agents used in some older versions of Opera // (2) WebTV is strapped onto Internet Explorer so we must // check for WebTV before IE // (3) (deprecated) Galeon is based on Firefox and needs to be // tested before Firefox is tested // (4) OmniWeb is based on Safari so OmniWeb check must occur // before Safari // (5) Netscape 9+ is based on Firefox so Netscape checks // before FireFox are necessary $this->checkBrowserWebTv() || $this->checkBrowserMaxthon() || //add BugBuster, must be before IE, (Dual Engine: Webkit and Trident) $this->checkBrowserInternetExplorer() || $this->checkBrowserGaleon() || $this->checkBrowserNetscapeNavigator9Plus() || $this->checkBrowserFirefox() || $this->checkBrowserSongbird() || //add BugBuster $this->checkBrowserSeaMonkey() || //add BugBuster $this->checkBrowserChromePlus() || //add BugBuster $this->checkBrowserCoolNovo() || //add BugBuster $this->checkBrowserVivaldi() || //add BugBuster $this->checkBrowserDooble() || //add BugBuster $this->checkBrowserQtWebBrowser() || //add BugBuster $this->checkBrowserOmniWeb() || // common mobile $this->checkBrowserAndroidSamsungGalaxy() || //add BugBuster $this->checkBrowserAndroidHTCDesire() || //add BugBuster $this->checkBrowserAndroidHTCMagic() || //add BugBuster $this->checkBrowserAndroidHTCSensation() || //add BugBuster $this->checkBrowserAndroidHTCNexusOne() || //add BugBuster $this->checkBrowserAndroidHTCWildfire() || //add BugBuster $this->checkBrowserAndroidAcerA500() || //add BugBuster $this->checkBrowserAndroidAcerA501() || //add BugBuster $this->checkBrowserAndroidSamsungNexusS() || //add BugBuster $this->checkBrowserAndroidThinkPadTablet() || //add BugBuster $this->checkBrowserAndroidXoomTablet() || //add BugBuster $this->checkBrowserAndroidAsusTransfomerPad() || //add BugBuster $this->checkBrowserAndroidKindleFire() || //add BugBuster //at last Android only! $this->checkBrowserAndroid() || $this->checkBrowseriPad() || $this->checkBrowseriPod() || $this->checkBrowseriPhone() || $this->checkBrowserBlackBerry() || $this->checkBrowserNokia() || // common bots //$this->checkBrowserGoogleBot() || //$this->checkBrowserMSNBot() || //$this->checkBrowserSlurp() || // chrome post Android Pads $this->checkBrowserChrome() || // WebKit base check (post mobile and others) $this->checkBrowserSafari() || // Opera Mini must check post mobile $this->checkBrowserOpera() || // everyone else $this->checkBrowserTOnline() || $this->checkBrowserNetPositive() || $this->checkBrowserFirebird() || $this->checkBrowserKonqueror() || $this->checkBrowserIcab() || $this->checkBrowserPhoenix() || $this->checkBrowserAmaya() || $this->checkBrowserLynx() || $this->checkBrowserShiretoko() || $this->checkBrowserIceCat() || //$this->checkBrowserW3CValidator() || $this->checkBrowserIceweasel() || //why not?; BugBuster $this->checkBrowserHTTPRequest2() || // add BugBuster $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */ ); }
Protected routine to determine the browser type http://www.useragentstring.com/index.php @return boolean True if the browser was detected otherwise false
entailment
protected function checkBrowserInternetExplorer() { $match = ''; // Test for v1 - v1.5 IE if( stripos($this->_agent,'microsoft internet explorer') !== false ) { $this->setBrowser(self::BROWSER_IE); $this->setVersion('1.0'); $aresult = stristr($this->_agent, '/'); if( preg_match('/308|425|426|474|0b1/i', $aresult) ) { $this->setVersion('1.5'); } return true; } // Test for versions > 1.5 else if( stripos($this->_agent,'msie') !== false && stripos($this->_agent,'opera') === false && stripos($this->_agent,'iemobile') === false ) { /*// See if the browser is the odd MSN Explorer if( stripos($this->_agent,'msnb') !== false ) { $aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'MSN')); $this->setBrowser( self::BROWSER_MSN ); $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1])); return true; } */ $aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'msie')); $this->setBrowser( self::BROWSER_IE ); $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1])); return true; } // Test for versions for Edge else if ( stripos($this->_agent,'Edge') !== false && stripos($this->_agent,'windows phone') === false ) { $aresult = explode('/',stristr($this->_agent,'Edge')); $aversion = explode('.',$aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_MS_EDGE); return true; } // Test for versions for Edge mobile else if ( stripos($this->_agent,'Edge') !== false && stripos($this->_agent,'windows phone') !== false ) { $aresult = explode('/',stristr($this->_agent,'Edge')); $aversion = explode('.',$aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_MS_EDGE_MOBILE); $this->setPlatform( self::PLATFORM_WINDOWS_PHONE ); $this->setMobile(true); return true; } // Test for versions > 10 else if ( preg_match('/Trident\/[0-9\.]+/', $this->_agent) && preg_match('/rv:([0-9\.]+)/', $this->_agent, $match) ) { $this->setBrowser( self::BROWSER_IE ); $this->setVersion($match[1]); return true; } else if (stripos($this->_agent,'iemobile') !== false && stripos($this->_agent,'windows phone') !== false ) { // Windows Phones mit IEMobile $this->setPlatform( self::PLATFORM_WINDOWS_PHONE ); $this->setBrowser( self::BROWSER_IE_MOBILE ); $this->setMobile(true); $aresult = explode(' ',stristr(str_replace('/',' ',$this->_agent),'iemobile')); $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1])); return true; } else if (stripos($this->_agent,'iemobile') !== false && stripos($this->_agent,'windows phone') === false ) { // Irgendwas mit IEMobile $this->setBrowser( self::BROWSER_IE_MOBILE ); $this->setMobile(true); $aresult = explode(' ',stristr(str_replace('/',' ',$this->_agent),'iemobile')); $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1])); return true; } // Test for Pocket IE else if( stripos($this->_agent,'mspie') !== false || stripos($this->_agent,'pocket') !== false ) { $aresult = explode(' ',stristr($this->_agent,'mspie')); $this->setPlatform( self::PLATFORM_WINDOWS_CE ); $this->setBrowser( self::BROWSER_POCKET_IE ); $this->setMobile(true); if( stripos($this->_agent,'mspie') !== false ) { $this->setVersion($aresult[1]); } else { $aversion = explode('/',$this->_agent); $this->setVersion($aversion[1]); } return true; } return false; }
Determine if the browser is Internet Explorer or not (last updated 1.7) @return boolean True if the browser is Internet Explorer otherwise false
entailment
protected function checkBrowserOpera() { if( stripos($this->_agent,'opera mini') !== false ) { $resultant = stristr($this->_agent, 'opera mini'); if( preg_match('/\//',$resultant) ) { $aresult = explode('/',$resultant); $aversion = explode(' ',$aresult[1]); $this->setVersion($aversion[0]); } else { $aversion = explode(' ',stristr($resultant,'opera mini')); $this->setVersion($aversion[1]); } $this->_browser_name = self::BROWSER_OPERA_MINI; $this->setMobile(true); return true; } else if( stripos($this->_agent,'opera') !== false ) { $resultant = stristr($this->_agent, 'opera'); if( preg_match('/Version\/(10.*)$/',$resultant,$matches) ) { $this->setVersion($matches[1]); } if( preg_match('/Version\/(11.*)$/',$resultant,$matches) ) { $this->setVersion($matches[1]); } else if( preg_match('/\//',$resultant) ) { $aresult = explode('/',str_replace("("," ",$resultant)); $aversion = explode(' ',$aresult[1]); $this->setVersion($aversion[0]); } else { $aversion = explode(' ',stristr($resultant,'opera')); $this->setVersion(isset($aversion[1])?$aversion[1]:""); } $this->_browser_name = self::BROWSER_OPERA; return true; } return false; }
Determine if the browser is Opera or not (last updated 1.7) @return boolean True if the browser is Opera otherwise false
entailment
protected function checkBrowserChrome() { if( stripos($this->_agent,'Chrome') !== false ) { $aresult = explode('/',stristr($this->_agent,'Chrome')); $aversion = explode(' ',$aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_CHROME); return true; } return false; }
Determine if the browser is Chrome or not (last updated 1.7) @return boolean True if the browser is Chrome otherwise false
entailment
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 @return boolean True if the browser is Vivaldi otherwise false
entailment
protected function checkBrowserDooble() { if( stripos($this->_agent,'Dooble') !== false ) { $aresult = explode('/',stristr($this->_agent,'Dooble')); $aversion = explode(' ',$aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_DOOBLE); return true; } return false; }
Determine if the browser is Dooble (1.x) or not @return boolean True if the browser is Dooble otherwise false
entailment
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 @return boolean True if the browser is QtWebBrowser otherwise false
entailment
protected function checkBrowserSongbird() { if( stripos($this->_agent,'Songbird') !== false ) { $aversion = explode('/',stristr($this->_agent,'Songbird')); $this->setVersion($aversion[1]); $this->setBrowser(self::BROWSER_SONGBIRD); return true; } return false; }
Determine if the browser is Songbird or not, add by BugBuster @return boolean True if the browser is Songbird otherwise false
entailment
protected function checkBrowserSeaMonkey() { if( stripos($this->_agent,'SeaMonkey') !== false ) { $aversion = explode('/',stristr($this->_agent,'SeaMonkey')); $this->setVersion($aversion[1]); $this->setBrowser(self::BROWSER_SEAMONKEY); return true; } return false; }
Determine if the browser is Songbird or not, add by BugBuster @return boolean True if the browser is Songbird otherwise false
entailment
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 @return boolean True if the browser is T-Online Browser otherwise false
entailment
protected function checkBrowserAndroidSamsungGalaxy() { if( stripos($this->_agent,'Android') !== false ) { $this->setVersion(self::VERSION_UNKNOWN); $this->setMobile(true); if( stripos($this->_agent,'GT-I9000') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S); return true; } if( stripos($this->_agent,'GT-I9001') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S_PLUS); return true; } if( stripos($this->_agent,'GT-I9100') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S_II); return true; } if( stripos($this->_agent,'GT-I9300') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S_III); return true; } if( stripos($this->_agent,'GT-I8190') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S_III_MINI); return true; } if( stripos($this->_agent,'GT-I9301') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S_III_NEO); return true; } //S4 if( stripos($this->_agent,'GT-I9500') !== false || stripos($this->_agent,'GT-I9505') !== false || stripos($this->_agent,'GT-I9506') !== false || stripos($this->_agent,'GT-I9515') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S4); return true; } if( stripos($this->_agent,'GT-I9195') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S4_MINI); return true; } if( stripos($this->_agent,'GT-I9295') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S4_ACTIVE); return true; } if( stripos($this->_agent,'SM-C101') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S4_ZOOM); return true; } //S5 if( stripos($this->_agent,'SM-G900') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S5); return true; } if( stripos($this->_agent,'SM-G800') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S5_MINI); return true; } if( stripos($this->_agent,'SM-G870') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S5_ACTIVE); return true; } if( stripos($this->_agent,'SM-C115') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S5_ZOOM); return true; } //S6 if( stripos($this->_agent,'SM-G920') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S6); return true; } if( stripos($this->_agent,'SM-G890') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S6_ACTIVE); return true; } if( stripos($this->_agent,'SM-G9198') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S6_MINI); return true; } if( stripos($this->_agent,'SM-G925') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S6_EDGE); return true; } if( stripos($this->_agent,'SM-G928') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_S6_EDGE_P); return true; } if( stripos($this->_agent,'GT-S5830') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_ACE); return true; } if( stripos($this->_agent,'GT-I8160') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_ACE_2); return true; } if( stripos($this->_agent,'GT-S7500') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_ACE_PLUS); return true; } if( stripos($this->_agent,'GT-I9250') !== false || stripos($this->_agent,'Galaxy Nexus Build') !== false ) { $this->setBrowser(self::BROWSER_SAMSUNG_GALAXY_NEXUS); return true; } if( stripos($this->_agent,'GT-N7000') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_NOTE); return true; } if( stripos($this->_agent,'GT-P1000') !== false || stripos($this->_agent,'GT-P1010') !== false || stripos($this->_agent,'GT-P7100') !== false || stripos($this->_agent,'GT-P7300') !== false || stripos($this->_agent,'GT-P7510') !== false || stripos($this->_agent,'GT-P6200') !== false || stripos($this->_agent,'GT-P6210') !== false ) { $this->setBrowser(self::BROWSER_GALAXY_TAB); return true; } } return false; }
Determine if the browser is Android and Samsung Galaxy or not, add by BugBuster @return boolean True if the browser is Samsung Galaxy otherwise false
entailment
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 @return boolean True if the browser is HTC Desire otherwise false
entailment
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 @return boolean True if the browser is HTC Magic otherwise false
entailment
protected function checkBrowserAndroidHTCNexusOne() { if( stripos($this->_agent,'Android') !== false ) { if( stripos($this->_agent,'Nexus One') !== false ) { $this->setVersion(self::VERSION_UNKNOWN); $this->setMobile(true); $this->setBrowser(self::BROWSER_HTC_NEXUS_ONE); return true; } } return false; }
Determine if the browser is Android and HTC Nexus One (4Google) or not, add by BugBuster @return boolean True if the browser is HTC Nexus One otherwise false
entailment
protected function checkBrowserAndroidSamsungNexusS() { if( stripos($this->_agent,'Android') !== false ) { if( stripos($this->_agent,'Nexus S Build') !== false ) { $this->setVersion(self::VERSION_UNKNOWN); $this->setMobile(true); $this->setBrowser(self::BROWSER_SAMSUNG_NEXUS_S); return true; } } return false; }
Determine if the browser is Android and Samsung Nexus S (4Google) or not, add by BugBuster @return boolean True if the browser is Samsung Nexus S otherwise false
entailment
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 @return boolean True if the browser is HTC WildfireS A510e otherwise false
entailment
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 ) //usa name { $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 @return boolean True if the browser is HTC Sensation otherwise false
entailment
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 @return boolean True if the browser is ChromePlus otherwise false
entailment
protected function checkBrowserCoolNovo() { if( stripos($this->_agent,'CoolNovo') !== false ) { $aresult = explode('/',stristr($this->_agent,'CoolNovo')); $aversion = explode(' ',$aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_COOL_NOVO); return true; } return false; }
Determine if the browser is CoolNovo (previous ChromePlus) or not, add by BugBuster @return boolean True if the browser is CoolNovo otherwise false
entailment
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 @return boolean True if the browser is Maxthon otherwise false
entailment
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 @return boolean True if the browser is Pear HTTP_Request2 otherwise false
entailment
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 @return boolean True if the browser is an Acer Iconia A500 Tablet otherwise false
entailment
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 @return boolean True if the browser is an Acer A501 Tablet otherwise false
entailment
protected function checkBrowserAndroidThinkPadTablet() { if( stripos($this->_agent,'Android') !== false ) { if( stripos($this->_agent,'ThinkPad Tablet') !== false ) { $this->setVersion(self::VERSION_UNKNOWN); $this->setMobile(true); $this->setBrowser(self::BROWSER_LENOVO_THINKPAD_TABLET); return true; } } return false; }
Determine if the browser is a Lenovo ThinkPad Tablet or not, add by BugBuster @return boolean True if the browser is a Lenovo ThinkPad Tablet otherwise false
entailment
protected function checkBrowserAndroidXoomTablet() { if( stripos($this->_agent,'Android') !== false ) { if( stripos($this->_agent,'Xoom Build') !== false ) { $this->setVersion(self::VERSION_UNKNOWN); $this->setMobile(true); $this->setBrowser(self::BROWSER_MOTOROLA_XOOM_TABLET); return true; } } return false; }
Determine if the browser is a Motorola Xoom Tablet or not, add by BugBuster @return boolean True if the browser is a Motorola Xoom Tablet otherwise false
entailment
protected function checkBrowserAndroidAsusTransfomerPad() { if( stripos($this->_agent,'Android') !== false ) { if( stripos($this->_agent,'ASUS Transformer Pad') !== false ) { $this->setVersion(self::VERSION_UNKNOWN); $this->setMobile(true); $this->setBrowser(self::BROWSER_ASUS_TRANSFORMER_PAD); return true; } } return false; }
Determine if the browser is a Asus Transfomer Pad or not, add by BugBuster @return boolean True if the browser is a Asus Transfomer Pad otherwise false
entailment
protected function checkBrowserAndroidKindleFire() { if( stripos($this->_agent,'Android') !== false ) { if( stripos($this->_agent,'Silk') !== false ) { $this->setVersion(self::VERSION_UNKNOWN); $this->setBrowser(self::BROWSER_KINDLE_FIRE); $this->setMobile(true); return true; } } return false; }
Determine if the browser is a Kindle Fire with Silk Browser (Safari) or not, add by BugBuster @return boolean True if the browser is a Kindle Fire otherwise false
entailment
protected function checkPlatform() { if( stripos($this->_agent, 'iPad') !== false ) { $this->_platform = self::PLATFORM_APPLE; // iOS folgt spaeter } elseif( stripos($this->_agent, 'iPod') !== false ) { $this->_platform = self::PLATFORM_APPLE; // iOS folgt spaeter } elseif( stripos($this->_agent, 'iPhone') !== false ) { $this->_platform = self::PLATFORM_APPLE; // iOS folgt spaeter } elseif( stripos($this->_agent, 'android') !== false ) { $this->_platform = self::PLATFORM_ANDROID; } elseif( stripos($this->_agent, 'mac') !== false ) { $this->_platform = self::PLATFORM_APPLE; } elseif( stripos($this->_agent, 'linux') !== false ) { $this->_platform = self::PLATFORM_LINUX; } elseif( stripos($this->_agent, 'windows phone') !== false ) { $this->_platform = self::PLATFORM_WINDOWS_PHONE; } elseif( stripos($this->_agent, 'Nokia') !== false ) { $this->_platform = self::PLATFORM_NOKIA; } elseif( stripos($this->_agent, 'BlackBerry') !== false ) { $this->_platform = self::PLATFORM_BLACKBERRY; } elseif( stripos($this->_agent, 'windows ce') !== false ) { $this->_platform = self::PLATFORM_WINDOWS_CE; } elseif( stripos($this->_agent, 'windows') !== false ) { $this->_platform = self::PLATFORM_WINDOWS; } elseif( stripos($this->_agent,'FreeBSD') !== false ) { $this->_platform = self::PLATFORM_FREEBSD; } elseif( stripos($this->_agent,'OpenBSD') !== false ) { $this->_platform = self::PLATFORM_OPENBSD; } elseif( stripos($this->_agent,'NetBSD') !== false ) { $this->_platform = self::PLATFORM_NETBSD; } elseif( stripos($this->_agent, 'OpenSolaris') !== false ) { $this->_platform = self::PLATFORM_OPENSOLARIS; } elseif( stripos($this->_agent, 'SunOS') !== false ) { $this->_platform = self::PLATFORM_SUNOS; } elseif( stripos($this->_agent, 'OS/2') !== false ) { $this->_platform = self::PLATFORM_OS2; } elseif( stripos($this->_agent, 'BeOS') !== false ) { $this->_platform = self::PLATFORM_BEOS; } elseif( stripos($this->_agent, 'win') !== false ) { $this->_platform = self::PLATFORM_WINDOWS; } // add BugBuster elseif( stripos($this->_agent, 'PHP') !== false ) { $this->_platform = self::PLATFORM_PHP; } // add BugBuster elseif( stripos($this->_agent, 'PLAYSTATION') !== false ) { $this->_platform = self::PLATFORM_PLAYSTATION; } }
Determine the user's platform (last updated 1.7)
entailment
public function getPlatformVersion() { if ($this->_platformVersion === self::PLATFORM_UNKNOWN ) { $this->_platformVersion = $this->_platform; } return $this->_platformVersion; }
The name of the platform. All return types are from the class contants Fallback platformVersion with platform if platformVersion unknown @return string Platformversion of the browser
entailment
protected function checkPlatformVersion() { // based on browscap.ini if ($this->_platform == self::PLATFORM_WINDOWS) { /*if( stripos($this->_agent, 'windows NT 7.1') !== false ) { $this->_platform = self::PLATFORM_WINDOWS_7; } else*/ if( stripos($this->_agent, 'windows NT 10.0') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_10; } elseif( stripos($this->_agent, 'windows NT 6.3') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_81; if( stripos($this->_agent, 'arm') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_RT; } } elseif( stripos($this->_agent, 'windows NT 6.2') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_8; if( stripos($this->_agent, 'arm') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_RT; } } elseif( stripos($this->_agent, 'windows NT 6.1') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_7; } elseif( stripos($this->_agent, 'windows NT 6.0') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_VISTA; } elseif( stripos($this->_agent, 'windows NT 5.2') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_2003; } elseif( stripos($this->_agent, 'windows NT 5.1') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_XP; } elseif( stripos($this->_agent, 'windows XP') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_XP; } elseif( stripos($this->_agent, 'windows NT 5.0') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_2000; } elseif( stripos($this->_agent, 'windows NT 4.0') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_NT; } elseif( stripos($this->_agent, 'windows Me') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_ME; } elseif( stripos($this->_agent, 'windows 98') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_98; } elseif( stripos($this->_agent, 'windows 95') !== false ) { $this->_platformVersion = self::PLATFORM_WINDOWS_95; } } if ($this->_platform == self::PLATFORM_WINDOWS_PHONE) { if ( stripos($this->_agent, 'Windows Phone OS') !== false ) { $aresult = explode(' ',stristr($this->_agent,'Windows Phone OS')); $this->_platformVersion = self::PLATFORM_WINDOWS_PHONE .' '. str_replace(array('(',')',';'),'',$aresult[3]); } elseif ( stripos($this->_agent, 'Windows Phone') !== false ) { $aresult = explode(' ',stristr($this->_agent,'Windows Phone')); $this->_platformVersion = self::PLATFORM_WINDOWS_PHONE .' '. str_replace(array('(',')',';'),'',$aresult[2]); } } if ($this->_platform == self::PLATFORM_APPLE) { if ( stripos($this->_agent, 'Mac OS X') !== false ) { $this->_platformVersion = self::PLATFORM_MACOSX; } if ( stripos($this->_agent, 'iPad') !== false || stripos($this->_agent, 'iPod') !== false || stripos($this->_agent, 'iPhone') !== false) { $this->_platformVersion = self::PLATFORM_IOSX; } } elseif( stripos($this->_agent, 'Warp 4') !== false ) { $this->_platformVersion = self::PLATFORM_WARP4; } }
Improved checkPlatform with Windows Plattform Details and Mac OS X BugBuster (Glen Langer)
entailment
protected function setLang() { $array = explode(",", $this->_accept_language); $ca = count($array); for($i = 0; $i < $ca; $i++) { //Konqueror $array[$i] = str_replace(" ", null, $array[$i]); $array[$i] = substr($array[$i], 0, 2); $array[$i] = strtolower($array[$i]); } $array = array_unique($array); $this->_lang = strtoupper($array[0]); if(empty($this->_lang) || strlen($this->_lang) < 2) { $this->_lang = 'Unknown'; } return true; }
Ermittle akzeptierten Sprachen @return bool true @access protected
entailment
public function parse(string $data): InvokeSpec { $payload = @json_decode($data, true); if (!is_array($payload)) { return new InvokeSpec([new Error(new ParseErrorException())], true); } $units = []; // Single request if ($this->isSingleRequest($payload)) { $units[] = $this->decodeCall($payload); return new InvokeSpec($units, true); } // Batch request /** @var array $payload */ foreach ($payload as $record) { $units[] = $this->decodeCall($record); } return new InvokeSpec($units, false); }
Parse request data @param string $data @return InvokeSpec
entailment
private function decodeCall($record): AbstractInvoke { $record = $this->preParse($record); if ($this->isValidCall($record)) { $unit = new Invoke($record['id'], $record['method'], $record['params'] ?? []); } elseif ($this->isValidNotification($record)) { $unit = new Notification($record['method'], $record['params']); } else { $unit = new Error(new InvalidRequestException()); } return $unit; }
@param $record @return AbstractInvoke
entailment
private function isValidNotification($payload): bool { if (!is_array($payload)) { return false; } $headerValid = array_key_exists('jsonrpc', $payload) && $payload['jsonrpc'] === '2.0'; $methodValid = array_key_exists('method', $payload) && is_string($payload['method']); $idValid = !array_key_exists('id', $payload); // This member MAY be omitted $paramsValid = true; if (array_key_exists('params', $payload) && !is_array($payload['params'])) { $paramsValid = false; } return $headerValid && $methodValid && $paramsValid && $idValid; }
@param array $payload @return bool
entailment
private function preParse($record) { $container = $this->preParse->handle(new ParserContainer($this, $record)); if ($container instanceof ParserContainer) { return $container->getValue(); } throw new \RuntimeException(); }
@param mixed $record @return mixed
entailment
public function generate() { if (TL_MODE == 'BE') { $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### VISITORS LIST ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id; return $objTemplate->parse(); } //alte und neue Art gemeinsam zum Array bringen if (strpos($this->visitors_categories,':') !== false) { $this->visitors_categories = deserialize($this->visitors_categories, true); } else { $this->visitors_categories = array($this->visitors_categories); } // Return if there are no categories if (!is_array($this->visitors_categories) || !is_numeric($this->visitors_categories[0])) { return ''; } $this->useragent_filter = $this->visitors_useragent; return parent::generate(); }
Display a wildcard in the back end @return string
entailment
protected function compile() { //visitors_template $objVisitors = \Database::getInstance() ->prepare("SELECT tl_visitors.id AS id, visitors_name, visitors_startdate, visitors_average FROM tl_visitors LEFT JOIN tl_visitors_category ON (tl_visitors_category.id=tl_visitors.pid) WHERE pid=? AND published=? ORDER BY id, visitors_name") ->limit(1) ->execute($this->visitors_categories[0],1); if ($objVisitors->numRows < 1) { $this->strTemplate = 'mod_visitors_error'; $this->Template = new \FrontendTemplate($this->strTemplate); \System::getContainer() ->get('monolog.logger.contao') ->log(LogLevel::ERROR, 'ModuleVisitors User Error: no published counter found.', array('contao' => new ContaoContext('ModulVisitors compile ', TL_ERROR))); return; } $arrVisitors = array(); while ($objVisitors->next()) { //if (($objVisitors->visitors_template != $this->strTemplate) && ($objVisitors->visitors_template != '')) { if (($this->visitors_template != $this->strTemplate) && ($this->visitors_template != '')) { $this->strTemplate = $this->visitors_template; $this->Template = new \FrontendTemplate($this->strTemplate); } if ($this->strTemplate != 'mod_visitors_fe_invisible') { //VisitorsStartDate if (!strlen($objVisitors->visitors_startdate)) { $VisitorsStartDate = false; } else { $VisitorsStartDate = true; } if ($objVisitors->visitors_average) { $VisitorsAverageVisits = true; } else { $VisitorsAverageVisits = false; } if (!isset($GLOBALS['TL_LANG']['visitors']['VisitorsNameLegend'])) { $GLOBALS['TL_LANG']['visitors']['VisitorsNameLegend']=''; } $arrVisitors[] = array ( 'VisitorsName' => trim($objVisitors->visitors_name), 'VisitorsKatID' => $this->visitors_categories[0], 'VisitorsStartDate' => $VisitorsStartDate, 'AverageVisits' => $VisitorsAverageVisits, 'VisitorsNameLegend' => $GLOBALS['TL_LANG']['visitors']['VisitorsNameLegend'], 'VisitorsOnlineCountLegend' => $GLOBALS['TL_LANG']['visitors']['VisitorsOnlineCountLegend'], 'VisitorsStartDateLegend' => $GLOBALS['TL_LANG']['visitors']['VisitorsStartDateLegend'], 'TotalVisitCountLegend' => $GLOBALS['TL_LANG']['visitors']['TotalVisitCountLegend'], 'TotalHitCountLegend' => $GLOBALS['TL_LANG']['visitors']['TotalHitCountLegend'], 'TodayVisitCountLegend' => $GLOBALS['TL_LANG']['visitors']['TodayVisitCountLegend'], 'TodayHitCountLegend' => $GLOBALS['TL_LANG']['visitors']['TodayHitCountLegend'], 'AverageVisitsLegend' => $GLOBALS['TL_LANG']['visitors']['AverageVisitsLegend'], 'YesterdayHitCountLegend' => $GLOBALS['TL_LANG']['visitors']['YesterdayHitCountLegend'], 'YesterdayVisitCountLegend' => $GLOBALS['TL_LANG']['visitors']['YesterdayVisitCountLegend'], 'PageHitCountLegend' => $GLOBALS['TL_LANG']['visitors']['PageHitCountLegend'] ); } else { // invisible, but counting! $arrVisitors[] = array('VisitorsKatID' => $this->visitors_categories[0]); } } $this->Template->visitors = $arrVisitors; }
Generate module
entailment
public function handle( string $method = null, string $path = null, $action, array $arguments = [], ContainerInterface $di = null ) { $this->di = $di; if (is_null($action)) { return; } if (is_callable($action)) { if (is_array($action) && is_string($action[0]) && class_exists($action[0]) ) { $action[] = $arguments; return $this->handleAsControllerAction($action); } return $this->handleAsCallable($action, $arguments); } if (is_string($action) && class_exists($action)) { $callable = $this->isControllerAction($method, $path, $action); if ($callable) { return $this->handleAsControllerAction($callable); } } if ($di && is_array($action) && isset($action[0]) && isset($action[1]) && is_string($action[0]) ) { // Try to load service from app/di injected container return $this->handleUsingDi($action, $arguments, $di); } throw new ConfigurationException("Handler for route does not seem to be a callable action."); }
Handle the action for a route and return the results. @param string $method the request method. @param string $path that was matched. @param string|array $action base for the callable. @param array $arguments optional arguments. @param ContainerInjectableInterface $di container with services. @return mixed as the result from the route handler.
entailment
public function getHandlerType( $action, ContainerInterface $di = null ) { if (is_null($action)) { return "null"; } if (is_callable($action)) { return "callable"; } if (is_string($action) && class_exists($action)) { $callable = $this->isControllerAction(null, null, $action); if ($callable) { return "controller"; } } if ($di && is_array($action) && isset($action[0]) && isset($action[1]) && is_string($action[0]) && $di->has($action[0]) && is_callable([$di->get($action[0]), $action[1]]) ) { return "di"; } return "not found"; }
Get an informative string representing the handler type. @param string|array $action base for the callable. @param ContainerInjectableInterface $di container with services. @return string as the type of handler.
entailment
protected function isControllerAction( string $method = null, string $path = null, string $class ) { $method = ucfirst(strtolower($method)); $args = explode("/", $path); $action = array_shift($args); $action = empty($action) ? "index" : $action; $action = str_replace("-", "", $action); $action1 = "{$action}Action{$method}"; $action2 = "{$action}Action"; $action3 = "catchAll{$method}"; $action4 = "catchAll"; foreach ([$action1, $action2] as $target) { try { $refl = new \ReflectionMethod($class, $target); if (!$refl->isPublic()) { throw new NotFoundException("Controller method '$class::$target' is not a public method."); } return [$class, $target, $args]; } catch (\ReflectionException $e) { ; } } foreach ([$action3, $action4] as $target) { try { $refl = new \ReflectionMethod($class, $target); if (!$refl->isPublic()) { throw new NotFoundException("Controller method '$class::$target' is not a public method."); } array_unshift($args, $action); return [$class, $target, $args]; } catch (\ReflectionException $e) { ; } } return false; }
Check if items can be used to call a controller action, verify that the controller exists, the action has a class-method to call. @param string $method the request method. @param string $path the matched path, base for the controller action and the arguments. @param string $class the controller class @return array with callable details.
entailment
protected function handleAsControllerAction(array $callable) { $class = $callable[0]; $action = $callable[1]; $args = $callable[2]; $obj = new $class(); $refl = new \ReflectionClass($class); $diInterface = "Anax\Commons\ContainerInjectableInterface"; $appInterface = "Anax\Commons\AppInjectableInterface"; if ($this->di && $refl->implementsInterface($diInterface)) { $obj->setDI($this->di); } elseif ($this->di && $refl->implementsInterface($appInterface)) { if (!$this->di->has("app")) { throw new ConfigurationException( "Controller '$class' implements AppInjectableInterface but \$app is not available in \$di." ); } $obj->setApp($this->di->get("app")); } try { $refl = new \ReflectionMethod($class, "initialize"); if ($refl->isPublic()) { $obj->initialize(); } } catch (\ReflectionException $e) { ; } $refl = new \ReflectionMethod($obj, $action); $paramIsVariadic = false; foreach ($refl->getParameters() as $param) { if ($param->isVariadic()) { $paramIsVariadic = true; break; } } if (!$paramIsVariadic && $refl->getNumberOfParameters() < count($args) ) { throw new NotFoundException( "Controller '$class' with action method '$action' valid but to many parameters. Got " . count($args) . ", expected " . $refl->getNumberOfParameters() . "." ); } try { $res = $obj->$action(...$args); } catch (\ArgumentCountError $e) { throw new NotFoundException($e->getMessage()); } catch (\TypeError $e) { throw new NotFoundException($e->getMessage()); } return $res; }
Call the controller action with optional arguments and call initialisation methods if available. @param string $callable with details on what controller action to call. @return mixed result from the handler.
entailment
protected function handleAsCallable( $action, array $arguments ) { if (is_array($action) && isset($action[0]) && isset($action[1]) && is_string($action[0]) && is_string($action[1]) && class_exists($action[0]) ) { // ["SomeClass", "someMethod"] but not static $refl = new \ReflectionMethod($action[0], $action[1]); if ($refl->isPublic() && !$refl->isStatic()) { $obj = new $action[0](); return $obj->{$action[1]}(...$arguments); } } // Add $di to param list, if defined by the callback $refl = is_array($action) ? new \ReflectionMethod($action[0], $action[1]) : new \ReflectionFunction($action); $params = $refl->getParameters(); if (isset($params[0]) && $params[0]->getName() === "di") { array_unshift($arguments, $this->di); } return call_user_func($action, ...$arguments); }
Handle as callable support callables where the method is not static. @param string|array $action base for the callable @param array $arguments optional arguments @param ContainerInjectableInterface $di container with services @return mixed as the result from the route handler.
entailment
protected function handleUsingDi( $action, array $arguments, ContainerInterface $di ) { if (!$di->has($action[0])) { throw new ConfigurationException("Routehandler '{$action[0]}' not loaded in di."); } $service = $di->get($action[0]); if (!is_callable([$service, $action[1]])) { throw new ConfigurationException( "Routehandler '{$action[0]}' does not have a callable method '{$action[1]}'." ); } return call_user_func( [$service, $action[1]], ...$arguments ); }
Load callable as a service from the $di container. @param string|array $action base for the callable @param array $arguments optional arguments @param ContainerInjectableInterface $di container with services @return mixed as the result from the route handler.
entailment
public function fromReflection(ReflectionClass $reflectionClass) : array { $class = new Class_($reflectionClass->getShortName()); $statements = array($class); if ($parentClass = $reflectionClass->getParentClass()) { $class->extends = new FullyQualified($parentClass->getName()); } $interfaces = array(); foreach ($reflectionClass->getInterfaces() as $reflectionInterface) { $interfaces[] = new FullyQualified($reflectionInterface->getName()); } $class->implements = $interfaces; foreach ($reflectionClass->getConstants() as $constant => $value) { $class->stmts[] = new ClassConst( array(new Const_($constant, BuilderHelpers::normalizeValue($value))) ); } foreach ($reflectionClass->getProperties() as $reflectionProperty) { $class->stmts[] = $this->buildProperty($reflectionProperty); } foreach ($reflectionClass->getMethods() as $reflectionMethod) { $class->stmts[] = $this->buildMethod($reflectionMethod); } if (! $namespace = $reflectionClass->getNamespaceName()) { return $statements; } return array(new Namespace_(new Name(explode('\\', $namespace)), $statements)); }
@param \ReflectionClass $reflectionClass @return \PhpParser\Node[]
entailment
protected function buildProperty(ReflectionProperty $reflectionProperty) : Node\Stmt\Property { $propertyBuilder = new Property($reflectionProperty->getName()); if ($reflectionProperty->isPublic()) { $propertyBuilder->makePublic(); } if ($reflectionProperty->isProtected()) { $propertyBuilder->makeProtected(); } if ($reflectionProperty->isPrivate()) { $propertyBuilder->makePrivate(); } if ($reflectionProperty->isStatic()) { $propertyBuilder->makeStatic(); } if ($reflectionProperty->isDefault()) { $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties(); $propertyBuilder->setDefault($allDefaultProperties[$reflectionProperty->getName()]); } return $propertyBuilder->getNode(); }
@param ReflectionProperty $reflectionProperty @return Node\Stmt\Property
entailment
protected function buildMethod(ReflectionMethod $reflectionMethod) : Node\Stmt\ClassMethod { $methodBuilder = new Method($reflectionMethod->getName()); if ($reflectionMethod->isPublic()) { $methodBuilder->makePublic(); } if ($reflectionMethod->isProtected()) { $methodBuilder->makeProtected(); } if ($reflectionMethod->isPrivate()) { $methodBuilder->makePrivate(); } if ($reflectionMethod->isStatic()) { $methodBuilder->makeStatic(); } if ($reflectionMethod->isAbstract()) { $methodBuilder->makeAbstract(); } if ($reflectionMethod->isFinal()) { $methodBuilder->makeFinal(); } if ($reflectionMethod->returnsReference()) { $methodBuilder->makeReturnByRef(); } foreach ($reflectionMethod->getParameters() as $reflectionParameter) { $methodBuilder->addParam($this->buildParameter($reflectionParameter)); } // @todo should parse method body if possible (skipped for now) return $methodBuilder->getNode(); }
@param ReflectionMethod $reflectionMethod @return \PhpParser\Node\Stmt\ClassMethod
entailment
protected function buildParameter(ReflectionParameter $reflectionParameter) : Node\Param { $parameterBuilder = new Param($reflectionParameter->getName()); if ($reflectionParameter->isPassedByReference()) { $parameterBuilder->makeByRef(); } if ($reflectionParameter->isArray()) { $parameterBuilder->setTypeHint('array'); } if (method_exists($reflectionParameter, 'isCallable') && $reflectionParameter->isCallable()) { $parameterBuilder->setTypeHint('callable'); } if ($type = $reflectionParameter->getClass()) { $parameterBuilder->setTypeHint($type->getName()); } if ($reflectionParameter->isDefaultValueAvailable()) { if (method_exists($reflectionParameter, 'isDefaultValueConstant') && $reflectionParameter->isDefaultValueConstant() ) { $parameterBuilder->setDefault( new ConstFetch( new Name($reflectionParameter->getDefaultValueConstantName()) ) ); } else { $parameterBuilder->setDefault($reflectionParameter->getDefaultValue()); } } return $parameterBuilder->getNode(); }
@param ReflectionParameter $reflectionParameter @return Node\Param
entailment
private function checkPartAsArgument($rulePart, $queryPart, &$args) { if (substr($rulePart, -1) == "}" && !is_null($queryPart) ) { $part = substr($rulePart, 1, -1); $pos = strpos($part, ":"); $type = null; if ($pos !== false) { $type = substr($part, $pos + 1); if (! $this->checkPartMatchingType($queryPart, $type)) { return false; } } $args[] = $this->typeConvertArgument($queryPart, $type); return true; } return false; }
Check if part of route is a argument and optionally match type as a requirement {argument:type}. @param string $rulePart the rule part to check. @param string $queryPart the query part to check. @param array &$args add argument to args array if matched @return boolean
entailment
private function checkPartMatchingType($value, $type) { switch ($type) { case "digit": return ctype_digit($value); break; case "hex": return ctype_xdigit($value); break; case "alpha": return ctype_alpha($value); break; case "alphanum": return ctype_alnum($value); break; default: return false; } }
Check if value is matching a certain type of values. @param string $value the value to check. @param array $type the expected type to check against. @return boolean
entailment
private function matchPart($rulePart, $queryPart, &$args) { $match = false; $first = isset($rulePart[0]) ? $rulePart[0] : ''; switch ($first) { case '*': $match = true; break; case '{': $match = $this->checkPartAsArgument($rulePart, $queryPart, $args); break; default: $match = ($rulePart == $queryPart); break; } return $match; }
Match part of rule and query. @param string $rulePart the rule part to check. @param string $queryPart the query part to check. @param array &$args add argument to args array if matched @return boolean
entailment
private function matchRequestMethod( string $method = null, array $supported = null ) { if ($supported && !in_array($method, $supported)) { return false; } return true; }
Check if the request method matches. @param string $method as request method. @param string $supported as request methods that are valid. @return boolean true if request method matches
entailment
public function match( string $mount = null, string $relativePath = null, string $absolutePath = null, string $query, array $methodSupported = null, string $method = null ) { $this->arguments = []; $this->methodMatched = null; $this->pathMatched = null; if (!$this->matchRequestMethod($method, $methodSupported)) { return false; } // Is a null path - mounted on empty, or mount path matches // initial query. if (is_null($relativePath) && (empty($mount) || strncmp($query, $mount, strlen($mount)) == 0) ) { $this->methodMatched = $method; $this->pathMatched = $query; return true; } // Check all parts to see if they matches $ruleParts = explode('/', $absolutePath); $queryParts = explode('/', $query); $ruleCount = max(count($ruleParts), count($queryParts)); $args = []; for ($i = 0; $i < $ruleCount; $i++) { $rulePart = isset($ruleParts[$i]) ? $ruleParts[$i] : null; $queryPart = isset($queryParts[$i]) ? $queryParts[$i] : null; if ($rulePart === "**") { break; } if (!$this->matchPart($rulePart, $queryPart, $args)) { return false; } } $this->arguments = $args; $this->methodMatched = $method; $this->pathMatched = $query; return true; }
Check if the route matches a query and request method. @param string $mount of the current route being matched. @param string $relativePath of the current route being matched. @param string $absolutePath of the current route being matched. @param string $query to match against @param array $methodSupported as supported request method @param string $method as request method @return boolean true if query matches the route
entailment
public function enterNode(Node $node) { if ($node instanceof Namespace_) { if ($this->namespace) { throw new UnexpectedValueException('Multiple nested namespaces discovered (invalid AST?)'); } $this->namespace = $node; } if ($node instanceof Class_) { if ($this->class) { throw new UnexpectedValueException('Multiple classes discovered'); } $this->class = $node; } }
@param \PhpParser\Node $node @return null @throws Exception\UnexpectedValueException if more than one class is found
entailment
public function leaveNode(Node $node) { if ($node instanceof Namespace_) { $namespace = $this->currentNamespace; $replacedInNamespace = $this->replacedInNamespace; $this->currentNamespace = null; $this->replacedInNamespace = null; if ($namespace && $replacedInNamespace) { if (! $this->newNamespace) { // @todo what happens to other classes in here? return array($replacedInNamespace); } $namespace->name->parts = explode('\\', $this->newNamespace); return $namespace; } } if ($node instanceof Class_ && $this->namespaceMatches() && ($this->reflectedClass->getShortName() === (string)$node->name) ) { $node->name = $this->newName; // @todo too simplistic (assumes single class per namespace right now) if ($this->currentNamespace) { $this->replacedInNamespace = $node; $this->currentNamespace->stmts = array($node); } elseif ($this->newNamespace) { // wrap in namespace if no previous namespace exists return new Namespace_(new Name($this->newNamespace), array($node)); } return $node; } return null; }
Replaces (if matching) the given node to comply with the new given name @param \PhpParser\Node $node @todo can be abstracted away into a visitor that allows to modify the matched node via a callback @return array|null|\PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Namespace_|null
entailment
private function namespaceMatches() : bool { $currentNamespace = ($this->currentNamespace && is_array($this->currentNamespace->name->parts)) ? $this->currentNamespace->name->toString() : ''; return $currentNamespace === $this->reflectedClass->getNamespaceName(); }
Checks if the current namespace matches with the one provided with the reflection class @return bool
entailment
public function pathInfoFilter($path, $options = false) { if ($options) { $output = pathinfo($path, $options); } else { $output = pathinfo($path); } return $output; }
php pathinfo() wrapper -- http://php.net/manual/en/function.pathinfo.php @param $path @param bool $options @return mixed
entailment
public function baseNameFilter($path, $suffix = false) { if ($suffix) { $output = basename($path, $suffix); } else { $output = basename($path); } return $output; }
php basename() wrapper -- http://php.net/manual/en/function.basename.php @param $path @param bool $suffix @return string
entailment
public function swapExtensionFilter($path_or_url, $extension) { $path = $this->decomposeUrl($path_or_url); $path_parts = pathinfo($path['path']); $new_path = $path_parts['filename'] . "." . $extension; if (!empty($path_parts['dirname']) && $path_parts['dirname'] !== ".") { $new_path = $path_parts['dirname'] . DIRECTORY_SEPARATOR . $new_path; $new_path = preg_replace('#/+#', '/', $new_path); } $output = $path['prefix'] . $new_path . $path['suffix']; return $output; }
Swap the file extension on a passed url or path @param $path_or_url @param $extension @return string
entailment
public function swapDirectoryFilter($path_or_url, $directory) { $path = $this->decomposeUrl($path_or_url); $path_parts = pathinfo($path['path']); $new_path = $directory . DIRECTORY_SEPARATOR . $path_parts['basename']; $output = $path['prefix'] . $new_path . $path['suffix']; return $output; }
Swap the file directory on a passed url or path @param $path_or_url @param $directory @return string
entailment
public function appendSuffixFilter($path_or_url, $suffix) { $path = $this->decomposeUrl($path_or_url); $path_parts = pathinfo($path['path']); $new_path = $path_parts['filename'] . $suffix . "." . $path_parts['extension']; if (!empty($path_parts['dirname']) && $path_parts['dirname'] !== ".") { $new_path = $path_parts['dirname'] . DIRECTORY_SEPARATOR . $new_path; $new_path = preg_replace('#/+#', '/', $new_path); } $output = $path['prefix'] . $new_path . $path['suffix']; return $output; }
Append a suffix a passed url or path @param $path_or_url @param $suffix @return string
entailment
private function decomposeUrl($path_or_url) { $result = array(); if (filter_var($path_or_url, FILTER_VALIDATE_URL)) { $url_parts = parse_url($path_or_url); $result['prefix'] = $url_parts['scheme'] . "://" . $url_parts['host']; $result['path'] = $url_parts['path']; $result['suffix'] = ""; $result['suffix'] .= (empty($url_parts['query'])) ? "" : "?" . $url_parts['query']; $result['suffix'] .= (empty($url_parts['fragment'])) ? "" : "#" . $url_parts['fragment']; } else { $result['prefix'] = ""; $result['path'] = $path_or_url; $result['suffix'] = ""; } return $result; }
Decompose a url into a prefix, path, and suffix @param $path_or_url @return array
entailment
public function add(Interceptor $element) { if ($this->next) { $this->next->add($element); } else { $this->next = $element; } return $this; }
@param Interceptor $element @return $this
entailment
public function handle(AbstractContainer $container): AbstractContainer { // Execute callback and pass result next chain if (is_callable($this->callback)) { $result = call_user_func($this->callback, $container); if (!$this->next) { return $result; } return $this->next->handle($result); } // End of chain if (!$this->next) { return $container; } // Execute next chain return $this->next->handle($container); }
@param AbstractContainer $container @return mixed
entailment
public function toggleVisibility($intId, $blnVisible) { // Check permissions to publish if (!$this->User->isAdmin && !$this->User->hasAccess('tl_visitors::published', 'alexf')) { \System::getContainer() ->get('monolog.logger.contao') ->log(LogLevel::ERROR, 'Not enough permissions to publish/unpublish Visitors ID "'.$intId.'"', array('contao' => new ContaoContext('tl_visitors toggleVisibility', TL_ERROR))); $this->redirect('contao/main.php?act=error'); } // Update database \Database::getInstance()->prepare("UPDATE tl_visitors SET published='" . ($blnVisible ? 1 : '') . "' WHERE id=?") ->execute($intId); }
Disable/enable a counter @param integer @param boolean
entailment
public function get(QueryCacheBuilder $builder, $columns = ['*']) { if (!$this->enabled()) { return $this->performQuery($builder, $columns); } $key = $this->generateKey($builder, $columns); $cache = $this->getCache($builder); return $cache->remember($key, $this->length, function () use ($builder, $columns) { return $this->performQuery($builder, $columns); }); }
Gets the model results. @param QueryCacheBuilder $builder @param array $columns @return Collection
entailment
protected function getCache(QueryCacheBuilder $builder) { return $this->isTaggable() ? Cache::store($this->store)->tags($this->getTag($builder)) : Cache::store($this->store); }
Gets a Cache instance. @return Cache
entailment
protected function generateKey(QueryCacheBuilder $builder, array $columns) { $sql = $builder->select($columns)->toSql(); $whereClause = serialize($builder->getBindings()); return sha1($sql.$whereClause); }
Generates the cache key. @param QueryCacheBuilder $builder @param array $columns @return string
entailment
public function flush($tag) { if ($this->isTaggable()) { return Cache::tags($tag)->flush(); } return Cache::flush(); }
Flushes the cache for a model. @param $tag @return mixed
entailment
public function toObject($value) { if (!is_array($value)) { throw new TypeCastException('Is not array'); } foreach ($this->rules as $class => $rule) { if ($this->isMatch($rule, $value)) { return $this->createInstance($class, $value); } } throw new TypeCastException('Rule not found'); }
@param mixed $value Array @return mixed Instance of registered class
entailment
public function toArray($value) { if (!is_object($value)) { throw new TypeCastException('Is not object'); } foreach ($this->rules as $class => $rule) { if (get_class($value) === $class) { return $this->createMap($class, $value); } } throw new TypeCastException('Rule not found'); }
@param mixed $value Instance of registered class @return array
entailment
private function isMatch(Rule $expected, array $value): bool { return 0 === count(array_diff(array_keys($expected->getReflectedMap()), array_keys($value))); }
@param Rule $expected Transform rule @param array $value Raw unknown value @return bool
entailment
private function createInstance(string $class, array $data) { $rule = $this->rules[$class]; $reflectionClass = new \ReflectionClass($class); $object = $reflectionClass->newInstanceWithoutConstructor(); $reflectionObject = new \ReflectionObject($object); foreach ($rule->getMap() as $property => $key) { $reflectionProperty = $reflectionObject->getProperty($property); $reflectionProperty->setAccessible(true); $constructor = $rule->getConstructor($property); $reflectionProperty->setValue($object, is_callable($constructor) ? $constructor($data[$key]) : $data[$key]); } return $object; }
@param string $class @param array $data @return object
entailment
private function createMap(string $class, $object) { $rule = $this->rules[$class]; $reflectionObject = new \ReflectionObject($object); $result = []; foreach ($rule->getMap() as $property => $key) { $reflectionProperty = $reflectionObject->getProperty($property); $reflectionProperty->setAccessible(true); $serializer = $rule->getSerializer($property); $result[$key] = is_callable($serializer) ? $serializer($reflectionProperty->getValue($object)) : $reflectionProperty->getValue($object); } return $result; }
@param string $class @param object $object @return array
entailment
public function addRoutes(array $routes) : object { if (!(isset($routes["routes"]) && is_array($routes["routes"]))) { throw new ConfigurationException("No routes found, missing key 'routes' in configuration array."); } foreach ($routes["routes"] as $route) { if ($route["internal"] ?? false) { $this->addInternalRoute( $route["path"] ?? null, $route["handler"] ?? null, $route["info"] ?? null ); continue; } $mount = $this->createMountPath( $routes["mount"] ?? null, $route["mount"] ?? null ); $this->addRoute( $route["method"] ?? null, $mount, $route["path"] ?? null, $route["handler"] ?? null, $route["info"] ?? null ); } return $this; }
Add routes from an array where the array looks like this: [ "mount" => null|string, // Where to mount the routes "routes" => [ // All routes in this array [ "info" => "Just say hi.", "method" => null, "path" => "hi", "handler" => function () { return "Hi."; }, ] ] ] @throws ConfigurationException @param array $routes containing the routes to add. @return self to enable chaining.
entailment
private function createMountPath( string $mount1 = null, string $mount2 = null ) { $mount = null; if ($mount1 && $mount2) { $mount = rtrim($mount1, "/") . "/" . rtrim($mount2, "/"); return $mount; } if ($mount1) { $mount = $mount1; } if ($mount2) { $mount = $mount2; } trim($mount); rtrim($mount, "/"); $mount = empty($mount) ? null : $mount; return $mount; }
Prepare the mount string from configuration, use $mount1 or $mount2, the latter supersedes the first. @param string $mount1 first suggestion to mount path. @param string $mount2 second suggestion to mount path, ovverides the first. @return string|null as mount path.
entailment
public function addRoute( $method, $mount = null, $path = null, $handler = null, string $info = null ) : void { if (!is_array($path)) { $path = [$path]; } foreach ($path as $thePath) { $route = new Route(); $route->set($method, $mount, $thePath, $handler, $info); $this->routes[] = $route; } }
Add a route with a request method, a path rule to match and an action as the callback. Adding several path rules (array) results in several routes being created. @param string|array $method as request method to support @param string $mount prefix to $path @param string|array $path for this route, array for several paths @param string|array|callable $handler for this path, callable or equal @param string $info description of the route @return void.
entailment
public function addInternalRoute( string $path = null, $handler, string $info = null ) : void { $route = new Route(); $route->set(null, null, $path, $handler, $info); $this->internalRoutes[$path] = $route; }
Add an internal route to the router, this route is not exposed to the browser and the end user. @param string $path for this route @param string|array|callable $handler for this path, callable or equal @param string $info description of the route @return void.
entailment
public function handle($path, $method = null) { try { $match = false; foreach ($this->routes as $route) { if ($route->match($path, $method)) { $this->lastRoute = $route; $match = true; $results = $route->handle($path, $this->di); if ($results) { return $results; } } } return $this->handleInternal("404", "No route could be matched by the router."); } catch (ForbiddenException $e) { return $this->handleInternal("403", $e->getMessage()); } catch (NotFoundException $e) { return $this->handleInternal("404", $e->getMessage()); } catch (InternalErrorException $e) { return $this->handleInternal("500", $e->getMessage()); } catch (\Exception $e) { if ($this->mode === Router::DEVELOPMENT) { throw $e; } return $this->handleInternal("500", $e->getMessage()); } }
Handle the routes and match them towards the request, dispatch them when a match is made. Each route handler may throw exceptions that may redirect to an internal route for error handling. Several routes can match and if the routehandler does not break execution flow, the route matching will carry on. Only the last routehandler will get its return value returned further. @param string $path the path to find a matching handler for. @param string $method the request method to match. @return mixed content returned from route.
entailment
public function handleInternal(string $path, string $message = null) { $route = $this->internalRoutes[$path] ?? $this->internalRoutes[null] ?? null; if (!$route) { throw new NotFoundException("No internal route to handle: " . $path); } $this->errorMessage = $message; if ($message) { $route->setArguments([$message]); } $route->setMatchedPath($path); $this->lastRoute = $route; return $route->handle(null, $this->di); }
Handle an internal route, the internal routes are not exposed to the end user. @param string $path for this route. @param string $message with additional details. @throws \Anax\Route\Exception\NotFoundException @return mixed from the route handler.
entailment
public function addController($mount = null, $handler = null, $info = null) { $this->addRoute(null, $mount, null, $handler, $info); }
Add a route having a controller as a handler. @param string|array $mount point for this controller. @param string|callable $handler a callback handler for the controller. @param string $info description of the route. @return void.
entailment
public function any($method = null, $path = null, $handler = null, $info = null) { $this->addRoute($method, null, $path, $handler, $info); }
Add a route to the router by its method(s), path(s) and a callback. @param string|array $method as request method to support @param string|array $path for this route. @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void.
entailment
public function add($path = null, $handler = null, $info = null) { $this->addRoute(null, null, $path, $handler, $info); }
Add a route to the router by its path(s) and a callback for any request method . @param string|array $path for this route. @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void
entailment
public function always($handler, $info = null) { $this->addRoute(null, null, null, $handler, $info); }
Add a default route which will be applied for any path and any request method. @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void
entailment
public function all($method, $handler, $info = null) { $this->addRoute($method, null, null, $handler, $info); }
Add a default route which will be applied for any path, if the choosen request method is matching. @param string|array $method as request method to support @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void
entailment
public function get($path, $handler, $info = null) { $this->addRoute(["GET"], null, $path, $handler, $info); }
Shortcut to add a GET route for the http request method GET. @param string|array $path for this route. @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void
entailment
public function post($path, $handler, $info = null) { $this->addRoute(["POST"], null, $path, $handler, $info); }
Shortcut to add a POST route for the http request method POST. @param string|array $path for this route. @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void
entailment
public function put($path, $handler, $info = null) { $this->addRoute(["PUT"], null, $path, $handler, $info); }
Shortcut to add a PUT route for the http request method PUT. @param string|array $path for this route. @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void
entailment
public function patch($path, $handler, $info = null) { $this->addRoute(["PATCH"], null, $path, $handler, $info); }
Shortcut to add a PATCH route for the http request method PATCH. @param string|array $path for this route. @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void
entailment
public function delete($path, $handler, $info = null) { $this->addRoute(["DELETE"], null, $path, $handler, $info); }
Shortcut to add a DELETE route for the http request method DELETE. @param string|array $path for this route. @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void
entailment
public function options($path, $handler, $info = null) { $this->addRoute(["OPTIONS"], null, $path, $handler, $info); }
Shortcut to add a OPTIONS route for the http request method OPTIONS. @param string|array $path for this route. @param string|callable $handler a callback handler for the route. @param string $info description of the route @return void
entailment