forked from leftypol/leftypol
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Conflicts: inc/config.php inc/functions.php templates/generic_page.html templates/index.html
This commit is contained in:
commit
a0855cdcf5
22 changed files with 1304 additions and 1107 deletions
1047
inc/config.php
1047
inc/config.php
File diff suppressed because it is too large
Load diff
|
@ -121,14 +121,14 @@ function query($query) {
|
|||
return $pdo->query($query);
|
||||
}
|
||||
|
||||
function db_error($PDOStatement=null) {
|
||||
global $pdo;
|
||||
function db_error($PDOStatement = null) {
|
||||
global $pdo, $db_error;
|
||||
|
||||
if (isset($PDOStatement)) {
|
||||
$err = $PDOStatement->errorInfo();
|
||||
return $err[2];
|
||||
$db_error = $PDOStatement->errorInfo();
|
||||
return $db_error[2];
|
||||
}
|
||||
|
||||
$err = $pdo->errorInfo();
|
||||
return $err[2];
|
||||
$db_error = $pdo->errorInfo();
|
||||
return $db_error[2];
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ function createBoardlist($mod=false) {
|
|||
);
|
||||
}
|
||||
|
||||
function error($message, $priority = true) {
|
||||
global $board, $mod, $config;
|
||||
function error($message, $priority = true, $debug_stuff = false) {
|
||||
global $board, $mod, $config, $db_error;
|
||||
|
||||
if ($config['syslog'] && $priority !== false) {
|
||||
// Use LOG_NOTICE instead of LOG_ERR or LOG_WARNING because most error message are not significant.
|
||||
|
@ -70,17 +70,21 @@ function error($message, $priority = true) {
|
|||
die('Error: ' . $message . "\n");
|
||||
}
|
||||
|
||||
if ($config['debug'] && isset($db_error)) {
|
||||
$debug_stuff = array_combine(array('SQLSTATE', 'Error code', 'Error message'), $db_error);
|
||||
}
|
||||
|
||||
die(Element('page.html', array(
|
||||
'config'=>$config,
|
||||
'title'=>_('Error'),
|
||||
'subtitle'=>_('An error has occured.'),
|
||||
'body'=>'<center>' .
|
||||
'<h2>' . _($message) . '</h2>' .
|
||||
(isset($board) ?
|
||||
"<p><a href=\"" . $config['root'] .
|
||||
($mod ? $config['file_mod'] . '?/' : '') .
|
||||
$board['dir'] . $config['file_index'] . "\">"._("Go back")."</a>.</p>" : '') .
|
||||
'</center>'
|
||||
'config' => $config,
|
||||
'title' => _('Error'),
|
||||
'subtitle' => _('An error has occured.'),
|
||||
'body' => Element('error.html', array(
|
||||
'config' => $config,
|
||||
'message' => $message,
|
||||
'mod' => $mod,
|
||||
'board' => isset($board) ? $board : false,
|
||||
'debug' => is_array($debug_stuff) ? str_replace("\n", ' ', utf8tohtml(print_r($debug_stuff, true))) : utf8tohtml($debug_stuff)
|
||||
))
|
||||
)));
|
||||
}
|
||||
|
||||
|
@ -319,31 +323,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 +424,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();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -279,26 +279,24 @@ 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) {
|
||||
if (shell_exec("gifsicle --unoptimize -O2 --resize {$this->width}x{$this->height} < " .
|
||||
if (trim($error = shell_exec("gifsicle --unoptimize -O2 --resize {$this->width}x{$this->height} < " .
|
||||
escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" > " .
|
||||
escapeshellarg($this->temp)) || !file_exists($this->temp))
|
||||
error('Failed to resize image!');
|
||||
escapeshellarg($this->temp) . '2>&1 &&echo $?') !== '0') || !file_exists($this->temp))
|
||||
error('Failed to resize image!', null, $error);
|
||||
} else {
|
||||
if (shell_exec("convert -background transparent -filter Point -sample {$this->width}x{$this->height} +antialias -quality {$quality} " .
|
||||
escapeshellarg($this->src . '') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp))
|
||||
error('Failed to resize image!');
|
||||
if (trim($error = shell_exec('convert ' . sprintf($config['convert_args'], '', $this->width, $this->height) . ' ' .
|
||||
escapeshellarg($this->src) . ' ' . escapeshellarg($this->temp) . ' 2>&1 &&echo $?')) !== '0' || !file_exists($this->temp))
|
||||
error('Failed to resize image!', null, $error);
|
||||
}
|
||||
} else {
|
||||
if (shell_exec("convert -background transparent -flatten -filter Point -scale {$this->width}x{$this->height} +antialias -quality {$quality} " .
|
||||
escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp))
|
||||
error('Failed to resize image!');
|
||||
if (trim($error = shell_exec('convert ' . sprintf($config['convert_args'], '-flatten', $this->width, $this->height) . ' ' .
|
||||
escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp) . ' 2>&1 &&echo $?')) !== '0' || !file_exists($this->temp))
|
||||
error('Failed to resize image!', null, $error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
|
|
@ -13,13 +13,14 @@ function config_vars() {
|
|||
'default_temp' => false
|
||||
);
|
||||
$temp_comment = false;
|
||||
$line_no = 0;
|
||||
foreach ($config_file as $line) {
|
||||
if ($temp_comment) {
|
||||
$var['comment'][] = $temp_comment;
|
||||
$temp_comment = false;
|
||||
}
|
||||
|
||||
if (preg_match('!^\s*// (.*)$!', $line, $matches)) {
|
||||
if (preg_match('!^\s*// ([^$].*)$!', $line, $matches)) {
|
||||
if ($var['default'] !== false) {
|
||||
$line = '';
|
||||
$temp_comment = $matches[1];
|
||||
|
@ -28,7 +29,10 @@ function config_vars() {
|
|||
}
|
||||
} else if ($var['default_temp'] !== false) {
|
||||
$var['default_temp'] .= "\n" . $line;
|
||||
} elseif (preg_match('!^\s*\$config\[(.+?)\] = (.+?)(;( //.+)?)?$!', $line, $matches)) {
|
||||
} elseif (preg_match('!^[\s/]*\$config\[(.+?)\] = (.+?)(;( //.+)?)?$!', $line, $matches)) {
|
||||
if (preg_match('!^\s*//\s*!', $line)) {
|
||||
$var['commented'] = true;
|
||||
}
|
||||
$var['name'] = explode('][', $matches[1]);
|
||||
if (count($var['name']) == 1) {
|
||||
$var['name'] = preg_replace('/^\'(.*)\'$/', '$1', end($var['name']));
|
||||
|
@ -43,20 +47,37 @@ function config_vars() {
|
|||
$var['default_temp'] = $matches[2];
|
||||
}
|
||||
|
||||
if (trim($line) === '') {
|
||||
if ($var['name'] !== false) {
|
||||
if ($var['default_temp'])
|
||||
$var['default'] = $var['default_temp'];
|
||||
|
||||
$temp = eval('return ' . $var['default'] . ';');
|
||||
if (!isset($temp))
|
||||
if ($var['name'] !== false) {
|
||||
if ($var['default_temp'])
|
||||
$var['default'] = $var['default_temp'];
|
||||
if ($var['default'][0] == '&')
|
||||
continue; // This is just an alias.
|
||||
if (!preg_match('/^array|\[\]|function/', $var['default']) && !preg_match('/^Example: /', trim(implode(' ', $var['comment'])))) {
|
||||
$syntax_error = true;
|
||||
$temp = eval('$syntax_error = false;return ' . $var['default'] . ';');
|
||||
if ($syntax_error && $temp === false) {
|
||||
error('Error parsing config.php (line ' . $line_no . ')!', null, $var);
|
||||
} elseif (!isset($temp)) {
|
||||
$var['type'] = 'unknown';
|
||||
else
|
||||
} else {
|
||||
$var['type'] = gettype($temp);
|
||||
}
|
||||
|
||||
if ($var['type'] == 'integer' && $var['name'][0] == 'mod' &&
|
||||
(in_array($var['default'], array('JANITOR', 'MOD', 'ADMIN', 'DISABLED')) || mb_strpos($var['default'], "\$config['mod']") === 0)) {
|
||||
// Permissions variable
|
||||
$var['permissions'] = true;
|
||||
}
|
||||
|
||||
unset($var['default_temp']);
|
||||
|
||||
if (!is_array($var['name']) || (end($var['name']) != '' && !in_array(reset($var['name']), array('stylesheets')))) {
|
||||
$already_exists = false;
|
||||
foreach ($conf as $_var) {
|
||||
if ($var['name'] == $_var['name'])
|
||||
$already_exists = true;
|
||||
|
||||
}
|
||||
if (!$already_exists)
|
||||
$conf[] = $var;
|
||||
}
|
||||
}
|
||||
|
@ -65,9 +86,17 @@ function config_vars() {
|
|||
'name' => false,
|
||||
'comment' => array(),
|
||||
'default' => false,
|
||||
'default_temp' => false
|
||||
'default_temp' => false,
|
||||
'commented' => false,
|
||||
'permissions' => false,
|
||||
);
|
||||
}
|
||||
|
||||
if (trim($line) === '') {
|
||||
$var['comment'] = array();
|
||||
}
|
||||
|
||||
$line_no++;
|
||||
}
|
||||
|
||||
return $conf;
|
||||
|
|
|
@ -800,21 +800,21 @@ function mod_page_ip($ip) {
|
|||
$args['token'] = make_secure_link_token('ban');
|
||||
|
||||
if (hasPermission($config['mod']['view_ban'])) {
|
||||
$query = prepare("SELECT ``bans``.*, `username` FROM ``bans`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `ip` = :ip");
|
||||
$query = prepare("SELECT ``bans``.*, `username` FROM ``bans`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `ip` = :ip ORDER BY `set` DESC");
|
||||
$query->bindValue(':ip', $ip);
|
||||
$query->execute() or error(db_error($query));
|
||||
$args['bans'] = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
if (hasPermission($config['mod']['view_notes'])) {
|
||||
$query = prepare("SELECT ``ip_notes``.*, `username` FROM ``ip_notes`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `ip` = :ip");
|
||||
$query = prepare("SELECT ``ip_notes``.*, `username` FROM ``ip_notes`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `ip` = :ip ORDER BY `time` DESC");
|
||||
$query->bindValue(':ip', $ip);
|
||||
$query->execute() or error(db_error($query));
|
||||
$args['notes'] = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
if (hasPermission($config['mod']['modlog_ip'])) {
|
||||
$query = prepare("SELECT `username`, `mod`, `ip`, `board`, `time`, `text` FROM ``modlogs`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `text` LIKE :search ORDER BY `time` DESC LIMIT 20");
|
||||
$query = prepare("SELECT `username`, `mod`, `ip`, `board`, `time`, `text` FROM ``modlogs`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `text` LIKE :search ORDER BY `time` DESC LIMIT 50");
|
||||
$query->bindValue(':search', '%' . $ip . '%');
|
||||
$query->execute() or error(db_error($query));
|
||||
$args['logs'] = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
@ -1941,30 +1941,43 @@ function mod_report_dismiss($id, $all = false) {
|
|||
}
|
||||
|
||||
|
||||
function mod_config() {
|
||||
global $config, $mod;
|
||||
function mod_config($board_config = false) {
|
||||
global $config, $mod, $board;
|
||||
|
||||
if (!hasPermission($config['mod']['edit_config']))
|
||||
if ($board_config && !openBoard($board_config))
|
||||
error($config['error']['noboard']);
|
||||
|
||||
if (!hasPermission($config['mod']['edit_config'], $board_config))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
$config_file = $board_config ? $board['dir'] . 'config.php' : 'inc/instance-config.php';
|
||||
|
||||
if ($config['mod']['config_editor_php']) {
|
||||
$readonly = !is_writable('inc/instance-config.php');
|
||||
$readonly = !(is_file($config_file) ? is_writable($config_file) : is_writable(dirname($config_file)));
|
||||
|
||||
if (!$readonly && isset($_POST['code'])) {
|
||||
$code = $_POST['code'];
|
||||
file_put_contents('inc/instance-config.php', $code);
|
||||
header('Location: ?/config', true, $config['redirect_http']);
|
||||
file_put_contents($config_file, $code);
|
||||
header('Location: ?/config' . ($board_config ? '/' . $board_config : ''), true, $config['redirect_http']);
|
||||
return;
|
||||
}
|
||||
|
||||
$instance_config = file_get_contents('inc/instance-config.php');
|
||||
$instance_config = @file_get_contents($config_file);
|
||||
if ($instance_config === false) {
|
||||
$instance_config = "<?php\n\n// This file does not exist yet. You are creating it.";
|
||||
}
|
||||
$instance_config = str_replace("\n", '
', utf8tohtml($instance_config));
|
||||
|
||||
mod_page(_('Config editor'), 'mod/config-editor-php.html', array('php' => $instance_config, 'readonly' => $readonly));
|
||||
mod_page(_('Config editor'), 'mod/config-editor-php.html', array(
|
||||
'php' => $instance_config,
|
||||
'readonly' => $readonly,
|
||||
'boards' => listBoards(),
|
||||
'board' => $board_config,
|
||||
'file' => $config_file
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
require_once 'inc/mod/config-editor.php';
|
||||
|
||||
$conf = config_vars();
|
||||
|
@ -1975,7 +1988,7 @@ function mod_config() {
|
|||
foreach ($var['name'] as $n)
|
||||
$c = &$c[$n];
|
||||
} else {
|
||||
$c = $config[$var['name']];
|
||||
$c = @$config[$var['name']];
|
||||
}
|
||||
|
||||
$var['value'] = $c;
|
||||
|
@ -2010,14 +2023,28 @@ function mod_config() {
|
|||
$config_append .= '[' . var_export($var['name'], true) . ']';
|
||||
}
|
||||
|
||||
$config_append .= ' = ' . var_export($value, true) . ";\n";
|
||||
|
||||
$config_append .= ' = ';
|
||||
if (@$var['permissions'] && in_array($value, array(JANITOR, MOD, ADMIN, DISABLED))) {
|
||||
$perm_array = array(
|
||||
JANITOR => 'JANITOR',
|
||||
MOD => 'MOD',
|
||||
ADMIN => 'ADMIN',
|
||||
DISABLED => 'DISABLED'
|
||||
);
|
||||
$config_append .= $perm_array[$value];
|
||||
} else {
|
||||
$config_append .= var_export($value, true);
|
||||
}
|
||||
$config_append .= ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($config_append)) {
|
||||
$config_append = "\n// Changes made via web editor by \"" . $mod['username'] . "\" @ " . date('r') . ":\n" . $config_append . "\n";
|
||||
|
||||
if (!@file_put_contents('inc/instance-config.php', $config_append, FILE_APPEND)) {
|
||||
if (!is_file($config_file))
|
||||
$config_append = "<?php\n\n$config_append";
|
||||
if (!@file_put_contents($config_file, $config_append, FILE_APPEND)) {
|
||||
$config_append = htmlentities($config_append);
|
||||
|
||||
if ($config['minify_html'])
|
||||
|
@ -2026,8 +2053,8 @@ function mod_config() {
|
|||
$page['title'] = 'Cannot write to file!';
|
||||
$page['config'] = $config;
|
||||
$page['body'] = '
|
||||
<p style="text-align:center">Tinyboard could not write to <strong>inc/instance-config.php</strong> with the ammended configuration, probably due to a permissions error.</p>
|
||||
<p style="text-align:center">You may proceed with these changes manually by copying and pasting the following code to the end of <strong>inc/instance-config.php</strong>:</p>
|
||||
<p style="text-align:center">Tinyboard could not write to <strong>' . $config_file . '</strong> with the ammended configuration, probably due to a permissions error.</p>
|
||||
<p style="text-align:center">You may proceed with these changes manually by copying and pasting the following code to the end of <strong>' . $config_file . '</strong>:</p>
|
||||
<textarea style="width:700px;height:370px;margin:auto;display:block;background:white;color:black" readonly>' . $config_append . '</textarea>
|
||||
';
|
||||
echo Element('page.html', $page);
|
||||
|
@ -2035,12 +2062,18 @@ function mod_config() {
|
|||
}
|
||||
}
|
||||
|
||||
header('Location: ?/', true, $config['redirect_http']);
|
||||
header('Location: ?/config', true, $config['redirect_http']);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
mod_page(_('Config editor'), 'mod/config-editor.html', array('conf' => $conf));
|
||||
mod_page(_('Config editor') . ($board_config ? ': ' . sprintf($config['board_abbreviation'], $board_config) : ''),
|
||||
'mod/config-editor.html', array(
|
||||
'boards' => listBoards(),
|
||||
'board' => $board_config,
|
||||
'conf' => $conf,
|
||||
'file' => $config_file
|
||||
));
|
||||
}
|
||||
|
||||
function mod_themes_list() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue