require_once "resources/classes/text.php"; //add multi-lingual support $language = new text(); $text = $language->get(); //show the title if ($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 require_once "resources/classes/schema.php"; $obj = new schema(); echo $obj->schema("text"); //run all app_defaults.php files require_once "resources/classes/domains.php"; $domain = new domains(); $domain->upgrade(); //show the content if ($format == 'html') { echo "<div align='center'>\n"; echo "<table width='40%'>\n"; echo "<tr>\n"; echo "<th align='left'>" . $text['header-message'] . "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td class='row_style1'><strong>" . $text['message-upgrade'] . "</strong></td>\n"; echo "</tr>\n"; echo "</table>\n";
protected function app_defaults() { $this->write_progress("\tRunning app_defaults"); //set needed session settings $_SESSION["username"] = $this->admin_username; $_SESSION["domain_uuid"] = $this->global_settings->domain_uuid(); require $this->config_php; require "resources/require.php"; $_SESSION['event_socket_ip_address'] = $this->global_settings->event_host; $_SESSION['event_socket_port'] = $this->global_settings->event_port; $_SESSION['event_socket_password'] = $this->global_settings->event_password; //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 = $this->dbh->prepare(check_sql($sql)); $prep_statement->bindParam(':domain_uuid', $this->global_settings->domain_uuid); $prep_statement->bindParam(':user_uuid', $this->admin_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 = '" . $this->global_settings->domain_uuid . "' and group_name = '" . $field['group_name'] . "') "; } else { $sql .= "or (domain_uuid = '" . $this->global_settings->domain_uuid . "' and group_name = '" . $field['group_name'] . "') "; } $x++; } } $prep_statement_sub = $this->dbh->prepare($sql); $prep_statement_sub->execute(); $_SESSION['permissions'] = $prep_statement_sub->fetchAll(PDO::FETCH_NAMED); unset($sql, $prep_statement_sub); //include the config.php $db_type = $this->global_settings->db_type(); $db_path = $this->global_settings->db_path(); $db_host = $this->global_settings->db_host(); $db_port = $this->global_settings->db_port(); $db_name = $this->global_settings->db_name(); $db_username = $this->global_settings->db_username(); $db_password = $this->global_settings->db_password(); //add the database structure require_once "resources/classes/schema.php"; $schema = new schema(); echo $schema->schema(); //run all app_defaults.php files $default_language = $this->install_language; $domain = new domains(); $domain->upgrade(); //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"] = ""; }
} 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 "resources/classes/schema.php"; $obj = new schema(); $obj->schema($db, $db_type, $db_name, $display_type); //run all app_defaults.php files require_once "resources/classes/domains.php"; $domain = new domains(); $domain->upgrade(); //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
$sql3 .= "where domain_uuid = '" . $row['domain_uuid'] . "' "; $sql3 .= "and contact_uuid = '" . $row['contact_uuid'] . "' "; $prep_statement3 = $db->prepare(check_sql($sql3)); $prep_statement3->execute(); unset($sql3, $prep_statement3); } unset($sql2, $result2, $prep_statement2); } } } unset($obj); //populate primary url from deprecated field in v_contact table $obj = new schema(); $obj->db = $db; $obj->db_type = $db_type; $obj->schema(); $field_exists = $obj->column_exists($db_name, 'v_contacts', 'contact_url'); //check if field exists if ($field_exists) { // get email records $sql = "select * from v_contacts where contact_url is not null and contact_url != ''"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); unset($prep_statement, $sql); if ($result_count > 0) { foreach ($result as $row) { $sql = "insert into v_contact_urls "; $sql .= "("; $sql .= "domain_uuid, ";
$obj->upgrade(); //set the message $response_message = $text['message-upgrade_source_scripts']; } else { //set the message $response_message = $text['message-upgrade_source']; } } } // load an array of the database schema and compare it with the active database if ($do["schema"] && permission_exists("upgrade_schema")) { $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")) { $response_message = $text['message-upgrade_apps']; require_once "resources/classes/domains.php"; $domain = new domains(); $domain->upgrade(); } // restore defaults of the selected menu if ($do["menu"] && permission_exists("menu_restore")) { $sel_menu = explode('|', check_str($_POST["sel_menu"])); $menu_uuid = $sel_menu[0]; $menu_language = $sel_menu[1]; $included = true; require_once "core/menu/menu_restore_default.php";
$format = 'text'; //html, text //add multi-lingual support $language = new text(); $text = $language->get(); } else { if (!$included) { include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('upgrade_schema') || if_group("superadmin")) { //echo "access granted"; } else { echo "access denied"; exit; } require_once "resources/header.php"; $document['title'] = $text['title-upgrade_schema']; $format = 'html'; //html, text } } //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(); echo $obj->schema($format); if (!$included && $format == 'html') { echo "<br />\n"; echo "<br />\n"; require_once "resources/footer.php"; }