Log SQL errors.
[platal.git] / modules / core.php
index 8792c62..fa54116 100644 (file)
@@ -30,6 +30,7 @@ class CoreModule extends PLModule
             'send_bug'    => $this->make_hook('bug', AUTH_COOKIE),
             'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE, 'admin'),
             'kill_sessions' => $this->make_hook('kill_sessions', AUTH_COOKIE, 'admin'),
+            'sql_errors'  => $this->make_hook('sqlerror', AUTH_COOKIE, 'admin'),
             'get_rights'  => $this->make_hook('get_rights', AUTH_MDP, 'admin'),
 
             'wiki_help'    => $this->make_hook('wiki_help', AUTH_PUBLIC),
@@ -191,6 +192,21 @@ class CoreModule extends PLModule
         echo MiniWiki::wikiToHtml($text, $action == 'title');
         exit;
     }
+
+    function handler_sqlerror(&$page, $clear = null) {
+        global $globals;
+        $file = @fopen($globals->spoolroot . '/spool/tmp/query_errors', 'r');
+        if ($file !== false) {
+            echo '<html><body>';
+            fpassthru($file);
+            fclose($file);
+            echo '</html></body>';
+        }
+        if ($clear == 'clear') {
+            @unlink($globals->spoolroot . '/spool/tmp/query_errors');
+        }
+        exit;
+    }
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: