Browse Source

Basic "IP" page

pull/40/head
Savetheinternet 13 years ago
parent
commit
c2727787ab
  1. 6
      inc/config.php
  2. 40
      mod.php

6
inc/config.php

@ -164,6 +164,12 @@
define('MOD_DEFAULT', '/', true); define('MOD_DEFAULT', '/', true);
// Don't even display MySQL password to administrators (in the configuration page) // Don't even display MySQL password to administrators (in the configuration page)
define('MOD_NEVER_REAL_PASSWORD', true, true); define('MOD_NEVER_REAL_PASSWORD', true, true);
// Do a DNS lookup on IP addresses to get their hostname on the IP summary page
define('MOD_DNS_LOOKUP', true, true);
// Show ban form on the IP summary page
define('MOD_IP_BANFORM', true, true);
// How many recent posts, per board, to show in the IP summary page
define('MOD_IP_RECENTPOSTS', 5, true);
// Probably best not to change these: // Probably best not to change these:
define('MOD_JANITOR', 0, true); define('MOD_JANITOR', 0, true);

40
mod.php

@ -448,6 +448,46 @@
'mod'=>true 'mod'=>true
) )
); );
} elseif(preg_match('/^\/IP\/(\d+\.\d+\.\d+\.\d+)$/', $query, $matches)) {
// View information on an IP address
$ip = $matches[1];
$host = MOD_DNS_LOOKUP ? gethostbyaddr($ip) : false;
$body = '';
$boards = listBoards();
foreach($boards as &$_board) {
openBoard($_board['uri']);
$temp = '';
$query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `ip` = :ip ORDER BY `sticky` DESC, `time` LIMIT :limit", $_board['uri']));
$query->bindValue(':ip', $ip);
$query->bindValue(':limit', MOD_IP_RECENTPOSTS, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
while($post = $query->fetch()) {
$po = new Post($post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $mod ? '?/' : ROOT, $mod);
$temp .= $po->build();
}
if(!empty($temp))
$body .= '<fieldset><legend>Last ' . $query->rowCount() . ' posts on <a href="?/' .
sprintf(BOARD_PATH, $_board['uri']) . FILE_INDEX .
'">' .
sprintf(BOARD_ABBREVIATION, $_board['uri']) . ' - ' . $_board['title'] .
'</a></legend>' . $temp . '</fieldset>';
}
if(MOD_IP_BANFORM)
$body .= form_newBan($ip, null, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false);
echo Element('page.html', Array(
'index'=>ROOT,
'title'=>'IP: ' . $ip,
'subtitle' => $host,
'body'=>$body,
'mod'=>true
)
);
} else { } else {
error(ERROR_404); error(ERROR_404);
} }

Loading…
Cancel
Save