summaryrefslogtreecommitdiff
path: root/inc/mod/pages.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2013-01-25 23:56:55 +1100
committerMichael Save <savetheinternet@tinyboard.org>2013-01-25 23:56:55 +1100
commit9a2c33736aeee1016e45ef655d8c58690555152c (patch)
tree85bf7a94b04682647e817c74694318b81e835b7b /inc/mod/pages.php
parent764d718f8426da1c1161ddf82a5dd8a82fd4b935 (diff)
New debug page: ?/debug/sql
Diffstat (limited to 'inc/mod/pages.php')
-rw-r--r--inc/mod/pages.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/inc/mod/pages.php b/inc/mod/pages.php
index 8feac374..592ac5b1 100644
--- a/inc/mod/pages.php
+++ b/inc/mod/pages.php
@@ -1922,3 +1922,27 @@ function mod_debug_recent_posts() {
mod_page(_('Debug: Recent posts'), 'mod/debug/recent_posts.html', array('posts' => $posts));
}
+function mod_debug_sql() {
+ global $config;
+
+ if (!hasPermission($config['mod']['debug_sql']))
+ error($config['error']['noaccess']);
+
+ $args['security_token'] = make_secure_link_token('debug/sql');
+
+ if (isset($_POST['query'])) {
+ $args['query'] = $_POST['query'];
+ if ($query = query($_POST['query'])) {
+ $args['result'] = $query->fetchAll(PDO::FETCH_ASSOC);
+ if (!empty($args['result']))
+ $args['keys'] = array_keys($args['result'][0]);
+ else
+ $args['result'] = 'empty';
+ } else {
+ $args['error'] = db_error();
+ }
+ }
+
+ mod_page(_('Debug: SQL'), 'mod/debug/sql.html', $args);
+}
+