/    Sign up×
Community /Pin to ProfileBookmark

Ip Logging With PHP

I am trying to set up an IP logging PHP code:

This is a code i have stumbled accross.

<?
$log_file = “ip.txt”;
$hourdiff = “-8”;
$timeadjust = ($hourdiff * 60 * 60);
$date = date(“l, d F Y t h:i a”,time() + $timeadjust);
$ie = getenv(‘HTTP_USER_AGENT’);
$ip = getenv(‘REMOTE_ADDR’);
$ia = $_SERVER[“HTTP_REFERER”];
$fp = fopen(“$log_file”, “a”);
fputs($fp, “$iprn”);
flock($fp, 3);
fwrite($fp,$date);
fwrite($fp,”t”);
fwrite($fp,$ip);
fwrite($fp,”tt”);
fwrite($fp,$ie);
fwrite($fp,”t”);
fwrite($fp,$ia);
fwrite($fp,”n”);
fclose($fp);
PRINT(“Your Ip was logged $ip <br>”);
?>

the problem is, if you look at
[url]http://www.giggledesign.com/home/iplog.php[/url]

you will see that it wont work. i don’t know what to do.
can anyone help please?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@PittimannDec 08.2003 — Hi!

Seems, your problem is not getting the ip, but writing it to "ip.txt".

Either the path "ip.txt" (assigned to $log_file) is not correct, the file does not exist (I would assume that) or you didn't give yourself/ the user the right to write to that file...

Cheers - Pit
Copy linkTweet thisAlerts:
@Paul_JrDec 09.2003 — This code was posted in another post, so I nabbed it.

If the file "ip.txt" does not exist, it will be created automatically, and that's where the IP's will be posted. I didn't have any trouble using the bit of code myself.
×

Success!

Help @giggledesign spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...