A few minor changes to install.php.
This commit is contained in:
parent
885306d6e7
commit
6afa95e885
|
|
@ -74,7 +74,6 @@ require_once "includes/lib_functions.php";
|
|||
$db_create_password = $_POST["db_create_password"];
|
||||
$db_path = $_POST["db_path"];
|
||||
$install_step = $_POST["install_step"];
|
||||
$install_secure_dir = $_POST["install_secure_dir"];
|
||||
$install_tmp_dir = $_POST["install_tmp_dir"];
|
||||
$install_backup_dir = $_POST["install_backup_dir"];
|
||||
$install_switch_base_dir = $_POST["install_switch_base_dir"];
|
||||
|
|
@ -92,11 +91,6 @@ require_once "includes/lib_functions.php";
|
|||
$install_backup_dir = realpath($_POST["install_backup_dir"]);
|
||||
$install_backup_dir = str_replace("\\", "/", $install_backup_dir);
|
||||
|
||||
//set the default install_secure_dir
|
||||
if (strlen($install_secure_dir) == 0) { //secure dir
|
||||
$install_secure_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
|
||||
}
|
||||
|
||||
//set the default db_name
|
||||
if ($db_type == "sqlite") {
|
||||
if (strlen($db_name) == 0) { $db_name = "fusionpbx.db"; }
|
||||
|
|
@ -145,7 +139,7 @@ require_once "includes/lib_functions.php";
|
|||
switch (PHP_OS) {
|
||||
case "Linux":
|
||||
//set the default db_path
|
||||
if (strlen($db_path) == 0) { //secure dir
|
||||
if (strlen($db_path) == 0) {
|
||||
if (file_exists('/var/lib/fusionpbx')) {
|
||||
$db_path = '/var/lib/fusionpbx';
|
||||
}
|
||||
|
|
@ -192,7 +186,7 @@ require_once "includes/lib_functions.php";
|
|||
if (file_exists('/var/db/freeswitch')) {
|
||||
//FreeBSD port
|
||||
//set the default db_path
|
||||
if (strlen($db_path) == 0) { //secure dir
|
||||
if (strlen($db_path) == 0) {
|
||||
$db_path = '/var/db/fusionpbx';
|
||||
if (!is_readable($db_path)) { mkdir($db_path,0777,true); }
|
||||
}
|
||||
|
|
@ -215,7 +209,7 @@ require_once "includes/lib_functions.php";
|
|||
elseif (file_exists('/data/freeswitch')) {
|
||||
//FreeBSD embedded
|
||||
//set the default db_path
|
||||
if (strlen($db_path) == 0) { //secure dir
|
||||
if (strlen($db_path) == 0) {
|
||||
$db_path = '/data/db/fusionpbx';
|
||||
if (!is_readable($db_path)) { mkdir($db_path,0777,true); }
|
||||
}
|
||||
|
|
@ -242,7 +236,7 @@ require_once "includes/lib_functions.php";
|
|||
}
|
||||
else {
|
||||
//set the default db_path
|
||||
if (strlen($db_path) == 0) { //secure dir
|
||||
if (strlen($db_path) == 0) {
|
||||
$db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
|
||||
}
|
||||
}
|
||||
|
|
@ -250,20 +244,20 @@ require_once "includes/lib_functions.php";
|
|||
case "NetBSD":
|
||||
$startup_script_dir = '';
|
||||
//set the default db_path
|
||||
if (strlen($db_path) == 0) { //secure dir
|
||||
if (strlen($db_path) == 0) {
|
||||
$db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
|
||||
}
|
||||
break;
|
||||
case "OpenBSD":
|
||||
$startup_script_dir = '';
|
||||
//set the default db_path
|
||||
if (strlen($db_path) == 0) { //secure dir
|
||||
if (strlen($db_path) == 0) {
|
||||
$db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//set the default db_path
|
||||
if (strlen($db_path) == 0) { //secure dir
|
||||
if (strlen($db_path) == 0) {
|
||||
$db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
|
||||
}
|
||||
}
|
||||
|
|
@ -287,7 +281,6 @@ require_once "includes/lib_functions.php";
|
|||
// HP-UX
|
||||
// OpenBSD (not in Wikipedia)
|
||||
|
||||
|
||||
//set the dir defaults for windows
|
||||
if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
|
||||
if (substr($_SERVER["DOCUMENT_ROOT"], -3) == "www") {
|
||||
|
|
@ -366,6 +359,102 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
|
|||
}
|
||||
|
||||
if ($_POST["install_step"] == "3" && count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
|
||||
//generate the config.php
|
||||
$tmp_config = "<?php\n";
|
||||
$tmp_config .= "/* \$Id\$ */\n";
|
||||
$tmp_config .= "/*\n";
|
||||
$tmp_config .= " config.php\n";
|
||||
$tmp_config .= " Copyright (C) 2008, 2009 Mark J Crane\n";
|
||||
$tmp_config .= " All rights reserved.\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " Redistribution and use in source and binary forms, with or without\n";
|
||||
$tmp_config .= " modification, are permitted provided that the following conditions are met:\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " 1. Redistributions of source code must retain the above copyright notice,\n";
|
||||
$tmp_config .= " this list of conditions and the following disclaimer.\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " 2. Redistributions in binary form must reproduce the above copyright\n";
|
||||
$tmp_config .= " notice, this list of conditions and the following disclaimer in the\n";
|
||||
$tmp_config .= " documentation and/or other materials provided with the distribution.\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,\n";
|
||||
$tmp_config .= " INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY\n";
|
||||
$tmp_config .= " AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n";
|
||||
$tmp_config .= " AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n";
|
||||
$tmp_config .= " OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n";
|
||||
$tmp_config .= " SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n";
|
||||
$tmp_config .= " INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n";
|
||||
$tmp_config .= " CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n";
|
||||
$tmp_config .= " ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n";
|
||||
$tmp_config .= " POSSIBILITY OF SUCH DAMAGE.\n";
|
||||
$tmp_config .= "*/\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= "//-----------------------------------------------------\n";
|
||||
$tmp_config .= "// settings:\n";
|
||||
$tmp_config .= "//-----------------------------------------------------\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " //set the database type\n";
|
||||
$tmp_config .= " \$db_type = '".$db_type."'; //sqlite, mysql, pgsql, others with a manually created PDO connection\n";
|
||||
$tmp_config .= "\n";
|
||||
if ($db_type == "sqlite") {
|
||||
$tmp_config .= " //sqlite: the db_name and db_path are automatically assigned however the values can be overidden by setting the values here.\n";
|
||||
$tmp_config .= " \$db_name = '".$db_name."'; //host name/ip address + '.db' is the default database filename\n";
|
||||
$tmp_config .= " \$db_path = '".$db_path."'; //the path is determined by a php variable\n";
|
||||
}
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " //mysql: database connection information\n";
|
||||
if ($db_type == "mysql") {
|
||||
if ($db_host == "localhost") {
|
||||
//if localhost is used it defaults to a Unix Socket which doesn't seem to work.
|
||||
//replace localhost with 127.0.0.1 so that it will connect using TCP
|
||||
$db_host = "127.0.0.1";
|
||||
}
|
||||
$tmp_config .= " \$db_host = '".$db_host."';\n";
|
||||
$tmp_config .= " \$db_port = '".$db_port."';\n";
|
||||
$tmp_config .= " \$db_name = '".$db_name."';\n";
|
||||
$tmp_config .= " \$db_username = '".$db_username."';\n";
|
||||
$tmp_config .= " \$db_password = '".$db_password."';\n";
|
||||
}
|
||||
else {
|
||||
$tmp_config .= " //\$db_host = '';\n";
|
||||
$tmp_config .= " //\$db_port = '';\n";
|
||||
$tmp_config .= " //\$db_name = '';\n";
|
||||
$tmp_config .= " //\$db_username = '';\n";
|
||||
$tmp_config .= " //\$db_password = '';\n";
|
||||
}
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " //pgsql: database connection information\n";
|
||||
if ($db_type == "pgsql") {
|
||||
$tmp_config .= " \$db_host = '".$db_host."'; //set the host only if the database is not local\n";
|
||||
$tmp_config .= " \$db_port = '".$db_port."';\n";
|
||||
$tmp_config .= " \$db_name = '".$db_name."';\n";
|
||||
$tmp_config .= " \$db_username = '".$db_username."';\n";
|
||||
$tmp_config .= " \$db_password = '".$db_password."';\n";
|
||||
}
|
||||
else {
|
||||
$tmp_config .= " //\$db_host = '".$db_host."'; //set the host only if the database is not local\n";
|
||||
$tmp_config .= " //\$db_port = '".$db_port."';\n";
|
||||
$tmp_config .= " //\$db_name = '".$db_name."';\n";
|
||||
$tmp_config .= " //\$db_username = '".$db_username."';\n";
|
||||
$tmp_config .= " //\$db_password = '".$db_password."';\n";
|
||||
}
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " //show errors\n";
|
||||
$tmp_config .= " ini_set('display_errors', '1');\n";
|
||||
$tmp_config .= " //error_reporting (E_ALL); // Report everything\n";
|
||||
$tmp_config .= " //error_reporting (E_ALL ^ E_NOTICE); // Report everything\n";
|
||||
$tmp_config .= " error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= "?>";
|
||||
$fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/config.php","w");
|
||||
fwrite($fout, $tmp_config);
|
||||
unset($tmp_config);
|
||||
fclose($fout);
|
||||
|
||||
//include the new config.php file
|
||||
require "includes/config.php";
|
||||
|
||||
//create the sqlite database
|
||||
if ($db_type == "sqlite") {
|
||||
//sqlite database will be created when the config.php is loaded and only if the database file does not exist
|
||||
|
|
@ -407,9 +496,9 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
|
|||
|
||||
//loop line by line through all the lines of sql code
|
||||
$db_tmp->beginTransaction();
|
||||
$stringarray = explode("\n", $file_contents);
|
||||
$string_array = explode("\n", $file_contents);
|
||||
$x = 0;
|
||||
foreach($stringarray as $sql) {
|
||||
foreach($string_array as $sql) {
|
||||
try {
|
||||
$db_tmp->query($sql);
|
||||
}
|
||||
|
|
@ -487,9 +576,9 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
|
|||
$file_contents = str_replace("\r\n", "\n", $file_contents);
|
||||
|
||||
//loop line by line through all the lines of sql code
|
||||
$stringarray = explode("\n", $file_contents);
|
||||
$string_array = explode("\n", $file_contents);
|
||||
$x = 0;
|
||||
foreach($stringarray as $sql) {
|
||||
foreach($string_array as $sql) {
|
||||
if (strlen($sql) > 3) {
|
||||
try {
|
||||
$db_tmp->query($sql);
|
||||
|
|
@ -655,9 +744,9 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
|
|||
$file_contents = str_replace("\r\n", "\n", $file_contents);
|
||||
|
||||
//loop line by line through all the lines of sql code
|
||||
$stringarray = explode("\n", $file_contents);
|
||||
$string_array = explode("\n", $file_contents);
|
||||
$x = 0;
|
||||
foreach($stringarray as $sql) {
|
||||
foreach($string_array as $sql) {
|
||||
if (strlen($sql) > 3) {
|
||||
try {
|
||||
if ($v_debug) {
|
||||
|
|
@ -1085,100 +1174,7 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
|
|||
//unset the temporary database connection
|
||||
unset($db_tmp);
|
||||
|
||||
//generate the config.php
|
||||
$tmp_config = "<?php\n";
|
||||
$tmp_config .= "/* \$Id\$ */\n";
|
||||
$tmp_config .= "/*\n";
|
||||
$tmp_config .= " config.php\n";
|
||||
$tmp_config .= " Copyright (C) 2008, 2009 Mark J Crane\n";
|
||||
$tmp_config .= " All rights reserved.\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " Redistribution and use in source and binary forms, with or without\n";
|
||||
$tmp_config .= " modification, are permitted provided that the following conditions are met:\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " 1. Redistributions of source code must retain the above copyright notice,\n";
|
||||
$tmp_config .= " this list of conditions and the following disclaimer.\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " 2. Redistributions in binary form must reproduce the above copyright\n";
|
||||
$tmp_config .= " notice, this list of conditions and the following disclaimer in the\n";
|
||||
$tmp_config .= " documentation and/or other materials provided with the distribution.\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,\n";
|
||||
$tmp_config .= " INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY\n";
|
||||
$tmp_config .= " AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n";
|
||||
$tmp_config .= " AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n";
|
||||
$tmp_config .= " OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n";
|
||||
$tmp_config .= " SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n";
|
||||
$tmp_config .= " INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n";
|
||||
$tmp_config .= " CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n";
|
||||
$tmp_config .= " ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n";
|
||||
$tmp_config .= " POSSIBILITY OF SUCH DAMAGE.\n";
|
||||
$tmp_config .= "*/\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= "//-----------------------------------------------------\n";
|
||||
$tmp_config .= "// settings:\n";
|
||||
$tmp_config .= "//-----------------------------------------------------\n";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " //set the database type\n";
|
||||
$tmp_config .= " \$db_type = '".$db_type."'; //sqlite, mysql, pgsql, others with a manually created PDO connection\n";
|
||||
$tmp_config .= "\n";
|
||||
if ($db_type == "sqlite") {
|
||||
$tmp_config .= " //sqlite: the db_name and db_path are automatically assigned however the values can be overidden by setting the values here.\n";
|
||||
$tmp_config .= " \$db_name = '".$db_name."'; //host name/ip address + '.db' is the default database filename\n";
|
||||
$tmp_config .= " \$db_path = '".$db_path."'; //the path is determined by a php variable\n";
|
||||
}
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " //mysql: database connection information\n";
|
||||
if ($db_type == "mysql") {
|
||||
if ($db_host == "localhost") {
|
||||
//if localhost is used it defaults to a Unix Socket which doesn't seem to work.
|
||||
//replace localhost with 127.0.0.1 so that it will connect using TCP
|
||||
$db_host = "127.0.0.1";
|
||||
}
|
||||
$tmp_config .= " \$db_host = '".$db_host."';\n";
|
||||
$tmp_config .= " \$db_port = '".$db_port."';\n";
|
||||
$tmp_config .= " \$db_name = '".$db_name."';\n";
|
||||
$tmp_config .= " \$db_username = '".$db_username."';\n";
|
||||
$tmp_config .= " \$db_password = '".$db_password."';\n";
|
||||
}
|
||||
else {
|
||||
$tmp_config .= " //\$db_host = '';\n";
|
||||
$tmp_config .= " //\$db_port = '';\n";
|
||||
$tmp_config .= " //\$db_name = '';\n";
|
||||
$tmp_config .= " //\$db_username = '';\n";
|
||||
$tmp_config .= " //\$db_password = '';\n";
|
||||
}
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " //pgsql: database connection information\n";
|
||||
if ($db_type == "pgsql") {
|
||||
$tmp_config .= " \$db_host = '".$db_host."'; //set the host only if the database is not local\n";
|
||||
$tmp_config .= " \$db_port = '".$db_port."';\n";
|
||||
$tmp_config .= " \$db_name = '".$db_name."';\n";
|
||||
$tmp_config .= " \$db_username = '".$db_username."';\n";
|
||||
$tmp_config .= " \$db_password = '".$db_password."';\n";
|
||||
}
|
||||
else {
|
||||
$tmp_config .= " //\$db_host = '".$db_host."'; //set the host only if the database is not local\n";
|
||||
$tmp_config .= " //\$db_port = '".$db_port."';\n";
|
||||
$tmp_config .= " //\$db_name = '".$db_name."';\n";
|
||||
$tmp_config .= " //\$db_username = '".$db_username."';\n";
|
||||
$tmp_config .= " //\$db_password = '".$db_password."';\n";
|
||||
}
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= " //show errors\n";
|
||||
$tmp_config .= " ini_set('display_errors', '1');\n";
|
||||
$tmp_config .= " //error_reporting (E_ALL); // Report everything\n";
|
||||
$tmp_config .= " //error_reporting (E_ALL ^ E_NOTICE); // Report everything\n";
|
||||
$tmp_config .= " error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings";
|
||||
$tmp_config .= "\n";
|
||||
$tmp_config .= "?>";
|
||||
|
||||
$fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/config.php","w");
|
||||
fwrite($fout, $tmp_config);
|
||||
unset($tmp_config);
|
||||
fclose($fout);
|
||||
|
||||
//include the new config.php file
|
||||
//include additional files
|
||||
require "includes/require.php";
|
||||
|
||||
//set the defaults
|
||||
|
|
@ -1524,7 +1520,6 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
|
|||
echo " <input type='hidden' name='db_type' value='$db_type'>\n";
|
||||
echo " <input type='hidden' name='admin_username' value='$admin_username'>\n";
|
||||
echo " <input type='hidden' name='admin_password' value='$admin_password'>\n";
|
||||
echo " <input type='hidden' name='install_secure_dir' value='$install_secure_dir'>\n";
|
||||
echo " <input type='hidden' name='install_switch_base_dir' value='$install_switch_base_dir'>\n";
|
||||
echo " <input type='hidden' name='install_tmp_dir' value='$install_tmp_dir'>\n";
|
||||
echo " <input type='hidden' name='install_backup_dir' value='$install_backup_dir'>\n";
|
||||
|
|
@ -1639,7 +1634,6 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
|
|||
echo " <input type='hidden' name='db_type' value='$db_type'>\n";
|
||||
echo " <input type='hidden' name='admin_username' value='$admin_username'>\n";
|
||||
echo " <input type='hidden' name='admin_password' value='$admin_password'>\n";
|
||||
echo " <input type='hidden' name='install_secure_dir' value='$install_secure_dir'>\n";
|
||||
echo " <input type='hidden' name='install_switch_base_dir' value='$install_switch_base_dir'>\n";
|
||||
echo " <input type='hidden' name='install_tmp_dir' value='$install_tmp_dir'>\n";
|
||||
echo " <input type='hidden' name='install_backup_dir' value='$install_backup_dir'>\n";
|
||||
|
|
@ -1752,7 +1746,6 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
|
|||
echo " <input type='hidden' name='db_type' value='$db_type'>\n";
|
||||
echo " <input type='hidden' name='admin_username' value='$admin_username'>\n";
|
||||
echo " <input type='hidden' name='admin_password' value='$admin_password'>\n";
|
||||
echo " <input type='hidden' name='install_secure_dir' value='$install_secure_dir'>\n";
|
||||
echo " <input type='hidden' name='install_switch_base_dir' value='$install_switch_base_dir'>\n";
|
||||
echo " <input type='hidden' name='install_tmp_dir' value='$install_tmp_dir'>\n";
|
||||
echo " <input type='hidden' name='install_backup_dir' value='$install_backup_dir'>\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue