-
Notifications
You must be signed in to change notification settings - Fork 24
/
upgrade-2.php
172 lines (155 loc) · 4.72 KB
/
upgrade-2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
##################################################
#
# Copyright (c) 2004-2011 OIC Group, Inc.
# Copyright (c) 2006 Maxim Mueller
# Written and Designed by James Hunt
#
# This file is part of Exponent
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) exit('');
?>
<h2><?php echo gt('Installing and Upgrading tables'); ?></h2>
<?php
define("TMP_TABLE_EXISTED", 1);
define("TMP_TABLE_INSTALLED", 2);
define("TMP_TABLE_FAILED", 3);
define("TMP_TABLE_ALTERED", 4);
$dirs = array(
BASE."datatypes/definitions",
BASE."framework/core/database/definitions",
);
$tables = array();
foreach ($dirs as $dir) {
if (is_readable($dir)) {
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
if (is_readable("$dir/$file") && is_file("$dir/$file") && substr($file,-4,4) == ".php" && substr($file,-9,9) != ".info.php") {
$tablename = substr($file,0,-4);
$dd = include("$dir/$file");
$info = null;
if (is_readable("$dir/$tablename.info.php")) $info = include("$dir/$tablename.info.php");
if (!$db->tableExists($tablename)) {
foreach ($db->createTable($tablename,$dd,$info) as $key=>$status) {
$tables[$key] = $status;
}
} else {
foreach ($db->alterTable($tablename,$dd,$info) as $key=>$status) {
if (isset($tables[$key])) echo "$tablename, $key<br>";
if ($status == TABLE_ALTER_FAILED){
$tables[$key] = $status;
}else{
$tables[$key] = ($status == TABLE_ALTER_NOT_NEEDED ? DATABASE_TABLE_EXISTED : DATABASE_TABLE_ALTERED);
}
}
}
}
}
}
}
$newdef = BASE."framework/modules";
if (is_readable($newdef)) {
$dh = opendir($newdef);
while (($file = readdir($dh)) !== false) {
if (is_dir($newdef.'/'.$file) && ($file != '..' && $file != '.')) {
$dirpath = $newdef.'/'.$file.'/definitions';
if (file_exists($dirpath)) {
$def_dir = opendir($dirpath);
while (($def = readdir($def_dir)) !== false) {
eDebug("$dirpath/$def");
if (is_readable("$dirpath/$def") && is_file("$dirpath/$def") && substr($def,-4,4) == ".php" && substr($def,-9,9) != ".info.php") {
$tablename = substr($def,0,-4);
$dd = include("$dirpath/$def");
$info = null;
if (is_readable("$dirpath/$tablename.info.php")) $info = include("$dirpath/$tablename.info.php");
if (!$db->tableExists($tablename)) {
foreach ($db->createTable($tablename,$dd,$info) as $key=>$status) {
$tables[$key] = $status;
}
} else {
foreach ($db->alterTable($tablename,$dd,$info) as $key=>$status) {
if (isset($tables[$key])) echo "$tablename, $key<br>";
if ($status == TABLE_ALTER_FAILED){
$tables[$key] = $status;
}else{
$tables[$key] = ($status == TABLE_ALTER_NOT_NEEDED ? DATABASE_TABLE_EXISTED : DATABASE_TABLE_ALTERED);
}
}
}
}
}
}
}
}
}
ksort($tables);
?>
<table cellpadding="2" cellspacing="0" width="100%" border="0" class="exp-skin-table">
<thead>
<tr>
<th>
<?php echo gt('Table Name') ?>
</th>
<th>
<?php echo gt('Status') ?>
</th>
</tr>
</thead>
<tbody>
<?php
$row = "even";
$line = 0;
foreach ($tables as $table => $statusnum) {
if ($statusnum != TMP_TABLE_EXISTED) {
?>
<tr class="<?php echo $row ?>">
<td>
<?php echo gt($table) ?>
</td>
<td>
<?php if ($statusnum == TMP_TABLE_EXISTED) { ?>
<div style="color: blue; font-weight: bold">
<?php echo gt('Table Exists') ?>
</div>
<?php } elseif ($statusnum == TMP_TABLE_INSTALLED) { ?>
<div style="color: green; font-weight: bold">
<?php echo gt('Succeeded') ?>
</div>
<?php } elseif ($statusnum == TMP_TABLE_FAILED) { ?>
<div style="color: red; font-weight: bold">
<?php echo gt('Failed') ?>
</div>
<?php } elseif ($statusnum == TMP_TABLE_ALTERED) { ?>
<div style="color: green; font-weight: bold">
<?php echo gt('Altered Existing') ?>
</div>
<?php } elseif ($statusnum == TABLE_ALTER_FAILED) { ?>
<div style="color: red; font-weight: bold">
<?php echo gt('Failed Altering') ?>
</div>
<?php } ?>
</td>
</tr>
<?php
$row = $row == "even" ? "odd" : "even";
$line++;
}
?>
<tbody>
</table>
<?php
}
if ($line == 0) {
echo "<b>No Tables Were Changed!</b>";
}
?>
<a class="awesome large green" href="?page=upgrade-3"><?php echo gt('Continue Upgrade') ?></a>