A lot CSS classes rewritten, please update all your themes.
[mailer.git] / surfbar.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Load security stuff here
41 require('inc/libs/security_functions.php');
42
43 // Init start time
44 $GLOBALS['startTime'] = microtime(true);
45
46 // Set module
47 $GLOBALS['module'] = 'surfbar';
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 // Set content type
55 setContentType('text/html');
56
57 // Is a frame active?
58 if (isGetRequestParameterSet('frame')) {
59         // Then we need to set header_sent to 0
60         $GLOBALS['header_sent'] = '0';
61 } // END - if
62
63 // Only logged in users may use this surfbar!
64 redirectOnUninstalledExtension('surfbar');
65
66 // No member?
67 if (!isMember()) {
68         // Should we display login window or redirect to main page?
69         if ((getConfig('surfbar_guest_login_form') == 'Y') && (isExtensionActive('user'))) {
70                 // Is the form sent?
71                 if ((isFormSent()) && (isPostRequestParameterSet('id')) && (isPostRequestParameterSet('password'))) {
72                         // Do the login procedure
73                         $URL = doUserLogin(postRequestParameter('id'), postRequestParameter('password'), basename(__FILE__), basename(__FILE__) . '?code=');
74
75                         // And redirect to the URL
76                         redirectToUrl($URL);
77                 } else {
78                         // Load header
79                         loadIncludeOnce('inc/header.php');
80
81                         // Is there a 'code' provided?
82                         if (isGetRequestParameterSet('code')) {
83                                 // Then generate an error message
84                                 loadTemplate('admin_settings_saved', false, getMessageFromErrorCode(getRequestParameter('code')));
85                         } // END - if
86
87                         // Display login form
88                         loadTemplate('surfbar_login_form');
89
90                         // Allow footer here
91                         $GLOBALS['header_sent'] = 2;
92
93                         // Load footer
94                         loadIncludeOnce('inc/footer.php');
95                 }
96         } else {
97                 // Redirect
98                 redirectToUrl('modules.php?module=index');
99         }
100 } // END - if
101
102 // Initialize the surfbar
103 SURFBAR_INIT();
104
105 // Handle tasks on self-maintenance
106 SURFBAR_HANDLE_SELF_MAINTENANCE();
107
108 // Is there a check value?
109 if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in_array(getRequestParameter('frame'), array('stop', 'stop2', 'stats', 'textlinks'))))) {
110         // Reload-lock is full, surfbar stopped so...
111         // Load header
112         loadIncludeOnce('inc/header.php');
113
114         // Load template
115         if (((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'stop2')) || (!isGetRequestParameterSet('frame'))) {
116                 // Load template for "start" page
117                 loadTemplate('surfbar_frame_start');
118
119                 // Load banner
120                 loadTemplate('surfbar_start_banner');
121
122                 // This makes the footer appear again
123                 unsetGetRequestParameter('frame');
124         } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'stats')) {
125                 // Prepare content
126                 $content = array(
127                         'points' => getTotalPoints(getMemberId()),
128                         'reload' => (getConfig('surfbar_stats_reload') * 1000)
129                 );
130
131                 // Load template for "stats" page
132                 loadTemplate('surfbar_frame_stats', false, $content);
133         } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'textlinks')) {
134                 // Prepare content
135                 $content = array(
136                         'reload' => (getConfig('surfbar_stats_reload') * 1000)
137                 );
138
139                 // Load template for "stats" page
140                 loadTemplate('surfbar_frame_textlinks', false, $content);
141         } else {
142                 // Prepare content
143                 $content = array(
144                         'start'     => str_repeat('X', strlen(getConfig('surfbar_restart_time'))),
145                         'autostart' => (getConfig('surfbar_autostart') == 'Y') ? 'true' : 'false'
146                 );
147
148                 // Load template for stopped surfbar
149                 loadTemplate('surfbar_stopped', false, $content);
150         }
151 } elseif ((isGetRequestParameterSet('check')) && (isGetRequestParameterSet('id')) && (isGetRequestParameterSet('salt'))) {
152         // Dummy next id get
153         SURFBAR_DETERMINE_NEXT_ID(getRequestParameter('id'));
154
155         // Check reload lock and validation code
156         if ((!SURFBAR_CHECK_RELOAD_LOCK(getRequestParameter('id'))) && (SURFBAR_CHECK_VALIDATION_CODE(getRequestParameter('id'), getRequestParameter('check'), getRequestParameter('salt')))) {
157                 // Lock the URL (id) down
158                 SURFBAR_LOCKDOWN_ID(getRequestParameter('id'));
159
160                 // Code is valid so pay points here
161                 SURFBAR_PAY_POINTS();
162
163                 // Check if reload is full
164                 if (SURFBAR_CHECK_RELOAD_FULL()) {
165                         // Then load waiting page
166                         SURFBAR_RELOAD_TO_STOP_PAGE();
167                 } // END - if
168         } else {
169                 // Reload to stop frame!
170                 SURFBAR_RELOAD_TO_STOP_PAGE();
171         }
172
173         // All done, so fix notice for footer.php
174         $GLOBALS['footer_sent'] = 1;
175 } else {
176         // Prepare content
177         $content = '';
178
179         // Determine template name
180         $templateName = SURFBAR_DETERMINE_TEMPLATE_NAME();
181
182         // Load header in frameset mode is the default
183         $isFrameset = true;
184
185         // Frame "top" set?
186         if ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'top')) {
187                 // Determine next id
188                 $nextId = SURFBAR_DETERMINE_NEXT_ID();
189
190                 // Is there a valid id?
191                 if ($nextId > 0) {
192                         // Then prepare other content
193                         $content = array(
194                                 'url_id' => $nextId,
195                                 'xxx'    => str_repeat('X', strlen(SURFBAR_GET_RELOAD_TIME($nextId))),
196                         );
197
198                         // Update salt (double-call lock!) and statistics
199                         SURFBAR_UPDATE_SALT_STATS();
200                 } else {
201                         // Load new URL
202                         SURFBAR_RELOAD_TO_STOP_PAGE('stop');
203                 }
204         } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'start')) {
205                 // Starter frame found so let the footer display
206                 unsetGetRequestParameter('frame');
207         }
208
209         // Load header
210         loadIncludeOnce('inc/header.php');
211
212         // Load that template
213         //* DEBUG: */ die('templateName=' . $templateName . '<br /><strong>content</strong>=<pre>' . print_r($content, true) . '</pre>');
214         loadTemplate($templateName, false, $content);
215 }
216
217 // Load footer
218 $GLOBALS['footer_sent'] = 3;
219 loadIncludeOnce('inc/footer.php');
220
221 // [EOF]
222 ?>