]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/surfbar_functions.php
Cache system rewritten, thanks to profi-concept's hints of including not evaluating it
[mailer.git] / inc / libs / surfbar_functions.php
index e64aac3a53b6be392ac126dfb817704a8beca256..433dc73a03bc8c51f61d50dbf018db8d8b0679ff 100644 (file)
@@ -42,7 +42,7 @@ if (!defined('__SECURITY')) {
 // -----------------------------------------------------------------------------
 //
 // Admin has added an URL with given user id and so on
-function SURFBAR_ADMIN_ADD_URL ($url, $limit) {
+function SURFBAR_ADMIN_ADD_URL ($url, $limit, $reload) {
        // Do some pre-checks
        if (!IS_ADMIN()) {
                // Not an admin
@@ -59,10 +59,13 @@ function SURFBAR_ADMIN_ADD_URL ($url, $limit) {
        } elseif ("".($limit + 0)."" != "".$limit."") {
                // Invalid amount entered
                return false;
+       } elseif ("".($reload + 0)."" != "".$reload."") {
+               // Invalid amount entered
+               return false;
        }
 
        // Register the new URL
-       return SURFBAR_REGISTER_URL($url, "0", "ACTIVE", "unlock", $limit);
+       return SURFBAR_REGISTER_URL($url, "0", "ACTIVE", "unlock", array('limit' => $limit, 'reload' => $reload));
 }
 // Admin unlocked an email so we can migrate the URL
 function SURFBAR_ADMIN_MIGRATE_URL ($url, $uid) {
@@ -164,7 +167,7 @@ function SURFBAR_MEMBER_ADD_URL ($url, $limit) {
        }
 
        // Register the new URL
-       return SURFBAR_REGISTER_URL($url, $GLOBALS['userid'], "PENDING", "reg", $limit);
+       return SURFBAR_REGISTER_URL($url, $GLOBALS['userid'], "PENDING", "reg", array('limit' => $limit));
 }
 // Create list of actions depending on status for the user
 function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
@@ -340,6 +343,10 @@ function SURFBAR_MEMBER_UNPAUSE_ACTION ($urlData) {
        // Return status change
        return SURFBAR_CHANGE_STATUS($urlData['id'], $urlData['status'], $urlData['new_status'], array($urlData['id'] => $urlData));
 }
+// Resubmit locked URL
+function SURFBAR_MEMBER_RESUBMIT_ACTION ($urlData) {
+       return SURFBAR_CHANGE_STATUS($urlData['id'], $urlData['status'], $urlData['new_status'], array($urlData['id'] => $urlData));
+}
 // Display selected "action form"
 function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
        // Translate some data
@@ -535,7 +542,7 @@ function SURFBAR_GET_URL_DATA ($searchTerm, $column="id", $order="id", $sort="AS
        } // END - if
 
        // Look up the record
-       $result = SQL_QUERY_ESC("SELECT id, userid, url, views_total, views_max, views_allowed, status, registered, last_locked, lock_reason, views_max, views_allowed
+       $result = SQL_QUERY_ESC("SELECT id, userid, url, views_total, views_max, views_allowed, status, registered, last_locked, lock_reason, views_max, views_allowed, fixed_reload
 FROM "._MYSQL_PREFIX."_surfbar_urls
 WHERE %s='%s'".$add."
 ORDER BY %s %s
@@ -564,20 +571,23 @@ ORDER BY %s %s
        return $lastUrlData;
 }
 // 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", $limit=0) {
+function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $extraFields = array()) {
        global $_CONFIG;
 
        // Make sure by the user registered URLs are always pending
        if ($addMode == "reg") $status = "PENDING";
 
        // Prepare content
-       $content = array(
+       $content = array_merge($extraFields, array(
                'url'         => $url,
                'frametester' => FRAMETESTER($url),
                'uid'         => $uid,
                'status'      => $status,
-               'limit'       => $limit
-       );
+       ));
+
+       // Is limit/reload set?
+       if (!isset($config['limit']))  $content['limit']  = 0;
+       if (!isset($config['reload'])) $content['reload'] = 0;
 
        // Insert the URL into database
        $content['insert_id'] = SURFBAR_INSERT_URL_BY_ARRAY($content);
@@ -612,13 +622,14 @@ function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) {
        if (empty($uid)) $uid = 0;
 
        // Just run the insert query for now
-       SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_urls (userid,url,status,views_max,views_allowed) VALUES (%s,'%s','%s',%s,%s)",
+       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['limit'],
+                       $urlData['reload']
                ), __FILE__, __LINE__
        );
 
@@ -681,6 +692,14 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) {
                ADD_FATAL(MEMBER_SURFBAR_NOTIFY_SUBJECT_404, $constantName);
        }
 
+       // Translate some data if present
+       if (isset($content['status']))        $content['status']        = SURFBAR_TRANSLATE_STATUS($content['status']);
+       if (isset($content['registered']))    $content['registered']    = MAKE_DATETIME($content['registered'], "2");
+       if (isset($content['last_locked']))   $content['last_locked']   = MAKE_DATETIME($content['last_locked'], "2");
+       if (isset($content['views_total']))   $content['views_total']   = TRANSLATE_COMMA($content['views_total']);
+       if (isset($content['views_allowed'])) $content['views_allowed'] = TRANSLATE_COMMA($content['views_allowed']);
+       if (isset($content['views_max']))     $content['views_max']     = TRANSLATE_COMMA($content['views_max']);
+
        // Load template
        $mailText = LOAD_EMAIL_TEMPLATE($templateName, $content, $content['uid']);
 
@@ -793,7 +812,7 @@ function SURFBAR_CHECK_RELOAD_FULL() {
 
        // Cache static reload lock
        $SURFBAR_CACHE['surf_lock'] = $_CONFIG['surfbar_static_lock'];
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "Fixed surf lock is ".$_CONFIG['surfbar_static_lock']."", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Fixed surf lock is ".$_CONFIG['surfbar_static_lock']."", false);
 
        // Do we have dynamic model?
        if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
@@ -802,8 +821,10 @@ function SURFBAR_CHECK_RELOAD_FULL() {
        } // END - if
 
        // Ask the database
-       $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt FROM "._MYSQL_PREFIX."_surfbar_locks
-WHERE userid=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_DATA('surf_lock').") < UNIX_TIMESTAMP(last_surfed)
+       $result = SQL_QUERY_ESC("SELECT COUNT(l.id) AS cnt FROM "._MYSQL_PREFIX."_surfbar_locks AS l
+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($GLOBALS['userid']), __FILE__, __LINE__
        );
@@ -824,8 +845,8 @@ LIMIT 1",
        $total = SURFBAR_GET_TOTAL_URLS();
 
        // Do we have some URLs in lock? Admins can always surf on own URLs!
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "userLocks=".SURFBAR_GET_DATA('user_locks').",total={$total}", false);
-       $isFull = ((SURFBAR_GET_DATA('user_locks') == $total) && ($total > 0));
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "userLocks=".SURFBAR_GET_USER_LOCKS().",total={$total}", false);
+       $isFull = ((SURFBAR_GET_USER_LOCKS() == $total) && ($total > 0));
 
        // Return result
        return $isFull;
