<?php
/*
Copyright (C) 2009 DantoBB Team
http://www.dantobb.com
*/
/**
* Panel user activation
*
* Gives an interface to activate user accounts.
*
* @author DantoBB Team
* @link http://www.dantobb.com
* @license GPL-2
* @version $Revision: 1.0 $
* @copyright Copyright (C) 2009 DantoBB Team
* @package DantoBB
* @subpackage Panel
*/
//
// Die when called directly in browser
//
if ( !defined('INCLUDED') )
exit();
//
// User wants to activate
//
$session->update('activate');
//
// Include the page header
//
require(ROOT_PATH.'sources/page_head.php');
$template->set_page_title($lang['Activate']);
//
// Check if the user exists
//
$result = $db->query("SELECT id, name, active, active_key FROM ".TABLE_PREFIX."members WHERE id = ".$_GET['id']);
$userdata = $db->fetch_result($result);
if ( $userdata['id'] ) {
//
// If this user is already active,
// show an error message
//
if ( $userdata['active'] ) {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Error'],
'content' => sprintf($lang['AlreadyActivated'], $_GET['id'])
));
//
// If the user is not yet active and the key is OK, activate the user
//
} elseif ( md5($_GET['key']) == $userdata['active_key'] ) {
$result = $db->query("UPDATE ".TABLE_PREFIX."members SET active = 1, active_key = '' WHERE id = ".$_GET['id']);
$session->update('activate', $_GET['id']);
//
// Activation was succesful!
//
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Activate'],
'content' => sprintf($lang['Activated'], '<em>'.unhtml(stripslashes($userdata['name'])).'</em>')
));
//
// If the user is not yet active and the key is not OK, show an error message
//
} else {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Error'],
'content' => sprintf($lang['WrongActivationKey'], $_GET['id'])
));
}
//
// Show an error if the user ID does not exist
//
} else {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Error'],
'content' => sprintf($lang['NoSuchMember'], 'ID '.$_GET['id'])
));
}
//
// Include the page footer
//
require(ROOT_PATH.'sources/page_foot.php');
?>