root/wifidogadmin/wifidog/resend_validation.php

Revision 479, 6.8 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  * Resends the validation e-mail if it has been requested by the user
38  *
39  * @package    WiFiDogAuthServer
40  * @author     Philippe April
41  * @author     Benoit Grégoire <bock@step.polymtl.ca>
42  * @author     Max Horváth <max.horvath@freenet.de>
43  * @copyright  2004-2006 Philippe April
44  * @copyright  2004-2006 Benoit Grégoire, Technologies Coeus inc.
45  * @copyright  2006 Max Horváth, Horvath Web Consulting
46  * @version    Subversion $Id: resend_validation.php 1249 2007-07-12 20:05:42Z benoitg $
47  * @link       http://www.wifidog.org/
48  */
49
50 /**
51  * Load required files
52  */
53 require_once(dirname(__FILE__) . '/include/common.php');
54
55 require_once('classes/User.php');
56 require_once('classes/MainUI.php');
57 $smarty = SmartyWifidog::getObject();
58 /**
59  * Process recovering username
60  */
61
62 // Init ALL smarty SWITCH values
63 $smarty->assign('sectionTOOLCONTENT', false);
64 $smarty->assign('sectionMAINCONTENT', false);
65
66 // Init ALL smarty values
67 $smarty->assign('username', "");
68 $smarty->assign('message', "");
69 $smarty->assign('error', "");
70 $smarty->assign('auth_sources', "");
71 $smarty->assign('selected_auth_source', "");
72 $smarty->assign('SelectNetworkUI', "");
73
74 if (isset($_REQUEST["form_request"])) {
75     $account_origin = Network::getObject($_REQUEST['auth_source']);
76
77     try {
78         /*
79          * Tool content
80          */
81
82         // Set section of Smarty template
83         $smarty->assign('sectionTOOLCONTENT', true);
84
85         // Compile HTML code
86         $html = $smarty->fetch("templates/sites/resend_validation.tpl");
87
88         /*
89          * Main content
90          */
91
92         // Reset ALL smarty SWITCH values
93         $smarty->assign('sectionTOOLCONTENT', false);
94         $smarty->assign('sectionMAINCONTENT', false);
95
96         // Set section of Smarty template
97         $smarty->assign('sectionMAINCONTENT', true);
98
99         if (empty($account_origin)) {
100             throw new Exception(_("Sorry, this network does not exist !"));
101         }
102
103         if (!$_REQUEST["username"]) {
104             throw new Exception(_("Please specify a username"));
105         }
106
107         // Get a list of users with this username
108         $user = User::getUserByUsernameAndOrigin($_REQUEST['username'], $account_origin);
109
110         if ($user == null) {
111             throw new Exception(_("This username could not be found in our database"));
112         }
113
114         $user->sendValidationEmail();
115
116         $smarty->assign('message', _("An email with confirmation instructions was sent to your email address."));
117
118         // Compile HTML code
119         $html_body = $smarty->fetch("templates/sites/validate.tpl");
120
121         /*
122          * Render output
123          */
124         $ui = MainUI::getObject();
125         $ui->addContent('left_area_middle', $html);
126         $ui->addContent('main_area_middle', $html_body);
127         $ui->display();
128
129         // We're done ...
130         exit;
131     } catch (Exception $e) {
132         $smarty->assign('error', $e->getMessage());
133
134         // Reset HTML output
135         $html = "";
136         $html_body = "";
137
138         // Reset ALL smarty SWITCH values
139         $smarty->assign('sectionTOOLCONTENT', false);
140         $smarty->assign('sectionMAINCONTENT', false);
141     }
142 }
143
144 /*
145  * Tool content
146  */
147
148 // Set section of Smarty template
149 $smarty->assign('sectionTOOLCONTENT', true);
150
151 // Compile HTML code
152 $html = $smarty->fetch("templates/sites/resend_validation.tpl");
153
154 /*
155  * Main content
156  */
157
158 // Reset ALL smarty SWITCH values
159 $smarty->assign('sectionTOOLCONTENT', false);
160 $smarty->assign('sectionMAINCONTENT', false);
161
162 // Set section of Smarty template
163 $smarty->assign('sectionMAINCONTENT', true);
164
165 // Add the auth servers list to smarty variables
166 $sources = array();
167
168 // Preserve keys
169 $network_array=Network::getAllNetworks();
170
171 foreach ($network_array as $network) {
172     if ($network->getAuthenticator()->isRegistrationPermitted()) {
173         $sources[$network->getId()] = $network->getName();
174     }
175 }
176
177 if (isset($sources)) {
178     $smarty->assign('auth_sources', $sources);
179 }
180
181 // Pass the account_origin along, if it's set
182 if (isset($_REQUEST["auth_source"])) {
183     $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]);
184 }
185
186 $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source'));
187
188 // Compile HTML code
189 $html_body = $smarty->fetch("templates/sites/resend_validation.tpl");
190
191 /*
192  * Render output
193  */
194 $ui = MainUI::getObject();
195 $ui->addContent('left_area_middle', $html);
196 $ui->addContent('main_area_middle', $html_body);
197 $ui->display();
198
199 /*
200  * Local variables:
201  * tab-width: 4
202  * c-basic-offset: 4
203  * c-hanging-comment-ender-p: nil
204  * End:
205  */
206
207 ?>
208
Note: See TracBrowser for help on using the browser.