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