slashpine Posted November 13, 2008 Share Posted November 13, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/ Share on other sites More sharing options...
premiso Posted November 13, 2008 Share Posted November 13, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689312 Share on other sites More sharing options...
.josh Posted November 13, 2008 Share Posted November 13, 2008 fwrite($hFile,date("l, F jS Y - H:i:s-").($ip = $_SERVER['REMOTE_ADDR'])."<a href='{$_SERVER['HTTP_REFERER']}'>{$_SERVER['HTTP_REFERER']}</a>"); Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689315 Share on other sites More sharing options...
slashpine Posted November 13, 2008 Author Share Posted November 13, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689659 Share on other sites More sharing options...
premiso Posted November 13, 2008 Share Posted November 13, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689663 Share on other sites More sharing options...
Mark Baker Posted November 13, 2008 Share Posted November 13, 2008 Or simply display it wrapped in <pre> tags Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689680 Share on other sites More sharing options...
slashpine Posted November 13, 2008 Author Share Posted November 13, 2008 Or simply display it wrapped in <pre> tags can you elaborate? Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689686 Share on other sites More sharing options...
Mark Baker Posted November 13, 2008 Share Posted November 13, 2008 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>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689724 Share on other sites More sharing options...
slashpine Posted November 13, 2008 Author Share Posted November 13, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689733 Share on other sites More sharing options...
Mark Baker Posted November 13, 2008 Share Posted November 13, 2008 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>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689743 Share on other sites More sharing options...
slashpine Posted November 13, 2008 Author Share Posted November 13, 2008 runs with no errors but there is no formatting to the display...it's all jammed together... Quote Link to comment https://forums.phpfreaks.com/topic/132563-request-help-with-hyperlinking-flat-file-output/#findComment-689771 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.