BLOG:CMS :: Support Forum

Support Forum for BLOG:CMS

You are not logged in.

#1 03.12.2008 23:01

badlee55
newbie...
Registered: 03.12.2008
Posts: 1

Captcha on createaccount.html

I have had blogcms for some time now, and every day it seems as though i recieve more and more spam accounts!!! I have also set up security (so that only members can view the sight) using the built in features, and i have been having a problem trying to use the np_captcha(which works with templates) and use it on the createaccounts.html page. any suggestions as to how to fix that? or another work arround without using a .httaccess file.

Badlee55

Offline

 

#2 13.01.2009 22:47

Aughavey
BLOG:CMS Senior
Registered: 08.07.2004
Posts: 50

Re: Captcha on createaccount.html

I have captcha on comments and contact forums for non registered members but how do I get the captcha on the new / register account form? At the moment I have had to disable new registrations and implemented captcha on punbb to stop spam there whilst allowing punbb registrations. 

thanks for any help.

Offline

 

#3 17.01.2009 00:58

Radek Hulán
Site Admin
From: Prague, Czech Republic
Registered: 17.03.2004
Posts: 2509
Website

Re: Captcha on createaccount.html

You need to add code like this to createaccount.html (and rename it to PHP):

Code:

        <?php
        // create CAPTCHA
        include("cfg.php");
        global $manager;
        $plugin =& $manager->getPlugin('NP_Captcha');
        if (!$plugin) 
            doError('CAPTCHA not configure, please contact system admin.');
        $data = array();
        $data['type'] = 'membermailform-notloggedin';
        $plugin->event_FormExtra($data);
        ?>

Plus modify action.php to check for CAPTCHA string:

Code:

// creates a new user account
function createAccount() {
    global $CONF, $manager, $member;

    if (!$CONF['AllowMemberCreate'])
        doError(_ERROR_MEMBERCREATEDISABLED);

    if ($member && $member->isLoggedIn())
        doError(_ERROR_MEMBERCREATEDISABLED);

    // check CAPTCHA
    $plugin =& $manager->getPlugin('NP_Captcha');
    if ($plugin) {
        $data = array();
        $data['type'] = 'membermail';
        $plugin->event_ValidateForm(&$data,'');
        if (isset($data['error'])) {
            doError($data['error']);
            die;
        }
    }
    
    // spamboxes
    $badmail = array('mailinator.com','mailinator2.com','sogetthis.com','mailin8r.com','mailinator.net','spamherelots.com','thisisnotmyrealemail.com','aravensoft.com','petr.bobes','ballyfinance.com','freemail.lt');
    $email = postVar('email');
    foreach($badmail as $mail)
        if (eregi($mail,$email)){
            doError(_ERROR_MEMBERCREATEDISABLED);
        }
        
    // email exists
    $exists = quickQuery("SELECT count(*) as result FROM ".sql_table('member')." WHERE memail='".sql_escape($email)."'");
    if ($exists)
        doError(_ERROR_BADNAME);

    // create random password
    $pw = genPassword(10);
    // create member (non admin/can login/no notes)
    $r = MEMBER::create(postVar('name'), postVar('realname'), $pw, postVar('email'), postVar('url'), 0, $CONF['NewMemberCanLogon'], '');
    if ($r != 1)
        doError($r);
    // send message containing password.
    $newmem = & new MEMBER();
    $newmem->readFromName(postVar('name'));
    $newmem->sendPassword($pw);

    $manager->notify('PostRegister',array('member' => &$newmem));

    if (postVar('desturl')) {
        header('Expires: 0');
        header('Pragma: no-cache');
        Header('Location: ' . postVar('desturl'));
    } else {
echo "Account created";
exit(0);
    }
}

--= BLOG:CMS developer =--

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

TOPlist