define('SERVER_URL', "http://www.mxchange.org");
// Current SVN revision
-define('CURR_SVN_REVISION', "622");
+define('CURR_SVN_REVISION', "623");
// Take a prime number which is long (if you know a longer one please try it out!)
define('_PRIME', 591623);
// Skip double close
return false;
} // END - if
+
+ // Do we need to update cache/db counter?
//* DEBUG: */ echo "DB=".$_CONFIG['db_hits'].",CACHE=".$_CONFIG['cache_hits']."<br />\n";
if ((GET_EXT_VERSION("cache") >= "0.0.7") && (isset($_CONFIG['db_hits'])) && (isset($_CONFIG['cache_hits'])) && (is_object($cacheInstance))) {
// Add new hits
if ((EXT_IS_ACTIVE("cache")) || (GET_EXT_VERSION("cache") != "")) {
//* DEBUG: */ echo __LINE__.": DESTROY!<br />\n";
// Remove cache files
- if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
- if ($cacheInstance->cache_file("mod_reg")) $cacheInstance->cache_destroy();
- if ($cacheInstance->cache_file("config")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
} // END - if
// Check for added include files
if (((EXT_IS_ACTIVE("cache")) || (GET_EXT_VERSION("cache") != "")) && (((SQL_AFFECTEDROWS() == 1)) || ($sqlRan === true) || ($EXT_LOAD_MODE == "activate") || ($EXT_LOAD_MODE == "deactivate"))) {
//* DEBUG: */ echo __LINE__.": DESTROY!<br />\n";
// Remove cache files
- if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
- if ($cacheInstance->cache_file("mod_reg")) $cacheInstance->cache_destroy();
- if ($cacheInstance->cache_file("config")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
// @TODO This causes the whole (!) menu cache being purged
CACHE_PURGE_ADMIN_MENU();
// Update cache
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
- if ($cacheInstance->cache_file("config")) $cacheInstance->cache_destroy();
- if ($cacheInstance->cache_file("mod_reg")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
} // END - if
// Remove array
break;
case "0.0.4": // SQL queries for v0.0.4
- // Update notes (these will be set as task text!)
+ // Is the cache extension itself there?
if (EXT_IS_ACTIVE("cache")) {
// Check for cache when extension is already installed
- if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
} // END - if
+
+ // Update notes (these will be set as task text!)
$UPDATE_NOTES = "Spalte "keep_active" ist hinzugefügt. Cache wurde reinitialisiert.";
break;
// Create instance on class
if ($cacheMode != "init") {
// Initialize cache system only when it's needed
- $cacheInstance = new mxchange_cache($_CONFIG['cache_update'], PATH."inc/".$_CONFIG['cache_path'], $_CONFIG['cache_tested']);
+ $cacheInstance = new CacheSystem($_CONFIG['cache_update'], PATH."inc/".$_CONFIG['cache_path'], $_CONFIG['cache_tested']);
if ($cacheInstance->getStatus() != "done") {
// Failed to initialize cache sustem
ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_INITIALIZE);
// Remove extensions and mod_reg cache file
require_once(PATH."inc/libs/cache_functions.php");
require_once(PATH."inc/extensions/ext-cache.php");
- if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
- if ($cacheInstance->cache_file("mod_reg")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
} // END - if
} // END - if
// Shall I remove the cache file?
if ((EXT_IS_ACTIVE("cache")) && (is_object($cacheInstance))) {
// Rebuild cache
- if ($cacheInstance->cache_file($cache)) {
+ if ($cacheInstance->loadCacheFile($cache)) {
// Destroy it
- $cacheInstance->cache_destroy();
+ $cacheInstance->destroyCacheFile();
} // END - if
// Include file given?
// Remove cache file
if ((EXT_IS_ACTIVE("cache")) && ($cache_update == "1")) {
- if ($cacheInstance->cache_file("admins")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("admins")) $cacheInstance->destroyCacheFile();
}
}
// Remove cache if cache system is activated
if ((EXT_IS_ACTIVE("cache")) && ($cache_update == "1")) {
- if ($cacheInstance->cache_file("admins")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("admins")) $cacheInstance->destroyCacheFile();
}
}
}
// Caching class
-class mxchange_cache {
+class CacheSystem {
// Define variables
var $ret = "init";
- var $cache_path = "";
- var $cache_inc = "";
- var $cache_pointer = false;
- var $cache_data = "";
- var $cache_version = "";
- var $cache_file = "";
+ var $path = "";
+ var $inc = "";
+ var $pointer = false;
+ var $data = "";
+ var $version = "";
+ var $name = "";
// Constructor
- function mxchange_cache($interval, $path, $tested) {
+ function CacheSystem ($interval, $path, $tested) {
// Failed is the default
$this->ret = "failed";
// Remeber path
- $this->cache_path = $path;
+ $this->path = $path;
// Check if path exists
if ((is_dir($path)) && (!$tested)) {
}
// Checks validity of cache file and if content is given
- function cache_file ($file, $forceContent = false) {
+ function loadCacheFile ($file, $forceContent = false) {
// Remember cache file
- $this->cache_file = $file;
+ $this->name = $file;
// Construct FQFN (full qualified file name)
- $inc = $this->cache_path.$file.".cache";
-
- // Rember it + filename in class
- $this->cache_inc = $inc;
+ $this->inc = $this->path.$file.".cache";
// Check if file exists and if version matches
- $status = (FILE_READABLE($inc) && (is_writeable($inc)) && ($this->ext_version_matches("cache")));
+ $status = (FILE_READABLE($this->inc) && (is_writeable($this->inc)) && ($this->extensionVersionMatches("cache")));
// Return status
return $status;
}
- function cache_init($array) {
+ function init () {
// This will destory an existing cache file!
if ($this->ret == "done") {
// Create file
- if (FILE_READABLE($this->cache_inc)) chmod($this->cache_inc, 0666);
- $this->cache_pointer = fopen($this->cache_inc, 'w') or mxchange_die("Cannot write to cache ".$this->cache_inc." !");
+ if (FILE_READABLE($this->inc)) chmod($this->inc, 0666);
+ $this->pointer = fopen($this->inc, 'w') or mxchange_die("Cannot write to cache ".$this->inc." !");
- // Begin of cache file
- fwrite($this->cache_pointer, "<?php\n\$ARRAY = \"".$array."\";\n\n");
+ // Add open PHP tag
+ fwrite($this->pointer, "<?php\n");
// Add default depency
- $this->store_extension_version("cache");
+ $this->storeExtensionVersion("cache");
} else {
// Cannot create file
ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
- function add_row ($data) {
+ function addRow ($data) {
global $cacheArray;
- if (is_resource($this->cache_pointer)) {
+ if (is_resource($this->pointer)) {
// Write every array element to cache file
foreach ($data as $k => $v) {
// Write global cache array for immediate access
}
// Write cache line to file
- fwrite($this->cache_pointer, $this->add_raw_row($k, $v));
+ fwrite($this->pointer, $this->rewriteEntry($k, $v));
}
} else {
// Cannot create file
}
}
- function cache_close() {
+ function finalize () {
// Quit function when no pointer is set
- if (empty($this->cache_pointer)) return;
- if (is_resource($this->cache_pointer)) {
+ if (is_resource($this->pointer)) {
// Write footer
- fwrite($this->cache_pointer, "?>\n");
+ fwrite($this->pointer, "?>\n");
// Close file add destroy handler
- fclose($this->cache_pointer);
+ fclose($this->pointer);
// Set rights
- if (FILE_READABLE($this->cache_inc)) chmod($this->cache_inc, 0666);
+ if (FILE_READABLE($this->inc)) chmod($this->inc, 0666);
// Remove pointer
- unset($this->cache_pointer);
+ $this->pointer = false;
} else {
// Cannot create file
ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
- function cache_load() {
+ function getArrayFromCache () {
// Is the cache already loaded?
- if (isset($this->cache_data[$this->cache_file])) {
+ if (isset($this->data[$this->name])) {
// Return it's content!
- return $this->cache_data[$this->cache_file];
+ return $this->data[$this->name];
} // END - if
// Is the cache file there?
- if (FILE_READABLE($this->cache_inc)) {
+ if (FILE_READABLE($this->inc)) {
// Prepare temporary array
$data = array();
$cache_version = null;
// Load cache file
- require_once($this->cache_inc);
+ require_once($this->inc);
// Is there an array?
if (is_array($data)) {
// Cache data
- $this->cache_data[$this->cache_file] = $data;
+ $this->data[$this->name] = $data;
// Cache version found?
if ((is_array($cache_version)) && (count($cache_version) > 0)) {
// Remember it as well...
- $this->cache_version[$this->cache_file] = $cache_version;
+ $this->version[$this->name] = $cache_version;
} else {
// Invalid cache so destroy it
- $this->cache_destroy();
+ $this->destroyCacheFile();
// Clear cached data
- $this->cache_data[$this->cache_file] = array();
+ $this->data[$this->name] = array();
}
// Return cache
- return $this->cache_data[$this->cache_file];
+ return $this->data[$this->name];
} else {
// Cache problem detected!
- $this->cache_destroy();
+ $this->destroyCacheFile();
}
} else {
// Cache file not found or not readable
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_LOAD_1.$this->cache_inc.CACHE_CANNOT_LOAD_2);
+ ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_LOAD_1.$this->inc.CACHE_CANNOT_LOAD_2);
}
}
// Destroy an existing cache file
- function cache_destroy() {
+ function destroyCacheFile () {
// Is the cache file there?
- if (FILE_READABLE($this->cache_inc)) {
+ if (FILE_READABLE($this->inc)) {
// Close cache
- $this->cache_close();
+ $this->finalize();
// Remove cache file from system
- unlink($this->cache_inc);
+ unlink($this->inc);
// Is the file there?
- if (!FILE_READABLE($this->cache_inc)) {
+ if (!FILE_READABLE($this->inc)) {
// The cache does no longer exist so kill the content
- unset($this->cache_data[$this->cache_file]);
+ unset($this->data[$this->name]);
} else {
// Not removed!
- ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2);
+ ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_UNLINK_1.$this->inc.CACHE_CANNOT_UNLINK_2);
}
} else {
// Does not exist!
}
}
- function cache_remove($search, $data, $array) {
- global $ARRAY;
- if ((FILE_READABLE($this->cache_inc)) && (is_writeable($this->cache_inc))) {
+ // Unused method:
+ function removeEntry ($search, $data, $array) {
+ if ((FILE_READABLE($this->inc)) && (is_writeable($this->inc))) {
// Load cache into dummy array
- $dummy = $this->cache_load();
+ $dummy = $this->getArrayFromCache();
// Search for key in array
$key = array_search($data, $dummy[$search]);
}
// Flush array to cache file
- $this->cache_init($ARRAY);
+ $this->init();
// Write array out
- $this->cache_write_array($dummy);
+ $this->writeArray($dummy);
// Close cache file
- $this->cache_close();
+ $this->finalize();
}
} else {
// Cannot write to cache!
}
}
- function cache_write_array ($array) {
- if (is_resource($this->cache_pointer)) {
+ function writeArray ($array) {
+ if (is_resource($this->pointer)) {
foreach ($array as $k => $v) {
if (is_array($v)) {
// Multi line(s) found
$LINE = "";
foreach($v as $k2 => $v2) {
// Put every array element in a row...
- $LINE .= $this->add_raw_row($k, $v2);
+ $LINE .= $this->rewriteEntry($k, $v2);
}
} else {
// Single line found
- $LINE = $this->add_raw_row($k, $v);
+ $LINE = $this->rewriteEntry($k, $v);
}
// Write line(s)
- fwrite($this->cache_pointer, $LINE);
+ fwrite($this->pointer, $LINE);
} // END - foreach
} else {
// Cannot write array!
}
}
- function cache_replace($search, $replace, $search_key, $array) {
- global $ARRAY;
- if ((FILE_READABLE($this->cache_inc)) && (is_writeable($this->cache_inc))) {
+ // Unused method
+ function replaceEntry ($search, $replace, $search_key, $array) {
+ if ((FILE_READABLE($this->inc)) && (is_writeable($this->inc))) {
// Load cache into dummy array
- $dummy = $this->cache_load();
+ $dummy = $this->getArrayFromCache();
// Check if $dummy is valid (prevents some errors)
if ((is_array($dummy)) && (isset($dummy[$search])) && (is_array($dummy[$search]))) {
}
// Flush array to cache file
- $this->cache_init($ARRAY);
+ $this->init();
// Write array out
- $this->cache_write_array($dummy);
+ $this->writeArray($dummy);
// Close cache file
- $this->cache_close();
+ $this->finalize();
}
}
} else {
}
}
- function store_extension_version ($ext_name) {
+ function storeExtensionVersion ($ext_name) {
// Valid cache pointer?
- if (is_resource($this->cache_pointer)) {
+ if (is_resource($this->pointer)) {
// Get extension version
$ext_ver = GET_EXT_VERSION($ext_name);
// Write cache line to file
- fwrite($this->cache_pointer, "\$cache_version['".$ext_name."'] = \"".$ext_ver."\";\n");
+ fwrite($this->pointer, "\$cache_version['".$ext_name."'] = \"".$ext_ver."\";\n");
} else {
// Cannot create file
ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
}
}
- function ext_version_matches ($ext_name) {
+ function extensionVersionMatches ($ext_name) {
// Load cache (dummy)
- $this->cache_load();
+ $this->getArrayFromCache();
// Get extension version
$ext_ver = GET_EXT_VERSION($ext_name);
// Compare both
- return ((isset($this->cache_version[$this->cache_file][$ext_name])) && ($this->cache_version[$this->cache_file][$ext_name] == $ext_ver));
+ return ((isset($this->version[$this->name][$ext_name])) && ($this->version[$this->name][$ext_name] == $ext_ver));
}
- function add_raw_row ($key, $value) {
+ function rewriteEntry ($key, $value) {
// Init line
$line = "";
// String or non-string? ;-)
- if ((is_string($value)) || (is_null($value))) {
+ if (is_string($value)) {
// String...
$line = "\$data['".$key."'][] = \"".$value."\";\n";
+ } elseif (is_null($value)) {
+ // Null
+ $line = "\$data['".$key."'][] = null;\n";
+ } elseif (is_bool($value)) {
+ // Boolean value
+ if ($value === true) {
+ $line = "\$data['".$key."'][] = true;\n";
+ } else {
+ $line = "\$data['".$key."'][] = false;\n";
+ }
} else {
// Non-string
$line = "\$data['".$key."'][] = ".$value.";\n";
if ((($cacheArray['up_refid'][$cacheArray['back_level']] == $uid) || ($cacheArray['up_refid'][$cacheArray['back_level']] == 0)) && (GET_EXT_VERSION("cache") >= "0.1.2") && (!isset($cacheArray['back_cached']))) {
// Remove cache here
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$cacheArray['up_refid'][$cacheArray['back_level']]} - CACHE!<br />\n";
- if ($cacheInstance->cache_file("refback")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("refback")) $cacheInstance->destroyCacheFile();
$cacheArray['back_cached'] = 1;
} // END - if
include_once(PATH."inc/extensions/ext-cache.php");
// Check extension cache
- switch (($cacheInstance->cache_file("extensions", true)) && ($cacheInstance->ext_version_matches("sql_patches"))) {
+ switch (($cacheInstance->loadCacheFile("extensions", true)) && ($cacheInstance->extensionVersionMatches("sql_patches"))) {
case true : $cacheMode = "load"; break;
case false: $cacheMode = "init"; break;
}
// Do we need to init the cache?
if (($cacheMode == "init") && ($_CONFIG['cache_exts'] == "Y")) {
// Init cache file
- $cacheInstance->cache_init("EXTENSIONS");
- $cacheInstance->store_extension_version("sql_patches");
+ $cacheInstance->init("EXTENSIONS");
+ $cacheInstance->storeExtensionVersion("sql_patches");
} elseif ($_CONFIG['cache_exts'] == "N") {
// Cache will not be created for extensions
$cacheMode = "skip";
$EXT_POOL = array();
// Re-initialize handler
- $cacheInstance->cache_file("extensions", true);
+ $cacheInstance->loadCacheFile("extensions", true);
// Load extension data from cache file
- $EXT_DUMMY = $cacheInstance->cache_load();
+ $EXT_DUMMY = $cacheInstance->getArrayFromCache();
// Is the cache file fine?
if (!isset($EXT_DUMMY['ext_name'])) {
// Cache file is damaged so kill it
- $cacheInstance->cache_destroy();
+ $cacheInstance->destroyCacheFile();
// Skip any further execution
return;
$EXT_DUMMY['ext_name'] = $EXT_NAMES;
unset($EXT_NAMES);
- // Close cache file
- $cacheInstance->cache_close();
-
// Loading cache is done so let's free some memory!
unset($EXT_DUMMY['ext_lang']);
unset($EXT_DUMMY['ext_keep']);
if (GET_EXT_VERSION("sql_patches") >= "0.0.6") {
// Query with CSS file from DB
- $res_ext_crt = SQL_QUERY("SELECT id, ext_name, ext_lang_file, ext_has_css, ext_active, ext_version
+ $res_ext_crt = SQL_QUERY("SELECT id AS ext_id, ext_name, ext_lang_file AS ext_lang, ext_has_css AS ext_css, ext_active, ext_version
FROM "._MYSQL_PREFIX."_extensions".$ADD."
ORDER BY ext_name", __FILE__, __LINE__);
} else {
// Old obsolete query string
- $res_ext_crt = SQL_QUERY("SELECT id, ext_name, ext_lang_file, ext_name, ext_active, ext_version
+ $res_ext_crt = SQL_QUERY("SELECT id AS ext_id, ext_name, ext_lang_file AS ext_lang, ext_name, ext_active, ext_version
FROM "._MYSQL_PREFIX."_extensions".$ADD."
ORDER BY ext_name", __FILE__, __LINE__);
}
require_once(PATH."inc/theme-manager.php");
// Extensions are registered so we load them
- while (list($EXT_ID, $name, $lang, $css, $active, $version) = SQL_FETCHROW($res_ext_crt)) {
+ while ($content = SQL_FETCHARRAY($res_ext_crt)) {
// Get menu entry
- $menu = "N";
- if (MODULE_HAS_MENU($name, true)) {
- $menu = "Y";
+ $content['ext_menu'] = "N";
+ if (MODULE_HAS_MENU($content['ext_name'], true)) {
+ $content['ext_menu'] = "Y";
} // END - if
// Load extensions
- $file1 = sprintf("%sinc/extensions/ext-%s.php", PATH, $name);
+ $file1 = sprintf("%sinc/extensions/ext-%s.php", PATH, $content['ext_name']);
$file2 = $file1; $EXT_CSS = "N"; $EXT_ALWAYS_ACTIVE = "N";
// Special functions file
- $file3 = sprintf("%sinc/libs/%s_functions.php", PATH, $name);
+ $file3 = sprintf("%sinc/libs/%s_functions.php", PATH, $content['ext_name']);
// Does the extension file exists?
if (FILE_READABLE($file1)) {
// If there's no language file specified we don't need to load one... ;-)
- if (!empty($lang)) {
+ if (!empty($content['ext_lang'])) {
// Create language file
- $file2 = sprintf("%sinc/language/%s_%s.php", PATH, $lang, GET_LANGUAGE());
+ $file2 = sprintf("%sinc/language/%s_%s.php", PATH, $content['ext_lang'], GET_LANGUAGE());
} // END - if
if (FILE_READABLE($file3)) {
// Special functions file
- $funcs = "Y";
+ $content['ext_funcs'] = "Y";
require_once($file3);
} else {
// Don't load functions file
- $funcs = "N";
+ $content['ext_funcs'] = "N";
}
// Do we need a language file?
if (($file1 != $file2) && (FILE_READABLE($file2))) {
// Load language file
- $lang = "Y";
+ $content['ext_lang'] = "Y";
include($file2);
} else {
// Don't load language file
- $lang = "N";
+ $content['ext_lang'] = "N";
}
+ // By default no extension is always active, except sql_patches
+ $EXT_ALWAYS_ACTIVE = "N";
+
// Load extension
- if ($name != "sql_patches") {
+ if ($content['ext_name'] != "sql_patches") {
// Load extension's file
include_once($file1);
} else {
- // KEEP sql_patches ALWAYS ACTIVE!
+ // Keep sql_patches always active
$EXT_ALWAYS_ACTIVE = "Y";
}
- if ($css == "Y") {
- $CSS_FILE = sprintf("%stheme/%s/css/%s.css", PATH, GET_CURR_THEME(), $name);
+ // Transfer EXT_ALWAYS_ACTIVE flag
+ $content['ext_keep'] = $EXT_ALWAYS_ACTIVE;
+
+ // CSS file handling:
+ if ((!isset($content['ext_css'])) || ($content['ext_css'] == "Y")) {
+ // Create FQFN for the CSS file
+ $CSS_FILE = sprintf("%stheme/%s/css/%s.css", PATH, GET_CURR_THEME(), $content['ext_name']);
+
+ // Is the file there?
if (FILE_READABLE($CSS_FILE)) {
// CSS file for extension was found (use only relative path for now!)
- $EXT_CSS_FILES[] = $name.".css";
+ $EXT_CSS_FILES[] = $content['ext_name'].".css";
+ $content['ext_css'] = "Y";
} else {
// Don't load CSS file
- $css = "N";
+ $content['ext_css'] = "N";
}
} // END - if
- // Add cache row
+ // Shall we cache?
if ($cacheMode == "init") {
- $cacheInstance->add_row(array(
- 'ext_id' => $EXT_ID,
- 'ext_name' => $name,
- 'ext_lang' => $lang,
- 'ext_css' => $css,
- 'ext_menu' => $menu,
- 'ext_funcs' => $funcs,
- 'ext_active' => $active,
- 'ext_version' => $version,
- 'ext_keep' => $EXT_ALWAYS_ACTIVE,
- ));
+ // Add cache row
+ $cacheInstance->addRow($content);
} elseif ($cacheMode == "no") {
// Remember this value for later usage
- $cacheArray['active_extensions'][$name] = $EXT_ALWAYS_ACTIVE;
+ $cacheArray['active_extensions'][$content['ext_name']] = $EXT_ALWAYS_ACTIVE;
}
} elseif (!FILE_READABLE($file1)) {
// Deleted extension file so we mark it for removal from DB
- $DEL[] = $name;
+ $DEL[] = $content['ext_name'];
}
} // END - while
if ($cacheMode == "init") {
// Close cache file
- $cacheInstance->cache_close();
+ $cacheInstance->finalize();
// Load more cache files (like admins)
require_once(PATH."inc/load_cache.php");
// Uninstall extensions that are no longer in our system
if (!empty($DEL[0])) {
// Remove extensions from two tables: extension registry and tasks table
- foreach ($DEL as $name) {
+ foreach ($DEL as $del_ext) {
// First remove entry from extensions table
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
- array($name), __FILE__, __LINE__);
+ array($del_ext), __FILE__, __LINE__);
// Remove (maybe?) found tasks (main task and possible updates
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE subject LIKE '[%s:]%%' AND (task_type='EXTENSION' OR task_type='EXTENSION_UPDATE')",
- array($name), __FILE__, __LINE__);
+ array($del_ext), __FILE__, __LINE__);
} // END - foreach
// I think it's not neccessary to run the optimization function here
} // END - if
// Let's start with the admins table...
-if (($cacheInstance->cache_file("admins")) && ($cacheInstance->ext_version_matches("admins"))) {
+if (($cacheInstance->loadCacheFile("admins")) && ($cacheInstance->extensionVersionMatches("admins"))) {
// Load cache
global $cacheArray;
- $cacheArray['admins'] = $cacheInstance->cache_load();
+ $cacheArray['admins'] = $cacheInstance->getArrayFromCache();
// Check if valid
if ((isset($cacheArray['admins']['login'])) && (is_array($cacheArray['admins']['login'])) && (is_array($cacheArray['admins']['aid']))) {
} // END - for
} else {
// Nope, cache file is corrupted!
- $cacheInstance->cache_destroy();
+ $cacheInstance->destroyCacheFile();
unset($cacheArray['admins']);
}
} else {
// Nope, cache file is corrupted!
- $cacheInstance->cache_destroy();
+ $cacheInstance->destroyCacheFile();
unset($cacheArray['admins']);
}
} elseif (($_CONFIG['cache_admins'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
// Create cache file
- $cacheInstance->cache_init("ADMINS");
- $cacheInstance->store_extension_version("admins");
+ $cacheInstance->init("ADMINS");
+ $cacheInstance->storeExtensionVersion("admins");
// Load every data from DB to cache file
$ADD = ", id, id";
ORDER BY login", __FILE__, __LINE__);
while($dummy = SQL_FETCHARRAY($result_admins)) {
// Save row
- $cacheInstance->add_row($dummy);
+ $cacheInstance->addRow($dummy);
} // END - while
// Free memory
SQL_FREERESULT($result_admins);
// Close cache
- $cacheInstance->cache_close();
+ $cacheInstance->finalize();
// Reload the cache
require(__FILE__);
}
-// Close file
-$cacheInstance->cache_close();
-
// Next cached table are the admins_acls...
if (GET_EXT_VERSION("admins") >= "0.3") {
// Check for cache file
- if (($cacheInstance->cache_file("admins_acls")) && ($cacheInstance->ext_version_matches("admins"))) {
+ if (($cacheInstance->loadCacheFile("admins_acls")) && ($cacheInstance->extensionVersionMatches("admins"))) {
// Load referal system from cache
global $cacheArray;
- $cacheArray['admin_acls'] = $cacheInstance->cache_load();
+ $cacheArray['admin_acls'] = $cacheInstance->getArrayFromCache();
} elseif (($_CONFIG['cache_acls'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
// Create cache file here
- $cacheInstance->cache_init("ADMINS_ACLS");
- $cacheInstance->store_extension_version("admins");
+ $cacheInstance->init("ADMINS_ACLS");
+ $cacheInstance->storeExtensionVersion("admins");
// Load all modules and their data
$result = SQL_QUERY("SELECT id, admin_id, action_menu, what_menu, access_mode FROM "._MYSQL_PREFIX."_admins_acls ORDER BY admin_id, action_menu, what_menu", __FILE__, __LINE__);
// Add all rows
while ($data = SQL_FETCHARRAY($result)) {
// Add row to cache file
- $cacheInstance->add_row($data);
+ $cacheInstance->addRow($data);
} // END - while
// Free memory
SQL_FREERESULT($result);
// Close cache
- $cacheInstance->cache_close();
+ $cacheInstance->finalize();
// Reload the cache
require(__FILE__);
}
-
- // Close file
- $cacheInstance->cache_close();
} // END - if
//
}
// Next cached table is the configuration (config)...
-if (($cacheInstance->cache_file("config", true)) && ($cacheInstance->ext_version_matches("sql_patches"))) {
+if (($cacheInstance->loadCacheFile("config", true)) && ($cacheInstance->extensionVersionMatches("sql_patches"))) {
// Load config from cache
global $cacheArray;
- $cacheArray['config'] = $cacheInstance->cache_load();
+ $cacheArray['config'] = $cacheInstance->getArrayFromCache();
// TODO: Do we really need to cache the config???
} elseif (($_CONFIG['cache_config'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
// Create cache file here
- $cacheInstance->cache_init("CONFIG");
- $cacheInstance->store_extension_version("sql_patches");
+ $cacheInstance->init("CONFIG");
+ $cacheInstance->storeExtensionVersion("sql_patches");
// Load all modules and their data
$result = SQL_QUERY("SELECT * FROM "._MYSQL_PREFIX."_config ORDER BY config ASC", __FILE__, __LINE__);
while ($data = SQL_FETCHARRAY($result)) {
// Add row to cache file
- $cacheInstance->add_row($data);
+ $cacheInstance->addRow($data);
} // END - while
// Free memory
SQL_FREERESULT($result);
// Close the cache
- $cacheInstance->cache_close();
+ $cacheInstance->finalize();
// Reload the cache
require(__FILE__);
}
-// Close file
-$cacheInstance->cache_close();
-
//
?>
}
// Next cached table is the module registry (mod_reg)...
-if (($cacheInstance->cache_file("mod_reg")) && ($cacheInstance->ext_version_matches("sql_patches"))) {
+if (($cacheInstance->loadCacheFile("mod_reg")) && ($cacheInstance->extensionVersionMatches("sql_patches"))) {
// Load cache
global $cacheArray;
- $cacheArray['modules'] = $cacheInstance->cache_load();
+ $cacheArray['modules'] = $cacheInstance->getArrayFromCache();
// Rewrite module cache
$modArray = $cacheArray['modules'];
unset($modArray);
} elseif (($_CONFIG['cache_modreg'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
// Create cache file here
- $cacheInstance->cache_init("MODULES");
- $cacheInstance->store_extension_version("sql_patches");
+ $cacheInstance->init("MODULES");
+ $cacheInstance->storeExtensionVersion("sql_patches");
// Load all modules and their data
if (GET_EXT_VERSION("sql_patches") >= "0.3.6") {
// Cache all data
while ($data = SQL_FETCHARRAY($result)) {
// Add row to cache file
- $cacheInstance->add_row($data);
+ $cacheInstance->addRow($data);
} // END - while
// Free memory
SQL_FREERESULT($result);
// Close the cache
- $cacheInstance->cache_close();
+ $cacheInstance->finalize();
// Reload the cache
require(__FILE__);
}
-// Close file
-$cacheInstance->cache_close();
-
//
?>
}
// Next cached table is the referal system (refdepths)...
-if (($cacheInstance->cache_file("refdepths")) && ($cacheInstance->ext_version_matches("sql_patches"))) {
+if (($cacheInstance->loadCacheFile("refdepths")) && ($cacheInstance->extensionVersionMatches("sql_patches"))) {
// Load referal system from cache
global $cacheArray;
- $cacheArray['ref_depths'] = $cacheInstance->cache_load();
+ $cacheArray['ref_depths'] = $cacheInstance->getArrayFromCache();
} elseif (($_CONFIG['cache_refdepth'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
// Create cache file here
- $cacheInstance->cache_init("REFDEPTHS");
- $cacheInstance->store_extension_version("sql_patches");
+ $cacheInstance->init("REFDEPTHS");
+ $cacheInstance->storeExtensionVersion("sql_patches");
// Load all modules and their data
$result = SQL_QUERY("SELECT id, level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__);
while ($data = SQL_FETCHARRAY($result)) {
// Add row to cache file
- $cacheInstance->add_row($data);
+ $cacheInstance->addRow($data);
} // END - while
// Free memory
SQL_FREERESULT($result);
// Close the cache
- $cacheInstance->cache_close();
+ $cacheInstance->finalize();
// Reload the cache
require(__FILE__);
}
-// Close file
-$cacheInstance->cache_close();
-
//
?>
}
// Next cached table is the referal system (refsystem)...
-if (($cacheInstance->cache_file("refsystem")) && ($cacheInstance->ext_version_matches("sql_patches"))) {
+if (($cacheInstance->loadCacheFile("refsystem")) && ($cacheInstance->extensionVersionMatches("sql_patches"))) {
// Load referal system from cache
global $cacheArray;
- $cacheArray['ref_system'] = $cacheInstance->cache_load();
+ $cacheArray['ref_system'] = $cacheInstance->getArrayFromCache();
} elseif (($_CONFIG['cache_refsys'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
// Create cache file here
- $cacheInstance->cache_init("REFSYSTEM");
- $cacheInstance->store_extension_version("sql_patches");
+ $cacheInstance->init("REFSYSTEM");
+ $cacheInstance->storeExtensionVersion("sql_patches");
// Load all modules and their data
$result = SQL_QUERY("SELECT id, userid, level, counter FROM "._MYSQL_PREFIX."_refsystem ORDER BY userid, level", __FILE__, __LINE__);
while ($data = SQL_FETCHARRAY($result)) {
// Add row to cache file
- $cacheInstance->add_row($data);
+ $cacheInstance->addRow($data);
} // END - while
// Free memory
SQL_FREERESULT($result);
// Close the cache
- $cacheInstance->cache_close();
+ $cacheInstance->finalize();
// Reload the cache
require(__FILE__);
}
-// Close file
-$cacheInstance->cache_close();
-
//
?>
}
// Next cached table is the referal system (themes)...
-if (($cacheInstance->cache_file("themes")) && ($cacheInstance->ext_version_matches("theme"))) {
+if (($cacheInstance->loadCacheFile("themes")) && ($cacheInstance->extensionVersionMatches("theme"))) {
// Load referal system from cache
global $cacheArray;
- $cache = $cacheInstance->cache_load();
+ $cache = $cacheInstance->getArrayFromCache();
// Restructure the array
$cacheArray['themes'] = array();
unset($cache);
} elseif (($_CONFIG['cache_refsys'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
// Create cache file here
- $cacheInstance->cache_init("THEMES");
- $cacheInstance->store_extension_version("theme");
+ $cacheInstance->init("THEMES");
+ $cacheInstance->storeExtensionVersion("theme");
// Load all themes and their data
if (GET_EXT_VERSION("theme") >= "0.0.7") {
}
while ($data = SQL_FETCHARRAY($result)) {
// Add row to cache file
- $cacheInstance->add_row($data);
+ $cacheInstance->addRow($data);
} // END - while
// Free memory
SQL_FREERESULT($result);
// Close the cache
- $cacheInstance->cache_close();
+ $cacheInstance->finalize();
// Reload the cache
require(__FILE__);
}
-// Close file
-$cacheInstance->cache_close();
-
//
?>
$cacheName = "admin_".$act."_".$wht."_".GET_LANGUAGE()."_".strtolower(get_session('admin_login'));
// Is that cache there?
- if ($cacheInstance->cache_file($cacheName)) {
+ if ($cacheInstance->loadCacheFile($cacheName)) {
// Then load it
- $data = $cacheInstance->cache_load();
+ $data = $cacheInstance->getArrayFromCache();
// Extract all parts
$OUT = base64_decode($data['output'][0]);
// Is there a cache instance again?
if ((is_object($cacheInstance)) && (isset($_CONFIG['cache_admin_menu'])) && ($_CONFIG['cache_admin_menu'] == "Y")) {
// Init cache
- $cacheInstance->cache_init($cacheName);
+ $cacheInstance->init($cacheName);
// Prepare cache data
$data = array(
);
// Write the data away
- $cacheInstance->add_row($data);
+ $cacheInstance->addRow($data);
// Close cache
- $cacheInstance->cache_close();
+ $cacheInstance->finalize();
} // END - if
// Return or output content?
// Remove cache file
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->cache_file("admins")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("admins")) $cacheInstance->destroyCacheFile();
}
} else {
// Free memory
// Update cache when installed
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->cache_file("admins_acls")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("admins_acls")) $cacheInstance->destroyCacheFile();
// Purge menu cache
CACHE_PURGE_ADMIN_MENU($_POST['admin'][$id]);
// Update cache when installed
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->cache_file("admins_acls")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("admins_acls")) $cacheInstance->destroyCacheFile();
// @TODO This causes the whole (!) menu cache being rebuild
CACHE_PURGE_ADMIN_MENU();
// Update cache when installed
if (EXT_IS_ACTIVE("cache")) {
- if ($cacheInstance->cache_file("admins_acls")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("admins_acls")) $cacheInstance->destroyCacheFile();
// Purge cache
CACHE_PURGE_ADMIN_MENU($_POST['admin_id'], $_POST['action_menu'], $_POST['what_menu']);
}
// Delete deactivated cache files
- if (($_POST['cache_admins'] == "N") && ($cacheInstance->cache_file("admins"))) {
- $cacheInstance->cache_destroy();
+ if (($_POST['cache_admins'] == "N") && ($cacheInstance->loadCacheFile("admins"))) {
+ $cacheInstance->destroyCacheFile();
}
- if (($_POST['cache_acls'] == "N") && ($cacheInstance->cache_file("acls"))) {
- $cacheInstance->cache_destroy();
+ if (($_POST['cache_acls'] == "N") && ($cacheInstance->loadCacheFile("acls"))) {
+ $cacheInstance->destroyCacheFile();
}
- if (($_POST['cache_exts'] == "N") && ($cacheInstance->cache_file("extensions", true))) {
- $cacheInstance->cache_destroy();
+ if (($_POST['cache_exts'] == "N") && ($cacheInstance->loadCacheFile("extensions", true))) {
+ $cacheInstance->destroyCacheFile();
}
- if (($_POST['cache_config'] == "N") && ($cacheInstance->cache_file("config"))) {
- $cacheInstance->cache_destroy();
+ if (($_POST['cache_config'] == "N") && ($cacheInstance->loadCacheFile("config"))) {
+ $cacheInstance->destroyCacheFile();
}
- if (($_POST['cache_modreg'] == "N") && ($cacheInstance->cache_file("modreg"))) {
- $cacheInstance->cache_destroy();
+ if (($_POST['cache_modreg'] == "N") && ($cacheInstance->loadCacheFile("modreg"))) {
+ $cacheInstance->destroyCacheFile();
}
- if (($_POST['cache_refdepth'] == "N") && ($cacheInstance->cache_file("refdepth"))) {
- $cacheInstance->cache_destroy();
+ if (($_POST['cache_refdepth'] == "N") && ($cacheInstance->loadCacheFile("refdepth"))) {
+ $cacheInstance->destroyCacheFile();
}
- if (($_POST['cache_refsys'] == "N") && ($cacheInstance->cache_file("refsys"))) {
- $cacheInstance->cache_destroy();
+ if (($_POST['cache_refsys'] == "N") && ($cacheInstance->loadCacheFile("refsys"))) {
+ $cacheInstance->destroyCacheFile();
}
// Save configuration
// Remove cache file if version matches
if (GET_EXT_VERSION("cache") >= "0.1.2")
{
- if ($cacheInstance->cache_file("mod_reg")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
}
// Entries updated
// Update cache file
if (GET_EXT_VERSION("cache") >= "0.1.2") {
- if ($cacheInstance->cache_file("refdepths")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("refdepths")) $cacheInstance->destroyCacheFile();
}
break;
// Do we need to update cache file?
if ((EXT_IS_ACTIVE("cache")) && ($cacheMode != "no")) {
// Remove cache file (will be auto-created again!)
- if ($cacheInstance->cache_file("config")) $cacheInstance->cache_destroy();
- if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
- if ($cacheInstance->cache_file("mod_reg")) $cacheInstance->cache_destroy();
+ if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
+ if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
} // END - if
} elseif (GET_EXT_VERSION($ext_name) != "") {
// Motify the admin that we have a problem here...