From 85710249b705c455b2243f450765e458c14cdba6 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Thu, 24 Jan 2013 19:16:25 +1100 Subject: Raw HTML editing --- mod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod.php') diff --git a/mod.php b/mod.php index 7017dd05..1e39fdf1 100644 --- a/mod.php +++ b/mod.php @@ -61,7 +61,7 @@ $pages = array( '/ban' => 'secure_POST ban', // new ban '/(\w+)/ban(&delete)?/(\d+)' => 'secure_POST ban_post', // ban poster '/(\w+)/move/(\d+)' => 'secure_POST move', // move thread - '/(\w+)/edit/(\d+)' => 'secure_POST edit_post', // edit post + '/(\w+)/edit(_raw)?/(\d+)' => 'secure_POST edit_post', // edit post '/(\w+)/delete/(\d+)' => 'secure delete', // delete post '/(\w+)/deletefile/(\d+)' => 'secure deletefile', // delete file from post '/(\w+)/deletebyip/(\d+)(/global)?' => 'secure deletebyip', // delete all posts by IP address -- cgit v1.3 From d5a994537b4ea1f9780868eb53c79d9f97a75f86 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Fri, 25 Jan 2013 22:18:03 +1100 Subject: New debug mod page: ?/debug/recent (recent posts across all boards) --- inc/mod/pages.php | 99 ++++++++++++++++++++++------------- mod.php | 1 + templates/mod/debug/recent_posts.html | 81 ++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 37 deletions(-) create mode 100644 templates/mod/debug/recent_posts.html (limited to 'mod.php') diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 19502f60..ce643cb5 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1733,43 +1733,6 @@ function mod_config() { mod_page(_('Config editor'), 'mod/config-editor.html', array('conf' => $conf)); } -function mod_debug_antispam() { - global $pdo, $config; - - $args = array(); - - if (isset($_POST['board'], $_POST['thread'])) { - $where = '`board` = ' . $pdo->quote($_POST['board']); - if ($_POST['thread'] != '') - $where .= ' AND `thread` = ' . $pdo->quote($_POST['thread']); - - if (isset($_POST['purge'])) { - $query = prepare('UPDATE `antispam` SET `expires` = UNIX_TIMESTAMP() + :expires WHERE' . $where); - $query->bindValue(':expires', $config['spam']['hidden_inputs_expire']); - $query->execute() or error(db_error()); - } - - $args['board'] = $_POST['board']; - $args['thread'] = $_POST['thread']; - } else { - $where = ''; - } - - $query = query('SELECT COUNT(*) FROM `antispam`' . ($where ? " WHERE $where" : '')) or error(db_error()); - $args['total'] = number_format($query->fetchColumn(0)); - - $query = query('SELECT COUNT(*) FROM `antispam` WHERE `expires` IS NOT NULL' . ($where ? " AND $where" : '')) or error(db_error()); - $args['expiring'] = number_format($query->fetchColumn(0)); - - $query = query('SELECT * FROM `antispam` ' . ($where ? "WHERE $where" : '') . ' ORDER BY `passed` DESC LIMIT 40') or error(db_error()); - $args['top'] = $query->fetchAll(PDO::FETCH_ASSOC); - - $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); -} - function mod_themes_list() { global $config; @@ -1897,3 +1860,65 @@ function mod_theme_rebuild($theme_name) { 'theme_name' => $theme_name, )); } + +function mod_debug_antispam() { + global $pdo, $config; + + $args = array(); + + if (isset($_POST['board'], $_POST['thread'])) { + $where = '`board` = ' . $pdo->quote($_POST['board']); + if ($_POST['thread'] != '') + $where .= ' AND `thread` = ' . $pdo->quote($_POST['thread']); + + if (isset($_POST['purge'])) { + $query = prepare('UPDATE `antispam` SET `expires` = UNIX_TIMESTAMP() + :expires WHERE' . $where); + $query->bindValue(':expires', $config['spam']['hidden_inputs_expire']); + $query->execute() or error(db_error()); + } + + $args['board'] = $_POST['board']; + $args['thread'] = $_POST['thread']; + } else { + $where = ''; + } + + $query = query('SELECT COUNT(*) FROM `antispam`' . ($where ? " WHERE $where" : '')) or error(db_error()); + $args['total'] = number_format($query->fetchColumn(0)); + + $query = query('SELECT COUNT(*) FROM `antispam` WHERE `expires` IS NOT NULL' . ($where ? " AND $where" : '')) or error(db_error()); + $args['expiring'] = number_format($query->fetchColumn(0)); + + $query = query('SELECT * FROM `antispam` ' . ($where ? "WHERE $where" : '') . ' ORDER BY `passed` DESC LIMIT 40') or error(db_error()); + $args['top'] = $query->fetchAll(PDO::FETCH_ASSOC); + + $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); +} + +function mod_debug_recent_posts() { + global $pdo, $config; + + $limit = 150; + + $boards = listBoards(); + + // Manually build an SQL query + $query = 'SELECT * FROM ('; + foreach ($boards as $board) { + $query .= sprintf('SELECT *, %s AS `board` FROM `posts_%s` UNION ALL ', $pdo->quote($board['uri']), $board['uri']); + } + // Remove the last "UNION ALL" seperator and complete the query + $query = preg_replace('/UNION ALL $/', ') AS `all_posts` ORDER BY `time` DESC LIMIT ' . $limit, $query); + $query = query($query) or error(db_error()); + $posts = $query->fetchAll(PDO::FETCH_ASSOC); + + foreach ($posts as &$post) { + $post['snippet'] = pm_snippet($post['body']); + } + + mod_page(_('Debug: Recent posts'), 'mod/debug/recent_posts.html', array('posts' => $posts)); +} + diff --git a/mod.php b/mod.php index 1e39fdf1..c3b81e37 100644 --- a/mod.php +++ b/mod.php @@ -78,6 +78,7 @@ $pages = array( // these pages aren't listed in the dashboard without $config['debug'] '/debug/antispam' => 'debug_antispam', + '/debug/recent' => 'debug_recent_posts', // This should always be at the end: '/(\w+)/' => 'view_board', diff --git a/templates/mod/debug/recent_posts.html b/templates/mod/debug/recent_posts.html new file mode 100644 index 00000000..9da5c0d2 --- /dev/null +++ b/templates/mod/debug/recent_posts.html @@ -0,0 +1,81 @@ + + + + + + + + + + + + + {% for post in posts %} + + + + + + + + + + + + {% endfor %} +
TimeBoardIDThreadIPNameSubjectFileBody (snippet)
+ {{ post.time | ago }} ago + + {{ config.board_abbreviation|sprintf(post.board) }} + + {% if post.thread %} + {% set thread = post.thread %} + {% else %} + {% set thread = post.id %} + {% endif %} + + {{ post.id }} + + + {% if post.thread %} + {{ post.thread }} + {% else %} + (OP) + {% endif %} + + + {{ post.ip }} + + + {% if post.email|length > 0 %} + {# start email #} + + {% endif %} + {% if capcode %} + {{ capcode.cap }} + {% endif %} + + {% if post.subject %} + {{ post.subject }} + {% else %} + – + {% endif %} + + {% if post.file %} + {{ post.file }} ({{ post.filesize | filesize }}) + {% else %} + – + {% endif %} + + {{ post.snippet }} +
+ -- cgit v1.3 From cadf2768913bcd1941dfdc96f4a5565e02d6386d Mon Sep 17 00:00:00 2001 From: Michael Save Date: Fri, 25 Jan 2013 23:57:51 +1100 Subject: New debug page: ?/debug/sql --- mod.php | 1 + 1 file changed, 1 insertion(+) (limited to 'mod.php') diff --git a/mod.php b/mod.php index c3b81e37..9de2c15b 100644 --- a/mod.php +++ b/mod.php @@ -79,6 +79,7 @@ $pages = array( // these pages aren't listed in the dashboard without $config['debug'] '/debug/antispam' => 'debug_antispam', '/debug/recent' => 'debug_recent_posts', + '/debug/sql' => 'secure_POST debug_sql', // This should always be at the end: '/(\w+)/' => 'view_board', -- cgit v1.3