A question about a reply of yours on phpbb.com re: anti-bot

Requests and support for phpBB3 core and modifications.
Forum rules
NOTE: You may not re-post any of the information found within this forum without the express consent of me. Any websites that are found to have information posted from this forum, without my consent, will be forwarded to the appropriate authorities.

A question about a reply of yours on phpbb.com re: anti-bot

Postby Spider M. Mann » 14 Feb 2009, 09:33

Hello Rich,

I implemented your solution for integrating CoC's Anti-Bot Question mod into the guest reply of phpBB3 (phpbb.com/community/viewtopic.php?f=69&t=645075&start=435#p7915645), and it worked wonderfully, but in trying to port that solution to another mod, I ran into a small problem.

I am attempting to add the question to dyn's Mini Quick Reply mod, and was thinking about also adding it to Evil <3's Contact Board Administration mod. The problem is that instead of the set anti-bot question showing, only { AB_QUESTION } shows, and I can't track down the issue.

Here are the changes I have made to the Mini Quick Reply files:

In functions_quick_reply.php find:
Code: Select all
    // set subject
   $subject = ((strpos($topic_data['topic_title'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($topic_data['topic_title']);
   list($s_hidden_fields['subject'], $subject) = array($subject, ''); 

After Add:
Code: Select all
    //   BEGIN Anti-Bot question addon
   if ($config['enable_abquestion'] && !$user->data['is_registered'])
   {
      $user->add_lang('ucp');
      $ab_question = strtolower(request_var('ab_question', ''));

      if ($ab_question == '')
      {
         $error[] = $user->lang['AB_NO_ANSWER'];
      }
      elseif ($ab_question != strtolower($config['abanswer']) && $ab_question != strtolower($config['abanswer2']))
      {
         $error[] = $user->lang['AB_QUESTION_ERROR'];
      }
      else
      {
         $solved_abq = true;
      }

      $template->assign_vars(array(
         'S_AB_QUESTION'         => true,
         'L_AB_QUESTION'         => $config['abquestion'],
         'L_AB_QUESTION_EXPLAIN'   => $user->lang['AB_QUESTION_EXPLAIN'],
         'AB_QUESTION'         => $ab_question,
      ));
   }
    // END Anti-Bot question addon 


Add in posting_qr_body.html:
Code: Select all
          <dl>
            <dt><label for="ab_question">{L_AB_QUESTION}:</label><br /><span>{L_AB_QUESTION_EXPLAIN}</span></dt>
            <dd><input type="hidden" name="ab_question" value="{AB_QUESTION}" /></dd>
            <dd><input type="text" name="ab_question" id="ab_question" size="25" maxlength="255" tabindex="3" class="inputbox narrow" /></dd>
         </dl> 


It seems the 'L_AB_QUESTION' => $config['abquestion'], is not being passed for some reason, but I'll be damned if I can figure out why. Other than that, it functions normally - if I enter the correct answer, it processes normally, and if I give a wrong answer, or no answer, it throws the correct error.

Thanks for the help. This one has me stumped.
-Spider
Last edited by RMcGirr83 on 25 Feb 2009, 22:19, edited 1 time in total.
Reason: Changed topic icon
Spider M. Mann
 
Posts: 7
Joined: 14 Feb 2009, 09:18
Last Visit: 25 Feb 2009, 23:02

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby RMcGirr83 » 15 Feb 2009, 03:42

If you could post a link to the quick reply mod I'll take a look at the files and try and provide an answer.
Rich McGirr
Please don't PM me asking for support...use the forums
My Validated and Released Mods
Grateful for the mods/support? Then why not buy me a beer!.
Image
My Gamercard
My Gamercard
RMcGirr83
 
Posts: 1507
Joined: 01 Aug 2008, 15:20
Location: East Lyme, CT, US
Last Visit: Today, 06:50
Name: Rich McGirr

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby Spider M. Mann » 15 Feb 2009, 05:04

Sure thing. Here you go... and thanks for taking the time to look into it.

Mini Quick Reply
phpbb.com/community/viewtopic.php?f=69&t=937055

Pretty much any way to make the bot question portable is what I am shooting for, so I can replace the CAPCHA's where I can (I hate those things ;) ).
Spider M. Mann
 
Posts: 7
Joined: 14 Feb 2009, 09:18
Last Visit: 25 Feb 2009, 23:02

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby RMcGirr83 » 25 Feb 2009, 12:16

Rich McGirr
Please don't PM me asking for support...use the forums
My Validated and Released Mods
Grateful for the mods/support? Then why not buy me a beer!.
Image
My Gamercard
My Gamercard
RMcGirr83
 
Posts: 1507
Joined: 01 Aug 2008, 15:20
Location: East Lyme, CT, US
Last Visit: Today, 06:50
Name: Rich McGirr

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby Spider M. Mann » 25 Feb 2009, 16:56

Sorry, tried that, cleared the template cache and the main cache, and am still getting { AB_QUESTION }: displayed. I am truly baffled...

It's just the question that's not coming through; the L_AB_QUESTION_EXPLAIN comes through fine, and the functionality is normal, just no question. Sorry to be a downer. :(
Spider M. Mann
 
Posts: 7
Joined: 14 Feb 2009, 09:18
Last Visit: 25 Feb 2009, 23:02

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby RMcGirr83 » 25 Feb 2009, 17:01

:?

Seems to work on my test forum.

Perhaps you could post up functions_quick_reply.php as well as the qr_whatever.html file so I can take a look to see where the problem may be (please use the code bbcode tags)?
Rich McGirr
Please don't PM me asking for support...use the forums
My Validated and Released Mods
Grateful for the mods/support? Then why not buy me a beer!.
Image
My Gamercard
My Gamercard
RMcGirr83
 
Posts: 1507
Joined: 01 Aug 2008, 15:20
Location: East Lyme, CT, US
Last Visit: Today, 06:50
Name: Rich McGirr

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby Spider M. Mann » 25 Feb 2009, 17:21

Sure...

functions_quick_reply.php
Code: Select all
<?php
/**
* Mini Quick Reply
* ( based on Evil Quick Reply )
*
* @package   phpBB3
* @version 1.0.0
* @Mini Quick Reply copyleft  (>) 2008 dyn
* @Evil Quick Reply copyright (c) 2007 eviL3
* @license   opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
   exit;
}

/**
* This function will load everything needed for the Mini quick reply
*
* @param int $topic_id
* @param int $forum_id
* @param array $topic_data
*/
function quick_reply($topic_id, $forum_id, &$topic_data)
{
   global $template, $user, $auth, $db;
   global $phpbb_root_path, $phpEx, $config;

   // Config for the Mini quick reply
   $qr_config = array(
      'enabled'         => true,    // Disable it easily
      'bbcodes'         => isset($config['mini_qr_bbcodes']) ? $config['mini_qr_bbcodes'] : false,
   );

   // do mini_qr_ prefixed of the config values exist in $config
   foreach (array_keys($qr_config) as $key)
   {
      if (isset($config['mini_qr_' . $key]))
      {
         $qr_config[$key] = $config['mini_qr_' . $key];
      }
   }

   // Check if user has reply permissions for this forum or the topic is locked (thanks damnian)
   if (!$auth->acl_get('f_reply', $forum_id) || ($topic_data['topic_status'] == ITEM_LOCKED && !$auth->acl_get('m_lock', $forum_id)) || !$qr_config['enabled'])
   {
      return;
   }

   // Hidden fields
   $s_hidden_fields = array(
      't'         => $topic_id,
      'f'         => $forum_id,
      'mode'      => 'reply',
      'lastclick'   => time(),
      'icon'      => 0,
   );

   // Set preferences
   $reply_prefs = array(
      'disable_bbcode'   => ($config['allow_bbcode'] && $user->optionget('bbcode')) ? false : true,
      'disable_smilies'   => ($config['allow_smilies'] && $user->optionget('smilies')) ? false : true,
      'disable_magic_url'   => false,
      'attach_sig'      => ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false,
      'notify'         => ($config['allow_topic_notify'] && ($user->data['user_notify'] || isset($topic_data['notify_status']))) ? true : false,
      'lock_topic'      => ($topic_data['topic_status'] == ITEM_LOCKED && $auth->acl_get('m_lock', $forum_id)) ? true : false,
   );

   foreach ($reply_prefs as $name => $value)
   {
      if ($value)
      {
         $s_hidden_fields[$name] = 1;
      }
   }

   // set subject
   $subject = ((strpos($topic_data['topic_title'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($topic_data['topic_title']);
   list($s_hidden_fields['subject'], $subject) = array($subject, '');

   // Confirmation code handling ( from posting.php )
   if ($config['enable_post_confirm'] && !$user->data['is_registered'])
   {
      // Show confirm image
      $sql = 'DELETE FROM ' . CONFIRM_TABLE . "
         WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
            AND confirm_type = " . CONFIRM_POST;
      $db->sql_query($sql);

      // Generate code
      $code = gen_rand_string(mt_rand(5, 8));
      $confirm_id = md5(unique_id($user->ip));
      $seed = hexdec(substr(unique_id(), 4, 10));

      // compute $seed % 0x7fffffff
      $seed -= 0x7fffffff * floor($seed / 0x7fffffff);

      $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array(
         'confirm_id'   => (string) $confirm_id,
         'session_id'   => (string) $user->session_id,
         'confirm_type'   => (int) CONFIRM_POST,
         'code'         => (string) $code,
         'seed'         => (int) $seed,
      ));

      $db->sql_query($sql);

      $template->assign_vars(array(
         'S_CONFIRM_CODE'   => true,
         'CONFIRM_ID'      => $confirm_id,
         'CONFIRM_IMAGE'      => '<img src="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=confirm&amp;id=' . $confirm_id . '&amp;type=' . CONFIRM_POST) . '" alt="" title="" />',
      ));
   }

   //     BEGIN ABD question addon
   if ($config['enable_abquestion'] && !$user->data['is_registered'])
   {
      $user->add_lang('ucp');
      $ab_question = '';
      $template->assign_vars(array(
         'S_AB_QUESTION'                => true,
         'L_AB_QUESTION'                => $config['abquestion'],
         'L_AB_QUESTION_EXPLAIN'        => $user->lang['AB_QUESTION_EXPLAIN'],
         'AB_QUESTION'                => $ab_question,
      ));
   }

   // new RC6/RC7 stuff
   add_form_key('posting');

   // Page title & action URL, include session_id for security purpose
   $s_action = append_sid("{$phpbb_root_path}posting.$phpEx", false, true, $user->session_id);

  // Add other bbcodes ( from posting.php )
  $bbcode_status      = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false;
   $img_status            = ($bbcode_status && $auth->acl_get('f_img', $forum_id)) ? true : false;
   $url_status            = ($config['allow_post_links']) ? true : false;
   $flash_status         = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash']) ? true : false;
   $quote_status         = ($auth->acl_get('f_reply', $forum_id)) ? true : false;

   // Assign template variables
   $template->assign_vars(array(
      'S_QR_HIDDEN_FIELDS'   => build_hidden_fields($s_hidden_fields),
      'S_QR_POST_ACTION'      => $s_action,
      'S_QR_ENABLED'            => $qr_config['enabled'],
      'S_BBCODE_IMG'            => $img_status,
      'S_BBCODE_URL'            => $url_status,
      'S_LINKS_ALLOWED'         => $url_status,
      'S_BBCODE_FLASH'         => $flash_status,
      'S_BBCODE_QUOTE'         => $quote_status
   ));

   // enable bbcodes only when board allows them
   // comment out display_custom_bbcodes(); if you don't want custom bbcodes
   if ($bbcode_status && $qr_config['bbcodes'])
   {
      $user->add_lang('posting');
      $template->assign_var('S_BBCODE_ALLOWED', true);
      display_custom_bbcodes();
   }
}

?>


posting_qr_body.html
Code: Select all
<div id="quick_reply">
   <form action="{S_QR_POST_ACTION}" method="post" id="postform">
      <div class="panel" id="postingbox">
         <div class="inner"><span class="corners-top"><span></span></span>

         <h3>{L_QUICK_REPLY}</h3>

         <fieldset class="fields1">
         <!-- IF S_BBCODE_ALLOWED -->
            <!-- INCLUDE posting_buttons.html -->
         <!-- ENDIF -->

         <div id="message-box-qr">
            <textarea name="message" id="message" rows="8" cols="76" class="inputbox">{MESSAGE}</textarea>
         </div>

         </fieldset>

         <span class="corners-bottom"><span></span></span></div>
      </div>

      <!-- IF not S_USER_LOGGED_IN -->
   <div class="panel">
      <div class="inner"><span class="corners-top"><span></span></span>

      <fieldset class="fields2">
         <dl>
            <dt><label for="username">{L_USERNAME}:</label></dt>
            <dd><input type="text" name="username" id="username" size="25" maxlength="30" class="inputbox medium" title="{L_YOUR_NAME}" /></dd>
            <dd>{L_YOUR_NAME_EXPLAIN}</dd>
         </dl>

         <!-- IF S_CONFIRM_CODE -->
         <dl>
            <dt><label for="confirm_code">{L_CONFIRM_CODE}:</label></dt>
            <dd><input type="hidden" name="confirm_id" value="{CONFIRM_ID}" />{CONFIRM_IMAGE}</dd>
            <dd><input type="text" name="confirm_code" id="confirm_code" size="8" maxlength="8" class="inputbox narrow" title="{L_CONFIRM}" /></dd>
            <dd>{L_CONFIRM_CODE_EXPLAIN}</dd>
         </dl>
         <!-- ENDIF -->
         <!-- IF S_AB_QUESTION -->
         <dl>
            <dt><label for="ab_question">{L_AB_QUESTION}:</label><br /><span>{L_AB_QUESTION_EXPLAIN}</span></dt>
            <dd><input type="hidden" name="ab_question" value="{AB_QUESTION}" /></dd>
            <dd><input type="text" name="ab_question" id="ab_question" size="25" maxlength="255" tabindex="3" class="inputbox narrow" /></dd>
         </dl>
         <!-- ENDIF -->
      </fieldset>
      
      <span class="corners-bottom"><span></span></span></div>
   </div>
      <!-- ENDIF -->

      <div class="panel bg2">
         <div class="inner"><span class="corners-top"><span></span></span>

         <fieldset class="submit-buttons">
            {S_FORM_TOKEN}
            {S_QR_HIDDEN_FIELDS}
            <input type="submit" name="preview" value="{L_PREVIEW}" class="button1" onclick="document.getElementById('postform').action += '#preview';" />&nbsp;
            <input type="submit" name="post" value="{L_SUBMIT}" class="button1" accesskey="s" />
         </fieldset>

         <span class="corners-bottom"><span></span></span></div>
      </div>
   </form>
</div>
<script type=text/javascript>
window.onload = document.getElementById('message').blur;
</script>
Spider M. Mann
 
Posts: 7
Joined: 14 Feb 2009, 09:18
Last Visit: 25 Feb 2009, 23:02

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby Spider M. Mann » 25 Feb 2009, 17:27

It seems that the AB Question is being displayed above the confirmation code in the quick reply for some reason... not sure why that is surviving the cache purges. Maybe that may be a clue...
Spider M. Mann
 
Posts: 7
Joined: 14 Feb 2009, 09:18
Last Visit: 25 Feb 2009, 23:02

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby RMcGirr83 » 25 Feb 2009, 18:10

What is this?

Code: Select all
<script type=text/javascript>
window.onload = document.getElementById('message').blur;
</script>


..and can you provide a link to your forum (preferably one that allows guest posting ;) ).
Rich McGirr
Please don't PM me asking for support...use the forums
My Validated and Released Mods
Grateful for the mods/support? Then why not buy me a beer!.
Image
My Gamercard
My Gamercard
RMcGirr83
 
Posts: 1507
Joined: 01 Aug 2008, 15:20
Location: East Lyme, CT, US
Last Visit: Today, 06:50
Name: Rich McGirr

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby Spider M. Mann » 25 Feb 2009, 18:28

I'm testing on local host, so I don't have a live link. If you would like, I can set this up on my live site -- as a matter of fact, let me do that. Give me a few minutes and I'll post a link.

The javascript element is in the original posting_qr_body.html template file included with the Mini Quick Reply MOD, so I have no idea what it's for.
Spider M. Mann
 
Posts: 7
Joined: 14 Feb 2009, 09:18
Last Visit: 25 Feb 2009, 23:02

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby Spider M. Mann » 25 Feb 2009, 19:14

OK, looks good on my live site, not sure why locally it's not purging correctly. So that's good.
However, the functionality is now broken. A wrong or missing answer allows the post to go through.

*EDIT* Nevermind... I'm an idiot. I forgot the original edits to the posting.php file. Your edits work perfectly. Thank you very much for putting up with my dumb mistakes. Again, your solution works exactly as it should.

Check it out at: shadowcaste.com/viewtopic.php?f=7&t=17

Thank you once again for your time. :)
Spider M. Mann
 
Posts: 7
Joined: 14 Feb 2009, 09:18
Last Visit: 25 Feb 2009, 23:02

Re: A question about a reply of yours on phpbb.com re: anti-bot

Postby RMcGirr83 » 25 Feb 2009, 22:19

:)

Good to hear!!

Enjoy!!
Rich McGirr
Please don't PM me asking for support...use the forums
My Validated and Released Mods
Grateful for the mods/support? Then why not buy me a beer!.
Image
My Gamercard
My Gamercard
RMcGirr83
 
Posts: 1507
Joined: 01 Aug 2008, 15:20
Location: East Lyme, CT, US
Last Visit: Today, 06:50
Name: Rich McGirr


Return to phpBB3 Modifications - Requests - Support

Who is online

Users browsing this forum: No registered users and 2 guests

OSUOSL Friend   W3c Valid   Powered by phpBB