Welcome to Geeklog, Anonymous Friday, November 22 2024 @ 11:11 pm EST

Geeklog Forums

Date time member last logged on


Status: offline

lgriffin

Forum User
Junior
Registered: 12/01/04
Posts: 24
cheerful
I see in the table gl_users the field for regdate and I have also found in table gl_userinfo the field lastlogin. That field is not in datetime format but a varchar. So my question is how can I tell what was the date and/or time that a uid last logged in?

Thanks
Larry
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
This information is only displayed to the Admin when editing a user's information (Admin Block -> Users).

bye, Dirk
 Quote

Status: offline

jlawrence

Forum User
Chatty
Registered: 12/30/04
Posts: 49
Location:Plymouth, Devon, UK
You could write a php function to list usernames and last logons.
The varchar you refer to is probably a timestamp so you could turn it into a data using the php date function.
www.plymouthcricketclub.com - providing cricket for all ages in the Plymouth area.
 Quote

Status: offline

lgriffin

Forum User
Junior
Registered: 12/01/04
Posts: 24
did a php for that table and still got that strange varchar

7 No Location. 1109131175
8 Maine 1108725673
9 Tucson, Arizona 1106603407

so that date time is: 1106603407 ?
 Quote

Status: offline

destr0yr

Forum User
Full Member
Registered: 07/06/02
Posts: 324
Quote by lgriffin: did a php for that table and still got that strange varchar

The strange varchar is a unix timestamp... I edited my users.php file (and associated templates) w/the following around line 135:
Text Formatted Code

   if ($A['lastlogin'] > 0) {
        $curtime2 = COM_getUserDateTimeFormat($A["lastlogin"]);
        $A['lastlogin'] = $curtime2[0];
        $user_templates->set_var('user_lastlogin', $A['lastlogin']);
    } else if ($A['lastlogin'] == 0 ) {
        $user_templates->set_var('user_lastlogin', 'The user has never logged in');
    }


 

<shamlessplug>An example can be seen here ("Last login" line): http://www.okanagangirlz.com/users.php?mode=profile&uid=784</shamlessplug>
-- destr0yr
"I love deadlines. I like the whooshing sound they make as they fly by." -- Douglas Adams
 Quote

Status: offline

lgriffin

Forum User
Junior
Registered: 12/01/04
Posts: 24
awake
Ok I that in the single member form ok, but what I trying to get to is to do a list of members and last time logged on. So I guess the questions is how to change that stange varchar unix timestamp to something that makes sense to people?
Text Formatted Code
$color = "#C0C0C0"; // this set the background color of the switched row.

//get and prep array of user info
$membersprep = DB_query( "SELECT * FROM gl_users, gl_userinfo where gl_users.uid = gl_userinfo.uid ORDER BY username" );
//$members = DB_fetchArray($membersprep);

//figure out haw many users we really have here
$limit = DB_count('gl_userinfo') - 2;
$count = 1;

// tell folks how popular we really are
$putout .= "There are currently " . $limit . " members of the site!n";

//Load up the first of the display
$putout .= "<table>";

//create our header row
$putout .= "<TR bgcolor="#FFFFFF">n";
$putout .= "<TD><B><H3>Name</H3></B></TD>n";
$putout .= "<TD><B><H3>Join Date</H3></B></TD>n";
$putout .= "<TD><B><H3>Last Login Date</H3></B></TD>n";
$putout .= "</TR>n";

//start spewing out information and switching the bkgrnd color
$switch = false;
while($count <= $limit){
$membersout = DB_fetcharray($membersprep);
switch ( $switch ) {
case true:
$switch = false; // alternating color
$putout .= "<TR bgcolor="" . $color . "">n";
break;
default:
$switch = true; // default, no back color
$putout .= "<TR bgcolor"FFFFFF">n";
} // switch
$putout .= "<TD><a href="http://www.lomguild.com/admin/user.php?mode=edit&uid=";
$putout .= $membersout['uid'] . "">" . $membersout['username'] . "</a></TD>n";
$putout .= "<TD>" . $membersout['regdate'] . "</TD>n";
$putout .= "<TD>" . $membersout['lastlogin'] . "</TD>n";
$putout .= "</TR>n";
$count++;
} // while

//close out the table
$putout .= "</TABLE>";
return $putout;;

 


Thanks Larry
 Quote

Status: offline

lgriffin

Forum User
Junior
Registered: 12/01/04
Posts: 24
cheerful
After a lot of trail and much error, finally got it fixed, and for those wanting to see the same thing: here is the code I used in a static page with php turned on that page. It give User Name, Date they Joined, and the Date (that you can read) of the last time they logged on.
I hope this has helped.

Text Formatted Code
$color = "#C0C0C0"; // this set the background color of the switched row.

//get and prep array of user info
$membersprep = DB_query( "SELECT * FROM gl_users, gl_userinfo where gl_users.uid = gl_userinfo.uid ORDER BY username" );
//$members = DB_fetchArray($membersprep);

//figure out haw many users we really have here
$limit = DB_count('gl_userinfo') - 2;
$count = 1;

// tell folks how popular we really are
$putout .= "There are currently " . $limit . " members of the site!\n";

//Load up the first of the display
$putout .= "<table>";

//create our header row
$putout .= "<TR bgcolor=\"#FFFFFF\">\n";
$putout .= "<TD><B><H3>Name</H3></B></TD>\n";
$putout .= "<TD><B><H3>Join Date</H3></B></TD>\n";
$putout .= "<TD><B><H3>Last Login Date</H3></B></TD>\n";
$putout .= "</TR>\n";

