本文整理汇总了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;
}
示例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));
}
示例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>