MyBB Community Forums

Full Version: adding some PHP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I want to have a PHP code at the top of every webpage (before the <html> tag) and another PHP code before the </body> tag. Where do I go / what do I edit?

Thank you.
just edit all the files that you download in the zip pack (edit index.php, and all the others in the folder.

What exactly is it that you want to do??
get a page generated in *** seconds on the bottom ef each page
ok, well, whats the code you are using??
put
<?php $mtime = microtime(); $mtime = explode(" ",$mtime);  $mtime = $mtime[1] + $mtime[0]; $tstart = $mtime; ?>
before the <html>

and put
<?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0];  $tend = $mtime; $totaltime = ($tend - $tstart); printf ("              Page generated in <U>%f</U> secs", $totaltime); ?>
in the body
ok, well, I would have said add it to the header and footer template, unfortunatly, I dont think they support php :/

So, I would suggest this:
<?php $mtime = microtime(); $mtime = explode(" ",$mtime);  $mtime = $mtime[1] + $mtime[0]; $tstart = $mtime; ?>
before the <html> like you said, but put
<?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0];  $tend = $mtime; $totaltime = ($tend - $tstart); $totaltime); ?>
Then:
Page generated in <U>%f</U> secs
in the header and footer template. Im not sure if this will work, you could try for one of the pages.
the page im using it for is at http://guillaumelforum.theglassprison.net/index.php (you can see the results for yourself)
it just says
Page generated in %f secs

I know the script works see http://guillaumelforum.theglassprison.net/test.php
I would recommend waiting for Chris to do this. There might already be a timer a you can print to the page. If there isn't he'd probably know the easiest way to accomplish what you are trying to do.

And no... the templates don't support PHP so placing anything PHP related in a template besides variables will not work.
hmm, ok, maybe putting the code into functions somewhere and calling it might work??
Pages: 1 2 3