One more found
[mailer.git] / surfbar.php
index ccec32bb02fc723e781783281d2aee9a2f1f57b9..1dc43451c404946ce55bc829dcac3d52e915e01b 100644 (file)
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -42,8 +41,8 @@ require('inc/libs/security_functions.php');
 // Init start time
 $GLOBALS['startTime'] = microtime(true);
 
-// Set module
-$GLOBALS['module'] = 'surfbar';
+// Set module output mode
+$GLOBALS['__module'] = 'surfbar';
 $GLOBALS['output_mode'] = '0';
 $GLOBALS['header_sent'] = 3;
 
@@ -54,7 +53,7 @@ require('inc/config-global.php');
 setContentType('text/html');
 
 // Is a frame active?
-if (isGetRequestParameterSet('frame')) {
+if (isGetRequestElementSet('frame')) {
        // Then we need to set header_sent to 0
        $GLOBALS['header_sent'] = '0';
 } // END - if
@@ -67,20 +66,20 @@ if (!isMember()) {
        // Should we display login window or redirect to main page?
        if ((getConfig('surfbar_guest_login_form') == 'Y') && (isExtensionActive('user'))) {
                // Is the form sent?
-               if ((isFormSent()) && (isPostRequestParameterSet('id')) && (isPostRequestParameterSet('password'))) {
+               if ((isFormSent()) && (isPostRequestElementSet('id')) && (isPostRequestElementSet('password'))) {
                        // Do the login procedure
-                       $URL = doUserLogin(postRequestParameter('id'), postRequestParameter('password'), basename(__FILE__), basename(__FILE__) . '?code=');
+                       $url = doUserLogin(postRequestElement('id'), postRequestElement('password'), basename(__FILE__), basename(__FILE__) . '?code=');
 
                        // And redirect to the URL
-                       redirectToUrl($URL);
+                       redirectToUrl($url);
                } else {
                        // Load header
                        loadIncludeOnce('inc/header.php');
 
                        // Is there a 'code' provided?
-                       if (isGetRequestParameterSet('code')) {
+                       if (isGetRequestElementSet('code')) {
                                // Then generate an error message
-                               loadTemplate('admin_settings_saved', false, getMessageFromErrorCode(getRequestParameter('code')));
+                               displayMessage(getMessageFromErrorCode(getRequestElement('code')));
                        } // END - if
 
                        // Display login form
@@ -94,7 +93,7 @@ if (!isMember()) {
                }
        } else {
                // Redirect
-               redirectToUrl('index.php');
+               redirectToUrl('modules.php?module=index');
        }
 } // END - if
 
@@ -105,13 +104,13 @@ SURFBAR_INIT();
 SURFBAR_HANDLE_SELF_MAINTENANCE();
 
 // Is there a check value?
-if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in_array(getRequestParameter('frame'), array('stop', 'stop2', 'stats', 'textlinks'))))) {
+if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestElementSet('frame')) && (in_array(getRequestElement('frame'), array('stop', 'stop2', 'stats', 'textlinks'))))) {
        // Reload-lock is full, surfbar stopped so...
        // Load header
        loadIncludeOnce('inc/header.php');
 
        // Load template
-       if (((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'stop2')) || (!isGetRequestParameterSet('frame'))) {
+       if (((isGetRequestElementSet('frame')) && (getRequestElement('frame') == 'stop2')) || (!isGetRequestElementSet('frame'))) {
                // Load template for "start" page
                loadTemplate('surfbar_frame_start');
 
@@ -119,30 +118,20 @@ if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in
                loadTemplate('surfbar_start_banner');
 
                // This makes the footer appear again
-               unsetGetRequestParameter('frame');
-       } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'stats')) {
-               // Get total points amount
-               $points = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
-
+               unsetGetRequestElement('frame');
+       } elseif ((isGetRequestElementSet('frame')) && (getRequestElement('frame') == 'stats')) {
                // Prepare content
                $content = array(
-                       'points'   => translateComma($points),
-                       'online'   => SURFBAR_DETERMINE_TOTAL_ONLINE(),
-                       'reload'   => (getConfig('surfbar_stats_reload') * 1000),
-                       'c_total'  => translateComma(getConfig('surfbar_total_counter')),
-                       'c_today'  => translateComma(getConfig('surfbar_daily_counter')),
-                       'c_yester' => translateComma(getConfig('surfbar_yester_counter')),
-                       'c_week'   => translateComma(getConfig('surfbar_weekly_counter')),
-                       'c_month'  => translateComma(getConfig('surfbar_monthly_counter')),
+                       'points' => getTotalPoints(getMemberId()),
+                       'reload' => (getConfig('surfbar_stats_reload') * 1000)
                );
 
                // Load template for "stats" page
                loadTemplate('surfbar_frame_stats', false, $content);
-       } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'textlinks')) {
+       } elseif ((isGetRequestElementSet('frame')) && (getRequestElement('frame') == 'textlinks')) {
                // Prepare content
                $content = array(
-                       'online'   => SURFBAR_DETERMINE_TOTAL_ONLINE(),
-                       'reload'   => (getConfig('surfbar_stats_reload') * 1000)
+                       'reload' => (getConfig('surfbar_stats_reload') * 1000)
                );
 
                // Load template for "stats" page
@@ -157,14 +146,14 @@ if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in
                // Load template for stopped surfbar
                loadTemplate('surfbar_stopped', false, $content);
        }
