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 * -------------------------------------------------------------------- *
13 * Copyright (c) 2003 - 2009 by Roland Haeder *
14 * Copyright (c) 2009 - 2016 by Mailer Developer Team *
15 * For more information visit: http://mxchange.org *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
25 * GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, write to the Free Software *
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
31 ************************************************************************/
33 // Load security stuff here
34 require('inc/libs/security_functions.php');
37 $GLOBALS['__start_time'] = microtime(TRUE);
39 // Set module output mode
40 $GLOBALS['__module'] = 'surfbar';
41 $GLOBALS['__output_mode'] = '0';
42 $GLOBALS['__header_sent'] = 3;
44 // Initialize application
45 require('inc/init.php');
48 setContentType('text/html');
52 // Then we need to set header_sent to 0
53 $GLOBALS['__header_sent'] = '0';
56 // Only logged in users may use this surfbar!
57 redirectOnUninstalledExtension('surfbar');
61 // Should we display login window or redirect to main page?
62 if ((isSurfbarGuestLoginFormEnabled()) && (isExtensionActive('user'))) {
64 if ((isFormSent('login')) && (isPostRequestElementSet('id')) && (isPostRequestElementSet('password'))) {
65 // Do the login procedure
66 $url = doUserLogin(postRequestElement('id'), postRequestElement('password'), basename(__FILE__), basename(__FILE__) . '?code=');
68 // And redirect to the URL
74 // Is there a 'code' provided?
75 if (isGetRequestElementSet('code')) {
76 // Then generate an error message
77 displayMessage(getMessageFromErrorCode(getRequestElement('code')));
81 loadTemplate('surfbar_login_form');
84 $GLOBALS['__header_sent'] = 2;
91 redirectToUrl('modules.php?module=index');
95 // Initialize the surfbar
98 // Handle tasks on self-maintenance
99 doSurfbarSelfMaintenance();
101 // Is there a check value?
102 if ((isSurfbarReloadFull()) || ((!isFullPage()) && (in_array(getRequestElement('frame'), array('stop', 'stop2', 'stats', 'textlinks'))))) {
103 // Reload-lock is full, surfbar stopped so...
108 if (((!isFullPage()) && (getRequestElement('frame') == 'stop2')) || (isFullPage())) {
109 // Load template for "start" page
110 loadTemplate('surfbar_frame_start');
113 loadTemplate('surfbar_start_banner');
115 // This makes the footer appear again
116 unsetGetRequestElement('frame');
117 } elseif ((!isFullPage()) && (getRequestElement('frame') == 'stats')) {
120 'points' => getTotalPoints(getMemberId()),
121 'reload' => (getSurfbarStatsReload() * 1000)
124 // Load template for "stats" page
125 loadTemplate('surfbar_frame_stats', FALSE, $content);
126 } elseif ((!isFullPage()) && (getRequestElement('frame') == 'textlinks')) {
129 'reload' => (getSurfbarStatsReload() * 1000)
132 // Load template for "stats" page
133 loadTemplate('surfbar_frame_textlinks', FALSE, $content);
137 'start' => str_repeat('X', strlen(getSurfbarRestartTime())),
138 'autostart' => (isSurfbarAutoStartEnabled()) ? 'true' : 'false'
141 // Load template for stopped surfbar
142 loadTemplate('surfbar_stopped', FALSE, $content);
144 } elseif ((isGetRequestElementSet('check')) && (isGetRequestElementSet('id')) && (isGetRequestElementSet('salt'))) {
146 determineSurfbarNextId(getRequestElement('id'));
148 // Check reload lock and validation code
149 if ((!ifSurfbarReloadLock(getRequestElement('id'))) && (isSurfbarValidationCodeValid(getRequestElement('id'), getRequestElement('check'), getRequestElement('salt')))) {
150 // Lock the URL (id) down
151 addSurfbarReloadLockById(getRequestElement('id'));
153 // Code is valid so pay points here
154 doSurfbarPayPoints();
156 // Check if reload is full
157 if (isSurfbarReloadFull()) {
158 // Then load waiting page
159 redirectToSurfbarStopPage();
162 // Load header to avoid a bug
165 // Reload to stop frame!
166 redirectToSurfbarStopPage();
169 // All done, so fix notice for loadTemplateFooter()
170 $GLOBALS['__footer_sent'] = 1;
176 if ((!isFullPage()) && (getRequestElement('frame') == 'top')) {
178 $nextId = determineSurfbarNextId();
179 //* DEBUG: */ exit('nextId='.$nextId);
181 // Is there a valid id?
182 if (isValidId($nextId)) {
183 // Then prepare other content
186 'xxx' => str_repeat('X', strlen(getSurfbarWaitingTime($nextId))),
189 // Update salt (double-call lock!) and statistics
190 updateSurfbarSaltStatistics();
193 redirectToSurfbarStopPage('stop');
195 } elseif ((!isFullPage()) && (getRequestElement('frame') == 'start')) {
196 // Starter frame found so let the footer display
197 unsetGetRequestElement('frame');
203 // Determine template name
204 $templateName = determineSurfbarTemplateName();
206 // Load that template
207 //* DEBUG: */ exit('templateName=' . $templateName . '<br /><strong>content</strong>=<pre>' . print_r($content, TRUE) . '</pre>');
208 loadTemplate($templateName, FALSE, $content);
212 $GLOBALS['__footer_sent'] = 3;