Knowledge Base

Testing your templates for compatibility with Visual Confirmation
Article ID: 15
Written By: espicom
Written On: Mon Apr 23, 2007 9:24 am
Description: This article will help you test your templates to check they support Visual confirmation and if not help you fix them.
link to this article on phpbb.com: Select All
[kb=testing-your-templates-for-compatibility-with-visual-confirmation]Testing your templates for compatibility with Visual Confirmation[/kb]
link to this article on your own board: Select All
[url=http://www.phpbb.com/kb/article/testing-your-templates-for-compatibility-with-visual-confirmation/]Knowledge Base - Testing your templates for compatibility with Visual Confirmation[/url]

Overview
  • If you have recently upgraded to a post-2.0.10 version of PHPBB, there is a feature called "Visual Confirmation", which displays an image with text that a new user is supposed to read and type into a field on their membership application form, to confirm that they are a real person. However, many (most?) templates do not have the necessary changes to display the VC image to your users, or even allow you to activate it in the configuration screen.

Check Script
  • The following script will check all templates you have installed on your forum for the key phrases needed to display the VC image and configuration option. Save it as a text file on your local computer, then upload it to your PHPBB root directory as "template_check.php". You can execute it by pointing your browser at it, as in:

    http://www.mysite.com/forum/template_check.php

    (if your forum is at "www.mysite.com/forum")
  • Code: Select all
    <?php
    // read config file
    define('IN_PHPBB', true);
    $phpbb_root_path = './';
    $template_path= $phpbb_root_path . "templates/";
    include($phpbb_root_path . 'config.php');

    // connect to the database server
    $db = mysql_connect($dbhost,$dbuser,$dbpasswd);
    if (!$db) die("Unable to connect to database!\n");

    // select the PHPBB database
    mysql_select_db($dbname,$db);

    $sql = "SELECT config_value FROM ".$table_prefix."config WHERE config_name='enable_confirm'";
    $config = mysql_query($sql,$db);
    if (($config === false) or (mysql_num_rows($config) == 0))
    {
       echo "Configuration setting Visual Confirmation missing.<br>\n";
    //   remove the /* */ around this section to allow the program to add the configuration setting
    /*   $sql = "INSERT INTO ".$table_prefix."config (config_name,config_value) VALUES ('enable_confirm','1')";
       $config = mysql_query($sql,$db);
       if ($config !== false)
          echo "Successfully added Visual Confirmation to config table.<br>\n";
    */
    }
    else
    {
       $enconf = mysql_fetch_array($config);
       echo "Visual Confirmation is ";
       echo ($enconf['config_value'] == '0' ? "disabled" : "enabled");
       echo " in your configuration table<br>\n";
    }

    $sql = "SHOW TABLES LIKE '".$table_prefix."confirm'";
    $config = mysql_query($sql,$db);
    if (($config === false) or (mysql_num_rows($config) == 0))
    {
       echo $table_prefix."confirm table missing.<br>\n";
    //   remove the /* */ around this section to allow the program to add the confirm table
    /*   $sql = "CREATE TABLE ".$table_prefix."confirm (
          confirm_id char(32) NOT NULL default '',
          session_id char(32) NOT NULL default '',
          code char(6) NOT NULL default '',
          PRIMARY KEY  (session_id,confirm_id)
          ) TYPE=MyISAM";
       $config = mysql_query($sql,$db);
       if ($config !== false)
          echo "Successfully added Confirm table to database.<br>\n";
    */
    }
    else
    {
       echo $table_prefix."confirm table found.<br>\n";
    }

    $sql = "SELECT template_name, style_name FROM ".$table_prefix."themes";
    $styles = mysql_query($sql,$db);
    if ($styles === false)
       die("No styles found!\n");
    while ($check = mysql_fetch_array($styles))
    {
       $check_path1 = $template_path . $check['template_name'] . "/profile_add_body.tpl";
       $check_path2 = $template_path . $check['template_name'] . "/admin/board_config_body.tpl";
       $user_text = file_get_contents($check_path1);
       $user = strpos(strtolower($user_text),"switch_confirm");
       $config_text = file_get_contents($check_path2);
       $config = strpos(strtolower($config_text),"visual_confirm");
       echo "Style '".$check['style_name']."' ";
       echo $user > 0 ? "supports " : "does not support ";
       echo "Visual Confirmation for registration, ";
       echo $config > 0 ? "supports " : "does not support ";
       echo "Visual Confirmation configuration option.<br>\n";
    }
    ?>

  • Note: You will have to remove the /* */ around the code, if you want it to enter the settings

Fixes
  • Any templates that fail (tagged as "does not support") will need to have the visual confirmation support code added to them. In this next section, "block" refers to a section of the template, bounded by "<tr>" and "</tr>" tags, having a format similar to what you will be adding.
  • In admin/board_config_body.tpl, find the block for "L_ACCT_ACTIVATION", and add the following block below it:

    Code: Select all
       <tr>
          <td class="row1">{L_VISUAL_CONFIRM}<br /><span class="gensmall">{L_VISUAL_CONFIRM_EXPLAIN}</span></td>
          <td class="row2"><input type="radio" name="enable_confirm" value="1" {CONFIRM_ENABLE} />{L_YES}&nbsp; &nbsp;<input type="radio" name="enable_confirm" value="0" {CONFIRM_DISABLE} />{L_NO}</td>
       </tr>


  • In profile_add_body.tpl, find the block for "L_CONFIRM_PASSWORD", and add below it:

    Code: Select all
      <!-- Visual Confirmation -->
       <!-- BEGIN switch_confirm -->
       <tr>
          <td class="row1" colspan="2" align="center"><span class="gensmall">{L_CONFIRM_CODE_IMPAIRED}</span><br /><br />{CONFIRM_IMG}<br /><br /></td>
       </tr>
       <tr>
         <td class="row1"><span class="gen">{L_CONFIRM_CODE}: * </span><br /><span class="gensmall">{L_CONFIRM_CODE_EXPLAIN}</span></td>
         <td class="row2"><input type="text" class="post" style="width: 200px" name="confirm_code" size="6" maxlength="6" value="" /></td>
       </tr>
       <!-- END switch_confirm -->