]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/surfbar_functions.php
Some fixes for surfbar extension (#123), double->single, misc cleanups/fixes
[mailer.git] / inc / libs / surfbar_functions.php
index 7c9f58af84b22c6dfbfbe5a8c8829127232a3856..bbf56465680a37f68c9e57b727d58a3b0472e1a2 100644 (file)
@@ -51,21 +51,27 @@ function SURFBAR_ADMIN_ADD_URL ($url, $limit, $reload) {
        // Do some pre-checks
        if (!IS_ADMIN()) {
                // Not an admin
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Not admin.", $url, $limit, $reload));
                return false;
        } elseif (!isUrlValid($url)) {
                // URL invalid
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Invalid URL.", $url, $limit, $reload));
                return false;
        } elseif (SURFBAR_LOOKUP_BY_URL($url, '0')) {
                // URL already found in surfbar!
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Already added.", $url, $limit, $reload));
                return false;
        } elseif (!SURFBAR_IF_USER_BOOK_MORE_URLS()) {
                // No more allowed!
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : No more URLs allowed.", $url, $limit, $reload));
                return false;
-       } elseif (''.($limit + 0).'' != ''.$limit.'') {
-               // Invalid amount entered
+       } elseif ('' . ($limit + 0) . '' != '' . $limit . '') {
+               // Invalid limit entered
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Invalid limit entered.", $url, $limit, $reload));
                return false;
-       } elseif (''.($reload + 0).'' != ''.$reload.'') {
+       } elseif ('' . ($reload + 0) . '' != '' . $reload . '') {
                // Invalid amount entered
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s : Invalid reload entered.", $url, $limit, $reload));
                return false;
        }
 
@@ -159,7 +165,7 @@ function SURFBAR_MEMBER_ADD_URL ($url, $limit) {
        if (!IS_MEMBER()) {
                // Not a member
                return false;
-       } elseif (!isUrlValid($url)) {
+       } elseif ((!isUrlValid($url)) && (!IS_ADMIN())) {
                // URL invalid
                return false;
        } elseif (SURFBAR_LOOKUP_BY_URL($url, getUserId())) {
@@ -193,11 +199,11 @@ function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
        foreach ($actionArray as $actionId => $action) {
                // Add form for this action
                $OUT .= sprintf(LOAD_TEMPLATE('member_surfbar_list_form', true),
-                       $width,
-                       bigintval($urlId),
-                       strtolower($action),
-                       strtoupper($action),
-                       strtoupper($action)
+               $width,
+               bigintval($urlId),
+               strtolower($action),
+               strtoupper($action),
+               strtoupper($action)
                );
        } // END - foreach
 
@@ -265,7 +271,7 @@ function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
 function SURFBAR_VALIDATE_MEMBER_ACTION_STATUS ($action, $status) {
        // Search for the requested action/status combination in database
        $result = SQL_QUERY_ESC("SELECT new_status FROM `{!_MYSQL_PREFIX!}_surfbar_actions` WHERE `action`='%s' AND `status`='%s' LIMIT 1",
-               array($action, $status), __FUNCTION__, __LINE__);
+       array($action, $status), __FUNCTION__, __LINE__);
 
        // Is the entry there?
        $isValid = (SQL_NUMROWS($result) == 1);
@@ -292,7 +298,7 @@ function SURFBAR_VALIDATE_MEMBER_ACTION_STATUS ($action, $status) {
 function SURFBAR_MEMBER_RETREAT_ACTION ($urlData) {
        // Create the data array for next function call
        $data = array(
-               $urlData['id'] => $urlData
+       $urlData['id'] => $urlData
        );
 
        // Simply change the status here
@@ -303,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
@@ -374,13 +380,13 @@ function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
        if ($action == 'edit') {
                // Default is not limited
                $urlData['limited_yes'] = '';
-               $urlData['limited_no']  = ' chkecked="checked"';
+               $urlData['limited_no']  = ' checked="checked"';
                $urlData['limited']     = 'false';
 
                // Is this URL limited?
                if ($urlData['views_max'] > 0) {
                        // Then rewrite form data
-                       $urlData['limited_yes'] = ' chkecked="checked"';
+                       $urlData['limited_yes'] = ' checked="checked"';
                        $urlData['limited_no']  = '';
                        $urlData['limited']     = 'true';
                } // END - if
@@ -439,10 +445,10 @@ function SURFBAR_MEMBER_EXECUTE_EDIT_ACTION ($urlData) {
 
        // Has the URL or limit changed?
        if (true) {
-       //if (($urlData['views_allowed'] != $urlData['edit']['limit']) || ($url1 != $url2)) {
+               //if (($urlData['views_allowed'] != $urlData['edit']['limit']) || ($url1 != $url2)) {
                // Run the query
                SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_urls` SET url='%s', views_allowed=%s, views_max=%s WHERE `id`=%s AND `status`='%s' LIMIT 1",
-                       array($urlData['url'], $urlData['edit']['limit'], $urlData['edit']['limit'], $urlData['id'], $urlData['status']), __FUNCTION__, __LINE__);
+               array($urlData['url'], $urlData['edit']['limit'], $urlData['edit']['limit'], $urlData['id'], $urlData['status']), __FUNCTION__, __LINE__);
 
                // All fine
                $status = true;
@@ -513,7 +519,7 @@ function SURFBAR_HANDLE_LOW_POINTS () {
 
                        // Update last notified
                        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET surfbar_low_notified=NOW() WHERE userid=%s LIMIT 1",
-                               array($uid), __FUNCTION__, __LINE__);
+                       array($uid), __FUNCTION__, __LINE__);
                } // END - if
        } // END - foreach
 }
@@ -534,19 +540,19 @@ function SURFBAR_LOOKUP_BY_URL ($url, $uid) {
 }
 
 // Load URL data by given search term and column
-function SURFBAR_GET_URL_DATA ($searchTerm, $column="id", $order="id", $sort="ASC", $group="id", $add = '') {
+function SURFBAR_GET_URL_DATA ($searchTerm, $column='id', $order='id', $sort="ASC", $group='id', $add = '') {
        // By default nothing is found
        $GLOBALS['last_url_data'] = array();
 
        // Is the column an id number?
-       if (($column == "id") || ($column == 'userid')) {
+       if (($column == 'id') || ($column == 'userid')) {
                // Extra secure input
                $searchTerm = bigintval($searchTerm);
        } // END - if
 
-       // If the column is "id" there can be only one entry
+       // If the column is 'id' there can be only one entry
        $limit = '';
-       if ($column == "id") {
+       if ($column == 'id') {
                $limit = "LIMIT 1";
        } // END - if
 
@@ -556,14 +562,14 @@ FROM `{!_MYSQL_PREFIX!}_surfbar_urls`
 WHERE %s='%s'".$add."
 ORDER BY %s %s
 %s",
-               array($column, $searchTerm, $order, $sort, $limit), __FUNCTION__, __LINE__);
+       array($column, $searchTerm, $order, $sort, $limit), __FUNCTION__, __LINE__);
 
        // Is there at least one record?
        if (SQL_NUMROWS($result) > 0) {
                // Then load all!
                while ($dataRow = SQL_FETCHARRAY($result)) {
                        // Shall we group these results?
-                       if ($group == "id") {
+                       if ($group == 'id') {
                                // Add the row by id as index
                                $GLOBALS['last_url_data'][$dataRow['id']] = $dataRow;
                        } else {
@@ -581,9 +587,11 @@ ORDER BY %s %s
 }
 
 // Registers an URL with the surfbar. You should have called SURFBAR_LOOKUP_BY_URL() first!
-function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $extraFields = array()) {
+function SURFBAR_REGISTER_URL ($url, $uid, $status = 'PENDING', $addMode = 'reg', $extraFields = array()) {
        // Make sure by the user registered URLs are always pending
-       if ($addMode == "reg") $status = "PENDING";
+       if ($addMode == 'reg') {
+               $status = 'PENDING';
+       } // END - if
 
        // Prepare content
        $content = merge_array($extraFields, array(
@@ -594,8 +602,12 @@ function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $e
        ));
 
        // Is limit/reload set?
-       if (!isset($config['limit']))  $content['limit']  = 0;
-       if (!isset($config['reload'])) $content['reload'] = 0;
+       if (!isset($config['limit'])) {
+               $content['limit']  = 0;
+       } // END - if
+       if (!isset($config['reload'])) {
+               $content['reload'] = 0;
+       } // END - if
 
        // Insert the URL into database
        $content['insert_id'] = SURFBAR_INSERT_URL_BY_ARRAY($content);
@@ -610,7 +622,7 @@ function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $e
        $content['limit'] = surfbarTranslateLimit($content['limit']);
 
        // If in reg-mode we notify admin
-       if (($addMode == "reg") || (getConfig('surfbar_notify_admin_unlock') == 'Y')) {
+       if (($addMode == 'reg') || (getConfig('surfbar_notify_admin_unlock') == 'Y')) {
                // Notify admin even when he as unlocked an email
                SURFBAR_NOTIFY_ADMIN("url_{$addMode}", $content);
        } // END - if
@@ -632,14 +644,14 @@ function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) {
 
        // Just run the insert query for now
        SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_urls` (userid,url,status,views_max,views_allowed,fixed_reload) VALUES (%s,'%s','%s',%s,%s,%s)",
-               array(
-                       $uid,
-                       $urlData['url'],
-                       $urlData['status'],
-                       $urlData['limit'],
-                       $urlData['limit'],
-                       $urlData['reload']
-               ), __FUNCTION__, __LINE__
+       array(
+       $uid,
+       $urlData['url'],
+       $urlData['status'],
+       $urlData['limit'],
+       $urlData['limit'],
+       $urlData['reload']
+       ), __FUNCTION__, __LINE__
        );
 
        // Return insert id
@@ -653,7 +665,7 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
 
        // Prepare subject
        $subject = getMessage(sprintf("ADMIN_SURFBAR_NOTIFY_%s_SUBJECT",
-               strtoupper($messageType)
+       strtoupper($messageType)
        ));
 
        // Is the subject line there?
@@ -664,8 +676,8 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
 
        // Translate some data if present
        if (isset($content['status']))        $content['status']        = surfbarTranslateUserStatus($content['status']);
-       if (isset($content['registered']))    $content['registered']    = generateDateTime($content['registered'], "2");
-       if (isset($content['last_locked']))   $content['last_locked']   = generateDateTime($content['last_locked'], "2");
+       if (isset($content['registered']))    $content['registered']    = generateDateTime($content['registered'], '2');
+       if (isset($content['last_locked']))   $content['last_locked']   = generateDateTime($content['last_locked'], '2');
        if (isset($content['views_total']))   $content['views_total']   = translateComma($content['views_total']);
        if (isset($content['views_allowed'])) $content['views_allowed'] = translateComma($content['views_allowed']);
        if (isset($content['views_max']))     $content['views_max']     = translateComma($content['views_max']);
@@ -686,7 +698,7 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) {
 
        // Prepare subject
        $subject = getMessage(sprintf("MEMBER_SURFBAR_NOTIFY_%s_SUBJECT",
-               strtoupper($messageType)
+       strtoupper($messageType)
        ));
 
        // Is the subject line there?
@@ -697,8 +709,8 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) {
 
        // Translate some data if present
        if (isset($content['status']))        $content['status']        = surfbarTranslateUserStatus($content['status']);
-       if (isset($content['registered']))    $content['registered']    = generateDateTime($content['registered'], "2");
-       if (isset($content['last_locked']))   $content['last_locked']   = generateDateTime($content['last_locked'], "2");
+       if (isset($content['registered']))    $content['registered']    = generateDateTime($content['registered'], '2');
+       if (isset($content['last_locked']))   $content['last_locked']   = generateDateTime($content['last_locked'], '2');
        if (isset($content['views_total']))   $content['views_total']   = translateComma($content['views_total']);
        if (isset($content['views_allowed'])) $content['views_allowed'] = translateComma($content['views_allowed']);
        if (isset($content['views_max']))     $content['views_max']     = translateComma($content['views_max']);
@@ -797,10 +809,10 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() {
        $templateName = "surfbar_frameset";
 
        // Any frame set? ;-)
-       if (REQUEST_ISSET_GET(('frame'))) {
+       if (REQUEST_ISSET_GET('frame')) {
                // Use the frame as a template name part... ;-)
                $templateName = sprintf("surfbar_frame_%s",
-                       REQUEST_GET(('frame'))
+               REQUEST_GET('frame')
                );
        } // END - if
 
@@ -830,7 +842,7 @@ INNER JOIN `{!_MYSQL_PREFIX!}_surfbar_urls` AS u
 ON u.id=l.url_id
 WHERE l.userid=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(l.last_surfed) AND (((UNIX_TIMESTAMP(l.last_surfed) - u.fixed_reload) < 0 AND u.fixed_reload > 0) OR u.fixed_reload = 0)
 LIMIT 1",
-               array(getUserId()), __FUNCTION__, __LINE__
+       array(getUserId()), __FUNCTION__, __LINE__
        );
 
        // Fetch row
@@ -870,8 +882,8 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = 0) {
        // Get amount from database
        $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
 FROM `{!_MYSQL_PREFIX!}_surfbar_urls`
-WHERE userid NOT IN (".implode(",", $UIDs['uid']).") AND `status`='%s'",
-               array($status), __FUNCTION__, __LINE__
+WHERE userid NOT IN (".implode(',', $UIDs['uid']).") AND `status`='%s'",
+       array($status), __FUNCTION__, __LINE__
        );
 
        // Fetch row
@@ -924,7 +936,7 @@ function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status = '',$exclude = '') {
 FROM `{!_MYSQL_PREFIX!}_surfbar_urls`
 WHERE userid=%s".$add."
 LIMIT %s",
-               array($uid, getConfig('surfbar_max_order')), __FUNCTION__, __LINE__
+       array($uid, getConfig('surfbar_max_order')), __FUNCTION__, __LINE__
        );
 
        // Fetch row
@@ -963,7 +975,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt = '') {
                }
 
                // ... and now the validation code
-               $valCode = generateRandomCodde($length, sha1(SURFBAR_GET_SALT().':'.$urlId), getUserId());
+               $valCode = generateRandomCode($length, sha1(SURFBAR_GET_SALT().':'.$urlId), getUserId());
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "valCode={$valCode}", false);
        } // END - while
 
@@ -998,11 +1010,11 @@ function SURFBAR_LOCKDOWN_ID ($urlId) {
        ///* DEBUG: */ return;
        // Just add it to the database
        SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_locks` (userid, url_id) VALUES (%s, %s)",
-               array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__);
+       array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__);
 
        // Remove the salt from database
        SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_surfbar_salts` WHERE url_id=%s AND `userid`=%s LIMIT 1",
-               array(bigintval($urlId), getUserId()), __FUNCTION__, __LINE__);
+       array(bigintval($urlId), getUserId()), __FUNCTION__, __LINE__);
 }
 
 // Pay points to the user and remove it from the sender if userid is given else it is a "sponsored surf"
@@ -1034,17 +1046,17 @@ function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
 
        // Update URL stats
        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_urls` SET views_total=views_total+1".$add." WHERE `id`=%s LIMIT 1",
-               array(SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
+       array(SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
 
        // Update the stats entry
        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_stats` SET count=count+1 WHERE userid=%s AND url_id=%s LIMIT 1",
-               array(getUserId(), SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
+       array(getUserId(), SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
 
        // Was that update okay?
        if (SQL_AFFECTEDROWS() < 1) {
                // No, then insert entry
                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_stats` (userid,url_id,count) VALUES (%s,%s,1)",
-                       array(getUserId(), SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
+               array(getUserId(), SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
        } // END - if
 
        // Update total/daily/weekly/monthly counter
@@ -1064,7 +1076,7 @@ function SURFBAR_UPDATE_SALT_STATS () {
 
        // Simply store the salt from cache away in database...
        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_salts` SET last_salt='%s' WHERE url_id=%s AND `userid`=%s LIMIT 1",
-               array(SURFBAR_GET_SALT(), SURFBAR_GET_ID(), getUserId()), __FUNCTION__, __LINE__);
+       array(SURFBAR_GET_SALT(), SURFBAR_GET_ID(), getUserId()), __FUNCTION__, __LINE__);
 
        // Debug message
        //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".getUserId()."", false);
@@ -1073,7 +1085,7 @@ function SURFBAR_UPDATE_SALT_STATS () {
        if (SQL_AFFECTEDROWS() < 1) {
                // Insert missing entry!
                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_salts` (url_id,userid,last_salt) VALUES (%s, %s, '%s')",
-                       array(SURFBAR_GET_ID(), getUserId(), SURFBAR_GET_SALT()), __FUNCTION__, __LINE__);
+               array(SURFBAR_GET_ID(), getUserId(), SURFBAR_GET_SALT()), __FUNCTION__, __LINE__);
        } // END - if
 
        // Debug message
@@ -1092,7 +1104,7 @@ FROM `{!_MYSQL_PREFIX!}_surfbar_locks`
 WHERE userid=%s AND url_id=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(last_surfed)
 ORDER BY last_surfed ASC
 LIMIT 1",
-               array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
+       array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
        );
 
        // Fetch counter
@@ -1130,7 +1142,7 @@ ON u.userid=d.userid
 WHERE u.userid NOT IN (%s,0) AND u.`status`='ACTIVE'
 GROUP BY u.userid
 ORDER BY u.userid ASC",
-                       array(getUserId()), __FUNCTION__, __LINE__);
+               array(getUserId()), __FUNCTION__, __LINE__);
        } else {
                // Get all userid
                $result = SQL_QUERY("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
@@ -1162,7 +1174,7 @@ ORDER BY u.userid ASC", __FUNCTION__, __LINE__);
        SQL_FREERESULT($result);
 
        // Debug message
-       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".getUserId().")", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".getUserId().')', false);
 
        // Return result
        return $UIDs;
@@ -1175,7 +1187,7 @@ function SURFBAR_DETERMINE_TOTAL_ONLINE () {
 FROM `{!_MYSQL_PREFIX!}_surfbar_stats`
 WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_online)) <= %s
 GROUP BY userid",
-               array(getConfig('online_timeout')), __FUNCTION__, __LINE__);
+       array(getConfig('online_timeout')), __FUNCTION__, __LINE__);
 
        // Fetch count
        $cnt = SQL_NUMROWS($result);
@@ -1187,7 +1199,7 @@ GROUP BY userid",
        return $cnt;
 }
 
-// Determine waiting time for one URL 
+// Determine waiting time for one URL
 function SURFBAR_DETERMINE_WAIT_TIME () {
        // Get fixed reload lock
        $fixed = SURFBAR_GET_FIXED_RELOAD();
@@ -1362,7 +1374,7 @@ WHERE
        userid=%s
 ORDER BY
        id ASC", array(getUserId()),
-               __FUNCTION__, __LINE__);
+       __FUNCTION__, __LINE__);
 
        // Load all entries
        while ($content = SQL_FETCHARRAY($result)) {
@@ -1410,7 +1422,7 @@ LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_salts` AS sbs
 ON sbu.id=sbs.url_id
 LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
 ON sbu.id=l.url_id
-WHERE sbu.userid NOT IN (".implode(",", $UIDs).") AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0)) AND sbu.`status`='ACTIVE'".$add."
+WHERE sbu.userid NOT IN (".implode(',', $UIDs).") AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0)) AND sbu.`status`='ACTIVE'".$add."
 GROUP BY sbu.id", __FUNCTION__, __LINE__);
 
        // Log last query
@@ -1436,7 +1448,7 @@ function SURFBAR_GET_USER_URLS () {
 FROM `{!_MYSQL_PREFIX!}_surfbar_urls` AS u
 WHERE u.userid=%s AND u.status != 'DELETED'
 ORDER BY u.id ASC",
-               array(getUserId()), __FUNCTION__, __LINE__);
+       array(getUserId()), __FUNCTION__, __LINE__);
 
        // Are there entries?
        if (SQL_NUMROWS($result) > 0) {
@@ -1461,7 +1473,7 @@ function SURFBAR_getModeAction_ARRAY ($status) {
 
        // Get all assigned actions
        $result = SQL_QUERY_ESC("SELECT action FROM `{!_MYSQL_PREFIX!}_surfbar_actions` WHERE `status`='%s' ORDER BY `id` ASC",
-               array($status), __FUNCTION__, __LINE__);
+       array($status), __FUNCTION__, __LINE__);
 
        // Some entries there?
        if (SQL_NUMROWS($result) > 0) {
@@ -1484,10 +1496,10 @@ function SURFBAR_RELOAD_TO_STOP_PAGE ($page="stop") {
        // Internal or external?
        if ((getConfig('surfbar_pause_mode') == 'INTERNAL') || (getConfig('surfbar_pause_url') == '')) {
                // Reload to internal page
-               redirectToUrl("surfbar.php?frame=".$page);
+               redirectToUrl('surfbar.php?frame=' . $page);
        } else {
                // Reload to external page
-               LOAD_CONFIGURED_URL('surfbar_pause_url');
+               redirectToConfiguredUrl('surfbar_pause_url');
        }
 }
 
@@ -1510,11 +1522,11 @@ function SURFBAR_DETERMINE_NEXT_ID ($urlId = 0) {
                        $add = " AND sbu.id NOT IN (";
                        foreach ($USE as $url_id => $lid) {
                                // Add URL id
-                               $add .= $url_id.",";
+                               $add .= $url_id.',';
                        } // END - foreach
 
                        // Add closing bracket
-                       $add = substr($add, 0, -1) . ")";
+                       $add = substr($add, 0, -1) . ')';
                } // END - if
 
                // Determine depleted user account
@@ -1537,11 +1549,11 @@ LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_salts` AS sbs
 ON sbu.id=sbs.url_id
 LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
 ON sbu.id=l.url_id
-WHERE sbu.userid NOT IN (".implode(",", $UIDs['uid']).") AND sbu.`status`='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$add."
+WHERE sbu.userid NOT IN (".implode(',', $UIDs['uid']).") AND sbu.`status`='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$add."
 GROUP BY sbu.id
 ORDER BY l.last_surfed ASC, sbu.id ASC
 LIMIT %s,1",
-                       array($randNum), __FUNCTION__, __LINE__
+               array($randNum), __FUNCTION__, __LINE__
                );
        } else {
                // Get data from specified id number
@@ -1553,7 +1565,7 @@ LEFT JOIN `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
 ON sbu.id=l.url_id
 WHERE sbu.userid != %s AND sbu.`status`='ACTIVE' AND sbu.id=%s AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))
 LIMIT 1",
-                       array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
+               array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
                );
        }