Huge patchset (I don't recall all details):
[mailer.git] / inc / modules / guest / what-register.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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 - 2009 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         die();
42 } // END - if
43
44 // Add description as navigation point
45 addMenuDescription('guest', __FILE__);
46
47 if (!isExtensionActive('register')) {
48         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('register'));
49         return;
50 } elseif (!isExtensionActive('country')) {
51         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('country'));
52         return;
53 }
54
55 // Is the form sent and all went fine?
56 //* DEBUG: */ print intval(isFormSent()) . '/' . intval(isRegistrationDataComplete()) . '/' . intval(isAdmin()) . '<br />';
57 if ((isFormSent()) && (isRegistrationDataComplete())) {
58         // Do the registration here
59         doRegistration();
60
61         // Output success registration
62         loadTemplate('admin_settings_saved', false, getMessage('REGISTRATION_DONE'));
63 } else {
64         if (postRequestParameter('agree') == '!') {
65                 registerOutputFailedMessage('HAVE_TO_AGREE');
66         } // END - if
67
68         if (postRequestParameter('email') == '!') {
69                 registerOutputFailedMessage('ENTER_EMAIL');
70                 setPostRequestParameter('email', '');
71         } elseif (postRequestParameter('email') == '?') {
72                 registerOutputFailedMessage('EMAIL_ALREADY_DB');
73                 setPostRequestParameter('email', '');
74         }
75
76         if (postRequestParameter('surname') == '!') {
77                 registerOutputFailedMessage('ENTER_SURNAME');
78                 setPostRequestParameter('surname', '');
79         } // END - if
80
81         if (postRequestParameter('family') == '!') {
82                 registerOutputFailedMessage('ENTER_FAMILY');
83                 setPostRequestParameter('family', '');
84         } // END - if
85
86         if ((postRequestParameter('pass1') == '!') && (postRequestParameter('pass2') == '!')) {
87                 registerOutputFailedMessage('ENTER_BOTH_PASSWORDS');
88         } elseif (postRequestParameter('pass1') == '!') {
89                 registerOutputFailedMessage('ENTER_PASS1');
90         } elseif (postRequestParameter('pass2') == '!') {
91                 registerOutputFailedMessage('ENTER_PASS2');
92         }
93
94         if ($GLOBALS['registration_short_password'] === true) {
95                 registerOutputFailedMessage('SHORT_PASS', ': ' . getConfig('pass_len'));
96         } // END - if
97
98         if ($GLOBALS['registration_ip_timeout'] === true) {
99                 registerOutputFailedMessage('REMOTE_ADDR_TIMEOUT');
100         } // END - if
101
102         if ((!empty($GLOBALS['register_selected_cats'])) && ($GLOBALS['register_selected_cats'] < getConfig('least_cats'))) {
103                 registerOutputFailedMessage('', getMessage('CATS_LEAST'));
104         } // END - if
105
106         // Generate birthday selection
107         switch (getLanguage()) {
108                 case 'de': // German date format
109                         $content['birthday_selection'] = addSelectionBox('day', postRequestParameter('day')).addSelectionBox('month', postRequestParameter('month')).addSelectionBox('year', postRequestParameter('year'));
110                         break;
111
112                 default: // Default is the US date format... :)
113                         $content['birthday_selection'] = addSelectionBox('month', postRequestParameter('month')).addSelectionBox('day', postRequestParameter('day')).addSelectionBox('year', postRequestParameter('year'));
114                         break;
115         }
116
117         // Adds a table for the guests with all visible categories
118         $content['category_selection'] = registerGenerateCategoryTable('guest', true);
119
120         // Adds maximum receiveable mails list... :)
121         $content['max_receive_list'] = addMaxReceiveList('guest', '', true);
122
123         // Shall I display the refid or shall I make it editable?
124         if (getConfig('display_refid') == 'Y') {
125                 // Load "hide" form template
126                 $content['refid_content'] = loadTemplate('guest_register_refid_hide', true, determineReferalId());
127         } else {
128                 // Load template to enter it
129                 $content['refid_content'] = loadTemplate('guest_register_refid', true, determineReferalId());
130         }
131
132         // You may want to modify the register_header.tpl.xx file and not this script when you add your scripts etc. :-)
133         $content['header_content'] = loadTemplate('register_header', true);
134
135         // Other values
136         $content['surname']   = SQL_ESCAPE(postRequestParameter('surname'));
137         $content['family']    = SQL_ESCAPE(postRequestParameter('family'));
138         $content['street_nr'] = SQL_ESCAPE(postRequestParameter('street_nr'));
139         $content['zip']       = '';
140         if (isPostRequestParameterSet('zip')) {
141                 $content['zip']       = bigintval(postRequestParameter('zip'));
142         } // END - if
143         $content['city']      = SQL_ESCAPE(postRequestParameter('city'));
144         $content['email']     = SQL_ESCAPE(postRequestParameter('email'));
145
146         // Prepare country selection box
147         $OUT  = "<select name=\"country_code\" class=\"guest_select\" size=\"1\">\n";
148         $whereStatement = "WHERE `is_active`='Y'";
149         if (isAdmin()) $whereStatement = '';
150         $OUT .= generateOptionList('countries', 'id', 'descr', postRequestParameter('country_code'), 'code', $whereStatement);
151         $OUT .= "</select>";
152         $content['country'] = $OUT;
153
154         // Set must-fillout fields
155         $content = runFilterChain('register_must_fillout', $content);
156
157         // Display registration form
158         loadTemplate('guest_register', false, $content);
159 }
160
161 // [EOF]
162 ?>