phpbb_confirm_handler.php

Support for the phpbbmodders_lib.
User avatar
Crispy
New member
New member
Posts: 43
Joined: 10 Aug 2008, 12:57
Real name: Clive

phpbb_confirm_handler.php

Postby Crispy » 19 Aug 2008, 14:55

I under stand this file can be used as a captcha for a form.
I have saved it in my phpbb3root/includes folder
I'm guessing i have to include this file in my page somewhere, could you give me some pointers of getting it working. :)
Last edited by Crispy on 19 Aug 2008, 15:10, edited 1 time in total.

User avatar
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Re: phpbb_confirm_handler.php

Postby igorw » 19 Aug 2008, 15:09

Documentation on-demand :roll: :P :lol: 8-)

First we need to include the file:

Code: Select all

include($phpbb_root_path . 'includes/lib/phpbb_confirm_handler.' . $phpEx);


Now, we'll need a confirm_type. These are defined in includes/constants.php:

Code: Select all

// Confirm types
define('CONFIRM_REG', 1);
define('CONFIRM_LOGIN', 2);
define('CONFIRM_POST', 3);


So let's add our own:

Code: Select all

define('CONFIRM_CONTACT', 666); // 666 - the number of the contact form


Now, let's create a new confirm object, and pass our new constant to the constructor:

Code: Select all

$phpbb_confirm = new phpbb_confirm_handler(CONFIRM_CONTACT);


Now, we need to get $confirm_id and $confirm_code from the user (they are sent with the form):

Code: Select all

$confirm_id      = request_var('confirm_id', '');
$confirm_code   = request_var('confirm_code', '');


Now, if the form has been submitted, we check if the code is correct, $error is an array that will hold our errors:

Code: Select all

if (!$confirm_id || !$phpbb_confirm->check($confirm_id, $confirm_code))
{
   $error[] = $user->lang['CONFIRM_CODE_WRONG'];
}


Now, in case the form wasn't submitted or there was an error, we want to display our confirm image and add the confirm_id to our hidden fields:

Code: Select all

$confirm_image = $phpbb_confirm->confirm_image($config['contact_max_attempts'], $confirm_id);
$s_hidden_fields = build_hidden_fields(array('confirm_id' => $confirm_id));


Now you have to assign these two as template variables and you're done. ;)

User avatar
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Re: phpbb_confirm_handler.php

Postby igorw » 19 Aug 2008, 15:11

Oh, and here's the section in our contact form template responsible for the confirm code:

Code: Select all

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

   <h3>{L_CONTACT_CONFIRM}</h3>

   <p>{L_CONTACT_CONFIRM_EXPLAIN}</p>

   <fieldset class="fields2">
   <dl>
      <dt><label for="confirm_code">{L_CONFIRM_CODE}:</label></dt>
      <dd>{CONFIRM_IMG}</dd>
      <dd><input type="text" name="confirm_code" id="confirm_code" size="8" maxlength="8" class="inputbox narrow" title="{L_CONTACT_CONFIRM}" tabindex="6" /></dd>

      <dd>{L_CONFIRM_CODE_EXPLAIN}</dd>
   </dl>
   </fieldset>

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

S_CONFIRM_CODE is assigned automatically by the class. The language vars will have to be adjusted though. ;)

Jyujinkai
New member
New member
Posts: 3
Joined: 24 Jan 2009, 08:45

Re: phpbb_confirm_handler.php

Postby Jyujinkai » 25 Jan 2009, 13:54

Hi...

I am new to phpbb coding and I am trying to place a captcha test on a form i have written for my board.

Anyway I can not understand how this is ment to work and how to incorperate it into my current files.

Here is the PHP File that you place in ROOT

Code: Select all

<?php

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);


// start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('posting');


// variable definition
$page_title = "Application Form";


// app detail
$cname = $_POST['charname'];
$class = $_POST['charclass'];
$spec = $_POST['specratio'];
$serv = $_POST['realm'];
$carmory = $_POST['chararmory'];
$cemail = $_POST['playeremail'];
$age = $_POST['ageid'];
$vent = $_POST['ventid'];
$raidsch = $_POST['raidsch'];
$prevguild = $_POST['prevguild'];
$raidexp = $_POST['preraidexp'];
$reference = $_POST['reference'];
$whyapp = $_POST['whyapp'];
$addinfo = $_POST['addinfo'];
$gearset = $_POST['gearset'];
$wwsreport = $_POST['wwsreport'];
$canswer1 = $_POST['canswer1'];
$canswer2 = $_POST['canswer2'];
$canswer3 = $_POST['canswer3'];
$classmod = $_POST['clasmod'];


