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



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
3 - 2 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     

Re: Captcha problem when multiple instances on page
by tank1955 on 2009/10/25 14:16:06

Even though I figured out a hack to make the image id's unique the first image is still overwritten by the second image.
Re: Captcha problem when multiple instances on page
by tank1955 on 2009/10/25 13:30:29

You are correct ghia. That is actually where I started. As I worked through how the class is supposed to work I eventually narrowed it down to the setConfig method that appears to be the problem.

The image.php file contains the code which renders the image and makes the tag assignment. Here is the specific code I am looking at:

le="color: #000000"><?php function loadImage() { $ret = "<img id='" . ($this->config['name']) . "' src='" . XOOPS_URL . "/" . $this->config["imageurl"] . "' onclick="this.src='" . XOOPS_URL . "/" . $this->config["imageurl"] . "?refresh='+Math.random()"."" style='cursor: pointer; vertical-align: middle;' alt='' />"; return $ret; }


From what I have been able to figure out I believe that once the "name" value is assigned in the config array contained in the config.php it can not be changed. This is based on the following found in xoopscaptcha.php:

le="color: #000000"><?php function setConfig($name, $val) { if (isset($this->$name)) { $this->$name = $val; } else { $this->config[$name] = $val; } return true; }


As soon as the config array is loaded $this->name is also assigned so performing the setConfig can reassign $this->name but not $this->config["name"].
Re: Captcha problem when multiple instances on page
by ghia on 2009/10/24 18:20:55

Is the name not to be added as second argument in the new XoopsFormCaptcha?
le="color: #000000"><?php XoopsFormCaptcha($caption = '', $name = 'xoopscaptcha', $skipmember = true, $configs = array())
Captcha problem when multiple instances on page
by tank1955 on 2009/10/24 15:57:29

For next version of ShoutBox module I thought I would revisit the use of captcha images for anonymous posts. By rights the image id tag of the captcha image should be unique so there are no conflicts if another instance appears on the same page. For example, the person who reported this had defined the shoutbox block to appear in the Right column on All Pages. Therefore it would appear on the Registration page which also employs captcha. So now we have two instances of captcha but both images have the same id tag, which is the default one provided in the class config file.

I am working with 2.3.3 as I explore this issue. I thought it should be as simple as calling setConfig() but it appears not. Here is what my code looks like in the block.

le="color: #000000"><?php include_once(XOOPS_ROOT_PATH.'/class/xoopsform/formcaptcha.php'); $shoutcaptcha = new XoopsFormCaptcha(); $result = $shoutcaptcha->setConfig('name','shoutboxcaptcha'); $block['captcha_caption'] = $shoutcaptcha->getCaption(); $block['captcha_render'] = $shoutcaptcha->render();


Calling setConfig appears to have no affect on the config value. Am I overlooking something?

Who's Online

821 user(s) are online (752 user(s) are browsing Support Forums)


Members: 0


Guests: 821


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