- Fixed a problem that no cache file was removed and later used after another registration
- Fixed a problem with CSS mode: cache files got created and removed, now only allowed in 'mode 0'
- Fixed a problem with CSS mode again: When ext-cache is registered css.php raises a missing array element 'revision'
- Some double quotes to single quotes converted
- Deprecated (ext-repair vs. ext-menu) includes removed
- Other minor improvements like more debug messages in debug-mode
inc/modules/admin/what-overview.php -text
inc/modules/admin/what-payments.php -text
inc/modules/admin/what-refbanner.php -text
-inc/modules/admin/what-repair_amenu.php -text
inc/modules/admin/what-repair_amnu.php -text
inc/modules/admin/what-repair_cats.php -text
-inc/modules/admin/what-repair_gmenu.php -text
inc/modules/admin/what-repair_gmnu.php -text
-inc/modules/admin/what-repair_mmenu.php -text
inc/modules/admin/what-repair_mmnu.php -text
inc/modules/admin/what-send_bonus.php -text
inc/modules/admin/what-send_newsletter.php -text
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Language loaded.");
$GLOBALS['ext_loaded']['lang'][$ext_name] = true;
loadIncludeOnce($langInclude);
- } elseif (($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
+ } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
// No language file is not so good...
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no language file or we cannot read from it. lang=%s",
$ext_name, getLanguage()
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Functions loaded.");
$GLOBALS['ext_loaded']['funcs'][$ext_name] = true;
loadIncludeOnce($funcsInclude);
- } elseif (($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
+ } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
// No functions file is not so good...
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no own functions file or we cannot read from it.",
$ext_name
//* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()."<br />\n";
// Remove task from system when id and extension's name is valid
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
- array(bigintval($task_id)), __FUNCTION__, __LINE__);
+ array(bigintval($task_id)), __FUNCTION__, __LINE__);
}
// Is this the sql_patches?
$ext_name = GET_EXT_NAME($ext_id);
// If it is not set then maybe there is no extension for that ID number
- if ($ext_name == '') return false;
+ if (empty($ext_name)) {
+ // We should fix these all!
+ debug_report_bug(__FUNCTION__ . ': ext_name is empty. ext_id=' . $ext_id);
+ } // END - if
// Set current SQL name
EXT_SET_CURR_NAME($ext_name);
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":SQLs::count=".COUNT_SQLS()."");
if ((IS_SQLS_VALID() && (COUNT_SQLS() > 0))) {
+ // Run any filters depending on the action here
+ runFilterChain('extension_' . $load_mode, $ext_name);
+
// Run SQL commands...
runFilterChain('run_sqls');
// Empty extension name should be fixed!
if (empty($ext_name)) {
// Please report this bug!
- debug_report_bug(__FUNCTION__.": ext_name is empty which is not allowed here.");
+ debug_report_bug(__FUNCTION__ . ': ext_name is empty which is not allowed here.');
} // END - if
// Extensions are all inactive during installation
} elseif (!EXT_IS_ACTIVE('cache')) {
// Load from database
$result = SQL_QUERY_ESC("SELECT ext_name FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `id`=%s LIMIT 1",
- array(bigintval($ext_id)), __FUNCTION__, __LINE__);
+ array(bigintval($ext_id)), __FUNCTION__, __LINE__);
list($ret) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
}
+
+ // Return the extension name
return $ret;
}
} elseif (!EXT_IS_ACTIVE('cache')) {
// Load from database
$result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
- array($ext_name), __FUNCTION__, __LINE__);
+ array($ext_name), __FUNCTION__, __LINE__);
list($ret) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
}
} // END - if
// Shall we remove? (default, not while just showing an extension removal)
- if (!$dry_run) {
+ if ($dry_run === false) {
// Mark for filter removal
- $GLOBALS['filters']['chains'][$filterName][$filterFunction] = "R";
- unset($GLOBALS['filters']['counter'][$filterName][$filterFunction]);
+ $GLOBALS['filters']['chains'][$filterName][$filterFunction] = 'R';
} // END - if
}
// Is that filter chain there?
if (!isset($GLOBALS['filters']['chains'][$filterName])) {
// Then abort here (quick'N'dirty hack)
- if ((!$silentAbort) && (defined('FILTER_FAILED_NO_FILTER_FOUND'))) {
+ if (($silentAbort === false) && (defined('FILTER_FAILED_NO_FILTER_FOUND'))) {
// Add fatal message
addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_NO_FILTER_FOUND'), $filterName);
} // END - if
// Then run all filters
foreach ($GLOBALS['filters']['chains'][$filterName] as $filterFunction=>$active) {
// Debug message
- //* DEBUG: */ echo __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): name={$filterName},func={$filterFunction},active={$active}<br />\n";
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Running: name={$filterName},func={$filterFunction},active={$active}");
// Is the filter active?
- if ($active == 'Y') {
+ if (($active == 'Y') || ((in_array($filterName, array('extension_remove', 'post_extension_run_sql'))) && ($active == 'R'))) {
// Is this filter there?
if (!function_exists($filterFunction)) {
// Unregister it
$returnValue = call_user_func_array($filterFunction, array($returnValue));
// Update usage counter
- $GLOBALS['filters']['counter'][$filterName][$filterFunction]++;
- } // END - if
+ countFilterUsage($filterName, $filterFunction);
+ } elseif (isDebugModeEnabled()) {
+ // Debug message
+ DEBUG_LOG(__FUNCTION__, __LINE__, "Skipped: name={$filterName},func={$filterFunction},active={$active}");
+ }
} // END - foreach
// Return the filtered content
return $returnValue;
}
+// Count the filter usage
+function countFilterUsage ($filterName, $filterFunction) {
+ // Is it there?
+ if (isset($GLOBALS['filters']['counter'][$filterName][$filterFunction])) {
+ // Yes, then increase
+ $GLOBALS['filters']['counter'][$filterName][$filterFunction]++;
+ } else {
+ // No, then create
+ $GLOBALS['filters']['counter'][$filterName][$filterFunction] = 1;
+ }
+}
+
// -----------------------------------------------------------------------------
// Generic filter functions we always need
// -----------------------------------------------------------------------------
// Load header
loadIncludeOnce('inc/header.php');
- // Prepare message for output
+ // Rewrite message for output
$message = sprintf(getMessage('MXCHANGE_HAS_DIED'), basename($F), $L, $message);
+ // Better log this message away
+ DEBUG_LOG($F, $L, $message);
+
// Load the message template
LOAD_TEMPLATE('admin_settings_saved', false, $message);
if (EXT_IS_ACTIVE('cache')) {
// Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
- if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') $new = true;
- if (!isset($GLOBALS['cache_array']['revision'][$type])
- || count($GLOBALS['cache_array']['revision']) < 3
- || !$GLOBALS['cache_instance']->loadCacheFile('revision')) $new = true;
+ if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') {
+ // Force rebuild by URL parameter
+ $new = true;
+ } elseif ((
+ !isset($GLOBALS['cache_array']['revision'][$type])
+ ) || (
+ count($GLOBALS['cache_array']['revision']) < 3
+ ) || (
+ !$GLOBALS['cache_instance']->loadCacheFile('revision')
+ )) {
+ // Out-dated cache
+ $new = true;
+ } // END - if
// Is the cache file outdated/invalid?
if ($new === true){
- $GLOBALS['cache_instance']->destroyCacheFile(); // @TODO isn't it better to do $GLOBALS['cache_instance']->destroyCacheFile('revision')?
+ // Destroy cache file
+ $GLOBALS['cache_instance']->destroyCacheFile();
// @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')?
unset($GLOBALS['cache_array']['revision']);
// Reload load_cach-revison.php
loadInclude('inc/loader/load_cache-revision.php');
+
+ // Abort here
+ return;
} // END - if
// Return found value
return $GLOBALS['cache_array']['revision'][$type][0];
-
} else {
// Old Version without ext-cache active (deprecated ?)
// Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
if ((REQUEST_ISSET_GET('check_revision_data')) && (REQUEST_GET('check_revision_data') == 'yes')) {
- // Has changed!
+ // Forced rebuild of .revision file
$new = true;
} else {
// Check for revision file
} // END - if
// Add output
- $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>inc/cache/debug.log</strong> in your report (you cannot attach files!):<pre>";
+ $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>inc/cache/debug.log</strong> in your report (you can now attach files):<pre>";
$debug .= debug_get_printable_backtrace();
$debug .= "</pre>\nRequest-URI: " . $_SERVER['REQUEST_URI']."<br />\n";
$debug .= "Thank you for finding bugs.";
// Handle message codes from URL
function handleCodeMessage () {
if (REQUEST_ISSET_GET('msg')) {
- // Default extension is "unknown"
+ // Default extension is 'unknown'
$ext = 'unknown';
// Is extension given?
$this->path = $path;
// Check if path exists
- if ((isDirectory($path)) && (!$tested)) {
+ if ((isDirectory($path)) && ($tested === false)) {
// Make FQFN for dummy file
$fqfn = $path . 'dummy.tmp';
}
// Destroy an existing cache file
- function destroyCacheFile () {
+ function destroyCacheFile ($removeArray = false) {
+ // Only run in regular output mode
+ if (getOutputMode() != 0) {
+ // Debug message if allowed
+ if (isDebugModeEnabled()) {
+ // Debug message
+ DEBUG_LOG(__METHOD__, __LINE__, 'Not removing cache ' . $this->name . ' in output_mode=' . getOutputMode());
+ } // END - if
+
+ // Abort here
+ return;
+ } // END - if
+
// Is the cache file there?
if ((!isset($this->rebuilt[$this->name])) && ($this->isCacheReadable())) {
// Close cache
$this->finalize();
+ // Debug-mode enabled?
+ if (isDebugModeEnabled()) {
+ // Log removal of cache
+ DEBUG_LOG(__METHOD__, __LINE__, 'removing cache: ' . $this->name);
+ } // END - if
+
// Remove cache file from system
- //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): {$this->name} - DESTROYED!<br />\n";
removeFile($this->fqfn);
- // @TODO remove from $GLOBALS['cache_array']!!!
+
+ // Shall we remove the array from memory?
+ if ($removeArray === true) {
+ // Debug message if allowed
+ if (isDebugModeEnabled()) {
+ // Debug message
+ DEBUG_LOG(__METHOD__, __LINE__, 'removing array!');
+ } // END - if
+
+ // Remove it from memory
+ unset($GLOBALS['cache_array'][$this->name]);
+ } // END - if
// Is the file there?
if (!$this->isCacheReadable()) {
if (!isCacheInstanceValid()) return $data;
// Remove cache
- if ($GLOBALS['cache_instance']->loadCacheFile('config')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('extensions')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('modreg')) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile('config')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('extensions')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('modreg')) $GLOBALS['cache_instance']->destroyCacheFile(false);
// Return it
return $data;
if (!isCacheInstanceValid()) return false;
// Remove cache
- if ($GLOBALS['cache_instance']->loadCacheFile('admins')) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile('admins')) $GLOBALS['cache_instance']->destroyCacheFile(false);
}
// Destroy all cache files
function FILTER_CACHE_DESTROY_ALL () {
// Skip this step if the cache instance is not there
+ DEBUG_LOG(__FUNCTION__, __LINE__, 'Called!');
if (!isCacheInstanceValid()) return false;
// Remove cache files
- if ($GLOBALS['cache_instance']->loadCacheFile('admins')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('config')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('extensions')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('modreg')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('refdepths')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('refsystem')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('themes')) $GLOBALS['cache_instance']->destroyCacheFile();
- if ($GLOBALS['cache_instance']->loadCacheFile('revision')) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile('admins')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('config')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('extensions')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('modreg')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('refdepths')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('refsystem')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('themes')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ if ($GLOBALS['cache_instance']->loadCacheFile('revision')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+ DEBUG_LOG(__FUNCTION__, __LINE__, 'Done!');
}
// Filter for purging entire admin menu cache
} else {
// Already added!
$message = sprintf(getMessage('SPONSOR_ALREADY_FOUND', $POST['email']));
- $ret = "already";
+ $ret = 'already';
}
if (!empty($sql)) {
switch (($GLOBALS['cache_instance']->loadCacheFile('extensions', true)) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) {
case true : $GLOBALS['cache_mode'] = 'load'; break;
case false: $GLOBALS['cache_mode'] = 'init'; break;
- }
+ } // END - switch
- // Do we need to init the cache?
- if (($GLOBALS['cache_mode'] == 'init') && (getConfig('cache_exts') == 'Y')) {
+ // Do we need to init the cache? But not in "CSS mode".
+ if (($GLOBALS['cache_mode'] == 'init') && (getConfig('cache_exts') == 'Y') && (getOutputMode() == '0')) {
// Init cache file
$GLOBALS['cache_instance']->init('EXTENSIONS');
$GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
// Register an administrator account
function REGISTER_ADMIN ($user, $md5, $email) {
// Login does already exist
- $ret = "already";
+ $ret = 'already';
// Lookup the admin
$result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_admins` WHERE login='%s' LIMIT 1",
- array($user), __FUNCTION__, __LINE__);
+ array($user), __FUNCTION__, __LINE__);
// Is the entry there?
if (SQL_NUMROWS($result) == 0) {
$add = runFilterChain('sql_admin_extra_data');
// Get password from DB
- $result = SQL_QUERY_ESC("SELECT password".$add." FROM `{!_MYSQL_PREFIX!}_admins` WHERE `id`=%s LIMIT 1",
- array($aid), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT password" . $add . " FROM `{!_MYSQL_PREFIX!}_admins` WHERE `id`=%s LIMIT 1",
+ array($aid), __FUNCTION__, __LINE__);
// Entry found?
if (SQL_NUMROWS($result) == 1) {
if ((GET_EXT_VERSION('admins') >= '0.7.0') && ((EXT_VERSION_IS_OLDER('sql_patches', '0.3.6')) || (GET_EXT_VERSION('sql_patches') == ''))) {
// Reset counter on out-dated sql_patches version
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_admins` SET login_failures=0,last_failure='0000-00-00 00:00:00' WHERE login='%s' LIMIT 1",
- array($adminLogin), __FUNCTION__, __LINE__);
+ array($adminLogin), __FUNCTION__, __LINE__);
// Rebuild cache
rebuildCacheFiles('admins', 'admin');
} // END - if
// Now set all session variables and return the result
- return (
- (
- setSession('admin_md5', generatePassString($passHash))
+ return ((
+ setSession('admin_md5', generatePassString($passHash))
) && (
- setSession('admin_login', $adminLogin)
+ setSession('admin_login', $adminLogin)
) && (
- setSession('admin_last', time())
+ setSession('admin_last', time())
) && (
- setSession('admin_to', bigintval(REQUEST_POST('timeout')))
- )
- );
+ setSession('admin_to', bigintval(REQUEST_POST('timeout')))
+ ));
}
// Only be executed on cookie checking
function CHECK_ADMIN_COOKIES ($admin_login, $password) {
// By default no admin cookies are found
- $ret = '404'; $pass = '';
+ $ret = '404';
+ $pass = '';
// Get hash
$pass = GET_ADMIN_HASH(GET_ADMIN_ID($admin_login));
if (($ret == 'pass') && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass)))) {
// Passwords matches!
$ret = 'done';
- }
+ } // END - if
// Return result
return $ret;
$GLOBALS['menu']['description'][$menu] = $descr;
}
$OUT .= "<li class=\"admin_menu\">
- <div class=\"nobr\"><strong>·</strong> ";
+<div class=\"nobr\"><strong>·</strong> ";
if (($menu == $act) && (empty($wht))) {
$OUT .= "<strong>";
// "Walk" through all entries
foreach ($IDs as $id => $sel) {
// Construct SQL query
- $sql = sprintf("UPDATE `{!_MYSQL_PREFIX!}_%s` SET",
- SQL_ESCAPE($table)
- );
+ $sql = sprintf("UPDATE `{!_MYSQL_PREFIX!}_%s` SET", SQL_ESCAPE($table));
// Load data of entry
$result = SQL_QUERY_ESC("SELECT * FROM `{!_MYSQL_PREFIX!}_%s` WHERE %s=%s LIMIT 1",
- array($table, $idColumn, $id), __FUNCTION__, __LINE__);
+ array($table, $idColumn, $id), __FUNCTION__, __LINE__);
// Fetch the data
$content = SQL_FETCHARRAY($result);
SQL_FREERESULT($result);
// Add all status entries (e.g. status column last_updated or so)
- $newStatus = "UNKNOWN";
- $oldStatus = "UNKNOWN";
- $statusColumn = "unknown";
+ $newStatus = 'UNKNOWN';
+ $oldStatus = 'UNKNOWN';
+ $statusColumn = 'unknown';
foreach ($statusArray as $column => $statusInfo) {
// Does the entry exist?
if ((isset($content[$column])) && (isset($statusInfo[$content[$column]]))) {
$sql .= sprintf(" %s='%s',", SQL_ESCAPE($column), SQL_ESCAPE($statusInfo[$content[$column]]));
// Remember status
- if ($statusColumn == "unknown") {
+ if ($statusColumn == 'unknown') {
// Always (!!!) change status column first!
$oldStatus = $content[$column];
$newStatus = $statusInfo[$oldStatus];
array(bigintval($ext_id)), __FILE__, __LINE__);
list($name, $active) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
- $css = "X";
+ $css = 'X';
}
// Output row
$cssSelection = '---';
- if (GET_EXT_VERSION('sql_patches') >= '0.0.6') $cssSelection = ADD_SELECTION('yn', $css, "css", $ext_id);
+ if (GET_EXT_VERSION('sql_patches') >= '0.0.6') $cssSelection = ADD_SELECTION('yn', $css, 'css', $ext_id);
// Prepare data for the row template
$content = array(
);
// Load row template and switch color
- $OUT .= LOAD_TEMPLATE("admin_extensions_edit_row", true, $content);
+ $OUT .= LOAD_TEMPLATE('admin_extensions_edit_row', true, $content);
$SW = 3 - $SW;
}
} // END - foreach
define('__EXTENSIONS_ROWS', $OUT);
// Load template
- LOAD_TEMPLATE("admin_extensions_edit");
+ LOAD_TEMPLATE('admin_extensions_edit');
$do = 'edit';
}
} elseif ((REQUEST_ISSET_POST('delete')) && ($SEL > 0) && (!IS_DEMO())) {
);
// Load row template and switch color
- $OUT .= LOAD_TEMPLATE("admin_extensions_delete_row", true, $content);
+ $OUT .= LOAD_TEMPLATE('admin_extensions_delete_row', true, $content);
$SW = 3 - $SW;
} // END - foreach
define('__EXTENSIONS_ROWS', $OUT);
// Load template
- LOAD_TEMPLATE("admin_extensions_delete");
- $do = "delete";
+ LOAD_TEMPLATE('admin_extensions_delete');
+ $do = 'delete';
} elseif ((REQUEST_ISSET_POST('remove')) && ($SEL > 0) && (!IS_DEMO())) {
// Remove extensions from DB (you have to delete all files manually!)
$cache_update = 0;
// Is this extension selected?
if ($active == 1) {
- // Run any assigned removal filters
- runFilterChain('extension_remove', GET_EXT_NAME($ext_id));
-
// Run embeded SQL commands
EXTENSION_RUN_SQLS($ext_id, 'remove');
} // END - if
}
// Load data for the template
-switch (REQUEST_GET('mode'))
-{
- case "already": // Already payed out points
+// @TODO Try to rewrite this into include files
+switch (REQUEST_GET('mode')) {
+ case 'already': // Already payed out points
break;
case 'overview': // General overview page
list($cnt) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
- if ((empty($cnt)) || ($cnt == '0'))
- {
+ if ((empty($cnt)) || ($cnt == '0')) {
// Nothing payed out so far
+ // @TODO Rewrite all these constants
define('__DOUBLER_ALREADY_DIRECT_LINK', '0');
+ } else {
+ // Something was payed out
+ $SUM_ALREADY += $cnt;
+ define('__DOUBLER_ALREADY_DIRECT_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=already&select=direct\">".$cnt."</a>");
}
- else
- {
- // Something was payed out
- $SUM_ALREADY += $cnt;
- define('__DOUBLER_ALREADY_DIRECT_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=already&select=direct\">".$cnt."</a>");
- }
- $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='Y' AND is_ref='Y'", __FILE__, __LINE__);
- list($cnt) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
- if ((empty($cnt)) || ($cnt == '0'))
- {
- // Nothing payed out so far
- define('__DOUBLER_ALREADY_REF_LINK', '0');
- }
- else
- {
- // Something was payed out
- $SUM_ALREADY += $cnt;
- define('__DOUBLER_ALREADY_REF_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=already&select=ref\">".$cnt."</a>");
- }
- define('__DOUBLER_ALREADY_ALL_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=already&select=all\">".$SUM_ALREADY."</a>");
+ $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='Y' AND is_ref='Y'", __FILE__, __LINE__);
+ list($cnt) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
+
+ if ((empty($cnt)) || ($cnt == '0')) {
+ // Nothing payed out so far
+ define('__DOUBLER_ALREADY_REF_LINK', '0');
+ } else {
+ // Something was payed out
+ $SUM_ALREADY += $cnt;
+ define('__DOUBLER_ALREADY_REF_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=already&select=ref\">".$cnt."</a>");
+ }
+ define('__DOUBLER_ALREADY_ALL_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=already&select=all\">".$SUM_ALREADY."</a>");
+
+ // And the same for waiting pouts (direct and referal)
+ $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' AND is_ref='N'", __FILE__, __LINE__);
+ list($cnt) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
- // And the same for waiting pouts (direct and referal)
- $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' AND is_ref='N'", __FILE__, __LINE__);
- list($cnt) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ if ((empty($cnt)) || ($cnt == '0')) {
+ // Nothing payed out so far
+ define('__DOUBLER_WAITING_DIRECT_LINK', '0');
+ } else {
+ // Something was payed out
+ $SUM_WAITING += $cnt;
+ define('__DOUBLER_WAITING_DIRECT_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=waiting&select=direct\">".$cnt."</a>");
+ }
- if ((empty($cnt)) || ($cnt == '0'))
- {
- // Nothing payed out so far
- define('__DOUBLER_WAITING_DIRECT_LINK', '0');
- }
- else
- {
- // Something was payed out
- $SUM_WAITING += $cnt;
- define('__DOUBLER_WAITING_DIRECT_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=waiting&select=direct\">".$cnt."</a>");
- }
- $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' AND is_ref='Y'", __FILE__, __LINE__);
- list($cnt) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' AND is_ref='Y'", __FILE__, __LINE__);
+ list($cnt) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
- if ((empty($cnt)) || ($cnt == '0'))
- {
- // Nothing payed out so far
- define('__DOUBLER_WAITING_REF_LINK', '0');
- }
- else
- {
- // Something was payed out
- $SUM_WAITING += $cnt;
- define('__DOUBLER_WAITING_REF_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=waiting&select=ref\">".$cnt."</a>");
- }
- define('__DOUBLER_WAITING_ALL_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=waiting&select=all\">".$SUM_WAITING."</a>");
+ if ((empty($cnt)) || ($cnt == '0')) {
+ // Nothing payed out so far
+ define('__DOUBLER_WAITING_REF_LINK', '0');
+ } else {
+ // Something was payed out
+ $SUM_WAITING += $cnt;
+ define('__DOUBLER_WAITING_REF_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=waiting&select=ref\">".$cnt."</a>");
+ }
+ define('__DOUBLER_WAITING_ALL_LINK', "<a href=\"{!URL!}/modules.php?module=admin&what=list_doubler&mode=waiting&select=all\">".$SUM_WAITING."</a>");
- // All data is loaded here...
- break;
+ // All data is loaded here...
+ break;
}
// Load mode template
-LOAD_TEMPLATE("admin_list_doubler_".REQUEST_GET('mode'));
+LOAD_TEMPLATE('admin_list_doubler_' . REQUEST_GET('mode'));
//
?>
+++ /dev/null
-<?php
-// @DERECATED
-?>
+++ /dev/null
-<?php
-// @DERECATED
-?>
+++ /dev/null
-<?php
-// @DERECATED
-?>
// Check if cache is latest version
if (GET_EXT_VERSION('cache') >= '0.1.2') {
// Is the cache there?
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Using cache.');
if (!isset($GLOBALS['cache_array']['modules'])) {
// This happens when a new extension is registered while ext-cache is installed
$ret = 'cache_miss';
// Is the module cached?
if (isset($GLOBALS['cache_array']['modules']['locked'][$mod_chk])) {
// Check cache
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Cache found.');
$locked = $GLOBALS['cache_array']['modules']['locked'][$mod_chk];
$hidden = $GLOBALS['cache_array']['modules']['hidden'][$mod_chk];
$admin = $GLOBALS['cache_array']['modules']['admin_only'][$mod_chk];
}
} elseif (!EXT_IS_ACTIVE('cache')) {
// Check for module in database
- $result = SQL_QUERY_ESC("SELECT locked, hidden, admin_only, mem_only FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1",
- array($mod_chk), __FUNCTION__, __LINE__);
+ //* DEBUG: */ DEBUG_LOG(__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",
+ array($mod_chk), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Read data
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Entry found.');
list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
$found = true;
+ } elseif (isDebugModeEnabled()) {
+ // Debug message only in debug-mode...
+ DEBUG_LOG(__FUNCTION__, __LINE__, 'Module ' . $mod_chk . ' not found!');
}
+
+ // Free result
+ SQL_FREERESULT($result);
}
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'ret=' . $ret);
// Is the module found?
if ($found === true) {
} // END - if
// Still no luck or not found?
- if (($ret == 'cache_miss') || (!$found)) {
+ if ((($ret == 'cache_miss') || ($found === false)) && (getOutputMode() == '0')) {
// ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name ---
if ((isFileReadable(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s/%s.php", constant('PATH'), $extension, $mod)))) {
// Data is missing so we add it
// Since 0.3.6 we have 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`
-(module, locked, hidden, mem_only, admin_only, has_menu) VALUES
+(`module`, `locked`, `hidden`, `mem_only`, `admin_only`, `has_menu`) VALUES
('%s','Y','N','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__);
} else {
// Wrong/missing sql_patches!
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg`
-(module, locked, hidden, mem_only, admin_only) VALUES
+(`module`, `locked`, `hidden`, `mem_only`, `admin_only`) VALUES
('%s','Y','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__);
}
} // END - if
// Destroy cache here
+ // @TODO Rewrite this to a filter
rebuildCacheFiles('modreg', 'modreg');
// And reload data
} elseif (!$found) {
// Problem with module detected
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s",
- $mod,
- $ret,
- $locked,
- $hidden,
- $mem,
- $admin
+ $mod,
+ $ret,
+ $locked,
+ $hidden,
+ $mem,
+ $admin
));
}
// Return the value
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'ret=' . $ret);
return $ret;
}
// Add menu description pending on given file name (without path!)
-function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
+function ADD_DESCR ($accessLevel, $FQFN, $return = false, $output = true) {
// Use only filename of the FQFN...
$file = basename($FQFN);
// This is an action file!
$type = 'action';
$search = substr($file, 7);
- switch ($ACC_LVL) {
+ switch ($accessLevel) {
case 'admin':
$modCheck = 'admin';
break;
$type = 'what';
$search = substr($file, 5);
$AND = '';
- switch ($ACC_LVL) {
+ switch ($accessLevel) {
case 'admin':
$modCheck = 'admin';
break;
}
break;
}
+
$dummy = substr($search, 0, -4);
- $AND .= " AND `action`='".getModeAction($ACC_LVL, $dummy)."'";
- } elseif (($ACC_LVL == 'sponsor') || ($ACC_LVL == "engine")) {
+ $AND .= " AND `action`='".getModeAction($accessLevel, $dummy)."'";
+ } elseif (($accessLevel == 'sponsor') || ($accessLevel == "engine")) {
// Sponsor / engine menu
$type = 'what';
$search = $file;
$AND = '';
} else {
// Other
- $type = "menu";
+ $type = 'menu';
$search = $file;
$modCheck = getModule();
$AND = '';
$prefix = '';
}
- $prefix .= " -> ";
+ $prefix .= ' -> ';
// We need to remove .php and the end
if (substr($search, -4, 4) == '.php') {
// Get the title from menu
$result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE %s='%s' ".$AND." LIMIT 1",
- array($ACC_LVL, $type, $search), __FUNCTION__, __LINE__);
+ array($accessLevel, $type, $search), __FUNCTION__, __LINE__);
// Menu found?
if (SQL_NUMROWS($result) == 1) {
return $ret;
} elseif (((GET_EXT_VERSION('sql_patches') >= '0.2.3') && (getConfig('youre_here') == 'Y')) || ((IS_ADMIN()) && ($modCheck == 'admin'))) {
// Output HTML code
- $OUT = $prefix."<strong><a class=\"you_are_here\" href=\"{!URL!}/modules.php?module=".$modCheck.'&'.$type.'='.$search.$LINK_ADD."\">".$ret."</a></strong>\n";
+ $OUT = $prefix . "<strong><a class=\"you_are_here\" href=\"{!URL!}/modules.php?module=" . $modCheck . '&' . $type . '=' . $search.$LINK_ADD . "\">" . $ret . "</a></strong>\n";
// Can we close the you-are-here navigation?
//* DEBUG: */ echo __LINE__."*".$type.'/'.getWhat()."*<br />\n";
$GLOBALS['nav_depth'] = '0';
// Run the filter chain
- $ret = runFilterChain('post_youhere_line', array('access_level' => $ACC_LVL, 'type' => $type, 'content' => ""));
+ $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => ""));
$OUT .= $ret['content'];
} // END - if
}
//* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$GLOBALS['pool_cnt']."*<br />";
break;
- case "already":
+ case 'already':
// Entry already found, but we still count one up!
$GLOBALS['pool_cnt']++;
//* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$GLOBALS['pool_cnt']."<br />";
$check = checkModulePermissions($GLOBALS['module']);
switch ($check)
{
- case 'admin_only':
- case 'mem_only':
- case 'done':
+ case 'cache_miss': // The cache is gone
+ case 'admin_only': // Admin-only access
+ case 'mem_only': // Member-only access
+ case 'done': // All fine!
// Does the module exists on local file system?
if ((isFileReadable(constant('__MODULE'))) && (getTotalFatalErrors() == 0)) {
// Module is valid, active and located on the local disc...