当前位置: 首页>>代码示例>>PHP>>正文


PHP Host::by_ip_addr方法代码示例

本文整理汇总了PHP中Host::by_ip_addr方法的典型用法代码示例。如果您正苦于以下问题:PHP Host::by_ip_addr方法的具体用法?PHP Host::by_ip_addr怎么用?PHP Host::by_ip_addr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Host的用法示例。


在下文中一共展示了Host::by_ip_addr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: by_ip_addr

 /**
  *	@fn by_ip_addr($ip_addr, $params)
  *	@short Creates a Geoip object for the given IP address.
  *	@param ip_addr The IP address.
  *	@param params Parameters to initialize the IP address.
  */
 public static function by_ip_addr($ip_addr, $params = NULL)
 {
     // Get GEOIP data from web service
     $rough = file_get_contents(sprintf(GEOIP_LOOKUP, $ip_addr));
     // Split response in key-value lines
     $pairs = explode("\n", $rough);
     $geoip = parent::by_ip_addr($ip_addr, $params);
     $geoip->ip_addr = $ip_addr;
     $geoip->altitude = 0;
     foreach ($pairs as $pair) {
         // Create an element with given key-value association
         list($key, $value) = explode(":", $pair);
         $key = strtolower(str_replace(' ', '_', $key));
         $geoip->{$key} = trim($value);
     }
     return $geoip;
 }
开发者ID:emeraldion,项目名称:zelda,代码行数:23,代码来源:geoip.php

示例2: hits_by_host_list

 /**
  *	@fn hits_by_host_list
  *	@short Action method that builds the list of hits by host.
  *	@details This method is invoked with AJAX calls to update the list
  *	of hits by host in a dynamic fashion.
  */
 public function hits_by_host_list()
 {
     $conn = Db::get_connection();
     $conn->prepare("SELECT `ip_addr`, `params`, COUNT(*) AS `weight` " . "FROM `visits` " . "WHERE `gate` LIKE '%{1}%' " . "AND `date` >= '{2}' " . "AND (`ip_addr` LIKE '%{3}%' " . "OR `params` LIKE '%Apache'' => ''%{3}%') " . "AND `referrer` LIKE '%{4}%' " . "AND `user_agent` LIKE '%{5}%' " . "GROUP BY CONCAT(`ip_addr`, `user_agent`) " . "HAVING `weight` >= '{6}' AND `weight` <= '{7}' " . "ORDER BY `weight` DESC " . "LIMIT {8}", @$_REQUEST['p'], date("Y-m-d H:i:s", Time::ago(@$_REQUEST['t'])), @$_REQUEST['f'], @$_REQUEST['r'], @$_REQUEST['u'], @$_REQUEST['l'], @$_REQUEST['h'], 9999);
     $conn->exec();
     $this->hosts = array();
     if ($conn->num_rows() > 0) {
         while ($line = $conn->fetch_assoc()) {
             $host = Host::by_ip_addr($line['ip_addr'], $line['params']);
             $host->weight = $line['weight'];
             $this->hosts[] = $host;
         }
     }
     $conn->free_result();
     Db::close_connection($conn);
     $this->render(array('layout' => FALSE));
 }
开发者ID:emeraldion,项目名称:zelda,代码行数:23,代码来源:meta_controller.php

示例3: array

}
if ($visit->gate) {
    ?>
			<dt>Gate</dt>
			<dd><?php 
    echo Gate::by_URI($visit->gate, $visit->params);
    ?>
</dd>
<?php 
}
if ($visit->ip_addr) {
    ?>
			<dt>Hostname</dt>
			<dd>
				<?php 
    echo Host::by_ip_addr($visit->ip_addr)->hostname;
    ?>
				[<?php 
    echo $this->link_to($visit->ip_addr, array('action' => 'hits_by_host', 'query_string' => "ip={$visit->ip_addr}&l=1"));
    ?>
]
			</dd>
<?php 
}
if ($visit->user_agent) {
    ?>
			<dt>User Agent</dt>
			<dd><?php 
    echo $visit->user_agent;
    ?>
</dd>
开发者ID:emeraldion,项目名称:zelda,代码行数:31,代码来源:_visit.php


注:本文中的Host::by_ip_addr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。