mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-23 23:20:57 +01:00
multiple improvements
This commit is contained in:
parent
f0412b0814
commit
cc614e36b4
@ -80,7 +80,7 @@ function ban($mask, $reason, $length, $board) {
|
||||
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
modLog('Created a new ban (<small>#' . $pdo->lastInsertId() . '</small>) for <strong>' . utf8tohtml($mask) . '</strong> with ' . ($reason ? 'reason: <small>' . $reason . '</small>' : 'no reason'));
|
||||
modLog('Created a new ban (<small>#' . $pdo->lastInsertId() . '</small>) for <strong>' . utf8tohtml($mask) . '</strong> with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
|
||||
}
|
||||
|
||||
function unban($id) {
|
||||
|
@ -15,6 +15,7 @@ function mod_page($title, $template, $args) {
|
||||
echo Element('page.html', array(
|
||||
'config' => $config,
|
||||
'mod' => $mod,
|
||||
'hide_dashboard_link' => $template == 'mod/dashboard.html',
|
||||
'title' => $title,
|
||||
'body' => Element($template,
|
||||
array_merge(
|
||||
@ -262,10 +263,12 @@ function mod_bans($page_no = 1) {
|
||||
$unban[] = $match[1];
|
||||
}
|
||||
|
||||
query('DELETE FROM `bans` WHERE `id` = ' . implode(' OR `id` = ', $unban)) or error(db_error());
|
||||
if (!empty($unban)) {
|
||||
query('DELETE FROM `bans` WHERE `id` = ' . implode(' OR `id` = ', $unban)) or error(db_error());
|
||||
|
||||
foreach ($unban as $id) {
|
||||
modLog("Removed ban #{$id}");
|
||||
foreach ($unban as $id) {
|
||||
modLog("Removed ban #{$id}");
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: ?/bans', true, $config['redirect_http']);
|
||||
@ -278,8 +281,8 @@ function mod_bans($page_no = 1) {
|
||||
$query = prepare("SELECT `bans`.*, `username` FROM `bans` INNER JOIN `mods` ON `mod` = `mods`.`id` WHERE `expires` = 0 OR `expires` > :time ORDER BY `set` DESC LIMIT :offset, :limit");
|
||||
}
|
||||
$query->bindValue(':time', time(), PDO::PARAM_INT);
|
||||
$query->bindValue(':limit', $config['mod']['modlog_page'], PDO::PARAM_INT);
|
||||
$query->bindValue(':offset', ($page_no - 1) * $config['mod']['modlog_page'], PDO::PARAM_INT);
|
||||
$query->bindValue(':limit', $config['mod']['banlist_page'], PDO::PARAM_INT);
|
||||
$query->bindValue(':offset', ($page_no - 1) * $config['mod']['banlist_page'], PDO::PARAM_INT);
|
||||
$query->execute() or error(db_error($query));
|
||||
$bans = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
@ -295,6 +298,58 @@ function mod_bans($page_no = 1) {
|
||||
mod_page('Ban list', 'mod/ban_list.html', array('bans' => $bans, 'count' => $count));
|
||||
}
|
||||
|
||||
|
||||
function mod_lock($board, $unlock, $post) {
|
||||
global $config;
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
||||
if (!hasPermission($config['mod']['lock'], $board))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
$query = prepare(sprintf('UPDATE `posts_%s` SET `locked` = :locked WHERE `id` = :id AND `thread` IS NULL', $board));
|
||||
$query->bindValue(':id', $post);
|
||||
$query->bindValue(':locked', $unlock ? 0 : 1);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
function mod_sticky($board, $unsticky, $post) {
|
||||
global $config;
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
||||
if (!hasPermission($config['mod']['sticky'], $board))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
$query = prepare(sprintf('UPDATE `posts_%s` SET `sticky` = :sticky WHERE `id` = :id AND `thread` IS NULL', $board));
|
||||
$query->bindValue(':id', $post);
|
||||
$query->bindValue(':sticky', $unsticky ? 0 : 1);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
function mod_bumplock($board, $unbumplock, $post) {
|
||||
global $config;
|
||||
|
||||
if (!openBoard($board))
|
||||
error($config['error']['noboard']);
|
||||
|
||||
if (!hasPermission($config['mod']['bumplock'], $board))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
$query = prepare(sprintf('UPDATE `posts_%s` SET `sage` = :bumplock WHERE `id` = :id AND `thread` IS NULL', $board));
|
||||
$query->bindValue(':id', $post);
|
||||
$query->bindValue(':bumplock', $unbumplock ? 0 : 1);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
function mod_delete($board, $post) {
|
||||
global $config, $mod;
|
||||
|
||||
@ -599,4 +654,19 @@ function mod_report_dismiss($id, $all = false) {
|
||||
header('Location: ?/reports', true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
function mod_debug_antispam() {
|
||||
$args = array();
|
||||
|
||||
$query = query('SELECT COUNT(*) FROM `antispam`') or error(db_error());
|
||||
$args['total'] = number_format($query->fetchColumn(0));
|
||||
|
||||
$query = query('SELECT COUNT(*) FROM `antispam` WHERE `expires` IS NOT NULL') or error(db_error());
|
||||
$args['expiring'] = number_format($query->fetchColumn(0));
|
||||
|
||||
$query = query('SELECT * FROM `antispam` /* WHERE `passed` > 0 */ ORDER BY `passed` DESC LIMIT 25') or error(db_error());
|
||||
$args['top'] = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
mod_page("Debug: Anti-spam", 'mod/debug/antispam.html', $args);
|
||||
}
|
||||
|
||||
|
||||
|
11
mod.php
11
mod.php
@ -43,10 +43,17 @@ $pages = array(
|
||||
'!^/bans/(\d+)$!' => 'bans', // ban list
|
||||
|
||||
'!^/(\w+)/delete/(\d+)$!' => 'delete', // delete post
|
||||
'!^/(\w+)/(un)?lock/(\d+)$!' => 'lock', // lock thread
|
||||
'!^/(\w+)/(un)?sticky/(\d+)$!' => 'sticky', // sticky thread
|
||||
'!^/(\w+)/bump(un)?lock/(\d+)$!' => 'bumplock', // "bumplock" thread
|
||||
|
||||
// these pages aren't listed in the dashboard without $config['debug']
|
||||
'!^/debug/antispam$!' => 'debug_antispam',
|
||||
|
||||
// This should always be at the end:
|
||||
'!^/(\w+)/' . preg_quote($config['file_index'], '!') . '?$!' => 'view_board',
|
||||
'!^/(\w+)/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) . '$!' => 'view_board',
|
||||
'!^/(\w+)/$!' => 'view_board',
|
||||
'!^/(\w+)/' . preg_quote($config['file_index'], '!') . '$!' => 'view_board',
|
||||
'!^/(\w+)/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) . '$!' => 'view_board',
|
||||
'!^/(\w+)/' . preg_quote($config['dir']['res'], '!') .
|
||||
str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) . '$!' => 'view_thread',
|
||||
);
|
||||
|
@ -79,3 +79,13 @@
|
||||
|
||||
{# TODO #}
|
||||
</fieldset>
|
||||
|
||||
{% if config.debug %}
|
||||
<fieldset>
|
||||
<legend>Debug</legend>
|
||||
<ul>
|
||||
<li><a href="?/debug/antispam">Anti-spam</a></li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
|
||||
|
42
templates/mod/debug/antispam.html
Normal file
42
templates/mod/debug/antispam.html
Normal file
@ -0,0 +1,42 @@
|
||||
<p style="text-align:center">
|
||||
Most used (in active):
|
||||
</p>
|
||||
<table class="modlog" style="width:600px;margin:auto">
|
||||
<tr>
|
||||
<th>Board</th>
|
||||
<th>Thread</th>
|
||||
<th>Hash (CRC32)</th>
|
||||
<th>Created</th>
|
||||
<th>Expires</th>
|
||||
<th>Passed</th>
|
||||
</tr>
|
||||
{% for hash in top %}
|
||||
<tr>
|
||||
<td>{{ config.board_abbreviation|sprintf(hash.board) }}</td>
|
||||
<td>
|
||||
{% if hash.thread %}
|
||||
{{ hash.thread }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}</td>
|
||||
<td>{{ hash.hash }}</td>
|
||||
<td>
|
||||
<span title="{{ hash.created|date(config.post_date) }}">{{ hash.created|ago }} ago</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if hash.expires %}
|
||||
<span title="{{ hash.expires|date(config.post_date) }}">
|
||||
{{ hash.expires|until }}
|
||||
</span>
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ hash.passed }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<p style="text-align:center">
|
||||
Total: <strong>{{ total }}</strong> (<strong>{{ expiring }}</strong> set to expire)
|
||||
</p>
|
||||
|
@ -17,7 +17,7 @@
|
||||
{% if subtitle %}
|
||||
{{ subtitle }}
|
||||
{% endif %}
|
||||
{% if mod %}<p><a href="?/">{% trans %}Return to dashboard{% endtrans %}</a></p>{% endif %}
|
||||
{% if mod and not hide_dashboard_link %}<p><a href="?/">{% trans %}Return to dashboard{% endtrans %}</a></p>{% endif %}
|
||||
</div>
|
||||
</header>
|
||||
{{ body }}
|
||||
|
Loading…
Reference in New Issue
Block a user