2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/22/2009 *
4 * =================== Last change: 10/22/2009 *
6 * -------------------------------------------------------------------- *
7 * File : install-functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for installation procedure *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen fuer die Installationsroutine *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // Write the local config-local.php file from "template"
44 function doInstallWriteLocalConfig () {
45 // Copy the config template and verify it
46 copyFileVerified(postRequestElement('spath') . 'inc/config-local.php.dist', getPath() . getCachePath() . 'config-local.php', 0644);
48 // Ok, all done. So we can write the config data to the php files
49 if (postRequestElement('spath') != getPath()) changeDataInLocalConfigurationFile('SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestElement('spath'), 0);
50 if (postRequestElement('burl') != getUrl()) changeDataInLocalConfigurationFile('HOST-URL', "setConfigEntry('URL', '", "');", postRequestElement('burl'), 0);
51 changeDataInLocalConfigurationFile('MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestElement('title'), 0);
52 changeDataInLocalConfigurationFile('SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestElement('slogan'), 0);
53 changeDataInLocalConfigurationFile('WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestElement('email'), 0);
54 changeDataInLocalConfigurationFile('NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestElement('warn_no_pass'), 0);
55 changeDataInLocalConfigurationFile('WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestElement('wfooter'), 0);
56 changeDataInLocalConfigurationFile('BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestElement('blink'), 0);
57 // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0);
58 changeDataInLocalConfigurationFile('MYSQL-HOST', " 'host' => '", "',", postRequestElement('mysql','host'), 0);
59 changeDataInLocalConfigurationFile('MYSQL-DBASE', " 'dbase' => '", "',", postRequestElement('mysql','dbase'), 0);
60 changeDataInLocalConfigurationFile('MYSQL-LOGIN', " 'login' => '", "',", postRequestElement('mysql','login'), 0);
61 changeDataInLocalConfigurationFile('MYSQL-PASSWORD', " 'password' => '", "',", postRequestElement('mysql','pass1'), 0);
62 changeDataInLocalConfigurationFile('MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestElement('mysql','prefix'), 0);
63 changeDataInLocalConfigurationFile('TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestElement('mysql','type'), 0);
64 changeDataInLocalConfigurationFile('SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestElement('smtp_host'), 0);
65 changeDataInLocalConfigurationFile('SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestElement('smtp_user'), 0);
66 changeDataInLocalConfigurationFile('SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestElement('smtp_pass1'), 0);
68 // Generate a long site key
69 $siteKey = generatePassword(50);
72 changeDataInLocalConfigurationFile('SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", $siteKey, 0);
74 // Script is now installed
75 changeDataInLocalConfigurationFile('INSTALLED', "setConfigEntry('MXCHANGE_INSTALLED', '", "');", 'Y', 0);
78 // Adds a given template with content to install output stream
79 function addTemplateToInstallContent ($template, $content = array()) {
81 $out = loadTemplate($template, true, $content);
84 addToInstallContent($out);
87 // Add it to install content
88 function addToInstallContent ($out) {
90 if (!isset($GLOBALS['install_content'])) {
92 $GLOBALS['install_content'] = $out;
95 $GLOBALS['install_content'] .= $out;
99 // Somewhat getter for installer content
100 function getInstallerContent () {
102 if (isset($GLOBALS['install_content'])) {
104 $content = $GLOBALS['install_content'];
106 // Nothing found, this needs fixing
107 $content = displayMessage('{--INSTALLER_CONTENT_404--}', true);
114 // Read a given SQL dump
115 function readSqlDump ($FQFN) {
117 $content = readFromFile($FQFN);
119 // Remove some unwanted chars
120 $content = str_replace("\r", '', $content);
121 $content = str_replace("\n\n", "\n", $content);
123 // Return the content