|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Log last accestime
I want to log each user's latest accestime ..but the script below only logs the latest user.
If the user doesn't exist it must be added to the list. <? function traceuser($REMOTE_IP,$userid){ if ($REMOTE_IP == "192.168.0.2"){ //Niks doen }else{ $lasthitfile="hosts.log"; //Log file $count_it = 1; $now = time(); $hits=""; if(file_exists($lasthitfile)) { $cf = fopen($lasthitfile, "r"); while (!feof($cf)) { $line=fgets($cf, 4096); list($where, $who, $when) = explode(":", $line); if ($when > $now-($trigger*60)) { if (($where==$userid) && ($who==$REMOTE_IP)) $count_it=1; else $hits.="$userid:$who:$when\n"; } } fclose($cf); } $hits.="$userid:$REMOTE_IP:$now\n"; $cf = fopen($lasthitfile, "w"); fwrite($cf, $hits); fclose($cf); } } ?> |
|
#2
|
|||
|
|||
|
Hey,
It all has to do with the way that you're opening the file for writing when you put the data back. You need to append to the file, like this: $cf = fopen($lasthitfile, "a+"); fwrite($cf, $hits); fclose($cf); |
|
#3
|
|||
|
|||
|
tnx but it's not the solution
Maybe i i tod it wrong.
But .... What it supposed to do is: When a user logs in .. look in the file if the user exist .. user exist ? -> change last acces time user doesnt't exist ? -> appent to file. but now it logs alll user activity ![]() |
|
#4
|
|||
|
|||
|
I'm not sure if this helps or anything...
but I log the last access time for each user by simply having a field in the DB called "LastLogin". Each time the user logs in the field is set to "now()". I am mearly a beginner tho!! So sorry if it's not what you're looking for!! ![]() |
|
#5
|
|||
|
|||
|
Well,
normally that should do the trick ..but the file needs to be send with an email trhu a cron job. I haven't compiledthe php excecutable so ...i cannot retreive.. |
|
#6
|
|||
|
|||
|
aaah I see!
No Probs!! ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Log last accestime |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|