-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathschema.php
More file actions
executable file
·93 lines (77 loc) · 3.12 KB
/
schema.php
File metadata and controls
executable file
·93 lines (77 loc) · 3.12 KB
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
<?php
// IPplan v4.92b
// Aug 24, 2001
//
// This program 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.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// when the database layout changes, bump up this value.
define("SCHEMA", 22);
require_once("adodb/adodb.inc.php");
require_once("class.dbflib.php");
// checks to see if user is using latest schema
function CheckSchema() {
// check php version
if (phpversion() < "4.1.0") {
die("You need php version 4.1.0 or later");
}
if (phpversion() >= "6") {
die("This version of IPplan will not work with PHP 6.x");
}
// cant use myError here as we do not have access to layout yet!
$ds=new IPplanDbf();
//$ds->ds->debug = true;
if (!$ds) {
die(my_("Could not connect to database"));
}
// check mysql version
if (DBF_TYPE=="mysql" or DBF_TYPE=="maxsql") {
$result=&$ds->ds->Execute("SELECT version() AS version");
$row = $result->FetchRow();
$version=$row["version"];
if ($version < "3.23.15") {
die("You need mysql version 3.23.15 or later");
}
}
// get schema version
// schema is reserved word in mssql
if (DBF_TYPE=="mssql" or DBF_TYPE=="ado_mssql" or DBF_TYPE=="odbc_mssql" or
DBF_TYPE=='mysql' or DBF_TYPE=='maxsql') {
$result=&$ds->ds->Execute("SELECT version
FROM version");
}
else {
$result=&$ds->ds->Execute("SELECT version
FROM schema");
}
// could return error if schema table does not exist!
if (!$result) {
echo my_("Problem with database permission or database tables - have installation instructions been followed?")."<p>";
die(my_("Could not connect to database"));
}
$row = $result->FetchRow();
$version=$row["version"];
// schema version did not change
if ($version == SCHEMA)
return;
else if (SCHEMA < $version) {
echo my_("You are trying to downgrade IPplan - impossible");
exit;
}
echo "<b>".my_("Schema version outdated")."</b>:<p>";
echo sprintf(my_("The database structures need to be upgraded to accommodate new features. For this to happen, you require enough access rights on the %s database. If you get errors back from the upgrade process, you will need to temporarily grant more access rights to the %s database for the duration of the upgrade"), DBF_NAME, DBF_NAME);
echo "<p>".my_("This process needs to be done by the administrator by executing the installation scripts. See information in the INSTALL and UPGRADE files.");
exit;
}
?>