348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
1 |
<?php
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
2 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
3 |
/*
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
4 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
|
685
17ebe24cdf85
Rebranded as 1.1.5 (Caoineag alpha 5) and fixed a couple bugs related to CDN support in template_nodb and installerUI. Updated readme.
Dan
diff
changeset
|
5 |
* Version 1.1.5 (Caoineag alpha 5)
|
536
|
6 |
* Copyright (C) 2006-2008 Dan Fuhry
|
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
7 |
* Installation package
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
8 |
* libenanoinstall.php - Installation payload backend
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
9 |
*
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
10 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
12 |
*
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
13 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
14 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
15 |
*/
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
16 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
17 |
$neutral_color = 'C';
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
18 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
19 |
function run_installer_stage($stage_id, $stage_name, $function, $failure_explanation, $allow_skip = true)
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
20 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
21 |
static $resumed = false;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
22 |
static $resume_stack = array();
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
23 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
24 |
if ( empty($resume_stack) && isset($_POST['resume_stack']) && preg_match('/[a-z_]+((\|[a-z_]+)+)/', $_POST['resume_stack']) )
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
25 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
26 |
$resume_stack = explode('|', $_POST['resume_stack']);
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
27 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
28 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
29 |
$already_run = false;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
30 |
if ( in_array($stage_id, $resume_stack) )
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
31 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
32 |
$already_run = true;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
33 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
34 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
35 |
if ( !$resumed )
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
36 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
37 |
if ( !isset($_GET['sub']) )
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
38 |
$resumed = true;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
39 |
if ( isset($_GET['sub']) && $_GET['sub'] == $stage_id )
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
40 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
41 |
$resumed = true;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
42 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
43 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
44 |
if ( !$resumed && $allow_skip )
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
45 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
46 |
echo_stage_success($stage_id, $stage_name);
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
47 |
return false;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
48 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
49 |
if ( !function_exists($function) )
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
50 |
die('libenanoinstall: CRITICAL: function "' . $function . '" for ' . $stage_id . ' doesn\'t exist');
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
51 |
$result = @call_user_func($function, false, $already_run);
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
52 |
if ( $result )
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
53 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
54 |
echo_stage_success($stage_id, $stage_name);
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
55 |
$resume_stack[] = $stage_id;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
56 |
return true;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
57 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
58 |
else
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
59 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
60 |
echo_stage_failure($stage_id, $stage_name, $failure_explanation, $resume_stack);
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
61 |
return false;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
62 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
63 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
64 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
65 |
function start_install_table()
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
66 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
67 |
echo '<table border="0" cellspacing="0" cellpadding="0" style="margin-top: 10px;">' . "\n";
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
68 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
69 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
70 |
function close_install_table()
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
71 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
72 |
echo '</table>' . "\n\n";
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
73 |
flush();
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
74 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
75 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
76 |
function echo_stage_success($stage_id, $stage_name)
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
77 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
78 |
global $neutral_color;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
79 |
$neutral_color = ( $neutral_color == 'A' ) ? 'C' : 'A';
|
404
fb4f9e6f378f
Made the form validation icons (check/X/?) more visually appealing. IE-friendliness is still on the TODO list.
Dan
diff
changeset
|
80 |
echo '<tr><td style="width: 500px; background-color: #' . "{$neutral_color}{$neutral_color}FF{$neutral_color}{$neutral_color}" . '; padding: 0 5px;">' . htmlspecialchars($stage_name) . '</td><td style="padding: 0 5px;"><img alt="Done" src="../images/check.png" /></td></tr>' . "\n";
|
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
81 |
flush();
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
82 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
83 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
84 |
function echo_stage_failure($stage_id, $stage_name, $failure_explanation, $resume_stack)
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
85 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
86 |
global $neutral_color;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
87 |
global $lang;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
88 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
89 |
$neutral_color = ( $neutral_color == 'A' ) ? 'C' : 'A';
|
404
fb4f9e6f378f
Made the form validation icons (check/X/?) more visually appealing. IE-friendliness is still on the TODO list.
Dan
diff
changeset
|
90 |
echo '<tr><td style="width: 500px; background-color: #' . "FF{$neutral_color}{$neutral_color}{$neutral_color}{$neutral_color}" . '; padding: 0 5px;">' . htmlspecialchars($stage_name) . '</td><td style="padding: 0 5px;"><img alt="Failed" src="../images/checkbad.png" /></td></tr>' . "\n";
|
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
91 |
flush();
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
92 |
close_install_table();
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
93 |
$post_data = '';
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
94 |
$mysql_error = mysql_error();
|
626
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
|
95 |
$file = ( defined('IN_ENANO_UPGRADE') ) ? 'upgrade.php' : 'install.php';
|
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
96 |
foreach ( $_POST as $key => $value )
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
97 |
{
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
98 |
// FIXME: These should really also be sanitized for double quotes
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
99 |
$value = htmlspecialchars($value);
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
100 |
$key = htmlspecialchars($key);
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
101 |
$post_data .= " <input type=\"hidden\" name=\"$key\" value=\"$value\" />\n";
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
102 |
}
|
352
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
103 |
if ( $stage_id == 'renameconfig' )
|
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
104 |
echo '<p>' . $failure_explanation . '</p>';
|
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
105 |
else
|
626
be0e904eec17
Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings
Dan
diff
changeset
|
106 |
echo '<form action="' . $file . '?stage=install&sub=' . $stage_id . '" method="post">
|
352
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
107 |
' . $post_data . '
|
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
108 |
<input type="hidden" name="resume_stack" value="' . htmlspecialchars(implode('|', $resume_stack)) . '" />
|
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
109 |
<h3>' . $lang->get('meta_msg_err_stagefailed_title') . '</h3>
|
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
110 |
<p>' . $failure_explanation . '</p>
|
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
111 |
' . ( !empty($mysql_error) ? "<p>" . $lang->get('meta_msg_err_stagefailed_mysqlerror') . " $mysql_error</p>" : '' ) . '
|
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
112 |
<p>' . $lang->get('meta_msg_err_stagefailed_body') . '</p>
|
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
113 |
<p style="text-align: center;"><input type="submit" value="' . $lang->get('meta_btn_retry_installation') . '" /></p>
|
9d7225c0db6d
Enano's new installable installer, alpha 1. No upgrade and (in some parts) very little localization.
Dan
diff
changeset
|
114 |
</form>';
|
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
115 |
global $ui;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
116 |
$ui->show_footer();
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
117 |
exit;
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
118 |
}
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
119 |
|
494
|
120 |
function enano_perform_upgrade($target_branch)
|
|
121 |
{
|
|
122 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
123 |
// Import version info
|
|
124 |
global $enano_versions;
|
|
125 |
// Import UI functions
|
|
126 |
global $ui;
|
|
127 |
// This is needed for upgrade abstraction
|
|
128 |
global $dbdriver;
|
627
|
129 |
|
|
130 |
// see if we're actually supposed to be in post-upgrade
|
|
131 |
if ( getConfig('enano_version') == 'upg-' . installer_enano_version() )
|
|
132 |
{
|
|
133 |
// yep, fall out here to avoid errors
|
|
134 |
return true;
|
|
135 |
}
|
|
136 |
|
494
|
137 |
// Main upgrade stage
|
|
138 |
|
|
139 |
// Init vars
|
|
140 |
list($major_version, $minor_version) = explode('.', installer_enano_version());
|
|
141 |
$installer_branch = "$major_version.$minor_version";
|
627
|
142 |
$installer_branch = preg_replace('/^upg-/', '', $installer_branch);
|
|
143 |
$target_branch = preg_replace('/^upg-/', '', $target_branch);
|
494
|
144 |
|
|
145 |
$version_flipped = array_flip($enano_versions[$target_branch]);
|
|
146 |
$version_curr = enano_version();
|
|
147 |
// Change this to be the last version in the current branch.
|
|
148 |
// If we're just upgrading within this branch, use the version the installer library
|
|
149 |
// reports to us. Else, use the latest in the old (current target) branch.
|
|
150 |
// $version_target = installer_enano_version();
|
|
151 |
$version_target = ( $target_branch === $installer_branch ) ? installer_enano_version() : $enano_versions[$target_branch][ count($enano_versions[$target_branch]) - 1 ];
|
|
152 |
|
|
153 |
// Calculate which scripts to run
|
|
154 |
if ( !isset($version_flipped[$version_curr]) )
|
|
155 |
{
|
|
156 |
echo '<p>ERROR: Unsupported version</p>';
|
|
157 |
$ui->show_footer();
|
|
158 |
exit;
|
|
159 |
}
|
|
160 |
if ( !isset($version_flipped[$version_target]) )
|
|
161 |
{
|
|
162 |
echo '<p>ERROR: Upgrader doesn\'t support its own version</p>';
|
|
163 |
$ui->show_footer();
|
|
164 |
exit;
|
|
165 |
}
|
|
166 |
$upg_queue = array();
|
|
167 |
for ( $i = $version_flipped[$version_curr]; $i < $version_flipped[$version_target]; $i++ )
|
|
168 |
{
|
|
169 |
if ( !isset($enano_versions[$target_branch][$i + 1]) )
|
|
170 |
{
|
|
171 |
echo '<p>ERROR: Unsupported intermediate version</p>';
|
|
172 |
$ui->show_footer();
|
|
173 |
exit;
|
|
174 |
}
|
|
175 |
$ver_this = $enano_versions[$target_branch][$i];
|
|
176 |
$ver_next = $enano_versions[$target_branch][$i + 1];
|
|
177 |
$upg_queue[] = array($ver_this, $ver_next);
|
|
178 |
}
|
|
179 |
|
|
180 |
// Verify that all upgrade scripts are usable
|
|
181 |
foreach ( $upg_queue as $verset )
|
|
182 |
{
|
|
183 |
$file = ENANO_ROOT . "/install/schemas/upgrade/{$verset[0]}-{$verset[1]}-$dbdriver.sql";
|
|
184 |
if ( !file_exists($file) )
|
|
185 |
{
|
|
186 |
echo "<p>ERROR: Couldn't find required schema file: $file</p>";
|
|
187 |
$ui->show_footer();
|
|
188 |
exit;
|
|
189 |
}
|
|
190 |
}
|
|
191 |
// Perform upgrade
|
|
192 |
foreach ( $upg_queue as $verset )
|
|
193 |
{
|
|
194 |
$file = ENANO_ROOT . "/install/schemas/upgrade/{$verset[0]}-{$verset[1]}-$dbdriver.sql";
|
|
195 |
try
|
|
196 |
{
|
|
197 |
$parser = new SQL_Parser($file);
|
|
198 |
}
|
|
199 |
catch(Exception $e)
|
|
200 |
{
|
|
201 |
die("<pre>$e</pre>");
|
|
202 |
}
|
|
203 |
|
|
204 |
$parser->assign_vars(array(
|
|
205 |
'TABLE_PREFIX' => table_prefix
|
|
206 |
));
|
|
207 |
|
|
208 |
$sql_list = $parser->parse();
|
|
209 |
// Check for empty schema file
|
|
210 |
if ( $sql_list[0] === ';' && count($sql_list) == 1 )
|
|
211 |
{
|
|
212 |
// It's empty, report success for this version
|
|
213 |
// See below for explanation of why setConfig() is called here
|
|
214 |
setConfig('enano_version', $verset[1]);
|
|
215 |
continue;
|
|
216 |
}
|
|
217 |
|
|
218 |
foreach ( $sql_list as $sql )
|
|
219 |
{
|
|
220 |
// check for '@' operator on query
|
|
221 |
if ( substr($sql, 0, 1) == '@' )
|
|
222 |
{
|
|
223 |
// Yes - perform query but don't check for errors
|
|
224 |
$db->sql_query($sql);
|
|
225 |
}
|
|
226 |
else
|
|
227 |
{
|
|
228 |
// Perform as normal
|
|
229 |
if ( !$db->sql_query($sql) )
|
|
230 |
$db->_die();
|
|
231 |
}
|
|
232 |
}
|
|
233 |
|
|
234 |
// Is there an additional script (logic) to be run after the schema?
|
|
235 |
$postscript = ENANO_ROOT . "/install/schemas/upgrade/{$verset[0]}-{$verset[1]}.php";
|
|
236 |
if ( file_exists($postscript) )
|
|
237 |
@include($postscript);
|
|
238 |
|
|
239 |
// The advantage of calling setConfig on the system version here?
|
|
240 |
// Simple. If the upgrade fails, it will pick up from the last
|
|
241 |
// version, not try to start again from the beginning. This will
|
|
242 |
// still cause errors in most cases though. Eventually we probably
|
|
243 |
// need some sort of query-numbering system that tracks in-progress
|
|
244 |
// upgrades.
|
|
245 |
|
|
246 |
setConfig('enano_version', $verset[1]);
|
|
247 |
}
|
|
248 |
}
|
|
249 |
|
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
diff
changeset
|
250 |
?>
|