Validation of points amount added to surfbar
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
35 require_once("inc/libs/security_functions.php");
36
37 // Init "action" and "what"
38 global $what, $action, $startTime, $SURFBAR_CACHE;
39 $SURFBAR_CACHE = array();
40 $GLOBALS['startTime'] = microtime(true);
41 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
42
43 // Set module
44 $GLOBALS['module'] = "surfbar";
45 $GLOBALS['refid']  = 0;
46 $CSS = 0;
47 $msg = null;
48
49 // Load the required file(s)
50 require ("inc/config.php");
51
52 // Is the script installed?
53 if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed'))) {
54         // Only logged in users may use this surfbar!
55         if (!IS_LOGGED_IN()) {
56                 // Redirect
57                 LOAD_URL(URL."/modules.php?module=index");
58         } // END - if
59
60         // Is there a check value?
61         if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isset($_GET['frame'])) && (($_GET['frame'] == "stop") || ($_GET['frame'] == "stop2")))) {
62                 // Reload-lock is full, surfbar stopped so...
63                 // Load header
64                 require_once(PATH."inc/header.php");
65
66                 // Load template
67                 if (((isset($_GET['frame'])) && ($_GET['frame'] == "stop")) || (!isset($_GET['frame']))) {
68                         // Load template for "start" page
69                         LOAD_TEMPLATE("surfbar_frame_start");
70
71                         // Load banner
72                         OUTPUT_HTML("<br />");
73                         LOAD_TEMPLATE("surfbar_start_banner");
74
75                         // This makes the footer appear again
76                         unset($_GET['frame']);
77                 } else {
78                         // Prepare content
79                         $content = array(
80                                 'restart'   => $_CONFIG['surfbar_restart_time'],
81                                 'start'     => str_repeat("X", strlen($_CONFIG['surfbar_restart_time'])),
82                                 'autostart' => ($_CONFIG['surfbar_autostart'] == "Y") ? "true" : "false"
83                         );
84
85                         // Load template for stopped surfbar
86                         LOAD_TEMPLATE("surfbar_stopped", false, $content);
87                 }
88         } elseif ((isset($_GET['check'])) && (isset($_GET['id'])) && (isset($_GET['salt']))) {
89                 // Dummy next id get
90                 SURFBAR_GET_NEXT_ID($_GET['id']);
91
92                 // Check reload lock and validation code
93                 if ((!SURFBAR_CHECK_RELOAD_LOCK($_GET['id'])) && (SURFBAR_CHECK_VALIDATION_CODE($_GET['id'], $_GET['check'], $_GET['salt']))) {
94                         // Lock the URL (id) down
95                         SURFBAR_LOCKDOWN_ID($_GET['id']);
96
97                         // Code is valid so pay points here
98                         SURFBAR_PAY_POINTS($_GET['id']);
99
100                         // Check if reload is full
101                         if (SURFBAR_CHECK_RELOAD_FULL()) {
102                                 // Then load waiting page
103                                 LOAD_URL("surfbar.php?frame=stop");
104                         } // END - if
105                 } else {
106                         // Reload to stop frame!
107                         LOAD_URL("surfbar.php?frame=stop");
108                 }
109
110                 // All done, so fix notice for footer.php
111                 $footer = 1;
112         } else {
113                 // Prepare content
114                 $content = "";
115
116                 // Determine template name
117                 $templateName = SURFBAR_DETERMINE_TEMPLATE_NAME();
118
119                 // Frame "top" set?
120                 if ((isset($_GET['frame'])) && ($_GET['frame'] == "top")) {
121                         // Determine next id
122                         $nextId = SURFBAR_GET_NEXT_ID();
123
124                         // Is there a valid id?
125                         if ($nextId > 0) {
126                                 // Then prepare other content
127                                 $content = array(
128                                         'id'          => $nextId,
129                                         'check'       => SURFBAR_GENERATE_VALIDATION_CODE($nextId),
130                                         'salt'        => SURFBAR_GET_SALT(),
131                                         'reward'      => TRANSLATE_COMMA(SURFBAR_GET_REWARD($nextId)),
132                                         'url'         => SURFBAR_GET_URL($nextId),
133                                         'curr_reload' => SURFBAR_GET_USER_RELOAD_LOCK(),
134                                         'max_urls'    => SURFBAR_GET_TOTAL_URLS(),
135                                         'reload'      => SURFBAR_GET_RELOAD_TIME($nextId)
136                                 );
137
138                                 // Update salt (double-call lock!)
139                                 SURFBAR_UPDATE_SALT();
140                         } else {
141                                 // Load new URL
142                                 LOAD_URL("surfbar.php?frame=stop2");
143                         }
144                 } elseif ((isset($_GET['frame'])) && ($_GET['frame'] == "start")) {
145                         // Starter frame found so let the footer display
146                         unset($_GET['frame']);
147                 } else {
148                         // Load header in frameset mode
149                         $isFrameset = true;
150                 }
151
152                 // Load header
153                 require_once(PATH."inc/header.php");
154
155                 // Load that template
156                 //* DEBUG: */ die("templateName={$templateName}<br />\n<strong>content</strong>=<pre>".print_r($content, true)."</pre>");
157                 LOAD_TEMPLATE($templateName, false, $content);
158         }
159
160         // Load footer
161         require_once(PATH."inc/footer.php");
162 } else {
163         // You have to configure first!
164         LOAD_URL("install.php");
165 }
166
167 // Close any open database connection here
168 SQL_CLOSE($link, __FILE__, __LINE__);
169
170 // Really all done here... ;-)
171 ?>