示例#1
0
 /**
  *	@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
0
 /**
  *	@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
0
}
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>