handling of boolean constants improved (not fully)
authorRoland Häder <roland@mxchange.org>
Fri, 22 Feb 2008 22:06:56 +0000 (22:06 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 22 Feb 2008 22:06:56 +0000 (22:06 +0000)
34 files changed:
admin.php
agb.php
beg.php
birthday_confirm.php
confirm.php
doubler.php
img.php
inc/config.php
inc/db/lib-mysql3.php
inc/db/lib.php
inc/extensions.php
inc/extensions/ext-order.php
inc/extensions/ext-sql_patches.php
inc/fatal_errors.php
inc/functions.php
inc/header.php
inc/install-inc.php
inc/language.php
inc/libs/cache_functions.php
inc/load_extensions.php
inc/modules/admin.php
inc/mysql-connect.php
inc/mysql-manager.php
inc/session.php
inc/stylesheet.php
inc/theme-manager.php
index.php
install.php
lead-confirm.php
login.php
mailid.php
mailid_top.php
ref.php
show_bonus.php

index 8c26089496863c3d1897a65becdc5eec7a6d1068..f73daff9086a152e9fb56ffc18ec297748ce9a27 100644 (file)
--- a/admin.php
+++ b/admin.php
@@ -45,7 +45,7 @@ $GLOBALS['module'] = "admin"; $CSS = -1;
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Simply redirect... :-)
        LOAD_URL("modules.php?module=admin&amp;action=login");
diff --git a/agb.php b/agb.php
index a321428bc3cdb7dc8d9514cd6763348c3229be97..c9c2654fc8c2c8320478de57cdc57b307ef10c62 100644 (file)
--- a/agb.php
+++ b/agb.php
@@ -45,7 +45,7 @@ $GLOBALS['module'] = "agb"; $CSS = -1;
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Simply redirect... :-)
        LOAD_URL("modules.php?module=index&amp;what=agb");
