vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Adding Image Verification to a plugin (https://vborg.vbsupport.ru/showthread.php?t=142216)

TheMilkCarton 03-16-2007 03:44 PM

Adding Image Verification to a plugin
 
Hi,

I've had this hack 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
Quote:

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:

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
Quote:

{
$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
Quote:

"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:

// ### 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:
PHP Code:

eval(standard_error(fetch_error('register_imagecheck'))); 

or even

PHP Code:

eval(print_standard_redirect('register_imagecheck'truetrue)); 


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
Code:

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

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?


All times are GMT. The time now is 09:56 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02198 seconds
  • Memory Usage 1,743KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete