This is a discussion on Calling PHP file within the PHP General forums, part of the PHP Programming Forums category; I am just wondering if there is a PHP function that returns the file name or domain name of where ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
http://php.net/reserved.variables
Predefined variables (part of the page) ____________ Server variables $_SERVER $_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI 1.1 specification, so you should be able to expect those. 'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted 'REMOTE_ADDR' The IP address from which the user is viewing the current page. ______________ something like onscreen display <? php echo $_SERVER['REMOTE_ADDRESS']; echo $_SERVER['HTTP_REFERER']; ?> or write it to a file, <?php //stats.php // Get the user stats. $getdate = date( 'd-m-Y, H:i:s' );// Get the date. $user_ip = $_SERVER['REMOTE_ADDR'];// Get the users IP. $user_browser = $_SERVER['HTTP_USER_AGENT'];// Get the browser type. //see if its worth rewriting the page to support multiple browsers $referer = getenv("HTTP_REFERER");// Get the refering page. another approach as well as $_server // Look for the text file and open it for writting. $file = "./logfile.csv";// define the file. //csv files import easily in excell for analysis, file has to be chmod writeable $fp = fopen($file, "a+");//open file for writing. // Write the user stats into the text file. fputs ($fp, "$user_ip,$getdate, $referer\n"); //comma separated values, my choice any other format you wish fclose($fp);// Close the text file. ?> or get any of the premade php monitor scripts and see how they did it, http://www.bbclone.de is an example -- If at first you dont succeed try try try again If at first you do succeed try not to look surprised _ "David Cain" <david@shesurf.ws> wrote in message news:4648d2af$0$16033$afc38c87@news.optusnet.com.a u... > I am just wondering if there is a PHP function that returns the file > name or domain name of where the file/script is located that called the > PHP script in question? > > Thanks in advance. |
|
|||
|
dammit - long lines text wrapped
_ "AlmostBob" <anonymous1@discussions.microsoft.com> wrote in message news:u652i.9661$V75.4901@edtnps89... http://php.net/reserved.variables Predefined variables (part of the page) ____________ Server variables $_SERVER $_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI 1.1 specification, so you should be able to expect those. 'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted 'REMOTE_ADDR' The IP address from which the user is viewing the current page. ______________ something like onscreen display <? php echo $_SERVER['REMOTE_ADDRESS']; echo $_SERVER['HTTP_REFERER']; ?> or write it to a file, <?php //stats.php // Get the user stats. $getdate = date( 'd-m-Y, H:i:s' );// Get the date. $user_ip = $_SERVER['REMOTE_ADDR'];// Get the users IP. $user_browser = $_SERVER['HTTP_USER_AGENT'];// Get the browser type. //see if its worth rewriting the page to support multiple browsers $referer = getenv("HTTP_REFERER");// Get the refering page. another approach // as well as $_server // Look for the text file and open it for writting. $file = "./logfile.csv";// define the file. //csv files import easily in excell for analysis, file has to be chmod // writeable $fp = fopen($file, "a+");//open file for writing. // Write the user stats into the text file. fputs ($fp, "$user_ip,$getdate, $referer\n"); //comma separated values, my // choice any other format you wish fclose($fp);// Close the text file. ?> or get any of the premade php monitor scripts and see how they did it, http://www.bbclone.de is an example -- If at first you dont succeed try try try again If at first you do succeed try not to look surprised _ > "David Cain" <david@shesurf.ws> wrote in message > news:4648d2af$0$16033$afc38c87@news.optusnet.com.a u... > > I am just wondering if there is a PHP function that returns the file > > name or domain name of where the file/script is located that called the > > PHP script in question? > > > > Thanks in advance. > > |
|
|||
|
On Tue, 15 May 2007 07:20:47 +1000, David Cain <david@shesurf.ws>
wrote: >I am just wondering if there is a PHP function that returns the file >name or domain name of where the file/script is located that called the >PHP script in question? > >Thanks in advance. $_SERVER used with one of several reserved variables will do that. I like... $_SERVER['PHP_SELF'] Here's how you might use it... <?php if ($_SERVER['PHP_SELF'] == '/index.php') {include('signature.php');}?> |