1
Will_H
<{$user_lastlogin}>
  • 2007/10/19 0:49

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


I would like to work this into my themes, and have been trying to figure out the best way to do this for a few hours now. I have searched, and people have asked about using it in blocks, but I want it right in my theme.

So does anyone know what the best way would be to get this to actually populate.

I imagine it would be similar to the PM method, but Ican't get it.

Heres the gist of what I am trying

<{php}> if (is_object($xoopsUser)) {
            
$date $thisUser->getVar("last_login");
            if (!empty(
$date)) {
                
$xoopsTpl->assign('user_lastlogin'formatTimestamp($date,"m"));
            }
        <{/
php}


any help?

2
Will_H
Re: <{$user_lastlogin}>
  • 2007/10/19 0:59

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


version 2:

<{php}>    GLOBAL $xoopsUser;
            
$date $thisUser->getVar('last_login');
            if (!empty(
$date)) {
                
$GLOBALS['xoopsTpl']->assign('user_lastlogin'formatTimestamp($date,'m'));
            }
        <{/
php}>

3
Will_H
Re: <{$user_lastlogin}>
  • 2007/10/19 7:40

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


30s to load this page....

Vers. 3 (overblown)
<{php}>
    GLOBAL 
$xoopsUser;
    {
        if (!isset(
$this->_last_login)) {
                
$handler =& xoops_gethandler('_last_login');
                    
$this->_last_login formatTimestamp($newmembers[$i]->getVar('last_login'), 's');
        }    
        return 
$this->getVar("lastlogin");
}
echo 
"$last_login;
<{/
php}>


Version 4
<{php}>
$zlast_log formatTimestamp($row['last_login'], 's'); 
echo 
"$zlast_log;<{/php}>


On a side note:

Does anyone else think its ridiculous that XOOPS uses variables such as this, and then they cant be used throughout the site?

What is the point of using variables for this is only able to be used in one place? Why are these not global, without having to...

GetHeadache->$thisSucks('shootme');

???????anyone???????

4
Will_H
Re: <{$user_lastlogin}>
  • 2007/10/19 8:34

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


Alright, thanks to Sublime we actually got something that close to works.

<{php}>
$zlast_log formatTimestamp('##########''s'); 
echo 
"$zlast_log;
<{/
php}>


the ######### represents an actual users timestamp pulled directly from the database.

So the question is, how to get this dynamic? I am not a php expert, so I think my question may sound a little roghh.

but here goes.

in place off the ######### what should i put to have it look at the row in the database that corresponds with the user that is looking at the page?

also, would it be easier to read the users cookie? with this technique you could actually display anons last visit as well.

5
Will_H
Re: <{$user_lastlogin}>
  • 2007/10/19 10:08

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


nevermind, i figured it out.

[for future searches]
Display <{$xoops_lastlogin}>
last login display
Display last login in theme
[/for futer searches]

<{php}>
                if (
$row["last_login"] == 0){
                        
$datetime date("l M. d, Y - h:n a");
                }
            echo 
"$datetime;
                
$query "UPDATE " DB_TABLE_USERS " SET last_login=now() where userid='$userinfo->userid'";
                    
$result mysql_query($query);
            <{/
php}>

6
Will_H
Re: <{$user_lastlogin}>
  • 2007/10/19 16:20

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


Just for the heck of it I will go ahead and show how to use this.

<{if $xoops_isuser}>
            <
div class="welcome_user" align="left"><strong>Welcome Back <{$xoops_uname}>; your last visit was:strong><span style="color: #5176B5;"
            <{
php}>
                if (
$row["last_login"] == 0){
                        
$datetime date("l M. d, Y - h:n a");
                }
            echo 
"$datetime;
                
$query "UPDATE " DB_TABLE_USERS " SET last_login=now() where userid='$userinfo->userid'";
                    
$result mysql_query($query);
            <{/
php}>span>
            div>
        <{else}>
            <
div class="welcome_user" align="left"><strong>Welcome GuestPlease Login Herestrong><span style="color: #5176B5;"> -->span>div>
        <{/if}>


Pretty nice.

7
Will_H
Re: <{$user_lastlogin}>
  • 2007/10/22 5:32

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


Alright, seems that this actually does not work.

Technically it does report the last visit, but only after a user has logged in.

Unfortunately, the core updates the last_login table well before the theme data can pull the information.

...sigh, and I was all excited

We really should consider implementing this feature into the core. I believe it would be a simple addition, wherein on login the current user-unique data in the last_login row is copied to a (***NEW***)previous_login row. Prior to the last_login row being updated with the current time. The previous_login row could then be summoned and displayed using the code snippet i have provided altered like so.

<{php}>
    if (
$row["previous_login"] == 0){
              
$datetime date("l M. d, Y - h:n a");
    }
    echo 
"$datetime;
<{/
php}>


I.M.E. - It offers just a little bit more security for our users. If they see their previous_last_login time is different from when they last logged in, they would know that someone else has gained access to their account. Thereby they could take measures to prevent account hijacks and smurfing by changing their password.

This would also give users a time frame for browsing new content, i.e. they would know that they have not seen any content that was published after their previous_last_login.

I could keep going with reasons why users should be able to see their last_login, and not their current one. However, this thread would be ridiculously long.

____

The code I provided works, just not in the manner I intended because of the limitations of the core. So copy/paste/file away until another day.

8
suico
Re:
  • 2007/10/22 8:54

  • suico

  • Friend of XOOPS

  • Posts: 374

  • Since: 2003/7/24


I like the idea and as it is a security matter i think maybe this could be included in next release the "security" release as I call it 2.0.18 should include this, good point!
Yogurt Social Network Service
Visit: http://www.marcellobrandao.eti.br/

9
mjoel
Re: <{$user_lastlogin}>
  • 2007/11/15 4:03

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


what about displaying x users who were online today or from past x minutes using the info from last_login....

does anyone how to do this ?

Login

Who's Online

323 user(s) are online (189 user(s) are browsing Support Forums)


Members: 0


Guests: 323


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits