diff --git a/core/upgrade/app_config.php b/core/upgrade/app_config.php index e5cdf15c5a..08e3f4aada 100644 --- a/core/upgrade/app_config.php +++ b/core/upgrade/app_config.php @@ -1,4 +1,5 @@ + +?> \ No newline at end of file diff --git a/core/upgrade/app_languages.php b/core/upgrade/app_languages.php index ccf39c3f64..a41cc3b8ad 100644 --- a/core/upgrade/app_languages.php +++ b/core/upgrade/app_languages.php @@ -190,11 +190,9 @@ $text['message-upgrade']['pt-pt'] = "Actualização Efectuada"; $text['message-upgrade']['fr-fr'] = "Mis à jour"; -/******************/ - $text['login-message_text']['en-us'] = "Keep up with the FusionPBX project by configuring your preferences in the newly added Notifications section, under the System menu!"; $text['login-message_text']['es-cl'] = "Manténgase al día con el proyecto FusionPBX configurando sus preferencias en la sección Notificaciones acaba de agregar, en el menú del sistema!"; $text['login-message_text']['pt-pt'] = "Mantenha-se com o projeto FusionPBX configurando suas preferências na seção Notificações recém-adicionado, no menu Sistema!"; $text['login-message_text']['fr-fr'] = "Tenez-vous au projet FusionPBX en configurant vos préférences dans la section Notifications nouvellement ajouté, dans le menu du système!"; -?> +?> \ No newline at end of file diff --git a/core/upgrade/index.php b/core/upgrade/index.php index 3897a78806..30b17e4c8f 100644 --- a/core/upgrade/index.php +++ b/core/upgrade/index.php @@ -64,28 +64,23 @@ if (sizeof($_POST) > 0) { $response_message = $text['message-upgrade_svn']; } - // load the default database into memory and compare it with the active database + // load an array of the database schema and compare it with the active database if ($do["schema"] && permission_exists("upgrade_schema")) { - $included = true; - $response_output = "return"; - $response_format = "html"; - $upgrade_data_types = check_str($do["data_types"]); - require_once "core/upgrade/upgrade_schema.php"; - if ($response_upgrade_schema != '') { - $_SESSION["response_upgrade_schema"] = $response_upgrade_schema; - } - unset($apps); $response_message = $text['message-upgrade_schema']; + + $upgrade_data_types = check_str($do["data_types"]); + require_once "resources/classes/schema.php"; + $obj = new schema(); + $_SESSION["schema"]["response"] = $obj->schema("html"); } // process the apps defaults if ($do["apps"] && permission_exists("upgrade_apps")) { - $included = true; - $domain_language_code = $_SESSION['domain']['language']['code']; - require_once "core/upgrade/upgrade_domains.php"; - $_SESSION['domain']['language']['code'] = $domain_language_code; - unset($domain_language_code); $response_message = $text['message-upgrade_apps']; + + require_once "resources/classes/domains.php"; + $domain = new domains; + $domain->upgrade(); } // restore defaults of the selected menu @@ -260,12 +255,12 @@ if ($_SESSION["response_svn_update"] != '') { // output result of upgrade schema -if ($_SESSION["response_upgrade_schema"] != '') { +if ($_SESSION["schema"]["response"] != '') { echo "


"; echo "".$text['header-upgrade_schema_results'].""; echo "

