Esempio n. 1
0
 public function phpbrowscapIsCrawler()
 {
     // Create a new Browscap object (loads or creates the cache)
     $bc = new \phpbrowscap\Browscap(storage_path('cache'));
     // Get information about the current browser's user agent
     $browser = $bc->getBrowser();
     return $browser->Crawler;
 }
Esempio n. 2
0
/**
 * Returns array of all browser info.
 *
 * @usage global $browser_info;
 *
 * @return array
 */
function php_browser_info()
{
    $browscap = new \phpbrowscap\Browscap(apply_filters('php_browser_detection_cache_dir', PBD_DIR_PATH . 'cache'));
    $browscap->doAutoUpdate = apply_filters('php_browser_detection_autoupdate', TRUE);
    $browscap->updateInterval = apply_filters('php_browser_detection_cache_time', 2592000);
    // 30 days, default is 5
    $browscap->remoteIniUrl = apply_filters('php_browser_detection_version', "http://browscap.org/stream?q=Lite_PHP_BrowsCapINI");
    return $browscap->getBrowser(NULL, TRUE);
}
Esempio n. 3
0
 public function bcap()
 {
     $this->output('Generating bcap file...' . PHP_EOL);
     $path = \Clips\cache_filename(BCAP_FILENAME);
     $b = new \phpbrowscap\Browscap(dirname($path));
     $b->localFile = $path;
     $b->lowercase = true;
     $b->getBrowser();
     $this->output("Done!");
 }
Esempio n. 4
0
 /**
  * Parse the user agent string.
  *
  * @param  string $agent
  * @return mixed
  */
 public function parse($agent)
 {
     // Location of the browscap cache dir.
     $cacheDir = $this->objectConfigGet('cacheDir') ?: realpath(__DIR__ . '/../../cache/Browscap');
     // Create the instance with the ini's location.
     $browscap = new \phpbrowscap\Browscap($cacheDir);
     // Overwrite the class defaults, with custom configs.
     $browscap->iniFilename = $this->objectConfigGet('iniFilename');
     $browscap->cacheFilename = $this->objectConfigGet('cacheFilename');
     $browscap->doAutoUpdate = $this->objectConfigGet('doAutoUpdate');
     $browscap->updateInterval = $this->objectConfigGet('updateInterval');
     $browscap->errorInterval = $this->objectConfigGet('errorInterval');
     $browscap->updateMethod = $this->objectConfigGet('updateMethod');
     $browscap->timeout = $this->objectConfigGet('timeout');
     return $browscap->getBrowser($agent, true);
 }
Esempio n. 5
0
 /**
  * The command to download browser caps file
  */
 public function bcap()
 {
     $this->output("Downloading browser caps file from " . BCAP_URL . PHP_EOL);
     $path = \Clips\cache_filename(BCAP_FILENAME);
     if ($path) {
         $file = $this->downloadmanager->download(BCAP_URL);
         // Write the file
         file_put_contents($path, $file);
         // We already have the browscap cache
         $b = new \phpbrowscap\Browscap(dirname($path));
         $b->localFile = $path;
         $b->lowercase = true;
         $this->output("Generating the browser cap cache file.\n");
         $b->getBrowser();
         $this->output("Done!");
     } else {
         $this->error('Can\'t download browser cap file, since there is no cache directory to download!');
     }
 }
Esempio n. 6
0
 /**
  * Get the request browser's meta data using PHP's browscap support
  */
 public function browserMeta()
 {
     if (isset($this->browser)) {
         return $this->browser;
     }
     $bcap_filename = cache_filename(BCAP_FILENAME);
     if (file_exists($bcap_filename)) {
         // We already have the browscap cache
         $b = new \phpbrowscap\Browscap(dirname($bcap_filename));
         $b->localFile = $bcap_filename;
         $b->doAutoUpdate = false;
         $this->browser = $b->getBrowser();
         return $this->browser;
     } else {
         // We need to download that, log error and try the default get_browser
         $this->logger->warn('Can\'t find the browse cap file(you can get it by using command clips get bcap), using php default get_browser instead.');
     }
     $this->browser = get_browser();
     return $this->browser;
 }
Esempio n. 7
0
 public function update()
 {
     // 이벤트 라이브러리를 로딩합니다
     $eventname = 'event_admin_config_browscapupdate_update';
     $this->load->event($eventname);
     // 이벤트가 존재하면 실행합니다
     Events::trigger('before', $eventname);
     $dir = FCPATH . 'plugin/browscap';
     if (!(is_readable($dir) && is_writeable($dir))) {
         exit(json_encode(array('success' => 'no', 'message' => 'plugin/browscap 경로가 파일쓰기가 금지되어있습니다. 퍼미션 확인 후에 다시 실행바랍니다')));
     }
     ini_set('memory_limit', '-1');
     require_once FCPATH . 'plugin/browscap/Browscap.php';
     $browscap = new phpbrowscap\Browscap($dir);
     $browscap->updateMethod = 'cURL';
     $browscap->cacheFilename = 'browscap_cache.php';
     $browscap->updateCache();
     // 이벤트가 존재하면 실행합니다
     Events::trigger('after', $eventname);
     exit(json_encode(array('success' => 'ok', 'message' => 'Browscap 업데이트가 완료되었습니다')));
 }
Esempio n. 8
0
 /**
  * Get browser information.
  */
 public static function getBrowser($useragent = null, $return_array = false)
 {
     if (Registry::keyExists('Client_Browser')) {
         $browser = Registry::get('Client_Browser');
     } else {
         require_once ROOT_PATH . '/libs/Browscap/Browscap.php';
         $bc = new \phpbrowscap\Browscap(ROOT_PATH . '/libs/Browscap/');
         $browser = $bc->getBrowser($useragent, $return_array);
         Registry::set('Client_Browser', $browser);
     }
     return $browser;
 }
