}
// Determine reward
-function SURFBAR_DETERMINE_REWARD ($onlyMin=false) {
+function SURFBAR_DETERMINE_REWARD ($onlyMin = false) {
// Static values are default
$reward = getConfig('surfbar_static_reward');
// Do we have static or dynamic?
- if (getConfig('surfbar_pay_model') == 'DYNAMIC') {
+ if (getSurfbarPaymentModel() == 'DYNAMIC') {
// "Calculate" dynamic reward
- if ($onlyMin) {
+ if ($onlyMin === true) {
$reward += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
} else {
$reward += SURFBAR_CALCULATE_DYNAMIC_ADD();
$costs = getConfig('surfbar_static_costs');
// Do we have static or dynamic?
- if (getConfig('surfbar_pay_model') == 'DYNAMIC') {
+ if (getSurfbarPaymentModel() == 'DYNAMIC') {
// "Calculate" dynamic costs
if ($onlyMin) {
$costs += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
// Determine right template name
function SURFBAR_DETERMINE_TEMPLATE_NAME() {
// Default is the frameset
- $templateName = "surfbar_frameset";
+ $templateName = 'surfbar_frameset';
// Any frame set? ;-)
if (isGetRequestParameterSet('frame')) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Fixed surf lock is '.getConfig('surfbar_static_lock') . '', false);
// Do we have dynamic model?
- if (getConfig('surfbar_pay_model') == 'DYNAMIC') {
+ if (getSurfbarPaymentModel() == 'DYNAMIC') {
// "Calculate" dynamic lock
$GLOBALS['surfbar_cache']['surf_lock'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
} // END - if
// Ask the database
$result = SQL_QUERY_ESC("SELECT
- COUNT(l.locks_id) AS cnt
+ COUNT(l.`locks_id`) AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_surfbar_locks` AS l
INNER JOIN
`{?_MYSQL_PREFIX?}_surfbar_urls` AS u
ON
- u.url_id=l.locks_url_id
+ u.`url_id`=l.`locks_url_id`
WHERE
- l.locks_userid=%s AND
- (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(l.locks_last_surfed) AND
+ l.`locks_userid`=%s AND
+ (UNIX_TIMESTAMP() - {%pipe,SURFBAR_GET_SURF_LOCK%}) < UNIX_TIMESTAMP(l.`locks_last_surfed`) AND
(
- ((UNIX_TIMESTAMP(l.locks_last_surfed) - u.url_fixed_reload) < 0 AND u.url_fixed_reload > 0) OR
- u.url_fixed_reload = '0'
+ ((UNIX_TIMESTAMP(l.`locks_last_surfed`) - u.`url_fixed_reload`) < 0 AND u.`url_fixed_reload` > 0) OR
+ u.`url_fixed_reload` = 0
)
LIMIT 1",
array(getMemberId()), __FUNCTION__, __LINE__
// 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')) < getSurfbarMaxOrder()));
}
// Get total amount of URLs of given status for current user
$userid = getMemberId();
} elseif ($userid == '0') {
// Error!
- return (getConfig('surfbar_max_order') + 1);
+ return (getSurfbarMaxOrder() + 1);
}
// Default is all URLs
// Remove it from the URL owner
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS().'', false);
if (isValidUserId(SURFBAR_GET_USERID())) {
- subtractPoints(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
+ subtractPoints(sprintf("surfbar_%s", getSurfbarPaymentModel()), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
} // END - if
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.SURFBAR_GET_REWARD().'', false);
unset($GLOBALS['ref_level']);
// Book it to the user
- addPointsThroughReferalSystem(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getMemberId(), SURFBAR_GET_REWARD());
+ addPointsThroughReferalSystem(sprintf("surfbar_%s", getSurfbarPaymentModel()), getMemberId(), SURFBAR_GET_REWARD());
}
// Updates the statistics of current URL/userid
$time = getConfig('surfbar_static_time');
// Which payment model do we have?
- if (getConfig('surfbar_pay_model') == 'DYNAMIC') {
+ if (getSurfbarPaymentModel() == 'DYNAMIC') {
// "Calculate" dynamic time
$time += SURFBAR_CALCULATE_DYNAMIC_ADD();
} // END - if
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'BASE/STATIC - reward='.SURFBAR_GET_REWARD().'|costs='.SURFBAR_GET_COSTS().'', false);
// Only in dynamic model add the dynamic bonus!
- if (getConfig('surfbar_pay_model') == 'DYNAMIC') {
+ if (getSurfbarPaymentModel() == 'DYNAMIC') {
// Calculate dynamic reward/costs and add it
$GLOBALS['surfbar_cache']['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
$GLOBALS['surfbar_cache']['costs'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
// "Getter" for surfbar_dynamic_percent
function getSurfbarDynamicPercent () {
// Do we have cache?
- if (!isset($GLOBALS['surfbar_dynamic_percent'])) {
+ if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
- $GLOBALS['surfbar_dynamic_percent'] = getConfig('surfbar_dynamic_percent');
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_dynamic_percent');
} // END - if
// Return cache
- return $GLOBALS['surfbar_dynamic_percent'];
+ return $GLOBALS[__FUNCTION__];
}
// "Getter" for surfbar_static_reward
function getSurfbarStaticReward () {
// Do we have cache?
- if (!isset($GLOBALS['surfbar_static_reward'])) {
+ if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
- $GLOBALS['surfbar_static_reward'] = getConfig('surfbar_static_reward');
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_static_reward');
} // END - if
// Return cache
- return $GLOBALS['surfbar_static_reward'];
+ return $GLOBALS[__FUNCTION__];
}
// "Getter" for surfbar_static_time
function getSurfbarStaticTime () {
// Do we have cache?
- if (!isset($GLOBALS['surfbar_static_time'])) {
+ if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
- $GLOBALS['surfbar_static_time'] = getConfig('surfbar_static_time');
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_static_time');
} // END - if
// Return cache
- return $GLOBALS['surfbar_static_time'];
+ return $GLOBALS[__FUNCTION__];
}
// "Getter" for surfbar_max_order
function getSurfbarMaxOrder () {
// Do we have cache?
- if (!isset($GLOBALS['surfbar_max_order'])) {
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_max_order');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for surfbar_payment_model
+function getSurfbarPaymentModel () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
- $GLOBALS['surfbar_max_order'] = getConfig('surfbar_max_order');
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_payment_model');
} // END - if
// Return cache
- return $GLOBALS['surfbar_max_order'];
+ return $GLOBALS[__FUNCTION__];
}
// -----------------------------------------------------------------------------