//start spewing out information and switching the bkgrnd color
$switch = false;
while($count <= $limit){
$membersout = DB_fetcharray($membersprep);
switch ( $switch ) {
case true:
$switch = false; // alternating color
$putout .= "<TR bgcolor=\"" . $color . "\">\n";
break;
default:
$switch = true; // default, no back color
$putout .= "<TR bgcolor\"FFFFFF\">\n";
} // switch
$putout .= "<TD><a href=\"http://www.lomguild.com/admin/user.php?mode=edit&uid=";
$putout .= $membersout['uid'] . "\">" . $membersout['username'] . "</a></TD>\n";
$putout .= "<TD>" . $membersout['regdate'] . "</TD>\n";
$curtime2 = COM_getUserDateTimeFormat($membersout['lastlogin']);
$membersout['lastlogin'] = $curtime2[0];
$putout .= "<TD>" . $membersout['lastlogin'] . "</TD>\n";
$putout .= "</TR>\n";
$count++;
} // while

//close out the table
$putout .= "</TABLE>";
return $putout;;

 


Enjoy
Larry
 Quote

Status: offline

ronack

Forum User
Full Member
Registered: 05/27/03
Posts: 612
I just tried this and am getting the wrong information. I get 90% in my list all Logged in at the same time same date. Anyone else try this?
 Quote

Status: offline

ronack

Forum User
Full Member
Registered: 05/27/03
Posts: 612
Looking at the database for userinfo it has a last login of zero for a great many even though I know they have logged it. Well almost everyone logs in at least once.

So now the question is why is the last login reseting to zero.
 Quote

Status: offline

ronack

Forum User
Full Member
Registered: 05/27/03
Posts: 612
Ok I fixed the script so that it says "Never" for those who haven't logged in.

Text Formatted Code
$color = "#C0C0C0"; // this set the background color of the switched row.
   
    //get and prep array of user info
    $membersprep = DB_query( "SELECT * FROM gl_users, gl_userinfo where gl_users.uid = gl_userinfo.uid ORDER BY username" );
    //$members = DB_fetchArray($membersprep);
   
    //figure out haw many users we really have here
    $limit = DB_count('gl_userinfo') - 2;
    $count = 1;
   
    // tell folks how popular we really are
    $putout .= "There are currently " . $limit . " members of the site!";
   
    //Load up the first of the display
    $putout .= "<table>";
   
    //create our header row
    $putout .= "<TR bgcolor='#FFFFFF'>";
    $putout .= "<TD><B><H3>Name</H3></B></TD>";
    $putout .= "<TD><B><H3>Join Date</H3></B></TD>";
    $putout .= "<TD><B><H3>Last Login Date</H3></B></TD>";
    $putout .= "</TR>";
   
    //start spewing out information and switching the bkgrnd color
    $switch = false;
    while($count <= $limit){
    $membersout = DB_fetcharray($membersprep);
    switch ( $switch ) {
    case true:
    $switch = false; // alternating color
    $putout .= "<TR bgcolor=' " . $color . "'>";
    break;
    default:
    $switch = true; // default, no back color
    $putout .= "<TR bgcolor='FFFFFF'>";
    } // switch
    $putout .= "<TD><a href='http://www.miplanet.com/admin/user.php?mode=edit&uid=";
    $putout .= $membersout['uid'] . " '>" . $membersout['username'] . "</a></TD>";
    $putout .= "<TD>" . $membersout['regdate'] . "</TD>";
    $curtime2 = COM_getUserDateTimeFormat($membersout['lastlogin']);
   
   
    if ( ($membersout['lastlogin']) == '0') {
     $membersout["lastlogin"] =  'Never';
    } else {
        $membersout['lastlogin'] = $curtime2[0];
    }
   
   
   
    $putout .= "<TD>" . $membersout['lastlogin'] . "</TD>";
    $putout .= "</TR>";
    $count++;
    } // while
   
    //close out the table
    $putout .= "</TABLE>";
return $putout;
 


Now we need to address as to why so many seem to be reset to zero or in one case empty. Of course maybe there is a large number who register then never log in?
 Quote

Status: offline

ronack

Forum User
Full Member
Registered: 05/27/03
Posts: 612
Now, here's a delemna I have core GL which tells me I have 109 users. This script says I have 108 and appears to have dropped off one user. I also have added the Total Members hack which shows that I have 110 users. Heres the breakdown.

Core GL = 109
Date time memeber last logged in hack = 108
Total Members = 110

I'll see if I can fix these problems now.
 Quote

Status: offline

ronack

Forum User
Full Member
Registered: 05/27/03
Posts: 612
Ok core GL does not include Annonymous where Total Members does. Might need to change that.

Not sure the difference in this script just yet.
 Quote

Status: offline

ronack

Forum User
Full Member
Registered: 05/27/03
Posts: 612
Solved...

Change the following
Text Formatted Code
    //figure out haw many users we really have here
    $limit = DB_count('gl_userinfo') - 2;
 

To (remove the -2)
Text Formatted Code
    //figure out haw many users we really have here
    $limit = DB_count('gl_userinfo');
 

Fixes the count and includes all users. Shows one more than Core GL because it also include Annonymous. To much work to not include Annonymous but it's ok for Annonymous to be there.
 Quote

All times are EST. The time is now 11:11 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content