entfernten Angreifer theoretisch moeglich, SQL-Befehle einzuschleusen und auch
Attacken auf die Variable $PHP_SELF durchzufueheren. Seit Patch 486 und 487
(laden Sie sich am Besten immer die aktuellsten Patches herunter!) sind nun
-entsprechende Zeilen aus der inc/db/lib-mysql3.php (Funktion SQL_QUERY_ESC)
+entsprechende Zeilen aus der inc/db/lib-mysql3.php (Funktion sqlQueryEscaped)
entfernt und sollten nicht mehr angreifbar sein. Der generierten SQL-Befehl
wurde vor der Ausfuehrung nochmals "uebersetzt", also alle
sicherheitsgefaehrdenen Zeichen wieder eingebaut. Zudem existiert im Script
- Den gesamten HTML-Code auf XHTML portieren und mit http://validator.w3.org validieren
- Replace all HTTP_GET_VARS and HTTP_POST_VARS with _GET and _POST
-- Replace SQL_QUERY() command with SQL_QUERY_ESC() commands where ever it is
+- Replace sqlQuery() command with sqlQueryEscaped() commands where ever it is
needed to secure SQL queries.
- Secure ID numbers with bigintval()
- Secure other non-numberous data with sprintf() and later with new security
functions
-- Use the abstract function SQL_FREERESULT() wherever we transfer massive data
+- Use the abstract function sqlFreeResult() wherever we transfer massive data
from the database to free memory
entfernten Angreifer theoretisch moeglich, SQL-Befehle einzuschleusen und auch
Attacken auf die Variable $PHP_SELF durchzufueheren. Seit Patch 486 und 487
(laden Sie sich am Besten immer die aktuellsten Patches herunter!) sind nun
-entsprechende Zeilen aus der inc/db/lib-mysql3.php (Funktion SQL_QUERY_ESC)
+entsprechende Zeilen aus der inc/db/lib-mysql3.php (Funktion sqlQueryEscaped)
entfernt sollten nicht mehr angreifbar sein. Der generierten SQL-Befehl wurde
vor der Ausfuehrung nochmals "uebersetzt", also alle sicherheitsgefaehrdenen
Zeichen wieder eingebaut. Zudem existiert im Script
- Extend the documenation!
- Complete english language translation
-- Replace SQL_QUERY() command with SQL_QUERY_ESC() commands where ever it is
+- Replace sqlQuery() command with sqlQueryEscaped() commands where ever it is
needed to secure SQL queries.
-- Use the abstract function SQL_FREERESULT() wherever we trasnfer massive data
+- Use the abstract function sqlFreeResult() wherever we trasnfer massive data
from the database to free memory
- Simplify CSS classes
- Add more database abstraction layers like ODBC/M$SQL/Oracle
// User id valid and not webmaster's id?
if ((isValidId(getUserData('userid'))) && (getBegUserid() != getUserData('userid'))) {
// Update counter
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_clicks`=`beg_clicks`+1 WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_clicks`=`beg_clicks`+1 WHERE `userid`=%s LIMIT 1",
array(getUserData('userid')), __FILE__, __LINE__);
// Check for last entry for userid w/o IP number 12 33 2 23 44 3 21 1 1
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE ((UNIX_TIMESTAMP() - `timeout`) >= {?beg_timeout?} OR ((UNIX_TIMESTAMP() - `timeout`) >= {?beg_userid_timeout?} AND `userid`=%s)) AND (`remote_ip`='%s' OR `sid`='%s') LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE ((UNIX_TIMESTAMP() - `timeout`) >= {?beg_timeout?} OR ((UNIX_TIMESTAMP() - `timeout`) >= {?beg_userid_timeout?} AND `userid`=%s)) AND (`remote_ip`='%s' OR `sid`='%s') LIMIT 1",
array(
getUserData('userid'),
determineRealRemoteAddress(),
// Entry not found, points set and not logged in?
//* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'SQL_HASZERONUMS()=' . intval(SQL_HASZERONUMS($result)) . ',isAdmin()=' . intval(isAdmin()) . ',points=' . $points . ',isMember()=' . intval(isMember()) . ',getBegPayMode()=' . getBegPayMode());
- if ((SQL_HASZERONUMS($result)) && ($points > 0) && (getBegPayMode() == 'NONE') && ((!isMember()) || (isAdmin()))) {
+ if ((ifSqlHasZeroNums($result)) && ($points > 0) && (getBegPayMode() == 'NONE') && ((!isMember()) || (isAdmin()))) {
// Default is result from isAdmin(), mostly false
$isPayed = isAdmin();
* but only when there is no admin begging.
* Admins shall be able to test it!
*/
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_beg_ips` (`userid`, `remote_ip`, `sid`, `timeout`) VALUES ('%s','%s','%s', UNIX_TIMESTAMP())",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_beg_ips` (`userid`, `remote_ip`, `sid`, `timeout`) VALUES ('%s','%s','%s', UNIX_TIMESTAMP())",
array(
getUserData('userid'),
determineRealRemoteAddress(),
), __FILE__, __LINE__);
// Was is successfull?
- $isPayed = (!SQL_HASZEROAFFECTED());
+ $isPayed = (!ifSqlHasZeroAffectedRows());
} // END - if
// Pay points?
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Include header
loadIncludeOnce('inc/header.php');
$chk = bigintval(getRequestElement('check'), FALSE);
// Check if link is not clicked so far
-$result = SQL_QUERY_ESC("SELECT
+$result = sqlQueryEscaped("SELECT
`b`.`points`,
`d`.`userid`,
`d`.`gender`,
$content = array();
// Is an entry there?
-if (SQL_NUMROWS($result) == 1) {
+if (sqlNumRows($result) == 1) {
// Ok, congratulation again! Here's your gift from us...
- $data = SQL_FETCHARRAY($result, FALSE);
+ $data = sqlFetchArray($result, FALSE);
// Is the account confirmed?
if ($data['status'] == 'CONFIRMED') {
addPointsThroughReferralSystem('birthday_confirm', $userid, $data['points']);
// Remove entry from table
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_birthday` WHERE `userid`=%s AND `chk_value`='%s' LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_birthday` WHERE `userid`=%s AND `chk_value`='%s' LIMIT 1",
array($userid, $chk), __FILE__, __LINE__);
// Load message from template
}
// Free memory
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Set this because there is no module in URI
$GLOBALS['__module'] = 'birthday_confirm';
// Construct FQFN for the module
$inc = sprintf("inc/debug/%s/request_%s.php",
getConfig('debug_mode'),
- SQL_ESCAPE(postRequestElement('request'))
+ sqlEscapeString(postRequestElement('request'))
);
// Is the module there? Else we log it!
if (($points - getConfig('doubler_left') - postRequestElement('points') * getDoublerCharge() / 100) >= 0) {
// Enough points are left so let's continue with the doubling process
// Create doubling "account" with *DOUBLED* points
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(), 'N','N')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(), 'N','N')",
array(
getUserData('userid'),
convertZeroToNull(determineReferralId()),
// Add second line for the referral but only when userid != refid
if ((isValidId(determineReferralId())) && (determineReferralId() != getUserData('userid'))) {
// Okay add a refid line and apply refid percents
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES (%s,0,%s,'%s',UNIX_TIMESTAMP(),'N','Y')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES (%s,0,%s,'%s',UNIX_TIMESTAMP(),'N','Y')",
array(
convertZeroToNull(determineReferralId()),
(postRequestElement('points') * 2 * getDoublerRef() / 100),
unsetSqlLinkUp(__FUNCTION__, __LINE__);
// Establish link
- $linkResource = SQL_CONNECT(getSession('mysql_host'), getSession('mysql_login'), getSession('mysql_password1'), __FUNCTION__, __LINE__);
+ $linkResource = sqlConnectToDatabase(getSession('mysql_host'), getSession('mysql_login'), getSession('mysql_password1'), __FUNCTION__, __LINE__);
// Is this a link resource?
if (!is_resource($linkResource)) {
} // END - if
// Does selecting the database work?
- if (!SQL_SELECT_DB(getSession('mysql_dbase'), __FUNCTION__, __LINE__)) {
+ if (!sqlSelectDatabase(getSession('mysql_dbase'), __FUNCTION__, __LINE__)) {
// Could not be selected
reportBug(__FUNCTION__, __LINE__, 'Could not select database ' . getSession('mysql_dbase'));
} elseif ((!isFileReadable(getSession('base_path') . 'install/tables.sql')) || (!isFileReadable(getSession('base_path') . 'install/menu-'.getLanguage().'.sql'))) {
runFilterChain('run_sqls');
// Close SQL link
- SQL_CLOSE(__FUNCTION__, __LINE__);
+ sqlCloseLink(__FUNCTION__, __LINE__);
}
// Call-back function to import menu SQL file
runFilterChain('run_sqls');
// Close SQL link
- SQL_CLOSE(__FUNCTION__, __LINE__);
+ sqlCloseLink(__FUNCTION__, __LINE__);
}
// Call-back function to install some important extensions
// Checks for string without any added extra data
function isXmlTypeString ($value) {
// Just let SQL_ESCAPE() do the job
- return ($value == SQL_ESCAPE($value));
+ return ($value == sqlEscapeString($value));
}
// Fake-check for array type
$ret = '0.0.0.0';
// Search for hostname in cache
- $result = SQL_QUERY_ESC("SELECT `ip` FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE `hostname`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `ip` FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE `hostname`='%s' LIMIT 1",
array($hostname), __METHOD__, __LINE__);
// Does an entry exist?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Then load the hostname
- list($ip) = SQL_FETCHROW($result);
+ list($ip) = sqlFetchRow($result);
// Count cache hit
incrementStatsEntry('dns_cache_hits');
// Seems to be an IP! Now check deeper...
if (($matches[0] == $ip) && ($matches[1] >= 0) && ($matches[1] <= 255) && ($matches[2] >= 0) && ($matches[2] <= 255) && ($matches[3] >= 0) && ($matches[3] <= 255) && ($matches[4] > 0) && ($matches[4] < 255)) {
// We also cache IP addresses
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_dns_cache` (`ip`, `hostname`, `added`) VALUES ('%s', '%s', NOW())",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_dns_cache` (`ip`, `hostname`, `added`) VALUES ('%s', '%s', NOW())",
array($ip, $hostname), __METHOD__, __LINE__);
// Set return value to $ip
//* DEBUG: */ logDebugMessage(__METHOD__, __LINE__, sprintf("Cannot lookup: %s", $hostname));
} else {
// Put entry in DB
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_dns_cache` (`ip`, `hostname`, `added`) VALUES ('%s', '%s', NOW())",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_dns_cache` (`ip`, `hostname`, `added`) VALUES ('%s', '%s', NOW())",
array($ip, $hostname), __METHOD__, __LINE__);
// Set return value to $ip
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return IP number (let's hope it)
return $ret;
// Purge old entries
function purgeEntries() {
// SQL for cleaning up
- SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`added`) >= {?dns_cache_timeout?})',
+ sqlQuery('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`added`) >= {?dns_cache_timeout?})',
__METHOD__, __LINE__);
}
}
setConfigEntry($entry, $values[$idx]);
} else {
// String detected
- $SQL .= sprintf("`%s`='%s',", $entry, SQL_ESCAPE($values[$idx]));
+ $SQL .= sprintf("`%s`='%s',", $entry, sqlEscapeString($values[$idx]));
// Set it in config as well
setConfigEntry($entry, $values[$idx]);
setConfigEntry($entries, time());
} else {
// Regular entry to update
- $SQL = sprintf("`%s`='%s'", $entries, SQL_ESCAPE($values));
+ $SQL = sprintf("`%s`='%s'", $entries, sqlEscapeString($values));
// Set it in config as well
- setConfigEntry($entries, SQL_ESCAPE($values));
+ setConfigEntry($entries, sqlEscapeString($values));
}
// Run database update
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SQL=' . $SQL);
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_config` SET ".$SQL." WHERE `config`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_config` SET ".$SQL." WHERE `config`=%s LIMIT 1",
array(bigintval($config)), __FUNCTION__, __LINE__);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SQL=' . $SQL . ',affectedRows=' . SQL_AFFECTEDROWS());
// Load config from cache
mergeConfig($GLOBALS['cache_array']['config'][$no]);
- // Count cache hits
+ // Count cache hits
incrementStatsEntry('cache_hits');
} elseif ((!isExtensionActive('cache')) || (!isset($GLOBALS['cache_array']['config'][$no]))) {
// Load config from DB
- $result_config = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_config` WHERE `config`='%s' LIMIT 1",
+ $result_config = sqlQueryEscaped("SELECT * FROM `{?_MYSQL_PREFIX?}_config` WHERE `config`='%s' LIMIT 1",
array(bigintval($no)), __FUNCTION__, __LINE__);
// Is the config there?
- if (SQL_NUMROWS($result_config) == 1) {
+ if (sqlNumRows($result_config) == 1) {
// Get config from database
- mergeConfig(SQL_FETCHARRAY($result_config));
+ mergeConfig(sqlFetchArray($result_config));
} // END - if
// Free result
- SQL_FREERESULT($result_config);
+ sqlFreeResult($result_config);
// Remember this config in the array
$GLOBALS['cache_array']['config'][$no] = getConfigArray();
//* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Daily reset started.');
// Check for 100% klickrate mails
-$result_bonus = SQL_QUERY("SELECT
+$result_bonus = sqlQuery("SELECT
`id`,
`userid`,
`subject`,
ORDER BY
`userid` ASC", __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result_bonus)) {
+if (!ifSqlHasZeroNums($result_bonus)) {
// We found some mail orders...
- while ($content = SQL_FETCHARRAY($result_bonus)) {
+ while ($content = sqlFetchArray($result_bonus)) {
// Add points
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_stats`=`bonus_stats`+{?bonus_stats?} WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_stats`=`bonus_stats`+{?bonus_stats?} WHERE `userid`=%s LIMIT 1",
array(bigintval($content['userid'])), __FILE__, __LINE__);
// Translate some data
sendEmail($content['userid'], '{--MEMBER_BONUS_STATS_SUBJECT--}', $message);
// Update database
- $result_update = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `bonus_stats_active`='Y' WHERE `id`=%s LIMIT 1",
+ $result_update = sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `bonus_stats_active`='Y' WHERE `id`=%s LIMIT 1",
array(bigintval($content['id'])), __FILE__, __LINE__);
} // END - while
} // END - if
// Free memory
-SQL_FREERESULT($result_bonus);
+sqlFreeResult($result_bonus);
// Debug line
//* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Daily reset ended.');
} // END - if
// Only confirmed members shall receive birthday mails...
-$result_birthday = SQL_QUERY_ESC("SELECT
+$result_birthday = sqlQueryEscaped("SELECT
`d`.`userid`,
`d`.`email`,
`d`.`birth_year`
`d`.`userid` ASC",
array($day, $month), __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result_birthday)) {
+if (!ifSqlHasZeroNums($result_birthday)) {
// Start sending out birthday mails
- while ($content = SQL_FETCHARRAY($result_birthday)) {
+ while ($content = sqlFetchArray($result_birthday)) {
// Calculate own timestamp for birthday and today
$bd = $content['birth_year'] + 12 * $month + 365 * $day;
$now = $year + 12 * $month + 365 * $day;
} // END - for
// Insert row into database
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_birthday` (`userid`, `points`, `chk_value`) VALUES (%s,{?birthday_points?},'%s' )",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_birthday` (`userid`, `points`, `chk_value`) VALUES (%s,{?birthday_points?},'%s' )",
array(
bigintval($content['userid']),
$content['check']
sendEmail($content['userid'], '{--MEMBER_HAPPY_BIRTHDAY_SUBJECT--}', $message);
// Remember him that he has received a birthday mail
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `birthday_sent`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `birthday_sent`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1",
array(bigintval($content['userid'])), __FILE__, __LINE__);
} // END - while
// Free memory
- SQL_FREERESULT($result_birthday);
+ sqlFreeResult($result_birthday);
} // END - if
// Debug line
//* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Daily reset started.');
// Check for holidays we need to enable and send email to user
-$result_main = SQL_QUERY("SELECT
+$result_main = sqlQuery("SELECT
`userid`,
`holiday_activated`
FROM
__FILE__, __LINE__);
// Entries found?
-if (!SQL_HASZERONUMS($result_main)) {
+if (!ifSqlHasZeroNums($result_main)) {
// Init SQLs
initSqls();
// We have found at least one useraccount so let's check it...
- while ($content = SQL_FETCHARRAY($result_main)) {
+ while ($content = sqlFetchArray($result_main)) {
// Check if his holiday can be activated
- $result_holiday = SQL_QUERY_ESC("SELECT
+ $result_holiday = sqlQueryEscaped("SELECT
`holiday_start`,
`holiday_end`
FROM
array(bigintval($content['userid'])), __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result_holiday) == 1) {
+ if (sqlNumRows($result_holiday) == 1) {
// Okay, this user can be send away to holiday...
- $content = merge_array($content, SQL_FETCHARRAY($result_holiday));
+ $content = merge_array($content, sqlFetchArray($result_holiday));
// Prepare all data for the template
$content = merge_array($content, array(
sendEmail($content['userid'], '{--MEMBER_HOLIDAY_ACTIVATED_SUBJECT--}', $message);
// Update account
- addSql(SQL_QUERY_ESC("UPDATE
+ addSql(sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`holiday_active`='Y'
} // END - if
// Free memory
- SQL_FREERESULT($result_holiday);
+ sqlFreeResult($result_holiday);
} // END - while
// Run all SQLs
} // END - if
// Free memory
-SQL_FREERESULT($result_main);
+sqlFreeResult($result_main);
// Stop currently activated holidays
stopHolidays();
//* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Daily reset started.');
// Reset mail order values
-$result_ext = SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mail_orders`=0 WHERE `mail_orders` > 0', __FILE__, __LINE__);
+$result_ext = sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mail_orders`=0 WHERE `mail_orders` > 0', __FILE__, __LINE__);
// Debug line
//* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Daily reset ended.');
if ((isSendProfileUpdateEnabled()) && (getProfileUpdate() > 0) && (getResendProfileUpdate() > 0)) {
// Load personal data
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`userid`,
`email`,
`last_update`,
`userid` ASC", __FILE__, __LINE__);
// Are there some notifications to sent?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// We need to send-out notifications...
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Translate timestamp
$content['joined'] = generateDateTime($content['joined'], '0');
sendEmail($content['userid'], '{--MEMBER_PROFILE_OUTDATED_SUBJECT--}', $message);
// Update profile data
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`last_profile_sent`=UNIX_TIMESTAMP(),
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Debug line
// Update user profiles
if (isExtensionInstalledAndNewer('order', '0.1.1')) {
// Latest version
- SQL_QUERY('UPDATE
+ sqlQuery('UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`receive_mails`=`max_mails`,
' . runFilterChain('user_exclusion_sql', ' ') . '', __FILE__, __LINE__);
} else {
// Obsolete version
- SQL_QUERY('UPDATE
+ sqlQuery('UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`receive_mails`=`max_mails`
}
// Transfer points from locked_points to points
-$result_daily = SQL_QUERY("SELECT
+$result_daily = sqlQuery("SELECT
`userid`
FROM
`{?_MYSQL_PREFIX?}_user_data`
`userid` ASC", __FILE__, __LINE__);
//* DEBUG: */ debugOutput(basename(__FILE__) . ':payout=0;daily|numRows=' . SQL_NUMROWS($result_daily));
-if (!SQL_HASZERONUMS($result_daily)) {
+if (!ifSqlHasZeroNums($result_daily)) {
// Init SQLs
initSqls();
// Run through all 'locked_(foo)_points columsn
foreach (runFilterChain('locked_points_columns_array', array('points')) as $columnName) {
// Start checking accounts which are on 0 confirmed-to-go mails
- while ($content = SQL_FETCHARRAY($result_daily)) {
+ while ($content = sqlFetchArray($result_daily)) {
//* DEBUG: */ debugOutput(basename(__FILE__) . ':' . $content['userid']);
- $result_points = SQL_QUERY_ESC("SELECT
+ $result_points = sqlQueryEscaped("SELECT
`ref_depth`,
`locked_%s`
FROM
), __FILE__, __LINE__);
//* DEBUG: */ debugOutput(basename(__FILE__) . ':payout=0;points|numRows=' . SQL_NUMROWS($result_points));
- if (!SQL_HASZERONUMS($result_points)) {
+ if (!ifSqlHasZeroNums($result_points)) {
// Ok transfer points
- while ($content2 = SQL_FETCHARRAY($result_points)) {
+ while ($content2 = sqlFetchArray($result_points)) {
// Merge both arrays
$content = merge_array($content, $content2);
//* DEBUG: */ debugOutput(basename(__FILE__) . ':userid=' . $content['userid'].',depth='.$content['ref_depth'].',columnName=' . $columnName . ',locked='.$content['locked_' . $columnName]);
if ($content['ref_depth'] > 0) {
// Level 1+
- addSql(SQL_QUERY_ESC("UPDATE
+ addSql(sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_points`
SET
`%s`=`%s`+%s,
);
} else {
// Level zero
- addSql(SQL_QUERY_ESC("UPDATE
+ addSql(sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_points`
SET
`%s`=`%s`+%s,
} // END - if
// Free memory
- SQL_FREERESULT($result_points);
+ sqlFreeResult($result_points);
} // END - while
} // END - foreach
} // END - if
// Free memory
-SQL_FREERESULT($result_daily);
+sqlFreeResult($result_daily);
// Debug line
//* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Daily reset ended.');
// Is auto-purging activated and configured correctly?
if ((isApSubidsEnabled()) && (getApSubidsSince() > 0)) {
// Start purging
- SQL_QUERY('DELETE LOW_PRIORITY FROM
+ sqlQuery('DELETE LOW_PRIORITY FROM
`{?_MYSQL_PREFIX?}_subid_log`
WHERE
(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`entry_added`)) >= {?ap_subids_since?}',
__FILE__, __LINE__);
// Are some entries deleted?
- if (SQL_AFFECTEDROWS() > 0) {
+ if (sqlAffectedRows() > 0) {
// Okay, then send an email to the admin
- sendAdminNotification('{--ADMIN_PURGE_USER_SUBID_LOG_SUBJECT--}', 'admin_purge_user_subid_log', SQL_AFFECTEDROWS());
+ sendAdminNotification('{--ADMIN_PURGE_USER_SUBID_LOG_SUBJECT--}', 'admin_purge_user_subid_log', sqlAffectedRows());
} // END - if
} // END - if
} // END - if
// SQL queries
-function SQL_QUERY ($sqlString, $F, $L, $enableCodes = TRUE) {
+function sqlQuery ($sqlString, $F, $L, $enableCodes = TRUE) {
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$sqlString])) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called: ' . $sqlString);
basename($F),
$L
));
- } elseif (!SQL_IS_LINK_UP()) {
+ } elseif (!isSqlLinkUp()) {
// We should not quietly ignore this
reportBug(__FUNCTION__, __LINE__, sprintf("Cannot query database: sqlString=%s,file=%s,line=%s",
$sqlStringModified,
$sqlStringModified = str_replace(array(chr(9), PHP_EOL, chr(13)), array(' ', ' ', ' '), $sqlStringModified);
// Compile config entries out
- $sqlStringModified = SQL_PREPARE_SQL_STRING($sqlStringModified, $enableCodes);
+ $sqlStringModified = sqlPrepareQueryString($sqlStringModified, $enableCodes);
// Cache it and remember as last SQL query
$GLOBALS[__FUNCTION__][$sqlString] = $sqlStringModified;
$GLOBALS['last_sql'] = $sqlStringModified;
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Stored cache: ' . $sqlStringModified);
- } elseif (!SQL_IS_LINK_UP()) {
+ } elseif (!isSqlLinkUp()) {
// Link went down while using cached SQL
reportBug(__FUNCTION__, __LINE__, 'Link went down while using cached SQL: sqlString=' . $sqlString . ',F=' . basename($F) . ',L=' . $L . ',enableCodes=' . intval($enableCodes));
} else {
// Run SQL command
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . basename($F) . ',L=' . $L . ',sql=' . $GLOBALS['last_sql']);
- $result = mysql_query($GLOBALS['last_sql'], SQL_GET_LINK())
- or SQL_ERROR($F, $L, 'file='. basename($F) . ',line=' . $L . ':mysql_error()=' . mysql_error() . ',last_query=' . $GLOBALS['last_sql']);
+ $result = mysql_query($GLOBALS['last_sql'], getSqlLink())
+ or sqlError($F, $L, 'file='. basename($F) . ',line=' . $L . ':mysql_error()=' . mysql_error() . ',last_query=' . $GLOBALS['last_sql']);
//* DEBUG: */ logDebugMessage($F, $L, 'sql=' . $GLOBALS['last_sql'] . ',affected=' . SQL_AFFECTEDROWS() . ',numRows='.(is_resource($result) ? SQL_NUMROWS($result) : gettype($result)));
// Calculate query time
incrementConfigEntry('sql_count');
// Debug output
- if (SQL_DEBUG_ENABLED()) {
+ if (isSqlDebugEnabled()) {
// Is this the first call?
if (!isset($GLOBALS['sql_first_entry'])) {
// Write first entry
} // END - if
// Append debug line
- appendLineToFile(getCachePath() . 'mysql.log', basename($F) . '|LINE=' . $L . '|NUM=' . (is_resource($result) ? SQL_NUMROWS($result) : 'false') . '|AFFECTED=' . SQL_AFFECTEDROWS() . '|QUERYTIME:' . ($queryTime * 1000) . 'ms): ' . str_replace(array(chr(13), PHP_EOL), array('', ' '), $GLOBALS['last_sql']));
+ appendLineToFile(getCachePath() . 'mysql.log', basename($F) . '|LINE=' . $L . '|NUM=' . (is_resource($result) ? sqlNumRows($result) : 'false') . '|AFFECTED=' . sqlAffectedRows() . '|QUERYTIME:' . ($queryTime * 1000) . 'ms): ' . str_replace(array(chr(13), PHP_EOL), array('', ' '), $GLOBALS['last_sql']));
} // END - if
// Increment stats entry
}
// SQL num rows
-function SQL_NUMROWS ($resource) {
+function sqlNumRows ($resource) {
// Valid link resource?
- if (!SQL_IS_LINK_UP()) return FALSE;
+ if (!isSqlLinkUp()) return FALSE;
// Link is not up, no rows by default
$lines = FALSE;
}
// SQL affected rows
-function SQL_AFFECTEDROWS () {
+function sqlAffectedRows () {
// Valid link resource?
- if (!SQL_IS_LINK_UP()) return FALSE;
+ if (!isSqlLinkUp()) return FALSE;
// Get affected rows
- $lines = mysql_affected_rows(SQL_GET_LINK());
+ $lines = mysql_affected_rows(getSqlLink());
// Return it
return $lines;
}
// SQL fetch row
-function SQL_FETCHROW ($resource) {
+function sqlFetchRow ($resource) {
// Is $resource valid?
- if ((!is_resource($resource)) || (!SQL_IS_LINK_UP())) return FALSE;
+ if ((!is_resource($resource)) || (!isSqlLinkUp())) return FALSE;
// Fetch the data and return it
return mysql_fetch_row($resource);
}
// SQL fetch array
-function SQL_FETCHARRAY ($resource) {
+function sqlFetchArray ($resource) {
// Is $resource valid?
- if ((!is_resource($resource)) || (!SQL_IS_LINK_UP())) return FALSE;
+ if ((!is_resource($resource)) || (!isSqlLinkUp())) return FALSE;
// Load row as array from database
$row = mysql_fetch_assoc($resource);
}
// SQL result
-function SQL_RESULT ($resource, $row, $field = '0') {
+function sqlResult ($resource, $row, $field = '0') {
// Is $resource valid?
- if ((!is_resource($resource)) || (!SQL_IS_LINK_UP())) return FALSE;
+ if ((!is_resource($resource)) || (!isSqlLinkUp())) return FALSE;
// Run the result command
$result = mysql_result($resource, $row, $field);
}
// SQL connect
-function SQL_CONNECT ($host, $login, $password, $F, $L) {
+function sqlConnectToDatabase ($host, $login, $password, $F, $L) {
// Try to connect
- $linkResource = mysql_connect($host, $login, $password) or SQL_ERROR($F, $L, mysql_error());
+ $linkResource = mysql_connect($host, $login, $password) or sqlError($F, $L, mysql_error());
// Set the link resource
if (is_resource($linkResource)) {
/*
* A non-resource (boolean) may happen on installation phase which
* shall not be set here. Only valid link resources shall be set so
- * SQL_IS_LINK_UP() will only return 'true' if there is really a
+ * isSqlLinkUp() will only return 'true' if there is really a
* working database link.
*/
- SQL_SET_LINK(__FUNCTION__, __LINE__, $linkResource);
+ setSqlLink(__FUNCTION__, __LINE__, $linkResource);
// Init charsets (UTF-8 is default now)
- SQL_QUERY("SET
+ sqlQuery("SET
`character_set_results`='utf8',
`character_set_client`='utf8',
`character_set_connection`='utf8',
}
// SQL select database
-function SQL_SELECT_DB ($dbName, $F, $L) {
+function sqlSelectDatabase ($dbName, $F, $L) {
// Is there still a valid link? If not, skip it.
- if (!SQL_IS_LINK_UP()) return FALSE;
+ if (!isSqlLinkUp()) return FALSE;
// Return the result
//* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, 'Selecting database ' . $dbName);
- return mysql_select_db($dbName, SQL_GET_LINK()) or SQL_ERROR($F, $L, mysql_error());
+ return mysql_select_db($dbName, getSqlLink()) or sqlError($F, $L, mysql_error());
}
// SQL close link
-function SQL_CLOSE ($F, $L) {
+function sqlCloseLink ($F, $L) {
// Is the link up?
- if (!SQL_IS_LINK_UP()) {
+ if (!isSqlLinkUp()) {
// Skip double close
//* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, 'Called but no link is open.');
return FALSE;
} // END - if
// Close database link and forget the link
- $close = mysql_close(SQL_GET_LINK()) or SQL_ERROR($F . ':' . __FUNCTION__, $L . ':' . __LINE__, mysql_error());
+ $close = mysql_close(getSqlLink()) or sqlError($F . ':' . __FUNCTION__, $L . ':' . __LINE__, mysql_error());
// Close link in this layer
unsetSqlLinkUp(__FUNCTION__, __LINE__);
}
// SQL free result
-function SQL_FREERESULT ($resource) {
- if ((!is_resource($resource)) || (!SQL_IS_LINK_UP())) {
+function sqlFreeResult ($resource) {
+ if ((!is_resource($resource)) || (!isSqlLinkUp())) {
// Abort here
return FALSE;
} // END - if
}
// Get id from last INSERT command and secure id
-function SQL_INSERT_ID () {
- if (!SQL_IS_LINK_UP()) return FALSE;
+function getSqlInsertId () {
+ if (!isSqlLinkUp()) return FALSE;
return bigintval(mysql_insert_id());
}
// Escape a string for the database
-function SQL_ESCAPE ($str, $secureString = TRUE, $strip = TRUE) {
+function sqlEscapeString ($str, $secureString = TRUE, $strip = TRUE) {
// Is there cache?
if (!isset($GLOBALS['sql_escapes']['' . $str . ''])) {
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ' - BEFORE!');
// Prepare the string here
- $str = SQL_PREPARE_SQL_STRING($str);
+ $str = sqlPrepareQueryString($str);
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ' - AFTER!');
// Init (invalid) value
$ret = '!INVALID!';
- if (!SQL_IS_LINK_UP()) {
+ if (!isSqlLinkUp()) {
// Fall-back to escapeQuotes() when there is no link
$ret = escapeQuotes($str);
} elseif (function_exists('mysql_real_escape_string')) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str);
// The new and improved version
- $ret = mysql_real_escape_string($str, SQL_GET_LINK());
+ $ret = mysql_real_escape_string($str, getSqlLink());
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ',ret=' . $ret);
} elseif (function_exists('mysql_escape_string')) {
// The obsolete function
- $ret = mysql_escape_string($str, SQL_GET_LINK());
+ $ret = mysql_escape_string($str, getSqlLink());
} else {
// If nothing else works, fall back to escapeQuotes() again
$ret = escapeQuotes($str);
}
// Log SQL errors to debug.log in installation phase or call reportBug()
-function SQL_ERROR ($file, $line, $message) {
+function sqlError ($file, $line, $message) {
// Remember plain error in last_sql_error
$GLOBALS['last_sql_error'] = mysql_error();
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
// New way, with CSS
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $currentName . ',always_active=' . getThisExtensionAlwaysActive() . ', ext_ver=' . getCurrentExtensionVersion() . 'ext_css=' . getExtensionHasCss());
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_extensions` (`ext_name`, `ext_active`, `ext_version`, `ext_has_css`) VALUES ('%s','%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_extensions` (`ext_name`, `ext_active`, `ext_version`, `ext_has_css`) VALUES ('%s','%s','%s','%s')",
array(
$currentName,
getThisExtensionAlwaysActive(),
} else {
// Old way, no CSS
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $currentName . ',always_active=' . getThisExtensionAlwaysActive() . ', ext_ver=' . getCurrentExtensionVersion());
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_extensions` (`ext_name`, `ext_active`, `ext_version`) VALUES ('%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_extensions` (`ext_name`, `ext_active`, `ext_version`) VALUES ('%s','%s','%s')",
array(
$currentName,
getThisExtensionAlwaysActive(),
* Use the insert id as extension id and "cache" all data for
* this extension for early usage.
*/
- copyExtensionDataToCacheArray($currentName, SQL_INSERT_ID());
+ copyExtensionDataToCacheArray($currentName, getSqlInsertId());
// Mark it as installed
$GLOBALS['ext_is_installed'][$currentName] = TRUE;
} elseif ((isValidId($taskId)) && (getCurrentExtensionName() != '')) {
// Remove task from system when id and extension's name is valid
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
array(bigintval($taskId)), __FUNCTION__, __LINE__);
}
runFilterChain('extension_' . $load_mode);
// Remove cache file(s) if extension is active
- if (((isExtensionActive('cache')) && ((!SQL_HASZEROAFFECTED()) || ($sqlRan === TRUE) || ($load_mode == 'activate') || ($load_mode == 'deactivate')))) {
+ if (((isExtensionActive('cache')) && ((!ifSqlHasZeroAffectedRows()) || ($sqlRan === TRUE) || ($load_mode == 'activate') || ($load_mode == 'deactivate')))) {
// Run filters
runFilterChain('post_extension_run_sql', getCurrentExtensionName());
} // END - if
} elseif (($ext_name == 'cache') || (!isExtensionInstalled('cache'))) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'DB! ext_name=' . $ext_name);
// Load from database
- $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load entry
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set cache
setExtensionCacheRow($ext_name, $data);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Extension not active!
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ': Not active!');
incrementStatsEntry('cache_hits');
} elseif ((!isCacheInstanceValid()) || (isset($GLOBALS['cache_array']['extension'])) || (!isHtmlOutputMode())) {
// Load from database
- $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ': DB - '.SQL_NUMROWS($result).'');
// Is the extension there?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load entry
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set cache
setExtensionCacheRow($ext_name, $data);
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Extension version should not be invalid
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result = SQL_QUERY_ESC("SELECT `ext_name` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `ext_name` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1",
array(bigintval($ext_id)), __FUNCTION__, __LINE__);
// Is the entry there?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Get the extension's name from database
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Did we find some extension?
incrementStatsEntry('cache_hits');
} else {
// Load from database
- $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
// Is the entry there?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Get the extension's id from database
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set cache
setExtensionCacheRow($ext_name, $data);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return value
} // END - if
// Activate the extension
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='Y' WHERE `ext_name`='%s' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='Y' WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
// Then run all queries
} // END - if
// Activate the extension
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='%s' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
// Then run all queries
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',taskId[' . gettype($taskId) . ']=' . $taskId);
if ((!isValidId($taskId)) && (isExtensionInstalled($ext_name))) {
// Task not created so add it
- $taskId = createNewTask($subject, SQL_ESCAPE(loadTemplate('task_EXTENSION_deactivated', TRUE, $ext_name)), 'EXTENSION_DEACTIVATION');
+ $taskId = createNewTask($subject, sqlEscapeString(loadTemplate('task_EXTENSION_deactivated', TRUE, $ext_name)), 'EXTENSION_DEACTIVATION');
} // END - if
// Return task id
$data['task_id'] = NULL;
// Search for extension task's id
- $result = SQL_QUERY_ESC("SELECT `id` AS `task_id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `task_type`='EXTENSION' AND `subject`='[%s:]' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` AS `task_id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `task_type`='EXTENSION' AND `subject`='[%s:]' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Task found so load task's id and register extension...
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return it
return $data['task_id'];
$data['task_id'] = '0';
// Search for task id
- $result = SQL_QUERY_ESC("SELECT `id` AS `task_id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` AS `task_id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1",
array($subject), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Task found so load task's id and register extension...
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return it
return $data['task_id'];
case '0.1.4': // SQL queries for v0.1.4
// Update notes (these will be set as task text!)
- setExtensionUpdateNotes("SQL-Anweisungen mit SQL_QUERY_ESC() abgesichert.");
+ setExtensionUpdateNotes("SQL-Anweisungen mit sqlQueryEscaped() abgesichert.");
break;
case '0.1.5': // SQL queries for v0.1.5
case 'activate': // Do stuff when admin activates this extension
// Check if mod_rewrite is loadeded
if (!isApacheModuleLoaded('mod_rewrite')) {
- SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='rewrite' LIMIT 1", __FILE__, __LINE__);
+ sqlQuery("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='rewrite' LIMIT 1", __FILE__, __LINE__);
enableExtensionReportingFailure(TRUE);
addFatalMessage(__FILE__, __LINE__, '{--MOD_REWRITE_ERROR--}');
} // END - if
// Check if mod_rewrite is loadeded
if (!isApacheModuleLoaded('mod_rewrite')) {
enableExtensionReportingFailure(TRUE);
- SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='rewrite' LIMIT 1", __FILE__, __LINE__);
+ sqlQuery("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='N' WHERE `ext_name`='rewrite' LIMIT 1", __FILE__, __LINE__);
if (!isAdmin()) {
addFatalMessage(__FILE__, __LINE__, '{--MOD_REWRITE_ERROR--}');
} // END - if
case '0.3.7': // SQL queries for v0.3.7
// Update notes (these will be set as task text!)
- setExtensionUpdateNotes("SQL-Anweisungen mit SQL_QUERY_ESC() abgesichert.");
+ setExtensionUpdateNotes("SQL-Anweisungen mit sqlQueryEscaped() abgesichert.");
break;
case '0.3.8': // SQL queries for v0.3.8
} // END - if
// Load all filters
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`filter_name`,
`filter_function`,
`filter_active`
`filter_id` ASC', __FUNCTION__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all filters
- while ($filterArray = SQL_FETCHARRAY($result)) {
+ while ($filterArray = sqlFetchArray($result)) {
// Get filter name and function
$filterName = $filterArray['filter_name'];
$filterFunction = $filterArray['filter_function'];
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Init filters
} // END - if
// Run the SQL query
- SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE (UNIX_TIMESTAMP() - `timeout`) >= %s',
+ sqlQueryEscaped('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE (UNIX_TIMESTAMP() - `timeout`) >= %s',
array($OLD + 60*60), __FUNCTION__, __LINE__);
// Check for beg rallye is active and send mails out
if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (isBonusRallyeActive()) && (isIncludeBonusLoginEnabled())) {
// Update last login if far enougth away
// @TODO This query isn't right, it will only update if the user was for a longer time away!
- SQL_QUERY_ESC('UPDATE
+ sqlQueryEscaped('UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`last_login`=UNIX_TIMESTAMP()
);
// Updated entry?
- $bonus = (!SQL_HASZEROAFFECTED());
+ $bonus = (!ifSqlHasZeroAffectedRows());
} // END - if
if (($bonus === TRUE) && (getRequestElement('do') == 'bonus')) {
} // END - if
// Now check if the user has subscription and amount left
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`d`.`earning_id`,
`d`.`earning_provider`,
`u`.`earning_current_amount`,
), __FUNCTION__, __LINE__);
// Are there entries left?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all names
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Merge the $filterData array in
$content = merge_array($content, $filterData);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return filter data
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
} // END - if
// Now search for the user
- $result = SQL_QUERY_ESC("SELECT `timestamp` FROM `{?_MYSQL_PREFIX?}_online` WHERE `sid`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `timestamp` FROM `{?_MYSQL_PREFIX?}_online` WHERE `sid`='%s' LIMIT 1",
array(session_id()), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Then update it
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_online`
SET
`module`='%s',
`is_admin`='%s',
`timestamp`=UNIX_TIMESTAMP(),
`ip`='%s'
-WHERE
+WHERE
`sid`='%s'
LIMIT 1",
array(
), __FUNCTION__, __LINE__);
} else {
// No entry does exists so we simply add it!
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_online` (`module`, `action`, `what`, `userid`, `refid`, `is_member`, `is_admin`, `timestamp`, `sid`, `ip`) VALUES ('%s','%s','%s', %s, %s, '%s','%s', UNIX_TIMESTAMP(), '%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_online` (`module`, `action`, `what`, `userid`, `refid`, `is_member`, `is_admin`, `timestamp`, `sid`, `ip`) VALUES ('%s','%s','%s', %s, %s, '%s','%s', UNIX_TIMESTAMP(), '%s','%s')",
array(
getModule(),
$action,
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Purge old entries
- SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_online` WHERE (UNIX_TIMESTAMP() - `timestamp`) >= {?online_timeout?}', __FUNCTION__, __LINE__);
+ sqlQuery('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_online` WHERE (UNIX_TIMESTAMP() - `timestamp`) >= {?online_timeout?}', __FUNCTION__, __LINE__);
// Return data
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
));
// Check for new started but not notified rallyes
- $result = SQL_QUERY("SELECT SQL_SMALL_RESULT
+ $result = sqlQuery("SELECT SQL_SMALL_RESULT
`d`.`id`,
`d`.`title`,
`d`.`start_time`,
`d`.`start_time` <= UNIX_TIMESTAMP() AND
`d`.`end_time` > UNIX_TIMESTAMP()
LIMIT 1", __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Start rallye
autostartReferralRallyes($result);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Check for expired rallyes
- $result = SQL_QUERY("SELECT SQL_SMALL_RESULT
+ $result = sqlQuery("SELECT SQL_SMALL_RESULT
`d`.`id`,
`d`.`title`,
`d`.`start_time`,
`d`.`expired`='N' AND
(`d`.`end_time` <= UNIX_TIMESTAMP()" . $sqlAddons['or'] . ")
LIMIT 1", __FILE__, __LINE__);
- if ((SQL_NUMROWS($result) == 1) && (isExtensionActive('autopurge'))) {
+ if ((sqlNumRows($result) == 1) && (isExtensionActive('autopurge'))) {
// End rallye here...
stopRallyeByResult($result);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return data
function FILTER_REGISTER_MUST_FILLOUT ($filterData) {
// Get all fields for output
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
- $result = SQL_QUERY('SELECT `field_name`, `field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC',
+ $result = sqlQuery('SELECT `field_name`, `field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC',
__FUNCTION__, __LINE__);
// Walk through all entries
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Must the user fill out this element?
$value = '';
if ($row['field_required'] == 'Y') {
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return it
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
assert(isReferralIdValid());
// Update ref counter, determineReferralId() must already be called before this filter is executed
- SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`={%pipe,getReferralId%} LIMIT 1', __FUNCTION__, __LINE__);
+ sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`={%pipe,getReferralId%} LIMIT 1', __FUNCTION__, __LINE__);
// Return filter data
return $filterData;
assert(isReferralIdValid());
// Get sub id and secure it
- $subId = SQL_ESCAPE(getRequestElement('subid'));
+ $subId = sqlEscapeString(getRequestElement('subid'));
// Is the sub id available and registered with referral id?
if (countSumTotalData(getReferralId(), 'user_subids', 'id', 'userid', TRUE, sprintf(" AND `subid`='%s'", $subId)) == 1) {
// Sub id is assigned to referral id, so add a record
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_subid_log`
(
`refid`,
'{%%pipe,detectUserAgent%%}'
)",
array(
- // @NOTE: SQL_QUERY_ESC() already escape it, don't use $subId here
+ // @NOTE: sqlQueryEscaped() already escape it, don't use $subId here
getRequestElement('subid')
), __FUNCTION__, __LINE__);
// Add insert id for other filters
- $filterData['insert_id'] = SQL_INSERT_ID();
+ $filterData['insert_id'] = getSqlInsertId();
// Register sub id in filter
setSession('subid', $subId);
// Does the current user have sub ids?
if (getTotalMemberSubIds() > 0) {
// Then Load all
- $result = SQL_QUERY_ESC('SELECT `id`, `subid` FROM `{?_MYSQL_PREFIX?}_user_subids` WHERE `userid`=%s ORDER BY `subid` ASC',
+ $result = sqlQueryEscaped('SELECT `id`, `subid` FROM `{?_MYSQL_PREFIX?}_user_subids` WHERE `userid`=%s ORDER BY `subid` ASC',
array(getMemberId()), __FUNCTION__, __LINE__);
// There should be entries left
- assert(!SQL_HASZERONUMS($result));
+ assert(!ifSqlHasZeroNums($result));
// Load all
$out = '';
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Load row template
$out .= loadTemplate('member_list_reflink_user_subids_row', TRUE, $row);
} // END - while
$content .= loadTemplate('member_list_reflink_user_subids', TRUE, $out);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return data
initSqls();
// Is a database link here and not in installation mode?
- if ((!SQL_IS_LINK_UP()) && (!isInstallationPhase())) {
+ if ((!isSqlLinkUp()) && (!isInstallationPhase())) {
// Abort here
reportBug(__FUNCTION__, __LINE__, 'No database link is up. Cannot flush filters.');
- } elseif ((isInstallationPhase()) && (!SQL_IS_LINK_UP())) {
+ } elseif ((isInstallationPhase()) && (!isSqlLinkUp())) {
// If the link is not up in installation phase, skip flushing filters
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters: No link is up.');
return;
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'FOUND:'.$filterName.'/'.$filterFunction.'='.$active);
if (((!isset($GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction])) && ($active != 'R')) || ($active == 'A')) {
// Is this filter already in database?
- if (countSumTotalData($filterFunction, 'filters', 'filter_name', 'filter_function', TRUE, sprintf(" AND `filter_name`='%s'", SQL_ESCAPE($filterName))) == 0) {
+ if (countSumTotalData($filterFunction, 'filters', 'filter_name', 'filter_function', TRUE, sprintf(" AND `filter_name`='%s'", sqlEscapeString($filterName))) == 0) {
// Add this filter (all filters are active by default)
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ADD:'.$filterName.'/'.$filterFunction);
$insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction);
if ((substr(strtolower($sql), 0, 11) == 'alter table') && (!isset($filterData['ext_installing']))) {
// Analyse the alteration command
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Alterting table: ' . $sql . ',enable_codes=' . intval($filterData['enable_codes']));
- SQL_ALTER_TABLE($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']);
+ sqlQueryAlterTable($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']);
} else {
// Run regular SQL command
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Running regular query: ' . $sql . ',enable_codes=' . intval($filterData['enable_codes']));
- SQL_QUERY($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']);
+ sqlQuery($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']);
}
// Has a line changed?
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Add it to total account
- $count += SQL_AFFECTEDROWS();
+ $count += sqlAffectedRows();
} // END - if
} // END - if
} // END - foreach
// Runs some generic filter update steps
function FILTER_UPDATE_EXTENSION_DATA ($ext_name) {
// Create task (we ignore the task id here)
- createExtensionUpdateTask(getCurrentAdminId(), $ext_name, $GLOBALS['update_ver'][$ext_name], SQL_ESCAPE(getExtensionNotes(getExtensionNotes())));
+ createExtensionUpdateTask(getCurrentAdminId(), $ext_name, $GLOBALS['update_ver'][$ext_name], sqlEscapeString(getExtensionNotes(getExtensionNotes())));
// Update extension's version
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_version`='%s' WHERE `ext_name`='%s' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_version`='%s' WHERE `ext_name`='%s' LIMIT 1",
array($GLOBALS['update_ver'][$ext_name], $ext_name), __FUNCTION__, __LINE__);
// Remove arrays
// Filter for removing the given extension
function FILTER_REMOVE_EXTENSION () {
// Delete this extension (remember to remove it from your server *before* you click on welcome!
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array(getCurrentExtensionName()), __FUNCTION__, __LINE__);
// Remove the extension from cache array as well
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getModule()=' . getModule() . ' - ENTERED!');
// Count module click
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `clicks`=`clicks`+1 WHERE `module`='%s' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `clicks`=`clicks`+1 WHERE `module`='%s' LIMIT 1",
array(getModule()), __FUNCTION__, __LINE__);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getModule()=' . getModule() . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS() . ' - EXIT!');
}
// Remmeber login failures if available
if (isExtensionInstalledAndNewer('user', '0.3.7')) {
// Reset login failures
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`login_failures`=0,
$GLOBALS['__page_header'] .= loadTemplate(getMenuModeFromModule() . '_metadata', TRUE);
// Add meta description to header
- if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP()) && (getModule() == 'index')) {
+ if ((isInstalled()) && (isAdminRegistered()) && (isSqlLinkUp()) && (getModule() == 'index')) {
// Add meta description not in admin and login module and when the script is installed
generateMetaDescriptionCode();
} // END - if
// Filter to add history entry
function FILTER_ADD_HISTORY_ENTRY ($filterData) {
// Add the entry
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_history` (`history_subject`, `history_userid`, `history_value`) VALUES ('%s',%s,'%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_history` (`history_subject`, `history_userid`, `history_value`) VALUES ('%s',%s,'%s')",
$filterData,
__FUNCTION__, __LINE__);
// Remember insert id for other filters
- $filterData['history_id'] = SQL_INSERT_ID();
+ $filterData['history_id'] = getSqlInsertId();
// Return data
return $filterData;
// Check required parameters
if ((isGetRequestElementSet('user')) && (isGetRequestElementSet('banner'))) {
// Update clicks counter...
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
// A line has been updated?
- if ((!SQL_HASZEROAFFECTED()) && (isGetRequestElementSet('user'))) {
+ if ((!ifSqlHasZeroAffectedRows()) && (isGetRequestElementSet('user'))) {
// Redirect to the user's referral link
redirectToUrl('ref.php?refid=' . bigintval(getRequestElement('user')));
} // END - if
// Are all required parameters set
if ((isGetRequestElementSet('user')) && (isGetRequestElementSet('banner'))) {
// For later things... ;-)
- $result = SQL_QUERY_ESC("SELECT `url` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `url` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
// Is there the banner?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load the URL
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Update counter
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `counter`=`counter`+1 WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `counter`=`counter`+1 WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('banner'))), __FUNCTION__, __LINE__);
// Set header and ...
logDebugMessage(__FUNCTION__, __LINE__, 'Banner ' . bigintval(getRequestElement('banner')) . ' not found.');
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Do nothing for now
// Is purging configured?
if ((isApServerNameEnabled()) && (getApServerNameSince() > 0)) {
// Then start purging
- SQL_QUERY('DELETE LOW_PRIORITY FROM
+ sqlQuery('DELETE LOW_PRIORITY FROM
`{?_MYSQL_PREFIX?}_server_name_log`
WHERE
(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`server_name_added`)) >= {?ap_server_name_since?}',
__FILE__, __LINE__);
// Are some entries deleted?
- if (SQL_AFFECTEDROWS() > 0) {
+ if (sqlAffectedRows() > 0) {
// Okay, then send an email to the admin
- sendAdminNotification('{--ADMIN_PURGE_USER_SERVER_NAME_LOG_SUBJECT--}', 'admin_purge_user_server_name_log', SQL_AFFECTEDROWS());
+ sendAdminNotification('{--ADMIN_PURGE_USER_SERVER_NAME_LOG_SUBJECT--}', 'admin_purge_user_server_name_log', sqlAffectedRows());
} // END - if
} // END - if
} // END - if
// Get all filters
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`filter_name`,
`filter_function`
FROM
`filter_function` ASC', __FILE__, __LINE__);
// Are there entries? (there should be!)
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Load row by row
- while ($filter = SQL_FETCHARRAY($result)) {
+ while ($filter = sqlFetchArray($result)) {
// Now search again for this filter and get it's total count
- $count = countSumTotalData($filter['filter_name'], 'filters', 'filter_id', 'filter_name', TRUE, sprintf(" AND `filter_function`='%s'", SQL_ESCAPE($filter['filter_function'])));
+ $count = countSumTotalData($filter['filter_name'], 'filters', 'filter_id', 'filter_name', TRUE, sprintf(" AND `filter_function`='%s'", sqlEscapeString($filter['filter_function'])));
// Is there more than one entry?
if ($count > 1) {
} // END - if
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Now insert our unqiue key
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_filters` DROP KEY `name_function`');
// Get all menus
foreach (array('guest','member','admin') as $menu) {
// Query it
- $result = SQL_QUERY_ESC("SELECT `action`, `what` FROM `{?_MYSQL_PREFIX?}_%s_menu` ORDER BY `action` ASC,`what` ASC",
+ $result = sqlQueryEscaped("SELECT `action`, `what` FROM `{?_MYSQL_PREFIX?}_%s_menu` ORDER BY `action` ASC,`what` ASC",
array($menu), __FILE__, __LINE__);
// Init array
$menus = array();
// Load all entries
- while ($entry = SQL_FETCHARRAY($result)) {
+ while ($entry = sqlFetchArray($result)) {
// Is the menu entry set?
if (!isset($menus['menu'][$entry['action']][$entry['what']])) {
// Not found
// Remove all except one
if (is_null($entry['what'])) {
// Main menu is double
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` IS NULL LIMIT %s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` IS NULL LIMIT %s",
array(
$menu,
$entry['action'],
), __FILE__, __LINE__);
} else {
// Sub menu is double
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what`='%s' LIMIT %s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what`='%s' LIMIT %s",
array(
$menu,
$entry['action'],
} // END - while
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Init sqls
initSqls();
} // END - if
// Sanity-check: Is there ref level 0? If so, this must be fixed to NULL and `level` must be increased by one
-$result = SQL_QUERY('SELECT `id` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `level`=0', __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result)) {
+$result = sqlQuery('SELECT `id` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `level`=0', __FILE__, __LINE__);
+if (!ifSqlHasZeroNums($result)) {
// Remove index temporaly
- SQL_ALTER_TABLE('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` DROP INDEX `userid_level`', __FILE__, __LINE__);
+ sqlQueryAlterTable('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` DROP INDEX `userid_level`', __FILE__, __LINE__);
// Upgrade refsystem
- SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `level`=`level`+1', __FILE__, __LINE__);
+ sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `level`=`level`+1', __FILE__, __LINE__);
// Add it again
- SQL_ALTER_TABLE('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` ADD UNIQUE INDEX `userid_level` (`userid`, `level`)', __FILE__, __LINE__);
+ sqlQueryAlterTable('ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` ADD UNIQUE INDEX `userid_level` (`userid`, `level`)', __FILE__, __LINE__);
// Rebuild cache
rebuildCache('refsystem', 'refsystem');
} // END - if
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Reset the table
-SQL_QUERY('TRUNCATE TABLE `{?_MYSQL_PREFIX?}_user_refs`', __FILE__, __LINE__);
+sqlQuery('TRUNCATE TABLE `{?_MYSQL_PREFIX?}_user_refs`', __FILE__, __LINE__);
// Begin with all users in level one
-$result_direct = SQL_QUERY('SELECT
+$result_direct = sqlQuery('SELECT
`userid`
FROM
`{?_MYSQL_PREFIX?}_user_data`
`userid` ASC', __FILE__, __LINE__);
// Are there entries?
-if (!SQL_HASZERONUMS($result_direct)) {
+if (!ifSqlHasZeroNums($result_direct)) {
// When 'walk' through all users
- while ($content = SQL_FETCHARRAY($result_direct)) {
+ while ($content = sqlFetchArray($result_direct)) {
// Update refback table
/* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'userid=' . $content['userid'] . ' - BEFORE!');
updateReferralTable($content['userid']);
} // END - if
// Free result
-SQL_FREERESULT($result_direct);
+sqlFreeResult($result_direct);
// [EOF]
?>
} // END - if
// Get all user points
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`userid`,
`points`,
`locked_points`,
`userid` ASC', __FILE__, __LINE__);
// Are there entries? (there should be!)
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Load row by row
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Update the database again
foreach (array_keys($row) as $column) {
// Not userid itself
if ($column != 'userid') {
// Update amount
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth` IS NULL",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth` IS NULL",
array(
$column,
$column,
), __FILE__, __LINE__);
// Nothing has been updated?
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// Then insert it
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`, `ref_depth`, `%s`) VALUES (%s,NULL,%s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`, `ref_depth`, `%s`) VALUES (%s,NULL,%s)",
array(
$column,
$row['userid'],
} // END - if
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Remove all entries
-SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `ref_depth`=0', __FILE__, __LINE__);
+sqlQuery('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `ref_depth`=0', __FILE__, __LINE__);
// [EOF]
?>
runFilterChain('shutdown', NULL);
// Check if link is up
- if (SQL_IS_LINK_UP()) {
+ if (isSqlLinkUp()) {
// Close link
- SQL_CLOSE(__FUNCTION__, __LINE__);
+ sqlCloseLink(__FUNCTION__, __LINE__);
} elseif (!isInstallationPhase()) {
// No database link
reportBug(__FUNCTION__, __LINE__, 'Database link is already down, while shutdown is running.');
// Map only these, still lame code...
switch ($moduleName) {
case 'index': // 'index' is the guest's menu
- $moduleName = 'guest';
+ $moduleName = 'guest';
break;
case 'login': // ... and 'login' the member's menu
// Check it and cache it in $GLOBALS
$GLOBALS['debug_sql_available'] = ((isConfigurationLoaded()) && (isDisplayDebugSqlEnabled()));
} // END - if
-
+
// Don't execute anything here if we don't need or ext-other is missing
if ($GLOBALS['debug_sql_available'] === FALSE) {
return;
// Generate record
$record = array(
- 'num_rows' => SQL_NUMROWS($result),
- 'affected' => SQL_AFFECTEDROWS(),
+ 'num_rows' => sqlNumRows($result),
+ 'affected' => sqlAffectedRows(),
'sql_str' => $sqlString,
'timing' => $timing,
'file' => basename($F),
// Is the mail type supported?
if (!empty($table)) {
// Query for the mail
- $result = SQL_QUERY_ESC("SELECT `id`, `%s` AS `mail_status` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `%s` AS `mail_status` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `id`=%s LIMIT 1",
array(
$statusColumn,
$table,
), __FILE__, __LINE__);
// Is there one entry there?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load the entry
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Add output and type
$content['type'] = $mailType;
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return generated HTML code
doGenericAddEntries($tableName, $columns, $filterFunctions, $extraValues, $timeColumns, $columnIndex);
// Entry has been added?
- if ((!SQL_HASZEROAFFECTED()) && ($GLOBALS['__XML_PARSE_RESULT'] === TRUE)) {
+ if ((!ifSqlHasZeroAffectedRows()) && ($GLOBALS['__XML_PARSE_RESULT'] === TRUE)) {
// Display success message
displayMessage('{--MEMBER_ENTRY_ADDED--}');
} else {
displayMessage('{--MEMBER_ALL_ENTRIES_REMOVED--}');
} else {
// Some are still there :(
- displayMessage(sprintf(getMessage('MEMBER_SOME_ENTRIES_NOT_DELETED'), SQL_AFFECTEDROWS(), countPostSelection($idColumn[0])));
+ displayMessage(sprintf(getMessage('MEMBER_SOME_ENTRIES_NOT_DELETED'), sqlAffectedRows(), countPostSelection($idColumn[0])));
}
} else {
// List for deletion confirmation
/**
* Compress given data and encodes it into BASE64 to be stored in database with
- * SQL_QUERY_ESC()
+ * sqlQueryEscaped()
*
* @param $data Data to be compressed and encoded
* @return $data Compressed+encoded data
);
// Check for normal mails
-$result_media = SQL_QUERY('SELECT
+$result_media = sqlQuery('SELECT
SUM(`max_rec`) AS `normal_send`,
SUM(`clicks`) AS `normal_clicks`
FROM
`{?_MYSQL_PREFIX?}_user_stats`', __FILE__, __LINE__);
// Merge data together
-$content = merge_array($content, SQL_FETCHARRAY($result_media));
+$content = merge_array($content, sqlFetchArray($result_media));
// Free memory
-SQL_FREERESULT($result_media);
+sqlFreeResult($result_media);
// Check for bonus extension
if (isExtensionActive('bonus')) {
$bcount = countSumTotalData('', 'bonus', 'id', '', TRUE);
// Check for bonus mails
- $result_media = SQL_QUERY('SELECT
+ $result_media = sqlQuery('SELECT
SUM(`mails_send`) AS `bonus_send`,
SUM(`clicks`) AS `bonus_clicks`
FROM
LIMIT 1', __FILE__, __LINE__);
// Merge data together
- $content = merge_array($content, SQL_FETCHARRAY($result_media));
+ $content = merge_array($content, sqlFetchArray($result_media));
// Free memory
- SQL_FREERESULT($result_media);
+ sqlFreeResult($result_media);
} // END - if
// Load (maybe) missing file
// Is ext-sql_patches at least version 0.9.2?
if (isExtensionInstalledAndNewer('sql_patches', '0.9.2')) {
// Is there an entry?
- if (countSumTotalData(detectServerName(), 'server_name_log', 'server_name_id', 'server_name', TRUE, str_replace('%', '{PER}', sprintf(" AND `server_name_remote_addr`='%s' AND `server_name_ua`='%s' AND `server_name_referrer`='%s'", SQL_ESCAPE(detectRemoteAddr(TRUE)), SQL_ESCAPE(detectUserAgent(TRUE)), SQL_ESCAPE(detectReferer(TRUE))))) == 1) {
+ if (countSumTotalData(detectServerName(), 'server_name_log', 'server_name_id', 'server_name', TRUE, str_replace('%', '{PER}', sprintf(" AND `server_name_remote_addr`='%s' AND `server_name_ua`='%s' AND `server_name_referrer`='%s'", sqlEscapeString(detectRemoteAddr(TRUE)), sqlEscapeString(detectUserAgent(TRUE)), sqlEscapeString(detectReferer(TRUE))))) == 1) {
// Update counter, as all are the same
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_server_name_log`
SET
`server_name_counter`=`server_name_counter`+1
), __FUNCTION__, __LINE__);
} else {
// Then log it away
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_server_name_log` (`server_name`, `server_name_remote_addr`, `server_name_ua`, `server_name_referrer`) VALUES('%s','%s', '%s', '%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_server_name_log` (`server_name`, `server_name_remote_addr`, `server_name_ua`, `server_name_referrer`) VALUES('%s','%s', '%s', '%s')",
array(
detectServerName(),
detectRemoteAddr(TRUE),
unsetSqlLinkUp(__FUNCTION__, __LINE__);
// Try to connect to the database
- SQL_CONNECT(postRequestElement('mysql_host'), postRequestElement('mysql_login'), postRequestElement('mysql_password1'), __FUNCTION__, __LINE__);
+ sqlConnectToDatabase(postRequestElement('mysql_host'), postRequestElement('mysql_login'), postRequestElement('mysql_password1'), __FUNCTION__, __LINE__);
// Is the link up
- if (!SQL_IS_LINK_UP()) {
+ if (!isSqlLinkUp()) {
// Cannot connect to database
$GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_CONNECT_ERROR--}';
array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_login', 'mysql_password1', 'mysql_password2');
} // END - if
// Then attempt to select the database
- if (!SQL_SELECT_DB(postRequestElement('mysql_dbase'), __FUNCTION__, __LINE__)) {
+ if (!sqlSelectDatabase(postRequestElement('mysql_dbase'), __FUNCTION__, __LINE__)) {
// Could not find database
$GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_SELECT_FAILED--}';
array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_dbase');
// Disconnect here, we don't need idle database connections laying around
- SQL_CLOSE(__FUNCTION__, __LINE__);
+ sqlCloseLink(__FUNCTION__, __LINE__);
// Abort here
return FALSE;
array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_engine');
// Disconnect here, we don't need idle database connections laying around
- SQL_CLOSE(__FUNCTION__, __LINE__);
+ sqlCloseLink(__FUNCTION__, __LINE__);
// Abort here
return FALSE;
array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_engine');
// Disconnect here, we don't need idle database connections laying around
- SQL_CLOSE(__FUNCTION__, __LINE__);
+ sqlCloseLink(__FUNCTION__, __LINE__);
// Abort here
return FALSE;
array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_engine');
// Disconnect here, we don't need idle database connections laying around
- SQL_CLOSE(__FUNCTION__, __LINE__);
+ sqlCloseLink(__FUNCTION__, __LINE__);
// Abort here
return FALSE;
$isValid = (count($tables) == $missingTables);
// Disconnect here, we don't need idle database connections laying around
- SQL_CLOSE(__FUNCTION__, __LINE__);
+ sqlCloseLink(__FUNCTION__, __LINE__);
// If the status is true, disconnect the database
if ($isValid === FALSE) {
unsetSqlLinkUp(__FILE__, __LINE__);
// Connect to database server
- SQL_CONNECT($GLOBALS['install_mysql']['host'], $GLOBALS['install_mysql']['login'], $GLOBALS['install_mysql']['password1'], __FILE__, __LINE__);
+ sqlConnectToDatabase($GLOBALS['install_mysql']['host'], $GLOBALS['install_mysql']['login'], $GLOBALS['install_mysql']['password1'], __FILE__, __LINE__);
// Is the link up?
- if (SQL_IS_LINK_UP()) {
+ if (isSqlLinkUp()) {
// Seems to work, also right database?
- if (SQL_SELECT_DB($GLOBALS['install_mysql']['dbase'], __FILE__, __LINE__) === TRUE) {
+ if (sqlSelectDatabase($GLOBALS['install_mysql']['dbase'], __FILE__, __LINE__) === TRUE) {
// Check for dumps
if ((!isFileReadable(postRequestElement('spath') . 'install/tables.sql')) || (!isFileReadable(postRequestElement('spath') . 'install/menu-'.getLanguage().'.sql'))) {
// Installation area not found
'ADMIN_REGISTER_DONE' => "Das Admin-Account wurde soeben erstellt. Sie können sich nun mit den eingegeben Login-Daten einloggen.",
'ADMIN_CANNOT_COMPLETE' => "Kann die Regsitrierung des Admin-Accounts nicht abschliessen.",
'ADMIN_LOGIN_TITLE' => "Einloggen zum Administrationsbereich",
- 'ADMIN_LOGIN_NOW' => "Sie können sich nun in den Administratorbereich einloggen. Geben Sie Ihren Admin-Login und das Passwort dazu ein.",
+ 'ADMIN_LOGIN_NOW' => "Login zum Administratorbereich. Geben Sie Ihren Admin-Login und das Passwort dazu ein.",
'ENTER_ADMIN_LOGIN' => "Administrator-Login",
'ENTER_ADMIN_PASS' => "Passwort zum Admin-Account",
'ADMIN_LOGIN_SUBMIT' => "Einloggen",
'ADMIN_EXTENSION_INITIAL_RELEASE' => "Erstes Release fertiggestellt.",
'ADMIN_EXTENSION_DEVELOPER_RELEASE' => "Entwickler-Version zum Testen.",
'ADMIN_EXTENSION_UPDATE_NOTICES_404' => "Keine Update-Hinweise gefunden.",
- 'MYSQL_QUERY_STRING' => "SQL-Abfragebefehl war:",
+ 'MYsqlQuery_STRING' => "SQL-Abfragebefehl war:",
'MEMBER_NO_MAILS_IN_POOL' => "Sie haben noch keine Mailbuchungen aufgegeben! Es können somit Ihnen auch keine angezeigt werden.",
'ADMIN_BACK_TO_GUEST_MENU' => "Zum Gastmenü zurück...",
'ADMIN_LOGOUT_NOW' => "Aus dem Admin-Bereich ausloggen",
$result = FALSE;
if (!empty($action)) {
// Main menu
- $result = SQL_QUERY_ESC("SELECT `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `admin_id`=%s AND `action_menu`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `admin_id`=%s AND `action_menu`='%s' LIMIT 1",
array(bigintval($adminId), $action), __FUNCTION__, __LINE__);
} elseif (!empty($what)) {
// Sub menu
- $result = SQL_QUERY_ESC("SELECT `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `admin_id`=%s AND `what_menu`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `admin_id`=%s AND `what_menu`='%s' LIMIT 1",
array(bigintval($adminId), $what), __FUNCTION__, __LINE__);
}
// Is an entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load ACL
- list($aclMode) = SQL_FETCHROW($result);
+ list($aclMode) = sqlFetchRow($result);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// But default result is failed
// Is it an email?
if (isInString('@', $email)) {
// Create email link
- $result = SQL_QUERY_ESC("SELECT `id`
+ $result = sqlQueryEscaped("SELECT `id`
FROM
`{?_MYSQL_PREFIX?}_admins`
WHERE
array($email), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load userid
- list($adminId) = SQL_FETCHROW($result);
+ list($adminId) = sqlFetchRow($result);
// Call this function again
$email = generateAdminEmailLink($adminId, $mod);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} elseif (isValidId($email)) {
// Direct id given
$email = '{%url=modules.php?module=' . $mod . '&what=admins_contct&id=' . bigintval($email) . '%}';
// When both passwords match update admin account
if ((!empty($element)) && (isset($postData[$element]))) {
// Save this setting
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
array(
$element,
$postData[$element][$id],
// Save password when set
if (!empty($postData['password1'][$id])) {
- $add = sprintf(",`password`='%s'", SQL_ESCAPE($hash));
+ $add = sprintf(",`password`='%s'", sqlEscapeString($hash));
} // END - if
// Get admin's id
// Update admin account
if ($default == 'allow') {
// Allow changing default ACL
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_admins`
SET
`login`='%s'" . $add . ",
), __FUNCTION__, __LINE__);
} else {
// Do not allow it here
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_admins`
SET
`login`='%s'" . $add . ",
$SQL = getUpdateSqlFromArray($postData, 'admins', 'id', '%s', array('login', 'id'), $id);
// Run it
- SQL_QUERY_ESC($SQL, array(bigintval($id)), __FUNCTION__, __LINE__);
+ sqlQueryEscaped($SQL, array(bigintval($id)), __FUNCTION__, __LINE__);
// Was it updated?
- if (SQL_AFFECTEDROWS() == 1) {
+ if (sqlAffectedRows() == 1) {
// Admin account saved
$message = '{--ADMIN_ACCOUNT_SAVED--}';
} else {
$id = bigintval($id);
// Get the admin's data
- $result = SQL_QUERY_ESC('SELECT `login`, `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
+ $result = sqlQueryEscaped('SELECT `login`, `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
array($id), __FUNCTION__, __LINE__);
- if ((SQL_NUMROWS($result) == 1) && ($selected == 1)) {
+ if ((sqlNumRows($result) == 1) && ($selected == 1)) {
// Entry found
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Prepare some more data for the template
$content['id'] = $id;
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
// Load template
$id = bigintval($id);
// Get the admin's data
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`login`,
`email`,
`default_acl` AS `access_mode`,
array($id), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Entry found, so load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
$content['access_mode'] = '{--ADMIN_ADMINS_ACCESS_MODE_' . strtoupper($content['access_mode']) . '--}';
$content['la_mode'] = '{--ADMIN_ADMINS_LA_MODE_' . strtoupper($content['la_mode']) . '--}';
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
// Load template
// Delete only when it's not your own account!
if (($del == 1) && (getCurrentAdminId() != $id)) {
// Rewrite his tasks to all admins
- SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=NULL WHERE `assigned_admin`=%s',
+ sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=NULL WHERE `assigned_admin`=%s',
array($id), __FUNCTION__, __LINE__);
// Remove account
- SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
+ sqlQueryEscaped('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
array($id), __FUNCTION__, __LINE__);
}
}
// List all admin accounts
function adminsListAdminAccounts() {
// Select all admin accounts
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`login`,
`email`,
ORDER BY
`login` ASC', __FUNCTION__, __LINE__);
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Compile some variables
$content['access_mode'] = '{--ADMIN_ADMINS_ACCESS_MODE_' . strtoupper($content['access_mode']) . '--}';
$content['la_mode'] = '{--ADMIN_ADMINS_LA_MODE_' . strtoupper($content['la_mode']) . '--}';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
loadTemplate('admin_list_admins', FALSE, $OUT);
$message = loadEmailTemplate($template, $content, $userid);
// Check which admin shall receive this mail
- $result = SQL_QUERY_ESC("SELECT `admin_id` FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE `mail_template`='%s' ORDER BY `admin_id` ASC",
+ $result = sqlQueryEscaped("SELECT `admin_id` FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE `mail_template`='%s' ORDER BY `admin_id` ASC",
array($template), __FUNCTION__, __LINE__);
// No entries found?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Is ext-admins' version at least 0.7.9?
if (isExtensionInstalledAndNewer('admins', '0.7.9')) {
// Create new entry (to all admins)
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (`admin_id`, `mail_template`) VALUES (NULL, '%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (`admin_id`, `mail_template`) VALUES (NULL, '%s')",
array($template), __FUNCTION__, __LINE__);
} // END - if
// Select all email adresses (default)
- $result = SQL_QUERY('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC',
+ $result = sqlQuery('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC',
__FUNCTION__, __LINE__);
} else {
// Load admin ids...
// @TODO This can be, somehow, rewritten
$adminIds = array();
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
array_push($adminIds, $content['admin_id']);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Init result
$result = FALSE;
return;
} elseif (($adminId == '0') || (empty($adminId))) {
// Select all email adresses
- $result = SQL_QUERY('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC',
+ $result = sqlQuery('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC',
__FUNCTION__, __LINE__);
} else {
// If Admin-Id is not "to-all" select
- $result = SQL_QUERY_ESC('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id` IN (%s) ORDER BY `id` ASC',
+ $result = sqlQueryEscaped('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id` IN (%s) ORDER BY `id` ASC',
array($adminId), __FUNCTION__, __LINE__);
}
}
} // END - if
// Load email addresses and send away
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
sendEmail($content['email'], $subject, $message, 'N', $mailHeader);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// "Getter" for current admin's expert settings
incrementStatsEntry('cache_hits');
} elseif (!isExtensionInstalled('cache')) {
// Load from database
- $result = SQL_QUERY_ESC('SELECT `expert_settings` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
+ $result = sqlQueryEscaped('SELECT `expert_settings` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
array($adminId), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Fetch data
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set cache
$GLOBALS['cache_array']['admin']['expert_settings'][$adminId] = $data['expert_settings'];
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return the result
incrementStatsEntry('cache_hits');
} elseif (!isExtensionInstalled('cache')) {
// Load from database
- $result = SQL_QUERY_ESC('SELECT `expert_warning` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
+ $result = sqlQueryEscaped('SELECT `expert_warning` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
array($adminId), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Fetch data
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set cache
$GLOBALS['cache_array']['admin']['expert_warning'][$adminId] = $data['expert_warning'];
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return the result
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result = SQL_QUERY_ESC('SELECT `login_failures` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
+ $result = sqlQueryEscaped('SELECT `login_failures` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
array($adminId), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Get it
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return the login_failures
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result = SQL_QUERY_ESC('SELECT UNIX_TIMESTAMP(`last_failure`) AS `last_failure` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
+ $result = sqlQueryEscaped('SELECT UNIX_TIMESTAMP(`last_failure`) AS `last_failure` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1',
array($adminId), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Get it
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return the last_failure
// Is begging rallye active?
if (isBegRallyeEnabled()) {
// Add points to rallye account
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=`beg_points`+%s WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=`beg_points`+%s WHERE `userid`=%s LIMIT 1",
array($points, $userid), __FUNCTION__, __LINE__);
// We need to set $add here, two
- $added = (!SQL_HASZEROAFFECTED());
+ $added = (!ifSqlHasZeroAffectedRows());
} else {
// Add points to account
initReferralSystem();
return FALSE;
} elseif (!isset($GLOBALS['blacklist_data'][$type][$data])) {
// Check black-list for given email
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`data`,
`pool_id`,
), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Jupp, we got one listed
- $GLOBALS['blacklist_data'][$type][$data] = SQL_FETCHARRAY($result);
+ $GLOBALS['blacklist_data'][$type][$data] = sqlFetchArray($result);
// Mark it as listed
$listed = TRUE;
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Is found in cache -> black-listed
$listed = TRUE;
reportBug(__FUNCTION__, __LINE__, 'Blacklisting of type ' . $type . ' is disabled, data=' . $data . ',poolId=' . convertZeroToNull($poolId));
} elseif (!isUrlBlacklisted($data)) {
// Did not find a record so we can add it... :)
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_blacklist`
(
`data`,
} // END - if
// Return insert id for debugging/reporting pursposes
- return SQL_INSERT_ID();
+ return getSqlInsertId();
}
// ----------------------------------------------------------------------------
}
// Add points to his account directly
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `turbo_bonus`=`turbo_bonus`+%s WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `turbo_bonus`=`turbo_bonus`+%s WHERE `userid`=%s LIMIT 1",
array(
$points,
bigintval($userid)
), __FUNCTION__, __LINE__);
// Rember this whole data for displaying ranking list
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus_turbo` (`userid`, `mail_id`, `bonus_id`, `level`, `points`, `timemark`) VALUES (%s, %s, %s, %s, %s, UNIX_TIMESTAMP())",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_bonus_turbo` (`userid`, `mail_id`, `bonus_id`, `level`, `points`, `timemark`) VALUES (%s, %s, %s, %s, %s, UNIX_TIMESTAMP())",
array(
bigintval($userid),
$mailId,
$ranks = count(explode(';', getTurboRates())) + 1;
// Load current user's data
- $result = SQL_QUERY_ESC("SELECT `level`, `points`, `timemark` FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `%s`=%s AND `userid`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `level`, `points`, `timemark` FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `%s`=%s AND `userid`=%s LIMIT 1",
array(
$type,
$data,
), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- $GLOBALS['ranking_content'] = merge_array($GLOBALS['ranking_content'], SQL_FETCHARRAY($result));
+ $GLOBALS['ranking_content'] = merge_array($GLOBALS['ranking_content'], sqlFetchArray($result));
// Remember all values for later use
$self = TRUE;
} // END - if
// Load rankings
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `%s`=%s ORDER BY `level` ASC LIMIT {?bonus_lines?}",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `%s`=%s ORDER BY `level` ASC LIMIT {?bonus_lines?}",
array($type, $data), __FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Output all ranks (levels)
- for ($rank = 1; $rank <= SQL_NUMROWS($result); $rank++) {
+ for ($rank = 1; $rank <= sqlNumRows($result); $rank++) {
// Load data
- $result_users = SQL_QUERY_ESC("SELECT
+ $result_users = sqlQueryEscaped("SELECT
`userid`,
`points`
FROM
$rows['points'] = '---';
// Are you one of them?
- if (SQL_NUMROWS($result_users) == 1) {
+ if (sqlNumRows($result_users) == 1) {
// Load data
- $rows = merge_array($rows, SQL_FETCHARRAY($result_users));
+ $rows = merge_array($rows, sqlFetchArray($result_users));
} // END - if
// Free result
- SQL_FREERESULT($result_users);
+ sqlFreeResult($result_users);
// Add more
$rows['rank'] = $rank;
// Purges expired fast-click bonus entries
function purgeExpiredTurboBonus () {
// Remove entries
- $result = SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE (UNIX_TIMESTAMP() - `timemark`) >= {?bonus_timeout?}', __FUNCTION__, __LINE__);
+ $result = sqlQuery('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE (UNIX_TIMESTAMP() - `timemark`) >= {?bonus_timeout?}', __FUNCTION__, __LINE__);
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Send out email to admin
- sendAdminNotification('{--ADMIN_AUTOPURGE_TURBO_SUBJECT--}', 'admin_purge_turbo', SQL_AFFECTEDROWS());
+ sendAdminNotification('{--ADMIN_AUTOPURGE_TURBO_SUBJECT--}', 'admin_purge_turbo', sqlAffectedRows());
} // END - if
}
} // END - if
// Add record entry here
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_booking` (`userid`, `subject`, `points_mode`, `points_account_type`, `points`) VALUES (%s, '%s', '%s', '%s', %s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_booking` (`userid`, `subject`, `points_mode`, `points_account_type`, `points`) VALUES (%s, '%s', '%s', '%s', %s)",
array(
bigintval($userid),
$subject,
$ret = '{--COUNTRY_CODE_404--}';
// Load code and description
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`code`,
`descr`
FROM
array(bigintval($id)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load entry
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
//* DEBUG: */ print($id.'=<pre>'.print_r($content, TRUE).'</pre>');
// Construct human-readable description
} // END - if
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return info
return $ret;
}
// List entries
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`userid`,
`refid`,
`points`,
$limit
), __FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List entries
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Rewrite userid/refid only if admin is in
// @TODO Can't this be moved into EL?
if (isAdmin()) {
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// List no entries
$OUT = '<tr>
// Insert member earning entry
function insertMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') {
// Insert the record
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_earning` (`earning_id`, `earning_userid`, `earning_daily_amount`, `earning_active`) VALUES(%s,%s,%s,'%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_earning` (`earning_id`, `earning_userid`, `earning_daily_amount`, `earning_active`) VALUES(%s,%s,%s,'%s')",
array(
bigintval($earningId),
getMemberId(),
// Prepare content
$content = array(
- 'insert_id' => SQL_INSERT_ID(),
+ 'insert_id' => getSqlInsertId(),
'earning_id' => bigintval($earningId),
'daily_amount' => bigintval($dailyAmount),
'is_active' => $isActive
} // END - if
// Update database record
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_earning`
SET
`earning_daily_amount`=%s,
), __FUNCTION__, __LINE__);
// Determine whether something has changed
- $status = (!SQL_HASZEROAFFECTED());
+ $status = (!ifSqlHasZeroAffectedRows());
// Has the record changed?
if ($status === TRUE) {
// Is forced type not NULL?
if (!is_null($forcedType)) {
// Then set proper WHERE
- $where = sprintf("WHERE `forced_ads_type`='%s'", SQL_ESCAPE($forcedType));
+ $where = sprintf("WHERE `forced_ads_type`='%s'", sqlEscapeString($forcedType));
} // END - if
// Search all given types
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`forced_ads_id`,
`forced_ads_ad_url`,
`forced_ads_click_url`,
`forced_ads_id` ASC', __FUNCTION__, __LINE__);
// Is there at least one entry?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Get all elements
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add it
$forcedAds[$content['forced_ads_id']] = $content;
} // END - while
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return it
return $forcedAds;
// Is visibility not NULL?
if (!is_null($visibility)) {
// Then add WHERE statement
- $where = sprintf(" WHERE `forced_costs_visibility`='%s'", SQL_ESCAPE($visibility));
+ $where = sprintf(" WHERE `forced_costs_visibility`='%s'", sqlEscapeString($visibility));
} // END - if
// Search all given types
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`forced_costs_id`,
`forced_costs_price_click`,
`forced_costs_payment_click`,
`forced_costs_id` ASC", __FUNCTION__, __LINE__);
// Is there at least one entry?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Get all elements
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add it
$forcedCosts[$content['forced_costs_id']] = $content;
} // END - while
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return it
return $forcedCosts;
$forcedCampaigns = array();
// Search all given types
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`forced_campaign_id`,
UNIX_TIMESTAMP(`forced_campaign_created`) AS `forced_campaign_created`,
`forced_campaign_status`,
), __FUNCTION__, __LINE__);
// Is there at least one entry?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Get all elements
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add it
$forcedCampaigns[$content['forced_campaign_id']] = $content;
} // END - while
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return it
return $forcedCampaigns;
// Update the status now
// ---------- Comment out for debugging/developing member actions! ---------
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_forced_campaigns` SET `forced_campaign_status`='%s' WHERE `forced_campaign_id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_forced_campaigns` SET `forced_campaign_status`='%s' WHERE `forced_campaign_id`=%s LIMIT 1",
array(
$newStatus,
bigintval($campaignId)
// 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
} // END - if
// Look for all
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`grade_id`,
`grade_name`
FROM
$gradeValues = array();
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all entries
- while ($grade = SQL_FETCHARRAY($result)) {
+ while ($grade = sqlFetchArray($result)) {
// Add it to arrays
array_push($gradeKeys , $grade['grade_id']);
array_push($gradeValues, $grade['grade_name']);
);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return cache
// Stops all expired holidays
function stopHolidays () {
// Let's find some expired holiday requests...
- $result_stop = SQL_QUERY("SELECT
+ $result_stop = sqlQuery("SELECT
`userid`,
`holiday_start`,
`holiday_end`,
`holiday_end` <= UNIX_TIMESTAMP()
ORDER BY
`userid` ASC", __FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result_stop)) {
+ if (!ifSqlHasZeroNums($result_stop)) {
// We foud at least one
$admin = '';
initSqls();
// Process all found entries
- while ($content = SQL_FETCHARRAY($result_stop)) {
+ while ($content = sqlFetchArray($result_stop)) {
// Stop holiday
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_holidays` WHERE `userid`=%s LIMIT 1",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_holidays` WHERE `userid`=%s LIMIT 1",
array(bigintval($content['userid'])), __FUNCTION__, __LINE__, FALSE));
// Unlock account
- addSql(SQL_QUERY_ESC("UPDATE
+ addSql(sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`holiday_active`='N',
} // END - if
// Free memory
- SQL_FREERESULT($result_stop);
+ sqlFreeResult($result_stop);
}
// ----------------------------------------------------------------------------
$data['points'] = '0.00000';
// Read them
- $result = SQL_QUERY("SELECT `points` FROM `{?_MYSQL_PREFIX?}_jackpot` WHERE `ok`='ok' LIMIT 1", __FUNCTION__, __LINE__);
+ $result = sqlQuery("SELECT `points` FROM `{?_MYSQL_PREFIX?}_jackpot` WHERE `ok`='ok' LIMIT 1", __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// No, so create line
- SQL_QUERY("INSERT INTO `{?_MYSQL_PREFIX?}_jackpot` (`ok`, `points`) VALUES ('ok','0.00000')", __FUNCTION__, __LINE__);
+ sqlQuery("INSERT INTO `{?_MYSQL_PREFIX?}_jackpot` (`ok`, `points`) VALUES ('ok','0.00000')", __FUNCTION__, __LINE__);
} else {
// Read the line
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return them
return $data['points'];
$jackpot = getJackpotPoints();
// Update points
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_jackpot` SET `points`=`points`+%s WHERE `ok`='ok' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_jackpot` SET `points`=`points`+%s WHERE `ok`='ok' LIMIT 1",
array($points), __FUNCTION__, __LINE__);
}
// Enougth points i jackpot?
if ($jackpot >= $points) {
// Update points when there are enougth points in jackpot
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_jackpot` SET `points`=`points`-%s WHERE `ok`='ok' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_jackpot` SET `points`=`points`-%s WHERE `ok`='ok' LIMIT 1",
array($points), __FUNCTION__, __LINE__);
- $ret = (!SQL_HASZEROAFFECTED());
+ $ret = (!ifSqlHasZeroAffectedRows());
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return the result
return $ret;
// @TODO Rewrite this to a filter
switch ($data['link_type']) {
case 'NORMAL':
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1",
array(bigintval($data['id'])), __FILE__, __LINE__);
// Update mediadata as well
break;
case 'BONUS':
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1",
array(bigintval($data['id'])), __FILE__, __LINE__);
// Update mediadata as well
// @TODO Rewrite these blocks to filter
if (isExtensionInstalledAndNewer('user', '0.1.2')) {
// Update counter
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mails_confirmed`=`mails_confirmed`+1 WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mails_confirmed`=`mails_confirmed`+1 WHERE `userid`=%s LIMIT 1",
array(bigintval($data['userid'])), __FILE__, __LINE__);
// Update random confirmed as well?
if ((isExtensionInstalledAndNewer('user', '0.3.4')) && (isRandomReferralIdEnabled())) {
// Update second counter
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=`rand_confirmed` + 1 WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=`rand_confirmed` + 1 WHERE `userid`=%s LIMIT 1",
array(bigintval($data['userid'])), __FILE__, __LINE__);
} // END - if
} // END - if
} // END - if
// Count down ref_payout value
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_payout`=`ref_payout`-1 WHERE `userid`=%s AND `ref_payout` > 0 LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_payout`=`ref_payout`-1 WHERE `userid`=%s AND `ref_payout` > 0 LIMIT 1",
array(bigintval($data['userid'])), __FILE__, __LINE__);
// Add points
}
// Remove link from table
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `id`=%s LIMIT 1",
array(bigintval($data['link_id'])), __FILE__, __LINE__);
}
// Is an array so we can run it through
foreach ($keys_array as $key) {
// First check if it does exist
- $result_media = SQL_QUERY_ESC("SELECT
+ $result_media = sqlQueryEscaped("SELECT
`media_key`
FROM
`{?_MYSQL_PREFIX?}_mediadata`
`media_key`='%s'
LIMIT 1", array($key), __FUNCTION__, __LINE__);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',SQL_NUMROWS()=' . SQL_NUMROWS($result_media));
- if (SQL_NUMROWS($result_media) == 0) {
+ if (sqlNumRows($result_media) == 0) {
// Not found so we create it (mode will be ignored here!)
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mediadata` (`media_key`, `media_value`) VALUES ('%s', '%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_mediadata` (`media_key`, `media_value`) VALUES ('%s', '%s')",
array($key, $value), __FUNCTION__, __LINE__);
} else {
// Update entry
if ($mode == 'init') {
// Initialize entry
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_mediadata` SET `media_value`=%s WHERE `media_key`='%s' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_mediadata` SET `media_value`=%s WHERE `media_key`='%s' LIMIT 1",
array($value, $key), __FUNCTION__, __LINE__);
} else {
// Update entry
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_mediadata` SET `media_value`=`media_value`".$mode."%s WHERE `media_key`='%s' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_mediadata` SET `media_value`=`media_value`".$mode."%s WHERE `media_key`='%s' LIMIT 1",
array($value, $key), __FUNCTION__, __LINE__);
}
}
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added=' . intval($added));
- $added = (!SQL_HASZEROAFFECTED());
+ $added = (!ifSqlHasZeroAffectedRows());
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added=' . intval($added));
} // END - foreach
} // END - if
$value = '';
// Check for entry
- $result = SQL_QUERY_ESC("SELECT `media_value` FROM `{?_MYSQL_PREFIX?}_mediadata` WHERE `media_key`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `media_value` FROM `{?_MYSQL_PREFIX?}_mediadata` WHERE `media_key`='%s' LIMIT 1",
array($key), __FUNCTION__, __LINE__);
// Is there one?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- list($value) = SQL_FETCHROW($result);
+ list($value) = sqlFetchRow($result);
} // END - if
// Return data
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$networkId][$type])) {
// Does it exist?
- $GLOBALS[__FUNCTION__][$networkId][$type] = (countSumTotalData(bigintval($networkId), 'network_types', 'network_type_id', 'network_id', TRUE, sprintf(" AND `network_type_handler`='%s'", SQL_ESCAPE($type))) == 1);
+ $GLOBALS[__FUNCTION__][$networkId][$type] = (countSumTotalData(bigintval($networkId), 'network_types', 'network_type_id', 'network_id', TRUE, sprintf(" AND `network_type_handler`='%s'", sqlEscapeString($type))) == 1);
} // END - if
// Return result
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$networkId][$networkTypeId][$key])) {
// Does it exist?
- $GLOBALS[__FUNCTION__][$networkId][$networkTypeId][$key] = (countSumTotalData(bigintval($networkId), 'network_request_params', 'network_request_param_id', 'network_id', TRUE, sprintf(" AND `network_type_id`=%s AND `network_request_param_key`='%s'", bigintval($networkTypeId), SQL_ESCAPE($key))) == 1);
+ $GLOBALS[__FUNCTION__][$networkId][$networkTypeId][$key] = (countSumTotalData(bigintval($networkId), 'network_request_params', 'network_request_param_id', 'network_id', TRUE, sprintf(" AND `network_type_id`=%s AND `network_request_param_key`='%s'", bigintval($networkTypeId), sqlEscapeString($key))) == 1);
} // END - if
// Return result
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$networkId][$networkTypeId][$key])) {
// Does it exist?
- $GLOBALS[__FUNCTION__][$networkId][$networkTypeId][$key] = (countSumTotalData(bigintval($networkId), 'network_array_translation', 'network_array_id', 'network_id', TRUE, sprintf(" AND `network_type_id`=%s AND `network_array_index`='%s'", bigintval($networkTypeId), SQL_ESCAPE($key))) == 1);
+ $GLOBALS[__FUNCTION__][$networkId][$networkTypeId][$key] = (countSumTotalData(bigintval($networkId), 'network_array_translation', 'network_array_id', 'network_id', TRUE, sprintf(" AND `network_type_id`=%s AND `network_array_index`='%s'", bigintval($networkTypeId), sqlEscapeString($key))) == 1);
} // END - if
// Return result
$GLOBALS['network_data'][$networkId] = array();
// Query for the network data
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_id`,
`network_short_name`,
`network_title`,
array(bigintval($networkId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Then get it
- $GLOBALS['network_data'][$networkId] = SQL_FETCHARRAY($result);
+ $GLOBALS['network_data'][$networkId] = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return result
$GLOBALS['network_type_data'][$networkTypeId] = array();
// Query for the network data
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`d`.`network_id`,
`d`.`network_short_name`,
`d`.`network_title`,
array(bigintval($networkTypeId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Then get it
- $GLOBALS['network_type_data'][$networkTypeId] = SQL_FETCHARRAY($result);
+ $GLOBALS['network_type_data'][$networkTypeId] = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return result
$GLOBALS['network_type_data'][$networkTypeId] = array();
// Query for the network data
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_type_id`,
`network_id`,
`network_type_handler`,
array(bigintval($networkTypeId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Then get it
- $GLOBALS['network_type_data'][$networkTypeId] = SQL_FETCHARRAY($result);
+ $GLOBALS['network_type_data'][$networkTypeId] = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return result
$GLOBALS['network_types'][$networkId] = array();
// Query for the network data
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_type_id`,
`network_id`,
`network_type_handler`,
array(bigintval($networkId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Then add all
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Add it with new index as it is no longer required
$GLOBALS['network_types'][$networkId][] = $row;
} // END - if
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return result
$networkRequestData = array();
// Query for the network data
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_request_param_id`,
`network_id`,
`network_type_id`,
array(bigintval($networkRequestId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Then get it
- $networkRequestData = SQL_FETCHARRAY($result);
+ $networkRequestData = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $networkRequestData;
$networkTranslationData = array();
// Query for the network data
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_array_id`,
`network_id`,
`network_type_id`,
array(bigintval($networkTranslationId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Then get it
- $networkTranslationData = SQL_FETCHARRAY($result);
+ $networkTranslationData = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $networkTranslationData;
$GLOBALS['network_request_parameters'][$networkTypeId] = array();
// Search for all
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_id`,
`network_type_id`,
`network_request_param_key`,
), __FUNCTION__, __LINE__);
// Are there records?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all but make new indexes as the old are not required
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Add it
$GLOBALS['network_request_parameters'][$networkTypeId][] = $row;
} // END - while
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return "cached" values
$GLOBALS['network_full_config'][$networkTypeId] = array();
// Search for all
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`nac`.`network_id`,
`ntc`.`network_type_id`,
`nac`.`network_api_affiliate_id`,
), __FUNCTION__, __LINE__);
// Is there one entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load it
- $GLOBALS['network_full_config'][$networkTypeId] = SQL_FETCHARRAY($result);
+ $GLOBALS['network_full_config'][$networkTypeId] = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return "cached" values
// Removes given network entry
function doAdminRemoveNetworkEntry ($table, $column, $id, $limit = 1) {
// Remove the entry
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_network_%s` WHERE `%s`=%s LIMIT %s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_network_%s` WHERE `%s`=%s LIMIT %s",
array(
$table,
$column,
), __FUNCTION__, __LINE__);
// Return affected rows
- return SQL_AFFECTEDROWS();
+ return sqlAffectedRows();
}
// Generates a list of networks for given script and returns it
$content = '';
// Query for all networks
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`network_id`,
`network_short_name`,
`network_title`,
`network_short_name` ASC', __FUNCTION__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List all entries
$rows = array();
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Is this valid, then add it
if ((is_array($row)) && (isset($row['network_id']))) {
// Exclude configured and is it configured or same for unconfired but only if not separated lists?
}
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return the list
return $content;
$content = '';
// Query all types of this network
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_type_id`,
`network_type_handler`
FROM
), __FUNCTION__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List all entries
$rows = array();
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Is this valid, then add it
if ((is_array($row)) && (isset($row['network_type_id']))) {
// Add entry
}
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return content
return $content;
$content = '';
// Query all types of this network
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`t`.`network_type_id`,
`t`.`network_type_handler`,
`d`.`network_title`
`t`.`network_type_handler` ASC', __FUNCTION__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List all entries
$rows = array();
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Is this valid, then add it
if ((is_array($row)) && (isset($row['network_type_id']))) {
// Add entry
}
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
//* DEBUG: */ die('<pre>'.encodeEntities($content).'</pre>');
// Return content
// Is debug logging enabled or status code not 200 OK?
if ((getConfig('network_logging_debug') == 'Y') || (!isHttpStatusOkay($headers[0]))) {
// Add entry
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_network_header_logging` (`network_id`, `network_type_id`, `network_http_status_code`, `network_http_headers`, `network_logging_type`) VALUES(%s, %s, '%s', '%s', '%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_network_header_logging` (`network_id`, `network_type_id`, `network_http_status_code`, `network_http_headers`, `network_logging_type`) VALUES(%s, %s, '%s', '%s', '%s')",
array(
bigintval($networkId),
bigintval($networkTypeId),
// So is there cache?
if (countSumTotalData($networkId, 'network_cache', 'network_cache_id', 'network_id', TRUE, ' AND `network_type_id`=' . bigintval($networkTypeId)) == 1) {
// Entry found, so update it
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_network_cache`
SET
`network_cache_data`='%s',
), __FUNCTION__, __LINE__);
} else {
// Add entry
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_network_cache` (`network_id`, `network_type_id`, `network_cache_data`, `network_cache_body`, `network_cache_type`, `network_cache_admin_id`) VALUES(%s, %s, '%s', '%s', '%s', %s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_network_cache` (`network_id`, `network_type_id`, `network_cache_data`, `network_cache_body`, `network_cache_type`, `network_cache_admin_id`) VALUES(%s, %s, '%s', '%s', '%s', %s)",
array(
bigintval($networkId),
bigintval($networkTypeId),
} // END - if
// Okay, so update database
- $result = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_network_api_config` SET `network_api_remaining_requests`=`network_api_remaining_requests`-1 WHERE `network_id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_network_api_config` SET `network_api_remaining_requests`=`network_api_remaining_requests`-1 WHERE `network_id`=%s LIMIT 1",
array(
bigintval($networkData['network_id'])
), __FUNCTION__, __LINE__);
// Return affected rows
- return SQL_AFFECTEDROWS();
+ return sqlAffectedRows();
}
/**
$GLOBALS['network_array_index'] = array();
// Get all entries
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`network_array_id`,
`network_array_index`,
`network_translation_name`
`network_array_sort` ASC', __FUNCTION__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Get all entries
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Add it to our global array
$GLOBALS['network_array_index'][$row['network_array_index']] = $row;
} // END - while
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Default name is unknown
} // END - if
// Add the whole request to database
- SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_data'), __FUNCTION__, __LINE__);
+ sqlQuery(getInsertSqlFromArray(postRequestArray(), 'network_data'), __FUNCTION__, __LINE__);
// Add the id for output only
- setPostRequestElement('network_id', SQL_INSERT_ID());
+ setPostRequestElement('network_id', getSqlInsertId());
// Output message
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Successfully added
loadTemplate('admin_network_added', FALSE, postRequestArray());
} else {
} // END - if
// Add the whole request to database
- SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_types'), __FUNCTION__, __LINE__);
+ sqlQuery(getInsertSqlFromArray(postRequestArray(), 'network_types'), __FUNCTION__, __LINE__);
// Output message
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Successfully added
loadTemplate('admin_network_type_added', FALSE, postRequestArray());
} else {
} // END - if
// Add the whole request to database
- SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_request_params'), __FUNCTION__, __LINE__);
+ sqlQuery(getInsertSqlFromArray(postRequestArray(), 'network_request_params'), __FUNCTION__, __LINE__);
// Output message
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Successfully added
loadTemplate('admin_network_request_param_added', FALSE, postRequestArray());
} else {
) + 1));
// Add the whole request to database
- SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_array_translation'), __FUNCTION__, __LINE__);
+ sqlQuery(getInsertSqlFromArray(postRequestArray(), 'network_array_translation'), __FUNCTION__, __LINE__);
// Output message
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Successfully added
loadTemplate('admin_network_array_translation_added', FALSE, postRequestArray());
} else {
}
// Run the query
- SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+ sqlQuery($SQL, __FUNCTION__, __LINE__);
// Output message
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Successfully added
displayMessage('{--ADMIN_CONFIG_NETWORK_API_SAVED--}');
} else {
// Shall we set for all?
if ($setAll === TRUE) {
// Get all handlers
- $result = SQL_QUERY_ESC('SELECT `network_type_id` FROM `{?_MYSQL_PREFIX?}_network_types` WHERE `network_id`=%s ORDER BY `network_type_id` ASC',
+ $result = sqlQueryEscaped('SELECT `network_type_id` FROM `{?_MYSQL_PREFIX?}_network_types` WHERE `network_id`=%s ORDER BY `network_type_id` ASC',
array(bigintval(getRequestElement('network_id'))), __FUNCTION__, __LINE__);
// Are there entries?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// No, then abort here
displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL_404--}');
return;
$numRows = 0;
// Fetch all ids
- while (list($typeId) = SQL_FETCHROW($result)) {
+ while (list($typeId) = sqlFetchRow($result)) {
// Set it in GET data
setGetRequestElement('network_type_id', $typeId);
} // END - while
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Output message
if ($numRows > 0) {
$SQL = getInsertSqlFromArray(postRequestArray(), 'network_handler_config');
// Run the query
- SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+ sqlQuery($SQL, __FUNCTION__, __LINE__);
// Shall we display the message?
if ($displayMessage === TRUE) {
// Output message
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Successfully added
displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_SAVED--}');
} else {
}
} else {
// Return amount of affected rows (1 or 2)
- return SQL_AFFECTEDROWS();
+ return sqlAffectedRows();
}
}
}
// Shall we set for all?
if ($setAll === TRUE) {
// Get all data entries
- $result = SQL_QUERY_ESC('SELECT `network_data_id` FROM `{?_MYSQL_PREFIX?}_network_handler_config` WHERE `network_id`=%s ORDER BY `network_type_id` ASC',
+ $result = sqlQueryEscaped('SELECT `network_data_id` FROM `{?_MYSQL_PREFIX?}_network_handler_config` WHERE `network_id`=%s ORDER BY `network_type_id` ASC',
array(bigintval(getRequestElement('network_id'))), __FUNCTION__, __LINE__);
// Are there entries?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// No, then abort here
displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL_404--}');
return;
$numRows = 0;
// Fetch all ids
- while (list($dataId) = SQL_FETCHROW($result)) {
+ while (list($dataId) = sqlFetchRow($result)) {
// Set it in GET data
setPostRequestElement('network_data_id', $dataId);
} // END - while
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Output message
if ($numRows > 0) {
$SQL = getUpdateSqlFromArray(postRequestArray(), 'network_handler_config', 'network_data_id', postRequestElement('network_data_id'), array('network_data_id'));
// Run the query
- SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+ sqlQuery($SQL, __FUNCTION__, __LINE__);
// Shall we display the message?
if ($displayMessage === TRUE) {
// Output message
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Successfully added
displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_SAVED--}');
} else {
}
} else {
// Return amount of affected rows (1 or 2)
- return SQL_AFFECTEDROWS();
+ return sqlAffectedRows();
}
}
}
// Exports (and displays) the table 'network_data'
function doAdminNetworkExportData () {
// Query for all networks
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`network_short_name`,
`network_title`,
`network_reflink`,
$SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_network_data` (`network_short_name`, `network_title`, `network_reflink`, `network_data_separator`, `network_row_separator`, `network_request_type`, `network_charset`, `network_require_id_card`, `network_query_amount`, `network_active`) VALUES' . PHP_EOL;
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row
$SQL .= "('" .
$content['network_short_name'] . "', '" .
$SQL = substr($SQL, 0, -2);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Output the SQL query
loadTemplate('admin_export_network_data', FALSE, $SQL);
} // END - if
// Get all network types of given network
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_type_id`,
`network_id`,
`network_type_handler`,
$SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_network_types` (`network_type_id`, `network_id`, `network_type_handler`, `network_type_api_url`, `network_type_click_url`, `network_type_banner_url`, `network_type_reload_time_unit`, `network_text_encoding`) VALUES' . PHP_EOL;
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row
$SQL .= '(' .
$content['network_type_id'] . ', ' .
$SQL = substr($SQL, 0, -2);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Output the SQL query
loadTemplate('admin_export_network_types', FALSE, $SQL);
} // END - if
// Get all network types of given network
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_id`,
`network_type_id`,
`network_request_param_key`,
$SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_network_request_params` (`network_id`, `network_type_id`, `network_request_param_key`, `network_request_param_value`, `network_request_param_default`) VALUES' . PHP_EOL;
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row
$SQL .= '(' .
$content['network_id'] . ', ' .
$content['network_type_id'] . ", '" .
$content['network_request_param_key'] . "', '" .
$content['network_request_param_value'] . "', ";
-
+
// Is the column NULL?
if (is_null($content['network_request_param_default'])) {
// Column is NULL
$SQL = substr($SQL, 0, -2);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Output the SQL query
loadTemplate('admin_export_network_request_params', FALSE, $SQL);
} // END - if
// Get all network types of given network
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_id`,
`network_type_id`,
`network_array_index`,
$SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_network_array_translation` (`network_id`, `network_type_id`, `network_array_index`, `network_array_sort`) VALUES' . PHP_EOL;
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row
$SQL .= '(' .
$content['network_id'] . ', ' .
$SQL = substr($SQL, 0, -2);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Output the SQL query
loadTemplate('admin_export_network_array_translation', FALSE, $SQL);
$tot_all = '0';
// Get table status
- $result = SQL_QUERY('SHOW TABLE STATUS FROM `{?__DB_NAME?}`', __FUNCTION__, __LINE__);
+ $result = sqlQuery('SHOW TABLE STATUS FROM `{?__DB_NAME?}`', __FUNCTION__, __LINE__);
// Init array
$ret['total_size'] = '0';
- $ret['total_tabs'] = SQL_NUMROWS($result);
+ $ret['total_tabs'] = sqlNumRows($result);
$ret['tables'] = array();
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Fetch all rows
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
$tot_data = $row['Data_length'];
$tot_idx = $row['Index_length'];
$total = $tot_data + $tot_idx;
$gain = round ($gain, 3);
// Repair table
- $result1 = SQL_QUERY_ESC("REPAIR TABLE `%s`",
+ $result1 = sqlQueryEscaped("REPAIR TABLE `%s`",
array($row['Name']), __FUNCTION__, __LINE__);
- $rep = SQL_FETCHARRAY($result1);
+ $rep = sqlFetchArray($result1);
// Optimize table
- $result1 = SQL_QUERY_ESC("OPTIMIZE TABLE `%s`",
+ $result1 = sqlQueryEscaped("OPTIMIZE TABLE `%s`",
array($row['Name']), __FUNCTION__, __LINE__);
- $opt = SQL_FETCHARRAY($result1);
+ $opt = sqlFetchArray($result1);
// Add data to array
array_push($ret['tables'], array($row['Name'], $opt['Msg_text'], $rep['Msg_text'], $total, $gain));
$ret['total_gain'] = $total_gain;
// Insert new row
- $result = SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_optimize_gain` (`gain`) VALUES (%s)",
+ $result = sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_optimize_gain` (`gain`) VALUES (%s)",
array($total_gain), __FUNCTION__, __LINE__);
// Get total runs and total optimization count
- $result = SQL_QUERY('SELECT COUNT(`id`) AS `total_rows`, SUM(`gain`) AS `total_optimized` FROM `{?_MYSQL_PREFIX?}_optimize_gain`', __FUNCTION__, __LINE__);
- $ret = merge_array($ret, SQL_FETCHARRAY($result));
+ $result = sqlQuery('SELECT COUNT(`id`) AS `total_rows`, SUM(`gain`) AS `total_optimized` FROM `{?_MYSQL_PREFIX?}_optimize_gain`', __FUNCTION__, __LINE__);
+ $ret = merge_array($ret, sqlFetchArray($result));
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return array
return $ret;
// Enougth points?
if ($points > 0) {
// Pay this out!
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`id`,
`type`,
`rate`,
ORDER BY
`type` ASC',
array($points), __FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Init output
$OUT = '';
// Now let's check
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Are these points enougth?
if ($points >= $content['min_points']) {
// Prepare content for template
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Points is empty
displayErrorMessage('{--MEMBER_PAYOUT_NO_POINTS_ENTERED--}');
// Auto-start referral rallyes
function autostartReferralRallyes ($result) {
// Load all rallyes (usally we have only one rallye active per time!
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Set notified to Y
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_rallye_data`
SET
`notified`='Y'
array(bigintval($content['id'])), __FUNCTION__, __LINE__);
// Query all users
- $result_user = SQL_QUERY("SELECT
+ $result_user = sqlQuery("SELECT
`userid`
FROM
`{?_MYSQL_PREFIX?}_user_data`
`userid` ASC", __FUNCTION__, __LINE__);
// Let's begin with the userids...
- while ($row = SQL_FETCHARRAY($result_user)) {
+ while ($row = sqlFetchArray($result_user)) {
// Merge both arrays
$content = merge_array($content, $row);
if (empty($count)) $count = '0'; // Added prevent some unknown troubles... :-?
// Check if line is already included...
- $result_ref = SQL_QUERY_ESC("SELECT
+ $result_ref = sqlQueryEscaped("SELECT
`id`
FROM
`{?_MYSQL_PREFIX?}_rallye_users`
array(bigintval($content['id']), bigintval($content['userid'])), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_HASZERONUMS($result_ref)) {
+ if (ifSqlHasZeroNums($result_ref)) {
// Add userid and his ref count to table
- $result_ref = SQL_QUERY_ESC("SELECT
+ $result_ref = sqlQueryEscaped("SELECT
SUM(`p`.`points`) AS `points`
FROM
`{?_MYSQL_PREFIX?}_user_points` AS `p`
array(bigintval($content['userid'])), __FUNCTION__, __LINE__);
// Get points
- list($cpoints) = SQL_FETCHROW($result_ref);
+ list($cpoints) = sqlFetchRow($result_ref);
// Free result
- SQL_FREERESULT($result_ref);
+ sqlFreeResult($result_ref);
if (empty($cpoints)) $cpoints = '0.00000';
// Add info line
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_rallye_users`
(
`rallye_id`,
} // END - if
// Free memory
- SQL_FREERESULT($result_ref);
+ sqlFreeResult($result_ref);
// Ignored but for the template required refs (made before start of rallye)
$content['refs'] = $count;
sendAdminNotification('{%message,ADMIN_RALLYE_NOTIFY_SUBJECT=' . $content['title'] . '%}', $templ, $content);
// Free memory
- SQL_FREERESULT($result_user);
+ sqlFreeResult($result_user);
}
//
} // END - switch
// Load prices
- $result_prices = SQL_QUERY_ESC("SELECT
+ $result_prices = sqlQueryEscaped("SELECT
`price_level`,
`points`,
`info`
array($rallye), __FUNCTION__, __LINE__);
// Entries found?
- if (!SQL_HASZERONUMS($result_prices)) {
+ if (!ifSqlHasZeroNums($result_prices)) {
// Load prices
$prices = '';
if ($mode == PHP_EOL) {
$prices = '{--RALLYE_MEMBER_PRICES_ADDED--}:' . $mode . '------------------------------' . $mode;
} // END - if
- while ($content = SQL_FETCHARRAY($result_prices)) {
+ while ($content = sqlFetchArray($result_prices)) {
$prices .= $content['price_level']. '{--RALLYE_PRICE--}:';
if (!empty($content['info'])) {
$prices .= $content['info'];
} // END - if
// Free memory
- SQL_FREERESULT($result_prices);
+ sqlFreeResult($result_prices);
} else {
// No prices???
$prices = '{%message,RALLYE_MEMBER_NO_PRICES=' . $mode . '%}';
$prices = getTotalRallyePrices($rallye);
// And load only limited users
- $result = SQL_QUERY_ESC("SELECT DISTINCT
+ $result = sqlQueryEscaped("SELECT DISTINCT
`u`.`userid`,
`u`.`refs`,
`u`.`curr_points`,
);
// Load all users
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $row['userid'] . ',refs=' . $row['refs']);
// Get current refs
$count = getReferralRallyeRefsCount($row['userid'], $row['refs']);
// Points of ref's
- $result_ref = SQL_QUERY_ESC("SELECT
+ $result_ref = sqlQueryEscaped("SELECT
`p`.`points`
FROM
`{?_MYSQL_PREFIX?}_user_points` AS `p`
array(bigintval($row['userid'])), __FUNCTION__, __LINE__);
// Get points
- list($refpoints) = SQL_FETCHROW($result_ref);
+ list($refpoints) = sqlFetchRow($result_ref);
// Free result
- SQL_FREERESULT($result_ref);
+ sqlFreeResult($result_ref);
// Fix empty values (ugly code again)
if (empty($refpoints)) {
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Sort whole array
array_pk_sort($content, array('cpoints', 'ref'), 0, 1, TRUE);
} // END - if
// Check for an auto-add rallye
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`id`,
`title`,
`start_time`,
`auto_add_new_user`='Y' AND
`expired`='N'
LIMIT 1", __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Init variables
$min_users = '0';
$min_prices = '0';
// Load and merge data
- $content = merge_array($content, SQL_FETCHARRAY($result));
+ $content = merge_array($content, sqlFetchArray($result));
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Notify the user?
if ($content['send_notify'] == 'Y') {
} // END - if
// Check if line is already included...
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`
FROM
`{?_MYSQL_PREFIX?}_rallye_users`
), __FUNCTION__, __LINE__);
// Is this user added?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Add userid and his ref count to table
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_rallye_users`
(
`rallye_id`,
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
}
// Stops the given rallye result (from SQL layer) by marking it as expirced
function stopRallyeByResult ($result) {
// Load rallye data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Init array
$count = '0';
} // END - if
// Expire rallye
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `expired`='Y' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `expired`='Y' WHERE `id`=%s LIMIT 1",
array(bigintval($content['id'])), __FUNCTION__, __LINE__);
// Run array through (by userid is the most important 2nd-level-array)
$ret = '';
// Load users
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`userid`, `gender`, `surname`, `family`, `email`
FROM
`{?_MYSQL_PREFIX?}_user_data`
$userid_string,
count($userIds)
), __FUNCTION__, __LINE__);
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Construct the message masked and add it
$ret .= sprintf("{%%pipe,translateGender=%s%} %s %s (%s) - %s\n",
$content['gender'],
);
// Load prices
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`price_level`,
`points`,
`info`
array(bigintval($rallye)), __FUNCTION__, __LINE__);
// Transfer elements
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
$prices['level'][] = $content['price_level'];
array_push($prices['points'], $content['points']);
array_push($prices['info'], $content['info']);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return array
return $prices;
* - refs = Old amount of referrals (before the rallye has started)
* - curr_points = Current amount of total points
*/
- $result_user = SQL_QUERY_ESC("SELECT
+ $result_user = sqlQueryEscaped("SELECT
`userid`,
`refs`,
`curr_points`
ORDER BY
`userid` ASC",
array(bigintval($rallye)), __FUNCTION__, __LINE__);
- while ($content = SQL_FETCHARRAY($result_user)) {
+ while ($content = sqlFetchArray($result_user)) {
// Load current ref count
$count = getReferralRallyeRefsCount($content['userid'], $content['refs']);
// Points of ref's
- $result_ref = SQL_QUERY_ESC("SELECT
+ $result_ref = sqlQueryEscaped("SELECT
SUM(`p`.`points`) AS `points`
FROM
`{?_MYSQL_PREFIX?}_user_points` AS `p`
array(bigintval($content['userid'])), __FUNCTION__, __LINE__);
// Get points
- list($refpoints) = SQL_FETCHROW($result_ref);
+ list($refpoints) = sqlFetchRow($result_ref);
// Free result
- SQL_FREERESULT($result_ref);
+ sqlFreeResult($result_ref);
// Fix empty refpoints
if (empty($refpoints)) $refpoints = '0';
} // END - while
// Free memory
- SQL_FREERESULT($result_user);
+ sqlFreeResult($result_user);
// Sort array for refs (descending)
array_pk_sort($users, array('cpoints', 'ref'), 0, 1, TRUE);
function purgeExpiredReferralRallyes () {
// Check for expired rallyes
$EXPIRE = 3; // @TODO The hard-coded value...
- $result_rallye = SQL_QUERY_ESC("SELECT
+ $result_rallye = sqlQueryEscaped("SELECT
`id`,
`title`,
`start_time`,
`expired`='Y'",
array($EXPIRE), __FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result_rallye)) {
+ if (!ifSqlHasZeroNums($result_rallye)) {
// Init SQLs
initSqls();
// Expire found rallyes and notify admin
- while ($content = SQL_FETCHARRAY($result_rallye)) {
+ while ($content = sqlFetchArray($result_rallye)) {
// Prepare data for mail template
$content['start_time'] = generateDateTime($content['start_time'], 1);
$content['end_time'] = generateDateTime($content['end_time'] , 1);
sendAdminNotification('{%message,ADMIN_RALLYE_PURGED_SUBJECT=' . $content['title'] . '%}', 'admin_rallye_purged', $content);
// Purge whole rallye
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE `id`=%s LIMIT 1",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE `id`=%s LIMIT 1",
array(bigintval($content['id'])), __FUNCTION__, __LINE__, FALSE));
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `rallye_id`=%s LIMIT 1",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `rallye_id`=%s LIMIT 1",
array(bigintval($content['id'])), __FUNCTION__, __LINE__, FALSE));
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `rallye_id`=%s LIMIT 1",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `rallye_id`=%s LIMIT 1",
array(bigintval($content['id'])), __FUNCTION__, __LINE__, FALSE));
// Add task (we ignore the task id here
} // END - if
// Free memory
- SQL_FREERESULT($result_rallye);
+ sqlFreeResult($result_rallye);
}
//
} // END - if
} else {
// Load current refs from database
- $result_ref = SQL_QUERY_ESC("SELECT
+ $result_ref = sqlQueryEscaped("SELECT
SUM(s.counter) AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_refsystem` AS `s`
), __FUNCTION__, __LINE__);
// Load count @TODO Can't we rewrite this to our API?
- list($count) = SQL_FETCHROW($result_ref);
+ list($count) = sqlFetchRow($result_ref);
// Free result
- SQL_FREERESULT($result_ref);
+ sqlFreeResult($result_ref);
if (empty($count)) {
$count = '0';
} else {
$return = $ref_points;
// Get all ref levels
- $result_refs = SQL_QUERY('SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level` > 0 ORDER BY `level` ASC',
+ $result_refs = sqlQuery('SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level` > 0 ORDER BY `level` ASC',
__FUNCTION__, __LINE__);
// "Walk" through all level
- while ($content = SQL_FETCHARRAY($result_refs)) {
+ while ($content = sqlFetchArray($result_refs)) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'level=' . $content['level'] . ',percents=' . $content['percents'] . ' - LOOP START!');
// Reset ref depths
initReferralSystem();
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'points=' . $points . ',percents=' . $content['percents'] . ',refback_percents=' . $content['refback_percents'] . ',level=' . $content['level'] . ',refback_points=' . $refbackPoints);
// Update refback table ('refid' and 'userid' must be exchanged!)
- SQL_QUERY_ESC('UPDATE
+ sqlQueryEscaped('UPDATE
`{?_MYSQL_PREFIX?}_user_refs`
SET
`refback_points`=`refback_points`+%s
), __FUNCTION__, __LINE__);
// Something must have been updated
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// Please report this bug
reportBug(__FUNCTION__, __LINE__, 'Nothing has been updated in user_refs,userid=' . $userid . ',refid=' . convertNullToZero($refid) . ',refbackPoints=' . $refbackPoints);
} // END - if
} // END - while
// Free result
- SQL_FREERESULT($result_refs);
+ sqlFreeResult($result_refs);
// Restore ref depth
$GLOBALS['ref_level'] = $GLOBALS['refback_depth'][$userid][$ref];
$GLOBALS['refback_percents'][$userid][$refid] = '0';
// Get percents from database
- $result = SQL_QUERY_ESC("SELECT `refback_percents` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `refid`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `refback_percents` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `refid`=%s LIMIT 1",
array($userid, $refid), __FUNCTION__, __LINE__);
// Entry found? (Should be!)
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Fetch percents
- list($GLOBALS['refback_percents'][$userid][$refid]) = SQL_FETCHROW($result);
+ list($GLOBALS['refback_percents'][$userid][$refid]) = sqlFetchRow($result);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ',percents=' . $GLOBALS['refback_percents'][$userid][$refid]);
} else {
// Please report all findings
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return percents
$userIds = array();
// Look for all
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`userid`
FROM
`{?_MYSQL_PREFIX?}_user_refs`
// Entries found?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'numRows=' . SQL_NUMROWS($result));
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Add all
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . convertNullToZero($refid) . ',level=' . $level . ',userid=' . $content['userid']);
array_push($userIds, $content['userid']);
} // END - while
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return array
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . convertNullToZero($refid) . ',userIds()=' . count($userIds) . ' - EXIT!');
$refs = array();
// Get refs from database
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`r`.`id`,
`r`.`refid`,
`r`.`refback_percents`,
array(bigintval($userid), bigintval($level)), __FUNCTION__, __LINE__);
// Are there some entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Fetch all entries
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Init click rate
$row['click_rate'] = '0';
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refs()=' . count($refs) . ' - EXIT!');
$id = bigintval($id);
// Get entry from database
- $result = SQL_QUERY_ESC("SELECT `id`, `userid`, `refid`, `refback_percents`, `level`, `refback_points` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `userid`, `refid`, `refback_percents`, `level`, `refback_points` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1",
array($id, getMemberId()), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Fetch data
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return entry
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',data()=' . count($data) . ' - EXIT!');
$percents = convertCommaToDot($percents);
// Update entry
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_refs` SET `refback_percents`='%s' WHERE `id`=%s AND `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_refs` SET `refback_percents`='%s' WHERE `id`=%s AND `userid`=%s LIMIT 1",
array(
$percents,
$id,
), __FUNCTION__, __LINE__);
// Entry updated?
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// Entry not updated!
$status['message'] = 'MEMBER_REFBACK_ERROR_NOT_UPDATED';
return $status;
$ret = TRUE;
foreach ($array as $key => $value) {
// Check all fields that must register
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_must_register` WHERE `field_name`='%s' AND `field_required`='Y' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_must_register` WHERE `field_name`='%s' AND `field_required`='Y' LIMIT 1",
array($key), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Check if extension country is not found (you have to enter the 2-chars long country code) or
// if extensions is present check if country code was selected
// 01 2 21 12 3 32 234 5 54 4 43 34 4 4 5 5432 2 3 3210
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
// Return result
} // END - if
// Look for categories
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`cat`,
`visible`
`sort` ASC',
__FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List alle visible modules (or all to the admin)
$OUT .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare array for the template
$content['default_yes'] = '';
$content['default_no'] = '';
$OUT .= '</table>';
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No categories setted up so far...
$OUT .= displayMessage('{--NO_CATEGORIES_VISIBLE--}', TRUE);
} // END - if
// Create user's account...
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_user_data`
(
`gender`,
), __FUNCTION__, __LINE__);
// Get his userid
- $filterData['register_insert_id'] = SQL_INSERT_ID();
+ $filterData['register_insert_id'] = getSqlInsertId();
// Did this work?
if (!isValidId($filterData['register_insert_id'])) {
// Shall we reset random refid? Only possible with latest ext-user
if (isExtensionInstalledAndNewer('user', '0.3.4')) {
// Reset all accounts, registration is done
- SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0', __FUNCTION__, __LINE__);
+ sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0', __FUNCTION__, __LINE__);
} // END - if
// Update referral table
} // END - foreach
// Run SQL without last commata
- SQL_QUERY(substr($sql, 0, -1), __FUNCTION__, __LINE__);
+ sqlQuery(substr($sql, 0, -1), __FUNCTION__, __LINE__);
} // END - if
// Registration phase is done here, so for tester accounts we end here
$content = array(
'hash' => $GLOBALS['register_confirm_hash'],
'userid' => $filterData['register_insert_id'],
- 'gender' => SQL_ESCAPE(postRequestElement('gender')),
- 'surname' => SQL_ESCAPE(postRequestElement('surname')),
- 'family' => SQL_ESCAPE(postRequestElement('family')),
- 'email' => SQL_ESCAPE(postRequestElement('email')),
- 'street' => SQL_ESCAPE(postRequestElement('street_nr')),
- 'city' => SQL_ESCAPE(postRequestElement('city')),
+ 'gender' => sqlEscapeString(postRequestElement('gender')),
+ 'surname' => sqlEscapeString(postRequestElement('surname')),
+ 'family' => sqlEscapeString(postRequestElement('family')),
+ 'email' => sqlEscapeString(postRequestElement('email')),
+ 'street' => sqlEscapeString(postRequestElement('street_nr')),
+ 'city' => sqlEscapeString(postRequestElement('city')),
'zip' => bigintval(postRequestElement('zip')),
'country' => $GLOBALS['register_country_data'],
- 'refid' => SQL_ESCAPE(postRequestElement('refid')),
- 'password' => SQL_ESCAPE(postRequestElement('password1')),
+ 'refid' => sqlEscapeString(postRequestElement('refid')),
+ 'password' => sqlEscapeString(postRequestElement('password1')),
);
} else {
// No ZIP code entered
$content = array(
'hash' => $GLOBALS['register_confirm_hash'],
'userid' => $filterData['register_insert_id'],
- 'gender' => SQL_ESCAPE(postRequestElement('gender')),
- 'surname' => SQL_ESCAPE(postRequestElement('surname')),
- 'family' => SQL_ESCAPE(postRequestElement('family')),
- 'email' => SQL_ESCAPE(postRequestElement('email')),
- 'street' => SQL_ESCAPE(postRequestElement('street_nr')),
- 'city' => SQL_ESCAPE(postRequestElement('city')),
+ 'gender' => sqlEscapeString(postRequestElement('gender')),
+ 'surname' => sqlEscapeString(postRequestElement('surname')),
+ 'family' => sqlEscapeString(postRequestElement('family')),
+ 'email' => sqlEscapeString(postRequestElement('email')),
+ 'street' => sqlEscapeString(postRequestElement('street_nr')),
+ 'city' => sqlEscapeString(postRequestElement('city')),
'zip' => '',
'country' => $GLOBALS['register_country_data'],
- 'refid' => SQL_ESCAPE(postRequestElement('refid')),
- 'password' => SQL_ESCAPE(postRequestElement('password1')),
+ 'refid' => sqlEscapeString(postRequestElement('refid')),
+ 'password' => sqlEscapeString(postRequestElement('password1')),
);
}
$SAVE = FALSE;
} else {
// Add a new sponsor or update his data?
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE email='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE email='%s' LIMIT 1",
array($postData['email']), __FUNCTION__, __LINE__);
// Is a sponsor alread in the db?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Yes, he is!
if ((getWhat() == 'add_sponsor') || ($update)) {
// Already found
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
break;
foreach ($postData as $k => $v) {
// Do not add 'force' !
if ($k != 'force') {
- $OUT .= '<input type="hidden" name="' . secureString($k) . '" value="' . SQL_ESCAPE($v) . '" />';
+ $OUT .= '<input type="hidden" name="' . secureString($k) . '" value="' . sqlEscapeString($v) . '" />';
} // END - if
} // END - foreach
if (!empty($sql)) {
// Run SQL command
- $result = SQL_QUERY_ESC($sql, $DATA['values'], __FUNCTION__, __LINE__);
+ $result = sqlQueryEscaped($sql, $DATA['values'], __FUNCTION__, __LINE__);
} // END - if
} else {
// Error detected
if (isAdmin()) $WHERE = '';
// Load main menu entries
- $result_main = SQL_QUERY("SELECT
+ $result_main = sqlQuery("SELECT
`action` AS `main_action`,
`title` AS `main_title`
FROM
" . $WHERE . "
ORDER BY
`sort` ASC", __FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result_main)) {
+ if (!ifSqlHasZeroNums($result_main)) {
// Load every menu and it's sub menus
- while ($content = SQL_FETCHARRAY($result_main)) {
+ while ($content = sqlFetchArray($result_main)) {
// Load sub menus
- $result_sub = SQL_QUERY_ESC("SELECT
+ $result_sub = sqlQueryEscaped("SELECT
`what` AS `sub_what`,
`title` AS `sub_title`
FROM
ORDER BY
`sort` ASC",
array($content['main_action']), __FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result_sub)) {
+ if (!ifSqlHasZeroNums($result_sub)) {
// Load sub menus
$SUB = '';
- while ($content2 = SQL_FETCHARRAY($result_sub)) {
+ while ($content2 = sqlFetchArray($result_sub)) {
// Check if current selected menu is matching the loaded one
if ($current == $content2['sub_what']) $content2['sub_title'] = '<strong>' . $content2['sub_title'] . '</strong>';
}
// Free memory
- SQL_FREERESULT($result_sub);
+ sqlFreeResult($result_sub);
} // END - while
} else {
// No main menus active
}
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
// Return content
return $OUT;
// Is sponsor?
if (isSponsor()) {
// Update last online timestamp
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_sponsor_data`
SET
`last_online`=NOW()
), __FUNCTION__, __LINE__);
// This update went fine?
- $login = (!SQL_HASZEROAFFECTED());
+ $login = (!ifSqlHasZeroAffectedRows());
} // END - if
// Return status
unset($postData[$remove]);
} // END - foreach
- // This array is for the submitted data which we will use with the SQL_QUERY_ESC() function to
+ // This array is for the submitted data which we will use with the sqlQueryEscaped() function to
// secure the data
$DATA = array();
// Mmmmm, too less security here???
$sql .= " `" . secureString($key) . "`='%s',";
- // We will secure this later inside the SQL_QUERY_ESC() function
+ // We will secure this later inside the sqlQueryEscaped() function
array_push($DATA, secureString($value));
} // END - foreach
} // END - switch
// Has an entry updated?
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Template and subject are set?
if (!empty($templ) && !empty($subject)) {
// Run SQL command and check for success
- $result = SQL_QUERY_ESC($sql, $DATA, __FUNCTION__, __LINE__);
+ $result = sqlQueryEscaped($sql, $DATA, __FUNCTION__, __LINE__);
// Add all data to content
$content['new_data'] = $postData;
// But admins shall always see it
if (isAdmin()) $locked = '';
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`
FROM
`{?_MYSQL_PREFIX?}_sponsor_data`
" . $locked . "
LIMIT 1",
array($email), __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load sponsor_id
- list($sponsor_id) = SQL_FETCHROW($result);
+ list($sponsor_id) = sqlFetchRow($result);
// Rewrite email address to contact link
$email = '{%url=modules.php?module=' . $mod . '&what=sponsor_contct&sponsor_id=' . bigintval($sponsor_id) . '%}';
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return rewritten (?) email address
return $email;
switch ($status) {
case 'added': // Sponsor successfully added with account status = UNCONFIRMED!
// Check for his id number
- $result = SQL_QUERY_ESC("SELECT `id`, `hash` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE '%s' REGEXP `email` LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `hash` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE '%s' REGEXP `email` LIMIT 1",
array(postRequestElement('email')), __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// id found so let's load it for the confirmation email
- list($id, $hash) = SQL_FETCHROW($result);
+ list($id, $hash) = sqlFetchRow($result);
// Prepare data for the email template
$content['id'] = $id;
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
break;
default:
$ADD = '';
// Query for the sponsor
- $result = SQL_QUERY_ESC("SELECT *".$ADD." FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `%s`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT *".$ADD." FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `%s`='%s' LIMIT 1",
array($column, $sponsor_id), __FUNCTION__, __LINE__);
// Is there a record?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data from cookies
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set the sponsor_id for later use
setCurrentSponsorId($data['id']);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $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;
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!');
// New format...
foreach ($sqls as $key => $sql) {
// Run SQL command, get line numbers and free memory
- $result = SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ $result = sqlQuery($sql, __FUNCTION__, __LINE__);
// Prepare array for output
$content = array(
$content['bottom'] = 'bottom';
} // END - if
- if ((!SQL_HASZERONUMS($result)) && (!empty($WHATs[$key]))) {
+ if ((!ifSqlHasZeroNums($result)) && (!empty($WHATs[$key]))) {
if (empty($TITLEs[$key])) {
$TITLEs[$key] = '{--ADMIN_TASK_UNKNOWN_LIST_TITLE--}';
} // END - if
- $content['row_link'] = '<a href="{%url=modules.php?module=admin&what=' . $WHATs[$key] . '%}" title="' . $TITLEs[$key] . '">' . SQL_NUMROWS($result) . '</a>';
+ $content['row_link'] = '<a href="{%url=modules.php?module=admin&what=' . $WHATs[$key] . '%}" title="' . $TITLEs[$key] . '">' . sqlNumRows($result) . '</a>';
} else {
$content['row_link'] = '0';
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// And insert the final string into extras template
$OUT .= loadTemplate('admin_overview_task_rows', TRUE, $content);
} // END - if
// Select all themes we want
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`theme_path`,
`theme_name`
FROM
`theme_name` ASC', __FUNCTION__, __LINE__);
// Load all themes
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Construct relative include file name
$inc = sprintf("theme/%s/theme.php", secureString($row['theme_path']));
} // END - while
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Construct selection form for the box template
// @TODO Can't this be rewritten to an API function?
incrementStatsEntry('cache_hits');
} elseif (isExtensionInstalledAndNewer('cache', '0.1.8')) {
// Load version from database
- $result = SQL_QUERY_ESC("SELECT `theme_ver` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `theme_ver` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' LIMIT 1",
array($name), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Fetch data
- list($cver) = SQL_FETCHROW($result);
+ list($cver) = sqlFetchRow($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return version
incrementStatsEntry('cache_hits');
} elseif (isExtensionInstalledAndNewer('cache', '0.1.8')) {
// Check if current theme is already imported or not
- $result = SQL_QUERY_ESC("SELECT `theme_active` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' AND `theme_active`='Y' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `theme_active` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' AND `theme_active`='Y' LIMIT 1",
array($name), __FUNCTION__, __LINE__);
// Is the theme active and installed?
- $active = (SQL_NUMROWS($result) == 1);
+ $active = (sqlNumRows($result) == 1);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return result
incrementStatsEntry('cache_hits');
} elseif (isExtensionInstalledAndNewer('cache', '0.1.8')) {
// Check if current theme is already imported or not
- $result = SQL_QUERY_ESC("SELECT `theme_name` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' AND `theme_active`='Y' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `theme_name` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' AND `theme_active`='Y' LIMIT 1",
array($name), __FUNCTION__, __LINE__);
// Load theme name
- list($name) = SQL_FETCHROW($result);
+ list($name) = sqlFetchRow($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return name
incrementStatsEntry('cache_hits');
} elseif (isExtensionInstalledAndNewer('cache', '0.1.8')) {
// Check if current theme is already imported or not
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' LIMIT 1",
array($name), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Fetch data
- list($id) = SQL_FETCHROW($result);
+ list($id) = sqlFetchRow($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return id
// Purge expired transfer entries
function autoPurgeTransfers ($max, $age) {
// First get total in-going lines
- $result = SQL_QUERY('SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` ORDER BY `id` ASC', __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) > $max) {
+ $result = sqlQuery('SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` ORDER BY `id` ASC', __FUNCTION__, __LINE__);
+ if (sqlNumRows($result) > $max) {
// Update overdue transfers
- $remove = SQL_NUMROWS($result) - $max;
+ $remove = sqlNumRows($result) - $max;
// This will make it really old, so the final removal query will find it
- $result = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_transfers_in` SET `time_trans`=0 ORDER BY `id` ASC LIMIT %s",
+ $result = sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_transfers_in` SET `time_trans`=0 ORDER BY `id` ASC LIMIT %s",
array($remove), __FUNCTION__, __LINE__);
} // END - if
// Second get total out-going lines
- $result = SQL_QUERY('SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` ORDER BY `id` ASC', __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) > $max) {
+ $result = sqlQuery('SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` ORDER BY `id` ASC', __FUNCTION__, __LINE__);
+ if (sqlNumRows($result) > $max) {
// Update overdue transfers
- $remove = SQL_NUMROWS($result) - $max;
+ $remove = sqlNumRows($result) - $max;
// This will make it really old, so the final removal query will find it
- $result = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_transfers_out` SET `time_trans`=0 ORDER BY `id` ASC LIMIT %s",
+ $result = sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_transfers_out` SET `time_trans`=0 ORDER BY `id` ASC LIMIT %s",
array($remove), __FUNCTION__, __LINE__);
} // END - if
// Remove old in-going transfers
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `time_trans` < (UNIX_TIMESTAMP() - %s)",
+ $result = sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `time_trans` < (UNIX_TIMESTAMP() - %s)",
array($age), __FUNCTION__, __LINE__);
- $removed = SQL_AFFECTEDROWS();
+ $removed = sqlAffectedRows();
// Remove old out-going transfers
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `time_trans` < (UNIX_TIMESTAMP() - %s)",
+ $result = sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `time_trans` < (UNIX_TIMESTAMP() - %s)",
array($age), __FUNCTION__, __LINE__);
- $removed += SQL_AFFECTEDROWS();
+ $removed += sqlAffectedRows();
// Only send email to admin(s) when we have removed entries
if ($removed > 0) {
} // END - if
// Search for the email address
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`userid`
FROM
`{?_MYSQL_PREFIX?}_user_data`
array($email), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load userid
- list($userid) = SQL_FETCHROW($result);
+ list($userid) = sqlFetchRow($result);
// Rewrite email address to contact link
$email = '{%url=modules.php?module=' . $mod . '&what=user_contct&userid=' . bigintval($userid) . '%}';
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return rewritten (?) email address
return $email;
$randUserid = mt_rand(0, ($totalUsers - 1));
// Look for random user
- $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` " . runFilterChain('user_exclusion_sql', "WHERE `status`='CONFIRMED'") . ' AND `rand_confirmed` >= {?user_min_confirmed?} ORDER BY `rand_confirmed` DESC LIMIT %s, 1',
+ $result = sqlQueryEscaped("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` " . runFilterChain('user_exclusion_sql', "WHERE `status`='CONFIRMED'") . ' AND `rand_confirmed` >= {?user_min_confirmed?} ORDER BY `rand_confirmed` DESC LIMIT %s, 1',
array($randUserid), __FUNCTION__, __LINE__);
// Is there one entry there?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Use that userid as new referral id
- list($refid) = SQL_FETCHROW($result);
+ list($refid) = sqlFetchRow($result);
// Debug message
/* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ' - choosen!');
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - if
// ... and update database
// @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `password`='%s' WHERE `userid`=%s AND `status`='CONFIRMED' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `password`='%s' WHERE `userid`=%s AND `status`='CONFIRMED' LIMIT 1",
array($content['hash'], $userid), __FUNCTION__, __LINE__);
// No login bonus by default
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',hash=' . $content['hash'] . '(' . strlen($content['hash']) . ')');
if ((setSession('userid', $userid )) && (setSession('u_hash', encodeHashForCookie($content['hash'])))) {
// Update database records
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `total_logins`=`total_logins`+1" . $add . " WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `total_logins`=`total_logins`+1" . $add . " WHERE `userid`=%s LIMIT 1",
array($userid), __FUNCTION__, __LINE__);
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Is a success URL set?
if (empty($successUrl)) {
// Procedure to checking for login data
}
} elseif (isExtensionInstalledAndNewer('sql_patches', '0.6.1')) {
// Update failure counter
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `login_failures`=`login_failures`+1,`last_failure`=NOW() WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `login_failures`=`login_failures`+1,`last_failure`=NOW() WHERE `userid`=%s LIMIT 1",
array($userid), __FUNCTION__, __LINE__);
// Wrong password!
$newPassword = generatePassword();
// Update database
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `password`='%s' WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `password`='%s' WHERE `userid`=%s LIMIT 1",
array(
generateHash($newPassword),
getUserData('userid')
} // END - if
// Try to find the entry
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
UNIX_TIMESTAMP(`inserted`) AS `inserted`
FROM
`{?_MYSQL_PREFIX?}_user_stats_data`
), __FUNCTION__, __LINE__);
// Is the entry there?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Get this stamp
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return stamp
return $data['inserted'];
// Does it exist?
if ((!getEpocheTimeFromUserStats($statsType, $statsData, $userid)) && (!is_array($statsData))) {
// Then insert it!
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats_data` (`userid`, `stats_type`, `stats_data`) VALUES (%s,'%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats_data` (`userid`, `stats_type`, `stats_data`) VALUES (%s,'%s','%s')",
array(
bigintval($userid),
$statsType,
), __FUNCTION__, __LINE__);
// Does it have worked?
- $return = (!SQL_HASZEROAFFECTED());
+ $return = (!ifSqlHasZeroAffectedRows());
} elseif (is_array($statsData)) {
// Invalid data!
logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',type=' . $statsType . ',data=' . gettype($statsData) . ': Invalid statistics data type!');
$userid = NULL;
// Search for an unconfirmed or confirmed account
- $result = SQL_QUERY_ESC("SELECT `userid`, `refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `userid`, `refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
array($hash), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Ok, he want's to confirm now so we load some data
- list($userid, $refid) = SQL_FETCHROW($result);
+ list($userid, $refid) = sqlFetchRow($result);
// Fetch user data
if (!fetchUserData($userid)) {
$content = getUserDataArray();
// Unlock his account (but only when it is on UNCONFIRMED!)
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`status`='CONFIRMED',
array($hash), __FILE__, __LINE__);
// Was it updated?
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Send email if updated
$message = loadEmailTemplate('guest_user_confirmed', $content, bigintval($userid));
// If version matches add ref bonus to refid's account
if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) {
// Add points (directly only!)
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_ref`=`bonus_ref`+{?bonus_ref?} WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_ref`=`bonus_ref`+{?bonus_ref?} WHERE `userid`=%s LIMIT 1",
array(bigintval($refid)), __FILE__, __LINE__);
// Subtract points from system
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$id])) {
// Check database for record
- $result = SQL_QUERY_ESC("SELECT `subid` FROM `{?_MYSQL_PREFIX?}_user_subids` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `subid` FROM `{?_MYSQL_PREFIX?}_user_subids` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load it
- list($GLOBALS[__FUNCTION__][$id]) = SQL_FETCHROW($result);
+ list($GLOBALS[__FUNCTION__][$id]) = sqlFetchRow($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return cache
// Log the transfer
function WERNIS_LOG_TRANSFER ($wdsId, $amount, $type = 'FAILED', $message = '', $status = '') {
// Register this wernis movement
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_wernis` (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`, `wernis_api_message`, `wernis_api_status`) VALUES (%s, %s, %s, UNIX_TIMESTAMP(), '%s', '%s', '%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_wernis` (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`, `wernis_api_message`, `wernis_api_status`) VALUES (%s, %s, %s, UNIX_TIMESTAMP(), '%s', '%s', '%s')",
array(
getMemberId(),
bigintval($wdsId),
$mailMode = YOOMEDIA_CONVERT_MODE($mailMode);
// Add the entry
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_yoomedia_reload` (`type`, `y_id`, `y_reload`, `inserted`) VALUES ('%s',%s,%s,'0000-00-00 00:00')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_yoomedia_reload` (`type`, `y_id`, `y_reload`, `inserted`) VALUES ('%s',%s,%s,'0000-00-00 00:00')",
array(
$mailMode,
bigintval($data['id']),
$mailMode = YOOMEDIA_CONVERT_MODE($mailMode);
// Add the entry
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_yoomedia_reload` WHERE `type`='%s' AND `y_id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_yoomedia_reload` WHERE `type`='%s' AND `y_id`=%s LIMIT 1",
array($mailMode, bigintval($data['id'])), __FUNCTION__, __LINE__);
}
$reloaded = FALSE;
// Query database
- $result = SQL_QUERY_ESC("SELECT `id`, UNIX_TIMESTAMP(`inserted`) AS `inserted` FROM `{?_MYSQL_PREFIX?}_yoomedia_reload` WHERE `type`='%s' AND `y_id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, UNIX_TIMESTAMP(`inserted`) AS `inserted` FROM `{?_MYSQL_PREFIX?}_yoomedia_reload` WHERE `type`='%s' AND `y_id`=%s LIMIT 1",
array($type, bigintval($id)), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load time
- list($id, $time) = SQL_FETCHROW($result);
+ list($id, $time) = sqlFetchRow($result);
// Are we ready to sent again?
if (((time() - $time) >= ($reload * 60*60)) && ($time > 0)) {
// Remove entry
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_yoomedia_reload` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_yoomedia_reload` WHERE `id`=%s LIMIT 1",
array($id), __FUNCTION__, __LINE__);
} else {
// Dont' sent again this mail
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $reloaded;
$mailMode = YOOMEDIA_CONVERT_MODE($mailMode);
// Add the entry
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_yoomedia_reload` (`type`, `y_id`, `y_reload`) VALUES ('%s',%s,%s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_yoomedia_reload` (`type`, `y_id`, `y_reload`) VALUES ('%s',%s,%s)",
array($mailMode, bigintval($data['id']), bigintval($data['reload'])), __FUNCTION__, __LINE__);
} // END - if
}
$GLOBALS['cache_instance']->init();
// Query the database about this
- $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_foos` ORDER BY `some_bar` ASC', __FILE__, __LINE__);
- while ($dummy = SQL_FETCHARRAY($result)) {
+ $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_foos` ORDER BY `some_bar` ASC', __FILE__, __LINE__);
+ while ($dummy = sqlFetchArray($result)) {
// Save row
$GLOBALS['cache_instance']->addRow($dummy);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close cache
$GLOBALS['cache_instance']->storeExtensionVersion('foo');
$add = runFilterChain('sql_admin_extra_data');
// Query the database about this
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id` AS `admin_id`,
`login`,
`password`,
`{?_MYSQL_PREFIX?}_admins`
ORDER BY
`login` ASC', __FILE__, __LINE__);
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Save row
$GLOBALS['cache_instance']->addRow($row);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close cache
$GLOBALS['cache_instance']->storeExtensionVersion('admins');
$GLOBALS['cache_instance']->init();
// Load all admins and their data
- $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY `admin_id` ASC,`action_menu` ASC,`what_menu` ASC', __FILE__, __LINE__);
+ $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY `admin_id` ASC,`action_menu` ASC,`what_menu` ASC', __FILE__, __LINE__);
// Add all rows
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row to cache file
$GLOBALS['cache_instance']->addRow($content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close cache
$GLOBALS['cache_instance']->storeExtensionVersion('admins');
$GLOBALS['cache_instance']->init();
// Query for all config entries
- $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_config` ORDER BY `config` ASC', __FILE__, __LINE__);
+ $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_config` ORDER BY `config` ASC', __FILE__, __LINE__);
// .. and load them
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row to cache file
$GLOBALS['cache_instance']->addRow($content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close the cache
$GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
$GLOBALS['cache_instance']->init();
// Query the database about this
- $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_earning_data` ORDER BY `earning_id` ASC', __FILE__, __LINE__);
- while ($dummy = SQL_FETCHARRAY($result)) {
+ $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_earning_data` ORDER BY `earning_id` ASC', __FILE__, __LINE__);
+ while ($dummy = sqlFetchArray($result)) {
// Save row
$GLOBALS['cache_instance']->addRow($dummy);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close cache
$GLOBALS['cache_instance']->storeExtensionVersion('earning');
} // END - if
// Query for all extensions
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id` AS `ext_id`,
`ext_name`,
`ext_active`,
`ext_name` ASC', __FILE__, __LINE__);
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load extension
if (!loadExtension($content['ext_name'], 'test')) {
// Is the name valid?
if (!isExtensionNameValid($content['ext_name'])) {
// Is not valid name (empty ext-foo.php script)
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array($content['ext_name']), __FILE__, __LINE__);
} else {
// Didn't load so deactivate it
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close the cache
$GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
$GLOBALS['cache_instance']->init();
// Query for all filters
- $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_filters` ORDER BY `filter_name` ASC, `filter_id` ASC', __FILE__, __LINE__);
+ $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_filters` ORDER BY `filter_name` ASC, `filter_id` ASC', __FILE__, __LINE__);
// Load all filters
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row to cache file
$GLOBALS['cache_instance']->addRow($content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close the cache
$GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
$GLOBALS['cache_instance']->init();
// Query the database about this
- $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_imprint_data` ORDER BY `imprint_id` ASC', __FILE__, __LINE__);
- while ($row = SQL_FETCHARRAY($result)) {
+ $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_imprint_data` ORDER BY `imprint_id` ASC', __FILE__, __LINE__);
+ while ($row = sqlFetchArray($result)) {
// Save row
$GLOBALS['cache_instance']->addRow($row);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close cache
$GLOBALS['cache_instance']->storeExtensionVersion('imprint');
// Is there up-to-date ext-sql_patches?
if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) {
// Yes, has_menu shall be there
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`module`,
`title`,
`module` ASC', __FILE__, __LINE__);
} else {
// Not recent enough ext-sql_patches ...
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`module`,
`title`,
}
// ... and load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row to cache file
$GLOBALS['cache_instance']->addRow($content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close the cache
$GLOBALS['cache_instance']->storeExtensionVersion('mods');
$GLOBALS['cache_instance']->init();
// Query the database about this
- $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `id` ASC', __FILE__, __LINE__);
- while ($dummy = SQL_FETCHARRAY($result)) {
+ $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `id` ASC', __FILE__, __LINE__);
+ while ($dummy = sqlFetchArray($result)) {
// Save row
$GLOBALS['cache_instance']->addRow($dummy);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close cache
$GLOBALS['cache_instance']->storeExtensionVersion('payments');
$GLOBALS['cache_instance']->init();
// Query the database about this
- $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_points_data` ORDER BY `id` ASC', __FILE__, __LINE__);
- while ($dummy = SQL_FETCHARRAY($result)) {
+ $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_points_data` ORDER BY `id` ASC', __FILE__, __LINE__);
+ while ($dummy = sqlFetchArray($result)) {
// Save row
$GLOBALS['cache_instance']->addRow($dummy);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close cache
$GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
$GLOBALS['cache_instance']->init();
// Query for all referral depths
- $result = SQL_QUERY('SELECT `id`, `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC', __FILE__, __LINE__);
+ $result = sqlQuery('SELECT `id`, `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC', __FILE__, __LINE__);
// ... and load them
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row to cache file
$GLOBALS['cache_instance']->addRow($content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close the cache
$GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
$GLOBALS['cache_instance']->init();
// Query for all referrals
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`userid`,
`level`,
`level` ASC', __FILE__, __LINE__);
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row to cache file
$GLOBALS['cache_instance']->addRow($content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close the cache
$GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
// Load all themes and their data
if (isExtensionInstalledAndNewer('theme', '0.0.7')) {
- $result = SQL_QUERY('SELECT `id`, `theme_path`, `theme_active`, `theme_ver`, `theme_name` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC', __FILE__, __LINE__);
+ $result = sqlQuery('SELECT `id`, `theme_path`, `theme_active`, `theme_ver`, `theme_name` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC', __FILE__, __LINE__);
} else {
- $result = SQL_QUERY('SELECT `id`, `theme_path`, `theme_active`, `theme_ver` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC', __FILE__, __LINE__);
+ $result = sqlQuery('SELECT `id`, `theme_path`, `theme_active`, `theme_ver` FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id` ASC', __FILE__, __LINE__);
}
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row to cache file
$GLOBALS['cache_instance']->addRow($content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Close the cache
$GLOBALS['cache_instance']->storeExtensionVersion('theme');
} // END - if
// Check for accounts to be notified
- $result_main = SQL_QUERY($sql, __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_main)) {
+ $result_main = sqlQuery($sql, __FILE__, __LINE__);
+ if (!ifSqlHasZeroNums($result_main)) {
// Normal notification mails or bonus mails?
$sentBonusMails = ((getBegNotifyBonus() > 0) && ($mode == 'enable') && (isExtensionActive('bonus')));
$receiver = ''; $userids = array();
// Okay lets notify all users!
- while ($row = SQL_FETCHARRAY($result_main)) {
+ while ($row = sqlFetchArray($result_main)) {
// Merge arrays
$content = merge_array($content, $row);
// Update account
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`beg_rallye_%s_notify`=UNIX_TIMESTAMP()
$url = 'modules.php?module=index&what=login';
// Insert mail
- addBonusMailToQueue('{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getBegNotifyBonus(), getBegNotifyWait(), $url, 0, 'normal', SQL_NUMROWS($result_main));
+ addBonusMailToQueue('{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getBegNotifyBonus(), getBegNotifyWait(), $url, 0, 'normal', sqlNumRows($result_main));
} // END - if
} // END - if
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
} // END - if
// [EOF]
$receiver = ''; $userids = array();
// Check for accounts to be notified
- $result_main = SQL_QUERY($sql, __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_main)) {
+ $result_main = sqlQuery($sql, __FILE__, __LINE__);
+ if (!ifSqlHasZeroNums($result_main)) {
// Okay lets notify all users!
- while ($content = SQL_FETCHARRAY($result_main)) {
+ while ($content = sqlFetchArray($result_main)) {
// Update account
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`bonus_rallye_%s_notify`=UNIX_TIMESTAMP()
$url = 'modules.php?module=index&what=login';
// Insert mail
- addBonusMailToQueue('{--MEMBER_BONUS_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getBonusNotifyPoints(), getConfig('bonus_notify_wait'), $url, 0, 'normal', SQL_NUMROWS($result_main));
+ addBonusMailToQueue('{--MEMBER_BONUS_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getBonusNotifyPoints(), getConfig('bonus_notify_wait'), $url, 0, 'normal', sqlNumRows($result_main));
} // END - if
} // END - if
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
} // END - if
//
// Get total points of the doubler itself
$totalPoints = getDoublerTotalPointsLeft();
if ($totalPoints == '0') {
- // Exit here to prevent some SQL errors (SQL_QUERY_ESC doen't insert zeros! We need to fix this...)
+ // Exit here to prevent some SQL errors (sqlQueryEscaped doen't insert zeros! We need to fix this...)
return;
} // END - if
} // END - if
// Check for doubles which we can pay out
-$result_total = SQL_QUERY_ESC("SELECT
+$result_total = sqlQueryEscaped("SELECT
COUNT(`do`.`id`) AS `cnt`,
FROM
`{?_MYSQL_PREFIX?}_doubler` AS `do`
), __FILE__, __LINE__);
// Get total count
-list($totalCount) = SQL_FETCHROW($result_total);
+list($totalCount) = sqlFetchRow($result_total);
// Free memory
-SQL_FREERESULT($result_total);
+sqlFreeResult($result_total);
// Check for accounts with limitation
-$result_main = SQL_QUERY_ESC("SELECT
+$result_main = sqlQueryEscaped("SELECT
`do`.`id`,
`do`.`userid`,
`do`.`points`,
), __FILE__, __LINE__);
// Are there entries found?
-if ((($totalCount > 0) && (getConfig('doubler_sent_all') == 'Y')) || ((SQL_NUMROWS($result_main) == getConfig('doubler_group_sent')) && (getConfig('doubler_sent_all') != 'Y'))) {
+if ((($totalCount > 0) && (getConfig('doubler_sent_all') == 'Y')) || ((sqlNumRows($result_main) == getConfig('doubler_group_sent')) && (getConfig('doubler_sent_all') != 'Y'))) {
// Switch to matching SQL resource
$result_load = $result_main;
if (($totalCount > 0) && (getConfig('doubler_sent_all') == 'Y')) {
} // END - if
// At least one account was found
- while ($content = SQL_FETCHARRAY($result_load)) {
+ while ($content = sqlFetchArray($result_load)) {
// Only double when points are enougth!
if ($totalPoints >= $content['points']) {
// Check for his ref points
if (($refPoints > 0) && ($GLOBALS['local_doubler_userid'] == $content['userid']) && (!empty($refPoints))) {
// Referral points found so add them and set line(s) to completed='Y'
$content['points'] += $refPoints;
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_doubler` SET `completed`='Y' WHERE `refid`=%s AND `completed`='N' AND `is_ref`='Y'",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_doubler` SET `completed`='Y' WHERE `refid`=%s AND `completed`='N' AND `is_ref`='Y'",
array(bigintval($content['userid'])), __FILE__, __LINE__);
} else {
// No referral points found
} // END - if
// Set entry as "payed"
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_doubler` SET `completed`='Y' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_doubler` SET `completed`='Y' WHERE `id`=%s LIMIT 1",
array(bigintval($content['id'])), __FILE__, __LINE__);
$okay = FALSE;
} // END - if
// Free memory
-SQL_FREERESULT($result_total);
-SQL_FREERESULT($result_main);
+sqlFreeResult($result_total);
+sqlFreeResult($result_main);
// [EOF]
?>
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
array($module), __FUNCTION__, __LINE__);
// Is the entry there?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Get the title from database
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
} // END - if
} else {
// No name found
$data['title'] = '{%message,UNKNOWN_MODULE_DETECTED_TITLE=' . $module . '%}';
- if ((is_resource($result)) && (SQL_HASZERONUMS($result))) {
+ if ((is_resource($result)) && (ifSqlHasZeroNums($result))) {
// Add module to database and ignore return value
checkModulePermissions($module);
} // END - if
} elseif (!isExtensionActive('cache')) {
// Check for module in database
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using database.');
- $result = SQL_QUERY_ESC("SELECT `locked`, `hidden`, `admin_only`, `mem_only` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `locked`, `hidden`, `admin_only`, `mem_only` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
array($module), __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Read data
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set all entries
foreach ($data as $key => $value) {
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return status
* Since 0.3.6 there is a has_menu column, this took me a half
* hour to find a loop here... *sigh*
*/
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg`
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg`
(`module`, `locked`, `hidden`, `mem_only`, `admin_only`, `has_menu`)
VALUES
('%s','Y','N','N','N','N')", array($module_chk), __FUNCTION__, __LINE__);
} else {
// Wrong/missing sql_patches!
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg`
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg`
(`module`, `locked`, `hidden`, `mem_only`, `admin_only`)
VALUES
('%s','Y','N','N','N')", array($module_chk), __FUNCTION__, __LINE__);
}
// Everthing is fine?
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// Something bad happend!
setModuleStatus($module_chk, 'major');
return 'major';
}
} elseif ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && ((!isExtensionActive('cache')) || ($forceDb === TRUE))) {
// Check database for entry
- $result = SQL_QUERY_ESC("SELECT `has_menu` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `has_menu` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
array($module), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load "has_menu" column
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Fake cache... ;-)
$GLOBALS['cache_array']['extension']['ext_menu'][$module] = $data['has_menu'];
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} elseif (!isExtensionInstalled('sql_patches')) {
// No ext-sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered?
$ret = in_array($module, array('admin', 'index', 'login', 'sponsor')); // Then there is a menu!
if ((isExtensionActive('maintenance')) && (isMaintenanceEnabled()) && (!isAdmin()) && (getModule() != 'admin')) {
// Maintain mode is active and you are no admin
addFatalMessage(__FUNCTION__, __LINE__, '{--MAILER_DOWN_FOR_MAINTENANCE--}');
- } elseif ((SQL_IS_LINK_UP()) && (!ifFatalErrorsDetected())) {
+ } elseif ((isSqlLinkUp()) && (!ifFatalErrorsDetected())) {
// Do the small "load module" call
$isModuleValid = loadModule();
} elseif (!ifFatalErrorsDetected()) {
$ret = 'already';
// Lookup the admin
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
array($adminLogin), __FUNCTION__, __LINE__);
// Is the entry there?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Is ext-admins installed and version at least 0.3.0?
if (isExtensionInstalledAndNewer('admins', '0.3.0')) {
// Ok, let's create the admin login
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`, `default_acl`) VALUES ('%s', '%s', '%s', '%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`, `default_acl`) VALUES ('%s', '%s', '%s', '%s')",
array(
$adminLogin,
$passHash,
), __FUNCTION__, __LINE__);
} else {
// Ok, let's create the admin login
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')",
array(
$adminLogin,
$passHash,
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $ret;
loadTemplate('admin_main', FALSE, $content);
// Check if action/what pair is valid
- $result_action = SQL_QUERY_ESC("SELECT
+ $result_action = sqlQueryEscaped("SELECT
`id`
FROM
`{?_MYSQL_PREFIX?}_admin_menu`
), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result_action) == 1) {
+ if (sqlNumRows($result_action) == 1) {
// Is valid but does the inlcude file exists?
$inc = sprintf("inc/modules/admin/action-%s.php", $action);
if ((isIncludeReadable($inc)) && (isMenuActionValid('admin', $action, $what)) && ($GLOBALS['acl_allow'] === TRUE)) {
}
// Free memory
- SQL_FREERESULT($result_action);
+ sqlFreeResult($result_action);
// Tableset footer
loadTemplate('admin_main_footer', FALSE, $content);
$GLOBALS['menu']['title'] = array();
// Build main menu
- $result_main = SQL_QUERY("SELECT
+ $result_main = sqlQuery("SELECT
`action` AS `main_action`,
`title` AS `main_title`,
`descr` AS `main_descr`
`id` DESC", __FUNCTION__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result_main)) {
+ if (!ifSqlHasZeroNums($result_main)) {
$OUT .= '<ul class="admin_menu_main">';
// Load all 'action' menus
- while ($mainContent = SQL_FETCHARRAY($result_main)) {
+ while ($mainContent = sqlFetchArray($result_main)) {
// Filename
$inc = sprintf("inc/modules/admin/action-%s.php", $mainContent['main_action']);
$OUT .= '</ul>';
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
} // END - if
// Return content
$OUT = '';
// Check for menu entries
- $result_what = SQL_QUERY_ESC("SELECT
+ $result_what = sqlQueryEscaped("SELECT
`what` AS `sub_what`,
`title` AS `sub_title`,
`descr` AS `sub_descr`
array($mainContent['main_action']), __FUNCTION__, __LINE__);
// Remember the count for later checks
- setAdminMenuHasEntries($mainContent['main_action'], ((!SQL_HASZERONUMS($result_what)) && (($action == $mainContent['main_action']) || (isAdminMenuJavascriptEnabled()))));
+ setAdminMenuHasEntries($mainContent['main_action'], ((!ifSqlHasZeroNums($result_what)) && (($action == $mainContent['main_action']) || (isAdminMenuJavascriptEnabled()))));
// Start li-tag for sub menu content
$OUT .= '<li class="admin_menu_sub" id="action_menu_' . $mainContent['main_action'] . '"' . addStyleMenuContent('admin', $mainContent['main_action'], $action) . '>';
$SUB = TRUE;
// Are there entries?
- if (!SQL_HASZERONUMS($result_what)) {
+ if (!ifSqlHasZeroNums($result_what)) {
// Start HTML code
$OUT .= '<ul class="admin_menu_sub">';
// Load all entries
- while ($subContent = SQL_FETCHARRAY($result_what)) {
+ while ($subContent = sqlFetchArray($result_what)) {
// Filename
$inc = sprintf("inc/modules/admin/what-%s.php", $subContent['sub_what']);
} // END - if
// Free memory
- SQL_FREERESULT($result_what);
+ sqlFreeResult($result_what);
} // END - if
// Close li-tag
} // END - if
// Query all entries
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`login`
' . $ADD . '
$OUT = '';
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Default is none
$content['default'] = '';
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Add form to content
$content['form_selection'] = $OUT;
// Create a member selection box
function addMemberSelectionBox ($userid = NULL, $add_all = FALSE, $return = FALSE, $none = FALSE, $field = 'userid', $whereStatement = " WHERE `surname` NOT LIKE '{?tester_user_surname_prefix?}%'") {
// Output selection form with all confirmed user accounts listed
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`userid`,
`surname`,
`family`
}
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . intval($userid) . '/' . $content['userid']);
$OUT .= '<option value="' . bigintval($content['userid']) . '"';
if (bigintval($userid, FALSE, FALSE) === bigintval($content['userid'])) {
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
if ($return === FALSE) {
// Remeber options in constant
$what = "`what` != '' AND `what` IS NOT NULL";
if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND `action` != 'login'";
- $result = SQL_QUERY_ESC("SELECT `%s` AS `menu`, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
+ $result = sqlQueryEscaped("SELECT `%s` AS `menu`, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
array($mode), __FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load menu as selection
$OUT = '<select name="' . $mode . '_menu';
if (!isValidId($defid)) $OUT .= '[' . intval($defid) . ']';
$OUT .= '" size="1" class="form_select">
<option value="">{--SELECT_NONE--}</option>';
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
$OUT .= '<option value="' . $content['menu'] . '"';
if ((!empty($default)) && ($default == $content['menu'])) {
$OUT .= ' selected="selected"';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Add closing select-tag
$OUT .= '</select>';
$result = FALSE;
if ($alwaysAdd === FALSE) {
if (!empty($whereStatement)) {
- $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` WHERE " . $whereStatement . " LIMIT 1", __FUNCTION__, __LINE__);
+ $result = sqlQuery("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` WHERE " . $whereStatement . " LIMIT 1", __FUNCTION__, __LINE__);
} else {
- $result = SQL_QUERY("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` LIMIT 1", __FUNCTION__, __LINE__);
+ $result = sqlQuery("SELECT * FROM `{?_MYSQL_PREFIX?}" . $tableName . "` LIMIT 1", __FUNCTION__, __LINE__);
}
} // END - if
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// "Implode" all data to single string
$updatedData = implode(', ', $tableData);
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Simply run generated SQL string
- SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ sqlQuery($sql, __FUNCTION__, __LINE__);
// Remember affected rows
- $affected = SQL_AFFECTEDROWS();
+ $affected = sqlAffectedRows();
// Rebuild cache
rebuildCache('config', 'config');
incrementStatsEntry('cache_hits');
} elseif (isExtensionInstalledAndNewer('admins', '0.6.7')) {
// Load from database when version of 'admins' is enough
- $result = SQL_QUERY_ESC("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
array($adminId), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- list($adminMode) = SQL_FETCHROW($result);
+ list($adminMode) = sqlFetchRow($result);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Check what the admin wants and set it when it's not the default mode
// Should always be set... ;-)
if (!empty($selected)) {
// Determine new status
- $result = SQL_QUERY_ESC("SELECT %s FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT %s FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
array(
$row,
$table,
), __FUNCTION__, __LINE__);
// Row found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load the status
- list($currStatus) = SQL_FETCHROW($result);
+ list($currStatus) = sqlFetchRow($result);
// And switch it N<->Y
$newStatus = convertBooleanToYesNo(!($currStatus == 'Y'));
// Change this status
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s` SET %s='%s' WHERE %s=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_%s` SET %s='%s' WHERE %s=%s LIMIT 1",
array(
$table,
$row,
), __FUNCTION__, __LINE__);
// Count up affected rows
- $count += SQL_AFFECTEDROWS();
+ $count += sqlAffectedRows();
} // END - if
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - foreach
// "Walk" through all entries
foreach (postRequestElement($idColumn[0]) as $id => $sel) {
// Construct SQL query
- $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET", SQL_ESCAPE($tableName[0]));
+ $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET", sqlEscapeString($tableName[0]));
// Load data of entry
- $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
array(
$tableName[0],
$idColumn[0],
), __FUNCTION__, __LINE__);
// Fetch the data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Add all status entries (e.g. status column last_updated or so)
$newStatus = 'UNKNOWN';
// Does the entry exist?
if ((isset($content[$column])) && (isset($statusInfo[$content[$column]]))) {
// Add these entries for update
- $sql .= sprintf(" `%s`='%s',", SQL_ESCAPE($column), SQL_ESCAPE($statusInfo[$content[$column]]));
+ $sql .= sprintf(" `%s`='%s',", sqlEscapeString($column), sqlEscapeString($statusInfo[$content[$column]]));
// Remember status
if ($statusColumn == 'unknown') {
// Are there brackets () at the end?
if (substr($entries[$id], -2, 2) == '()') {
// Direct SQL command found
- $sql .= sprintf(" `%s`=%s,", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
+ $sql .= sprintf(" `%s`=%s,", sqlEscapeString($key), sqlEscapeString($entries[$id]));
} else {
// Add regular entry
- $sql .= sprintf(" `%s`='%s',", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
+ $sql .= sprintf(" `%s`='%s',", sqlEscapeString($key), sqlEscapeString($entries[$id]));
// Add entry
$content[$key] = $entries[$id];
);
// Run the SQL
- SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ sqlQuery($sql, __FUNCTION__, __LINE__);
// Send "build mails" out
sendGenericBuildMails($mode, $tableName, $content, $id, $statusInfo[$content[$column]], $userIdColumn);
displayMessage('{--ADMIN_ALL_ENTRIES_REMOVED--}');
} else {
// Some are still there :(
- displayMessage(sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_DELETED'), SQL_AFFECTEDROWS(), countPostSelection($idColumn[0])));
+ displayMessage(sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_DELETED'), sqlAffectedRows(), countPostSelection($idColumn[0])));
}
} else {
// List for deletion confirmation
doGenericAddEntries($tableName, $columns, $filterFunctions, $extraValues, $timeColumns, $columnIndex);
// Entry has been added?
- if ((!SQL_HASZEROAFFECTED()) && ($GLOBALS['__XML_PARSE_RESULT'] === TRUE)) {
+ if ((!ifSqlHasZeroAffectedRows()) && ($GLOBALS['__XML_PARSE_RESULT'] === TRUE)) {
// Display success message
displayMessage('{--ADMIN_ENTRY_ADDED--}');
} else {
$OUT = '';
// Look up administator login
- $result = SQL_QUERY_ESC("SELECT `id`, `login`, `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE '%s' REGEXP `email` LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `login`, `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE '%s' REGEXP `email` LIMIT 1",
array($email), __FUNCTION__, __LINE__);
// Is there an account?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// No account found
return '{--ADMIN_NO_LOGIN_WITH_EMAIL--}';
} // END - if
// Load all data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Generate hash for reset link
$content['hash'] = generateHash(getUrl() . getEncryptSeparator() . $content['id'] . getEncryptSeparator() . $content['login'] . getEncryptSeparator() . $content['password'], substr($content['password'], getSaltLength()));
$valid = FALSE;
// Then try to find that user
- $result = SQL_QUERY_ESC("SELECT `id`, `password`, `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `password`, `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
array($login), __FUNCTION__, __LINE__);
// Is an account here?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load all data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Generate hash again
$hashFromData = generateHash(getUrl() . getEncryptSeparator() . $content['id'] . getEncryptSeparator() . $login . getEncryptSeparator() . $content['password'], substr($content['password'], getSaltLength()));
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $valid;
} // END - if
// Update the task
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
array(
$row,
$data,
// Shall we update a menu or sub menu?
if (!isGetRequestElementSet('sub')) {
// Update with 'what'=null
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s',`action`='%s',`what`=NULL WHERE ".$AND." AND `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s',`action`='%s',`what`=NULL WHERE ".$AND." AND `id`=%s LIMIT 1",
array(
$type,
$menu,
), __FUNCTION__, __LINE__);
} else {
// Update with selected 'what'
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s',`action`='%s',`what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `title`='%s',`action`='%s',`what`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
array(
$type,
$menu,
break;
case 'delete': // Delete menu
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(
$type,
$sel
break;
case 'status': // Change status of menus
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `visible`='%s',`locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `visible`='%s',`locked`='%s' WHERE ".$AND." AND `id`=%s LIMIT 1",
array(
$type,
postRequestElement('visible', $sel),
// Get ids
if (isGetRequestElementSet('w')) {
// Sub menus selected
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
array(
$type,
getRequestElement('act'),
bigintval(getRequestElement('tid'))
), __FUNCTION__, __LINE__);
- list($tid) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
+ list($tid) = sqlFetchRow($result);
+ sqlFreeResult($result);
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `sort`=%s LIMIT 1",
array(
$type,
getRequestElement('act'),
bigintval(getRequestElement('fid'))
), __FUNCTION__, __LINE__);
- list($fid) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ list($fid) = sqlFetchRow($result);
+ sqlFreeResult($result);
} else {
// Main menu selected
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
array(
$type,
bigintval(getRequestElement('tid'))
), __FUNCTION__, __LINE__);
- list($tid) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
+ list($tid) = sqlFetchRow($result);
+ sqlFreeResult($result);
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL) AND `sort`=%s LIMIT 1",
array(
$type,
bigintval(getRequestElement('fid'))
), __FUNCTION__, __LINE__);
- list($fid) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ list($fid) = sqlFetchRow($result);
+ sqlFreeResult($result);
}
if ((!empty($tid)) && (!empty($fid))) {
// Sort menu
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
array(
$type,
bigintval(getRequestElement('tid')),
bigintval($fid)
), __FUNCTION__, __LINE__);
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `sort`=%s WHERE ".$AND." AND `id`=%s LIMIT 1",
array(
$type,
bigintval(getRequestElement('fid')),
// @TODO This function does also check for uncompleted tasks
function outputStandardOverview (&$result_tasks) {
// First check for solved and not assigned tasks and assign them to current admin
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=%s WHERE `assigned_admin` IS NULL AND status != 'NEW'",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=%s WHERE `assigned_admin` IS NULL AND status != 'NEW'",
array(getCurrentAdminId()), __FILE__, __LINE__);
// We currently don't want to install an extension so let's find out if we need...
} // END - foreach
// At last - but not least - check for own and new unassigned tasks...
- $result_tasks = SQL_QUERY_ESC("SELECT
+ $result_tasks = sqlQueryEscaped("SELECT
`id`,
`assigned_admin`,
`userid`,
`task_created` DESC",
array(getCurrentAdminId()), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_tasks)) {
+ if (!ifSqlHasZeroNums($result_tasks)) {
// New jobs found
$jobsDone = FALSE;
} // END - if
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return status
return $jobsDone;
// Assign / do tasks
$OUT = '';
foreach ($postData['sel'] as $taskId => $sel) {
- $result_task = SQL_QUERY_ESC("SELECT
+ $result_task = sqlQueryEscaped("SELECT
`id`,
`userid`,
`task_type`,
), __FILE__, __LINE__);
// Task is found?
- if (SQL_NUMROWS($result_task) == 1) {
+ if (sqlNumRows($result_task) == 1) {
// Task is valid so load it's data
- $taskData = SQL_FETCHARRAY($result_task);
+ $taskData = sqlFetchArray($result_task);
if ($taskData['assigned_admin'] == '0') {
// Assgin current admin to unassgigned task
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=%s WHERE `id`=%s AND `assigned_admin` IS NULL LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=%s WHERE `id`=%s AND `assigned_admin` IS NULL LIMIT 1",
array(
getCurrentAdminId(),
bigintval($taskData['id'])
case 'PAYOUT_REQUEST': // Payout requests
if (isExtensionActive('payout')) {
// Extension is installed so let him send a notification to the user
- $result_pay = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `userid`=%s AND `payout_timestamp`=%s LIMIT 1",
+ $result_pay = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `userid`=%s AND `payout_timestamp`=%s LIMIT 1",
array(bigintval($taskData['userid']), bigintval($taskData['task_created'])), __FILE__, __LINE__);
- list($pid) = SQL_FETCHROW($result_pay);
- SQL_FREERESULT($result_pay);
+ list($pid) = sqlFetchRow($result_pay);
+ sqlFreeResult($result_pay);
if (isValidId($pid)) {
// Payout id can be obtained
case 'WERNIS_REQUEST': // Wernis requests
if (isExtensionActive('wernis')) {
// Extension is installed so let him send a notification to the user
- $result_pay = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_wernis` WHERE `userid`=%s AND wernis_timestamp=%s LIMIT 1",
+ $result_pay = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_wernis` WHERE `userid`=%s AND wernis_timestamp=%s LIMIT 1",
array(bigintval($taskData['userid']), bigintval($taskData['task_created'])), __FILE__, __LINE__);
- list($pid) = SQL_FETCHROW($result_pay);
- SQL_FREERESULT($result_pay);
+ list($pid) = sqlFetchRow($result_pay);
+ sqlFreeResult($result_pay);
if (isValidId($pid)) {
// Payout id can be obtained
} // END - if
// Free result
- SQL_FREERESULT($result_task);
+ sqlFreeResult($result_task);
} // END - foreach
// Load final template
if (!empty($postData['unassign'])) {
// Unassign from tasks
foreach ($postData['sel'] as $taskId => $sel) {
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=NULL WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=NULL WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1",
array(bigintval($taskId), getCurrentAdminId()), __FILE__, __LINE__);
} // END - foreach
} elseif (!empty($postData['delete'])) {
// Delete tasks
foreach ($postData['sel'] as $taskId => $sel) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s AND `assigned_admin` IN (%s,0,NULL) LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s AND `assigned_admin` IN (%s,0,NULL) LIMIT 1",
array(bigintval($taskId), getCurrentAdminId()), __FILE__, __LINE__);
} // END - foreach
} else {
}
// Update query
- $result_tasks = SQL_QUERY_ESC("SELECT `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `assigned_admin`=%s OR ((`assigned_admin`=0 OR `assigned_admin` IS NULL) AND `status`='NEW') ORDER BY `task_created` DESC",
+ $result_tasks = sqlQueryEscaped("SELECT `id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `assigned_admin`=%s OR ((`assigned_admin`=0 OR `assigned_admin` IS NULL) AND `status`='NEW') ORDER BY `task_created` DESC",
array(getCurrentAdminId()), __FILE__, __LINE__);
} // END - if
// There are uncompleted jobs!
$OUT = '';
- while ($content = SQL_FETCHARRAY($result_tasks)) {
+ while ($content = sqlFetchArray($result_tasks)) {
// Init infos
$content['infos'] = '';
} // END - while
// Free memory
- SQL_FREERESULT($result_tasks);
+ sqlFreeResult($result_tasks);
// Load footer template
loadTemplate('admin_overview_table', FALSE, $OUT);
$content['points'] = bigintval(postRequestElement('points'));
// Select all users
- $result_main = SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' ORDER BY `userid` ASC",
+ $result_main = sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' ORDER BY `userid` ASC",
__FILE__, __LINE__);
// Process all entries
- while ($row = SQL_FETCHARRAY($result_main)) {
+ while ($row = sqlFetchArray($result_main)) {
// Merge $row into $content
$content = merge_array($content, $row);
// Prepare content
$content = array(
- 'reason' => SQL_ESCAPE(postRequestElement('reason')),
+ 'reason' => sqlEscapeString(postRequestElement('reason')),
'points' => bigintval(postRequestElement('points')),
'userid' => $row['userid'],
'subject' => 'admin_add_all',
} // END - while
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
// Output message
displayMessage('{--ADMIN_ALL_POINTS_ADDED--}');
// Prepare content
$content = array(
- 'reason' => SQL_ESCAPE(postRequestElement('reason')),
+ 'reason' => sqlEscapeString(postRequestElement('reason')),
'points' => bigintval(postRequestElement('points')),
'subject' => 'admin_add_single',
);
$END = mktime(postRequestElement('end_time_ho') , postRequestElement('end_time_mi') , 0, postRequestElement('end_time_mo') , postRequestElement('end_time_da') , postRequestElement('end_time_ye') );
// Is there already a rallye running?
- $result = SQL_QUERY_ESC("SELECT `id`, `admin_id` FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE (`start_time` <= %s AND `end_time` >= %s) OR (`start_time` >= %s AND `start_time` <= %s) LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `admin_id` FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE (`start_time` <= %s AND `end_time` >= %s) OR (`start_time` >= %s AND `start_time` <= %s) LIMIT 1",
array($START, $START, $START, $END), __FILE__, __LINE__);
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Ok, start and end time did not overlap
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_rallye_data`
(
`admin_id`,
), __FILE__, __LINE__);
// Load id
- $id = SQL_INSERT_ID();
+ $id = getSqlInsertId();
if (!empty($id)) {
// Reload to prices...
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Starting day
$below = array();
// Get all available main menus
- $result = SQL_QUERY("SELECT `action`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ $result = sqlQuery("SELECT `action`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
+ if (!ifSqlHasZeroNums($result)) {
// Read menu structure
// @TODO Cant this be rewritten?
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Menu actions
array_push($menus, $content['action']);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remove double eintries
// @TODO This can be somehow rewritten to a function
// Load sub menus :)
foreach ($menus as $key_main => $value_main) {
- $result = SQL_QUERY_ESC("SELECT `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
+ $result = sqlQueryEscaped("SELECT `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
array($value_main), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Init arrays
$menus[$value_main] = array();
$titles[$value_main] = array();
$below[$value_main] = array();
// Read menu structure
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Menu actions
array_push($menus[$value_main], $content['what']);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remove double eintries
// @TODO This can be somehow rewritten to a function
// Insert new menu entry
if (isPostRequestElementSet('menu')) {
// Add sub menu
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu` (`action`, `what`, `title`, `descr`, `sort`) VALUES ('%s','%s','%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu` (`action`, `what`, `title`, `descr`, `sort`) VALUES ('%s','%s','%s','%s','%s')",
array(
postRequestElement('menu'),
postRequestElement('name'),
);
} else {
// Add main menu
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu` (action, title, descr, sort) VALUES ('%s','%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu` (action, title, descr, sort) VALUES ('%s','%s','%s','%s')",
array(
postRequestElement('name'),
postRequestElement('title'),
foreach (postRequestElement('sel') as $sel => $confirm) {
if ($confirm == 1) {
$count++;
- $result = SQL_QUERY_ESC("SELECT `title`, `action`, `what`, `descr` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title`, `action`, `what`, `descr` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Entry found so we load the stuff...
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Prepare data for the row template
$content = array(
}
// Free result and switch color
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - foreach
foreach (postRequestElement('sel') as $sel => $confirm) {
if ($confirm == 1) {
$count++;
- $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Entry found so we load the stuff...
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Prepare data for the row template
$content = array(
);
$OUT .= loadTemplate('admin_menu_404_row', TRUE, $content);
}
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - switch
$sel = bigintval($sel);
// Update entry
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_admin_menu`
SET
`title`='%s',
case 'delete': // Delete menu
foreach (postRequestElement('sel') as $sel => $menu) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
} // END - foreach
doAdminProcessMenuWeightning('admin', $AND);
// Run SQL
- $result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." ORDER BY `sort` ASC", __FILE__, __LINE__);
+ $result = sqlQuery("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$AND." ORDER BY `sort` ASC", __FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Init variables
$OUT = '';
$count = '0';
// Process all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Remember sub value
$content['sub'] = $subMenu;
if (($content['sort'] == '0') || (($content['sort'] == 1) && (!empty($subMenu)))) {
// Is highest position
$content['navi'] = '<a href="{%url=modules.php?module=admin&what=adminedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']+1) . '&fid=' . $content['sort'] . '%}">{--LOWER--}</a>';
- } elseif (SQL_NUMROWS($result) == $count) {
+ } elseif (sqlNumRows($result) == $count) {
// Is lowest position
$content['navi'] = '<a href="{%url=modules.php?module=admin&what=adminedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']-1) . '&fid=' . $content['sort'] . '%}">{--HIGHER--}</a>';
} elseif ($content['sort'] > 0) {
$content['sub'] = $subMenu;
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
loadTemplate('admin_edit_admin_menu', FALSE, $content);
$rows = '';
foreach (postRequestElement('sel') as $template => $sel) {
// First of all load data from DB
- $result = SQL_QUERY_ESC("SELECT `admin_id`, `id` FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE `mail_template`='%s' ORDER BY `id` ASC",
+ $result = sqlQueryEscaped("SELECT `admin_id`, `id` FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE `mail_template`='%s' ORDER BY `id` ASC",
array($template), __FILE__, __LINE__);
$OUT = '';
$adminId2 = '0'; $id = '0';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// @TODO Can this be rewritten to an API function?
$OUT .= '<select name="admin_id[' . $content['id'] . ']" size="1" class="form_select">
<option value="0"';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Prepare content
$content['id'] = $id;
}
} else {
// Load all assigned mails
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`m`.`id`,
`m`.`admin_id`,
`a`.`login`,
`m`.`admin_id` ASC,
`m`.`mail_template` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Shall I change entries?
if (isFormSent('do_edit')) {
// Init SQLs
$content['admin_id'] = bigintval($content['admin_id']);
// Update entry
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins_mails` SET `admin_id`=%s WHERE `id`=%s ORDER BY `id` LIMIT 1",
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_admins_mails` SET `admin_id`=%s WHERE `id`=%s ORDER BY `id` LIMIT 1",
array($content['admin_id'], $id), __FILE__, __LINE__, FALSE));
if ((!isValidId($content['admin_id'])) && (isPostRequestElementSet('template', $id))) {
// Remove any other admin entries
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE mail_template='%s' AND id != '%s'",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE mail_template='%s' AND id != '%s'",
array(postRequestElement('template', $id), $id), __FILE__, __LINE__, FALSE));
} // END - if
if (postRequestElement('admin_new', postRequestElement('template', $id)) > 0) {
// Add new admin
- addSql(SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (admin_id, mail_template) VALUES ('%s','%s')",
+ addSql(sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (admin_id, mail_template) VALUES ('%s','%s')",
array($content['admin_id'], postRequestElement('template', $id)), __FILE__, __LINE__, FALSE));
} // END - if
} // END - foreach
runFilterChain('run_sqls');
// Query again...
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`m`.`id`,
`m`.`admin_id`,
`a`.`login`,
// List found entries
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template
$OUT .= loadTemplate('admin_admins_mails_list_row', TRUE, $content);
} // END - while
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
loadTemplate('admin_admins_mails_list', FALSE, $OUT);
} // END - if
// Load all what menu points
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`id`,
`what`,
`title`
$OUT = '';
// Process all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Link for setting 'what' as new 'home'
$newHomeLink = '<a href="{%url=modules.php?module=admin&what=config_home&sub=target&home=' . $content['what'] . '%}">{--_IS_NEW_HOME--}</a>';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
loadTemplate('admin_list_home', FALSE, $OUT);
// Handle form ...
} else {
// Query for all imprint data rows
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`imprint_key`,
`imprint_value`
FROM
`imprint_id` ASC', __FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all entries
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template
$OUT .= loadTemplate('admin_list_imprint_row', TRUE, $content);
} // END - while
// Is there a network selected?
if (isGetRequestElementSet('network_id')) {
// Check all networks that doesn't have a configuration entry
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_id`,
`network_short_name`,
`network_title`,
), __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Is the network active?
if (($content['network_active'] == 'N') && (!isAdminsExpertWarningEnabled()) && (!isDebugModeEnabled())) {
} // END - if
// Query for config table
- $result_config = SQL_QUERY_ESC('SELECT
+ $result_config = sqlQueryEscaped('SELECT
`network_api_affiliate_id`,
`network_api_password`,
`network_api_site_id`,
), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result_config) == 1) {
+ if (sqlNumRows($result_config) == 1) {
// Load entries
- $content = merge_array($content, SQL_FETCHARRAY($result_config));
+ $content = merge_array($content, sqlFetchArray($result_config));
} // END - if
// Free result
- SQL_FREERESULT($result_config);
+ sqlFreeResult($result_config);
// Load main template (for "add" and "edit")
loadTemplate('admin_config_network_api', FALSE, $content);
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Generate network list for this script
$OUT = generateAdminNetworkList(TRUE);
// Is a network type handler selected?
if (isGetRequestElementSet('network_type_id')) {
// Load data for given network
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`t`.`network_id`,
`t`.`network_type_id`,
`t`.`network_type_handler`,
), __FUNCTION__, __LINE__);
// Is there a record?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load it
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Is the network active?
if (($content['network_active'] == 'N') && (!isAdminsExpertWarningEnabled()) && (!isDebugModeEnabled())) {
} // END - if
// Check for network type configuration
- $result_config = SQL_QUERY_ESC('SELECT
+ $result_config = sqlQueryEscaped('SELECT
`network_data_id`,
`network_max_reload_time`,
`network_min_waiting_time`,
$templateName = 'admin_add_config_network_type_form';
// Do we also have configuration?
- if (SQL_NUMROWS($result_config) == 1) {
+ if (sqlNumRows($result_config) == 1) {
// Load as well and merge it
- $content = merge_array($content, SQL_FETCHARRAY($result_config));
+ $content = merge_array($content, sqlFetchArray($result_config));
// Use template for editing
$templateName = 'admin_edit_config_network_type_form';
} // END - if
// Free result
- SQL_FREERESULT($result_config);
+ sqlFreeResult($result_config);
// "Translate" some values
$content['network_max_reload_time'] = createTimeSelections($content['network_max_reload_time'], 'network_max_reload_time', 'WDhms');
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Get all type handlers
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_id`,
`network_type_id`,
`network_type_handler`,
), __FUNCTION__, __LINE__);
// Are there entries left?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Init row output
$OUT = '';
// List all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Check if config entry is there
- $result_config = SQL_QUERY_ESC('SELECT
+ $result_config = sqlQueryEscaped('SELECT
`network_data_id`,
`network_max_reload_time`,
`network_min_waiting_time`,
), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result_config) == 1) {
+ if (sqlNumRows($result_config) == 1) {
// Load this data as well
- $content = merge_array($content, SQL_FETCHARRAY($result_config));
+ $content = merge_array($content, sqlFetchArray($result_config));
// Add it with extra template
$content['network_type_config_content'] = loadTemplate('admin_show_config_network_type', TRUE, $content);
}
// Free result
- SQL_FREERESULT($result_config);
+ sqlFreeResult($result_config);
// Load row template
$OUT .= loadTemplate('admin_config_network_types_row', TRUE, $content);
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Generate network list for this script
$OUT = generateAdminNetworkList(FALSE, TRUE, FALSE);
// Do we add an entry?
if ((isFormSent('add')) && (isPostRequestElementSet('title')) && (postRequestElement('rate') > 0)) {
// Add new payout type
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE type='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE type='%s' LIMIT 1",
array(postRequestElement('title')), __FILE__, __LINE__);
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Add now
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_payout_types`
(
`type`, `rate`, `min_points`, `from_account`, `from_pass`, `engine_url`, `engine_ret_ok`, `engine_ret_failed`, `pass_enc`, `allow_url`
$message = '{--ADMIN_PAYOUT_TYPE_ADDED--}';
} else {
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Does already exist
$message = '<div class="bad">{--ADMIN_PAYOUT_TYPE_ALREADY--}</div>';
}
// Payout requests by your members
-$result_mem = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `status`='NEW' ORDER BY payout_timestamp DESC", __FILE__, __LINE__);
+$result_mem = sqlQuery("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `status`='NEW' ORDER BY payout_timestamp DESC", __FILE__, __LINE__);
$display = TRUE;
if ((isFormSent('edit')) && (ifPostContainsSelections())) {
$OUT = '';
foreach (postRequestElement('sel') as $id => $sel) {
// Load data
- $result = SQL_QUERY_ESC("SELECT `id`, `type`, `rate`, `min_points`, `allow_url` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `type`, `rate`, `min_points`, `allow_url` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
- SQL_FREERESULT($result);
+ $content = sqlFetchArray($result);
+ sqlFreeResult($result);
// Prepare data for the row template
$content['allow_url'] = addSelectionBox('yn', $content['allow_url'], 'allow_url[' . $content['id'] . ']');
// Edit only if something is entered
if ((isPostRequestElementSet('type', $id)) && (postRequestElement('rate', $id) > 0)) {
// Update entry
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_payout_types` SET
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_payout_types` SET
`type`='%s',
`rate`=%s,
`min_points`=%s,
$id = bigintval($id);
// Load data
- $result = SQL_QUERY_ESC("SELECT `id`, `type`, `rate`, `min_points` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `type`, `rate`, `min_points` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
array($id), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
- SQL_FREERESULT($result);
+ $content = sqlFetchArray($result);
+ sqlFreeResult($result);
// Load row template and switch color
$OUT .= loadTemplate('admin_delete_payouts_row', TRUE, $content);
// Delete entries
foreach (postRequestElement('sel') as $id => $sel) {
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__, FALSE));
} // END - foreach
} // END - if
// Payout types
-$result_type = SQL_QUERY('SELECT
+$result_type = sqlQuery('SELECT
`id`,
`type`,
`rate`,
ORDER BY
`type` ASC', __FILE__, __LINE__);
-if ((!SQL_HASZERONUMS($result_type)) && ($display)) {
+if ((!ifSqlHasZeroNums($result_type)) && ($display)) {
// List all payout types
$OUT = '';
- while ($content = SQL_FETCHARRAY($result_type)) {
+ while ($content = sqlFetchArray($result_type)) {
// Load row template and switch color
$OUT .= loadTemplate('admin_config_payouts_row', TRUE, $content);
} // END - while
// Free memory
- SQL_FREERESULT($result_type);
+ sqlFreeResult($result_type);
// Load main template
loadTemplate('admin_config_payouts', FALSE, $OUT);
} // END - if
// Does your members request payouts?
-if ((!SQL_HASZERONUMS($result_mem)) && ($display === TRUE)) {
+if ((!ifSqlHasZeroNums($result_mem)) && ($display === TRUE)) {
// Members has requested payouts
displayMessage('<a href="{%url=modules.php?module=admin&what=list_payouts%}">{--ADMIN_PAYOUT_LIST_REQUESTS--}</a>');
} elseif ($display === TRUE) {
}
// Free result
-SQL_FREERESULT($result_mem);
+sqlFreeResult($result_mem);
// Add new payout type
if ($display === TRUE) {
// Update all entries
foreach (postRequestElement('sel') as $id => $value) {
// Update database
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_must_register` SET `field_required`='%s' WHERE `id`=%s AND `field_required` != '%s' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_must_register` SET `field_required`='%s' WHERE `id`=%s AND `field_required` != '%s' LIMIT 1",
array(
$value,
bigintval($id),
),__FILE__, __LINE__);
// Get affected rows
- $count += SQL_AFFECTEDROWS();
+ $count += sqlAffectedRows();
} // END - foreach
// Output message for updated entries
} // END - if
// List all register values
-$result = SQL_QUERY("SELECT `id`, `field_name`, `field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC", __FILE__, __LINE__);
+$result = sqlQuery("SELECT `id`, `field_name`, `field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC", __FILE__, __LINE__);
$OUT = '';
-while ($content = SQL_FETCHARRAY($result)) {
+while ($content = sqlFetchArray($result)) {
// Get language string
$content['field_name'] = '{--' . strtoupper($content['field_name']) . '--}';
} // END - while
// Free memory
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Load template
loadTemplate('admin_config_register', FALSE, $OUT);
adminSaveSettingsFromPostData();
} else {
// Load existing modules and generate TR rows for the template
- $result = SQL_QUERY("SELECT `module`, `title` FROM `{?_MYSQL_PREFIX?}_mod_reg` ORDER BY module", __FILE__, __LINE__);
+ $result = sqlQuery("SELECT `module`, `title` FROM `{?_MYSQL_PREFIX?}_mod_reg` ORDER BY module", __FILE__, __LINE__);
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Already registered module?
if (isInString($content['module'], getConfig('rewrite_skip'))) {
// Found
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load main template
loadTemplate('admin_config_rewrite', FALSE, $OUT);
sendEmail($content['sender'], '{--MEMBER_ORDER_DELETED--}', $message_user);
// Fetch right stats_id from pool
- $result_pool = SQL_QUERY_ESC("SELECT
+ $result_pool = sqlQueryEscaped("SELECT
`s`.`id`
FROM
`{?_MYSQL_PREFIX?}_user_stats` AS `s`
`s`.`pool_id`=%s
LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_pool) == 1) {
+ if (sqlNumRows($result_pool) == 1) {
// Fetch stats id
- list($stats_id) = SQL_FETCHROW($result_pool);
+ list($stats_id) = sqlFetchRow($result_pool);
// Get all user links
$links = countSumTotalData($stats_id, 'user_links', 'userid', 'stats_id', TRUE);
}
// Remove links from DB
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s",
array(bigintval($stats_id)), __FILE__, __LINE__);
- $count += SQL_AFFECTEDROWS();
+ $count += sqlAffectedRows();
// Load template for link
displayMessage('<a href="{%url=modules.php?module=admin&what=del_email&pid=' . bigintval(getRequestElement('id')) . '%}">{--ADMIN_REMOVE_STATS_ENTRY--}</a>');
} // END - if
// Free the result
- SQL_FREERESULT($result_pool);
+ sqlFreeResult($result_pool);
// Delete mail from queue
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- $count += SQL_AFFECTEDROWS();
+ $count += sqlAffectedRows();
// Output link for manually removing stats entry
outputHtml('{%message,ADMIN_DELETED_MAILS_COUNT=' . $count . '%}');
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} elseif (isGetRequestElementSet('pid')) {
// Remove stats entries
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__);
// Output message
displayMessage('{--ADMIN_USER_STATS_REMOVED--}');
} elseif (((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'bonus')) && (isExtensionActive('bonus'))) {
// Load data from bonus mail
- $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp`, `mails_sent` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `subject`, `url`, `timestamp`, `mails_sent` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
// Delete mail only once
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Reset sent mails for recipient(s)
reduceRecipientReceivedMails('bonus_id', getRequestElement('id'), $content['mails_sent']);
$count = '0';
// Delete bonus mail entirely from database
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- $count += SQL_AFFECTEDROWS();
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
+ $count += sqlAffectedRows();
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- $count += SQL_AFFECTEDROWS();
+ $count += sqlAffectedRows();
// Prepare data for the template
$content['timestamp'] = generateDateTime($content['timestamp'], '0');
}
} elseif ((isGetRequestElementSet('nid')) && (isExtensionInstalledAndNewer('bonus', '0.8.7'))) {
// Load data from bonus mail
- $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `subject`, `url`, `timestamp` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('nid'))), __FILE__, __LINE__);
// Delete mail only once
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Init counter for deleted mails
$count = '0';
// Delete bonus mail entirely from database
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('nid'))), __FILE__, __LINE__);
- $count += SQL_AFFECTEDROWS();
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
+ $count += sqlAffectedRows();
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
array(bigintval(getRequestElement('nid'))), __FILE__, __LINE__);
- $count += SQL_AFFECTEDROWS();
+ $count += sqlAffectedRows();
// Prepare data for the template
$content['timestamp'] = generateDateTime($content['timestamp'], '0');
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No mail orders fond
displayMessage('{--ADMIN_WRONG_CALL--}');
$count = '0';
foreach (postRequestElement('sel') as $id => $sel) {
// Get the userid
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`userid`,
`holiday_start`,
`holiday_end`
WHERE
`id`=%s
LIMIT 1", array(bigintval($id)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data and free memory
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Update user's account
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data`
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data`
SET
`holiday_active`='N',
`holiday_activated`=0
LIMIT 1", array(bigintval($content['userid'])), __FILE__, __LINE__);
// Remove holiday
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM
`{?_MYSQL_PREFIX?}_user_holidays`
WHERE
`id`=%s
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
// Display final message
$message = '{--ADMIN_HOLIDAY_SINGLE_404--}';
// Fetch data
- $result_load = SQL_QUERY_ESC("SELECT
+ $result_load = sqlQueryEscaped("SELECT
`holiday_start` AS `start`,
`holiday_end` AS `end`
FROM
`userid`=%s
LIMIT 1",
array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_load) == 1) {
+ if (sqlNumRows($result_load) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result_load);
+ $content = sqlFetchArray($result_load);
// Delete one holiday request (for task)
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM
`{?_MYSQL_PREFIX?}_user_holidays`
WHERE
`userid`=%s
} // END - if
// Free memory
- SQL_FREERESULT($result_load);
+ sqlFreeResult($result_load);
// Output message
displayMessage($message);
if (isGetRequestElementSet('id')) {
// Check for selected sponsor
- $result = SQL_QUERY_ESC("SELECT `id`, `email`, `gender`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `email`, `gender`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Remove sponsor
if (isFormSent()) {
// Load data and remember it in constants
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Prepare data for the template
$content['reason'] = postRequestElement('reason');
sendEmail($content['email'], '{--ADMIN_SPONSOR_DELETE_SUBJECT--}', $message);
// Remove account
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
// Remove orders
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_orders` WHERE `sponsor_id`='%s' LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_orders` WHERE `sponsor_id`='%s' LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
// Output message
redirectToUrl('modules.php?module=admin&what=list_sponsor&id='.bigintval(getRequestElement('id')));
} else {
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Transfer data to constants for the template
$content['userid'] = bigintval(getRequestElement('id'));
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Not called by what-list_sponsor.php
displayMessage('{--ADMIN_CALL_NOT_DIRECTLY--}');
// Delete entries...
foreach (postRequestElement('sel') as $id => $sel) {
- addSql(SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `trans_id`=%s LIMIT 1',
+ addSql(sqlQueryEscaped('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `trans_id`=%s LIMIT 1',
array(bigintval($id)), __FILE__, __LINE__, FALSE));
- addSql(SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `trans_id`=%s LIMIT 1',
+ addSql(sqlQueryEscaped('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `trans_id`=%s LIMIT 1',
array(bigintval($id)), __FILE__, __LINE__, FALSE));
} // END - foreach
} // END - if
// We only need outgoing transfers
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`userid` AS `from_userid`,
`to_userid`,
`trans_id`,
`trans_id` ASC', __FILE__, __LINE__);
$total = '0';
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Output rows
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare data for the row template
$content['time_trans'] = generateDateTime($content['time_trans'], 3);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Nothing for in and out
$OUT = '<tr>
loadTemplate('admin_edit_email', FALSE, $content);
} elseif ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'bonus')) {
// Make also this email editable
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`id`,
`subject`,
`text`,
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
// Fetch row
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
loadTemplate('admin_edit_bonus_email', FALSE, $content);
}
} elseif ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'bonus')) {
// Update pool
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_bonus`
SET
`subject`='%s',
bigintval(postRequestElement('id')),
), __FILE__, __LINE__);
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
$content = '{--ADMIN_EMAIL_CHANGES_SAVED--}';
} else {
$content = '<span class="bad">{--ADMIN_EMAIL_CHANGES_NOT_SAVED--}</span>';
displayMessage($content);
} else {
// Query the pool
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`sender`,
`subject`,
`timestamp` ASC', __FILE__, __LINE__);
// Entries found?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// There are mail orders available
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template and switch colors
$OUT .= loadTemplate('admin_edit_email_row', TRUE, $content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load email template
loadTemplate('admin_edit_email_select', FALSE, $OUT);
if ((isGetRequestElementSet('id')) && (isGetRequestElementSet('do'))) {
// Check for selected sponsor
- $result_main = SQL_QUERY_ESC("SELECT
+ $result_main = sqlQueryEscaped("SELECT
`id`, `company`, `position`, `gender`, `surname`, `family`,
`street_nr1`, `street_nr2`, `zip`, `city`, `country`,
`phone`, `fax`, `cell`, `email`, `url`, `tax_ident`,
`id`=%s
LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_main) == 1) {
+ if (sqlNumRows($result_main) == 1) {
// Load sponsor details
- $content = SQL_FETCHARRAY($result_main);
+ $content = sqlFetchArray($result_main);
// Warning because low points
$content['receive_warnings'] = addSelectionBox('yn', $content['receive_warnings'], 'receive_warning');
$points = bigintval(convertCommaToDot(postRequestElement('points')));
// Add points to account
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `points_amount`=`points_amount`+%s WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `points_amount`=`points_amount`+%s WHERE `id`=%s LIMIT 1",
array($points, bigintval(getRequestElement('id'))), __FILE__, __LINE__);
// Remember points /reason for the template
$points = bigintval(convertCommaToDot(postRequestElement('points')));
// Add points to account
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `points_used`=`points_used`+%s WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `points_used`=`points_used`+%s WHERE `id`=%s LIMIT 1",
array($points, bigintval(getRequestElement('id'))), __FILE__, __LINE__);
// Remember points /reason for the template
}
// Free result
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
} else {
// Not called by what-list_sponsor.php
displayMessage('{--ADMIN_CALL_NOT_DIRECTLY--}');
$result_main = FALSE;
if (isGetRequestElementSet('userid')) {
// Load user entry
- $result_main = SQL_QUERY_ESC("SELECT
+ $result_main = sqlQueryEscaped("SELECT
`userid`, `gender`, `surname`, `family`, `street_nr`, `zip`, `city`, `country`,
`email`,
`birth_day`, `birth_month`, `birth_year`,
), __FILE__, __LINE__);
} // END - if
-if ((!isGetRequestElementSet('userid')) || (SQL_NUMROWS($result_main) == 1)) {
+if ((!isGetRequestElementSet('userid')) || (sqlNumRows($result_main) == 1)) {
// User found
if (!isGetRequestElementSet('userid')) {
// Output selection form with all confirmed user accounts listed
if ($updateUser === TRUE) {
// We have to add the following things: birthday and max receive mails
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`gender`='%s',
displayMessage($content);
} else {
// Load entry
- $content = SQL_FETCHARRAY($result_main);
+ $content = sqlFetchArray($result_main);
// Load template
loadTemplate('admin_edit_user', FALSE, $content);
}
// Free the result
-SQL_FREERESULT($result_main);
+sqlFreeResult($result_main);
// [EOF]
?>
`timestamp` DESC";
// Check for maximum pages
-$result_maximum = SQL_QUERY($sql, __FILE__, __LINE__);
+$result_maximum = sqlQuery($sql, __FILE__, __LINE__);
// Set offset an current page to default values
if (!isGetRequestElementSet('page')) setGetRequestElement('page' , 1);
$sql .= ' LIMIT ' . (getRequestElement('offset') * getRequestElement('page') - getRequestElement('offset')) . ', ' . getRequestElement('offset');
// Run SQL query for normal mails
-$result = SQL_QUERY($sql, __FILE__, __LINE__);
+$result = sqlQuery($sql, __FILE__, __LINE__);
// Calculate pages
-$numPages = round(SQL_NUMROWS($result_maximum) / getMailsPage() + 0.5);
+$numPages = round(sqlNumRows($result_maximum) / getMailsPage() + 0.5);
// Free the result which we don't need
-SQL_FREERESULT($result_maximum);
+sqlFreeResult($result_maximum);
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Mail orders are in pool so we can display them
// Add navigation table rows
// List all entries
$OUT = '';
- while ($pool = SQL_FETCHARRAY($result)) {
+ while ($pool = sqlFetchArray($result)) {
// Check sent mails and clicks
- $result_mails = SQL_QUERY_ESC("SELECT `max_rec`, `clicks` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
+ $result_mails = sqlQueryEscaped("SELECT `max_rec`, `clicks` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
array(bigintval($pool['id'])), __FILE__, __LINE__);
// Load entries
- $pool = merge_array($pool, SQL_FETCHARRAY($result_mails));
+ $pool = merge_array($pool, sqlFetchArray($result_mails));
// Merge result
- SQL_FREERESULT($result_mails);
+ sqlFreeResult($result_mails);
// Unconfirmed mails
$pool['unconfirmed'] = generateUnconfirmedAdminLink($pool['id'], ($pool['max_rec'] - $pool['clicks']), 'normal');
}
// Free memory
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
if ((isExtensionActive('bonus')) && (empty($WHO))) {
// Check for maximum pages
- $result_bonus = SQL_QUERY("SELECT
+ $result_bonus = sqlQuery("SELECT
`id`,
`subject`,
`text`,
} // END - if
// Check for maximum pages
-$result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
+$result_normal = sqlQuery($sql, __FILE__, __LINE__);
// Set offset an current page to default values
if (!isGetRequestElementSet('page')) setGetRequestElement('page', 1);
} // END - if
// Run SQL query for normal mails
-$result_list = SQL_QUERY($sql, __FILE__, __LINE__);
+$result_list = sqlQuery($sql, __FILE__, __LINE__);
if ((!empty($SQL2)) && (empty($WHO))) {
- $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
+ $result_bonus = sqlQuery($SQL2, __FILE__, __LINE__);
} // END - if
// Calculate pages
$numPages = '0';
if (isConfigEntrySet('mails_page')) {
- $numPages = round(SQL_NUMROWS($result_normal) / getMailsPage() + 0.3);
+ $numPages = round(sqlNumRows($result_normal) / getMailsPage() + 0.3);
} // END - if
// Free result
-SQL_FREERESULT($result_normal);
+sqlFreeResult($result_normal);
$MAIL = FALSE;
-if (!SQL_HASZERONUMS($result_list)) {
+if (!ifSqlHasZeroNums($result_list)) {
// Init rows
$OUT = '';
// Walk through all entries
- while ($content = SQL_FETCHARRAY($result_list)) {
+ while ($content = sqlFetchArray($result_list)) {
// Unconfirmed mails and sent mails
- $result_uncon = SQL_QUERY_ESC("SELECT (`max_rec` - `clicks`) AS `unconfirmed` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
+ $result_uncon = sqlQueryEscaped("SELECT (`max_rec` - `clicks`) AS `unconfirmed` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
array(bigintval($content['id'])), __FILE__, __LINE__);
// Load and merge data
- $content = merge_array($content, SQL_FETCHARRAY($result_uncon));
+ $content = merge_array($content, sqlFetchArray($result_uncon));
// Free result
- SQL_FREERESULT($result_uncon);
+ sqlFreeResult($result_uncon);
// Unconfirmed mails
$content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], ($content['unconfirmed']), 'normal');
} // END - while
// Free memory
- SQL_FREERESULT($result_list);
+ sqlFreeResult($result_list);
// Add navigation (with change box and colspan=3)
$content['nav'] = addEmailNavigation($numPages, getMailsPage(), FALSE, 3, TRUE);
$MAIL = TRUE;
if ((isExtensionActive('bonus')) && (empty($WHO))) {
// Only check if bonus extension is active
- if (!SQL_HASZERONUMS($result_bonus)) outputHtml('<br /><br />');
+ if (!ifSqlHasZeroNums($result_bonus)) outputHtml('<br /><br />');
} // END - if
} // END - if
if ((isExtensionActive('bonus')) && (empty($WHO))) {
// Load bonus mails only when extension is active
- if (!SQL_HASZERONUMS($result_bonus)) {
+ if (!ifSqlHasZeroNums($result_bonus)) {
// Calculate pages
- $numPages = round(SQL_NUMROWS($result_bonus) / getMailsPage() + 0.5);
+ $numPages = round(sqlNumRows($result_bonus) / getMailsPage() + 0.5);
// List emails
$OUT = '';
- while ($content = SQL_FETCHARRAY($result_bonus)) {
+ while ($content = sqlFetchArray($result_bonus)) {
// Add link to list_unconfirmed what-file
$content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed'], 'bonus');
} // END - if
// Update database
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='%s' WHERE `id`=%s AND `ext_active`='%s' LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='%s' WHERE `id`=%s AND `ext_active`='%s' LIMIT 1",
array(
$active,
bigintval($ext_id),
// Update extension's record
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
// Update also CSS column when extensions ext-sql_patches is newer or exact v0.0.6
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_has_css`='%s',`ext_active`='%s' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_has_css`='%s',`ext_active`='%s' WHERE `id`=%s LIMIT 1",
array(postRequestElement('css', $ext_id), $active, $ext_id), __FILE__, __LINE__);
} else {
// When extension is older than v0.0.6 there is no column for the CSS information
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='%s' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='%s' WHERE `id`=%s LIMIT 1",
array($active, $ext_id), __FILE__, __LINE__);
}
// Load required data
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
- $result = SQL_QUERY_ESC("SELECT `ext_has_css`, `ext_active` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `ext_has_css`, `ext_active` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1",
array(bigintval($ext_id)), __FILE__, __LINE__);
- list($css, $active) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ list($css, $active) = sqlFetchRow($result);
+ sqlFreeResult($result);
} else {
- $result = SQL_QUERY_ESC("SELECT `ext_active` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `ext_active` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1",
array(bigintval($ext_id)), __FILE__, __LINE__);
- list($active) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ list($active) = sqlFetchRow($result);
+ sqlFreeResult($result);
$css = 'X';
}
// Shall we display active/inactive extensions?
$where = '';
if (isGetRequestElementSet('active')) {
- $where = sprintf("WHERE `ext_active`='%s'", SQL_ESCAPE(getRequestElement('active')));
+ $where = sprintf("WHERE `ext_active`='%s'", sqlEscapeString(getRequestElement('active')));
} // END - if
// Case selection
case 'overview': // List all registered extensions
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
// Load extension data with CSS informations
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id` AS `ext_id`,
`ext_name`,
`ext_active`,
`ext_name` ASC', __FILE__, __LINE__);
} else {
// Load extension data without CSS informations
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id` AS `ext_id`,
`ext_name`,
`ext_active`,
}
// Are there some entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Extensions are registered
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare CSS selection output
$cssSelection = '---';
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
loadTemplate('admin_list_extensions', FALSE, $OUT);
// Is the id number valid and the task was found?
if ((isValidId($taskId)) && ($numTasks > 0)) {
// id is valid so begin with registration, we first want to it's real name from task management (subject column)
- $result = SQL_QUERY_ESC("SELECT `subject` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `subject` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1",
array(bigintval($taskId)), __FILE__, __LINE__);
- list($subject) = SQL_FETCHROW($result);
+ list($subject) = sqlFetchRow($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Disable cache update by default
$cache_update = '0';
$menus = array(); $titles = array(); $below = array();
// Get all available main menus
- $result_menu = SQL_QUERY("SELECT
+ $result_menu = sqlQuery("SELECT
`action`, `title`, `sort`
FROM
`{?_MYSQL_PREFIX?}_guest_menu`
(`what`='' OR `what` IS NULL)
ORDER BY
`sort` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_menu)) {
+ if (!ifSqlHasZeroNums($result_menu)) {
// Read menu structure
// @TODO Cant this be rewritten?
- while ($content = SQL_FETCHARRAY($result_menu)) {
+ while ($content = sqlFetchArray($result_menu)) {
// Menu actions
array_push($menus, $content['action']);
// Load sub menus :)
foreach ($menus as $key_main => $value_main) {
// Query for sub menus
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`what`, `title`, `sort`
FROM
`{?_MYSQL_PREFIX?}_guest_menu`
`what` IS NOT NULL
ORDER BY `sort` ASC",
array($value_main), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Initialize arrays
$menus[$value_main] = array();
$titles[$value_main] = array();
$below[$value_main] = array();
// Read menu structure
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Menu actions
array_push($menus[$value_main], $content['what']);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
} // END - if
// Free memory
- SQL_FREERESULT($result_menu);
+ sqlFreeResult($result_menu);
$OUT = '<select class="form_select" name="sort" size="1">
<option value="0">{--ADMIN_IS_FIRST_MENU--}</option>';
} elseif (!isDemoModeActive()) {
// Insert new menu entry
if (isPostRequestElementSet('menu')) {
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_guest_menu` (`action`, `what`, `title`, `sort`, `visible`, `locked`) VALUES ('%s','%s','%s','%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_guest_menu` (`action`, `what`, `title`, `sort`, `visible`, `locked`) VALUES ('%s','%s','%s','%s','%s','%s')",
array(
postRequestElement('menu'),
postRequestElement('name'),
postRequestElement('active'),
), __FILE__, __LINE__);
} else {
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_guest_menu` (`action`, `title`, `sort`, `visible`, `locked`) VALUES ('%s','%s','%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_guest_menu` (`action`, `title`, `sort`, `visible`, `locked`) VALUES ('%s','%s','%s','%s','%s')",
array(
postRequestElement('name'),
postRequestElement('title'),
foreach (postRequestElement('sel') as $sel => $confirm) {
if ($confirm == 1) {
$count++;
- $result = SQL_QUERY_ESC("SELECT `title`, `action`, `what` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title`, `action`, `what` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Entry found so we load the stuff...
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Prepapre content
$content = array(
}
// Free result and switch color
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - foreach
foreach (postRequestElement('sel') as $sel => $confirm) {
if ($confirm == 1) {
$count++;
- $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Entry found so we load the stuff...
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
$content = array(
'count' => $count,
'menu' => $content['title'],
);
$OUT .= loadTemplate('admin_menu_404_row', TRUE, $content);
}
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - foreach
foreach (postRequestElement('sel') as $sel => $confirm) {
if ($confirm == 1) {
$count++;
- $result = SQL_QUERY_ESC("SELECT `title`, `visible`, `locked` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title`, `visible`, `locked` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Entry found so we load the stuff...
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
$content = array(
'count' => $count,
'menu' => $content['title'],
$OUT .= loadTemplate('admin_menu_404_row', TRUE, $content);
}
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - foreach
// By default list menus
if (empty($subMenu)) {
// List only main menus
- $result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
+ $result = sqlQuery("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
} else {
// List sub menus
- $result = SQL_QUERY_ESC("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
+ $result = sqlQueryEscaped("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
array($subMenu), __FILE__, __LINE__);
}
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Init variables
$count = '0';
$OUT = '';
// Process all menu entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Set sub value
$content['sub'] = $subMenu;
if (($content['sort'] == '0') || (($content['sort'] == 1) && (!empty($subMenu)))) {
// Is highest position
$NAVI = '<a href="{%url=modules.php?module=admin&what=guestedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']+1) . '&fid=' . $content['sort'] . '%}">{--LOWER--}</a>';
- } elseif (SQL_NUMROWS($result) == $count) {
+ } elseif (sqlNumRows($result) == $count) {
// Is lowest position
$NAVI = '<a href="{%url=modules.php?module=admin&what=guestedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']-1) . '&fid=' . $content['sort'] . '%}">{--HIGHER--}</a>';
} elseif ($content['sort'] > 0) {
$content['sub'] = $subMenu;
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
loadTemplate('admin_edit_guest_menu', FALSE, $content);
$OUT = '';
foreach (postRequestElement('sel') as $id => $selected) {
// Load data for the id
- $result = SQL_QUERY_ESC("SELECT `id`, `admin_id`, `action_menu`, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `admin_id`, `action_menu`, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
// Load all data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Prepare data for the row template
$content = array(
$id = bigintval($id);
// Update entries
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_admins_acls`
SET
`admin_id`=%s,
$OUT = '';
foreach (postRequestElement('sel') as $id => $selected) {
// Load data for the id
- $result = SQL_QUERY_ESC("SELECT `id`, `admin_id`, `action_menu`, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `admin_id`, `action_menu`, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
- SQL_FREERESULT($result);
+ $content = sqlFetchArray($result);
+ sqlFreeResult($result);
// Get admin mode
$content['access_mode'] = '{--ADMIN_ADMINS_ACCESS_MODE_' . strtoupper($content['access_mode']) . '--}';
// Remove entries
// @TODO Rewrite this to filter 'run_sqls'
foreach (postRequestElement('sel') as $id => $selected) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1",
array(bigintval($id)),__FILE__, __LINE__);
} // END - foreach
// Check if one has been selected
if ((((isPostRequestElementSet('action_menu')) && (postRequestElement('action_menu') != '')) || ((isPostRequestElementSet('what_menu')) && (postRequestElement('what_menu') != ''))) && ($BOTH === FALSE)) {
// Main or sub menu selected
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `admin_id`=%s AND `action_menu`='%s' AND `what_menu`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `admin_id`=%s AND `action_menu`='%s' AND `what_menu`='%s' LIMIT 1",
array(
bigintval(postRequestElement('admin_id')),
postRequestElement('action_menu'),
postRequestElement('what_menu')
), __FILE__, __LINE__);
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Finally add the new ACL
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_acls` (
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_admins_acls` (
`admin_id`,
`action_menu`,
`what_menu`,
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No menu selected makes also no sence...
$content = '{--ADMIN_ADMINS_SELECT_ACTION_WHAT--}';
displayMessage($content);
} else {
// List all ACLs
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`admin_id`,
`action_menu`,
`id` ASC', __FILE__, __LINE__);
// Entries found?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List ACLs
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Generate mode string
$content['access_mode'] = '{--ADMIN_ADMINS_ACCESS_MODE_' . strtoupper($content['access_mode']) . '--}';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load main template
loadTemplate('admin_list_admins_acls', FALSE, $OUT);
} // END - if
// Check for all accounts
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`d`.`userid`,
`d`.`gender`,
`d`.`surname`,
ORDER BY
`d`.`userid` ASC", __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Ok, we have found some inactive accounts
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare data for the row template
$content = array(
'userid' => $content['userid'],
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
$content['rows'] = $OUT;
// Load main template
if ($show === FALSE) return;
// Load all banking packages from DB
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`id`,
`title`,
`description`,
`id` ASC', __FILE__, __LINE__);
// Is there at lease one package?
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// List all packages
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template
$OUT .= loadTemplate('admin_list_bank_package_row', TRUE, $content);
} // END - while
}
// Free the result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
} // END - if
// Check if at least one is in the active rallye
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`userid`,
`email`,
`beg_points`,
`last_online` DESC,
`userid` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List users
$OUT = ''; $count = 1; $total = '0';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Init variables
$WIN1 = '';
$WIN2 = '';
} // END - if
// Check if at least one is in the active rallye
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`userid`,
`email`,
" . $pointsColumns . " AS `points`,
`last_online` DESC,
`userid` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List users
$OUT = '';
$count = 1;
$total = '0';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add total points
$total += $content['points'];
if (isFormSent('add')) {
// Add a new category
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `cat`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `cat`='%s' LIMIT 1",
array(postRequestElement('catname')), __FILE__, __LINE__);
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Category does not exists, we simply add it...
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_cats` (`cat`, `visible`, `sort`) VALUES ('%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_cats` (`cat`, `visible`, `sort`) VALUES ('%s','%s','%s')",
array(
postRequestElement('catname'),
postRequestElement('visible'),
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Display message
displayMessage($content);
if (!empty($cat)) {
switch (getRequestElement('do')) {
case 'edit': // Change categories
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_cats` SET `cat`='%s',`visible`='%s',`sort`=%s WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_cats` SET `cat`='%s',`visible`='%s',`sort`=%s WHERE `id`=%s LIMIT 1",
array(
$cat,
postRequestElement('visible', $id),
break;
case 'delete': // Delete categories
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1",
array($id), __FILE__, __LINE__);
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `cat_id`=%s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `cat_id`=%s",
array($id), __FILE__, __LINE__);
$TEXT = '{--ADMIN_CATEGORIES_DELETED--}';
break;
$OUT = '';
foreach (postRequestElement('sel') as $id => $value) {
// Load data from the category
- $result = SQL_QUERY_ESC("SELECT `id`, `visible`, `sort` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `visible`, `sort` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Prepare data for the row template
$content['visible_selection'] = addSelectionBox('yn', $content['visible'], 'visible', $content['id']);
$CATS = '';
// Load all categories
- $result = SQL_QUERY("SELECT `id`, `cat`, `visible`, `sort` FROM `{?_MYSQL_PREFIX?}_cats` ORDER BY `sort` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ $result = sqlQuery("SELECT `id`, `cat`, `visible`, `sort` FROM `{?_MYSQL_PREFIX?}_cats` ORDER BY `sort` ASC", __FILE__, __LINE__);
+ if (!ifSqlHasZeroNums($result)) {
// Init variables
$OUT = '';
// List already existing categories for editing
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Put cat descriptions into variable for the selection box
if (strlen($content['cat']) > 40) $content['cat'] = substr($content['cat'], 0, 37) . '...';
$CATS .= '<option value="' . $content['sort'] . '">' . $content['cat'] . '</option>';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load main template
loadTemplate('admin_list_cats', FALSE, $OUT);
// Add new code?
if ((isFormSent('add')) && (isPostRequestElementSet('code')) && (isPostRequestElementSet('descr'))) {
// Check if country code does already exist
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `code`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `code`='%s' LIMIT 1",
array(strtoupper(postRequestElement('code'))), __FILE__, __LINE__);
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Save entry
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_countries` (`code`, `descr`, `is_active`) VALUES ('%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_countries` (`code`, `descr`, `is_active`) VALUES ('%s','%s','%s')",
array(
strtoupper(substr(postRequestElement('code'), 0, 2)),
postRequestElement('descr'),
$message = '{%message,ADMIN_COUNTRY_ADDED=' . strtoupper(postRequestElement('descr')) . '%}';
} else {
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Does already exist
$message = '{%message,ADMIN_COUNTRY_ALREADY=' . strtoupper(postRequestElement('code')) . '%}';
$OUT = '';
foreach (postRequestElement('id') as $id => $isActive) {
// Load data from DB
- $result = SQL_QUERY_ESC("SELECT `id`, `code`, `descr` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `code`, `descr` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Add $isActive
$content['is_active'] = $isActive;
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
// Prepare content for template
} // END - if
// Load currenty setup country codes to list
- $result = SQL_QUERY('SELECT `id`, `code`, `descr`, `is_active` FROM `{?_MYSQL_PREFIX?}_countries` ORDER BY `code` ASC',
+ $result = sqlQuery('SELECT `id`, `code`, `descr`, `is_active` FROM `{?_MYSQL_PREFIX?}_countries` ORDER BY `code` ASC',
__FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List all countries
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template and switch colors
$OUT .= loadTemplate('admin_list_country_row', TRUE, $content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No code setup so far (not possible by this software! 'DE' for 'Deutschland' is default
$OUT = loadTemplate('admin_list_country_no_row', TRUE);
if (isGetRequestElementSet('coupon_id')) {
// List userids for given coupon
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`u`.`coupon_id`,
`u`.`userid`,
UNIX_TIMESTAMP(`u`.`cashed_on`) AS `cashed_on`,
), __FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Init variable
$OUT = '';
// Load all rows
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Translate all timestamps
$content['cashed_on'] = generateDateTime($content['cashed_on'] , '2');
$content['coupon_created'] = generateDateTime($content['coupon_created'], '2');
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Check if the user has cashed coupons
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`d`.`id` AS `coupon_id`,
UNIX_TIMESTAMP(`d`.`coupon_created`) AS `coupon_created`,
UNIX_TIMESTAMP(`d`.`coupon_expired`) AS `coupon_expired`,
`d`.`id` ASC', __FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Init variable
$OUT = '';
// Load all rows
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Translate all timestamps
$content['coupon_created'] = generateDateTime($content['coupon_created'], '2');
$content['coupon_expired'] = generateDateTime($content['coupon_expired'], '2');
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// [EOF]
if (isPostRequestElementSet('add_max')) {
// Save all settings
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE value='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE value='%s' LIMIT 1",
array(bigintval(postRequestElement('max'))), __FILE__, __LINE__);
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Add this value (including comment)
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_max_receive` (`value`, `comment`) VALUES ('%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_max_receive` (`value`, `comment`) VALUES ('%s','%s')",
array(bigintval(postRequestElement('max')), postRequestElement('comment')),__FILE__, __LINE__);
$content = '{--ADMIN_MAX_VALUE_SAVED--}';
} else {
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Display message
displayMessage($content);
switch (getRequestElement('do')) {
case 'edit': // Change entries
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_max_receive` SET value='%s', comment='%s' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_max_receive` SET value='%s', comment='%s' WHERE `id`=%s LIMIT 1",
array(
bigintval(postRequestElement('val', $id)),
postRequestElement('comm', $id),
break;
case 'delete':
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
array($id), __FILE__, __LINE__);
$TEXT = '{--ADMIN_MAX_RECEIVE_DELETED--}';
break;
$OUT = '';
foreach (postRequestElement('sel') as $id => $value) {
// Load data
- $result = SQL_QUERY_ESC("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
- SQL_FREERESULT($result);
+ $content = sqlFetchArray($result);
+ sqlFreeResult($result);
// Load row template and switch color
$OUT .= loadTemplate('admin_delete_email_max_rec_row', TRUE, $content);
$OUT = '';
foreach (postRequestElement('sel') as $id => $value) {
// Load data
- $result = SQL_QUERY_ESC("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
- SQL_FREERESULT($result);
+ $content = sqlFetchArray($result);
+ sqlFreeResult($result);
// Load row template and switch color
$OUT .= loadTemplate('admin_edit_email_max_rec_row', TRUE, $content);
// Load main template
loadTemplate('admin_edit_email_max_rec', FALSE, $content);
} else {
- $result = SQL_QUERY("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC",
+ $result = sqlQuery("SELECT `id`, `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC",
__FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List already existing entries for editing
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template and switch color
$OUT .= loadTemplate('admin_list_email_max_rec_row', TRUE, $content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
$content['rows'] = $OUT;
// Load main template
addYouAreHereLink('admin', __FILE__);
// Start listing holiday requests
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`h`.`id`,
`h`.`userid`,
`h`.`holiday_start`,
ORDER BY
`h`.`userid` ASC", __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// List all holiday requests
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare data for the row template
$content = array(
'id' => $content['id'],
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load main template
loadTemplate('admin_list_holiday', FALSE, $OUT);
} // END - if
// Load user links data
- $result = SQL_QUERY_ESC("SELECT `userid`, `stats_id`, `%s`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `id` ASC",
+ $result = sqlQueryEscaped("SELECT `userid`, `stats_id`, `%s`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `id` ASC",
array(
$linkDataName,
bigintval(getRequestElement('userid'))
), __FILE__, __LINE__);
// Are there some entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Some unconfirmed mails left
if (getRequestElement('delete') == 'all') {
// Delete all unconfirmed mails by this user
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s LIMIT %s",
- array(bigintval(getRequestElement('userid')), SQL_NUMROWS($result)), __FILE__, __LINE__);
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s LIMIT %s",
+ array(bigintval(getRequestElement('userid')), sqlNumRows($result)), __FILE__, __LINE__);
// Prepare mail and send it away
- $message = loadEmailTemplate('member_delete_links', SQL_NUMROWS($result), bigintval(getRequestElement('userid')));
+ $message = loadEmailTemplate('member_delete_links', sqlNumRows($result), bigintval(getRequestElement('userid')));
sendEmail(getUserData('userid'), '{--ADMIN_DELETE_LINK_SUBJECT--}', $message);
// Display message
$OUT = '';
// List all unconfirmed mails
- while ($linkData = SQL_FETCHARRAY($result)) {
+ while ($linkData = sqlFetchArray($result)) {
// Initializes all other elements
$linkData['mail_id'] = '';
$linkData['problem'] = '{--ADMIN_GENERAL_MAIL_PROBLEM--}';
// @TODO Rewrite this to includes/filter
switch ($linkData['link_type']) {
case 'NORMAL':
- $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp_ordered` AS `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
+ $result_data = sqlQueryEscaped("SELECT `subject`, `timestamp_ordered` AS `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
array(bigintval($linkData['stats_id'])), __FILE__, __LINE__);
$linkData['link_type'] = 'mailid';
$linkData['mail_id'] = $linkData['stats_id'];
break;
case 'BONUS':
- $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ $result_data = sqlQueryEscaped("SELECT `subject`, `timestamp`, `cat_id` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
array(bigintval($linkData['bonus_id'])), __FILE__, __LINE__);
$linkData['link_type'] = 'bonusid';
$linkData['mail_id'] = $linkData['bonus_id'];
} // END - switch
// Is there an entry?
- if (SQL_NUMROWS($result_data) == 1) {
+ if (sqlNumRows($result_data) == 1) {
// Mail was found
- $mailData = merge_array($linkData, SQL_FETCHARRAY($result_data));
+ $mailData = merge_array($linkData, sqlFetchArray($result_data));
// Fix empty subject
if (empty($mailData['subject'])) {
}
// Free result
- SQL_FREERESULT($result_data);
+ sqlFreeResult($result_data);
} // END - while
// Remember list in constant for the template
$content = array(
'email' => '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . getUserData('email') . '</a>',
'rows' => $OUT,
- 'nums' => SQL_NUMROWS($result),
+ 'nums' => sqlNumRows($result),
'userid' => bigintval(getRequestElement('userid')),
);
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load final template
loadTemplate('admin_list_links', FALSE, $content);
foreach (postRequestElement('sel') as $id => $sel) {
// Load module data
// @TODO This can be moved into mysql-function.php, see checkModulePermissions() function
- $result = SQL_QUERY_ESC("SELECT `id`, `module`, `title`, `locked`, `hidden`, `admin_only`, `mem_only` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `module`, `title`, `locked`, `hidden`, `admin_only`, `mem_only` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Prepare array for the template
$content['locked'] = addSelectionBox('yn', $content['locked'] , 'locked', $id);
$id = bigintval($id);
// Update module
- addSql(SQL_QUERY_ESC("UPDATE
+ addSql(sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_mod_reg`
SET
`title`='%s',
if (!ifPostContainsSelections()) {
// Load module data (We do not need to check if there's at least one...)
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`, `module`, `locked`, `hidden`, `admin_only`, `title`, `mem_only`
FROM
`{?_MYSQL_PREFIX?}_mod_reg`
`module` ASC', __FILE__, __LINE__);
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Reset title to --- if it is NULL
if (($content['module'] == 'index') || ($content['module'] == 'login')) {
// Add link to detail statistics
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load main template
loadTemplate('admin_list_mods', FALSE, $OUT);
} // END - if
// Load all advert codes for given network
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`p`.`network_array_id`,
`t`.`network_type_id`,
`t`.`network_type_handler`,
), __FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List all entries
$OUT = '';
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Add it to network if the type matches selected
if ($row['network_type_id'] == postRequestElement('network_type_id')) {
// Matches, then add it for disabling this entry
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Add form for adding new array_translation pair
loadTemplate('admin_add_network_array_translation', FALSE, $networkData);
} // END - if
// Query for networks
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`network_id`,
`network_short_name`,
`network_title`,
`network_short_name` ASC', __FILE__, __LINE__);
// Are there entries?
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// List all
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template
$OUT .= loadTemplate('admin_list_network_data_row', TRUE, $content);
} // END - while
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Add form for adding new entry
loadTemplate('admin_add_network');
} // END - if
// Load all advert types for given network
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`p`.`network_request_param_id`,
`t`.`network_type_id`,
`t`.`network_type_handler`,
array(bigintval(getRequestElement('network_id'))), __FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List all entries
$OUT = '';
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Add it to network if the type matches selected
if ($row['network_type_id'] == postRequestElement('network_type_id')) {
// Matches, then add it for disabling this entry
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Add form for adding new params
loadTemplate('admin_add_network_request_param', FALSE, $networkData);
$GLOBALS['network_types_disabled'] = array();
// Load all advert types for given network
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`network_type_id`,
`network_type_handler`,
`network_type_api_url`,
array(bigintval(getRequestElement('network_id'))), __FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List all entries
$OUT = '';
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Set disabled entry
$GLOBALS['network_types_disabled'][$row['network_type_handler']] = TRUE;
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Add content for reload time unit
$networkData['network_type_reload_time_unit'] = generateTimeUnitSelectionBox('h', 'network_type_reload_time_unit', array('W', 'D', 'h', 'm', 's'));
`timestamp` DESC";
// Check for maximum pages
- $result_max = SQL_QUERY($SQL2, __FILE__, __LINE__);
+ $result_max = sqlQuery($SQL2, __FILE__, __LINE__);
} else {
// Bonus extension required!
displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=bonus%}');
// Add limitation
if (!empty($SQL2)) $SQL2 .= $add;
-if ((isExtensionActive('bonus')) && (!SQL_HASZERONUMS($result_max)) && (!empty($SQL2))) {
+if ((isExtensionActive('bonus')) && (!ifSqlHasZeroNums($result_max)) && (!empty($SQL2))) {
// Run SQL query for notification mails
- $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
+ $result_bonus = sqlQuery($SQL2, __FILE__, __LINE__);
// Load bonus mails only when extension is active
- if (!SQL_HASZERONUMS($result_bonus)) {
+ if (!ifSqlHasZeroNums($result_bonus)) {
// Calculate pages
- $numPages = round(SQL_NUMROWS($result_bonus) / getMailsPage() + 0.5);
+ $numPages = round(sqlNumRows($result_bonus) / getMailsPage() + 0.5);
// List emails
$OUT = ''; $content = array();
- while ($content = SQL_FETCHARRAY($result_bonus)) {
+ while ($content = sqlFetchArray($result_bonus)) {
// Add "unconfirmed-link"
$content['unconfirmed_content'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed'], 'bonus');
// Load main template
loadTemplate('admin_list_notify_emails', FALSE, $content);
}
-} elseif ((SQL_NUMROWS($result_max) === 0) && (is_resource($result_max))) {
+} elseif ((sqlNumRows($result_max) === 0) && (is_resource($result_max))) {
// No notifications found
displayMessage('{--ADMIN_NO_NOTIFICATIONS--}');
}
if (isGetRequestElementSet('pid')) {
// First let's get the member's id
- $result = SQL_QUERY_ESC("SELECT `userid`, `target_account`, `payout_total`, `payout_timestamp`, `password` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `userid`, `target_account`, `payout_total`, `payout_timestamp`, `password` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1",
array(getRequestElement('pid')), __FILE__, __LINE__);
- list($userid, $tuserid, $points, $tstamp, $tpass) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ list($userid, $tuserid, $points, $tstamp, $tpass) = sqlFetchRow($result);
+ sqlFreeResult($result);
// Obtain some data
if (!isGetRequestElementSet('task') && (!empty($userid)) && (isValidId($userid))) {
// Get task id from database
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `userid`=%s AND `task_type`='PAYOUT_REQUEST' AND `task_created`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `userid`=%s AND `task_type`='PAYOUT_REQUEST' AND `task_created`=%s LIMIT 1",
array(bigintval($userid), bigintval($tstamp)), __FILE__, __LINE__);
- list($taskId) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ list($taskId) = sqlFetchRow($result);
+ sqlFreeResult($result);
if (empty($taskId)) $taskId = '0';
} elseif (!isValidId($userid)) {
// Cannot obtain member id!
// Ok, now we can output the form or execute accepting
if (isFormSent()) {
// Obtain payout type and other data
- $result = SQL_QUERY_ESC("SELECT `payout_id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `payout_id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__);
// Load ptype (id)
- list($ptype) = SQL_FETCHROW($result);
+ list($ptype) = sqlFetchRow($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
if (!empty($ptype)) {
// Obtain data from payout type
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`from_account`,
`from_pass`,
`engine_url`,
array(bigintval($ptype)), __FILE__, __LINE__);
// Load data
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
if (!empty($data['engine_url'])) {
// Ok, run URL...
} // END - if
// Clear payout request
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_payouts` SET `status`='ACCEPTED' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_payouts` SET `status`='ACCEPTED' WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__);
// Send out mail
} // END - if
// Clear payout request
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_payouts` SET `status`='REJECTED' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_payouts` SET `status`='REJECTED' WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__);
// Send out mail
} else {
if (getRequestElement('do') == 'delete') {
// Delete all requests
- $result = SQL_QUERY("TRUNCATE `{?_MYSQL_PREFIX?}_user_payouts`", __FILE__, __LINE__);
+ $result = sqlQuery("TRUNCATE `{?_MYSQL_PREFIX?}_user_payouts`", __FILE__, __LINE__);
} // END - if
// Search for payouts
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`p`.`id`,
`p`.`userid`,
`p`.`payout_total`,
ORDER BY
`p`.`payout_timestamp` DESC', __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List found payouts
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
if ($content['status'] == 'NEW') {
// Generate links for direct accepting and rejecting
$content['status'] = '<a href="{%url=modules.php?module=admin&what=list_payouts&do=accept&pid=' . $content['id'] . '%}">{--ADMIN_PAYOUT_ACCEPT_PAYOUT--}</a>|<a href="{%url=modules.php?module=admin&what=list_payouts&do=reject&pid=' . $content['id'] . '%}">{--ADMIN_PAYOUT_REJECT_PAYOUT--}</a>';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load final template
loadTemplate('admin_list_payouts', FALSE, $OUT);
if (isFormSent('add')) {
if ((isPostRequestElementSet('level')) && ((isPostRequestElementSet('points')) || (isPostRequestElementSet('info')))) {
// Submitted data is valid, but maybe we already have this price level?
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `rallye_id`=%s AND `price_level`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `rallye_id`=%s AND `price_level`='%s' LIMIT 1",
array(bigintval(getRequestElement('rallye_id')), bigintval(postRequestElement('level'))), __FILE__, __LINE__);
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Ok, new price level entered!
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_rallye_prices`
(`rallye_id`, `price_level`, `points`, `info`)
VALUES
displayMessage('{--ADMIN_RALLYE_PRICE_LEVEL_SAVED--}');
} else {
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Price level found
displayMessage('{--ADMIN_RALLYE_PRICE_ALREADY_FOUND--}');
if (ifPostContainsSelections()) {
// Delete selected entries
foreach (postRequestElement('sel') as $id => $sel) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
} // END - foreach
$id = bigintval($id);
// Update entry
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_rallye_prices`
SET
`rallye_id`=%s,
$OUT = '';
foreach (postRequestElement('sel') as $id => $sel) {
// Load data to selected rallye
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`rallye_id`,
`price_level`,
array(bigintval($id)), __FILE__, __LINE__);
// Fetch data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Add more content
$content['rallye_content'] = generateOptions('rallye_data', 'id', 'title', $content['rallye_id']);
$OUT = '';
foreach (postRequestElement('sel') as $id => $sel) {
// Load data to selected rallye
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`rallye_id`,
`price_level`,
array(bigintval($id)), __FILE__, __LINE__);
// Fetch data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load row template and switch color
$OUT .= loadTemplate('admin_delete_rallye_prices_row', TRUE, $content);
}
} else {
// A rallye was selected, so check if there are already prices assigned...
- $result = SQL_QUERY_ESC("SELECT `id`, `price_level`, `points`, `info` FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `rallye_id`=%s ORDER BY `price_level` ASC",
+ $result = sqlQueryEscaped("SELECT `id`, `price_level`, `points`, `info` FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `rallye_id`=%s ORDER BY `price_level` ASC",
array(bigintval(getRequestElement('rallye_id'))), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all prices for the selected rallye
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template and switch color
$OUT .= loadTemplate('admin_list_rallye_prices_simple_row', TRUE, $content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// @TODO Rewrite these two constants
$content['rows'] = $OUT;
} // END - if
} else {
// No rallye selected so display all available without prices
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`d`.`id` AS `rallye_id`,
`d`.`admin_id`,
`d`.`start_time`,
`d`.`admin_id`=`a`.`id`
ORDER BY
`d`.`start_time` DESC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List found rallyes
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare data for the row template
$content['start_time'] = generateDateTime($content['start_time'], '3');
$content['end_time'] = generateDateTime($content['end_time'] , '3');
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load main template
loadTemplate('admin_list_rallye_prices', FALSE, $OUT);
// Activate / deactivate
switch (getRequestElement('activate')) {
case '1': // Activate
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `is_active`='Y' WHERE `id`=%s AND `is_active`='N' LIMIT 1",
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `is_active`='Y' WHERE `id`=%s AND `is_active`='N' LIMIT 1",
array(bigintval(getRequestElement('rallye_id'))), __FILE__, __LINE__, FALSE)
);
break;
case '0': // Deactivate
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `is_active`='N' WHERE `id`=%s AND `is_active`='Y' LIMIT 1",
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `is_active`='N' WHERE `id`=%s AND `is_active`='Y' LIMIT 1",
array(bigintval(getRequestElement('rallye_id'))), __FILE__, __LINE__, FALSE)
);
break;
// Automatic notification
switch (getRequestElement('notify')) {
case '1': // Activate
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `send_notify`='Y' WHERE `id`=%s AND `send_notify`='N' LIMIT 1",
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `send_notify`='Y' WHERE `id`=%s AND `send_notify`='N' LIMIT 1",
array(bigintval(getRequestElement('rallye_id'))), __FILE__, __LINE__, FALSE)
);
break;
case '0': // Deactivate
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `send_notify`='N' WHERE `id`=%s AND `send_notify`='Y' LIMIT 1",
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `send_notify`='N' WHERE `id`=%s AND `send_notify`='Y' LIMIT 1",
array(bigintval(getRequestElement('rallye_id'))), __FILE__, __LINE__, FALSE)
);
break;
// Automatic adding of new members
switch (getRequestElement('auto')) {
case '1': // Activate
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `auto_add_new_user`='Y' WHERE `id`=%s AND `auto_add_new_user`='N' LIMIT 1",
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `auto_add_new_user`='Y' WHERE `id`=%s AND `auto_add_new_user`='N' LIMIT 1",
array(bigintval(getRequestElement('rallye_id'))), __FILE__, __LINE__, FALSE)
);
break;
case '0': // Deactivate
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `auto_add_new_user`='N' WHERE `id`=%s AND `auto_add_new_user`='Y' LIMIT 1",
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_rallye_data` SET `auto_add_new_user`='N' WHERE `id`=%s AND `auto_add_new_user`='Y' LIMIT 1",
array(bigintval(getRequestElement('rallye_id'))), __FILE__, __LINE__, FALSE)
);
break;
// Delete selected rallyes and all it's data
foreach (postRequestElement('sel') as $id => $selected) {
// Remove selected rallye entirely...
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE `id`=%s LIMIT 1",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__, FALSE));
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `rallye_id`=%s",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_prices` WHERE `rallye_id`=%s",
array(bigintval($id)), __FILE__, __LINE__, FALSE));
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `rallye_id`=%s",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `rallye_id`=%s",
array(bigintval($id)), __FILE__, __LINE__, FALSE));
} // END - foreach
$END = mktime(postRequestElement('end_time_ho', $id) , postRequestElement('end_time_mi', $id) , 0, postRequestElement('end_time_mo', $id) , postRequestElement('end_time_da', $id) , postRequestElement('end_time_ye', $id) );
// Update entry
- addSql(SQL_QUERY_ESC("UPDATE
+ addSql(sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_rallye_data`
SET
`title`='%s',
// Then set it
$mode = 'delete';
} // END - if
-
+
// Check for selections
if (ifPostContainsSelections()) {
// Make all selected and deactivated rallyes editable
$OUT = '';
foreach (postRequestElement('sel') as $id => $selected) {
// Load rallye basic data
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`title`,
`descr`,
`template`,
array(bigintval($id)), __FILE__, __LINE__);
// Fetch an array
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Only for editing ...
if ($mode == 'edit') {
}
} elseif ((getRequestElement('sub') == 'users') && (getRequestElement('rallye_id') > 0)) {
// List users and their refs before start and current
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`userid`,
`refs`,
`curr_points`
ORDER BY
`userid` ASC",
array(bigintval(getRequestElement('rallye_id'))), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
$OUT = '';
$content['rallye_id'] = bigintval(getRequestElement('rallye_id'));
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Check for referral count
$count = getReferralRallyeRefsCount($row['userid'], $row['refs']);
$content['rallye_id'] = bigintval(getRequestElement('rallye_id'));
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
loadTemplate('admin_list_rallye_usr', FALSE, $content);
}
} else {
// Start listing rallyes
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`id` AS `rallye_id`,
`admin_id`,
`title`,
`start_time` DESC", __FILE__, __LINE__);
// Records found?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List found rallyes
$OUT = '';
- while ($data = SQL_FETCHARRAY($result)) {
+ while ($data = sqlFetchArray($result)) {
// Count joined userids
$users = countSumTotalData($data['rallye_id'], 'rallye_users', 'rallye_id', 'rallye_id', TRUE);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remember rows in array
$content['rows'] = $OUT;
displayMessage(sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink(getRequestElement('userid')), $totalReferrals, $totalLockedReferrals));
// Load all referral levels
- $result_levels = SQL_QUERY("SELECT
+ $result_levels = sqlQuery("SELECT
`level`,
`percents`
FROM
`level` ASC", __FILE__, __LINE__);
// Are there some levels (VERY BAD IF NONE!)
- if (!SQL_HASZERONUMS($result_levels)) {
+ if (!ifSqlHasZeroNums($result_levels)) {
// List all ref levels or entries if no refback is installed
$OUT = '';
- while ($levels = SQL_FETCHARRAY($result_levels)) {
+ while ($levels = sqlFetchArray($result_levels)) {
// Load all refs of this user
- $result_refs = SQL_QUERY_ESC("SELECT `refid` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s ORDER BY `refid` ASC",
+ $result_refs = sqlQueryEscaped("SELECT `refid` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s ORDER BY `refid` ASC",
array(
$userid,
$levels['level']
//* DEBUG: */ debugOutput($userid.'/'.$levels['level'].'/'.SQL_NUMROWS($result_refs));
// Is there levels?
- if (!SQL_HASZERONUMS($result_refs)) {
+ if (!ifSqlHasZeroNums($result_refs)) {
// Count entries
$totalReferrals = getUsersTotalReferrals($userid, $levels['level']);
$totalLockedReferrals = getUsersTotalLockedReferrals($userid, $levels['level']);
$OUT_REFS = '';
// Load all refs
- while ($content = SQL_FETCHARRAY($result_refs)) {
+ while ($content = sqlFetchArray($result_refs)) {
// Is the data there?
if (fetchUserData($content['refid'])) {
// Check for referrals
}
// Free result
- SQL_FREERESULT($result_refs);
+ sqlFreeResult($result_refs);
// Load level template
$OUT .= loadTemplate('admin_list_refs_level', TRUE, $levels);
}
// Free result
- SQL_FREERESULT($result_levels);
+ sqlFreeResult($result_levels);
} else {
// User not found
displayMessage('{%message,ADMIN_MEMBER_404=' . getRequestElement('userid') . '%}');
if (isGetRequestElementSet('id')) {
// Show detailed informations to a sponsor
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`company`, `position`, `gender`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`,
`phone`, `fax`, `cell`, `email`, `url`, `tax_ident`,
`status`,
`id`=%s LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load sponsor details
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Check if an entry is empty
foreach ($content as $k => $v) {
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} elseif (isGetRequestElementSet('refid')) {
// Search for sponsor
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('refid'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Sponsor found so let's list all his referrals
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`gender`,
`surname`,
`id` ASC",
array(bigintval(getRequestElement('refid'))), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List refs now
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No refs made so far
displayMessage(getMaskedMessage('ADMIN_SPONSOR_REFS_404', '<a href="{%url=modules.php?module=admin&what=list_sponsor&id=' . bigintval(getRequestElement('refid')) . '%}">' . bigintval(getRequestElement('refid')) . '</a>'));
}
} else {
// List all sponsors
- $result_main = SQL_QUERY("SELECT
+ $result_main = sqlQuery("SELECT
`id`, `gender`, `surname`, `family`, `email`, `status`,
UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
UNIX_TIMESTAMP(`last_online`) AS `last_online`,
ORDER BY
`id` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_main)) {
+ if (!ifSqlHasZeroNums($result_main)) {
// At least one sponsor found
$OUT = '';
- while ($content = SQL_FETCHARRAY($result_main)) {
+ while ($content = sqlFetchArray($result_main)) {
// Transfer data to array
$content['email'] = generateEmailLink($content['email'], 'sponsor_data');
$content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
} // END - while
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
// Load final template
loadTemplate('admin_list_sponsor', FALSE, $OUT);
$id = bigintval($id);
// Save entry
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_sponsor_paytypes`
SET
`pay_name`='%s',
// Remove entries here...
foreach (postRequestElement('id') as $id => $sel) {
// Remove entry
- SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1',
+ sqlQueryEscaped('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1',
array(bigintval($id)), __FILE__, __LINE__);
}
if (isFormSent('add')) {
// Check if entry with same name does exists
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `pay_name`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `pay_name`='%s' LIMIT 1",
array(postRequestElement('pay_name')), __FILE__, __LINE__);
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// No entry found so add this line
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_paytypes` (`pay_name`, `pay_rate`, `pay_min_count`, `pay_currency`) VALUES ('%s','%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_paytypes` (`pay_name`, `pay_rate`, `pay_min_count`, `pay_currency`) VALUES ('%s','%s','%s','%s')",
array(
postRequestElement('pay_name'),
convertCommaToDot(postRequestElement('pay_rate')),
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Output message
displayMessage($message);
$OUT = '';
foreach (postRequestElement('id') as $id => $sel) {
// Load entry
- $result = SQL_QUERY_ESC("SELECT `id`, `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
if (isFormSent('edit')) {
// Edit entry
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
// Load main template depending on mode (edit/delete)
}
} else {
// Load all payment types
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`pay_name`,
`pay_rate`,
__FILE__, __LINE__);
// Are there some payment types setup?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Prepare variables for listing
$OUT = '';
// List alle found payment types
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add row
$OUT .= loadTemplate('admin_list_sponsor_pay_row', TRUE, $content);
} // END - while
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load final template
loadTemplate('admin_sponsor_paytypes', FALSE, $content);
if (isGetRequestElementSet('id')) {
// Check for selected sponsor
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// ...
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Sponsor not found
displayMessage('{%message,ADMIN_SPONSOR_404=' . bigintval(getRequestElement('id')) . '%}');
outputSeletectedTasks(postRequestArray(), $dmy);
} else {
// Start listing tasks matching selected filter
- $result_tasks = SQL_QUERY('SELECT
+ $result_tasks = sqlQuery('SELECT
`id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
FROM
`{?_MYSQL_PREFIX?}_task_system`
if (isFormSent('unassign')) {
// Unassign from tasks
foreach (postRequestElement('sel') as $id => $sel) {
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=NULL WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `assigned_admin`=NULL WHERE `id`=%s AND `assigned_admin`=%s LIMIT 1",
array(bigintval($id), getCurrentAdminId()), __FILE__, __LINE__);
} // END - foreach
} elseif (isFormSent('delete')) {
foreach (postRequestElement('sel') as $id => $sel) {
if (getRequestElement('type') == 'deleted') {
// Delete task immediately
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1",
array(bigintval($id)),__FILE__, __LINE__);
} else {
// Mark task as to be deleted (purged by autopurge extension)
}
// Update query
- $result_tasks = SQL_QUERY('SELECT
+ $result_tasks = sqlQuery('SELECT
`id`, `assigned_admin`, `userid`, `task_type`, `subject`, `text`, `task_created`
FROM
`{?_MYSQL_PREFIX?}_task_system`
// There are uncompleted jobs!
$OUT = '';
- while ($content = SQL_FETCHARRAY($result_tasks)) {
+ while ($content = sqlFetchArray($result_tasks)) {
// Init infos
$content['infos'] = '';
} // END - while
// Free memory
- SQL_FREERESULT($result_tasks);
+ sqlFreeResult($result_tasks);
// Prepare content
$content = array(
addYouAreHereLink('admin', __FILE__);
// We only need outgoing transfers
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`userid` AS `from_userid`,
`to_userid`,
`trans_id`,
`trans_id` ASC', __FILE__, __LINE__);
$total = '0';
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Output rows
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare data for the row template
$content['time_trans'] = generateDateTime($content['time_trans'], 3);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Nothing for in and out
$OUT = '<tr>
// Shall I display links or not?
if (($listed === TRUE) && (!empty($sql))) {
// Load mail data
- $result_master = SQL_QUERY($sql, __FILE__, __LINE__);
+ $result_master = sqlQuery($sql, __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result_master) == 1) {
+ if (sqlNumRows($result_master) == 1) {
// Mail order / bonus mail found
- $poolData = SQL_FETCHARRAY($result_master);
+ $poolData = sqlFetchArray($result_master);
// If there is a pool id and $ID is not set, we take it
if (($poolData['id'] > 0) && ($ID == '-1')) {
// Load unconfirmed mail links. Hmmm, this select query is pretty cool
// but it does only show unconfirmed mail links from existing user
// accounts. So if you have delete one you did not see those links
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`l`.`userid`,
`u`.`status`,
`u`.`surname`,
),__FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// At least one link left to confirm
$OUT = '';
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// User data found? We can take any field of u.
if (!is_null($row['status'])) {
// Prepare data for the row template
// Prepare content
$content = $poolData;
- $content['unconfirmed'] = SQL_NUMROWS($result);
+ $content['unconfirmed'] = sqlNumRows($result);
$content['timestamp'] = generateDateTime($poolData['timestamp'], 2);
$content['rows'] = $OUT;
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load final template
loadTemplate('admin_list_unconfirmed', FALSE, $content);
}
// Free result
- SQL_FREERESULT($result_master);
+ sqlFreeResult($result_master);
} // END - if
// [EOF]
$userid = bigintval(getRequestElement('userid'));
// Does the account exists?
- $result_user = SQL_QUERY_ESC('SELECT
+ $result_user = sqlQueryEscaped('SELECT
`userid`,
`country`,
`email`,
array($userid), __FILE__, __LINE__);
// User found?
- if (SQL_NUMROWS($result_user) == 1) {
+ if (sqlNumRows($result_user) == 1) {
// Account found
- $content = SQL_FETCHARRAY($result_user);
+ $content = sqlFetchArray($result_user);
// Get count/sum of refs, selected categories, unconfirmed mails
// @TODO Refacture these old link generation to functions
}
// Free the result
- SQL_FREERESULT($result_user);
+ sqlFreeResult($result_user);
} else {
$whereStatement = '';
if (isGetRequestElementSet('letter')) {
// Is a WHERE statement already there?
if (!empty($whereStatement)) {
// Then append the status column
- $whereStatement .= sprintf(" AND `status`='%s'", SQL_ESCAPE(strtoupper(getRequestElement('status'))));
+ $whereStatement .= sprintf(" AND `status`='%s'", sqlEscapeString(strtoupper(getRequestElement('status'))));
} else {
// Start a new one
- $whereStatement = sprintf(" WHERE `status`='%s'", SQL_ESCAPE(strtoupper(getRequestElement('status'))));
+ $whereStatement = sprintf(" WHERE `status`='%s'", sqlEscapeString(strtoupper(getRequestElement('status'))));
}
// Exclude other users
break;
default: // Invalid list mode
- reportBug(__FILE__, __LINE__, sprintf('Invalid do %s detected.', SQL_ESCAPE(getRequestElement('do'))));
+ reportBug(__FILE__, __LINE__, sprintf('Invalid do %s detected.', sqlEscapeString(getRequestElement('do'))));
break;
} // END - switch
);
// Prepare SQL and run it
- $result_master = SQL_QUERY($sql, __FILE__, __LINE__);
+ $result_master = sqlQuery($sql, __FILE__, __LINE__);
// Is the user limit zero?
if (getUserLimit() == '0') {
} // END - if
// Calculate page count (0.5 fixes a bug with page count)
- $numPages = round(SQL_NUMROWS($result_master) / getUserLimit() + 0.5);
+ $numPages = round(sqlNumRows($result_master) / getUserLimit() + 0.5);
if (!isGetRequestElementSet('page')) setGetRequestElement('page' , 1);
if (!isGetRequestElementSet('offset')) setGetRequestElement('offset', getUserLimit());
// Add limitation to SQL string and run him again
$sql .= ' LIMIT ' . (getRequestElement('offset') * getRequestElement('page') - getRequestElement('offset')) . ', ' . getRequestElement('offset');
- $result = SQL_QUERY($sql, __FILE__, __LINE__);
+ $result = sqlQuery($sql, __FILE__, __LINE__);
// Are there some entries?
- if (!SQL_HASZERONUMS($result_master)) {
+ if (!ifSqlHasZeroNums($result_master)) {
// Sorting links and number of pages
$templateContent['sort_links'] = addSortLinks(getRequestElement('letter'), getRequestElement('sortby'));
$templateContent['num_pages'] = $numPages;
// Load all users
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Merge more data in
$content = merge_array($content, $templateContent);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Free some memory
- SQL_FREERESULT($result_master);
+ sqlFreeResult($result_master);
// Remember all rows
$content['rows'] = $OUT;
}
// Free memory
- SQL_FREERESULT($result_master);
+ sqlFreeResult($result_master);
}
// [EOF]
$sql = substr($sql, 0, -1);
// Run the query to obtain all user's amounts (regardless of their status)
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`p`.`userid`,
SUM(
' . $sql . ' -
`p`.`userid` ASC', __FILE__, __LINE__);
// Are there entries? (sorry, the XML functions cannot "produce" the above SQL statement)
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Init amounts and points
$totalPoints = '0';
$amounts = array();
// Then load all
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Add it
$amounts[$row['userid']] = $row;
$totalPoints += $row['points'];
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
$content['email'] = '<a href="' . generateEmailLink($content['email'], 'user_data') . '">{%pipe,translateGender=' . $content['gender'] . '%} ' . $content['surname'] . ' ' . $content['family'] . '</a>';
// Ok, list categories of this user
- $result_cats = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats` ORDER BY `sort` ASC", __FILE__, __LINE__);
+ $result_cats = sqlQuery("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats` ORDER BY `sort` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_cats)) {
+ if (!ifSqlHasZeroNums($result_cats)) {
// List categories
$count = 1; $OUT = '';
- while ($row = SQL_FETCHARRAY($result_cats)) {
+ while ($row = sqlFetchArray($result_cats)) {
// Merge both arrays
$content = merge_array($content, $row);
// Check user's selection
// @TODO Rewrite this to countSum.....() function
- $result_user = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s AND `cat_id`=%s LIMIT 1",
+ $result_user = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s AND `cat_id`=%s LIMIT 1",
array(bigintval(getRequestElement('userid')), bigintval($content['id'])), __FILE__, __LINE__);
// Set selection
$selection = '<font color="#ee0000">{--NO--}</div>';
- if (SQL_NUMROWS($result_user) == 1) {
+ if (sqlNumRows($result_user) == 1) {
$selection = '<font color="#00ee00">{--YES--}</div>';
} // END - if
} // END - while
// Free memory
- SQL_FREERESULT($result_cats);
+ sqlFreeResult($result_cats);
// Remember all rows in the array
$content['rows'] = $OUT;
));
} elseif ((isGetRequestElementSet('do')) && (isGetRequestElementSet('id'))) {
// Construct module name
- $incFile = sprintf("inc/modules/admin/subid-%s.php", SQL_ESCAPE(getRequestElement('do')));
+ $incFile = sprintf("inc/modules/admin/subid-%s.php", sqlEscapeString(getRequestElement('do')));
// Is the include readable and is the sub id assigned to current admin?
if (!isUserSubIdAssignedToMember(getRequestElement('id'), getRequestElement('userid'))) {
addYouAreHereLink('admin', __FILE__);
// Check for entries
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`id`,
`userid`,
`wernis_account`,
__FILE__, __LINE__);
// Are there some entries to display?
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// List all entries
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Translate some data and add color
$content['wernis_timestamp'] = generateDateTime($content['wernis_timestamp'], 2);
}
// Free the result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
if (isGetRequestElementSet('id')) {
// Check for selected sponsor
- $result_sponsor = SQL_QUERY_ESC("SELECT `gender`, `surname`, `family`, `email`, `status` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
+ $result_sponsor = sqlQueryEscaped("SELECT `gender`, `surname`, `family`, `email`, `status` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_sponsor) == 1) {
+ if (sqlNumRows($result_sponsor) == 1) {
// Get sponsor's current status and let only confirmed and locked status pass
- $content = SQL_FETCHARRAY($result_sponsor);
+ $content = sqlFetchArray($result_sponsor);
if (($content['status'] == 'CONFIRMED') || ($content['status'] == 'LOCKED')) {
// Transfer data to constants
sendEmail($content['email'], $subject, $message);
// Update sponsor's account
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `status`='%s' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `status`='%s' WHERE `id`=%s LIMIT 1",
array($content['status'], bigintval(getRequestElement('id'))), __FILE__, __LINE__);
} elseif (isPostRequestElementSet('no')) {
// No don't lock / unlock now!
}
// Free result
- SQL_FREERESULT($result_sponsor);
+ sqlFreeResult($result_sponsor);
} else {
// Not called by what-list_sponsor.php
$message = '{--ADMIN_CALL_NOT_DIRECTLY--}';
// Ok, lock the account!
if (isExtensionInstalledAndNewer('user', '0.3.5')) {
// Lock with reason
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED',`lock_reason`='%s',`lock_timestamp`=NOW() WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED',`lock_reason`='%s',`lock_timestamp`=NOW() WHERE `userid`=%s LIMIT 1",
array(postRequestElement('reason'), bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
} else {
// Lock with no lock reason saved
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED' WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED' WHERE `userid`=%s LIMIT 1",
array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
}
// Entry updated?
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Send an email to the user! In later version you can optionally switch this feature off
$message = loadEmailTemplate('member_user_locked', array('text' => postRequestElement('reason')), bigintval(getRequestElement('userid')));
// Ok, unlock the account!
if (isExtensionInstalledAndNewer('user', '0.3.5')) {
// Reset lock reason as well
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`status`='CONFIRMED',
array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
} else {
// No lock reason to reset
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='CONFIRMED' WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='CONFIRMED' WHERE `userid`=%s LIMIT 1",
array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
}
// Entry updated?
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Send an email to the user! In later version you can optionally switch this feature off
$message = loadEmailTemplate('member_user_unlocked', array('text' => postRequestElement('reason')), bigintval(getRequestElement('userid')));
if (isGetRequestElementSet('access')) {
// Secure input and construct FQFN
- $access = SQL_ESCAPE(getRequestElement('access'));
+ $access = sqlEscapeString(getRequestElement('access'));
$target = sprintf("%slogs/%s", getPath(), $access);
// Is the file valid and readable?
$below = array();
// Get all available main menus
- $result = SQL_QUERY("SELECT `action`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC",
+ $result = sqlQuery("SELECT `action`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC",
__FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Read menu structure
// @TODO Cant this be rewritten?
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Menu actions
array_push($menus, $content['action']);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remove double eintries
// @TODO This can be somehow rewritten to a function
// Load sub menus :)
foreach ($menus as $key_main => $value_main) {
- $result = SQL_QUERY_ESC("SELECT `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' ORDER BY `sort` ASC",
+ $result = sqlQueryEscaped("SELECT `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' ORDER BY `sort` ASC",
array($value_main), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Initialize arrays
$menus[$value_main] = array();
$titles[$value_main] = array();
$below[$value_main] = array();
// Read menu structure
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Menu actions
array_push($menus[$value_main], $content['what']);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remove double eintries
// @TODO This can be somehow rewritten to a function
} elseif (!isDemoModeActive()) {
// Insert new menu entry
if (isPostRequestElementSet('menu')) {
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`, `what`, `title`, `visible`, `locked`, `sort`) VALUES ('%s','%s','%s','%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`, `what`, `title`, `visible`, `locked`, `sort`) VALUES ('%s','%s','%s','%s','%s','%s')",
array(
postRequestElement('menu'),
postRequestElement('name'),
bigintval(postRequestElement('sort')),
), __FILE__, __LINE__);
} else {
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`, `title`, `visible`, `locked`, `sort`) VALUES ('%s','%s','%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_member_menu` (`action`, `title`, `visible`, `locked`, `sort`) VALUES ('%s','%s','%s','%s','%s')",
array(
postRequestElement('name'),
postRequestElement('title'),
foreach (postRequestElement('sel') as $sel => $confirm) {
if ($confirm == 1) {
$count++;
- $result = SQL_QUERY_ESC("SELECT `title`, `action`, `what` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title`, `action`, `what` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Entry found so we load the stuff...
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
$content = array(
'count' => $count,
'sel' => $sel,
// Load template
$OUT .= loadTemplate('admin_menu_404_row', TRUE, $content);
}
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - foreach
foreach (postRequestElement('sel') as $sel => $confirm) {
if ($confirm == 1) {
$count++;
- $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Entry found so we load the stuff...
- list($title) = SQL_FETCHROW($result);
+ list($title) = sqlFetchRow($result);
$content = array(
'count' => $count,
'sel' => $sel,
// Load template
$OUT .= loadTemplate('admin_menu_404_row', TRUE, $content);
}
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - foreach
foreach (postRequestElement('sel') as $sel => $confirm) {
if ($confirm == 1) {
$count++;
- $result = SQL_QUERY_ESC("SELECT `title`, `visible`, `locked` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title`, `visible`, `locked` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `id`=%s LIMIT 1",
array(bigintval($sel)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Entry found so we load the stuff...
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
$content = array(
'count' => $count,
'menu' => $content['title'],
// Load template
$OUT .= loadTemplate('admin_menu_404_row', TRUE, $content);
}
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - foreach
if (!empty($subMenu)) {
// Edit sub menus
- $result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", __FILE__, __LINE__);
+ $result = sqlQuery("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE ".$AND." AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC", __FILE__, __LINE__);
} else {
// Edit main menus
- $result = SQL_QUERY("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
+ $result = sqlQuery("SELECT `id`, `action`, `what`, `title`, `sort` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC", __FILE__, __LINE__);
}
// Some are there?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
$count = '0'; $OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Set sub value
$content['sub'] = $subMenu;
if (($content['sort'] == '0') || (($content['sort'] == 1) && (!empty($subMenu)))) {
// Is highest position
$content['navi'] = '<a href="{%url=modules.php?module=admin&what=memedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']+1) . '&fid=' . $content['sort'] . '%}">{--LOWER--}</a>';
- } elseif ($count == SQL_NUMROWS($result)) {
+ } elseif ($count == sqlNumRows($result)) {
// Is lowest position
$content['navi'] = '<a href="{%url=modules.php?module=admin&what=memedit&sub=' . $content['sub'] . '&act=' . $content['action'] . '&w=' . $content['what'] . '&tid=' . ($content['sort']-1) . '&fid=' . $content['sort'] . '%}">{--HIGHER--}</a>';
} elseif ($content['sort'] > 0) {
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remember rows/sub in array
$content['rows'] = $OUT;
// Delete entries here
$OUT = '';
foreach (postRequestElement('sel') as $id => $value) {
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`time`,
`payment`,
`id`=%s
LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load row template and switch colors
$OUT .= loadTemplate('admin_delete_payments_row', TRUE, $content);
// Edit entries
$OUT = '';
foreach (postRequestElement('sel') as $id => $value) {
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`time`,
`payment`,
`id`=%s
LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load row template and switch colors
$OUT .= loadTemplate('admin_edit_payments_row', TRUE, $content);
loadTemplate('admin_edit_payments', FALSE, $OUT);
} else {
// Referral levels
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`id`,
`time`,
`payment`,
`{?_MYSQL_PREFIX?}_payments`
ORDER BY
`time` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Make referral levels editable and deletable
$OUT = '';
// List already existing categories for editing
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template and switch colors
$OUT .= loadTemplate('admin_list_payments_row', TRUE, $content);
} // END - switch
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load main template
loadTemplate('admin_list_payments', FALSE, $OUT);
switch (getRequestElement('do')) {
case 'add':
// Check if banner is already added
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `url`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `url`='%s' LIMIT 1",
array(postRequestElement('url')), __FILE__, __LINE__);
// Was the banner found?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Add banner
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refbanner` (`url`, `alternate`, `visible`)
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_refbanner` (`url`, `alternate`, `visible`)
VALUES ('%s','%s','%s')",
array(
postRequestElement('url'),
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
break;
case 'edit': // Update banner
$id = bigintval($id);
// Update entry
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `url`='%s',`alternate`='%s',`visible`='%s' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `url`='%s',`alternate`='%s',`visible`='%s' WHERE `id`=%s LIMIT 1",
array(
postRequestElement('url', $id),
postRequestElement('alternate', $id),
} // END - switch
// Check if we have saved (updated)
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Updated!
$content = '{--SETTINGS_SAVED--}';
} else {
$OUT = '';
foreach (postRequestElement('sel') as $id => $sel) {
// Load data
- $result = SQL_QUERY_ESC("SELECT `id`, `url`, `alternate`, `visible` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `url`, `alternate`, `visible` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
- SQL_FREERESULT($result);
+ $content = sqlFetchArray($result);
+ sqlFreeResult($result);
// Preapre data for the row
$content['visible'] = addSelectionBox('yn', $content['visible'], 'visible');
if ((ifPostContainsSelections()) && (isFormSent('delete'))) {
// Delete banner
foreach (postRequestElement('sel') as $id => $sel) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
array(bigintval($id)), __FILE__, __LINE__);
} // END - foreach
} // END - if
// Referral levels
- $result = SQL_QUERY('SELECT `id`, `url`, `alternate`, `visible`, `counter`, `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `url` ASC', __FILE__, __LINE__);
+ $result = sqlQuery('SELECT `id`, `url`, `alternate`, `visible`, `counter`, `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `url` ASC', __FILE__, __LINE__);
// Entries found?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Make referral banner editable and deletable
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template and switch color
$OUT .= loadTemplate('admin_list_refbanner_row', TRUE, $content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load main template
loadTemplate('admin_list_refbanner', FALSE, $OUT);
$actions = array();
// First fix all main menus (what = '')...
-$result_fix = SQL_QUERY("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__);
+$result_fix = sqlQuery("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__);
$count = '0'; $repairedWeights = '0';
-while ($content = SQL_FETCHARRAY($result_fix)) {
+while ($content = sqlFetchArray($result_fix)) {
// Store act value for later usage in sorting sub menus
array_push($actions, $content['action']);
// Fix weight
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET sort=%s WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET sort=%s WHERE `id`=%s LIMIT 1",
array($count, $content['id']), __FILE__, __LINE__);
- $repairedWeights += SQL_AFFECTEDROWS();
+ $repairedWeights += sqlAffectedRows();
// Count one up
$count++;
} // END - while
// Set logout weight to 999
-SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `sort`='999' WHERE `action`='logout' AND (`what`='' OR `what` IS NULL) LIMIT 1", __FILE__, __LINE__);
+sqlQuery("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `sort`='999' WHERE `action`='logout' AND (`what`='' OR `what` IS NULL) LIMIT 1", __FILE__, __LINE__);
// Now sort every each menu
foreach ($actions as $action) {
- $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
+ $result_fix = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
array($action), __FILE__, __LINE__);
$count = 1;
- while ($content = SQL_FETCHARRAY($result_fix)) {
+ while ($content = sqlFetchArray($result_fix)) {
// Fix weight
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1",
array($count, $content['id']), __FILE__, __LINE__);
- $repairedWeights += SQL_AFFECTEDROWS();
+ $repairedWeights += sqlAffectedRows();
// Count one up
$count++;
addYouAreHereLink('admin', __FILE__);
// Go through all categories
-$result = SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_cats` GROUP BY `userid` ORDER BY `userid` ASC", __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result)) {
+$result = sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_cats` GROUP BY `userid` ORDER BY `userid` ASC", __FILE__, __LINE__);
+if (!ifSqlHasZeroNums($result)) {
// Nothing is removed for now... ;-)
$removedRows = '0';
// Check if found userid is also found in user_data table
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Is the account not there?
if (!fetchUserData($content['userid'])) {
// Ok, we found something to remove
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s",
array(bigintval($content['userid'])), __FILE__, __LINE__);
- $removedRows += SQL_AFFECTEDROWS();
+ $removedRows += sqlAffectedRows();
} // END - if
} // END - while
$actions = array();
// First fix all main menus (what = '')...
-$result_fix = SQL_QUERY("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__);
+$result_fix = sqlQuery("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__);
$count = '0'; $repairedWeights = '0';
-while ($content = SQL_FETCHARRAY($result_fix)) {
+while ($content = sqlFetchArray($result_fix)) {
// Store act value for later usage in sorting sub menus
array_push($actions, $content['action']);
// Fix weight
- $result_sort = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1",
+ $result_sort = sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1",
array($count, $content['id']), __FILE__, __LINE__);
// Get updated rows
- $repairedWeights += SQL_AFFECTEDROWS();
+ $repairedWeights += sqlAffectedRows();
// Count one up
$count++;
} // END - while
// Set logout weight to 999
-$result_sort = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET sort='999' WHERE `action`='logout' AND (`what`='' OR `what` IS NULL) LIMIT 1", __FILE__, __LINE__);
+$result_sort = sqlQuery("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET sort='999' WHERE `action`='logout' AND (`what`='' OR `what` IS NULL) LIMIT 1", __FILE__, __LINE__);
// Now sort every each menu
foreach ($actions as $action) {
- $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
+ $result_fix = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
array($action), __FILE__, __LINE__);
$count = 1;
- while ($content = SQL_FETCHARRAY($result_fix)) {
+ while ($content = sqlFetchArray($result_fix)) {
// Fix weight
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1",
array($count, $content['id']), __FILE__, __LINE__);
- $repairedWeights += SQL_AFFECTEDROWS();
+ $repairedWeights += sqlAffectedRows();
// Count one up
$count++;
$actions = array();
// First fix all main menus (what = '')...
-$result_fix = SQL_QUERY("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__);
+$result_fix = sqlQuery("SELECT `id`, `action` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE (`what`='' OR `what` IS NULL) AND `action` != 'logout' ORDER BY `sort` ASC", __FILE__, __LINE__);
$count = '0'; $repairedWeights = '0';
-while ($content = SQL_FETCHARRAY($result_fix)) {
+while ($content = sqlFetchArray($result_fix)) {
// Store action value for later usage in sorting sub menus
array_push($actions, $content['action']);
// Fix weight
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `sort`=%s WHERE `id`=%s LIMIT 1",
array($count, $content['id']), __FILE__, __LINE__);
- $repairedWeights += SQL_AFFECTEDROWS();
+ $repairedWeights += sqlAffectedRows();
// Count one up
$count++;
} // END - while
// Set logout weight to 999
-SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET sort='999' WHERE `action`='logout' AND (`what`='' OR `what` IS NULL) LIMIT 1", __FILE__, __LINE__);
+sqlQuery("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET sort='999' WHERE `action`='logout' AND (`what`='' OR `what` IS NULL) LIMIT 1", __FILE__, __LINE__);
// Now sort every each menu
foreach ($actions as $action) {
- $result_fix = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
+ $result_fix = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC",
array($action), __FILE__, __LINE__);
$count = 1;
- while ($content = SQL_FETCHARRAY($result_fix)) {
+ while ($content = sqlFetchArray($result_fix)) {
// Fix weight
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET sort=%s WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET sort=%s WHERE `id`=%s LIMIT 1",
array($count, $content['id']), __FILE__, __LINE__);
- $repairedWeights += SQL_AFFECTEDROWS();
+ $repairedWeights += sqlAffectedRows();
// Count one up
$count++;
displayMessage('{--ADMIN_SEND_COUPON_DESCRIPTION_NOT_ENTERED--}');
} else {
// All fields are set, so we can start looking for users who wants to receive coupons
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`userid`
FROM
`{?_MYSQL_PREFIX?}_user_data`
__FILE__, __LINE__);
// Are there entries left?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Convert timestamp selections
$expirationTime = time() + createEpocheTimeFromSelections('coupon_default_time', postRequestArray());
// Insert coupon data
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_coupon_data` (`coupon_expired`, `total_created`, `points`, `coupon_description`) VALUES ('{%%pipe,SQL_EPOCHE_TO_TIMESTAMP=%s%%}', %s,%s,'%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_coupon_data` (`coupon_expired`, `total_created`, `points`, `coupon_description`) VALUES ('{%%pipe,SQL_EPOCHE_TO_TIMESTAMP=%s%%}', %s,%s,'%s')",
array(
$expirationTime,
- SQL_NUMROWS($result),
+ sqlNumRows($result),
bigintval(postRequestElement('points')),
postRequestElement('coupon_description')
), __FILE__, __LINE__
);
// Get the insert id from the table
- $couponId = SQL_INSERT_ID();
+ $couponId = getSqlInsertId();
// Init userid array
$adminUserids = array();
// Load entry
- while (list($userid) = SQL_FETCHROW($result)) {
+ while (list($userid) = sqlFetchRow($result)) {
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'NUMS=' . SQL_NUMROWS($result) . ',userid=' . $userid);
} // END - while
// The above loop should always set $couponCode, so we can now insert it
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_coupons` (`coupon_id`, `userid`, `coupon_code`) VALUES (%s,%s,'%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_coupons` (`coupon_id`, `userid`, `coupon_code`) VALUES (%s,%s,'%s')",
array(
$couponId,
$userid,
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
} else {
// Prepare some template data
addYouAreHereLink('admin', __FILE__);
if (isFormSent()) {
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`userid`,
`email`
FROM
`nl_receive`='Y'
ORDER BY
`userid` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Members are available so we can send out the newsletter!
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Construct mail...
$template = 'newsletter';
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Copy data into constants for the template and load it
$content['datestamp'] = generateDateTime(time(), 3);
$mod = mapModuleToTable(getRequestElement('mod'));
// Load module's detail statistic
- $result = SQL_QUERY_ESC("SELECT `action`, `title`, `counter` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `what` != '' AND `what` IS NOT NULL ORDER BY `counter` DESC, `action` ASC, `sort` ASC",
+ $result = sqlQueryEscaped("SELECT `action`, `title`, `counter` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `what` != '' AND `what` IS NOT NULL ORDER BY `counter` DESC, `action` ASC, `sort` ASC",
array($mod), __FILE__, __LINE__);
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load row template
$OUT .= loadTemplate('admin_list_mods_stats2_row', TRUE, $content);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load final template
loadTemplate('admin_list_mods_stats2', FALSE, $OUT);
} else {
// Load module statics
- $result = SQL_QUERY('SELECT `module`, `title`, `clicks` FROM `{?_MYSQL_PREFIX?}_mod_reg` ORDER BY `clicks` DESC, `module` ASC', __FILE__, __LINE__);
+ $result = sqlQuery('SELECT `module`, `title`, `clicks` FROM `{?_MYSQL_PREFIX?}_mod_reg` ORDER BY `clicks` DESC, `module` ASC', __FILE__, __LINE__);
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
if (($content['module'] == 'index') || ($content['module'] == 'login')) {
// Add link to detail statistics
$content['module'] = '<a href="{%url=modules.php?module=admin&what=stats_mods&mod=' . $content['module'] . '%}">' . $content['module'] . '</a>';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load final template
loadTemplate('admin_list_mods_stats', FALSE, $OUT);
$content['points'] = bigintval(postRequestElement('points'));
// Load userid
- $result_main = SQL_QUERY("SELECT `userid`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' ORDER BY `userid` ASC",
+ $result_main = sqlQuery("SELECT `userid`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' ORDER BY `userid` ASC",
__FILE__, __LINE__);
- while ($row = SQL_FETCHARRAY($result_main)) {
+ while ($row = sqlFetchArray($result_main)) {
// Merge both arrays
$content = merge_array($content, $row);
// Prepare content
$content = array(
- 'reason' => SQL_ESCAPE(postRequestElement('reason')),
+ 'reason' => sqlEscapeString(postRequestElement('reason')),
'points' => bigintval(postRequestElement('points')),
'subject' => 'admin_sub_all',
);
} // END - while
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
// Output message
displayMessage('{--ADMIN_ALL_POINTS_SUB_DONE--}');
// Prepare content
$content = array(
- 'reason' => SQL_ESCAPE(postRequestElement('reason')),
+ 'reason' => sqlEscapeString(postRequestElement('reason')),
'points' => bigintval(postRequestElement('points')),
'subject' => 'admin_sub_single',
);
// Is the 'url_id' set?
if (isGetRequestElementSet('url_id')) {
// Generate general statistics
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`stats_userid`,
`stats_count` AS `total_visits`,
UNIX_TIMESTAMP(`stats_last_surfed`) AS `last_surfed`
array(bigintval(getRequestElement('url_id'))), __FILE__, __LINE__);
// Entries found?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Get all rows
$OUT = ''; $count = '0'; $visits = '0';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Count totals
$visits += $content['total_visits'];
}
} else {
// Generate general statistics
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`stats_userid`,
COUNT(`stats_url_id`) AS `visited_urls`,
SUM(`stats_count`) AS `total_visits`
`stats_userid` ASC", __FILE__, __LINE__);
// Entries found?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Get all rows
$OUT = ''; $urlArray = '0'; $visits = '0';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Count totals
$urlArray += $content['visited_urls'];
$visits += $content['total_visits'];
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
// Run SQL command?
if (!empty($sql)) {
// Run it
- $result = SQL_QUERY_ESC($sql, array(bigintval($id)), __FILE__, __LINE__);
+ $result = sqlQueryEscaped($sql, array(bigintval($id)), __FILE__, __LINE__);
// Rebuild cache
rebuildCache('themes', 'them');
}
// Init rows
-$OUT = '';
+$OUT = '';
// Switch to testing mode
$GLOBALS['theme_mode'] = 'test';
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`id`,
`theme_path`,
`theme_active`,
ORDER BY
`theme_path` ASC", __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result)) {
- while ($content = SQL_FETCHARRAY($result)) {
+if (!ifSqlHasZeroNums($result)) {
+ while ($content = sqlFetchArray($result)) {
// Construct IFN
$inc = sprintf("theme/%s/theme.php", $content['theme_path']);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No themes found???
$OUT .= '<tr>
// Check if theme is there
if (!ifThemeExists(postRequestElement('theme'))) {
// Import theme
- $inc = sprintf("theme/%s/theme.php", SQL_ESCAPE(postRequestElement('theme')));
+ $inc = sprintf("theme/%s/theme.php", sqlEscapeString(postRequestElement('theme')));
// Is the theme readable?
if (isIncludeReadable($inc)) {
loadInclude($inc);
// Register it ith the exchange
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_themes` (`theme_path`, `theme_active`, `theme_ver`, `theme_name`)
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_themes` (`theme_path`, `theme_active`, `theme_ver`, `theme_name`)
VALUES ('%s','N','%s','%s')",
array(
postRequestElement('theme'),
addYouAreHereLink('admin', __FILE__);
// Check for mails
-$result_main = SQL_QUERY("SELECT
+$result_main = sqlQuery("SELECT
`id`,
`url`,
`subject`,
ORDER BY
`timestamp` ASC", __FILE__, __LINE__);
-if ((!SQL_HASZERONUMS($result_main)) || (isFormSent('lock'))) {
+if ((!ifSqlHasZeroNums($result_main)) || (isFormSent('lock'))) {
if (isFormSent('accept')) {
if (ifPostContainsSelections()) {
// Accept mail orders
// Check for bonus extension version >= 0.4.4 for the order bonus
if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) {
// Add points directly
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_order`=`bonus_order`+{?bonus_order?} WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_order`=`bonus_order`+{?bonus_order?} WHERE `userid`=%s LIMIT 1",
array(bigintval($content['sender'])), __FILE__, __LINE__);
// Subtract bonus points from system
} elseif ((!isFormSent('lock')) && (!isFormSent('accept')) && (!isFormSent('reject'))) {
// Mail orders are in pool so we can display them
$OUT = '';
- while ($content = SQL_FETCHARRAY($result_main)) {
+ while ($content = sqlFetchArray($result_main)) {
// Prepare data for the template
$content['timestamp'] = generateDateTime($content['timestamp'], 2);
} // END - while
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
// Remember in array
$content['rows'] = $OUT;
);
// Load his personal data
- $result_main = SQL_QUERY_ESC("SELECT
+ $result_main = sqlQueryEscaped("SELECT
`id`, `gender`, `surname`, `family`, `email`, `remote_addr`,
UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
`points_amount`, `points_used`,
array($content['id']), __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result_main) == 1) {
+ if (sqlNumRows($result_main) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result_main);
+ $content = sqlFetchArray($result_main);
// Check for open payments and close them
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`so`.`admin_id`,
`so`.`pay_count`,
UNIX_TIMESTAMP(`so`.`pay_ordered`) AS `pay_ordered`,
ORDER BY
`sp`.`pay_name` ASC",
array($content['id']), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Payment does exist
- while ($content2 = SQL_FETCHARRAY($result)) {
+ while ($content2 = sqlFetchArray($result)) {
// Merge both arrays
$content = merge_array($content, $content2);
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Not found
displayMessage('{%message,ADMIN_SPONSOR_ACCOUNT_404_ALREADY_CONFIRMED=' . $content['id'] . '%}');
}
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
// Unlock sponsor account
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_sponsor_data`
SET
`status`='CONFIRMED'
// Update, if applyable, referral count and points
if ((isValidId($content['refid'])) && ($content['refid'] != $content['id'])) {
// Update referral account
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_sponsor_data`
SET
`points_amount`=`points_amount`+{?sponsor_ref_points?},
array(bigintval($content['refid'])), __FILE__, __LINE__);
// Whas that update fine?
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Load referral's data
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`gender`,
`surname`,
`id`=%s
LIMIT 1",
array(bigintval($content['refid'])), __FILE__, __LINE__);
- $REFERRAL = SQL_FETCHARRAY($result);
+ $REFERRAL = sqlFetchArray($result);
// Send warnings out?
if ($REFERRAL['receive_warnings'] == 'Y') {
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - if
} // END - if
// Begin listing of all pending sponsor accounts
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`id`, `gender`, `surname`, `family`, `email`, `remote_addr`,
UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`
FROM
ORDER BY
`id`", __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Entries found so let's list them!
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Translate some data
$content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
}
// Free memory
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
if ((!empty($FQFN)) && (isFileReadable($FQFN))) {
// @TODO This code is double, see loadTemplate() and loadEmailTemplate() in functions.php
- eval('$content="' . SQL_ESCAPE(readFromFile($FQFN)) . '";');
+ eval('$content="' . sqlEscapeString(readFromFile($FQFN)) . '";');
// Until here...
// Replace URLs
loadTemplate('admin_mini_online', FALSE, $content);
// Check for online users
- $result = SQL_QUERY("SELECT `id`, `ip`, `userid`, `refid`, `module`, `action`, `what`, `is_member`, `is_admin`, `timestamp` FROM `{?_MYSQL_PREFIX?}_online` ORDER by `timestamp` DESC",
+ $result = sqlQuery("SELECT `id`, `ip`, `userid`, `refid`, `module`, `action`, `what`, `is_member`, `is_admin`, `timestamp` FROM `{?_MYSQL_PREFIX?}_online` ORDER by `timestamp` DESC",
__FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List all online users
$OUT = '';
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
if ($row['is_admin'] == 'Y') {
// Is an administrator
$row['userid'] = '{--_IS_ADMIN--}';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remember rows and fancy time in array
$content['rows'] = $OUT;
// Finally is the entry valid?
if ((count($content) > 0) && ($content['data_type'] == 'TEMP')) {
// Load subject and URL (but forwhat do we need the subject line here???
- list($url) = SQL_FETCHROW($result);
+ list($url) = sqlFetchRow($result);
// This fixes a white page
setPostRequestElement('url', $url);
} // END - if
// Check for members who were active only this day
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`userid`,
`last_online`
FROM
LIMIT {?active_limit?}", __FILE__, __LINE__);
// Entries found?
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// At least one member was online so let's load them all
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// If ext-nickname is not installed, set 'nickname' to empty
if (!isExtensionActive('nickname')) {
$content['nickname'] = '';
// Set userid and crypt password when login data was submitted
if (isNicknameUsed(postRequestElement('id'))) {
// Nickname entered
- $userid = SQL_ESCAPE(postRequestElement('id'));
+ $userid = sqlEscapeString(postRequestElement('id'));
} else {
// Direct userid entered
$userid = bigintval(postRequestElement('id'));
$userid = NULL;
if (isPostRequestElementSet('email')) {
// Email is set
- $userid = SQL_ESCAPE(postRequestElement('email'));
+ $userid = sqlEscapeString(postRequestElement('email'));
} elseif (isPostRequestElementSet('id')) {
// Is there nickname or userid?
if (isNicknameUsed(postRequestElement('id'))) {
// Nickname entered
- $userid = SQL_ESCAPE(postRequestElement('id'));
+ $userid = sqlEscapeString(postRequestElement('id'));
} else {
// Direct userid entered
$userid = bigintval(postRequestElement('id'));
$content['jackpot'] = $jackpot;
// Total referral link clicks, total logins
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
SUM(`d`.`ref_clicks`) AS `total_ref_clicks`,
SUM(`d`.`total_logins`) AS `total_logins`
FROM
`{?_MYSQL_PREFIX?}_user_data` AS `d`
' . runFilterChain('user_exclusion_sql', ''), __FILE__, __LINE__);
-list($ref, $logins) = SQL_FETCHROW($result);
-SQL_FREERESULT($result);
+list($ref, $logins) = sqlFetchRow($result);
+sqlFreeResult($result);
// Get total points
$points = getMediadataEntry('total_points');
$total = countSumTotalData('Y', 'refbanner', 'id', 'visible', TRUE);
// Total views and clicks
-$result = SQL_QUERY("SELECT SUM(`counter`) AS `views`, SUM(`clicks`) AS `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
-list($views, $clicks) = SQL_FETCHROW($result);
-SQL_FREERESULT($result);
+$result = sqlQuery("SELECT SUM(`counter`) AS `views`, SUM(`clicks`) AS `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
+list($views, $clicks) = sqlFetchRow($result);
+sqlFreeResult($result);
if (empty($total)) $total = '0';
if (empty($views)) $views = '0';
if (isExtensionActive('holiday')) {
// Total holiday requests
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
COUNT(`h`.`userid`) AS `count_holidays`
FROM
`{?_MYSQL_PREFIX?}_user_holidays` AS `h`
`d`.`holiday_active`='Y'
" . runFilterChain('user_exclusion_sql', ' '),
__FILE__, __LINE__);
- list($holiday) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ list($holiday) = sqlFetchRow($result);
+ sqlFreeResult($result);
if (empty($holiday)) $holiday = '0';
$data = array(
'lang' => '{--MEDIA_HOLIDAY_COUNT--}',
if (isExtensionActive('transfer')) {
// Statistics for points transfers
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
COUNT(`t`.`id`) AS `cnt`,
SUM(`t`.`points`) AS `points`
FROM
`t`.`userid`=`d`.`userid`
" . runFilterChain('user_exclusion_sql', ''),
__FILE__, __LINE__);
- list($count_in, $points_in) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ list($count_in, $points_in) = sqlFetchRow($result);
+ sqlFreeResult($result);
if (empty($count_in)) $count_in = '0';
if (empty($points_in)) $points_in = '0';
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
COUNT(`t`.`id`) AS `cnt`, SUM(`t`.`points`) AS `points`
FROM
`{?_MYSQL_PREFIX?}_user_transfers_out` AS `t`
`t`.`userid`=`d`.`userid`
" . runFilterChain('user_exclusion_sql', ''),
__FILE__, __LINE__);
- list($count_out, $points_out) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ list($count_out, $points_out) = sqlFetchRow($result);
+ sqlFreeResult($result);
if (empty($count_out)) $count_out = '0';
if (empty($points_out)) $points_out = '0';
$ADD = " AND `d`.`is_active`='Y'";
if (isAdmin()) $ADD = '';
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`d`.`id`,
`d`.`admin_id`,
`a`.`login`,
`d`.`end_time` ASC
LIMIT 1", __FILE__, __LINE__);
-if (SQL_NUMROWS($result) == 1) {
+if (sqlNumRows($result) == 1) {
// Found some (normally one...
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
$expired = FALSE;
if (($content['end_time'] < time()) && (getTotalConfirmedUser() >= $content['min_users']) && (getTotalRallyeWinners($content['id']) >= $content['min_prices'])) {
// Other values
foreach (array('gender', 'surname', 'family', 'street_nr', 'city', 'email') as $entry) {
- $content[$entry] = SQL_ESCAPE(postRequestElement($entry));
+ $content[$entry] = sqlEscapeString(postRequestElement($entry));
} // END - foreach
// Set must-fillout fields
$OUT_PAY = '';
// Load all sponsor actions
-$result_act = SQL_QUERY("SELECT
+$result_act = sqlQuery("SELECT
`m`.`title` AS `conv_title`,
`c`.`conv_rate`,
`c`.`conv_name`
ORDER BY
`m`.`sort` ASC", __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result_act)) {
+if (!ifSqlHasZeroNums($result_act)) {
// Load all actions
- while ($content = SQL_FETCHARRAY($result_act)) {
+ while ($content = sqlFetchArray($result_act)) {
// Load row template and switch color
$OUT_ACT .= loadTemplate('guest_sponsor_act_row', TRUE, $content);
} // END - while
// Check for pay types
- $result_pay = SQL_QUERY('SELECT `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` ORDER BY `pay_name` ASC', __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_pay)) {
+ $result_pay = sqlQuery('SELECT `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` ORDER BY `pay_name` ASC', __FILE__, __LINE__);
+ if (!ifSqlHasZeroNums($result_pay)) {
// Load all pay types
- while ($content = SQL_FETCHARRAY($result_pay)) {
+ while ($content = sqlFetchArray($result_pay)) {
// Load row template and switch color
$OUT_PAY .= loadTemplate('guest_sponsor_pay_row', TRUE, $content);
} // END - while
}
// Free memory
-SQL_FREERESULT($result_act);
-SQL_FREERESULT($result_pay);
+sqlFreeResult($result_act);
+sqlFreeResult($result_pay);
// Transfer rows to an array
$content = array(
// Check if hash for confirmation of email address is given...
if (isGetRequestElementSet('hash')) {
// Lookup sponsor
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`, `status`, `gender`, `surname`, `family`,
`company`, `position`, `tax_ident`,
`street_nr1`, `street_nr2`, `country`, `zip`, `city`, `email`, `phone`, `fax`, `cell`,
`status`='EMAIL'
)
LIMIT 1", array(getRequestElement('hash')), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Sponsor found, load his data...
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Unconfirmed account or changed email address?
if ($data['status'] == 'UNCONFIRMED') {
// Set account to pending
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_sponsor_data`
SET
`status`='PENDING',
), __FILE__, __LINE__);
// Check on success
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Prepare mail and send it to the sponsor
$message = loadEmailTemplate('sponsor_pending', $data);
sendEmail($data['email'], '{--SPONSOR_ACCOUNT_PENDING_SUBJECT--}', $message);
}
} elseif ($data['status'] == 'EMAIL') {
// Changed email adress need to be confirmed
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_sponsor_data`
SET
`status`='CONFIRMED',
array(bigintval($data['id']), getRequestElement('hash')), __FILE__, __LINE__);
// Check on success
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Sponsor account is unlocked again
displayMessage('{--SPONSOR_ACCOUNT_IS_CONFIRMED_AGAIN--}');
} else {
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} elseif ($mode == 'activate') {
// Send activation link again
if (isFormSent('login')) {
if (isFormSent('login')) {
// Check email
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`hash`,
`status`,
array(postRequestElement('email')), __FILE__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Unconfirmed sponsor account found so let's load the requested data
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Translate some data
$data['sponsor_created'] = generateDateTime($data['sponsor_created']);
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Load form
loadTemplate('guest_sponsor_activate');
if (isFormSent('login')) {
// Check email
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`hash`,
`remote_addr`,
array(postRequestElement('email'), bigintval(postRequestElement('id'))), __FILE__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Unconfirmed sponsor account found so let's load the requested data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Generate password/translate some data
$content['password'] = generatePassword();
sendEmail(postRequestElement('email'), '{--SPONSOR_LOST_PASSWORD_SUBJECT--}', $message_sponsor);
// Update password
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_sponsor_data`
SET
`password`='%s'
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Load form
loadTemplate('guest_sponsor_lost');
}
} elseif (isFormSent('login')) {
// Check status and login data ...
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`status`
FROM
`{?_MYSQL_PREFIX?}_sponsor_data`
md5(postRequestElement('password'))
), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Okay, first login data check passed, now has he/she an approved (CONFIRMED) account?
- list($status) = SQL_FETCHROW($result);
+ list($status) = sqlFetchRow($result);
if ($status == 'CONFIRMED') {
// Is confirmed so both is fine and we can continue with login procedure
$login = ((setSession('sponsor_id' , bigintval(postRequestElement('sponsor_id')))) &&
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Login formular and other links
loadTemplate('guest_sponsor_login');
);
// Calulate points
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
(`pay_rate` * `pay_min_count`) AS `points`,
`pay_min_count`,
`pay_currency`
`id`=%s
LIMIT 1',
array(postRequestElement('pay_type')), __FILE__, __LINE__);
- list($points, $pay, $curr) = SQL_FETCHROW($result);
+ list($points, $pay, $curr) = sqlFetchRow($result);
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Add points to array
postRequestElement('points_amount', $points);
displayMessage($message);
} else {
// Check for payment types
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`pay_name`,
`pay_rate`,
`pay_min_count`
FROM
`{?_MYSQL_PREFIX?}_sponsor_paytypes`
-ORDER BY
+ORDER BY
`pay_name` ASC', __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all types...
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare content for output
$content['res'] = translateComma($content['pay_rate'] * $content['pay_min_count']);
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// [EOF]
default:
// Unsupported mode
- reportBug(__FILE__, __LINE__, sprintf("Unsupported mode <span class=\"data\">%s</span> detected.", SQL_ESCAPE($do)));
+ reportBug(__FILE__, __LINE__, sprintf("Unsupported mode <span class=\"data\">%s</span> detected.", sqlEscapeString($do)));
break;
} // END - switch
} // END - for
// Members in categories
- $result = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `visible`='Y' ORDER BY `id` ASC", __FILE__, __LINE__);
+ $result = sqlQuery("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `visible`='Y' ORDER BY `id` ASC", __FILE__, __LINE__);
// Load categories first
$cats = array(); $cat_cnt = array();
// @TODO This can be somehow rewritten
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Simple...
$cats[$content['id']] = $content['cat'];
} // END - while
// Prepare data for the template
$content['total_users'] = ($male + $female);
- $content['unconfirmed'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status` != 'CONFIRMED'" . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__));
+ $content['unconfirmed'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status` != 'CONFIRMED'" . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__));
$content['total_males'] = $male;
$content['total_females'] = $female;
- $content['tmem_count'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `last_online` >= {?START_TDAY?}" . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'"), __FILE__, __LINE__));
- $content['ymem_count'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `last_online` >= {?START_YDAY?} AND `last_online` < {?START_TDAY?}" . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'"), __FILE__, __LINE__));
- $content['treg_count'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= {?START_TDAY?}" . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__));
- $content['yreg_count'] = SQL_NUMROWS(SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= {?START_YDAY?} AND `joined` < {?START_TDAY?}" . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__));
+ $content['tmem_count'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `last_online` >= {?START_TDAY?}" . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'"), __FILE__, __LINE__));
+ $content['ymem_count'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `last_online` >= {?START_YDAY?} AND `last_online` < {?START_TDAY?}" . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'"), __FILE__, __LINE__));
+ $content['treg_count'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= {?START_TDAY?}" . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__));
+ $content['yreg_count'] = sqlNumRows(sqlQuery("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `joined` >= {?START_YDAY?} AND `joined` < {?START_TDAY?}" . runFilterChain('user_exclusion_sql', ' '), __FILE__, __LINE__));
$content['lmode'] = $lmode;
$content['ltitle'] = $ltitle;
if (isAdmin()) $AND = '';
// Query for guest and member menus
- $guest_t10 = SQL_QUERY('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__);
- $mem_t10 = SQL_QUERY('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__);
- $OUT = '';
+ $guest_t10 = sqlQuery('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__);
+ $mem_t10 = sqlQuery('SELECT `counter`, `title` FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `counter` > 0' . $AND . ' ORDER BY `counter` DESC LIMIT 0,10', __FILE__, __LINE__);
+ $OUT = '';
- if (!SQL_HASZERONUMS($guest_t10)) {
+ if (!ifSqlHasZeroNums($guest_t10)) {
// Guest clicks
$OUT .= loadTemplate('guest_stats_header', TRUE, '{--GUEST_TOP_GUEST_STATS--}');
- while ($content = SQL_FETCHARRAY($guest_t10)) {
+ while ($content = sqlFetchArray($guest_t10)) {
// Load row template
$OUT .= loadTemplate('guest_stats_row', TRUE, $content);
} // END - while
} // END - if
- if (!SQL_HASZERONUMS($mem_t10)) {
+ if (!ifSqlHasZeroNums($mem_t10)) {
// Member clicks
$OUT .= loadTemplate('guest_stats_header', TRUE, '{--GUEST_TOP_MEMBER_STATS--}');
- while ($content = SQL_FETCHARRAY($mem_t10)) {
+ while ($content = sqlFetchArray($mem_t10)) {
// Load row template
$OUT .= loadTemplate('guest_stats_row', TRUE, $content);
} // END - while
$rows = array();
// TOP logins
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`userid`,
`last_online`
FROM
LIMIT {?top10_max?}", __FILE__, __LINE__);
$OUT = ''; $count = 1;
-while ($content = SQL_FETCHARRAY($result)) {
+while ($content = sqlFetchArray($result)) {
// Prepare data for template
$content = array(
'count' => $count,
$rows['logins_out'] = $OUT;
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// TOP earners
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`d`.`userid`,
SUM(`p`.`points` + `p`.`locked_points`) AS `points`,
`d`.`last_online`
LIMIT {?top10_max?}", __FILE__, __LINE__);
$OUT = ''; $count = 1;
-while ($content = SQL_FETCHARRAY($result)) {
+while ($content = sqlFetchArray($result)) {
// Prepare data for template
$content['count'] = $count;
$content['last_online'] = generateDateTime($content['last_online'], '3');
$rows['points_out'] = $OUT;
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// TOP referral "hunter"
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`d`.`userid`,
SUM(`r`.`counter`) AS `refs`,
`d`.`last_online`
LIMIT {?top10_max?}", __FILE__, __LINE__);
$OUT = ''; $count = 1;
-while ($content = SQL_FETCHARRAY($result)) {
+while ($content = sqlFetchArray($result)) {
// Prepare data for template
$content = array(
'count' => $count,
$rows['referrals_out'] = $OUT;
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Load final template
loadTemplate('guest_top10', FALSE, $rows);
} // END - if
// Let's check if there are some points left we can pay...
-$result = SQL_QUERY_ESC("SELECT
+$result = sqlQueryEscaped("SELECT
`userid`,
`beg_points`,
`last_online`
// Reset temporary variable and check for users
$OUT = '';
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Load our winners...
$count = 1;
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare data for the template
$content['count'] = $count;
$content['last_online'] = generateDateTime($content['last_online'], '2');
$content['rows'] = $OUT;
// Free memory
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Load final template
loadTemplate('member_list_beg', FALSE, $content);
} // END - if
// Let's check if there are some points left we can 'pay'...
-$result = SQL_QUERY_ESC("SELECT
+$result = sqlQueryEscaped("SELECT
`userid`,
".$pointsColumns." AS `points`,
`last_online`
// Reset temporary variable and check for users
$OUT = '';
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Load our winners...
$count = 1;
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare data for the template
$content['count'] = $count;
$content['last_online'] = generateDateTime($content['last_online'], '2');
}
// Free memory
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Prepare content array
$content['rows'] = $OUT;
// Is the coupon code entered?
if (isPostRequestElementSet('coupon_code')) {
// Search for the coupon
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`c`.`coupon_id`,
`c`.`userid`,
`c`.`coupon_code`,
), __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Run pre-filter
$content = runFilterChain('pre_cash_coupon', $content);
// Mark it as "cashed"
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_coupons`
SET
`cashed_on`=NOW(),
), __FILE__, __LINE__);
// Does it work?
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// Abort it here, it always must work
reportBug(__FILE__, __LINE__, 'User coupon cannot be updated! coupon_id=' . $content['coupon_id']);
} // END - if
// Update count as well
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_coupon_data` SET `total_cashed`=`total_cashed`+1 WHERE `id`=%s AND `total_cashed` < `total_created` LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_coupon_data` SET `total_cashed`=`total_cashed`+1 WHERE `id`=%s AND `total_cashed` < `total_created` LIMIT 1",
array(bigintval($content['coupon_id'])), __FILE__, __LINE__);
// Does it work?
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// Abort it here, it always must work
reportBug(__FILE__, __LINE__, 'Coupon data cannot be updated! coupon_id=' . $content['coupon_id']);
} // END - if
}
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No code entered!
displayMessage('{--MEMBER_COUPON_CODE_EMPTY--}');
}
// And change it in the database
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receiving_coupons`='%s' WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receiving_coupons`='%s' WHERE `userid`=%s LIMIT 1",
array($newStatus, getMemberId()), __FILE__, __LINE__);
// Did something change?
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Records have been updated
displayMessage($message);
} else {
if (isAdmin()) $whereStatement = '';
// Get all categories
-$result = SQL_QUERY('SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats`' . $whereStatement . ' ORDER BY `sort` ASC', __FILE__, __LINE__);
+$result = sqlQuery('SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats`' . $whereStatement . ' ORDER BY `sort` ASC', __FILE__, __LINE__);
// Are there entries?
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
$LEAST = FALSE;
if (isFormSent()) {
$count = '0';
if ($joined != 'Y') $count++;
} // END - foreach
- if ((SQL_NUMROWS($result) - $count) < getLeastCats()) {
+ if ((sqlNumRows($result) - $count) < getLeastCats()) {
unsetPostRequestElement('ok');
$LEAST = TRUE;
} // END - if
// Load all categories of this member
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Default he has not joined, add color switch
$content['jn'] = ' checked="checked"';
$content['jy'] = '';
} // END - while
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load footer template
loadTemplate('member_cats', FALSE, $OUT);
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
} // END - if
// Check for all earnings
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`d`.`earning_id`,
`d`.`earning_group`,
`d`.`earning_provider`
`d`.`earning_sorting` ASC', __FILE__, __LINE__);
// Are there entries?
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Init output
$OUT = '';
// List all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Load user_earning data
- $result2 = SQL_QUERY_ESC('SELECT
+ $result2 = sqlQueryEscaped('SELECT
`u`.`earning_active`,
UNIX_TIMESTAMP(`u`.`earning_added`) AS `earning_added`,
UNIX_TIMESTAMP(`u`.`earning_canceled`) AS `earning_canceled`,
), __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result2) == 1) {
+ if (sqlNumRows($result2) == 1) {
// Load it
- $content = merge_array($content, SQL_FETCHARRAY($result2));
+ $content = merge_array($content, sqlFetchArray($result2));
} // END - if
// Free result
- SQL_FREERESULT($result2);
+ sqlFreeResult($result2);
// Is there user_earning data available?
if (!isset($content['earning_active'])) {
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
$content = array();
// Check for running mail orders in pool
-$result1 = SQL_QUERY_ESC("SELECT
+$result1 = sqlQueryEscaped("SELECT
`timestamp`
FROM
`{?_MYSQL_PREFIX?}_pool`
LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
// Check for sent mail orders in stats
-$result2 = SQL_QUERY_ESC("SELECT
+$result2 = sqlQueryEscaped("SELECT
`timestamp_ordered`
FROM
`{?_MYSQL_PREFIX?}_user_stats`
`timestamp_ordered` DESC
LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
-if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) {
+if ((sqlNumRows($result1) == 1) || (sqlNumRows($result2) == 1)) {
// Mail order found
- $content = merge_array($content, SQL_FETCHARRAY($result1));
- $content = merge_array($content, SQL_FETCHARRAY($result2));
+ $content = merge_array($content, sqlFetchArray($result1));
+ $content = merge_array($content, sqlFetchArray($result2));
// Fix missing entries
if (empty($content['timestamp'])) $content['timestamp'] = '0';
} // END - if
// Free memory
-SQL_FREERESULT($result1);
-SQL_FREERESULT($result2);
+sqlFreeResult($result1);
+sqlFreeResult($result2);
if (isFormSent()) {
// Check holiday request...
unsetPostRequestElement('ok');
} else {
// Everything went okay so let's store his request and send mails
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_holidays` (`userid`, `holiday_start`, `holiday_end`, `comments`) VALUES ('%s','%s','%s','%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_holidays` (`userid`, `holiday_start`, `holiday_end`, `comments`) VALUES ('%s','%s','%s','%s')",
array(
getMemberId(),
$content['holiday_start'],
), __FILE__, __LINE__);
// Activate holiday system
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`holiday_active`='N',
// Holiday shall be ended now
if (isPostRequestElementSet('stop')) {
// Okay, end the holiday here...
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`holiday_active`,
`holiday_activated`
FROM
LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Merge arrays
- $content = merge_array($content, SQL_FETCHARRAY($result));
+ $content = merge_array($content, sqlFetchArray($result));
if (($content['holiday_active'] == 'Y') && (($content['holiday_activated'] + getHolidayLock()) < time())) {
// Load data
- $result2 = SQL_QUERY_ESC("SELECT
+ $result2 = sqlQueryEscaped("SELECT
`holiday_start`,
`holiday_end`
FROM
WHERE
`userid`=%s
LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
- if (SQL_NUMROWS($result2) == 1) {
+ if (sqlNumRows($result2) == 1) {
// Data was found so merge it
- $content = merge_array($content, SQL_FETCHARRAY($result2));
+ $content = merge_array($content, sqlFetchArray($result2));
// Prepare it for the template
$content['start'] = generateDateTime($content['holiday_start'], 3);
$content['end'] = generateDateTime($content['holiday_end'] , 3);
// Deactivate it now
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`holiday_active`='N',
array(getMemberId()), __FILE__, __LINE__);
// Remove entry
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM
`{?_MYSQL_PREFIX?}_user_holidays`
WHERE
`userid`=%s
}
// Free result
- SQL_FREERESULT($result2);
+ sqlFreeResult($result2);
} elseif ($content['holiday_active'] == 'Y') {
// To fast!
displayMessage('{--MEMBER_HOLIDAY_LOCKED--}');
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// If something is wrong or link in menu is just clicked display form
if ((!isFormSent()) && (!isPostRequestElementSet('stop'))) {
// Check if user is in holiday...
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`holiday_active`,
`holiday_activated`
FROM
WHERE
`userid`=%s
LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
- $content = SQL_FETCHARRAY($result);
- SQL_FREERESULT($result);
+ $content = sqlFetchArray($result);
+ sqlFreeResult($result);
// Check for lock
if (($content['holiday_activated'] + getHolidayLock()) < time()) {
switch ($content['holiday_active']) {
case 'Y': // Display deactivation form
// Load starting and ending date
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`holiday_start`,
`holiday_end`
FROM
WHERE
`userid`=%s
LIMIT 1", array(getMemberId()), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Data was found so merge it
- $content = merge_array($content, SQL_FETCHARRAY($result));
+ $content = merge_array($content, sqlFetchArray($result));
// Prepare it for the template
$content['start'] = generateDateTime($content['holiday_start'] , 3);
loadTemplate('member_holiday_deactivate', FALSE, $content);
} else {
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remove entry and reload URL
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`holiday_active`='N'
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
break;
case 'N': // Display activation form
// Class was found and loaded
if (isFormSent()) {
// Save settings
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `html`='%s' WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `html`='%s' WHERE `userid`=%s LIMIT 1",
array(postRequestElement('html'), getMemberId()), __FILE__, __LINE__);
displayMessage('{--MEMBER_SETTINGS_SAVED--}');
} else {
} // END - if
// Check if the user has cashed coupons
-$result = SQL_QUERY_ESC("SELECT
+$result = sqlQueryEscaped("SELECT
UNIX_TIMESTAMP(`u`.`cashed_on`) AS `cashed_on`,
UNIX_TIMESTAMP(`d`.`coupon_created`) AS `coupon_created`,
UNIX_TIMESTAMP(`d`.`coupon_expired`) AS `coupon_expired`,
`u`.`cashed_on` DESC", array(getMemberId()), __FILE__, __LINE__);
// Are there entries?
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Init variable
$OUT = '';
// Load all rows
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Translate all timestamps
$content['cashed_on'] = generateDateTime($content['cashed_on'] , '2');
$content['coupon_created'] = generateDateTime($content['coupon_created'], '2');
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
case 'edit': // Edit data
if (isExtensionActive('country', TRUE)) {
// New way
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`surname`,
`family`,
`street_nr`,
array(getMemberId()), __FILE__, __LINE__);
} else {
// Old way
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`surname`,
`family`,
`street_nr`,
}
// Get line
- $content = merge_array($content, SQL_FETCHARRAY($result));
+ $content = merge_array($content, sqlFetchArray($result));
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
$content['update_check'] = $content['last_update'] + getProfileLock();
// Update member's profile
if (isExtensionActive('country')) {
// New way
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`gender`='%s',
), __FILE__, __LINE__);
} else {
// Old way
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`gender`='%s',
}
// Did something change?
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// Get all modes ...
$modes = explode(';', $mode);
break;
case 'notify': // Switch off notfication
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `notified`='N',`last_update`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `notified`='N',`last_update`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1",
array(getMemberId()), __FILE__, __LINE__);
$url = 'modules.php?module=login&what=mydata&code=' . getCode('PROFILE_UPDATED');
break;
$content = '{--MEMBER_NICKNAME_ALREADY_IN_USE--}';
// Look for nickname in database (we only need just one entry so don't worry about the "LIMIT 1" !)
- $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `nickname`='%s' AND `userid` != %s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `nickname`='%s' AND `userid` != %s LIMIT 1",
array(
postRequestElement('nickname'),
getMemberId()
), __FILE__, __LINE__);
// Is it not in use?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// Prepare array
$filterData = array(
'history_subject' => 'NICKNAME_CHANGED',
runFilterChain('add_history_entry', $filterData);
// Nickname not in use, so set it now
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `nickname`='%s' WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `nickname`='%s' WHERE `userid`=%s LIMIT 1",
array(
postRequestElement('nickname'),
getMemberId()
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
displayMessage($content);
//
// First we would like to store the data and get it's pool position back...
// @TODO Try to move out url_tlock to a filter for extra SQL statements
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`data_type`
FROM
postRequestElement('url')
), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load id and mail type
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
if ($data['data_type'] == 'TEMP') {
/*
// Still no error?
if (empty($data['url'])) {
// Check for userids
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`c`.`userid`
FROM
`{?_MYSQL_PREFIX?}_user_cats` AS `c`
), __FILE__, __LINE__);
// Are there still receivers left?
- if (SQL_NUMROWS($result) >= postRequestElement('receiver')) {
+ if (sqlNumRows($result) >= postRequestElement('receiver')) {
// Load receivers from database
$TEST = array(); $count = '0';
- while ($holidayContent = SQL_FETCHARRAY($result)) {
+ while ($holidayContent = sqlFetchArray($result)) {
if (isExtensionInstalledAndNewer('holiday', '0.1.3')) {
// Check for his holiday status
- $result_holiday = SQL_QUERY_ESC("SELECT
+ $result_holiday = sqlQueryEscaped("SELECT
`id`
FROM
`{?_MYSQL_PREFIX?}_user_holidays`
`holiday_end` > UNIX_TIMESTAMP()
LIMIT 1",
array($holidayContent['userid']), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_holiday) == 1) {
+ if (sqlNumRows($result_holiday) == 1) {
// Exclude user who are in holiday
$holidayContent['userid'] = '0';
} // END - if
// Free memory
- SQL_FREERESULT($result_holiday);
+ sqlFreeResult($result_holiday);
} // END - if
if (isValidId($holidayContent['userid'])) {
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Implode array into string for the sending pool
$receiver = implode($TEST, ';');
$content['target_send'] = count($TEST);
// Update receiver list
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receive_mails`=`receive_mails`-1 WHERE `userid` IN (%s) LIMIT %s",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receive_mails`=`receive_mails`-1 WHERE `userid` IN (%s) LIMIT %s",
array(
convertReceivers($receiver),
bigintval($content['target_send'])
if (isAdmin()) $whereStatement = '';
// Display order form
- $result_cats = SQL_QUERY('SELECT
+ $result_cats = sqlQuery('SELECT
`id`,
`cat`
FROM
`sort` ASC', __FILE__, __LINE__);
// Some categories found?
- if (!SQL_HASZERONUMS($result_cats)) {
+ if (!ifSqlHasZeroNums($result_cats)) {
// Enought points left?
if ($totalPoints > 0) {
// Initialize array...
} // END - if
// ... and begin loading stuff
- while ($categoriesContent = SQL_FETCHARRAY($result_cats)) {
+ while ($categoriesContent = sqlFetchArray($result_cats)) {
$categories['id'][] = bigintval($categoriesContent['id']);
array_push($categories['name'], $categoriesContent['cat']);
// Select users in current category
- $result_userids = SQL_QUERY_ESC('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `cat_id`=%s AND `userid` != %s ORDER BY `userid` ASC',
+ $result_userids = sqlQueryEscaped('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `cat_id`=%s AND `userid` != %s ORDER BY `userid` ASC',
array(bigintval($categoriesContent['id']), getMemberId()), __FILE__, __LINE__);
$userid_cnt = '0';
- while (list($userid) = SQL_FETCHROW($result_userids)) {
+ while (list($userid) = sqlFetchRow($result_userids)) {
// Check for holiday system
$isHolidayActive = FALSE;
if (isExtensionInstalledAndNewer('holiday', '0.1.3')) {
// Check user's holiday status
- $result_holiday = SQL_QUERY_ESC("SELECT
+ $result_holiday = sqlQueryEscaped("SELECT
COUNT(`d`.`userid`) AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_user_data` AS `d`
array(bigintval($userid)), __FILE__, __LINE__);
// Fetch entry
- list($count) = SQL_FETCHROW($result_holiday);
+ list($count) = sqlFetchRow($result_holiday);
// Free memory
- SQL_FREERESULT($result_holiday);
+ sqlFreeResult($result_holiday);
// Is holiday is active?
$isHolidayActive = ($count == 1);
if ($isHolidayActive === FALSE) {
// Check if the user want's to receive mails?
- $result_ver = SQL_QUERY_ESC("SELECT `zip` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s" . $HTML . " AND `receive_mails` > 0 AND `status`='CONFIRMED' LIMIT 1",
+ $result_ver = sqlQueryEscaped("SELECT `zip` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s" . $HTML . " AND `receive_mails` > 0 AND `status`='CONFIRMED' LIMIT 1",
array(bigintval($userid)), __FILE__, __LINE__);
- if ((SQL_NUMROWS($result_ver) == 1) && (isPostRequestElementSet('zip')) && (isOrderMultiPageEnabled())) {
+ if ((sqlNumRows($result_ver) == 1) && (isPostRequestElementSet('zip')) && (isOrderMultiPageEnabled())) {
// Get zip code
- list($zip) = SQL_FETCHROW($result_ver);
+ list($zip) = sqlFetchRow($result_ver);
if (substr($zip, 0, strlen(postRequestElement('zip'))) == postRequestElement('zip')) {
// Ok, ZIP code part is found
$userid_cnt++;
} // END - if
} else {
// Count numbers up!
- $userid_cnt += SQL_NUMROWS($result_ver);
+ $userid_cnt += sqlNumRows($result_ver);
}
// Free result
- SQL_FREERESULT($result_ver);
+ sqlFreeResult($result_ver);
} // END - if
} // END - while
// Free memory
- SQL_FREERESULT($result_userids);
+ sqlFreeResult($result_userids);
array_push($categories['userids'], $userid_cnt);
} // END - while
// Free memory
- SQL_FREERESULT($result_cats);
+ sqlFreeResult($result_cats);
// Now we need to load the mail types...
- $result = SQL_QUERY("SELECT `id`, `price`, `payment`, `mail_title` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `price` > 0 AND `payment` > 0 ORDER BY `payment` ASC", __FILE__, __LINE__);
+ $result = sqlQuery("SELECT `id`, `price`, `payment`, `mail_title` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `price` > 0 AND `payment` > 0 ORDER BY `payment` ASC", __FILE__, __LINE__);
$payments = array();
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Is the error code set?
if (isGetRequestElementSet('code')) {
// Display error message
} // END - if
// Load all email types...
- while ($payment = SQL_FETCHARRAY($result)) {
+ while ($payment = sqlFetchArray($result)) {
array_push($payments, $payment);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Output user's points
$content['total_points'] = $totalPoints;
$target = '';
// Check if we already have an order placed and make it editable
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`subject`,
`text`,
`payment_id`,
LIMIT 1",
array(getMemberId()), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Old order found
- $content = merge_array($content, SQL_FETCHARRAY($result));
+ $content = merge_array($content, sqlFetchArray($result));
// Fix max receivers when it is too much
if ((isset($categories['userids'][$content['cat_id']])) && ($content['target_send'] > $categories['userids'][$content['cat_id']])) {
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
if ((isPostRequestElementSet('data')) || ((getOrderMultiPage() != 'Y') && ((!isAdmin()) && (!isExtensionActive('html_mail'))))) {
// Pre-output categories
if (!isGetRequestElementSet('payout')) {
// Load payout types
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`id`,
`type`,
`rate`,
ORDER BY
`type` ASC",
array($payoutPoints), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Check for his payouts
- $result_payouts = SQL_QUERY_ESC('SELECT
+ $result_payouts = sqlQueryEscaped('SELECT
`p`.`id`,
`p`.`payout_total`,
`p`.`target_account`,
ORDER BY
`p`.`payout_timestamp` DESC',
array(getMemberId()), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_payouts)) {
+ if (!ifSqlHasZeroNums($result_payouts)) {
// List all his requests
$OUT = '';
- while ($content = SQL_FETCHARRAY($result_payouts)) {
+ while ($content = sqlFetchArray($result_payouts)) {
// Nothing entered must be secured in member/what-payputs.php !
if ($content['allow_url'] == 'Y') {
// Banner/Textlink views/clicks request
} // END - if
// Free memory
- SQL_FREERESULT($result_payouts);
+ sqlFreeResult($result_payouts);
// Output payout list
outputPayoutList($payoutPoints);
}
} else {
// Chedk if he can get paid by selected type
- $result = SQL_QUERY_ESC("SELECT `type`, `rate`, `min_points`, `allow_url` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `type`, `rate`, `min_points`, `allow_url` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
array(bigintval(getRequestElement('payout'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// id is valid so load the data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Calculate maximum value
$max = round($payoutPoints * $content['rate'] - 0.5);
// Add entry to his tranfer history
if ($content['allow_url'] == 'Y') {
// Banner/textlink ordered
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_payouts` (`userid`, `payout_total`, `payout_id`, `payout_timestamp`, `status`, `target_url`, `link_text`, `banner_url`)
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_payouts` (`userid`, `payout_total`, `payout_id`, `payout_timestamp`, `status`, `target_url`, `link_text`, `banner_url`)
VALUES (%s,%s,%s, UNIX_TIMESTAMP(), 'NEW','%s','%s','%s')",
array(
getMemberId(),
}
} else {
// e-currency payout requested
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_payouts` (`userid`, `payout_total`, `target_account`, `target_bank`, `payout_id`, `payout_timestamp`, `status`, `password`)
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_payouts` (`userid`, `payout_total`, `target_account`, `target_bank`, `payout_id`, `payout_timestamp`, `status`, `password`)
VALUES (%s,%s,%s,'%s',%s, UNIX_TIMESTAMP(), 'NEW','%s')",
array(
getMemberId(),
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// [EOF]
} // END - if
// Query for referral levels and percents
-$result_depths = SQL_QUERY('SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC', __FILE__, __LINE__);
+$result_depths = sqlQuery('SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC', __FILE__, __LINE__);
// Get total depths
-$numDepths = SQL_NUMROWS($result_depths);
+$numDepths = sqlNumRows($result_depths);
// Add many more rows for the login/turbo/ref/order bonus
// @TODO Should we rewrite this to a filter?
$OUT = '';
// Load ref levels
-while ($data = SQL_FETCHARRAY($result_depths)) {
+while ($data = sqlFetchArray($result_depths)) {
// Init points and counter here
$content['counter'] = '0';
$content['points'] = '0.00000';
} // END - if
// Load referral points
- $result_points = SQL_QUERY_ESC('SELECT
+ $result_points = sqlQueryEscaped('SELECT
' . getAllPointColumns('p.', ',') . '
`r`.`counter`
FROM
), __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result_points) == 1) {
+ if (sqlNumRows($result_points) == 1) {
// Load data
- $content = merge_array($content, SQL_FETCHARRAY($result_points));
+ $content = merge_array($content, sqlFetchArray($result_points));
// Add locked-/points
$content['part_points'] += $content['points'];
} // END - if
// Free result
- SQL_FREERESULT($result_points);
+ sqlFreeResult($result_points);
// Output row
$OUT .= loadTemplate('member_points_row', TRUE, $content);
} // END - while
// Free memory
-SQL_FREERESULT($result_depths);
+sqlFreeResult($result_depths);
// Add userid
$content['userid'] = getMemberId();
$ADD = " AND `d`.`is_active`='Y'";
if (isAdmin()) $ADD = '';
-$result = SQL_QUERY("SELECT
+$result = sqlQuery("SELECT
`d`.`id`,
`d`.`admin_id`,
`a`.`login`,
`d`.`end_time` ASC
LIMIT 1", __FILE__, __LINE__);
-if (SQL_NUMROWS($result) == 1) {
+if (sqlNumRows($result) == 1) {
// Found some (normally one...
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
$expired = FALSE;
if (($content['end_time'] < time()) && (getTotalConfirmedUser() >= $content['min_users']) && (getTotalRallyeWinners($content['id']) >= $content['min_prices'])) {
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
} // END - if
// Load all referral levels
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`r`.`level`,
`r`.`percents`
FROM
`r`.`level` ASC', __FILE__, __LINE__);
// Are there some entries? (Shall be!)
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// List all levels
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Init variables
$rows = '';
$content['counter'] = 0;
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
$whereStatement = " WHERE `visible`='Y'";
if (isAdmin()) $whereStatement = '';
-$result = SQL_QUERY('SELECT `id`, `url`, `alternate`, `counter`, `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `id` ASC', __FILE__, __LINE__);
+$result = sqlQuery('SELECT `id`, `url`, `alternate`, `counter`, `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `id` ASC', __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// List available ref banners
$OUT = '';
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
$test = str_replace(getUrl(), getPath(), $row['url']); $size = '0';
if ($test == $row['url']) {
// Download banner (I hope you keep the banner on same server???)
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Add extra content through filter
$content['extra_content'] = runFilterChain('member_reflink_extra_content');
addYouAreHereLink('member', __FILE__);
// Load all referral levels
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`level`,
`percents`
FROM
`level` ASC', __FILE__, __LINE__);
// Are there some entries? (Shall be!)
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// List all levels
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Init variables
$rows = '';
$counter = '0';
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
$main_content = array();
// Load waiting/pending orders
-$result = SQL_QUERY_ESC("SELECT
+$result = sqlQueryEscaped("SELECT
`id`,
`cat_id`,
`payment_id`,
array(getMemberId()), __FILE__, __LINE__);
// Are there mails left in pool?
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Load all orders
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare content for output
$content['timestamp'] = generateDateTime($content['timestamp'], '2');
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Load sent orders
-$result = SQL_QUERY_ESC('SELECT
+$result = sqlQueryEscaped('SELECT
`id`,
`cat_id`,
`payment_id`,
`timestamp_ordered` DESC',
array(getMemberId()), __FILE__, __LINE__);
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Mail orders are in pool so we can display them
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare data for the template
$content['timestamp_ordered'] = generateDateTime($content['timestamp_ordered'], '2');
$content['timestamp_sent'] = generateDateTime($content['timestamp_send'], '2');
}
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Load main template
loadTemplate('member_stats_pool', FALSE, $main_content);
doGenericXmlTemplateCallback('member_delete_do_user_subid');
} elseif ((isGetRequestElementSet('do')) && (isGetRequestElementSet('id'))) {
// Construct module name
- $incFile = sprintf("inc/modules/member/subid-%s.php", SQL_ESCAPE(getRequestElement('do')));
+ $incFile = sprintf("inc/modules/member/subid-%s.php", sqlEscapeString(getRequestElement('do')));
// Is the include readable and is the sub id assigned to current member?
if (!isUserSubIdAssignedToMember(getRequestElement('id'))) {
if (isPostRequestElementSet('member_theme')) {
// Save theme to member's profile
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `curr_theme`='%s' WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `curr_theme`='%s' WHERE `userid`=%s LIMIT 1",
array(
postRequestElement('member_theme'),
getMemberId()
), __FILE__, __LINE__);
// Set new theme for guests
- $newTheme = SQL_ESCAPE(postRequestElement('member_theme'));
+ $newTheme = sqlEscapeString(postRequestElement('member_theme'));
// Change to new theme
setMailerTheme($newTheme);
$valid_recipient = isValidId(postRequestElement('to_userid'));
// Re-check receivers and own personal data
- $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid` IN ('%s','%s') AND `status`='CONFIRMED'" . runFilterChain('user_exclusion_sql', ' ') . " LIMIT 2",
+ $result = sqlQueryEscaped("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid` IN ('%s','%s') AND `status`='CONFIRMED'" . runFilterChain('user_exclusion_sql', ' ') . " LIMIT 2",
array(
getMemberId(),
bigintval(postRequestElement('to_userid'))
), __FILE__, __LINE__);
// Is there two entries?
- $valid_data = (SQL_NUMROWS($result) == 2);
+ $valid_data = (sqlNumRows($result) == 2);
// Final check if all is fine
if ($valid_code && $valid_data && $valid_pass && $valid_amount && $valid_reason && $valid_recipient) {
// Let's start the transfer and load user data
- $content['sender'] = SQL_FETCHARRAY($result);
- $content['recipient'] = SQL_FETCHARRAY($result);
+ $content['sender'] = sqlFetchArray($result);
+ $content['recipient'] = sqlFetchArray($result);
// Is the nickname extension not installed?
if (!isExtensionActive('nickname')) {
$content['trans_id'] = bigintval(generateRandomCode('10', getRandomTan(), getMemberId(), postRequestElement('reason')));
// Add entries to both tables
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_in` (`userid`, `from_userid`, `points`, `reason`, `time_trans`, `trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_in` (`userid`, `from_userid`, `points`, `reason`, `time_trans`, `trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
array(
bigintval(postRequestElement('to_userid')),
getMemberId(),
postRequestElement('reason'),
$content['trans_id']
), __FILE__, __LINE__);
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_out` (`userid`, `to_userid`, `points`, `reason`, `time_trans`, `trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_out` (`userid`, `to_userid`, `points`, `reason`, `time_trans`, `trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
array(
getMemberId(),
bigintval(postRequestElement('to_userid')),
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
if (!isFormSent()) {
// Load member list
- $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED'" . runFilterChain('user_exclusion_sql', ' ') . " AND `opt_in`='Y' AND `userid` != '%s' ORDER BY `userid` ASC",
+ $result = sqlQueryEscaped("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED'" . runFilterChain('user_exclusion_sql', ' ') . " AND `opt_in`='Y' AND `userid` != '%s' ORDER BY `userid` ASC",
array(getMemberId()), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load list
$OUT = '<select name="to_userid" size="1" class="form_select">
<option value="0">{--SELECT_NONE--}</option>';
- while (list($userid) = SQL_FETCHROW($result)) {
+ while (list($userid) = sqlFetchRow($result)) {
$OUT .= ' <option value="' . $userid . '"';
if ((isPostRequestElementSet('to_userid')) && (postRequestElement('to_userid') == $userid)) {
$OUT .= ' selected="selected"';
$content['to_disabled'] = '';
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No one else is opt-in
$OUT = displayMessage('{--MEMBER_TRANSFER_NO_ONE_ELSE_OPT_IN--}', TRUE);
// Run the SQL command and set total points to zero
$totalPoints = '0';
- $result = SQL_QUERY_ESC($sql, array(getMemberId()), __FILE__, __LINE__);
+ $result = sqlQueryEscaped($sql, array(getMemberId()), __FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Rewrite points, out is subtracted
if ($type == 'OUT') {
$content['points'] = $content['points'] * -1;
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Nothing for in or out
$OUT = '<tr>
*/
// First of all create the per-user temporary table
- $result = SQL_QUERY_ESC("CREATE TEMPORARY TABLE `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (
+ $result = sqlQueryEscaped("CREATE TEMPORARY TABLE `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (
`trans_id` VARCHAR(12) NOT NULL DEFAULT '',
`party_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
) ENGINE = HEAP COMMENT = 'Temporary transfer table'", array(getMemberId()), __FILE__, __LINE__);
// Let's begin with the incoming list
- $result = SQL_QUERY_ESC("SELECT `trans_id`, `from_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `id` ASC LIMIT {?transfer_max?}",
+ $result = sqlQueryEscaped("SELECT `trans_id`, `from_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `id` ASC LIMIT {?transfer_max?}",
array(getMemberId()), __FILE__, __LINE__);
- while ($content = SQL_FETCHROW($result)) {
+ while ($content = sqlFetchRow($result)) {
array_push($content, 'IN');
$content = implode("','", $content);
- $res_temp = SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $content . "')", array(getMemberId()), __FILE__, __LINE__);
+ $res_temp = sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $content . "')", array(getMemberId()), __FILE__, __LINE__);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// As the last table transfer data from outgoing table to temporary
- $result = SQL_QUERY_ESC("SELECT `trans_id`, `to_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `id` LIMIT {?transfer_max?}",
+ $result = sqlQueryEscaped("SELECT `trans_id`, `to_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `id` LIMIT {?transfer_max?}",
array(getMemberId()), __FILE__, __LINE__);
- while ($content = SQL_FETCHROW($result)) {
+ while ($content = sqlFetchRow($result)) {
array_push($content, 'OUT');
$content = implode("','", $content);
- $res_temp = SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $content . "')", array(getMemberId()), __FILE__, __LINE__);
+ $res_temp = sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $content . "')", array(getMemberId()), __FILE__, __LINE__);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Search for entries
- $result = SQL_QUERY_ESC("SELECT `party_userid`, `trans_id`, `points`, `reason`, `time_trans`, `trans_type` FROM `{?_MYSQL_PREFIX?}_%s_transfers_tmp` ORDER BY `time_trans` DESC",
+ $result = sqlQueryEscaped("SELECT `party_userid`, `trans_id`, `points`, `reason`, `time_trans`, `trans_type` FROM `{?_MYSQL_PREFIX?}_%s_transfers_tmp` ORDER BY `time_trans` DESC",
array(getMemberId()), __FILE__, __LINE__);
$total = '0';
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Output rows
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Rewrite points if OUT
if ($content['trans_type'] == 'OUT') {
$content['points'] = $content['points'] * -1;
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// ... and add them to a constant for the template
$content['rows'] = $OUT;
$content['balance'] = '{--TRANSFER_TOTAL_BALANCE--}';
// At the end we don't need a temporary table in memory
- $result = SQL_QUERY_ESC("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_%s_transfers_tmp`", array(getMemberId()), __FILE__, __LINE__);
+ $result = sqlQueryEscaped("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_%s_transfers_tmp`", array(getMemberId()), __FILE__, __LINE__);
// Load final template
loadTemplate('member_transfer_list', FALSE, $content);
// Free some memory...
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
break;
default: // Overview page
if (isFormSent()) {
// Save settings
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `opt_in`='%s' WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `opt_in`='%s' WHERE `userid`=%s LIMIT 1",
array(postRequestElement('opt_in'), getMemberId()), __FILE__, __LINE__);
// "Settings saved..."
} // END - switch
// Check for latest out-transfers
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`time_trans`
FROM
`{?_MYSQL_PREFIX?}_user_transfers_out`
), __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load newest transaction
- list($newest) = SQL_FETCHROW($result);
+ list($newest) = sqlFetchRow($result);
$content['settings'] = '{%message,MEMBER_TRANSFER_LATEST_IS=' . generateDateTime($newest, '3') . '%}';
} else {
// Load template
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
loadTemplate('member_transfer_overview', FALSE, $content);
// Shall we display a mail?
if ((isGetRequestElementSet('bonusid')) && (isExtensionActive('bonus'))) {
// Display bonus mail by loading it's full data
- $result_data = SQL_QUERY_ESC('SELECT
+ $result_data = sqlQueryEscaped('SELECT
`id`,
`subject`,
`timestamp`,
array(bigintval(getRequestElement('bonusid'))), __FILE__, __LINE__);
// Load data
- $content = SQL_FETCHARRAY($result_data);
+ $content = sqlFetchArray($result_data);
// Translate some data
$content['timestamp'] = generateDateTime($content['timestamp'], '2');
loadTemplate('member_mail_bonus_' . strtolower($content['data_type']), FALSE, $content);
// Free result
- SQL_FREERESULT($result_data);
+ sqlFreeResult($result_data);
} elseif (isGetRequestElementSet('mailid')) {
// Display regular member mail by loading its full data
- $result_data = SQL_QUERY_ESC("SELECT
+ $result_data = sqlQueryEscaped("SELECT
`id` AS `stats_id`,
`pool_id`,
`subject`,
array(bigintval(getRequestElement('mailid'))), __FILE__, __LINE__);
// Load data
- $content = SQL_FETCHARRAY($result_data);
+ $content = sqlFetchArray($result_data);
$content = merge_array($content, getPoolDataFromId($content['pool_id']));
// Translate some data
loadTemplate('member_mail_normal_' . strtolower($content['data_type']), FALSE, $content);
// Free result
- SQL_FREERESULT($result_data);
+ sqlFreeResult($result_data);
}
if (isExtensionActive('bonus')) {
// Load bonus id
- $result = SQL_QUERY_ESC("SELECT `stats_id`, `bonus_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `bonus_id` DESC, stats_id DESC",
+ $result = sqlQueryEscaped("SELECT `stats_id`, `bonus_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `bonus_id` DESC, stats_id DESC",
array(getMemberId()), __FILE__, __LINE__);
} else {
// Don't load bonus id if ext-bonus is not installed
- $result = SQL_QUERY_ESC("SELECT `stats_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `stats_id` DESC",
+ $result = sqlQueryEscaped("SELECT `stats_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `stats_id` DESC",
array(getMemberId()), __FILE__, __LINE__);
}
// Mails left for confirmation?
-if (!SQL_HASZERONUMS($result)) {
+if (!ifSqlHasZeroNums($result)) {
// Please confirm these mails!
$sum = '0'; $OUT = '';
$content = array();
// @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Load data from stats table...
$cat = '';
$result_data = FALSE;
$data = $row['stats_id'] . '/' . $row['bonus_id'] . '/' . $row['link_type'];
switch ($row['link_type']) {
case 'NORMAL':
- $result_data = SQL_QUERY_ESC("SELECT
+ $result_data = sqlQueryEscaped("SELECT
`s`.`subject`,
`s`.`timestamp_ordered` AS `timestamp`,
`s`.`cat_id`,
break;
case 'BONUS':
- $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp`, `cat_id`, `points`, NULL FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ $result_data = sqlQueryEscaped("SELECT `subject`, `timestamp`, `cat_id`, `points`, NULL FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
array(bigintval($row['bonus_id'])), __FILE__, __LINE__);
$row['link_type'] = 'bonusid';
$data = $row['bonus_id'];
} // END - switch
// Data found to this mail?
- if ((SQL_NUMROWS($result_data) == 1) && (($row['link_type'] == 'mailid') || ($row['link_type'] == 'bonusid'))) {
+ if ((sqlNumRows($result_data) == 1) && (($row['link_type'] == 'mailid') || ($row['link_type'] == 'bonusid'))) {
// Mail was found
- $rowData = SQL_FETCHARRAY($result_data);
+ $rowData = sqlFetchArray($result_data);
// Subject line found?
if (empty($rowData['subject'])) {
}
// Free result
- SQL_FREERESULT($result_data);
+ sqlFreeResult($result_data);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remember total points
$content['total_points'] = $sum;
setGetRequestElement('do', 'list');
// And load all rows!
- $result = SQL_QUERY_ESC("SELECT `id`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type` FROM `{?_MYSQL_PREFIX?}_user_wernis` WHERE `userid`=%s ORDER BY `wernis_timestamp` DESC",
+ $result = sqlQueryEscaped("SELECT `id`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type` FROM `{?_MYSQL_PREFIX?}_user_wernis` WHERE `userid`=%s ORDER BY `wernis_timestamp` DESC",
array(getMemberId()), __FILE__, __LINE__);
// Load all rows
$content['rows'] = '';
- while ($data = SQL_FETCHARRAY($result)) {
+ while ($data = sqlFetchArray($result)) {
// Prepare data for output
$rowContent = array(
'wernis_timestamp' => generateDateTime($data['wernis_timestamp'], 2),
} // END - while
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Default links are not active!
$content['payout_link'] = '<span class="bad">{--MEMBER_WERNIS_PAYOUT_DISABLED--}</span>';
addPointsThroughReferralSystem('wernis_withdraw', getMemberId(), bigintval(postRequestElement('amount')));
// Update the user data as well..
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1",
array(bigintval(postRequestElement('wernis_userid')), getMemberId()), __FILE__, __LINE__);
// All done!
subtractPoints('wernis_payout', getMemberId(), postRequestElement('amount'));
// Update WDS66 id
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1",
array(bigintval(postRequestElement('wernis_userid')), getMemberId()), __FILE__, __LINE__);
// All done!
}
// Data for the formular
-$result = SQL_QUERY_ESC("SELECT
+$result = sqlQueryEscaped("SELECT
`id`, `company`, `position`, `tax_ident`,
`gender`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`,
`phone`, `fax`, `cell`, `email`, `url`,
), __FILE__, __LINE__);
// Entry found?
-if (SQL_NUMROWS($result) == 1) {
+if (sqlNumRows($result) == 1) {
// Load sponsor data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
if ($content['status'] == 'CONFIRMED') {
// Check if form was submitted or not
if (isFormSent()) {
}
// Free memory
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
$message = '';
// Data for the formular
-$result = SQL_QUERY_ESC("SELECT
+$result = sqlQueryEscaped("SELECT
`status`,
`receive_warnings`,
`warning_interval`,
getSession('sponsorpass')
), __FILE__, __LINE__);
-if (SQL_NUMROWS($result) == 1) {
+if (sqlNumRows($result) == 1) {
// Load sponsor data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
if ($content['status'] == 'CONFIRMED') {
// Check if form was submitted or not
if (isFormSent()) {
}
// Free memory
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
}
// Load some data
-$result = SQL_QUERY_ESC('SELECT
+$result = sqlQueryEscaped('SELECT
`id`,
`gender`,
`surname`,
), __FILE__, __LINE__);
// Fetch data
-$content = SQL_FETCHARRAY($result);
+$content = sqlFetchArray($result);
// Free memory
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// Load main template
$GLOBALS['sponsor_output'] = loadTemplate('sponsor_welcome', TRUE, $content);
} // END - if
// SQL string to check for accounts
- $result_main = SQL_QUERY("SELECT
+ $result_main = sqlQuery("SELECT
`d`.`userid`,
`d`.`beg_points`
FROM
`d`.`userid` ASC
LIMIT {?beg_ranks?}", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_main)) {
+ if (!ifSqlHasZeroNums($result_main)) {
// Load our winners...
- while ($content = SQL_FETCHARRAY($result_main)) {
+ while ($content = sqlFetchArray($result_main)) {
// Add points to user's account directly
initReferralSystem();
addPointsThroughReferralSystem('monthly_beg', $content['userid'], $content['beg_points']);
} // END - while
// Reset accounts
- $result = SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=0.00000 WHERE `beg_points` > 0', __FILE__, __LINE__);
+ $result = sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=0.00000 WHERE `beg_points` > 0', __FILE__, __LINE__);
} // END - if
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
} // END - if
// Debug line
} // END - if
// Run SQL string to check for accounts
- $result_main = SQL_QUERY('SELECT
+ $result_main = sqlQuery('SELECT
`d`.`userid`,
(0' . $add . ') AS `points`
FROM
LIMIT {?bonus_ranks?}', __FILE__, __LINE__);
// Some entries were found?
- if (!SQL_HASZERONUMS($result_main)) {
+ if (!ifSqlHasZeroNums($result_main)) {
// Load our winners...
- while ($content = SQL_FETCHARRAY($result_main)) {
+ while ($content = sqlFetchArray($result_main)) {
// Make sure zero points are not mailed
if ($content['points'] > 0) {
// Add points to user's account directly
} // END - while
// Reset all accounts
- $result = SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data`
+ $result = sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data`
SET
`turbo_bonus`=0,
`login_bonus`=0,
} // END - if
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
} // END - if
// Debug line
$data['title'] = '??? (' . $what . ')';
// Look for title
- $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `%s`='%s'" . $ADD . " LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `title` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `%s`='%s'" . $ADD . " LIMIT 1",
array(
$mode,
$column,
), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Fetch the title
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return it
return $data['title'];
} // END - if
// Load SQL data and add the menu to the output stream...
- $result_main = SQL_QUERY_ESC("SELECT
+ $result_main = sqlQueryEscaped("SELECT
`title`,
`what`,
`action`,
array($mode), __FUNCTION__, __LINE__);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',getWhat()=' . getWhat());
- if (!SQL_HASZERONUMS($result_main)) {
+ if (!ifSqlHasZeroNums($result_main)) {
// There are menus available, so we simply display them... :)
$GLOBALS['rows'] = '';
- while ($content = SQL_FETCHARRAY($result_main)) {
+ while ($content = sqlFetchArray($result_main)) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',action=' . $content['action'] . ',getWhat()=' . getWhat());
// Disable the block-mode
enableBlockMode(FALSE);
$GLOBALS['rows'] .= loadTemplate($mode . '_menu_title', TRUE, $content);
// Sub menu
- $result_sub = SQL_QUERY_ESC("SELECT
+ $result_sub = sqlQueryEscaped("SELECT
`title` AS `sub_title`,
`what` AS `sub_what`,
`visible` AS `sub_visible`,
), __FUNCTION__, __LINE__);
// Are there some entries?
- if (!SQL_HASZERONUMS($result_sub)) {
+ if (!ifSqlHasZeroNums($result_sub)) {
// Init counter
$count = '0';
// Load all sub menus
- while ($content2 = SQL_FETCHARRAY($result_sub)) {
+ while ($content2 = sqlFetchArray($result_sub)) {
// Merge both arrays in one
$content = merge_array($content, $content2);
);
// Add regular menu row or bottom row?
- if ($count < SQL_NUMROWS($result_sub)) {
+ if ($count < sqlNumRows($result_sub)) {
$GLOBALS['rows'] .= loadTemplate($mode . '_menu_row', TRUE, $content);
} else {
$GLOBALS['rows'] .= loadTemplate($mode . '_menu_bottom', TRUE, $content);
}
// Free result
- SQL_FREERESULT($result_sub);
+ sqlFreeResult($result_sub);
// Count one up
$main_cnt++;
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',getWhat()=' . getWhat());
- if (SQL_NUMROWS($result_main) > $main_cnt) {
+ if (sqlNumRows($result_main) > $main_cnt) {
// Add separator
$GLOBALS['rows'] .= loadTemplate('menu_separator', TRUE, $mode);
} // END - while
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
// Prepare filter data array
$filterData = array(
$ADD = runFilterChain('convert_user_data_columns', ' ');
// Query for the user
- $result = SQL_QUERY_ESC("SELECT *" . $ADD . " FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `%s`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT *" . $ADD . " FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `%s`='%s' LIMIT 1",
array(
$column,
$value
), __FUNCTION__, __LINE__);
// Is there a record?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data from cookies
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set the userid for later use
setCurrentUserId($data['userid']);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $found;
switch ($mode) {
case 'guest':
// Guests (in the registration form) are not allowed to select 0 mails per day.
- $result = SQL_QUERY('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `value` > 0 ORDER BY `value` ASC',
+ $result = sqlQuery('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `value` > 0 ORDER BY `value` ASC',
__FUNCTION__, __LINE__);
break;
case 'admin':
case 'member':
// Members are allowed to set to zero mails per day (we will change this soon!)
- $result = SQL_QUERY('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC',
+ $result = sqlQuery('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC',
__FUNCTION__, __LINE__);
break;
}
// Some entries are found?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
$OUT .= ' <option value="' . $content['value'] . '"';
if (postRequestElement('max_mails') == $content['value']) {
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return generated HTML code
return $OUT;
$email = str_replace('.', '{DOT}', $email);
// Query the database
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
COUNT(`userid`) AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_user_data`
), __FUNCTION__, __LINE__);
// Is the email there?
- list($count) = SQL_FETCHROW($result);
+ list($count) = sqlFetchRow($result);
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return ($count == 1);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mode=' . $mode . ',action=' . $action . ',what=' . $what);
if (($mode != 'admin') && ($updateEntry === TRUE)) {
// Update guest or member menu
- $sql = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `counter`=`counter`+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1",
+ $sql = sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `counter`=`counter`+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1",
array(
$mode,
$action,
), __FUNCTION__, __LINE__, FALSE);
} elseif (($what != 'welcome') && (!empty($what))) {
// Other actions
- $sql = SQL_QUERY_ESC("SELECT `id`, `what` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what`='%s'".$add." ORDER BY `action` DESC LIMIT 1",
+ $sql = sqlQueryEscaped("SELECT `id`, `what` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what`='%s'".$add." ORDER BY `action` DESC LIMIT 1",
array(
$mode,
$action,
), __FUNCTION__, __LINE__, FALSE);
} else {
// Admin login overview
- $sql = SQL_QUERY_ESC("SELECT `id`, `what` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND (`what`='' OR `what` IS NULL)".$add." ORDER BY `action` DESC LIMIT 1",
+ $sql = sqlQueryEscaped("SELECT `id`, `what` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND (`what`='' OR `what` IS NULL)".$add." ORDER BY `action` DESC LIMIT 1",
array(
$mode,
$action
}
// Run SQL command
- $result = SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ $result = sqlQuery($sql, __FUNCTION__, __LINE__);
// Should we look for affected rows (only update) or found rows?
if ($updateEntry === TRUE) {
// Check updated/affected rows
- $ret = (!SQL_HASZEROAFFECTED());
+ $ret = (!ifSqlHasZeroAffectedRows());
} else {
// Check found rows
- $ret = (!SQL_HASZERONUMS($result));
+ $ret = (!ifSqlHasZeroNums($result));
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Set cache entry
$GLOBALS['action_valid'][$mode][$action][$what] = $ret;
} // END - if
// Load from database
- $result = SQL_QUERY_ESC("SELECT `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `what`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `what`='%s' LIMIT 1",
array(
$module,
$what
), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load action value and pray that this one is the right you want... ;-)
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} elseif ((!isExtensionInstalled('sql_patches')) && ($module != 'admin') && ($module != 'unknown')) {
// No ext-sql_patches installed, but maybe we need to register an admin?
if (isAdminRegistered()) {
$data['cat'] = '{--_CATEGORY_NONE--}';
} elseif (isValidId($cid)) {
// Lookup the category in database
- $result = SQL_QUERY_ESC('SELECT `cat` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1',
+ $result = sqlQueryEscaped('SELECT `cat` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1',
array(bigintval($cid)), __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Category found... :-)
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return result
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Search for it in database
- $result = SQL_QUERY_ESC('SELECT `%s` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1',
+ $result = sqlQueryEscaped('SELECT `%s` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1',
array(
$lookFor,
bigintval($paymentsId)
), __FUNCTION__, __LINE__);
// Is the entry there?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Payment type found... :-)
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return value
} // END - if
// Try to look the entry up
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s AND `userid`=%s AND `link_type`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s AND `userid`=%s AND `link_type`='%s' LIMIT 1",
array(
$rowName,
bigintval($statsId),
), __FUNCTION__, __LINE__);
// Was it *not* found?
- if (SQL_HASZERONUMS($result)) {
+ if (ifSqlHasZeroNums($result)) {
// So we add one!
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`, `userid`, `link_type`) VALUES (%s,%s,'%s')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`, `userid`, `link_type`) VALUES (%s,%s,'%s')",
array(
$rowName,
bigintval($statsId),
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
} // END - if
if ($countRows === TRUE) {
// Count whole table
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'COUNT!');
- $result = SQL_QUERY_ESC('SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`' . $add . ' LIMIT 1',
+ $result = sqlQueryEscaped('SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`' . $add . ' LIMIT 1',
array(
$lookFor,
$tableName
} else {
// Sum whole table
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SUM!');
- $result = SQL_QUERY_ESC('SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`' . $add . ' LIMIT 1',
+ $result = sqlQueryEscaped('SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`' . $add . ' LIMIT 1',
array(
$lookFor,
$tableName
// Look for NULL/0
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'COUNT-NULL!');
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE (`%s` %s NULL OR `%s`=0)" . $add . ' LIMIT 1',
+ $result = sqlQueryEscaped("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE (`%s` %s NULL OR `%s`=0)" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName,
} else {
// Regular entry
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'COUNT!');
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1',
+ $result = sqlQueryEscaped("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName,
// Look for NULL/0
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SUM-NULL!');
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE (`%s` %s NULL OR `%s`=0)" . $add . ' LIMIT 1',
+ $result = sqlQueryEscaped("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE (`%s` %s NULL OR `%s`=0)" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName,
} else {
// Regular entry
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SUM!');
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1',
+ $result = sqlQueryEscaped("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1',
array(
$lookFor,
$tableName,
}
// Load row
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Fix empty values
if ((empty($data['res'])) && ($lookFor != 'counter') && ($lookFor != 'id') && ($lookFor != 'userid') && ($lookFor != 'rallye_id')) {
} // END - if
// Load all admin email addresses
- $result = SQL_QUERY('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC', __FUNCTION__, __LINE__);
+ $result = sqlQuery('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC', __FUNCTION__, __LINE__);
// And send the notification to all of them
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Send the email out
sendEmail($content['email'], $subject, $message, 'N', $mailHeader);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Really simple... ;-)
}
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
array($adminLogin), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Get it
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return the id
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result = SQL_QUERY_ESC("SELECT `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
array(bigintval($adminId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Fetch data
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set cache
setAdminHash($adminId, $data['password']);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return password hash
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result = SQL_QUERY_ESC("SELECT `login` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `login` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
array(bigintval($adminId)), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Fetch data
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Set cache
$GLOBALS['cache_array']['admin']['login'][$adminId] = $data['login'];
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return the result
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result_admin_id = SQL_QUERY_ESC("SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+ $result_admin_id = sqlQueryEscaped("SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
array(bigintval($adminId)), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result_admin_id) == 1) {
+ if (sqlNumRows($result_admin_id) == 1) {
// Get data
- $data = SQL_FETCHARRAY($result_admin_id);
+ $data = sqlFetchArray($result_admin_id);
// Set cache
$GLOBALS['cache_array']['admin']['email'][$adminId] = $data['email'];
} // END - if
// Free result
- SQL_FREERESULT($result_admin_id);
+ sqlFreeResult($result_admin_id);
}
// Return email
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result_admin_id = SQL_QUERY_ESC("SELECT `default_acl` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+ $result_admin_id = sqlQueryEscaped("SELECT `default_acl` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
array(bigintval($adminId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result_admin_id) == 1) {
+ if (sqlNumRows($result_admin_id) == 1) {
// Fetch data
- $data = SQL_FETCHARRAY($result_admin_id);
+ $data = sqlFetchArray($result_admin_id);
// Set cache
$GLOBALS['cache_array']['admin']['default_acl'][$adminId] = $data['default_acl'];
}
// Free result
- SQL_FREERESULT($result_admin_id);
+ sqlFreeResult($result_admin_id);
}
// Return default ACL
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result_admin_id = SQL_QUERY_ESC("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+ $result_admin_id = sqlQueryEscaped("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
array(bigintval($adminId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result_admin_id) == 1) {
+ if (sqlNumRows($result_admin_id) == 1) {
// Fetch data
- $data = SQL_FETCHARRAY($result_admin_id);
+ $data = sqlFetchArray($result_admin_id);
// Set cache
$GLOBALS['cache_array']['admin']['la_mode'][$adminId] = $data['la_mode'];
}
// Free result
- SQL_FREERESULT($result_admin_id);
+ sqlFreeResult($result_admin_id);
}
// Return default ACL
} // END - if
// Run SQL query
- $result = SQL_QUERY_ESC("SELECT `%s` AS `key`, `%s` AS `value`" . $extraColumn . " FROM `{?_MYSQL_PREFIX?}_%s` " . $whereStatement . " ORDER BY `%s` ASC",
+ $result = sqlQueryEscaped("SELECT `%s` AS `key`, `%s` AS `value`" . $extraColumn . " FROM `{?_MYSQL_PREFIX?}_%s` " . $whereStatement . " ORDER BY `%s` ASC",
array(
$key,
$value,
), __FUNCTION__, __LINE__);
// Is there rows?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Found data so add them as OPTION lines
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Is extra set?
if (!isset($content['extra'])) {
// Set it to empty
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Return - hopefully - the requested data
$data['points'] = '0';
// Search for the points and user data
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
(SUM(`p`.`points`) - `d`.`used_points`) AS `points`
FROM
`{?_MYSQL_PREFIX?}_user_points` AS `p`
array(bigintval($userid)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Save his points to add them to the jackpot
- $data = SQL_FETCHARRAY($result);
+ $data = sqlFetchArray($result);
// Delete points entries as well
// @TODO Rewrite these lines to a filter
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s",
array(bigintval($userid)), __FUNCTION__, __LINE__);
// Update mediadata as well
} // END - if
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Delete category selections as well...
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s",
array(bigintval($userid)), __FUNCTION__, __LINE__);
// Remove from rallye if found
// @TODO Rewrite this to a filter
if (isExtensionActive('rallye')) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `userid`=%s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `userid`=%s",
array(bigintval($userid)), __FUNCTION__, __LINE__);
} // END - if
sendEmail($userid, '{--ADMIN_DELETE_ACCOUNT--}', $message);
// Ok, delete the account!
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1", array(bigintval($userid)), __FUNCTION__, __LINE__);
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1", array(bigintval($userid)), __FUNCTION__, __LINE__);
}
// Gets the matching what name from module
);
// Get categories
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`cat`
FROM
__FUNCTION__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// ... and begin loading stuff
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Transfer some data
$categories['id'][] = $content['id'];
array_push($categories['name'], $content['cat']);
// Check which users are in this category
- $result_userids = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `cat_id`=%s AND `userid` != %s ORDER BY `userid` ASC",
+ $result_userids = sqlQueryEscaped("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `cat_id`=%s AND `userid` != %s ORDER BY `userid` ASC",
array(
bigintval($content['id']),
convertNullToZero($userid)
$userid_cnt = '0';
// Start adding all
- while ($data = SQL_FETCHARRAY($result_userids)) {
+ while ($data = sqlFetchArray($result_userids)) {
// Add user count
$userid_cnt += countSumTotalData($data['userid'], 'user_data', 'userid', 'userid', TRUE, runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED' AND `receive_mails` > 0"));
} // END - while
// Free memory
- SQL_FREERESULT($result_userids);
+ sqlFreeResult($result_userids);
// Add counter
array_push($categories['userids'], $userid_cnt);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Generate options
$OUT = '';
// HTML extension active?
if (isExtensionActive('html_mail')) {
// Add HTML mail
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` (
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` (
`subject`,
`text`,
`receivers`,
), __FUNCTION__, __LINE__);
} else {
// Add regular mail
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` (
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` (
`subject`,
`text`,
`receivers`,
} // END - if
// Run query
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`d`.`userid`
FROM
`{?_MYSQL_PREFIX?}_user_data` AS `d`
), __FUNCTION__, __LINE__);
// Entries found?
- if ((SQL_NUMROWS($result) >= $receiver) && ($receiver > 0)) {
+ if ((sqlNumRows($result) >= $receiver) && ($receiver > 0)) {
// Load all entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add receiver when not empty
if (!empty($content['userid'])) {
$receiverList .= $content['userid'] . ';';
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Remove trailing semicolon
$receiverList = substr($receiverList, 0, -1);
// Recuce the amount of received emails for the receipients for given email
function reduceRecipientReceivedMails ($column, $id, $count) {
// Search for mail in database
- $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s ORDER BY `userid` ASC LIMIT %s",
+ $result = sqlQueryEscaped("SELECT * FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s ORDER BY `userid` ASC LIMIT %s",
array($column, bigintval($id), $count), __FUNCTION__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Now load all userids for one big query!
$userids = array();
- while ($data = SQL_FETCHARRAY($result)) {
+ while ($data = sqlFetchArray($result)) {
// By default reduce and found no emails
$num = 0;
if (count($userids) > 0) {
// Now update all user accounts
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`-1 WHERE `userid` IN (%s) LIMIT %s",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`-1 WHERE `userid` IN (%s) LIMIT %s",
array(
implode(',', $userids),
count($userids)
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Creates a new task
function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = NULL, $strip = TRUE) {
// Insert the task data into the database
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s, %s, 'NEW', '%s', '%s', '%s', UNIX_TIMESTAMP())",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s, %s, 'NEW', '%s', '%s', '%s', UNIX_TIMESTAMP())",
array(
convertZeroToNull($adminId),
convertZeroToNull($userid),
), __FUNCTION__, __LINE__, TRUE, $strip);
// Return insert id which is the task id
- return SQL_INSERT_ID();
+ return getSqlInsertId();
}
// Updates last module / online time
// Is 'what' set?
if (isWhatSet()) {
// Run the update query
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`{%%pipe,getUserLastWhatName%%}`='{%%pipe,getWhat%%}',
), __FUNCTION__, __LINE__);
} else {
// No what set, needs to be ignored (last_module is last_what)
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
`{%%pipe,getUserLastWhatName%%}`=NULL,
// Do the listing of entries
function doListEntries ($sql, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array(), $content = array()) {
// Run the SQL query
- $result = SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ $result = sqlQuery($sql, __FUNCTION__, __LINE__);
// Are there some URLs left?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List all URLs
$OUT = '';
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// "Translate" content
foreach ($callbackColumns as $columnName => $callbackName) {
// Fill the callback arguments
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Adds a given entry to the database
//* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',columnName[' . gettype($columnName) . ']=' . $columnName . ',filterFunctions=' . $filterFunctions[$key] . ',extraValues=' . intval(isset($extraValues[$key])) . ',extraValuesName=' . intval(isset($extraValues[$columnName . '_list'])));
// Copy entry securely to the final arrays
- $sqlColumns[$key] = SQL_ESCAPE($columnName);
- $sqlValues[$key] = SQL_ESCAPE(postRequestElement($columnName));
+ $sqlColumns[$key] = sqlEscapeString($columnName);
+ $sqlValues[$key] = sqlEscapeString(postRequestElement($columnName));
// Search for it
$search = key(search_array($columns, 'column', $columnName));
$sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_' . $tableName[0] . '` (`' . implode('`, `', $sqlColumns) . "`) VALUES (" . implode(',', $sqlValues) . ')';
// Run the SQL query
- SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ sqlQuery($sql, __FUNCTION__, __LINE__);
// Add id number
- setPostRequestElement('id', SQL_INSERT_ID());
+ setPostRequestElement('id', getSqlInsertId());
// Prepare filter data array
$filterData = array(
'mode' => 'add',
'table_name' => $tableName,
'content' => postRequestArray(),
- 'id' => SQL_INSERT_ID(),
+ 'id' => getSqlInsertId(),
'subject' => '',
// @TODO Used generic 'userid' here
'userid_column' => array('userid'),
'raw_userid' => array('userid'),
- 'affected' => SQL_AFFECTEDROWS(),
+ 'affected' => sqlAffectedRows(),
'sql' => $sql,
);
// Prepare SQL for this row
$sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET",
- SQL_ESCAPE($tableName[0])
+ sqlEscapeString($tableName[0])
);
// "Walk" through all entries
} // END - foreach
// Finish SQL command
- $sql = substr($sql, 0, -1) . " WHERE `" . SQL_ESCAPE($idColumn[0]) . "`=" . $id;
+ $sql = substr($sql, 0, -1) . " WHERE `" . sqlEscapeString($idColumn[0]) . "`=" . $id;
if ((isset($rawUserId[0])) && (isset($userIdColumn[0])) && (isPostRequestElementSet($rawUserId[0])) && (!is_array(postRequestElement($rawUserId[0])))) {
// Add user id as well
$sql .= ' AND `' . $userIdColumn[0] . '`=' . bigintval(postRequestElement($rawUserId[0]));
// Run this query
//* BUG: */ die($sql.'<pre>'.print_r(postRequestArray(), TRUE).'</pre>');
- SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ sqlQuery($sql, __FUNCTION__, __LINE__);
// Add affected rows
- $edited = SQL_AFFECTEDROWS();
+ $edited = sqlAffectedRows();
$affected += $edited;
// Load all data from that id
- $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
array(
$tableName[0],
$idColumn[0],
), __FUNCTION__, __LINE__);
// Fetch the data and merge it into $content
- $content = merge_array($content, SQL_FETCHARRAY($result));
+ $content = merge_array($content, sqlFetchArray($result));
// Prepare filter data array
$filterData = array(
runFilterChain('send_build_mail', $filterData);
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
// Delete cache?
// Is there a userid?
if (isPostRequestElementSet($userIdColumn[0])) {
// Load all data from that id
- $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
array(
$tableName[0],
$idColumn[0],
), __FUNCTION__, __LINE__);
// Fetch the data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Send "build mails" out
sendGenericBuildMails('delete', $tableName, $content, $id, '', $userIdColumn);
} // END - foreach
// Run the query
- SQL_QUERY_ESC($sql,
+ sqlQueryEscaped($sql,
array(
$tableName[0],
$idColumn[0],
), __FUNCTION__, __LINE__);
// Return affected rows
- return SQL_AFFECTEDROWS();
+ return sqlAffectedRows();
}
// Build a special template list
$id = bigintval($id);
// Get result from a given column array and table name
- $result = SQL_RESULT_FROM_ARRAY($tableName[0], $columns, $idColumn[0], $id, __FUNCTION__, __LINE__);
+ $result = getSqlResultFromArray($tableName[0], $columns, $idColumn[0], $id, __FUNCTION__, __LINE__);
// Is there one entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load all data
- $row = SQL_FETCHARRAY($result);
+ $row = sqlFetchArray($result);
// Filter all data
foreach ($row as $key => $value) {
} // END - if
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
// Is there an entry in $content?
if (($value == 'NULL') || (is_null($value))) {
// Add key with NULL
$sql .= sprintf(' `%s`=NULL,',
- SQL_ESCAPE($key)
+ sqlEscapeString($key)
);
} elseif ((is_double($value)) || (is_float($value)) || (is_int($value))) {
// Is a number, so addd it directly
$sql .= sprintf(" `%s`=%s,",
- SQL_ESCAPE($key),
+ sqlEscapeString($key),
$value
);
} else {
// Else add the value escape'd
$sql .= sprintf(" `%s`='%s',",
- SQL_ESCAPE($key),
- SQL_ESCAPE($value)
+ sqlEscapeString($key),
+ sqlEscapeString($value)
);
}
$content = array();
// Search for pool data
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`id`,
`sender`,
`subject`,
array(bigintval($poolId)), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return found data
return $content;
assert(!is_array($data));
// Then use this on the column with this mode (mostly counters)
- SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`=`%s`%s%s WHERE `id`=%s' . $whereSql . ' LIMIT 1',
+ sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`=`%s`%s%s WHERE `id`=%s' . $whereSql . ' LIMIT 1',
array(
$columnName,
$columnName,
$sql = 'UPDATE `{?_MYSQL_PREFIX?}_pool` SET ';
foreach ($data as $key => $value) {
// Add it
- $sql .= sprintf("`%s`='%s',", SQL_ESCAPE($key), SQL_ESCAPE($value));
+ $sql .= sprintf("`%s`='%s',", sqlEscapeString($key), sqlEscapeString($value));
} // END - foreach
// Finish SQL
$sql = substr($sql, 0, -1) . $moreSql . ' WHERE `id`=' . bigintval($id) . $whereSql . ' LIMIT 1';
// And finally run it
- SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ sqlQuery($sql, __FUNCTION__, __LINE__);
} else {
// Regular update
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`='%s' WHERE `id`=%s" . $whereSql . ' LIMIT 1',
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`='%s' WHERE `id`=%s" . $whereSql . ' LIMIT 1',
array(
$columnName,
$data,
}
// Return if it has an affected row
- return (SQL_AFFECTEDROWS() == 1);
+ return (sqlAffectedRows() == 1);
}
// Insert data into pool and return its insert id
$sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_pool (`' . implode('`,`', array_map('SQL_ESCAPE', array_keys($data))) . "`) VALUES ('" . implode("','", array_values($data)) . "')";
// Run the query
- SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ sqlQuery($sql, __FUNCTION__, __LINE__);
// Return insert id
- return SQL_INSERT_ID();
+ return getSqlInsertId();
}
// [EOF]
} // END - if
// Run query
- $result_main = SQL_QUERY("SELECT
+ $result_main = sqlQuery("SELECT
`id`,
`subject`,
`text`,
`timestamp` DESC", __FILE__, __LINE__);
// Some mails left?
- if (!SQL_HASZERONUMS($result_main)) {
+ if (!ifSqlHasZeroNums($result_main)) {
// Init SQLs here
initSqls();
// Send these mails away...
$count2 = '';
- while ($mailData = SQL_FETCHARRAY($result_main)) {
+ while ($mailData = sqlFetchArray($result_main)) {
// Message is active in queue
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='QUEUE' WHERE `id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='QUEUE' WHERE `id`=%s LIMIT 1",
array(bigintval($mailData['id'])), __FILE__, __LINE__);
// Default is no users left
//* DEBUG: */ debugOutput('-L:'.__LINE__.'/'.countSelection($temporaryReceivers).'-');
if (countSelection($temporaryReceivers) == 0) {
// Queue reached!
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_bonus`
SET
`data_type`='SEND',
} // END - if
} elseif ($GLOBALS['pool_cnt'] >= getMaxSend()) {
// Update bonus pool
- SQL_QUERY_ESC("UPDATE
+ sqlQueryEscaped("UPDATE
`{?_MYSQL_PREFIX?}_bonus`
SET
`data_type`='NEW',
} // END - if
// Free memory
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
// Remove variable
unset($mailText);
} // END - if
// Main query
-$result_main = SQL_QUERY("SELECT
+$result_main = sqlQuery("SELECT
`id`,
`sender` AS `sender_userid`,
`subject`,
$count_back = array(0);
$pointsBack = array(0);
-if (!SQL_HASZERONUMS($result_main)) {
+if (!ifSqlHasZeroNums($result_main)) {
// Parse all mails
- while ($mailData = SQL_FETCHARRAY($result_main)) {
+ while ($mailData = sqlFetchArray($result_main)) {
// Set mail order as 'active'. That means it will be sent out
updatePoolDataById($mailData['id'], 'data_type', 'ACTIVE', NULL, " AND `data_type`='NEW'");
} // END - if
// Entry updated?
- if (!SQL_HASZEROAFFECTED()) {
+ if (!ifSqlHasZeroAffectedRows()) {
// "Explode" all receivers into an array
if (isInString(';', $mailData['receivers'])) {
// There's more than one receiver in the list...
//* DEBUG: */ debugOutput('*L:'.__LINE__.'/'.SQL_NUMROWS($result_user).'*');
if (fetchUserData($userid)) {
// Is there a stats entry?
- $result_stats = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1",
+ $result_stats = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1",
array($mailData['id'], $mailData['sender_userid'], $mailData['timestamp']), __FILE__, __LINE__);
// If there's no stats entry add it!
//* DEBUG: */ debugOutput('!L:'.__LINE__.'/'.SQL_NUMROWS($result_stats).'!');
- if (SQL_HASZERONUMS($result_stats)) {
+ if (ifSqlHasZeroNums($result_stats)) {
// No entry was found, so we add him!
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_user_stats`
(
`pool_id`,
), __FILE__, __LINE__);
// Receive it's id for the links table
- $result_stats = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1",
+ $result_stats = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1",
array(bigintval($mailData['id']), bigintval($mailData['sender_userid']), bigintval($mailData['timestamp'])), __FILE__, __LINE__);
} // END - if
//* DEBUG: */ debugOutput('!L:'.__LINE__.'/'.SQL_NUMROWS($result_stats).'!');
- if (SQL_NUMROWS($result_stats) == 1) {
+ if (sqlNumRows($result_stats) == 1) {
// We got one!
- list($stats_id) = SQL_FETCHROW($result_stats);
+ list($stats_id) = sqlFetchRow($result_stats);
// Remove receiver from list
$status = removeReceiver($temporaryReceivers, $key, bigintval($userid), bigintval($mailData['id']), bigintval($stats_id));
sendEmail(getUserData('userid'), $mailData['subject'], $mailText, $isHtml);
// Count sent mails...
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_sent`=`emails_sent`+1 WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_sent`=`emails_sent`+1 WHERE `userid`=%s LIMIT 1",
array(bigintval($mailData['sender_userid'])), __FILE__, __LINE__);
if (isExtensionInstalledAndNewer('user', '0.1.4')) {
// Update mails received for receiver
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`+1 WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`+1 WHERE `userid`=%s LIMIT 1",
array(bigintval($userid)), __FILE__, __LINE__);
} // END - if
updatePoolDataById($mailData['id'], NULL, array('data_type' => 'SEND', 'target_send' => '0', 'receivers' => ''));
// Update send-completed-time
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `timestamp_send`=UNIX_TIMESTAMP() WHERE `pool_id`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `timestamp_send`=UNIX_TIMESTAMP() WHERE `pool_id`=%s LIMIT 1",
array(bigintval($mailData['id'])), __FILE__, __LINE__);
$lastSentId = $mailData['id']; $GLOBALS['pool_cnt'] = '0';
}
// Free result
- SQL_FREERESULT($result_stats);
+ sqlFreeResult($result_stats);
} else {
// User does not exists so we have add the sender's points back to sender's account
if (($receivers['id'] == '0') || (empty($receivers['id']))) {
} // END - if
// Free memory
-SQL_FREERESULT($result_main);
+sqlFreeResult($result_main);
// Remove variable
unset($mailText);
}
// Search for all expired coupons that we can purge
-$result = SQL_QUERY('SELECT
+$result = sqlQuery('SELECT
`id`,
UNIX_TIMESTAMP(`coupon_created`) AS `coupon_created`,
UNIX_TIMESTAMP(`coupon_expired`) AS `coupon_expired`,
`id` ASC', __FILE__, __LINE__);
// Are there entries?
-if (SQL_NUMROWS($result) > 0) {
+if (sqlNumRows($result) > 0) {
// Init variables
$out = '';
$ids = array();
// Start purging all
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Add id
array_push($ids, $content['id']);
} // END - while
// Purge all entries
- SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_coupon_data` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`coupon_expired`)) >= {?coupon_autopurge_time?}', __FILE__, __LINE__);
+ sqlQuery('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_coupon_data` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`coupon_expired`)) >= {?coupon_autopurge_time?}', __FILE__, __LINE__);
// Purge also user entries
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_coupons` WHERE `coupon_id` IN (%s) LIMIT %s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_coupons` WHERE `coupon_id` IN (%s) LIMIT %s",
array(
implode(',', $ids),
count($ids)
} // END - if
// Free result
-SQL_FREERESULT($result);
+sqlFreeResult($result);
// [EOF]
?>
$admin_points = '0';
// Then check for outdated mail order. We don't delete them just the confirmation links will be deleted.
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`userid`,
`pool_id`,
(UNIX_TIMESTAMP() - `timestamp_ordered`) >= {?auto_purge?}
ORDER BY
`userid` ASC', __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Start deleting procedure
$userid = NULL;
$points = '0';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Check if confirmation links are purged or not
- $result_links = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s LIMIT 1",
+ $result_links = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s LIMIT 1",
array(bigintval($content['id'])), __FILE__, __LINE__);
// Is there one entry?
- if (SQL_NUMROWS($result_links) == 1) {
+ if (sqlNumRows($result_links) == 1) {
// At least one link was found, enougth to pay back the points
if (($userid != $content['userid']) && (isValidId($userid)) && ($points > 0)) {
// Directly add points back to senders account
$admin_points += $content['price'];
// Remove confirmation links from queue
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s",
array(bigintval($content['id'])), __FILE__, __LINE__, FALSE));
// Update status of order
} // END - if
// Free memory
- SQL_FREERESULT($result_links);
+ sqlFreeResult($result_links);
} // END - while
// Are some points collected?
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Is the 'bonus' extension installed and activated?
if (isExtensionActive('bonus', TRUE)) {
// Check for bonus campaigns
- $result = SQL_QUERY("SELECT `id`, `points` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `data_type`='SEND' AND `timestamp` <= {?auto_purge?} ORDER BY `id` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ $result = sqlQuery("SELECT `id`, `points` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `data_type`='SEND' AND `timestamp` <= {?auto_purge?} ORDER BY `id` ASC", __FILE__, __LINE__);
+ if (!ifSqlHasZeroNums($result)) {
// Start deleting procedure
$points = '0';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Check if confirmation links are purged or not
- $result_links = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
+ $result_links = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
array(bigintval($content['id'])), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_links)) {
+ if (!ifSqlHasZeroNums($result_links)) {
// At least one link was found, enougth to pay back the points
- $points += $content['points'] * SQL_NUMROWS($result_links);
+ $points += $content['points'] * sqlNumRows($result_links);
// Free memory
- SQL_FREERESULT($result_links);
+ sqlFreeResult($result_links);
// Remove confirmation links from queue
- addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
+ addSql(sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
array(bigintval($content['id'])), __FILE__, __LINE__, FALSE));
// Update status of order
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='DELETED' WHERE `id`=%s LIMIT 1",
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='DELETED' WHERE `id`=%s LIMIT 1",
array(bigintval($content['id'])), __FILE__, __LINE__, FALSE));
} // END - if
} // END - while
} // END - if
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Add points from deleted accounts to jackpot, but here just add to notify mail
} // END - if
// Check for all accounts
- $result_inactive = SQL_QUERY("SELECT
+ $result_inactive = sqlQuery("SELECT
`userid`,
`email`,
`last_online`
ORDER BY
`userid` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_inactive)) {
+ if (!ifSqlHasZeroNums($result_inactive)) {
// Prepare variables and constants...
$userids = array();
$content['since'] = (getApInactiveSince() / 60 / 60);
$content['time'] = (getApInactiveTime() / 60 / 60);
// Mark found accounts as inactive and send an email
- while ($row = SQL_FETCHARRAY($result_inactive)) {
+ while ($row = sqlFetchArray($result_inactive)) {
// Merge both arrays
$content = merge_array($content, $row);
sendEmail($content['userid'], '{--MEMBER_AUTOPURGE_INACTIVE_SUBJECT--}', $message);
// Update this account
- addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ap_notified`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1",
+ addSql(sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ap_notified`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1",
array(bigintval($content['userid'])), __FILE__, __LINE__, FALSE));
} // END - while
} // END - if
// Free memory
- SQL_FREERESULT($result_inactive);
+ sqlFreeResult($result_inactive);
/*
* Now let's have a look for inactive accounts for deletion. Use the newly
* added exclude list here for e.g. excluding holiday users, test users et
* cetera.
*/
- $result_inactive = SQL_QUERY("SELECT
+ $result_inactive = sqlQuery("SELECT
`userid`,
`email`,
`last_online`
ORDER BY
`userid` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_inactive)) {
+ if (!ifSqlHasZeroNums($result_inactive)) {
// Prepare userid array for admin...
$userids = array();
// Delete inactive accounts
- while ($content = SQL_FETCHARRAY($result_inactive)) {
+ while ($content = sqlFetchArray($result_inactive)) {
// Remember userids for the admin
array_push($userids, $content['userid']);
} // END - if
// Free memory
- SQL_FREERESULT($result_inactive);
+ sqlFreeResult($result_inactive);
// Run all SQLs
runFilterChain('run_sqls');
} // END - if
// Okay, let's check for deleted mails
-$result_mails = SQL_QUERY("SELECT
+$result_mails = sqlQuery("SELECT
`sender`
FROM
`{?_MYSQL_PREFIX?}_pool`
$deletedStats = '0';
// Is there "purged" mails?
-if (!SQL_HASZERONUMS($result_mails)) {
+if (!ifSqlHasZeroNums($result_mails)) {
// Okay, check for their sender's
- while ($content = SQL_FETCHARRAY($result_mails)) {
+ while ($content = sqlFetchArray($result_mails)) {
// Check now...
if (!fetchUserData($content['sender'])) {
// Okay we found some mails!
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_pool` WHERE `sender`=%s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_pool` WHERE `sender`=%s",
array(bigintval($content['sender'])), __FILE__, __LINE__);
// Get all affected (deleted) rows
- $deletedStats += SQL_AFFECTEDROWS();
+ $deletedStats += sqlAffectedRows();
} // END - if
} // END - while
} // END - if
// Free memory
-SQL_FREERESULT($result_mails);
+sqlFreeResult($result_mails);
// Now let's check for stats entries as well;
-$result_mails = SQL_QUERY("SELECT
+$result_mails = sqlQuery("SELECT
`userid` AS `sender`
FROM
`{?_MYSQL_PREFIX?}_user_stats`
`userid` ASC", __FILE__, __LINE__);
// Is there "purged" mails?
-if (!SQL_HASZERONUMS($result_mails)) {
+if (!ifSqlHasZeroNums($result_mails)) {
// Okay, check for their sender's
- while ($content = SQL_FETCHARRAY($result_mails)) {
+ while ($content = sqlFetchArray($result_mails)) {
// Check now...
if (!fetchUserData($content['sender'])) {
// Okay we found some mails!
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `userid`=%s",
+ sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `userid`=%s",
array(bigintval($content['sender'])), __FILE__, __LINE__);
// Get all affected (deleted) rows
- $deletedStats += SQL_AFFECTEDROWS();
+ $deletedStats += sqlAffectedRows();
// Reset query (to prevent possible errors) ...
- $result_mails = SQL_QUERY("SELECT
+ $result_mails = sqlQuery("SELECT
`userid` AS `sender`
FROM
`{?_MYSQL_PREFIX?}_user_stats`
} // END - if
// Free memory
-SQL_FREERESULT($result_mails);
+sqlFreeResult($result_mails);
// Is there deleted mails and the admin want's to receive a notification
if (($deletedStats > 0) && (getConfig('ap_dm_notify') == 'Y')) {
// Check version (must be >= 0.1.9)
if ((isExtensionInstalledAndNewer('task', '0.1.9')) && (getConfig('autopurge_tasks') == 'Y')) {
// Select all tasks that needs purging
- $result = SQL_QUERY("SELECT
+ $result = sqlQuery("SELECT
`id`,
`assigned_admin`,
`userid`,
(UNIX_TIMESTAMP() - `task_created`) >= {?ap_tasks_time?}", __FILE__, __LINE__);
// Send out a notification?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Init output and load all rows
$output = ''; $ids = array();
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// "Translate" creation timestamp
$row['task_created'] = generateDateTime($row['task_created'], '1');
// Init content array
$content = array(
- 'count' => SQL_NUMROWS($result),
+ 'count' => sqlNumRows($result),
'rows' => $output
);
// Delete all tasks
- SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id` IN (' . implode(', ', $ids) . ')', __FILE__, __LINE__);
+ sqlQuery('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id` IN (' . implode(', ', $ids) . ')', __FILE__, __LINE__);
// Send out email to admin
sendAdminNotification('{--ADMIN_AUTOPURGE_TASKS_SUBJECT--}', 'admin_purge_task', $content);
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
//
// Shall I auto-purge unconfirmed accounts?
if (getConfig('autopurge_unconfirmed') == 'Y') {
// Init variables and find unconfirmed accounts which I shall auto-purge;
- $result_uncon = SQL_QUERY("SELECT
+ $result_uncon = sqlQuery("SELECT
`userid`,
`email`,
`joined`
(UNIX_TIMESTAMP() - `joined`) >= {?ap_unconfirmed_time?}
ORDER BY
`userid` ASC", __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result_uncon)) {
+ if (!ifSqlHasZeroNums($result_uncon)) {
// Prepare variable...
$userids = '';
$content['time'] = (getApUnconfirmedTime() / 60 / 60);
// Delete inactive accounts
- while ($row = SQL_FETCHARRAY($result_uncon)) {
+ while ($row = sqlFetchArray($result_uncon)) {
// Merge both arrays
$content = merge_array($content, $row);
} // END - if
// Free memory
- SQL_FREERESULT($result_uncon);
+ sqlFreeResult($result_uncon);
} // END - if
// [EOF]
} // END - if
} elseif (!isExtensionActive('cache')) {
// Get referral data
- $result_level = SQL_QUERY_ESC("SELECT `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level`=%s LIMIT 1",
+ $result_level = sqlQueryEscaped("SELECT `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level`=%s LIMIT 1",
array(bigintval($level)), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result_level) == 1) {
+ if (sqlNumRows($result_level) == 1) {
// Get percents
- $data = SQL_FETCHARRAY($result_level);
+ $data = sqlFetchArray($result_level);
} // END - if
// Free result
- SQL_FREERESULT($result_level);
+ sqlFreeResult($result_level);
}
// Return percent
// Update points...
if (is_null($GLOBALS['ref_level'])) {
// Level NULL (self)
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth` IS NULL LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth` IS NULL LIMIT 1",
array(
$pointsColumn,
$pointsColumn,
), __FUNCTION__, __LINE__);
} else {
// Level 1+
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth`=%s LIMIT 1",
array(
$pointsColumn,
$pointsColumn,
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'pointsColumn='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.convertNullToZero($GLOBALS['ref_level']).',mode='.$paymentMethod.' - UPDATE! ('.SQL_AFFECTEDROWS().')');
// No entry updated?
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// First ref in this level! :-)
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`, `ref_depth`, `%s`) VALUES (%s, %s, %s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`, `ref_depth`, `%s`) VALUES (%s, %s, %s)",
array(
$pointsColumn,
bigintval($userid),
} // END - if
// Check affected rows
- $added = (SQL_AFFECTEDROWS() == 1);
+ $added = (sqlAffectedRows() == 1);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added=' . intval($added) . ' - BEFORE FILTER');
// Prepare data for the filter
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid(' . $refid . ')=' . $GLOBALS['cache_array']['ref_level'][$refid] . ' - ADVANCED!');
// Update counter
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`=%s LIMIT 1",
array(
bigintval($refid),
bigintval($GLOBALS['cache_array']['ref_level'][$refid])
// When no entry was updated then we have to create it here
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $GLOBALS['cache_array']['ref_level'][$refid] . ',updated=' . SQL_AFFECTEDROWS());
- if (SQL_HASZEROAFFECTED()) {
+ if (ifSqlHasZeroAffectedRows()) {
// First count!
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)",
array(
bigintval($refid),
convertZeroToNull($GLOBALS['cache_array']['ref_level'][$refid])
// Subtract points from database and mediadata cache
function subtractPoints ($subject, $userid, $points) {
// Add points to used points
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `used_points`=`used_points`+%s WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `used_points`=`used_points`+%s WHERE `userid`=%s LIMIT 1",
array(
$points,
bigintval($userid)
'points' => $points,
'points_mode' => 'sub',
'column' => 'used_points',
- 'added' => (!SQL_HASZEROAFFECTED())
+ 'added' => (!ifSqlHasZeroAffectedRows())
);
// Insert booking record
$refs = array();
// Get refs from database
- $result = SQL_QUERY_ESC('SELECT
+ $result = sqlQueryEscaped('SELECT
`ur`.`id`,
`ur`.`refid`,
`ud`.`status`,
), __FUNCTION__, __LINE__);
// Are there some entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Fetch all entries
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
// Init click rate with zero
$row['click_rate'] = '0';
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ' - EXIT!');
} // END - if
// Now checkout the entry in database table
- $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `column_name`, `locked_mode`, `payment_method`, `notify_recipient` FROM `{?_MYSQL_PREFIX?}_points_data` WHERE `subject`='%s' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `subject`, `column_name`, `locked_mode`, `payment_method`, `notify_recipient` FROM `{?_MYSQL_PREFIX?}_points_data` WHERE `subject`='%s' LIMIT 1",
array($subject), __FUNCTION__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Then load it
- $pointsData = SQL_FETCHARRAY($result);
+ $pointsData = sqlFetchArray($result);
// Add all entries to our cache array
foreach ($pointsData as $key => $value) {
} // END - foreach
} else {
// Register this automatically
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`, `column_name`, `locked_mode`, `payment_method`, `notify_recipient`) VALUES ('%s','points','LOCKED','REFERRAL','N')",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`, `column_name`, `locked_mode`, `payment_method`, `notify_recipient`) VALUES ('%s','points','LOCKED','REFERRAL','N')",
array($subject), __FUNCTION__, __LINE__);
// Re-request it
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return it
return $GLOBALS['cache_array']['points_data'][$subject];
$GLOBALS['referral_refid'][$userid] = array();
// Get all level entries from the refsystem table
- $GLOBALS['referral_result'][$userid] = SQL_QUERY_ESC('SELECT `level` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s ORDER BY `level` ASC',
+ $GLOBALS['referral_result'][$userid] = sqlQueryEscaped('SELECT `level` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s ORDER BY `level` ASC',
array($userid), __FUNCTION__, __LINE__);
// Are there entries?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL_NUMROWS()=' . SQL_NUMROWS($GLOBALS['referral_result'][$userid]));
- if (SQL_NUMROWS($GLOBALS['referral_result'][$userid]) > 0) {
+ if (sqlNumRows($GLOBALS['referral_result'][$userid]) > 0) {
// Then walk through all levels
- while (list($level) = SQL_FETCHROW($GLOBALS['referral_result'][$userid])) {
+ while (list($level) = sqlFetchRow($GLOBALS['referral_result'][$userid])) {
// Init array
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level);
$GLOBALS['referral_refid'][$userid][$level] = array();
// Level is = 1?
if ($level == 1) {
// Load all referrals of this user
- $GLOBALS['referral_result_refs'][$userid] = SQL_QUERY_ESC('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=%s ORDER BY `userid` ASC',
+ $GLOBALS['referral_result_refs'][$userid] = sqlQueryEscaped('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=%s ORDER BY `userid` ASC',
array($userid), __FUNCTION__, __LINE__);
// Are there entries?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',SQL_NUMROWS()=' . SQL_NUMROWS($GLOBALS['referral_result_refs'][$userid]));
- if (SQL_NUMROWS($GLOBALS['referral_result_refs'][$userid]) > 0) {
+ if (sqlNumRows($GLOBALS['referral_result_refs'][$userid]) > 0) {
// Then again walk through all
- while (list($refid) = SQL_FETCHROW($GLOBALS['referral_result_refs'][$userid])) {
+ while (list($refid) = sqlFetchRow($GLOBALS['referral_result_refs'][$userid])) {
// Add this refid
array_push($GLOBALS['referral_refid'][$userid][$level], $refid);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid . ' - ADDED!');
} // END - if
// Free result
- SQL_FREERESULT($GLOBALS['referral_result_refs'][$userid]);
+ sqlFreeResult($GLOBALS['referral_result_refs'][$userid]);
} // END - if
} // END - while
} // END - if
// Free result
- SQL_FREERESULT($GLOBALS['referral_result'][$userid]);
+ sqlFreeResult($GLOBALS['referral_result'][$userid]);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!');
}
// And run it
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL=' . $SQL);
if ($executeSql === TRUE) {
- SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+ sqlQuery($SQL, __FUNCTION__, __LINE__);
} // END - if
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!');
$value = $GLOBALS['cache_request']['get'][$element];
} elseif (isGetRequestElementSet($element)) {
// Then get it directly
- $value = SQL_ESCAPE($GLOBALS['raw_request']['get'][$element]);
+ $value = sqlEscapeString($GLOBALS['raw_request']['get'][$element]);
// Store it in cache
$GLOBALS['cache_request']['get'][$element] = $value;
// Setter for element in $_GET
function setGetRequestElement ($element, $value) {
// Escape both
- $element = SQL_ESCAPE($element);
- $value = SQL_ESCAPE($value);
+ $element = sqlEscapeString($element);
+ $value = sqlEscapeString($value);
// Set in $_GET
$GLOBALS['raw_request']['get'][$element] = $value;
// Is $subElement set?
if ((!is_null($subElement)) && (isPostRequestElementSet($element, $subElement))) {
// Then use this
- $value = SQL_ESCAPE($value[$subElement]);
+ $value = sqlEscapeString($value[$subElement]);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',subElement=' . $subElement . ' - SUB!');
} elseif (!is_array($value)) {
// Escape it here
- $value = SQL_ESCAPE($value);
+ $value = sqlEscapeString($value);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ' - REGULAR!');
}
$eval .= implode("']['", $element);
// Finish eval() command
- $eval .= sprintf("'] = \"%s\";", SQL_ESCAPE($value));
+ $eval .= sprintf("'] = \"%s\";", sqlEscapeString($value));
// And run it
eval($eval);
} elseif (is_array($value)) {
// Escape element
- $element = SQL_ESCAPE($element);
+ $element = sqlEscapeString($element);
// Value is an array so set it directly
$GLOBALS['raw_request']['post'][$element] = $value;
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',value=' . $value . ' - BEFORE!');
// Escape both
- $element = SQL_ESCAPE($element);
- $value = SQL_ESCAPE($value);
+ $element = sqlEscapeString($element);
+ $value = sqlEscapeString($value);
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',value=' . $value . ' - AFTER!');
// Now add all parameters
foreach (getRequestArray() as $key => $value) {
// Add it secured
- $return .= SQL_ESCAPE($key) . '=' . SQL_ESCAPE($value) . '&';
+ $return .= sqlEscapeString($key) . '=' . sqlEscapeString($value) . '&';
} // END - foreach
// Remove trailing &
// Is the variable there?
if (isSessionVariableSet($var)) {
// Then get it secured!
- $value = SQL_ESCAPE($GLOBALS['_SESSION'][$var]);
+ $value = sqlEscapeString($GLOBALS['_SESSION'][$var]);
} // END - if
// Return the value
$SQL .= '`' . $entry . '`=NULL,';
} elseif ((substr($value, -2, 2) == '()') || (substr($value, 0, 1) == '`')) {
// SQL function needs no ticks (')
- $SQL .= '`' . $entry . '`=' . SQL_ESCAPE($value) . ',';
+ $SQL .= '`' . $entry . '`=' . sqlEscapeString($value) . ',';
} elseif ('' . bigintval($value, TRUE, FALSE) . '' == '' . $value . '') {
// No need for ticks (')
$SQL .= '`' . $entry . '`=' . $value . ',';
$SQL .= '`' . $entry . '`=' . sprintf(getConfig('FLOAT_MASK'), $value) . ',';
} else {
// Strings need ticks (') around them
- $SQL .= '`' . $entry . "`='" . SQL_ESCAPE($value) . "',";
+ $SQL .= '`' . $entry . "`='" . sqlEscapeString($value) . "',";
}
} else {
// Handle multi-dimensional data
$SQL .= '`' . $entry . '`=NULL,';
} elseif ((substr($value[$multiDimId], -2, 2) == '()') || (substr($value[$multiDimId], 0, 1) == '`')) {
// SQL function needs no ticks (')
- $SQL .= '`' . $entry . '`=' . SQL_ESCAPE($value[$multiDimId]) . ',';
+ $SQL .= '`' . $entry . '`=' . sqlEscapeString($value[$multiDimId]) . ',';
} elseif (('' . bigintval($value[$multiDimId], TRUE, FALSE) . '' == '' . $value[$multiDimId] . '')) {
// No need for ticks (')
$SQL .= '`' . $entry . '`=' . $value[$multiDimId] . ',';
$SQL .= '`' . $entry . '`=' . sprintf(getConfig('FLOAT_MASK'), $value[$multiDimId]) . ',';
} else {
// Strings need ticks (') around them
- $SQL .= '`' . $entry . "`='" . SQL_ESCAPE($value[$multiDimId]) . "',";
+ $SQL .= '`' . $entry . "`='" . sqlEscapeString($value[$multiDimId]) . "',";
}
}
} // END - foreach
$SQL .= 'NULL,';
} elseif (substr($value, -2, 2) == '()') {
// SQL function needs no ticks (')
- $SQL .= SQL_ESCAPE($value) . ',';
+ $SQL .= sqlEscapeString($value) . ',';
} elseif ('' . bigintval($value, TRUE, FALSE) . '' == '' . $value . '') {
// Number detected, no need for ticks (')
$SQL .= bigintval($value) . ',';
$SQL .= sprintf(getConfig('FLOAT_MASK'), $value) . ',';
} else {
// Everything else might be a string, so add ticks around it
- $SQL .= chr(39) . SQL_ESCAPE($value) . chr(39) . ',';
+ $SQL .= chr(39) . sqlEscapeString($value) . chr(39) . ',';
}
} // END - foreach
function unsetSqlLinkUp ($F, $L) {
// Unset it
//* DEBUG: */ logDebugMessage($F, $L, __FUNCTION__ . ': Called!');
- SQL_SET_LINK($F, $L, NULL);
+ setSqlLink($F, $L, NULL);
}
// Initializes the SQL link by bringing it up if set
unsetSqlLinkUp(__FUNCTION__, __LINE__);
// Do this only if link is down
- assert(!SQL_IS_LINK_UP());
+ assert(!isSqlLinkUp());
// Is the configuration data set?
if ((!empty($GLOBALS['mysql']['host'])) && (!empty($GLOBALS['mysql']['login'])) && (!empty($GLOBALS['mysql']['dbase']))) {
unsetSqlLinkUp(__FUNCTION__, __LINE__);
// Connect to DB
- SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FUNCTION__, __LINE__);
+ sqlConnectToDatabase($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FUNCTION__, __LINE__);
// Is the link valid?
- if (SQL_IS_LINK_UP()) {
+ if (isSqlLinkUp()) {
// Enable exit on error
enableExitOnError();
// Is it a valid resource?
- if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FUNCTION__, __LINE__) === TRUE) {
+ if (sqlSelectDatabase($GLOBALS['mysql']['dbase'], __FUNCTION__, __LINE__) === TRUE) {
// Set database name (required for ext-optimize and ifSqlTableExists())
setConfigEntry('__DB_NAME', $GLOBALS['mysql']['dbase']);
}
// SQL string escaping
-function SQL_QUERY_ESC ($sqlString, $data, $F, $L, $run = TRUE, $strip = TRUE, $secure = TRUE) {
+function sqlQueryEscaped ($sqlString, $data, $F, $L, $run = TRUE, $strip = TRUE, $secure = TRUE) {
// Link is there?
- if ((!SQL_IS_LINK_UP()) || (!is_array($data))) {
+ if ((!isSqlLinkUp()) || (!is_array($data))) {
// Link is down or data is not an array
- //* DEBUG: */ logDebugMessage($F, $L, 'SQL_IS_LINK_UP()=' . intval(SQL_IS_LINK_UP()) . ',data[]=' . gettype($data) . ',sqlString=' . $sqlString . ': ABORTING!');
+ //* DEBUG: */ logDebugMessage($F, $L, 'isSqlLinkUp()=' . intval(isSqlLinkUp()) . ',data[]=' . gettype($data) . ',sqlString=' . $sqlString . ': ABORTING!');
return FALSE;
} // END - if
// Escape all data
foreach ($data as $key => $value) {
- $dataSecured[$key] = SQL_ESCAPE($value, $secure, $strip);
+ $dataSecured[$key] = sqlEscapeString($value, $secure, $strip);
} // END - foreach
// Generate query
if ($run === TRUE) {
// Run SQL query (default)
- return SQL_QUERY($query, $F, $L);
+ return sqlQuery($query, $F, $L);
} else {
// Return secured string
return $query;
}
// SELECT query string from table, columns and so on... ;-)
-function SQL_RESULT_FROM_ARRAY ($table, $columns, $idRow, $id, $F, $L) {
+function getSqlResultFromArray ($table, $columns, $idRow, $id, $F, $L) {
// Is columns an array?
if (!is_array($columns)) {
// No array
}
// Return the result
- return SQL_QUERY_ESC($sql,
+ return sqlQueryEscaped($sql,
array(
$table,
$idRow,
}
// ALTER TABLE wrapper function
-function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = TRUE) {
+function sqlQueryAlterTable ($sql, $F, $L, $enableCodes = TRUE) {
// Abort if link is down
- if (!SQL_IS_LINK_UP()) return FALSE;
+ if (!isSqlLinkUp()) return FALSE;
// This is the default result...
$result = FALSE;
if (((!ifSqlTableColumnExists($tableName, $columnName)) && (isInString('ADD', $sql))) || ((ifSqlTableColumnExists($tableName, $columnName)) && ((isInString('DROP', $sql)) || ((isInString('CHANGE', $sql)) && ($idx == 4) && ((!ifSqlTableColumnExists($tableName, $tableArray[5])) || ($columnName == $tableArray[5])))))) {
// Do the query
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Executing: ' . $sql);
- $result = SQL_QUERY($sql, $F, $L, FALSE);
+ $result = sqlQuery($sql, $F, $L, FALSE);
// Skip further attempt(s)
break;
// Shall we run it?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ', tableArray[3]=' . $tableArray[3] . ',keyName=' . $keyName);
if (($tableArray[3] == 'ADD') && (!ifSqlTableIndexExist($tableName, $keyName))) {
- // Send it to the SQL_QUERY() function to add it
+ // Send it to the sqlQuery() function to add it
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ' - ADDING!');
- $result = SQL_QUERY($sql, $F, $L, $enableCodes);
+ $result = sqlQuery($sql, $F, $L, $enableCodes);
} elseif (($tableArray[3] == 'DROP') && (ifSqlTableIndexExist($tableName, $keyName))) {
- // Send it to the SQL_QUERY() function to drop it
+ // Send it to the sqlQuery() function to drop it
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ' - DROPPING!');
- $result = SQL_QUERY($sql, $F, $L, $enableCodes);
+ $result = sqlQuery($sql, $F, $L, $enableCodes);
} else {
// Not executed
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not executed: ' . $sql);
} else {
// Other ALTER TABLE query
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
- $result = SQL_QUERY($sql, $F, $L, $enableCodes);
+ $result = sqlQuery($sql, $F, $L, $enableCodes);
}
// Return result
}
// Getter for SQL link
-function SQL_GET_LINK () {
+function getSqlLink () {
// Init link
$link = NULL;
}
// Setter for link
-function SQL_SET_LINK ($F, $L, $link) {
+function setSqlLink ($F, $L, $link) {
//* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, 'link[]=' . gettype($link) . ' - ENTERED!');
// Is this a resource or null?
if ((ifFatalErrorsDetected()) && (isInstallationPhase())) {
}
// Checks if the link is up
-function SQL_IS_LINK_UP () {
+function isSqlLinkUp () {
// Is there cached this?
if (!isset($GLOBALS['__is_sql_link_up'])) {
// Something bad went wrong
}
// Wrapper function to make code more readable
-function SQL_HASZERONUMS ($result) {
+function ifSqlHasZeroNums ($result) {
// Just pass it through
- return (SQL_NUMROWS($result) === 0);
+ return (sqlNumRows($result) === 0);
}
// Wrapper function to make code more readable
-function SQL_HASZEROAFFECTED () {
+function ifSqlHasZeroAffectedRows () {
// Just pass it through
- return (SQL_AFFECTEDROWS() === 0);
+ return (sqlAffectedRows() === 0);
}
// Private function to prepare the SQL query string
-function SQL_PREPARE_SQL_STRING ($sqlString, $enableCodes = TRUE) {
+function sqlPrepareQueryString ($sqlString, $enableCodes = TRUE) {
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString=' . $sqlString . ',enableCodes=' . intval($enableCodes) . ' - ENTERED!');
}
// Creates a MySQL TIMESTAMP compatible string from given Uni* timestamp
-function SQL_EPOCHE_TO_TIMESTAMP ($timestamp) {
- return generateDateTime($timestamp, 7);
+function getSqlTimestampFromUnix ($timestamp) {
+ return generateDateTime($timestamp, '7');
}
// Check if there is a SQL table created
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$tableName])) {
// Check if the table is there
- $result = SQL_QUERY_ESC("SHOW TABLES FROM `{?__DB_NAME?}` WHERE `Tables_in_{?__DB_NAME?}`='{?_MYSQL_PREFIX?}_%s'",
+ $result = sqlQueryEscaped("SHOW TABLES FROM `{?__DB_NAME?}` WHERE `Tables_in_{?__DB_NAME?}`='{?_MYSQL_PREFIX?}_%s'",
array($tableName), __FUNCTION__, __LINE__);
// Is a link there?
// Is installation phase?
if (isInstallationPhase()) {
// Then silently abort here
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(SQL_IS_LINK_UP()) . ',tableName=' . $tableName . ' - Returning FALSE ...');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(isSqlLinkUp()) . ',tableName=' . $tableName . ' - Returning FALSE ...');
return FALSE;
} else {
// Please report this
} // END - if
// Is there an entry?
- $GLOBALS[__FUNCTION__][$tableName] = (SQL_NUMROWS($result) == 1);
+ $GLOBALS[__FUNCTION__][$tableName] = (sqlNumRows($result) == 1);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',numRows=' . intval($GLOBALS[__FUNCTION__][$tableName]));
} // END - if
} // END - if
// Get column information
- $result = SQL_QUERY_ESC("SHOW COLUMNS FROM `%s` LIKE '%s'",
+ $result = sqlQueryEscaped("SHOW COLUMNS FROM `%s` LIKE '%s'",
array(
$tableName,
$columnName
// Is installation phase?
if (isInstallationPhase()) {
// Then silently abort here
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(SQL_IS_LINK_UP()) . ',tableName=' . $tableName . ',columnName=' . $columnName . ' - Returning FALSE ...');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(isSqlLinkUp()) . ',tableName=' . $tableName . ',columnName=' . $columnName . ' - Returning FALSE ...');
return $forceFound;
} else {
// Please report this
} // END - if
// Determine it
- $doesExist = (!SQL_HASZERONUMS($result));
+ $doesExist = (!ifSqlHasZeroNums($result));
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return cache
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName . ',doesExist=' . intval($doesExist) . ' - EXIT!');
} // END - if
// Show indexes
- $result = SQL_QUERY_ESC("SHOW INDEX FROM `%s`", array($tableName), __FUNCTION__, __LINE__);
+ $result = sqlQueryEscaped("SHOW INDEX FROM `%s`", array($tableName), __FUNCTION__, __LINE__);
// Is a link there?
if (!is_resource($result)) {
// Is installation phase?
if (isInstallationPhase()) {
// Then silently abort here
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(SQL_IS_LINK_UP()) . ',tableName=' . $tableName . ',keyName=' . $keyName . ' - Returning FALSE ...');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(isSqlLinkUp()) . ',tableName=' . $tableName . ',keyName=' . $keyName . ' - Returning FALSE ...');
return $forceFound;
} else {
// Please report this
$doesExist = FALSE;
// Walk through all
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Is it the requested one?
if ($content['Key_name'] == $keyName) {
// Then it is found and exit
} // END - while
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return cache
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',keyName=' . $keyName . ',doesExist=' . intval($doesExist) . ' - EXIT!');
$engines = array();
// This also worked, now we need to check if the selected database type is supported
- $result = SQL_QUERY('SHOW ENGINES', __FUNCTION__, __LINE__);
+ $result = sqlQuery('SHOW ENGINES', __FUNCTION__, __LINE__);
// Are there entries? (Bad if not)
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// Load all and check for active entries
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'support=' . $requestedEngine . ',Engine=' . $content['Engine'] . ',Support=' . $content['Support']);
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Return result
return $engines;
// Loads stats table
function loadStatsTable () {
// Check if the link is up
- if (!SQL_IS_LINK_UP()) return FALSE;
+ if (!isSqlLinkUp()) return FALSE;
// Is it there for today?
if (!isStatsTableCreated()) {
} // END - if
// Load it from database
- $result = SQL_QUERY_ESC("SELECT `stats_entry`, `stats_value` FROM `{?_MYSQL_PREFIX?}_stats_%s` ORDER BY `stats_entry` ASC",
+ $result = sqlQueryEscaped("SELECT `stats_entry`, `stats_value` FROM `{?_MYSQL_PREFIX?}_stats_%s` ORDER BY `stats_entry` ASC",
array(
generateDateTime(time(), '6')
), __FUNCTION__, __LINE__);
// Read all rows
- while ($row = SQL_FETCHARRAY($result)) {
+ while ($row = sqlFetchArray($result)) {
$GLOBALS['stats'][$row['stats_entry']] = $row['stats_value'];
} // END - while
// Free the result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
}
// Checks if the the statistics table is created
function isStatsTableCreated () {
// Check if the link is up
- if (!SQL_IS_LINK_UP()) return FALSE;
+ if (!isSqlLinkUp()) return FALSE;
// Ask for it
- $result = SQL_QUERY_ESC("SHOW TABLES LIKE '{?_MYSQL_PREFIX?}_stats_%s'",
+ $result = sqlQueryEscaped("SHOW TABLES LIKE '{?_MYSQL_PREFIX?}_stats_%s'",
array(generateDateTime(time(), '6')), __FUNCTION__, __LINE__);
// Is there a row?
- return SQL_NUMROWS($result);
+ return sqlNumRows($result);
}
// Create the dummy table
function createStatsTable () {
// Check if the link is up
- if (!SQL_IS_LINK_UP()) return FALSE;
+ if (!isSqlLinkUp()) return FALSE;
// Create it here
- $result = SQL_QUERY_ESC("CREATE TEMPORARY TABLE IF NOT EXISTS `{?_MYSQL_PREFIX?}_stats_%s` (
+ $result = sqlQueryEscaped("CREATE TEMPORARY TABLE IF NOT EXISTS `{?_MYSQL_PREFIX?}_stats_%s` (
`stats_entry` VARCHAR(100) NOT NULL DEFAULT '',
`stats_value` BIGINT(20) NOT NULL DEFAULT 0,
PRIMARY KEY (`stats_entry`)
// Write all entries to the table
function writeStatsTable () {
// Check if the link is up
- if (!SQL_IS_LINK_UP()) return FALSE;
+ if (!isSqlLinkUp()) return FALSE;
// Empty the table first
- SQL_QUERY_ESC("TRUNCATE `{?_MYSQL_PREFIX?}_stats_%s`",
+ sqlQueryEscaped("TRUNCATE `{?_MYSQL_PREFIX?}_stats_%s`",
array(generateDateTime(time(), '6')), __FUNCTION__, __LINE__);
// Begin the SQL command
} // END - foreach
// Finalize it and run it
- SQL_QUERY(substr($sql, 0, -1), __FUNCTION__, __LINE__);
+ sqlQuery(substr($sql, 0, -1), __FUNCTION__, __LINE__);
}
// Filter for flushing statistics
$pageTitle = '';
// Config and database connection valid?
- if ((isConfigLocalLoaded()) && (isConfigurationLoaded()) && (SQL_IS_LINK_UP()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) {
+ if ((isConfigLocalLoaded()) && (isConfigurationLoaded()) && (isSqlLinkUp()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) {
// Title decoration enabled?
if ((isTitleDecorationEnabled()) && (getTitleLeft() != '')) {
$pageTitle .= '{%config,trim=title_left%} ';
} // END - if
// Check for all referrals
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
COUNT(`d`.`userid`) AS `cnt`
FROM
`{?_MYSQL_PREFIX?}_user_data` AS `d`
), __FUNCTION__, __LINE__);
// Load count
- list($GLOBALS[__FUNCTION__][$userid][$level]) = SQL_FETCHROW($result);
+ list($GLOBALS[__FUNCTION__][$userid][$level]) = sqlFetchRow($result);
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return it
}
// Wrapper function for SQL layer to speed-up things
-function SQL_DEBUG_ENABLED () {
+function isSqlDebugEnabled () {
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
// Maybe he wants to confirm an email?
switch ($data['type']) {
case 'normal':
- $result_main = SQL_QUERY_ESC("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1",
+ $result_main = sqlQueryEscaped("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1",
array($data['id'], $data['userid']), __FILE__, __LINE__);
break;
case 'bonus':
- $result_main = SQL_QUERY_ESC("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1",
+ $result_main = sqlQueryEscaped("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1",
array($data['id'], $data['userid']), __FILE__, __LINE__);
break;
} // END - switch
// Is an entry found?
- if (SQL_NUMROWS($result_main) == 1) {
+ if (sqlNumRows($result_main) == 1) {
// Is the stats id valid?
- $data = merge_array($data, SQL_FETCHARRAY($result_main));
+ $data = merge_array($data, sqlFetchArray($result_main));
// Init result here with invalid to avoid possible missing variable
$result_mailid = FALSE;
// @TODO Rewrite this to a filter/function
switch ($data['link_type']) {
case 'NORMAL':
- $result_mailid = SQL_QUERY_ESC("SELECT `pool_id`, `userid` AS `sender` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
+ $result_mailid = sqlQueryEscaped("SELECT `pool_id`, `userid` AS `sender` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
array($data['id']), __FILE__, __LINE__);
break;
case 'BONUS':
- $result_mailid = SQL_QUERY_ESC("SELECT `id` AS `pool_id`, `is_notify` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ $result_mailid = sqlQueryEscaped("SELECT `id` AS `pool_id`, `is_notify` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
array($data['id']), __FILE__, __LINE__);
break;
} // END - switch
// Entry found?
- if (SQL_NUMROWS($result_mailid) == 1) {
+ if (sqlNumRows($result_mailid) == 1) {
// Load data
- $data = merge_array($data, SQL_FETCHARRAY($result_mailid));
+ $data = merge_array($data, sqlFetchArray($result_mailid));
// Correct notification switch in non-bonus mails
if ((!isset($data['is_notify'])) || (!in_array($data['is_notify'], array('Y', 'N')))) {
// @TODO Rewrite this to a filter
switch ($data['link_type']) {
case 'NORMAL':
- $result = SQL_QUERY_ESC("SELECT `payment_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `payment_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
array(bigintval($data['pool_id'])), __FILE__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
- $data = merge_array($data, SQL_FETCHARRAY($result));
+ if (sqlNumRows($result) == 1) {
+ $data = merge_array($data, sqlFetchArray($result));
$data['time'] = getPaymentTime($data['payment_id']);
$data['payment'] = getPaymentPayment($data['payment_id']);
$isValid = TRUE;
} // END - if
// Free memory...
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
break;
case 'BONUS':
- $result = SQL_QUERY_ESC("SELECT `time`, `points` AS `payment` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `time`, `points` AS `payment` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
array(bigintval($data['pool_id'])), __FILE__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
- $data = merge_array($data, SQL_FETCHARRAY($result));
+ if (sqlNumRows($result) == 1) {
+ $data = merge_array($data, sqlFetchArray($result));
$isValid = TRUE;
} // END - if
// Free memory...
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
break;
default: // Unknown type
}
// Free result
- SQL_FREERESULT($result_mailid);
+ sqlFreeResult($result_mailid);
} else {
$data['error_code'] = getCode('ALREADY_CONFIRMED');
$data['do'] = 'failed';
}
// Free result
- SQL_FREERESULT($result_main);
+ sqlFreeResult($result_main);
} else {
// Not all variables are set
$data['error_code'] = getCode('ERROR_MAILID');
// Valid type?
if (!empty($t)) {
// Check for data
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`d`.`userid`,
`b`.`level`,
`b`.`points`
), __FILE__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load data
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Prepare constants for the pre-template
$content['mailid'] = bigintval(getRequestElement('d'));
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Wrong type entered
$content['message'] = '<span class="bad">{--BONUS_SHOW_WRONG_TYPE--}</span>';