- Performance hack in SQL_QUERY() to save some expensive str_replace() and other
function calls
- Encapsulation of admin session data
- Some more usage of EL code in admin welcome templates
- TODOs.txt updated
./inc/language/rallye_de.php:13: * @TODO Naming convention not applied for language strings *
./inc/language/refback_de.php:44:// @TODO Rewrite these constants to one
./inc/language/sponsor_de.php:117:// @TODO Rewrite these four constants to one and use sprintf()
-./inc/libs/admins_functions.php:433: // @TODO This can be, somehow, rewritten
+./inc/libs/admins_functions.php:435: // @TODO This can be, somehow, rewritten
./inc/libs/beg_functions.php:55: // @TODO Try to rewrite the following unset()
./inc/libs/bonus_functions.php:199: // @TODO Move this HTML to a template
./inc/libs/bonus_functions.php:287: // @TODO This query isn't right, it will only update if the user was for a longer time away!
./inc/loader/load_cache-extension.php:13: * @TODO Rewrite this whole file to load_cache-extensions.php *
./inc/module-functions.php:267: // @TODO Nothing helped???
./inc/module-functions.php:308: // @TODO Rewrite this to a filter
-./inc/modules/admin/admin-inc.php:262: // @TODO Rewrite this to $content = SQL_FETCHARRAY()
-./inc/modules/admin/admin-inc.php:267: // @TODO ACL is 'allow'... hmmm
-./inc/modules/admin/admin-inc.php:333: // @TODO Rewrite this to $content = SQL_FETCHARRAY()
-./inc/modules/admin/admin-inc.php:339: // @TODO ACL is 'allow'... hmmm
-./inc/modules/admin/admin-inc.php:439:// @TODO Try to rewrite this to adminAddMenuSelectionBox()
+./inc/modules/admin/admin-inc.php:170: // @TODO This and the next getCurrentAdminId() call might be moved into the templates?
+./inc/modules/admin/admin-inc.php:259: // @TODO Rewrite this to $content = SQL_FETCHARRAY()
+./inc/modules/admin/admin-inc.php:264: // @TODO ACL is 'allow'... hmmm
+./inc/modules/admin/admin-inc.php:330: // @TODO Rewrite this to $content = SQL_FETCHARRAY()
+./inc/modules/admin/admin-inc.php:336: // @TODO ACL is 'allow'... hmmm
+./inc/modules/admin/admin-inc.php:436:// @TODO Try to rewrite this to adminAddMenuSelectionBox()
./inc/modules/admin/overview-inc.php:162: // @TODO Rewrite this to a filter
./inc/modules/admin/overview-inc.php:275: // @TODO Rewrite this to something with include files and/or filter
./inc/modules/admin/overview-inc.php:309: // @TODO This may also be rewritten to include files
./inc/modules/admin/what-list_links.php:85: // @TODO Find a way to rewrite this. See some lines above for different queries
./inc/modules/admin/what-list_links.php:94: // @TODO Rewrite this to includes/filter
./inc/modules/admin/what-list_refs.php:107: // @TODO Try to rewrite some to EL
-./inc/modules/admin/what-list_unconfirmed.php:77: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}');
-./inc/modules/admin/what-list_unconfirmed.php:96: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus
+./inc/modules/admin/what-list_unconfirmed.php:80: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}');
+./inc/modules/admin/what-list_unconfirmed.php:99: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus
./inc/modules/admin/what-list_user.php:149: // @TODO Rewrite these to filters
./inc/modules/admin/what-list_user.php:255: // @TODO Rewrite this into a filter
./inc/modules/admin/what-list_user.php:295: // @TODO Rewrite this into a filter
./inc/modules/order.php:74: // @TODO Unused: 2,4
./inc/monthly/monthly_bonus.php:67: // @TODO Rewrite this to a filter
./inc/mysql-manager.php:1183: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1438: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
-./inc/mysql-manager.php:1544: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1915: // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1959:// @TODO Fix inconsistency between last_module and getWhat()
+./inc/mysql-manager.php:1441: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/mysql-manager.php:1547: // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1918: // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1962:// @TODO Fix inconsistency between last_module and getWhat()
./inc/mysql-manager.php:368: // @TODO Try to rewrite this to one or more functions
./inc/mysql-manager.php:44:// @TODO Can we cache this?
./inc/reset/reset_beg.php:52:// @TODO This should be converted in a daily beg rallye
./inc/reset/reset_birthday.php:92: // @TODO 4 is hard-coded here, should we move it out in config?
./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array'
-./inc/template-functions.php:1041: // @TODO Deprecate this thing
-./inc/template-functions.php:1052: // @TODO Deprecate this thing
-./inc/template-functions.php:1139: // @TODO This can be easily moved out after the merge from EL branch to this is complete
-./inc/template-functions.php:1172: // @TODO Add a little more infos here
-./inc/template-functions.php:1460:// @TODO Lame description for this function
-./inc/template-functions.php:1482: // @TODO Move this in a filter
-./inc/template-functions.php:187: * @TODO On some pages this is buggy
-./inc/template-functions.php:263: // @TODO Remove this sanity-check if all is fine
-./inc/template-functions.php:576:// @TODO $simple/$constants are deprecated
-./inc/template-functions.php:600: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates
+./inc/template-functions.php:1043: // @TODO Deprecate this thing
+./inc/template-functions.php:1054: // @TODO Deprecate this thing
+./inc/template-functions.php:1141: // @TODO This can be easily moved out after the merge from EL branch to this is complete
+./inc/template-functions.php:1174: // @TODO Add a little more infos here
+./inc/template-functions.php:1462:// @TODO Lame description for this function
+./inc/template-functions.php:1484: // @TODO Move this in a filter
+./inc/template-functions.php:189: * @TODO On some pages this is buggy
+./inc/template-functions.php:265: // @TODO Remove this sanity-check if all is fine
+./inc/template-functions.php:578:// @TODO $simple/$constants are deprecated
+./inc/template-functions.php:602: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates
./inc/wrapper-functions.php:130:// @TODO Implement $compress
./inc/wrapper-functions.php:137:// @TODO Implement $decompress
./inc/wrapper-functions.php:452:// @TODO Do some more sanity check here
./templates/de/html/member/member_unconfirmed_table_nopoints.tpl:11: <!-- @TODO Nothing to say here? //-->
./templates/de/html/surfbar/surfbar_frame_textlinks.tpl:5: <!-- @TODO These are static lines and should be replaced by a filter (see ext-sponsor) //-->
### ### DEPRECATION FOLLOWS: ### ###
-./inc/modules/admin/admin-inc.php:440:// @DEPRECATED
+./inc/modules/admin/admin-inc.php:437:// @DEPRECATED
### ### template-warnings.log follows: ### ###
Warning: Not parsing JavaScript templates/de/html/js/js_order_send.tpl.
Warning: Not parsing JavaScript templates/de/html/js/js_cookies_disabled.tpl.
// SQL queries
function SQL_QUERY ($sqlString, $F, $L, $enableCodes = true) {
- // Trim SQL string
- $sqlString = trim($sqlString);
-
- // Link is up?
- if (!SQL_IS_LINK_UP()) {
- // We should not quietly ignore this!
- debug_report_bug(__FUNCTION__, __LINE__, sprintf("Cannot query database: sqlString=%s,file=%s,line=%s",
- $sqlString,
- basename($F),
- $L
- ));
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$sqlString])) {
+ // Trim SQL string
+ $sqlStringModified = trim($sqlString);
+
+ // Empty query string or link is not up?
+ if (empty($sqlStringModified)) {
+ // Empty SQL string!
+ debug_report_bug(__FUNCTION__, __LINE__, sprintf("SQL string is empty. Please fix this. file=%s, line=%s",
+ basename($F),
+ $L
+ ));
+ } elseif (!SQL_IS_LINK_UP()) {
+ // We should not quietly ignore this
+ debug_report_bug(__FUNCTION__, __LINE__, sprintf("Cannot query database: sqlString=%s,file=%s,line=%s",
+ $sqlStringModified,
+ basename($F),
+ $L
+ ));
+ }
- // Return 'false' because it has failed
- return false;
- } elseif (empty($sqlString)) {
- // Empty SQL string!
- debug_report_bug(__FUNCTION__, __LINE__, sprintf("SQL string is empty. Please fix this. file=%s, line=%s",
- basename($F),
- $L
- ));
+ // Remove \t, \n and \r from queries they may confuse some MySQL versions
+ $sqlStringModified = str_replace("\t", ' ', str_replace("\n", ' ', str_replace("\r", ' ', $sqlStringModified)));
- // This is invalid, of course
- return false;
- }
+ // Compile config entries out
+ $sqlStringModified = SQL_PREPARE_SQL_STRING($sqlStringModified, $enableCodes);
- // Remove \t, \n and \r from queries they may confuse some MySQL versions
- $sqlString = str_replace("\t", ' ', str_replace("\n", ' ', str_replace("\r", ' ', $sqlString)));
+ // Cache it and remember as last SQL query
+ $GLOBALS[__FUNCTION__][$sqlString] = $sqlStringModified;
+ $GLOBALS['last_sql'] = $sqlStringModified;
+ } else {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cache used!');
- // Compile config entries out
- $GLOBALS['last_sql'] = SQL_PREPARE_SQL_STRING($sqlString, $enableCodes);
+ // Use cache (to save a lot function calls
+ $sqlString = $GLOBALS[__FUNCTION__][$sqlString];
+ }
// Starting time
$querytimeBefore = microtime(true);
addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD default_acl ENUM('deny','allow') NOT NULL DEFAULT 'deny'");
// But allow current admin everything (THIS SHALL BE YOU!)
- addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `default_acl`='allow' WHERE `id`=".bigintval(getSession('admin_id'))." LIMIT 1");
+ addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `default_acl`='allow' WHERE `id`=".bigintval(getCurrentAdminId())." LIMIT 1");
addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_admins_acls`');
addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_admins_acls` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
function FILTER_DO_LOGIN_ADMIN ($data) {
// Now set all session variables and store the result for later processing
$GLOBALS['admin_login_success'] = ((
- setSession('admin_md5', encodeHashForCookie($data['pass_hash']))
+ setAdminMd5(encodeHashForCookie($data['pass_hash']))
) && (
- setSession('admin_id', $data['id'])
+ setAdminId($data['id'])
) && (
- setSession('admin_last', time())
+ setAdminLast(time())
));
// Return the data for further processing
// Rewrite cookie when it's own account
if ($adminId == $id) {
// Set timeout cookie
- setSession('admin_last', time());
+ setAdminLast(time());
- if ($adminId != getSession('admin_id')) {
+ if ($adminId != getCurrentAdminId()) {
// Update login cookie
- setSession('admin_id', $adminId);
+ setAdminId($adminId);
// Update password cookie as well?
- if (!empty($add)) setSession('admin_md5', $hash);
- } elseif (generateHash($postData['pass1'][$id], $salt) != getSession('admin_md5')) {
+ if (!empty($add)) {
+ setAdminMd5($hash);
+ } // END - if
+ } elseif (generateHash($postData['pass1'][$id], $salt) != getAdminMd5()) {
// Update password cookie
- setSession('admin_md5', $hash);
+ setAdminMd5($hash);
}
} // END - if
adminsChangeAdminAccount($postData);
// Update cookie/session and data array
- setSession('admin_md5', encodeHashForCookie($newHash));
+ setAdminMd5(encodeHashForCookie($newHash));
$data['pass_hash'] = $newHash;
// Always make sure the cache is destroyed
}
} else {
// Maybe an Admin want's to login?
- $ret = ifAdminCookiesAreValid(getSession('admin_id'), getSession('admin_md5'));
+ $ret = ifAdminCookiesAreValid(getCurrentAdminId(), getAdminMd5());
// Check status
switch ($ret) {
case '404': // Administrator login not found
setPostRequestParameter('ok', $ret);
- loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_ACCOUNT_404', getSession('admin_id')));
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_ACCOUNT_404', getCurrentAdminId()));
destroyAdminSession();
break;
// Get action value
$action = getActionFromModuleWhat(getModule(), $what);
- // Define admin login name and id number
- $content['login'] = getAdminLogin(getSession('admin_id'));
- $content['id'] = getCurrentAdminId();
-
- // Preload templates
+ // Load welcome template
if (isExtensionActive('admins')) {
- $content['welcome'] = loadTemplate('admin_welcome_admins', true, $content);
+ // @TODO This and the next getCurrentAdminId() call might be moved into the templates?
+ $content['welcome'] = loadTemplate('admin_welcome_admins', true, getCurrentAdminId());
} else {
- $content['welcome'] = loadTemplate('admin_welcome', true, $content);
+ $content['welcome'] = loadTemplate('admin_welcome', true, getCurrentAdminId());
}
// Load header, footer, render menu
// Is the element set, then we need to change the admin
if (isPostRequestParameterSet('expert_settings')) {
// Get it and prepare final post data array
- $postData['login'][getCurrentAdminId()] = getAdminLogin(getCurrentAdminId());
+ $postData['login'][getCurrentAdminId()] = getCurrentAdminLogin();
$postData['expert_warning'][getCurrentAdminId()] = 'N';
// Change it in the admin
if (((isPostRequestParameterSet('action_menu')) || (isPostRequestParameterSet('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",
- array(bigintval(postRequestParameter('admin_id')), postRequestParameter('action_menu'), postRequestParameter('what_menu')), __FILE__, __LINE__);
+ array(
+ bigintval(postRequestParameter('admin_id')),
+ postRequestParameter('action_menu'),
+ postRequestParameter('what_menu')
+ ), __FILE__, __LINE__);
if (SQL_HASZERONUMS($result)) {
// Finally add the new ACL
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_acls` (`admin_id`, `action_menu`, `what_menu`, `access_mode`)
// List found rallyes
$OUT = '';
while ($data = SQL_FETCHARRAY($result)) {
- // Load admin login
- $data['login'] = getAdminLogin($data['admin_id']);
-
// Count joined userids
$users = countSumTotalData($data['id'], 'rallye_users', 'id', 'rallye_id', true);
$users = '<a href="{%url=modules.php?module=admin&what=list_rallyes&sub=users&rallye=' . $data['id'] . '%}" title="{--RALLYE_LIST_USERS_TITLE--}">' . $users . '</a>';
} // END - if
- // Alter some variables
- if (empty($data['login'])) $data['login'] = '???';
-
// Transfer data into array for the template
$row = array(
'select' => '<input type="checkbox" name="sel[' . $data['id'] . ']" class="form_field" value="1" />',
'admin_id' => $data['admin_id'],
- 'login' => $data['login'],
'id' => $data['id'],
'title' => $data['title'],
'template' => $data['template'],
// Don't load the admin_list_unconfirmed template by default
$listed = false;
+// Init query
+$sql = '';
+
// List confirmation links from normal or bonus mails
if (isGetRequestParameterSet('mid')) {
// SQL query for mail data
}
// Shall I display links or not?
-if ($listed === true) {
+if (($listed === true) && (!empty($sql))) {
// Load mail data
$result_master = SQL_QUERY($sql, __FILE__, __LINE__);
// If admin login is not given take current from cookies...
if ((isSessionVariableSet('admin_id')) && (isSessionVariableSet('admin_md5'))) {
// Get admin login and password from session/cookies
- $adminId = getSession('admin_id');
- $passCookie = getSession('admin_md5');
+ $adminId = getCurrentAdminId();
+ $passCookie = getAdminMd5();
} // END - if
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminId.'/'.$passCookie);
// "Getter" for current admin id
function getCurrentAdminId () {
+ // Log debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
+
// Do we have cache?
if (!isset($GLOBALS['current_admin_id'])) {
// Get the admin login from session
// Some security stuff...
if (!defined('__SECURITY')) {
die();
-}
+} // END - if
// Don't run on daily reset
if (isResetModeEnabled()) {
// Destroys the admin session
function destroyAdminSession ($destroy = true) {
// Kill maybe existing session variables including array elements
- setSession('admin_id' , '');
- setSession('admin_md5' , '');
- setSession('admin_last', '');
+ setAdminId('');
+ setAdminMd5('');
+ setAdminLast('');
- // Destroy session and return status
- if ($destroy) {
+ // Destroy session if requested and return status
+ if ($destroy === true) {
return session_destroy();
} // END - if
$str = trim($str);
// Is the string empty?
- if (empty($str)) $str = '---';
+ if (empty($str)) {
+ $str = '---';
+ } // END - if
// Return string
return $str;
// Base directory
$basePath = sprintf("%stemplates/%s/html/", getPath(), getLanguage());
- $extraPath = detectExtraTemplatePath($template);;
+ $extraPath = detectExtraTemplatePath($template);
// Generate FQFN
$FQFN = $basePath . $extraPath . $template . '.tpl';
// Is cache set?
if (!isset($GLOBALS[__FUNCTION__])) {
// Simply check it
- $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getAdminLogin(getSession('admin_id')) == 'demo'));
+ $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
} // END - if
// Return it
$GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
}
+// Getter for current admin login
+function getCurrentAdminLogin () {
+ // Log debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
+
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
+ } // END - if
+
+ // Return it
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Setter for admin id (and current)
+function setAdminId ($adminId) {
+ // Log debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
+
+ // Set session
+ $status = setSession('admin_id', bigintval($adminId));
+
+ // Set current id
+ setCurrentAdminId($adminId);
+
+ // Return status
+ return $status;
+}
+
+// Setter for admin_last
+function setAdminLast ($adminLast) {
+ // Log debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
+
+ // Set session
+ $status = setSession('admin_last', $adminLast);
+
+ // Return status
+ return $status;
+}
+
+// Setter for admin_md5
+function setAdminMd5 ($adminMd5) {
+ // Log debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
+
+ // Set session
+ $status = setSession('admin_md5', $adminMd5);
+
+ // Return status
+ return $status;
+}
+
+// Getter for admin_md5
+function getAdminMd5 () {
+ // Log debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
+
+ // Get session
+ return getSession('admin_md5');
+}
+
// Init user data array
function initUserData () {
// User id should not be zero
</td>
<td align="center" width="300" class="dashed tiny">
Aktueller Admin:
- [<span class="notice tiny" title="Erweiterung admins nicht installiert.">$content[login]</span>]
+ [<span class="notice tiny" title="Erweiterung admins nicht installiert.">{%pipe,getAdminLogin=$content[id]%}</span>]
</td>
<td class="logout_box top bottom right" align="center" width="100">
<a class="logout_box tiny" href="{%url=modules.php?module=admin&action=logout%}">Ausloggen</a>
</td>
<td align="center" width="300" class="dashed tiny">
Aktueller Admin:
- [<a class="tiny" href="{%url=modules.php?module=admin&what=admins_edit&admin=$content[id]%}"><strong>$content[login]</strong></a>]
+ [<a class="tiny" href="{%url=modules.php?module=admin&what=admins_edit&admin=$content%}"><strong>{%pipe,getAdminLogin=$content%}</strong></a>]
</td>
<td align="center" width="100" class="logout_box top bottom right">
<a class="logout_box tiny" href="{%url=modules.php?module=admin&action=logout%}">Ausloggen</a>