]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/surfbar_functions.php
Naming convention applied, new wrapper introduced:
[mailer.git] / inc / libs / surfbar_functions.php
index b36ceb782ab6b6476982081600438f621e2b476b..8a4d3236196f09f0c3dbd99d3ef7c07125c6a18d 100644 (file)
@@ -216,7 +216,7 @@ function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
 }
 
 // Do the member form request
-function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
+function SURFBAR_MEMBER_DO_FORM ($formData, $urlArray) {
        // By default no action is performed
        $performed = false;
 
@@ -227,10 +227,10 @@ function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
        } elseif ((!isset($formData['id'])) || (!isset($formData['action']))) {
                // Important form elements are missing!
                return false;
-       } elseif (!isset($URLs[$formData['id']])) {
+       } elseif (!isset($urlArray[$formData['id']])) {
                // id not found in cache
                return false;
-       } elseif (!SURFBAR_VALIDATE_MEMBER_ACTION_STATUS($formData['action'], $URLs[$formData['id']]['url_status'])) {
+       } elseif (!SURFBAR_VALIDATE_MEMBER_ACTION_STATUS($formData['action'], $urlArray[$formData['id']]['url_status'])) {
                // Action not allowed for current URL status
                return false;
        }
@@ -250,10 +250,10 @@ function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
        // Is the function there?
        if (function_exists($functionName)) {
                // Add new status
-               $URLs[$formData['id']]['new_status'] = SURFBAR_GET_NEW_STATUS('new_status');
+               $urlArray[$formData['id']]['new_status'] = SURFBAR_GET_NEW_STATUS('new_status');
 
                // Extract URL data for call-back
-               $urlData = array(merge_array($URLs[$formData['id']], array($action => $formData)));
+               $urlData = array(merge_array($urlArray[$formData['id']], array($action => $formData)));
 
                // Action found so execute it
                $performed = call_user_func_array($functionName, $urlData);
@@ -309,7 +309,7 @@ function SURFBAR_MEMBER_RETREAT_ACTION ($urlData) {
 function SURFBAR_MEMBER_BOOKNOW_ACTION ($urlData) {
        // Create the data array for next function call
        $data = array(
-       $urlData['id'] => $urlData
+               $urlData['id'] => $urlData
        );
 
        // Simply change the status here
@@ -366,25 +366,19 @@ function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
        // Translate some data if present
        $content = SURFBAR_PREPARE_CONTENT_FOR_TEMPLATE($content);
 
-       // Is the lock reason empty?
-       if (empty($urlData['lock_reason'])) {
-               // Fix it to three dashes
-               $urlData['lock_reason'] = '---';
-       } // END - if
-
        // Include fields only for action 'edit'
        if ($action == 'edit') {
                // Default is not limited
-               $urlData['limited_y'] = '';
-               $urlData['limited_n'] = ' checked="checked"';
-               $urlData['limited']   = 'false';
+               $urlData['limited_yes'] = '';
+               $urlData['limited_no']  = ' checked="checked"';
+               $urlData['limited']     = 'false';
 
                // Is this URL limited?
                if (SURFBAR_GET_VIEWS_MAX() > 0) {
                        // Then rewrite form data
-                       $urlData['limited_y'] = ' checked="checked"';
-                       $urlData['limited_n'] = '';
-                       $urlData['limited']   = 'true';
+                       $urlData['limited_yes'] = ' checked="checked"';
+                       $urlData['limited_no']  = '';
+                       $urlData['limited']     = 'true';
                } // END - if
        } // END - if
 
@@ -418,7 +412,7 @@ function SURFBAR_MEMBER_EXECUTE_ACTION ($action, $urlData) {
                } // END - if
        } else {
                // Not found!
-               addFatalMessage(__FUNCTION__, __LINE__, getMessage('MEMBER_SURFBAR_EXECUTE_ACTION_404'), $functionName);
+               addFatalMessage(__FUNCTION__, __LINE__, '{--MEMBER_SURFBAR_EXECUTE_ACTION_404--}', $functionName);
        }
 
        // Return status
@@ -488,16 +482,14 @@ function SURFBAR_HANDLE_LOW_POINTS () {
        $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points'));
 
        // "Walk" through all URLs
-       foreach ($userids['userid'] as $userid => $dummy) {
+       foreach ($userids['url_userid'] as $userid => $dummy) {
                // Is the last notification far enougth away to notify again?
                if ((time() - $userids['notified'][$userid]) >= getConfig('surfbar_low_interval')) {
                        // Prepare content
                        $content = array(
-                               'userid'   => $userid,
-                               'low'      => translateComma(getConfig('surfbar_warn_low_points')),
-                               'points'   => translateComma($userids['points'][$userid]),
-                               'notified' => generateDateTime($userids['notified'][$userid]),
-                               'interval' => createFancyTime(getConfig('surfbar_low_interval'))
+                               'url_userid' => $userid,
+                               'points'     => $userids['points'][$userid],
+                               'notified'   => $userids['notified'][$userid]
                        );
 
                        // Notify this user
@@ -560,7 +552,7 @@ function SURFBAR_GET_URL_DATA ($searchTerm, $column = 'url_id', $order = 'url_id
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_urls`
 WHERE
-       `%s`='%s'".$add."
+       `%s`='%s'" . $add . "
 ORDER BY
        `%s` %s
 %s",
@@ -573,7 +565,7 @@ ORDER BY
                ), __FUNCTION__, __LINE__);
 
        // Is there at least one record?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Then load all!
                while ($dataRow = SQL_FETCHARRAY($result)) {
                        // Shall we group these results?
@@ -604,7 +596,6 @@ function SURFBAR_REGISTER_URL ($url, $userid, $status = 'PENDING', $addMode = 'r
        // Prepare content
        $content = merge_array($extraFields, array(
                'url'         => $url,
-               'frametester' => generateFrametesterUrl($url),
                'url_userid'  => $userid,
                'url_status'  => $status,
        ));
@@ -626,9 +617,6 @@ function SURFBAR_REGISTER_URL ($url, $userid, $status = 'PENDING', $addMode = 'r
                return false;
        } // END - if
 
-       // Translate status and limit
-       $content['limit'] = translateSurfbarLimit($content['limit']);
-
        // If in reg-mode we notify admin
        if (($addMode == 'reg') || (getConfig('surfbar_notify_admin_unlock') == 'Y')) {
                // Notify admin even when he as unlocked an email
@@ -672,9 +660,9 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
        $templateName = sprintf("admin_surfbar_%s", $messageType);
 
        // Prepare subject
-       $subject = getMessage(sprintf("ADMIN_SURFBAR_NOTIFY_%s_SUBJECT",
+       $subject = sprintf("{--ADMIN_SURFBAR_NOTIFY_%s_SUBJECT--}",
                strtoupper($messageType)
-       ));
+       );
 
        // Is the subject line there?
        if ((substr($subject, 0, 1) == '!') && (substr($subject, -1, 1) == '!')) {
@@ -686,13 +674,13 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
        $content = SURFBAR_PREPARE_CONTENT_FOR_TEMPLATE($content);
 
        // Send the notification out
-       return sendAdminNotification($subject, $templateName, $content, $content['userid']);
+       return sendAdminNotification($subject, $templateName, $content, $content['url_userid']);
 }
 
 // Notify the user about the performed action
 function SURFBAR_NOTIFY_USER ($messageType, $content) {
        // Skip notification if userid is zero
-       if ($content['userid'] == '0') {
+       if ($content['url_userid'] == '0') {
                return false;
        } // END - if
 
@@ -700,36 +688,32 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) {
        $templateName = sprintf("member_surfbar_%s", $messageType);
 
        // Prepare subject
-       $subject = getMessage(sprintf("MEMBER_SURFBAR_NOTIFY_%s_SUBJECT",
+       $subject = sprintf("{--MEMBER_SURFBAR_NOTIFY_%s_SUBJECT--}",
                strtoupper($messageType)
-       ));
+       );
 
        // Is the subject line there?
        if ((substr($subject, 0, 1) == '!') && (substr($subject, -1, 1) == '!')) {
                // Set default subject if following eval() wents wrong
-               $subject = getMessage('MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT');
+               $subject = '{--MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT--}';
        } // END - if
 
        // Translate some data if present
        $content = SURFBAR_PREPARE_CONTENT_FOR_TEMPLATE($content);
 
        // Load template
-       $mailText = loadEmailTemplate($templateName, $content, $content['userid']);
+       $mailText = loadEmailTemplate($templateName, $content, $content['url_userid']);
 
        // Send the email
-       return sendEmail($content['userid'], $subject, $mailText);
+       return sendEmail($content['url_userid'], $subject, $mailText);
 }
 
 // Translates some data for template usage
 // @TODO Can't we use our new expression language instead of this ugly code?
 function SURFBAR_PREPARE_CONTENT_FOR_TEMPLATE ($content) {
        // Prepare some code
-       if (isset($content['url_status']))      $content['url_status']      = translateSurfbarUrlStatus($content['url_status']);
        if (isset($content['url_registered']))  $content['url_registered']  = generateDateTime($content['url_registered'], 2);
        if (isset($content['url_last_locked'])) $content['url_last_locked'] = generateDateTime($content['url_last_locked'], 2);
-       if (isset($content['url_views_total'])) $content['url_views_total'] = translateComma($content['url_views_total']);
-       if (isset($content['url_views_allowed']))   $content['url_views_allowed']   = translateComma($content['url_views_allowed']);
-       if (isset($content['views_max']))       $content['views_max']       = translateComma($content['views_max']);
 
        // Return translated content
        return $content;
@@ -740,7 +724,7 @@ function translateSurfbarLimit ($limit) {
        // Is this zero?
        if ($limit == '0') {
                // Unlimited!
-               $return = getMessage('MEMBER_SURFBAR_UNLIMITED_VIEWS');
+               $return = '{--MEMBER_SURFBAR_UNLIMITED_VIEWS--}';
        } else {
                // Translate comma
                $return = translateComma($limit);
@@ -752,14 +736,8 @@ function translateSurfbarLimit ($limit) {
 
 // Translate the URL status
 function translateSurfbarUrlStatus ($status) {
-       // Create constant name
-       $constantName = sprintf("SURFBAR_URL_STATUS_%s", strtoupper($status));
-
-       // Get message
-       $statusTranslated = getMessage($constantName);
-
        // Return result
-       return $statusTranslated;
+       return sprintf("{--SURFBAR_URL_STATUS_%s--}", strtoupper($status));
 }
 
 // Determine reward
@@ -819,7 +797,7 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() {
        if (isGetRequestParameterSet('frame')) {
                // Use the frame as a template name part... ;-)
                $templateName = sprintf("surfbar_frame_%s",
-               getRequestParameter('frame')
+                       getRequestParameter('frame')
                );
        } // END - if
 
@@ -829,7 +807,7 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() {
 
 // Check if the "reload lock" of the current user is full, call this function
 // before you call SURFBAR_CHECK_RELOAD_LOCK().
-function SURFBAR_CHECK_RELOAD_FULL() {
+function SURFBAR_CHECK_RELOAD_FULL () {
        // Default is full!
        $isFull = true;
 
@@ -892,7 +870,7 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
        $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS();
 
        // If we dont get any user ids back, there are no URLs
-       if (count($userids['userid']) == 0) {
+       if (count($userids['url_userid']) == 0) {
                // No user ids found, no URLs!
                return 0;
        } // END - if
@@ -900,7 +878,7 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
        // Is the exlude userid set?
        if ($excludeUserId > 0) {
                // Then add it
-               $userids['userid'][$excludeUserId] = $excludeUserId;
+               $userids['url_userid'][$excludeUserId] = $excludeUserId;
        } // END - if
 
        // Get amount from database
@@ -909,7 +887,7 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_urls`
 WHERE
-       `url_userid` NOT IN (".implode(', ', $userids['userid']).") AND
+       `url_userid` NOT IN (".implode(', ', $userids['url_userid']).") AND
        `url_status`='%s'
 LIMIT 1",
                array($status), __FUNCTION__, __LINE__
@@ -921,6 +899,9 @@ LIMIT 1",
        // Free result
        SQL_FREERESULT($result);
 
+       // Debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $cnt);
+
        // Return result
        return $cnt;
 }
@@ -1024,7 +1005,7 @@ function SURFBAR_CHECK_VALIDATION_CODE ($urlId, $check, $salt) {
 
 // Lockdown the userid/id combination (reload lock)
 function SURFBAR_LOCKDOWN_ID ($urlId) {
-       //* DEBUG: */ outputHtml('LOCK!');
+       //* DEBUG: */ debugOutput('LOCK!');
        ///* DEBUG: */ return;
        // Just add it to the database
        SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)",
@@ -1039,7 +1020,7 @@ function SURFBAR_LOCKDOWN_ID ($urlId) {
 function SURFBAR_PAY_POINTS () {
        // Remove it from the URL owner
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS().'', false);
-       if (SURFBAR_GET_USERID() > 0) {
+       if (isValidUserId(SURFBAR_GET_USERID())) {
                subtractPoints(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
        } // END - if
 
@@ -1098,6 +1079,9 @@ function SURFBAR_UPDATE_SALT_STATS () {
        // Update statistics record
        SURFBAR_UPDATE_INSERT_STATS_RECORD();
 
+       // Update salt
+       SURFBAR_GENERATE_VALIDATION_CODE(SURFBAR_GET_ID());
+
        // Simply store the salt from cache away in database...
        SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_salts` SET `salts_last_salt`='%s' WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1",
                array(
@@ -1155,17 +1139,17 @@ LIMIT 1",
 function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
        // Init array
        $userids = array(
-               'userid'      => array(),
-               'points'   => array(),
-               'notified' => array(),
+               'url_userid'   => array(),
+               'points'       => array(),
+               'notified'     => array(),
        );
 
        // Do we have a current user id?
        if ((isMember()) && ($limit == '0')) {
                // Then add this as well
-               $userids['userid'][getMemberId()]      = getMemberId();
-               $userids['points'][getMemberId()]   = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
-               $userids['notified'][getMemberId()] = '0';
+               $userids['url_userid'][getMemberId()] = getMemberId();
+               $userids['points'][getMemberId()]     = getTotalPoints(getMemberId());
+               $userids['notified'][getMemberId()]   = '0';
 
                // Get all userid except logged in one
                $result = SQL_QUERY_ESC("SELECT
@@ -1204,16 +1188,16 @@ ORDER BY
        // Load all userid
        while ($content = SQL_FETCHARRAY($result)) {
                // Get total points
-               $points = countSumTotalData($content['userid'], 'user_points', 'points') - countSumTotalData($content['userid'], 'user_data', 'used_points');
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['userid']},points={$points}", false);
+               $points = getTotalPoints($content['url_userid']);
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['url_userid']},points={$points}", false);
 
                // Shall we add this to ignore?
                if ($points <= $limit) {
                        // Ignore this one!
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['userid']} has depleted points amount!", false);
-                       $userids['userid'][$content['userid']]      = $content['userid'];
-                       $userids['points'][$content['userid']]   = $points;
-                       $userids['notified'][$content['userid']] = $content['notified'];
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['url_userid']} has depleted points amount!", false);
+                       $userids['url_userid'][$content['url_userid']] = $content['url_userid'];
+                       $userids['points'][$content['url_userid']]     = $points;
+                       $userids['notified'][$content['url_userid']]   = $content['notified'];
                } // END - if
        } // END - while
 
@@ -1299,7 +1283,7 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array())
 
        // Update the status now
        // ---------- Comment out for debugging/developing member actions! ---------
-       //SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `status`='%s' WHERE `id`=%s LIMIT 1",
+       //SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `status`='%s' WHERE `url_id`=%s LIMIT 1",
        //      array($newStatus, bigintval($urlId)), __FUNCTION__, __LINE__);
        // ---------- Comment out for debugging/developing member actions! ---------
 
@@ -1312,7 +1296,7 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array())
        // ---------- Comment out for debugging/developing member actions! ---------
 
        // Prepare content for notification routines
-       $data[$urlId]['userid']         = $data[$urlId]['userid'];
+       $data[$urlId]['url_userid']  = $data[$urlId]['url_userid'];
        $data[$urlId]['frametester'] = generateFrametesterUrl($data[$urlId]['url']);
        $data[$urlId]['reward']      = translateComma(getConfig('surfbar_static_reward'));
        $data[$urlId]['costs']       = translateComma(getConfig('surfbar_static_costs'));
@@ -1342,7 +1326,7 @@ function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () {
        $percent = abs(log(getConfig('surfbar_dynamic_percent') / 100 + 1));
 
        // Get total users
-       $totalUsers = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
+       $totalUsers = getTotalConfirmedUser();
 
        // Get online users
        $onlineUsers = SURFBAR_DETERMINE_TOTAL_ONLINE();
@@ -1379,7 +1363,7 @@ function SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE () {
        $percent = abs(log(getConfig('surfbar_dynamic_percent') / 100 + 1));
 
        // Get total users
-       $totalUsers = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
+       $totalUsers = getTotalConfirmedUser();
 
        // Calculate addon
        $addon += abs($max * $percent * $totalUsers);
@@ -1502,7 +1486,7 @@ GROUP BY
 // Load all URLs of the current user and return it as an array
 function SURFBAR_GET_USER_URLS () {
        // Init array
-       $URLs = array();
+       $urlArray = array();
 
        // Begin the query
        $result = SQL_QUERY_ESC("SELECT
@@ -1526,11 +1510,11 @@ ORDER BY
        array(getMemberId()), __FUNCTION__, __LINE__);
 
        // Are there entries?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Load all rows
                while ($row = SQL_FETCHARRAY($result)) {
                        // Add the row
-                       $URLs[$row['id']] = $row;
+                       $urlArray[$row['id']] = $row;
                } // END - while
        } // END - if
 
@@ -1538,7 +1522,7 @@ ORDER BY
        SQL_FREERESULT($result);
 
        // Return the array
-       return $URLs;
+       return $urlArray;
 }
 
 // "Getter" for member action array for given status
@@ -1551,7 +1535,7 @@ function SURFBAR_GET_ARRAY_FROM_STATUS ($status) {
                array($status), __FUNCTION__, __LINE__);
 
        // Some entries there?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Load all actions
                // @TODO This can be somehow rewritten
                while ($content = SQL_FETCHARRAY($result)) {
@@ -1608,7 +1592,7 @@ function SURFBAR_DETERMINE_NEXT_ID ($urlId = '0') {
                $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS();
 
                // Get maximum randomness factor
-               $maxRand = SURFBAR_GET_MAX_RANDOM($userids['userid'], $add);
+               $maxRand = SURFBAR_GET_MAX_RANDOM($userids['url_userid'], $add);
 
                // If more than one URL can be called generate the random number!
                if ($maxRand > 1) {
@@ -1639,7 +1623,7 @@ LEFT JOIN
 ON
        sbu.url_id=l.locks_url_id
 WHERE
-       sbu.url_userid NOT IN (".implode(',', $userids['userid']).") AND
+       sbu.url_userid NOT IN (".implode(',', $userids['url_userid']).") AND
        sbu.url_status='ACTIVE' AND
        (sbu.url_views_allowed=0 OR (sbu.url_views_allowed > 0 AND sbu.url_views_max > 0))
        ".$add."
@@ -1733,6 +1717,58 @@ LIMIT 1",
        return $nextId;
 }
 
+// ----------------------------------------------------------------------------
+// Wrapper function
+// ----------------------------------------------------------------------------
+
+// "Getter" for surfbar_dynamic_percent
+function getSurfbarDynamicPercent () {
+       // Do we have cache?
+       if (!isset($GLOBALS['surfbar_dynamic_percent'])) {
+               // Determine it
+               $GLOBALS['surfbar_dynamic_percent'] = getConfig('surfbar_dynamic_percent');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['surfbar_dynamic_percent'];
+}
+
+// "Getter" for surfbar_static_reward
+function getSurfbarStaticReward () {
+       // Do we have cache?
+       if (!isset($GLOBALS['surfbar_static_reward'])) {
+               // Determine it
+               $GLOBALS['surfbar_static_reward'] = getConfig('surfbar_static_reward');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['surfbar_static_reward'];
+}
+
+// "Getter" for surfbar_static_time
+function getSurfbarStaticTime () {
+       // Do we have cache?
+       if (!isset($GLOBALS['surfbar_static_time'])) {
+               // Determine it
+               $GLOBALS['surfbar_static_time'] = getConfig('surfbar_static_time');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['surfbar_static_time'];
+}
+
+// "Getter" for surfbar_max_order
+function getSurfbarMaxOrder () {
+       // Do we have cache?
+       if (!isset($GLOBALS['surfbar_max_order'])) {
+               // Determine it
+               $GLOBALS['surfbar_max_order'] = getConfig('surfbar_max_order');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['surfbar_max_order'];
+}
+
 // -----------------------------------------------------------------------------
 // PLEASE DO NOT ADD ANY OTHER FUNCTIONS BELOW THIS LINE IF THEY DON'T "WRAP"
 // THE $GLOBALS['surfbar_cache'] ARRAY!
@@ -1756,14 +1792,14 @@ function SURFBAR_GET_DATA ($element) {
                // Then take it
                $data = $GLOBALS['surfbar_cache'][$element];
        } else { // END - if
-               print("<pre>");
+               print('<pre>');
                print_r($GLOBALS['surfbar_cache']);
-               print("</pre>");
-               debug_report_bug();
+               print('</pre>');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Element ' . $element . ' not found.');
        }
 
        // Return result
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "element[$element]={$data}", false);
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element[' . $element . ']=[' . gettype($data) . ']' . $data, false);
        return $data;
 }