Adding page generate time at the bottom? Adding page generate time at the bottom?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Adding page generate time at the bottom?

Started by eagleknight, March 14, 2005, 02:57:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

eagleknight

Did a search, but couldn't find how to do this. It is probally pretty simple, but where and what do I add to get the page generate time at the bottom of each page. I know it is given in debug mode, but would like it to be able to show to anyone visisted.  ???

Nibbler

Same way as any other pagefooter (- see the docs). You can get the time by doing:

$time_end = cpgGetMicroTime();
$time = round($time_end - $time_start, 3);

eagleknight


eagleknight

I need to add it in the theme.php from reading the docs, but I was going down through there and saw many places where there is footer. Do I need to add those 2 lines any in every footer place?

Joachim Müller


eagleknight

Ok got it working, changed it a bit to get it look the way I wanted. Have a slight problem I also included query number and time, but it just shows 0 everytime. I edited the pagefooter section and here is my code, what is my mistake? My site is imagebutler.com if you want to see what it looks like at the bottom.

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)) {
    cpg_debug_output();
    }

    //get info for query times
    $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);

    echo '<div class="footer" align="center" style="padding-top: 10px; font-size: 8pt;">';
    echo 'Page generated in ';
    echo $time;
    echo ' seconds - ';
    echo $query_count;
    echo ' queries in ';
    echo $total_query_time;
    echo ' seconds</div>';
   
    echo $template_footer;
}

foulu

not
global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries;;
just
global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries;


eagleknight

Didn't work...still the same. If that was the problem I think it would have been sytax error and it would have failed to load page.

foulu

$query_stats, $queries only appear in debug mode so in normal mode it show all zero.

so go to function.php - function db_query($query, $link_id = 0) - line 82

change

          if (isset($CONFIG['debug_mode']) && (($CONFIG['debug_mode']==1) || ($CONFIG['debug_mode']==2) )) {
                $query_stats[] = $query_end - $query_start;
                $queries[] = $query;
          }
to

//          if (isset($CONFIG['debug_mode']) && (($CONFIG['debug_mode']==1) || ($CONFIG['debug_mode']==2) )) {
                $query_stats[] = $query_end - $query_start;
                $queries[] = $query;
//          }

to make it work

eagleknight