From 42631964ccbd1af4ffdf5ccda93f4f9fa29a9590 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 1 Jun 2019 17:31:34 -0600 Subject: [PATCH] Delete install.php --- core/install/install.php | 408 --------------------------------------- 1 file changed, 408 deletions(-) delete mode 100644 core/install/install.php diff --git a/core/install/install.php b/core/install/install.php deleted file mode 100644 index 86a596d1ef..0000000000 --- a/core/install/install.php +++ /dev/null @@ -1,408 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane - Matthew Vale -*/ -//add the required includes - require_once "root.php"; - require_once "resources/functions.php"; - require_once "resources/classes/text.php"; - require_once "resources/classes/message.php"; - -//start a php session - if (!isset($_SESSION)) { session_start(); } - -//initialize variables we are going to use - $event_host = ''; - $event_port = ''; - $event_password = ''; - $install_language = 'en-us'; - $admin_username = ''; - $admin_password = ''; - $install_default_country = 'US'; - $install_template_name = ''; - $domain_name = ''; - $db_type = ''; - $db_path = ''; - $db_host = ''; - $db_port = ''; - $db_name = ''; - $db_username = ''; - $db_password = ''; - $db_create = ''; - $db_create_username = ''; - $db_create_password = ''; - $db = NULL; - -//detect the iso country code from the locale - //$locale = Locale::getDefault(); - $timezone = 'UTC'; - if (is_link('/etc/localtime')) { - // Mac OS X (and older Linuxes) - // /etc/localtime is a symlink to the - // timezone in /usr/share/zoneinfo. - $filename = readlink('/etc/localtime'); - if (strpos($filename, '/usr/share/zoneinfo/') === 0) { - $timezone = substr($filename, 20); - } - } elseif (file_exists('/etc/timezone')) { - // Ubuntu / Debian. - $data = file_get_contents('/etc/timezone'); - if ($data) { - $timezone = rtrim($data); - } - } elseif (file_exists('/etc/sysconfig/clock')) { - // RHEL / CentOS - $data = parse_ini_file('/etc/sysconfig/clock'); - if (!empty($data['ZONE'])) { - $timezone = $data['ZONE']; - } - } - -//set the time zone - date_default_timezone_set($timezone); - -//if the config.php exists deny access to install.php - if (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) { - echo "access denied"; - exit; - } elseif (file_exists("/etc/fusionpbx/config.php")) { - echo "access denied"; - exit; - } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) { - echo "access denied"; - exit; - } - -//intialize variables - $install_step = ''; - $return_install_step = ''; - $re_detect_switch = false; - -//process the the HTTP POST - if (count($_POST) > 0) { - $install_language = check_str($_POST["install_language"]); - $install_step = check_str($_POST["install_step"]); - $return_install_step = check_str($_POST["return_install_step"]); - if(isset($_POST["event_host"])){ - $event_host = check_str($_POST["event_host"]); - $event_port = check_str($_POST["event_port"]); - $event_password = check_str($_POST["event_password"]); - } - if(isset($_POST["db_type"])){ - $db_type = $_POST["db_type"]; - $admin_username = $_POST["admin_username"]; - $admin_password = $_POST["admin_password"]; - $install_default_country = $_POST["install_default_country"]; - $install_template_name = $_POST["install_template_name"]; - $domain_name = $_POST["domain_name"]; - } - if($install_step == 'config_detail' and strlen(check_str($_POST["re_detect_switch"])) > 0 ){ - $re_detect_switch = true; - } - } - -//set the install step if it is not set - if(!$install_step) { $install_step = 'select_language'; } - -//set the language for the install - $_SESSION['domain']['language']['code'] = $install_language; - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//set a default enviroment if first_time - //initialize some varibles to cut down on warnings - $_SESSION['message'] = ''; - $v_link_label_play = ''; - $v_link_label_pause = ''; - $default_login = 0; - $onload = ''; - -//buffer the content - if (sizeof(ob_get_status())!=0) ob_end_clean(); //clean the buffer - ob_start(); - - $messages = array(); - if (!extension_loaded('PDO')) { - $messages[] = "PHP PDO was not detected. Please install it before proceeding"; - } - if (!(extension_loaded('pdo_pgsql') or extension_loaded('pdo_mysql') or extension_loaded('pdo_sqlite'))) { - $messages[] = "no database PDO driver was detected. Please install one of pgsql, mysql or sqlite before proceeding"; - } - - 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."/resources/pdo.php")) { - $messages[] = "Write access to ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH." and its sub-directories are required during the install."; - } - //test for selinux - if (file_exists('/usr/sbin/getenforce')) { - $enforcing; - exec('getenforce', $enforcing); - if($enforcing[0] == 'Enforcing'){ - $messages[] = "SELinux is enabled and enforcing you must have a policy installed to let the webserver connect to the switch event socket
". - "You can use the following to find what ports are allowed
semanage port -l | grep '^http_port_t'
"; - } - } - //test for windows and non sqlite - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' and strlen($db_type) > 0 and $db_type !='sqlite') { - //Test for ODBC DSN in ODBC.INI. It should have section: - //[fusionpbx] - //Driver32=C:\Program Files\psqlODBC\0906\bin\psqlodbc35w.dll - if ( preg_match('/\[fusionpbx\]/mi', file_get_contents('c:/Windows/ODBC.INI')) == 0 ) { - $messages[] = "Windows requires a system DSN ODBC connection with name 'fusionpbx'."; - } - } - - //action code - if($return_install_step == 'config_detail'){ - //check for all required data - $existing_errors = count($messages); - if (strlen($admin_username) == 0) { $messages[] = "Please provide the Admin Username"; } - if (strlen($admin_password) == 0) { $messages[] = "Please provide the Admin Password"; } - elseif (strlen($admin_password) < 5) { $messages[] = "Please provide an Admin Password that is 5 or more characters.
\n"; } - if ( count($messages) > $existing_errors) { $install_step = 'config_detail'; } - } - if($re_detect_switch === true ){ - $install_step = 'detect_config'; - } - - if($install_step =='execute') { - //set the max execution time to 1 hour - ini_set('max_execution_time',3600); - } - - //display messages - if (count($messages)>0) { - echo "
\n"; - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
Messages
    \n"; - foreach ($messages as $message){ - echo "
  • $message
  • \n"; - } - echo "
