* -------------------------------------------------------------------- *
* Kurzbeschreibung : Funktionen fuer die Installationsroutine *
* -------------------------------------------------------------------- *
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Funktionen fuer die Installationsroutine *
* -------------------------------------------------------------------- *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2008 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2008 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
if ((REQUEST_ISSET_POST(('mysql'))) && (is_array(REQUEST_POST('mysql')))) $mysql = REQUEST_POST('mysql');
// Check if both passwords from SMTP are matching
if ((REQUEST_ISSET_POST(('mysql'))) && (is_array(REQUEST_POST('mysql')))) $mysql = REQUEST_POST('mysql');
// Check if both passwords from SMTP are matching
// Okay, we have to check it
if (REQUEST_ISSET_POST(('smtp_user')) && (!REQUEST_ISSET_POST(('smtp_host')))) {
// Hostname not set
// Okay, we have to check it
if (REQUEST_ISSET_POST(('smtp_user')) && (!REQUEST_ISSET_POST(('smtp_host')))) {
// Hostname not set
if (empty($mysql['dbase'])) $mysql['dbase'] = "your_database";
if (empty($mysql['login'])) $mysql['login'] = "your_login";
if (empty($mysql['host'])) $mysql['host'] = "localhost";
if (empty($mysql['dbase'])) $mysql['dbase'] = "your_database";
if (empty($mysql['login'])) $mysql['login'] = "your_login";
if (empty($mysql['host'])) $mysql['host'] = "localhost";
if (getTotalFatalErrors() > 0) {
OUTPUT_HTML("<span class=\"install_fatal\">");
foreach (getFatalArray() as $key => $err) {
if (getTotalFatalErrors() > 0) {
OUTPUT_HTML("<span class=\"install_fatal\">");
foreach (getFatalArray() as $key => $err) {
define('__MYSQL_HOST' , $mysql['host']);
define('__MYSQL_DBASE' , $mysql['dbase']);
define('__MYSQL_PREFIX', $mysql['prefix']);
define('__MYSQL_HOST' , $mysql['host']);
define('__MYSQL_DBASE' , $mysql['dbase']);
define('__MYSQL_PREFIX', $mysql['prefix']);
define('__MYSQL_LOGIN' , $mysql['login']);
define('__SPATH_VALUE' , REQUEST_POST('spath'));
define('__BURL_VALUE' , REQUEST_POST('burl'));
define('__MYSQL_LOGIN' , $mysql['login']);
define('__SPATH_VALUE' , REQUEST_POST('spath'));
define('__BURL_VALUE' , REQUEST_POST('burl'));
- define('__SPATH_VALUE' , REQUEST_POST('spath'));
- define('__BURL_VALUE' , REQUEST_POST('burl'));
- define('__TITLE_VALUE' , REQUEST_POST('title'));
- define('__SLOGAN_VALUE' , REQUEST_POST('slogan'));
- define('__EMAIL_VALUE' , REQUEST_POST('email'));
+ define('__SPATH_VALUE' , REQUEST_POST('spath'));
+ define('__BURL_VALUE' , REQUEST_POST('burl'));
+ define('__TITLE_VALUE' , REQUEST_POST('title'));
+ define('__SLOGAN_VALUE', REQUEST_POST('slogan'));
+ define('__EMAIL_VALUE' , REQUEST_POST('email'));
- define('__MYSQL_HOST' , $mysql['host']);
- define('__MYSQL_DBASE' , $mysql['dbase']);
- define('__MYSQL_PREFIX' , $mysql['prefix']);
- define('__MYSQL_LOGIN' , $mysql['login']);
- define('__MYSQL_PASS1' , $mysql['pass1']);
- define('__MYSQL_PASS2' , $mysql['pass2']);
+ define('__MYSQL_HOST' , $mysql['host']);
+ define('__MYSQL_DBASE' , $mysql['dbase']);
+ define('__MYSQL_PREFIX', $mysql['prefix']);
+ define('__TABLE_TYPE' , $mysql['type']);
+ define('__MYSQL_LOGIN' , $mysql['login']);
+ define('__MYSQL_PASS1' , $mysql['pass1']);
+ define('__MYSQL_PASS2' , $mysql['pass2']);
- define('__SMTP_HOST' , $smtpHost);
- define('__SMTP_USER' , $smtpUser);
- define('__SMTP_PASS1' , $smtpPass1);
- define('__SMTP_PASS2' , $smtpPass2);
+ define('__SMTP_HOST' , $smtpHost);
+ define('__SMTP_USER' , $smtpUser);
+ define('__SMTP_PASS1', $smtpPass1);
+ define('__SMTP_PASS2', $smtpPass2);
- define('__SPATH_VALUE' , REQUEST_POST('spath'));
- define('__BURL_VALUE' , REQUEST_POST('burl'));
- define('__TITLE_VALUE' , REQUEST_POST('title'));
- define('__SLOGAN_VALUE' , REQUEST_POST('slogan'));
- define('__EMAIL_VALUE' , REQUEST_POST('email'));
+ define('__SPATH_VALUE' , REQUEST_POST('spath'));
+ define('__BURL_VALUE' , REQUEST_POST('burl'));
+ define('__TITLE_VALUE' , REQUEST_POST('title'));
+ define('__SLOGAN_VALUE', REQUEST_POST('slogan'));
+ define('__EMAIL_VALUE' , REQUEST_POST('email'));
- define('__MYSQL_HOST' , $mysql['host']);
- define('__MYSQL_DBASE' , $mysql['dbase']);
- define('__MYSQL_PREFIX' , $mysql['prefix']);
- define('__MYSQL_LOGIN' , $mysql['login']);
+ define('__MYSQL_HOST' , $mysql['host']);
+ define('__MYSQL_DBASE' , $mysql['dbase']);
+ define('__MYSQL_PREFIX', $mysql['prefix']);
+ define('__TABLE_TYPE' , $mysql['type']);
+ define('__MYSQL_LOGIN' , $mysql['login']);
- define('__SMTP_HOST' , REQUEST_POST('smtp_host'));
- define('__SMTP_USER' , REQUEST_POST('smtp_user'));
- define('__SMTP_PASS' , REQUEST_POST('smtp_pass1'));
+ define('__SMTP_HOST', REQUEST_POST('smtp_host'));
+ define('__SMTP_USER', REQUEST_POST('smtp_user'));
+ define('__SMTP_PASS', REQUEST_POST('smtp_pass1'));
<input type=\"hidden\" name=\"burl\" value=\"{!__BURL_VALUE!}\" />
<input type=\"hidden\" name=\"title\" value=\"{!__TITLE_VALUE!}\" />
<input type=\"hidden\" name=\"slogan\" value=\"{!__SLOGAN_VALUE!}\" />
<input type=\"hidden\" name=\"burl\" value=\"{!__BURL_VALUE!}\" />
<input type=\"hidden\" name=\"title\" value=\"{!__TITLE_VALUE!}\" />
<input type=\"hidden\" name=\"slogan\" value=\"{!__SLOGAN_VALUE!}\" />
case "finalize": // Write captured data to files
if ((REQUEST_ISSET_POST(('finalize'))) && (!isInstalled())) {
case "finalize": // Write captured data to files
if ((REQUEST_ISSET_POST(('finalize'))) && (!isInstalled())) {
// Connect to MySQL server
SQL_CONNECT($mysql['host'], $mysql['login'], $mysql['pass1'], __FILE__, __LINE__);
// Connect to MySQL server
SQL_CONNECT($mysql['host'], $mysql['login'], $mysql['pass1'], __FILE__, __LINE__);
// Seems to work, also right database?
if (SQL_SELECT_DB($mysql['dbase'], __FILE__, __LINE__) === true) {
// Automatically run install.sql
// Seems to work, also right database?
if (SQL_SELECT_DB($mysql['dbase'], __FILE__, __LINE__) === true) {
// Automatically run install.sql
if (FILE_READABLE($FQFN)) {
// Read the file
$fileContent = READ_FILE($FQFN, true);
if (FILE_READABLE($FQFN)) {
// Read the file
$fileContent = READ_FILE($FQFN, true);
+ // Replace the {!prefix/type!} with actual one
+ foreach (array('prefix', 'type') as $replace) {
+ while (strpos($fileContent, '{!' . $replace . '!}') !== false) {
+ $fileContent = str_replace('{!' . $replace . '!}', $mysql[$replace], $fileContent);
+ } // END - while
+ } // END - foreach
+
- foreach ($SQLs as $sql) {
- // Trim spaces away
- $sql = trim($sql);
-
- // Is this query not empty and not a comment?
- if ((!empty($sql)) && (substr($sql, 0, 2) != "--") && (substr($sql, 0, 1) != "#")) {
- // Then run it!
- SQL_QUERY($sql, __FILE__, __LINE__);
- } // END - if
- } // END - foreach
+ runFilterChain('run_sqls');
// Ok, all done. So we can write the config data to the php files
if (REQUEST_POST('spath') != constant('PATH')) changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SERVER-PATH", "define('PATH', \"", "\");", REQUEST_POST('spath'), 0);
// Ok, all done. So we can write the config data to the php files
if (REQUEST_POST('spath') != constant('PATH')) changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SERVER-PATH", "define('PATH', \"", "\");", REQUEST_POST('spath'), 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-LOGIN", " 'login' => \"", "\",", $mysql['login'], 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-PASSWORD", " 'password' => \"", "\",", $mysql['pass1'], 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-PREFIX", "define('_MYSQL_PREFIX', \"", "\");", $mysql['prefix'], 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-LOGIN", " 'login' => \"", "\",", $mysql['login'], 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-PASSWORD", " 'password' => \"", "\",", $mysql['pass1'], 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-PREFIX", "define('_MYSQL_PREFIX', \"", "\");", $mysql['prefix'], 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-HOSTNAME", "define('SMTP_HOSTNAME', \"", "\");", REQUEST_POST('smtp_host'), 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-USER", "define('SMTP_USER', \"", "\");", REQUEST_POST('smtp_user'), 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-PASSWORD", "define('SMTP_PASSWORD', \"", "\");", REQUEST_POST('smtp_pass1'), 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "INSTALLED", "define('mxchange_installed', ", ");", "true", 0);
} else {
// Installation area not found!
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-HOSTNAME", "define('SMTP_HOSTNAME', \"", "\");", REQUEST_POST('smtp_host'), 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-USER", "define('SMTP_USER', \"", "\");", REQUEST_POST('smtp_user'), 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-PASSWORD", "define('SMTP_PASSWORD', \"", "\");", REQUEST_POST('smtp_pass1'), 0);
changeDataInFile(REQUEST_POST('spath')."inc/config.php", "INSTALLED", "define('mxchange_installed', ", ");", "true", 0);
} else {
// Installation area not found!
foreach (getFatalArray() as $value) {
$OUT .= " <li>".$value."</li>\n";
} // END foreach
define('__FATAL_ERROR_LI', $OUT);
foreach (getFatalArray() as $value) {
$OUT .= " <li>".$value."</li>\n";
} // END foreach
define('__FATAL_ERROR_LI', $OUT);
} // END foreach
define('__MYSQL_DATA' , $OUT);
define('__SPATH_VALUE' , REQUEST_POST('spath'));
} // END foreach
define('__MYSQL_DATA' , $OUT);
define('__SPATH_VALUE' , REQUEST_POST('spath'));
- addFatalMessage(getMessage('INSTALL_FINALIZER_FAILED'));
- LOAD_INC("inc/fatal_errors.php");
+ addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_FINALIZER_FAILED'));
+ LOAD_INC('inc/fatal_errors.php');
}
break;
default:
DEBUG_LOG(__FILE__, __LINE__, sprintf("Wrong page %s detected", REQUEST_GET('page')));
}
break;
default:
DEBUG_LOG(__FILE__, __LINE__, sprintf("Wrong page %s detected", REQUEST_GET('page')));