|
Posted by HarveyP on 11/28/05 22:30
Sorry, dyslexic keyboard last 2 posts ...
oddsnsods.php (not html or htms ...)
The absolute addressing is because I also call log.php from a file in
another directory, hence the PHP_SELF reference. I bought the original
design of the site and have been messing about with it since I gained
full access., but rearranging the whole file structure is something I
haven't got around to yet
Worse yet, I surfed one of my other, non PHP pages tonight and found the
same problem! Perhaps it is an ADSL thing - I am new to high speed
downloading ...
Apologies for posting in the wrong forum. I shall start this thread
again in a HTML forum, or an ADSL forum.
Thanks for your time.
Sean wrote:
>OK, here is the simplest example I can think of.
>
>
>HarveyP wrote:
>
>
>>In File oddsnsod.htms
>>...
>><META NAME="Date" CONTENT="2005-11-27" SCHEME="Year-Month-Day">
>><link rel="stylesheet"
>>href="http://www.pearblossomhouse.com/mypages.css" type="text/css">
>><?php
>> include '/home/pearblocom/public_html/php_scripts/log.php';
>>?>
>><script language="JavaScript" TYPE="text/javascript">
>><!--
>>function MM_swapImgRestore() { //v3.0
>>...
>>
>>
>
>This html and the php include are stored in a .htms file. I have never
>seen that type of file extension before but it doest matter. Is there
>something in your webserver configuration that tells the webserver to
>process .htms files with the php interpreter?? If not then the php
>include will not be executed and will simply just print to the screen.
>
>If you don't know what I am writing about then rename oddsnsod.htms
>to oddsnsod.php and try it.
>
>If the same thing is still happening then its because php is not
>enabled to work with your webserver.
>
>
>
>>In log.php
>>..
>><?php
>>
>>function iif($expression, $returntrue, $returnfalse = '') {
>> return ($expression ? $returntrue : $returnfalse);
>>}
>>
>>// Getting the information
>>$ipaddress = $_SERVER['REMOTE_ADDR'];
>>$page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
>>$page .= iif(!empty($_SERVER['QUERY_STRING']),
>>"?{$_SERVER['QUERY_STRING']}", "");
>>$referrer = $_SERVER['HTTP_REFERER'];
>>$datetime = mktime();
>>$useragent = $_SERVER['HTTP_USER_AGENT'];
>>$remotehost = @getHostByAddr($ipaddress);
>>
>>// Create log line
>>$logline = $ipaddress . '|' . $referrer . '|' . $datetime . '|' .
>>$useragent . '|' . $remotehost . '|' . $page . "\n";
>>
>>// Write to log file:
>>$logfile = sprintf('/home/username/public_html/logs/logs%d.txt',date('m'));
>>
>>// Open the log file in "Append" mode
>>if (!$handle = fopen($logfile, 'ab')) {
>> die("Failed to open log file");
>>}
>>
>>// Write $logline to our logfile.
>>if (fwrite($handle, $logline) === FALSE) {
>> die("Failed to write to log file");
>>}
>>
>>//close it all up
>>fclose($handle);
>>
>>?>
>>...
>>
>>
>
>All that looks ok. But your using allot of absolute addresses, you can
>make things easier on yourself by using relative ones.
>
>
>
Navigation:
[Reply to this message]
|