mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-29 01:34:31 +01:00
added "bumplocking" feature
This commit is contained in:
parent
b695e6f5c5
commit
af3f5d9371
@ -630,6 +630,7 @@
|
|||||||
// These can be URLs OR base64 (data URI scheme)
|
// These can be URLs OR base64 (data URI scheme)
|
||||||
//$config['image_sticky'] = $config['dir']['static'] . 'sticky.gif';
|
//$config['image_sticky'] = $config['dir']['static'] . 'sticky.gif';
|
||||||
//$config['image_locked'] = $config['dir']['static'] . 'locked.gif';
|
//$config['image_locked'] = $config['dir']['static'] . 'locked.gif';
|
||||||
|
//$config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif';
|
||||||
//$config['image_deleted'] = $config['dir']['static'] . 'deleted.';
|
//$config['image_deleted'] = $config['dir']['static'] . 'deleted.';
|
||||||
//$config['image_zip'] = $config['dir']['static'] . 'zip.';
|
//$config['image_zip'] = $config['dir']['static'] . 'zip.';
|
||||||
|
|
||||||
@ -675,6 +676,8 @@
|
|||||||
$config['mod']['link_desticky'] = '[-Sticky]';
|
$config['mod']['link_desticky'] = '[-Sticky]';
|
||||||
$config['mod']['link_lock'] = '[Lock]';
|
$config['mod']['link_lock'] = '[Lock]';
|
||||||
$config['mod']['link_unlock'] = '[-Lock]';
|
$config['mod']['link_unlock'] = '[-Lock]';
|
||||||
|
$config['mod']['link_bumplock'] = '[Sage]';
|
||||||
|
$config['mod']['link_bumpunlock'] = '[-Sage]';
|
||||||
|
|
||||||
// Moderator capcodes
|
// Moderator capcodes
|
||||||
$config['capcode'] = ' <a class="capcode">## %s</a>';
|
$config['capcode'] = ' <a class="capcode">## %s</a>';
|
||||||
@ -770,7 +773,11 @@
|
|||||||
$config['mod']['lock'] = MOD;
|
$config['mod']['lock'] = MOD;
|
||||||
// Post in a locked thread
|
// Post in a locked thread
|
||||||
$config['mod']['postinlocked'] = MOD;
|
$config['mod']['postinlocked'] = MOD;
|
||||||
// Post bypass unoriginal content check
|
// Prevent a thread from being bumped
|
||||||
|
$config['mod']['bumplock'] = MOD;
|
||||||
|
// View whether a thread has been bumplocked ("-1" to allow non-mods to see too)
|
||||||
|
$config['mod']['view_bumplock'] = MOD;
|
||||||
|
// Post bypass unoriginal content check on robot-enabled boards
|
||||||
$config['mod']['postunoriginal'] = ADMIN;
|
$config['mod']['postunoriginal'] = ADMIN;
|
||||||
// Bypass flood check
|
// Bypass flood check
|
||||||
$config['mod']['flood'] = ADMIN;
|
$config['mod']['flood'] = ADMIN;
|
||||||
|
@ -276,7 +276,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Thread {
|
class Thread {
|
||||||
public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $embed, $root=null, $mod=false, $hr=true) {
|
public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $bumplocked, $embed, $root=null, $mod=false, $hr=true) {
|
||||||
global $config;
|
global $config;
|
||||||
if(!isset($root)) $root = &$config['root'];
|
if(!isset($root)) $root = &$config['root'];
|
||||||
|
|
||||||
@ -302,6 +302,7 @@
|
|||||||
$this->ip = $ip;
|
$this->ip = $ip;
|
||||||
$this->sticky = $sticky;
|
$this->sticky = $sticky;
|
||||||
$this->locked = $locked;
|
$this->locked = $locked;
|
||||||
|
$this->bumplocked = $bumplocked;
|
||||||
$this->embed = $embed;
|
$this->embed = $embed;
|
||||||
$this->root = $root;
|
$this->root = $root;
|
||||||
$this->mod = $mod;
|
$this->mod = $mod;
|
||||||
@ -357,6 +358,12 @@
|
|||||||
else
|
else
|
||||||
$built .= ' <a title="Make thread sticky" href="?/' . $board['uri'] . '/sticky/' . $this->id . '">' . $config['mod']['link_sticky'] . '</a>';
|
$built .= ' <a title="Make thread sticky" href="?/' . $board['uri'] . '/sticky/' . $this->id . '">' . $config['mod']['link_sticky'] . '</a>';
|
||||||
|
|
||||||
|
if(hasPermission($config['mod']['bumplock'], $board['uri'], $this->mod))
|
||||||
|
if($this->bumplocked)
|
||||||
|
$built .= ' <a title="Allow thread to be bumped" href="?/' . $board['uri'] . '/bumpunlock/' . $this->id . '">' . $config['mod']['link_bumpunlock'] . '</a>';
|
||||||
|
else
|
||||||
|
$built .= ' <a title="Prevent thread from being bumped" href="?/' . $board['uri'] . '/bumplock/' . $this->id . '">' . $config['mod']['link_bumplock'] . '</a>';
|
||||||
|
|
||||||
// Lock
|
// Lock
|
||||||
if(hasPermission($config['mod']['lock'], $board['uri'], $this->mod))
|
if(hasPermission($config['mod']['lock'], $board['uri'], $this->mod))
|
||||||
if($this->locked)
|
if($this->locked)
|
||||||
|
@ -62,6 +62,8 @@
|
|||||||
$config['image_sticky'] = $config['dir']['static'] . 'sticky.gif';
|
$config['image_sticky'] = $config['dir']['static'] . 'sticky.gif';
|
||||||
if(!isset($config['image_locked']))
|
if(!isset($config['image_locked']))
|
||||||
$config['image_locked'] = $config['dir']['static'] . 'locked.gif';
|
$config['image_locked'] = $config['dir']['static'] . 'locked.gif';
|
||||||
|
if(!isset($config['image_bumplocked']))
|
||||||
|
$config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif';
|
||||||
if(!isset($config['image_deleted']))
|
if(!isset($config['image_deleted']))
|
||||||
$config['image_deleted'] = $config['dir']['static'] . 'deleted.png';
|
$config['image_deleted'] = $config['dir']['static'] . 'deleted.png';
|
||||||
if(!isset($config['image_zip']))
|
if(!isset($config['image_zip']))
|
||||||
@ -543,6 +545,21 @@
|
|||||||
return (bool) $post['locked'];
|
return (bool) $post['locked'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function threadSageLocked($id) {
|
||||||
|
global $board;
|
||||||
|
|
||||||
|
$query = prepare(sprintf("SELECT `sage` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NULL LIMIT 1", $board['uri']));
|
||||||
|
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
|
$query->execute() or error(db_error());
|
||||||
|
|
||||||
|
if(!$post = $query->fetch()) {
|
||||||
|
// Non-existant, so it can't be locked...
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (bool) $post['sage'];
|
||||||
|
}
|
||||||
|
|
||||||
function threadExists($id) {
|
function threadExists($id) {
|
||||||
global $board;
|
global $board;
|
||||||
|
|
||||||
@ -557,7 +574,7 @@
|
|||||||
|
|
||||||
function post($post, $OP) {
|
function post($post, $OP) {
|
||||||
global $pdo, $board;
|
global $pdo, $board;
|
||||||
$query = prepare(sprintf("INSERT INTO `posts_%s` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :time, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, :embed)", $board['uri']));
|
$query = prepare(sprintf("INSERT INTO `posts_%s` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :time, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, 0, :embed)", $board['uri']));
|
||||||
|
|
||||||
// Basic stuff
|
// Basic stuff
|
||||||
$query->bindValue(':subject', $post['subject']);
|
$query->bindValue(':subject', $post['subject']);
|
||||||
@ -754,7 +771,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['capcode'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $th['sticky'], $th['locked'], $th['embed'], $mod ? '?/' : $config['root'], $mod);
|
$thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['capcode'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $th['sticky'], $th['locked'], $th['sage'], $th['embed'], $mod ? '?/' : $config['root'], $mod);
|
||||||
|
|
||||||
$posts = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `thread` = :id ORDER BY `id` DESC LIMIT :limit", $board['uri']));
|
$posts = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `thread` = :id ORDER BY `id` DESC LIMIT :limit", $board['uri']));
|
||||||
$posts->bindValue(':id', $th['id']);
|
$posts->bindValue(':id', $th['id']);
|
||||||
@ -1372,7 +1389,7 @@
|
|||||||
|
|
||||||
while($post = $query->fetch()) {
|
while($post = $query->fetch()) {
|
||||||
if(!isset($thread)) {
|
if(!isset($thread)) {
|
||||||
$thread = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['embed'], $mod ? '?/' : $config['root'], $mod);
|
$thread = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['sage'], $post['embed'], $mod ? '?/' : $config['root'], $mod);
|
||||||
} else {
|
} else {
|
||||||
$thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], $mod ? '?/' : $config['root'], $mod));
|
$thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], $mod ? '?/' : $config['root'], $mod));
|
||||||
}
|
}
|
||||||
|
38
mod.php
38
mod.php
@ -951,7 +951,7 @@
|
|||||||
$temp = '';
|
$temp = '';
|
||||||
while($post = $query->fetch()) {
|
while($post = $query->fetch()) {
|
||||||
if(!$post['thread']) {
|
if(!$post['thread']) {
|
||||||
$po = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['embed'], '?/', $mod, false);
|
$po = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['sage'], $post['embed'], '?/', $mod, false);
|
||||||
} else {
|
} else {
|
||||||
$po = new Post($post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod);
|
$po = new Post($post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod);
|
||||||
}
|
}
|
||||||
@ -1310,7 +1310,7 @@
|
|||||||
openBoard($report['uri']);
|
openBoard($report['uri']);
|
||||||
|
|
||||||
if(!$post['thread']) {
|
if(!$post['thread']) {
|
||||||
$po = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['embed'], '?/', $mod, false);
|
$po = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['sage'], $post['embed'], '?/', $mod, false);
|
||||||
} else {
|
} else {
|
||||||
$po = new Post($post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod);
|
$po = new Post($post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod);
|
||||||
}
|
}
|
||||||
@ -1935,6 +1935,38 @@
|
|||||||
buildThread($post);
|
buildThread($post);
|
||||||
|
|
||||||
|
|
||||||
|
// Redirect
|
||||||
|
header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['file_index'], true, $config['redirect_http']);
|
||||||
|
} elseif(preg_match('/^\/' . $regex['board'] . 'bump(un)?lock\/(\d+)$/', $query, $matches)) {
|
||||||
|
// Lock/Unlock
|
||||||
|
|
||||||
|
$boardName = &$matches[1];
|
||||||
|
if(!hasPermission($config['mod']['bumplock'], $boardName)) error($config['error']['noaccess']);
|
||||||
|
|
||||||
|
$post = &$matches[3];
|
||||||
|
// Open board
|
||||||
|
if(!openBoard($boardName))
|
||||||
|
error($config['error']['noboard']);
|
||||||
|
|
||||||
|
$query = prepare(sprintf("UPDATE `posts_%s` SET `sage` = :bumplocked WHERE `id` = :id AND `thread` IS NULL", $board['uri']));
|
||||||
|
$query->bindValue(':id', $post, PDO::PARAM_INT);
|
||||||
|
|
||||||
|
if($matches[2] == 'un') {
|
||||||
|
// Record the action
|
||||||
|
modLog("Unbumplocked post #{$post}");
|
||||||
|
$query->bindValue(':bumplocked', 0, PDO::PARAM_INT);
|
||||||
|
} else {
|
||||||
|
// Record the action
|
||||||
|
modLog("Bumplocked post #{$post}");
|
||||||
|
$query->bindValue(':bumplocked', 1, PDO::PARAM_INT);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
buildIndex();
|
||||||
|
buildThread($post);
|
||||||
|
|
||||||
|
|
||||||
// Redirect
|
// Redirect
|
||||||
header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['file_index'], true, $config['redirect_http']);
|
header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['file_index'], true, $config['redirect_http']);
|
||||||
} elseif(preg_match('/^\/' . $regex['board'] . 'deletebyip\/(\d+)$/', $query, $matches)) {
|
} elseif(preg_match('/^\/' . $regex['board'] . 'deletebyip\/(\d+)$/', $query, $matches)) {
|
||||||
@ -2197,7 +2229,7 @@
|
|||||||
|
|
||||||
while($post = $query->fetch()) {
|
while($post = $query->fetch()) {
|
||||||
if(!$post['thread']) {
|
if(!$post['thread']) {
|
||||||
$po = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['embed'], '?/', $mod, false);
|
$po = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['sage'], $post['embed'], '?/', $mod, false);
|
||||||
} else {
|
} else {
|
||||||
$po = new Post($post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod);
|
$po = new Post($post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod);
|
||||||
}
|
}
|
||||||
|
2
post.php
2
post.php
@ -545,7 +545,7 @@
|
|||||||
|
|
||||||
buildThread(($OP?$id:$post['thread']));
|
buildThread(($OP?$id:$post['thread']));
|
||||||
|
|
||||||
if(!$OP && strtolower($post['email']) != 'sage' && ($config['reply_limit'] == 0 || numPosts($post['thread']) < $config['reply_limit'])) {
|
if(!$OP && strtolower($post['email']) != 'sage' && !threadSageLocked($post['thread']) && ($config['reply_limit'] == 0 || numPosts($post['thread']) < $config['reply_limit'])) {
|
||||||
bumpThread($post['thread']);
|
bumpThread($post['thread']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,9 @@
|
|||||||
{% if post.locked %}
|
{% if post.locked %}
|
||||||
<img class="icon" title="Locked" src="{{ config.image_locked }}" alt="Locked" />
|
<img class="icon" title="Locked" src="{{ config.image_locked }}" alt="Locked" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if post.bumplocked and (config.mod.view_bumplock < 0 or (post.mod and post.mod|hasPermission(config.mod.view_bumplock, board.uri))) %}
|
||||||
|
<img class="icon" title="Bumplocked" src="{{ config.image_bumplocked }}" alt="Locked" />
|
||||||
|
{% endif %}
|
||||||
{% if index %}
|
{% if index %}
|
||||||
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ config.file_page|sprintf(post.id) }}">[Reply]</a>
|
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ config.file_page|sprintf(post.id) }}">[Reply]</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user