1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-25 07:50:23 +01:00
This commit is contained in:
Michael Save 2012-04-14 22:58:36 +10:00
parent bb09b2c452
commit 1726238cd8
3 changed files with 68 additions and 8 deletions

View File

@ -117,6 +117,9 @@ function mod_view_thread($boardName, $thread) {
function mod_ip_remove_note($ip, $id) { function mod_ip_remove_note($ip, $id) {
global $config, $mod; global $config, $mod;
if (!hasPermission($config['mod']['remove_notes']))
error($config['error']['noaccess']);
if (filter_var($ip, FILTER_VALIDATE_IP) === false) if (filter_var($ip, FILTER_VALIDATE_IP) === false)
error("Invalid IP address."); error("Invalid IP address.");
@ -135,6 +138,9 @@ function mod_page_ip($ip) {
error("Invalid IP address."); error("Invalid IP address.");
if (isset($_POST['ban_id'], $_POST['unban'])) { if (isset($_POST['ban_id'], $_POST['unban'])) {
if (!hasPermission($config['mod']['unban']))
error($config['error']['noaccess']);
require_once 'inc/mod/ban.php'; require_once 'inc/mod/ban.php';
unban($_POST['ban_id']); unban($_POST['ban_id']);
@ -143,12 +149,8 @@ function mod_page_ip($ip) {
} }
if (isset($_POST['note'])) { if (isset($_POST['note'])) {
if (hasPermission($config['mod']['create_notes'])) { if (!hasPermission($config['mod']['create_notes']))
$query = prepare("SELECT `bans`.*, `username` FROM `bans` LEFT JOIN `mods` ON `mod` = `mods`.`id` WHERE `ip` = :ip"); error($config['error']['noaccess']);
$query->bindValue(':ip', $ip);
$query->execute() or error(db_error($query));
$args['bans'] = $query->fetchAll(PDO::FETCH_ASSOC);
}
markup($_POST['note']); markup($_POST['note']);
$query = prepare('INSERT INTO `ip_notes` VALUES (NULL, :ip, :mod, :time, :body)'); $query = prepare('INSERT INTO `ip_notes` VALUES (NULL, :ip, :mod, :time, :body)');
@ -328,11 +330,57 @@ function mod_new_pm($username) {
} }
function mod_rebuild() { function mod_rebuild() {
global $config; global $config, $twig;
if (!hasPermission($config['mod']['rebuild'])) if (!hasPermission($config['mod']['rebuild']))
error($config['error']['noaccess']); error($config['error']['noaccess']);
if (isset($_POST['rebuild'])) {
$log = array();
$boards = listBoards();
$rebuilt_scripts = array();
if (isset($_POST['rebuild_cache'])) {
$log[] = 'Clearing template cache';
load_twig();
$twig->clearCacheFiles();
}
if (isset($_POST['rebuild_themes'])) {
$log[] = 'Regenerating theme files';
rebuildThemes('all');
}
if (isset($_POST['rebuild_javascript'])) {
$log[] = 'Rebuilding <strong>' . $config['file_script'] . '</strong>';
buildJavascript();
$rebuilt_scripts[] = $config['file_script'];
}
foreach ($boards as $board) {
if (!(isset($_POST['boards_all']) || isset($_POST['boards_' . $board['uri']])))
continue;
openBoard($board['uri']);
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Creating index pages';
if (!in_array($config['file_script'], $rebuilt_scripts)) {
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding <strong>' . $config['file_script'] . '</strong>';
buildJavascript();
$rebuilt_scripts[] = $config['file_script'];
}
$query = query(sprintf("SELECT `id` FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
while($post = $query->fetch()) {
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding thread #' . $post['id'];
buildThread($post['id']);
}
}
mod_page("Rebuild", 'mod/rebuilt.html', array('logs' => $log));
return;
}
mod_page("Rebuild", 'mod/rebuild.html', array('boards' => listBoards())); mod_page("Rebuild", 'mod/rebuild.html', array('boards' => listBoards()));
} }

View File

@ -66,6 +66,6 @@
</ul> </ul>
<p style="text-align:center"> <p style="text-align:center">
<input type="submit" value="Rebuild"> <input type="submit" value="Rebuild" name="rebuild">
</p> </p>
</form> </form>

View File

@ -0,0 +1,12 @@
<div class="ban">
<h2>Rebuilt</h2>
<ul>
{% for log in logs %}
<li>{{ log }}</li>
{% endfor %}
</ul>
<p>
<a href="?/rebuild">Go back and rebuild again</a>.
</p>
</div>