function ip_geoloc_get_recent_visitor_locations in IP Geolocation Views & Maps 8
Same name and namespace in other branches
- 7 ip_geoloc_blocks.inc \ip_geoloc_get_recent_visitor_locations()
Get recent visitor locations.
Parameters
int $how_many: How many locations to retrieve.
Return value
object Object of locations found.
1 call to ip_geoloc_get_recent_visitor_locations()
- RecentVisistorsMapBlock::build in src/
Plugin/ Block/ RecentVisistorsMapBlock.php - Builds and returns the renderable array for this block plugin.
File
- ./
ip_geoloc_blocks.inc, line 41 - Blocks available in IP Geolocation Views & Maps.
Code
function ip_geoloc_get_recent_visitor_locations($how_many) {
// @TODO Review how to migrate this code
/*$locations = array();
$injected_database->schema()->tableExists('accesslog');
if (db_table_exists('accesslog')) {
A LEFT JOIN would also pick up new IP addresses that are about to be
// inserted into the {accesslog}.
// However a LEFT JOIN in this query can easily make it 100 times slower
// than the INNER JOIN used below and would only be relevant for the very
// first click from a new IP address or in the case where the IP address was
// removed from the {accesslog}.
$result = db_query_range('SELECT DISTINCT ip_address, latitude, longitude, formatted_address, COUNT(a.timestamp) AS visit_count, MAX(a.timestamp) AS last_visit FROM {ip_geoloc} i INNER JOIN {accesslog} a ON i.ip_address = a.hostname GROUP BY i.ip_address ORDER BY last_visit DESC', 0, $how_many);
foreach ($result as $location) {
// Prevent older IP address locations overwriting the latest location.
if (!isset($locations[$location->ip_address])) {
$loc_rendered = new stdClass();
$loc_rendered->latitude = $location->latitude;
$loc_rendered->longitude = $location->longitude;
$loc_rendered->balloon_text = t('IP address') . ' ' . $location->ip_address . '<br/>'
. $location->formatted_address . '<br/>'
. t('#visits') . ' ' . (empty($location->visit_count) ? '?' : $location->visit_count)
. ', ' . t('last visit') . ' ' . (empty($location->last_visit) ? '?' : format_date($location->last_visit, 'short'));
$locations[$location->ip_address] = $loc_rendered;
}
}
}*/
$build = [
'#type' => 'inline_template',
'#template' => '<p>Removed until better statictics D8 port</p>',
'#context' => [],
];
$build = [];
return $build;
}