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