mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-27 17:00:52 +01:00
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Conflicts: install.php templates/index.html templates/thread.html
This commit is contained in:
commit
7bdb96a16b
@ -384,6 +384,9 @@
|
||||
// When true, a blank password will be used for files (not usable for deletion).
|
||||
$config['field_disable_password'] = false;
|
||||
|
||||
// Require users to see the ban page at least once for a ban even if it has since expired?
|
||||
$config['require_ban_view'] = false;
|
||||
|
||||
/*
|
||||
* ====================
|
||||
* Markup settings
|
||||
@ -557,6 +560,9 @@
|
||||
// Number of characters in the poster ID (maximum is 40)
|
||||
$config['poster_id_length'] = 5;
|
||||
|
||||
// Show thread subject in page title?
|
||||
$config['thread_subject_in_title'] = false;
|
||||
|
||||
// Page footer
|
||||
$config['footer'][] = 'All trademarks, copyrights, comments, and images on this page are owned by and are the responsibility of their respective parties.';
|
||||
|
||||
@ -923,6 +929,9 @@
|
||||
// Edit raw HTML in posts by default
|
||||
$config['mod']['raw_html_default'] = false;
|
||||
|
||||
// Automatically dismiss all reports regarding a thread when it is locked
|
||||
$config['mod']['dismiss_reports_on_lock'] = true;
|
||||
|
||||
// Probably best not to change these:
|
||||
if (!defined('JANITOR')) {
|
||||
define('JANITOR', 0, true);
|
||||
|
@ -214,7 +214,7 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) {
|
||||
}
|
||||
|
||||
function bidi_cleanup($str){
|
||||
# Closes all embedded RTL and LTR unicode formatting blocks in a string so that
|
||||
# Removes all embedded RTL and LTR unicode formatting blocks in a string so that
|
||||
# it can be used inside another without controlling its direction.
|
||||
# More info: http://www.iamcal.com/understanding-bidirectional-text/
|
||||
#
|
||||
@ -228,21 +228,7 @@ function bidi_cleanup($str){
|
||||
$explicits = '\xE2\x80\xAA|\xE2\x80\xAB|\xE2\x80\xAD|\xE2\x80\xAE';
|
||||
$pdf = '\xE2\x80\xAC';
|
||||
|
||||
$stack = 0;
|
||||
$str = preg_replace_callback("!(?<explicits>$explicits)|(?<pdf>$pdf)!", function($match) use (&$stack) {
|
||||
if (isset($match['explicits']) && $match['explicits']) {
|
||||
$stack++;
|
||||
} else {
|
||||
if ($stack)
|
||||
$stack--;
|
||||
else
|
||||
return '';
|
||||
}
|
||||
return $match[0];
|
||||
}, $str);
|
||||
for ($i=0; $i<$stack; $i++){
|
||||
$str .= "\xE2\x80\xAC";
|
||||
}
|
||||
$str = preg_replace("!(?<explicits>$explicits)|(?<pdf>$pdf)!", '', $str);
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ function loadConfig() {
|
||||
|
||||
if ($config['debug']) {
|
||||
if (!isset($debug)) {
|
||||
$debug = array('sql' => array(), 'purge' => array(), 'cached' => array());
|
||||
$debug = array('sql' => array(), 'purge' => array(), 'cached' => array(), 'write' => array());
|
||||
$debug['start'] = microtime(true);
|
||||
}
|
||||
}
|
||||
@ -392,7 +392,7 @@ function purge($uri) {
|
||||
}
|
||||
|
||||
function file_write($path, $data, $simple = false, $skip_purge = false) {
|
||||
global $config;
|
||||
global $config, $debug;
|
||||
|
||||
if (preg_match('/^remote:\/\/(.+)\:(.+)$/', $path, $m)) {
|
||||
if (isset($config['remote'][$m[1]])) {
|
||||
@ -419,7 +419,7 @@ function file_write($path, $data, $simple = false, $skip_purge = false) {
|
||||
error('Unable to truncate file: ' . $path);
|
||||
|
||||
// Write data
|
||||
if (fwrite($fp, $data) === false)
|
||||
if (($bytes = fwrite($fp, $data)) === false)
|
||||
error('Unable to write to file: ' . $path);
|
||||
|
||||
// Unlock
|
||||
@ -445,6 +445,10 @@ function file_write($path, $data, $simple = false, $skip_purge = false) {
|
||||
purge($path);
|
||||
}
|
||||
|
||||
if ($config['debug']) {
|
||||
$debug['write'][] = $path . ': ' . $bytes . ' bytes';
|
||||
}
|
||||
|
||||
event('write', $path);
|
||||
}
|
||||
|
||||
@ -575,6 +579,12 @@ function ago($timestamp) {
|
||||
function displayBan($ban) {
|
||||
global $config;
|
||||
|
||||
if (!$ban['seen']) {
|
||||
$query = prepare("UPDATE `bans` SET `seen` = 1 WHERE `id` = :id");
|
||||
$query->bindValue(':id', $ban['id'], PDO::PARAM_INT);
|
||||
$query->execute() or error(db_error($query));
|
||||
}
|
||||
|
||||
$ban['ip'] = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// Show banned page and exit
|
||||
@ -601,12 +611,12 @@ function checkBan($board = 0) {
|
||||
if (event('check-ban', $board))
|
||||
return true;
|
||||
|
||||
$query = prepare("SELECT `set`, `expires`, `reason`, `board`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC, `expires` DESC LIMIT 1");
|
||||
$query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC, `expires` DESC LIMIT 1");
|
||||
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
||||
$query->bindValue(':board', $board);
|
||||
$query->execute() or error(db_error($query));
|
||||
if ($query->rowCount() < 1 && $config['ban_range']) {
|
||||
$query = prepare("SELECT `set`, `expires`, `reason`, `board`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND :ip LIKE REPLACE(REPLACE(`ip`, '%', '!%'), '*', '%') ESCAPE '!' ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1");
|
||||
$query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND :ip LIKE REPLACE(REPLACE(`ip`, '%', '!%'), '*', '%') ESCAPE '!' ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1");
|
||||
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
||||
$query->bindValue(':board', $board);
|
||||
$query->execute() or error(db_error($query));
|
||||
@ -614,7 +624,7 @@ function checkBan($board = 0) {
|
||||
|
||||
if ($query->rowCount() < 1 && $config['ban_cidr'] && !isIPv6()) {
|
||||
// my most insane SQL query yet
|
||||
$query = prepare("SELECT `set`, `expires`, `reason`, `board`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board)
|
||||
$query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board)
|
||||
AND (
|
||||
`ip` REGEXP '^(\[0-9]+\.\[0-9]+\.\[0-9]+\.\[0-9]+\)\/(\[0-9]+)$'
|
||||
AND
|
||||
@ -631,15 +641,29 @@ function checkBan($board = 0) {
|
||||
if ($ban = $query->fetch()) {
|
||||
if ($ban['expires'] && $ban['expires'] < time()) {
|
||||
// Ban expired
|
||||
$query = prepare("DELETE FROM `bans` WHERE `id` = :id LIMIT 1");
|
||||
$query = prepare("DELETE FROM `bans` WHERE `id` = :id");
|
||||
$query->bindValue(':id', $ban['id'], PDO::PARAM_INT);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
if ($config['require_ban_view'] && !$ban['seen']) {
|
||||
displayBan($ban);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
displayBan($ban);
|
||||
}
|
||||
|
||||
// I'm not sure where else to put this. It doesn't really matter where; it just needs to be called every now and then to keep the ban list tidy.
|
||||
purge_bans();
|
||||
}
|
||||
|
||||
// No reason to keep expired bans in the database (except those that haven't been viewed yet)
|
||||
function purge_bans() {
|
||||
$query = prepare("DELETE FROM `bans` WHERE `expires` IS NOT NULL AND `expires` < :time AND `seen` = 1");
|
||||
$query->bindValue(':time', time());
|
||||
$query->execute() or error(db_error($query));
|
||||
}
|
||||
|
||||
function threadLocked($id) {
|
||||
@ -1539,8 +1563,9 @@ function buildThread($id, $return=false, $mod=false) {
|
||||
error($config['error']['nonexistant']);
|
||||
|
||||
$body = Element('thread.html', array(
|
||||
'board'=>$board,
|
||||
'body'=>$thread->build(),
|
||||
'board' => $board,
|
||||
'thread' => $thread,
|
||||
'body' => $thread->build(),
|
||||
'config' => $config,
|
||||
'id' => $id,
|
||||
'mod' => $mod,
|
||||
|
@ -56,7 +56,7 @@ function parse_time($str) {
|
||||
function ban($mask, $reason, $length, $board) {
|
||||
global $mod, $pdo;
|
||||
|
||||
$query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :time, :expires, :reason, :board)");
|
||||
$query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :time, :expires, :reason, :board, 0)");
|
||||
$query->bindValue(':ip', $mask);
|
||||
$query->bindValue(':mod', $mod['id']);
|
||||
$query->bindValue(':time', time());
|
||||
|
@ -217,6 +217,19 @@ function mod_edit_board($boardName) {
|
||||
$query = prepare('DELETE FROM `antispam` WHERE `board` = :board');
|
||||
$query->bindValue(':board', $board['uri']);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
// Remove board from users/permissions table
|
||||
$query = query('SELECT `id`,`boards` FROM `mods`') or error(db_error());
|
||||
while ($user = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$user_boards = explode(',', $user['boards']);
|
||||
if (in_array($board['uri'], $user_boards)) {
|
||||
unset($user_boards[array_search($board['uri'], $user_boards)]);
|
||||
$_query = prepare('UPDATE `mods` SET `boards` = :boards WHERE `id` = :id');
|
||||
$_query->bindValue(':boards', implode(',', $user_boards));
|
||||
$_query->bindValue(':id', $user['id']);
|
||||
$_query->execute() or error(db_error($_query));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$query = prepare('UPDATE `boards` SET `title` = :title, `subtitle` = :subtitle WHERE `uri` = :uri');
|
||||
$query->bindValue(':uri', $board['uri']);
|
||||
@ -725,6 +738,13 @@ function mod_lock($board, $unlock, $post) {
|
||||
buildIndex();
|
||||
}
|
||||
|
||||
if ($config['mod']['dismiss_reports_on_lock']) {
|
||||
$query = prepare('DELETE FROM `reports` WHERE `board` = :board AND `post` = :id');
|
||||
$query->bindValue(':board', $board);
|
||||
$query->bindValue(':id', $post);
|
||||
$query->execute() or error(db_error($query));
|
||||
}
|
||||
|
||||
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
|
||||
|
||||
if ($unlock)
|
||||
@ -906,8 +926,10 @@ function mod_move($originBoard, $postID) {
|
||||
|
||||
modLog("Moved thread #${postID} to " . sprintf($config['board_abbreviation'], $targetBoard) . " (#${newID})", $originBoard);
|
||||
|
||||
// build new hread
|
||||
// build new thread
|
||||
buildThread($newID);
|
||||
|
||||
clean();
|
||||
buildIndex();
|
||||
|
||||
// trigger themes
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
// Installation/upgrade file
|
||||
define('VERSION', 'v0.9.6-dev-7 + <a href="https://github.com/vichan-devel/Tinyboard/">vichan-devel-4.0-gold</a>');
|
||||
define('VERSION', 'v0.9.6-dev-8 + <a href="https://github.com/vichan-devel/Tinyboard/">vichan-devel-4.0.1</a>');
|
||||
|
||||
require 'inc/functions.php';
|
||||
|
||||
@ -228,6 +228,8 @@ if (file_exists($config['has_installed'])) {
|
||||
query(sprintf("ALTER TABLE `posts_%s` DROP INDEX `thread`", $_board['uri'])) or error(db_error());
|
||||
}
|
||||
case 'v0.9.6-dev-7':
|
||||
case 'v0.9.6-dev-7 + <a href="https://github.com/vichan-devel/Tinyboard/">vichan-devel-4.0-gold</a>':
|
||||
query("ALTER TABLE `bans` ADD `seen` BOOLEAN NOT NULL") or error(db_error());
|
||||
case false:
|
||||
// Update version number
|
||||
file_write($config['has_installed'], VERSION);
|
||||
|
@ -51,6 +51,7 @@ CREATE TABLE IF NOT EXISTS `bans` (
|
||||
`expires` int(11) DEFAULT NULL,
|
||||
`reason` text,
|
||||
`board` varchar(120) DEFAULT NULL,
|
||||
`seen` tinyint(1) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FULLTEXT KEY `ip` (`ip`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||
|
4
mod.php
4
mod.php
@ -103,7 +103,7 @@ if (isset($config['mod']['custom_pages'])) {
|
||||
|
||||
$new_pages = array();
|
||||
foreach ($pages as $key => $callback) {
|
||||
if (preg_match('/^secure /', $callback))
|
||||
if (is_string($callback) && preg_match('/^secure /', $callback))
|
||||
$key .= '(/(?P<token>[a-f0-9]{8}))?';
|
||||
$new_pages[@$key[0] == '!' ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!'] = $callback;
|
||||
}
|
||||
@ -113,7 +113,7 @@ foreach ($pages as $uri => $handler) {
|
||||
if (preg_match($uri, $query, $matches)) {
|
||||
$matches = array_slice($matches, 1);
|
||||
|
||||
if (preg_match('/^secure(_POST)? /', $handler, $m)) {
|
||||
if (is_string($handler) && preg_match('/^secure(_POST)? /', $handler, $m)) {
|
||||
$secure_post_only = isset($m[1]);
|
||||
if (!$secure_post_only || $_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$token = isset($matches['token']) ? $matches['token'] : (isset($_POST['token']) ? $_POST['token'] : false);
|
||||
|
4
post.php
4
post.php
@ -635,10 +635,6 @@ if (isset($_POST['delete'])) {
|
||||
incrementSpamHash($post['antispam_hash']);
|
||||
}
|
||||
|
||||
if (isset($post['antispam_hash'])) {
|
||||
incrementSpamHash($post['antispam_hash']);
|
||||
}
|
||||
|
||||
if (isset($post['tracked_cites'])) {
|
||||
foreach ($post['tracked_cites'] as $cite) {
|
||||
$query = prepare('INSERT INTO `cites` VALUES (:board, :post, :target_board, :target)');
|
||||
|
@ -1,9 +1,17 @@
|
||||
{% filter remove_whitespace %}
|
||||
{# Automatically removes unnecessary whitespace #}
|
||||
<div class="ban">
|
||||
{% if ban.expires and time() >= ban.expires %}
|
||||
<h2>{% trans %}You were banned! ;_;{% endtrans %}</h2>
|
||||
{% else %}
|
||||
<h2>{% trans %}You are banned! ;_;{% endtrans %}</h2>
|
||||
{% endif %}
|
||||
<p>
|
||||
{% if ban.expires and time() >= ban.expires %}
|
||||
{% trans %}You were banned from{% endtrans %}
|
||||
{% else %}
|
||||
{% trans %}You have been banned from{% endtrans %}
|
||||
{% endif %}
|
||||
{% if ban.board %}
|
||||
<strong>{{ config.board_abbreviation|sprintf(ban.board) }}</strong>
|
||||
{% else %}
|
||||
@ -23,7 +31,9 @@
|
||||
<p>
|
||||
{% trans %}Your ban was filed on{% endtrans %}
|
||||
<strong>{{ ban.set|date(config.ban_date) }}</strong> {% trans %}and{% endtrans %} <span id="expires">
|
||||
{% if ban.expires %}
|
||||
{% if ban.expires and time() >= ban.expires %}
|
||||
{% trans %} has since expired. Refresh the page to continue.{% endtrans %}
|
||||
{% elseif ban.expires %}
|
||||
{% trans %}expires{% endtrans %} <span id="countdown">{{ ban.expires|until }}</span> {% trans %}from now, which is on{% endtrans %}
|
||||
<strong>
|
||||
{{ ban.expires|date(config.ban_date) }}
|
||||
|
@ -15,7 +15,7 @@
|
||||
</script>
|
||||
|
||||
{% include 'header.html' %}
|
||||
<title>{{ board.url }} - {{ board.name }}</title>
|
||||
<title>{{ board.url }} - {{ board.title|e }}</title>
|
||||
</head>
|
||||
<body>
|
||||
{{ boardlist.top }}
|
||||
|
@ -10,6 +10,7 @@
|
||||
<th>{% trans 'Set' %}</th>
|
||||
<th>{% trans 'Duration' %}</th>
|
||||
<th>{% trans 'Expires' %}</th>
|
||||
<th>{% trans 'Seen' %}</th>
|
||||
<th>{% trans 'Staff' %}</th>
|
||||
</tr>
|
||||
{% for ban in bans %}
|
||||
@ -58,6 +59,13 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if ban.seen %}
|
||||
{% trans 'Yes' %}
|
||||
{% else %}
|
||||
{% trans 'No' %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if ban.username %}
|
||||
{% if mod|hasPermission(config.mod.view_banstaff) %}
|
||||
|
@ -101,6 +101,7 @@
|
||||
</ul>
|
||||
</fieldset>
|
||||
|
||||
{#
|
||||
<fieldset>
|
||||
<legend>{% trans 'Search' %}</legend>
|
||||
|
||||
@ -115,6 +116,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
#}
|
||||
|
||||
{% if config.debug %}
|
||||
<fieldset>
|
||||
|
@ -136,6 +136,16 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans 'Seen' %}</th>
|
||||
<td>
|
||||
{% if ban.seen %}
|
||||
{% trans 'Yes' %}
|
||||
{% else %}
|
||||
{% trans 'No' %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans 'Staff' %}</th>
|
||||
<td>
|
||||
|
@ -8,7 +8,7 @@
|
||||
</script>
|
||||
|
||||
{% include 'header.html' %}
|
||||
<title>{{ board.url }} - {{ board.name }}</title>
|
||||
<title>{{ board.url }} - {% if config.thread_subject_in_title and thread.subject %}{{ thread.subject }}{% else %}{{ board.title|e }}{% endif %}</title>
|
||||
</head>
|
||||
<body>
|
||||
{{ boardlist.top }}
|
||||
|
Loading…
Reference in New Issue
Block a user