}
// This patched function will reduce many SELECT queries for the specified or current admin login
-function isAdmin ($adminLogin = '') {
+function isAdmin () {
// No admin in installation phase!
if ((isInstallationPhase()) || (!isAdminRegistered())) {
return false;
// Init variables
$ret = false;
+ $adminId = '0';
$passCookie = '';
$valPass = '';
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminLogin);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminId);
// If admin login is not given take current from cookies...
- if ((empty($adminLogin)) && (isSessionVariableSet('admin_login')) && (isSessionVariableSet('admin_md5'))) {
+ if ((isSessionVariableSet('admin_id')) && (isSessionVariableSet('admin_md5'))) {
// Get admin login and password from session/cookies
- $adminLogin = getSession('admin_login');
+ $adminId = getSession('admin_id');
$passCookie = getSession('admin_md5');
} // END - if
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminLogin.'/'.$passCookie);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminId.'/'.$passCookie);
+
+ // Abort if admin id is zero
+ if ($adminId == '0') {
+ return false;
+ } // END - if
// Do we have cache?
- if (!isset($GLOBALS['is_admin'][$adminLogin])) {
+ if (!isset($GLOBALS['is_admin'][$adminId])) {
// Init it with failed
- $GLOBALS['is_admin'][$adminLogin] = false;
+ $GLOBALS['is_admin'][$adminId] = false;
// Search in array for entry
if (isset($GLOBALS['admin_hash'])) {
// Use cached string
$valPass = $GLOBALS['admin_hash'];
- } elseif ((!empty($passCookie)) && (isAdminHashSet($adminLogin) === true) && (!empty($adminLogin))) {
+ } elseif ((!empty($passCookie)) && (isAdminHashSet($adminId) === true) && (!empty($adminId))) {
// Login data is valid or not?
- $valPass = encodeHashForCookie(getAdminHash($adminLogin));
+ $valPass = encodeHashForCookie(getAdminHash($adminId));
// Cache it away
$GLOBALS['admin_hash'] = $valPass;
// Count cache hits
incrementStatsEntry('cache_hits');
- } elseif ((!empty($adminLogin)) && ((!isExtensionActive('cache')) || (isAdminHashSet($adminLogin) === false))) {
+ } elseif ((!empty($adminId)) && ((!isExtensionActive('cache')) || (isAdminHashSet($adminId) === false))) {
// Get admin hash and hash it
- $valPass = encodeHashForCookie(getAdminHash($adminLogin));
+ $valPass = encodeHashForCookie(getAdminHash($adminId));
// Cache it away
$GLOBALS['admin_hash'] = $valPass;
if (!empty($valPass)) {
// Check if password is valid
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '(' . $valPass . '==' . $passCookie . ')='.intval($valPass == $passCookie));
- $GLOBALS['is_admin'][$adminLogin] = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == '*FAILED*') && (!isExtensionActive('cache'))));
+ $GLOBALS['is_admin'][$adminId] = (($GLOBALS['admin_hash'] == $passCookie) || ((strlen($GLOBALS['admin_hash']) == 32) && ($GLOBALS['admin_hash'] == md5($passCookie))) || (($GLOBALS['admin_hash'] == '*FAILED*') && (!isExtensionActive('cache'))));
} // END - if
} // END - if
// Return result of comparision
- return $GLOBALS['is_admin'][$adminLogin];
+ return $GLOBALS['is_admin'][$adminId];
}
// Generates a list of "max receiveable emails per day"
$message = loadEmailTemplate('confirm-referal', $content, bigintval($userid));
// Send email
- sendEmail($userid, getMessage('THANX_REFERAL_ONE_SUBJECT'), $message);
+ sendEmail($userid, '{--THANX_REFERAL_ONE_SUBJECT--}', $message);
} elseif (($sendNotify === true) && (getUserData('refid') == '0') && ($locked === false) && ($add_mode == 'direct')) {
// Prepare content
$content = array(
- 'text' => getMessage('REASON_DIRECT_PAYMENT'),
+ 'text' => '{--REASON_DIRECT_PAYMENT--}',
'points' => $ref_points
);
$message = loadEmailTemplate('add-points', $content, $userid);
// And sent it away
- sendEmail($userid, getMessage('SUBJECT_DIRECT_PAYMENT'), $message);
+ sendEmail($userid, '{--DIRECT_PAYMENT_SUBJECT--}', $message);
if (!isGetRequestParameterSet('mid')) loadTemplate('admin_settings_saved', false, '{--ADMIN_POINTS_ADDED--}');
}
// Do we have cache?
if (!isset($GLOBALS['current_admin_id'])) {
// Get the admin login from session
- $adminLogin = getSession('admin_login');
-
- // "Solve" it into an id
- $adminId = getAdminId($adminLogin);
+ $adminId = getSession('admin_id');
// Remember in cache securely
setCurrentAdminId(bigintval($adminId));
}
// Get password hash from administrator's login name
-function getAdminHash ($adminLogin) {
+function getAdminHash ($adminId) {
// By default an invalid hash is returned
$data['password'] = '-1';
- if (isAdminHashSet($adminLogin)) {
+ if (isAdminHashSet($adminId)) {
// Check cache
- $data['password'] = $GLOBALS['cache_array']['admin']['password'][$adminLogin];
+ $data['password'] = $GLOBALS['cache_array']['admin']['password'][$adminId];
// Update cache hits
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
- $result = SQL_QUERY_ESC("SELECT `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
- array($adminLogin), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+ array(bigintval($adminId)), __FUNCTION__, __LINE__);
// Do we have an entry?
if (SQL_NUMROWS($result) == 1) {
$data = SQL_FETCHARRAY($result);
// Set cache
- setAdminHash($adminLogin, $data['password']);
+ setAdminHash($adminId, $data['password']);
} // END - if
// Free result
// Now a mail to the user and that's all...
$message = loadEmailTemplate('del-user', $data, $userid);
- sendEmail($userid, getMessage('ADMIN_DEL_ACCOUNT'), $message);
+ sendEmail($userid, '{--ADMIN_DEL_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__);
} // END - foreach
} else {
// No cateogries are defined yet
- $OUT = '<option class="member_failed">{--MEMBER_NO_CATS--}</option>';
+ $OUT = '<option class="member_failed">{--MEMBER_NO_CATEGORIES--}</option>';
}
// Return HTML code
$subject,
$notes
), __FUNCTION__, __LINE__, true, $strip);
+
+ // Return insert id which is the task id
+ return SQL_INSERTID();
}
// Updates last module / online time