mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-02-20 20:51:50 +01:00
Merge pull request #816 from Zankaria/fix-dir-config
Assorted php fixes
This commit is contained in:
commit
f421e25e63
@ -1429,14 +1429,10 @@
|
||||
$config['dir'] = [
|
||||
'img' => 'src/',
|
||||
'thumb' => 'thumb/',
|
||||
'res' => 'res/'
|
||||
];
|
||||
|
||||
// For load balancing, having a seperate server (and domain/subdomain) for serving static content is
|
||||
// possible. This can either be a directory or a URL. Defaults to $config['root'] . 'static/'.
|
||||
// $config['dir']['static'] = 'http://static.example.org/';
|
||||
|
||||
$config['dir'] = [
|
||||
'res' => 'res/',
|
||||
// For load balancing, having a seperate server (and domain/subdomain) for serving static content is
|
||||
// possible. This can either be a directory or a URL. Defaults to $config['root'] . 'static/'.
|
||||
// $config['dir']['static'] = 'http://static.example.org/';
|
||||
// Where to store the .html templates. This folder and the template files must exist.
|
||||
'template' => getcwd() . '/templates',
|
||||
// Location of vichan "themes".
|
||||
@ -1563,50 +1559,6 @@
|
||||
'lock_ip' => true,
|
||||
// The page that is first shown when a moderator logs in. Defaults to the dashboard (?/).
|
||||
'default' => '/',
|
||||
|
||||
'link_delete' => '[D]',
|
||||
'link_ban' => '[B]',
|
||||
'link_bandelete' => '[&D]',
|
||||
'link_deletefile' => '[F]',
|
||||
'link_spoilerimage' => '[S]',
|
||||
'link_deletebyip' => '[D+]',
|
||||
'link_deletebyip_global' => '[D++]',
|
||||
'link_sticky' => '[Sticky]',
|
||||
'link_desticky' => '[-Sticky]',
|
||||
'link_lock' => '[Lock]',
|
||||
'link_unlock' => '[-Lock]',
|
||||
'link_bumplock' => '[Sage]',
|
||||
'link_bumpunlock' => '[-Sage]',
|
||||
'link_editpost' => '[Edit]',
|
||||
'link_move' => '[Move]',
|
||||
'link_cycle' => '[Cycle]',
|
||||
'link_uncycle' => '[-Cycle]'
|
||||
];
|
||||
|
||||
// Moderator capcodes.
|
||||
$config['capcode'] = ' <span class="capcode">## %s</span>';
|
||||
|
||||
// "## Custom" becomes lightgreen, italic and bold:
|
||||
//$config['custom_capcode']['Custom'] ='<span class="capcode" style="color:lightgreen;font-style:italic;font-weight:bold"> ## %s</span>';
|
||||
|
||||
// "## Mod" makes everything purple, including the name and tripcode:
|
||||
//$config['custom_capcode']['Mod'] = array(
|
||||
// '<span class="capcode" style="color:purple"> ## %s</span>',
|
||||
// 'color:purple', // Change name style; optional
|
||||
// 'color:purple' // Change tripcode style; optional
|
||||
//);
|
||||
|
||||
// "## Admin" makes everything red and bold, including the name and tripcode:
|
||||
//$config['custom_capcode']['Admin'] = array(
|
||||
// '<span class="capcode" style="color:red;font-weight:bold"> ## %s</span>',
|
||||
// 'color:red;font-weight:bold', // Change name style; optional
|
||||
// 'color:red;font-weight:bold' // Change tripcode style; optional
|
||||
//);
|
||||
|
||||
// Enable the moving of single replies
|
||||
$config['move_replies'] = false;
|
||||
|
||||
$config['mod'] = [
|
||||
// Do DNS lookups on IP addresses to get their hostname for the moderator IP pages (?/IP/x.x.x.x).
|
||||
'dns_lookup' => true,
|
||||
// How many recent posts, per board, to show in ?/IP/x.x.x.x.
|
||||
@ -1657,9 +1609,50 @@
|
||||
'dismiss_reports_on_lock' => true,
|
||||
|
||||
// Replace ?/config with a simple text editor for editing inc/instance-config.php.
|
||||
'config_editor_php' => false
|
||||
'config_editor_php' => false,
|
||||
|
||||
'link_delete' => '[D]',
|
||||
'link_ban' => '[B]',
|
||||
'link_bandelete' => '[&D]',
|
||||
'link_deletefile' => '[F]',
|
||||
'link_spoilerimage' => '[S]',
|
||||
'link_deletebyip' => '[D+]',
|
||||
'link_deletebyip_global' => '[D++]',
|
||||
'link_sticky' => '[Sticky]',
|
||||
'link_desticky' => '[-Sticky]',
|
||||
'link_lock' => '[Lock]',
|
||||
'link_unlock' => '[-Lock]',
|
||||
'link_bumplock' => '[Sage]',
|
||||
'link_bumpunlock' => '[-Sage]',
|
||||
'link_editpost' => '[Edit]',
|
||||
'link_move' => '[Move]',
|
||||
'link_cycle' => '[Cycle]',
|
||||
'link_uncycle' => '[-Cycle]'
|
||||
];
|
||||
|
||||
// Moderator capcodes.
|
||||
$config['capcode'] = ' <span class="capcode">## %s</span>';
|
||||
|
||||
// "## Custom" becomes lightgreen, italic and bold:
|
||||
//$config['custom_capcode']['Custom'] ='<span class="capcode" style="color:lightgreen;font-style:italic;font-weight:bold"> ## %s</span>';
|
||||
|
||||
// "## Mod" makes everything purple, including the name and tripcode:
|
||||
//$config['custom_capcode']['Mod'] = array(
|
||||
// '<span class="capcode" style="color:purple"> ## %s</span>',
|
||||
// 'color:purple', // Change name style; optional
|
||||
// 'color:purple' // Change tripcode style; optional
|
||||
//);
|
||||
|
||||
// "## Admin" makes everything red and bold, including the name and tripcode:
|
||||
//$config['custom_capcode']['Admin'] = array(
|
||||
// '<span class="capcode" style="color:red;font-weight:bold"> ## %s</span>',
|
||||
// 'color:red;font-weight:bold', // Change name style; optional
|
||||
// 'color:red;font-weight:bold' // Change tripcode style; optional
|
||||
//);
|
||||
|
||||
// Enable the moving of single replies
|
||||
$config['move_replies'] = false;
|
||||
|
||||
/*
|
||||
* ====================
|
||||
* Mod permissions
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (c) 2010-2013 Tinyboard Development Group
|
||||
*/
|
||||
|
||||
use Vichan\Context;
|
||||
use Vichan\Functions\Net;
|
||||
|
||||
defined('TINYBOARD') or exit;
|
||||
@ -232,7 +233,7 @@ function make_secure_link_token(string $uri): string {
|
||||
return substr(sha1($config['cookies']['salt'] . '-' . $uri . '-' . $mod['id']), 0, 8);
|
||||
}
|
||||
|
||||
function check_login(bool $prompt = false): void {
|
||||
function check_login(Context $ctx, bool $prompt = false): void {
|
||||
global $config, $mod;
|
||||
|
||||
$is_https = Net\is_connection_secure($config['cookies']['secure_login_only'] === 1);
|
||||
@ -246,7 +247,9 @@ function check_login(bool $prompt = false): void {
|
||||
if (count($cookie) != 3) {
|
||||
// Malformed cookies
|
||||
destroyCookies();
|
||||
if ($prompt) mod_login();
|
||||
if ($prompt) {
|
||||
mod_login($ctx);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -259,7 +262,9 @@ function check_login(bool $prompt = false): void {
|
||||
if ($cookie[1] !== mkhash($cookie[0], $user['password'], $cookie[2])) {
|
||||
// Malformed cookies
|
||||
destroyCookies();
|
||||
if ($prompt) mod_login();
|
||||
if ($prompt) {
|
||||
mod_login($ctx);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
7
mod.php
7
mod.php
@ -11,7 +11,10 @@ if ($config['debug']) {
|
||||
|
||||
require_once 'inc/mod/pages.php';
|
||||
|
||||
check_login(true);
|
||||
|
||||
$ctx = Vichan\build_context($config);
|
||||
|
||||
check_login($ctx, true);
|
||||
|
||||
$query = isset($_SERVER['QUERY_STRING']) ? rawurldecode($_SERVER['QUERY_STRING']) : '';
|
||||
|
||||
@ -136,8 +139,6 @@ foreach ($pages as $key => $callback) {
|
||||
}
|
||||
$pages = $new_pages;
|
||||
|
||||
$ctx = Vichan\build_context($config);
|
||||
|
||||
foreach ($pages as $uri => $handler) {
|
||||
if (preg_match($uri, $query, $matches)) {
|
||||
$matches[0] = $ctx; // Replace the text captured by the full pattern with a reference to the context.
|
||||
|
Loading…
x
Reference in New Issue
Block a user