本文整理汇总了PHP中get_browser函数的典型用法代码示例。如果您正苦于以下问题:PHP get_browser函数的具体用法?PHP get_browser怎么用?PHP get_browser使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_browser函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: check
public function check($browser = null)
{
$browserAttributes = get_browser();
if (!isset($browserAttributes['browser'])) {
return false;
}
if (!$browser) {
foreach ($this->_browsers as $browser) {
if ($browserAttributes['browser'] !== $browser->browserName()) {
continue;
}
if (isset($browserAttributes['version'])) {
if (!$browser->checkVersion($browserAttributes['version'])) {
return false;
}
}
if (isset($browserAttributes['css'])) {
if (!$browser->checkCssVersion($browserAttributes['css'])) {
return false;
}
}
if (isset($browserAttributes['javascript']) and $browser->javascriptEnabled() != NULL) {
if ($browser->javascriptEnabled() != $browserAttributes['javascript']) {
return false;
}
}
if (isset($browserAttributes['cookies']) and $browser->cookieEnabled() != NULL) {
if (!$browser->cookieEnabled() != $browserAttributes['cookies']) {
return false;
}
}
}
} elseif ($browser instanceof Browser) {
}
}
开发者ID:coretyson,项目名称:coretyson,代码行数:35,代码来源:BrowserCompatibility.php
示例2: getFromRequest
/**
* Get features from request
*
* @param array $request $_SERVER variable
* @param array $config ignored; included only to satisfy parent class
* @return array
*/
public static function getFromRequest($request, array $config)
{
$browscap = get_browser($request['http_user_agent'], true);
$features = array();
if (is_array($browscap)) {
foreach ($browscap as $key => $value) {
// For a few keys, we need to munge a bit for the device object
switch ($key) {
case 'browser':
$features['mobile_browser'] = $value;
break;
case 'version':
$features['mobile_browser_version'] = $value;
break;
case 'platform':
$features['device_os'] = $value;
break;
default:
$features[$key] = $value;
break;
}
}
}
return $features;
}
开发者ID:siite,项目名称:choose-sa-cloud,代码行数:32,代码来源:Browscap.php
示例3: getDeviceInfo
/**
*
* @return string device type
*/
public static function getDeviceInfo()
{
$browser = get_browser(null, true);
if (!$browser['ismobiledevice'] && !$browser['istablet']) {
return self::$device_types['desktop'];
}
$iPod = stripos($_SERVER['HTTP_USER_AGENT'], "iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'], "iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'], "iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'], "Android");
$webOS = stripos($_SERVER['HTTP_USER_AGENT'], "webOS");
if ($iPhone) {
return self::$device_types['iPhone'];
} else {
if ($iPod) {
return self::$device_types['iPod'];
} else {
if ($iPad) {
return self::$device_types['iPad'];
} else {
if ($Android) {
if ($browser['istablet']) {
return self::$device_types['Android_tablet'];
}
return self::$device_types['Android_smart'];
} else {
if ($webOS) {
return self::$device_types['webos'];
}
}
}
}
}
return self::$device_types['unknown'];
}
开发者ID:aversilov,项目名称:prexr,代码行数:39,代码来源:SoftwareInfo.php
示例4: getAllCaps
static function getAllCaps()
{
if (self::$__caps == null) {
self::$__caps = get_browser(null, true);
}
return self::$__caps;
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:7,代码来源:browsercaps.php
示例5: userAgentProperty
/**
* Returns the value of a property of the user's agent, according to the BrowsCap project.
*
* The names of the properties and their meanings are defined by the
* [Browser Capabilities Project](http://browscap.org/).
*
* @param string $propertyName The name of the BrowsCap property.
*
* @return CUStringObject The value of the BrowsCap property.
*/
public static function userAgentProperty($propertyName)
{
assert('is_cstring($propertyName)', vs(isset($this), get_defined_vars()));
if (!isset(self::$ms_browsCap)) {
self::$ms_browsCap = get_browser(null, true);
}
return (string) self::$ms_browsCap[$propertyName];
}
开发者ID:nunodotferreira,项目名称:Phred,代码行数:18,代码来源:CRequest.php
示例6: getBrowserData
public static function getBrowserData()
{
if (function_exists('get_browser')) {
return get_browser();
} else {
return array('browser_name_regex' => '^mozilla/5\\.0 (windows; .; windows nt 5\\.1; .*rv:.*) gecko/.* firefox/0\\.9.*$', 'browser_name_pattern' => 'Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*', 'parent' => 'Firefox 0.9', 'platform' => 'WinXP', 'browser' => 'Firefox', 'version' => 0.9, 'majorver' => 0, 'minorver' => 9, 'cssversion' => 2, 'frames' => 1, 'iframes' => 1, 'tables' => 1, 'cookies' => 1);
}
}
开发者ID:Caroga,项目名称:sdk,代码行数:8,代码来源:Helper.php
示例7: vendorBasicBrowscapGetBrowser
/**
* Get information about the user browser.
* @return array
*/
function vendorBasicBrowscapGetBrowser()
{
if (ini_get('browscap')) {
return get_browser();
}
$bc = new Browscap(APPPATH . 'data/cache');
return $bc->getBrowser();
}
开发者ID:esironal,项目名称:exidoengine,代码行数:12,代码来源:_init.php
示例8: getBrowser
/**
* Encapsule l'appel à la fonction php get_browser() pour éviter les erreurs en mode console
* @return array
*/
public static function getBrowser()
{
if (!array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
// Cette variable n'est pas initialisée en mode console
return array();
}
return get_browser(null, true);
}
开发者ID:ChristopheBrun,项目名称:hLib,代码行数:12,代码来源:h.php
示例9: check_browser
function check_browser()
{
$displayHTML = '<b>Nice modern browser you got there!</b>';
$displayHTML = $_SERVER['HTTP_USER_AGENT'] . "<br>";
$browser = get_browser();
$displayHTML .= $browser;
return $displayHTML;
}
开发者ID:a11y-matters,项目名称:tricityopenair,代码行数:8,代码来源:functions.php
示例10: _getClientInfo
private function _getClientInfo($bGenerateInfo = true)
{
if (!$bGenerateInfo) {
return '';
}
$_aBrowser = @ini_get('browscap') ? get_browser($_SERVER['HTTP_USER_AGENT'], true) : array();
unset($_aBrowser['browser_name_regex']);
return empty($_aBrowser) ? __('No browser information found.', 'admin-page-framework') : $_aBrowser;
}
开发者ID:szepeviktor,项目名称:admin-page-framework,代码行数:9,代码来源:AdminPageFramework_FieldType_system.php
示例11: randomBytes
function randomBytes($length = 16, $secure = true, $raw = true, $startEntropy = "", &$rounds = 0, &$drop = 0)
{
static $lastRandom = "";
$output = "";
$length = abs((int) $length);
$secureValue = "";
$rounds = 0;
$drop = 0;
while (!isset($output[$length - 1])) {
//some entropy, but works ^^
$weakEntropy = array(is_array($startEntropy) ? implode($startEntropy) : $startEntropy, serialize(stat(__FILE__)), __DIR__, PHP_OS, microtime(), (string) lcg_value(), (string) PHP_MAXPATHLEN, PHP_SAPI, (string) PHP_INT_MAX . "." . PHP_INT_SIZE, serialize($_SERVER), serialize(get_defined_constants()), get_current_user(), serialize(ini_get_all()), (string) memory_get_usage() . "." . memory_get_peak_usage(), php_uname(), phpversion(), extension_loaded("gmp") ? gmp_strval(gmp_random(4)) : microtime(), zend_version(), (string) getmypid(), (string) getmyuid(), (string) mt_rand(), (string) getmyinode(), (string) getmygid(), (string) rand(), function_exists("zend_thread_id") ? (string) zend_thread_id() : microtime(), var_export(@get_browser(), true), function_exists("getrusage") ? @implode(getrusage()) : microtime(), function_exists("sys_getloadavg") ? @implode(sys_getloadavg()) : microtime(), serialize(get_loaded_extensions()), sys_get_temp_dir(), (string) disk_free_space("."), (string) disk_total_space("."), uniqid(microtime(), true), file_exists("/proc/cpuinfo") ? file_get_contents("/proc/cpuinfo") : microtime());
shuffle($weakEntropy);
$value = hash("sha512", implode($weakEntropy), true);
$lastRandom .= $value;
foreach ($weakEntropy as $k => $c) {
//mixing entropy values with XOR and hash randomness extractor
$value ^= hash("sha256", $c . microtime() . $k, true) . hash("sha256", mt_rand() . microtime() . $k . $c, true);
$value ^= hash("sha512", (string) lcg_value() . $c . microtime() . $k, true);
}
unset($weakEntropy);
if ($secure === true) {
$strongEntropyValues = array(is_array($startEntropy) ? hash("sha512", $startEntropy[($rounds + $drop) % count($startEntropy)], true) : hash("sha512", $startEntropy, true), file_exists("/dev/urandom") ? fread(fopen("/dev/urandom", "rb"), 64) : str_repeat("", 64), (function_exists("openssl_random_pseudo_bytes") and version_compare(PHP_VERSION, "5.3.4", ">=")) ? openssl_random_pseudo_bytes(64) : str_repeat("", 64), function_exists("mcrypt_create_iv") ? mcrypt_create_iv(64, MCRYPT_DEV_URANDOM) : str_repeat("", 64), $value);
$strongEntropy = array_pop($strongEntropyValues);
foreach ($strongEntropyValues as $value) {
$strongEntropy = $strongEntropy ^ $value;
}
$value = "";
//Von Neumann randomness extractor, increases entropy
$bitcnt = 0;
for ($j = 0; $j < 64; ++$j) {
$a = ord($strongEntropy[$j]);
for ($i = 0; $i < 8; $i += 2) {
$b = ($a & 1 << $i) > 0 ? 1 : 0;
if ($b != (($a & 1 << $i + 1) > 0 ? 1 : 0)) {
$secureValue |= $b << $bitcnt;
if ($bitcnt == 7) {
$value .= chr($secureValue);
$secureValue = 0;
$bitcnt = 0;
} else {
++$bitcnt;
}
++$drop;
} else {
$drop += 2;
}
}
}
}
$output .= substr($value, 0, min($length - strlen($output), $length));
unset($value);
++$rounds;
}
$lastRandom = hash("sha512", $lastRandom, true);
return $raw === false ? bin2hex($output) : $output;
}
开发者ID:Kengaming1st,项目名称:Secure-PHP-Random-Bytes,代码行数:56,代码来源:randomBytes.php
示例12: userLogin
public static function userLogin()
{
$browser = get_browser(null, true);
if (isset(Yii::$app->request->cookies['guest_id'])) {
Yii::$app->response->cookies->remove('guest_id');
}
$user = Yii::$app->user->identity;
$data = ['user_id' => $user->id, 'old_ip' => $user->ip, 'new_ip' => $_SERVER['REMOTE_ADDR'], 'is_dynamic_ip' => $user->is_dynamic_ip, 'browser_name' => $browser['browser'], 'browser_version' => $browser['version'], 'os' => $browser['platform'], 'device' => SoftwareInfo::getDeviceInfo()];
CurlHelper::sendStatsData('UserLogin', $data);
}
开发者ID:aversilov,项目名称:prexr,代码行数:10,代码来源:StatsOperator.php
示例13: getBrowserInfo
/**
* Returns all browser infos of the session.
*
* @return array
*/
public function getBrowserInfo()
{
if (!$this->exists("browser_info")) {
$browserInfo = array();
if (ini_get("browscap")) {
$browserInfo = get_browser($this->get("useragent"), true);
}
$this->set("browser_info", $browserInfo);
}
return $this->get("browser_info");
}
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:16,代码来源:SessionLog.php
示例14: update_visitor_info
function update_visitor_info($resume_id)
{
$browser = get_browser(null, true);
$this->data['VisitorInfo']['resume_id'] = $resume_id;
$this->data['VisitorInfo']['browser'] = $browser['browser'];
$this->data['VisitorInfo']['version'] = $browser['version'];
$this->data['VisitorInfo']['platform'] = $browser['platform'];
$this->data['VisitorInfo']['ip_address'] = $_SERVER['SERVER_ADDR'];
$this->data['VisitorInfo']['domain_name'] = $_SERVER['HTTP_HOST'];
$this->save($this->data);
}
开发者ID:adityar003,项目名称:Cake-Resume-Builder,代码行数:11,代码来源:visitor_info.php
示例15: SetAttributes
/**
* Collect user agent data and save in Attributes array.
*/
protected function SetAttributes($Sender, &$Args)
{
if (!isset($Args['FormPostValues']['Attributes'])) {
$Args['FormPostValues']['Attributes'] = array();
}
// Add user agent data to Attributes
$Data = @get_browser(GetValue('HTTP_USER_AGENT', $_SERVER));
// requires browsecap.ini or throws error
$Args['FormPostValues']['Attributes']['Platform'] = GetValue('platform', $Data);
$Args['FormPostValues']['Attributes']['Browser'] = trim(GetValue('browser', $Data) . ' ' . GetValue('version', $Data));
$Args['FormPostValues']['Attributes'] = serialize($Args['FormPostValues']['Attributes']);
}
开发者ID:SatiricMan,项目名称:addons,代码行数:15,代码来源:class.useragent.plugin.php
示例16: update_browser_stats
function update_browser_stats($resume_analytic_id)
{
$this->VisitorBrowser = ClassRegistry::init('VisitorBrowser');
$visitorBrowser = $this->VisitorBrowser->findByResumeAnalyticId($resume_analytic_id);
if (empty($visitorBrowser) || time() - strtotime($visitorBrowser['VisitorBrowser']['stamp']) > 300) {
$browser = get_browser(null, true);
$this->data['VisitorBrowser']['resume_analytic_id'] = $resume_analytic_id;
$this->data['VisitorBrowser']['browser'] = $browser['browser'];
$this->data['VisitorBrowser']['version'] = $browser['version'];
$this->data['VisitorBrowser']['platform'] = $browser['platform'];
$this->VisitorBrowser->save($this->data);
}
}
开发者ID:adityar003,项目名称:Cake-Resume-Builder,代码行数:13,代码来源:analytic.php
示例17: findBrowser
private function findBrowser()
{
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return 'Unknown';
}
$data = get_browser($_SERVER['HTTP_USER_AGENT'], true);
if (empty($data['parent'])) {
return 'Unknown';
}
if (empty($data['platform'])) {
return 'Unknown';
}
return $data['parent'] . ' on ' . $data['platform'];
}
开发者ID:Zandemmer,项目名称:HackThisSite-Old,代码行数:14,代码来源:logs.php
示例18: getBrowser
protected function getBrowser($userAgent)
{
$version = '';
try {
$version = get_browser($userAgent)['version'];
} catch (Exception $e) {
}
foreach (Config::get('csi.browsers') as $regex => $value) {
if (preg_match($regex, $userAgent)) {
return array('name' => $value, 'version' => $version);
}
}
return array('name' => '', 'version' => '');
}
开发者ID:ixudra,项目名称:csi,代码行数:14,代码来源:CrashFactory.php
示例19: get
/**
* @param $names
* @param callable $cb
*/
public function get($agent, $cb)
{
$this->browsers->findOne(function ($item) use($cb, $agent) {
if ($item) {
call_user_func($cb, $item);
return;
}
$browser = \get_browser($agent, true);
$browser['name'] = $browser['browser'];
unset($browser['browser_name_regex'], $browser['browser']);
$this->browsers->insert(['_id' => $agent] + $browser);
call_user_func($cb, $browser);
}, ['where' => ['_id' => $agent]]);
}
开发者ID:kakserpom,项目名称:WakePHP,代码行数:18,代码来源:Browsers.php
示例20: testCompare
/**
* @dataProvider providerUserAgent
* @depends testCheckProperties
*
* @param string $userAgent
*
* @throws \Exception
* @throws \phpbrowscap\Exception
*/
public function testCompare($userAgent)
{
$libResult = get_browser($userAgent);
$bcResult = self::$object->getBrowser($userAgent);
$doNotCheck = array('browser_name_regex', 'browser_name_pattern', 'Parent', 'RenderingEngine_Description');
foreach (array_keys($this->properties) as $bcProp) {
if (in_array($bcProp, $doNotCheck)) {
continue;
}
$libProp = strtolower($bcProp);
$libValue = (string) $libResult->{$libProp};
$bcValue = (string) $bcResult->{$bcProp};
self::assertSame($libValue, $bcValue, 'Expected actual "' . $bcProp . '" to be "' . (string) $libValue . '" (was "' . (string) $bcValue . '"; used pattern: ' . (string) $bcResult->browser_name_pattern . ')');
}
}
开发者ID:antoniorequenalorente,项目名称:web_starter_kit,代码行数:24,代码来源:CompareBrowscapWithOriginalTest.php
注:本文中的get_browser函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论