PHP Bulletin Board Home
News About Home
Features of phpBB Test drive phpBB Downloads Support for phpBB The phpBB Community Styles for customising phpBB 3rd party modifications to phpBB

Support Home | Knowledge Base Home | Submit Article | Search Articles | Browse Articles
 Users can't see Visual Confirmation in my template 
Description: Testing your templates for compatibility with Visual Confirmation
Author: espicom
Date: Mon Aug 29, 2005 4:32 pm
Type: HowTo
Keywords: visual confirmation, template
Category: Installing/upgrading/converting
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.

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:
<?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 emove the /* */ around the code, if you want it to enter the settings

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

Username: Password:
News | Features | Demo | Downloads | Support | Community | Styles | Mods | Links | Merchandise | About | Home
 © Copyright 2002 The phpBB Group.