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 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
45 // Write the local config-local.php file from "template"
46 function doInstallWriteLocalConfig () {
47 // Copy the config template and verify it
48 copyFileVerified(postRequestParameter('spath') . 'inc/config-local.php.dist', getCachePath() . 'config-local.php', 0644);
50 // Ok, all done. So we can write the config data to the php files
51 if (postRequestParameter('spath') != getPath()) changeDataInFile(getCachePath() . 'config-local.php', 'SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestParameter('spath'), 0);
52 if (postRequestParameter('burl') != getUrl()) changeDataInFile(getCachePath() . 'config-local.php', 'HOST-URL', "setConfigEntry('URL', '", "');", postRequestParameter('burl'), 0);
53 changeDataInFile(getCachePath() . 'config-local.php', 'MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestParameter('title'), 0);
54 changeDataInFile(getCachePath() . 'config-local.php', 'SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestParameter('slogan'), 0);
55 changeDataInFile(getCachePath() . 'config-local.php', 'WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestParameter('email'), 0);
56 changeDataInFile(getCachePath() . 'config-local.php', 'NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestParameter('warn_no_pass'), 0);
57 changeDataInFile(getCachePath() . 'config-local.php', 'WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestParameter('wfooter'), 0);
58 changeDataInFile(getCachePath() . 'config-local.php', 'BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestParameter('blink'), 0);
59 // @TODO DEACTIVATED: changeDataInFile(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
60 changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-HOST', " 'host' => '", "',", postRequestParameter('mysql','host'), 0);
61 changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-DBASE', " 'dbase' => '", "',", postRequestParameter('mysql','dbase'), 0);
62 changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-LOGIN', " 'login' => '", "',", postRequestParameter('mysql','login'), 0);
63 changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-PASSWORD', " 'password' => '", "',", postRequestParameter('mysql','pass1'), 0);
64 changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestParameter('mysql','prefix'), 0);
65 changeDataInFile(getCachePath() . 'config-local.php', 'TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestParameter('mysql','type'), 0);
66 changeDataInFile(getCachePath() . 'config-local.php', 'SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestParameter('smtp_host'), 0);
67 changeDataInFile(getCachePath() . 'config-local.php', 'SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestParameter('smtp_user'), 0);
68 changeDataInFile(getCachePath() . 'config-local.php', 'SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestParameter('smtp_pass1'), 0);
70 // Generate a long site key
71 $siteKey = generatePassword(50);
74 changeDataInFile(getCachePath() . 'config-local.php', 'SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", $siteKey, 0);
76 // Script is now installed
77 changeDataInFile(getCachePath() . 'config-local.php', 'INSTALLED', "setConfigEntry('MXCHANGE_INSTALLED', '", "');", 'Y', 0);
80 // Adds a given template with content to install output stream
81 function addTemplateToInstallContent ($template, $content = array()) {
83 $out = loadTemplate($template, true, $content);
86 addToInstallContent($out);
89 // Add it to install content
90 function addToInstallContent ($out) {
92 if (!isset($GLOBALS['install_content'])) {
94 $GLOBALS['install_content'] = $out;
97 $GLOBALS['install_content'] .= $out;
101 // Read a given SQL dump
102 function readSqlDump ($FQFN) {
104 $content = readFromFile($FQFN);
106 // Remove some unwanted chars
107 $content = str_replace("\r", '', $content);
108 $content = str_replace("\n\n", "\n", $content);
110 // Return the content