function pagefooter()
{
    global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $ALBUM_SET, $CONFIG, $time_start, $query_stats;
    global $template_footer;
    if ($CONFIG['debug_mode'] == 1 || $CONFIG['debug_mode'] == 2 && GALLERY_ADMIN_MODE) {
        cpg_debug_output();
    }
    echo $template_footer;
    if (defined('CMS_INTEGRATION')) {
        $custom_footer = cms_pagefooter();
        echo $custom_footer;
    }
}
function pagefooter()
{
    global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries;
    global $template_footer;
    if ($CONFIG['debug_mode'] == 1 || $CONFIG['debug_mode'] == 2 && GALLERY_ADMIN_MODE) {
        $time_end = cpgGetMicroTime();
        $time = round($time_end - $time_start, 3);
        $query_count = count($query_stats);
        $query_times = '';
        $total_query_time = 0;
        foreach ($query_stats as $qtime) {
            $query_times .= round($qtime, 3) . "s ";
            $total_query_time += $qtime;
        }
        $total_query_time = round($total_query_time, 3);
        starttable('100%', 'Debug info');
        echo "<tr><td class=\"tableb\">";
        echo "USER: <pre>";
        print_r($USER);
        echo "</pre></td></tr><td class=\"tableb\">";
        echo "<tr><td class=\"tableb\">";
        echo "USER DATA: <pre>";
        print_r($USER_DATA);
        echo "</pre></td></tr><td class=\"tableb\">";
        echo "<tr><td class=\"tableb\">";
        echo "Queries: <pre>";
        print_r($queries);
        echo "</pre></td></tr><td class=\"tableb\">";
        echo "GET :<pre>";
        print_r($HTTP_GET_VARS);
        echo "</pre></td></tr><td class=\"tableb\">";
        echo "POST :<pre>";
        print_r($HTTP_POST_VARS);
        echo "</pre></td></tr><td class=\"tableb\" >";
        echo <<<EOT
                Page generated in <b>{$time}</b> seconds - <b>{$query_count}</b> queries in <b>{$total_query_time}</b> seconds - Album set : {$ALBUM_SET}
EOT;
        echo "</td></tr>";
        echo "<tr><td class=\"tableb\">";
        echo "<a href=\"phpinfo.php\">Advanced debug mode</a> (phpinfo)";
        echo "</td></tr>";
        endtable();
    }
    echo $template_footer;
    if (defined('CMS_INTEGRATION')) {
        $custom_footer = cms_pagefooter();
        echo $custom_footer;
    }
}