@@ -932,16 +953,16 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt="") {
                if (empty($salt)) {
                        // Generate random hashed string
                        $SURFBAR_CACHE['salt'] = sha1(GEN_PASS(255));
-                       //DEBUG_LOG(__FUNCTION__, __LINE__, "newSalt=".SURFBAR_GET_SALT()."", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "newSalt=".SURFBAR_GET_SALT()."", false);
                } else {
                        // Use this as salt!
                        $SURFBAR_CACHE['salt'] = $salt;
-                       //DEBUG_LOG(__FUNCTION__, __LINE__, "oldSalt=".SURFBAR_GET_SALT()."", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "oldSalt=".SURFBAR_GET_SALT()."", false);
                }
 
                // ... and now the validation code
                $valCode = GEN_RANDOM_CODE($length, sha1(SURFBAR_GET_SALT().":".$urlId), $GLOBALS['userid']);
-               //DEBUG_LOG(__FUNCTION__, __LINE__, "valCode={$valCode}", false);
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "valCode={$valCode}", false);
        } // END - while
 
        // Hash it with md5() and salt it with the random string
@@ -951,7 +972,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt="") {
        $valHashedCode = generatePassString($hashedCode);
 
        // Return hashed value
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "finalValCode={$valHashedCode}", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "finalValCode={$valHashedCode}", false);
        return $valHashedCode;
 }
 // Check validation code
