1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-24 23:50:11 +01:00

Protect some boards

This commit is contained in:
8chan 2014-09-13 16:36:16 +00:00
parent 18ac30b7cc
commit 09ef51996a

View File

@ -4,7 +4,7 @@ include "inc/functions.php";
if (!(php_sapi_name() == "cli")) { if (!(php_sapi_name() == "cli")) {
die('nope'); die('nope');
} }
$protected = array('burgers', 'cow', 'wilno');
$q = query("SELECT uri FROM boards"); $q = query("SELECT uri FROM boards");
$boards = $q->fetchAll(PDO::FETCH_COLUMN); $boards = $q->fetchAll(PDO::FETCH_COLUMN);
$now = new DateTime(); $now = new DateTime();
@ -14,6 +14,10 @@ $mod_ago = (new DateTime)->sub(new DateInterval('P14D'));
// Find out the last activity for our board // Find out the last activity for our board
$delete = array(); $delete = array();
foreach($boards as $board) { foreach($boards as $board) {
if (in_array($board, $protected)) {
continue;
}
// last post // last post
$query = prepare(sprintf("SELECT MAX(time) AS time FROM posts_%s", $board)); $query = prepare(sprintf("SELECT MAX(time) AS time FROM posts_%s", $board));
$query->execute(); $query->execute();
@ -125,6 +129,7 @@ foreach($delete as $i => $d){
// Delete entire board directory // Delete entire board directory
rrmdir($board['uri'] . '/'); rrmdir($board['uri'] . '/');
rrmdir('static/banners/' . $board['uri']);
cache::delete('board_' . $board['uri']); cache::delete('board_' . $board['uri']);
_syslog(LOG_NOTICE, "Board deleted: {$board['uri']}"); _syslog(LOG_NOTICE, "Board deleted: {$board['uri']}");
@ -140,3 +145,4 @@ cache::delete('all_boards_uri');
cache::delete('all_boards'); cache::delete('all_boards');
rebuildThemes('boards'); rebuildThemes('boards');
$query = query('DELETE FROM board_create WHERE uri NOT IN (SELECT uri FROM boards);') or error(db_error()); $query = query('DELETE FROM board_create WHERE uri NOT IN (SELECT uri FROM boards);') or error(db_error());
file_get_contents('https://8chan.co/listboards.php');