./includes/common/debug.php

<?php

if ( !defined('IN_SITE') )
{
    
header("HTTP/1.0 404 Not Found");
    
exit;
}

function report($error, $why)
{
    
//gets the stats array

    
global $stats;
    
global $tredir;
    
global $base_URL_domain;

    
//start the report construction
    $report = '<h1>ERROR REPORT</h1><p>';
    
$report .= '<B>GENERATED ON:</B> '.date('d/M/Y, H:i');
    
$report .= '<p><B>GIVEN RESSON: </B>'.$error.'<BR><B>QUERY:</B> '.$why.'<h2>VARIABLES:</h2><br>';

    
foreach($stats as $type => $content)
    
{
        
$report .= '<p><h3>'.$type.'</h3>';
        
if(is_array($stats[$type]))
        
{
            
foreach($content as $name => $value)
            
{
                
$report .= '<b>'.$name.': </b>'.$value.'<br>';
            
}
        
}
    
}

    
//We dont want to redirect, show the error straight out
    die($report);
}