'mysql_host' => 'database_config',
'mysql_dbase' => 'database_config',
'mysql_prefix' => 'database_config',
- 'mysql_type' => 'database_config',
+ 'mysql_engine' => 'database_config',
'mysql_login' => 'database_config',
'mysql_password1' => 'database_config',
'mysql_password2' => 'database_config',
}
// Write the local config-local.php file from "template"
-function doInstallWriteLocalConfigurationFile ($path) {
+function doInstallWriteLocalConfigurationFile ($path, $url, $title, $slogan, $email, $noPassword, $writeFooter, $backLink, $databaseHost, $databaseName, $databaseLogin, $databasePassword, $databasePrefix, $databaseType, $smtpHost, $smtpUser, $smtpPassword) {
// Copy the config template and verify it
- copyFileVerified(postRequestElement('spath') . 'inc/config-local.php.dist', postRequestElement('spath') . getCachePath() . 'config-local.php', 0644);
-
- // Ok, all done. So we can write the config data to the php files
- // Do only write these if they differ from auto-detected values
- if (postRequestElement('spath') != getPath()) changeDataInLocalConfigurationFile('SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestElement('spath'), 0);
- if (postRequestElement('burl') != getUrl()) changeDataInLocalConfigurationFile('HOST-URL', "setConfigEntry('URL', '", "');", postRequestElement('burl'), 0);
+ copyFileVerified($path . 'inc/config-local.php.dist', $path . getCachePath() . 'config-local.php', 0644);
+
+ /*
+ * Ok, all done. So we can write the config data to the php files. Do only
+ * write these if they differ from auto-detected values.
+ */
+ if ($path != getPath()) {
+ changeDataInLocalConfigurationFile('SERVER-PATH', "setConfigEntry('PATH', '", "');", $path, 0);
+ } // END - if
+ if ($url != getUrl()) {
+ changeDataInLocalConfigurationFile('HOST-URL', "setConfigEntry('URL', '", "');", $url, 0);
+ } // END - if
// Write more data
- changeDataInLocalConfigurationFile('MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestElement('title'), 0);
- changeDataInLocalConfigurationFile('SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestElement('slogan'), 0);
- changeDataInLocalConfigurationFile('WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestElement('email'), 0);
- changeDataInLocalConfigurationFile('NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestElement('warn_no_pass'), 0);
- changeDataInLocalConfigurationFile('WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestElement('wfooter'), 0);
- changeDataInLocalConfigurationFile('BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestElement('blink'), 0);
+ changeDataInLocalConfigurationFile('MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", $title, 0);
+ changeDataInLocalConfigurationFile('SLOGAN', "setConfigEntry('SLOGAN', '", "');", $slogan, 0);
+ changeDataInLocalConfigurationFile('WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", $email, 0);
+ changeDataInLocalConfigurationFile('NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", $noPassword, 0);
+ changeDataInLocalConfigurationFile('WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", $writeFooter, 0);
+ changeDataInLocalConfigurationFile('BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", $backLink, 0);
// @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0);
- changeDataInLocalConfigurationFile('MYSQL-HOST', " 'host' => '", "',", postRequestElement('mysql','host'), 0);
- changeDataInLocalConfigurationFile('MYSQL-DBASE', " 'dbase' => '", "',", postRequestElement('mysql','dbase'), 0);
- changeDataInLocalConfigurationFile('MYSQL-LOGIN', " 'login' => '", "',", postRequestElement('mysql','login'), 0);
- changeDataInLocalConfigurationFile('MYSQL-PASSWORD', " 'password' => '", "',", postRequestElement('mysql','pass1'), 0);
- changeDataInLocalConfigurationFile('MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestElement('mysql','prefix'), 0);
- changeDataInLocalConfigurationFile('TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestElement('mysql','type'), 0);
- changeDataInLocalConfigurationFile('SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestElement('smtp_host'), 0);
- changeDataInLocalConfigurationFile('SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestElement('smtp_user'), 0);
- changeDataInLocalConfigurationFile('SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestElement('smtp_pass1'), 0);
+ changeDataInLocalConfigurationFile('MYSQL-HOST', " 'host' => '", "',", $databaseHost, 0);
+ changeDataInLocalConfigurationFile('MYSQL-DBASE', " 'dbase' => '", "',", $databaseName, 0);
+ changeDataInLocalConfigurationFile('MYSQL-LOGIN', " 'login' => '", "',", $databaseLogin, 0);
+ changeDataInLocalConfigurationFile('MYSQL-PASSWORD', " 'password' => '", "',", $databasePassword, 0);
+ changeDataInLocalConfigurationFile('MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", $databasePrefix, 0);
+ changeDataInLocalConfigurationFile('TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", $databaseType, 0);
+ changeDataInLocalConfigurationFile('SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", $smtpHost, 0);
+ changeDataInLocalConfigurationFile('SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", $smtpUser, 0);
+ changeDataInLocalConfigurationFile('SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", $smtpPassword, 0);
// Generate a long site-key and write it
changeDataInLocalConfigurationFile('SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", generatePassword(50), 0);
// Script is now installed
- changeDataInLocalConfigurationFile('INSTALLED', "setConfigEntry('MXCHANGE_INSTALLED', '", "');", 'Y', 0);
+ changeDataInLocalConfigurationFile('INSTALLED', "setConfigEntry('MAILER_INSTALLED', '", "');", 'Y', 0);
}
// Adds a given template with content to install output stream
// Remove some unwanted chars
$content = str_replace(chr(13), '', $content);
- $content = str_replace("\n\n", chr(10), $content);
+ $content = str_replace(PHP_EOL . PHP_EOL, PHP_EOL, $content);
// Return the content
return $content;
'/ARRAY/',
array('MyISAM', 'InnoDB'),
array('{--INSTALLER_TABLE_TYPE_MYISAM--}', '{--INSTALLER_TABLE_TYPE_INNODB--}'),
- getSession('mysql_type')
+ getSession('mysql_engine')
);
}
return $isPlainInstaller;
}
+// Handle all given failed fields
+function handleInstallerFailedFields ($failedFields) {
+ // Don't do anything with no array or no entries
+ if ((!is_array($failedFields)) || (count($failedFields) == 0)) {
+ // Abort here
+ reportBug(__FUNCTION__, __LINE__, 'failedFields[]=' . gettype($failedFields) . ' verification failed');
+ } // END - if
+
+ // Handle all
+ $out = '<ol>';
+ foreach ($failedFields as $key => $field) {
+ // "Translate" it
+ $out .= '<li>{--INSTALLER_FIELD_FAILED_' . strtoupper($field) . '--}</li>';
+ } // END - foreach
+ $out .= '</ol>';
+
+ // Return it
+ return $out;
+}
+
// Checks given key/value pair if it is valid by a call-back
function isInstallerDataValid (&$saveStatus, $key, $value) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ' - ENTERED!');
} // END - if
// Then call it back
- $isValid = (bool) call_user_func($callbackName, $value);
+ $isValid = (bool) call_user_func($callbackName, trim($value));
// Is it not valid?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',isValid=' . intval($isValid));
$isValid = (
// Is it a directory?
(isDirectory($value))
+ &&
+ // Doesn't contain dots
+ (strpos($value, '..') === FALSE)
&&
// Is there a trailing slash?
(substr($value, -1, 1) == '/')
&&
// What about gen_sql_patches.php?
(isFileReadable($value . 'inc/gen_sql_patches.php'))
+ &&
+ // And how about referral-functions.php?
+ (isFileReadable($value . 'inc/referral-functions.php'))
);
// Return it
return $isValid;
}
+// Call-back function to checl validity of 'main_title'
+function isInstallerMainTitleValid ($value) {
+ // Is it valid?
+ // @TODO Comparing with DEFAULT_MAIN_TITLE doesn't work
+ $isValid = ((strlen($value) >= 4) && ($value != getMessage('DEFAULT_MAIN_TITLE')));
+
+ // Return it
+ return $isValid;
+}
+
+// Call-back function to checl validity of 'slogan'
+function isInstallerSloganValid ($value) {
+ // Is it valid?
+ $isValid = ((strlen($value) >= 4) && ($value != getMessage('DEFAULT_SLOGAN')));
+
+ // Return it
+ return $isValid;
+}
+
// Call-back function to check validity of 'webmaster'
function isInstallerWebmasterValid ($value) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' - ENTERED!');
// Is it a valid email address?
- $isValid = (
+ $isValid = ((
// Is it a valid email address?
(isEmailValid($value))
||
// Or is there 'localhost/127.0.0.1' as hostname? Then don't check email address (e.g. you@localhost)
(in_array(detectServerName(), array('localhost', '127.0.0.1')))
- );
+ ) && (
+ // Is not default "email address"
+ $value != getMessage('DEFAULT_WEBMASTER')
+ ));
// Return it
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ',isValid=' . intval($isValid) . ' - EXIT');
function isInstallerMysqlHostValid ($value) {
// This value must match a hostname or IP address
$isValid = (
+ // Shall not be empty
+ (!empty($value)) && (
// Is localhost/127.0.0.1? (mostly the case)
(in_array($value, array('localhost', '127.0.0.1')))
||
||
// Host name match
(preg_match('/([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}/', $value))
- );
+ ));
// Return it
return $isValid;
}
-// Call-back function to check validity of 'mysql_type'
-function isInstallerMysqlTypeValid ($value) {
+// Call-back function to check validity of 'mysql_engine'
+function isInstallerMysqlEngineValid ($value) {
// This value must be 'MyISAM' or 'InnoDB'
$isValid = in_array($value, array('MyISAM', 'InnoDB'));
return $isValid;
}
+// Call-back function to check validity of 'mysql_dbase'
+function isInstallerMysqlDbaseValid ($value) {
+ // This value must not be empty
+ $isValid = ((!empty($value)) && ($value != 'your_database'));
+
+ // Return it
+ return $isValid;
+}
+
+// Call-back function to check validity of 'mysql_login'
+function isInstallerMysqlLoginValid ($value) {
+ // This value must not be empty
+ $isValid = ((!empty($value)) && ($value != 'your_login'));
+
+ // Return it
+ return $isValid;
+}
+
+// Call-back function to check validity of 'mysql_prefix'
+function isInstallerMysqlPrefixValid ($value) {
+ // This value must not be empty
+ $isValid = !empty($value);
+
+ // Return it
+ return $isValid;
+}
+
// ----------------- SMTP configuration -----------------
// ----------------- Other configuration -----------------
// Call-back functions to post-check validity
//-----------------------------------------------------------------------------
+// Call-back function to check if base data is valid
+function isInstallerPostBaseDataValid ($currentTab) {
+ // By default it is not valid
+ $isValid = FALSE;
+
+ // Is the base path valid?
+ if (!isInstallerBasePathValid(postRequestElement('base_path'))) {
+ // Then mark it
+ $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_BASE_PATH_INVALID--}';
+ array_push($GLOBALS['installer_failed_fields'][$currentTab], 'base_path');
+ return FALSE;
+ } elseif (!isInstallerBaseUrlValid(postRequestElement('base_url'))) {
+ // Then mark it
+ $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_BASE_URL_INVALID--}';
+ array_push($GLOBALS['installer_failed_fields'][$currentTab], 'base_url');
+ return FALSE;
+ } elseif (strlen(postRequestElement('main_title')) < 3) {
+ // To short
+ $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_MAIN_TITLE_INVALID--}';
+ array_push($GLOBALS['installer_failed_fields'][$currentTab], 'main_title');
+ return FALSE;
+ } elseif (strlen(postRequestElement('slogan')) < 3) {
+ // To short
+ $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_SLOGAN_INVALID--}';
+ array_push($GLOBALS['installer_failed_fields'][$currentTab], 'slogan');
+ return FALSE;
+ } elseif (!isInstallerWebmasterValid(postRequestElement('webmaster'))) {
+ // Then mark it
+ $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_WEBMASTER_INVALID--}';
+ array_push($GLOBALS['installer_failed_fields'][$currentTab], 'webmaster');
+ return FALSE;
+ } else {
+ // All fine
+ $isValid = TRUE;
+
+ // Remember this tab in session
+ installTabOkay($currentTab);
+ }
+
+ // Return it
+ return $isValid;
+}
+
// Call-back function to check if database configuration in POST is valid
function isInstallerPostDatabaseConfigValid ($currentTab) {
// By default nothing is valid
// Could not find database
$GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_SELECT_FAILED--}';
array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_dbase');
+
+ // Disconnect here, we don't need idle database connections laying around
+ SQL_CLOSE(__FUNCTION__, __LINE__);
+
+ // Abort here
return FALSE;
} // END - if
setConfigEntry('_MYSQL_PREFIX', postRequestElement('mysql_prefix'));
// Get an array of all supported engines
- $engines = getArrayFromSupportedSqlEngines();
+ $engines = getArrayFromSupportedSqlEngines(postRequestElement('mysql_engine'));
// Is this an array?
if (!is_array($engines)) {
// Something bad happened
$GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_ENGINES_SQL_ERROR--}';
- array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_type');
+ array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_engine');
+
+ // Disconnect here, we don't need idle database connections laying around
+ SQL_CLOSE(__FUNCTION__, __LINE__);
+
+ // Abort here
return FALSE;
} elseif (count($engines) == 0) {
// No engine is active
$GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_NO_ENGINES_ACTIVE--}';
- array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_type');
+ array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_engine');
+
+ // Disconnect here, we don't need idle database connections laying around
+ SQL_CLOSE(__FUNCTION__, __LINE__);
+
+ // Abort here
return FALSE;
}
$engineValid = FALSE;
// Is the engine there?
- if (strtolower($engineArray['Engine']) == strtolower(postRequestElement('mysql_type'))) {
+ if (strtolower($engineArray['Engine']) == strtolower(postRequestElement('mysql_engine'))) {
// Okay, engine is found
$engineValid = TRUE;
break;
if ($engineValid === FALSE) {
// Requested engine is not active
$GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_ENGINE_UNSUPPORTED--}';
- array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_type');
+ array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_engine');
+
+ // Disconnect here, we don't need idle database connections laying around
+ SQL_CLOSE(__FUNCTION__, __LINE__);
+
+ // Abort here
return FALSE;
} // END - if
// Still something bad happened (e.g. tables found)
$GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_IN_USE--}';
array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_dbase');
- } // END - if
+ } else {
+ // Remember this tab in session
+ installTabOkay($currentTab);
+ }
// Return status
return $isValid;
}
+// Store given tab in session
+function installTabOkay ($currentTab) {
+ // Is it set?
+ if (isSessionVariableSet('installer_okay')) {
+ // Is this tab already found?
+ if (strpos(getSession('installer_okay'), $currentTab) === FALSE) {
+ // Then extend it
+ setSession('installer_okay', getSession('installer_okay') . ';' . $currentTab);
+ } // END - if
+ } else {
+ // Initially set it
+ setSession('installer_okay', $currentTab);
+ }
+}
+
+// Checks whether at least the required tabs are completed
+function isInstallationDataCompleted () {
+ // Check both
+ $isCompleted = (
+ (isSessionVariableSet('installer_okay')) &&
+ (strpos(getSession('installer_okay'), 'base_data') !== FALSE) &&
+ (strpos(getSession('installer_okay'), 'database_config') !== FALSE)
+ );
+
+ // Return it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCompleted=' . intval($isCompleted) . ',installer_okay=' . getSession('installer_okay'));
+ return $isCompleted;
+}
+
// Call-back function to check if enable_backlink is Y/N
function isInstallerEnableBacklinkValid ($currentTab) {
// Check and return it
return in_array($currentTab, array('render', 'direct'));
}
+// Wrapper to import given installation SQL dump
+function importInstallSqlDump ($dumpName) {
+ // Import the file
+ importSqlDump('install', $dumpName, 'install');
+}
+
// [EOF]
?>