mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-25 07:50:23 +01:00
Major config.php cleanup and a few minor misc fixes.
This commit is contained in:
parent
e445c88d1d
commit
d59e74f394
1040
inc/config.php
1040
inc/config.php
File diff suppressed because it is too large
Load Diff
@ -319,31 +319,31 @@ class Post {
|
||||
|
||||
// Delete
|
||||
if (hasPermission($config['mod']['delete'], $board['uri'], $this->mod))
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_delete'], 'Delete', 'Are you sure you want to delete this?', $board['uri'] . '/delete/' . $this->id);
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_delete'], 'Delete', 'Are you sure you want to delete this?', $board['dir'] . 'delete/' . $this->id);
|
||||
|
||||
// Delete all posts by IP
|
||||
if (hasPermission($config['mod']['deletebyip'], $board['uri'], $this->mod))
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip'], 'Delete all posts by IP', 'Are you sure you want to delete all posts by this IP address?', $board['uri'] . '/deletebyip/' . $this->id);
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip'], 'Delete all posts by IP', 'Are you sure you want to delete all posts by this IP address?', $board['dir'] . 'deletebyip/' . $this->id);
|
||||
|
||||
// Delete all posts by IP (global)
|
||||
if (hasPermission($config['mod']['deletebyip_global'], $board['uri'], $this->mod))
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip_global'], 'Delete all posts by IP across all boards', 'Are you sure you want to delete all posts by this IP address, across all boards?', $board['uri'] . '/deletebyip/' . $this->id . '/global');
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip_global'], 'Delete all posts by IP across all boards', 'Are you sure you want to delete all posts by this IP address, across all boards?', $board['dir'] . 'deletebyip/' . $this->id . '/global');
|
||||
|
||||
// Ban
|
||||
if (hasPermission($config['mod']['ban'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="'._('Ban').'" href="?/' . $board['uri'] . '/ban/' . $this->id . '">' . $config['mod']['link_ban'] . '</a>';
|
||||
$built .= ' <a title="'._('Ban').'" href="?/' . $board['dir'] . 'ban/' . $this->id . '">' . $config['mod']['link_ban'] . '</a>';
|
||||
|
||||
// Ban & Delete
|
||||
if (hasPermission($config['mod']['bandelete'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="'._('Ban & Delete').'" href="?/' . $board['uri'] . '/ban&delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
|
||||
$built .= ' <a title="'._('Ban & Delete').'" href="?/' . $board['dir'] . 'ban&delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
|
||||
|
||||
// Delete file (keep post)
|
||||
if (!empty($this->file) && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod))
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['uri'] . '/deletefile/' . $this->id);
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['dir'] . 'deletefile/' . $this->id);
|
||||
|
||||
// Edit post
|
||||
if (hasPermission($config['mod']['editpost'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="'._('Edit post').'" href="?/' . $board['uri'] . '/edit' . ($config['mod']['raw_html_default'] ? '_raw' : '') . '/' . $this->id . '">' . $config['mod']['link_editpost'] . '</a>';
|
||||
$built .= ' <a title="'._('Edit post').'" href="?/' . $board['dir'] . 'edit' . ($config['mod']['raw_html_default'] ? '_raw' : '') . '/' . $this->id . '">' . $config['mod']['link_editpost'] . '</a>';
|
||||
|
||||
if (!empty($built))
|
||||
$built = '<span class="controls">' . $built . '</span>';
|
||||
@ -420,54 +420,54 @@ class Thread {
|
||||
// Mod controls (on posts)
|
||||
// Delete
|
||||
if (hasPermission($config['mod']['delete'], $board['uri'], $this->mod))
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_delete'], _('Delete'), _('Are you sure you want to delete this?'), $board['uri'] . '/delete/' . $this->id);
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_delete'], _('Delete'), _('Are you sure you want to delete this?'), $board['dir'] . 'delete/' . $this->id);
|
||||
|
||||
// Delete all posts by IP
|
||||
if (hasPermission($config['mod']['deletebyip'], $board['uri'], $this->mod))
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip'], _('Delete all posts by IP'), _('Are you sure you want to delete all posts by this IP address?'), $board['uri'] . '/deletebyip/' . $this->id);
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip'], _('Delete all posts by IP'), _('Are you sure you want to delete all posts by this IP address?'), $board['dir'] . 'deletebyip/' . $this->id);
|
||||
|
||||
// Delete all posts by IP (global)
|
||||
if (hasPermission($config['mod']['deletebyip_global'], $board['uri'], $this->mod))
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip_global'], _('Delete all posts by IP across all boards'), _('Are you sure you want to delete all posts by this IP address, across all boards?'), $board['uri'] . '/deletebyip/' . $this->id . '/global');
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletebyip_global'], _('Delete all posts by IP across all boards'), _('Are you sure you want to delete all posts by this IP address, across all boards?'), $board['dir'] . 'deletebyip/' . $this->id . '/global');
|
||||
|
||||
// Ban
|
||||
if (hasPermission($config['mod']['ban'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="'._('Ban').'" href="?/' . $board['uri'] . '/ban/' . $this->id . '">' . $config['mod']['link_ban'] . '</a>';
|
||||
$built .= ' <a title="'._('Ban').'" href="?/' . $board['dir'] . 'ban/' . $this->id . '">' . $config['mod']['link_ban'] . '</a>';
|
||||
|
||||
// Ban & Delete
|
||||
if (hasPermission($config['mod']['bandelete'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="'._('Ban & Delete').'" href="?/' . $board['uri'] . '/ban&delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
|
||||
$built .= ' <a title="'._('Ban & Delete').'" href="?/' . $board['dir'] . 'ban&delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
|
||||
|
||||
// Delete file (keep post)
|
||||
if (!empty($this->file) && $this->file != 'deleted' && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod))
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['uri'] . '/deletefile/' . $this->id);
|
||||
$built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['dir'] . 'deletefile/' . $this->id);
|
||||
|
||||
// Sticky
|
||||
if (hasPermission($config['mod']['sticky'], $board['uri'], $this->mod))
|
||||
if ($this->sticky)
|
||||
$built .= ' <a title="'._('Make thread not sticky').'" href="?/' . secure_link($board['uri'] . '/unsticky/' . $this->id) . '">' . $config['mod']['link_desticky'] . '</a>';
|
||||
$built .= ' <a title="'._('Make thread not sticky').'" href="?/' . secure_link($board['dir'] . 'unsticky/' . $this->id) . '">' . $config['mod']['link_desticky'] . '</a>';
|
||||
else
|
||||
$built .= ' <a title="'._('Make thread sticky').'" href="?/' . secure_link($board['uri'] . '/sticky/' . $this->id) . '">' . $config['mod']['link_sticky'] . '</a>';
|
||||
$built .= ' <a title="'._('Make thread sticky').'" href="?/' . secure_link($board['dir'] . '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="?/' . secure_link($board['uri'] . '/bumpunlock/' . $this->id) . '">' . $config['mod']['link_bumpunlock'] . '</a>';
|
||||
$built .= ' <a title="'._('Allow thread to be bumped').'" href="?/' . secure_link($board['dir'] . 'bumpunlock/' . $this->id) . '">' . $config['mod']['link_bumpunlock'] . '</a>';
|
||||
else
|
||||
$built .= ' <a title="'._('Prevent thread from being bumped').'" href="?/' . secure_link($board['uri'] . '/bumplock/' . $this->id) . '">' . $config['mod']['link_bumplock'] . '</a>';
|
||||
$built .= ' <a title="'._('Prevent thread from being bumped').'" href="?/' . secure_link($board['dir'] . 'bumplock/' . $this->id) . '">' . $config['mod']['link_bumplock'] . '</a>';
|
||||
|
||||
// Lock
|
||||
if (hasPermission($config['mod']['lock'], $board['uri'], $this->mod))
|
||||
if ($this->locked)
|
||||
$built .= ' <a title="'._('Unlock thread').'" href="?/' . secure_link($board['uri'] . '/unlock/' . $this->id) . '">' . $config['mod']['link_unlock'] . '</a>';
|
||||
$built .= ' <a title="'._('Unlock thread').'" href="?/' . secure_link($board['dir'] . 'unlock/' . $this->id) . '">' . $config['mod']['link_unlock'] . '</a>';
|
||||
else
|
||||
$built .= ' <a title="'._('Lock thread').'" href="?/' . secure_link($board['uri'] . '/lock/' . $this->id) . '">' . $config['mod']['link_lock'] . '</a>';
|
||||
$built .= ' <a title="'._('Lock thread').'" href="?/' . secure_link($board['dir'] . 'lock/' . $this->id) . '">' . $config['mod']['link_lock'] . '</a>';
|
||||
|
||||
if (hasPermission($config['mod']['move'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="'._('Move thread to another board').'" href="?/' . $board['uri'] . '/move/' . $this->id . '">' . $config['mod']['link_move'] . '</a>';
|
||||
$built .= ' <a title="'._('Move thread to another board').'" href="?/' . $board['dir'] . 'move/' . $this->id . '">' . $config['mod']['link_move'] . '</a>';
|
||||
|
||||
// Edit post
|
||||
if (hasPermission($config['mod']['editpost'], $board['uri'], $this->mod))
|
||||
$built .= ' <a title="'._('Edit post').'" href="?/' . $board['uri'] . '/edit' . ($config['mod']['raw_html_default'] ? '_raw' : '') . '/' . $this->id . '">' . $config['mod']['link_editpost'] . '</a>';
|
||||
$built .= ' <a title="'._('Edit post').'" href="?/' . $board['dir'] . 'edit' . ($config['mod']['raw_html_default'] ? '_raw' : '') . '/' . $this->id . '">' . $config['mod']['link_editpost'] . '</a>';
|
||||
|
||||
if (!empty($built))
|
||||
$built = '<span class="controls op">' . $built . '</span>';
|
||||
|
@ -132,10 +132,10 @@ class Filter {
|
||||
function do_filters(array $post) {
|
||||
global $config;
|
||||
|
||||
if (!isset($config['flood_filters']))
|
||||
if (!isset($config['filters']))
|
||||
return;
|
||||
|
||||
foreach ($config['flood_filters'] as $arr) {
|
||||
foreach ($config['filters'] as $arr) {
|
||||
$filter = new Filter($arr);
|
||||
if ($filter->check($post))
|
||||
$filter->action();
|
||||
|
@ -40,7 +40,7 @@ function loadConfig() {
|
||||
'dir',
|
||||
'mod',
|
||||
'spam',
|
||||
'flood_filters',
|
||||
'filters',
|
||||
'wordfilters',
|
||||
'custom_capcode',
|
||||
'custom_tripcode',
|
||||
@ -54,7 +54,8 @@ function loadConfig() {
|
||||
'stylesheets',
|
||||
'additional_javascript',
|
||||
'markup',
|
||||
'custom_pages'
|
||||
'custom_pages',
|
||||
'dashboard_links'
|
||||
);
|
||||
|
||||
$config = array();
|
||||
@ -85,8 +86,8 @@ function loadConfig() {
|
||||
|
||||
date_default_timezone_set($config['timezone']);
|
||||
|
||||
if (!isset($config['blotter']))
|
||||
$config['blotter'] = false;
|
||||
if (!isset($config['global_message']))
|
||||
$config['global_message'] = false;
|
||||
|
||||
if (!isset($config['post_url']))
|
||||
$config['post_url'] = $config['root'] . $config['file_post'];
|
||||
@ -128,8 +129,6 @@ function loadConfig() {
|
||||
$config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif';
|
||||
if (!isset($config['image_deleted']))
|
||||
$config['image_deleted'] = $config['dir']['static'] . 'deleted.png';
|
||||
if (!isset($config['image_zip']))
|
||||
$config['image_zip'] = $config['dir']['static'] . 'zip.png';
|
||||
|
||||
if (!isset($config['uri_thumb']))
|
||||
$config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb'];
|
||||
@ -1704,7 +1703,7 @@ function buildThread($id, $return = false, $mod = false) {
|
||||
'mod' => $mod,
|
||||
'antibot' => $mod ? false : create_antibot($board['uri'], $id),
|
||||
'boardlist' => createBoardlist($mod),
|
||||
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['uri'] . '/' . $config['file_index'])
|
||||
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
|
||||
));
|
||||
|
||||
if ($return)
|
||||
|
@ -279,10 +279,8 @@ class ImageConvert extends ImageBase {
|
||||
}
|
||||
|
||||
$this->temp = tempnam($config['tmp'], 'imagick');
|
||||
|
||||
$quality = $config['thumb_quality'] * 10;
|
||||
|
||||
$config['thumb_keep_animation_frames'] = (int) $config['thumb_keep_animation_frames'];
|
||||
|
||||
$config['thumb_keep_animation_frames'] = (int)$config['thumb_keep_animation_frames'];
|
||||
|
||||
if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) {
|
||||
if ($this->gifsicle) {
|
||||
@ -291,12 +289,12 @@ class ImageConvert extends ImageBase {
|
||||
escapeshellarg($this->temp)) || !file_exists($this->temp))
|
||||
error('Failed to resize image!');
|
||||
} else {
|
||||
if (shell_exec("convert -background transparent -filter Point -sample {$this->width}x{$this->height} +antialias -quality {$quality} " .
|
||||
if (shell_exec('convert ' . sprintf($config['convert_args'], $this->width, $this->height) . ' ' .
|
||||
escapeshellarg($this->src . '') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp))
|
||||
error('Failed to resize image!');
|
||||
}
|
||||
} else {
|
||||
if (shell_exec("convert -background transparent -flatten -filter Point -scale {$this->width}x{$this->height} +antialias -quality {$quality} " .
|
||||
if (shell_exec('convert ' . sprintf($config['convert_args'], $this->width, $this->height) .
|
||||
escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp))
|
||||
error('Failed to resize image!');
|
||||
}
|
||||
@ -309,7 +307,7 @@ class ImagePNG extends ImageBase {
|
||||
}
|
||||
public function to($src) {
|
||||
global $config;
|
||||
imagepng($this->image, $src, $config['thumb_quality']);
|
||||
imagepng($this->image, $src);
|
||||
}
|
||||
public function resize() {
|
||||
$this->GD_create();
|
||||
@ -322,7 +320,7 @@ class ImagePNG extends ImageBase {
|
||||
|
||||
class ImageGIF extends ImageBase {
|
||||
public function from() {
|
||||
$this->image = @imagecreatefromgif ($this->src);
|
||||
$this->image = @imagecreatefromgif($this->src);
|
||||
}
|
||||
public function to($src) {
|
||||
imagegif ($this->image, $src);
|
||||
|
11
mod.php
11
mod.php
@ -109,7 +109,7 @@ $new_pages = array();
|
||||
foreach ($pages as $key => $callback) {
|
||||
if (is_string($callback) && preg_match('/^secure /', $callback))
|
||||
$key .= '(/(?P<token>[a-f0-9]{8}))?';
|
||||
$key = str_replace('\%b', $config['board_regex'], $key);
|
||||
$key = str_replace('\%b', '?P<board>' . sprintf(substr($config['board_path'], 0, -1), $config['board_regex']), $key);
|
||||
$new_pages[@$key[0] == '!' ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!u'] = $callback;
|
||||
}
|
||||
$pages = $new_pages;
|
||||
@ -118,6 +118,15 @@ foreach ($pages as $uri => $handler) {
|
||||
if (preg_match($uri, $query, $matches)) {
|
||||
$matches = array_slice($matches, 1);
|
||||
|
||||
if (isset($matches['board'])) {
|
||||
$board_match = $matches['board'];
|
||||
unset($matches['board']);
|
||||
$key = array_search($board_match, $matches);
|
||||
if (preg_match('/^' . sprintf(substr($config['board_path'], 0, -1), '(' . $config['board_regex'] . ')') . '$/u', $matches[$key], $board_match)) {
|
||||
$matches[$key] = $board_match[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (is_string($handler) && preg_match('/^secure(_POST)? /', $handler, $m)) {
|
||||
$secure_post_only = isset($m[1]);
|
||||
if (!$secure_post_only || $_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
2
post.php
2
post.php
@ -428,7 +428,7 @@ if (isset($_POST['delete'])) {
|
||||
$post['filehash'] = $config['file_hash']($upload);
|
||||
$post['filesize'] = filesize($upload);
|
||||
|
||||
if ($is_an_image) {
|
||||
if ($is_an_image && $config['ie_mime_type_detection'] !== false) {
|
||||
// Check IE MIME type detection XSS exploit
|
||||
$buffer = file_get_contents($upload, null, null, null, 255);
|
||||
if (preg_match($config['ie_mime_type_detection'], $buffer)) {
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
{% include 'post_form.html' %}
|
||||
|
||||
{% if config.blotter %}<hr /><div class="blotter">{{ config.blotter }}</div>{% endif %}
|
||||
{% if config.global_message %}<hr /><div class="blotter">{{ config.global_message }}</div>{% endif %}
|
||||
<hr />
|
||||
<form name="postcontrols" action="{{ config.post_url }}" method="post">
|
||||
<input type="hidden" name="board" value="{{ board.uri }}" />
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
{% include 'post_form.html' %}
|
||||
|
||||
{% if config.blotter %}<hr /><div class="blotter">{{ config.blotter }}</div>{% endif %}
|
||||
{% if config.global_message %}<hr /><div class="blotter">{{ config.global_message }}</div>{% endif %}
|
||||
<hr />
|
||||
<form name="postcontrols" action="{{ config.post_url }}" method="post">
|
||||
<input type="hidden" name="board" value="{{ board.uri }}" />
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
{% include 'post_form.html' %}
|
||||
|
||||
{% if config.blotter %}<hr /><div class="blotter">{{ config.blotter }}</div>{% endif %}
|
||||
{% if config.global_message %}<hr /><div class="blotter">{{ config.global_message }}</div>{% endif %}
|
||||
<hr />
|
||||
<form name="postcontrols" action="{{ config.post_url }}" method="post">
|
||||
<input type="hidden" name="board" value="{{ board.uri }}" />
|
||||
|
Loading…
Reference in New Issue
Block a user