PDA

View Full Version : Re-population of comment form on bad CAPTCHA code submission


jessenco
02-13-2007, 08:23 PM
Title says it all.
This save your users from loosing their comments if they submit a bad captcha code.
To solve this annoying event and spare some frustration to your users this little mod comes to the rescue.

Require Subdreamer 2.4 only

1- Make a backup copy of your original functions.php file found in includes/ folder.
2- Open functions.php
3- Near line 175 (if you do not have any mods installed in your file) find this:
(Please be very careful and makes sure you find the right piece of code. The php function that start with this commented line: // ########## DISPLAY COMMENT FORM ##############)

if(!$userinfo['loggedin'])
{
echo '<tr><td style="padding-bottom: 8px;">' . $sdlanguage['your_name'] . '</td></tr>
<tr><td style="padding-bottom: 8px;"><input type="text" size="' . $inputsize . '" name="com_username" value="" /></td></tr>';
}

Just after it, add this:

if($mainsettings['commentvvc'])
{
$vvcid = $_POST['com_vvcid'];
$code = $_POST['com_verifycode'];

if(!ValidVisualVerifyCode($vvcid, $code))
{
$tempcom = $_POST['com_comment'];
}
}

4- Find this (should be just next below):

echo '<tr><td style="padding-bottom: 8px;">' . $sdlanguage['comment'] . '</td></tr>
<tr><td style="padding-bottom: 8px;"><textarea name="com_comment" rows="5" cols="' . $inputsize . '"></textarea></td></tr>';

Replace with this:

echo '<tr><td style="padding-bottom: 8px;">' . $sdlanguage['comment'] . '</td></tr>
<tr><td style="padding-bottom: 8px;"><textarea name="com_comment" rows="5" cols="' . $inputsize . '">'. $tempcom . '</textarea></td></tr>';

Save/upload/enjoy!


Uninstallation: Replace functions.php with backup file.

Ziad
02-14-2007, 12:25 AM
Great stuff! Can we add this into our system?

jessenco
02-14-2007, 12:36 AM
Great stuff! Can we add this into our system?

Of course. :)

recon
03-13-2007, 08:54 AM
Excellent. I was looking for that.