/**
  * IP转地区号
  * 
  * @param integer|string $ip
  * @param boolean $ip2long
  * @return integer
  */
 protected function _ip2area($ip, $ip2long = false)
 {
     if ($ip2long && is_string($ip)) {
         $ip = ip2long($ip);
     }
     if (null === $this->_ip) {
         $this->_ip = new ZtChart_Model_Assemble_Ip();
     }
     return $this->_ip->getArea($ip);
 }
 /**
  * 扩展父类功能,设置默认缓存。
  */
 public function getCacheManager()
 {
     if (null != ($cacheManager = parent::getCacheManager())) {
         // 设置图表数据的缓存
         if ($cacheManager->hasCache('chart')) {
             ZtChart_Model_Assemble::setCache($cacheManager->getCache('chart'));
         }
         // 设置权限控制数据的缓存
         if ($cacheManager->hasCache('acl')) {
             ZtChart_Model_Acl_Loader::setCache($cacheManager->getCache('acl'));
         }
         // 设置IP数据的缓存
         if ($cacheManager->hasCache('ip')) {
             ZtChart_Model_Assemble_Ip::setCache($cacheManager->getCache('ip'));
         }
     }
     return $cacheManager;
 }
 /**
  * 初始化IP数据的目录
  */
 protected function _initIpDataPath()
 {
     ZtChart_Model_Assemble_Ip::setDataPath(realpath(__DIR__ . '/../data'));
 }
Example #4
0
 /**
  * 设置IP数据文件目录
  * 
  * @param string $datapath
  */
 public static function setDataPath($datapath)
 {
     self::$_datapath = $datapath;
 }