\n"; - echo "
\n"; - } - - //includes and title - $document['title'] = $text['title-install']; - - //view code - if($install_step == 'select_language'){ - echo "
\n"; - include "resources/page_parts/install_select_language.php"; - echo " \n"; - echo " \n"; - echo "
\n"; - } elseif($install_step == 'detect_config'){ - if(!($event_host == '' || $event_host == 'localhost' || $event_host == '::1' || $event_host == '127.0.0.1' )){ - echo "

Warning you have chosen a value other than localhost for event_host, this is unsupported at present

\n"; - } - //if($detect_ok){ - echo "
\n"; - include "resources/page_parts/install_event_socket.php"; - //echo " \n"; - //echo " \n"; - //echo " \n"; - //echo " \n"; - //echo " \n"; - //echo " \n"; - //echo "
\n"; - //echo " \n"; - //echo " \n"; - //echo "
\n"; - echo "
\n"; - //} else { - // echo "
\n"; - // echo "
\n"; - // echo " \n"; - // echo "
\n"; - // echo "
\n"; - //} - } - elseif($install_step == 'config_detail'){ - //get the domain - if(!$domain_name){ - $domain_array = explode(":", $_SERVER["HTTP_HOST"]); - $domain_name = $domain_array[0]; - } - include "resources/page_parts/install_config_detail.php"; - } - elseif($install_step == 'config_database'){ - include "resources/page_parts/install_config_database.php"; - } - elseif($install_step == 'execute'){ - echo "

".$text['header-installing']."

\n"; - //$protocol = 'http'; - //if($_SERVER['HTTPS']) { $protocol = 'https'; } - //echo ""; - require_once "core/install/resources/classes/detect_switch.php"; - $detect_switch = new detect_switch($event_host, $event_port, $event_password); - $detect_ok = true; - try { - $detect_switch->detect(); - } catch(Exception $e){ - //echo "

Failed to detect configuration detect_switch reported: " . $e->getMessage() . "

