// Destroy cache here
// @TODO Rewrite this to a filter
- if (getOutputMode() == '0') rebuildCacheFile('modreg', 'modreg');
+ if (getOutputMode() == 0) rebuildCacheFile('modules', 'modules');
// And reload data
unset($GLOBALS['module_status'][$mod]);
}
} elseif (($ret == 'cache_miss') && (getOutputMode() == 0)) {
// Rebuild the cache files
- rebuildCacheFile('modreg', 'modreg');
+ rebuildCacheFile('modules', 'modules');
} elseif ($found === false) {
// Problem with module detected
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s, output_mode=%s",
//* DEBUG: */ outputHtml(__LINE__.'+'.$type."+<br />");
// Add closing div and br-tag
$OUT .= "</div><br />\n";
- $GLOBALS['nav_depth'] = '0';
+ $GLOBALS['nav_depth'] = 0;
// Run the filter chain
$ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => ""));
// Get admin login and password from session/cookies
$admin = getSession('admin_login');
$passCookie = getSession('admin_md5');
- }
+ } // END - if
//* DEBUG: */ outputHtml(__LINE__."ADMIN:".$admin.'/'.$passCookie."<br />");
// Search in array for entry
if (isset($GLOBALS['admin_hash'])) {
// Use cached string
$valPass = $GLOBALS['admin_hash'];
- } elseif ((!empty($passCookie)) && (isset($GLOBALS['cache_array']['admins']['password'][$admin])) && (!empty($admin))) {
+ } elseif ((!empty($passCookie)) && (isAdminHashSet($admin) === true) && (!empty($admin))) {
// Login data is valid or not?
- $valPass = generatePassString($GLOBALS['cache_array']['admins']['password'][$admin]);
+ $valPass = generatePassString(getAdminHash($admin));
// Cache it away
$GLOBALS['admin_hash'] = $valPass;
// Count cache hits
incrementStatsEntry('cache_hits');
- } elseif ((!empty($admin)) && ((!isExtensionActive('cache'))) || (!isset($GLOBALS['cache_array']['admins']['password'][$admin]))) {
+ } elseif ((!empty($admin)) && ((!isExtensionActive('cache'))) || (isAdminHashSet($admin) === false)) {
// Search for admin
$result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
array($admin), __FUNCTION__, __LINE__);
list($passDB) = SQL_FETCHROW($result);
// Temporary cache it
- $GLOBALS['cache_array']['admins']['password'][$admin] = $passDB;
+ setAdminHash($admin, $passDB);
// Generate password hash
$valPass = generatePassString($passDB);
if (!empty($valPass)) {
// Check if password is valid
- //* DEBUG: */ outputHtml(__FUNCTION__."*".$valPass.'/'.$passCookie."*<br />");
- $ret = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == "*FAILED*") && (!isExtensionActive('cache'))));
+ //* DEBUG: */ print(__FUNCTION__ . ':' . $valPass . '/' . $passCookie . '<br />');
+ $ret = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == '*FAILED*') && (!isExtensionActive('cache'))));
} // END - if
// Return result of comparision
}
// Validate the given menu action
-function isMenuActionValid ($mode, $action, $what, $UPDATE=false) {
+function isMenuActionValid ($mode, $action, $what, $updateEntry=false) {
// Is the cache entry there and we shall not update?
- if ((isset($GLOBALS['action_valid'][$mode][$action][$what])) && ($UPDATE === false)) {
+ if ((isset($GLOBALS['action_valid'][$mode][$action][$what])) && ($updateEntry === false)) {
// Count cache hit
incrementStatsEntry('cache_hits');
if ((!isAdmin()) && ($mode != 'admin')) $add = " AND `locked`='N'";
//* DEBUG: */ outputHtml(__LINE__.':'.$mode.'/'.$action.'/'.$what."*<br />");
- if (($mode != 'admin') && ($UPDATE === true)) {
+ 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",
array($mode, $action, $what), __FUNCTION__, __LINE__, false);
// Run SQL command
$result = SQL_QUERY($sql, __FUNCTION__, __LINE__);
- if ($UPDATE === true) {
+ if ($updateEntry === true) {
// Check updated/affected rows
$ret = (SQL_AFFECTEDROWS() == 1);
} else {
loadTemplate('admin_settings_saved', false, $content);
}
-// Update module counter
-function countModuleHit($mod) {
- // Do count all other modules but not accesses on CSS file css.php!
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `clicks`=`clicks`+1 WHERE `module`='%s' LIMIT 1",
- array($mod), __FUNCTION__, __LINE__);
-}
-
// Get action value from mode (admin/guest/member) and what-value
function getModeAction ($mode, $what) {
// Init status
} elseif ((!isExtensionInstalled('sql_patches')) && ($mode != 'admin')) {
// No sql_patches installed, but maybe we need to register an admin?
if (isAdminRegistered()) {
- // Redirect
- // @TODO Why does this lead into an endless loop but we still need it???
- // @TODO Commented out redirectToUrl('admin.php');
+ // Redirect to admin area
+ redirectToUrl('admin.php');
} // END - if
}
$ret = getMessage('_CATEGORY_404');
// Is the category id set?
- if ($cid == '0') {
+ if ($cid == 0) {
// No category
$ret = getMessage('_CATEGORY_NONE');
} elseif ($cid > 0) {
function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '') {
$ret = 0;
//* DEBUG: */ outputHtml($search.'/'.$tableName.'/'.$lookFor.'/'.$whereStatement.'/'.$add.'<br />');
- if ((empty($search)) && ($search != '0')) {
+ if ((empty($search)) && ($search != 0)) {
// Count or sum whole table?
if ($countRows === true) {
// Count whole table
$ret = '0.00000';
} elseif (''.$ret.'' == '') {
// Fix empty result
- $ret = '0';
+ $ret = 0;
}
// Return value
$per = 0;
// Do we have cache?
- if ((isset($GLOBALS['cache_array']['ref_depths']['level'])) && (isExtensionActive('cache'))) {
+ if ((isset($GLOBALS['cache_array']['refdepths']['level'])) && (isExtensionActive('cache'))) {
// First look for level
- $key = array_search($level, $GLOBALS['cache_array']['ref_depths']['level']);
+ $key = array_search($level, $GLOBALS['cache_array']['refdepths']['level']);
if ($key !== false) {
// Entry found!
- $per = $GLOBALS['cache_array']['ref_depths']['percents'][$key];
+ $per = $GLOBALS['cache_array']['refdepths']['percents'][$key];
// Count cache hit
incrementStatsEntry('cache_hits');
- }
+ } // END - if
} elseif (!isExtensionActive('cache')) {
// Get referal data
- $result_level = SQL_QUERY_ESC("SELECT percents FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE level='%s' LIMIT 1",
+ $result_level = SQL_QUERY_ESC("SELECT `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level`='%s' LIMIT 1",
array(bigintval($level)), __FUNCTION__, __LINE__);
// Entry found?
* add_mode = Add points only to $userid or also refs? (WARNING! Changing 'ref' to 'direct'
* for default value will cause no referal will get points ever!!!)
*/
-function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $rid = '0', $locked = false, $add_mode = 'ref') {
+function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $rid = 0, $locked = false, $add_mode = 'ref') {
//* DEBUG: */ outputHtml("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");
// Convert mode to lower-case
$add_mode = strtolower($add_mode);
// When $userid = 0 add points to jackpot
- if (($userid == '0') && (isExtensionActive('jackpot'))) {
+ if (($userid == 0) && (isExtensionActive('jackpot'))) {
// Add points to jackpot
addPointsToJackpot($points);
return;
'subject' => $subject,
'userid' => $userid,
'points' => $points,
- 'notify' => $notify,
+ 'notify' => $sendNotify,
'rid' => $rid,
'locked' => $locked,
'mode' => 'add',
$ret = '-1';
// Check cache
- if (isset($GLOBALS['cache_array']['admins']['admin_id'][$login])) {
+ if (isset($GLOBALS['cache_array']['admin']['admin_id'][$login])) {
// Use it if found to save SQL queries
- $ret = $GLOBALS['cache_array']['admins']['admin_id'][$login];
+ $ret = $GLOBALS['cache_array']['admin']['admin_id'][$login];
// Update cache hits
incrementStatsEntry('cache_hits');
}
// Get password hash from administrator's login name
-function getAdminHash ($adminId) {
+function getAdminHash ($admin) {
// By default an invalid hash is returned
$ret = '-1';
- if (isset($GLOBALS['cache_array']['admins']['password'][$adminId])) {
+ if (isAdminHashSet($admin)) {
// Check cache
- $ret = $GLOBALS['cache_array']['admins']['password'][$adminId];
+ $ret = $GLOBALS['cache_array']['admin']['password'][$admin];
// Update cache hits
incrementStatsEntry('cache_hits');
} elseif (!isExtensionActive('cache')) {
// Load from database
$result = SQL_QUERY_ESC("SELECT password FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
- array($adminId), __FUNCTION__, __LINE__);
+ array($admin), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Fetch data
list($ret) = SQL_FETCHROW($result);
// Set cache
- $GLOBALS['cache_array']['admins']['password'][$adminId] = $ret;
+ setAdminHash($admin, $ret);
} // END - if
// Free result
// By default a non-existent login is returned (other functions react on this!)
$ret = '***';
- if (isset($GLOBALS['cache_array']['admins']['login'][$adminId])) {
+ if (isset($GLOBALS['cache_array']['admin']['login'][$adminId])) {
// Get cache
- $ret = $GLOBALS['cache_array']['admins']['login'][$adminId];
+ $ret = $GLOBALS['cache_array']['admin']['login'][$adminId];
// Update cache hits
incrementStatsEntry('cache_hits');
list($ret) = SQL_FETCHROW($result);
// Set cache
- $GLOBALS['cache_array']['admins']['login'][$adminId] = $ret;
+ $GLOBALS['cache_array']['admin']['login'][$adminId] = $ret;
} // END - if
// Free memory
// By default an invalid emails is returned
$ret = '***';
- if (isset($GLOBALS['cache_array']['admins']['email'][$adminId])) {
+ if (isset($GLOBALS['cache_array']['admin']['email'][$adminId])) {
// Get cache
- $ret = $GLOBALS['cache_array']['admins']['email'][$adminId];
+ $ret = $GLOBALS['cache_array']['admin']['email'][$adminId];
// Update cache hits
incrementStatsEntry('cache_hits');
list($ret) = SQL_FETCHROW($result_admin_id);
// Set cache
- $GLOBALS['cache_array']['admins']['email'][$adminId] = $ret;
+ $GLOBALS['cache_array']['admin']['email'][$adminId] = $ret;
} // END - if
// Free result
if (!isExtensionActive('sql_patches')) {
// Not found, which is bad, so we need to allow all
$ret = 'allow';
- } elseif (isset($GLOBALS['cache_array']['admins']['def_acl'][$adminId])) {
+ } elseif (isset($GLOBALS['cache_array']['admin']['def_acl'][$adminId])) {
// Use cache
- $ret = $GLOBALS['cache_array']['admins']['def_acl'][$adminId];
+ $ret = $GLOBALS['cache_array']['admin']['def_acl'][$adminId];
// Update cache hits
incrementStatsEntry('cache_hits');
list($ret) = SQL_FETCHROW($result_admin_id);
// Set cache
- $GLOBALS['cache_array']['admins']['def_acl'][$adminId] = $ret;
+ $GLOBALS['cache_array']['admin']['def_acl'][$adminId] = $ret;
}
// Free result
updateConfiguration('activate_xchange' ,0);
// Rebuild cache
- rebuildCacheFile('modreg', 'modreg');
+ rebuildCacheFile('modules', 'modules');
} // END - if
}