FrontEndUsers Enhansement

Talk about new features for CMSMS and modules.
Post Reply
User avatar
johnbmcdonald
Forum Members
Forum Members
Posts: 60
Joined: Mon May 14, 2007 8:01 pm

FrontEndUsers Enhansement

Post by johnbmcdonald »

I had a customer that needed to be able to restrict user accounts to a specific number of IP addresses.

If you are interested, here is the code:

        global $gCms;
        if( isset($params['ipcheck']) && $params['ipcheck'] ) {
              $ipnum = isset($params['maxnumip'])?$params['maxnumip']:3;
              $db =& $this->GetDb();
            $module =& $this->GetModuleInstance('FrontEndUsers');
            if( !$module ) return FALSE;
            $uid = $module->LoggedInId();         
              $sql = "SELECT distinct(ipaddress) FROM ".cms_db_prefix()."module_feusers_history
                    WHERE userid =" . $uid . " AND ipaddress IS NOT NULL";
          $dbresult = &$db->Execute($sql);
            while( $dbresult && $row = $dbresult->FetchRow()) {
                $data[] = $row;
            }   
          if( count($data) > $ipnum ) {
                $url = !empty($params['errorpage'])?$params['errorpage']:" http://localhost:90/cms/index.php?page=How-CMSMS-Works";
                header("Location:" . $url);
                exit();
          }                               
        }
Here is how you use it:
{cms_module module=CustomContent ipcheck=1 maxnumip=4 errorpage=http://google.com}

eMail me if you would like the whole CustomContent.module.php file

John
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: FrontEndUsers Enhansement

Post by calguy1000 »

it's possible to do this without modifying CustomContent.  You could have used the $customcontent_ip smarty variable
and some smarty logic.
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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: FrontEndUsers Enhansement

Post by calguy1000 »

oh, I'm sorry.... this restricts people to a maximum of N distinct IP addresses.... it doesn't restrict 'which' ip addresses.
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.
Post Reply

Return to “Feature ideas”