Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "includes/lib_functions.php"; //set debug to true or false $v_debug = true; //set the default domain_uuid $_SESSION["domain_uuid"] = uuid(); //add the menu uuid $menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286'; //error reporting ini_set('display_errors', '1'); //error_reporting (E_ALL); // Report everything error_reporting (E_ALL ^ E_NOTICE); // Report everything //error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings //get the domain $domain_array = explode(":", $_SERVER["HTTP_HOST"]); $domain_name = $domain_array[0]; //if the config file exists then disable the install page if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/config.php")) { $msg .= "Already Installed"; header("Location: ".PROJECT_PATH."/index.php?msg=".urlencode($msg)); exit; } //set the max execution time to 1 hour ini_set('max_execution_time',3600); //save an install log if debug is true if ($v_debug) { $fp = fopen(sys_get_temp_dir()."/install.log", "w"); } //set php variables with data from http post $db_type = $_POST["db_type"]; $admin_username = $_POST["admin_username"]; $admin_password = $_POST["admin_password"]; $db_name = $_POST["db_name"]; $db_host = $_POST["db_host"]; $db_port = $_POST["db_port"]; $db_name = $_POST["db_name"]; $db_username = $_POST["db_username"]; $db_password = $_POST["db_password"]; $db_create_username = $_POST["db_create_username"]; $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"]; $install_template_name = $_POST["install_template_name"]; //clean up the values if (strlen($install_switch_base_dir) > 0) { $install_switch_base_dir = realpath($install_switch_base_dir); $install_switch_base_dir = str_replace("\\", "/", $install_switch_base_dir); } $install_tmp_dir = realpath($_POST["install_tmp_dir"]); $install_tmp_dir = str_replace("\\", "/", $install_tmp_dir); $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"; } } //set the required directories //set the freeswitch bin directory if (file_exists('/usr/local/freeswitch/bin')) { $install_switch_base_dir = '/usr/local/freeswitch'; $switch_bin_dir = '/usr/local/freeswitch/bin'; } if (file_exists('/opt/freeswitch')) { $install_switch_base_dir = '/opt/freeswitch'; $switch_bin_dir = '/opt/freeswitch/bin'; } //set the default startup script directory if (file_exists('/usr/local/etc/rc.d')) { $startup_script_dir = '/usr/local/etc/rc.d'; } if (file_exists('/etc/init.d')) { $startup_script_dir = '/etc/init.d'; } //set the default directories $switch_bin_dir = $install_switch_base_dir.'/bin'; //freeswitch bin directory $switch_conf_dir = $install_switch_base_dir.'/conf'; $switch_db_dir = $install_switch_base_dir.'/db'; $switch_log_dir = $install_switch_base_dir.'/log'; $switch_mod_dir = $install_switch_base_dir.'/mod'; $switch_extensions_dir = $switch_conf_dir.'/directory'; $switch_gateways_dir = $switch_conf_dir.'/sip_profiles'; $switch_dialplan_dir = $switch_conf_dir.'/dialplan'; $switch_scripts_dir = $install_switch_base_dir.'/scripts'; $switch_grammar_dir = $install_switch_base_dir.'/grammar'; $switch_storage_dir = $install_switch_base_dir.'/storage'; $switch_voicemail_dir = $install_switch_base_dir.'/storage/voicemail'; $switch_recordings_dir = $install_switch_base_dir.'/recordings'; $switch_sounds_dir = $install_switch_base_dir.'/sounds'; $install_tmp_dir = realpath(sys_get_temp_dir()); $install_backup_dir = realpath(sys_get_temp_dir()); $v_download_path = ''; //set specific alternative directories as required switch (PHP_OS) { case "FreeBSD": //if the freebsd port is installed use the following paths by default. if (file_exists('/var/db/freeswitch')) { //freebsd port //set the default db_path if (strlen($db_path) == 0) { //secure dir $db_path = '/var/db/fusionpbx'; if (!is_readable($db_path)) { mkdir($db_path,0777,true); } } //set the other default directories $switch_bin_dir = '/usr/local/bin'; //freeswitch bin directory $switch_conf_dir = '/usr/local/etc/freeswitch/conf'; $switch_db_dir = '/var/db/freeswitch'; $switch_log_dir = '/var/log/freeswitch'; $switch_mod_dir = '/usr/local/lib/freeswitch/mod'; $switch_extensions_dir = $switch_conf_dir.'/directory'; $switch_gateways_dir = $switch_conf_dir.'/sip_profiles'; $switch_dialplan_dir = $switch_conf_dir.'/dialplan'; $switch_scripts_dir = '/usr/local/etc/freeswitch/scripts'; $switch_grammar_dir = '/usr/local/etc/freeswitch/grammar'; $switch_storage_dir = '/var/freeswitch'; $switch_voicemail_dir = '/var/spool/freeswitch/voicemail'; $switch_recordings_dir = '/var/freeswitch/recordings'; $switch_sounds_dir = '/usr/local/share/freeswitch/sounds'; } elseif (file_exists('/data/freeswitch')) { //freebsd embedded //set the default db_path if (strlen($db_path) == 0) { //secure dir $db_path = '/data/db/fusionpbx'; if (!is_readable($db_path)) { mkdir($db_path,0777,true); } } //set the other default directories $switch_bin_dir = '/usr/local/bin'; //freeswitch bin directory $switch_conf_dir = '/usr/local/etc/freeswitch/conf'; $switch_db_dir = '/data/freeswitch/db'; if (is_readable('/var/log/freeswitch')) { $switch_log_dir = '/var/log/freeswitch'; } else { $switch_log_dir = '/data/freeswitch/log'; } $switch_mod_dir = '/usr/local/lib/freeswitch/mod'; $switch_extensions_dir = $switch_conf_dir.'/directory'; $switch_gateways_dir = $switch_conf_dir.'/sip_profiles'; $switch_dialplan_dir = $switch_conf_dir.'/dialplan'; $switch_scripts_dir = '/usr/local/etc/freeswitch/scripts'; $switch_grammar_dir = '/usr/local/etc/freeswitch/grammar'; $switch_storage_dir = '/data/freeswitch'; $switch_voicemail_dir = '/data/freeswitch/voicemail'; $switch_recordings_dir = '/data/freeswitch/recordings'; $switch_sounds_dir = '/data/freeswitch/sounds'; } else { //set the default db_path if (strlen($db_path) == 0) { //secure dir $db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure'; } } break; case "NetBSD": $startup_script_dir = ''; //set the default db_path if (strlen($db_path) == 0) { //secure dir $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 $db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure'; } break; default: //set the default db_path if (strlen($db_path) == 0) { //secure dir $db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure'; } } // // CYGWIN_NT-5.1 // Darwin // FreeBSD // HP-UX // IRIX64 // Linux // NetBSD // OpenBSD // SunOS // Unix // WIN32 // WINNT // Windows // CYGWIN_NT-5.1 // IRIX64 // SunOS // 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") { //integrated installer $install_switch_base_dir = realpath($_SERVER["DOCUMENT_ROOT"]."/.."); $startup_script_dir = ''; } elseif (is_readable('C:/program files/FreeSWITCH')) { $install_switch_base_dir = 'C:/program files/FreeSWITCH'; $startup_script_dir = ''; } elseif (is_readable('D:/program files/FreeSWITCH')) { $install_switch_base_dir = 'D:/program files/FreeSWITCH'; $startup_script_dir = ''; } elseif (is_readable('E:/program files/FreeSWITCH')) { $install_switch_base_dir = 'E:/program files/FreeSWITCH'; $startup_script_dir = ''; } elseif (is_readable('F:/program files/FreeSWITCH')) { $install_switch_base_dir = 'F:/program files/FreeSWITCH'; $startup_script_dir = ''; } elseif (is_readable('C:/FreeSWITCH')) { $install_switch_base_dir = 'C:/FreeSWITCH'; $startup_script_dir = ''; } elseif (is_readable('D:/FreeSWITCH')) { $install_switch_base_dir = 'D:/FreeSWITCH'; $startup_script_dir = ''; } elseif (is_readable('E:/FreeSWITCH')) { $install_switch_base_dir = 'E:/FreeSWITCH'; $startup_script_dir = ''; } elseif (is_readable('F:/FreeSWITCH')) { $install_switch_base_dir = 'F:/FreeSWITCH'; $startup_script_dir = ''; } } $msg = ''; if ($_POST["install_step"] == "2" && count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data if (strlen($admin_username) == 0) { $msg .= "Please provide the Admin Username
\n"; } if (strlen($admin_password) == 0) { $msg .= "Please provide the Admin Password
\n"; } else { if (strlen($admin_password) < 5) { $msg .= "Please provide an Admin Password that is 5 or more characters.
\n"; } } //define the step to return to if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { $_POST["install_step"] = ""; } } if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data if (strlen($db_type) == 0) { $msg .= "Please provide the Database Type
\n"; } if (PHP_OS == "FreeBSD" && file_exists('/usr/local/etc/freeswitch/conf')) { //install_switch_base_dir not required for the freebsd freeswitch port; } if (strlen($install_tmp_dir) == 0) { $msg .= "Please provide the Temp Directory.
\n"; } if (strlen($install_backup_dir) == 0) { $msg .= "Please provide the Backup Directory.
\n"; } if (strlen($install_template_name) == 0) { $msg .= "Please provide the Theme.
\n"; } //define the step to return to if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { $_POST["install_step"] = "2"; } } //show the error message if one exists if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "includes/persistformvar.php"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; exit; } if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //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 try { $db_tmp = new PDO('sqlite:'.$db_path.'/'.$db_name); //sqlite 3 //$db_tmp = new PDO('sqlite::memory:'); //sqlite 3 } catch (PDOException $error) { print "error: " . $error->getMessage() . "
"; die(); } //add additional functions to SQLite - bool PDO::sqliteCreateFunction ( string function_name, callback callback [, int num_args] ) if (!function_exists('php_now')) { function php_now() { if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) { @date_default_timezone_set(@date_default_timezone_get()); } return date("Y-m-d H:i:s"); } } $db_tmp->sqliteCreateFunction('now', 'php_now', 0); //add the database structure require_once "includes/classes/schema.php"; $schema = new schema; $schema->db = $db_tmp; $schema->db_type = $db_type; $schema->sql(); $schema->exec(); //get the contents of the sql file $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/sqlite.sql'; $file_contents = file_get_contents($filename); unset($filename); //replace \r\n with \n then explode on \n $file_contents = str_replace("\r\n", "\n", $file_contents); //loop line by line through all the lines of sql code $db_tmp->beginTransaction(); $stringarray = explode("\n", $file_contents); $x = 0; foreach($stringarray as $sql) { try { $db_tmp->query($sql); } catch (PDOException $error) { echo "error: " . $error->getMessage() . " sql: $sql
"; //die(); } $x++; } unset ($file_contents, $sql); $db_tmp->commit(); } //create the pgsql database if ($db_type == "pgsql") { //echo "DB Name: {$db_name}
"; //echo "DB Host: {$db_host}
"; //echo "DB User: {$db_username}
"; //echo "DB Pass: {$db_password}
"; //echo "DB Port: {$db_port}
"; //echo "DB Create User: {$db_create_username}
"; //echo "DB Create Pass: {$db_create_password}
"; //if $db_create_username provided, attempt to create new PG role and database if (strlen($db_create_username) > 0) { try { if (strlen($db_port) == 0) { $db_port = "5432"; } if (strlen($db_host) > 0) { $db_tmp = new PDO("pgsql:host={$db_host} port={$db_port} user={$db_create_username} password={$db_create_password} dbname=template1"); } else { $db_tmp = new PDO("pgsql:host=localhost port={$db_port} user={$db_create_username} password={$db_create_password} dbname=template1"); } } catch (PDOException $error) { print "error: " . $error->getMessage() . "
"; die(); } //create the database, user, grant perms $db_tmp->exec("CREATE DATABASE {$db_name}"); $db_tmp->exec("CREATE USER {$db_username} WITH PASSWORD '{$db_password}'"); $db_tmp->exec("GRANT ALL ON {$db_name} TO {$db_username}"); //close database connection_aborted $db_tmp = null; } //open database connection with $db_name try { if (strlen($db_port) == 0) { $db_port = "5432"; } if (strlen($db_host) > 0) { $db_tmp = new PDO("pgsql:host={$db_host} port={$db_port} dbname={$db_name} user={$db_username} password={$db_password}"); } else { $db_tmp = new PDO("pgsql:host=localhost port={$db_port} user={$db_username} password={$db_password} dbname={$db_name}"); } } catch (PDOException $error) { print "error: " . $error->getMessage() . "
"; die(); } //add the database structure require_once "includes/classes/schema.php"; $schema = new schema; $schema->db = $db_tmp; $schema->db_type = $db_type; $schema->sql(); $schema->exec(); //get the contents of the sql file $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/pgsql.sql'; $file_contents = file_get_contents($filename); //replace \r\n with \n then explode on \n $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); $x = 0; foreach($stringarray as $sql) { if (strlen($sql) > 3) { try { $db_tmp->query($sql); } catch (PDOException $error) { echo "error: " . $error->getMessage() . " sql: $sql
"; die(); } } $x++; } unset ($file_contents, $sql); } //create the mysql database if ($db_type == "mysql") { //database connection try { if (strlen($db_host) == 0 && strlen($db_port) == 0) { //if both host and port are empty use the unix socket if (strlen($db_create_username) == 0) { $db_tmp = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_username, $db_password); } else { $db_tmp = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_create_username, $db_create_password); } } else { if (strlen($db_port) == 0) { //leave out port if it is empty if (strlen($db_create_username) == 0) { $db_tmp = new PDO("mysql:host=$db_host;", $db_username, $db_password); } else { $db_tmp = new PDO("mysql:host=$db_host;", $db_create_username, $db_create_password); } } else { if (strlen($db_create_username) == 0) { $db_tmp = new PDO("mysql:host=$db_host;port=$db_port;", $db_username, $db_password); } else { $db_tmp = new PDO("mysql:host=$db_host;port=$db_port;", $db_create_username, $db_create_password); } } } $db_tmp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db_tmp->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); } catch (PDOException $error) { if ($v_debug) { print "error: " . $error->getMessage() . "
"; } } //create the table, user and set the permissions only if the db_create_username was provided if (strlen($db_create_username) > 0) { //select the mysql database try { $db_tmp->query("USE mysql;"); } catch (PDOException $error) { if ($v_debug) { print "error: " . $error->getMessage() . "
"; } } //create user and set the permissions try { $tmp_sql = "CREATE USER '".$db_username."'@'%' IDENTIFIED BY '".$db_password."'; "; $db_tmp->query($tmp_sql); } catch (PDOException $error) { if ($v_debug) { print "error: " . $error->getMessage() . "
"; } } //set account to unlimitted use try { if ($db_host == "localhost" || $db_host == "127.0.0.1") { $tmp_sql = "GRANT USAGE ON * . * TO '".$db_username."'@'localhost' "; $tmp_sql .= "IDENTIFIED BY '".$db_password."' "; $tmp_sql .= "WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; "; $db_tmp->query($tmp_sql); $tmp_sql = "GRANT USAGE ON * . * TO '".$db_username."'@'127.0.0.1' "; $tmp_sql .= "IDENTIFIED BY '".$db_password."' "; $tmp_sql .= "WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; "; $db_tmp->query($tmp_sql); } else { $tmp_sql = "GRANT USAGE ON * . * TO '".$db_username."'@'".$db_host."' "; $tmp_sql .= "IDENTIFIED BY '".$db_password."' "; $tmp_sql .= "WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; "; $db_tmp->query($tmp_sql); } } catch (PDOException $error) { if ($v_debug) { print "error: " . $error->getMessage() . "
"; } } //create the database and set the create user with permissions try { $tmp_sql = "CREATE DATABASE IF NOT EXISTS ".$db_name."; "; $db_tmp->query($tmp_sql); } catch (PDOException $error) { if ($v_debug) { print "error: " . $error->getMessage() . "
"; } } //set user permissions try { $db_tmp->query("GRANT ALL PRIVILEGES ON ".$db_name.".* TO '".$db_username."'@'%'; "); } catch (PDOException $error) { if ($v_debug) { print "error: " . $error->getMessage() . "
"; } } //make the changes active try { $tmp_sql = "FLUSH PRIVILEGES; "; $db_tmp->query($tmp_sql); } catch (PDOException $error) { if ($v_debug) { print "error: " . $error->getMessage() . "
"; } } } //if (strlen($db_create_username) > 0) //select the database try { $db_tmp->query("USE ".$db_name.";"); } catch (PDOException $error) { if ($v_debug) { print "error: " . $error->getMessage() . "
"; } } //add the database structure require_once "includes/classes/schema.php"; $schema = new schema; $schema->db = $db_tmp; $schema->db_type = $db_type; $schema->sql(); $schema->exec(); //add the defaults data into the database //get the contents of the sql file $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/mysql.sql'; $file_contents = file_get_contents($filename); //replace \r\n with \n then explode on \n $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); $x = 0; foreach($stringarray as $sql) { if (strlen($sql) > 3) { try { if ($v_debug) { fwrite($fp, $sql."\n"); } $db_tmp->query($sql); } catch (PDOException $error) { //echo "error on line $x: " . $error->getMessage() . " sql: $sql
"; //die(); } } $x++; } unset ($file_contents, $sql); } //replace back slashes with forward slashes $install_switch_base_dir = str_replace("\\", "/", $install_switch_base_dir); $startup_script_dir = str_replace("\\", "/", $startup_script_dir); $install_tmp_dir = str_replace("\\", "/", $install_tmp_dir); $install_backup_dir = str_replace("\\", "/", $install_backup_dir); //add the domain $sql = "insert into v_domains "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "domain_name, "; $sql .= "domain_description "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'".$_SESSION["domain_uuid"]."', "; $sql .= "'".$domain_name."', "; $sql .= "'' "; $sql .= ");"; if ($v_debug) { fwrite($fp, $sql."\n"); } $db_tmp->exec(check_sql($sql)); unset($sql); //get the web server protocol //$install_server_protocol = $_SERVER["SERVER_PORT"]; //$server_protocol_array = explode('/', $_SERVER["SERVER_PROTOCOL"]); //$install_server_protocol = strtolower($server_protocol[0]); //unset($server_protocol_array); //add the default settings $x = 0; $tmp[$x]['name'] = 'uuid'; $tmp[$x]['value'] = $menu_uuid; $tmp[$x]['category'] = 'domain'; $tmp[$x]['subcategory'] = 'menu'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'name'; $tmp[$x]['category'] = 'domain'; $tmp[$x]['subcategory'] = 'time_zone'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'code'; $tmp[$x]['value'] = 'en-us'; $tmp[$x]['category'] = 'domain'; $tmp[$x]['subcategory'] = 'language'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'name'; $tmp[$x]['value'] = $install_template_name; $tmp[$x]['category'] = 'domain'; $tmp[$x]['subcategory'] = 'template'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $install_tmp_dir; $tmp[$x]['category'] = 'server'; $tmp[$x]['subcategory'] = 'temp'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $startup_script_dir; $tmp[$x]['category'] = 'server'; $tmp[$x]['subcategory'] = 'startup_script'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $install_backup_dir; $tmp[$x]['category'] = 'server'; $tmp[$x]['subcategory'] = 'backup'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_bin_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'bin'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $install_switch_base_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'base'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_conf_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'conf'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_db_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'db'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_log_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'log'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_extensions_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'extensions'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_gateways_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'gateways'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_dialplan_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'dialplan'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_mod_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'mod'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_scripts_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'scripts'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_grammar_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'grammar'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_storage_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'storage'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_voicemail_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'voicemail'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_recordings_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'recordings'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = $switch_sounds_dir; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'sounds'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = ''; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'provision'; $tmp[$x]['enabled'] = 'false'; $x++; $db_tmp->beginTransaction(); foreach($tmp as $row) { $sql = "insert into v_default_settings "; $sql .= "("; $sql .= "default_setting_uuid, "; $sql .= "default_setting_name, "; $sql .= "default_setting_value, "; $sql .= "default_setting_category, "; $sql .= "default_setting_subcategory, "; $sql .= "default_setting_enabled "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'".uuid()."', "; $sql .= "'".$row['name']."', "; $sql .= "'".$row['value']."', "; $sql .= "'".$row['category']."', "; $sql .= "'".$row['subcategory']."', "; $sql .= "'".$row['enabled']."' "; $sql .= ");"; if ($v_debug) { fwrite($fp, $sql."\n"); } $db_tmp->exec(check_sql($sql)); unset($sql); } $db_tmp->commit(); unset($tmp); //add domain settings $x = 0; $tmp[$x]['name'] = 'uuid'; $tmp[$x]['value'] = $menu_uuid; $tmp[$x]['category'] = 'domain'; $tmp[$x]['subcategory'] = 'menu'; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'name'; $tmp[$x]['value'] = $install_template_name; $tmp[$x]['category'] = 'domain'; $tmp[$x]['subcategory'] = 'template'; $tmp[$x]['enabled'] = 'true'; $x++; $db_tmp->beginTransaction(); foreach($tmp as $row) { $sql = "insert into v_domain_settings "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "domain_setting_uuid, "; $sql .= "domain_setting_name, "; $sql .= "domain_setting_value, "; $sql .= "domain_setting_category, "; $sql .= "domain_setting_subcategory, "; $sql .= "domain_setting_enabled "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'".$_SESSION["domain_uuid"]."', "; $sql .= "'".uuid()."', "; $sql .= "'".$row['name']."', "; $sql .= "'".$row['value']."', "; $sql .= "'".$row['category']."', "; $sql .= "'".$row['subcategory']."', "; $sql .= "'".$row['enabled']."' "; $sql .= ");"; if ($v_debug) { fwrite($fp, $sql."\n"); } $db_tmp->exec(check_sql($sql)); unset($sql); } $db_tmp->commit(); unset($tmp); //get the list of installed apps from the core and mod directories $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); $x=0; foreach ($config_list as $config_path) { include($config_path); $x++; } //add the groups $x = 0; $tmp[$x]['group_name'] = 'superadmin'; $tmp[$x]['group_description'] = 'Super Administrator Group'; $x++; $tmp[$x]['group_name'] = 'admin'; $tmp[$x]['group_description'] = 'Administrator Group'; $x++; $tmp[$x]['group_name'] = 'user'; $tmp[$x]['group_description'] = 'User Group'; $x++; $tmp[$x]['group_name'] = 'public'; $tmp[$x]['group_description'] = 'Public Group'; $x++; $tmp[$x]['group_name'] = 'agent'; $tmp[$x]['group_description'] = 'Call Center Agent Group'; foreach($tmp as $row) { $sql = "insert into v_groups "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "group_uuid, "; $sql .= "group_name, "; $sql .= "group_description "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'".$_SESSION["domain_uuid"]."', "; $sql .= "'".uuid()."', "; $sql .= "'".$row['group_name']."', "; $sql .= "'".$row['group_description']."' "; $sql .= ");"; if ($v_debug) { fwrite($fp, $sql."\n"); } $db_tmp->exec(check_sql($sql)); unset($sql); } unset($tmp); //add a user and then add the user to the superadmin group //prepare the values $user_uuid = uuid(); $contact_uuid = uuid(); //set a sessiong variable $_SESSION["user_uuid"] = $user_uuid; //salt used with the password to create a one way hash $salt = generate_password('20', '4'); //add the user account $sql = "insert into v_users "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "user_uuid, "; $sql .= "contact_uuid, "; $sql .= "username, "; $sql .= "password, "; $sql .= "salt, "; $sql .= "add_date, "; $sql .= "add_user "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'".$_SESSION["domain_uuid"]."', "; $sql .= "'$user_uuid', "; $sql .= "'$contact_uuid', "; $sql .= "'".$admin_username."', "; $sql .= "'".md5($salt.$admin_password)."', "; $sql .= "'$salt', "; $sql .= "now(), "; $sql .= "'".$admin_username."' "; $sql .= ");"; if ($v_debug) { fwrite($fp, $sql."\n"); } $db_tmp->exec(check_sql($sql)); unset($sql); //add to contacts $sql = "insert into v_contacts "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "contact_uuid, "; $sql .= "contact_type, "; $sql .= "contact_name_given, "; $sql .= "contact_nickname "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'".$_SESSION["domain_uuid"]."', "; $sql .= "'$contact_uuid', "; $sql .= "'user', "; $sql .= "'$admin_username', "; $sql .= "'$admin_username' "; $sql .= ")"; $db_tmp->exec(check_sql($sql)); unset($sql); //add the user to the superadmin group $sql = "insert into v_group_users "; $sql .= "("; $sql .= "group_user_uuid, "; $sql .= "domain_uuid, "; $sql .= "user_uuid, "; $sql .= "group_name "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'".uuid()."', "; $sql .= "'".$_SESSION["domain_uuid"]."', "; $sql .= "'".$_SESSION["user_uuid"]."', "; $sql .= "'superadmin' "; $sql .= ");"; if ($v_debug) { fwrite($fp, $sql."\n"); } $db_tmp->exec(check_sql($sql)); unset($sql); //assign the default permissions to the groups $db_tmp->beginTransaction(); foreach($apps as $app) { if ($app['permissions']) { foreach ($app['permissions'] as $row) { if ($v_debug) { fwrite($fp, "v_group_permissions\n"); fwrite($fp, json_encode($row)."\n\n"); } if ($row['groups']) { foreach ($row['groups'] as $group) { //add the record $sql = "insert into v_group_permissions "; $sql .= "("; $sql .= "group_permission_uuid, "; $sql .= "domain_uuid, "; $sql .= "permission_name, "; $sql .= "group_name "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'".uuid()."', "; $sql .= "'".$_SESSION["domain_uuid"]."', "; $sql .= "'".$row['name']."', "; $sql .= "'".$group."' "; $sql .= ");"; if ($v_debug) { fwrite($fp, $sql."\n"); } $db_tmp->exec(check_sql($sql)); unset($sql); } } } } } $db_tmp->commit(); //unset the temporary database connection unset($db_tmp); //generate the config.php $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/require.php"; //set the defaults $menu_name = 'default'; $menu_language = 'en-us'; $menu_description = ''; //add the parent menu $sql = "insert into v_menus "; $sql .= "("; $sql .= "menu_uuid, "; $sql .= "menu_name, "; $sql .= "menu_language, "; $sql .= "menu_description "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'".$menu_uuid."', "; $sql .= "'$menu_name', "; $sql .= "'$menu_language', "; $sql .= "'$menu_description' "; $sql .= ");"; if ($v_debug) { fwrite($fp, $sql."\n"); } $db->exec(check_sql($sql)); unset($sql); //add the menu items require_once "includes/classes/menu.php"; $menu = new menu; $menu->db = $db; $menu->menu_uuid = $menu_uuid; $menu->restore(); unset($menu); //setup the switch config directory if it exists if ($switch_conf_dir != "/conf") { if ($v_debug) { fwrite($fp, "switch_base_dir: ".$install_switch_base_dir."\n"); fwrite($fp, "switch_conf_dir: ".$switch_conf_dir."\n"); fwrite($fp, "switch_dialplan_dir: ".$switch_dialplan_dir."\n"); fwrite($fp, "switch_scripts_dir: ".$switch_scripts_dir."\n"); fwrite($fp, "switch_sounds_dir: ".$switch_sounds_dir."\n"); fwrite($fp, "switch_recordings_dir: ".$switch_recordings_dir."\n"); } //create the necessary directories if (!is_readable($install_tmp_dir)) { mkdir($install_tmp_dir,0777,true); } if (!is_readable($install_backup_dir)) { mkdir($install_backup_dir,0777,true); } if (is_readable($switch_log_dir)) { if (!is_readable($switch_scripts_dir.'') && $switch_scripts_dir != "/scripts") { mkdir($switch_scripts_dir.'',0777,true); } if (!is_readable($switch_sounds_dir.'/en/us/callie/custom/8000') && $switch_scripts_dir != "/sounds") { mkdir($switch_sounds_dir.'/en/us/callie/custom/8000',0777,true); } if (!is_readable($switch_sounds_dir.'/en/us/callie/custom/16000') && $switch_scripts_dir != "/sounds") { mkdir($switch_sounds_dir.'/en/us/callie/custom/16000',0777,true); } if (!is_readable($switch_sounds_dir.'/en/us/callie/custom/32000') && $switch_scripts_dir != "/sounds") { mkdir($switch_sounds_dir.'/en/us/callie/custom/32000',0777,true); } if (!is_readable($switch_sounds_dir.'/en/us/callie/custom/48000') && $switch_scripts_dir != "/sounds") { mkdir($switch_sounds_dir.'/en/us/callie/custom/48000',0777,true); } if (!is_readable($switch_storage_dir.'/fax/') && $switch_scripts_dir != "/storage") { mkdir($switch_storage_dir.'/fax',0777,true); } if (!is_readable($switch_recordings_dir.'') && $switch_scripts_dir != "/recordings") { mkdir($switch_recordings_dir.'',0777,true); } } //copy the files and directories from includes/install require_once "includes/classes/install.php"; $install = new install; $install->domain_uuid = $_SESSION["domain_uuid"]; $install->domain = $domain_name; $install->switch_conf_dir = $switch_conf_dir; $install->switch_scripts_dir = $switch_scripts_dir; $install->switch_sounds_dir = $switch_sounds_dir; $install->copy_conf(); $install->copy(); clearstatcache(); //copy includes/templates/conf to the freeswitch/conf dir $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/conf"; $dst_dir = $switch_conf_dir; if (is_readable($dst_dir)) { $install->recursive_copy($src_dir, $dst_dir); } //print_r($install->result); //create the dialplan/default.xml for single tenant or dialplan/domain.xml require_once "includes/classes/switch_dialplan.php"; $dialplan = new dialplan; $dialplan->domain_uuid = $_SESSION["domain_uuid"]; $dialplan->domain = $domain_name; $dialplan->switch_dialplan_dir = $switch_dialplan_dir; $dialplan->restore_advanced_xml(); //print_r($dialplan->result); //write the xml_cdr.conf.xml file xml_cdr_conf_xml(); //write the switch.conf.xml file switch_conf_xml(); } //login the user account $_SESSION["username"] = $admin_username; //get the groups assigned to the user and then set the groups in $_SESSION["groups"] $sql = "SELECT * FROM v_group_users "; $sql .= "where domain_uuid=:domain_uuid "; $sql .= "and user_uuid=:user_uuid "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->bindParam(':domain_uuid', $_SESSION["domain_uuid"]); $prep_statement->bindParam(':user_uuid', $_SESSION["user_uuid"]); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $_SESSION["groups"] = $result; unset($sql, $row_count, $prep_statement); //get the permissions assigned to the groups that the user is a member of set the permissions in $_SESSION['permissions'] $x = 0; $sql = "select distinct(permission_name) from v_group_permissions "; foreach($_SESSION["groups"] as $field) { if (strlen($field['group_name']) > 0) { if ($x == 0) { $sql .= "where (domain_uuid = '".$_SESSION["domain_uuid"]."' and group_name = '".$field['group_name']."') "; } else { $sql .= "or (domain_uuid = '".$_SESSION["domain_uuid"]."' and group_name = '".$field['group_name']."') "; } $x++; } } $prep_statementsub = $db->prepare($sql); $prep_statementsub->execute(); $_SESSION['permissions'] = $prep_statementsub->fetchAll(PDO::FETCH_NAMED); unset($sql, $prep_statementsub); //make sure the database schema and installation have performed all necessary tasks $display_results = false; $display_type = 'none'; require_once "core/upgrade/upgrade_schema.php"; //synchronize the config with the saved settings save_switch_xml(); //do not show the apply settings reminder on the login page $_SESSION["reload_xml"] = false; //clear the menu $_SESSION["menu"] = ""; //redirect to the login page $msg = "install complete"; header("Location: ".PROJECT_PATH."/logout.php?msg=".urlencode($msg)); } //set a default template if (strlen($_SESSION['domain']['template']['name']) == 0) { $_SESSION['domain']['template']['name'] = 'enhanced'; } //get the contents of the template and save it to the template variable $template = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes/'.$_SESSION['domain']['template']['name'].'/template.php'); //buffer the content ob_end_clean(); //clean the buffer ob_start(); //show the html form if (!is_writable($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/header.php")) { $install_msg .= "
  • Write access to ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/ is required during the install.
  • \n"; } if (!extension_loaded('PDO')) { $install_msg .= "
  • PHP PDO was not detected. Please install it before proceeding.
  • "; } if ($install_msg) { echo "
    \n"; echo "
    \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
    Message
      $install_msg
    \n"; echo "
    \n"; } echo "
    \n"; $msg = ''; //make sure the includes directory is writable so the config.php file can be written. if (!is_writable($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/lib_pdo.php")) { $msg .= "Write access to ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."
    "; $msg .= "and its sub-directories are required during the install.

    \n"; } //display the message if (strlen($msg) > 0) { //echo "not writable"; echo $msg; echo "
    \n"; echo "
    \n"; unset($msg); //exit; } // step 1 if ($_POST["install_step"] == "") { echo "
    \n"; echo "
    \n"; echo "\n"; //echo "\n"; //echo "\n"; //echo "\n"; echo "\n"; echo "\n"; echo " \n"; //echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; //echo "\n"; echo "\n"; $db_type = $_POST["db_type"]; $install_step = $_POST["install_step"]; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " "; echo "
    Installation
    \n"; echo " The installation is a simple two step process. \n"; echo "
      \n"; echo "
    • Step 1 is used for selecting the database engine to use. After making that section then ensure the paths are correct and then press next.
    • "; echo "
    • Step 2 requests the database specific settings. When finished press save. The installation will then complete the tasks required to do the install.
    Step 1 
    \n"; echo " Database Type:\n"; echo "\n"; echo "
    \n"; echo " Select the database type.\n"; echo "\n"; echo "
    \n"; echo " Username:\n"; echo "\n"; echo "
    \n"; echo " Enter the username to use when logging in with the browser.
    \n"; echo "
    \n"; echo " Password:\n"; echo "\n"; echo "
    \n"; echo " Enter the password to use when logging in with the browser.
    \n"; echo "
    \n"; echo " Theme: \n"; echo " \n"; echo " \n"; echo "
    \n"; echo " Select a theme to set as the default.
    \n"; echo "
    \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
    "; echo "
    "; echo "
    "; } // step 2, sqlite if ($_POST["install_step"] == "2" && $_POST["db_type"] == "sqlite") { echo "
    \n"; echo "
    \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
    Installation: Step 2 - SQLite
    \n"; echo " Database Filename:\n"; echo "\n"; echo "
    \n"; echo " Set the database filename. The file extension should be '.db'.\n"; echo "\n"; echo "
    \n"; echo " Database Directory:\n"; echo "\n"; echo "
    \n"; echo " Set the path to the database directory.\n"; echo "
    \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
    "; echo "
    "; echo "
    "; } // step 2, mysql if ($_POST["install_step"] == "2" && $_POST["db_type"] == "mysql") { //set defaults if (strlen($db_host) == 0) { $db_host = 'localhost'; } if (strlen($db_port) == 0) { $db_port = '3306'; } //if (strlen($db_name) == 0) { $db_name = 'fusionpbx'; } //echo "However if preferred the database can be created manually with the mysql.sql script. "; echo "
    \n"; echo "
    \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
    Installation: Step 2 - MySQL
    \n"; echo " Database Host:\n"; echo "\n"; echo "
    \n"; echo " Enter the host address for the database server.\n"; echo "\n"; echo "
    \n"; echo " Database Port:\n"; echo "\n"; echo "
    \n"; echo " Enter the port number. It is optional if the database is using the default port.\n"; echo "\n"; echo "
    \n"; echo " Database Name:\n"; echo "\n"; echo "
    \n"; echo " Enter the name of the database.\n"; echo "\n"; echo "
    \n"; echo " Database Username:\n"; echo "\n"; echo "
    \n"; echo " Enter the database username. \n"; echo "\n"; echo "
    \n"; echo " Database Password:\n"; echo "\n"; echo "
    \n"; echo " Enter the database password.\n"; echo "\n"; echo "
    \n"; echo " Create Database Username:\n"; echo "\n"; echo "
    \n"; echo " Optional, this username is used to create the database, a database user and set the permissions. \n"; echo " By default this username is 'root' however it can be any account with permission to add a database, user, and grant permissions. \n"; echo "
    \n"; echo " Create Database Password:\n"; echo "\n"; echo "
    \n"; echo " Enter the create database password.\n"; echo "\n"; echo "
    \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
    "; echo "
    "; echo "
    "; } // step 2, pgsql if ($_POST["install_step"] == "2" && $_POST["db_type"] == "pgsql") { if (strlen($db_host) == 0) { $db_host = 'localhost'; } if (strlen($db_port) == 0) { $db_port = '5432'; } if (strlen($db_name) == 0) { $db_name = 'fusionpbx'; } echo "
    \n"; echo "
    \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
    Installation: Step 2 - Postgres
    \n"; echo " Database Host:\n"; echo "\n"; echo "
    \n"; echo " Enter the host address for the database server.\n"; echo "\n"; echo "
    \n"; echo " Database Port:\n"; echo "\n"; echo "
    \n"; echo " Enter the port number. It is optional if the database is using the default port.\n"; echo "\n"; echo "
    \n"; echo " Database Name:\n"; echo "\n"; echo "
    \n"; echo " Enter the name of the database.\n"; echo "\n"; echo "
    \n"; echo " Database Username:\n"; echo "\n"; echo "
    \n"; echo " Enter the database username.\n"; echo "\n"; echo "
    \n"; echo " Database Password:\n"; echo "\n"; echo "
    \n"; echo " Enter the database password.\n"; echo "\n"; echo "
    \n"; echo " Create Database Username:\n"; echo "\n"; echo "
    \n"; echo " Optional, this username is used to create the database, a database user and set the permissions. \n"; echo " By default this username is 'pgsql' however it can be any account with permission to add a database, user, and grant permissions. \n"; echo " Leave blank if the user and empty database already exist and you do not want them created. \n"; echo "
    \n"; echo " Create Database Password:\n"; echo "\n"; echo "
    \n"; echo " Enter the create database password.\n"; echo "\n"; echo "
    \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
    "; echo "
    "; echo "
    "; } echo "
    \n"; echo "
    \n"; echo "
    \n"; echo "
    \n"; echo "
    \n"; echo "
    \n"; echo "
    \n"; echo "
    \n"; // add the content to the template and then send output $body = $content_from_db.ob_get_contents(); //get the output from the buffer ob_end_clean(); //clean the buffer ob_start(); eval('?>' . $template . '", $custom_title, $template); // defined in each individual page $output = str_replace ("", $custom_head, $output); // defined in each individual page $output = str_replace ("", $_SESSION["menu"], $output); //defined in /includes/menu.php $output = str_replace ("", PROJECT_PATH, $output); //defined in /includes/menu.php $pos = strrpos($output, ""); if ($pos === false) { $output = $body; //if tag not found just show the body } else { //replace the body $output = str_replace ("", $body, $output); } echo $output; unset($output); ?>