Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 2124)
+++ branches/2.8.x/CHANGELOG	(revision 2125)
@@ -11,6 +11,11 @@
 ! = Update/Change
 ===============================================================================
 
+17 Jun -2015 Build 2125 Manuela v.d.Decken(DarkViper)
+! /framework/class.Login.php
+! /account/ ~login_form.php  ~login.php
+! /admin/login/index.php
+  fixed some possible intruder vectors and complete 2.8.4 adaption
 16 May-2015 Build 2124 Manuela v.d.Decken(DarkViper)
 ! /framework/initialize +
 ! /framework/WbAutoloader  abbreviation list moved to initialize; added method getAbbreviations()
Index: branches/2.8.x/wb/admin/login/index.php
===================================================================
--- branches/2.8.x/wb/admin/login/index.php	(revision 2124)
+++ branches/2.8.x/wb/admin/login/index.php	(revision 2125)
@@ -18,52 +18,39 @@
 // Include the configuration file
 $sStartFile = dirname(dirname(__DIR__)).'/framework/initialize.php';
 if (!defined('SYSTEM_RUN')) {
-	require($sStartFile);
+    require($sStartFile);
 }
-//if(!class_exists('login', false)){ require_once(WB_PATH.'/framework/class.login.php'); }
-//if(!class_exists('frontend', false)){ require_once(WB_PATH.'/framework/class.frontend.php'); }
+$username_fieldname = 'username';
+$password_fieldname = 'password';
+if(isset($oReg->SmartLogin) && $oReg->SmartLogin == 'true') {
+    $sTmp = '_'.substr(md5(microtime()), -8);
+    $username_fieldname .= $sTmp;
+    $password_fieldname .= $sTmp;
+}
 
-if(defined('SMART_LOGIN') AND SMART_LOGIN == 'enabled') {
-	// Generate username field name
-	$username_fieldname = 'username_';
-	$password_fieldname = 'password_';
-	$salt = "abchefghjkmnpqrstuvwxyz0123456789";
-	srand((double)microtime()*1000000);
-	$i = 0;
-	while ($i <= 7) {
-		$num = rand() % 33;
-		$tmp = substr($salt, $num, 1);
-		$username_fieldname = $username_fieldname . $tmp;
-		$password_fieldname = $password_fieldname . $tmp;
-		$i++;
-	}
-} else {
-	$username_fieldname = 'username';
-	$password_fieldname = 'password';
-}
 $admin = new frontend();
-$WarnUrl = str_replace(WB_PATH,WB_URL,$admin->correct_theme_source('warning.html'));
+$WarnUrl = str_replace($oReg->AppPath, $oReg->AppUrl, $admin->correct_theme_source('warning.html'));
 $LoginTpl = 'loginBox.htt';
 $ThemePath = dirname($admin->correct_theme_source('loginBox.htt'));
 $thisApp = new Login( array(
-        'MAX_ATTEMPS'           => '3',
+        'MAX_ATTEMPS'           => 3,
         'WARNING_URL'           => $WarnUrl,
         'INFO_URL'              => '##',
         'INFO_TEXT'             => 'News',
         'USERNAME_FIELDNAME'    => $username_fieldname,
         'PASSWORD_FIELDNAME'    => $password_fieldname,
-        'REMEMBER_ME_OPTION'    => SMART_LOGIN,
-        'MIN_USERNAME_LEN'      => '2',
-        'MIN_PASSWORD_LEN'      => '3',
-        'MAX_USERNAME_LEN'      => '30',
-        'MAX_PASSWORD_LEN'      => '30',
-        'LOGIN_URL'             => ADMIN_URL."/login/index.php",
-        'DEFAULT_URL'           => ADMIN_URL."/start/index.php",
+        'REMEMBER_ME_OPTION'    => $oReg->SmartLogin,
+        'MIN_USERNAME_LEN'      => 2,
+        'MIN_PASSWORD_LEN'      => 3,
+        'MAX_USERNAME_LEN'      => 100,
+        'MAX_PASSWORD_LEN'      => 100,
+        'LOGIN_URL'             => $oReg->AcpUrl."login/index.php",
+        'DEFAULT_URL'           => $oReg->AcpUrl."start/index.php",
         'TEMPLATE_DIR'          => $ThemePath,
         'TEMPLATE_FILE'         => $LoginTpl,
         'FRONTEND'              => false,
-        'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
-        'USERS_TABLE'           => TABLE_PREFIX."users",
-        'GROUPS_TABLE'          => TABLE_PREFIX."groups",
+        'FORGOTTEN_DETAILS_APP' => $oReg->AcpUrl."login/forgot/index.php",
+        'USERS_TABLE'           => $oDb->TablePrefix."users",
+        'GROUPS_TABLE'          => $oDb->TablePrefix."groups",
     )
 );
Index: branches/2.8.x/wb/account/login_form.php
===================================================================
--- branches/2.8.x/wb/account/login_form.php	(revision 2124)
+++ branches/2.8.x/wb/account/login_form.php	(revision 2125)
@@ -4,8 +4,8 @@
  * @category        frontend
  * @package         account
  * @author          WebsiteBaker Project
- * @copyright       2009-2012, WebsiteBaker Org. e.V.
- * @link			http://www.websitebaker2.org/
+ * @copyright       WebsiteBaker Org. e.V.
+ * @link			http://websitebaker.org/
  * @license         http://www.gnu.org/licenses/gpl.html
  * @platform        WebsiteBaker 2.8.x
  * @requirements    PHP 5.2.2 and higher
@@ -17,89 +17,70 @@
 
 /* -------------------------------------------------------- */
 // Must include code to stop this file being accessed directly
