PDA

View Full Version : Adding Image Verification to a plugin


TheMilkCarton
16 Mar 2007, 17:44
Hi,

I've had this hack (http://www.vbulletin.org/forum/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.

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

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
17 Mar 2007, 20:02
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
19 Mar 2007, 14:27
bump. Still haven't figured it out.

TheMilkCarton
21 Mar 2007, 11:52
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:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

But I'm still not sure...

sebbe
21 Mar 2007, 12:06
Try this:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



or even



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

TheMilkCarton
21 Mar 2007, 12:17
I have... but what is the if conditional I need?? "if condition="!reg_imagecheck"" Or something?

I've gotten one step closer. I added

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

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..

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

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?