You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 76 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Adding Template Switches [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
foxyfemfem
Support Staff
Support Staff


Joined: Jan 23, 2003
Posts: 668

Location: USA

PostPosted: Fri Apr 11, 2003 2:28 pm Reply with quoteBack to top

Hello,

I want to add a switch to my profile_add_body.tpl

The required codes to make the switch work has been added to the appropriate php files. Everything work, no error messages. When I added the switch code to the template it doesn't appear.

How can I add a switch to show up in the templates? Here's the code that make the switch turn on for unregistered or logged out users and turn off for registered login users.
Code:
<!-- BEGIN switch_validation -->
<tr>
<td class="catSides" colspan="2" height="28">&</td>
</tr>
<tr>
<th class="thSides" colspan="2" height="12" valign="middle">{L_VALIDATION}</th>
</tr>
<tr>
<td class="row1" valign="top"><span class="gen">{L_VALIDATION}:<br /></span><span class="gensmall">{L_VALIDATION_EXPLAIN}</span></td>
<td class="row2" align="center"><span class="gen"><img src="{S_ANTI_ROBOT1}" alt="" border="0"><img src="{S_ANTI_ROBOT2}" alt="" border="0"><img src="{S_ANTI_ROBOT3}" alt="" border="0"><img src="{S_ANTI_ROBOT4}" alt="" border="0"><img src="{S_ANTI_ROBOT5}" alt="" border="0"><br /><br /><input type="text" name="reg_key" maxlength="5" size="6"></span></td>
</tr>
<!-- END switch_validation -->
This is a simple anti robotic code switch that produce random letters for unregistered user to input upon registration. I'm trying to eliminate the Your Account registration if users can register via the forum. Yet, I want them to use the anti robotic code to do so (note: the forum is also setup for account activation as well)

This is the php file that generate the letters randomly (thinking something need to be modified here to work with phpnukebb)
Code:
function gen_reg_key()
{
   $key = "";
   $max_length_reg_key = 5;
   $chars = array(
      "a","b","c","d","e","f","g","h","i","j","k","l","m",
      "n","o","p","q","r","s","t","u","v","w","x","y","z");

   $count = count($chars) - 1;

   srand((double)microtime()*1000000);

   for($i = 0; $i < $max_length_reg_key; $i++)
   {
      $key .= $chars[rand(0, $count)];
   }

   return($key);
}

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_PROFILE,);
init_userprefs($userdata);
//
// End session management
//

if( !isset($HTTP_GET_VARS['id']) )
{
   die('Lack of information');
}

$id = intval($HTTP_GET_VARS['id']);

if ( ($id < 1) or ($id > 5) )
{
   die('Bad request');
}

// Get the properly char in key
$sql = "SELECT * FROM " . nuke_bbanti_robotic_reg . "
      WHERE session_id = '" . $userdata['session_id'] . "'";

if( !$result = $db->sql_query($sql) )
{
   die('Cannot obtain information from the database');
}

if( $db->sql_numrows($result) == 0 )
{
   $reg_key = gen_reg_key();

   $sql = "INSERT INTO ". nuke_bbanti_robotic_reg . "
         VALUES ('" . $userdata['session_id'] . "', '" . $reg_key . "', '" . time() . "')";
   if( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, 'Could not check registration information', '', __LINE__, __FILE__, $sql);
   }

   $sql = "SELECT * FROM " . nuke_bbanti_robotic_reg . "
         WHERE session_id = '" . $userdata['session_id'] . "'";

   if( !$result = $db->sql_query($sql) )
   {
      die('Cannot obtain information from the database');
   }
}

$reg_row = $db->sql_fetchrow($result);

$char = $reg_row['reg_key'][$id - 1];

// No Cache
header ("Expires: Sat, 10 Dec 1983 07:00:00 GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
header ("Pragma: no-cache");                          // HTTP/1.0

// Send Image
header('Content-Disposition: inline; filename=smartor.gif');
header('Content-type: image/gif');
readfile('images/anti_robotic_reg/anti_robotic_reg_' . $char . '.gif');
Find all posts by foxyfemfemView user's profileSend private message
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.195 Seconds - 333 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::