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 * 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 *
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. *
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. *
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, *
38 ************************************************************************/
40 // Load security stuff here
41 require('inc/libs/security_functions.php');
44 $GLOBALS['startTime'] = microtime(true);
47 $GLOBALS['module'] = 'surfbar';
48 $GLOBALS['output_mode'] = '0';
49 $GLOBALS['header_sent'] = 3;
51 // Load the required file(s)
52 require('inc/config-global.php');
55 setContentType('text/html');
58 if (isGetRequestParameterSet('frame')) {
59 // Then we need to set header_sent to 0
60 $GLOBALS['header_sent'] = '0';
63 // Only logged in users may use this surfbar!
64 redirectOnUninstalledExtension('surfbar');
68 // Should we display login window or redirect to main page?
69 if ((getConfig('surfbar_guest_login_form') == 'Y') && (isExtensionActive('user'))) {
71 if ((isFormSent()) && (isPostRequestParameterSet('id')) && (isPostRequestParameterSet('password'))) {
72 // Do the login procedure
73 $URL = doUserLogin(postRequestParameter('id'), postRequestParameter('password'), basename(__FILE__), basename(__FILE__) . '?code=');
75 // And redirect to the URL
79 loadIncludeOnce('inc/header.php');
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')));
88 loadTemplate('surfbar_login_form');
91 $GLOBALS['header_sent'] = 2;
94 loadIncludeOnce('inc/footer.php');
98 redirectToUrl('modules.php?module=index');
102 // Initialize the surfbar
105 // Handle tasks on self-maintenance
106 SURFBAR_HANDLE_SELF_MAINTENANCE();
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...
112 loadIncludeOnce('inc/header.php');
115 if (((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'stop2')) || (!isGetRequestParameterSet('frame'))) {
116 // Load template for "start" page
117 loadTemplate('surfbar_frame_start');
120 loadTemplate('surfbar_start_banner');
122 // This makes the footer appear again
123 unsetGetRequestParameter('frame');
124 } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'stats')) {
125 // Get total points amount
126 $points = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
131 'reload' => (getConfig('surfbar_stats_reload') * 1000)
134 // Load template for "stats" page
135 loadTemplate('surfbar_frame_stats', false, $content);
136 } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'textlinks')) {
139 'reload' => (getConfig('surfbar_stats_reload') * 1000)
142 // Load template for "stats" page
143 loadTemplate('surfbar_frame_textlinks', false, $content);
147 'start' => str_repeat('X', strlen(getConfig('surfbar_restart_time'))),
148 'autostart' => (getConfig('surfbar_autostart') == 'Y') ? 'true' : 'false'
151 // Load template for stopped surfbar
152 loadTemplate('surfbar_stopped', false, $content);
154 } elseif ((isGetRequestParameterSet('check')) && (isGetRequestParameterSet('id')) && (isGetRequestParameterSet('salt'))) {
156 SURFBAR_DETERMINE_NEXT_ID(getRequestParameter('id'));
158 // Check reload lock and validation code
159 if ((!SURFBAR_CHECK_RELOAD_LOCK(getRequestParameter('id'))) && (SURFBAR_CHECK_VALIDATION_CODE(getRequestParameter('id'), getRequestParameter('check'), getRequestParameter('salt')))) {
160 // Lock the URL (id) down
161 SURFBAR_LOCKDOWN_ID(getRequestParameter('id'));
163 // Code is valid so pay points here
164 SURFBAR_PAY_POINTS();
166 // Check if reload is full
167 if (SURFBAR_CHECK_RELOAD_FULL()) {
168 // Then load waiting page
169 SURFBAR_RELOAD_TO_STOP_PAGE();
172 // Reload to stop frame!
173 SURFBAR_RELOAD_TO_STOP_PAGE();
176 // All done, so fix notice for footer.php
177 $GLOBALS['footer_sent'] = 1;
182 // Determine template name
183 $templateName = SURFBAR_DETERMINE_TEMPLATE_NAME();
185 // Load header in frameset mode is the default
189 if ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'top')) {
191 $nextId = SURFBAR_DETERMINE_NEXT_ID();
193 // Is there a valid id?
195 // Then prepare other content
198 'xxx' => str_repeat('X', strlen(SURFBAR_GET_RELOAD_TIME($nextId)))
201 // Update salt (double-call lock!) and statistics
202 SURFBAR_UPDATE_SALT_STATS();
205 SURFBAR_RELOAD_TO_STOP_PAGE('stop');
207 } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'start')) {
208 // Starter frame found so let the footer display
209 unsetGetRequestParameter('frame');
213 loadIncludeOnce('inc/header.php');
215 // Load that template
216 //* DEBUG: */ die("templateName={$templateName}<br />\n<strong>content</strong>=<pre>".print_r($content, true)."</pre>");
217 loadTemplate($templateName, false, $content);
221 $GLOBALS['footer_sent'] = 3;
222 loadIncludeOnce('inc/footer.php');