@@ -965,8 +986,8 @@ function SURFBAR_CHECK_VALIDATION_CODE ($urlId, $check, $salt) {
        $code = SURFBAR_GENERATE_VALIDATION_CODE($urlId, $salt);
 
        // Return result of checking hashes and salts
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "---".$code."|".$check."---", false);
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "+++".$salt."|".SURFBAR_GET_DATA('last_salt')."+++", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "---".$code."|".$check."---", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "+++".$salt."|".SURFBAR_GET_DATA('last_salt')."+++", false);
        return (($code == $check) && ($salt == SURFBAR_GET_DATA('last_salt')));
 }
 // Lockdown the userid/id combination (reload lock)
@@ -981,17 +1002,19 @@ function SURFBAR_LOCKDOWN_ID ($urlId) {
        SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_surfbar_salts WHERE url_id=%s AND userid=%s LIMIT 1",
                array(bigintval($urlId), $GLOBALS['userid']), __FILE__, __LINE__);
 }
-// Pay points to the user and remove it from the sender
-function SURFBAR_PAY_POINTS ($urlId) {
+// Pay points to the user and remove it from the sender if userid is given else it is a "sponsored surf"
+function SURFBAR_PAY_POINTS () {
+       global $_CONFIG;
+
        // Remove it from the URL owner
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".SURFBAR_GET_USERID().",costs=".SURFBAR_GET_COSTS()."", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".SURFBAR_GET_USERID().",costs=".SURFBAR_GET_COSTS()."", false);
        if (SURFBAR_GET_USERID() > 0) {
-               SUB_POINTS("surfbar", SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
+               SUB_POINTS(sprintf("surfbar_%s", $_CONFIG['surfbar_pay_model']), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
        } // END - if
 
        // Book it to the user
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".$GLOBALS['userid'].",reward=".SURFBAR_GET_REWARD()."", false);
-       ADD_POINTS_REFSYSTEM("surfbar", $GLOBALS['userid'], SURFBAR_GET_DATA('reward'));
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".$GLOBALS['userid'].",reward=".SURFBAR_GET_REWARD()."", false);
+       ADD_POINTS_REFSYSTEM(sprintf("surfbar_%s", $_CONFIG['surfbar_pay_model']), $GLOBALS['userid'], SURFBAR_GET_DATA('reward'));
 }
 // Updates the statistics of current URL/userid
 function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
@@ -1001,7 +1024,7 @@ function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
        $ADD = "";
 
        // Get allowed views
-       $allowed = SURFBAR_GET_ALLOWED_VIEWS();
+       $allowed = SURFBAR_GET_VIEWS_ALLOWED();
 
        // Do we have a limit?
        if ($allowed > 0) {
@@ -1043,7 +1066,7 @@ function SURFBAR_UPDATE_SALT_STATS () {
                array(SURFBAR_GET_SALT(), SURFBAR_GET_ID(), $GLOBALS['userid']), __FILE__, __LINE__);
 
        // Debug message
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".$GLOBALS['userid']."", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".$GLOBALS['userid']."", false);
 
        // Was that okay?
        if (SQL_AFFECTEDROWS() < 1) {
@@ -1053,18 +1076,18 @@ function SURFBAR_UPDATE_SALT_STATS () {
        } // END - if
 
        // Debug message
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "affectedRows=".SQL_AFFECTEDROWS()."", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "affectedRows=".SQL_AFFECTEDROWS()."", false);
 
        // Return if the update was okay
        return (SQL_AFFECTEDROWS() == 1);
 }
 // Check if the reload lock is active for given id
 function SURFBAR_CHECK_RELOAD_LOCK ($urlId) {
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "id={$urlId}", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "id={$urlId}", false);
        // Ask the database
        $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
 FROM "._MYSQL_PREFIX."_surfbar_locks
-WHERE userid=%s AND url_id=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_DATA('surf_lock').") < UNIX_TIMESTAMP(last_surfed)
+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($GLOBALS['userid'], bigintval($urlId)), __FILE__, __LINE__
@@ -1077,7 +1100,7 @@ LIMIT 1",
        SQL_FREERESULT($result);
 
        // Return check
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "cnt={$cnt},".SURFBAR_GET_DATA('surf_lock')."", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "cnt={$cnt},".SURFBAR_GET_SURF_LOCK()."", false);
        return ($cnt == 1);
 }
 // Determine which user hash no more points left
