Jump to content

request help with hyperlinking flat file output...


slashpine

Recommended Posts

hi, I hope this is easy for you folks...

 

I currently have a script attached to a user application page that logs the following data:

fwrite($hFile,date("l, F jS Y - H:i:s-").($ip = $_SERVER['REMOTE_ADDR']).($_SERVER['HTTP_REFERER']));

 

Is there an easy way to hyperlink (add anchor tags) to the "$_SERVER[HTTP_REFERER]" output?

 

Currently the output file is plain text...I had been just including the text file into an HTML doc set to refresh itself to monitor the log...but I would like to be able to just click the referer link if it's possible...I think I can reset the flat file script to output as HTML rather than txt ?

 

anyone?

umm...

 

<?php
$refLink = '<a href="' . $_SERVER['HTTP_REFERER'] . '">Referer</a>'; 
fwrite($hFile,date("l, F jS Y - H:i:s-").($ip = $_SERVER['REMOTE_ADDR']).($refLink));
?>

 

If it is displayed as text, it will just be the a href deal, if it is displayed as html should show up as a link.

Thanks for the replies...works great...

 

maybe you can help with the format...reading the plain text file all I had to do was 'wordwrap' to make it easy to read...however when the text is included in or output as html the data is all run together...

 

thanks again...

Basic html...

 

<?php
$lineData = "<tr><td>" . date("l, F jS Y - H:i:s-"). "</td><td>" . ($ip = $_SERVER['REMOTE_ADDR']) . "</td><td>" . '<a href="' . $_SERVER['HTTP_REFERER'] . '">Referer</a></td></tr>'; 
fwrite($hFile,);
?>

 

You will need <table> tag somewhere before the first line and a </table> somewhere after the last line.

Or simply display it wrapped in <pre> tags

 

can you elaborate?

<?php
$lineData = date("l, F jS Y - H:i:s-"). "\t" . ($ip = $_SERVER['REMOTE_ADDR']) . "\t" . '<a href="' . $_SERVER['HTTP_REFERER'] . '">Referer</a>'.PHP_EOL; 
fwrite($hFile,$lineData);

$fileData = file_get_contents('./logFile.txt');
echo '<pre>';
echo $fileData;
echo '</pre>';

?>

Or simply display it wrapped in <pre> tags

 

can you elaborate?

<?php
$lineData = date("l, F jS Y - H:i:s-"). "\t" . ($ip = $_SERVER['REMOTE_ADDR']) . "\t" . '<a href="' . $_SERVER['HTTP_REFERER'] . '">Referer</a>'.PHP_EOL; 
fwrite($hFile,$lineData);

$fileData = file_get_contents('./logFile.txt');
echo '<pre>';

echo $fileData;
echo '</pre>';

?>

 

That won't work for me...this scripts runs at the bottom of a public query results page...the output

of the script is not meant for the public to see...

 

Or simply display it wrapped in <pre> tags

 

can you elaborate?

<?php
$lineData = date("l, F jS Y - H:i:s-"). "\t" . ($ip = $_SERVER['REMOTE_ADDR']) . "\t" . '<a href="' . $_SERVER['HTTP_REFERER'] . '">Referer</a>'.PHP_EOL; 
fwrite($hFile,$lineData);

$fileData = file_get_contents('./logFile.txt');
echo '<pre>';

echo $fileData;
echo '</pre>';

?>

 

That won't work for me...this scripts runs at the bottom of a public query results page...the output

of the script is not meant for the public to see...

OK, to rephrase:-

In the script where you write to the log:

<?php
$lineData = date("l, F jS Y - H:i:s-"). "\t" . ($ip = $_SERVER['REMOTE_ADDR']) . "\t" . '<a href="' . $_SERVER['HTTP_REFERER'] . '">Referer</a>'.PHP_EOL; 
fwrite($hFile,$lineData);
?>

 

In the script where you read the log:

<?php
$fileData = file_get_contents('./logFile.txt');
echo '<pre>';
echo $fileData;
echo '</pre>';
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.