From f74581eca45c393033acfd9d7798b958031bc625 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 1 Mar 2009 02:52:57 +0000 Subject: [PATCH] More rewrites of constants and fix for loading mass-included scripts by GET_DIR_AS_ARRAY() --- admin.php | 2 +- agb.php | 2 +- beg.php | 2 +- birthday_confirm.php | 2 +- confirm.php | 2 +- debug.php | 2 +- doubler.php | 2 +- img.php | 2 +- inc/autopurge.php | 2 +- inc/check-reset.php | 2 +- inc/extensions.php | 8 ++++---- inc/extensions/ext-order.php | 2 +- inc/fatal_errors.php | 2 +- inc/filters.php | 7 +++++++ inc/functions.php | 31 +++++++++++++++++++++---------- inc/header.php | 7 +++++-- inc/install-inc.php | 6 +++--- inc/language/de.php | 3 --- inc/language/en.php | 3 --- inc/language/install_de.php | 2 -- inc/load_cache.php | 2 +- inc/load_extensions.php | 2 +- inc/modules/admin.php | 6 +++--- inc/modules/admin/admin-inc.php | 2 +- inc/mysql-connect.php | 10 +++++----- inc/mysql-manager.php | 12 ++++++++---- inc/pool-update.php | 2 +- inc/request-functions.php | 16 ++++++++++++---- inc/stylesheet.php | 2 +- index.php | 2 +- install.php | 2 +- js.php | 2 +- lead-confirm.php | 2 +- login.php | 2 +- mailid.php | 2 +- mailid_top.php | 2 +- ref.php | 2 +- show_bonus.php | 2 +- sponsor_confirm.php | 2 +- sponsor_ref.php | 2 +- surfbar.php | 2 +- 41 files changed, 97 insertions(+), 72 deletions(-) diff --git a/admin.php b/admin.php index 97c2630822..c2beb5939a 100644 --- a/admin.php +++ b/admin.php @@ -46,7 +46,7 @@ $GLOBALS['output_mode'] = -1; require("inc/config.php"); // Is the script installed? -if (isBooleanConstantAndTrue('mxchange_installed')) { +if (isInstalled()) { // Simply redirect... :-) LOAD_URL("modules.php?module=admin"); } else { diff --git a/agb.php b/agb.php index adf6172c29..a98ef75758 100644 --- a/agb.php +++ b/agb.php @@ -46,7 +46,7 @@ $GLOBALS['output_mode'] = -1; 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 { diff --git a/beg.php b/beg.php index bcc39658e6..ab2817211a 100644 --- a/beg.php +++ b/beg.php @@ -52,7 +52,7 @@ require("inc/config.php"); 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 diff --git a/birthday_confirm.php b/birthday_confirm.php index 47bb1753b9..bb38a1eb30 100644 --- a/birthday_confirm.php +++ b/birthday_confirm.php @@ -49,7 +49,7 @@ require("inc/config.php"); 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')); diff --git a/confirm.php b/confirm.php index a865009f7c..cf27796429 100644 --- a/confirm.php +++ b/confirm.php @@ -46,7 +46,7 @@ $GLOBALS['output_mode'] = -1; 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'))) { diff --git a/debug.php b/debug.php index 533676e3f9..01198f58f5 100644 --- a/debug.php +++ b/debug.php @@ -46,7 +46,7 @@ $GLOBALS['output_mode'] = -1; 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 diff --git a/doubler.php b/doubler.php index b3292fbecf..983653ddaa 100644 --- a/doubler.php +++ b/doubler.php @@ -51,7 +51,7 @@ require("inc/config.php"); 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')); diff --git a/img.php b/img.php index 6cf27a6fe4..fa53941636 100644 --- a/img.php +++ b/img.php @@ -46,7 +46,7 @@ $GLOBALS['output_mode'] = -1; require("inc/config.php"); // Script installed? -if (isBooleanConstantAndTrue('mxchange_installed')) { +if (isInstalled()) { // Load header LOAD_INC_ONCE("inc/header.php"); diff --git a/inc/autopurge.php b/inc/autopurge.php index 8f2e72a208..262bc3d1f3 100644 --- a/inc/autopurge.php +++ b/inc/autopurge.php @@ -38,7 +38,7 @@ if (!defined('__SECURITY')) { } // 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); diff --git a/inc/check-reset.php b/inc/check-reset.php index 7de291abbf..45c59f4341 100644 --- a/inc/check-reset.php +++ b/inc/check-reset.php @@ -38,7 +38,7 @@ if (!defined('__SECURITY')) { } // 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); diff --git a/inc/extensions.php b/inc/extensions.php index dabaadb743..ba65fb3649 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -320,7 +320,7 @@ function EXTENSION_RUN_SQLS ($ext_id, $load_mode) { // 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"; @@ -372,7 +372,7 @@ function GET_EXT_VERSION ($ext_name) { $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? @@ -759,8 +759,8 @@ function MODULE_HAS_MENU ($mod, $forceDb = false) { // 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 diff --git a/inc/extensions/ext-order.php b/inc/extensions/ext-order.php index 6112f61c6d..f3435cc401 100644 --- a/inc/extensions/ext-order.php +++ b/inc/extensions/ext-order.php @@ -320,7 +320,7 @@ case "test": // For testing purposes. For details see file inc/modules/admin/wha 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 diff --git a/inc/fatal_errors.php b/inc/fatal_errors.php index a336a41483..57d133bec6 100644 --- a/inc/fatal_errors.php +++ b/inc/fatal_errors.php @@ -59,7 +59,7 @@ if (getTotalFatalErrors() > 0) { // 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) { diff --git a/inc/filters.php b/inc/filters.php index 64de90acd5..ebed4a6034 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -103,6 +103,7 @@ ORDER BY `filter_id` ASC", __FILE__, __LINE__); // 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'); @@ -505,5 +506,11 @@ function FILTER_INIT_RANDOMIZER () { 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(); +} + // ?> diff --git a/inc/functions.php b/inc/functions.php index f353494c6d..7d96a7ed02 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -356,7 +356,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { // Add surrounding HTML comments to help finding bugs faster $ret = "\n".$ret."\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 = "
".TEMPLATE_404."
(".basename($FQFN).")
@@ -925,6 +925,7 @@ function LOAD_URL ($URL, $addUrlData=true) { // 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 @@ -2377,7 +2378,7 @@ function GET_CURR_THEME() { // 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'))); @@ -2982,13 +2983,13 @@ function GET_DIR_AS_ARRAY ($baseDir, $prefix) { $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__."(".__LINE__."):baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}
\n"; @@ -3002,10 +3003,10 @@ function GET_DIR_AS_ARRAY ($baseDir, $prefix) { // 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 @@ -3029,7 +3030,7 @@ function RESET_ADD_INCLUDES () { } // 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()); @@ -3040,7 +3041,7 @@ function RESET_ADD_INCLUDES () { // 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); @@ -3052,7 +3053,7 @@ function RESET_ADD_INCLUDES () { // 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); @@ -3392,6 +3393,16 @@ function isInstalling () { 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 // ////////////////////////////////////////////////// diff --git a/inc/header.php b/inc/header.php index 723933c179..226c9918cd 100644 --- a/inc/header.php +++ b/inc/header.php @@ -76,7 +76,10 @@ if (($GLOBALS['header_sent'] != "1") && ($GLOBALS['header_sent'] != "2")) { // 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 { @@ -100,7 +103,7 @@ if (($GLOBALS['header_sent'] != "1") && ($GLOBALS['header_sent'] != "2")) { 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 diff --git a/inc/install-inc.php b/inc/install-inc.php index 1ad0dbc5ca..065726a9d2 100644 --- a/inc/install-inc.php +++ b/inc/install-inc.php @@ -74,7 +74,7 @@ if ((REQUEST_ISSET_GET(('page')) && (REQUEST_GET('page') == 5))) { } // 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')); @@ -264,7 +264,7 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT 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(); @@ -360,7 +360,7 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT // Installation is done! LOAD_URL("install.php?page=finalize"); } - } elseif (isBooleanConstantAndTrue('mxchange_installed')) { + } elseif (isInstalled()) { // Redirection after writing data... :-) LOAD_TEMPLATE("install_finished"); } else { diff --git a/inc/language/de.php b/inc/language/de.php index dbe56aa7c6..eb063ea9a8 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -37,9 +37,6 @@ if (!defined('__SECURITY')) { require($INC); } -// Language identifier -define('__LANG_ID', "Deutsch (Dtl.)"); - // Installation/setup define('CONFIG_IS_WRITE_PROTECTED', "Die Konfigurationsdatei inc/config.php ist schreibgeschützt. Bitte setzen Sie CHMOD 666 auf die Datei!"); define('DUMMY_IS_WRITE_PROTECTED', "In dem Verzeichnis inc/ kann keine Datei erzeugt werden. Bitte setzen Sie CHMOD 777 auf das Verzeichnis!"); diff --git a/inc/language/en.php b/inc/language/en.php index f3bc65839f..370b41463d 100644 --- a/inc/language/en.php +++ b/inc/language/en.php @@ -37,9 +37,6 @@ if (!defined('__SECURITY')) { 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 %s does not exists."); diff --git a/inc/language/install_de.php b/inc/language/install_de.php index ce32e43d8b..c171e777b0 100644 --- a/inc/language/install_de.php +++ b/inc/language/install_de.php @@ -38,8 +38,6 @@ if (!defined('__SECURITY')) { } // 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?) rel="external" ist gesetzt. Bitte nicht den Backlink einbauen, und nofollow verwenden! Das schadet allen."); diff --git a/inc/load_cache.php b/inc/load_cache.php index cc441d5d8b..88d53eaf6e 100644 --- a/inc/load_cache.php +++ b/inc/load_cache.php @@ -38,7 +38,7 @@ if (!defined('__SECURITY')) { } // 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); diff --git a/inc/load_extensions.php b/inc/load_extensions.php index 726591df3d..4c2c33739f 100644 --- a/inc/load_extensions.php +++ b/inc/load_extensions.php @@ -46,7 +46,7 @@ $GLOBALS['cache_instance'] = null; $GLOBALS['cache_array'] = array(); // Skip loading extensions -if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isInstalling())) { +if ((!isInstalled()) || (isInstalling())) { // Init filter system here INIT_FILTER_SYSTEM(); diff --git a/inc/modules/admin.php b/inc/modules/admin.php index 67f359aa6a..198995ae10 100644 --- a/inc/modules/admin.php +++ b/inc/modules/admin.php @@ -38,7 +38,7 @@ if (!defined('__SECURITY')) { } // 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 @@ -53,7 +53,7 @@ FIX_DELETED_COOKIES(array('admin_login', 'admin_md5', 'admin_last', 'admin_to')) $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', "***"); @@ -97,7 +97,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) { } // 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); diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 0e50b238a4..8d98c3d7ea 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -974,7 +974,7 @@ function ADMIN_DELETE_ENTRIES_CONFIRM ($IDs, $table, $columns=array(), $filterFu $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__); diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 14ff7074fe..e354d7c9c6 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -56,10 +56,10 @@ set_error_handler('__errorHandler'); 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("{--LANG_WARNING--}: "); - if (isBooleanConstantAndTrue('mxchange_installed')) { + if (isInstalled()) { // You have changed my configuration file! mxchange_die("{--DIE_CONFIG_CHANGED_YOU--}"); } else { @@ -85,7 +85,7 @@ $GLOBALS['header_sent'] = 0; 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"; @@ -219,7 +219,7 @@ if ((!isInstalling()) && (isBooleanConstantAndTrue('mxchange_installed'))) { } // 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')); @@ -233,7 +233,7 @@ if ((!isInstalling()) && (isBooleanConstantAndTrue('mxchange_installed'))) { } // 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"); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 6b244371c2..f1a90a82bd 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -44,7 +44,7 @@ function ADD_MODULE_TITLE ($mod) { $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 @@ -100,7 +100,7 @@ function CHECK_MODULE ($mod) { $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 @@ -916,8 +916,12 @@ function GET_ACTION ($MODE, &$wht) { // 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 diff --git a/inc/pool-update.php b/inc/pool-update.php index 93e986148a..2b17629be4 100644 --- a/inc/pool-update.php +++ b/inc/pool-update.php @@ -47,7 +47,7 @@ if (defined('__DAILY_RESET')) { $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); diff --git a/inc/request-functions.php b/inc/request-functions.php index 839a2ffe71..b110317396 100644 --- a/inc/request-functions.php +++ b/inc/request-functions.php @@ -59,8 +59,12 @@ function REQUEST_GET ($element) { } // 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 @@ -106,8 +110,12 @@ function REQUEST_POST ($element) { } // 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 diff --git a/inc/stylesheet.php b/inc/stylesheet.php index dfbe878f02..8a519af597 100644 --- a/inc/stylesheet.php +++ b/inc/stylesheet.php @@ -43,7 +43,7 @@ $STYLES = array( ); // 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"); diff --git a/index.php b/index.php index 4f2b720262..6a03eee622 100644 --- a/index.php +++ b/index.php @@ -49,7 +49,7 @@ $GLOBALS['output_mode'] = "0"; require("inc/config.php"); // Is the script installed? -if (isBooleanConstantAndTrue('mxchange_installed')) { +if (isInstalled()) { // Header LOAD_INC("inc/header.php"); diff --git a/install.php b/install.php index 6be0243cbc..238ae1317f 100644 --- a/install.php +++ b/install.php @@ -69,7 +69,7 @@ if (!REQUEST_ISSET_GET('page')) { } // END - if // Already installed? -if ((isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered'))) { +if ((isInstalled()) && (isAdminRegistered())) { // Add fatal message addFatalMessage(getMessage('ALREADY_INSTALLED')); } // END - if diff --git a/js.php b/js.php index ea67c9dd58..ec46e60e49 100644 --- a/js.php +++ b/js.php @@ -55,7 +55,7 @@ $GLOBALS['module'] = "js"; 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"); diff --git a/lead-confirm.php b/lead-confirm.php index 3d51c0bb2e..1a89ab74d4 100644 --- a/lead-confirm.php +++ b/lead-confirm.php @@ -49,7 +49,7 @@ $GLOBALS['output_mode'] = "0"; require("inc/config.php"); // Is the script installed? -if (isBooleanConstantAndTrue('mxchange_installed')) { +if (isInstalled()) { // Header LOAD_INC("inc/header.php"); diff --git a/login.php b/login.php index 231f9cdf27..5de0aee776 100644 --- a/login.php +++ b/login.php @@ -48,7 +48,7 @@ $GLOBALS['output_mode'] = "0"; 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 diff --git a/mailid.php b/mailid.php index 2133bd1922..0823734e6f 100644 --- a/mailid.php +++ b/mailid.php @@ -45,7 +45,7 @@ $GLOBALS['output_mode'] = -1; // Load the required file(s) require("inc/config.php"); -if (isBooleanConstantAndTrue('mxchange_installed')) { +if (isInstalled()) { // Is the extension active? REDIRECT_ON_UNINSTALLED_EXTENSION("mailid"); diff --git a/mailid_top.php b/mailid_top.php index 6af37a64d2..7e63705eaa 100644 --- a/mailid_top.php +++ b/mailid_top.php @@ -45,7 +45,7 @@ $GLOBALS['output_mode'] = 0; // 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! diff --git a/ref.php b/ref.php index 35b1e175fe..c26ce8bfde 100644 --- a/ref.php +++ b/ref.php @@ -46,7 +46,7 @@ $GLOBALS['output_mode'] = -1; 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')) { diff --git a/show_bonus.php b/show_bonus.php index 5773cf1b7d..db429a7024 100644 --- a/show_bonus.php +++ b/show_bonus.php @@ -50,7 +50,7 @@ require("inc/config.php"); 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"); diff --git a/sponsor_confirm.php b/sponsor_confirm.php index a479aaaa52..9d54361107 100644 --- a/sponsor_confirm.php +++ b/sponsor_confirm.php @@ -47,7 +47,7 @@ $GLOBALS['output_mode'] = "0"; 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'))) { diff --git a/sponsor_ref.php b/sponsor_ref.php index 0b3345e3ce..9e909bd3f2 100644 --- a/sponsor_ref.php +++ b/sponsor_ref.php @@ -46,7 +46,7 @@ $GLOBALS['output_mode'] = "0"; 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="; diff --git a/surfbar.php b/surfbar.php index 01ddd7e57a..3e10594f67 100644 --- a/surfbar.php +++ b/surfbar.php @@ -50,7 +50,7 @@ $msg = null; 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"); -- 2.39.5