From: Roland Häder Date: Tue, 24 Feb 2009 00:02:26 +0000 (+0000) Subject: More variables renamed to , install/admin_WriteData() is now generic (with open TODO) X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=d52156d35605388b7554c31d08bc29f0bb167079 More variables renamed to , install/admin_WriteData() is now generic (with open TODO) --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 08a314f678..096d83001e 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -3,6 +3,7 @@ ./inc/extensions/ext-sql_patches.php:740: // @TODO Rewrite this to a filter! ./inc/extensions/ext-sql_patches.php:778: // @TODO Can we remove this? setConfigEntry('verbose_sql' , "N"); ./inc/extensions/ext-nickname.php:204: // @TODO|@DEPRECATED Please rewrite these constants, LOAD_CONFIG() is no more needed in extensions +./inc/modules/guest/what-wernis_portal.php:80:// @TODO Can this be removed? $rdf->clear_cache(); ./inc/modules/guest/what-sponsor_reg.php:279: // @TODO Swap this HTML code to templates ./inc/modules/guest/what-register.php:194: // @TODO Rewrite this to a single filter ./inc/modules/member/what-bonus.php:50: // @TODO Rewrite this to a filter @@ -23,8 +24,8 @@ ./inc/modules/admin/overview-inc.php:269: default: // @TODO Unknown support mode ./inc/modules/admin/what-repair_amenu.php:79:// @TODO This causes the whole (!) menu cache being rebuilded ./inc/modules/admin.php:92: // @TODO Why is this set to 'done'? -./inc/libs/task_functions.php:48:// @TODO Move all extension-dependent queries into filters ./inc/libs/yoomedia_functions.php:60: $response = YOOMEDIA_QUERY_API("out_textmail.php", true); // @TODO Ask Yoo!Media for test script +./inc/libs/task_functions.php:48:// @TODO Move all extension-dependent queries into filters ./inc/libs/rallye_functions.php:653: $EXPIRE = getConfig('one_day') * 3; // @TODO The hard-coded value... ./inc/libs/rallye_functions.php:717: // @TODO Rewrite this to our API function ./inc/libs/doubler_functions.php:41:// @TODO Lame description @@ -46,8 +47,9 @@ ./inc/functions.php:3321:// @TODO Implement $compress ./inc/functions.php:3328:// @TODO Implement $decompress ./inc/functions.php:3431: // @TODO We may want to switch over to UTF-8 here! -./inc/mysql-manager.php:1713: // @TODO Find a way for updating $_CONFIG here -./inc/mysql-manager.php:1737: // @TODO Find a way for updating $_CONFIG here +./inc/functions.php:3439:// @TODO Rewrite this function to use READ_FILE() and WRITE_FILE() +./inc/mysql-manager.php:1715: // @TODO Find a way for updating $_CONFIG here +./inc/mysql-manager.php:1739: // @TODO Find a way for updating $_CONFIG here ./beg.php:191: // @TODO Opps, what is missing here??? -./mailid_top.php:205: // @TODO Rewrite these blocks to filter ./surfbar.php:60: // @TODO Display quick login form here or redirect as configured +./mailid_top.php:205: // @TODO Rewrite these blocks to filter diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index f90a8f6f9a..50b7189f83 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -232,7 +232,7 @@ function SQL_FREERESULT ($result) { } // SQL string escaping -function SQL_QUERY_ESC ($qstring, $data, $file, $line, $run=true, $strip=true) { +function SQL_QUERY_ESC ($qstring, $data, $F, $L, $run=true, $strip=true) { global $link; // Link is there? @@ -260,7 +260,7 @@ function SQL_QUERY_ESC ($qstring, $data, $file, $line, $run=true, $strip=true) { // Debugging // //* DEBUG: */ $fp = fopen(constant('PATH')."inc/cache/escape_debug.log", 'a') or mxchange_die("Cannot write debug.log!"); - //* DEBUG: */ fwrite($fp, $file."(".$line."): ".str_replace("\r", "", str_replace("\n", " ", $eval))."\n"); + //* DEBUG: */ fwrite($fp, $F."(".$L."): ".str_replace("\r", "", str_replace("\n", " ", $eval))."\n"); //* DEBUG: */ fclose($fp); // Run the code @@ -274,7 +274,7 @@ function SQL_QUERY_ESC ($qstring, $data, $file, $line, $run=true, $strip=true) { if ($run === true) { // Run SQL query (default) - return SQL_QUERY($query, $file, $line); + return SQL_QUERY($query, $F, $L); } else { // Return secured string return $query; diff --git a/inc/functions.php b/inc/functions.php index ef6cbde532..f7c7e5be09 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -303,7 +303,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { //////////////////////// // Generate file name // //////////////////////// - $file = $BASE.$MODE.$template.".tpl"; + $FQFN = $BASE.$MODE.$template.".tpl"; if ((!empty($GLOBALS['what'])) && ((strpos($template, "_header") > 0) || (strpos($template, "_footer") > 0)) && (($MODE == "guest/") || ($MODE == "member/") || ($MODE == "admin/"))) { // Select what depended header/footer template file for admin/guest/member area @@ -315,22 +315,22 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { ); // Probe for it... - if (FILE_READABLE($file2)) $file = $file2; + if (FILE_READABLE($file2)) $FQFN = $file2; // Remove variable from memory unset($file2); } // Does the special template exists? - if (!FILE_READABLE($file)) { + if (!FILE_READABLE($FQFN)) { // Reset to default template - $file = $BASE.$template.".tpl"; + $FQFN = $BASE.$template.".tpl"; } // END - if // Now does the final template exists? - if (FILE_READABLE($file)) { + if (FILE_READABLE($FQFN)) { // The local file does exists so we load it. :) - $tmpl_file = READ_FILE($file); + $tmpl_file = READ_FILE($FQFN); // Replace ' to our own chars to preventing them being quoted while (strpos($tmpl_file, "'") !== false) { $tmpl_file = str_replace("'", '{QUOT}', $tmpl_file); } @@ -351,7 +351,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { } elseif ((IS_ADMIN()) || ((isBooleanConstantAndTrue('mxchange_installing')) && (!isBooleanConstantAndTrue('mxchange_installed')))) { // Only admins shall see this warning or when installation mode is active $ret = "
".TEMPLATE_404."
-(".basename($file).")
+(".basename($FQFN).")

