"debug" thing

This commit is contained in:
Savetheinternet 2011-05-21 15:22:10 +10:00
parent bdb05b16d8
commit 5c4ead4f66
2 changed files with 14 additions and 4 deletions

View File

@ -36,14 +36,20 @@
} }
function prepare($query) { function prepare($query) {
global $pdo; global $pdo, $debug, $config;
if($config['debug']) {
$debug['sql'][] = $query;
}
sql_open(); sql_open();
return $pdo->prepare($query); return $pdo->prepare($query);
} }
function query($query) { function query($query) {
global $pdo; global $pdo, $debug, $config;
if($config['debug']) {
$debug['sql'][] = $query;
}
sql_open(); sql_open();
return $pdo->query($query); return $pdo->query($query);

View File

@ -168,13 +168,17 @@
} }
function Element($templateFile, array $options) { function Element($templateFile, array $options) {
global $config; global $config, $debug;
// Small little hack to add the PM system // Small little hack to add the PM system
if(function_exists('create_pm_header') && (@$options['mod'] || @$options['__mod'])) { if(function_exists('create_pm_header') && (isset($options['mod']) || isset($options['__mod']))) {
$options['pm'] = create_pm_header(); $options['pm'] = create_pm_header();
} }
if(isset($options['body']) && $config['debug']) {
$options['body'] .= '<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' . print_r($debug, true) . '</pre><hr/>';
}
// Read the template file // Read the template file
if($template = @file_get_contents("{$config['dir']['template']}/${templateFile}")) { if($template = @file_get_contents("{$config['dir']['template']}/${templateFile}")) {
return templateParse($template, $options, null, $templateFile); return templateParse($template, $options, null, $templateFile);