Possible further fix for #128
[mailer.git] / inc / modules / guest / what-register.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/10/2003 *
4  * ===============                              Last change: 11/26/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-register.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Registration form                                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Anmeldeformular                                  *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
42         require($INC);
43 } elseif ((!EXT_IS_ACTIVE('register'))) {
44         addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveNotInstalledMessage('register'));
45         return;
46 }
47
48 // Add description as navigation point
49 ADD_DESCR('guest', __FILE__);
50
51 global $DATA;
52
53 // Initialize variables
54 $isFailed   = false;
55 $shortPass = false;
56 $cats       = 0;
57 $ipTimedOut = false;
58
59 if (!isFormSent()) REQUEST_UNSET_POST('ok');
60
61 if (!REQUEST_ISSET_POST(('agree')))        REQUEST_SET_POST('agree'       , '');
62 if (!REQUEST_ISSET_POST(('addy')))         REQUEST_SET_POST('addy'        , '');
63 if (!REQUEST_ISSET_POST(('surname')))      REQUEST_SET_POST('surname'     , '');
64 if (!REQUEST_ISSET_POST(('family')))       REQUEST_SET_POST('family'      , '');
65 if (!REQUEST_ISSET_POST('pass1'))        REQUEST_SET_POST('pass1'       , '');
66 if (!REQUEST_ISSET_POST('pass2'))        REQUEST_SET_POST('pass2'       , '');
67 if (!REQUEST_ISSET_POST(('day')))          REQUEST_SET_POST('day'         , '');
68 if (!REQUEST_ISSET_POST(('month')))        REQUEST_SET_POST('month'       , '');
69 if (!REQUEST_ISSET_POST(('year')))         REQUEST_SET_POST('year'        , '');
70 if (!REQUEST_ISSET_POST(('max_mails')))    REQUEST_SET_POST('max_mails'   , '');
71 if (!REQUEST_ISSET_POST(('street_nr')))    REQUEST_SET_POST('street_nr'   , '');
72 if (!REQUEST_ISSET_POST('zip'))          REQUEST_SET_POST('zip'         , '');
73 if (!REQUEST_ISSET_POST(('city')))         REQUEST_SET_POST('city'        , '');
74 if (!REQUEST_ISSET_POST(('cntry')))        REQUEST_SET_POST('cntry'       , '');
75 if (!REQUEST_ISSET_POST(('country_code'))) REQUEST_SET_POST('country_code', '1');
76
77 // Default refid is zero
78 REQUEST_SET_POST('refid', 0);
79 if ($GLOBALS['refid'] > 0) {
80         // Test if the refid is valid
81         $result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
82         array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
83
84         // Userid found?
85         //* DEBUG: */ die("refid={$GLOBALS['refid']}/numRows=".SQL_NUMROWS($result)."");
86         if (SQL_NUMROWS($result) == 0) {
87                 // Not found so we set your refid!
88                 REQUEST_SET_POST('refid', getConfig('def_refid'));
89                 setSession('refid', getConfig('def_refid'));
90         } else {
91                 // Use the refid here
92                 REQUEST_SET_POST('refid', $GLOBALS['refid']);
93         }
94 } // END - if
95
96 if (isFormSent()) {
97         // First we only check the submitted data then we continue... :)
98         //
99         // Did he agree to our Terms Of Usage?
100         if (REQUEST_POST('agree') != 'Y') {
101                 REQUEST_SET_POST('agree', '!');
102                 $isFailed = true;
103         } // END - if
104
105         // Did he enter a valid email address? (we really don't care about
106         // that, he has to click on a confirmation link :P )
107         if ((!REQUEST_ISSET_POST(('addy'))) || (!isEmailValid(REQUEST_POST('addy')))) {
108                 REQUEST_SET_POST('addy', '!');
109                 $isFailed = true;
110         } // END - if
111
112         // And what about surname and family's name?
113         if (!REQUEST_ISSET_POST(('surname'))) {
114                 REQUEST_SET_POST('surname', '!');
115                 $isFailed = true;
116         } // END - if
117         if (!REQUEST_ISSET_POST(('family'))) {
118                 REQUEST_SET_POST('family', '!');
119                 $isFailed = true;
120         } // END - if
121
122         // Get temporary array for modification
123         $postArray = REQUEST_POST_ARRAY();
124
125         // Check for required fields
126         if ($isFailed === false) $isFailed = ifRequiredRegisterFieldsAreSet($postArray);
127
128         // Set it back in request
129         REQUEST_SET_POST_ARRAY($postArray);
130
131         // Did he enter his password twice?
132         if (((!REQUEST_ISSET_POST('pass1')) || (!REQUEST_ISSET_POST('pass2'))) || ((REQUEST_POST('pass1') != REQUEST_POST('pass2')) && (REQUEST_ISSET_POST('pass1')) && (REQUEST_ISSET_POST('pass2')))) {
133                 if ((REQUEST_POST('pass1') != REQUEST_POST('pass2')) && (REQUEST_ISSET_POST('pass1')) && (REQUEST_ISSET_POST('pass2'))) {
134                         REQUEST_SET_POST('pass1', '!');
135                         REQUEST_SET_POST('pass2', '!');
136                 } else {
137                         if (!REQUEST_ISSET_POST('pass1')) { REQUEST_SET_POST('pass1', '!'); } else { REQUEST_SET_POST('pass1', ''); }
138                         if (!REQUEST_ISSET_POST('pass2')) { REQUEST_SET_POST('pass2', '!'); } else { REQUEST_SET_POST('pass2', ''); }
139                 }
140                 $isFailed = true;
141         } // END - if
142
143         // Is the password long enouth?
144         if ((strlen(REQUEST_POST('pass1')) < getConfig('pass_len')) && ($isFailed === false)) {
145                 $shortPass = true;
146                 $isFailed = true;
147         } // END - if
148
149         // No admin? Admins can always register!
150         if (!IS_ADMIN()) {
151                 // Do this check only when no admin is logged in
152                 foreach (REQUEST_POST('cat') as $id => $answer) {
153                         if ($answer == 'Y') $cats++;
154                 } // END - foreach
155
156                 if ($cats < getConfig('least_cats')) {
157                         // ... nope!
158                         $isFailed = true;
159                 } // END - if
160         } // END - if
161
162         if ((REQUEST_POST('addy') != '!') && (getConfig('check_double_email') == 'Y')) {
163                 // Does the email address already exists in our database?
164                 $CHK = isEmailTaken(REQUEST_POST('addy'));
165                 if ($CHK === true) {
166                         REQUEST_SET_POST('addy', '?');
167                         $isFailed = true;
168                 } // END - if
169         } // END - if
170
171         // Check for IP timeout?
172         if (getConfig('ip_timeout') > 0) {
173                 // Check his IP number
174                 $result = SQL_QUERY_ESC("SELECT joined, last_update FROM `{!_MYSQL_PREFIX!}_user_data` WHERE REMOTE_ADDR='%s' AND (joined > (UNIX_TIMESTAMP() - %s) OR last_update > (UNIX_TIMESTAMP() - %s)) LIMIT 1",
175                 array(detectRemoteAddr(), getConfig('ip_timeout'), getConfig('ip_timeout')), __FILE__, __LINE__);
176                 if (SQL_NUMROWS($result) == 1) {
177                         // Same IP in timeout range and different email address entered... Eat this, faker! ;-)
178                         // But admins are allowed to fake their own exchange service.
179                         $ipTimedOut = true;
180                         $isFailed = true;
181                 } // END - if
182         } // END - if
183
184         // Free memory
185         SQL_FREERESULT($result);
186 }
187
188 if ((isFormSent()) && (($isFailed === false) || (IS_ADMIN()))) {
189         // Prepapre month and day of birth
190         if (strlen(REQUEST_POST('day'))   == 1) REQUEST_SET_POST('day'  , '0'.REQUEST_POST('day'));
191         if (strlen(REQUEST_POST('month')) == 1) REQUEST_SET_POST('month', '0'.REQUEST_POST('month'));
192
193         // Get total ...
194         // ... confirmed, ...
195         $confirmedUsers   = GET_TOTAL_DATA('CONFIRMED'  , 'user_data', 'userid', 'status', true);
196         // ... unconfirmed ...
197         $unconfirmedUsers = GET_TOTAL_DATA('UNCONFIRMED', 'user_data', 'userid', 'status', true);
198         // ... and locked users!
199         $lockedUsers      = GET_TOTAL_DATA('LOCKED'     , 'user_data', 'userid', 'status', true);
200
201         // Generate hash which will be inserted into confirmation mail
202         $hash = generateHash(sha1($confirmedUsers.getConfig('ENCRYPT_SEPERATOR').$unconfirmedUsers.getConfig('ENCRYPT_SEPERATOR').$lockedUsers.getConfig('ENCRYPT_SEPERATOR').REQUEST_POST('month') . '-'.REQUEST_POST('day') . '-'.REQUEST_POST('year').getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_NAME').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr().getConfig('ENCRYPT_SEPERATOR').detectUserAgent() . '/' . getConfig('SITE_KEY') . '/' . getConfig('DATE_KEY') . '/'. constant('RAND_NUMBER')));
203
204         // Add design when extension sql_patches is v0.2.7 or greater
205         // @TODO Rewrite these all to a single filter
206         $ADD1 = '';
207         $ADD2 = '';
208         if (GET_EXT_VERSION('theme') >= '0.0.8') {
209                 // Okay, add design here
210                 $ADD1 = ", `curr_theme`";
211                 $ADD2 = ", '".getCurrentTheme()."'";
212         } // END - if
213
214         // Check if I shall disable sending mail to newly registered members out about active/begging rallye
215         //
216         // First comes first: begging rallye
217         if (GET_EXT_VERSION('beg') >= '0.1.7') {
218                 // Okay, shall I disable now?
219                 if (getConfig('beg_new_mem_notify') != 'Y') {
220                         $ADD1 .= ", `beg_ral_notify`, `beg_ral_en_notify`";
221                         $ADD2 .= ", UNIX_TIMESTAMP(), UNIX_TIMESTAMP()";
222                 } // END - if
223         } // END - if
224
225         // Second: active rallye
226         if (GET_EXT_VERSION('bonus') >= '0.7.7') {
227                 // Okay, shall I disable now?
228                 if (getConfig('bonus_new_mem_notify') != 'Y') {
229                         $ADD1 .= ", `bonus_ral_notify`, `bonus_ral_en_notify`";
230                         $ADD2 .= ", UNIX_TIMESTAMP(), UNIX_TIMESTAMP()";
231                 } // END - if
232         } // END - if
233
234         // Write user data to table
235         if (EXT_IS_ACTIVE('country')) {
236                 // Save with new selectable country code
237                 $countryRow = "`country_code`";
238                 $countryData = bigintval(REQUEST_POST('country_code'));
239         } else {
240                 // Old way with enterable two-char-code
241                 $countryRow = "`country`";
242                 $countryData = substr(REQUEST_POST('cntry'), 0, 2);
243         }
244
245         //////////////////////////////
246         // Create user's account... //
247         //////////////////////////////
248         //
249         SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_data` (gender, surname, family, street_nr,%s, zip, city, email, birth_day, birth_month, birth_year, password, max_mails, receive_mails, refid, status, user_hash, REMOTE_ADDR, joined, last_update".$ADD1.")
250 VALUES ('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONFIRMED','%s','%s', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()".$ADD2.")",
251         array(
252                 $countryRow,
253                 substr(REQUEST_POST('gender'), 0, 1),
254                 REQUEST_POST('surname'),
255                 REQUEST_POST('family'),
256                 REQUEST_POST('street_nr'),
257                 $countryData,
258                 bigintval(REQUEST_POST('zip')),
259                 REQUEST_POST('city'),
260                 REQUEST_POST('addy'),
261                 bigintval(REQUEST_POST('day')),
262                 bigintval(REQUEST_POST('month')),
263                 bigintval(REQUEST_POST('year')),
264                 generateHash(REQUEST_POST('pass1')),
265                 bigintval(REQUEST_POST('max_mails')),
266                 bigintval(REQUEST_POST('max_mails')),
267                 bigintval(REQUEST_POST('refid')),
268                 $hash,
269                 detectRemoteAddr(),
270         ), __FILE__, __LINE__);
271
272         // Get his userid
273         $userid = SQL_INSERTID();
274
275         // Did this work?
276         if ($userid == 0) {
277                 // Something bad happened!
278                 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('USER_NOT_REGISTERED'));
279                 return;
280         } // END - if
281
282         // Is the refback extension there?
283         // @TODO Rewrite this to a filter
284         if (EXT_IS_ACTIVE('refback')) {
285                 // Update refback table
286                 updateRefbackTable($userid);
287         } // END - if
288
289         // Write his welcome-points
290         $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_points` WHERE userid=%s AND ref_depth=0 LIMIT 1",
291         array(bigintval($userid)), __FILE__, __LINE__);
292         if (SQL_NUMROWS($result) == 0) {
293                 // Add only when the line was not found (maybe some more secure?)
294                 $locked = "points";
295                 if (getConfig('ref_payout') > 0) $locked = "locked_points"; // Pay him later. First he has to confirm some mails!
296                 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_points` (userid, ref_depth, ".$locked.") VALUES (%s,0,'%s')",
297                 array(bigintval($userid), getConfig('points_register')), __FILE__, __LINE__);
298
299                 // Update mediadata as well
300                 if ((GET_EXT_VERSION('mediadata') >= '0.0.4') && ($locked == "points")) {
301                         // Update database
302                         MEDIA_UPDATE_ENTRY(array('total_points'), 'add', getConfig('points_register'));
303                 } // END - if
304         } // END - if
305
306         // Write catgories
307         if ((is_array(REQUEST_POST('cat'))) && (count(REQUEST_POST('cat')))) {
308                 foreach (REQUEST_POST('cat') as $cat => $joined) {
309                         if ($joined == 'Y') {
310                                 // Insert category entry
311                                 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_cats` (userid, cat_id) VALUES (%s, %s)",
312                                 array(bigintval($userid), bigintval($cat)), __FILE__, __LINE__);
313                         } // END - if
314                 } // END - foreach
315         } // END - if
316
317         // Rewrite gender
318         $gender = translateGender(REQUEST_POST('gender'));
319
320         // ... rewrite a zero referal ID to the main title
321         if (REQUEST_POST('refid') == '0') REQUEST_SET_POST('refid', constant('MAIN_TITLE'));
322
323         // Is ZIP code set?
324         if (REQUEST_ISSET_POST('zip')) {
325                 // Prepare data array for the email template
326                 // Start with the gender...
327                 $DATA = array(
328                         'hash'    => $hash,
329                         'uid'     => $userid,
330                         'gender'  => $gender,
331                         'surname' => SQL_ESCAPE(REQUEST_POST('surname')),
332                         'family'  => SQL_ESCAPE(REQUEST_POST('family')),
333                         'email'   => SQL_ESCAPE(REQUEST_POST('addy')),
334                         'street'  => SQL_ESCAPE(REQUEST_POST('street_nr')),
335                         'city'    => SQL_ESCAPE(REQUEST_POST('city')),
336                         'zip'     => bigintval(REQUEST_POST('zip')),
337                         'country' => $countryData,
338                         'refid'   => SQL_ESCAPE(REQUEST_POST('refid')),
339                         'pass'    => SQL_ESCAPE(REQUEST_POST('pass1')),
340                 );
341         } else {
342                 // No ZIP code entered
343                 $DATA = array(
344                         'hash'    => $hash,
345                         'uid'     => $userid,
346                         'gender'  => $gender,
347                         'surname' => SQL_ESCAPE(REQUEST_POST('surname')),
348                         'family'  => SQL_ESCAPE(REQUEST_POST('family')),
349                         'email'   => SQL_ESCAPE(REQUEST_POST('addy')),
350                         'street'  => SQL_ESCAPE(REQUEST_POST('street_nr')),
351                         'city'    => SQL_ESCAPE(REQUEST_POST('city')),
352                         'zip'     => "",
353                         'country' => $countryData,
354                         'refid'   => SQL_ESCAPE(REQUEST_POST('refid')),
355                         'pass'    => SQL_ESCAPE(REQUEST_POST('pass1')),
356                 );
357         }
358
359         // Continue with birthday...
360         switch (getLanguage()) {
361                 case 'de':
362                         $DATA['birthday'] = bigintval(REQUEST_POST('day')) . '.' . bigintval(REQUEST_POST('month')) . '.' . bigintval(REQUEST_POST('year'));
363                         break;
364
365                 default:
366                         $DATA['birthday'] = bigintval(REQUEST_POST('month')) . '/' . bigintval(REQUEST_POST('day')) . '/' . bigintval(REQUEST_POST('year'));
367                         break;
368         } // END - switch
369
370         // Display information to the user that he got mail and send it away
371         $messageGuest = LOAD_EMAIL_TEMPLATE('register-member', $DATA, $userid);
372
373         // Send mail to user (confirmation link!)
374         $email = $DATA['email'];
375         sendEmail($DATA['email'], getMessage('GUEST_CONFIRM_LINK'), $messageGuest);
376         $DATA['email'] = $email;
377
378         // Send mail to admin
379         sendAdminNotification(getMessage('ADMIN_NEW_ACCOUNT'), 'register-admin', $DATA, $userid);
380
381         // Output success registration
382         LOAD_TEMPLATE('admin_settings_saved', false, getMessage('REGISTRATION_DONE'));
383 } else {
384         if (REQUEST_POST('agree') == '!') {
385                 registerOutputFailedMessage('HAVE_TO_AGREE');
386         } // END - if
387
388         if (REQUEST_POST('addy') == '!') {
389                 registerOutputFailedMessage('ENTER_EMAIL');
390                 REQUEST_SET_POST('addy', '');
391         } elseif (REQUEST_POST('addy') == '?') {
392                 registerOutputFailedMessage('EMAIL_ALREADY_DB');
393                 REQUEST_SET_POST('addy', '');
394         }
395
396         if (REQUEST_POST('surname') == '!') {
397                 registerOutputFailedMessage('ENTER_SURNAME');
398                 REQUEST_SET_POST('surname', '');
399         } // END - if
400
401         if (REQUEST_POST('family') == '!') {
402                 registerOutputFailedMessage('ENTER_FAMILY');
403                 REQUEST_SET_POST('family', '');
404         } // END - if
405
406         if ((REQUEST_POST('pass1') == '!') && (REQUEST_POST('pass2') == '!')) {
407                 registerOutputFailedMessage('ENTER_BOTH_PASSWORDS');
408         } elseif (REQUEST_POST('pass1') == '!') {
409                 registerOutputFailedMessage('ENTER_PASS1');
410         } elseif (REQUEST_POST('pass2') == '!') {
411                 registerOutputFailedMessage('ENTER_PASS2');
412         }
413
414         if ($shortPass === true) {
415                 registerOutputFailedMessage('SHORT_PASS', ": ".getConfig('pass_len'));
416         } // END - if
417
418         if ($ipTimedOut === true) {
419                 registerOutputFailedMessage('REMOTE_ADDR_TIMEOUT');
420         } // END - if
421
422         if ((!empty($cats)) && ($cats < getConfig('least_cats'))) {
423                 registerOutputFailedMessage(sprintf(getMessage('CATS_LEAST'), getConfig('least_cats')));
424         } // END - if
425
426         // Generate birthday selection
427         switch (getLanguage()) {
428                 case 'de': // German date format
429                         define('BIRTHDAY_SELECTION', ADD_SELECTION('day', REQUEST_POST('day')).ADD_SELECTION('month', REQUEST_POST('month')).ADD_SELECTION('year', REQUEST_POST('year')));
430                         break;
431
432                 default: // Default is the US date format... :)
433                         define('BIRTHDAY_SELECTION', ADD_SELECTION('month', REQUEST_POST('month')).ADD_SELECTION('day', REQUEST_POST('day')).ADD_SELECTION('year', REQUEST_POST('year')));
434                         break;
435         }
436
437         // Adds a table for the guests with all visible categories
438         define('CATEGORY_SELECTION', registerGenerateCategoryTable('guest', true));
439
440         // Adds maximum receiveable mails list... :)
441         define('MAX_RECEIVE_LIST', addMaxReceiveList('guest', '', true));
442
443         // Shall I display the refid or shall I make it editable?
444         if (getConfig('display_refid') == 'Y') {
445                 // Load "hide" form template
446                 define('REFID_CONTENT', LOAD_TEMPLATE('guest_register_refid_hide', true, $GLOBALS['refid']));
447         } else {
448                 // Load template to enter it
449                 define('REFID_CONTENT', LOAD_TEMPLATE('guest_register_refid', true, $GLOBALS['refid']));
450         }
451
452         // You may want to modify the register_header.tpl.xx file and not this script when you add your scripts etc. :-)
453         define('REGISTER_HEADER_CONTENT', LOAD_TEMPLATE('register_header', true));
454
455         // Please select at least x categories
456         define('LEAST_CATS_VALUE', getConfig('least_cats'));
457
458         // Other values
459         define('__SURNAME', SQL_ESCAPE(REQUEST_POST('surname')));
460         define('__FAMILY',  SQL_ESCAPE(REQUEST_POST('family')));
461         define('__STREET',  SQL_ESCAPE(REQUEST_POST('street_nr')));
462         define('__COUNTRY', SQL_ESCAPE(REQUEST_POST('cntry')));
463         if ((REQUEST_ISSET_POST('zip')) && (REQUEST_POST('zip') != '')) {
464                 define('__ZIP', bigintval(REQUEST_POST('zip')));
465         } else {
466                 define('__ZIP', '');
467         }
468         define('__CITY',    SQL_ESCAPE(REQUEST_POST('city')));
469         define('__ADDY',    SQL_ESCAPE(REQUEST_POST('addy')));
470
471         // Shall I add a counrty selection box or the old input box?
472         if (EXT_IS_ACTIVE('country')) {
473                 // New variant, good!
474                 $OUT  = "<select name=\"country_code\" class=\"guest_select\" size=\"1\">\n";
475                 $whereStatement = "WHERE `is_active`='Y'";
476                 if (IS_ADMIN()) $whereStatement = '';
477                 $OUT .= generateOptionList('countries', 'id', 'descr', REQUEST_POST('country_code'), 'code', $whereStatement);
478                 $OUT .= "</select>";
479                 define('__COUNTRY_CONTENT', $OUT);
480         } else {
481                 // Old out-dated variant
482                 define('__COUNTRY_CONTENT', "<input type=\"text\" name=\"cntry\" class=\"guest_normal\" size=\"2\" maxlength=\"3\" value=\"{!__COUNTRY!}\" />");
483         }
484
485         // Set MUST_??? constants
486         if ((EXT_IS_ACTIVE('register')) && (GET_EXT_VERSION('register') > '0.0')) registerMustFillout();
487
488         // Display registration form
489         LOAD_TEMPLATE('guest_register');
490 }
491
492 //
493 ?>