@@ -1120,12 +1143,12 @@ ORDER BY u.userid ASC", __FILE__, __LINE__);
        while (list($uid, $notified) = SQL_FETCHROW($result)) {
                // Get total points
                $points = GET_TOTAL_DATA($uid, "user_points", "points") - GET_TOTAL_DATA($uid, "user_data", "used_points");
-               //DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid},points={$points}", false);
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid},points={$points}", false);
 
                // Shall we add this to ignore?
                if ($points <= $limit) {
                        // Ignore this one!
-                       //DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid} has depleted points amount!", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid} has depleted points amount!", false);
                        $UIDs['uid'][$uid] = $uid;
                        $UIDs['points'][$uid] = $points;
                        $UIDs['notified'][$uid] = $notified;
@@ -1136,7 +1159,7 @@ ORDER BY u.userid ASC", __FILE__, __LINE__);
        SQL_FREERESULT($result);
 
        // Debug message
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".$GLOBALS['userid'].")", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".$GLOBALS['userid'].")", false);
 
        // Return result
        return $UIDs;
@@ -1165,6 +1188,15 @@ GROUP BY userid",
 function SURFBAR_DETERMINE_WAIT_TIME () {
        global $_CONFIG;
 
+       // Get fixed reload lock
+       $fixed = SURFBAR_GET_FIXED_RELOAD();
+
+       // Is the fixed reload time set?
+       if ($fixed > 0) {
+               // Return it
+               return $fixed;
+       } // END - if
+
        // Static time is default
        $time = $_CONFIG['surfbar_static_time'];
 
@@ -1205,15 +1237,15 @@ 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",
-               array($newStatus, bigintval($urlId)), __FILE__, __LINE__);
+       //SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_surfbar_urls SET status='%s' WHERE id=%s LIMIT 1",
+       //      array($newStatus, bigintval($urlId)), __FILE__, __LINE__);
        // ---------- Comment out for debugging/developing member actions! ---------
 
        // Was that fine?
-       if (SQL_AFFECTEDROWS() != 1) {
-               // No, something went wrong
-               return false;
-       } // END - if
+       //if (SQL_AFFECTEDROWS() != 1) {
+       //      // No, something went wrong
+       //      return false;
+       //} // END - if
 
        // Prepare content for notification routines
        $data[$urlId]['uid']         = $data[$urlId]['userid'];
@@ -1335,17 +1367,17 @@ ORDER BY
        // Load all entries
        while (list($lid, $url, $last) = SQL_FETCHROW($result)) {
                // Debug message
-               //DEBUG_LOG(__FUNCTION__, __LINE__, "next - lid={$lid},url={$url},rest=".(time() - $last)."/".SURFBAR_GET_DATA('surf_lock')."", false);
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "next - lid={$lid},url={$url},rest=".(time() - $last)."/".SURFBAR_GET_SURF_LOCK()."", false);
 
                // Skip entries that are too old
