Show logged event IPs on user page
This commit is contained in:
parent
7abf1aa591
commit
a8dfc9277b
@ -240,7 +240,9 @@ class UserPage extends Extension {
|
||||
$this->theme->display_ip_list(
|
||||
$page,
|
||||
$this->count_upload_ips($event->display_user),
|
||||
$this->count_comment_ips($event->display_user));
|
||||
$this->count_comment_ips($event->display_user),
|
||||
$this->count_log_ips($event->display_user)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,6 +589,21 @@ class UserPage extends Extension {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
private function count_log_ips(User $duser): array {
|
||||
if(!class_exists('LogDatabase')) return array();
|
||||
global $database;
|
||||
$rows = $database->get_pairs("
|
||||
SELECT
|
||||
address,
|
||||
COUNT(id) AS count,
|
||||
MAX(date_sent) AS most_recent
|
||||
FROM score_log
|
||||
WHERE username=:username
|
||||
GROUP BY address
|
||||
ORDER BY most_recent DESC", array("username"=>$duser->name));
|
||||
return $rows;
|
||||
}
|
||||
|
||||
private function delete_user(Page $page, bool $with_images=false, bool $with_comments=false) {
|
||||
global $user, $config, $database;
|
||||
|
||||
|
@ -168,7 +168,7 @@ class UserPageTheme extends Themelet {
|
||||
$page->add_block(new Block("Login", $html, "left", 90));
|
||||
}
|
||||
|
||||
public function display_ip_list(Page $page, array $uploads, array $comments) {
|
||||
public function display_ip_list(Page $page, array $uploads, array $comments, array $events) {
|
||||
$html = "<table id='ip-history'>";
|
||||
$html .= "<tr><td>Uploaded from: ";
|
||||
$n = 0;
|
||||
@ -190,8 +190,18 @@ class UserPageTheme extends Themelet {
|
||||
}
|
||||
}
|
||||
|
||||
$html .= "</td><td>Logged Events:";
|
||||
$n = 0;
|
||||
foreach($comments as $ip => $count) {
|
||||
$html .= '<br>'.$ip.' ('.$count.')';
|
||||
if(++$n >= 20) {
|
||||
$html .= "<br>...";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$html .= "</td></tr>";
|
||||
$html .= "<tr><td colspan='2'>(Most recent at top)</td></tr></table>";
|
||||
$html .= "<tr><td colspan='3'>(Most recent at top)</td></tr></table>";
|
||||
|
||||
$page->add_block(new Block("IPs", $html, "main", 70));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user