link posts in modlog

This commit is contained in:
Michael Save 2012-01-09 10:38:01 +11:00
parent 9969e37105
commit 9ff35f9bc5

23
mod.php
View File

@ -298,7 +298,26 @@
while($log = $query->fetch()) { while($log = $query->fetch()) {
$log['text'] = utf8tohtml($log['text']); $log['text'] = utf8tohtml($log['text']);
$log['text'] = preg_replace('/(\d+\.\d+\.\d+\.\d+)/', '<a href="?/IP/$1">$1</a>', $log['text']); $log['text'] = preg_replace('/(\d+\.\d+\.\d+\.\d+)/', '<a href="?/IP/$1">$1</a>', $log['text']);
if(isset($boards[$log['board']])) {
if(preg_match('/post #(\d+)/', $log['text'], $match)) {
$post_query = prepare(sprintf("SELECT `thread` FROM `posts_%s` WHERE `id` = :id", $boards[$log['board']]));
$post_query->bindValue(':id', $match[1], PDO::PARAM_INT);
$post_query->execute() or error(db_error($query));
if($post = $post_query->fetch()) {
$log['text'] = preg_replace('/post #(\d+)/', '<a href="' .
'?/' .
sprintf($config['board_path'], $boards[$log['board']]) .
$config['dir']['res'] .
($post['thread'] ?
sprintf($config['file_page'], $post['thread']) . '#' . $match[1]
: sprintf($config['file_page'], $match[1])) .
'">$0</a>', $log['text']);
}
}
}
$body .= '<tr>' . $body .= '<tr>' .
'<td class="minimal">' . '<td class="minimal">' .
($log['username'] ? ($log['username'] ?
@ -310,7 +329,7 @@
'<td class="minimal">' . '<td class="minimal">' .
($log['board'] ? ($log['board'] ?
(isset($boards[$log['board']]) ? (isset($boards[$log['board']]) ?
'<a href="?/' . $boards[$log['board']] . '/' . $config['file_index'] . '">' . sprintf($config['board_abbreviation'], $boards[$log['board']]) . '</a></td>' '<a href="?/' . sprintf($config['board_path'], $boards[$log['board']]) . $config['file_index'] . '">' . sprintf($config['board_abbreviation'], $boards[$log['board']]) . '</a></td>'
: '<em>deleted?</em>') : '<em>deleted?</em>')
: '-') . : '-') .
'<td>' . $log['text'] . '</td>' . '<td>' . $log['text'] . '</td>' .