require("inc/config.php");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Simply redirect... :-)
LOAD_URL("modules.php?module=admin");
} else {
require("inc/config.php");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Simply redirect... :-)
LOAD_URL("modules.php?module=index&what=agb");
} else {
REDIRCT_ON_UNINSTALLED_EXTENSION("beg");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Check for userid
if (REQUEST_ISSET_GET(('uid'))) {
// Init variables
REDIRECT_ON_UNINSTALLED_EXTENSION("birthday");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Script is installed so let's check for his confirmation link...
$uid = bigintval(REQUEST_GET('uid'));
require("inc/config.php");
// Is the script installed?
-if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered'))) {
+if ((isInstalled()) && (isAdminRegistered())) {
// Base URL for redirection
$URL = "modules.php?module=index&what=confirm&hash=";
if (!REQUEST_ISSET_GET(('hash'))) {
require("inc/config.php");
// Redirect only to registration page when this script is installed
-if ((isBooleanConstantAndTrue('mxchange_installed')) && (getTotalFatalErrors() == 0)) {
+if ((isInstalled()) && (getTotalFatalErrors() == 0)) {
// Is the extension installed?
if (!EXT_IS_ACTIVE("debug")) {
// Then abort here
REDIRECT_ON_UNINSTALLED_EXTENSION("doubler");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Probe for referal ID
if (REQUEST_ISSET_GET(('refid'))) $GLOBALS['refid'] = REQUEST_GET(('refid'));
require("inc/config.php");
// Script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Load header
LOAD_INC_ONCE("inc/header.php");
} // END - if
// Load all includes
-$INC_POOL = GET_DIR_AS_ARRAY(constant('PATH')."inc/autopurge/", "purge-");
+$INC_POOL = GET_DIR_AS_ARRAY("inc/autopurge/", "purge-");
// Run the filter
RUN_FILTER('load_includes', $INC_POOL);
}
// 01 2 3 32 2 3321 12 3 32 2 21 1 2 21 1 2 21 1 23 321 1 10
-if ((date("d", getConfig('last_update')) != date("d", time())) && ((!defined('mxchange_installing')) || (!mxchange_installing)) && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')) && (!REQUEST_ISSET_GET(('register'))) && ($GLOBALS['output_mode'] != 1)) {
+if ((date("d", getConfig('last_update')) != date("d", time())) && ((!defined('mxchange_installing')) || (!mxchange_installing)) && (isInstalled()) && (isAdminRegistered()) && (!REQUEST_ISSET_GET(('register'))) && ($GLOBALS['output_mode'] != 1)) {
// Do daily things in external PHP file but only when script is completely setup
// Daily reset was run!
define('__DAILY_RESET', true);
// Check if given extension is active
function EXT_IS_ACTIVE ($ext_name) {
// Extensions are all inactive during installation
- if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isInstalling()) || (empty($ext_name))) return false;
+ if ((!isInstalled()) || (isInstalling()) || (empty($ext_name))) return false;
// Not active is the default
$active = "N";
$ext_ver = false;
// Extensions are all inactive during installation
- if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isInstalling())) return "";
+ if ((!isInstalled()) || (isInstalling())) return "";
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": ext_name={$ext_name}");
// Is the cache written?
// Free memory
SQL_FREERESULT($result);
} elseif (GET_EXT_VERSION("sql_patches") == "") {
- // No sql_patches installed, so maybe in admin area?
- $ret = ((IS_ADMIN()) && ($mod == "admin")); // Then there is a menu!
+ // No sql_patches installed, so maybe in admin area or no admin registered?
+ $ret = (((IS_ADMIN()) || (!isAdminRegistered())) && ($mod == "admin")); // Then there is a menu!
}
// Return status
default: // Do stuff when extension is loaded
// Do daily reset only when installed and extension version is at least 0.1.1
- if ((isBooleanConstantAndTrue('__DAILY_RESET')) && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')) && (GET_EXT_VERSION("order") >= "0.1.1")) {
+ if ((isBooleanConstantAndTrue('__DAILY_RESET')) && (isInstalled()) && (isAdminRegistered()) && (GET_EXT_VERSION("order") >= "0.1.1")) {
// Reset mail order values
$result_ext = SQL_QUERY("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET mail_orders=0 WHERE mail_orders > 0", __FILE__, __LINE__);
} // END - if
// Load main template
LOAD_TEMPLATE("install_fatal_table", false, $OUT);
- } elseif (isBooleanConstantAndTrue('mxchange_installed')) {
+ } elseif (isInstalled()) {
// Display all runtime fatal errors
$OUT = "";
foreach (getFatalArray() as $key => $value) {
// Init filters
REGISTER_FILTER('init', 'UPDATE_LOGIN_DATA');
REGISTER_FILTER('init', 'INIT_RANDOMIZER');
+ REGISTER_FILTER('init', 'INIT_MEM_CACHE');
// Login failures handler
REGISTER_FILTER('post_youhere_line', 'CALL_HANDLER_LOGIN_FAILTURES');
mt_srand(generateSeed() + constant('_ADD'));
}
+// Filter for initializing misc mem-cache arrays (NOT memcache!)
+function FILTER_INIT_MEM_CACHE () {
+ // For LOAD_INC_ONCE()
+ $GLOBALS['cache_array']['load_once'] = array();
+}
+
//
?>
// Add surrounding HTML comments to help finding bugs faster
$ret = "<!-- Template ".$template." - Start -->\n".$ret."<!-- Template ".$template." - End -->\n";
- } elseif ((IS_ADMIN()) || ((isInstalling()) && (!isBooleanConstantAndTrue('mxchange_installed')))) {
+ } elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
// Only admins shall see this warning or when installation mode is active
$ret = "<br /><span class=\"guest_failed\">".TEMPLATE_404."</span><br />
(".basename($FQFN).")<br />
// Get output buffer
//* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
+ DEBUG_LOG(__FUNCTION__, __LINE__, $URL);
$OUTPUT = ob_get_contents();
// Clear it only if there is content
// Fix it to default
$ret = "default";
} // END - if
- } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isInstalling()) || ($GLOBALS['output_mode'] == true)) && ((REQUEST_ISSET_GET(('theme'))) || (REQUEST_ISSET_POST(('theme'))))) {
+ } elseif ((!isInstalled()) && ((isInstalling()) || ($GLOBALS['output_mode'] == true)) && ((REQUEST_ISSET_GET(('theme'))) || (REQUEST_ISSET_POST(('theme'))))) {
// Prepare FQFN for checking
$theme = sprintf("%stheme/%s/theme.php", constant('PATH'), REQUEST_GET(('theme')));
$INCs = array();
// Open directory
- $dirPointer = opendir($baseDir) or mxchange_die("Cannot read ".basename($baseDir)." path!");
+ $dirPointer = opendir(constant('PATH') . $baseDir) or mxchange_die("Cannot read ".basename($baseDir)." path!");
// Read all entries
while ($baseFile = readdir($dirPointer)) {
// Load file only if extension is active
- // Make full path
- $FQFN = $baseDir.$baseFile;
+ $INC = $baseDir.$baseFile;
+ $FQFN = constant('PATH') . $INC;
// Is this a valid reset file?
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}<br />\n";
// Is the extension valid and active?
if (($extId > 0) && (EXT_IS_ACTIVE($extName))) {
// Then add this file
- $INCs[] = $FQFN;
+ $INCs[] = $INC;
} elseif ($extId == 0) {
// Add non-extension files as well
- $INCs[] = $FQFN;
+ $INCs[] = $INC;
}
} // END - if
} // END - while
} // END - if
// Get more daily reset scripts
- $INC_POOL = GET_DIR_AS_ARRAY(constant('PATH')."inc/reset/", "reset_");
+ $INC_POOL = GET_DIR_AS_ARRAY("inc/reset/", "reset_");
// Update database
if (!defined('DEBUG_RESET')) UPDATE_CONFIG("last_update", time());
// Has it changed?
if (getConfig('last_week') != $currWeek) {
// Include weekly reset scripts
- $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY(constant('PATH')."inc/weekly/", "weekly_"));
+ $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY("inc/weekly/", "weekly_"));
// Update config
if (!defined('DEBUG_WEEKLY')) UPDATE_CONFIG("last_week", $currWeek);
// Has it changed?
if (getConfig('last_month') != $currMonth) {
// Include monthly reset scripts
- $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY(constant('PATH')."inc/monthly/", "monthly_"));
+ $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY("inc/monthly/", "monthly_"));
// Update config
if (!defined('DEBUG_MONTHLY')) UPDATE_CONFIG("last_month", $currMonth);
return (isset($GLOBALS['mxchange_installing']));
}
+// Check wether this script is installed
+function isInstalled () {
+ return isBooleanConstantAndTrue('mxchange_installed');
+}
+
+// Check wether an admin is registered
+function isAdminRegistered () {
+ return isBooleanConstantAndTrue('admin_registered');
+}
+
//////////////////////////////////////////////////
// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
//////////////////////////////////////////////////
// Remember title in constant for the template
define('__PAGE_TITLE', $TITLE);
- } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered'))) {
+ } elseif ((!isInstalled()) || (!isAdminRegistered())) {
+ // Load language here
+ LOAD_INC_ONCE("inc/language.php");
+
// Installation mode
define('__PAGE_TITLE', getMessage('INSTALLATION_OF_MXCHANGE'));
} else {
LOAD_TEMPLATE("metadata");
// Add meta description to header
- if ((isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')) && (SQL_IS_LINK_UP())) {
+ if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) {
// Add meta description not in admin and login module and when the script is installed
META_DESCRIPTION($GLOBALS['module'], $GLOBALS['what']);
} // END - if
} // END - if
// Is MXChange installed or no admin registered so far?
-if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered')))
+if ((!isInstalled()) || (!isAdminRegistered()))
{
// Set URL for FORM actions
define('__BURL_ACTION', constant('URL'));
break;
case "finalize": // Write captured data to files
- if ((REQUEST_ISSET_POST(('finalize'))) && (!isBooleanConstantAndTrue('mxchange_installed'))) {
+ if ((REQUEST_ISSET_POST(('finalize'))) && (!isInstalled())) {
// You have submitted data then we have to reset the fatal messages
$SQLs = array();
// Installation is done!
LOAD_URL("install.php?page=finalize");
}
- } elseif (isBooleanConstantAndTrue('mxchange_installed')) {
+ } elseif (isInstalled()) {
// Redirection after writing data... :-)
LOAD_TEMPLATE("install_finished");
} else {
require($INC);
}
-// Language identifier
-define('__LANG_ID', "Deutsch (Dtl.)");
-
// Installation/setup
define('CONFIG_IS_WRITE_PROTECTED', "Die Konfigurationsdatei <strong>inc/config.php</strong> ist schreibgeschützt. Bitte setzen Sie CHMOD 666 auf die Datei!");
define('DUMMY_IS_WRITE_PROTECTED', "In dem Verzeichnis <strong>inc/</strong> kann keine Datei erzeugt werden. Bitte setzen Sie CHMOD 777 auf das Verzeichnis!");
require($INC);
}
-// Language identifier
-define('__LANG_ID', "English (US)");
-
// Language definitions
define('LANG_DOWN_MAINTAINCE', "System is down for maintenance.");
define('LANG_MOD_REG_404', "Module <u>%s</u> does not exists.");
}
// Language definitions
-define('MT_WORD', "Mailtausch");
-define('MT_WORD2', "Mailtausches");
define('INSTALLATION_OF_MXCHANGE', "Installation von MXChange-{!MT_WORD!}-Script");
define('INSTALL_MISSING_DUMPS', "Die SQL-Dumps wurden nicht gefunden! Diese sollten auch mit hochgeladen werden und lesbar sein (CHMOD 644).");
define('INSTALL_ENABLE_BACKLINK', "Backlink (=Rückverlinkung zu mxchange.org setzen?) <em>rel="external"</em> ist gesetzt. Bitte nicht den Backlink einbauen, und <strong>nofollow</strong> verwenden! Das schadet allen.");
}
// Load more cache includes
-$INC_POOL = GET_DIR_AS_ARRAY(constant('PATH')."inc/loader/", "load_cache-");
+$INC_POOL = GET_DIR_AS_ARRAY("inc/loader/", "load_cache-");
// Run the filter
RUN_FILTER('load_includes', $INC_POOL);
$GLOBALS['cache_array'] = array();
// Skip loading extensions
-if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isInstalling())) {
+if ((!isInstalled()) || (isInstalling())) {
// Init filter system here
INIT_FILTER_SYSTEM();
}
// Login is default
-if ((empty($GLOBALS['action'])) && ($check == "admin_only")) {
+if ((empty($GLOBALS['action'])) && (CHECK_MODULE($GLOBALS['module']) == "admin_only")) {
// Redirect to right URL
LOAD_URL("modules.php?module=admin&action=login");
} // END - if
$ret = "init";
// Is no admin registered?
-if (!isBooleanConstantAndTrue('admin_registered')) {
+if (!isAdminRegistered()) {
// Admin is not registered so we have to inform the user
if ((IS_FORM_SENT()) && ((!REQUEST_ISSET_POST(('login'))) || (!REQUEST_ISSET_POST(('pass'))) || (strlen(REQUEST_POST('pass')) < 4))) {
REQUEST_SET_POST('ok', "***");
}
// Admin still not registered?
- if (!isBooleanConstantAndTrue('admin_registered')) {
+ if (!isAdminRegistered()) {
// Write to config that registration is done
changeDataInFile(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
$idList = "";
foreach ($IDs as $id => $sel) {
// Is there a userid?
- if (REQUEST_ISSET_POST(('uid_raw', $id))) {
+ if (REQUEST_ISSET_POST('uid_raw', $id)) {
// Load all data from that id
$result = SQL_QUERY_ESC("SELECT * FROM `{!_MYSQL_PREFIX!}_%s` WHERE %s=%s LIMIT 1",
array($table, $idColumn, $id), __FILE__, __LINE__);
register_shutdown_function('__SHUTDOWN_HOOK');
// Check if the user setups his MySQL stuff...
-if ((empty($MySQL['login'])) && (!defined('mxchange_installing')) && (!REQUEST_ISSET_GET(('installing'))) && (isBooleanConstantAndTrue('mxchange_installed'))) {
+if ((empty($MySQL['login'])) && (!defined('mxchange_installing')) && (!REQUEST_ISSET_GET(('installing'))) && (isInstalled())) {
// No login entered and outside installation mode
OUTPUT_HTML("<strong>{--LANG_WARNING--}:</strong> ");
- if (isBooleanConstantAndTrue('mxchange_installed')) {
+ if (isInstalled()) {
// You have changed my configuration file!
mxchange_die("{--DIE_CONFIG_CHANGED_YOU--}");
} else {
initFatalMessages();
// Check if this file is writeable or read-only and warn the user
-if ((!isInstalling()) && (isBooleanConstantAndTrue('mxchange_installed'))) {
+if ((!isInstalling()) && (isInstalled())) {
// Check for write-permission for config.php and inc directory
if (empty($GLOBALS['module'])) $GLOBALS['module'] = "index";
} // END - if
// Double-check installation mode
- if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered'))) {
+ if ((!isInstalled()) || (!isAdminRegistered())) {
// Check for file permissions
if (!IS_INC_WRITEABLE("config")) {
addFatalMessage(getMessage('CONFIG_IS_WRITE_PROTECTED'));
} // END - if
}
-if ((getTotalFatalErrors() > 0) && (isBooleanConstantAndTrue('mxchange_installed')) && (!defined('mxchange_installing')) && ($GLOBALS['output_mode'] != "1")) {
+if ((getTotalFatalErrors() > 0) && (isInstalled()) && (!defined('mxchange_installing')) && ($GLOBALS['output_mode'] != "1")) {
// One or more fatal error(s) occur during connect...
LOAD_INC_ONCE("inc/header.php");
LOAD_INC_ONCE("inc/fatal_errors.php");
$result = false;
// Is the script installed?
- if (isBooleanConstantAndTrue('mxchange_installed')) {
+ if (isInstalled()) {
// Check if cache is valid
if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($GLOBALS['cache_array']['modules']['module'])) && (in_array($mod, $GLOBALS['cache_array']['modules']['module']))) {
// Load from cache
$ret = "major";
// Check if script is installed if not return a "done" to prevent some errors
- if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isInstalling()) || (!isBooleanConstantAndTrue('admin_registered'))) {
+ if ((!isInstalled()) || (isInstalling()) || (!isAdminRegistered())) {
// Not installed or no admin registered or in installation phase
return "done";
} // END - if
// Free memory
SQL_FREERESULT($result);
} elseif ((GET_EXT_VERSION("sql_patches") == "") && ($MODE != "admin")) {
- // No sql_patches installed!
- LOAD_URL("admin.php");
+ // 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???
+ LOAD_URL("admin.php");
+ } // END - if
}
// Return action value
$GLOBALS['pool_cnt'] = 0;
// Load more cache includes
-$INC_POOL = GET_DIR_AS_ARRAY(constant('PATH')."inc/pool/", "pool-");
+$INC_POOL = GET_DIR_AS_ARRAY("inc/pool/", "pool-");
// Run the filter
RUN_FILTER('load_includes', $INC_POOL);
}
// Checks if an element in $_GET exists
-function REQUEST_ISSET_GET ($element) {
- return (isset($_GET[$element]));
+function REQUEST_ISSET_GET ($element, $extra="") {
+ if (empty($extra)) {
+ return (isset($_GET[$element]));
+ } else {
+ return (isset($_GET[$element][$extra]));
+ }
}
// Removes an element from $_GET
}
// Checks if an element in $_POST exists
-function REQUEST_ISSET_POST ($element) {
- return (isset($_POST[$element]));
+function REQUEST_ISSET_POST ($element, $extra="") {
+ if (empty($extra)) {
+ return (isset($_POST[$element]));
+ } else {
+ return (isset($_POST[$element][$extra]));
+ }
}
// Removes an element from $_POST
);
// Add stylesheet for installation
-if ((basename($_SERVER['PHP_SELF']) == "install.php") || (!isBooleanConstantAndTrue('mxchange_installed')) || (REQUEST_ISSET_GET(('installing')))) $STYLES[] = "install.css";
+if ((basename($_SERVER['PHP_SELF']) == "install.php") || (!isInstalled()) || (REQUEST_ISSET_GET(('installing')))) $STYLES[] = "install.css";
// When no CSS output-mode is set, set it to file-output
if (!isConfigEntrySet('css_php')) setConfigEntry('css_php', "FILE");
require("inc/config.php");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Header
LOAD_INC("inc/header.php");
} // END - if
// Already installed?
-if ((isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered'))) {
+if ((isInstalled()) && (isAdminRegistered())) {
// Add fatal message
addFatalMessage(getMessage('ALREADY_INSTALLED'));
} // END - if
require("inc/config.php");
// Is this script installed and a JavaScript tag is provied?
-if ((isBooleanConstantAndTrue('mxchange_installed')) && (REQUEST_ISSET_GET(('tag')))) {
+if ((isInstalled()) && (REQUEST_ISSET_GET(('tag')))) {
// Set header
header("Content-type: text/javascript");
require("inc/config.php");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Header
LOAD_INC("inc/header.php");
require("inc/config.php");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Is this a member?
if (IS_MEMBER()) {
// Then redirect into login area
// Load the required file(s)
require("inc/config.php");
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Is the extension active?
REDIRECT_ON_UNINSTALLED_EXTENSION("mailid");
// Load the required file(s)
require("inc/config.php");
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Is the extension active
if (!EXT_IS_ACTIVE("mailid", true)) {
// Is not activated/installed yet!
require("inc/config.php");
// Redirect only to registration page when this script is installed
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Base URL for redirection
switch (getConfig('refid_target'))
{
REDIRECT_ON_UNINSTALLED_EXTENSION("bonus");
// List only rankings when script is installed
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Include header
LOAD_INC("inc/header.php");
require("inc/config.php");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Base URL for redirection
$URL = "modules.php?module=index&what=sponsor_login&hash=";
if (!REQUEST_ISSET_GET(('hash'))) {
require("inc/config.php");
// Redirect only to registration page when this script is installed
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Base URL for redirection
$URL = "modules.php?module=index&what=sponsor_reg&refid=";
require("inc/config.php");
// Is the script installed?
-if (isBooleanConstantAndTrue('mxchange_installed')) {
+if (isInstalled()) {
// Only logged in users may use this surfbar!
REDIRECT_ON_UNINSTALLED_EXTENSION("surfbar");