-if(!defined('WB_PATH')) {
-require_once(dirname(dirname(__FILE__)).'/framework/globalExceptionHandler.php');
-throw new IllegalFileException();
+if(!defined('SYSTEM_RUN')) {
+    throw new Exception('illegal file access [account/login_form.php]');
 }
 /* -------------------------------------------------------- */
 
-	// Generate username field name
-$username_fieldname = 'username_';
-$password_fieldname = 'password_';
+// Generate username field name
+$username_fieldname = 'username';
+$password_fieldname = 'password';
+if(isset($oReg->SmartLogin) && $oReg->SmartLogin == 'true') {
+    $sTmp = '_'.substr(md5(microtime()), -8);
+    $username_fieldname .= $sTmp;
+    $password_fieldname .= $sTmp;
+}
 $output = '';
 msgQueue::clear();
 
-if(defined('SMART_LOGIN') AND SMART_LOGIN == 'true') {
-
-	$temp = array_merge(range('a','z'), range(0,9));
-	shuffle($temp);
-	for($i=0;$i<=7;$i++) {
-		$username_fieldname .= $temp[$i];
-		$password_fieldname .= $temp[$i];
-	}
-} else {
-	$username_fieldname = 'username';
-	$password_fieldname = 'password';
-}
-
 $thisApp->redirect_url = (isset($thisApp->redirect_url) && ($thisApp->redirect_url!='')  ? $thisApp->redirect_url : $_SESSION['HTTP_REFERER'] );
 //$thisApp->redirect_url = '';
 $sIncludeHeadLinkCss = '';
-if( is_readable(WB_PATH .'/account/frontend.css')) {
-	$sIncludeHeadLinkCss .= '<link href="'.WB_URL.'/account/frontend.css"';
-	$sIncludeHeadLinkCss .= ' rel="stylesheet" type="text/css" media="screen" />'."\n";
+if( is_readable($oReg->AppPath.'account/frontend.css')) {
+    $sIncludeHeadLinkCss .= '<link href="'.$oReg->AppUrl.'account/frontend.css"';
+    $sIncludeHeadLinkCss .= ' rel="stylesheet" type="text/css" media="screen" />'."\n";
 }
 
 // set template file and assign module and template block
-	$oTpl = new Template(dirname(__FILE__).'/htt');
-	$oTpl->set_file('page', 'login.htt');
-	$oTpl->debug = false; // false, true
-	$oTpl->set_block('page', 'main_block', 'main');
+    $oTpl = new Template(__DIR__.'/htt');
+    $oTpl->set_file('page', 'login.htt');
+    $oTpl->debug = false;
+    $oTpl->set_block('page', 'main_block', 'main');
 
-	$oTpl->set_block('main_block', 'message_block', 'message');
-	$oTpl->set_block('message', '');
-
+    $oTpl->set_block('main_block', 'message_block', 'message');
+    $oTpl->set_block('message', '');
+// language vars
+    $oTpl->set_var($oReg->Trans->getLangArray());
 // generell vars
-	$oTpl->set_var(array(
-		'FTAN' => $wb->getFTAN(),
-		'ACTION_URL' => WB_URL.'/account/login.php',
-		'FORGOT_URL' => WB_URL.'/account/forgot.php',
-		'REDIRECT_URL' => $thisApp->redirect_url,
-		'WB_URL' => WB_URL,
-		'THEME_URL' => THEME_URL,
-		'TEMPLATE_URL' => TEMPLATE_DIR,
-		'HTTP_REFERER' => $thisApp->redirect_url,
-        'CSS_BLOCK'	=> $sIncludeHeadLinkCss,
-		'MESSAGE_VALUE' => '',
-		'ERROR_VALUE' => '',
-		'THISAPP_MESSAGE_VALUE' => $thisApp->message,
-		'TEXT_FORGOTTEN_DETAILS' => $TEXT['FORGOTTEN_DETAILS'],
-		'TEXT_USERNAME' => $TEXT['USERNAME'],
-		'TEXT_PASSWORD' => $TEXT['PASSWORD'],
-		'USER_FIELDNAME' => $username_fieldname,
-		'PASSWORD_FIELDNAME' => $password_fieldname,
-		'TEXT_LOGIN' => $TEXT['LOGIN'],
-		'TEXT_RESET' => $TEXT['RESET'],
-		'TEXT_CANCEL' => $TEXT['CANCEL'],
-		)
-	);
+    $oTpl->set_var(array(
+        'FTAN'                  => $wb->getFTAN(),
+        'ACTION_URL'            => $oReg->AppUrl.'account/login.php',
+        'FORGOT_URL'            => $oReg->AppUrl.'account/forgot.php',
+        'REDIRECT_URL'          => $thisApp->redirect_url,
+        'WB_URL'                => $oReg->AppUrl,
+        'THEME_URL'             => $oReg->ThemeUrl,
+        'TEMPLATE_URL'          => $oReg->TemplateDir,
+        'HTTP_REFERER'          => $thisApp->redirect_url,
+        'CSS_BLOCK'             => $sIncludeHeadLinkCss,
+        'MESSAGE_VALUE'         => '',
+        'ERROR_VALUE'           => '',
+        'THISAPP_MESSAGE_VALUE' => $thisApp->message,
+        'USER_FIELDNAME'        => $username_fieldname,
+        'PASSWORD_FIELDNAME'    => $password_fieldname,
+        )
+    );
 
-	$oTpl->set_block('main_block', 'show_smart_login_block', 'show_smart_login');
-//	$oTpl->parse('show_smart_login', '');
-	if($username_fieldname != 'username') {
-		$oTpl->set_var(array(
-		'TEXT_REMEMBER_ME' => $TEXT['REMEMBER_ME'],
-			)
-		);
+    $oTpl->set_block('main_block', 'show_smart_login_block', 'show_smart_login');
+// $oTpl->parse('show_smart_login', '');
+    if($username_fieldname != 'username') {
+        $oTpl->parse('show_smart_login', 'show_smart_login_block', true);
+    } else {
+        $oTpl->set_block('show_smart_login', '');
+    }
 
-		$oTpl->parse('show_smart_login', 'show_smart_login_block', true);
-	} else {
-		$oTpl->set_block('show_smart_login', '');
-	}
+    //$oTpl->parse('message', 'message_block', true);
+    $oTpl->parse('main', 'main_block', false);
+    $output = $oTpl->finish($oTpl->parse('output', 'page'));
+    unset($oTpl);
+    print $output;
 
-	//$oTpl->parse('message', 'message_block', true);
-	$oTpl->parse('main', 'main_block', false);
-	$output = $oTpl->finish($oTpl->parse('output', 'page'));
-	unset($oTpl);
-	print $output;
-
Index: branches/2.8.x/wb/account/login.php
===================================================================
--- branches/2.8.x/wb/account/login.php	(revision 2124)
+++ branches/2.8.x/wb/account/login.php	(revision 2125)
@@ -15,40 +15,30 @@
  *
  */
 
-// Include config file
-$config_file = realpath('../config.php');
-if(file_exists($config_file) && !defined('WB_URL'))
-{
-	require_once($config_file);
-}
+// Include the configuration file
+$sStartFile = dirname(__DIR__).'/framework/initialize.php';
+if (!defined('SYSTEM_RUN')) { require($sStartFile); }
+require_once($oReg->AppPath.'framework/functions.php');
 
-//if(!class_exists('login', false)){ include(WB_PATH.'/framework/class.login.php'); }
-//if(!class_exists('frontend', false)){ include(WB_PATH.'/framework/class.frontend.php'); }
-
-require_once(WB_PATH.'/framework/functions.php');
-
 $wb = new frontend(false);
 
 // Make sure the login is enabled
-if(!FRONTEND_LOGIN) {
-		header('Location: '.WB_URL.'/');
-		exit(0);
-//	if(INTRO_PAGE) {
-//		header('Location: '.WB_URL.PAGES_DIRECTORY.'/index.php');
-//		exit(0);
-//	} else {
-//	}
+if(!$oReg->FrontendLogin) {
+    header('Location: '.$oReg->AppUrl);
+    exit;
 }
+$page_id =
+    isset($oReg->ReferrerId)
+    ? $oReg->ReferrerId
+    : isset($_SESSION['PAGE_ID']) ? $_SESSION['PAGE_ID'] : 0;
 
-$page_id = defined('REFERRER_ID') ? REFERRER_ID : isset($_SESSION['PAGE_ID']) ? $_SESSION['PAGE_ID'] : 0;
-
 // Required page details
 $page_description = '';
 $page_keywords = '';
 // Work out level
-$level = ($page_id > 0 )? level_count($page_id): $page_id;
+$level = ($page_id > 0 ) ? level_count($page_id) : $page_id;
 // Work out root parent
-$root_parent = ($page_id > 0 )? root_parent($page_id): $page_id;
+$root_parent = ($page_id > 0 ) ? root_parent($page_id) : $page_id;
 
 define('PAGE_ID', $page_id);
 define('ROOT_PARENT', $root_parent);
@@ -55,50 +45,48 @@
 define('PARENT', 0);
 define('LEVEL', $level);
 
-define('PAGE_TITLE', $TEXT['PLEASE_LOGIN']);
-define('MENU_TITLE', $TEXT['PLEASE_LOGIN']);
+define('PAGE_TITLE', $oTrans->TEXT_PLEASE_LOGIN);
+define('MENU_TITLE', $oTrans->TEXT_PLEASE_LOGIN);
 define('VISIBILITY', 'public');
 // Set the page content include file
-define('PAGE_CONTENT', WB_PATH.'/account/login_form.php');
+define('PAGE_CONTENT', $oReg->AppPath.'account/login_form.php');
 
 // Create new login app
 $requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
-$redirect  = strip_tags(isset(${$requestMethod}['redirect']) ? ${$requestMethod}['redirect'] : '');
+$sRedirect  = strip_tags(isset(${$requestMethod}['redirect']) ? ${$requestMethod}['redirect'] : '');
 //$redirect = ( (empty($redirect)) ?  $_SERVER['HTTP_REFERER'] : $redirect);
-$_SESSION['HTTP_REFERER'] = str_replace(WB_URL,'',$redirect);
+$_SESSION['HTTP_REFERER'] = str_replace($oReg->AppUrl,'/',$sRedirect);
 
-$loginUrl  = WB_URL.'/account/login.php';
-$loginUrl .= (!empty($redirect) ? '?redirect=' .$_SESSION['HTTP_REFERER'] : '');
+$sLoginUrl  = $oReg->AppUrl.'account/login.php';
+$sLoginUrl .= (!empty($sRedirect) ? '?redirect=' .$_SESSION['HTTP_REFERER'] : '');
 
-$WarningUrl  = str_replace(WB_PATH,WB_URL,$wb->correct_theme_source('warning.html'));
+$sWarningUrl  = str_replace($oReg->AppPath, $oReg->AppUrl, $wb->correct_theme_source('warning.html'));
 // Setup template object, parse vars to it, then parse it
-$ThemePath = realpath(WB_PATH.$wb->correct_theme_source('loginBox.htt'));
+$sThemePath = realpath($oReg->AppPath . ltrim($wb->correct_theme_source('loginBox.htt'), '/'));
 
 $thisApp = new Login(
-				array(
-						"MAX_ATTEMPS" => "3",
-						"WARNING_URL" => $WarningUrl,
-						"USERNAME_FIELDNAME" => 'username',
-						"PASSWORD_FIELDNAME" => 'password',
-						"REMEMBER_ME_OPTION" => SMART_LOGIN,
-						"MIN_USERNAME_LEN" => "2",
-						"MIN_PASSWORD_LEN" => "2",
-						"MAX_USERNAME_LEN" => "30",
-						"MAX_PASSWORD_LEN" => "30",
-						"LOGIN_URL" => $loginUrl,
-						"DEFAULT_URL" => WB_URL."/index.php",
-						"TEMPLATE_DIR" => $ThemePath,
-						"TEMPLATE_FILE" => "login.htt",
-						"FRONTEND" => true,
-						"FORGOTTEN_DETAILS_APP" => WB_URL."/account/forgot.php",
-						"USERS_TABLE" => TABLE_PREFIX."users",
-						"GROUPS_TABLE" => TABLE_PREFIX."groups",
-						"REDIRECT_URL" => $redirect
-                    )
-		);
-
+    array(
+        'MAX_ATTEMPS'           => 3,
+        'WARNING_URL'           => $sWarningUrl,
+        'USERNAME_FIELDNAME'    => 'username',
+        'PASSWORD_FIELDNAME'    => 'password',
+        'REMEMBER_ME_OPTION'    => $oReg->SmartLogin,
+        'MIN_USERNAME_LEN'      => 2,
+        'MIN_PASSWORD_LEN'      => 3,
+        'MAX_USERNAME_LEN'      => 100,
+        'MAX_PASSWORD_LEN'      => 100,
+        'LOGIN_URL'             => $sLoginUrl,
+        'DEFAULT_URL'           => $oReg->AppUrl.'index.php',
+        'TEMPLATE_DIR'          => $sThemePath,
+        'TEMPLATE_FILE'         => 'login.htt',
+        'FRONTEND'              => true,
+        'FORGOTTEN_DETAILS_APP' => $oReg->AppUrl.'/account/forgot.php',
+        'USERS_TABLE'           => $oDb->TablePrefix.'users',
+        'GROUPS_TABLE'          => $oDb->TablePrefix.'groups',
+        'REDIRECT_URL'          => $sRedirect
+    )
+);
 // Set extra outsider var
 $globals[] = 'thisApp';
-
 // Include the index (wrapper) file
-require(WB_PATH.'/index.php');
+require($oReg->AppPath.'index.php');
Index: branches/2.8.x/wb/framework/class.Login.php
===================================================================
--- branches/2.8.x/wb/framework/class.Login.php	(revision 2124)
+++ branches/2.8.x/wb/framework/class.Login.php	(revision 2125)
@@ -14,13 +14,6 @@
  * @lastmodified    $Date$
  *
  */
-/* -------------------------------------------------------- */
-// Must include code to stop this file being accessed directly
-if(!defined('WB_PATH')) {
-	require_once(dirname(__FILE__).'/globalExceptionHandler.php');
-	throw new IllegalFileException();
-}
-/* -------------------------------------------------------- */
 define('LOGIN_CLASS_LOADED', true);
 
 // Get WB version
@@ -27,355 +20,308 @@
 require_once(ADMIN_PATH.'/interface/version.php');
 
 class Login extends admin {
-	public function __construct($config_array) {
-		// Get language vars
-		global $MESSAGE, $database;
-		parent::__construct();
-		// Get configuration values
-		while(list($key, $value) = each($config_array)) {
-			$this->{(strtolower($key))} = $value;
-		}
-		if(!isset($this->redirect_url)) { $this->redirect_url = ''; }
-		// Get the supplied username and password
-		if ($this->get_post('username_fieldname') != ''){
-			$username_fieldname = $this->get_post('username_fieldname');
-			$password_fieldname = $this->get_post('password_fieldname');
-		} else {
-			$username_fieldname = 'username';
-			$password_fieldname = 'password';
-		}
 
-        if( is_array($this->get_post($username_fieldname) ) ) {
-            $_POST[$username_fieldname]=implode(',',$this->get_post($username_fieldname));            
-        }
-		$this->username = htmlspecialchars (strtolower( $this->get_post($username_fieldname) ), ENT_QUOTES);
+    const PASS_CHARS = '\w!#$%&*+\-.:=?@\|';
+    const USER_CHARS = 'a-z0-9&\-.=@_';
 
-        if( is_array($this->get_post($password_fieldname) ) ) {
-            $_POST[$password_fieldname]=implode(',',$this->get_post($password_fieldname));            
-        }
-		$this->password = $this->get_post($password_fieldname);
+    protected $oReg    = null;
+    protected $oDb     = null;
+    protected $oTrans  = null;
+    protected $message = '';
 
-		// Figure out if the "remember me" option has been checked
-		if($this->get_post('remember') == 'true') {
-			$this->remember = $this->get_post('remember');
-		} else {
-			$this->remember = false;
-		}
-		// Get the length of the supplied username and password
-		if($this->get_post($username_fieldname) != '') {
-			$this->username_len = strlen($this->username);
-			$this->password_len = strlen($this->password);
-		}
+    public function __construct($config_array)
+    {
+        $this->oReg   = WbAdaptor::getInstance();
+        $this->oDb    = $this->oReg->Db;
+        $this->oTrans = $this->oReg->Trans;
 
-		$aServerUrl = $this->mb_parse_url(WB_URL);
-
-        $sServerUrl = $_SERVER['SERVER_NAME'];        
-        $sServerScheme = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : isset($aServerUrl['scheme']) ? $aServerUrl['scheme'] : ' http';        
-        $sServerPath = $_SERVER['SCRIPT_NAME'];        
-		// If the url is blank, set it to the default url
-		$this->url = $this->get_post('url');
+        parent::__construct();
+    // Get configuration values
+        while(list($key, $value) = each($config_array)) {
+            $this->{(strtolower($key))} = $value;
+        }
+    // calculate redirect URL
+        if(!isset($this->redirect_url)) { $this->redirect_url = ''; }
+        $aServerUrl = $this->mb_parse_url($this->oReg->AppUrl);
+        $sServerUrl = $_SERVER['SERVER_NAME'];
+        $sServerScheme =
+            isset($_SERVER['REQUEST_SCHEME'])
+            ? $_SERVER['REQUEST_SCHEME']
+            : isset($aServerUrl['scheme']) ? $aServerUrl['scheme'] : ' http';
+        $sServerPath = $_SERVER['SCRIPT_NAME'];
+        // If the url is blank, set it to the default url
+        $this->url = $this->get_post('url');
+        if (preg_match('/%0d|%0a|\s/i', $this->url)) {
+            throw new Exception('Warning: possible intruder detected on login');
+        }
         $aUrl = $this->mb_parse_url( $this->url );
-        $this->url = isset($aRedirecthUrl['host']) &&($sServerUrl==$aUrl['host']) ? $this->url:ADMIN_URL.'/start/index.php';        
-		if ($this->redirect_url!='') {
+        $this->url =
+            isset($aRedirecthUrl['host']) &&($sServerUrl == $aUrl['host'])
+            ? $this->url
+            : $this->oReg->AcpUrl.'start/index.php';
+        if ($this->redirect_url!='') {
             $aRedirecthUrl = $this->mb_parse_url( $this->redirect_url );
-            $this->redirect_url = isset($aRedirecthUrl['host']) &&($sServerUrl==$aRedirecthUrl['host']) ? $this->redirect_url:$sServerScheme.'://'.$sServerUrl;        
-			$this->url = $this->redirect_url;
-		}
-		if(strlen($this->url) < 2) {
+            $this->redirect_url =
+                isset($aRedirecthUrl['host']) &&($sServerUrl==$aRedirecthUrl['host'])
+                ? $this->redirect_url
+                : $sServerScheme.'://'.$sServerUrl;
+            $this->url = $this->redirect_url;
+        }
+        if(strlen($this->url) < 2) {
             $aDefaultUrl = $this->mb_parse_url( $this->default_url );
-            $this->default_url = isset($aDefaultUrl['host']) &&($sServerUrl==$aDefaultUrl['host']) ? $this->default_url:$sServerScheme.'://'.$sServerUrl;        
-			$this->url = $this->default_url;
-		}
+            $this->default_url =
+                isset($aDefaultUrl['host']) &&($sServerUrl==$aDefaultUrl['host'])
+                ? $this->default_url
+                : $sServerScheme.'://'.$sServerUrl;
+            $this->url = $this->default_url;
+        }
+    // get username & password and validate it
+        $username_fieldname = (string)$this->get_post('username_fieldname');
+        $username_fieldname = (preg_match('/^_?[a-z][\w]+$/i', $username_fieldname) ? $username_fieldname : 'username');
+        $sUsername = strtolower(trim((string)$this->get_post($username_fieldname)));
+        $this->username = (preg_match(
+            '/^['.self::USER_CHARS.']{'.$this->min_username_len.','.$this->max_username_len.'}$/is',
+            $sUsername
+        ) ? $sUsername : '');
+        $password_fieldname = (string)$this->get_post('password_fieldname');
+        $password_fieldname = (preg_match('/^_?[a-z][\w]+$/i', $password_fieldname) ? $password_fieldname : 'password');
 
-		if($this->is_authenticated() == true) {
-			// User already logged-in, so redirect to default url
-				$this->send_header($this->url);
-		} elseif($this->is_remembered() == true) {
-			// User has been "remembered"
-			// Get the users password
-			// $database = new database();
-			$sql  = 'SELECT * FROM `'.$this->users_table.'` ';
-			$sql .= 'WHERE `user_id`=\''.$this->get_safe_remember_key().'\'';
-			$query_details = $database->query($sql);
-			$fetch_details = $query_details->fetchRow(MYSQL_ASSOC);
-			$this->username = $fetch_details['username'];
-			$this->password = $fetch_details['password'];
-			// Check if the user exists (authenticate them)
-			if($this->authenticate()) {
-				// Authentication successful
-				$this->send_header($this->url);
-			} else {
-				$this->message = $MESSAGE['LOGIN_AUTHENTICATION_FAILED'];
-				$this->increase_attemps();
-			}
-		} elseif($this->username == '' AND $this->password == '') {
-			$this->message = $MESSAGE['LOGIN_BOTH_BLANK'];
-			$this->display_login();
-		} elseif($this->username == '') {
-			$this->message = $MESSAGE['LOGIN_USERNAME_BLANK'];
-			$this->increase_attemps();
-		} elseif($this->password == '') {
-			$this->message = $MESSAGE['LOGIN_PASSWORD_BLANK'];
-			$this->increase_attemps();
-		} elseif($this->username_len < $config_array['MIN_USERNAME_LEN']) {
-			$this->message = $MESSAGE['LOGIN_USERNAME_TOO_SHORT'];
-			$this->increase_attemps();
-		} elseif($this->password_len < $config_array['MIN_PASSWORD_LEN']) {
-			$this->message = $MESSAGE['LOGIN_PASSWORD_TOO_SHORT'];
-			$this->increase_attemps();
-		} elseif($this->username_len > $config_array['MAX_USERNAME_LEN']) {
-			$this->message = $MESSAGE['LOGIN_USERNAME_TOO_LONG'];
-			$this->increase_attemps();
-		} elseif($this->password_len > $config_array['MAX_PASSWORD_LEN']) {
-			$this->message = $MESSAGE['LOGIN_PASSWORD_TOO_LONG'];
-			$this->increase_attemps();
-		} else {
-			// Check if the user exists (authenticate them)
-			$this->password = md5($this->password);
-			if($this->authenticate()) {
-				// Authentication successful
-				$this->send_header($this->url);
-			} else {
-				$this->message = $MESSAGE['LOGIN_AUTHENTICATION_FAILED'];
-				$this->increase_attemps();
-			}
-		}
-	}
+        if ($this->username) {
+/** @TODO implement crypting */
+            $this->password = md5(trim((string)$this->get_post($password_fieldname)));
+            // Figure out if the "remember me" option has been checked
+            $this->remember = (@$_POST['remember'] == 'true' ? true : false);
+        // try to authenticate
+            $bSuccess = false;
+            if (!($bSuccess = $this->is_authenticated())) {
+                if ($this->is_remembered()) {
+                    $sql = 'SELECT * FROM `'.$this->oDb->TablePrefix.'users` '
+                         . 'WHERE `user_id`='.$this->get_safe_remember_key();
+                    if (($oUsers = $this->oDb->doQuery($sql))) {
+                        if (($aUser = $oUsers->fetchArray())) {
+                            $this->username = $aUser['username'];
+                            $this->password = $aUser['password'];
+                            // Check if the user exists (authenticate them)
+                            $bSuccess = $this->authenticate();
+                        }
+                    }
+                } else {
+                    // Check if the user exists (authenticate them)
+                    $bSuccess = $this->authenticate();
+                }
+            }
+            if ($bSuccess) {
+                // Authentication successful
+                $this->send_header($this->url);
+            } else {
+                $this->message = $this->oTrans->MESSAGE_LOGIN_AUTHENTICATION_FAILED;
+                $this->increase_attemps();
+            }
+        } else {
+            $this->display_login();
+        }
+    }
 
-	// Authenticate the user (check if they exist in the database)
-	function authenticate() {
-		global $database;
-		// Get user information
-		// $database = new database();
-		// $query = 'SELECT * FROM `'.$this->users_table.'` WHERE MD5(`username`) = "'.md5($this->username).'" AND `password` = "'.$this->password.'" AND `active` = 1';
- 		$loginname = ( preg_match('/[\;\=\&\|\<\> ]/',$this->username) ? '' : $this->username );
-		$sql  = 'SELECT * FROM `'.$this->users_table.'` ';
-		$sql .= 'WHERE `username`=\''.$loginname.'\' AND `password`=\''.$this->password.'\' AND `active`=1';
-		$results = $database->query($sql);
-		$results_array = $results->fetchRow(MYSQL_ASSOC);
-		$num_rows = $results->numRows();
-		if($num_rows == 1) {
-			$user_id = $results_array['user_id'];
-			$this->user_id = $user_id;
-			$_SESSION['USER_ID'] = $user_id;
-			$_SESSION['GROUP_ID'] = $results_array['group_id'];
-			$_SESSION['GROUPS_ID'] = $results_array['groups_id'];
-			$_SESSION['USERNAME'] = $results_array['username'];
-			$_SESSION['DISPLAY_NAME'] = $results_array['display_name'];
-			$_SESSION['EMAIL'] = $results_array['email'];
-			$_SESSION['HOME_FOLDER'] = $results_array['home_folder'];
-			// Run remember function if needed
-			if($this->remember == true) {
-				$this->remember($this->user_id);
-			}
-			// Set language
-			if($results_array['language'] != '') {
-				$_SESSION['LANGUAGE'] = $results_array['language'];
-			}
-			// Set timezone
-			if($results_array['timezone'] != '-72000') {
-				$_SESSION['TIMEZONE'] = $results_array['timezone'];
-			} else {
-				// Set a session var so apps can tell user is using default tz
-				$_SESSION['USE_DEFAULT_TIMEZONE'] = true;
-			}
-			// Set date format
-			if($results_array['date_format'] != '') {
-				$_SESSION['DATE_FORMAT'] = $results_array['date_format'];
-			} else {
-				// Set a session var so apps can tell user is using default date format
-				$_SESSION['USE_DEFAULT_DATE_FORMAT'] = true;
-			}
-			// Set time format
-			if($results_array['time_format'] != '') {
-				$_SESSION['TIME_FORMAT'] = $results_array['time_format'];
-			} else {
-				// Set a session var so apps can tell user is using default time format
-				$_SESSION['USE_DEFAULT_TIME_FORMAT'] = true;
-			}
+    // Authenticate the user (check if they exist in the database)
+    function authenticate()
+    {
+        // Get user information
+        $loginname = ( preg_match('/^['.self::USER_CHARS.']+$/s',$this->username) ? $this->username : '0');
+        $aSettings = array();
+        $aSettings['SYSTEM_PERMISSIONS']   = array();
+        $aSettings['MODULE_PERMISSIONS']   = array();
+        $aSettings['TEMPLATE_PERMISSIONS'] = array();
+        $bRetval = false;
 
-			// Get group information
-			$_SESSION['SYSTEM_PERMISSIONS'] = array();
-			$_SESSION['MODULE_PERMISSIONS'] = array();
-			$_SESSION['TEMPLATE_PERMISSIONS'] = array();
-			$_SESSION['GROUP_NAME'] = array();
-
-            $aGroupsIds = ((explode(',', $this->get_session('GROUPS_ID'))));
-            $bOnlyAdminGroup = $this->ami_group_member('1') && (sizeof($aGroupsIds) == 1);
-			$first_group = true;
-
-			foreach ( $aGroupsIds  as $cur_group_id)
-            {
-				$sql = 'SELECT * FROM `'.$this->groups_table.'` WHERE `group_id`=\''.$cur_group_id.'\'';
-				if($results = $database->query($sql)) {
-    				$results_array = $results->fetchRow(MYSQL_ASSOC);
-    				$_SESSION['GROUP_NAME'][$cur_group_id] = $results_array['name'];
-				}
-
-				// Set system permissions
-				if( ($results_array['system_permissions'] != '') ) {
-                    switch ($cur_group_id) :
-                        case 1:
-                            if( $this->user_id == 1) {
-               					$_SESSION['SYSTEM_PERMISSIONS'] = array_merge($_SESSION['SYSTEM_PERMISSIONS'], explode(',', $results_array['system_permissions']));
+        $sql = 'SELECT * FROM `'.$this->oDb->TablePrefix.'users` '
+             . 'WHERE `username`=\''.$this->oDb->escapeString($loginname).'\'';
+        if (($oUser = $this->oDb->doQuery($sql))) {
+            if (($aUser = $oUser->fetchArray())) {
+                if (
+                    $aUser['password'] == $this->password &&
+                    $aUser['active'] == 1
+                ) {
+                // valide authentcation !!
+                    $user_id                   = $aUser['user_id'];
+                    $this->user_id             = $user_id;
+                    $aSettings['USER_ID']      = $user_id;
+                    $aSettings['GROUP_ID']     = $aUser['group_id'];
+                    $aSettings['GROUPS_ID']    = $aUser['groups_id'];
+                    $aSettings['USERNAME']     = $aUser['username'];
+                    $aSettings['DISPLAY_NAME'] = $aUser['display_name'];
+                    $aSettings['EMAIL']        = $aUser['email'];
+                    $aSettings['HOME_FOLDER']  = $aUser['home_folder'];
+                    // Run remember function if needed
+                    if($this->remember == true) {
+                        $this->remember($this->user_id);
+                    }
+                    // Set language
+                    if($aUser['language'] != '') {
+                        $aSettings['LANGUAGE'] = $aUser['language'];
+                    }
+                    // Set timezone
+                    if($aUser['timezone'] != '-72000') {
+                        $aSettings['TIMEZONE'] = $aUser['timezone'];
+                    } else {
+                        // Set a session var so apps can tell user is using default tz
+                        $aSettings['USE_DEFAULT_TIMEZONE'] = true;
+                    }
+                    // Set date format
+                    if($aUser['date_format'] != '') {
+                        $aSettings['DATE_FORMAT'] = $aUser['date_format'];
+                    } else {
+                        // Set a session var so apps can tell user is using default date format
+                        $aSettings['USE_DEFAULT_DATE_FORMAT'] = true;
+                    }
+                    // Set time format
+                    if($aUser['time_format'] != '') {
+                        $aSettings['TIME_FORMAT'] = $aUser['time_format'];
+                    } else {
+                        // Set a session var so apps can tell user is using default time format
+                        $aSettings['USE_DEFAULT_TIME_FORMAT'] = true;
+                    }
+                    // Get group information
+                    $aSettings['GROUP_NAME'] = array();
+                    $bOnlyAdminGroup = $this->ami_group_member('1') && (sizeof($aGroupsIds) == 1);
+                    $sql = 'SELECT * FROM `'.$this->oDb->TablePrefix.'groups` '
+                         . 'WHERE `group_id` IN (\''.$aUser['groups_id'].',0\') '
+                         . 'ORDER BY `group_id`';
+                    if (($oGroups = $this->oDb->doQuery($sql))) {
+                        while (($aGroup = $oGroups->fetchArray())) {
+                            $aSettings['GROUP_NAME'][$aGroup['group_id']] = $aGroup['name'];
+                        // collect system_permissions (additively)
+                            $aSettings['SYSTEM_PERMISSIONS'] = array_merge(
+                                $aSettings['SYSTEM_PERMISSIONS'],
+                                explode(',', $aGroup['system_permissions'])
+                            );
+                        // collect module_permission (subtractive)
+                            if (!sizeof($aSettings['MODULE_PERMISSIONS'])) {
+                                $aSettings['MODULE_PERMISSIONS'] = explode(',', $aGroup['module_permissions']);
                             } else {
-                                $_SESSION['SYSTEM_PERMISSIONS'] = explode(',', $results_array['system_permissions']);
+                                $aSettings['MODULE_PERMISSIONS'] = array_intersect(
+                                    $aSettings['MODULE_PERMISSIONS'],
+                                    preg_split('/\s*[,;\|\+]/', $aGroup['module_permissions'], -1, PREG_SPLIT_NO_EMPTY)
+                                );
                             }
+                        // collect template_permission (subtractive)
+                            if (!sizeof($aSettings['TEMPLATE_PERMISSIONS'])) {
+                                $aSettings['TEMPLATE_PERMISSIONS'] = explode(',', $aGroup['template_permissions']);
+                            } else {
+                                $aSettings['TEMPLATE_PERMISSIONS'] = array_intersect(
+                                    $aSettings['TEMPLATE_PERMISSIONS'],
+                                    preg_split('/\s*[,;\|\+]/', $aGroup['template_permissions'], -1, PREG_SPLIT_NO_EMPTY)
+                                );
+                            }
+                        }
+                    }
+                    // Update the users table with current ip and timestamp
+                    $sRemoteAddress = @$_SERVER['REMOTE_ADDR'] ?: 'unknown';
+                    $sql = 'UPDATE `'.$this->oDb->TablePrefix.'users` '
+                         . 'SET `login_when`='.time().', '
+                         .     '`login_ip`=\''.$sRemoteAddress.'\' '
+                         . 'WHERE `user_id`=\''.$user_id.'\'';
+                    $this->oDb->doQuery($sql);
+                    $bRetval = true;
+                }
+            }
+        }
+        // merge settings into $_SESSION and overwrite older one values
+        $_SESSION = array_merge($_SESSION, $aSettings);
+        // Return if the user exists or not
+        return $bRetval;
+    }
 
-                            break;
-                        default:
-        					$_SESSION['SYSTEM_PERMISSIONS'] = array_merge($_SESSION['SYSTEM_PERMISSIONS'], explode(',', $results_array['system_permissions']));
-                    endswitch;
-				}
+    // Increase the count for login attemps
+    function increase_attemps()
+    {
+        $_SESSION['ATTEMPS'] = (isset($_SESSION['ATTEMPS']) ? $_SESSION['ATTEMPS']++ : 0);
+        $this->display_login();
+    }
 
-				// Set module permissions
-				if( $results_array['module_permissions'] != '' ) {
-					if ($first_group) {
-                  	$_SESSION['MODULE_PERMISSIONS'] = explode(',', $results_array['module_permissions']);
-                  } else {
-                  	$_SESSION['MODULE_PERMISSIONS'] = array_intersect($_SESSION['MODULE_PERMISSIONS'], explode(',', $results_array['module_permissions']));
-					}
-				}
-				// Set template permissions
-				if($results_array['template_permissions'] != '') {
-					if ($first_group) {
-                      	$_SESSION['TEMPLATE_PERMISSIONS'] = explode(',', $results_array['template_permissions']);
-                      } else {
-                      	$_SESSION['TEMPLATE_PERMISSIONS'] = array_intersect($_SESSION['TEMPLATE_PERMISSIONS'], explode(',', $results_array['template_permissions']));
-					}
-				}
-				$first_group = false;
-			}
+    // Function to set a "remembering" cookie for the user - removed
+    function remember($user_id)
+    {
+        return true;
+    }
 
-//            if( $$bOnlyAdminGroup ) {
-//    			$_SESSION['MODULE_PERMISSIONS'] = array();
-//    			$_SESSION['TEMPLATE_PERMISSIONS'] = array();
-//            }
+    // Function to check if a user has been remembered - removed
+    function is_remembered()
+    {
+        return false;
+    }
 
-			// Update the users table with current ip and timestamp
-			$get_ts = time();
-			$get_ip = $_SERVER['REMOTE_ADDR'];
-			$sql  = 'UPDATE `'.$this->users_table.'` ';
-			$sql .= 'SET `login_when`=\''.$get_ts.'\', `login_ip`=\''.$get_ip.'\' ';
-			$sql .= 'WHERE `user_id`=\''.$user_id.'\'';
-			$database->query($sql);
-		}else {
-		  $num_rows = 0;
-		}
-		// Return if the user exists or not
-		return $num_rows;
-	}
+    // Display the login screen
+    function display_login()
+    {
+        // If attemps more than allowed, warn the user
+        if($this->get_session('ATTEMPS') > $this->max_attemps) {
+            $this->warn();
+        }
+        // Show the login form
+        if($this->frontend != true) {
+            $template = new Template(dirname($this->correct_theme_source($this->template_file)));
+            $template->set_file('page', $this->template_file);
+            $template->set_block('page', 'mainBlock', 'main');
+            $template->set_var('DISPLAY_REMEMBER_ME', ($this->remember_me_option ? '' : 'display: none;'));
+            $template->set_var($this->oTrans->getLangArray());
+            $template->set_var(
+                array(
+                    'TITLE_LOGOUT'           => $this->oTrans->MENU_LOGIN,
+                    'TITLE_VIEW'             => $this->oTrans->TEXT_WEBSITE,
+                    'SECTION_NAME'           => $this->oTrans->MENU_LOGIN,
+                    'SECTION_LOGIN'          => $this->oTrans->MENU_LOGIN,
+                    'ACTION_URL'             => $this->login_url,
+                    'URL'                    => $this->default_url,
+                    'ATTEMPS'                => $this->get_session('ATTEMPS'),
+                    'USERNAME'               => $this->username,
+                    'USERNAME_FIELDNAME'     => $this->username_fieldname,
+                    'PASSWORD_FIELDNAME'     => $this->password_fieldname,
+                    'MESSAGE'                => $this->message,
+                    'WEBSITE_TITLE'          => $this->oReg->WebsiteTitle,
+                    'INTERFACE_DIR_URL'      => $this->oReg->AcpUrl.'interface',
+                    'MAX_USERNAME_LEN'       => $this->max_username_len,
+                    'MAX_PASSWORD_LEN'       => $this->max_password_len,
+                    'ADMIN_URL'              => $this->oReg->AcpUrl,
+                    'WB_URL'                 => $this->oReg->AppUrl,
+                    'URL_VIEW'               => $this->oReg->AppUrl,
+                    'THEME_URL'              => $this->oReg->ThemeUrl,
+                    'VERSION'                => $this->oReg->Version,
+                    'SP'                     => (isset($this->oReg->Sp) ? $this->oReg->Sp : ''),
+                    'REVISION'               => $this->oReg->Revision,
+                    'LANGUAGE'               => strtolower($this->oReg->Language),
+                    'FORGOTTEN_DETAILS_APP'  => $this->forgotten_details_app,
+                    'PAGES_DIRECTORY'        => $this->oReg->PagesDir,
+                    'LOGIN_DISPLAY_HIDDEN'   => !$this->is_authenticated() ? 'hidden' : '',
+                    'LOGIN_DISPLAY_NONE'     => !$this->is_authenticated() ? 'none' : '',
+                    'LOGIN_LINK'             => $_SERVER['SCRIPT_NAME'],
+                    'LOGIN_ICON'             => 'login',
+                    'START_ICON'             => 'blank',
+                    'URL_HELP'               => 'http://wiki.websitebaker.org/',
+                )
+            );
+            $template->set_var('CHARSET', (isset($this->oReg->DefaultCharset) ? $this->oReg->DefaultCharset : 'utf-8'));
+            $template->parse('main', 'mainBlock', false);
+            $template->pparse('output', 'page');
+        }
+    }
+    // sanities the REMEMBER_KEY cookie to avoid SQL injection
+    function get_safe_remember_key()
+    {
+        $iMatches = 0;
+        if (isset($_COOKIE['REMEMBER_KEY'])) {
+            $sRetval = preg_replace(
+                '/^([0-9]{11})_([0-9a-f]{11})$/i',
+                '\1\2',
+                $_COOKIE['REMEMBER_KEY'], -1, $iMatches
+            );
+        }
+        return ($iMatches ? $sRetval : '');
+    }
+    // Warn user that they have had to many login attemps
+    function warn()
+    {
+        $this->send_header($this->warning_url);
+        exit;
+    }
 
-	// Increase the count for login attemps
-	function increase_attemps() {
-		if(!isset($_SESSION['ATTEMPS'])) {
-			$_SESSION['ATTEMPS'] = 0;
-		} else {
-			$_SESSION['ATTEMPS'] = $this->get_session('ATTEMPS')+1;
-		}
-		$this->display_login();
-	}
-
-	// Function to set a "remembering" cookie for the user - removed
-	function remember($user_id) {
-		return true;
-	}
-
-	// Function to check if a user has been remembered - removed
-	function is_remembered()
-	{
-		return false;
-	}
-
-	// Display the login screen
-	function display_login() {
-		// Get language vars
-		global $MESSAGE, $MENU, $TEXT;
-		// If attemps more than allowed, warn the user
-		if($this->get_session('ATTEMPS') > $this->max_attemps) {
-			$this->warn();
-		}
-		// Show the login form
-		if($this->frontend != true) {
-			//require_once(WB_PATH.'/include/phplib/template.inc');
-			// $template = new Template($this->template_dir);
-			// Setup template object, parse vars to it, then parse it
-			$template = new Template(dirname($this->correct_theme_source($this->template_file)));
-			$template->set_file('page', $this->template_file);
-			$template->set_block('page', 'mainBlock', 'main');
-			if($this->remember_me_option != true) {
-				$template->set_var('DISPLAY_REMEMBER_ME', 'display: none;');
-			} else {
-				$template->set_var('DISPLAY_REMEMBER_ME', '');
-			}
-			$template->set_var(array(
-				'ACTION_URL' => $this->login_url,
-				'URL' => $this->default_url,
-				'ATTEMPS' => $this->get_session('ATTEMPS'),
-				'USERNAME' => $this->username,
-				'USERNAME_FIELDNAME' => $this->username_fieldname,
-				'PASSWORD_FIELDNAME' => $this->password_fieldname,
-				'MESSAGE' => $this->message,
-				'WEBSITE_TITLE' => WEBSITE_TITLE,
-				'TEXT_ADMINISTRATION' => $TEXT['ADMINISTRATION'],
-				'INTERFACE_DIR_URL' =>  ADMIN_URL.'/interface',
-				'MAX_USERNAME_LEN' => $this->max_username_len,
-				'MAX_PASSWORD_LEN' => $this->max_password_len,
-				'ADMIN_URL' => ADMIN_URL,
-				'WB_URL' => WB_URL,
-				'URL_VIEW' => WB_URL,
-				'THEME_URL' => THEME_URL,
-				'VERSION' => VERSION,
-				'SP' => (defined('SP') ? SP : ''),
-				'REVISION' => REVISION,
-				'LANGUAGE' => strtolower(LANGUAGE),
-				'FORGOTTEN_DETAILS_APP' => $this->forgotten_details_app,
-				'TEXT_FORGOTTEN_DETAILS' => $TEXT['FORGOTTEN_DETAILS'],
-				'TEXT_USERNAME' => $TEXT['USERNAME'],
-				'TEXT_PASSWORD' => $TEXT['PASSWORD'],
-				'TEXT_REMEMBER_ME' => $TEXT['REMEMBER_ME'],
-				'TEXT_LOGIN' => $TEXT['LOGIN'],
-				'TITLE_LOGOUT' => $MENU['LOGIN'],
-				'TEXT_RESET' => $TEXT['RESET'],
-				'TEXT_HOME' => $TEXT['HOME'],
-				'TITLE_VIEW' => $TEXT['WEBSITE'],
-				'PAGES_DIRECTORY' => PAGES_DIRECTORY,
-				'SECTION_NAME' => $MENU['LOGIN'],
-				'SECTION_LOGIN' => $MENU['LOGIN'],
-				'LOGIN_DISPLAY_HIDDEN' => !$this->is_authenticated() ? 'hidden' : '',
-				'LOGIN_DISPLAY_NONE' => !$this->is_authenticated() ? 'none' : '',
-				'LOGIN_LINK' => $_SERVER['SCRIPT_NAME'],
-				'LOGIN_ICON' => 'login',
-				'START_ICON' => 'blank',
-				'URL_HELP' => 'http://www.websitebaker.org/',
-				)
-			);
-			if(defined('DEFAULT_CHARSET')) {
-				$charset=DEFAULT_CHARSET;
-			} else {
-				$charset='utf-8';
-			}
-
-			$template->set_var('CHARSET', $charset);
-
-			$template->parse('main', 'mainBlock', false);
-			$template->pparse('output', 'page');
-		}
-	}
-
-	// sanities the REMEMBER_KEY cookie to avoid SQL injection
-	function get_safe_remember_key() {
-		if (!((strlen($_COOKIE['REMEMBER_KEY']) == 23) && (substr($_COOKIE['REMEMBER_KEY'], 11, 1) == '_'))) return '';
-		// create a clean cookie (XXXXXXXXXXX_YYYYYYYYYYY) where X:= numeric, Y:= hash
-		$clean_cookie = sprintf('%011d', (int) substr($_COOKIE['REMEMBER_KEY'], 0, 11)) . substr($_COOKIE['REMEMBER_KEY'], 11);
-		return ($clean_cookie == $_COOKIE['REMEMBER_KEY']) ? $this->add_slashes($clean_cookie) : '';
-	}
-
-	// Warn user that they have had to many login attemps
-	function warn() {
-//		header('Location: '.$this->warning_url);
-		$this->send_header($this->warning_url);
-		exit(0);
-	}
-
 }
