X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Flibs%2Fsurfbar_functions.php;h=354b33b3a44fb0aeac07ed0f7c66ab82198f9c86;hb=80539a22f89c2a5e4e765a886ad5081c5fc33dc2;hp=d87130fee37f06366ae64891ac42f807c8aa36ea;hpb=d495bd859975d08ee459d03c9b1cd51dd9b9304d;p=mailer.git diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index d87130fee3..354b33b3a4 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -1,7 +1,7 @@ $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')) ); @@ -737,14 +738,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; @@ -804,10 +799,10 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() { $templateName = "surfbar_frameset"; // Any frame set? ;-) - if (isGetRequestElementSet('frame')) { + if (isGetRequestParameterSet('frame')) { // Use the frame as a template name part... ;-) $templateName = sprintf("surfbar_frame_%s", - getRequestElement('frame') + getRequestParameter('frame') ); } // END - if @@ -841,7 +836,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__ ); @@ -872,10 +872,10 @@ 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') { // 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 +883,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__ ); @@ -906,7 +906,7 @@ 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') { // 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 @@ -979,7 +979,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt = '') { $hashedCode = generateHash(md5($valCode), SURFBAR_GET_SALT()); // Finally encrypt it PGP-like and return it - $valHashedCode = generatePassString($hashedCode); + $valHashedCode = encodeHashForCookie($hashedCode); // Return hashed value //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'finalValCode='.$valHashedCode.'', false); @@ -1120,7 +1120,7 @@ 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(), @@ -1129,9 +1129,9 @@ function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) { // Do we have a current user id? 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 +1177,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 +1187,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 @@ -1430,7 +1430,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 +1438,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 +1508,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 @@ -1546,10 +1546,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 +1565,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",