$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;
if (TRUE) {
// @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',
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
} // END - if
// Look up the record
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`url_id`,
`url_userid`,
`url_package_id`,
), __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'];
} // 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`, `url_fixed_waiting`) VALUES (%s, '%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'],
);
// Return secured insert id
- return SQL_INSERT_ID();
+ return getSqlInsertId();
}
// Notify admin(s) with a selected message and content
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'surf_lock=' . $GLOBALS['surfbar_cache']['surf_lock'] . ' - AFTER');
// Ask the database
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
COUNT(`l`.`locks_id`) AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
);
// 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();
} // END - if
// Get amount from database
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
COUNT(`url_id`) AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_surfbar_urls`
);
// 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!');
// 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()
} // 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',
+ 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(),
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(),
getSurfbarId()
updateInsertSurfbarStatisticsRecord();
// Simply store the salt from cache away in database...
- SQL_QUERY("UPDATE
+ sqlQuery("UPDATE
`{?_MYSQL_PREFIX?}_surfbar_salts`
SET
`salts_last_salt`='{%pipe,getSurfbarSalt%}'
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt=' . getSurfbarSalt() . ',id=' . getSurfbarId() . ',userid=' . getMemberId() . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS() . ' - UPDATE!');
// Was that okay?
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// Insert missing entry!
- SQL_QUERY("INSERT INTO
+ sqlQuery("INSERT INTO
`{?_MYSQL_PREFIX?}_surfbar_salts`
(
`salts_url_id`,
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'affectedRows=' . SQL_AFFECTEDROWS() . ' - 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
);
// 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 . ',getSurfbarSurfLock()=' . getSurfbarSurfLock() . ' - EXIT!');
$userids['notified'][getMemberId()] = '0';
// Get all userid except logged in one
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`u`.`url_userid`,
UNIX_TIMESTAMP(`d`.`surfbar_low_notified`) AS `notified`
FROM
array(getMemberId()), __FUNCTION__, __LINE__);
} else {
// Get all userid
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`u`.`url_userid`,
UNIX_TIMESTAMP(`d`.`surfbar_low_notified`) AS `notified`
FROM
}
// 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;
// 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']).'/'.getSurfbarSurfLock());
} // 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
+ $result = sqlQuery("SELECT
`sbu`.`url_id` AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu`
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS());
// 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
+ $result = sqlQueryEscaped("SELECT
`u`.`url_id`,
`u`.`url_userid`,
`u`.`url_package_id`,
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;
// And query the database
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'randNum='.$randNum.',maxRand='.$maxRand.',surfLock='.getSurfbarSurfLock());
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`sbu`.`url_id`,
`sbu`.`url_userid`,
`sbu`.`url_package_id`,
);
} else {
// Get data from specified id number
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`sbu`.`url_id`,
`sbu`.`url_userid`,
`sbu`.`url_package_id`,
// 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) {
+ 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
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',nextId=' . $nextId . ' - EXIT!');