本文整理匯總了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>