Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

default/core/settings/account/login_history.php (1 issue)

Check that a foreach expression is traversable

Bug Major
1
<?php
2
3
$user = elgg_get_page_owner_entity();
4
5
$log = system_log_get_log($user->guid, 'login', '', 'user', '', 20);
6
if (empty($log)) {
7
	return;
8
}
9
$body = '<table class="elgg-table">';
10
$body .= '<thead><tr>';
11
$body .= '<th>' . elgg_echo('usersettings:statistics:login_history:date') . '</th><th>' . elgg_echo('usersettings:statistics:login_history:ip') . '</th>';
12
$body .= '</tr></thead>';
13
$body .= '<tbody>';
14
				
15
foreach ($log as $entry) {
0 ignored issues
show
The expression $log of type integer is not traversable.
Loading history...
16
	if ($entry->ip_address) {
17
		$ip_address = $entry->ip_address;
18
	} else {
19
		$ip_address = elgg_echo('unknown');
20
	}
21
	
22
	$time = date(elgg_echo('friendlytime:date_format'), $entry->time_created);
23
	
24
	$body .= "<tr><td>{$time}</td><td>{$ip_address}</td></tr>";
25
}
26
27
$body .= '</tbody></table>';
28
29
echo elgg_view_module('info', elgg_echo('usersettings:statistics:login_history'), $body);
30