From cb11b0028323b24de48bfbab2ed576455e0d9465 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 4 Jun 2016 18:20:03 +0200 Subject: [PATCH] Rewrote init-phase stuff: - now inc/init.php is being loaded as first include file - renamed some libs (old names from my previous project "MyAutoInstaller Community") to have them conform with naming convention (easier loading, too) - moved code to new functions to have it encapsulated - inc/mysql-connect.php is now deprecated - updated TODOs.txt MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- DOCS/TODOs.txt | 61 +++---- admin.php | 4 +- agb.php | 4 +- ajax.php | 4 +- api.php | 4 +- autoreg.php | 4 +- beg.php | 4 +- birthday_confirm.php | 4 +- click.php | 4 +- confirm.php | 4 +- cron.php | 4 +- css.php | 4 +- debug.php | 4 +- doubler.php | 4 +- img.php | 4 +- inc/config-global.php | 54 +----- ...sql-manager.php => database-functions.php} | 2 +- inc/{handler.php => error-functions.php} | 4 +- inc/expression-functions.php | 3 - inc/{functions.php => general-functions.php} | 114 +++++++++++- inc/init.php | 69 +++++++ inc/install-functions.php | 64 +++++++ inc/install-inc.php | 4 +- inc/mysql-connect.php | 168 +----------------- index.php | 4 +- install.php | 4 +- js.php | 4 +- lead-confirm.php | 4 +- login.php | 4 +- mailid.php | 4 +- modules.php | 2 +- network-delurl.php | 4 +- network-vcheck.php | 4 +- ref.php | 4 +- show_bonus.php | 4 +- sponsor_confirm.php | 4 +- sponsor_ref.php | 4 +- surfbar.php | 4 +- view.php | 4 +- 39 files changed, 346 insertions(+), 311 deletions(-) rename inc/{mysql-manager.php => database-functions.php} (99%) rename inc/{handler.php => error-functions.php} (97%) rename inc/{functions.php => general-functions.php} (97%) create mode 100644 inc/init.php diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 3b01431478..1d82b0ed93 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -1,4 +1,4 @@ -### WARNING: THIS FILE IS AUTO-GENERATED BY ./contrib/todo-builder.sh (uid=1051406/user=) ### +### WARNING: THIS FILE IS AUTO-GENERATED BY ./contrib/todo-builder.sh (uid=/user=quix0r) ### ### DO NOT EDIT THIS FILE. ### ./api.php:66:// @TODO Do stuff here ./autoreg.php:57:// @TODO Add processing of request here @@ -10,15 +10,18 @@ ./inc/config-functions.php:354: // @TODO Call setConfigEntry() somehow ./inc/daily/daily_beg.php:47:// @TODO This should be converted in a daily beg rallye ./inc/daily/daily_birthday.php:58:// @TODO Move this out to an extension +./inc/database-functions.php:1521: // @TODO Rewrite these lines to a filter +./inc/database-functions.php:1545: // @TODO Rewrite this to a filter +./inc/database-functions.php:1861: // @TODO Rewrite this to a filter +./inc/database-functions.php:2029: // @TODO If the EL sub-system can support more than one parameter, this call_user_func_array() can be avoided +./inc/database-functions.php:2161: // @TODO Used generic 'userid' here +./inc/database-functions.php:2379:// @TODO cacheFiles is not yet supported +./inc/database-functions.php:39:// @TODO Can we cache this? +./inc/database-functions.php:403: // @TODO Try to rewrite this to one or more functions ./inc/email-functions.php:108: * @TODO Rewrite this to an extension 'smtp' ./inc/email-functions.php:204:// @TODO $rawUserId is currently unused ./inc/expression-functions.php:168:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again ./inc/expression-functions.php:41: // @TODO is escapeQuotes() enough for strings with single/double quotes? -./inc/extensions-functions.php:2234: // @TODO Is this really neccessary? -./inc/extensions-functions.php:2291:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' -./inc/extensions-functions.php:434: // @TODO This redirect is still needed to register sql_patches! Please try to avoid it -./inc/extensions-functions.php:450:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) -./inc/extensions-functions.php:590: // @TODO Extension is loaded, what next? ./inc/extensions/admins/mode-update.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/autopurge/mode-update.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/beg/mode-update.php:38:// @TODO Remove double tabs from all lines @@ -35,6 +38,11 @@ ./inc/extensions/ext-yoomedia.php:120: // @TODO Can this be moved into a database table? ./inc/extensions/ext-yoomedia.php:54:// @TODO Only deprecated when 'ext-network' is ready: setExtensionDeprecated('Y'); ./inc/extensions/forced/mode-setup.php:38:// @TODO Remove double tabs from all lines +./inc/extensions-functions.php:2234: // @TODO Is this really neccessary? +./inc/extensions-functions.php:2291:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' +./inc/extensions-functions.php:434: // @TODO This redirect is still needed to register sql_patches! Please try to avoid it +./inc/extensions-functions.php:450:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) +./inc/extensions-functions.php:590: // @TODO Extension is loaded, what next? ./inc/extensions/grade/mode-setup.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/html_mail/mode-update.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/network/mode-setup.php:13: * @TODO ADCocktail: All request parameters, BIDausKAS, WIDausKAS??? * @@ -83,13 +91,14 @@ ./inc/extensions/transfer/mode-update.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/user/mode-update.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/user/mode-update.php:548: // @TODO Make configurable through web interface -./inc/filter-functions.php:115: // @TODO Remove this forced removal after a year or so ./inc/filter/blacklist_filter.php:105: // @TODO Insert log entry ./inc/filter/blacklist_filter.php:116: // @TODO Insert log entry ./inc/filter/blacklist_filter.php:127: // @TODO Insert log entry ./inc/filter/bonus_filter.php:56: // @TODO This query isn't right, it will only update if the user was for a longer time away! ./inc/filter/forced_filter.php:75: // @TODO This part is unfinished +./inc/filter-functions.php:115: // @TODO Remove this forced removal after a year or so ./inc/filter/order_filter.php:132: // @TODO 200 is hard-coded here, swap it out to config + admin_config_order.tpl +./inc/filters.php:1379: // @TODO No banner found, output some default banner ./inc/filter/user_filter.php:279:// @TODO 0% done ./inc/filter/user_filter.php:289:// @TODO 0% done ./inc/filter/wernis_filter.php:137:// @TODO 0% done @@ -97,22 +106,21 @@ ./inc/filter/wernis_filter.php:62:// @TODO 10% done ./inc/filter/wernis_filter.php:80:// @TODO 10% done ./inc/filter/wernis_filter.php:98:// @TODO 10% done -./inc/filters.php:1379: // @TODO No banner found, output some default banner -./inc/functions.php:1242: // @TODO Are these convertions still required? -./inc/functions.php:1263:// @TODO Rewrite this function to use readFromFile() and writeToFile() -./inc/functions.php:1567: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. -./inc/functions.php:1943: // @TODO Find a way to cache this -./inc/functions.php:2047: // @TODO This is still very static, rewrite it somehow -./inc/functions.php:2226: // @TODO Rename column data_type to e.g. mail_status -./inc/functions.php:2576:// @TODO cacheFiles is not yet supported -./inc/functions.php:440:// @TODO $allowSpider is unused +./inc/general-functions.php:1354: // @TODO Are these convertions still required? +./inc/general-functions.php:1375:// @TODO Rewrite this function to use readFromFile() and writeToFile() +./inc/general-functions.php:1679: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. +./inc/general-functions.php:2055: // @TODO Find a way to cache this +./inc/general-functions.php:2159: // @TODO This is still very static, rewrite it somehow +./inc/general-functions.php:2338: // @TODO Rename column data_type to e.g. mail_status +./inc/general-functions.php:2688:// @TODO cacheFiles is not yet supported +./inc/general-functions.php:552:// @TODO $allowSpider is unused ./inc/gen_sql_patches.php:93:// @TODO Rewrite this to a filter -./inc/install-functions.php:102: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0); -./inc/install-functions.php:497: // @TODO Comparing with DEFAULT_MAIN_TITLE doesn't work -./inc/language-functions.php:249: // @TODO These are all valid languages, again hard-coded +./inc/install-functions.php:166: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0); +./inc/install-functions.php:561: // @TODO Comparing with DEFAULT_MAIN_TITLE doesn't work ./inc/language/de.php:1150: // @TODO Rewrite these two constants ./inc/language/de.php:1166: // @TODO Rewrite these three constants ./inc/language/de.php:46: // @TODO Please sort these language elements +./inc/language-functions.php:249: // @TODO These are all valid languages, again hard-coded ./inc/language/install_de.php:155: // @TODO Move this to e.g. ext-smtp ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no * ./inc/language/order_de.php:71: // @TODO Find better text @@ -191,12 +199,12 @@ ./inc/modules/admin/what-list_rallye_prices.php:222: // @TODO Rewrite these two constants ./inc/modules/admin/what-list_refs.php:101: // @TODO Try to rewrite some to EL ./inc/modules/admin/what-list_unconfirmed.php:115: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus +./inc/modules/admin/what-list_user_cats.php:54: // @TODO No longer needed? define('__CATEGORIES_BASE' , ' not working here ./inc/template-functions.php:1128: // @TODO Deprecate this thing @@ -274,8 +274,8 @@ ./templates/de/html/guest/guest_nickname_login.tpl:21: @TODO Deactivated feature, try to find a solution for this or remove it. ./templates/de/html/guest/guest_stats_member.tpl:21: @TODO We have to fix these counters. ./templates/de/html/member/member_list_unconfirmed_nopoints.tpl:20: -./templates/de/html/surfbar/surfbar_frame_textlinks.tpl:5: ./templates/de/html/surfbar/surfbar_frameset.tpl:4: // @TODO This redirect kills our own frameset +./templates/de/html/surfbar/surfbar_frame_textlinks.tpl:5: ./js/admin-network-query-api.js:67:// @TODO Add support for checkboxes ./js/admin-network-query-api.js:68:// @TODO Make progress window working ./js/ajax-common.js:245: // @TODO Need this be secured? @@ -289,6 +289,7 @@ ### ### DEPRECATION FOLLOWS: ### ### ./contrib/install_svn.php:2:// @DEPRECATED ./inc/modules/admin/admin-inc.php:539:// @DEPRECATED +./inc/mysql-connect.php:2:// @DEPRECATED ./inc/stylesheet.php:2:// @DEPRECATED ./inc/template-functions.php:2452:// Removes comments with @DEPRECATED ./inc/template-functions.php:2460: // Is there a @DEPRECATED? diff --git a/admin.php b/admin.php index 4eb3e7aea2..d9deaec77f 100644 --- a/admin.php +++ b/admin.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'admin'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type for e.g. search engines setContentType('text/html'); diff --git a/agb.php b/agb.php index dc606c4214..5cadca9b3c 100644 --- a/agb.php +++ b/agb.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'agb'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type for e.g. search engines setContentType('text/html'); diff --git a/ajax.php b/ajax.php index 7ebbaae429..73b3d8f191 100644 --- a/ajax.php +++ b/ajax.php @@ -48,8 +48,8 @@ $GLOBALS['__module'] = 'ajax'; $GLOBALS['__header_sent'] = 2; $GLOBALS['__footer_sent'] = 2; -// Load config file -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Load special AJAX library loadIncludeOnce('inc/ajax-functions.php'); diff --git a/api.php b/api.php index a27acc7b82..1b60bfc89a 100644 --- a/api.php +++ b/api.php @@ -51,8 +51,8 @@ $GLOBALS['__footer_sent'] = 2; // Temporary set HTTP 404 here. This will be removed once this stuff is ready. setHttpStatus('404 Not Found'); -// Load config file -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Load special API library //loadIncludeOnce('inc/api-functions.php'); diff --git a/autoreg.php b/autoreg.php index ecd2f9c2b9..f843365074 100644 --- a/autoreg.php +++ b/autoreg.php @@ -45,8 +45,8 @@ $GLOBALS['__module'] = 'autoreg'; $GLOBALS['__header_sent'] = 2; $GLOBALS['__footer_sent'] = 2; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type setContentType('text/plain'); diff --git a/beg.php b/beg.php index 2d52ee717b..5114836eb1 100644 --- a/beg.php +++ b/beg.php @@ -41,8 +41,8 @@ $GLOBALS['__module'] = 'beg'; $GLOBALS['__output_mode'] = '0'; $errorCode = NULL; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type setContentType('text/html'); diff --git a/birthday_confirm.php b/birthday_confirm.php index 0321d7f5b3..30a21421eb 100644 --- a/birthday_confirm.php +++ b/birthday_confirm.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'birthday_confirm'; $GLOBALS['__output_mode'] = '0'; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type setContentType('text/html'); diff --git a/click.php b/click.php index ca290a969b..0ef848cee5 100644 --- a/click.php +++ b/click.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'click'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type, this is required for search engines setContentType('text/html'); diff --git a/confirm.php b/confirm.php index 7ebd0d1184..7974397447 100644 --- a/confirm.php +++ b/confirm.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'confirm'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type for e.g. search engines setContentType('text/html'); diff --git a/cron.php b/cron.php index dc8af6902b..b6863e5d69 100644 --- a/cron.php +++ b/cron.php @@ -48,8 +48,8 @@ $GLOBALS['__module'] = 'cron'; $GLOBALS['__header_sent'] = 2; $GLOBALS['__footer_sent'] = 2; -// Load config file -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Load header here loadPageHeader(); diff --git a/css.php b/css.php index 2c2278960d..5178b29a0f 100644 --- a/css.php +++ b/css.php @@ -43,8 +43,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'css'; $GLOBALS['__output_mode'] = 1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set header setContentType('text/css'); diff --git a/debug.php b/debug.php index 46bdb2bc9d..50c800f0da 100644 --- a/debug.php +++ b/debug.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'debug'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Redirect only to registration page when this script is installed if ((isExtensionActive('debug')) && (!ifFatalErrorsDetected())) { diff --git a/doubler.php b/doubler.php index 496e30a1d4..c1b3b91a6e 100644 --- a/doubler.php +++ b/doubler.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'doubler'; $GLOBALS['__output_mode'] = '0'; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type setContentType('text/html'); diff --git a/img.php b/img.php index bc98c91e98..27722067f1 100644 --- a/img.php +++ b/img.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'img'; $GLOBALS['__output_mode'] = -3; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Load header loadPageHeader(); diff --git a/inc/config-global.php b/inc/config-global.php index 78359322d7..94cb2c867a 100644 --- a/inc/config-global.php +++ b/inc/config-global.php @@ -35,58 +35,23 @@ if (!defined('__SECURITY')) { die(); } // END - if -/************************************************************************ - * PLEASE DO NOT EDIT THE COMMENTS! install.php NEEDS THEM! * - ************************************************************************/ - -// Proper function exists? -if (function_exists('date_default_timezone_set')) { - // Set default timezone to Europe/Berlin (because I'm from Germany) - @date_default_timezone_set('Europe/Berlin'); -} // END - if - -// CFG: ERROR-REPORTING -error_reporting(E_ALL | E_DEPRECATED | E_STRICT); - -// Is the function there? (removed in PHP 5.4.0) -if (function_exists('import_request_variables')) { - // CFG: REGISTER-GLOBALS - @import_request_variables(''); -} // END - if - -// Detect path (without 'inc') and fix windozer paths -$path = str_replace(chr(92), '/', substr(dirname(__FILE__), 0, -3)); - -// Some very important function includes -foreach (array('config', 'wrapper', 'template', 'module', 'inc', 'http') as $inc) { - include($path . 'inc/' . $inc . '-functions.php'); -} // END - foreach - -// General functions -include($path . 'inc/functions.php'); +/******************************************************************************** + * Please don't touch anything here. Instead set them again in config-local.php * + ********************************************************************************/ // Auto-detection of URL $URL = detectServerProtocol() . '://' . detectServerName() . str_replace(chr(92), '/', dirname($_SERVER['PHP_SELF'])); while (substr($URL, -1, 1) == '/') { $URL = substr($URL, 0, -1); } -// Initialize the configuration -initConfig(); - -// Init HTTP handling -initHttp(); +// CFG: HOST-URL (without trailing '/' !) +setConfigEntry('URL', $URL); // CFG: FLOAT-MASK setConfigEntry('FLOAT_MASK', '%01.5f'); -// CFG: HOST-URL (without trailing '/' !) -setConfigEntry('URL', $URL); - // CFG: DOMAIN-NAME (without trailing '/' !) setConfigEntry('DOMAIN', detectDomainName()); -// CFG: SERVER-PATH -setConfigEntry('PATH', $path); - // CFG: VERSION setConfigEntry('VERSION', 'v0.2.1'); @@ -118,14 +83,7 @@ setConfigEntry('salt_length', 10); setConfigEntry('minium_admin_pass_length', 4); // Remove maybe conflicting variables -unset($url); -unset($path); - -// Connect to the database... -loadIncludeOnce('inc/mysql-connect.php'); - -// Init stats system -initStatsSystem(); +unset($URL); // [EOF] ?> diff --git a/inc/mysql-manager.php b/inc/database-functions.php similarity index 99% rename from inc/mysql-manager.php rename to inc/database-functions.php index d41930089f..c299781427 100644 --- a/inc/mysql-manager.php +++ b/inc/database-functions.php @@ -4,7 +4,7 @@ * =================== Last change: 11/29/2004 * * * * -------------------------------------------------------------------- * - * File : mysql-manager.php * + * File : database-functions.php * * -------------------------------------------------------------------- * * Short description : All database-related functions * * -------------------------------------------------------------------- * diff --git a/inc/handler.php b/inc/error-functions.php similarity index 97% rename from inc/handler.php rename to inc/error-functions.php index d21b68aa2e..9c36418b71 100644 --- a/inc/handler.php +++ b/inc/error-functions.php @@ -4,7 +4,7 @@ * =================== Last change: 02/28/2009 * * * * -------------------------------------------------------------------- * - * File : handler.php * + * File : error-functions.php * * -------------------------------------------------------------------- * * Short description : Handler functions (call-back) * * -------------------------------------------------------------------- * @@ -33,7 +33,7 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} +} // END - if // Error handler function function __errorHandler ($errno, $errstr, $errfile, $errline) { diff --git a/inc/expression-functions.php b/inc/expression-functions.php index 9bd74b48cc..fcd54874ca 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -322,9 +322,6 @@ function doExpressionMath ($data) { // Replace the code $code = replaceExpressionCode($data, $replacer); - // Load include once - loadIncludeOnce('inc/math-functions.php'); - // Return the (maybe) replaced code return $code; } diff --git a/inc/functions.php b/inc/general-functions.php similarity index 97% rename from inc/functions.php rename to inc/general-functions.php index 0d6c9889ec..acdec10b65 100644 --- a/inc/functions.php +++ b/inc/general-functions.php @@ -4,7 +4,7 @@ * =================== Last change: 11/29/2005 * * * * -------------------------------------------------------------------- * - * File : functions.php * + * File : general-functions.php * * -------------------------------------------------------------------- * * Short description : Many non-database functions (also file access) * * -------------------------------------------------------------------- * @@ -35,6 +35,118 @@ if (!defined('__SECURITY')) { die(); } // END - if +// Initialize application +function initApplication ($path) { + // Initialize the configuration + initConfig(); + + // Set base path in configuration + setConfigEntry('PATH', $path); + + // Load global configuration file + loadIncludeOnce('inc/config-global.php'); + + // Load more libraries + loadLibraries(); + + // Set error handler + set_error_handler('__errorHandler'); + + // Disable block-mode by default + enableBlockMode(FALSE); + + // Init error handler + initErrorHandler(); + + // Init request + initRequest(); + + // Init userid + initMemberId(); + + // Set important header_sent + if (!isset($GLOBALS['__header_sent'])) { + $GLOBALS['__header_sent'] = '0'; + } // END - if + + // Init fatal messages + initFatalMessages(); + + // Enable HTML templates by default + enableTemplateHtml(); + + // Are we in installation phase? + if ((!isInstaller()) && (isInstalled())) { + // Regular bootstrap + doNormalBootstrap(); + } else { + // Installer bootstrap + doInstallerBootstrap(); + } + + // Init stats system + initStatsSystem(); + + // Init HTTP handling + initHttp(); + + // Init stats system + initStatsSystem(); + + // Handle fatal errors + runFilterChain('handle_fatal_errors'); +} + +// Loads additional libraries +function loadLibraries () { + // Init arrays + $__functions = array(); + $__libs = array( + 'stats', + 'xml', + 'callback', + 'referral', + 'email', + 'request', + 'session', + 'code', + 'pool', + 'language', + 'sql', + 'expression', + 'encryption', + 'filter', + 'extensions', + 'database', + 'error', + 'math', + ); + + // Init include file array as it follows same naming scheme + foreach ($__libs as $lib) { + // Add it + array_push($__functions, $lib . '-functions'); + } // END - foreach + + // Add more libs (let's get rid of them slowly) + foreach (array('filters') as $lib) { + // Add it + array_push($__functions, $lib); + } // END - foreach + + // Load all + foreach ($__functions as $lib) { + // Load special functions + loadIncludeOnce('inc/' . $lib . '.php'); + } // END - foreach + + // Is installer phase? + if ((isInstaller()) || (!isInstalled())) { + // Add installer lib as well + loadIncludeOnce('inc/install-functions.php'); + } // END - if +} + // Init fatal message array function initFatalMessages () { $GLOBALS['fatal_messages'] = array(); diff --git a/inc/init.php b/inc/init.php new file mode 100644 index 0000000000..c46410b0c2 --- /dev/null +++ b/inc/init.php @@ -0,0 +1,69 @@ + diff --git a/inc/install-functions.php b/inc/install-functions.php index c62b260723..9b4b42403f 100644 --- a/inc/install-functions.php +++ b/inc/install-functions.php @@ -76,6 +76,70 @@ function initInstaller () { setConfigEntry('verbose_sql' , 'N'); } +// Installer bootstrap +function doInstallerBootstrap () { + // Default output is 'direct' for HTML output + setConfigEntry('OUTPUT_MODE', 'direct'); + + // This hack prevents a backtrace in CSS output + if (isCssOutputMode()) { + // Problem with config so set output mode + setConfigEntry('OUTPUT_MODE', 'render'); + } // END - if + + // Debug message + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isAjaxOutputMode()=' . intval(isAjaxOutputMode()) . ',isSessionVariableSet(database_extension)=' . intval(isSessionVariableSet('database_extension'))); + + // Is it AJAX call and database_extension is set? + if ((isAjaxOutputMode()) && (isSessionVariableSet('database_extension'))) { + // Then take it from session + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Setting _DB_TYPE from session;database_extension=' . getSession('database_extension')); + setConfigEntry('_DB_TYPE', getSession('database_extension')); + } elseif (isPhpExtensionLoaded('mysqli')) { + // Debug message + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Setting _DB_TYPE to MySQLi ...'); + + // Set (old) default + setConfigEntry('_DB_TYPE', 'mysqli'); + } elseif (isPhpExtensionLoaded('mysql')) { + // Debug message + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Setting _DB_TYPE to default (mysql) ...'); + + // Set (old) default + setConfigEntry('_DB_TYPE', 'mysql'); + } else { + // Opps, cannot detect it? + reportBug(__FUNCTION__, __LINE__, 'Cannot detect mysql/mysqli. Please fix your setup.'); + } + + // Set link as down + unsetSqlLinkUp(__FUNCTION__, __LINE__); + + // Load database layer here + loadIncludeOnce('inc/db/lib.php'); + + // Init message system + initMessages(); + + // Init session + initSession(); + + // Include more + foreach (array('databases', 'install-functions', 'load_config', 'load_cache') as $inc) { + // Load include file + loadIncludeOnce('inc/' . $inc . '.php'); + } // END - foreach + + // Init installer + initInstaller(); + + // Check whether we are in installation routine + if ((!isInstalling()) && (!isCssOutputMode()) && (!isRawOutputMode())) { + // Redirect to the URL + redirectToUrl('install.php'); + } // END - if +} + // Write the local config-local.php file from "template" function doInstallWriteLocalConfigurationFile ($path, $url, $title, $slogan, $email, $noPassword, $writeFooter, $backLink, $databaseHost, $databaseName, $databaseLogin, $databasePassword, $databasePrefix, $tableType, $databaseExtension, $smtpHost, $smtpUser, $smtpPassword) { // Copy the config template and verify it diff --git a/inc/install-inc.php b/inc/install-inc.php index 5483d4fd83..ab96d7b41e 100644 --- a/inc/install-inc.php +++ b/inc/install-inc.php @@ -6,9 +6,9 @@ * -------------------------------------------------------------------- * * File : install-inc.php * * -------------------------------------------------------------------- * - * Short description : Functions for installation procedure * + * Short description : Initial stuff for plain (old) installer * * -------------------------------------------------------------------- * - * Kurzbeschreibung : Funktionen fuer die Installationsroutine * + * Kurzbeschreibung : Initiale Dinge fuer alten Installer * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * * Copyright (c) 2009 - 2016 by Mailer Developer Team * diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 513b391e66..f551ef47b7 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -1,169 +1,3 @@ diff --git a/index.php b/index.php index 4eb0414c5d..0422155a35 100644 --- a/index.php +++ b/index.php @@ -45,8 +45,8 @@ $GLOBALS['__module'] = 'index'; $GLOBALS['__what'] = 'welcome'; $GLOBALS['__output_mode'] = '0'; -// Load config.php -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Fix what to 'home' setWhat(getIndexHome()); diff --git a/install.php b/install.php index 16c8f4e833..23fc61f58a 100644 --- a/install.php +++ b/install.php @@ -46,8 +46,8 @@ $GLOBALS['__mailer_installing'] = TRUE; $GLOBALS['__module'] = 'install'; $GLOBALS['__output_mode'] = '0'; -// Load config file -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type setContentType('text/html'); diff --git a/js.php b/js.php index 49e7946740..7fae050e4d 100644 --- a/js.php +++ b/js.php @@ -51,8 +51,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'js'; $GLOBALS['__output_mode'] = 1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set header and HTTP status setContentType('text/javascript'); diff --git a/lead-confirm.php b/lead-confirm.php index 262724e6a4..69125767d8 100644 --- a/lead-confirm.php +++ b/lead-confirm.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'lead-confirm'; $GLOBALS['__output_mode'] = '0'; -// Load config.php -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type setContentType('text/html'); diff --git a/login.php b/login.php index d86debb7fe..fa30f29771 100644 --- a/login.php +++ b/login.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'login'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Is this a member? if (isMember()) { diff --git a/mailid.php b/mailid.php index 1ba8898ea8..cebf439e9a 100644 --- a/mailid.php +++ b/mailid.php @@ -43,8 +43,8 @@ $GLOBALS['__output_mode'] = '0'; // Disable copyright footer which would be to large for the upper frame $GLOBALS['__copyright_enabled'] = 'N'; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type and HTTP status setContentType('text/html'); diff --git a/modules.php b/modules.php index b57ede4dcb..2a2440708a 100644 --- a/modules.php +++ b/modules.php @@ -44,7 +44,7 @@ $GLOBALS['__module'] = 'unknown'; $GLOBALS['__output_mode'] = '0'; // Needed include files -require('inc/config-global.php'); +require('inc/init.php'); // Include module doIncludeModule(); diff --git a/network-delurl.php b/network-delurl.php index f9a504dbdb..ff4cbeec0c 100644 --- a/network-delurl.php +++ b/network-delurl.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'network-delurl'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set HTTP status to 500 (if ext-network is not found, but this script is called) setHttpStatus('500 Internal Server Error'); diff --git a/network-vcheck.php b/network-vcheck.php index 002d2652dc..a21f50ea99 100644 --- a/network-vcheck.php +++ b/network-vcheck.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'network-vcheck'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set HTTP status to 500 (if ext-network is not found, but this script is called) setHttpStatus('500 Internal Server Error'); diff --git a/ref.php b/ref.php index 43f5f11e8f..80850e2f81 100644 --- a/ref.php +++ b/ref.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'ref'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type for e.g. search engines setContentType('text/html'); diff --git a/show_bonus.php b/show_bonus.php index 895a2e8877..1b8dec3d3b 100644 --- a/show_bonus.php +++ b/show_bonus.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'show_bonus'; $GLOBALS['__output_mode'] = '0'; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type setContentType('text/html'); diff --git a/sponsor_confirm.php b/sponsor_confirm.php index 1060999154..589db853d7 100644 --- a/sponsor_confirm.php +++ b/sponsor_confirm.php @@ -39,8 +39,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'sponsor_confirm'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type for e.g. search engines setContentType('text/html'); diff --git a/sponsor_ref.php b/sponsor_ref.php index 03f5a26ccb..eed2e8315c 100644 --- a/sponsor_ref.php +++ b/sponsor_ref.php @@ -39,8 +39,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'sponsor_ref'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type for e.g. search engines setContentType('text/html'); diff --git a/surfbar.php b/surfbar.php index edff6dd5a4..d33ab6b78c 100644 --- a/surfbar.php +++ b/surfbar.php @@ -41,8 +41,8 @@ $GLOBALS['__module'] = 'surfbar'; $GLOBALS['__output_mode'] = '0'; $GLOBALS['__header_sent'] = 3; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Set content type setContentType('text/html'); diff --git a/view.php b/view.php index 6423766b36..3d1d70fc4e 100644 --- a/view.php +++ b/view.php @@ -40,8 +40,8 @@ $GLOBALS['__start_time'] = microtime(TRUE); $GLOBALS['__module'] = 'view'; $GLOBALS['__output_mode'] = -1; -// Load the required file(s) -require('inc/config-global.php'); +// Initialize application +require('inc/init.php'); // Run filter chain runFilterChain('handle_view_php'); -- 2.30.2