Frontend Users not expiring

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
mahjong

Re: Frontend Users not expiring

Post by mahjong »

Solved the Expiring Time not saving issue:

Code: Select all

    <p class="pageinput">{html_select_date|utf8_encode prefix=$expires_dateprefix time=$expiresdate start_year=2000 end_year=2040} {html_select_time|utf8_encode prefix=$expires_dateprefix time=$expiresdate}</p>
The second $prefix was missing an underscore.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Frontend Users not expiring

Post by Dee »

Fixed in SVN. Thanks!
mahjong

Re: Frontend Users not expiring

Post by mahjong »

Code: Select all

    $dbresult = $db->Execute( $q, array( $uid, $name, md5($password), 
					 $db->DbTimeStamp(time()."'"),
					 $db->DbTimeStamp($expires,"'") ) );
This part doesn't make sense to me.

How come the first DbTimeStamp is with a dot (.) and not a coma (,) ? It's either or the other but not the two at the same time.
mahjong

Re: Frontend Users not expiring

Post by mahjong »

I fail to see the logic behind :

Code: Select all

	function DBTimeStamp($timestamp)
	{
		if (empty($timestamp) && $timestamp !== 0)
			return 'null';

		# strlen(14) allows YYYYMMDDHHMMSS format
		if (!is_string($timestamp) || (is_numeric($timestamp) && strlen($timestamp)<14)) 
			return adodb_date($this->fmtTimeStamp, $timestamp);

		if ($timestamp === 'null')
			return $timestamp;

		if ($this->isoDates && strlen($timestamp) !== 14)
			return "'$timestamp'";

		return adodb_date($this->fmtTimeStamp, $this->UnixTimeStamp($timestamp));
	}
mahjong

Re: Frontend Users not expiring

Post by mahjong »

THIS FUNCTION ALWAYS RETURN FALSE

Code: Select all

  function IsAccountExpired( $uid )
  {
    $db =& $this->GetDb();
    
    $q = "SELECT * FROM ".cms_db_prefix()."module_feusers_users
          WHERE id = ? AND expires > ?";
    $dbresult = $db->Execute( $q, array( $uid, 
					 $db->DbTimeStamp(time()) ) );
    if( $dbresult && $dbresult->RecordCount() == 1 )
      {
	return false;
      }

    return true;
  }
Last edited by mahjong on Sat Dec 09, 2006 1:34 am, edited 1 time in total.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Frontend Users not expiring

Post by jmcgin51 »

THANK YOU FOR THE TIMESTAMP FIX, MAHJONG!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I also saw the dot and comma issue, and didn't understand it.  Calguy?  Was this a typo or is there a reason one is a comma and one is a dot?

I can't help you with the function IsAccountExpired and DBTimeStamp code questions.  I know just a little less than nothing about PHP...

THANK YOU AGAIN for the timestamp fix - this really saved my site!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Frontend Users not expiring

Post by calguy1000 »

The dot issue was a typo..... thanks, I would never have seen that.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
mahjong

Re: Frontend Users not expiring

Post by mahjong »

The change in SVN still doesn't work and it doesn't make sense.

The DbTimeStamp function doesn't take 2 parameters. Can't be a coma.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Frontend Users not expiring

Post by jmcgin51 »

It's working for me - I'm using a comma in both locations, as follows


$dbresult = $db->Execute( $q, array( $uid, $name, md5($password),
                                                    $db->DbTimeStamp(time(),"'"),
                                                    $db->DbTimeStamp($expires,"'") ) );
mahjong

Re: Frontend Users not expiring

Post by mahjong »

When you say "It's working for me", do you mean expired users are forbidden to log in?
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Frontend Users not expiring

Post by jmcgin51 »

That's right.  Expired users are now forbidden to log on - kind of.  They can't view any protected content, but if I send them to a page that displays only the {cms_module module=FrontEndUsers} smarty tag, that page shows the "Change My Settings or Sign Off" links.  So the system is still recognizing that they are logged in and that their username exists, but it at least is preventing access to the restricted content.  I'm trying to figure out a workaround right now, since I'm too much of a PHP dunce to actually fix the module.

I'm thinking of something like
<?php
if ( loggedin != true {
echo ("{cms_module module=FrontEndUsers form=login}")
}

I don't know if this is the right php syntax, but I'm going to give it a try right now.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Frontend Users not expiring

Post by jmcgin51 »

well, I couldn't get that code to work, so I just rewrote my login page as follows

{cms_module module=CustomContent}

{cms_module module=FrontEndUsers}
{cms_selflink page='15' text='Home' title='Home'}

{cms_module module=FrontEndUsers form=login}


Now, as far as I can tell, everything works as I want...
mahjong

Re: Frontend Users not expiring

Post by mahjong »

You are saying expired user still can log in. They never receive the message "Account expired". You can only filter them afterwards, with another module. In other words, it doesn't work.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Frontend Users not expiring

Post by jmcgin51 »

Yes, that is correct.  I wasn't aware that they were supposed to see an "Account Expired" message.  I can't find that anywhere in the documentation, but it makes sense.  That would be great if it worked.
mahjong

Re: Frontend Users not expiring

Post by mahjong »

Strangely, if I strip the quotes around the output of DbTimeStamp it works.

I rewrote this function inside FrontEndUsers.api.php :

Code: Select all

  function IsAccountExpired( $uid )
  {
    $db =& $this->GetDb();
    
    $q = "SELECT * FROM ".cms_db_prefix()."module_feusers_users WHERE id = ? AND expires > ?";
    $dbresult = $db->Execute( $q, array( $uid, str_replace("'",'', $db->DbTimeStamp( time() ) ))  );

    if( $dbresult && $dbresult->RecordCount() )
      {
	return false;
      }

    return true;
  }
Post Reply

Return to “CMSMS Core”