Tons of rewrites (SQL queries), surfbar nearly finished (working: surfing with static...
[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_DATA;
39 $SURFBAR_DATA = 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 ((isset($_GET['check'])) && (isset($_GET['id'])) && (isset($_GET['salt']))) {
62                 // Dummy next id get
63                 SURFBAR_GET_NEXT_ID($_GET['id']);
64
65                 // Check validation code
66                 if (SURFBAR_CHECK_VALIDATION_CODE($_GET['id'], $_GET['check'], $_GET['salt'])) {
67                         // Lock the URL (id) down
68                         SURFBAR_LOCKDOWN_ID($_GET['id']);
69
70                         // Code is valid so pay points here
71                         SURFBAR_PAY_POINTS($_GET['id']);
72                 } // END - if
73
74                 // Set footer (fixes notice)
75                 $footer = 1;
76         } elseif (SURFBAR_CHECK_RELOAD_FULL()) {
77                 // Reload-lock is full, surfbar stopped so...
78                 // Load header
79                 require_once(PATH."inc/header.php");
80
81                 // Load template
82                 LOAD_TEMPLATE("surfbar_stopped");
83         } else {
84                 // Prepare content
85                 $content = "";
86
87                 // Determine template name
88                 $templateName = SURFBAR_DETERMINE_TEMPLATE_NAME();
89
90                 // Frame "top" set?
91                 if ((isset($_GET['frame'])) && ($_GET['frame'] == "top")) {
92                         // Determine next id
93                         $nextId = SURFBAR_GET_NEXT_ID();
94
95                         // Is there a valid id?
96                         if ($nextId > 0) {
97                                 // Then prepare other content
98                                 $content = array(
99                                         'id'          => $nextId,
100                                         'check'       => SURFBAR_GENERATE_VALIDATION_CODE($nextId),
101                                         'salt'        => $SURFBAR_DATA['salt'],
102                                         'reward'      => TRANSLATE_COMMA(SURFBAR_GET_REWARD($nextId)),
103                                         'url'         => SURFBAR_GET_URL($nextId),
104                                         'curr_reload' => SURFBAR_GET_USER_RELOAD_LOCK(),
105                                         'max_urls'    => SURFBAR_GET_TOTAL_URLS(),
106                                         'reload'      => SURFBAR_GET_RELOAD_TIME($nextId)
107                         );
108
109                                 // Update salt (double-call lock!)
110                                 SURFBAR_UPDATE_SALT();
111                         } else {
112                                 // Change template name
113                                 $templateName = "surfbar_stopped";
114                         }
115                 } else {
116                         // Load header in frameset mode
117                         $isFrameset = true;
118                 }
119
120                 // Load header
121                 require_once(PATH."inc/header.php");
122
123                 // Load that template
124                 LOAD_TEMPLATE($templateName, false, $content);
125         }
126
127         // Load footer
128         require_once(PATH."inc/footer.php");
129 } else {
130         // You have to configure first!
131         LOAD_URL("install.php");
132 }
133
134 // Close any open database connection here
135 SQL_CLOSE($link, __FILE__, __LINE__);
136
137 // Really all done here... ;-)
138 ?>