Esempio n. 9
0
<?php

if (!defined('_GNUBOARD_')) {
    exit;
}
// 개별 페이지 접근 불가
if (!(version_compare(phpversion(), '5.3.0', '>=') && defined('G5_BROWSCAP_USE') && G5_BROWSCAP_USE)) {
    return;
}
// Browscap 캐시 파일이 있으면 실행
if (defined('G5_VISIT_BROWSCAP_USE') && G5_VISIT_BROWSCAP_USE && is_file(G5_DATA_PATH . '/cache/browscap_cache.php')) {
    include_once G5_PLUGIN_PATH . '/browscap/Browscap.php';
    $browscap = new phpbrowscap\Browscap(G5_DATA_PATH . '/cache');
    $browscap->doAutoUpdate = false;
    $browscap->cacheFilename = 'browscap_cache.php';
    $info = $browscap->getBrowser($_SERVER['HTTP_USER_AGENT']);
    $vi_browser = $info->Comment;
    $vi_os = $info->Platform;
    $vi_device = $info->Device_Type;
}
 /**
  * User agent detection
  *
  * @param string $ua_string UA string
  *
  * @return array
  */
 static function detect($ua_string)
 {
     $dir = __DIR__ . "/../../../classes/vendor/phpbrowscap/phpbrowscap/";
     include "{$dir}/Browscap.php";
     // Update cache file (cache.php)
     /*$detect = new \phpbrowscap\Browscap($dir);
       $detect->cacheDir = __DIR__."/../../../tmp/";
       $detect->localFile = $dir."browscap.ini";
       $detect->updateMethod = "local";
       $detect->getBrowser($ua_string, true);
       return;
       */
     $detect = new \phpbrowscap\Browscap("{$dir}/cache.php");
     $detect->doAutoUpdate = false;
     $detect->iniFilename = "browscap.ini";
     $user_agent = new self();
     $user_agent->user_agent_string = substr($ua_string, 0, 255);
     return $detect->getBrowser($ua_string, true);
 }
Esempio n. 11
0
// clean the output buffer
ob_end_clean();
if (!(version_compare(phpversion(), '5.3.0', '>=') && defined('G5_BROWSCAP_USE') && G5_BROWSCAP_USE)) {
    die('사용할 수 없는 기능입니다.');
}
if ($is_admin != 'super') {
    die('최고관리자로 로그인 후 실행해 주세요.');
}
// browscap cache 파일 체크
if (!is_file(G5_DATA_PATH . '/cache/browscap_cache.php')) {
    echo '<p>Browscap 정보가 없습니다. 아래 링크로 이동해 Browscap 정보를 업데이트 하세요.</p>' . PHP_EOL;
    echo '<p><a href="' . G5_ADMIN_URL . '/browscap.php">Browscap 업데이트</a></p>' . PHP_EOL;
    exit;
}
include_once G5_PLUGIN_PATH . '/browscap/Browscap.php';
$browscap = new phpbrowscap\Browscap(G5_DATA_PATH . '/cache');
$browscap->doAutoUpdate = false;
$browscap->cacheFilename = 'browscap_cache.php';
// 데이터 변환
$rows = preg_replace('#[^0-9]#', '', $_GET['rows']);
if (!$rows) {
    $rows = 100;
}
$sql_common = " from {$g5['visit_table']} where vi_agent <> '' and ( vi_browser = '' or vi_os = '' or vi_device = '' ) ";
$sql_order = " order by vi_id desc ";
$sql_limit = " limit 0, {$rows} ";
$sql = " select count(vi_id) as cnt {$sql_common} ";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$sql = " select vi_id, vi_agent, vi_browser, vi_os, vi_device\n            {$sql_common}\n            {$sql_order}\n            {$sql_limit} ";
$result = sql_query($sql);
Esempio n. 12
0
File: lib.php Progetto: viyancs/bolt
/**
 * Update our app/resources/browscap/ files.
 */
function updateBrowscap()
{
    // Create a new Browscap object (loads or creates the cache)
    $bc = new \phpbrowscap\Browscap(dirname(__DIR__) . "/resources/browscap/");
    $bc->doAutoUpdate = true;
    $browser = $bc->getBrowser();
    echo __("Browscap file updated.") . "\n\n";
}
Esempio n. 13
0
function getUserAgentInfo()
{
    require_once 'phpbrowscap/Browscap.php';
    // phpbrowscap requires a cache; create cache dir if it doesn't exist
    if (!file_exists('phpbrowscap/cache')) {
        mkdir('phpbrowscap/cache', 0777, true);
    }
    // get and return the user agent info
    $bc = new phpbrowscap\Browscap('phpbrowscap/cache');
    return $bc->getBrowser();
}
Esempio n. 14
0
<?php

ini_set('memory_limit', '-1');
$sub_menu = "100510";
include_once './_common.php';
// clean the output buffer
ob_end_clean();
if (!(version_compare(phpversion(), '5.3.0', '>=') && defined('G5_BROWSCAP_USE') && G5_BROWSCAP_USE)) {
    die('사용할 수 없는 기능입니다.');
}
if ($is_admin != 'super') {
    die('최고관리자만 접근 가능합니다.');
}
include_once G5_PLUGIN_PATH . '/browscap/Browscap.php';
$browscap = new phpbrowscap\Browscap(G5_DATA_PATH . '/cache');
$browscap->updateMethod = 'cURL';
$browscap->cacheFilename = 'browscap_cache.php';
$browscap->updateCache();
die('');