".TEMPLATE_CONTENT."
".print_r($content, true)."
@@ -830,36 +830,36 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { // Check for admin/guest/member templates if (strpos($template, "admin_") > -1) { // Admin template found - $file = $BASE."admin/".$template.".tpl"; + $FQFN = $BASE."admin/".$template.".tpl"; } elseif (strpos($template, "guest_") > -1) { // Guest template found - $file = $BASE."guest/".$template.".tpl"; + $FQFN = $BASE."guest/".$template.".tpl"; } elseif (strpos($template, "member_") > -1) { // Member template found - $file = $BASE."member/".$template.".tpl"; + $FQFN = $BASE."member/".$template.".tpl"; } else { // Test for extension $test = substr($template, 0, strpos($template, "_")); if (EXT_IS_ACTIVE($test)) { // Set extra path to extension's name - $file = $BASE.$test."/".$template.".tpl"; + $FQFN = $BASE.$test."/".$template.".tpl"; } else { // No special filename - $file = $BASE.$template.".tpl"; + $FQFN = $BASE.$template.".tpl"; } } // Does the special template exists? - if (!FILE_READABLE($file)) { + if (!FILE_READABLE($FQFN)) { // Reset to default template - $file = $BASE.$template.".tpl"; + $FQFN = $BASE.$template.".tpl"; } // END - if // Now does the final template exists? $newContent = ""; - if (FILE_READABLE($file)) { + if (FILE_READABLE($FQFN)) { // The local file does exists so we load it. :) - $tmpl_file = READ_FILE($file); + $tmpl_file = READ_FILE($FQFN); $tmpl_file = SQL_ESCAPE($tmpl_file); // Run code @@ -2418,12 +2418,12 @@ function merge_array ($array1, $array2) { } // Debug message logger -function DEBUG_LOG ($file, $line, $message, $force=true) { +function DEBUG_LOG ($funcFile, $line, $message, $force=true) { // Is debug mode enabled? if ((isBooleanConstantAndTrue('DEBUG_MODE')) || ($force === true)) { // Log this message away $fp = fopen(constant('PATH')."inc/cache/debug.log", 'a') or mxchange_die("Cannot write logfile debug.log!"); - fwrite($fp, date("d.m.Y|H:i:s", time())."|".basename($file)."|".$line."|".strip_tags($message)."\n"); + fwrite($fp, date("d.m.Y|H:i:s", time())."|".basename($funcFile)."|".$line."|".strip_tags($message)."\n"); fclose($fp); } // END - if } @@ -2439,11 +2439,11 @@ function GET_DIR_AS_ARRAY ($baseDir, $prefix) { while ($baseFile = readdir($dirPointer)) { // Load file only if extension is active // Make full path - $file = $baseDir.$baseFile; + $FQFN = $baseDir.$baseFile; // Is this a valid reset file? //* DEBUG: */ print __FUNCTION__."(".__LINE__."):baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}
\n"; - if ((FILE_READABLE($file)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) { + if ((FILE_READABLE($FQFN)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) { // Remove both for extension name $extName = substr($baseFile, strlen($prefix), -4); @@ -2453,10 +2453,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[] = $file; + $INCs[] = $FQFN; } elseif ($extId == 0) { // Add non-extension files as well - $INCs[] = $file; + $INCs[] = $FQFN; } } // END - if } // END - while @@ -3435,6 +3435,78 @@ function decodeEntities ($str) { return $decodedString; } +// Wtites data to a config.php-style file +// @TODO Rewrite this function to use READ_FILE() and WRITE_FILE() +function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { + // Initialize some variables + $done = false; + $seek++; + $next = -1; + $found = false; + + // Is the file there and read-/write-able? + if ((FILE_READABLE($FQFN)) && (is_writeable($FQFN))) { + $search = "CFG: ".$comment; + $tmp = $FQFN.".tmp"; + + // Open the source file + $fp = @fopen($FQFN, 'r') or OUTPUT_HTML("READ: ".$FQFN."
"); + + // Is the resource valid? + if (is_resource($fp)) { + // Open temporary file + $fp_tmp = @fopen($tmp, 'w') or OUTPUT_HTML("WRITE: ".$tmp."
"); + + // Is the resource again valid? + if (is_resource($fp_tmp)) { + while (!feof($fp)) { + // Read from source file + $line = fgets ($fp, 1024); + + if (strpos($line, $search) > -1) { $next = 0; $found = true; } + + if ($next > -1) { + if ($next === $seek) { + $next = -1; + $line = $prefix . $DATA . $suffix."\n"; + } else { + $next++; + } + } + + // Write to temp file + fputs($fp_tmp, $line); + } + + // Close temp file + fclose($fp_tmp); + + // Finished writing tmp file + $done = true; + } + + // Close source file + fclose($fp); + + if (($done) && ($found)) { + // Copy back tmp file and delete tmp :-) + @copy($tmp, $FQFN); + @unlink($tmp); + define('_FATAL', false); + } elseif (!$found) { + OUTPUT_HTML("CHANGE: 404!"); + define('_FATAL', true); + } else { + OUTPUT_HTML("TMP: UNDONE!"); + define('_FATAL', true); + } + } + } else { + // File not found, not readable or writeable + OUTPUT_HTML("404: ".$FQFN."
"); + } +} + ////////////////////////////////////////////////// // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // ////////////////////////////////////////////////// diff --git a/inc/gen_sql_patches.php b/inc/gen_sql_patches.php index 1a7c1fc795..20cf9be76d 100644 --- a/inc/gen_sql_patches.php +++ b/inc/gen_sql_patches.php @@ -71,10 +71,10 @@ if (getConfig('master_salt') == "") { if (getConfig('file_hash') == "") { // Create filename from hashed random string - $file_hash = sha1(GEN_PASS(mt_rand(128, 256))); - $file = sprintf("%sinc/.secret/.%s", + $fileHash = sha1(GEN_PASS(mt_rand(128, 256))); + $FQFN = sprintf("%sinc/.secret/.%s", constant('PATH'), - $file_hash + $fileHash ); // Count of chars to be taken from back of the string @@ -84,18 +84,18 @@ if (getConfig('file_hash') == "") { $secretKey = substr(sha1(GEN_PASS(mt_rand(128, 256))), -$nums); // File hash was never created - WRITE_FILE($file, $secretKey); + WRITE_FILE($FQFN, $secretKey); // Is the file there? - if (FILE_READABLE($file)) { - //* DEBUG: */ unlink($file); + if (FILE_READABLE($FQFN)) { + //* DEBUG: */ unlink($FQFN); //* DEBUG: */ $test = hexdec(get_session('u_hash')) / hexdec($secretKey); //* DEBUG: */ $test = generateHash(str_replace('.', "", $test)); //* DEBUG: */ die("Secret-Key: ".$secretKey."
Cookie: ".get_session('u_hash')."
Test: ".$test); - // Write $file_hash to database + // Write $fileHash to database SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_config` SET file_hash='%s' WHERE config=0 LIMIT 1", - array($file_hash), __FILE__, __LINE__); + array($fileHash), __FILE__, __LINE__); // Generate FQFN for .htaccess file $FQFN = sprintf("%sinc/.secret/.htaccess", @@ -110,11 +110,11 @@ if (getConfig('file_hash') == "") { // Also update configuration setConfigEntry('secret_key', $secretKey); - setConfigEntry('file_hash' , $file_hash); + setConfigEntry('file_hash' , $fileHash); // Remove variables unset($secretKey); - unset($file_hash); + unset($fileHash); } // END - if } // END - if diff --git a/inc/install-inc.php b/inc/install-inc.php index eb85791009..dad33f5438 100644 --- a/inc/install-inc.php +++ b/inc/install-inc.php @@ -41,74 +41,9 @@ if (!defined('__SECURITY')) { require($INC); } -// -function install_WriteData ($file, $comment, $prefix, $suffix, $DATA, $sneak=0) { - // Initialize all and count up the "seak" value - $done = false; - $next = -1; - $sneak++; - - if (FILE_READABLE($file)) { - $search = "CFG: ".$comment; - $tmp = $file.".tmp"; - $fp = @fopen($file, 'r') or OUTPUT_HTML("READ: ".$file."
"); - if (is_resource($fp)) { - $fp_tmp = @fopen($tmp, 'w') or OUTPUT_HTML("WRITE: ".$tmp."
"); - if (is_resource($fp_tmp)) { - while (!feof($fp)) { - $line = fgets ($fp, 10240); - //* DEBUG: */ echo $search."/".htmlentities($line)."
\n"; - $found = strpos($line, $search); - //* DEBUG: */ echo "FOUND: "; - //* DEBUG: */ var_dump($found); - //* DEBUG: */ echo "
\n"; - if ($found !== false) $next = 0; - if ($next > -1) { - if ($next == $sneak) { - $next = -1; - $line = $prefix.$DATA.$suffix."\n"; - //* DEBUG: */ echo "NEW: ".htmlentities($line)."
\n"; - } else { - $next++; - } - } // END - if - //* DEBUG: */ echo "WRITE: ".htmlentities($line)."
\n"; - fputs($fp_tmp, $line); - } // END - while - fclose($fp_tmp); - - // Finished writing tmp file - $done = true; - } // END - if - - // Close source directory - fclose($fp); - - if (($done) && (is_writeable($file))) { - // Copy back tmp file and delete tmp :-) - @copy($tmp, $file); - @unlink($tmp); - } else { - OUTPUT_HTML("TMP: UNDONE!"); - } - } // END - if - } else { - OUTPUT_HTML("404: ".$file."
"); - } -} - -// +// Init variables $mysql = ""; -if (isset($_POST['mysql']) && is_array($_POST['mysql'])) $mysql = $_POST['mysql']; - -if (URL != "http://your-server.com") { - // Already installed??? - $burl = constant('URL'); -} elseif (empty($burl)) { - // Auto-detect URL - $burl = "http://".$SERVER_NAME.$_SERVER['PHP_SELF']; - $burl = substr($burl, 0, strpos($burl, "install.php")); -} +if ((isset($_POST['mysql'])) && (is_array($_POST['mysql']))) $mysql = $_POST['mysql']; // Check if both passwords from SMTP are matching if ((isset($_GET['page']) && ($_GET['page'] == 5))) { @@ -118,16 +53,19 @@ if ((isset($_GET['page']) && ($_GET['page'] == 5))) { OUTPUT_HTML(getMessage('INSTALL_SMTP_HOSTNAME_EMPTY')."
"); $_GET['page'] = 3; } // END - if + if ((empty($_POST['smtp_pass1'])) && (!empty($_POST['smtp_pass2']))) { // Password is empty OUTPUT_HTML(getMessage('INSTALL_SMTP_PASS1_EMPTY')."
"); $_GET['page'] = 3; } // END - if + if ((!empty($_POST['smtp_pass1'])) && (empty($_POST['smtp_pass2']))) { // Password repeat is empty OUTPUT_HTML(getMessage('INSTALL_SMTP_PASS2_EMPTY')."
"); $_GET['page'] = 3; } // END - if + if ($_POST['smtp_pass1'] != $_POST['smtp_pass1']) { // Passwords are not matching OUTPUT_HTML(getMessage('INSTALL_SMTP_PASS_MISMATCH')."
"); @@ -139,7 +77,7 @@ if ((isset($_GET['page']) && ($_GET['page'] == 5))) { if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered'))) { // Set URL for FORM actions - define('__BURL_ACTION', $burl); + define('__BURL_ACTION', constant('URL')); // Output page for entered value switch ($_GET['page']) @@ -341,14 +279,17 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT // Both exists so import them foreach (array("tables.sql", "menu-".GET_LANGUAGE().".sql") as $dump) { // Should be save here because file_exists() is there but we check it again. :) - $file = secureString($_POST['spath']) . "install/" . $dump; - if (FILE_READABLE($file)) { + $FQFN = secureString($_POST['spath']) . "install/" . $dump; + if (FILE_READABLE($FQFN)) { // Read the file - $SQLs = READ_FILE($file, true); + $SQLs = READ_FILE($FQFN, true); // And split it up against ;\n ... $SQLs = merge_array($SQLs, explode(";\n", $sql)); - } // END - if + } else { + // Not readable! + debug_report_bug(sprintf("SQL dump %s is not readable!", $dump)); + } } // END - foreach // Are some SQLs found? @@ -371,24 +312,24 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT } // END - foreach // Ok, all done. So we can write the config data to the php files - if ($_POST['spath'] != constant('PATH')) install_WriteData($_POST['spath']."inc/config.php", "SERVER-PATH", "define('PATH', \"", "\");", $_POST['spath'], 0); - if ($_POST['burl'] != constant('URL')) install_WriteData($_POST['spath']."inc/config.php", "HOST-URL", "define('URL', \"", "\");", $_POST['burl'], 0); - install_WriteData($_POST['spath']."inc/config.php", "MAIN_TITLE", "define('MAIN_TITLE', \"", "\");", $_POST['title'], 0); - install_WriteData($_POST['spath']."inc/config.php", "SLOGAN", "define('SLOGAN', \"", "\");", $_POST['slogan'], 0); - install_WriteData($_POST['spath']."inc/config.php", "WEBMASTER", "define('WEBMASTER', \"", "\");", $_POST['email'], 0); - install_WriteData($_POST['spath']."inc/config.php", "NULLPASS-WARNING", "define('warn_no_pass', ", ");", $_POST['warn_no_pass'], 0); - install_WriteData($_POST['spath']."inc/config.php", "WRITE-FOOTER", "define('WRITE_FOOTER', ", ");", $_POST['wfooter'], 0); - install_WriteData($_POST['spath']."inc/config.php", "BACKLINK", "define('ENABLE_BACKLINK', ", ");", $_POST['blink'], 0); - // install_WriteData($_POST['spath']."inc/config.php", "OUTPUT-MODE", "define('OUTPUT_MODE', \"", "\");", $_POST['omode'], 0); - install_WriteData($_POST['spath']."inc/config.php", "MYSQL-HOST", " 'host' => \"", "\",", $mysql['host'], 0); - install_WriteData($_POST['spath']."inc/config.php", "MYSQL-DBASE", " 'dbase' => \"", "\",", $mysql['dbase'], 0); - install_WriteData($_POST['spath']."inc/config.php", "MYSQL-LOGIN", " 'login' => \"", "\",", $mysql['login'], 0); - install_WriteData($_POST['spath']."inc/config.php", "MYSQL-PASSWORD", " 'password' => \"", "\",", $mysql['pass1'], 0); - install_WriteData($_POST['spath']."inc/config.php", "MYSQL-PREFIX", "define('_MYSQL_PREFIX', \"", "\");", $mysql['prefix'], 0); - install_WriteData($_POST['spath']."inc/config.php", "SMTP-HOSTNAME", "define('SMTP_HOSTNAME', \"", "\");", $_POST['smtp_host'], 0); - install_WriteData($_POST['spath']."inc/config.php", "SMTP-USER", "define('SMTP_USER', \"", "\");", $_POST['smtp_user'], 0); - install_WriteData($_POST['spath']."inc/config.php", "SMTP-PASSWORD", "define('SMTP_PASSWORD', \"", "\");", $_POST['smtp_pass'], 0); - install_WriteData($_POST['spath']."inc/config.php", "INSTALLED", "define('mxchange_installed', ", ");", "true", 0); + if ($_POST['spath'] != constant('PATH')) changeDataInFile($_POST['spath']."inc/config.php", "SERVER-PATH", "define('PATH', \"", "\");", $_POST['spath'], 0); + if ($_POST['burl'] != constant('URL')) changeDataInFile($_POST['spath']."inc/config.php", "HOST-URL", "define('URL', \"", "\");", $_POST['burl'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "MAIN_TITLE", "define('MAIN_TITLE', \"", "\");", $_POST['title'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "SLOGAN", "define('SLOGAN', \"", "\");", $_POST['slogan'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "WEBMASTER", "define('WEBMASTER', \"", "\");", $_POST['email'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "NULLPASS-WARNING", "define('warn_no_pass', ", ");", $_POST['warn_no_pass'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "WRITE-FOOTER", "define('WRITE_FOOTER', ", ");", $_POST['wfooter'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "BACKLINK", "define('ENABLE_BACKLINK', ", ");", $_POST['blink'], 0); + // changeDataInFile($_POST['spath']."inc/config.php", "OUTPUT-MODE", "define('OUTPUT_MODE', \"", "\");", $_POST['omode'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "MYSQL-HOST", " 'host' => \"", "\",", $mysql['host'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "MYSQL-DBASE", " 'dbase' => \"", "\",", $mysql['dbase'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "MYSQL-LOGIN", " 'login' => \"", "\",", $mysql['login'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "MYSQL-PASSWORD", " 'password' => \"", "\",", $mysql['pass1'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "MYSQL-PREFIX", "define('_MYSQL_PREFIX', \"", "\");", $mysql['prefix'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "SMTP-HOSTNAME", "define('SMTP_HOSTNAME', \"", "\");", $_POST['smtp_host'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "SMTP-USER", "define('SMTP_USER', \"", "\");", $_POST['smtp_user'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "SMTP-PASSWORD", "define('SMTP_PASSWORD', \"", "\");", $_POST['smtp_pass'], 0); + changeDataInFile($_POST['spath']."inc/config.php", "INSTALLED", "define('mxchange_installed', ", ");", "true", 0); } else { // Installation area not found! addFatalMessage(getMessage('INSTALL_MISSING_DUMPS')); @@ -418,7 +359,7 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT LOAD_TEMPLATE("install_fatal_errors"); } else { // Installation is done! - LOAD_URL($burl."/install.php?page=finalize"); + LOAD_URL("install.php?page=finalize"); } } elseif (isBooleanConstantAndTrue('mxchange_installed')) { // Redirection after writing data... :-) diff --git a/inc/libs/cache_functions.php b/inc/libs/cache_functions.php index 4e12fb90c3..121cfc096a 100644 --- a/inc/libs/cache_functions.php +++ b/inc/libs/cache_functions.php @@ -84,12 +84,12 @@ class CacheSystem { } // Checks validity of cache file and if content is given - function loadCacheFile ($file, $forceContent = false) { + function loadCacheFile ($cacheName, $forceContent = false) { // Remember cache file - $this->name = $file; + $this->name = $cacheName; // Construct FQFN (full qualified file name) - $this->inc = $this->path.$file.".cache"; + $this->inc = $this->path . $cacheName . ".cache"; // Check if file exists and if version matches $status = (FILE_READABLE($this->inc) && (is_writeable($this->inc)) && ($this->extensionVersionMatches("cache"))); diff --git a/inc/load_extensions.php b/inc/load_extensions.php index b6783c79ee..4b832a07d1 100644 --- a/inc/load_extensions.php +++ b/inc/load_extensions.php @@ -207,11 +207,11 @@ if ((SQL_NUMROWS($res_ext_crt) > 0) && ((($cacheMode == "init") && ($CSS != "1") $content['ext_menu'] = "Y"; } // END - if - // Load extensions - $file1 = sprintf("%sinc/extensions/ext-%s.php", constant('PATH'), $content['ext_name']); + // Generate FQFN for extension + $FQFN = sprintf("%sinc/extensions/ext-%s.php", constant('PATH'), $content['ext_name']); // Does the extension file exists? - if (FILE_READABLE($file1)) { + if (FILE_READABLE($FQFN)) { // By default no extension is always active, except sql_patches $EXT_ALWAYS_ACTIVE = "N"; @@ -251,7 +251,7 @@ if ((SQL_NUMROWS($res_ext_crt) > 0) && ((($cacheMode == "init") && ($CSS != "1") // Remember this value for later usage $cacheArray['active_extensions'][$content['ext_name']] = $EXT_ALWAYS_ACTIVE; } - } elseif (!FILE_READABLE($file1)) { + } elseif (!FILE_READABLE($FQFN)) { // Deleted extension file so we mark it for removal from DB $DEL[] = $content['ext_name']; } diff --git a/inc/modules/admin.php b/inc/modules/admin.php index 2127e9f67b..f72adf4b19 100644 --- a/inc/modules/admin.php +++ b/inc/modules/admin.php @@ -68,7 +68,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) { switch ($ret) { case "done": - admin_WriteData(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0); + changeDataInFile(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0); if (!constant('_FATAL')) { // Registering is done LOAD_URL("modules.php?module=admin&action=login®ister=done"); @@ -96,7 +96,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) { // Admin still not registered? if (!isBooleanConstantAndTrue('admin_registered')) { // Write to config that registration is done - admin_WriteData(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0); + changeDataInFile(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0); // Load URL for login LOAD_URL("modules.php?module=admin&action=login"); diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 7ab5e1283a..706a4724e4 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -233,76 +233,6 @@ function CHECK_ADMIN_COOKIES ($admin_login, $password) { // Return result return $ret; } -// -function admin_WriteData ($file, $comment, $prefix, $suffix, $DATA, $seek=0) { - // Initialize some variables - $done = false; - $seek++; - $next=-1; - $found = false; - - // Is the file there and read-/write-able? - if ((FILE_READABLE($file)) && (is_writeable($file))) { - $search = "CFG: ".$comment; - $tmp = $file.".tmp"; - - // Open the source file - $fp = @fopen($file, 'r') or OUTPUT_HTML("READ: ".$file."
"); - - // Is the resource valid? - if (is_resource($fp)) { - // Open temporary file - $fp_tmp = @fopen($tmp, 'w') or OUTPUT_HTML("WRITE: ".$tmp."
"); - - // Is the resource again valid? - if (is_resource($fp_tmp)) { - while (!feof($fp)) { - // Read from source file - $line = fgets ($fp, 1024); - - if (strpos($line, $search) > -1) { $next = 0; $found = true; } - - if ($next > -1) { - if ($next === $seek) { - $next = -1; - $line = $prefix . $DATA . $suffix."\n"; - } else { - $next++; - } - } - - // Write to temp file - fputs($fp_tmp, $line); - } - - // Close temp file - fclose($fp_tmp); - - // Finished writing tmp file - $done = true; - } - - // Close source file - fclose($fp); - - if (($done) && ($found)) { - // Copy back tmp file and delete tmp :-) - @copy($tmp, $file); - @unlink($tmp); - define('_FATAL', false); - } elseif (!$found) { - OUTPUT_HTML("CHANGE: 404!"); - define('_FATAL', true); - } else { - OUTPUT_HTML("TMP: UNDONE!"); - define('_FATAL', true); - } - } - } else { - // File not found, not readable or writeable - OUTPUT_HTML("404: ".$file."
"); - } -} // function ADMIN_DO_ACTION($wht) { diff --git a/inc/modules/admin/what-theme_check.php b/inc/modules/admin/what-theme_check.php index 04a9354383..d402ab5296 100644 --- a/inc/modules/admin/what-theme_check.php +++ b/inc/modules/admin/what-theme_check.php @@ -68,14 +68,14 @@ if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]")) // Leave loop when data is invalid or EOF? if ((substr($value, 0, 6) == "theme-") && (substr($value, -4) == ".zip")) { + // Extract name and version $name = substr($value, 6, -4); - $file = sprintf("%sthemes/%s/theme.php", constant('PATH'), $name); $ver = trim(substr($response[$idx + 3], 4)); // Load version $cver = THEME_GET_VERSION($name); - // Is the extension already installed or not? + // Is the theme already installed or not? if (($ver != $cver) && ($cver != "?") && ($cver != "!")) { // No, it isn't. So let's add this one! $THEMES['fname'][] = $name; @@ -87,7 +87,7 @@ if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]")) // Extract language strings from reponse $LANG_DUMMY = explode("[nl]", $response[$idx + 4]); $LANG = array(); - $INFO = ADMIN_EXT_NO_INFO_FOUND; + $INFO = getMessage('ADMIN_EXT_NO_INFO_FOUND'); // Trim every data line foreach ($LANG_DUMMY as $k => $v) { diff --git a/inc/modules/member/what-reflinks.php b/inc/modules/member/what-reflinks.php index 4a88da8c96..fbb1b0d59b 100644 --- a/inc/modules/member/what-reflinks.php +++ b/inc/modules/member/what-reflinks.php @@ -81,15 +81,15 @@ if (SQL_NUMROWS($result) > 0) { $test = str_replace(URL, constant('PATH'), $url); $size = 0; if ($test == $url) { // Download banner (I hope you keep the banner on same server???) - $fp = GET_URL($url); $file = ""; + $fp = GET_URL($url); $bannerContent = ""; if ((!empty($fp)) && (is_array($fp)) && (count($fp) > 0) { // Loads only found banner, when there is a 404 error this foreach() command // will cause an "Invalid argument supplied for foreach()" error foreach ($fp as $f) { - $file .= $f; + $bannerContent .= $f; } } - $size = strlen($file); + $size = strlen($bannerContent); } elseif (FILE_READABLE($test)) { $size = filesize($test); } diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index fa65d85ae5..2304e13b99 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -205,22 +205,23 @@ function CHECK_MODULE ($mod) { } // Add menu description pending on given file name (without path!) -function ADD_DESCR ($ACC_LVL, $file, $return = false, $output = true) { +function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { global $NAV_DEPTH; - // Use only filename of the file ;) - $file = basename($file); + // Use only filename of the FQFN... + $file = basename($FQFN); // Init variables - $LINK_ADD = ""; $OUT = ""; $AND = ""; + $LINK_ADD = ""; + $OUT = ""; + $AND = ""; // First we have to do some analysis... if (substr($file, 0, 7) == "action-") { // This is an action file! $type = "action"; $search = substr($file, 7); - switch ($ACC_LVL) - { + switch ($ACC_LVL) { case "admin": $modCheck = "admin"; break; @@ -237,8 +238,7 @@ function ADD_DESCR ($ACC_LVL, $file, $return = false, $output = true) { $type = "what"; $search = substr($file, 5); $AND = ""; - switch ($ACC_LVL) - { + switch ($ACC_LVL) { case "admin": $modCheck = "admin"; break; @@ -255,17 +255,19 @@ function ADD_DESCR ($ACC_LVL, $file, $return = false, $output = true) { $AND .= " AND `action`='".GET_ACTION($ACC_LVL, $dummy)."'"; } elseif (($ACC_LVL == "sponsor") || ($ACC_LVL == "engine")) { // Sponsor / engine menu - $type = "what"; - $search = $file; + $type = "what"; + $search = $file; $modCheck = $GLOBALS['module']; - $AND = ""; + $AND = ""; } else { // Other - $type = "menu"; - $search = $file; + $type = "menu"; + $search = $file; $modCheck = $GLOBALS['module']; - $AND = ""; + $AND = ""; } + + // Begin the navigation line if ((!isset($NAV_DEPTH)) && (!$return)) { $NAV_DEPTH = 0; $prefix = "
{--YOU_ARE_HERE--} Home";