X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Fsurfbar_functions.php;h=5b2bca1ce726ea51b19db1c9c02d458ed9688d96;hp=dd17a102a7a9406f41607c1dac1861d5b6d654da;hb=05c5310de0991ba52c441670a315b89ee4f9db12;hpb=916bba4f00ee924f0d88b8fc273dee5bfb798aed diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index dd17a102a7..5b2bca1ce7 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -1,7 +1,7 @@ 0? if ((isset($urlData[$action]['limited'])) && ($urlData[$action]['limited'] != 'Y') && ((isset($urlData[$action]['limit'])) && ($urlData[$action]['limit'] > 0)) || (!isset($urlData[$action]['limit']))) { // Set it to unlimited - $urlData[$action]['limit'] = 0; + $urlData[$action]['limit'] = '0'; } // END - if // Construct function name @@ -494,18 +494,18 @@ function SURFBAR_HANDLE_DEPLETED_VIEWS () { // Alert users which have URLs booked and are low on points amount function SURFBAR_HANDLE_LOW_POINTS () { // Get all userids - $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points')); + $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points')); // "Walk" through all URLs - foreach ($UIDs['userid'] as $userid => $dummy) { + foreach ($userids['userid'] as $userid => $dummy) { // Is the last notification far enougth away to notify again? - if ((time() - $UIDs['notified'][$userid]) >= getConfig('surfbar_low_interval')) { + if ((time() - $userids['notified'][$userid]) >= getConfig('surfbar_low_interval')) { // Prepare content $content = array( 'userid' => $userid, 'low' => translateComma(getConfig('surfbar_warn_low_points')), - 'points' => translateComma($UIDs['points'][$userid]), - 'notified' => generateDateTime($UIDs['notified'][$userid]), + 'points' => translateComma($userids['points'][$userid]), + 'notified' => generateDateTime($userids['notified'][$userid]), 'interval' => createFancyTime(getConfig('surfbar_low_interval')) ); @@ -598,17 +598,17 @@ function SURFBAR_REGISTER_URL ($url, $userid, $status = 'PENDING', $addMode = 'r // Is limit/reload set? if (!isset($config['limit'])) { - $content['limit'] = 0; + $content['limit'] = '0'; } // END - if if (!isset($config['reload'])) { - $content['reload'] = 0; + $content['reload'] = '0'; } // END - if // Insert the URL into database $content['insert_id'] = SURFBAR_INSERT_URL_BY_ARRAY($content); // Is this id valid? - if ($content['insert_id'] == 0) { + if ($content['insert_id'] == '0') { // INSERT did not insert any data! return false; } // END - if @@ -635,7 +635,7 @@ function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) { $userid = bigintval($urlData['userid']); // Is the id set? - if (empty($userid)) $userid = 0; + if (empty($userid)) $userid = '0'; // 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)", @@ -684,7 +684,7 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) { // 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['userid'] == '0') { return false; } // END - if @@ -720,7 +720,7 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) { // Translates the limit function translateSurfbarLimit ($limit) { // Is this zero? - if ($limit == 0) { + if ($limit == '0') { // Unlimited! $return = getMessage('MEMBER_SURFBAR_UNLIMITED_VIEWS'); } else { @@ -737,14 +737,8 @@ function translateSurfbarUrlStatus ($status) { // Create constant name $constantName = sprintf("SURFBAR_URL_STATUS_%s", strtoupper($status)); - // Set default translated status - $statusTranslated = '!'.$constantName.'!'; - - // Is the constant there? - if (defined($constantName)) { - // Then get it's value - $statusTranslated = constant($constantName); - } // END - if + // Get message + $statusTranslated = getMessage($constantName); // Return result return $statusTranslated; @@ -841,7 +835,12 @@ INNER JOIN 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) + 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(getMemberId()), __FUNCTION__, __LINE__ ); @@ -852,7 +851,7 @@ LIMIT 1", // Is it null? if (is_null($GLOBALS['surfbar_cache']['user_locks'])) { // Then fix it to zero! - $GLOBALS['surfbar_cache']['user_locks'] = 0; + $GLOBALS['surfbar_cache']['user_locks'] = '0'; } // END - if // Free result @@ -870,12 +869,12 @@ LIMIT 1", } // Get total amount of URLs of given status for current user or of ACTIVE URLs by default -function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = 0) { +function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') { // Determine depleted user account - $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS(); + $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS(); // If we dont get any user ids back, there are no URLs - if (count($UIDs['userid']) == 0) { + if (count($userids['userid']) == '0') { // No user ids found, no URLs! return 0; } // END - if @@ -883,13 +882,13 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = 0) { // Is the exlude userid set? if ($excludeUserId > 0) { // Then add it - $UIDs['userid'][$excludeUserId] = $excludeUserId; + $userids['userid'][$excludeUserId] = $excludeUserId; } // END - if // Get amount from database $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS cnt FROM `{?_MYSQL_PREFIX?}_surfbar_urls` -WHERE `userid` NOT IN (".implode(', ', $UIDs['userid']).") AND `status`='%s'", +WHERE `userid` NOT IN (".implode(', ', $userids['userid']).") AND `status`='%s'", array($status), __FUNCTION__, __LINE__ ); @@ -904,18 +903,18 @@ WHERE `userid` NOT IN (".implode(', ', $UIDs['userid']).") AND `status`='%s'", } // Check wether the user is allowed to book more URLs -function SURFBAR_IF_USER_BOOK_MORE_URLS ($userid = 0) { +function SURFBAR_IF_USER_BOOK_MORE_URLS ($userid = '0') { // Is this admin and userid is zero or does the user has some URLs left to book? - return ((($userid == 0) && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array("REJECTED")) < getConfig('surfbar_max_order'))); + return ((($userid == '0') && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array('REJECTED')) < getConfig('surfbar_max_order'))); } // Get total amount of URLs of given status for current user -function SURFBAR_GET_TOTAL_USER_URLS ($userid = 0, $status = '',$exclude = '') { +function SURFBAR_GET_TOTAL_USER_URLS ($userid = '0', $status = '',$exclude = '') { // Is the user 0 and user is logged in? - if (($userid == 0) && (isMember())) { + if (($userid == '0') && (isMember())) { // Then use this userid $userid = getMemberId(); - } elseif ($userid == 0) { + } elseif ($userid == '0') { // Error! return (getConfig('surfbar_max_order') + 1); } @@ -954,7 +953,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt = '') { $length = getConfig('code_length'); // Fix length to 10 - if ($length == 0) $length = 10; + if ($length == '0') $length = 10; // Generate a code until the length matches $valCode = ''; @@ -1120,18 +1119,18 @@ LIMIT 1", // Determine which user hash no more points left function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) { // Init array - $UIDs = array( + $userids = array( 'userid' => array(), 'points' => array(), 'notified' => array(), ); // Do we have a current user id? - if ((isMember()) && ($limit == 0)) { + if ((isMember()) && ($limit == '0')) { // Then add this as well - $UIDs['userid'][getMemberId()] = getMemberId(); - $UIDs['points'][getMemberId()] = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points'); - $UIDs['notified'][getMemberId()] = 0; + $userids['userid'][getMemberId()] = getMemberId(); + $userids['points'][getMemberId()] = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points'); + $userids['notified'][getMemberId()] = '0'; // Get all userid except logged in one $result = SQL_QUERY_ESC("SELECT @@ -1177,9 +1176,9 @@ ORDER BY if ($points <= $limit) { // Ignore this one! //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['userid']} has depleted points amount!", false); - $UIDs['userid'][$content['userid']] = $content['userid']; - $UIDs['points'][$content['userid']] = $points; - $UIDs['notified'][$content['userid']] = $content['notified']; + $userids['userid'][$content['userid']] = $content['userid']; + $userids['points'][$content['userid']] = $points; + $userids['notified'][$content['userid']] = $content['notified']; } // END - if } // END - while @@ -1187,10 +1186,10 @@ ORDER BY SQL_FREERESULT($result); // Debug message - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".getMemberId().')', false); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "UIDs::count=".count($userids)." (with own userid=".getMemberId().')', false); // Return result - return $UIDs; + return $userids; } // Determine how many users are Online in surfbar @@ -1245,7 +1244,7 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) $newStatus = strtolower($newStatus); // Get URL data for status comparison if missing - if ((!is_array($data)) || (count($data) == 0)) { + if ((!is_array($data)) || (count($data) == '0')) { // Fetch missing URL data $data = SURFBAR_GET_URL_DATA($urlId); } // END - if @@ -1302,7 +1301,7 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) // Calculate minimum value for dynamic payment model function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () { // Addon is zero by default - $addon = 0; + $addon = '0'; // Percentage part $percent = abs(log(getConfig('surfbar_dynamic_percent') / 100 + 1)); @@ -1336,7 +1335,7 @@ function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () { // Calculate maximum value for dynamic payment model function SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE () { // Addon is zero by default - $addon = 0; + $addon = '0'; // Maximum value $max = log(2); @@ -1430,7 +1429,7 @@ ORDER BY } // "Getter" for maximum random number -function SURFBAR_GET_MAX_RANDOM ($UIDs, $add) { +function SURFBAR_GET_MAX_RANDOM ($userids, $add) { // Count max availabe entries $result = SQL_QUERY("SELECT sbu.id AS cnt FROM `{?_MYSQL_PREFIX?}_surfbar_urls` AS sbu @@ -1438,7 +1437,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(',', $userids).") 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 @@ -1508,7 +1507,7 @@ function SURFBAR_GET_ARRAY_FROM_STATUS ($status) { } // Reload to configured stop page -function SURFBAR_RELOAD_TO_STOP_PAGE ($page="stop") { +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 @@ -1521,13 +1520,13 @@ function SURFBAR_RELOAD_TO_STOP_PAGE ($page="stop") { // Determine next id for surfbar or get data for given id, always call this before you call other // getters below this function!!! -function SURFBAR_DETERMINE_NEXT_ID ($urlId = 0) { +function SURFBAR_DETERMINE_NEXT_ID ($urlId = '0') { // Default is no id and no random number - $nextId = 0; - $randNum = 0; + $nextId = '0'; + $randNum = '0'; // Is the id set? - if ($urlId == 0) { + if ($urlId == '0') { // Get array with lock ids $USE = SURFBAR_GET_LOCK_IDS(); @@ -1546,10 +1545,10 @@ function SURFBAR_DETERMINE_NEXT_ID ($urlId = 0) { } // END - if // Determine depleted user account - $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS(); + $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS(); // Get maximum randomness factor - $maxRand = SURFBAR_GET_MAX_RANDOM($UIDs['userid'], $add); + $maxRand = SURFBAR_GET_MAX_RANDOM($userids['userid'], $add); // If more than one URL can be called generate the random number! if ($maxRand > 1) { @@ -1565,7 +1564,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['userid']).") 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(',', $userids['userid']).") 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", @@ -1607,7 +1606,7 @@ LIMIT 1", if ((!isset($GLOBALS['surfbar_cache']['last_surfed'])) || (is_null($GLOBALS['surfbar_cache']['last_surfed']))) { // Fix it here //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_surfed - FIXED!', false); - $GLOBALS['surfbar_cache']['last_surfed'] = 0; + $GLOBALS['surfbar_cache']['last_surfed'] = '0'; } // END - if // Get base/fixed reward and costs