X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Flibs%2Fsurfbar_functions.php;h=cdb46c8e7745386056baacf29230dc836cb6978d;hb=701f5ac005404813e0e546102b5821f2ba2af522;hp=164813300eff020e93abbc78d0b90e599769ebb2;hpb=3df5cfd765d32de200a4db2a21a04cb2fde40b23;p=mailer.git diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 164813300e..cdb46c8e77 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -246,14 +246,14 @@ function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) { $URLs[$formData['id']]['new_status'] = $SURFBAR_CACHE['new_status']; // Extract URL data for call-back - $urlData = array(array_merge($URLs[$formData['id']], array($action => $formData))); + $urlData = array(merge_array($URLs[$formData['id']], array($action => $formData))); // Action found so execute it $performed = call_user_func_array($functionName, $urlData); } else { // Log invalid request DEBUG_LOG(__FUNCTION__, __LINE__, " action={$formData['action']},id={$formData['id']},function={$functionName}"); - ADD_FATAL(sprintf("Invalid member action! action=%s,id=%s,function=%s", $formData['action'], $formData['id'], $functionName)); + addFatalMessage(sprintf("Invalid member action! action=%s,id=%s,function=%s", $formData['action'], $formData['id'], $functionName)); } // Return status @@ -413,7 +413,7 @@ function SURFBAR_MEMBER_EXECUTE_ACTION ($action, $urlData) { } // END - if } else { // Not found! - ADD_FATAL(sprintf(MEMBER_SURFBAR_EXECUTE_ACTION_404, $functionName)); + addFatalMessage(sprintf(MEMBER_SURFBAR_EXECUTE_ACTION_404, $functionName)); } // Return status @@ -485,26 +485,26 @@ function SURFBAR_HANDLE_LOW_POINTS () { global $_CONFIG; // Get all userids - $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS($_CONFIG['surfbar_warn_low_points']); + $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points')); // "Walk" through all URLs foreach ($UIDs['uid'] as $uid => $dummy) { // Is the last notification far enougth away to notify again? - if ((time() - $UIDs['notified'][$uid]) >= $_CONFIG['surfbar_low_interval']) { + if ((time() - $UIDs['notified'][$uid]) >= getConfig('surfbar_low_interval')) { // Prepare content $content = array( 'uid' => $uid, - 'low' => TRANSLATE_COMMA($_CONFIG['surfbar_warn_low_points']), + 'low' => TRANSLATE_COMMA(getConfig('surfbar_warn_low_points')), 'points' => TRANSLATE_COMMA($UIDs['points'][$uid]), 'notified' => MAKE_DATETIME($UIDs['notified'][$uid]), - 'interval' => CREATE_FANCY_TIME($_CONFIG['surfbar_low_interval']) + 'interval' => CREATE_FANCY_TIME(getConfig('surfbar_low_interval')) ); // Notify this user SURFBAR_NOTIFY_USER("low_points", $content); // Update last notified - SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET surfbar_low_notified=NOW() WHERE userid=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `"._MYSQL_PREFIX."_user_data` SET surfbar_low_notified=NOW() WHERE userid=%s LIMIT 1", array($uid), __FILE__, __LINE__); } // END - if } // END - foreach @@ -578,7 +578,7 @@ function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $e if ($addMode == "reg") $status = "PENDING"; // Prepare content - $content = array_merge($extraFields, array( + $content = merge_array($extraFields, array( 'url' => $url, 'frametester' => FRAMETESTER($url), 'uid' => $uid, @@ -602,7 +602,7 @@ function SURFBAR_REGISTER_URL ($url, $uid, $status="PENDING", $addMode="reg", $e $content['limit'] = SURFBAR_TRANSLATE_LIMIT($content['limit']); // If in reg-mode we notify admin - if (($addMode == "reg") || ($_CONFIG['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 @@ -653,7 +653,7 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) { if (defined($constantName)) { $subject = constant($constantName); } else { - ADD_FATAL(ADMIN_SURFBAR_NOTIFY_SUBJECT_404, $constantName); + addFatalMessage(ADMIN_SURFBAR_NOTIFY_SUBJECT_404, $constantName); } // Translate some data if present @@ -689,7 +689,7 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) { if (defined($constantName)) { $subject = constant($constantName); } else { - ADD_FATAL(MEMBER_SURFBAR_NOTIFY_SUBJECT_404, $constantName); + addFatalMessage(MEMBER_SURFBAR_NOTIFY_SUBJECT_404, $constantName); } // Translate some data if present @@ -742,10 +742,10 @@ function SURFBAR_DETERMINE_REWARD ($onlyMin=false) { global $_CONFIG; // Static values are default - $reward = $_CONFIG['surfbar_static_reward']; + $reward = getConfig('surfbar_static_reward'); // Do we have static or dynamic? - if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") { + if (getConfig('surfbar_pay_model') == "DYNAMIC") { // "Calculate" dynamic reward if ($onlyMin) { $reward += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE(); @@ -762,10 +762,10 @@ function SURFBAR_DETERMINE_COSTS ($onlyMin=false) { global $_CONFIG; // Static costs is default - $costs = $_CONFIG['surfbar_static_costs']; + $costs = getConfig('surfbar_static_costs'); // Do we have static or dynamic? - if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") { + if (getConfig('surfbar_pay_model') == "DYNAMIC") { // "Calculate" dynamic costs if ($onlyMin) { $costs += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE(); @@ -811,18 +811,20 @@ function SURFBAR_CHECK_RELOAD_FULL() { $isFull = true; // 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); + $SURFBAR_CACHE['surf_lock'] = getConfig('surfbar_static_lock'); + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Fixed surf lock is ".getConfig('surfbar_static_lock')."", false); // Do we have dynamic model? - if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") { + if (getConfig('surfbar_pay_model') == "DYNAMIC") { // "Calculate" dynamic lock $SURFBAR_CACHE['surf_lock'] += SURFBAR_CALCULATE_DYNAMIC_ADD(); } // 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__ ); @@ -843,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; @@ -881,7 +883,7 @@ function SURFBAR_IF_USER_BOOK_MORE_URLS ($uid=0) { global $_CONFIG; // Is this admin and userid is zero or does the user has some URLs left to book? - return ((($uid == 0) && (IS_ADMIN())) || (SURFBAR_GET_TOTAL_USER_URLS($uid, "", array("REJECTED")) < $_CONFIG['surfbar_max_order'])); + return ((($uid == 0) && (IS_ADMIN())) || (SURFBAR_GET_TOTAL_USER_URLS($uid, "", array("REJECTED")) < getConfig('surfbar_max_order'))); } // Get total amount of URLs of given status for current user function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status="",$exclude="") { @@ -893,7 +895,7 @@ function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status="",$exclude="") { $uid = $GLOBALS['userid']; } elseif ($uid == 0) { // Error! - return ($_CONFIG['surfbar_max_order'] + 1); + return (getConfig('surfbar_max_order') + 1); } // Default is all URLs @@ -919,7 +921,7 @@ function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status="",$exclude="") { FROM "._MYSQL_PREFIX."_surfbar_urls WHERE userid=%s".$ADD." LIMIT %s", - array($uid, $_CONFIG['surfbar_max_order']), __FILE__, __LINE__ + array($uid, getConfig('surfbar_max_order')), __FILE__, __LINE__ ); // Fetch row @@ -939,7 +941,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt="") { $SURFBAR_CACHE['salt'] = "INVALID"; // Get code length from config - $length = $_CONFIG['code_length']; + $length = getConfig('code_length'); // Fix length to 10 if ($length == 0) $length = 10; @@ -951,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 @@ -970,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 @@ -984,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) @@ -1000,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", getConfig('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", getConfig('surfbar_pay_model')), $GLOBALS['userid'], SURFBAR_GET_DATA('reward')); } // Updates the statistics of current URL/userid function SURFBAR_UPDATE_INSERT_STATS_RECORD () { @@ -1020,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) { @@ -1062,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) { @@ -1072,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__ @@ -1096,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 @@ -1118,7 +1122,7 @@ function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) { // Get all userid except logged in one $result = SQL_QUERY_ESC("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified FROM "._MYSQL_PREFIX."_surfbar_urls AS u -INNER JOIN "._MYSQL_PREFIX."_user_data AS d +INNER JOIN `"._MYSQL_PREFIX."_user_data` AS d ON u.userid=d.userid WHERE u.userid NOT IN (%s,0) AND u.status='ACTIVE' GROUP BY u.userid @@ -1128,7 +1132,7 @@ ORDER BY u.userid ASC", // Get all userid $result = SQL_QUERY("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified FROM "._MYSQL_PREFIX."_surfbar_urls AS u -INNER JOIN "._MYSQL_PREFIX."_user_data AS d +INNER JOIN `"._MYSQL_PREFIX."_user_data` AS d ON u.userid=d.userid WHERE u.status='ACTIVE' GROUP BY u.userid @@ -1139,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; @@ -1155,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; @@ -1169,7 +1173,7 @@ function SURFBAR_DETERMINE_TOTAL_ONLINE () { FROM "._MYSQL_PREFIX."_surfbar_stats WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_online)) <= %s GROUP BY userid", - array($_CONFIG['online_timeout']), __FILE__, __LINE__); + array(getConfig('online_timeout')), __FILE__, __LINE__); // Fetch count $cnt = SQL_NUMROWS($result); @@ -1182,8 +1186,6 @@ GROUP BY userid", } // Determine waiting time for one URL function SURFBAR_DETERMINE_WAIT_TIME () { - global $_CONFIG; - // Get fixed reload lock $fixed = SURFBAR_GET_FIXED_RELOAD(); @@ -1194,10 +1196,10 @@ function SURFBAR_DETERMINE_WAIT_TIME () { } // END - if // Static time is default - $time = $_CONFIG['surfbar_static_time']; + $time = getConfig('surfbar_static_time'); // Which payment model do we have? - if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") { + if (getConfig('surfbar_pay_model') == "DYNAMIC") { // "Calculate" dynamic time $time += SURFBAR_CALCULATE_DYNAMIC_ADD(); } // END - if @@ -1246,10 +1248,10 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) // Prepare content for notification routines $data[$urlId]['uid'] = $data[$urlId]['userid']; $data[$urlId]['frametester'] = FRAMETESTER($data[$urlId]['url']); - $data[$urlId]['reward'] = TRANSLATE_COMMA($_CONFIG['surfbar_static_reward']); - $data[$urlId]['costs'] = TRANSLATE_COMMA($_CONFIG['surfbar_static_costs']); + $data[$urlId]['reward'] = TRANSLATE_COMMA(getConfig('surfbar_static_reward')); + $data[$urlId]['costs'] = TRANSLATE_COMMA(getConfig('surfbar_static_costs')); - // Do some dirt fixing here: + // Do some dirty fixing here: if (($data[$urlId]['status'] == "STOPPED") && ($newStatus == "pending")) { // Fix for template change $newStatus = "continued"; @@ -1272,7 +1274,7 @@ function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () { $addon = 0; // Percentage part - $percent = abs(log($_CONFIG['surfbar_dynamic_percent'] / 100 + 1)); + $percent = abs(log(getConfig('surfbar_dynamic_percent') / 100 + 1)); // Get total users $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true); @@ -1310,7 +1312,7 @@ function SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE () { $max = log(2); // Percentage part - $percent = abs(log($_CONFIG['surfbar_dynamic_percent'] / 100 + 1)); + $percent = abs(log(getConfig('surfbar_dynamic_percent') / 100 + 1)); // Get total users $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true); @@ -1363,17 +1365,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; @@ -1381,7 +1383,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; @@ -1410,7 +1412,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=".getConfig('db_last_query')."|numRows=".SQL_NUMROWS($result)."|Affected=".SQL_AFFECTEDROWS()."", false); // Fetch max rand $maxRand = SQL_NUMROWS($result); @@ -1473,15 +1475,13 @@ function SURFBAR_GET_ACTION_ARRAY ($status) { } // Reload to configured stop page function SURFBAR_RELOAD_TO_STOP_PAGE($page="stop") { - global $_CONFIG; - // Internal or external? - if (($_CONFIG['surfbar_pause_mode'] == "INTERNAL") || (empty($_CONFIG['surfbar_pause_url']))) { + if ((getConfig('surfbar_pause_mode') == "INTERNAL") || (getConfig('surfbar_pause_url') == "")) { // Reload to internal page LOAD_URL("surfbar.php?frame=".$page); } else { // Reload to external page - LOAD_URL($_CONFIG['surfbar_pause_url']); + LOAD_CONFIGURED_URL('surfbar_pause_url'); } } @@ -1526,7 +1526,7 @@ 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); + //* 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 @@ -1554,12 +1554,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=".getConfig('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(); @@ -1567,28 +1567,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") { + if (getConfig('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 @@ -1599,7 +1599,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; } // ----------------------------------------------------------------------------- @@ -1609,7 +1609,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; @@ -1626,7 +1626,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 @@ -1660,7 +1660,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'); } @@ -1670,7 +1670,7 @@ 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'); } @@ -1679,5 +1679,10 @@ 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'); +} // ?>