root/wifidogadmin/wifidog/validate.php
| Revision 479, 4.4 kB (checked in by insultant, 8 months ago) |
|---|
| Line | |
|---|---|
| 1 | <?php |
| 2 | |
| 3 | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
| 4 | |
| 5 | // +-------------------------------------------------------------------+ |
| 6 | // | WiFiDog Authentication Server | |
| 7 | // | ============================= | |
| 8 | // | | |
| 9 | // | The WiFiDog Authentication Server is part of the WiFiDog captive | |
| 10 | // | portal suite. | |
| 11 | // +-------------------------------------------------------------------+ |
| 12 | // | PHP version 5 required. | |
| 13 | // +-------------------------------------------------------------------+ |
| 14 | // | Homepage: http://www.wifidog.org/ | |
| 15 | // | Source Forge: http://sourceforge.net/projects/wifidog/ | |
| 16 | // +-------------------------------------------------------------------+ |
| 17 | // | This program is free software; you can redistribute it and/or | |
| 18 | // | modify it under the terms of the GNU General Public License as | |
| 19 | // | published by the Free Software Foundation; either version 2 of | |
| 20 | // | the License, or (at your option) any later version. | |
| 21 | // | | |
| 22 | // | This program is distributed in the hope that it will be useful, | |
| 23 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 24 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 25 | // | GNU General Public License for more details. | |
| 26 | // | | |
| 27 | // | You should have received a copy of the GNU General Public License | |
| 28 | // | along with this program; if not, contact: | |
| 29 | // | | |
| 30 | // | Free Software Foundation Voice: +1-617-542-5942 | |
| 31 | // | 59 Temple Place - Suite 330 Fax: +1-617-542-2652 | |
| 32 | // | Boston, MA 02111-1307, USA gnu@gnu.org | |
| 33 | // | | |
| 34 | // +-------------------------------------------------------------------+ |
| 35 | |
| 36 | /** |
| 37 | * @package WiFiDogAuthServer |
| 38 | * @author Philippe April |
| 39 | * @author Benoit Grégoire <bock@step.polymtl.ca> |
| 40 | * @copyright 2004-2006 Philippe April |
| 41 | * @copyright 2004-2006 Benoit Grégoire, Technologies Coeus inc. |
| 42 | * @version Subversion $Id: validate.php 1249 2007-07-12 20:05:42Z benoitg $ |
| 43 | * @link http://www.wifidog.org/ |
| 44 | */ |
| 45 | |
| 46 | /** |
| 47 | * Load required files |
| 48 | */ |
| 49 | require_once(dirname(__FILE__) . '/include/common.php'); |
| 50 | |
| 51 | require_once('classes/User.php'); |
| 52 | require_once('classes/Node.php'); |
| 53 | require_once('classes/MainUI.php'); |
| 54 | $smarty = SmartyWifidog::getObject(); |
| 55 | $db = AbstractDb::getObject(); |
| 56 | try { |
| 57 | if (!isset($_REQUEST["token"])) |
| 58 | throw new Exception(_('No token specified!')); |
| 59 | |
| 60 | if (!isset($_REQUEST["user_id"])) |
| 61 | throw new Exception(_('No user ID specified!')); |
| 62 | |
| 63 | $validated_user = User::getObject($_REQUEST['user_id']); |
| 64 | |
| 65 | if ($db->escapeString($_REQUEST['token']) != $validated_user->getValidationToken()) |
| 66 | throw new Exception(_('The validation token does not match the one in the database.')); |
| 67 | |
| 68 | if ($validated_user->getAccountStatus() == ACCOUNT_STATUS_ALLOWED) |
| 69 | throw new Exception(_('Your account has already been activated.')); |
| 70 | |
| 71 | // This user wants to validate his account, the token is OK and he's not trying to pass the same token more than once |
| 72 | // Activate his account and let him in NOW |
| 73 | $validated_user->SetAccountStatus(ACCOUNT_STATUS_ALLOWED); |
| 74 | User::setCurrentUser($validated_user); |
| 75 | |
| 76 | // Show activation message |
| 77 | $smarty->assign('message', _("Your account has been succesfully activated!\n\nYou may now browse to a remote Internet address and take advantage of the free Internet access!\n\nIf you get prompted for a login, enter the username and password you have just created.")); |
| 78 | } catch (Exception $e) { |
| 79 | $smarty->assign('message', $e->getMessage()); |
| 80 | } |
| 81 | |
| 82 | $ui = MainUI::getObject(); |
| 83 | $ui->addContent('main_area_middle', $smarty->fetch("templates/sites/validate.tpl")); |
| 84 | $ui->display(); |
| 85 | |
| 86 | /* |
| 87 | * Local variables: |
| 88 | * tab-width: 4 |
| 89 | * c-basic-offset: 4 |
| 90 | * c-hanging-comment-ender-p: nil |
| 91 | * End: |
| 92 | */ |
| 93 | |
| 94 | ?> |
| 95 |
Note: See TracBrowser for help on using the browser.
