<?php
/**
* @copyright 68 Classifieds
*
* @author 68 Designs, LLC
* @version $Revision: 314 $
* @package 68Classifieds
* @link http://www.68classifieds.com
*
* @Updated: $Date: 2009-04-13 11:12:47 -0400 (Mon, 13 Apr 2009) $
*/

/**
 * Manages user registration (new & modify)
 *
 */
class Register
{
    
/**
     * Instance of database connection class
     * 
     * @access private
     * @var object
     */
    
var $_db null;
    
    
/**
     * Class message - usually in case of a failure
     *
     * @var string
     * @access public
     */
    
var $msg '';
    
    
/**
     * User data of person attempting new/modify registration
     *
     * @var array
     * @access private
     */
    
var $_userData = array();
    
    
/**
     * Holds the value of the confirmation code used to validate email addresses
     *
     * @access private
     * @var string
     */
    
var $_confirmCode '';
    
    
/**
     * Contains unfiltered variables 
     *
     * @access private
     * @var array
     */
    
var $_dirtyVars = array();
    
    
/**
     * Contains filtered variables
     *
     * @access private
     * @var array
     */
    
var $_cleanVars = array();

    
/**
     * Register Constructor
     *
     * @param object database Database functions
     * @access public
     * @return object Register
     * @internal if $int===true then the session is checked
     */
    
function Register ($int true)
    {
        
$this->_db Library::loadDb();
        if (
$int === true) {
            
$this->_init();
        }
    }

    
/**
     * Initialize the register object
     *
     * @access private
     * @return void
     */
    
function _init ()
    {
        
//not currently used
    
}

    
/**
     * Used to get the user fields for modify account or validation email
     *
     * @access private
     * @param integer $id
     * @return boolean 
     */
    
function _getUserData ($id$override false)
    {
        if (! empty(
$this->_userData) && $override === false) {
            return 
$this->_userData;
        }
        
$sql 'SELECT * FROM ' PREFIX 'users WHERE id=' . (int) $id;
        
$result $this->_db->query($sql);
        if (
$result->size() != || $this->_db->isError()) {
            
$this->msg 'Invalid user id';
            return 
false;
        }
        
$this->_userData $result->fetch();
        return 
true;
    }

    
/**
     * Sets the user data
     *
     * @access public
     * @param array $userData
     * @return void
     * @internal can be used like $Register->setUserData(array(['id'] => 1));
     */
    
function setUserData ($userData)
    {
        
$this->_userData $userData;
    }

    
/**
     * Public method to set dirty vars
     * 
     * @access public
     * @return void
     */
    
function setDirtyVars ($userData)
    {
        
$this->_dirtyVars $userData;
    }

    
/**
     * Pubilc function to get the filtered "clean" variables
     *
     * @access public
     * @return array $_cleanVars
     */
    
function getCleanVars ()
    {
        return 
$this->_cleanVars;
    }

    
/**
     * Creates the confirmation code
     *
     * @access public
     * @param string $username
     * @return void
     */
    
function createCode ($username)
    {
        
srand((double) microtime() * 1000000);
        
$this->_confirmCode md5($username time() . rand(11000000));
    }

    
/**
     * Gets the confirmation code if it is needed externally
     *
     * @access public
     * @return string
     */
    
function getConfirmationCode ()
    {
        return 
$this->_confirmCode;
    }
    
    
/**
     * Gets the customers ip address
     *
     * @return unknown
     */
    
function getIP()
    {
        return 
$_SERVER['REMOTE_ADDR'];
    }
    
    
/**
     * Confirms a signup against the confirmation code. If it
     * matches, changes the user level.  Sent by email, and is required
     * by an optional setting.
     *
     * @access private
     * @param string $confirmCode 
     * @return     boolean
     * @internal should we use _getUserData here too? I think we should
     */
    
function confirm ($confirmCode)
    {
        
$sql 'SELECT uVerify FROM ' PREFIX 'users WHERE uVerify=' $this->_db->quoteInto($confirmCode);
        
$result $this->_db->query($sql);
        if (
$result->size() != || $this->_db->isError()) {
            return 
false;
        }
        
$result->freeResult();
        
$sql 'UPDATE ' PREFIX 'users SET level=2 WHERE uVerify=' $this->_db->quoteInto($confirmCode);
        
$result $this->_db->query($sql);
        if (
$result->affectedRows() != || $this->_db->isError()) {
            
$result->freeResult();
            return 
false;
        }
        
$modules Library::loadLibrary('Modules');
        
$modules->call_hook('user_confirm'$userDetails); // Call any module functions
        
$result->freeResult();
        return 
true;
    }

    
/**
     * Sends the confirmation email
     * 
     * @access private
     * @uses Mailer::sendMail()
     * @return boolean
     */
    
function _sendConfirmation ()
    {
        
$Mailer Library::loadLibrary('Mailer');
        
$to $this->_userData['email']; //user's email address
        
$vars['validateurl'] = URLS '/login.php?code=' $this->_confirmCode//build the url for validation
        
$vars['firstname'] = $this->_userData['firstname'];
        
$vars['lastname'] = $this->_userData['lastname'];
        
$content 'validate.tpl';
        if ((
$msg $Mailer->sendMail($to$content$vars)) === true) {
            return 
true;
        }
        return 
$msg;
    }

    
/**
     * Sends the confirmation email
     *
     * @access public
     * @param integer $id
     * @uses _sendConfirmation
     * @return boolean
     */
    
function sendConfirmation ($id)
    {
        
$this->_getUserData($id);
        return 
$this->_sendConfirmation();
    }

    
/**
     * Resends the confirmation email
     *
     * @access public
     * @param integer $id
     * @uses _sendConfirmation
     * @return boolean
     */
    
function resendConfirmation ($id)
    {
        
$this->_getUserData($id);
        
$this->createCode($this->_userData['username']);
        
$sql 'UPDATE ' PREFIX 'users ' 'SET 
                    uVerify=' 
$this->_db->quoteInto($this->_confirmCode) . 
                    WHERE id='
.$id;
        
$result $this->_db->query($sql);
        if (
$this->_db->isError()) {
            return 
false;
        }
        return 
$this->_sendConfirmation();
    }

    
/**
     * Checks if a username or email address is unique, if an id is supplied it 
     * will check to see if this username or email address is unique excluding 
     * what is already stored for this user.
     *
     * @access public
     * @param string $username
     * @param string $email
     * @param integer $id
     * @return boolean
     * @internal left public because it could be used via ajax
     */
    
function checkUnique ($username$email$id false)
    {
        
$where '';
        if (
$id !== false) {
            
$where 'AND id <> ' . (int) $id;
        }
        
$sql 'SELECT id FROM ' PREFIX 'users WHERE (username=' $this->_db->quoteInto($username) . ' OR email=' $this->_db->quoteInto($email) . ') ' $where;
        
$result $this->_db->query($sql);
        if (
$result->size() > || $this->_db->isError()) {
            return 
false;
        }
        return 
true;
    }

    
/**
     * Inserts a record into the users table
     *
     * @access public
     * @param array contains user details. See constants defined for array keys
     * @return boolean true on success
     * @uses createCode()
     * @uses Modules::call_hook()
     */
    
function createSignup ($userDetails$callHook TRUE)
    {
        
$this->_userData $userDetails//these should already be in safe form and just need escaping
        
$this->_userData['password'] = Login::hashPassword($this->_userData['password']); //need the hashed value
        
$this->createCode($this->_userData['username']); //create the verification code
        

        // First check login and email are unique in user table
        
if (! $this->checkUnique($this->_userData['username'], $this->_userData['email'])) {
            return 
3//return status code of 3
        
}
        
// Handle different types of permissions when adding a user
        
if (defined('IN_ADMIN')) {
            if (! 
$this->_adminUserSignup()) { //admin adding a user
                
return 2;
            } else {
                if (
$callHook === true) {
                    
$modules Library::loadLibrary('Modules');
                    
$modules->call_hook('admin_user_join'$userDetails); // Call any module functions
                
}
            }
        } else {
            if (! 
$this->_userSignup()) { //user adding themself
                
return 2;
            } else {
                if (
$callHook === true) {
                    
$modules Library::loadLibrary('Modules');
                    
$modules->call_hook('user_join'$userDetails); // Call any module functions
                
}
            }
        }
        
//user has been added
        
return 1;
    }

    
/**
     * Creates a user from administration panel
     *
     * @access private
     * @return boolean
     * @internal $this->_userData must be set with appropriate variables & filtering
     */
    
function _adminUserSignup ()
    {
        if (! empty(
$this->_userData['adminCapabilities'])) {
            
$adminCapabilities 'adminCapabilities=' $this->_db->quoteInto(serialize($this->_userData['adminCapabilities'])) . ',';
        }
        
//build the query
        
$sql 'INSERT INTO ' PREFIX 'users ' 'SET 
                    username=' 
$this->_db->quoteInto($this->_userData['username']) . ', 
                    password=' 
$this->_db->quoteInto($this->_userData['password']) . ', 
                    custip=' 
$this->_db->quoteInto($this->_userData['custip']) . ', 
                    email=' 
$this->_db->quoteInto($this->_userData['email']) . ', 
                    firstname=' 
$this->_db->quoteInto($this->_userData['firstname']) . ', 
                    lastname=' 
$this->_db->quoteInto($this->_userData['lastname']) . ', 
                    address=' 
$this->_db->quoteInto($this->_userData['address']) . ', 
                    city=' 
$this->_db->quoteInto($this->_userData['city']) . ', 
                    state=' 
$this->_db->quoteInto($this->_userData['state']) . ', 
                    zip=' 
$this->_db->quoteInto($this->_userData['zip']) . ', 
                    country=' 
$this->_db->quoteInto($this->_userData['country']) . ', 
                    phone=' 
$this->_db->quoteInto($this->_userData['phone']) . ', 
                    newsletter=' 
$this->_db->quoteInto($this->_userData['newsletter']) . ', 
                    extra=' 
$this->_db->quoteInto($this->_userData['extra']) . ', 
                    extra2=' 
$this->_db->quoteInto($this->_userData['extra2']) . ', 
                    extra3=' 
$this->_db->quoteInto($this->_userData['extra3']) . ', 
                    level=' 
$this->_db->quoteInto($this->_userData['level']) . ', 
                    uVerify=' 
$this->_db->quoteInto($this->_confirmCode) . ', 
                    joindate=NOW(), 
                    '
$adminCapabilities .'
                    b_firstname=' 
$this->_db->quoteInto($this->_userData['b_firstname']) . ', 
                    b_lastname=' 
$this->_db->quoteInto($this->_userData['b_lastname']) . ', 
                    b_address=' 
$this->_db->quoteInto($this->_userData['b_address']) . ', 
                    b_city=' 
$this->_db->quoteInto($this->_userData['b_city']) . ', 
                    b_state=' 
$this->_db->quoteInto($this->_userData['b_state']) . ', 
                    b_zip=' 
$this->_db->quoteInto($this->_userData['b_zip']) . ', 
                    b_country=' 
$this->_db->quoteInto($this->_userData['b_country']) . ', 
                    b_phone=' 
$this->_db->quoteInto($this->_userData['b_phone']) . ', 
                    b_same=' 
$this->_db->quoteInto($this->_userData['b_same']);
        
$result $this->_db->query($sql);
        if (
$this->_db->isError()) {
            return 
false;
        }
        
$this->_userId $result->insertID();
        return 
true;
    }

    
/**
     * Creates a user from front-end registration page (userjoin.php)
     *
     * @access private
     * @return boolean
     * @internal $this->_userData must be set with appropriate variables & filtering
     */
    
function _userSignup ()
    {
        
//build the query
        
$sql 'INSERT INTO ' PREFIX 'users ' 'SET 
                    username=' 
$this->_db->quoteInto($this->_userData['username']) . ', 
                    password=' 
$this->_db->quoteInto($this->_userData['password']) . ', 
                    custip=' 
$this->_db->quoteInto($this->getIP()) . ', 
                    email=' 
$this->_db->quoteInto($this->_userData['email']) . ', 
                    firstname=' 
$this->_db->quoteInto($this->_userData['firstname']) . ', 
                    lastname=' 
$this->_db->quoteInto($this->_userData['lastname']) . ', 
                    address=' 
$this->_db->quoteInto($this->_userData['address']) . ', 
                    city=' 
$this->_db->quoteInto($this->_userData['city']) . ', 
                    state=' 
$this->_db->quoteInto($this->_userData['state']) . ', 
                    zip=' 
$this->_db->quoteInto($this->_userData['zip']) . ', 
                    country=' 
$this->_db->quoteInto($this->_userData['country']) . ', 
                    phone=' 
$this->_db->quoteInto($this->_userData['phone']) . ', 
                    newsletter=' 
$this->_db->quoteInto($this->_userData['newsletter']) . ', 
                    extra=' 
$this->_db->quoteInto($this->_userData['extra']) . ', 
                    extra2=' 
$this->_db->quoteInto($this->_userData['extra2']) . ', 
                    extra3=' 
$this->_db->quoteInto($this->_userData['extra3']) . ', 
                    level=' 
$this->_db->quoteInto($this->_userData['level']) . ', 
                    uVerify=' 
$this->_db->quoteInto($this->_confirmCode) . ', 
                    joindate=NOW()'
;
        
$result $this->_db->query($sql);
        if (
$this->_db->isError()) {
            return 
false;
        }
        
$this->_userId $result->insertID();
        return 
true;
    }

    
/**
     * Filter user submitted data
     * 
     * 0 values are preserved, empty values other than 0 are converted to '', all html
     * gets converted and tags removed. Array keys match the _dirtyVars keys
     * 
     * @access public
     * @uses strip_tags
     * @uses Filter::nonTagHtmlEntities
     * @return void
     */
    
function filterUserData ()
    {
        foreach (
$this->_dirtyVars as $key => $value) {
            if (! empty(
$this->_dirtyVars[$key]) && ! is_numeric($value)) {
                
$this->_cleanVars[$key] = strip_tags(Filter::nonTagHtmlEntities($value)); //no tags allowed
            
} elseif (is_numeric($value)) {
                
$this->_cleanVars[$key] = $value//preserve 0 values 
            
} else {
                
$this->_cleanVars[$key] = ''//standardize what is empty ie ===false, null, '', will be ''
            
}
        }
    }

    
/**
     * Modifies a record into the signup table
     *
     * @access public
     * @param     array $userDetails contains user details. See constants defined for array keys
     * @uses     Users::banUser()
     * @uses    Modules::call_hook()
     * @return     boolean true on success
     * @internal main proccess for registration modification
     */
    
function modifySignup ($userDetails)
    {
        
$this->_userData $userDetails//these should already be in safe form and just need escaping
        
if (! empty($this->_userData['password'])) {
            
$this->_userData['password'] = Login::hashPassword($this->_userData['password']); //need the hashed value
        
}
        
/*
        $this->createCode($this->_userData['username']); //create the verification code
        

        // First check login and email are unique in user table
        if (! $this->checkUnique($this->_userData['username'], $this->_userData['email'], $this->_userData['id'])) {
            return 3; //return status code of 3
        }
        */
        // Handle different types of permissions when adding a user
        
if (defined('IN_ADMIN')) {
            if (! 
$this->_adminModifyUserSignup()) { //admin modifying a user
                
return 2;
            }
            if (! empty(
$this->_userData['level']) && $this->_userData['level'] == 4) {
                
$Users Library::loadLibrary('Users');
                
$Users->banUser($this->_userData['id']);
            }
            
$modules Library::loadLibrary('Modules');
            
$modules->call_hook('admin_user_modify'$this->_userData); // Call any module functions
        
} else {
            if (! 
$this->_userModifySignup()) { //user modifying themself
                
return 2;
            }
            
$modules Library::loadLibrary('Modules');
            
$modules->call_hook('user_modify'$this->_userData); // Call any module functions
        
}
        return 
1//user added
    
}

    
/**
     * Modifies a user from administration panel
     *
     * @access private
     * @return boolean
     * @internal $this->_userData must be set with appropriate variables & filtering
     */
    
function _adminModifyUserSignup ()
    {
        
$conditionals '';
        if (! empty(
$this->_userData['username'])) {
            
$conditionals .= 'username=' $this->_db->quoteInto($this->_userData['username']) . ',';
        }
        if (! empty(
$this->_userData['password'])) {
            
$conditionals .= 'password=' $this->_db->quoteInto($this->_userData['password']) . ',';
        }
        if (! empty(
$this->_userData['level'])) {
            
$conditionals .= 'level=' $this->_db->quoteInto($this->_userData['level']) . ',';
        }
        if (! empty(
$this->_userData['email'])) {
            
$conditionals .= 'email=' $this->_db->quoteInto($this->_userData['email']) . ',';
        }
        
        if (! empty(
$this->_userData['b_same']) && $this->_userData['b_same'] == 'N') { //javascript setting these values?
            
$conditionals .= 'b_firstname=' $this->_db->quoteInto($this->_userData['b_firstname']) . ',';
            
$conditionals .= 'b_lastname=' $this->_db->quoteInto($this->_userData['b_lastname']) . ',';
            
$conditionals .= 'b_address=' $this->_db->quoteInto($this->_userData['b_address']) . ',';
            
$conditionals .= 'b_city=' $this->_db->quoteInto($this->_userData['b_city']) . ',';
            
$conditionals .= 'b_state=' $this->_db->quoteInto($this->_userData['b_state']) . ',';
            
$conditionals .= 'b_zip=' $this->_db->quoteInto($this->_userData['b_zip']) . ',';
            
$conditionals .= 'b_country=' $this->_db->quoteInto($this->_userData['b_country']) . ',';
            
$conditionals .= 'b_phone=' $this->_db->quoteInto($this->_userData['b_phone']) . ',';
            
$conditionals .= 'b_same="N",';
        } else {
            
$conditionals .= 'b_same="Y",';
        }
        
        if (! empty(
$this->_userData['adminCapabilities'])) {
            
$conditionals .= 'adminCapabilities=' $this->_db->quoteInto(serialize($this->_userData['adminCapabilities'])) . ',';
        }
        if (! empty(
$conditionals)) {
            
$conditionals ', ' String::removeLastChar($conditionals',');
        }
        
        
//build the query
        
$sql 'UPDATE ' PREFIX 'users ' 'SET 
                    firstname=' 
$this->_db->quoteInto($this->_userData['firstname']) . ', 
                    lastname=' 
$this->_db->quoteInto($this->_userData['lastname']) . ', 
                    address=' 
$this->_db->quoteInto($this->_userData['address']) . ', 
                    city=' 
$this->_db->quoteInto($this->_userData['city']) . ', 
                    state=' 
$this->_db->quoteInto($this->_userData['state']) . ', 
                    zip=' 
$this->_db->quoteInto($this->_userData['zip']) . ', 
                    country=' 
$this->_db->quoteInto($this->_userData['country']) . ', 
                    phone=' 
$this->_db->quoteInto($this->_userData['phone']) . ', 
                    newsletter=' 
$this->_db->quoteInto($this->_userData['newsletter']) . ', 
                    extra=' 
$this->_db->quoteInto($this->_userData['extra']) . ', 
                    extra2=' 
$this->_db->quoteInto($this->_userData['extra2']) . ', 
                    extra3=' 
$this->_db->quoteInto($this->_userData['extra3']) . $conditionals 
                WHERE id=' 
$this->_db->quoteInto($this->_userData['id']);
        
$result $this->_db->query($sql);
        if (
$this->_db->isError() || $result->isError()) {
            return 
false;
        }
        return 
true;
    }

    
/**
     * Modifies a user from front-end registration page (useraccountmodify.php)
     *
     * @access private
     * @return boolean
     * @internal $this->_userData must be set with appropriate variables & filtering
     */
    
function _userModifySignup ()
    {
        
$conditionals '';
        if (! empty(
$this->_userData['password'])) {
            
//echo $this->_userData['password'].'<BR>';
            
$conditionals .= 'password=' $this->_db->quoteInto($this->_userData['password']) . ',';
        }
        if (! empty(
$this->_userData['email'])) {
            
$conditionals .= 'email=' $this->_db->quoteInto($this->_userData['email']) . ',';
        }
        if (! empty(
$this->_userData['b_same']) && $this->_userData['b_same'] == 'Y') {
            
$conditionals .= 'b_firstname=' $this->_db->quoteInto($this->_userData['b_firstname']) . ',';
            
$conditionals .= 'b_lastname=' $this->_db->quoteInto($this->_userData['b_lastname']) . ',';
            
$conditionals .= 'b_address=' $this->_db->quoteInto($this->_userData['b_address']) . ',';
            
$conditionals .= 'b_city=' $this->_db->quoteInto($this->_userData['b_city']) . ',';
            
$conditionals .= 'b_state=' $this->_db->quoteInto($this->_userData['b_state']) . ',';
            
$conditionals .= 'b_zip=' $this->_db->quoteInto($this->_userData['b_zip']) . ',';
            
$conditionals .= 'b_country=' $this->_db->quoteInto($this->_userData['b_country']) . ',';
            
$conditionals .= 'b_phone=' $this->_db->quoteInto($this->_userData['b_phone']) . ',';
            
$conditionals .= 'b_same=' $this->_db->quoteInto($this->_userData['b_same']) . ',';
        }
        if (! empty(
$conditionals)) {
            
$conditionals ', ' String::removeLastChar($conditionals',');
        }
        
//build the query
        
$sql 'UPDATE ' PREFIX 'users ' 'SET  
                    custip=' 
$this->_db->quoteInto($this->getIP()) . ', 
                    firstname=' 
$this->_db->quoteInto($this->_userData['firstname']) . ', 
                    lastname=' 
$this->_db->quoteInto($this->_userData['lastname']) . ', 
                    address=' 
$this->_db->quoteInto($this->_userData['address']) . ', 
                    city=' 
$this->_db->quoteInto($this->_userData['city']) . ', 
                    state=' 
$this->_db->quoteInto($this->_userData['state']) . ', 
                    zip=' 
$this->_db->quoteInto($this->_userData['zip']) . ', 
                    country=' 
$this->_db->quoteInto($this->_userData['country']) . ', 
                    phone=' 
$this->_db->quoteInto($this->_userData['phone']) . ', 
                    newsletter=' 
$this->_db->quoteInto(@$this->_userData['newsletter']) . ', 
                    extra=' 
$this->_db->quoteInto(@$this->_userData['extra']) . ', 
                    extra2=' 
$this->_db->quoteInto(@$this->_userData['extra2']) . ', 
                    extra3=' 
$this->_db->quoteInto(@$this->_userData['extra3']) . 
                    ' 
$conditionals 
                WHERE id=' 
$this->_db->quoteInto($this->_userData['id']);
        
$result $this->_db->query($sql);
        if (
$this->_db->isError() || $result->isError()) {
            return 
false;
        }
        return 
true;
    }

    
/**
     * Creates the javascript for when a user is modified.
     *
     * @access public
     * @uses getStates()
     * @uses getCountries()
     * @return void It assigns it to the template class.
     */
    
function createJavascriptValidation ()
    {
        
$sql 'SELECT rID,rFirstName,rLastName,rAddress,rCity,rState,rCountry,rZip,rPhone,rEmail,rExtra,rExtra2,rExtra3 FROM ' PREFIX 'registration WHERE rID=1';
        
$result $this->_db->query($sql);
        
$rs $result->fetch();
        
        
$class_tpl Library::loadLibrary('Template');
        
        
//now explode them
        
$dis_fname explode("|"$rs['rFirstName']);
        
$dis_lname explode("|"$rs['rLastName']);
        
$dis_address explode("|"$rs['rAddress']);
        
$dis_city explode("|"$rs['rCity']);
        
$dis_state explode("|"$rs['rState']);
        
$dis_country explode("|"$rs['rCountry']);
        
$dis_zip explode("|"$rs['rZip']);
        
$dis_phone explode("|"$rs['rPhone']);
        
$dis_email explode("|"$rs['rEmail']);
        
$dis_extra explode("|"$rs['rExtra']);
        
$dis_extra2 explode("|"$rs['rExtra2']);
        
$dis_extra3 explode("|"$rs['rExtra3']);
        
        
//now define the display
        
$class_tpl->assign('dis_fname'$dis_fname[0]);
        
$class_tpl->assign('dis_lname'$dis_lname[0]);
        
$class_tpl->assign('dis_address'$dis_address[0]);
        
$class_tpl->assign('dis_city'$dis_city[0]);
        
$class_tpl->assign('dis_state'$dis_state[0]);
        
$class_tpl->assign('dis_zip'$dis_zip[0]);
        
$class_tpl->assign('dis_country'$dis_country[0]);
        
$class_tpl->assign('dis_phone'$dis_phone[0]);
        
$class_tpl->assign('dis_extra'$dis_extra[0]);
        
$class_tpl->assign('dis_extra2'$dis_extra2[0]);
        
$class_tpl->assign('dis_extra3'$dis_extra3[0]);
        
        
//now define the required
        
$class_tpl->assign('req_fname'$dis_fname[1]);
        
$class_tpl->assign('req_lname'$dis_lname[1]);
        
$class_tpl->assign('req_address'$dis_address[1]);
        
$class_tpl->assign('req_city'$dis_city[1]);
        
$class_tpl->assign('req_state'$dis_state[1]);
        
$class_tpl->assign('req_zip'$dis_zip[1]);
        
$class_tpl->assign('req_country'$dis_country[1]);
        
$class_tpl->assign('req_phone'$dis_phone[1]);
        
$class_tpl->assign('req_extra'$dis_extra[1]);
        
$class_tpl->assign('req_extra2'$dis_extra2[1]);
        
$class_tpl->assign('req_extra3'$dis_extra3[1]);
        
        
//now define the text
        
$class_tpl->assign('extra_text'$dis_extra[2]);
        
$class_tpl->assign('extra2_text'$dis_extra2[2]);
        
$class_tpl->assign('extra3_text'$dis_extra3[2]);
        
        
//now the country and states
        
$states getStates();
        
$countries getCountries();
        
$class_tpl->assign('showstates'$states);
        
$class_tpl->assign('showcountries'$countries);
        
        
//now generate the javascript//
        
$output '';
        
$output .= 'if (frm.username.value == "") {alert("' LANG_JAVASCRIPT_PLEASE_ENTER ' \'' LANG_USERNAME '\'."); frm.username.focus(); return (false);}';
        
$output .= "\n\n";
        
$output .= 'if (frm.email.value == "") {alert("' LANG_JAVASCRIPT_PLEASE_ENTER ' \'' LANG_EMAIL '\'."); frm.email.focus(); return (false);}';
        
$output .= "\n\n";
        
        
//now the password //
        
$output .= 'if (frm.password.value != "" ) {if (frm.password.value != frm.passwordconfirm.value) {alert("' LANG_JS_PASSWORD_ERROR '"); frm.password.focus(); return (false); }}';
        
$output .= "\n\n";
        
        
//now the level
        //$output .='var level = frm.level.options;';
        //$output .= "\n\n";
        //$output .='var sValue = level[level.selectedIndex].value;';
        //$output .= "\n\n";
        //$output .='if (sValue == 1) {';
        //$output .='if(!confirm("'.LANG_MEMBER_ADMINISTRATOR.'")){';
        //$output .='return (false);';
        //$output .='}}';
        //$output .= "\n\n";
        

        
$class_tpl->assign('validation'$output);
    }
}

/* End of file includes/classes/kernel/Register.php */