// format message body and subject
$message = "[color=#40FF00][b]Character name : [/b][/color] [armory=" . $_POST['realm'] . "]" . $cname . "[/armory] \n" . "[color=#40FF00][b]Character class : [/b][/color]" . $class . "\n" . "[color=#40FF00][b]Realm : [/b][/color]" . $_POST['realm'] . "\n" . "[color=#40FF00][b]Armory link : [/b][/color][url]" . $carmory . "[/url]" . "\n" . "[color=#40FF00][b]Contact email: [/b][/color]" . $cemail . "\n" . "\n" . "[color=#40FF00][b]Age: [/b][/color]" . $age . "\n" . "[color=#40FF00][b]Vent, Threat Meter and Boss Mod: [/b][/color]" . $vent . "\n". "\n" . "[color=#40FF00][b]Conflict with raiding schedule : [/b][/color]" . "\n" . $_POST['raidsch'] . "\n" . "\n" . "[color=#40FF00][b]Previous guilds information : [/b][/color]" . "\n" . $prevguild . "\n" . "\n" . "[color=#40FF00][b]What Class specific Mods do you use? : [/b][/color]" . "\n" . $classmod . "\n" . "\n" . "[color=#40FF00][b]Previous raiding experience : [/b][/color]" . "\n" . $raidexp . "\n" . "\n" . "[color=#40FF00][b]Other gear sets : [/b][/color]" . "\n" . $_POST['gearset'] . "\n" . "\n" . "[color=#40FF00][b]Additional information : [/b][/color]" . "\n" . $addinfo . "\n" . "\n" ;
$subject = $class . " - " . $cname . " - " . $spec;
$submit = (isset($_POST['submit'])) ? true : false;


// the forum ID that the app is going to be posted
$forum_id = 5;


// submit the post
if ($submit)
{
  if ( $message != '' )

    // variables to hold the parameters for submit_post
    $poll = $uid = $bitfield = $options = '';

    generate_text_for_storage($subject, $uid, $bitfield, $options, false, false, false);
    generate_text_for_storage($message, $uid, $bitfield, $options, true, true, true);

    $data = array(
       'forum_id'              => 5,
       'icon_id'               => false,

       'enable_bbcode'         => true,
       'enable_smilies'        => true,
       'enable_urls'           => true,
       'enable_sig'            => true,

       'message'               => $message,
       'message_md5'           => md5($message),
                
       'bbcode_bitfield'       => $bitfield,
       'bbcode_uid'            => $uid,

       'post_edit_locked'      => 0,
       'topic_title'           => $subject,
       'notify_set'            => false,
       'notify'                => false,
       'post_time'             => 0,
       'forum_name'            => '',
       'enable_indexing'       => true,
    );

    submit_post('post', $subject, '', POST_NORMAL, $poll, $data);

    // forward to the front page
     header( 'Location: http://location.of.where.u.want.them.taken.2.after.submit.com' ) ;
}


// output the page
page_header($page_title);

$template->set_filenames(array(
   'body' => 'application.html')
);

make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));

page_footer();

?>


Here is the HTML File you place in /styles/themename/template

Code: Select all

<!-- INCLUDE overall_header.html -->

<script type="text/javascript" language="javascript">

</script> 