diff --git a/beg.php b/beg.php
index 712a362f90fd947fe7cf6f2692355146203d7609..c5442dfc4c7eff8710bd28636ab3eb6ec283aeb8 100644 (file)
--- a/beg.php
+++ b/beg.php
@@ -49,7 +49,7 @@ $msg = null;
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (mxchange_installed)) {
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed'))) {
        // Check for userid
        if (!empty($_GET['uid'])) {
                // Init user ID
index cd2236573b90f6257ce33fb8e35dd603bf5e1b25..8dd674554a8111d1efff54c441dc3362d5819a25 100644 (file)
@@ -44,7 +44,7 @@ $GLOBALS['module'] = "birthday_confirm"; $CSS = -1;
 // Load the required file(s)
 require ("inc/config.php");
 
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Script is installed so let's check for his confirmation link...
        $uid = strip_tags(bigintval($_GET['uid']));
index 6e44e253088f1ed91f784000f3bdab51d8b1df3e..571941f329d8aa95de5401d6f45397d0ca91d271 100644 (file)
@@ -45,7 +45,7 @@ $GLOBALS['module'] = "confirm"; $CSS = -1;
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (mxchange_installed) && (admin_registered))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')))
 {
        // Base URL for redirection
        $URL = URL."/modules.php?module=index&what=confirm&hash=";
index f2690ca9bdc4f6c5932ca0ab8bc5a55fd4c44649..e8a088bc8cefdef9885e7ab482571898e9d1dcf1 100644 (file)
@@ -48,7 +48,7 @@ $CSS = "0";
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Probe for referral ID
        if (!empty($_GET['refid'])) $GLOBALS['refid'] = bigintval($_GET['refid']);
diff --git a/img.php b/img.php
index 82855eee2e59ed08d7d3696067647e6982c5ebc6..8710bd0ba13a908deb43f2d398fa250c59e83645 100644 (file)
--- a/img.php
+++ b/img.php
@@ -44,7 +44,7 @@ $GLOBALS['module'] = "img"; $CSS = -1;
 // Load the required file(s)
 require ("inc/config.php");
 
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        if (!empty($_GET['code']))
        {
index 3e98b5af6b35b6487e64e8d9d069e9320e855e8e..ace37e5d152d028281ea063624f41bfd3d54236f 100644 (file)
@@ -110,13 +110,6 @@ define('DEBUG_MODE', false);
 // When we are not installing
 if (!defined('mxchange_installing')) define('mxchange_installing', false);
 
-// Language stuff (default is german)
-require_once(PATH."inc/language.php");
-
-// We need general functions and database stuff here
-require_once(PATH."inc/functions.php");
-require_once(PATH."inc/mysql-manager.php");
-
 // Your MySQL data (we don't like M$ SQL ;-) )
 $MySQL = array(
        // CFG: MYSQL-HOST
index c0af2231674b1de36ea5a237807fb760a5ff26d9..0c2b15b17f24bf7e8715cdf2449928196ea0820a 100644 (file)
@@ -43,6 +43,9 @@ function SQL_QUERY($sql_string, $F, $L)
 {
        global $link, $CSS, $_CONFIG, $OK;
 
+       // Remove \t, \n and \r from queries they may confuse some MySQL version I have heard
+       $sql_string = str_replace("\t", " ", str_replace("\n", " ", str_replace("\r", " ", $sql_string)));
+
        // Run SQL command
        $result = @mysql_query($sql_string, $link)
         or ADD_FATAL($F." (".$L."):".mysql_error()."<br />
@@ -54,7 +57,7 @@ function SQL_QUERY($sql_string, $F, $L)
         $_CONFIG['sql_count']++;
 
         // Debug output
-        //* DEBUG: */ print "Query=<em>".$sql_string."</em>, affected=<b>".SQL_AFFECTEDROWS()."</b>, numrows=<b>".SQL_NUMROWS($result)."</b><br />\n";
+        //* DEBUG: */ print "Query=<pre>".$sql_string."</pre>, affected=<b>".SQL_AFFECTEDROWS()."</b>, numrows=<b>".SQL_NUMROWS($result)."</b><br />\n";
 
        if (($CSS != "1") && ($CSS != "-1") && (DEBUG_MODE) && (DEBUG_SQL))
        {
index 6bc4e7397186c0398adb11eb27ef14e86c4c8f45..d461ebf1e174eb229e8b28c4e7e7f9a272e1ac3a 100644 (file)
@@ -32,8 +32,7 @@
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
+if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
@@ -44,13 +43,10 @@ if (_DB_TYPE == "_DB_TYPE") define('_DB_TYPE', "mysql3");
 // Create include file name
 $INC = PATH."inc/db/lib-"._DB_TYPE.".php";
 
-if (file_exists($INC))
-{
+if ((file_exists($INC)) && (is_readable($INC))) {
        // Include abstraction layer
        require_once($INC);
-}
- else
-{
+} else {
        // Bye, bye...
        die("Cannot load database abstraction layer! R.I.P.");
 }
index a2aeb3f1ad2edc2fd0731cb61257269a143e7acd..3e301719a8b3b297f4cb36d1a5f4765d707d873b 100644 (file)
@@ -268,7 +268,7 @@ function EXT_IS_ACTIVE ($ext_name, $ignore_admin=false, $ignore_cache=false)
        global $cacheArray, $_CONFIG;
 
        // Extensions are all inactive during installation
-       if ((!mxchange_installed) || (mxchange_installing) || (empty($ext_name))) return false;
+       if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (empty($ext_name))) return false;
 
        // Extension's file name will also be checked
        $file = PATH."inc/extensions/ext-".$ext_name.".php";
@@ -325,7 +325,7 @@ function GET_EXT_VERSION ($ext_name) {
        $ret = false;
 
        // Extensions are all inactive during installation
-       if ((!mxchange_installed) || (mxchange_installing)) return "";
+       if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing'))) return "";
 
        // Is the cache written?
        if (!empty($cacheArray['extensions']['ext_version'][$ext_name])) {
index 34ff7e382a30a3a8b0fac78772630fe9e73ba93d..3244efa020b7786a0b1ef7ebd99f343a286a537a 100644 (file)
@@ -297,7 +297,7 @@ default: // Do stuff when extension is loaded
        unset($dummy);
 
        // Do daily reset only when installed and extension version is at least 0.1.1
-       if ((defined('__DAILY_RESET')) && (!mxchange_installing) && (mxchange_installed) && (admin_registered) && (GET_EXT_VERSION("order") >= "0.1.1"))
+       if ((defined('__DAILY_RESET')) && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')) && (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__);
index 2b232dd8b5244230a1b17a22f83c093530352a10..a4b5179c539057bbb149378c517aa65f8d919b06 100644 (file)
@@ -39,13 +39,13 @@ if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])))
 }
 
 // Version number
-$EXT_VERSION = "0.4.1";
+$EXT_VERSION = "0.4.2";
 
 // Auto-set extension version
 if (!isset($EXT_VER)) $EXT_VER = $EXT_VERSION;
 
 // Version history array (add more with , "0.1" and so on)
-$EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6", "0.1.7", "0.1.8", "0.1.9", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.3.6", "0.3.7", "0.3.8", "0.3.9", "0.4.0", "0.4.1");
+$EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6", "0.1.7", "0.1.8", "0.1.9", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.3.6", "0.3.7", "0.3.8", "0.3.9", "0.4.0", "0.4.1", "0.4.2");
 
 switch ($EXT_LOAD_MODE)
 {
@@ -521,6 +521,10 @@ PRIMARY KEY (id)
                // Update notes (these will be set as task text!)
                $UPDATE_NOTES = "Tabellen-Schl&uuml;ssel neu gesetzt und Parsing-Zeit im Footer eingeblendet.";
                break;
+
+       case "0.4.2": // SQL queries for v0.4.2
+               $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_online` ADD INDEX `admin_member` (`is_admin`, `is_member`)";
+               break;
        }
        break;
 
index edee328c70734d6b98083215650361dce3b530d4..6bb6a0ca55886cdc5ec99f641497f1e3f7d0ff27 100644 (file)
@@ -45,7 +45,7 @@ if ((sizeof($FATAL) > 0) || (!empty($FATAL[0])))
 
        // Set unset variable
        if (empty($check)) $check = "";
-       if (mxchange_installing) {
+       if (isBooleanConstantAndTrue('mxchange_installing')) {
                // While we are installing ouput other header than while it is installed... :-)
                $OUT = "";
                foreach ($FATAL as $key=>$value) {
@@ -61,7 +61,7 @@ if ((sizeof($FATAL) > 0) || (!empty($FATAL[0])))
 
                // Load main template
                LOAD_TEMPLATE("install_fatal_table", false, $OUT);
-       } elseif (mxchange_installed) {
+       } elseif (isBooleanConstantAndTrue('mxchange_installed')) {
                // Display all runtime fatal errors
                $OUT = "";
                foreach ($FATAL as $key=>$value) {
index c449c058a29024c509b99eed283c6b2e316c552a..150de6cc595ab853a719d60bdd373325191b3d86 100644 (file)
@@ -166,7 +166,7 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) {
 
 // Output the raw HTML code
 function OUTPUT_RAW ($HTML) {
-       if ((mxchange_installed) && (basename($_SERVER['PHP_SELF']) != "install.php")) {
+       if ((isBooleanConstantAndTrue('mxchange_installed')) && (basename($_SERVER['PHP_SELF']) != "install.php")) {
                // Not in install-mode so strip slashes away
                echo stripslashes($HTML);
        } else {
@@ -273,13 +273,13 @@ function LOAD_TEMPLATE($template, $return=false, $content="") {
        }
 
        // Does the special template exists?
-       if (!file_exists($file)) {
+       if ((!file_exists($file)) || (!is_readable($file))) {
                // Reset to default template
                $file = $BASE.$template.".tpl";
        }
 
        // Now does the final template exists?
-       if (file_exists($file)) {
+       if ((file_exists($file)) && (is_readable($file))) {
                // The local file does exists so we load it. :)
                $tmpl_file = implode("", file($file));
 
@@ -298,7 +298,7 @@ function LOAD_TEMPLATE($template, $return=false, $content="") {
 
                // Add surrounding HTML comments to help finding bugs faster
                $ret = "<!-- Template ".$template." - Start -->\n".$ret."<!-- Template ".$template." - End -->\n";
-       } elseif ((IS_ADMIN()) || ((mxchange_installing) && (!mxchange_installed))) {
+       } elseif ((IS_ADMIN()) || ((isBooleanConstantAndTrue('mxchange_installing')) && (!isBooleanConstantAndTrue('mxchange_installed')))) {
                // Only admins shall see this warning or when installation mode is active
                $ret = "<br /><SPAN class=\"guest_failed\">".TEMPLATE_404."</SPAN><br />
 (".basename($file).")<br />
@@ -1998,7 +1998,9 @@ function ADD_URL_DATA($URL)
 //
 function generatePassString($passHash) {
        global $_CONFIG;
-       $ret = "*FAILED*";
+
+       // Return vanilla password hash
+       $ret = $passHash;
 
        // Is a secret key and master salt already initialized?
        if ((!empty($_CONFIG['secret_key'])) && (!empty($_CONFIG['master_salt']))) {
@@ -2019,6 +2021,7 @@ function generatePassString($passHash) {
                        $start += 4;
                        $newHash .= $mod;
                }
+
                //* DEBUG: */ die($passHash."<br>".$newHash." (".strlen($newHash).")");
                $ret = generateHash($newHash, $_CONFIG['master_salt']);
        }
@@ -2109,6 +2112,13 @@ function set_session ($var, $value) {
        //* DEBUG: */ echo "IGNORED:".$var."=".$value."<br />\n";
        return true;
 }
+// Check wether a boolean constant is set
+// Taken from user comments in PHP documentation for function constant()
+function isBooleanConstantAndTrue($constname) { // : Boolean
+       $res = false;
+       if (defined($constname)) $res = (constant($constname) === true);
+       return($res);
+}
 
 //
 //////////////////////////////////////////////
index dee383f81f02d002d3444f3ea09a2238bfabef7e..20500100af20751f4e6d4f6cacb22be1a6c2b721 100644 (file)
@@ -68,7 +68,7 @@ if (($header != "1") && ($header != "2")) {
 
                                // Remember title in constant for the template
                                define('__PAGE_TITLE', html_entity_decode($TITLE));
-                       } elseif ((!mxchange_installed) || (!admin_registered)) {
+                       } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered'))) {
                                // Load language file because it was missing in installation finalizer step... *sigh*
                                require_once(sprintf("%sinc/language/install_%s.php",
                                        PATH,
@@ -94,7 +94,7 @@ if (($header != "1") && ($header != "2")) {
                LOAD_TEMPLATE("metadata");
 
                // Add meta description to header
-               if ((mxchange_installed) && (admin_registered) && ($GLOBALS['module'] != "admin") && ($GLOBALS['module'] != "login") && (isset($db)) && (isset($link))) {
+               if ((isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')) && ($GLOBALS['module'] != "admin") && ($GLOBALS['module'] != "login") && (isset($db)) && (isset($link))) {
                        // Add meta description not in admin and login module and when the script is installed
                        META_DESCRIPTION($GLOBALS['module'], $GLOBALS['what']);
                }
index 5e0a39a00df5a9904b180668eb0eece4990da176..14d36d3efbf2a59d71d5f836be289c55d0383fcf 100644 (file)
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
+if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
 
 //
 function install_WriteData ($file, $comment, $prefix, $suffix, $DATA, $sneak=0) {
-       $done = false;  $sneak++;
-       if (file_exists($file)) {
+       // Initialize all and count up the "seak" value
+       $done = false;
+       $next = 0;
+       $sneak++;
+       if ((file_exists($file)) && (is_readable($file))) {
                $search = "CFG: ".$comment;
                $tmp = $file.".tmp";
                $fp = @fopen($file, 'r') or OUTPUT_HTML("<STRONG>READ:</STRONG> ".$file."<br />");
@@ -66,6 +68,7 @@ function install_WriteData ($file, $comment, $prefix, $suffix, $DATA, $sneak=0)
                                        fputs($fp_tmp, $line);
                                }
                                fclose($fp_tmp);
+
                                // Finished writing tmp file
                                $done = true;
                        }
@@ -125,7 +128,7 @@ if ((isset($_GET['page']) && ($_GET['page'] == 5))) {
 }
 
 // Is MXChange installed or no admin registered so far?
-if ((!mxchange_installed) || (!admin_registered))
+if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered')))
 {
        // Set URL for FORM actions
        define('__BURL_ACTION', $burl);
@@ -320,7 +323,7 @@ if ((!mxchange_installed) || (!admin_registered))
                break;
 
        case "finalize": // Write captured data to files
-               if ((!empty($_POST['finalize'])) && (!mxchange_installed)) {
+               if ((!empty($_POST['finalize'])) && (!isBooleanConstantAndTrue('mxchange_installed'))) {
                        // You have submitted data then we have to reset the fatal messages
                        $FATAL = array(); $SQLs = array();
 
@@ -454,7 +457,7 @@ if ((!mxchange_installed) || (!admin_registered))
                                LOAD_URL($URL);
                        }
                }
-                elseif (mxchange_installed)
+                elseif (isBooleanConstantAndTrue('mxchange_installed'))
                {
                        // Redirection after writing data... :-)
                        LOAD_TEMPLATE("install_finished");
index 4516d20bec9fe07bdd1caf60f82e77ea556fc0d6..f39d09b5679ba104f66a2dcab5a0b0cefe417118 100644 (file)
@@ -38,12 +38,12 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
        require($INC);
 }
 
+// Set default language
 if (empty($mx_lang)) $mx_lang = DEFAULT_LANG;
 
 // Look for file
 $file = sprintf(PATH."inc/language/%s.php", $mx_lang);
-if (!file_exists($file))
-{
+if ((!file_exists($file)) || (!is_readable($file))) {
        // Switch to default (DO NOT CHANGE!!!)
        set_session("mx_lang", "de");
        $mx_lang = "de";
@@ -55,8 +55,7 @@ require($file);
 unset($file);
 
 // Check for installation mode
-if (!mxchange_installed)
-{
+if (isBooleanConstantAndTrue('mxchange_installing')) {
        // Load matching language file
        require(PATH."inc/language/install_".$mx_lang.".php");
 }
index 2e42b1dd9537a8e8b94efbeb0cd33422213e0659..cfb4cd4cae6e0e23812ef2a5cb2287ddbdadc609 100644 (file)
@@ -61,31 +61,25 @@ class mxchange_cache
                {
                        // Check if we can create a file inside the path
                        @touch($path."dummy.tmp", 'w');
-                       if (file_exists($path."dummy.tmp"))
-                       {
+                       if (file_exists($path."dummy.tmp")) {
                                // Yes, we can do. So let's remove it
-                               unlink($path."dummy.tmp");
+                               @unlink($path."dummy.tmp");
 
                                // Is there a .htaccess file?
-                               if (file_exists($path.".htaccess"))
-                               {
+                               if (file_exists($path.".htaccess")) {
                                        // Update database that we have tested it
                                        $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET cache_tested='1' WHERE config=0 LIMIT 1", __FILE__, __LINE__);
                                        $this->ret="done";
 
                                        // All done!
                                        return "done";
-                               }
-                               else
-                               {
+                               } else {
                                        // Stop! Set a .htaccess file first
                                        $this->ret="htaccess";
                                        return "htaccess";
                                }
                        }
-               }
-               elseif ($tested)
-               {
+               } elseif ($tested) {
                        // System already tested
                        $this->ret="done";
                        return "done";
index 0f35a1acfd6b45a39c34da302f09785d42d68338..b7499dae519648d1ada089037c92741ba0755c33 100644 (file)
@@ -43,7 +43,7 @@ $EXT_CSS_FILES = array();
 $ADD = "";
 
 // Skip loading extensions
-if ((!mxchange_installed) || (mxchange_installing)) return;
+if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing'))) return;
 
 // Load default sql_patches extension if present
 if (file_exists(PATH."inc/extensions/ext-sql_patches.php") && is_readable(PATH."inc/extensions/ext-sql_patches.php"))
index a4e8aeb1e4151bdc803cf70b141cd716893941e6..083009f303cfaac823b7ad6dfc62bd85afcd8cc9 100644 (file)
@@ -52,7 +52,7 @@ FIX_DELETED_COOKIES(array('admin_login', 'admin_md5', 'admin_last', 'admin_to'))
 // Is the logout empty?
 if (empty($_GET['logout'])) $_GET['logout'] = "";
 
-if (!admin_registered) {
+if (!isBooleanConstantAndTrue('admin_registered')) {
        // Admin is not registered so we have to inform the user
        if ((isset($_POST['ok'])) && ((empty($_POST['login'])) || (empty($_POST['pass'])) || (strlen($_POST['pass']) < 4))) $_POST['ok'] = "***";
        if ((isset($_POST['ok'])) && ($_POST['ok'] != "***")) {
@@ -89,7 +89,7 @@ if (!admin_registered) {
                                // Any other kind
                                $ret = "done";
                        }
-                       if (!admin_registered) {
+                       if (!isBooleanConstantAndTrue('admin_registered')) {
                                // Write to config that registration is done
                                admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define ('admin_registered', ", ");", "true", 0);
 
@@ -255,7 +255,7 @@ if (!admin_registered) {
        }
 } elseif ($_GET['logout'] == "1") {
        // Only try to remove cookies
-       if (set_session("admin_login", "", (time() - 3600), COOKIE_PATH) && set_session("admin_md5", "", (time() - 3600), COOKIE_PATH) && set_session("admin_last", "", (time() - 3600), COOKIE_PATH) && set_session("admin_to", "", (time() - 3600), COOKIE_PATH)) {
+       if (set_session("admin_login", "") && set_session("admin_md5", "") && set_session("admin_last", "") && set_session("admin_to", "")) {
                // Also remove array elements
                unset($_SESSION['admin_login']);
                unset($_SESSION['admin_md5']);
@@ -337,7 +337,7 @@ if (!admin_registered) {
        }
 }
 
-if (admin_registered)
+if (isBooleanConstantAndTrue('admin_registered'))
 {
        // Check config.php and inc directory for right access rights
        if (is_INCWritable("config"))     ADD_FATAL(FATAL_CONFIG_WRITABLE);
index 3a53518b7526564459c61e8d14d61ddf7ef650f4..6f2f6182a12a7f94a2e0f0dc9aa52922d2a9d808 100644 (file)
@@ -44,63 +44,64 @@ define('DEBUG_SQL', false);
 // Load library
 require_once(PATH."inc/db/lib.php");
 
+// Load general functions
+require_once(PATH."inc/functions.php");  // Non-database functions
+require_once(PATH."inc/extensions.php");
+require_once(PATH."inc/language.php");
+
 // Check if the user setups his MySQL stuff...
-if ((empty($MySQL['login'])) && (!mxchange_installing) && (!isset($_GET['installing'])) && (mxchange_installed))
-{
+if ((empty($MySQL['login'])) && (!isBooleanConstantAndTrue('mxchange_installing')) && (!isset($_GET['installing'])) && (isBooleanConstantAndTrue('mxchange_installed'))) {
        // No login entered and outside installation mode
        echo "<STRONG>".LANG_WARNING.":</STRONG> ";
-       if (mxchange_installed)
-       {
+       if (isBooleanConstantAndTrue('mxchange_installed')) {
                // You have changed my configuration file!
                die(DIE_CONFIG_CHANGED_YOU);
-       }
-        else
-       {
+       } else {
                // Please run the installation script (maybe again)
                die(DIE_RUN_INSTALL_MYSQL);
        }
-}
- elseif ((!mxchange_installing) && (!isset($_GET['installing'])) && (empty($MySQL['password'])) && (warn_no_pass))
-{
+} elseif ((!isBooleanConstantAndTrue('mxchange_installing')) && (!isset($_GET['installing'])) && (empty($MySQL['password'])) && (warn_no_pass)) {
        // No database password entered!!!
        echo "<STRONG>".LANG_WARNING.":</STRONG> ".WARN_NULL_PASSWORD;
 }
 
+
+// Init configuration arrays
+$_CONFIG = array(
+       'code_length' => 0
+);
+
 // Check if this file is writeable or read-only and warn the user
-if ((!mxchange_installing) && (mxchange_installed))
-{
+if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndTrue('mxchange_installed'))) {
        // Check for write-permission for config.php and inc directory
        if (empty($GLOBALS['module'])) $GLOBALS['module'] = "index";
-       if (($GLOBALS['module'] != "admin") && (admin_registered))
-       {
+       if (($GLOBALS['module'] != "admin") && (isBooleanConstantAndTrue('admin_registered')) && (!isset($_SERVER['WINDIR']))) {
                if (is_INCWritable("config"))     ADD_FATAL(FATAL_CONFIG_WRITABLE);
                if (is_INCWritable("dummy"))      ADD_FATAL(FATAL_INC_WRITABLE);
        }
-
-       // Init configuration arrays
-       $_CONFIG = array(
-               'code_length' => 0
-       );
        $EXT_CSS_FILES = array();
 
-       // Load general stuff, like...
-       require_once(PATH."inc/extensions.php"); // Extension management
-       require_once(PATH."inc/functions.php");  // Non-database functions
+       // Load "databases" aka static arrays
        require_once(PATH."inc/databases.php");     // Several hard-coded databases (arrays, constants)
 
        if ((!empty($MySQL['host'])) && (!empty($MySQL['login'])) && (!empty($MySQL['password'])) && (!empty($MySQL['dbase']))) {
                // Connect to DB
+               global $link;
                $link = SQL_CONNECT($MySQL['host'], $MySQL['login'], $MySQL['password'], __FILE__, __LINE__);
 
                // Is the link valid?
                if (is_resource($link)) {
                        // Choose the database
+                       global $db;
                        $db = SQL_SELECT_DB($MySQL['dbase'], $link, __FILE__, __LINE__);
 
                        // Is it a valid resource?
                        if ($db === true) {
                                // Load configuration stuff
-                               $result = SQL_QUERY("SELECT pass_len, points_register, points_ref, least_cats, check_double_email, check_double_pass, admin_notify, url_tlock, test_text, max_tlength, test_subj, autosend_active, max_send, url_blacklist, auto_purge, auto_purge_active, last_update, unconfirmed, profile_lock, online_timeout, mad_timestamp, mad_count, profile_update, send_prof_update, resend_profile_update, code_length, patch_level, patch_ctime, guest_stats, ref_payout, activate_xchange, order_multi_page, display_refid, ip_timeout, allow_direct_pay, config FROM "._MYSQL_PREFIX."_config WHERE config=0 LIMIT 1", __FILE__, __LINE__);
+                               $result = SQL_QUERY("SELECT pass_len, points_register, points_ref, least_cats, check_double_email, check_double_pass, admin_notify, url_tlock, test_text, max_tlength, test_subj, autosend_active, max_send, url_blacklist, auto_purge, auto_purge_active, last_update, unconfirmed, profile_lock, online_timeout, mad_timestamp, mad_count, profile_update, send_prof_update, resend_profile_update, code_length, patch_level, patch_ctime, guest_stats, ref_payout, activate_xchange, order_multi_page, display_refid, ip_timeout, allow_direct_pay, config
+FROM "._MYSQL_PREFIX."_config
+WHERE config=0
+LIMIT 1", __FILE__, __LINE__);
 
                                if (SQL_NUMROWS($result) == 1) {
                                        // Load data when previous SQL query did not fail
@@ -120,7 +121,7 @@ if ((!mxchange_installing) && (mxchange_installed))
                                        require_once(PATH."inc/mysql-manager.php"); // Functions which interact with the database
 
                                        // Run daily reset
-                                       if ((date("d", $_CONFIG['last_update']) != date("d", time()) || (DEBUG_MODE == true)) && (!mxchange_installing) && (mxchange_installed) && (admin_registered) && (!isset($_GET['register'])) && ($CSS != 1)) {
+                                       if ((date("d", $_CONFIG['last_update']) != date("d", time()) || (DEBUG_MODE == true)) && (!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')) && (!isset($_GET['register'])) && ($CSS != 1)) {
                                                // Do daily things in external PHP file but only when script is completely setup
                                                $INC_POOL[] = PATH."inc/reset/reset_daily.php";
 
@@ -231,7 +232,6 @@ if ((!mxchange_installing) && (mxchange_installed))
 
        // Include required files
        require_once(PATH."inc/databases.php");
-       require_once(PATH."inc/extensions.php");
        require_once(PATH."inc/theme-manager.php");
        require_once(PATH."inc/load_extensions.php");
        require_once(PATH."inc/session.php");
@@ -244,7 +244,7 @@ if ((!mxchange_installing) && (mxchange_installed))
        }
 
        // Double-check installation mode
-       if ((!mxchange_installed) || (!admin_registered)) {
+       if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered'))) {
                // Check for file permissions
                if (!is_INCWritable("config")) {
                        ADD_FATAL(CONFIG_IS_WRITE_PROTECTED);
@@ -260,7 +260,7 @@ if ((!mxchange_installing) && (mxchange_installed))
 
 // Any fatal messages?
 if (!is_array($FATAL)) $FATAL = array();
-if (((sizeof($FATAL) > 0) || (!empty($FATAL[0]))) && (mxchange_installed) && (!mxchange_installing) && ($CSS != "1"))
+if (((sizeof($FATAL) > 0) || (!empty($FATAL[0]))) && (isBooleanConstantAndTrue('mxchange_installed')) && (!isBooleanConstantAndTrue('mxchange_installing')) && ($CSS != "1"))
 {
        // One or more fatal error(s) occur during connect...
        include (PATH."inc/header.php");
index da0aa7159611826a404838f107ab7fd70ba07e1f..f8b4da5cde92d9a270470721b5b09e5a23ea6645 100644 (file)
@@ -44,18 +44,14 @@ function ADD_MODULE_TITLE($mod)
        global $cacheArray, $_CONFIG;
        $name = ""; $result = false;
        // Load title
-       if (!mxchange_installing)
-       {
-               if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (is_array($cacheArray['modules']['module'])) && (isset($cacheArray['modules']['module'][$mod])))
-               {
+       if (!isBooleanConstantAndTrue('mxchange_installed')) {
+               if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (is_array($cacheArray['modules']['module'])) && (isset($cacheArray['modules']['module'][$mod]))) {
                        // Load from cache
                        $name = $cacheArray['modules']['title'][$mod];
 
                        // Update cache hits
                        $_CONFIG['cache_hits']++;
-               }
-                else
-               {
+               } else {
                        // Load from database
                        $result = SQL_QUERY_ESC("SELECT title FROM "._MYSQL_PREFIX."_mod_reg WHERE module='%s' LIMIT 1", array($mod), __FILE__, __LINE__);
                        list($name) = SQL_FETCHROW($result);
@@ -67,12 +63,10 @@ function ADD_MODULE_TITLE($mod)
        $name = trim($name);
 
        // Still no luck or empty title?
-       if (empty($name))
-       {
+       if (empty($name)) {
                // No name found
                $name = LANG_UNKNOWN_MODULE." (".$mod.")";
-               if (SQL_NUMROWS($result) == 0)
-               {
+               if (SQL_NUMROWS($result) == 0) {
                        // Add module to database
                        $dummy = CHECK_MODULE($mod);
                }
@@ -104,7 +98,7 @@ function CHECK_MODULE($mod) {
        $ret = "major";
 
        // Check if script is installed if not return a "done" to prevent some errors
-       if ((!mxchange_installed) || (mxchange_installing) || (!admin_registered)) return "done";
+       if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (!isBooleanConstantAndTrue('admin_registered'))) return "done";
 
        // Check if cache is latest version
        $locked = 'Y'; $hidden = 'N'; $admin = 'N'; $mem = 'N'; $found = false;
@@ -394,31 +388,26 @@ function IS_ADMIN($admin="")
        //* DEBUG: */ echo __LINE__."ADMIN:".$admin."<br />";
 
        // If admin login is not given take current from cookies...
-       if ((empty($admin)) && (!empty($_SESSION['admin_login'])) && (!empty($_SESSION['admin_md5'])))
-       {
+       if ((empty($admin)) && (!empty($_SESSION['admin_login'])) && (!empty($_SESSION['admin_md5']))) {
                $admin = SQL_ESCAPE($_SESSION['admin_login']); $passCookie = $_SESSION['admin_md5'];
        }
        //* DEBUG: */ echo __LINE__."ADMIN:".$admin."/".$passCookie."<br />";
 
        // Search in array for entry
-       if ((!empty($passCookie)) && (isset($cacheArray['admins']['password'][$admin])) && (!empty($admin)))
-       {
+       if ((!empty($passCookie)) && (isset($cacheArray['admins']['password'][$admin])) && (!empty($admin))) {
                // Count cache hits
                $_CONFIG['cache_hits']++;
 
                // Login data is valid or not?
                $valPass = generatePassString($cacheArray['admins']['password'][$admin]);
-       }
-        elseif (!empty($admin))
-       {
+       } elseif (!empty($admin)) {
                // Search for admin
                $result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
                 array($admin), __FILE__, __LINE__);
 
                // Is he admin?
                $passDB = "";
-               if (SQL_NUMROWS($result) == 1)
-               {
+               if (SQL_NUMROWS($result) == 1) {
                        // Admin login was found so let's load password from DB
                        list($passDB) = SQL_FETCHROW($result);
                        $valPass = generatePassString($passDB);
@@ -428,8 +417,7 @@ function IS_ADMIN($admin="")
                SQL_FREERESULT($result);
        }
 
-       if (!empty($valPass))
-       {
+       if (!empty($valPass)) {
                // Check if password is valid
                //* DEBUG: */ echo __LINE__."*".$valPass."/".$passCookie)."*<br>";
                $ret = (($valPass == $passCookie) || (($valPass == "*FAILED*") && (!EXT_IS_ACTIVE("cache"))));
index 4d8c9d60137ca66d5d0aa316ed12391a94a37059..b0420aa12d9ef849f36d6b47ff008dc72ce9521e 100644 (file)
@@ -85,7 +85,7 @@ if (empty($_SESSION['refid']) || (!empty($GLOBALS['refid'])) || (($_SESSION['ref
 }
 
 // Test session if index.php or modules.php is loaded
-if ((basename($_SERVER['PHP_SELF']) == "index.php") || (basename($_SERVER['PHP_SELF']) == "modules.php") || (mxchange_installing)) {
+if ((basename($_SERVER['PHP_SELF']) == "index.php") || (basename($_SERVER['PHP_SELF']) == "modules.php") || (isBooleanConstantAndTrue('mxchange_installing'))) {
        if (count($_SESSION) > 0) {
                // Session variables accepted!
                define('__COOKIES', true);
index 9c3a67dd9e3714007f1c9f9b11b7c2de4ef01385..a341fd599f49262318f0e6db42d1d79a6d5f2455 100644 (file)
@@ -44,7 +44,7 @@ $STYLES = array(
 );
 
 // Add stylesheet for installation
-if ((basename($_SERVER['PHP_SELF']) == "install.php") || (!mxchange_installed) || (isset($_GET['installing']))) $STYLES[] = "install.css";
+if ((basename($_SERVER['PHP_SELF']) == "install.php") || (!isBooleanConstantAndTrue('mxchange_installed')) || (isset($_GET['installing']))) $STYLES[] = "install.css";
 
 // When no CSS output-mode is set, set it to file-output
 if (empty($_CONFIG['css_php'])) $_CONFIG['css_php'] = "FILE";
@@ -94,7 +94,7 @@ if (($CSS == "1") || ($_CONFIG['css_php'] == "DIRECT"))
 {
        // Now we load all CSS files from css.php!
        OUTPUT_HTML("<LINK rel=\"stylesheet\" type=\"text/css\" href=\"".URL."/css.php", false);
-       if (mxchange_installing)
+       if (isBooleanConstantAndTrue('mxchange_installing'))
        {
                // Default theme first
                $NEW_THEME = "default";
index 81e2fadfbc9a7dfdbd23ae7c4361de23cd47baa9..d591bbbfcd76967a8e51d270b1afa5f332df1e4b 100644 (file)
@@ -61,7 +61,7 @@ function GET_CURR_THEME() {
 
                // Free memory
                SQL_FREERESULT($result);
-       } elseif ((!mxchange_installed) && ((mxchange_installing) || ($CSS == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme'])))) {
+       } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isBooleanConstantAndTrue('mxchange_installing')) || ($CSS == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme'])))) {
                // Prepare FQFN for checking
                $theme = sprintf("%stheme/%s/theme.php", PATH, $_GET['theme']);
 
index d2ade5d6df1ddaae2b4a56254bc71b3645bd6201..0eb9d8dcc6e71189f1e82bc8d6d26db542f400ea 100644 (file)
--- a/index.php
+++ b/index.php
@@ -46,7 +46,7 @@ $GLOBALS['module'] = "index";
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (mxchange_installed)) {
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed'))) {
        // Header
        require(PATH."inc/header.php");
 
@@ -62,7 +62,7 @@ if (defined('mxchange_installed') && (mxchange_installed)) {
                        set_session("visited", "true", (time() + $_CONFIG['index_cookie']), COOKIE_PATH);
                } elseif (!empty($_SESSION['visited'])) {
                        // Remove cookie when admin set 0 in setup
-                       set_session("visited", "", (time() - 3600), COOKIE_PATH);
+                       set_session("visited", "");
                }
 
                // Template laden
index ca7e6335e137360177254e8bbdb9be1c426a728d..2dc4e84352de5d93ef35e95b3cbb0f6569958a08 100644 (file)
@@ -71,7 +71,7 @@ if (!isset($_GET['page']))
 }
 
 // Already installed?
-if ((mxchange_installed) && (admin_registered)) {
+if ((isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered'))) {
        // Add fatal message
        ADD_FATAL(ALREADY_INSTALLED);
 }
index 389f3a11684f24f09af94e6f8216b75d5c2baf39..382b4070e4fd8cc9e1ccf7f8ae50904b07c0cd52 100644 (file)
@@ -46,7 +46,7 @@ $GLOBALS['module'] = "lead-confirm";
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (mxchange_installed)) {
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed'))) {
        // Header
        require(PATH."inc/header.php");
 
index 7804c8c711698cea7827005f70e9d878bc8af0fb..4fb124e6071202bafe77f80b78ac19105984a9f6 100644 (file)
--- a/login.php
+++ b/login.php
@@ -45,7 +45,7 @@ $GLOBALS['module'] = "login";
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Simply redirect... :-)
        LOAD_URL("modules.php?module=index&amp;what=login");
index 3c851cab1d80c2c5e3d9e00fec31adda3da0a7d7..9b4c5786e653e99ff8e05a98447a70861781ba63 100644 (file)
@@ -44,7 +44,7 @@ $GLOBALS['module'] = "mailid"; $CSS = -1;
 // Load the required file(s)
 require ("inc/config.php");
 
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Is the extension active
        if (!EXT_IS_ACTIVE("mailid", true)) {
index eb1ed8657a07a92ea73a4e010581c4fbd877f831..a8501ad731c18c944f876dd48e39771c92c61720 100644 (file)
@@ -44,7 +44,7 @@ $GLOBALS['module'] = "mailid";  $CSS = "0";
 // Load the required file(s)
 require ("inc/config.php");
 
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Is the extension active
        if (!EXT_IS_ACTIVE("mailid", true)) {
diff --git a/ref.php b/ref.php
index 26e6087fe198b8e85b131eb31628497fe605b766..456fc3b9691169625ca332d91624ff6ab7c7f977 100644 (file)
--- a/ref.php
+++ b/ref.php
@@ -45,7 +45,7 @@ $GLOBALS['module'] = "ref"; $CSS = -1;
 require ("inc/config.php");
 
 // Redirect only to registration page when this script is installed
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Base URL for redirection
        switch ($_CONFIG['refid_target'])
index 7ebf85b15940cf085d5ba6e091cba73281b42745..0d5c910e7f7427bc6fc5be0679077f999acdad35 100644 (file)
@@ -46,7 +46,7 @@ $GLOBALS['module'] = "show_bonus"; $CSS = 0;
 require ("inc/config.php");
 
 // List only rankings when script is installed
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Include header
        include(PATH."inc/header.php");