-               if (($last > (time() - SURFBAR_GET_DATA('surf_lock'))) && (!in_array($url, $ignored))) {
+               if (($last > (time() - SURFBAR_GET_SURF_LOCK())) && (!in_array($url, $ignored))) {
                        // Debug message
-                       //DEBUG_LOG(__FUNCTION__, __LINE__, "okay - lid={$lid},url={$url},last={$last}", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "okay - lid={$lid},url={$url},last={$last}", false);
 
                        // Add only if missing or bigger
                        if ((!isset($IDs[$url])) || ($IDs[$url] > $last)) {
                                // Debug message
-                               //DEBUG_LOG(__FUNCTION__, __LINE__, "ADD - lid={$lid},url={$url},last={$last}", false);
+                               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ADD - lid={$lid},url={$url},last={$last}", false);
 
                                // Add this ID
                                $IDs[$url] = $last;
@@ -1353,7 +1385,7 @@ ORDER BY
                        } // END - if
                } else {
                        // Debug message
-                       //DEBUG_LOG(__FUNCTION__, __LINE__, "ignore - lid={$lid},url={$url},last={$last}", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ignore - lid={$lid},url={$url},last={$last}", false);
 
                        // Ignore these old entries!
                        $ignored[] = $url;
@@ -1382,7 +1414,7 @@ WHERE sbu.userid NOT IN (".implode(",", $UIDs).") AND (sbu.views_allowed=0 OR (s
 GROUP BY sbu.id", __FILE__, __LINE__);
 
        // Log last query
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
 
        // Fetch max rand
        $maxRand = SQL_NUMROWS($result);
@@ -1498,8 +1530,8 @@ function SURFBAR_DETERMINE_NEXT_ID ($urlId = 0) {
                } // END - if
 
                // And query the database
-               //DEBUG_LOG(__FUNCTION__, __LINE__, "randNum={$randNum},maxRand={$maxRand},surfLock=".SURFBAR_GET_DATA('surf_lock')."", false);
-               $result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.views_total, sbu.views_max, sbu.views_allowed, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "randNum={$randNum},maxRand={$maxRand},surfLock=".SURFBAR_GET_SURF_LOCK()."", false);
+               $result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.views_total, sbu.views_max, sbu.views_allowed, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed, sbu.fixed_reload
 FROM "._MYSQL_PREFIX."_surfbar_urls AS sbu
 LEFT JOIN "._MYSQL_PREFIX."_surfbar_salts AS sbs
 ON sbu.id=sbs.url_id
@@ -1513,7 +1545,7 @@ LIMIT %s,1",
                );
        } else {
                // Get data from specified id number
-               $result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.views_total, sbu.views_max, sbu.views_allowed, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed
+               $result = SQL_QUERY_ESC("SELECT sbu.id, sbu.userid, sbu.url, sbs.last_salt, sbu.views_total, sbu.views_max, sbu.views_allowed, UNIX_TIMESTAMP(l.last_surfed) AS last_surfed, sbu.fixed_reload
 FROM "._MYSQL_PREFIX."_surfbar_urls AS sbu
 LEFT JOIN "._MYSQL_PREFIX."_surfbar_salts AS sbs
 ON sbu.id=sbs.url_id
@@ -1526,12 +1558,12 @@ LIMIT 1",
        }
 
        // Is there an id number?
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "lastQuery=".$_CONFIG['db_last_query']."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false);
        if (SQL_NUMROWS($result) == 1) {
                // Load/cache data
-               //DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($SURFBAR_CACHE).") - BEFORE", false);
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($SURFBAR_CACHE).") - BEFORE", false);
                $SURFBAR_CACHE = merge_array($SURFBAR_CACHE, SQL_FETCHARRAY($result));
-               //DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($SURFBAR_CACHE).") - AFTER", false);
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "count(".count($SURFBAR_CACHE).") - AFTER", false);
 
                // Determine waiting time
                $SURFBAR_CACHE['time'] = SURFBAR_DETERMINE_WAIT_TIME();
@@ -1539,28 +1571,28 @@ LIMIT 1",
                // Is the last salt there?
                if (is_null($SURFBAR_CACHE['last_salt'])) {
                        // Then repair it wit the static!
-                       //DEBUG_LOG(__FUNCTION__, __LINE__, "last_salt - FIXED!", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "last_salt - FIXED!", false);
                        $SURFBAR_CACHE['last_salt'] = "";
                } // END - if
 
                // Fix missing last_surfed
                if ((!isset($SURFBAR_CACHE['last_surfed'])) || (is_null($SURFBAR_CACHE['last_surfed']))) {
                        // Fix it here
-                       //DEBUG_LOG(__FUNCTION__, __LINE__, "last_surfed - FIXED!", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "last_surfed - FIXED!", false);
                        $SURFBAR_CACHE['last_surfed'] = 0;
                } // END - if
 
                // Get base/fixed reward and costs
                $SURFBAR_CACHE['reward'] = SURFBAR_DETERMINE_REWARD();
                $SURFBAR_CACHE['costs']  = SURFBAR_DETERMINE_COSTS();
-               //DEBUG_LOG(__FUNCTION__, __LINE__, "BASE/STATIC - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."", false);
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "BASE/STATIC - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."", false);
 
                // Only in dynamic model add the dynamic bonus!
                if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
                        // Calculate dynamic reward/costs and add it
                        $SURFBAR_CACHE['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
                        $SURFBAR_CACHE['costs']  += SURFBAR_CALCULATE_DYNAMIC_ADD();
-                       //DEBUG_LOG(__FUNCTION__, __LINE__, "DYNAMIC+ - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "DYNAMIC+ - reward=".SURFBAR_GET_REWARD()."|costs=".SURFBAR_GET_COSTS()."", false);
                } // END - if
 
                // Now get the id
@@ -1571,7 +1603,7 @@ LIMIT 1",
        SQL_FREERESULT($result);
 
        // Return result
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "nextId={$nextId}", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "nextId={$nextId}", false);
        return $nextId;
 }
 // -----------------------------------------------------------------------------
