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://www.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(postRequestParameter('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 (postRequestParameter('spath') != getPath()) changeDataInInclude(getCachePath() . 'config-local.php', 'SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestParameter('spath'), 0);
50 if (postRequestParameter('burl') != getUrl()) changeDataInInclude(getCachePath() . 'config-local.php', 'HOST-URL', "setConfigEntry('URL', '", "');", postRequestParameter('burl'), 0);
51 changeDataInInclude(getCachePath() . 'config-local.php', 'MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestParameter('title'), 0);
52 changeDataInInclude(getCachePath() . 'config-local.php', 'SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestParameter('slogan'), 0);
53 changeDataInInclude(getCachePath() . 'config-local.php', 'WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestParameter('email'), 0);
54 changeDataInInclude(getCachePath() . 'config-local.php', 'NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestParameter('warn_no_pass'), 0);
55 changeDataInInclude(getCachePath() . 'config-local.php', 'WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestParameter('wfooter'), 0);
56 changeDataInInclude(getCachePath() . 'config-local.php', 'BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestParameter('blink'), 0);
57 // @TODO DEACTIVATED: changeDataInInclude(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
58 changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-HOST', " 'host' => '", "',", postRequestParameter('mysql','host'), 0);
59 changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-DBASE', " 'dbase' => '", "',", postRequestParameter('mysql','dbase'), 0);
60 changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-LOGIN', " 'login' => '", "',", postRequestParameter('mysql','login'), 0);
61 changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-PASSWORD', " 'password' => '", "',", postRequestParameter('mysql','pass1'), 0);
62 changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestParameter('mysql','prefix'), 0);
63 changeDataInInclude(getCachePath() . 'config-local.php', 'TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestParameter('mysql','type'), 0);
64 changeDataInInclude(getCachePath() . 'config-local.php', 'SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestParameter('smtp_host'), 0);
65 changeDataInInclude(getCachePath() . 'config-local.php', 'SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestParameter('smtp_user'), 0);
66 changeDataInInclude(getCachePath() . 'config-local.php', 'SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestParameter('smtp_pass1'), 0);
68 // Generate a long site key
69 $siteKey = generatePassword(50);
72 changeDataInInclude(getCachePath() . 'config-local.php', 'SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", $siteKey, 0);
74 // Script is now installed
75 changeDataInInclude(getCachePath() . 'config-local.php', '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 = loadTemplate('admin_settings_saved', true, '{--INSTALLER_CONTENT_404--}');
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