Code: Select all
// create a reference to a Captcha module object
$captcha = &$this->getModuleInstance('Captcha');
// show the captcha image
echo $captcha->getCaptcha();
// create a reference to a Captcha module object
$captcha = &$this->getModuleInstance('Captcha');
// check the user input (the checkCaptcha method will return TRUE if $input is correct, FALSE if $input is incorrect)
$validated = $captcha->checkCaptcha($input);
1. putting a text box on the page where the captcha image text should be input
2. validating the input (I think)
action.default.php:
Code: Select all
<?
// create a reference to a Captcha module object
$captcha = &$this->getModuleInstance('Captcha');
// show the captcha image
echo $captcha->getCaptcha();
// create a reference to a Captcha module object
$captcha = &$this->getModuleInstance('Captcha');
// check the user input (the checkCaptcha method will return TRUE if $input is correct, FALSE if $input is incorrect)
$validated = $captcha->checkCaptcha($input);
$message = '';
if( isset($params['message']) )
{
$message = $params['message'];
}
$this->smarty->assign('prompt_email',$this->Lang('emailaddress'));
$this->smarty->assign('error',$params['error']);
$this->smarty->assign('submitbtn',
$this->CreateInputSubmit($id, 'submit',
$this->Lang('submit')));
$template = 'nms_subscribeform';
$mode = 'subscribe';
if(isset($params['mode']) && $params['mode'] != '')
{
$mode = $params['mode'];
}
switch( $mode ) {
case 'usersettings':
{
$this->smarty->assign('error',$params['error']);
$this->smarty->assign('formstart',
$this->CreateFrontendFormStart($id, $returnid, 'usersettings_email' ));
$this->smarty->assign('formend',$this->CreateFormEnd());
$this->smarty->assign('email', $this->CreateInputText($id, 'email','',30, 150 ));
$this->smarty->assign('formhidden', $this->CreateInputHidden($id, 'usersettings'));
$template = 'usersettings_form';
}
break;
case 'unsubscribe':
{
$this->smarty->assign('error',$params['error']);
$this->smarty->assign('formstart',$this->CreateFrontendFormStart($id, $returnid, 'unsubscribe_email'));
$this->smarty->assign('formend',$this->CreateFormEnd());
$this->smarty->assign('email', $this->CreateInputText($id, 'email','',30, 150 ));
$this->smarty->assign('formhidden', $this->CreateInputHidden($id, 'unsubscribe'));
$template = 'nms_unsubscribeform';
}
break;
case 'subscribe':
{
if( isset( $params['displayform'] ) && $params['displayform'] == 0 )
{
// nothing
}
else
{
$lists = "";
if( isset( $params['select'] ) && $params['select'] != "" )
{
$ar = explode(",",$params['select']);
$lists = '("'.implode('","',$ar).'")';
}
$email = '';
if( isset( $params['email'] ) && $params['email'] != "" )
{
$email = $params['email'];
}
$username = '';
if( isset( $params['username'] ) && $params['username'] != "" )
{
$username = $params['username'];
}
$db = &$this->cms->db;
$result = array();
$temparray = array();
$query = "SELECT * FROM ".cms_db_prefix().$this->table_prefix."list
WHERE active = ?
AND public = ?";
if( $lists != "" )
{
$query .= " AND name IN ".$lists;
}
$query .= " ORDER BY listid";
$dbresult = $db->Execute($query,array(1,1));
if ($dbresult && $dbresult->RecordCount() > 0)
{
$oneonly = ($dbresult->RecordCount() == 1);
while ($row = $dbresult->FetchRow())
{
$extratext = '';
if( $oneonly )
{
$hidden .= $this->CreateInputHidden($id,"lists[]",$row['listid']);
$extratext = 'checked="checked" disabled="true"';
}
$temparray[] = "<label>" .
$this->CreateInputCheckbox($id, "lists[]",$row['listid'],"",$extratext).
$row['name'] . " - " . $row['description'] . "</label>";
}
$this->smarty->assign('listids',$temparray);
$this->smarty->assign('formstart',$this->CreateFrontendFormStart($id, $returnid, 'do_create_new_user','post','',true,'',$params));
$this->smarty->assign('formend',$this->CreateFormEnd());
$this->smarty->assign('email', $this->CreateInputText($id, 'email',$email,30, 150 ));
$this->smarty->assign('prompt_username',$this->Lang('name'));
$this->smarty->assign('username', $this->CreateInputText($id, 'username', $username, 30, 150 ));
$this->smarty->assign('formhidden', $hidden );
}
else
{
$message = $this->Lang('nolists');
}
}
}
break;
default:
$this->_DisplayErrorPage($id,$params,$returnid,
$this->Lang('invalidparam'));
return;
}
// Display the populated template
$smarty->assign('message',$message);
echo $this->ProcessTemplateFromDatabase($template);
?>