X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=inc%2Flibs%2Fsurfbar_functions.php;h=4c7f40a75fea358f6be5dd3754642bb4e89d437a;hb=ac3ce5eb46bd9f7e5f6f41b930f7ebdc17089ed2;hp=9feb142f5a05c29b82cdcc842483ba499175d36a;hpb=30ae22f62ae87c53a56baf0d134569ba91011111;p=mailer.git
diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php
index 9feb142f5a..4c7f40a75f 100644
--- a/inc/libs/surfbar_functions.php
+++ b/inc/libs/surfbar_functions.php
@@ -14,8 +14,6 @@
* $Date:: $ *
* $Tag:: 0.2.1-FINAL $ *
* $Author:: $ *
- * Needs to be in all Files and every File needs "svn propset *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
* Copyright (c) 2009, 2010 by Mailer Developer Team *
@@ -40,7 +38,7 @@
// Some security stuff...
if (!defined('__SECURITY')) {
die();
-}
+} // END - if
// -----------------------------------------------------------------------------
// Admin functions
@@ -189,8 +187,8 @@ function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
$actionArray = SURFBAR_GET_ARRAY_FROM_STATUS($status);
// Init HTML code
- $OUT = "
-\n";
+ $OUT = '
+';
// Calculate width
$width = round(100 / count($actionArray));
@@ -208,8 +206,8 @@ function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
} // END - foreach
// Close table
- $OUT .= "
-
\n";
+ $OUT .= '
+
';
// Return code
return $OUT;
@@ -369,16 +367,16 @@ function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
// Include fields only for action 'edit'
if ($action == 'edit') {
// Default is not limited
- $urlData['limited_y'] = '';
- $urlData['limited_n'] = ' checked="checked"';
- $urlData['limited'] = 'false';
+ $urlData['limited_yes'] = '';
+ $urlData['limited_no'] = ' checked="checked"';
+ $urlData['limited'] = 'false';
// Is this URL limited?
if (SURFBAR_GET_VIEWS_MAX() > 0) {
// Then rewrite form data
- $urlData['limited_y'] = ' checked="checked"';
- $urlData['limited_n'] = '';
- $urlData['limited'] = 'true';
+ $urlData['limited_yes'] = ' checked="checked"';
+ $urlData['limited_no'] = '';
+ $urlData['limited'] = 'true';
} // END - if
} // END - if
@@ -727,7 +725,7 @@ function translateSurfbarLimit ($limit) {
$return = '{--MEMBER_SURFBAR_UNLIMITED_VIEWS--}';
} else {
// Translate comma
- $return = translateComma($limit);
+ $return = '{%pipe,translateComma=' . $limit . '%}';
}
// Return value
@@ -876,7 +874,7 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
} // END - if
// Is the exlude userid set?
- if ($excludeUserId > 0) {
+ if (isValidUserId($excludeUserId)) {
// Then add it
$userids['url_userid'][$excludeUserId] = $excludeUserId;
} // END - if
@@ -894,16 +892,16 @@ LIMIT 1",
);
// Fetch row
- list($cnt) = SQL_FETCHROW($result);
+ list($count) = SQL_FETCHROW($result);
// Free result
SQL_FREERESULT($result);
// Debug message
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $cnt);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $count);
// Return result
- return $cnt;
+ return $count;
}
// Check wether the user is allowed to book more URLs
@@ -942,10 +940,10 @@ function SURFBAR_GET_TOTAL_USER_URLS ($userid = '0', $status = '', $exclude = ''
}
// Get amount from database
- $cnt = countSumTotalData($userid, 'surfbar_urls', 'url_id', 'url_userid', true, $add);
+ $count = countSumTotalData($userid, 'surfbar_urls', 'url_id', 'url_userid', true, $add);
// Return result
- return $cnt;
+ return $count;
}
// Generate a validation code for the given id number
@@ -954,7 +952,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt = '') {
$GLOBALS['surfbar_cache']['salt'] = 'INVALID';
// Get code length from config
- $length = getConfig('code_length');
+ $length = getCodeLength();
// Fix length to 10
if ($length == '0') $length = 10;
@@ -1024,9 +1022,12 @@ function SURFBAR_PAY_POINTS () {
subtractPoints(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
} // END - if
- // Book it to the user
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.SURFBAR_GET_REWARD().'', false);
- addPointsThroughReferalSystem(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getMemberId(), SURFBAR_GET_DATA('reward'));
+ // @TODO Try to rewrite the following unset()
+ unset($GLOBALS['ref_level']);
+
+ // Book it to the user
+ addPointsThroughReferalSystem(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getMemberId(), SURFBAR_GET_REWARD());
}
// Updates the statistics of current URL/userid
@@ -1055,7 +1056,7 @@ function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
), __FUNCTION__, __LINE__);
// Was that update okay?
- if (SQL_AFFECTEDROWS() < 1) {
+ if (SQL_HASZEROAFFECTED()) {
// No, then insert entry
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`, `stats_url_id`, `stats_count`) VALUES (%s,%s,1)",
array(
@@ -1094,7 +1095,7 @@ function SURFBAR_UPDATE_SALT_STATS () {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt='.SURFBAR_GET_SALT().',id='.SURFBAR_GET_ID().',userid='.getMemberId().'', false);
// Was that okay?
- if (SQL_AFFECTEDROWS() < 1) {
+ if (SQL_HASZEROAFFECTED()) {
// Insert missing entry!
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_salts` (`salts_url_id`, `salts_userid`, `salts_last_salt`) VALUES (%s, %s, '%s')",
array(SURFBAR_GET_ID(), getMemberId(), SURFBAR_GET_SALT()), __FUNCTION__, __LINE__);
@@ -1104,7 +1105,7 @@ function SURFBAR_UPDATE_SALT_STATS () {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'affectedRows='.SQL_AFFECTEDROWS().'', false);
// Return if the update was okay
- return (SQL_AFFECTEDROWS() == 1);
+ return (!SQL_HASZEROAFFECTED());
}
// Check if the reload lock is active for given id
@@ -1125,14 +1126,14 @@ LIMIT 1",
);
// Fetch counter
- list($cnt) = SQL_FETCHROW($result);
+ list($count) = SQL_FETCHROW($result);
// Free result
SQL_FREERESULT($result);
// Return check
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $cnt . ',' . SURFBAR_GET_SURF_LOCK() . '', false);
- return ($cnt == 1);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $count . ',' . SURFBAR_GET_SURF_LOCK() . '', false);
+ return ($count == 1);
}
// Determine which user hash no more points left
@@ -1147,9 +1148,9 @@ function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
// Do we have a current user id?
if ((isMember()) && ($limit == '0')) {
// Then add this as well
- $userids['url_userid'][getMemberId()] = getMemberId();
- $userids['points'][getMemberId()] = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
- $userids['notified'][getMemberId()] = '0';
+ $userids['url_userid'][getMemberId()] = getMemberId();
+ $userids['points'][getMemberId()] = getTotalPoints(getMemberId());
+ $userids['notified'][getMemberId()] = '0';
// Get all userid except logged in one
$result = SQL_QUERY_ESC("SELECT
@@ -1188,16 +1189,16 @@ ORDER BY
// Load all userid
while ($content = SQL_FETCHARRAY($result)) {
// Get total points
- $points = countSumTotalData($content['url_userid'], 'user_points', 'points') - countSumTotalData($content['url_userid'], 'user_data', 'used_points');
+ $points = getTotalPoints($content['url_userid']);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['url_userid']},points={$points}", false);
// Shall we add this to ignore?
if ($points <= $limit) {
// Ignore this one!
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['url_userid']} has depleted points amount!", false);
- $userids['url_userid'][$content['url_userid']] = $content['url_userid'];
- $userids['points'][$content['url_userid']] = $points;
- $userids['notified'][$content['url_userid']] = $content['notified'];
+ $userids['url_userid'][$content['url_userid']] = $content['url_userid'];
+ $userids['points'][$content['url_userid']] = $points;
+ $userids['notified'][$content['url_userid']] = $content['notified'];
} // END - if
} // END - while
@@ -1214,23 +1215,23 @@ ORDER BY
// Determine how many users are Online in surfbar
function SURFBAR_DETERMINE_TOTAL_ONLINE () {
// Count all users in surfbar modue and return the value
- $result = SQL_QUERY("SELECT
+ $result = SQL_QUERY('SELECT
`stats_id`
FROM
`{?_MYSQL_PREFIX?}_surfbar_stats`
WHERE
(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`stats_last_surfed`)) <= {?online_timeout?}
GROUP BY
- `stats_userid` ASC", __FUNCTION__, __LINE__);
+ `stats_userid` ASC', __FUNCTION__, __LINE__);
// Fetch count
- $cnt = SQL_NUMROWS($result);
+ $count = SQL_NUMROWS($result);
// Free result
SQL_FREERESULT($result);
// Return result
- return $cnt;
+ return $count;
}
// Determine waiting time for one URL
@@ -1297,9 +1298,9 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array())
// Prepare content for notification routines
$data[$urlId]['url_userid'] = $data[$urlId]['url_userid'];
- $data[$urlId]['frametester'] = generateFrametesterUrl($data[$urlId]['url']);
- $data[$urlId]['reward'] = translateComma(getConfig('surfbar_static_reward'));
- $data[$urlId]['costs'] = translateComma(getConfig('surfbar_static_costs'));
+ $data[$urlId]['frametester'] = '{%pipe,generateFrametesterUrl=' . $data[$urlId]['url'] . '%}';
+ $data[$urlId]['reward'] = '{%config,translateComma=surfbar_static_reward%}';
+ $data[$urlId]['costs'] = '{%config,translateComma=surfbar_static_costs%}';
// Do some dirty fixing here:
if (($data[$urlId]['url_status'] == 'STOPPED') && ($newStatus == 'pending')) {
@@ -1463,10 +1464,10 @@ LEFT JOIN
ON
sbu.url_id=l.locks_url_id
WHERE
- sbu.url_userid NOT IN (".implode(',', $userids).") AND
+ sbu.url_userid NOT IN (" . implode(',', $userids) . ") AND
(sbu.url_views_allowed=0 OR (sbu.url_views_allowed > 0 AND sbu.url_views_max > 0)) AND
sbu.url_status='ACTIVE'
- ".$add."
+ " . $add . "
GROUP BY
sbu.url_id ASC", __FUNCTION__, __LINE__);
@@ -1563,7 +1564,7 @@ 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!!!
+// getters below this function!
function SURFBAR_DETERMINE_NEXT_ID ($urlId = '0') {
// Default is no id and no random number
$nextId = '0';
@@ -1717,6 +1718,58 @@ LIMIT 1",
return $nextId;
}
+// ----------------------------------------------------------------------------
+// Wrapper function
+// ----------------------------------------------------------------------------
+
+// "Getter" for surfbar_dynamic_percent
+function getSurfbarDynamicPercent () {
+ // Do we have cache?
+ if (!isset($GLOBALS['surfbar_dynamic_percent'])) {
+ // Determine it
+ $GLOBALS['surfbar_dynamic_percent'] = getConfig('surfbar_dynamic_percent');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['surfbar_dynamic_percent'];
+}
+
+// "Getter" for surfbar_static_reward
+function getSurfbarStaticReward () {
+ // Do we have cache?
+ if (!isset($GLOBALS['surfbar_static_reward'])) {
+ // Determine it
+ $GLOBALS['surfbar_static_reward'] = getConfig('surfbar_static_reward');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['surfbar_static_reward'];
+}
+
+// "Getter" for surfbar_static_time
+function getSurfbarStaticTime () {
+ // Do we have cache?
+ if (!isset($GLOBALS['surfbar_static_time'])) {
+ // Determine it
+ $GLOBALS['surfbar_static_time'] = getConfig('surfbar_static_time');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['surfbar_static_time'];
+}
+
+// "Getter" for surfbar_max_order
+function getSurfbarMaxOrder () {
+ // Do we have cache?
+ if (!isset($GLOBALS['surfbar_max_order'])) {
+ // Determine it
+ $GLOBALS['surfbar_max_order'] = getConfig('surfbar_max_order');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['surfbar_max_order'];
+}
+
// -----------------------------------------------------------------------------
// PLEASE DO NOT ADD ANY OTHER FUNCTIONS BELOW THIS LINE IF THEY DON'T "WRAP"
// THE $GLOBALS['surfbar_cache'] ARRAY!