<table width="90%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr><td>

    <br />

    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td><span class="gen">Thank you for your application to THE END. Please fill out all the parts of the form correctly or your application will be instantly dismissed with out any attempt to evaluate you.</span><br />
            </td>
        </tr>
    </table>
       
    <br />

    <hr />

    <div id="app_content">
    <form name="send" action="{S_SEND_ACTION}" method="post">

    <table width="100%" border="0" cellpadding="1" cellspacing="1">
        <tr>
            <td><span class="gen">Character Name:<br /></span></td>
            <td><input name="charname" type="text" class="post" id="charname" size="25" /></td>
        </tr>
        <tr>
            <td><span class="gen">Class / Prefered Spec:<br /></span> </td>
            <td><select name="charclass" id="charclass">
                <option value="Druid - Restoration">Druid - Restoration</option>
                <option value="Druid - Feral">Druid - Feral</option>
                <option value="Druid - Balance">Druid - Balance</option>
                <option value="Hunter - Beast Mastery">Hunter - Beast Mastery</option>
                <option value="Hunter - Marksmanship">Hunter - Marksmanship</option>
                <option value="Hunter - Survival">Hunter - Survival</option>
                <option value="Mage - Arcane">Mage - Arcane</option>
                <option value="Mage - Fire">Mage - Fire</option>
                <option value="Mage - Frost">Mage - Frost</option>
                <option value="Paladin - Holy">Paladin - Holy</option>
                <option value="Paladin - Protection">Paladin - Protection</option>
                <option value="Paladin - Retribution">Paladin - Retribution</option>
                <option value="Priest - Holy">Priest - Holy</option>
                <option value="Priest - Discipline">Priest - Discipline</option>
                <option value="Priest - Shadow">Priest - Shadow</option>
                <option value="Rogue - Assassination">Rogue - Assassination</option>
                <option value="Rogue - Combat">Rogue - Combat</option>
                <option value="Rogue - Subtlety">Rogue - Subtlety</option>
                <option value="Shaman - Restoration">Shaman - Restoration</option>
                <option value="Shaman - Enhancement">Shaman - Enhancement</option>
                <option value="Shaman - Elemental">Shaman - Elemental</option>
                <option value="Warlock - Destruction">Warlock - Destruction</option>
                <option value="Warlock - Affliction">Warlock - Affliction</option>
                <option value="Warlock - Demonology ">Warlock - Demonology</option>
                <option value="Warrior - Protection">Warrior - Protection</option>
                <option value="Warrior - Fury">Warrior - Fury</option>
                <option value="Warrior - Arms">Warrior - Arms</option>
                <option value="Death Knight - Blood">Death Knight - Blood</option>
                <option value="Death Knight - Frost">Death Knight - Frost</option>
                <option value="Death Knight - Unholy">Death Knight - Unholy</option>
            </select></td>
        </tr>
        <tr>
            <td><span class="gen">Spec Ratios (xx/xx/xx):<br /></span></td>
            <td><input name="specratio" type="text" class="post" id="specratio" size="25" /></td>
        </tr>
        <tr>
            <td><span class="gen">Realm:<br /></span></td>
            <td><input name="realm" type="text" class="post" id="realm" size="25" /></td>
        </tr>
        <tr>
            <td><span class="gen">Armory Link in PvE Gear (Log out of WoW in your PvE Gear): <br /> </span></td>
            <td><input name="chararmory" type="text" class="post" id="chararmory" size="70" value="http://" /></td>
        </tr>
        <tr>
            <td><span class="gen">Contact Email: <br /></span></td>
            <td><input name="playeremail" type="text" class="post" id="playeremail" size="40" /></td>
        </tr>
        <tr>
            <td><span class="gen">Age:<br /></span> </td>
            <td><select name="ageid" id="ageid">
                <option value="16">16</option>
                <option value="17">17</option>
                <option value="18">18</option>
                <option value="19">19</option>
                <option value="20">20</option>
                <option value="21">21</option>
                <option value="22">22</option>
                <option value="23">23</option>
                <option value="24">24</option>
                <option value="25">25</option>
                <option value="26">26</option>
                <option value="27">27</option>
                <option value="28">28</option>
                <option value="29">29</option>
                <option value="30">30</option>
                <option value="31">31</option>
                <option value="32">32</option>
                <option value="33">33</option>
                <option value="34">34</option>
                <option value="35">35</option>
                <option value="36">36</option>
                <option value="37">37</option>
                <option value="38">38</option>
                <option value="39">39</option>
                <option value="40">40</option>
                <option value="41">41</option>
                <option value="42">42</option>
                <option value="43">43</option>
                <option value="44">44</option>
                <option value="45">45</option>
                <option value="46">46</option>
                <option value="47">47</option>
                <option value="48">48</option>
                <option value="49">49</option>
                <option value="50+">50+</option>
            </select></td>
        </tr>
        <tr>
            <td><span class="gen">Requirments to raid with us is Ventrillo and a working mic, a threat meter mod (we recommend <a href="http://www.wowinterface.com/downloads/info8459-OmenThreatMeter.html" TARGET="_blank">Omen Threat meter</a>) and a Boss Mod pack (we recommend <a href="http://www.wowinterface.com/downloads/info8814-DeadlyBossMods.html" TARGET="_blank">Deadly Boss Mods</a>). Do you have all these requirments met?:<br /></span> </td>
            <td><select name="ventid" id="ventid">
                <option value="Yes">Yes</option>
                <option value="No">No</option>
            </select></td>
        </tr>
    </table>

    <hr />


     <table width="100%" border="0" cellpadding="3" cellspacing="1">
        <tr>
            <td width="50%"><span class="gen">During progression we raid 3 days a week 5:00pm (GMT -8 / Stonemaul Local Server Time) and usually stopping around 8:00pm (GMT -8 / Stonemaul Local Server Time). Do you have any conflicts with this? You will be expected to retain a 75% attendance ratio. This mean being online on alts even if NOT in the raid for subs on certain bosses.</span></td>
            <td width="50%"><textarea class="post" name="raidsch" cols="50" rows="5" id="raidsch"></textarea></td>
        </tr>
        <tr>
            <td><span class="gen">What guilds (include server) have you been tagged under and what were your reasons for leaving them?</span></td>
            <td><textarea class="post" name="prevguild" cols="50" rows="5" id="prevguild"></textarea></td>
        </tr>
        <tr>
            <td><span class="gen">Please list any class specific Mods you use. (Eg:- <a href="http://www.wowinterface.com/downloads/info6096-HealBotcontinued.html" TARGET="_blank">Healbot</a>, <a href="http://www.wowinterface.com/downloads/info4937-Decursive.html" TARGET="_blank">Decursive</a>, <a href="http://www.wowinterface.com/downloads/info4676-Buffwatch.html" TARGET="_blank">Buffwatch++</a>) Some mods may be required for you to install to raid.</span></td>
            <td><textarea class="post" name="clasmod" cols="50" rows="5" id="clasmod"></textarea></td>
        </tr>
        <tr>
            <td><span class="gen">What raiding experience do you have, in Classic, TBC and WOTLK?</span></td>
            <td><textarea class="post" name="preraidexp" cols="50" rows="5" id="preraidexp"></textarea></td>
        </tr>
        <tr>
            <td><span class="gen">What sets of gear do you have besides the one shown on your armory?</span></td>
            <td><textarea class="post" name="gearset" cols="50" rows="5" id="gearset"></textarea></td>
        </tr>
        <tr>
            <td><span class="gen">Is there anything else you would like to add?</span></td>
            <td><textarea class="post" name="addinfo" cols="50" rows="5" id="addinfo"></textarea></td>
        </tr>
    </table>

    <hr />

    <br />

    <br />

    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="forumline">
        <tr>
            <td align="center"><input class="btnmain" type="submit" name="submit" value="{L_SUBMIT}" />&nbsp;&nbsp;<input class="btnlite" type="reset" value="{L_RESET}" /></td>
        </tr>
    </table>

    </form>
    </div>

