View Full Version : Adding Image Verification to a plugin
TheMilkCarton
03-16-2007, 03:44 PM
Hi,
I've had this hack (https://vborg.vbsupport.ru/showthread.php?t=126676) installed for awhile, but just recently started tackling a few of its shortcomings.
Namely, for Unregistered users to use the form, Guest Post Image Verification has to be disabled entirely.
So I started adding code to the plugin to get Image Verification, and I've been successful.. except for one thing: If the user enters the incorrect code and presses submit, it does NOT give this error like it should The string you entered for the image verification did not match what was displayed. The $vbphrase for it is "register_imagecheck" and I think there should be an "$errors[]=fetch_error" somewhere in there, but I just can't get it to work.
I'm really new to coding... so can anyone lend any hands? :)
I've added all the code in red. removed code, in case anyone tries taking credit for my upcoming hack :) I get the 'redirect_postthanks_moderate' redirect if I'm logged out (even if I enter the wrong image verification code), and the plugin takes me right to the thread it created if I'm logged in.
TheMilkCarton
03-17-2007, 06:02 PM
Anybody?
I figure I would need code in the format of this {
$vbulletin->url = 'forumdisplay.php?' . $vbulletin->session->vars['sessionurl'] . "f=$foruminfo[forumid]";
eval(print_standard_redirect('redirect_postthanks_ moderate', true, true));
}but with the variables changed..
I only need the error message to pop up when you enter the wrong verification code. :(
I guess I can just put a warning above the Image Verification telling users to double check the code they input, because it won't tell them if they've input the wrong one.. but that could lead to users submitting the same form over and over again if they're not sure they input the right code.
Argh.
TheMilkCarton
03-19-2007, 12:27 PM
bump. Still haven't figured it out.
TheMilkCarton
03-21-2007, 09:52 AM
Bump. In advance, excuse me for what will probably be improper terminology..
So the Form Hack uses the newthread_start hook, so I've been looking through newthread.php trying to find the code that shows "The string you entered for the image verification did not match what was displayed." and it's just not in there.. So does it call on a separate hook for this?
When using image verification in newthread or newreply, if the code you input is wrong, the "String did not match" error message pops up where the Preview of your post would. So this is all done inside of the same PHP file.. and the code has to be somewhere in there.. but I just can't seem to find it. So is there some "error" section in newthread.php or does it use the same code that clicking the Preview button does?
So, since no one is helping me with the big problem... does anybody at least have these answers?
I've at least found this code that might be what I want: // ### POST HAS ERRORS ###
$postpreview = construct_errors($errors); // this will take the preview's place
construct_checkboxes($newpost); But I'm still not sure...
sebbe
03-21-2007, 10:06 AM
Try this:
eval(standard_error(fetch_error('register_imageche ck')));
or even
eval(print_standard_redirect('register_imagecheck' , true, true));
TheMilkCarton
03-21-2007, 10:17 AM
I have... but what is the if conditional I need?? "if condition="!reg_imagecheck"" Or something?
I've gotten one step closer. I added if (sizeof($errors) > 0)
{
// ### POST HAS ERRORS ###
if ($vbulletin->GPC['ajax'])
{
require_once(DIR . '/includes/class_xml.php');
$xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
$xml->add_group('errors');
foreach ($errors AS $error)
{
$xml->add_tag('error', $error);
}
$xml->close_group();
$xml->print_xml();
}
else
{
$postpreview = construct_errors($errors); // this will take the preview's place
construct_checkboxes($newpost);
$_REQUEST['do'] = 'newreply';
$newpost['message'] = htmlspecialchars_uni($newpost['message']);
}
} but this was from newreply instead of newthread, because the code from newthread I tried didn't work...
But anyway, now if they get the Image Code wrong it redirects them to a blank box. (Instead of popping up a box with the error in the same window) So at least I'm getting somewhere. I'm a total n00b at coding, if you can't tell. :)
Yes yes yes yes yes. So I tried.. removed And it takes me to another page that says the register_imagecheck phrase. YAY. Now I just need to make sure everything else still works. :)
Is there a way to change it so that it ONLY evaluates that if !=='register_imagecheck' ? I don't want just any error causing it to give that message. Or will it?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.