Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
7 + 8 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     
'text', You can use 'text' or 'image' values and it works correct with me. May be you have different values for mode. Hope this will help. Do have any ideas on removing the second page in registration and bringing captcha to the first page?[/quote]" />

Re: Frameworks Captcha
by timgno on 2008/6/6 10:58:59

Sorry for my english!

I tried this hack with the version 2.0.18.1 of XOOPS but does not work. You may make changes for this?

Thank's
Re: Frameworks Captcha
by GlaDiaC on 2007/9/3 12:25:35

This is a Captcha HOWTO for XOOPS 2.2. Maybe you have different versions so I've added the approximatly line and a piece of the code.

REGISTER

File: modules/profiles/include/forms.php
Line: 331

le="color: #000000"><?php if ($xoopsModuleConfig['display_disclaimer'] != 0 && $xoopsModuleConfig['disclaimer'] != '') { $disc_tray = new XoopsFormElementTray(_PROFILE_MA_DISCLAIMER, '<br />'); $disc_text = new XoopsFormLabel("", "<div style="padding: 5px;">".$GLOBALS["myts"]->displayTarea($xoopsModuleConfig['disclaimer'],1)."</div>"); // Should we define a div.xoopsStatement class in style.css? $disc_tray->addElement($disc_text); $agree_chk = new XoopsFormCheckBox('', 'agree_disc'); $agree_chk->addOption(1, _PROFILE_MA_IAGREE); $disc_tray->addElement($agree_chk); $reg_form->addElement($disc_tray); } $reg_form->addElement(new XoopsFormHidden("op", "newuser")); [color=CC0000] // Captcha Hack $reg_form->addElement(new XoopsFormCaptcha()); // Captcha Hack[/color] $reg_form->addElement(new XoopsFormButton("", "submit", _PROFILE_MA_SUBMIT, "submit")); return $reg_form; }



File: modules/profiles/register.php
Line: 81

le="color: #000000"><?php if ( strcmp(trim($_POST['pass']), trim($_POST['vpass'])) ) { $stop .= _PROFILE_MA_PASSNOTSAME."<br />"; }elseif (!empty($xoopsModuleConfig['minpass']) && strlen(trim($_POST['pass'])) < $xoopsModuleConfig['minpass']) { $stop .= sprintf(_PROFILE_MA_PWDTOOSHORT,$xoopsModuleConfig['minpass'])."<br />"; } $stop .= userCheck($newuser); [color=CC0000] // Captcha Hack if (@include_once XOOPS_ROOT_PATH."/Frameworks/captcha/captcha.php") { $xoopsCaptcha = XoopsCaptcha::instance(); if (! $xoopsCaptcha->verify() ) { $stop .= $xoopsCaptcha->getMessage()."<br />"; } } // Captcha Hack[/color] if (empty($stop)) { echo _PROFILE_MA_USERNAME.": ".$newuser->getVar('loginname')."<br />"; echo _PROFILE_MA_EMAIL.": ".$newuser->getVar('email')."<br />"; echo _PROFILE_MA_DISPLAYNAME.": ".$newuser->getVar('uname')."<br />";




COMMENTS

File: include/comment_form.php
Line: 121

le="color: #000000"><?php if ('system' != $xoopsModule->getVar('dirname')) { $comment_config = $xoopsModule->getInfo('comments'); if (isset($comment_config['extraParams']) && is_array($comment_config['extraParams'])) { $myts =& MyTextSanitizer::getInstance(); foreach ($comment_config['extraParams'] as $extra_param) { // This routine is included from forms accessed via both GET and POST if (isset($_REQUEST[$extra_param])) { $hidden_value = htmlspecialchars($_REQUEST[$extra_param]); } else { $hidden_value = ''; } $cform->addElement(new XoopsFormHidden($extra_param, $hidden_value)); } } } [color=CC0000]// Captcha Hack $cform->addElement(new XoopsFormCaptcha()); // Captcha Hack[/color] $button_tray->addElement(new XoopsFormButton('', 'com_dopreview', _PREVIEW, 'submit')); $button_tray->addElement(new XoopsFormButton('', 'com_dopost', _CM_POSTCOMMENT, 'submit')); $cform->addElement($button_tray); $cform->display();



File: include/comment_post.php
Line: 141

le="color: #000000"><?php } else { xoops_cp_header(); themecenterposts($com_title, $p_comment); include XOOPS_ROOT_PATH.'/include/comment_form.php'; xoops_cp_footer(); } break; case "post": [color=CC0000] // Captcha Hack if(@include_once XOOPS_ROOT_PATH . "/Frameworks/captcha/captcha.php") { $xoopsCaptcha = XoopsCaptcha::instance(); if(! $xoopsCaptcha->verify(true) ) { redirect_header($redirect_page.'='.$com_itemid.'&com_id='.$com_id.'&com_mode='.$com_mode.'&com_order='.$com_order, 2, $xoopsCaptcha->getMessage()); } } // Captcha Hack[/color] $doimage = 1; $comment_handler =& xoops_gethandler('comment'); $add_userpost = false; $call_approvefunc = false; $call_updatefunc = false; // RMV-NOTIFY - this can be set to 'comment' or 'comment_submit' $notify_event = false;



SUBMIT NEWS

File: modules/news/include/storyform.inc.php
Line: 185

le="color: #000000"><?php if (is_object($xoopsUser)) { $notify_checkbox = new XoopsFormCheckBox('', 'notifypub', $notifypub); $notify_checkbox->addOption(1, _NW_NOTIFYPUBLISH); $option_tray->addElement($notify_checkbox); if ($xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { $nohtml_checkbox = new XoopsFormCheckBox('', 'nohtml', $nohtml); $nohtml_checkbox->addOption(1, _DISABLEHTML); $option_tray->addElement($nohtml_checkbox); } } $smiley_checkbox = new XoopsFormCheckBox('', 'nosmiley', $nosmiley); $smiley_checkbox->addOption(1, _DISABLESMILEY); $option_tray->addElement($smiley_checkbox); $sform->addElement($option_tray); [color=CC0000]// Captcha Hack $sform->addElement(new XoopsFormCaptcha()); // Captcha Hack[/color] //TODO: Approve checkbox + "Move to top" if editing + Edit indicator //Submit buttons $button_tray = new XoopsFormElementTray('' ,''); $preview_btn = new XoopsFormButton('', 'preview', _PREVIEW, 'submit'); $preview_btn->setExtra('accesskey="p"'); $button_tray->addElement($preview_btn); $submit_btn = new XoopsFormButton('', 'post', _NW_POST, 'submit'); $submit_btn->setExtra('accesskey="s"'); $button_tray->addElement($submit_btn); $sform->addElement($button_tray);


File: modules/news/include/submit.php
Line: 300

le="color: #000000"><?php //Display post edit form $returnside=intval($_POST['returnside']); include_once XOOPS_ROOT_PATH.'/modules/news/include/storyform.inc.php'; break; case 'post': [color=CC0000]// Captcha Hack if(@include_once XOOPS_ROOT_PATH . "/Frameworks/captcha/captcha.php") { $xoopsCaptcha = XoopsCaptcha::instance(); if(! $xoopsCaptcha->verify(true) ) { redirect_header(XOOPS_URL.'/modules/news/submit.php', 2, $xoopsCaptcha->getMessage()); } } // Captcha Hack[/color] $nohtml_db = isset($_POST['nohtml']) ? $_POST['nohtml'] : 1; if (is_object($xoopsUser) ) { $uid = $xoopsUser->getVar('uid'); if ($approveprivilege) { $nohtml_db = empty($_POST['nohtml']) ? 0 : 1; } if (isset($_POST['author']) && ($approveprivilege || $xoopsUser->isAdmin($xoopsModule->mid())) ) { $uid=intval($_POST['author']); } } else { $uid = 0; }
Re: Frameworks Captcha
by cutley on 2007/7/19 13:22:37

ooooo how did I not find that, my google skills are obviously not as good as they used to be. I'll give it a go later but it looks correct to me.

TANKS!
Re: Frameworks Captcha
by skenow on 2007/7/18 18:23:15

Try this solution Re: Captcha to register page.
Re: Frameworks Captcha
by cutley on 2007/7/18 14:16:04

Sorry to bump this up but I really need some help.

Iv been trying to get this to work for hours with no luck.

I want to get it to work with 2.2

I can get the form element to be generated fine but it doesnt check for it be valid.

Iv put this:


<?php // $Id: register.php,v 1.1.2.13.2.1 2005/09/18 13:59:36 mithyt2 Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // // <https://xoops.org/> // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // include '../../mainfile.php'; [color=CC0000]include_once XOOPS_ROOT_PATH.'/Frameworks/captcha/formcaptcha.php';[/color] include_once 'include/functions.php'; $myts =& MyTextSanitizer::getInstance(); if (empty($xoopsModuleConfig['allow_register'])) { redirect_header('../../index.php', 6, _PROFILE_MA_NOREGISTER); exit(); } include XOOPS_ROOT_PATH.'/header.php'; $member_handler =& xoops_gethandler('member'); $newuser =& $member_handler->createUser(); $op = !isset($_POST['op']) ? 'register' : $_POST['op']; if ($op != "register") { $newuser->setVar('uname', isset($_POST['uname']) ? trim($_POST['uname']) : ''); $newuser->setVar('loginname', isset($_POST['loginname']) ? trim($_POST['loginname']) : ''); $newuser->setVar('email', isset($_POST['email']) ? trim($_POST['email']) : ''); //Dynamic fields $profile_handler =& xoops_gethandler('profile'); // Get fields $fields =& $profile_handler->loadFields(); if (count($fields) > 0) { foreach (array_keys($fields) as $i) { $fieldname = $fields[$i]->getVar('field_name'); if ($fields[$i]->getVar('field_register') && isset($_POST[$fieldname])) { $newuser->setVar($fieldname, $_POST[$fieldname]); } } } $vpass = isset($_POST['vpass']) ? $myts->stripSlashesGPC($_POST['vpass']) : ''; $agree_disc = (isset($_POST['agree_disc']) && intval($_POST['agree_disc'])) ? 1 : 0; } switch ( $op ) { case 'newuser': if (!$GLOBALS['xoopsSecurity']->check()) { echo implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()); break; } $newuser->setVar('pass', isset($_POST['pass']) ? md5(trim($_POST['pass'])) : ''); $stop = ''; if ($xoopsModuleConfig['display_disclaimer'] != 0 && $xoopsModuleConfig['disclaimer'] != '') { if (empty($agree_disc)) { $stop .= _PROFILE_MA_UNEEDAGREE.'<br />'; } } if (!empty($xoopsModuleConfig['minpass']) && strlen(trim($_POST['pass'])) < $xoopsModuleConfig['minpass']) { $stop .= sprintf(_PROFILE_MA_PWDTOOSHORT,$xoopsModuleConfig['minpass'])."<br />"; } $stop .= userCheck($newuser); if (empty($stop)) { [color=CC0000]if(@include_once XOOPS_ROOT_PATH."/Frameworks/captcha/formcaptcha.php") { $cpatcha = new XoopsFormCaptcha(); echo $cpatcha->getCaption().": ".$cpatcha->render()."<br />"; }[/color] echo _PROFILE_MA_USERNAME.": ".$newuser->getVar('loginname')."<br />"; echo _PROFILE_MA_EMAIL.": ".$newuser->getVar('email')."<br />"; echo _PROFILE_MA_DISPLAYNAME.": ".$newuser->getVar('uname')."<br />"; $profile_handler =& xoops_gethandler('profile'); // Get fields $fields =& $profile_handler->loadFields(); if (count($fields) > 0) { foreach (array_keys($fields) as $i) { $fieldname = $fields[$i]->getVar('field_name'); if ($fields[$i]->getVar('field_register') && isset($_POST[$fieldname])) { $value = $newuser->getVar($fieldname); if (is_array($value)) { $values = array(); $options = $fields[$i]->getVar('field_options'); foreach ($value as $thisvalue) { $values = $options[$thisvalue]; } $value = implode(', ', $values); } echo $fields[$i]->getVar('field_title').": ".$value."<br />"; } } } //hidden POST form with variables include_once 'include/forms.php'; $finish_form =& getFinishForm($newuser, $vpass); $finish_form->display(); } else { echo "<div class='errorMsg'>$stop</div><br clear='both'>"; include_once 'include/forms.php'; $reg_form =& getRegisterForm($newuser); $reg_form->display(); } break; case 'finish': if (!$GLOBALS['xoopsSecurity']->check()) { echo implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()); break; } [color=CC0000]if(@include_once XOOPS_ROOT_PATH."/Frameworks/captcha/captcha.php") { $xoopsCaptcha = XoopsCaptcha::instance(); if(! $xoopsCaptcha->verify() ) { $stop .= $xoopsCaptcha->getMessage()."<br />"; } }[/color] $stop = ''; if ($xoopsModuleConfig['display_disclaimer'] != 0 && $xoopsModuleConfig['disclaimer'] != '') { if (empty($agree_disc)) { $stop .= _PROFILE_MA_UNEEDAGREE.'<br />'; } } $stop = userCheck($newuser); if ( empty($stop) ) { $newuser->setVar('pass', $_POST['pass']); $newuser->setVar('user_avatar','blank.gif'); $actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8); $newuser->setVar('actkey', $actkey); $newuser->setVar('user_regdate', time()); if ($xoopsModuleConfig['activation_type'] == 1) { $newuser->setVar('level', 1); } $profile_handler =& xoops_gethandler('profile'); // Get fields $fields =& $profile_handler->loadFields(); if (count($fields) > 0) { foreach (array_keys($fields) as $i) { $fieldname = $fields[$i]->getVar('field_name'); if ($fields[$i]->getVar('field_register') && isset($_POST[$fieldname])) { $newuser->setVar($fieldname, $_POST[$fieldname]); } } } if (!$member_handler->insertUser($newuser)) { echo _PROFILE_MA_REGISTERNG; echo implode('<br />', $newuser->getErrors()); break; } $newid = $newuser->getVar('uid'); if (!$member_handler->addUserToGroup(XOOPS_GROUP_USERS, $newid)) { echo _PROFILE_MA_REGISTERNG; break; } //Welcome PM Hack start //Yeah,already defined above^^ // $newid = $newuser->getVar('uid'); $pm_handler =& xoops_gethandler('privmessage'); $pm =& $pm_handler->create(); $pm->setVar("subject", "Welcome to Swift"); $pm->setVar("msg_text", "Thanks for taking the time to register on the site. You can now reply to/comment articles and use the forum. If you are based in/around Essex please [url=http://swift-freedom.com/x/essex/modules/articles/article.php?id=19]add yourself to the location directory[/url]. If you have any problems with the site please email swift@swift-freedom.com"); //Newuser's id $pm->setVar("to_userid", $newid); // Admin's id,1 in my case $pm->setVar("from_userid", 1); if (!$pm_handler->insert($pm)) { // echo "Failed to send Welcome Private Message!!"; // No need to echo this failure-message here,I think so!!...Just optional^^ } //Welcome PM Hack end if ($xoopsModuleConfig['activation_type'] == 1) { redirect_header(XOOPS_URL.'/index.php', 4, _PROFILE_MA_ACTLOGIN); } if ($xoopsModuleConfig['activation_type'] == 0) { $xoopsMailer =& getMailer(); $xoopsMailer->useMail(); $xoopsMailer->setTemplate('register.tpl'); $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH."/modules/profile/language/".$xoopsConfig['language']."/mail_template"); $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); $xoopsMailer->assign('SITEURL', XOOPS_URL."/"); $xoopsMailer->setToUsers(new XoopsUser($newid)); $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsConfig['sitename']); $xoopsMailer->setSubject(sprintf(_PROFILE_MA_USERKEYFOR, $newuser->getVar('uname'))); if ( !$xoopsMailer->send() ) { echo _PROFILE_MA_YOURREGMAILNG; } else { echo _PROFILE_MA_YOURREGISTERED; } } elseif ($xoopsModuleConfig['activation_type'] == 2) { $xoopsMailer =& getMailer(); $xoopsMailer->useMail(); $xoopsMailer->setTemplate('adminactivate.tpl'); $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH."/modules/profile/language/".$xoopsConfig['language']."/mail_template"); $xoopsMailer->assign('USERNAME', $newuser->getVar('uname')); $xoopsMailer->assign('USEREMAIL', $newuser->getVar('email')); $xoopsMailer->assign('USERACTLINK', XOOPS_URL.'/modules/profile/activate.php?op=actv&id='.$newid.'&actkey='.$actkey); $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); $xoopsMailer->assign('SITEURL', XOOPS_URL."/"); $member_handler =& xoops_gethandler('member'); $xoopsMailer->setToGroups($member_handler->getGroup($xoopsModuleConfig['activation_group'])); $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsConfig['sitename']); $xoopsMailer->setSubject(sprintf(_PROFILE_MA_USERKEYFOR, $newuser->getVar('uname'))); if ( !$xoopsMailer->send() ) { echo _PROFILE_MA_YOURREGMAILNG; } else { echo _PROFILE_MA_YOURREGISTERED2; } } if ($xoopsModuleConfig['new_user_notify'] == 1 && !empty($xoopsModuleConfig['new_user_notify_group'])) { $xoopsMailer =& getMailer(); $xoopsMailer->useMail(); $member_handler =& xoops_gethandler('member'); $xoopsMailer->setToGroups($member_handler->getGroup($xoopsModuleConfig['new_user_notify_group'])); $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsConfig['sitename']); $xoopsMailer->setSubject(sprintf(_PROFILE_MA_NEWUSERREGAT,$xoopsConfig['sitename'])); $xoopsMailer->setBody(sprintf(_PROFILE_MA_HASJUSTREG, $newuser->getVar('uname'))); $xoopsMailer->send(); } } else { echo "<div class='errorMsg'>$stop</div><br clear='both'>"; include_once 'include/forms.php'; $reg_form =& getRegisterForm($newuser); $reg_form->display(); } break; case 'register': default: include_once 'include/forms.php'; $reg_form =& getRegisterForm($newuser); $reg_form->display(); break; } include XOOPS_ROOT_PATH.'/footer.php'; ?>


p.s why am i not notified of new user registeration if it is set to automatic activation.

Who's Online

158 user(s) are online (104 user(s) are browsing Support Forums)


Members: 0


Guests: 158


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits