@ -9,10 +9,10 @@ defined('TINYBOARD') or exit;
function mod_page($title, $template, $args, $subtitle = false) {
global $config, $mod;
echo Element('page.html' , array(
echo Element($config['file_page_template'] , array(
'config' => $config,
'mod' => $mod,
'hide_dashboard_link' => $template == 'mod/dashboard.html' ,
'hide_dashboard_link' => $template == $config['file_mod_dashboard'] ,
'title' => $title,
'subtitle' => $subtitle,
'boardlist' => createBoardlist($mod),
@ -57,11 +57,11 @@ function mod_login($redirect = false) {
if (isset($_POST['username']))
$args['username'] = $_POST['username'];
mod_page(_('Login'), 'mod/login.html' , $args);
mod_page(_('Login'), $config['file_mod_login'] , $args);
}
function mod_confirm($request) {
mod_page(_('Confirm action'), 'mod/confirm.html' , array('request' => $request, 'token' => make_secure_link_token($request)));
mod_page(_('Confirm action'), $config['file_mod_confim'] , array('request' => $request, 'token' => make_secure_link_token($request)));
}
function mod_logout() {
@ -163,7 +163,7 @@ function mod_dashboard() {
$args['logout_token'] = make_secure_link_token('logout');
mod_page(_('Dashboard'), 'mod/dashboard.html' , $args);
mod_page(_('Dashboard'), $config['file_mod_dashboard'] , $args);
}
function mod_search_redirect() {
@ -335,7 +335,7 @@ function mod_search($type, $search_query_escaped, $page_no = 1) {
// $results now contains the search results
mod_page(_('Search results'), 'mod/search_results.html' , array(
mod_page(_('Search results'), $config['file_mod_search_results'] , array(
'search_type' => $type,
'search_query' => $search_query,
'search_query_escaped' => $search_query_escaped,
@ -439,7 +439,7 @@ function mod_edit_board($boardName) {
header('Location: ?/', true, $config['redirect_http']);
} else {
mod_page(sprintf('%s: ' . $config['board_abbreviation'], _('Edit board'), $board['uri']), 'mod/board.html' , array(
mod_page(sprintf('%s: ' . $config['board_abbreviation'], _('Edit board'), $board['uri']), $config['file_mod_board'] , array(
'board' => $board,
'token' => make_secure_link_token('edit/' . $board['uri'])
));
@ -509,7 +509,7 @@ function mod_new_board() {
header('Location: ?/' . $board['uri'] . '/' . $config['file_index'], true, $config['redirect_http']);
}
mod_page(_('New board'), 'mod/board.html' , array('new' => true, 'token' => make_secure_link_token('new-board')));
mod_page(_('New board'), $config['file_mod_board'] , array('new' => true, 'token' => make_secure_link_token('new-board')));
}
function mod_noticeboard($page_no = 1) {
@ -560,7 +560,7 @@ function mod_noticeboard($page_no = 1) {
$query->execute() or error(db_error($query));
$count = $query->fetchColumn();
mod_page(_('Noticeboard'), 'mod/noticeboard.html' , array(
mod_page(_('Noticeboard'), $config['file_mod_noticeboard'] , array(
'noticeboard' => $noticeboard,
'count' => $count,
'token' => make_secure_link_token('noticeboard')
@ -629,7 +629,7 @@ function mod_news($page_no = 1) {
$query->execute() or error(db_error($query));
$count = $query->fetchColumn();
mod_page(_('News'), 'mod/news.html' , array('news' => $news, 'count' => $count, 'token' => make_secure_link_token('edit_news')));
mod_page(_('News'), $config['file_mod_news'] , array('news' => $news, 'count' => $count, 'token' => make_secure_link_token('edit_news')));
}
function mod_news_delete($id) {
@ -669,7 +669,7 @@ function mod_log($page_no = 1) {
$query->execute() or error(db_error($query));
$count = $query->fetchColumn();
mod_page(_('Moderation log'), 'mod/log.html' , array('logs' => $logs, 'count' => $count));
mod_page(_('Moderation log'), $config['file_mod_log'] , array('logs' => $logs, 'count' => $count));
}
function mod_user_log($username, $page_no = 1) {
@ -696,7 +696,7 @@ function mod_user_log($username, $page_no = 1) {
$query->execute() or error(db_error($query));
$count = $query->fetchColumn();
mod_page(_('Moderation log'), 'mod/log.html' , array('logs' => $logs, 'count' => $count, 'username' => $username));
mod_page(_('Moderation log'), $config['file_mod_log'] , array('logs' => $logs, 'count' => $count, 'username' => $username));
}
function mod_board_log($board, $page_no = 1, $hide_names = false, $public = false) {
@ -734,7 +734,31 @@ function mod_board_log($board, $page_no = 1, $hide_names = false, $public = fals
$query->execute() or error(db_error($query));
$count = $query->fetchColumn();
mod_page(_('Board log'), 'mod/log.html', array('logs' => $logs, 'count' => $count, 'board' => $board, 'hide_names' => $hide_names, 'public' => $public));
mod_page(_('Board log'), $config['file_mod_log'], array('logs' => $logs, 'count' => $count, 'board' => $board, 'hide_names' => $hide_names, 'public' => $public));
}
function mod_view_catalog($boardName) {
global $config, $mod;
require_once($config['dir']['themes'].'/catalog/theme.php');
$settings = array();
$settings['boards'] = $boardName;
$settings['update_on_posts'] = true;
$settings['title'] = 'Catalog';
$settings['use_tooltipster'] = true;
$catalog = new Catalog($settings);
$query = prepare(sprintf('SELECT * FROM ``theme_settings`` WHERE `name` = "uri" AND `value` = :uri', $board));
$query->bindValue(':uri', $boardName);
$query->execute() or error(db_error($query));
if ($theme = $query->fetch(PDO::FETCH_ASSOC)){
if ($theme['theme'] == "rand")
echo $catalog->buildRand($mod);
if ($theme['theme'] == "ukko")
echo $catalog->buildUkko($mod);
} else {
echo $catalog->build($boardName, $mod);
}
}
function mod_view_board($boardName, $page_no = 1) {
@ -778,7 +802,7 @@ function mod_view_board($boardName, $page_no = 1) {
$page['mod'] = true;
$page['config'] = $config;
echo Element('index.html ', $page);
echo Element($config[ 'file_board_ index'] , $page);
}
function mod_view_thread($boardName, $thread) {
@ -858,6 +882,14 @@ function mod_page_ip($cip) {
header('Location: ?/IP/' . $cip . '#bans', true, $config['redirect_http']);
return;
}
if (isset($_POST['ban_id'], $_POST['edit_ban'])) {
if (!hasPermission($config['mod']['edit_ban']))
error($config['error']['noaccess']);
header('Location: ?/edit_ban/' . $_POST['ban_id'], true, $config['redirect_http']);
return;
}
if (isset($_POST['note'])) {
if (!hasPermission($config['mod']['create_notes']))
@ -959,7 +991,7 @@ function mod_page_ip($cip) {
$args['security_token'] = make_secure_link_token('IP/' . $cip);
mod_page(sprintf('%s: %s', _('IP'), htmlspecialchars($cip)), 'mod/view_ip.html', $args, $args['hostname'] ?? null );
mod_page(sprintf('%s: %s', _('IP'), htmlspecialchars($cip)), $config['file_mod_view_ip'], $args, $args['hostname'] );
}
function mod_announcements() {
@ -1004,7 +1036,7 @@ function mod_ban() {
error($config['error']['noaccess']);
if (!isset($_POST['ip'], $_POST['reason'], $_POST['length'], $_POST['board'])) {
mod_page(_('New ban'), 'mod/ban_form.html' , array('token' => make_secure_link_token('ban')));
mod_page(_('New ban'), $config['file_mod_ban_form'] , array('token' => make_secure_link_token('ban')));
return;
}
@ -1045,7 +1077,7 @@ function mod_bans() {
return;
}
mod_page(_('Ban list'), 'mod/ban_list.html' , array(
mod_page(_('Ban list'), $config['file_mod_ban_list'] , array(
'mod' => $mod,
'boards' => json_encode($mod['boards']),
'token' => make_secure_link_token('bans'),
@ -1065,6 +1097,56 @@ function mod_bans_json() {
Bans::stream_json(false, false, !hasPermission($config['mod']['view_banstaff']), $mod['boards']);
}
function mod_edit_ban($ban_id) {
global $mod, $config;
if (!hasPermission($config['mod']['edit_ban']))
error($config['error']['noaccess']);
$args['bans'] = Bans::find(null, false, true, $ban_id);
$args['ban_id'] = $ban_id;
$args['boards'] = listBoards();
$args['current_board'] = isset($args['bans'][0]['board']) ? $args['bans'][0]['board'] : false;
if (!$args['bans'])
error($config['error']['404']);
if (isset($_POST['new_ban'])) {
$new_ban['mask'] = $args['bans'][0]['mask'];
$new_ban['post'] = isset($args['bans'][0]['post']) ? $args['bans'][0]['post'] : false;
$new_ban['board'] = $args['current_board'];
if (isset($_POST['reason']))
$new_ban['reason'] = $_POST['reason'];
else
$new_ban['reason'] = $args['bans'][0]['reason'];
if (isset($_POST['length']) & & !empty($_POST['length']))
$new_ban['length'] = $_POST['length'];
else
$new_ban['length'] = false;
if (isset($_POST['board'])) {
if ($_POST['board'] == '*')
$new_ban['board'] = false;
else
$new_ban['board'] = $_POST['board'];
}
Bans::new_ban($new_ban['mask'], $new_ban['reason'], $new_ban['length'], $new_ban['board'], false, $new_ban['post']);
Bans::delete($ban_id);
header('Location: ?/', true, $config['redirect_http']);
}
$args['token'] = make_secure_link_token('edit_ban/' . $ban_id);
mod_page(_('Edit ban'), 'mod/edit_ban.html', $args);
}
function mod_ban_appeals() {
global $config, $board;
@ -1139,7 +1221,7 @@ function mod_ban_appeals() {
}
}
mod_page(_('Ban appeals'), 'mod/ban_appeals.html' , array(
mod_page(_('Ban appeals'), $config['file_mod_ban_appeals'] , array(
'ban_appeals' => $ban_appeals,
'token' => make_secure_link_token('ban-appeals')
));
@ -1358,7 +1440,7 @@ function mod_move_reply($originBoard, $postID) {
$security_token = make_secure_link_token($originBoard . '/move_reply/' . $postID);
mod_page(_('Move reply'), 'mod/move_reply.html' , array('post' => $postID, 'board' => $originBoard, 'boards' => $boards, 'token' => $security_token));
mod_page(_('Move reply'), $config['file_mod_move_reply'] , array('post' => $postID, 'board' => $originBoard, 'boards' => $boards, 'token' => $security_token));
}
@ -1598,7 +1680,7 @@ function mod_move($originBoard, $postID) {
$security_token = make_secure_link_token($originBoard . '/move/' . $postID);
mod_page(_('Move thread'), 'mod/move.html' , array('post' => $postID, 'board' => $originBoard, 'boards' => $boards, 'token' => $security_token));
mod_page(_('Move thread'), $config['file_mod_move'] , array('post' => $postID, 'board' => $originBoard, 'boards' => $boards, 'token' => $security_token));
}
function mod_merge($originBoard, $postID) {
@ -1934,7 +2016,7 @@ function mod_ban_post($board, $delete, $post, $token = false) {
'token' => $security_token
);
mod_page(_('New ban'), 'mod/ban_form.html' , $args);
mod_page(_('New ban'), $config['file_mod_ban_form'] , $args);
}
function mod_warning_post($board, $delete, $post, $token = false) {
@ -2092,7 +2174,7 @@ function mod_edit_post($board, $edit_raw_html, $postID) {
$post['body'] = str_replace("\t", '	 ', $post['body']);
}
mod_page(_('Edit post'), 'mod/edit_post_form.html' , array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post));
mod_page(_('Edit post'), $config['file_mod_edit_post_form'] , array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post));
}
}
@ -2490,7 +2572,7 @@ function mod_user($uid) {
$user['boards'] = explode(',', $user['boards']);
mod_page(_('Edit user'), 'mod/user.html' , array(
mod_page(_('Edit user'), $config['file_mod_user'] , array(
'user' => $user,
'logs' => $log,
'boards' => listBoards(),
@ -2547,7 +2629,7 @@ function mod_user_new() {
return;
}
mod_page(_('New user'), 'mod/user.html' , array('new' => true, 'boards' => listBoards(), 'token' => make_secure_link_token('users/new')));
mod_page(_('New user'), $config['file_mod_user'] , array('new' => true, 'boards' => listBoards(), 'token' => make_secure_link_token('users/new')));
}
@ -2569,7 +2651,7 @@ function mod_users() {
$user['demote_token'] = make_secure_link_token("users/{$user['id']}/demote");
}
mod_page(sprintf('%s (%d)', _('Manage users'), count($users)), 'mod/users.html' , array('users' => $users));
mod_page(sprintf('%s (%d)', _('Manage users'), count($users)), $config['file_mod_users'] , array('users' => $users));
}
function mod_user_promote($uid, $action) {
@ -2659,14 +2741,14 @@ function mod_pm($id, $reply = false) {
if (!$pm['to_username'])
error($config['error']['404']); // deleted?
mod_page(sprintf('%s %s', _('New PM for'), $pm['to_username']), 'mod/new_pm.html' , array(
mod_page(sprintf('%s %s', _('New PM for'), $pm['to_username']), $config['file_mod_new_pm'] , array(
'username' => $pm['username'],
'id' => $pm['sender'],
'message' => quote($pm['message']),
'token' => make_secure_link_token('new_PM/' . $pm['username'])
));
} else {
mod_page(sprintf('%s – #%d', _('Private message'), $id), 'mod/pm.html' , $pm);
mod_page(sprintf('%s – #%d', _('Private message'), $id), $config['file_mod_pm'] , $pm);
}
}
@ -2687,7 +2769,7 @@ function mod_inbox() {
$message['snippet'] = pm_snippet($message['message']);
}
mod_page(sprintf('%s (%s)', _('PM inbox'), count($messages) > 0 ? $unread . ' unread' : 'empty'), 'mod/inbox.html' , array(
mod_page(sprintf('%s (%s)', _('PM inbox'), count($messages) > 0 ? $unread . ' unread' : 'empty'), $config['file_mod_inbox'] , array(
'messages' => $messages,
'unread' => $unread
));
@ -2735,7 +2817,7 @@ function mod_new_pm($username) {
header('Location: ?/', true, $config['redirect_http']);
}
mod_page(sprintf('%s %s', _('New PM for'), $username), 'mod/new_pm.html' , array(
mod_page(sprintf('%s %s', _('New PM for'), $username), $config['file_mod_new_pm'] , array(
'username' => $username,
'id' => $id,
'token' => make_secure_link_token('new_PM/' . $username)
@ -2808,11 +2890,11 @@ function mod_rebuild() {
}
}
mod_page(_('Rebuild'), 'mod/rebuilt.html' , array('logs' => $log));
mod_page(_('Rebuild'), $config['file_mod_rebuilt'] , array('logs' => $log));
return;
}
mod_page(_('Rebuild'), 'mod/rebuild.html' , array(
mod_page(_('Rebuild'), $config['file_mod_rebuild'] , array(
'boards' => listBoards(),
'token' => make_secure_link_token('rebuild')
));
@ -2870,7 +2952,7 @@ function mod_reports() {
}
// a little messy and inefficient
$append_html = Element('mod/report.html' , array(
$append_html = Element($config['file_mod_report'] , array(
'report' => $report,
'config' => $config,
'mod' => $mod,
@ -2897,7 +2979,7 @@ function mod_reports() {
$count++;
}
mod_page(sprintf('%s (%d)', _('Report queue'), $count), 'mod/reports.html' , array('reports' => $body, 'count' => $count));
mod_page(sprintf('%s (%d)', _('Report queue'), $count), $config['file_mod_reports'] , array('reports' => $body, 'count' => $count));
}
function mod_report_dismiss($id, $all = false) {
@ -3022,7 +3104,7 @@ function mod_report_dismiss($id, $all = false) {
echo $jsondata;
}
else {
echo mod_page(_('Recent posts'), 'mod/recent_posts.html' , array(
echo mod_page(_('Recent posts'), $config['file_mod_recent_posts'] , array(
'posts' => $posts,
'limit' => $limit,
'last_time' => $last_time
@ -3116,7 +3198,7 @@ function mod_config($board_config = false) {
}
$instance_config = str_replace("\n", '
 ', utf8tohtml($instance_config));
mod_page(_('Config editor'), 'mod/config-editor-php.html' , array(
mod_page(_('Config editor'), $config['file_mod_config_editor_php'] , array(
'php' => $instance_config,
'readonly' => $readonly,
'boards' => listBoards(),
@ -3200,7 +3282,7 @@ function mod_config($board_config = false) {
< 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);
echo Element($config['file_page_template'] , $page);
exit;
}
}
@ -3211,7 +3293,7 @@ function mod_config($board_config = false) {
}
mod_page(_('Config editor') . ($board_config ? ': ' . sprintf($config['board_abbreviation'], $board_config) : ''),
'mod/config-editor.html' , array(
$config['file_mod_config_editor'] , array(
'boards' => listBoards(),
'board' => $board_config,
'conf' => $conf,
@ -3248,7 +3330,7 @@ function mod_themes_list() {
$theme['uninstall_token'] = make_secure_link_token('themes/' . $theme_name . '/uninstall');
}
mod_page(_('Manage themes'), 'mod/themes.html' , array(
mod_page(_('Manage themes'), $config['file_mod_themes'] , array(
'themes' => $themes,
'themes_in_use' => $themes_in_use,
));
@ -3317,7 +3399,7 @@ function mod_theme_configure($theme_name) {
// Build themes
rebuildThemes('all');
mod_page(sprintf(_($result ? 'Installed theme: %s' : 'Installation failed: %s'), $theme['name']), 'mod/theme_installed.html' , array(
mod_page(sprintf(_($result ? 'Installed theme: %s' : 'Installation failed: %s'), $theme['name']), $config['file_mod_theme_installed'] , array(
'theme_name' => $theme_name,
'theme' => $theme,
'result' => $result,
@ -3328,7 +3410,7 @@ function mod_theme_configure($theme_name) {
$settings = themeSettings($theme_name);
mod_page(sprintf(_('Configuring theme: %s'), $theme['name']), 'mod/theme_config.html' , array(
mod_page(sprintf(_('Configuring theme: %s'), $theme['name']), $config['file_mod_theme_config'] , array(
'theme_name' => $theme_name,
'theme' => $theme,
'settings' => $settings,
@ -3361,7 +3443,7 @@ function mod_theme_rebuild($theme_name) {
rebuildTheme($theme_name, 'all');
mod_page(sprintf(_('Rebuilt theme: %s'), $theme_name), 'mod/theme_rebuilt.html' , array(
mod_page(sprintf(_('Rebuilt theme: %s'), $theme_name), $config['file_mod_theme_rebuilt'] , array(
'theme_name' => $theme_name,
));
}
@ -3459,7 +3541,7 @@ function mod_edit_page($id) {
$fn = (isset($board['uri']) ? ($board['uri'] . '/') : '') . $page['name'] . '.html';
$body = "< div class = 'ban' > $write< / div > ";
$html = Element('page.html' , array('config' => $config, 'boardlist' => createBoardlist(), 'body' => $body, 'title' => utf8tohtml($page['title'])));
$html = Element($config['file_page_template'] , array('config' => $config, 'boardlist' => createBoardlist(), 'body' => $body, 'title' => utf8tohtml($page['title'])));
file_write($fn, $html);
}
@ -3470,7 +3552,7 @@ function mod_edit_page($id) {
$content = $query->fetchColumn();
}
mod_page(sprintf(_('Editing static page: %s'), $page['name']), 'mod/edit_page.html' , array('page' => $page, 'token' => make_secure_link_token("edit_page/$id"), 'content' => prettify_textarea($content), 'board' => $board));
mod_page(sprintf(_('Editing static page: %s'), $page['name']), $config['file_mod_edit_page'] , array('page' => $page, 'token' => make_secure_link_token("edit_page/$id"), 'content' => prettify_textarea($content), 'board' => $board));
}
function mod_pages($board = false) {
@ -3524,7 +3606,7 @@ function mod_pages($board = false) {
$p['delete_token'] = make_secure_link_token('edit_pages/delete/' . $p['name'] . ($board ? ('/' . $board) : ''));
}
mod_page(_('Pages'), 'mod/pages.html' , array('pages' => $pages, 'token' => make_secure_link_token('edit_pages' . ($board ? ('/' . $board) : '')), 'board' => $board));
mod_page(_('Pages'), $config['file_mod_pages'] , array('pages' => $pages, 'token' => make_secure_link_token('edit_pages' . ($board ? ('/' . $board) : '')), 'board' => $board));
}
function mod_debug_antispam() {
@ -3561,7 +3643,7 @@ function mod_debug_antispam() {
$query = query('SELECT * FROM ``antispam`` ' . ($where ? "WHERE $where" : '') . ' ORDER BY `created` DESC LIMIT 20') or error(db_error());
$args['recent'] = $query->fetchAll(PDO::FETCH_ASSOC);
mod_page(_('Debug: Anti-spam'), 'mod/debug/antispam.html' , $args);
mod_page(_('Debug: Anti-spam'), $config['file_mod_debug_antispam'] , $args);
}
function mod_debug_recent_posts() {
@ -3595,7 +3677,7 @@ function mod_debug_recent_posts() {
}
}
mod_page(_('Debug: Recent posts'), 'mod/debug/recent_posts.html' , array('posts' => $posts, 'flood_posts' => $flood_posts));
mod_page(_('Debug: Recent posts'), $config['file_mod_debug_recent_posts'] , array('posts' => $posts, 'flood_posts' => $flood_posts));
}
function mod_debug_sql() {
@ -3619,7 +3701,7 @@ function mod_debug_sql() {
}
}
mod_page(_('Debug: SQL'), 'mod/debug/sql.html' , $args);
mod_page(_('Debug: SQL'), $config['file_mod_debug_sql'] , $args);
}
function mod_debug_apc() {
@ -3641,6 +3723,6 @@ function mod_debug_apc() {
$cached_vars[] = $var;
}
mod_page(_('Debug: APC'), 'mod/debug/apc.html' , array('cached_vars' => $cached_vars));
mod_page(_('Debug: APC'), $config['file_mod_debug_apc'] , array('cached_vars' => $cached_vars));
}