How to check Captcha?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Locked
seregarem
Forum Members
Forum Members
Posts: 200
Joined: Sat Aug 28, 2010 1:03 pm

How to check Captcha?

Post by seregarem »

I need to check Captcha before to send the result of a form (FormBuilder). So,

Code: Select all

function setCaptcha(){
if (request.readyState == 4){
	if (request.status == 200){
        responseXml = request.responseXML;
        xmlDoc = responseXml.documentElement;
        action = xmlDoc.getElementsByTagName("action")[0].firstChild.data;
		alert(action);
        if (action == 'ok'){
			b=true;
		}else{
			b=false;
			alert('Error!');
		}
    }
  }
}

url = "../php/get_captcha.php?cap="+m5ce14fbrp_captcha_phrase.value;
//		alert(url);
		createRequest();
		request.open("GET", url, false);
		request.onreadystatechange = function() {setCaptcha();};
		request.send(null);
PHP

Code: Select all

require '../include.php'; // (from site's root )
$cap=$_GET['cap'];
$captcha = &$gCms->getModuleInstance('Captcha');
if(is_object($captcha)){
$validated=$captcha->CheckCaptcha($cap);
if($validated==true)
	$response = '<?xml version="1.0" encoding="utf8" standalone="yes"?><response><action>ok</action></response>';
else $response = '<?xml version="1.0" encoding="utf8" standalone="yes"?><response><action>bad</action></response>';

} else $response = '<?xml version="1.0" encoding="utf8" standalone="yes"?><response><action>no object</action></response>';

header('Content-Type: text/xml');
echo $response;
But always $validated returns false. What's wrong???
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1921
Joined: Mon Jan 29, 2007 4:47 pm

Re: How to check Captcha?

Post by Jo Morg »

If you are using Form Builder and Captcha modules as designed FB already has built in Captcha integration afaik. Check demo templates for sample on how it is used. No need for all that...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
seregarem
Forum Members
Forum Members
Posts: 200
Joined: Sat Aug 28, 2010 1:03 pm

Re: How to check Captcha?

Post by seregarem »

I have no need to reload the page... I need to show an alert, after a submit button click...
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: How to check Captcha?

Post by calguy1000 »

a: We do not support accessing CMSMS API's externally like this.
b: This board is for people writing modules and contributing to CMSMS not for site developers.
c: This topic is related to third party modules. Not to the core.

Topic closed.
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.
Locked

Return to “Developers Discussion”