"; - echo $_SESSION["response_upgrade_schema"]; - unset($_SESSION["response_upgrade_schema"]); + echo $_SESSION["schema"]["response"]; + unset($_SESSION["schema"]["response"]); } require_once "resources/footer.php"; diff --git a/core/upgrade/upgrade.php b/core/upgrade/upgrade.php index f8d530f28c..697b288c71 100644 --- a/core/upgrade/upgrade.php +++ b/core/upgrade/upgrade.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): @@ -32,13 +32,7 @@ set_include_path($document_root); require_once "resources/require.php"; $_SERVER["DOCUMENT_ROOT"] = $document_root; - $response_format = 'text'; //html, text - - //add multi-lingual support - require_once "app_languages.php"; - foreach($text as $key => $value) { - $text[$key] = $value[$_SESSION['domain']['language']['code']]; - } + $format = 'text'; //html, text } else { include "root.php"; @@ -51,39 +45,28 @@ echo "access denied"; exit; } - - //add multi-lingual support - require_once "app_languages.php"; - foreach($text as $key => $value) { - $text[$key] = $value[$_SESSION['domain']['language']['code']]; - } - + $format = 'html'; } -//set the default - if (!isset($response_output)) { - $response_output = "echo"; +//add multi-lingual support + require_once "app_languages.php"; + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; } -//include the header - if ($response_output == "echo") { - require_once "resources/header.php"; +//show the title + if ($format == 'text') { + echo "\n"; + echo $text['label-upgrade']."\n"; + echo "-----------------------------------------\n"; + echo "\n"; + echo $text['label-database']."\n"; } -if ($response_format == 'text') { - echo "\n"; - echo $text['label-upgrade']."\n"; - echo "-----------------------------------------\n"; - echo "\n"; - echo $text['label-database']."\n"; -} - //make sure the database schema and installation have performed all necessary tasks - $display_results = false; - $display_type = 'none'; require_once "resources/classes/schema.php"; $obj = new schema; - $obj->schema($db, $db_type, $db_name, $display_type); + echo $obj->schema("text"); //run all app_defaults.php files require_once "resources/classes/domains.php"; @@ -91,7 +74,7 @@ if ($response_format == 'text') { $domain->upgrade(); //show the content - if ($response_format == 'html') { + if ($format == 'html') { echo "
\n"; echo "\n"; echo "\n"; @@ -111,12 +94,13 @@ if ($response_format == 'text') { echo "
\n"; echo "
\n"; } - elseif ($response_format == 'text') { + elseif ($format == 'text') { echo "\n"; } //include the footer - if ($response_output == "echo") { + if ($format == "html") { require_once "resources/footer.php"; } + ?> \ No newline at end of file diff --git a/core/upgrade/upgrade_domains.php b/core/upgrade/upgrade_domains.php index 969f927b83..a4b8e97be9 100644 --- a/core/upgrade/upgrade_domains.php +++ b/core/upgrade/upgrade_domains.php @@ -35,7 +35,7 @@ set_include_path($document_root); require_once "resources/require.php"; $_SERVER["DOCUMENT_ROOT"] = $document_root; - $display_type = 'text'; //html, text + $format = 'text'; //html, text } else if (!$included) { include "root.php"; @@ -48,6 +48,7 @@ echo "access denied"; exit; } + $format = 'html'; //html, text } //run all app_defaults.php files diff --git a/core/upgrade/upgrade_schema.php b/core/upgrade/upgrade_schema.php index 6084b33e8a..bec4e76946 100644 --- a/core/upgrade/upgrade_schema.php +++ b/core/upgrade/upgrade_schema.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): @@ -27,7 +27,6 @@ // set included, if not if (!isset($included)) { $included = false; } - //check the permission if(defined('STDIN')) { $document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]); @@ -36,7 +35,7 @@ set_include_path($document_root); require_once "resources/require.php"; $_SERVER["DOCUMENT_ROOT"] = $document_root; - $response_format = 'text'; //html, text + $format = 'text'; //html, text //add multi-lingual support require_once "app_languages.php"; @@ -57,31 +56,18 @@ exit; } - //add multi-lingual support - require_once "app_languages.php"; - foreach($text as $key => $value) { - $text[$key] = $value[$_SESSION['domain']['language']['code']]; - } - require_once "resources/header.php"; $document['title'] = $text['title-upgrade_schema']; - $response_format = 'html'; //html, text + $format = 'html'; //html, text } -//set the default - if (!isset($response_output)) { - $response_output = "echo"; - } - -//load the default database into memory and compare it with the active database +//get the database schema put it into an array then compare and update the database as needed. require_once "resources/classes/schema.php"; $obj = new schema; - $obj->schema($db, $db_type, $db_name, $response_output); - unset($apps); + echo $obj->schema($format); - -if (!$included && $response_output == 'echo' && $response_format == 'html') { +if (!$included && $format == 'html') { echo "
\n"; echo "
\n"; require_once "resources/footer.php"; diff --git a/resources/classes/domains.php b/resources/classes/domains.php index 4f168863f8..0319822049 100644 --- a/resources/classes/domains.php +++ b/resources/classes/domains.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): diff --git a/resources/classes/schema.php b/resources/classes/schema.php index 495c129060..a6117de88c 100644 --- a/resources/classes/schema.php +++ b/resources/classes/schema.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Copyright (C) 2013 + Copyright (C) 2013 - 2014 All Rights Reserved. Contributor(s): @@ -445,16 +445,23 @@ include "root.php"; } //datatase schema - public function schema ($db, $db_type, $db_name, $response_output) { - //set the global variables - global $db; - global $text; // pulls in language variable array - global $response_format; - global $upgrade_data_types; + public function schema ($format) { + + //set the global variable + global $db, $db_type, $db_name, $db_username, $db_password; + global $db_host, $db_path, $db_port, $upgrade_data_types, $text; //get the PROJECT PATH include "root.php"; + //add multi-lingual support + if (!isset($text)) { + require "core/upgrade/app_languages.php"; + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } + } + //PHP PDO check if table or column exists //check if table exists // SELECT * FROM sqlite_master WHERE type='table' AND name='v_cdr' @@ -709,7 +716,7 @@ include "root.php"; $response = ''; //display results as html - if ($response_output != '' && $response_format == "html") { + if ($format == "html") { //show the database type $response .= "".$text['header-database_type'].": ".$db_type. "

"; //start the table @@ -812,11 +819,11 @@ include "root.php"; //loop line by line through all the lines of sql code $x = 0; - if (strlen($sql_update) == 0 && $response_format == "text") { + if (strlen($sql_update) == 0 && $format == "text") { $response .= " ".$text['label-schema'].": ".$text['label-no_change']."\n"; } else { - if ($response_format == "text") { + if ($format == "text") { $response .= " ".$text['label-schema'].":\n"; } //$db->beginTransaction(); @@ -825,14 +832,12 @@ include "root.php"; if (strlen(trim($sql))) { try { $db->query(trim($sql)); - if ($response_format == "text") { + if ($format == "text") { $response .= " $sql\n"; } } catch (PDOException $error) { - if ($response_output != '') { - $response .= " error: " . $error->getMessage() . " sql: $sql
"; - } + $response .= " error: " . $error->getMessage() . " sql: $sql
"; } } } @@ -842,12 +847,12 @@ include "root.php"; } //handle response - if ($response_output == "echo") { - echo $response; - } - else if ($response_output == "return") { + //if ($output == "echo") { + // echo $response; + //} + //else if ($output == "return") { return $response; - } + //} } //end function }