coppermine-gallery.com/forum

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Miscellaneous => Topic started by: eagleknight on March 14, 2005, 02:57:24 PM

Title: Adding page generate time at the bottom?
Post by: eagleknight on March 14, 2005, 02:57:24 PM
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.  ???
Title: Re: Adding page generate time at the bottom?
Post by: Nibbler on March 14, 2005, 03:11:24 PM
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);
Title: Re: Adding page generate time at the bottom?
Post by: eagleknight on March 14, 2005, 03:23:20 PM
Thx for fast reply. I'll try that.  ;)
Title: Re: Adding page generate time at the bottom?
Post by: eagleknight on March 14, 2005, 03:41:35 PM
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?
Title: Re: Adding page generate time at the bottom?
Post by: Joachim Müller on March 14, 2005, 07:43:15 PM
no, just theme.php
Title: Re: Adding page generate time at the bottom?
Post by: eagleknight on March 16, 2005, 04:14:05 AM
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;
}
Title: Re: Adding page generate time at the bottom?
Post by: foulu on March 16, 2005, 04:25:42 AM
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;

Title: Re: Adding page generate time at the bottom?
Post by: eagleknight on March 16, 2005, 04:51:10 AM
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.
Title: Re: Adding page generate time at the bottom?
Post by: foulu on March 16, 2005, 05:15:22 AM
$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
Title: Re: Adding page generate time at the bottom?
Post by: eagleknight on March 16, 2005, 05:44:31 AM
Thank you! Worked like a charm.  ;D