</td></tr>
</table>

<br clear="all" />



<br clear="all" />

<div align="{S_CONTENT_FLOW_END}"><!-- INCLUDE jumpbox.html --></div>

<!-- INCLUDE overall_footer.html -->


Can you please give me some advise on how to do this?

Netboost
New member
New member
Posts: 2
Joined: 26 May 2009, 10:13
Real name: Matthieu Vandevyver
Location: Lauwe

Re: phpbb_confirm_handler.php

Postby Netboost » 26 May 2009, 10:15

Hi, where can i found this class?

found somewhere the class, but it gives errors...:
errors on this one: [url]http://svn2.assembla.com/svn/phpbbmodders_lib/phpbb_confirm_handler.php[/url]


Error:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in c:\************\includes\lib\phpbb_confirm_handler.php on line 24
Boost your business - http://www.netboost.be - webdesign, freelance, seo, e-commerce, hosting, it, ...

User avatar
Lord Le Brand
Website Team
Website Team
Posts: 223
Joined: 08 Sep 2006, 15:44
Real name: Leroy
Location: Parkstad, Limburg, the Netherlands (GMT+1)

Re: phpbb_confirm_handler.php

Postby Lord Le Brand » 26 May 2009, 10:34

probably, you are using PHP 4, which doesn't understnad what to do with "protected" or "public" etc. You need PHP 5 for this to work.
Image

Netboost
New member
New member
Posts: 2
Joined: 26 May 2009, 10:13
Real name: Matthieu Vandevyver
Location: Lauwe

Re: phpbb_confirm_handler.php

Postby Netboost » 26 May 2009, 11:43

Fixed it myself.
(solution: delete 'public', ... before var-declarations and functions)

edit: Idd :) Sorry, was reply'ing this topic before i saw your answer. Thanks anyway!! 8-)
Idd my old host (where my phpbb forum still is at the moment) uses php 4.
Boost your business - http://www.netboost.be - webdesign, freelance, seo, e-commerce, hosting, it, ...

User avatar
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Re: phpbb_confirm_handler.php

Postby igorw » 26 May 2009, 19:22

There is no real excuse for using PHP4. It's not even supported by the PHP group / zend anymore...


Return to “Library”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests