// Set content type for e.g. search engines
setContentType('text/html');
-// Is the admin logged-in and no sql_patches installed?
+// Is the admin logged-in and no ext-sql_patches installed?
if ((isAdmin()) && (!isExtensionActive('sql_patches'))) {
// Extension 'sql_patches' is missing!
redirectToUrl('modules.php?module=admin&sql_patches=1');
class HostnameResolver {
// Resolve hostname -> IP address
function resolveHostname ($hostname) {
- // If sql_patches is not at least 0.7.0, abort here and return the hostname (gethostbyname() may return something unwanted)
+ // If ext-sql_patches is not at least 0.7.0, abort here and return the hostname (gethostbyname() may return something unwanted)
if (!isExtensionInstalledAndNewer('sql_patches', '0.7.0')) {
// Abort here
return $hostname;
break;
case '0.3.4': // SQL queries for v0.3.4
- // This update depends on latest sql_patches version
+ // This update depends on latest ext-sql_patches version
addExtensionDependency('sql_patches');
// Register points data
reportBug(__FUNCTION__, __LINE__, 'Filter system already initialized.');
} // END - if
- // Load all saved filers if sql_patches is updated
+ // Load all saved filers if ext-sql_patches is updated
if ((isset($GLOBALS['cache_array']['filter']['filter_name'])) && (!isset($GLOBALS['cache_array']['filter']['chains']))) {
// Prepare filter array
prepareFilterArray();
if ((!isInstallationPhase()) && ((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9')))) {
// Log only in debug mode
if (isDebugModeEnabled()) {
- logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters, sql_patches might be missing. isExtensionInstalled()=' . intval(isExtensionInstalled('sql_patches')) . ',isExtensionInstalledAndOlder()=' . intval(isExtensionInstalledAndOlder('sql_patches', '0.5.9')));
+ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters, ext-sql_patches might be missing. isExtensionInstalled()=' . intval(isExtensionInstalled('sql_patches')) . ',isExtensionInstalledAndOlder()=' . intval(isExtensionInstalledAndOlder('sql_patches', '0.5.9')));
} // END - if
// Abort silently here
return $content;
}
-// Filter for redirecting to logout if sql_patches has been installed
+// Filter for redirecting to logout if ext-sql_patches has been installed
function FILTER_REDIRECT_TO_LOGOUT_SQL_PATCHES () {
// Remove this filter
unregisterFilter(__FUNCTION__, __LINE__, 'shutdown', __FUNCTION__);
$GLOBALS['__page_header'] .= '</head>';
}
-// Cleans up the DNS cache if sql_patches is at least 0.7.0
+// Cleans up the DNS cache if ext-sql_patches is at least 0.7.0
function FILTER_CLEANUP_DNS_CACHE () {
// Is the latest version installed?
if (isExtensionInstalledAndNewer('sql_patches', '0.7.0')) {
// Does only allow numbers
function bigintval ($num, $castValue = TRUE, $abortOnMismatch = TRUE) {
//* DEBUG: */ debugOutput('[' . __FUNCTION__ . ':' . __LINE__ . '] ' . 'num=' . $num . ',castValue=' . intval($castValue) . ',abortOnMismatch=' . intval($abortOnMismatch) . ' - ENTERED!');
- // Filter all numbers out
+ // Filter all non-number chars out, so only number chars will remain
$ret = preg_replace('/[^0123456789]/', '', $num);
// Shall we cast?
// Add a record entry ('pointsMode' can be add/sub!)
function addBookingRecord ($subject, $userid, $points, $pointsMode) {
- // Is the sql_patches updated?
+ // Is the ext-sql_patches updated?
if (isExtensionInstalledAndOlder('sql_patches', '0.5.7')) {
// Abort here
return;
} elseif ((isValidUserId($userid)) && (empty($email))) {
// Direct userid entered
$accountFound = fetchUserData($userid);
- } else {
+ } elseif (isDebugModeEnabled()) {
// Userid not set!
logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',email=' . $email . ': Important variables are empty.');
}
// Update database
SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `password`='%s' WHERE `userid`=%s LIMIT 1",
- array(generateHash($NEW_PASS), getUserData('userid')), __FUNCTION__, __LINE__);
+ array(
+ generateHash($NEW_PASS),
+ getUserData('userid')
+ ), __FUNCTION__, __LINE__);
// Prepare data and message for email
$message = loadEmailTemplate('guest_new_password',
array(
'new_pass' => $NEW_PASS,
'nickname' => $userid
- ), bigintval(getUserData('userid')));
+ ), getUserData('userid'));
// ... and send it away
sendEmail(bigintval(getUserData('userid')), '{--GUEST_NEW_PASSWORD--}', $message);
// Create cache file here
$GLOBALS['cache_instance']->init();
- // Add more if sql_patches is recent enougth
+ // Add more if ext-sql_patches is recent enougth
$add = '';
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
$add = ',`ext_has_css` AS `ext_css`';
// Free memory
SQL_FREERESULT($result);
} elseif (!isExtensionInstalled('sql_patches')) {
- // No sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered?
+ // 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!
} else {
// Unsupported state!
// Set the default menu mode as the mode for all admins
$mode = 'global';
- // If sql_patches is up-to-date enough, use the configuration
+ // If ext-sql_patches is up-to-date enough, use the configuration
if (isExtensionInstalledAndNewer('sql_patches', '0.3.2')) {
$mode = getAdminMenu();
} // END - if
// Reset the password for the login. Do NOT call this function without calling above function first!
function doResetAdminPassword ($login, $password) {
- // Generate hash (we already check for sql_patches in generateHash())
+ // Generate hash (we already check for ext-sql_patches in generateHash())
$passHash = generateHash($password);
// Prepare fake POST data
// Update extension's record
if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) {
- // Update also CSS column when extensions sql_patches is newer or exact v0.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",
array(postRequestElement('css', $ext_id), $active, $ext_id), __FILE__, __LINE__);
} else {
die();
} // END - if
-// Is sql_patches not yet installed?
+// Is ext-sql_patches not yet installed?
if (!isExtensionInstalled('sql_patches')) {
// Output warning
displayMessage('{--ADMIN_WARNING_SQL_PATCHES_MISSING--}');
$data['action'] = '';
if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
- // sql_patches is missing so choose depending on mode
+ // ext-sql_patches is missing so choose depending on mode
$what = determineWhat($module);
} elseif ((empty($what)) && ($module != 'admin')) {
// Use configured 'home'
// Free memory
SQL_FREERESULT($result);
} elseif ((!isExtensionInstalled('sql_patches')) && ($module != 'admin') && ($module != 'unknown')) {
- // No sql_patches installed, but maybe we need to register an admin?
+ // No ext-sql_patches installed, but maybe we need to register an admin?
if (isAdminRegistered()) {
// Redirect to admin area
redirectToUrl('admin.php');
$type
), __FUNCTION__, __LINE__);
- // Update 'mails_sent' if sql_patches is updated
+ // Update 'mails_sent' if ext-sql_patches is updated
if (isExtensionInstalledAndNewer('sql_patches', '0.7.4')) {
// Update the pool
SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1',
// By default an invalid ACL value is returned
$data['default_acl'] = 'NO-ACL';
- // Is sql_patches there and was it found in cache?
+ // Is ext-sql_patches there and was it found in cache?
if (!isExtensionActive('sql_patches')) {
// Not found, which is bad, so we need to allow all
$data['default_acl'] = 'allow';
// By default an invalid mode
$data['la_mode'] = 'INVALID';
- // Is sql_patches there and was it found in cache?
+ // Is ext-sql_patches there and was it found in cache?
if (!isExtensionActive('sql_patches')) {
// Not found, which is bad, so we need to allow all
$data['la_mode'] = 'global';
$result = SQL_QUERY_ESC("SELECT
(SUM(p.`points`) - d.`used_points`) AS `points`
FROM
- `{?_MYSQL_PREFIX?}_user_points` AS p
+ `{?_MYSQL_PREFIX?}_user_points` AS `p`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_user_data` AS d
+ `{?_MYSQL_PREFIX?}_user_data` AS `d`
ON
p.`userid`=d.`userid`
WHERE
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",
- array(implode(',', $userids), count($userids)), __FUNCTION__, __LINE__);
+ array(
+ implode(',', $userids),
+ count($userids)
+ ), __FUNCTION__, __LINE__);
} else {
// Nothing deleted
displayMessage('{%message,ADMIN_MAIL_NOTHING_DELETED=' . $id . '%}');
// 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())",
+ 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())",
array(
convertZeroToNull($adminId),
convertZeroToNull($userid),
}
// Updates last module / online time
-function updateLastActivity($userid) {
+function updateLastActivity ($userid) {
// Is 'what' set?
if (isWhatSet()) {
// Run the update query
SQL_QUERY_ESC("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
- `%s`='%s',
+ `{%%pipe,getUserLastWhatName%%}`='{%%pipe,getWhat%%}',
`last_online`=UNIX_TIMESTAMP(),
- `REMOTE_ADDR`='%s'
+ `REMOTE_ADDR`='{%%pipe,detectRemoteAddr%%}'
WHERE
`userid`=%s
LIMIT 1",
array(
- getUserLastWhatName(),
- getWhat(),
- detectRemoteAddr(),
bigintval($userid)
), __FUNCTION__, __LINE__);
} else {
SQL_QUERY_ESC("UPDATE
`{?_MYSQL_PREFIX?}_user_data`
SET
- `%s`=NULL,
+ `{%%pipe,getUserLastWhatName%%}`=NULL,
`last_online`=UNIX_TIMESTAMP(),
- `REMOTE_ADDR`='%s'
+ `REMOTE_ADDR`='{%%pipe,detectRemoteAddr%%}'
WHERE
`userid`=%s
LIMIT 1",
array(
- getUserLastWhatName(),
- detectRemoteAddr(),
bigintval($userid)
), __FUNCTION__, __LINE__);
}
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using default refid (' . getDefRefid() . ')');
setReferralId(getDefRefid());
} else {
- // No default id when sql_patches is not installed or none set
+ // No default id when ext-sql_patches is not installed or none set
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using NULL as refid');
setReferralId(NULL);
}
// Generates meta description for current module and 'what' value
function generateMetaDescriptionCode () {
- // Only include from guest area and if sql_patches has correct version
+ // Only include from guest area and if ext-sql_patches has correct version
if ((getModule() == 'index') && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) {
// Output it directly
$GLOBALS['__page_header'] .= '<meta name="description" content="' . '{?MAIN_TITLE?} ' . trim(getConfig('title_middle')) . ' ' . getTitleFromMenu('guest', getWhat()) . '" />';