2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 09/05/2008 *
4 * =================== Last change: 09/05/2008 *
6 * -------------------------------------------------------------------- *
8 * -------------------------------------------------------------------- *
9 * Short description : The surfbar itself *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Die Surfbar selbst *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Load security stuff here
39 require('inc/libs/security_functions.php');
42 $GLOBALS['startTime'] = microtime(true);
45 $GLOBALS['module'] = 'surfbar';
46 $GLOBALS['output_mode'] = '0';
47 $GLOBALS['header_sent'] = 3;
49 // Load the required file(s)
50 require('inc/config-global.php');
53 setContentType('text/html');
56 if (isGetRequestParameterSet('frame')) {
57 // Then we need to set header_sent to 0
58 $GLOBALS['header_sent'] = '0';
61 // Only logged in users may use this surfbar!
62 redirectOnUninstalledExtension('surfbar');
66 // Should we display login window or redirect to main page?
67 if ((getConfig('surfbar_guest_login_form') == 'Y') && (isExtensionActive('user'))) {
69 if ((isFormSent()) && (isPostRequestParameterSet('id')) && (isPostRequestParameterSet('password'))) {
70 // Do the login procedure
71 $url = doUserLogin(postRequestParameter('id'), postRequestParameter('password'), basename(__FILE__), basename(__FILE__) . '?code=');
73 // And redirect to the URL
77 loadIncludeOnce('inc/header.php');
79 // Is there a 'code' provided?
80 if (isGetRequestParameterSet('code')) {
81 // Then generate an error message
82 displayMessage(getMessageFromErrorCode(getRequestParameter('code')));
86 loadTemplate('surfbar_login_form');
89 $GLOBALS['header_sent'] = 2;
92 loadIncludeOnce('inc/footer.php');
96 redirectToUrl('modules.php?module=index');
100 // Initialize the surfbar
103 // Handle tasks on self-maintenance
104 SURFBAR_HANDLE_SELF_MAINTENANCE();
106 // Is there a check value?
107 if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in_array(getRequestParameter('frame'), array('stop', 'stop2', 'stats', 'textlinks'))))) {
108 // Reload-lock is full, surfbar stopped so...
110 loadIncludeOnce('inc/header.php');
113 if (((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'stop2')) || (!isGetRequestParameterSet('frame'))) {
114 // Load template for "start" page
115 loadTemplate('surfbar_frame_start');
118 loadTemplate('surfbar_start_banner');
120 // This makes the footer appear again
121 unsetGetRequestParameter('frame');
122 } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'stats')) {
125 'points' => getTotalPoints(getMemberId()),
126 'reload' => (getConfig('surfbar_stats_reload') * 1000)
129 // Load template for "stats" page
130 loadTemplate('surfbar_frame_stats', false, $content);
131 } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'textlinks')) {
134 'reload' => (getConfig('surfbar_stats_reload') * 1000)
137 // Load template for "stats" page
138 loadTemplate('surfbar_frame_textlinks', false, $content);
142 'start' => str_repeat('X', strlen(getConfig('surfbar_restart_time'))),
143 'autostart' => (getConfig('surfbar_autostart') == 'Y') ? 'true' : 'false'
146 // Load template for stopped surfbar
147 loadTemplate('surfbar_stopped', false, $content);
149 } elseif ((isGetRequestParameterSet('check')) && (isGetRequestParameterSet('id')) && (isGetRequestParameterSet('salt'))) {
151 SURFBAR_DETERMINE_NEXT_ID(getRequestParameter('id'));
153 // Check reload lock and validation code
154 if ((!SURFBAR_CHECK_RELOAD_LOCK(getRequestParameter('id'))) && (SURFBAR_CHECK_VALIDATION_CODE(getRequestParameter('id'), getRequestParameter('check'), getRequestParameter('salt')))) {
155 // Lock the URL (id) down
156 SURFBAR_LOCKDOWN_ID(getRequestParameter('id'));
158 // Code is valid so pay points here
159 SURFBAR_PAY_POINTS();
161 // Check if reload is full
162 if (SURFBAR_CHECK_RELOAD_FULL()) {
163 // Then load waiting page
164 SURFBAR_RELOAD_TO_STOP_PAGE();
167 // Reload to stop frame!
168 SURFBAR_RELOAD_TO_STOP_PAGE();
171 // All done, so fix notice for footer.php
172 $GLOBALS['footer_sent'] = 1;
178 if ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'top')) {
180 $nextId = SURFBAR_DETERMINE_NEXT_ID();
181 //* DEBUG: */ die('nextId='.$nextId);
183 // Is there a valid id?
185 // Then prepare other content
188 'xxx' => str_repeat('X', strlen(SURFBAR_GET_RELOAD_TIME($nextId))),
191 // Update salt (double-call lock!) and statistics
192 SURFBAR_UPDATE_SALT_STATS();
195 SURFBAR_RELOAD_TO_STOP_PAGE('stop');
197 } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'start')) {
198 // Starter frame found so let the footer display
199 unsetGetRequestParameter('frame');
203 loadIncludeOnce('inc/header.php');
205 // Determine template name
206 $templateName = SURFBAR_DETERMINE_TEMPLATE_NAME();
208 // Load that template
209 //* DEBUG: */ die('templateName=' . $templateName . '<br /><strong>content</strong>=<pre>' . print_r($content, true) . '</pre>');
210 loadTemplate($templateName, false, $content);
214 $GLOBALS['footer_sent'] = 3;
215 loadIncludeOnce('inc/footer.php');