本文整理汇总了PHP中Countries::is_available方法的典型用法代码示例。如果您正苦于以下问题:PHP Countries::is_available方法的具体用法?PHP Countries::is_available怎么用?PHP Countries::is_available使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Countries
的用法示例。
在下文中一共展示了Countries::is_available方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compute_users
/**
* @desc Compute Stats of Site Users
*/
public static function compute_users()
{
//Inclusion une fois par jour et par visiteur.
$_SERVER['HTTP_USER_AGENT'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if (strpos($_SERVER['HTTP_USER_AGENT'], 'libwww') !== false) {
//Evite les bots.
return;
}
//Suppression des images de statistiques en cache.
$array_stats_img = array('browsers.png', 'os.png', 'lang.png');
foreach ($array_stats_img as $key => $value) {
@unlink(PATH_TO_ROOT . '/cache/' . $value);
}
########### Détection des navigateurs ###########
$array_browser = array('opera' => 'opera', 'firefox' => 'firefox', 'msie|internet explorer' => 'internetexplorer', 'edge' => 'edge', 'chrome' => 'chrome', 'safari' => 'safari', 'konqueror' => 'konqueror', 'netscape' => 'netscape', 'seamonkey' => 'seamonkey', 'mozilla' => 'mozilla', 'aol' => 'aol', 'lynx' => 'lynx', 'camino' => 'camino', 'links' => 'links', 'galeon' => 'galeaon', 'phoenix' => 'phoenix', 'chimera' => 'chimera', 'k-meleon' => 'k-meleon', 'icab' => 'icab', 'ncsa mosaic' => 'ncsa mosaic', 'amaya' => 'amaya', 'omniweb' => 'omniweb', 'hotjava' => 'hotjava', 'browsex' => 'browsex', 'amigavoyager' => 'amigavoyager', 'amiga-aweb' => 'amiga-aweb', 'ibrowse' => 'ibrowse', 'samsung|sony|nokia|blackberry|android|ipod|iphone|opera mini|palm|iemobile|smartphone|symbian' => 'phone');
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
$browser = 'other';
foreach ($array_browser as $regex => $name) {
if (preg_match('`' . $regex . '`i', $_SERVER['HTTP_USER_AGENT'])) {
$browser = $name;
break;
}
}
self::write_stats('browsers', $browser);
}
########### Détection des systèmes d'exploitation ###########
$array_os = array('android' => 'android', 'iphone|ipad' => 'ios', 'windows nt 10.0' => 'windows10', 'windows nt 6.3' => 'windows8.1', 'windows nt 6.2' => 'windows8', 'windows nt 6.1|seven' => 'windowsseven', 'windows nt 6.0|vista' => 'windowsvista', 'windows nt 5.2|windows server 2003' => 'windowsserver2003', 'windows nt 5.1|windows xp' => 'windowsxp', 'windows nt 5.0|windows 2000' => 'windowsold', 'winnt|windows nt|windows nt 4.0' => 'windowsold', 'windows 98|win98' => 'windowsold', 'win 9x 4.90|windows me' => 'windowsold', 'win95|win32|windows 95|windows 3.1' => 'windowsold', 'windows ce' => 'windowsold', 'windows phone' => 'windowsphone', 'linux|x11' => 'linux', 'macintosh|mac|ppc|powerpc' => 'macintosh', 'solaris|sunos' => 'sunos', 'nintendo wii' => 'wii', 'playstation portable' => 'psp', 'playstation 3' => 'playstation3', 'freebsd' => 'freebsd', 'aix' => 'aix', 'irix' => 'irix', 'hp-ux' => 'hp-ux', 'os2|os/2' => 'os2', 'netbsd' => 'netbsd', 'samsung|sony|nokia|blackberry|ipod|opera mini|palm|iemobile|smartphone|symbian' => 'phone');
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
$os = 'other';
foreach ($array_os as $regex => $name) {
if (preg_match('`' . $regex . '`i', $_SERVER['HTTP_USER_AGENT'])) {
$os = $name;
break;
}
}
self::write_stats('os', $os);
}
########### Détection de la langue utilisateur ###########
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$user_lang = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$favorite_lang = !empty($user_lang[0]) ? strtolower($user_lang[0]) : '';
if (strpos($favorite_lang, '-') !== false) {
$favorite_lang = preg_replace('`[a-z]{2}\\-([a-z]{2})`i', '$1', $favorite_lang);
}
$lang = str_replace(array('en', 'cs', 'sv', 'fa', 'ja', 'ko', 'he', 'da', 'gb'), array('uk', 'cz', 'se', 'ir', 'jp', 'kr', 'il', 'dk', 'uk'), $favorite_lang);
$lang = substr($lang, 0, 2);
if (!empty($lang)) {
$wlang = 'other';
if (Countries::is_available($lang)) {
$wlang = $lang;
}
self::write_stats('lang', $wlang);
}
}
}