-} elseif ((isGetRequestParameterSet('check')) && (isGetRequestParameterSet('id')) && (isGetRequestParameterSet('salt'))) {
+} elseif ((isGetRequestElementSet('check')) && (isGetRequestElementSet('id')) && (isGetRequestElementSet('salt'))) {
        // Dummy next id get
-       SURFBAR_DETERMINE_NEXT_ID(getRequestParameter('id'));
+       SURFBAR_DETERMINE_NEXT_ID(getRequestElement('id'));
 
        // Check reload lock and validation code
-       if ((!SURFBAR_CHECK_RELOAD_LOCK(getRequestParameter('id'))) && (SURFBAR_CHECK_VALIDATION_CODE(getRequestParameter('id'), getRequestParameter('check'), getRequestParameter('salt')))) {
+       if ((!SURFBAR_CHECK_RELOAD_LOCK(getRequestElement('id'))) && (SURFBAR_CHECK_VALIDATION_CODE(getRequestElement('id'), getRequestElement('check'), getRequestElement('salt')))) {
                // Lock the URL (id) down
-               SURFBAR_LOCKDOWN_ID(getRequestParameter('id'));
+               SURFBAR_LOCKDOWN_ID(getRequestElement('id'));
 
                // Code is valid so pay points here
                SURFBAR_PAY_POINTS();
@@ -174,6 +163,9 @@ if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in
                        // Then load waiting page
                        SURFBAR_RELOAD_TO_STOP_PAGE();
                } // END - if
+
+               // Load header to avoid a bug
+               loadIncludeOnce('inc/header.php');
        } else {
                // Reload to stop frame!
                SURFBAR_RELOAD_TO_STOP_PAGE();
@@ -185,30 +177,18 @@ if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in
        // Prepare content
        $content = '';
 
-       // Determine template name
-       $templateName = SURFBAR_DETERMINE_TEMPLATE_NAME();
-
-       // Load header in frameset mode is the default
-       $isFrameset = true;
-
        // Frame "top" set?
-       if ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'top')) {
+       if ((isGetRequestElementSet('frame')) && (getRequestElement('frame') == 'top')) {
                // Determine next id
                $nextId = SURFBAR_DETERMINE_NEXT_ID();
+               //* DEBUG: */ die('nextId='.$nextId);
 
                // Is there a valid id?
                if ($nextId > 0) {
                        // Then prepare other content
                        $content = array(
-                               'id'          => $nextId,
-                               'check'       => SURFBAR_GENERATE_VALIDATION_CODE($nextId),
-                               'salt'        => SURFBAR_GET_SALT(),
-                               'reward'      => translateComma(SURFBAR_GET_REWARD($nextId)),
-                               'url'         => SURFBAR_GET_URL($nextId),
-                               'curr_reload' => SURFBAR_GET_USER_LOCKS(),
-                               'max_urls'    => SURFBAR_GET_TOTAL_URLS(),
-                               'reload'      => SURFBAR_GET_RELOAD_TIME($nextId),
-                               'xxx'         => str_repeat('X', strlen(SURFBAR_GET_RELOAD_TIME($nextId)))
+                               'url_id' => $nextId,
+                               'xxx'    => str_repeat('X', strlen(SURFBAR_GET_RELOAD_TIME($nextId))),
                        );
 
                        // Update salt (double-call lock!) and statistics
@@ -217,16 +197,19 @@ if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestParameterSet('frame')) && (in
                        // Load new URL
                        SURFBAR_RELOAD_TO_STOP_PAGE('stop');
                }
-       } elseif ((isGetRequestParameterSet('frame')) && (getRequestParameter('frame') == 'start')) {
+       } elseif ((isGetRequestElementSet('frame')) && (getRequestElement('frame') == 'start')) {
                // Starter frame found so let the footer display
-               unsetGetRequestParameter('frame');
+               unsetGetRequestElement('frame');
        }
 
        // Load header
        loadIncludeOnce('inc/header.php');
 
+       // Determine template name
+       $templateName = SURFBAR_DETERMINE_TEMPLATE_NAME();
+
        // Load that template
-       //* DEBUG: */ die("templateName={$templateName}<br />\n<strong>content</strong>=<pre>".print_r($content, true)."</pre>");
+       //* DEBUG: */ die('templateName=' . $templateName . '<br /><strong>content</strong>=<pre>' . print_r($content, true) . '</pre>');
        loadTemplate($templateName, false, $content);
 }