@@ -1581,7 +1613,7 @@ LIMIT 1",
 // Private getter for data elements
 function SURFBAR_GET_DATA ($element) {
        global $SURFBAR_CACHE;
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "element={$element}", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "element={$element}", false);
 
        // Default is null
        $data = null;
@@ -1598,7 +1630,7 @@ function SURFBAR_GET_DATA ($element) {
        }
 
        // Return result
-       //DEBUG_LOG(__FUNCTION__, __LINE__, "element[$element]={$data}", false);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "element[$element]={$data}", false);
        return $data;
 }
 // Getter for reward from cache
@@ -1632,7 +1664,7 @@ function SURFBAR_GET_USERID () {
        return SURFBAR_GET_DATA('userid');
 }
 // Getter for user reload locks
-function SURFBAR_GET_USER_RELOAD_LOCK () {
+function SURFBAR_GET_USER_LOCKS () {
        // Get data element and return its contents
        return SURFBAR_GET_DATA('user_locks');
 }
@@ -1642,9 +1674,19 @@ function SURFBAR_GET_RELOAD_TIME () {
        return SURFBAR_GET_DATA('time');
 }
 // Getter for allowed views
-function SURFBAR_GET_ALLOWED_VIEWS () {
+function SURFBAR_GET_VIEWS_ALLOWED () {
        // Get data element and return its contents
        return SURFBAR_GET_DATA('views_allowed');
 }
+// Getter for fixed reload
+function SURFBAR_GET_FIXED_RELOAD () {
+       // Get data element and return its contents
+       return SURFBAR_GET_DATA('fixed_reload');
+}
+// Getter for surf lock
+function SURFBAR_GET_SURF_LOCK () {
+       // Get data element and return its contents
+       return SURFBAR_GET_DATA('surf_lock');
+}
 //
 ?>