]> git.mxchange.org Git - mailer.git/blob - surfbar.php
Login form for guests in surfbar added, some trigger_error() added, misc rewrites
[mailer.git] / surfbar.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 09/05/2008 *
4  * ===============                              Last change: 09/05/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : surfbar.php                                      *
8  * -------------------------------------------------------------------- *
9  * Short description : The surfbar itself                               *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Die Surfbar selbst                               *
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 // Load security stuff here
40 require('inc/libs/security_functions.php');
41
42 // Init start time
43 $GLOBALS['startTime'] = microtime(true);
44
45 // Set module
46 $GLOBALS['module'] = 'surfbar';
47 $GLOBALS['refid']  = 0;
48 $GLOBALS['output_mode'] = 0;
49 $GLOBALS['header_sent'] = 3;
50
51 // Load the required file(s)
52 require('inc/config-global.php');
53
54 // Is a frame active?
55 if (REQUEST_ISSET_GET('frame')) {
56         // Then we need to set header_sent to 0
57         $GLOBALS['header_sent'] = 0;
58 } // END - if
59
60 // Is the script installed?
61 if (!isInstalled()) {
62         // You have to install first!
63         redirectToUrl('install.php');
64 } // END - if
65
66 // Only logged in users may use this surfbar!
67 redirectOnUninstalledExtension('surfbar');
68
69 // No member?
70 if (!IS_MEMBER()) {
71         // Should we display login window or redirect to main page?
72         if ((getConfig('surfbar_guest_login_form') == 'Y') && (EXT_IS_ACTIVE('user'))) {
73                 // Is the form sent?
74                 if ((isFormSent()) && (REQUEST_ISSET_POST('id')) && (REQUEST_ISSET_POST('password'))) {
75                         // Do the login procedure
76                         $URL = USER_DO_LOGIN(REQUEST_POST('id'), REQUEST_POST('password'), basename(__FILE__));
77
78                         // And redirect to the URL
79                         redirectToUrl($URL);
80                 } else {
81                         // Load header
82                         loadIncludeOnce('inc/header.php');
83
84                         // Display login form
85                         LOAD_TEMPLATE('surfbar_login_form');
86
87                         // Allow footer here
88                         $GLOBALS['header_sent'] = 2;
89
90                         // Load footer
91                         loadIncludeOnce('inc/footer.php');
92                 }
93         } else {
94                 // Redirect
95                 redirectToUrl('index.php');
96         }
97 } // END - if
98
99 // Initialize the surfbar
100 SURFBAR_INIT();
101
102 // Handle tasks on self-maintenance
103 SURFBAR_HANDLE_SELF_MAINTENANCE();
104
105 // Is there a check value?
106 if ((SURFBAR_CHECK_RELOAD_FULL()) || ((REQUEST_ISSET_GET('frame')) && (in_array(REQUEST_GET('frame'), array('stop', 'stop2', 'stats', 'textlinks'))))) {
107         // Reload-lock is full, surfbar stopped so...
108         // Load header
109         loadIncludeOnce('inc/header.php');
110
111         // Load template
112         if (((REQUEST_ISSET_GET('frame')) && (REQUEST_GET('frame') == 'stop')) || (!REQUEST_ISSET_GET('frame'))) {
113                 // Load template for "start" page
114                 LOAD_TEMPLATE('surfbar_frame_start');
115
116                 // Load banner
117                 LOAD_TEMPLATE('surfbar_start_banner');
118
119                 // This makes the footer appear again
120                 REQUEST_UNSET_GET('frame');
121         } elseif ((REQUEST_ISSET_GET('frame')) && (REQUEST_GET('frame') == 'stats')) {
122                 // Get total points amount
123                 $points = GET_TOTAL_DATA(getUserId(), 'user_points', 'points') - GET_TOTAL_DATA(getUserId(), 'user_data', 'used_points');
124
125                 // Prepare content
126                 $content = array(
127                         'points'   => translateComma($points),
128                         'online'   => SURFBAR_DETERMINE_TOTAL_ONLINE(),
129                         'reload'   => (getConfig('surfbar_stats_reload') * 1000),
130                         'c_total'  => translateComma(getConfig('surfbar_total_counter')),
131                         'c_today'  => translateComma(getConfig('surfbar_daily_counter')),
132                         'c_yester' => translateComma(getConfig('surfbar_yester_counter')),
133                         'c_week'   => translateComma(getConfig('surfbar_weekly_counter')),
134                         'c_month'  => translateComma(getConfig('surfbar_monthly_counter')),
135                 );
136
137                 // Load template for "stats" page
138                 LOAD_TEMPLATE('surfbar_frame_stats', false, $content);
139         } elseif ((REQUEST_ISSET_GET('frame')) && (REQUEST_GET('frame') == 'textlinks')) {
140                 // Prepare content
141                 $content = array(
142                         'online'   => SURFBAR_DETERMINE_TOTAL_ONLINE(),
143                         'reload'   => (getConfig('surfbar_stats_reload') * 1000)
144                 );
145
146                 // Load template for "stats" page
147                 LOAD_TEMPLATE('surfbar_frame_textlinks', false, $content);
148         } else {
149                 // Prepare content
150                 $content = array(
151                         'restart'   => getConfig('surfbar_restart_time'),
152                         'start'     => str_repeat('X', strlen(getConfig('surfbar_restart_time'))),
153                         'autostart' => (getConfig('surfbar_autostart') == 'Y') ? 'true' : 'false'
154                 );
155
156                 // Load template for stopped surfbar
157                 LOAD_TEMPLATE('surfbar_stopped', false, $content);
158         }
159 } elseif ((REQUEST_ISSET_GET('check')) && (REQUEST_ISSET_GET('id')) && (REQUEST_ISSET_GET('salt'))) {
160         // Dummy next id get
161         SURFBAR_DETERMINE_NEXT_ID(REQUEST_GET('id'));
162
163         // Check reload lock and validation code
164         if ((!SURFBAR_CHECK_RELOAD_LOCK(REQUEST_GET('id'))) && (SURFBAR_CHECK_VALIDATION_CODE(REQUEST_GET('id'), REQUEST_GET('check'), REQUEST_GET('salt')))) {
165                 // Lock the URL (id) down
166                 SURFBAR_LOCKDOWN_ID(REQUEST_GET('id'));
167
168                 // Code is valid so pay points here
169                 SURFBAR_PAY_POINTS();
170
171                 // Check if reload is full
172                 if (SURFBAR_CHECK_RELOAD_FULL()) {
173                         // Then load waiting page
174                         SURFBAR_RELOAD_TO_STOP_PAGE();
175                 } // END - if
176         } else {
177                 // Reload to stop frame!
178                 SURFBAR_RELOAD_TO_STOP_PAGE();
179         }
180
181         // All done, so fix notice for footer.php
182         $GLOBALS['footer_sent'] = 1;
183 } else {
184         // Prepare content
185         $content = '';
186
187         // Determine template name
188         $templateName = SURFBAR_DETERMINE_TEMPLATE_NAME();
189
190         // Load header in frameset mode is the default
191         $isFrameset = true;
192
193         // Frame "top" set?
194         if ((REQUEST_ISSET_GET('frame')) && (REQUEST_GET('frame') == 'top')) {
195                 // Determine next id
196                 $nextId = SURFBAR_DETERMINE_NEXT_ID();
197
198                 // Is there a valid id?
199                 if ($nextId > 0) {
200                         // Then prepare other content
201                         $content = array(
202                                 'id'          => $nextId,
203                                 'check'       => SURFBAR_GENERATE_VALIDATION_CODE($nextId),
204                                 'salt'        => SURFBAR_GET_SALT(),
205                                 'points'      => translateComma(SURFBAR_GET_REWARD($nextId)),
206                                 'url'         => SURFBAR_GET_URL($nextId),
207                                 'curr_reload' => SURFBAR_GET_USER_LOCKS(),
208                                 'max_urls'    => SURFBAR_GET_TOTAL_URLS(),
209                                 'reload'      => SURFBAR_GET_RELOAD_TIME($nextId),
210                                 'xxx'         => str_repeat('X', strlen(SURFBAR_GET_RELOAD_TIME($nextId)))
211                         );
212
213                         // Update salt (double-call lock!) and statistics
214                         SURFBAR_UPDATE_SALT_STATS();
215                 } else {
216                         // Load new URL
217                         SURFBAR_RELOAD_TO_STOP_PAGE('stop2');
218                 }
219         } elseif ((REQUEST_ISSET_GET('frame')) && (REQUEST_GET('frame') == 'start')) {
220                 // Starter frame found so let the footer display
221                 REQUEST_UNSET_GET('frame');
222         }
223
224         // Load header
225         loadIncludeOnce('inc/header.php');
226
227         // Load that template
228         //* DEBUG: */ die("templateName={$templateName}<br />\n<strong>content</strong>=<pre>".print_r($content, true)."</pre>");
229         LOAD_TEMPLATE($templateName, false, $content);
230 }
231
232 // Load footer
233 $GLOBALS['footer_sent'] = 3;
234 loadIncludeOnce('inc/footer.php');
235
236 // [EOF]
237 ?>