root/wifidogadmin/wifidog/lost_username.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 username
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: lost_username.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('message', "");
68 $smarty->assign('error', "");
69 $smarty->assign('auth_sources', "");
70 $smarty->assign('selected_auth_source', "");
71 $smarty->assign('SelectNetworkUI', "");
72
73 $smarty->assign('email', "");
74
75 if (isset($_REQUEST["form_request"])) {
76     $account_origin = Network::getObject($_REQUEST['auth_source']);
77
78     try {
79         /*
80          * Tool content
81          */
82
83         // Set section of Smarty template
84         $smarty->assign('sectionTOOLCONTENT', true);
85
86         // Compile HTML code
87         $html = $smarty->fetch("templates/sites/lost_username.tpl");
88
89         /*
90          * Main content
91          */
92
93         // Reset ALL smarty SWITCH values
94         $smarty->assign('sectionTOOLCONTENT', false);
95         $smarty->assign('sectionMAINCONTENT', false);
96
97         // Set section of Smarty template
98         $smarty->assign('sectionMAINCONTENT', true);
99
100         if (empty($account_origin)) {
101             throw new Exception(_("Sorry, this network does not exist !"));
102         }
103
104         if (!$_REQUEST["email"]) {
105             throw new Exception(_("Please specify an email address"));
106         }
107
108         // Get a list of User objects and send mail messages to them
109         $user = User::getUserByEmailAndOrigin($_REQUEST['email'], $account_origin);
110
111         if ($user == null) {
112                 throw new Exception(_("This email could not be found in our database"));
113         }
114
115         $user->sendLostUsername();
116
117         $smarty->assign("message", _("Your username has been emailed to you."));
118
119         // Compile HTML code
120         $html_body = $smarty->fetch("templates/sites/validate.tpl");
121
122         /*
123          * Render output
124          */
125         $ui = MainUI::getObject();
126         $ui->addContent('left_area_middle', $html);
127         $ui->addContent('main_area_middle', $html_body);
128         $ui->display();
129
130         // We're done ...
131         exit;
132     } catch (Exception $e) {
133         $smarty->assign("error", $e->getMessage());
134
135         // Reset HTML output
136         $html = "";
137         $html_body = "";
138
139         // Reset ALL smarty SWITCH values
140         $smarty->assign('sectionTOOLCONTENT', false);
141         $smarty->assign('sectionMAINCONTENT', false);
142     }
143 }
144
145 /*
146  * Tool content
147  */
148
149 // Set section of Smarty template
150 $smarty->assign('sectionTOOLCONTENT', true);
151
152 // Compile HTML code
153 $html = $smarty->fetch("templates/sites/lost_username.tpl");
154
155 /*
156  * Main content
157  */
158
159 // Reset ALL smarty SWITCH values
160 $smarty->assign('sectionTOOLCONTENT', false);
161 $smarty->assign('sectionMAINCONTENT', false);
162
163 // Set section of Smarty template
164 $smarty->assign('sectionMAINCONTENT', true);
165
166 // Add the auth servers list to smarty variables
167 $sources = array();
168
169 // Preserve keys
170 $network_array = Network::getAllNetworks();
171
172 foreach ($network_array as $network) {
173     if ($network->getAuthenticator()->isRegistrationPermitted()) {
174         $sources[$network->getId()] = $network->getName();
175     }
176 }
177
178 if (isset($sources)) {
179     $smarty->assign('auth_sources', $sources);
180 }
181
182 // Pass the account_origin along, if it's set
183 if (isset($_REQUEST["auth_source"])) {
184     $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]);
185 }
186
187 $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source'));
188
189 // Compile HTML code
190 $html_body = $smarty->fetch("templates/sites/lost_username.tpl");
191
192 /*
193  * Render output
194  */
195 $ui = MainUI::getObject();
196 $ui->addContent('left_area_middle', $html);
197 $ui->addContent('main_area_middle', $html_body);
198 $ui->display();
199
200 /*
201  * Local variables:
202  * tab-width: 4
203  * c-basic-offset: 4
204  * c-hanging-comment-ender-p: nil
205  * End:
206  */
207
208 ?>
209
Note: See TracBrowser for help on using the browser.