Improvements to ?/debug/antispam and ?/debug/recentc

This commit is contained in:
Michael Foster 2013-09-09 20:16:13 +10:00
parent 2fae55c094
commit 5da8f28726
3 changed files with 72 additions and 9 deletions

View File

@ -2328,11 +2328,21 @@ function mod_debug_recent_posts() {
$query = query($query) or error(db_error()); $query = query($query) or error(db_error());
$posts = $query->fetchAll(PDO::FETCH_ASSOC); $posts = $query->fetchAll(PDO::FETCH_ASSOC);
// Fetch recent posts from flood prevention cache
$query = query("SELECT * FROM ``flood`` ORDER BY `time` DESC") or error(db_error());
$flood_posts = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($posts as &$post) { foreach ($posts as &$post) {
$post['snippet'] = pm_snippet($post['body']); $post['snippet'] = pm_snippet($post['body']);
foreach ($flood_posts as $flood_post) {
if ($flood_post['time'] == $post['time'] &&
$flood_post['posthash'] == make_comment_hex($post['body_nomarkup']) &&
$flood_post['filehash'] == $post['filehash'])
$post['in_flood_table'] = true;
}
} }
mod_page(_('Debug: Recent posts'), 'mod/debug/recent_posts.html', array('posts' => $posts)); mod_page(_('Debug: Recent posts'), 'mod/debug/recent_posts.html', array('posts' => $posts, 'flood_posts' => $flood_posts));
} }
function mod_debug_sql() { function mod_debug_sql() {

View File

@ -14,11 +14,14 @@
<tr> <tr>
<td>{{ config.board_abbreviation|sprintf(hash.board) }}</td> <td>{{ config.board_abbreviation|sprintf(hash.board) }}</td>
<td> <td>
{% if hash.thread %} {% if hash.thread > 0 %}
{{ hash.thread }} {{ hash.thread }}
{% elseif hash.thread < 0 %}
Index (page {{ - hash.thread }})
{% else %} {% else %}
- -
{% endif %}</td> {% endif %}
</td>
<td> <td>
<small><code>{{ hash.hash }}</code></small> <small><code>{{ hash.hash }}</code></small>
</td> </td>
@ -28,7 +31,11 @@
<td> <td>
{% if hash.expires %} {% if hash.expires %}
<span title="{{ hash.expires|date(config.post_date) }}"> <span title="{{ hash.expires|date(config.post_date) }}">
{{ hash.expires|until }} {% if hash.expires < time() %}
{{ hash.expires|ago }} ago
{% else %}
{{ hash.expires|until }}
{% endif %}
</span> </span>
{% else %} {% else %}
- -
@ -55,11 +62,14 @@
<tr> <tr>
<td>{{ config.board_abbreviation|sprintf(hash.board) }}</td> <td>{{ config.board_abbreviation|sprintf(hash.board) }}</td>
<td> <td>
{% if hash.thread %} {% if hash.thread > 0 %}
{{ hash.thread }} {{ hash.thread }}
{% elseif hash.thread < 0 %}
Index (page {{ - hash.thread }})
{% else %} {% else %}
- -
{% endif %}</td> {% endif %}
</td>
<td> <td>
<small><code>{{ hash.hash }}</code></small> <small><code>{{ hash.hash }}</code></small>
</td> </td>
@ -69,7 +79,11 @@
<td> <td>
{% if hash.expires %} {% if hash.expires %}
<span title="{{ hash.expires|date(config.post_date) }}"> <span title="{{ hash.expires|date(config.post_date) }}">
{{ hash.expires|until }} {% if hash.expires < time() %}
{{ hash.expires|ago }} ago
{% else %}
{{ hash.expires|until }}
{% endif %}
</span> </span>
{% else %} {% else %}
- -

View File

@ -1,3 +1,40 @@
<p style="text-align:center">
Flood prevention cache:
</p>
<table class="modlog" style="width:1%;">
<tr>
<th>#</th>
<th>Time</th>
<th>Board</th>
<th>Post hash</th>
<th>File hash</th>
</tr>
{% for post in flood_posts %}
<tr>
<td class="minimal">{{ post.id }}</td>
<td class="minimal"{% if post.in_flood_table %} style="color:red" title="Still in flood prevention cache."{% endif %}>
<small>{{ post.time | ago }} ago</small>
</td>
<td class="minimal">
<a href="?/{{ config.board_path|sprintf(post.board) }}{{ config.file_index }}">
{{ config.board_abbreviation|sprintf(post.board) }}
</a>
</td>
<td><code>{{ post.posthash }}</code></td>
<td>
{% if post.filehash %}
<code>{{ post.filehash }}</code>
{% else %}
<em>No file</em>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
<p style="text-align:center">
Most recent {{ posts|count }} posts:
</p>
<table class="modlog" style="word-wrap: break-word;"> <table class="modlog" style="word-wrap: break-word;">
<tr> <tr>
<th>Time</th> <th>Time</th>
@ -12,11 +49,13 @@
</tr> </tr>
{% for post in posts %} {% for post in posts %}
<tr> <tr>
<td class="minimal"> <td class="minimal"{% if post.in_flood_table %} style="color:red" title="Still in flood prevention cache."{% endif %}>
<small>{{ post.time | ago }} ago</small> <small>{{ post.time | ago }} ago</small>
</td> </td>
<td class="minimal"> <td class="minimal">
<a href="?/{{ config.board_path|sprintf(post.board) }}{{ config.file_index }}">{{ config.board_abbreviation|sprintf(post.board) }}</a> <a href="?/{{ config.board_path|sprintf(post.board) }}{{ config.file_index }}">
{{ config.board_abbreviation|sprintf(post.board) }}
</a>
</td> </td>
<td class="minimal" > <td class="minimal" >
{% if post.thread %} {% if post.thread %}