\n"; - //$detect_ok = false; - } - if($detect_ok){ - $install_ok = true; - echo "
\n";
-			function error_handler($err_severity, $errstr, $errfile, $errline ) {
-				if (0 === error_reporting()) { return false;}
-				switch($err_severity)
-				{
-					case E_ERROR:               throw new Exception ($errstr . " in $errfile line: $errline");
-					case E_PARSE:               throw new Exception ($errstr . " in $errfile line: $errline");
-					case E_CORE_ERROR:          throw new Exception ($errstr . " in $errfile line: $errline");
-					case E_COMPILE_ERROR:       throw new Exception ($errstr . " in $errfile line: $errline");
-					case E_USER_ERROR:          throw new Exception ($errstr . " in $errfile line: $errline");
-					case E_STRICT:              throw new Exception ($errstr . " in $errfile line: $errline");
-					case E_RECOVERABLE_ERROR:   throw new Exception ($errstr . " in $errfile line: $errline");
-					default:                    return false;
-				}
-			}
-			#set_error_handler("error_handler");
-			try {
-				require_once "resources/classes/global_settings.php";
-				$global_settings = new global_settings($detect_switch, $domain_name);
-				if(is_null($global_settings)){ throw new Exception("Error global_settings came back with null"); }
-				require_once "resources/classes/install_fusionpbx.php";
-				$system = new install_fusionpbx($global_settings);
-				$system->admin_username = $admin_username;
-				$system->admin_password = $admin_password;
-				$system->default_country = $install_default_country;
-				$system->install_language = $install_language;
-				$system->template_name = $install_template_name;
-
-				require_once "resources/classes/install_switch.php";
-				$switch = new install_switch($global_settings);
-				//$switch->debug = true;
-				//$system->debug = true;
-				$switch->echo_progress = true;
-				$system->echo_progress = true;
-				$system->install_phase_1();
-				$switch->install_phase_1();
-				$system->install_phase_2();
-				$switch->install_phase_2();
-			} catch(Exception $e){
-				echo "
\n"; - echo "

Failed to install
" . $e->getMessage() . "

\n"; - try { - require_once "resources/classes/install_fusionpbx.php"; - $system = new install_fusionpbx($global_settings); - $system->remove_config(); - } catch(Exception $e){ - echo "

Failed to remove config: " . $e->getMessage() . "

\n"; - } - $install_ok = false; - } - restore_error_handler(); - if($install_ok){ - echo "\n"; - header("Location: ".PROJECT_PATH."/logout.php"); - $_SESSION['message'] = 'Install complete'; - } else { - echo "
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - } - } - } - else { - echo "

Unkown install_step '$install_step'

\n"; - } - echo "
\n"; - -//initialize some defaults so we can be 'logged in' - $_SESSION['username'] = 'install_enabled'; - $_SESSION['permissions'][]['permission_name'] = 'superadmin'; - $_SESSION['menu'] = ''; - -//add the content to the template and then send output - $body = ob_get_contents(); //get the output from the buffer - ob_end_clean(); //clean the buffer - -//set a default template - $default_template = 'default'; - $_SESSION['domain']['template']['name'] = $default_template; - $x = 0; - include "themes/$default_template/app_config.php"; - $_SESSION['theme'] = Array(); - foreach ($apps as $app_id => $data) { - foreach ($apps[$app_id]['default_settings'] as $index => $default_setting) { - $sub_category = $default_setting['default_setting_subcategory']; - $name = $default_setting['default_setting_name']; - if($default_setting['default_setting_enabled'] == 'true'){ - if($name == 'array'){ - $_SESSION['theme'][$sub_category][(isset($default_setting['default_setting_order']) ? $default_setting['default_setting_order'] : null)] = $default_setting['default_setting_value']; - } - else { - $_SESSION['theme'][$sub_category][$name] = $default_setting['default_setting_value']; - } - }else{ - $_SESSION['theme'][$sub_category][$name] = ''; - } - } - } - unset($apps, $x); - $_SESSION['theme']['menu_brand_type']['text'] = "text"; - -//set the default template path - $template_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes/'.$default_template.'/template.php'; - -//get the content of the template - $template_content = file_get_contents($template_path); - -//replace the variables in the template - $template_content = str_replace ("", $document['title'], $template_content); // defined in each individual page - $template_content = str_replace ("", '', $template_content); // defined in each individual page - //$template_content = str_replace ("", $_SESSION["menu"], $template_content); //included in the theme - $template_content = str_replace ("", $body, $template_content); //defined in /themes/default/template.php - $template_content = str_replace ("", PROJECT_PATH, $template_content); //defined in /themes/default/template.php - -//get the contents of the template and save it to the template variable - ob_start(); - require_once "resources/classes/menu.php"; - eval('?>' . $template_content . '