GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Php script line break.. (https://gfy.com/showthread.php?t=869298)

xxweekxx 11-14-2008 11:41 AM

Php script line break..
 
Ok i found this script that shows referrer logs for traffic you send to it..
<?php
$myFile = "./data.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
fwrite($fh,"nReferer: ");
fwrite($fh, ($_SERVER['HTTP_REFERER']) );
fwrite($fh,", ");
fwrite($fh, ($_SERVER['HTTP_USER_AGENT']) );
fwrite($fh,", ");
fwrite($fh, $_SERVER['REMOTE_ADDR']);
fwrite($fh,", ");
fwrite($fh, date('l jS of F Y h:i:s A') );
fclose($fh);
?>

Anyone of making it seperate each new one and put it in a diff line.. right now it just jumbles em up..

nojob 11-14-2008 11:43 AM

If you want to pay I can have one of my progammers on bench create a solution for you. If so , hit me on icq.

drocd 11-14-2008 11:43 AM

PHP Code:

<?php
$myFile 
"./data.txt";
$fh fopen($myFile'a') or die("can't open file");
fwrite($fh,"nReferer: ");
fwrite($fh, ($_SERVER['HTTP_REFERER']) );
fwrite($fh,", ");
fwrite($fh, ($_SERVER['HTTP_USER_AGENT']) );
fwrite($fh,", ");
fwrite($fh$_SERVER['REMOTE_ADDR']);
fwrite($fh,", ");
fwrite($fhdate('l jS of F Y h:i:s A')."\n");
fclose($fh);
?>


xxweekxx 11-14-2008 11:49 AM

thanks drocd..

xxweekxx 11-14-2008 11:54 AM

Will the script lag if a lot of hits r sent?

I mean i dont know how reliable it is to write to a text file every time someone hits the page.

borked 11-14-2008 12:17 PM

Yes, Disk I/O will be a drag whore if you're getting a lot of traffic to it.

If you dont want to be scouring/parsing apache logs, hit me up on ICQ - I've just the (free) things that is right up your street....

borked 11-14-2008 12:28 PM

why aren't you storing this stuff in mysql? The problem with what you have now is that there are no file locks (flock), so you're going to be getting into a whole lotta mess with those kind of file writes with traffic.

Anyway, in answer to your original question, a line break is \n. *always* in within double quotes, never single eg

fwrite($fh, $_SERVER['REMOTE_ADDR'] . "\n");

fris 11-14-2008 02:18 PM

that is some horrible code

Tempest 11-14-2008 04:14 PM

Quote:

Originally Posted by borked (Post 15054228)
why aren't you storing this stuff in mysql? The problem with what you have now is that there are no file locks (flock), so you're going to be getting into a whole lotta mess with those kind of file writes with traffic.

You're kidding right??? :1orglaugh :1orglaugh :1orglaugh :1orglaugh


All times are GMT -7. The time now is 05:02 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123