Zubrag.com
May 21, 2019, 09:04:44 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Creating a simple log file as user logs in  (Read 26926 times)
elgo
Newbie
*
Posts: 1


« on: December 30, 2008, 07:45:52 PM »

Hello,

Thank you for creating this wonderful script. It has been the perfect answer for my needs.

After searching around the forum and then attempting to write the php to implement this on my own (my php skills are not good), I do have one question I hope someone may be able to help with.

Has anyone integrated into this script a simple log for tracking who has signed into protected pages? What I would like to accomplish is to have a simple text file log on the server (similar to the flat user file) which I can download and access to see which users have visited my site and have it with a time stamp. Example of one line in the log might be: Xyz_user logged into my site on Monday, June 8, 2008 at 6:30 pm. Just have it so each time a user signs in it adds to the end of the log file so I could go back over time and see which users logged in and when they did it.

If anyone has done this and would be willing to share their php for this I would appreciate it.

Thank you.

Logged
Surao
Newbie
*
Posts: 7


« Reply #1 on: February 18, 2009, 01:01:14 PM »

Hi,

I looking for the same functionality, has anyone implemented this as yet.

Help on this would be appreciated.

Logged
PHPwhattt?
Newbie
*
Posts: 2


« Reply #2 on: April 27, 2009, 07:54:43 AM »

I'm abit of a noob to this but i managed to create a log file.

Its not prefect but here is what i did.

On the password_protect .php page i created a session by placing this code (

<?php
session_start();
session_register("login");
?>

) under the html code.

This passes the username variable to the next page

And on the next page i wrote the variable to a text file along with the date and time like this:

<?php
$date=date("l, d F, Y, H:I");
$updatefile = "userlogs.txt";
$fh = fopen($updatefile, 'a') or die("can't open file");
$stringData = "User: $login &nbsp;&nbsp;&nbsp;&nbsp;";
fwrite($fh, $stringData);
$stringData = "Logged in: $date<br><hr>";
fwrite($fh, $stringData);
fclose($fh);
?>

I then created a page to display the userlogs.txt using the include function

<?php include("userlogs.txt"); ?>

Hope this helps / makes sense =S like i said im also new to php. Im sure there is a much better way of doing this?

Simon
Logged
cherrygirl
Newbie
*
Posts: 1


« Reply #3 on: June 12, 2009, 10:12:57 AM »

Hi,

I've come up with a method that sends you a short email everytime someone successfully logs in.
The time & date of the email sent will serve as the log in time/date.
So here is the code that you'd need to add to your password_protect.php file.

Firstly, inside the SETTINGS section, add this code just above the SETTINGS END, like this:

// get posted data into local variables
$EmailTo = "email@youremail.com";
$Subject = "User logged in";
$login = Trim(stripslashes($_POST['Login']));
$pass = Trim(stripslashes($_POST['Password']));

##################################################################
#  SETTINGS END
##################################################################

Don't forget to modify the $EmailTo value with your own email address!

Then, further down the page, the bit where it says:

setcookie("verify", md5($login.'%'.$pass), $timeout, '/');

add the following line just below:
$success = mail($EmailTo, $Subject, $login, $pass);

And that's it!

Hope this helps someone out there...
Logged
tropicaljantie
Newbie
*
Posts: 2


« Reply #4 on: July 13, 2009, 02:42:37 AM »

this seems to work only when you login to manager.php
Logged
1ststop
Newbie
*
Posts: 30


« Reply #5 on: September 11, 2009, 05:21:43 AM »

I also found that it only worked with admin log-in.

I have crudely added the function to the signup.php with the modification as below:
(copy the orange text and paste into page as shown. Don't forget to change the email address to yours)

Add after:
 function redirect() {
    header('Location: ' . SIGNUP_THANKS_URL);
    exit();
  }

}

// get posted data into local variables
$EmailTo = "your email address here";
$Subject = "New user signup";
$login = Trim(stripslashes($_POST['access_login']));
$pass = Trim(stripslashes($_POST['access_password']));

$success = mail($EmailTo, $Subject, $login, $pass);



and before: $signup_form_instance = new zubrag_signup_form();


The resultant email is simply the password and username in that order.
Logged
Fionnan
Newbie
*
Posts: 3


« Reply #6 on: September 22, 2010, 06:06:58 AM »

I'm abit of a noob to this but i managed to create a log file.

Its not prefect but here is what i did.

On the password_protect .php page i created a session by placing this code (

<?php
session_start();
session_register("login");
?>

) under the html code.

This passes the username variable to the next page

And on the next page i wrote the variable to a text file along with the date and time like this:

<?php
$date=date("l, d F, Y, H:I");
$updatefile = "userlogs.txt";
$fh = fopen($updatefile, 'a') or die("can't open file");
$stringData = "User: $login &nbsp;&nbsp;&nbsp;&nbsp;";
fwrite($fh, $stringData);
$stringData = "Logged in: $date<br><hr>";
fwrite($fh, $stringData);
fclose($fh);
?>

I then created a page to display the userlogs.txt using the include function

<?php include("userlogs.txt"); ?>

Hope this helps / makes sense =S like i said im also new to php. Im sure there is a much better way of doing this?

Simon


This is a great script. Would anybody know how to incorporate the IP address into this logfile, so it would show username, time, date and the IP address used to log in.

Regards,
Fionnan
Logged
Fionnan
Newbie
*
Posts: 3


« Reply #7 on: September 22, 2010, 06:14:03 AM »

Nevermind, I worked it out
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC