Forum Moderators: phranque

Message Too Old, No Replies

Including PHP files

         

Andrew1983

10:04 pm on Dec 11, 2005 (gmt 0)

10+ Year Member



Hello guys,

Currently for my stats I'm including "/path/to/stats.php" in the begging of each of the scripts that I'm executing. I want to skip the part when I go and include the script into each page I want to track. Any suggestions are welcome...

Regards,
Andrew

WebWalla

9:10 am on Dec 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As I understand it, you want to include that line when executing the script directly, but not when you include the script from a normal html page.

In this case, you should include the stats line in an IF statement, which is true when executing the script directly and false when you're loading an html page.

Think of a true or false state that you can test on in these different situations and include it in your code.

Andrew1983

10:19 am on Dec 13, 2005 (gmt 0)

10+ Year Member



Mmmm no actually...

Each time a surfer hits one of my pages a script is executed. If I don't include the PHP line that looks like

<?php include_once "/path/to/stats.php";?>

in the top of the .html/.php page I can't execute the script.

I want to be able to execute that script each time a surfer hits one of my pages WITHOUT putting the PHP code there. I was looking for an Apache module or something that would allow me to do that. I was going to use mod_rewrite to rewrite the page to stats.php, which works just fine, except for one thing.

I want to track this page:
[site1.com...]

The stats.php is located here:
[site2.com...]

Apache would rewrite the URL to:

[site2.com...]

If the stats.php was located at site1.com the URL wouldn't change in the browser of the surfer...

I'm not sure how clear this sounds, but anyway....

-- Andrew

jdMorgan

3:28 pm on Dec 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Andrew1983,

Welcome to WebmasterWorld!

You might want to look into PHP's auto-prepend function to include the code on every page.

You'll probably find more expertise on this subject over in the WebmasterWorld PHP forum.

Jim

Andrew1983

4:03 pm on Dec 13, 2005 (gmt 0)

10+ Year Member



jdMorgan, thank you very much for that reply. I just found all needed info at Zend's site. Although, this is done thru httpd.conf and/or .htaccess, so you see why I was looking for answer in this forum :)

Here's the page I'm looking at now:
[zend.com...]

Again, thanks for the reply :)