-if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed'))) {
- // Only logged in users may use this surfbar!
- if (!IS_LOGGED_IN()) {
- // Redirect
- LOAD_URL(URL."/modules.php?module=index");
- } // END - if
-
- // Is there a check value?
- if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isset($_GET['frame'])) && (($_GET['frame'] == "stop") || ($_GET['frame'] == "stop2")))) {
- // Reload-lock is full, surfbar stopped so...
- // Load header
- require_once(PATH."inc/header.php");
-
- // Load template
- if (((isset($_GET['frame'])) && ($_GET['frame'] == "stop")) || (!isset($_GET['frame']))) {
- // Load template for "start" page
- LOAD_TEMPLATE("surfbar_frame_start");
-
- // Load banner
- OUTPUT_HTML("<br />");
- LOAD_TEMPLATE("surfbar_start_banner");
-
- // This makes the footer appear again
- unset($_GET['frame']);
- } else {
- // Prepare content
- $content = array(
- 'restart' => $_CONFIG['surfbar_restart_time'],
- 'start' => str_repeat("X", strlen($_CONFIG['surfbar_restart_time'])),
- 'autostart' => ($_CONFIG['surfbar_autostart'] == "Y") ? "true" : "false"
- );
+if (!isInstalled()) {
+ // You have to install first!
+ redirectToUrl('install.php');
+} // END - if
+
+// Only logged in users may use this surfbar!
+redirectOnUninstalledExtension('surfbar');
+
+// No member?
+if (!IS_MEMBER()) {
+ // Redirect
+ // @TODO Display quick login form here or redirect as configured
+ redirectToUrl('modules.php?module=index');
+} // END - if
+
+// Initialize the surfbar
+SURFBAR_INIT();
+
+// Handle tasks on self-maintenance
+SURFBAR_HANDLE_SELF_MAINTENANCE();
+
+// Is there a check value?
+if ((SURFBAR_CHECK_RELOAD_FULL()) || ((REQUEST_ISSET_GET('frame')) && (in_array(REQUEST_GET('frame'), array('stop', 'stop2', 'stats', 'textlinks'))))) {
+ // Reload-lock is full, surfbar stopped so...
+ // Load header
+ loadIncludeOnce('inc/header.php');
+
+ // Load template
+ if (((REQUEST_ISSET_GET('frame')) && (REQUEST_GET('frame') == 'stop')) || (!REQUEST_ISSET_GET('frame'))) {
+ // Load template for "start" page
+ LOAD_TEMPLATE('surfbar_frame_start');
+
+ // Load banner
+ LOAD_TEMPLATE('surfbar_start_banner');
+
+ // This makes the footer appear again
+ REQUEST_UNSET_GET('frame');
+ } elseif ((REQUEST_ISSET_GET('frame')) && (REQUEST_GET('frame') == 'stats')) {
+ // Get total points amount
+ $points = GET_TOTAL_DATA(getUserId(), 'user_points', 'points') - GET_TOTAL_DATA(getUserId(), 'user_data', 'used_points');