-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.php
74 lines (60 loc) · 2.38 KB
/
db.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
<?php
if(!defined("PHORUM")) return;
// The database schema version, which is used to handle
// installation and upgrades directly from the module.
define("VIRTUAL_HOSTING_DB_VERSION", 3);
// The table name for storing virtual hosts.
$PHORUM["virtual_hosts_table"] =
"{$PHORUM["DBCONFIG"]["table_prefix"]}_virtual_hosts";
// Load database layer functions.
include("./mods/virtual_hosting/db/{$PHORUM["DBCONFIG"]["type"]}/layer.php");
/**
* This function will check if an upgrade of the database scheme is needed.
* It is generic for all database layers.
*/
function virtual_hosting_db_install()
{
$PHORUM = $GLOBALS["PHORUM"];
$version = isset($PHORUM["mod_virtual_hosting_installed"])
? $PHORUM["mod_virtual_hosting_installed"] : 0;
while ($version < VIRTUAL_HOSTING_DB_VERSION)
{
// Initialize the settings array that we will be saving.
$version++;
$settings = array( "mod_virtual_hosting_installed" => $version );
$sqlfile = "./mods/virtual_hosting/db/" .
$PHORUM["DBCONFIG"]["type"] . "/$version.php";
if (! file_exists($sqlfile)) {
print "<b>Unexpected situation on installing " .
"the Virtual Hosting module</b>: " .
"unable to find the database schema setup script " .
htmlspecialchars($sqlfile);
return false;
}
$sqlqueries = array();
include($sqlfile);
if (count($sqlqueries) == 0) {
print "<b>Unexpected situation on installing " .
"the Virtual Hosting module</b>: could not read any SQL " .
"queries from file " . htmlspecialchars($sqlfile);
return false;
}
$err = phorum_db_run_queries($sqlqueries);
if ($err) {
print "<b>Unexpected situation on installing " .
"the Virtual Hosting module</b>: running the " .
"install queries from file " . htmlspecialchars($sqlfile) .
" failed: $err";
return false;
}
// Save our settings.
if (!phorum_db_update_settings($settings)) {
print "<b>Unexpected situation on installing " .
"the Virtual Hosting module</b>: updating the " .
"mod_virtual_hosting_installed setting failed";
return false;
}
}
return true;
}
?>