* $Author:: $ *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team *
* For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
//------------------------------------------------------------------------------
// Admin has added an URL with given user id and so on
-function doSurfbarAdminAddUrl ($url, $limit, $reload) {
+function doSurfbarAdminAddUrl ($url, $limit, $reload, $waiting) {
// Do some pre-checks
if (!isAdmin()) {
// Not an admin
// Invalid amount entered
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s: Invalid reload entered.", $url, $limit, $reload));
return FALSE;
+ } elseif ('' . ($waiting + 0) . '' != '' . $waiting . '') {
+ // Invalid amount entered
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,waiting=%s: Invalid waiting entered.", $url, $limit, $waiting));
+ return FALSE;
}
// Register the new URL
- return doSurfbarRegisterUrl($url, 0, 'ACTIVE', 'unlock', array('limit' => $limit, 'reload' => $reload));
+ return doSurfbarRegisterUrl($url, 0, 'ACTIVE', 'unlock', array('limit' => $limit, 'reload' => $reload, 'waiting' => $waiting));
}
// Admin unlocked an email so we can migrate the URL
// Is this a member?
if (!isMember()) {
// No member!
- /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: isMember()=false');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: isMember()=false');
return FALSE;
} elseif ((!isset($formData['url_id'])) || (!isset($formData['action']))) {
// Important form elements are missing!
- /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Invalid form data, required field id/action not found');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Invalid form data, required field id/action not found');
return FALSE;
} elseif (!isset($urlArray[$formData['url_id']])) {
// Id not found in cache
- /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Field url_id not found in cache');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Field url_id not found in cache');
return FALSE;
} elseif (!isSurfbarMemberActionStatusValid($formData['action'], $urlArray[$formData['url_id']]['url_status'])) {
// Action not allowed for current URL status
- /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Action not allowed to perform. action=' . $formData['action'] . ',url_status=' . $urlArray[$formData['url_id']]['url_status'] . ',url_id=' . $formData['url_id']);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Action not allowed to perform. action=' . $formData['action'] . ',url_status=' . $urlArray[$formData['url_id']]['url_status'] . ',url_id=' . $formData['url_id']);
return FALSE;
}
// Is the function there?
if (function_exists($functionName)) {
+ // Load data and add it to globals array
+ $urlData = getSurfbarUrlData($formData['url_id']);
+ $GLOBALS['surfbar_cache'] = merge_array($GLOBALS['surfbar_cache'], $urlData[$formData['url_id']]);
+
// Add new status
- $urlArray[$formData['url_id']]['new_status'] = gerSurfbarNewStatus('new_status');
+ $urlArray[$formData['url_id']]['new_status'] = getSurfbarNewStatus('new_status');
// Extract URL data for call-back
$urlData = array(merge_array($urlArray[$formData['url_id']], array($action => $formData)));
}
// Getter for surfbar_actions table by given id number
-function getSurfbarActionsDataById ($columnName, $id) {
+function getSurfbarActionsDataFromId ($columnName, $id) {
// Is cache set?
if (!isset($GLOBALS[__FUNCTION__][$id][$columnName])) {
// Default is not found
$GLOBALS[__FUNCTION__][$id][$columnName] = '*INVALID*';
// Search for it
- $result = SQL_QUERY_ESC("SELECT `%s` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `%s` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_id`=%s LIMIT 1",
array(
$columnName,
bigintval($id)
), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load it
- list($GLOBALS[__FUNCTION__][$id][$columnName]) = SQL_FETCHROW($result);
+ list($GLOBALS[__FUNCTION__][$id][$columnName]) = sqlFetchRow($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return value
// Validate if the requested action can be performed on current URL status
function isSurfbarMemberActionStatusValid ($action, $status) {
// Search for the requested action/status combination in database
- $result = SQL_QUERY_ESC("SELECT `actions_new_status` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_action`='%s' AND `actions_status`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `actions_new_status` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_action`='%s' AND `actions_status`='%s' LIMIT 1",
array(
strtoupper($action),
strtoupper($status)
), __FUNCTION__, __LINE__);
// Is the entry there?
- $isValid = (SQL_NUMROWS($result) == 1);
+ $isValid = (sqlNumRows($result) == 1);
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'action=' . $action . ',status=' . $status . ',isValid=' . intval($isValid));
// Fetch the new status if found
if ($isValid === TRUE) {
// Load new status
- list($GLOBALS['surfbar_cache']['new_status']) = SQL_FETCHROW($result);
+ list($GLOBALS['surfbar_cache']['new_status']) = sqlFetchRow($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return status
return $isValid;
// Fix missing entry for template
$urlData['edit'] = $urlData['unpause'];
$urlData['edit']['url'] = $urlData['url'];
- $urlData['edit']['limit'] = gerSurfbarViewsMax();
+ $urlData['edit']['limit'] = getSurfbarViewsMax();
// Return status change
return changeSurfbarUrlStatus($urlData['url_id'], $urlData['url_status'], $urlData['new_status'], array($urlData['url_id'] => $urlData));
// Display selected "action form"
function displaySurfbarMemberActionForm ($action, $urlData) {
// Translate some data if present
- $content = prepareSurfbarContentForTemplate($content);
+ $content = prepareSurfbarContentForTemplate($urlData);
// Include fields only for action 'edit'
if ($action == 'edit') {
$urlData['limited'] = 'false';
// Is this URL limited?
- if (gerSurfbarViewsMax() > 0) {
+ if (getSurfbarViewsMax() > 0) {
// Then rewrite form data
$urlData['limited_yes'] = ' checked="checked"';
$urlData['limited_no'] = '';
// Has the URL or limit changed?
if (TRUE) {
- //if (($urlData['url_views_allowed'] != $urlData['edit']['limit']) || ($url1 != $url2)) {
+ // @TODO if (($urlData['url_views_allowed'] != $urlData['edit']['limit']) || ($url1 != $url2)) {
// Run the query
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_surfbar_urls`
SET
`url`='%s',
`url_views_max`=%s
WHERE
`url_id`=%s AND
- `status`='%s'
+ `url_status`='%s'
LIMIT 1",
array(
$urlData['url'],
// Handle URLs which limit has depleted
function doHandleSurfbarDepletedViews () {
// Get all URLs
- $urlArray = getSurfbarUrlData(0, 'url_views_max', 'url_id', 'ASC', 'url_id', " AND `url_views_allowed` > 0 AND `url_status`='ACTIVE'");
+ $urlArray = getSurfbarUrlData('0', 'url_views_max', 'url_id', 'ASC', 'url_id', " AND `url_views_allowed` > 0 AND `url_status`='ACTIVE'");
// Are there some entries?
if (count($urlArray) > 0) {
doSurfbarNotifyMember('low_points', $content);
// Update last notified
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `surfbar_low_notified`=NOW() WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `surfbar_low_notified`=NOW() WHERE `userid`=%s LIMIT 1",
array($userid), __FUNCTION__, __LINE__);
} // END - if
} // END - foreach
// If the column is 'url_id' there can be only one entry
$limit = '';
if ($column == 'url_id') {
- $limit = "LIMIT 1";
+ $limit = 'LIMIT 1';
} // END - if
// Look up the record
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`url_id`,
`url_userid`,
+ `url_package_id`,
`url`,
`url_views_total`,
`url_views_max`,
`url_lock_reason`,
`url_views_max`,
`url_views_allowed`,
- `url_fixed_reload`
+ `url_fixed_reload`,
+ `url_fixed_waiting`
FROM
`{?_MYSQL_PREFIX?}_surfbar_urls`
WHERE
), __FUNCTION__, __LINE__);
// Is there at least one record?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Then load all!
- while ($dataRow = SQL_FETCHARRAY($result)) {
+ while ($dataRow = sqlFetchArray($result)) {
// Shall we group these results?
if ($group == 'url_id') {
// Add the row by id as index
} // END - if
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return the result
return $GLOBALS['last_url_data'];
if (!isset($content['reload'])) {
$content['reload'] = '0';
} // END - if
+ if (!isset($content['waiting'])) {
+ $content['waiting'] = '0';
+ } // END - if
// Insert the URL into database
$content['insert_id'] = insertSurfbarUrlByArray($content);
} // END - if
// Just run the insert query for now
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_urls` (`url_userid`, `url`, `url_status`, `url_views_max`, `url_views_allowed`, `url_fixed_reload`) VALUES (%s,'%s','%s',%s,%s,%s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_urls` (`url_userid`, `url`, `url_status`, `url_views_max`, `url_views_allowed`, `url_fixed_reload`, `url_fixed_waiting`) VALUES (%s, '%s', '%s', %s, %s, %s, %s)",
array(
$userid,
$urlData['url'],
$urlData['url_status'],
$urlData['limit'],
$urlData['limit'],
- $urlData['reload']
+ $urlData['reload'],
+ $urlData['waiting']
), __FUNCTION__, __LINE__
);
- // Return insert id
- return SQL_INSERTID();
+ // Return secured insert id
+ return getSqlInsertId();
}
// Notify admin(s) with a selected message and content
// Determine reward
function determineSurfbarReward ($onlyMin = FALSE) {
// Static values are default
- $reward = getConfig('surfbar_static_reward');
+ $reward = getSurfbarStaticReward();
// Is there static or dynamic?
if (getSurfbarPaymentModel() == 'DYNAMIC') {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'surf_lock=' . $GLOBALS['surfbar_cache']['surf_lock'] . ' - AFTER');
// Ask the database
- $result = SQL_QUERY_ESC("SELECT
- COUNT(l.`locks_id`) AS `cnt`
+ $result = sqlQueryEscaped("SELECT
+ COUNT(`l`.`locks_id`) AS `cnt`
FROM
- `{?_MYSQL_PREFIX?}_surfbar_locks` AS l
+ `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
INNER JOIN
- `{?_MYSQL_PREFIX?}_surfbar_urls` AS u
+ `{?_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() - {%%pipe,gerSurfbarSurfLock%%}) < UNIX_TIMESTAMP(l.`locks_last_surfed`) AND
+ `l`.`locks_userid`=%s AND
+ (UNIX_TIMESTAMP() - {%%pipe,getSurfbarSurfLock%%}) < 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__
);
// Fetch row
- list($GLOBALS['surfbar_cache']['user_locks']) = SQL_FETCHROW($result);
+ list($GLOBALS['surfbar_cache']['user_locks']) = sqlFetchRow($result);
// Is it null?
if (is_null($GLOBALS['surfbar_cache']['user_locks'])) {
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Get total URLs
$total = getSurfbarTotalUrls();
$isFull = ((getSurfbarUserLocks() == $total) && ($total > 0));
// Return result
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userLocks=' . getSurfbarUserLocks() . ',total=' . $total . 'isFull=' . intval($isFull) . ' - EXIT!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userLocks=' . getSurfbarUserLocks() . ',total=' . $total . ',isFull=' . intval($isFull) . ' - EXIT!');
return $isFull;
}
} // END - if
// Is the exlude userid set?
- if (isValidUserId($excludeUserId)) {
+ if (isValidId($excludeUserId)) {
// Then add it
$userids['url_userid'][$excludeUserId] = $excludeUserId;
} // END - if
// Get amount from database
- $result = SQL_QUERY_ESC("SELECT
- COUNT(`url_id`) AS cnt
+ $result = sqlQueryEscaped("SELECT
+ COUNT(`url_id`) AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_surfbar_urls`
WHERE
- (`url_userid` NOT IN (".implode(', ', $userids['url_userid']).") OR `url_userid` IS NULL) AND
+ (`url_userid` NOT IN (" . implode(', ', $userids['url_userid']) . ") OR `url_userid` IS NULL) AND
`url_status`='%s'
LIMIT 1",
array($status), __FUNCTION__, __LINE__
);
// Fetch row
- list($count) = SQL_FETCHROW($result);
+ list($count) = sqlFetchRow($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $count . ' - EXIT!');
if (empty($salt)) {
// Generate random hashed string
$GLOBALS['surfbar_cache']['salt'] = sha1(generatePassword(mt_rand(200, 255)));
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newSalt='.gerSurfbarSalt().'', FALSE);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newSalt='.getSurfbarSalt().'', FALSE);
} else {
// Use this as salt!
$GLOBALS['surfbar_cache']['salt'] = $salt;
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'oldSalt='.gerSurfbarSalt().'', FALSE);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'oldSalt='.getSurfbarSalt().'', FALSE);
}
// Hash it with md5() and salt it with the random string
- $hashedCode = generateHash(md5($urlId . getEncryptSeparator() . getMemberId()), gerSurfbarSalt());
+ $hashedCode = generateHash(md5($urlId . getEncryptSeparator() . getMemberId()), getSurfbarSalt());
// Finally encrypt it PGP-like and return it
$valHashedCode = encodeHashForCookie($hashedCode);
// Is there no record?
if ($countLock == 0) {
// Just add it to the database
- SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)',
+ sqlQueryEscaped('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)',
array(
getMemberId(),
bigintval($urlId)
} // END - if
// Remove the salt from database
- SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_surfbar_salts` WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1',
+ sqlQueryEscaped('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_surfbar_salts` WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1',
array(
bigintval($urlId),
getMemberId()
), __FUNCTION__, __LINE__);
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',getMemberId()=' . getMemberId() . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS() . ' - EXIT!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',getMemberId()=' . getMemberId() . ',sqlAffectedRows()=' . sqlAffectedRows() . ' - EXIT!');
}
// Pay points to the user and remove it from the sender if userid is given else it is a "sponsored surf"
function doSurfbarPayPoints () {
// Remove it from the URL owner
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.gerSurfbarUserid().',costs='.gerSurfbarCosts() . ' - ENTERED!');
- if (isValidUserId(gerSurfbarUserid())) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getSurfbarUserid().',costs='.getSurfbarCosts() . ' - ENTERED!');
+ if (isValidId(getSurfbarUserid())) {
// Subtract points and ignore return status
- subtractPoints(sprintf("surfbar_%s", getSurfbarPaymentModel()), gerSurfbarUserid(), gerSurfbarCosts());
+ subtractPoints(sprintf("surfbar_%s", getSurfbarPaymentModel()), getSurfbarUserid(), getSurfbarCosts());
} // END - if
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.gerSurfbarReward());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.getSurfbarReward());
// Init referral system here
initReferralSystem();
// Book it to the user and ignore return status
- addPointsThroughReferralSystem(sprintf("surfbar:%s", getSurfbarPaymentModel()), getMemberId(), gerSurfbarReward());
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.gerSurfbarUserid().',costs='.gerSurfbarCosts() . ' - EXIT!');
+ addPointsThroughReferralSystem(sprintf("surfbar:%s", getSurfbarPaymentModel()), getMemberId(), getSurfbarReward());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getSurfbarUserid().',costs='.getSurfbarCosts() . ' - EXIT!');
}
// Updates the statistics of current URL/userid
$add = '';
// Get allowed views
- $allowed = gerSurfbarViewsAllowed();
+ $allowed = getSurfbarViewsAllowed();
// Is there a limit?
if ($allowed > 0) {
} // END - if
// Update URL stats
- SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `url_views_total`=`url_views_total`+1' . $add . ' WHERE `url_id`=%s LIMIT 1',
- array(gerSurfbarId()), __FUNCTION__, __LINE__);
+ sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `url_views_total`=`url_views_total`+1' . $add . ' WHERE `url_id`=%s LIMIT 1',
+ array(getSurfbarId()), __FUNCTION__, __LINE__);
// Update the stats entry
- SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_surfbar_stats` SET `stats_count`=`stats_count`+1 WHERE `stats_userid`=%s AND `stats_url_id`=%s LIMIT 1',
+ sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_surfbar_stats` SET `stats_count`=`stats_count`+1 WHERE `stats_userid`=%s AND `stats_url_id`=%s LIMIT 1',
array(
getMemberId(),
- gerSurfbarId()
+ getSurfbarId()
), __FUNCTION__, __LINE__);
// Was that update okay?
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// No, then insert entry
- SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`, `stats_url_id`, `stats_count`) VALUES (%s,%s,1)',
+ sqlQueryEscaped('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`, `stats_url_id`, `stats_count`) VALUES (%s,%s,1)',
array(
getMemberId(),
- gerSurfbarId()
+ getSurfbarId()
), __FUNCTION__, __LINE__);
} // END - if
// Update the salt for validation and statistics
function updateSurfbarSaltStatistics () {
// Update salt
- generateSurfbarValidationCode(gerSurfbarId());
+ generateSurfbarValidationCode(getSurfbarId());
// Make sure only valid salts can pass
- if (gerSurfbarSalt() == 'INVALID') {
+ if (getSurfbarSalt() == 'INVALID') {
// Invalid provided
- reportBug(__FUNCTION__, __LINE__, 'Invalid salt provided, id=' . gerSurfbarId() . ',getMemberId()=' . getMemberId());
+ reportBug(__FUNCTION__, __LINE__, 'Invalid salt provided, id=' . getSurfbarId() . ',getMemberId()=' . getMemberId());
} // END - if
// Update statistics record
updateInsertSurfbarStatisticsRecord();
// Simply store the salt from cache away in database...
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_salts` SET `salts_last_salt`='%s' WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1",
- array(
- gerSurfbarSalt(),
- gerSurfbarId(),
- getMemberId()
- ), __FUNCTION__, __LINE__);
+ sqlQuery("UPDATE
+ `{?_MYSQL_PREFIX?}_surfbar_salts`
+SET
+ `salts_last_salt`='{%pipe,getSurfbarSalt%}'
+WHERE
+ `salts_url_id`={%pipe,getSurfbarId%} AND
+ `salts_userid`={%pipe,getMemberId%}
+LIMIT 1", __FUNCTION__, __LINE__);
// Debug message
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt=' . gerSurfbarSalt() . ',id=' . gerSurfbarId() . ',userid=' . getMemberId() . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS() . ' - UPDATE!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt=' . getSurfbarSalt() . ',id=' . getSurfbarId() . ',userid=' . getMemberId() . ',sqlAffectedRows()=' . sqlAffectedRows() . ' - UPDATE!');
// Was that okay?
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// 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(
- gerSurfbarId(),
- getMemberId(),
- gerSurfbarSalt()
- ), __FUNCTION__, __LINE__);
+ sqlQuery("INSERT INTO
+ `{?_MYSQL_PREFIX?}_surfbar_salts`
+(
+ `salts_url_id`,
+ `salts_userid`,
+ `salts_last_salt`
+) VALUES (
+ {%pipe,getSurfbarId%},
+ {%pipe,getMemberId%},
+ '{%pipe,getSurfbarSalt%}'
+)", __FUNCTION__, __LINE__);
} // END - if
// Debug message
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'affectedRows=' . SQL_AFFECTEDROWS() . ' - EXIT!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'affectedRows=' . sqlAffectedRows() . ' - EXIT!');
// Return if the update was okay
- return (!SQL_HASZEROAFFECTED());
+ return (!ifSqlHasZeroAffectedRows());
}
// Check if the reload lock is active for given id
function ifSurfbarReloadLock ($urlId) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $urlId . ' - ENTERED!');
// Ask the database
- $result = SQL_QUERY_ESC("SELECT COUNT(`locks_id`) AS cnt
+ $result = sqlQueryEscaped('SELECT COUNT(`locks_id`) AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_surfbar_locks`
WHERE
`locks_userid`=%s AND
`locks_url_id`=%s AND
- (UNIX_TIMESTAMP() - ".gerSurfbarSurfLock().") < UNIX_TIMESTAMP(`locks_last_surfed`)
+ (UNIX_TIMESTAMP() - {%%pipe,getSurfbarSurfLock%%}) < UNIX_TIMESTAMP(`locks_last_surfed`)
ORDER BY
`locks_last_surfed` ASC
-LIMIT 1",
+LIMIT 1',
array(getMemberId(), bigintval($urlId)), __FUNCTION__, __LINE__
);
// Fetch counter
- list($count) = SQL_FETCHROW($result);
+ list($count) = sqlFetchRow($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return check
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',count=' . $count . ',gerSurfbarSurfLock()=' . gerSurfbarSurfLock() . ' - EXIT!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',count=' . $count . ',getSurfbarSurfLock()=' . getSurfbarSurfLock() . ' - EXIT!');
return ($count == 1);
}
$userids['notified'][getMemberId()] = '0';
// Get all userid except logged in one
- $result = SQL_QUERY_ESC("SELECT
- u.url_userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
+ $result = sqlQueryEscaped("SELECT
+ `u`.`url_userid`,
+ UNIX_TIMESTAMP(`d`.`surfbar_low_notified`) AS `notified`
FROM
- `{?_MYSQL_PREFIX?}_surfbar_urls` AS u
+ `{?_MYSQL_PREFIX?}_surfbar_urls` AS `u`
INNER JOIN
- `{?_MYSQL_PREFIX?}_user_data` AS d
+ `{?_MYSQL_PREFIX?}_user_data` AS `d`
ON
- u.`url_userid`=d.`userid`
+ `u`.`url_userid`=`d`.`userid`
WHERE
- u.`url_userid` NOT IN (%s) AND
- u.`url_userid` IS NOT NULL AND
- u.`url_status`='ACTIVE'
+ `u`.`url_userid` NOT IN (%s) AND
+ `u`.`url_userid` IS NOT NULL AND
+ `u`.`url_status`='ACTIVE'
GROUP BY
- u.`url_userid`
+ `u`.`url_userid`
ORDER BY
- u.`url_userid` ASC",
+ `u`.`url_userid` ASC",
array(getMemberId()), __FUNCTION__, __LINE__);
} else {
// Get all userid
- $result = SQL_QUERY("SELECT
- u.url_userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
+ $result = sqlQuery("SELECT
+ `u`.`url_userid`,
+ UNIX_TIMESTAMP(`d`.`surfbar_low_notified`) AS `notified`
FROM
- `{?_MYSQL_PREFIX?}_surfbar_urls` AS u
+ `{?_MYSQL_PREFIX?}_surfbar_urls` AS `u`
INNER JOIN
- `{?_MYSQL_PREFIX?}_user_data` AS d
+ `{?_MYSQL_PREFIX?}_user_data` AS `d`
ON
- u.`url_userid`=d.`userid`
+ `u`.`url_userid`=`d`.`userid`
WHERE
- u.`url_userid` > 0 AND
- u.`url_status`='ACTIVE'
+ `u`.`url_userid` > 0 AND
+ `u`.`url_status`='ACTIVE'
GROUP BY
- u.`url_userid`
+ `u`.`url_userid`
ORDER BY
- u.`url_userid` ASC", __FUNCTION__, __LINE__);
+ `u`.`url_userid` ASC", __FUNCTION__, __LINE__);
}
// Load all userid
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Get total points
$points = getTotalPoints($content['url_userid']);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $content['url_userid'] . ',points=' . $points);
} // END - while
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UIDs::count=' . count($userids) . ' (with own userid=' . getMemberId() . ')');
// Determine how many users are Online in surfbar
function determineSurfbarTotalOnline () {
// Count all users in surfbar modue and return the value
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`stats_id`
FROM
`{?_MYSQL_PREFIX?}_surfbar_stats`
`stats_userid` ASC', __FUNCTION__, __LINE__);
// Fetch count
- $count = SQL_NUMROWS($result);
+ $count = sqlNumRows($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $count;
// Determine waiting time for one URL
function determineSurfbarWaitingTime () {
// Get fixed reload lock
- $fixed = getSurfbarFixedReload();
+ $fixed = getSurfbarFixedWaitingTime();
- // Is the fixed reload time set?
+ // Is the URL's fixed waiting time set?
if ($fixed > 0) {
// Return it
return $fixed;
} // END - if
// Static time is default
- $time = getConfig('surfbar_static_time');
+ $time = getSurfbarStaticTime();
// Which payment model do we have?
if (getSurfbarPaymentModel() == 'DYNAMIC') {
} // END - if
// Prepare array
- $filterData = array(
+ $filterData = array(
'url_id' => $urlId,
'prev_status' => $prevStatus,
'new_status' => $newStatus,
// Update the status now
// ---------- Comment out for debugging/developing member actions! ---------
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `url_status`='%s' WHERE `url_id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `url_status`='%s' WHERE `url_id`=%s LIMIT 1",
array(
$newStatus,
bigintval($urlId)
// Was that fine?
// ---------- Comment out for debugging/developing member actions! ---------
- if (SQL_AFFECTEDROWS() != 1) {
+ if (sqlAffectedRows() != 1) {
// No, something went wrong
return FALSE;
} // END - if
$ignored = array();
// Get all id from locks within the timestamp
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`locks_id`,
`locks_url_id`,
UNIX_TIMESTAMP(`locks_last_surfed`) AS `last_surfed`
__FUNCTION__, __LINE__);
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Debug message
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'next - lid='.$content['locks_id'].',url='.$content['locks_url_id'].',rest='.(time() - $content['last_surfed']).'/'.gerSurfbarSurfLock());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'next - lid='.$content['locks_id'].',url='.$content['locks_url_id'].',rest='.(time() - $content['last_surfed']).'/'.getSurfbarSurfLock());
// Skip entries that are too old
- if (($content['last_surfed'] > (time() - gerSurfbarSurfLock())) && (!in_array($content['locks_url_id'], $ignored))) {
+ if (($content['last_surfed'] > (time() - getSurfbarSurfLock())) && (!in_array($content['locks_url_id'], $ignored))) {
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'okay - lid='.$content['locks_id'].',url='.$content['locks_url_id'].',last='.$content['last_surfed']);
} // END - while
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return array
return $USE;
// "Getter" for maximum random number
function getSurfbarMaximumRandom ($userids, $add) {
// Count max availabe entries
- $result = SQL_QUERY("SELECT
- sbu.url_id AS cnt
+ $result = sqlQuery("SELECT
+ `sbu`.`url_id` AS `cnt`
FROM
- `{?_MYSQL_PREFIX?}_surfbar_urls` AS sbu
+ `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_surfbar_salts` AS sbs
+ `{?_MYSQL_PREFIX?}_surfbar_salts` AS `sbs`
ON
- sbu.url_id=sbs.salts_url_id
+ `sbu`.`url_id`=`sbs`.`salts_url_id`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_surfbar_locks` AS l
+ `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
ON
- sbu.url_id=l.locks_url_id
+ `sbu`.`url_id`=`l`.`locks_url_id`
WHERE
- 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'
+ `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 . "
GROUP BY
- sbu.url_id ASC", __FUNCTION__, __LINE__);
+ `sbu`.`url_id` ASC", __FUNCTION__, __LINE__);
// Log last query
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.sqlNumRows($result).'|Affected='.sqlAffectedRows());
// Fetch max rand
- $maxRand = SQL_NUMROWS($result);
+ $maxRand = sqlNumRows($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return value
return $maxRand;
$urlArray = array();
// Begin the query
- $result = SQL_QUERY_ESC("SELECT
- u.`url_id`,
- u.`url_userid`,
- u.`url`,
- u.`url_status`,
- u.`url_views_total`,
- u.`url_views_max`,
- u.`url_views_allowed`,
- UNIX_TIMESTAMP(u.`url_registered`) AS `url_registered`,
- UNIX_TIMESTAMP(u.`url_last_locked`) AS `url_last_locked`,
- u.`url_lock_reason`
+ $result = sqlQueryEscaped("SELECT
+ `u`.`url_id`,
+ `u`.`url_userid`,
+ `u`.`url_package_id`,
+ `u`.`url`,
+ `u`.`url_status`,
+ `u`.`url_views_total`,
+ `u`.`url_views_max`,
+ `u`.`url_views_allowed`,
+ UNIX_TIMESTAMP(`u`.`url_registered`) AS `url_registered`,
+ UNIX_TIMESTAMP(`u`.`url_last_locked`) AS `url_last_locked`,
+ `u`.`url_lock_reason`
FROM
- `{?_MYSQL_PREFIX?}_surfbar_urls` AS u
+ `{?_MYSQL_PREFIX?}_surfbar_urls` AS `u`
WHERE
- u.`url_userid`=%s AND
- u.`url_status` != 'DELETED'
+ `u`.`url_userid`=%s AND
+ `u`.`url_status` != 'DELETED'
ORDER BY
- u.`url_id` ASC",
+ `u`.`url_id` ASC",
array(getMemberId()), __FUNCTION__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all rows
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Add the row
$urlArray[$row['url_id']] = $row;
} // END - while
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return the array
return $urlArray;
$returnArray = array();
// Get all assigned actions
- $result = SQL_QUERY_ESC("SELECT `actions_action` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_status`='%s' ORDER BY `actions_id` ASC",
+ $result = sqlQueryEscaped("SELECT `actions_action` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_status`='%s' ORDER BY `actions_id` ASC",
array($status), __FUNCTION__, __LINE__);
// Some entries there?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all actions
// @TODO This can be somehow rewritten
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
array_push($returnArray, $content['actions_action']);
} // END - if
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $returnArray;
$add = '';
if (count($USE) > 0) {
// Ignore some!
- $add = " AND sbu.`url_id` NOT IN (";
+ $add = " AND `sbu`.`url_id` NOT IN (";
foreach ($USE as $url_id => $lid) {
// Add URL id
$add .= $url_id.',';
} // END - if
// And query the database
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'randNum='.$randNum.',maxRand='.$maxRand.',surfLock='.gerSurfbarSurfLock());
- $result = SQL_QUERY_ESC("SELECT
- sbu.url_id,
- sbu.url_userid,
- sbu.url,
- sbs.salts_last_salt,
- sbu.url_views_total,
- sbu.url_views_max,
- sbu.url_views_allowed,
- UNIX_TIMESTAMP(l.locks_last_surfed) AS last_surfed,
- sbu.url_fixed_reload
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'randNum='.$randNum.',maxRand='.$maxRand.',surfLock='.getSurfbarSurfLock());
+ $result = sqlQueryEscaped("SELECT
+ `sbu`.`url_id`,
+ `sbu`.`url_userid`,
+ `sbu`.`url_package_id`,
+ `sbu`.`url`,
+ `sbs`.`salts_last_salt`,
+ `sbu`.`url_views_total`,
+ `sbu`.`url_views_max`,
+ `sbu`.`url_views_allowed`,
+ UNIX_TIMESTAMP(`l`.`locks_last_surfed`) AS `last_surfed`,
+ `sbu`.`url_fixed_reload`
FROM
- `{?_MYSQL_PREFIX?}_surfbar_urls` AS sbu
+ `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_surfbar_salts` AS sbs
+ `{?_MYSQL_PREFIX?}_surfbar_salts` AS `sbs`
ON
- sbu.url_id=sbs.salts_url_id
+ `sbu`.`url_id`=`sbs`.`salts_url_id`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_surfbar_locks` AS l
+ `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
ON
- sbu.url_id=l.locks_url_id
+ `sbu`.`url_id`=`l`.`locks_url_id`
WHERE
- (sbu.`url_userid` NOT IN (".implode(',', $userids['url_userid']).") OR sbu.`url_userid` IS NULL) AND
- sbu.url_status='ACTIVE' AND
- (sbu.url_views_allowed=0 OR (sbu.url_views_allowed > 0 AND sbu.url_views_max > 0))
- ".$add."
+ (`sbu`.`url_userid` NOT IN (" . implode(',', $userids['url_userid']) . ") OR `sbu`.`url_userid` IS NULL) AND
+ `sbu`.`url_status`='ACTIVE' AND
+ (`sbu`.`url_views_allowed`=0 OR (`sbu`.`url_views_allowed` > 0 AND `sbu`.`url_views_max` > 0))
+ " . $add . "
GROUP BY
- sbu.`url_id`
+ `sbu`.`url_id`
ORDER BY
- l.locks_last_surfed ASC,
- sbu.url_id ASC
+ `l`.`locks_last_surfed` ASC,
+ `sbu`.`url_id` ASC
LIMIT %s,1",
array($randNum), __FUNCTION__, __LINE__
);
} else {
// Get data from specified id number
- $result = SQL_QUERY_ESC("SELECT
- sbu.url_id,
- sbu.url_userid,
- sbu.url,
- sbs.salts_last_salt,
- sbu.url_views_total,
- sbu.url_views_max,
- sbu.url_views_allowed,
- UNIX_TIMESTAMP(l.locks_last_surfed) AS last_surfed,
- sbu.url_fixed_reload
+ $result = sqlQueryEscaped("SELECT
+ `sbu`.`url_id`,
+ `sbu`.`url_userid`,
+ `sbu`.`url_package_id`,
+ `sbu`.`url`,
+ `sbs`.`salts_last_salt`,
+ `sbu`.`url_views_total`,
+ `sbu`.`url_views_max`,
+ `sbu`.`url_views_allowed`,
+ UNIX_TIMESTAMP(`l`.`locks_last_surfed`) AS `last_surfed`,
+ `sbu`.`url_fixed_reload`
FROM
- `{?_MYSQL_PREFIX?}_surfbar_urls` AS sbu
+ `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_surfbar_salts` AS sbs
+ `{?_MYSQL_PREFIX?}_surfbar_salts` AS `sbs`
ON
- sbu.url_id=sbs.salts_url_id
+ `sbu`.`url_id`=`sbs`.`salts_url_id`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_surfbar_locks` AS l
+ `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
ON
- sbu.url_id=l.locks_url_id
+ `sbu`.`url_id`=`l`.`locks_url_id`
WHERE
- (sbu.url_userid != %s OR sbu.url_userid IS NULL) AND
- sbu.url_status='ACTIVE' AND
- sbu.url_id=%s AND
- (sbu.url_views_allowed=0 OR (sbu.url_views_allowed > 0 AND sbu.url_views_max > 0))
+ (`sbu`.`url_userid` != %s OR `sbu`.`url_userid` IS NULL) AND
+ `sbu`.`url_status`='ACTIVE' AND
+ `sbu`.`url_id`=%s AND
+ (`sbu`.`url_views_allowed` = 0 OR (`sbu`.`url_views_allowed` > 0 AND `sbu`.`url_views_max` > 0))
LIMIT 1",
array(getMemberId(), bigintval($urlId)), __FUNCTION__, __LINE__
);
}
// Is there an id number?
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS());
- if (SQL_NUMROWS($result) == 1) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.sqlNumRows($result).'|Affected='.sqlAffectedRows());
+ if (sqlNumRows($result) == 1) {
// Load/cache data
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - BEFORE', FALSE);
- $GLOBALS['surfbar_cache'] = merge_array($GLOBALS['surfbar_cache'], SQL_FETCHARRAY($result));
+ $GLOBALS['surfbar_cache'] = merge_array($GLOBALS['surfbar_cache'], sqlFetchArray($result));
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - AFTER', FALSE);
// Determine waiting time
- $GLOBALS['surfbar_cache']['time'] = determineSurfbarWaitingTime();
+ $GLOBALS['surfbar_cache']['waiting'] = determineSurfbarWaitingTime();
// Is the last salt there?
if (is_null($GLOBALS['surfbar_cache']['salts_last_salt'])) {
// Get base/fixed reward and costs
$GLOBALS['surfbar_cache']['reward'] = determineSurfbarReward();
$GLOBALS['surfbar_cache']['costs'] = determineSurfbarCosts();
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'BASE/STATIC - reward='.gerSurfbarReward().'|costs='.gerSurfbarCosts());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'BASE/STATIC - reward='.getSurfbarReward().'|costs='.getSurfbarCosts());
// Only in dynamic model add the dynamic bonus!
if (getSurfbarPaymentModel() == 'DYNAMIC') {
// Calculate dynamic reward/costs and add it
$GLOBALS['surfbar_cache']['reward'] += calculateSurfbarDynamicAddValue();
$GLOBALS['surfbar_cache']['costs'] += calculateSurfbarDynamicAddValue();
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'DYNAMIC+ - reward='.gerSurfbarReward().'|costs='.gerSurfbarCosts());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'DYNAMIC+ - reward='.getSurfbarReward().'|costs='.getSurfbarCosts());
} // END - if
// Now get the id
- $nextId = gerSurfbarId();
+ $nextId = getSurfbarId();
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',nextId=' . $nextId . ' - EXIT!');
return $nextId;
}
+// Generates an URL to the given booking package
+function generateSurfbarPackageLink ($packageId) {
+ // Base URL
+ $url = '{%url=modules.php?module=admin&what=list_surfbar_packages';
+
+ // Is package id given?
+ if (isValidId($packageId)) {
+ // Then add it
+ $url .= '&package_id=' . bigintval($packageId);
+ } // END - if
+
+ // Finish URL EL code
+ $url .= '%}';
+
+ // Return it
+ return $url;
+}
+
//-----------------------------------------------------------------------------
// Wrapper function
//-----------------------------------------------------------------------------
return $GLOBALS[__FUNCTION__];
}
+// "Getter" for surfbar_restart_time
+function getSurfbarRestartTime () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_restart_time');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for surfbar_auto_start
+function getSurfbarAutoStart () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_auto_start');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether auto-start is enabled
+function isSurfbarAutoStartEnabled () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = (getSurfbarAutoStart() == 'Y');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for surfbar_daily_counter
+function getSurfbarDailyCounter () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_daily_counter');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for surfbar_yester_counter
+function getSurfbarYesterCounter () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_yester_counter');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for surfbar_weekly_counter
+function getSurfbarWeeklyCounter () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_weekly_counter');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for surfbar_monthly_counter
+function getSurfbarMonthlyCounter () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_monthly_counter');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for surfbar_total_counter
+function getSurfbarTotalCounter () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_total_counter');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
//------------------------------------------------------------------------------
// Template helper functions
//------------------------------------------------------------------------------
// Private getter for data elements
function getSurfbarData ($element) {
+ // Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ' - ENTERED!');
// Default is null
$data = NULL;
// Is the entry there?
- if ((isset($GLOBALS['surfbar_cache'][$element])) || (is_null($GLOBALS['surfbar_cache'][$element]))) {
+ if (isset($GLOBALS['surfbar_cache'][$element])) {
// Then take it
$data = $GLOBALS['surfbar_cache'][$element];
- } else { // END - if
- print('surfbar_cache=<pre>');
- print_r($GLOBALS['surfbar_cache']);
- print('</pre>');
- reportBug(__FUNCTION__, __LINE__, 'Element ' . $element . ' not found.');
- }
+ } // END - if
// Return result
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element[' . $element . ']=[' . gettype($data) . ']' . $data . ' - EXIT!');
}
// Getter for reward from cache
-function gerSurfbarReward () {
+function getSurfbarReward () {
// Get data element and return its contents
return getSurfbarData('reward');
}
// Getter for costs from cache
-function gerSurfbarCosts () {
+function getSurfbarCosts () {
// Get data element and return its contents
return getSurfbarData('costs');
}
// Getter for URL from cache
-function gerSurfbarUrl () {
+function getSurfbarUrl () {
// Get data element and return its contents
return getSurfbarData('url');
}
// Getter for salt from cache
-function gerSurfbarSalt () {
+function getSurfbarSalt () {
// Get data element and return its contents
return getSurfbarData('salt');
}
// Getter for id from cache
-function gerSurfbarId () {
+function getSurfbarId () {
// Get data element and return its contents
return getSurfbarData('url_id');
}
// Getter for userid from cache
-function gerSurfbarUserid () {
+function getSurfbarUserid () {
// Get data element and return its contents
return getSurfbarData('url_userid');
}
}
// Getter for reload time
-function gerSurfbarReloadTime () {
+function getSurfbarWaitingTime () {
// Get data element and return its contents
- return getSurfbarData('time');
+ return getSurfbarData('waiting');
}
// Getter for allowed views
-function gerSurfbarViewsAllowed () {
+function getSurfbarViewsAllowed () {
// Get data element and return its contents
return getSurfbarData('url_views_allowed');
}
// Getter for maximum views
-function gerSurfbarViewsMax () {
+function getSurfbarViewsMax () {
// Get data element and return its contents
return getSurfbarData('url_views_max');
}
return getSurfbarData('url_fixed_reload');
}
+// Getter for fixed waiting time
+function getSurfbarFixedWaitingTime () {
+ // Get data element and return its contents
+ return getSurfbarData('url_fixed_waiting');
+}
+
+// Getter for package id
+function getSurfbarPackageId () {
+ // Get data element and return its contents
+ return getSurfbarData('url_package_id');
+}
+
// Getter for surf lock
-function gerSurfbarSurfLock () {
+function getSurfbarSurfLock () {
// Get data element and return its contents
return getSurfbarData('surf_lock');
}
// Getter for new status
-function gerSurfbarNewStatus () {
+function getSurfbarNewStatus () {
// Get data element and return its contents
return getSurfbarData('new_status');
}
// Getter for last salt
-function gerSurfbarLastSalt () {
+function getSurfbarLastSalt () {
// Get data element and return its contents
return getSurfbarData('salts_last_salt');
}