Mercurial > hg > fapweb
annotate managedb.php @ 581:adc8f66f9c33
10L.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 02 Oct 2014 13:39:59 +0300 |
parents | ba521a7e7653 |
children | 83dee3e7c36f |
rev | line source |
---|---|
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 #!/usr/bin/php |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 <? |
175
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
170
diff
changeset
|
3 require_once "mconfig.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
170
diff
changeset
|
4 require_once "msite.inc.php"; |
555
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
5 require_once "dbdefs.inc.php"; |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 |
479
86ee2b42a995
Move CLI helper functions to msitegen, again.
Matti Hamalainen <ccr@tnsp.org>
parents:
426
diff
changeset
|
7 stCheckCLIExec(); |
50
184a4188555c
Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
8 |
555
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
9 |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
541
diff
changeset
|
10 $currVersion = -1; |
555
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
11 $dbMetaData = array( |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
12 "dbVersion" => array(VT_INT, $dbVersion, "Database version"), |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
13 ); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
14 |
555
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
15 $sqlTables["dbmeta"] = array( |
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
16 array("key" , "VARCHAR(32)", "PRIMARY KEY"), |
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
17 array("vtype" , "INT"), |
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
18 array("vstr" , "VARCHAR(128)"), |
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
19 array("vtext" , "TEXT"), |
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
20 array("vint" , "INT"), |
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
21 array("sdesc" , "VARCHAR(128)"), |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 ); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 |
515 | 24 |
88
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
25 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 // |
36 | 27 // Helper functions |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 // |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
29 function stCreateTables($dbh, $upgrade) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 global $sqlTables; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 echo "Creating tables...\n"; |
503
3232f682f0d2
Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents:
502
diff
changeset
|
33 foreach ($sqlTables as $name => $schemaData) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 echo " - '".$name."'\n"; |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
36 stDBExecSQL($dbh, "DROP TABLE IF EXISTS ".$name); |
576 | 37 if (!stDBCreateOneTable($dbh, $name, stDBGetTableSchema($dbh, $schemaData)) && !$upgrade) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 return FALSE; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 return TRUE; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
44 function stUpgradeMap($type, $name) |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
45 { |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
46 global $upgradeMappings, $currVersion, $dbVersion; |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
47 |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
48 $converted = FALSE; |
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
49 $tmpName = $name; |
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
50 |
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
51 for ($ver = $currVersion; $ver <= $dbVersion; $ver++) |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
52 { |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
53 if (isset($upgradeMappings[$ver]) && |
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
54 isset($upgradeMappings[$ver][$tmpName]) && |
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
55 isset($upgradeMappings[$ver][$tmpName][$type])) |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
56 { |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
57 $tmpName = $upgradeMappings[$ver][$tmpName][$type]; |
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
58 $converted = TRUE; |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
59 } |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
60 } |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
61 |
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
62 if ($converted) |
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
63 return $tmpName; |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
64 else |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
65 switch ($type) |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
66 { |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
67 case "table": return $name; |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
68 case "key": return $name; |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
69 default: die("Invalid upgrade type '".$type."'.\n"); |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
70 } |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
71 } |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
72 |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
73 |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
74 function stAddSettings($inDB, $outDB, $settings, $table, $upgrade) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 { |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
76 echo ($upgrade ? "Adding settings to" : "Upgrading settings in")." '".$table."' table."; |
80 | 77 |
519 | 78 $status = TRUE; |
581 | 79 stDBBeginTransaction($outDB); |
519 | 80 |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
81 foreach ($settings as $key => $data) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 { |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
83 $sql = false; |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
84 |
515 | 85 // Get setting type |
80 | 86 switch ($data[0]) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 case VT_TEXT: $type = "%s"; $var = "vtext"; break; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 case VT_STR: $type = "%s"; $var = "vstr"; break; |
72
63a6caf59e5c
Fix creation of boolean settings, and add '%b' formatter into stPrepareSQL().
Matti Hamalainen <ccr@tnsp.org>
parents:
67
diff
changeset
|
90 case VT_BOOL: $type = "%b"; $var = "vint"; break; |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 case VT_INT: $type = "%d"; $var = "vint"; break; |
80 | 92 default: die("Invalid type in default settings '".$key."', type=".$data[0]."\n"); |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 |
515 | 95 // Check if we are upgrading |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
96 if ($upgrade) |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
97 { |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
98 // Map the key, in case the name has changed |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
99 $inKey = stUpgradeMap("key", $key); |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
100 $inTable = stUpgradeMap("table", $table); |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
101 |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
102 if (($res = stDBFetchSQL($inDB, stDBPrepareSQL($inDB, "SELECT * FROM ".$inTable." WHERE key=%s", $inKey))) !== FALSE) |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
103 { |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
104 // Yup, upgrade the data, if we can |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
105 echo "."; |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
106 |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
107 if ($res["vtype"] != $data[0]) |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
108 die("Oops! Data type of '".$key."' does not match in table '".$table.". DB upgrade failed.\n"); |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
109 |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
110 $sql = stDBPrepareSQL($outDB, |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
111 "INSERT INTO ".$table." (key,vtype,".$var.",sdesc) VALUES (%s,%d,".$type.",%s)", |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
112 $key, $data[0], $res[$var], $data[2]); |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
113 } |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
114 } |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
115 |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
116 if ($sql === false) |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
117 { |
515 | 118 // Normal insertion of default data |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
119 echo "+"; |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
120 $sql = stDBPrepareSQL($outDB, |
519 | 121 "INSERT INTO ".$table." (key,vtype,".$var.",sdesc) VALUES (%s,%d,".$type.",%s)", |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
122 $key, $data[0], $data[1], $data[2]); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
123 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
124 |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
125 if (stDBExecSQL($outDB, $sql) === FALSE) |
519 | 126 { |
127 $status = FALSE; | |
128 break; | |
129 } | |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
130 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
131 echo "\n"; |
519 | 132 |
581 | 133 stDBCommitTransaction($outDB); |
519 | 134 return $status; |
135 } | |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
136 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
137 |
519 | 138 function stAddTestData($outDB) |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
139 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
140 global $siteTestData; |
519 | 141 |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
142 echo "Adding test data.\n"; |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
143 |
519 | 144 $status = TRUE; |
581 | 145 stDBBeginTransaction($outDB); |
519 | 146 |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
147 foreach ($siteTestData as $table => $data) |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
148 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
149 echo " - ".$table."...\n"; |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
150 if (count($data) >= 3) |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
151 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
152 for ($n = 2; $n < count($data); $n++) |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
153 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
154 $arr = array_merge( |
519 | 155 array($outDB, "INSERT INTO ".$table." (".$data[0].") VALUES (".$data[1].")"), |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
156 $data[$n]); |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
157 |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
158 $sql = call_user_func_array('stDBPrepareSQL', $arr); |
519 | 159 if (stDBExecSQL($outDB, $sql) === false) |
160 { | |
161 $status = false; | |
162 break; | |
163 } | |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
164 } |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
165 } |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
166 else |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
167 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
168 echo " Invalid table / data definition.\n"; |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
169 } |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
170 } |
519 | 171 |
581 | 172 stDBCommitTransaction($outDB); |
519 | 173 return $status; |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
174 } |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
175 |
499 | 176 |
504
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
177 function stGetSQLTypeParam($dbh, $def, $value) |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
178 { |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
179 switch (substr($def, 0, 3)) |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
180 { |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
181 case "INT": |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
182 return intval($value); |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
183 |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
184 case "VAR": |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
185 case "TEX": |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
186 return $dbh->quote($value); |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
187 |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
188 default: die("Unknown type ".$col[1].".\n"); |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
189 } |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
190 } |
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
191 |
519 | 192 |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
193 function stMigrateTables($inDB, $outDB, $upgrade, $excluded) |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
194 { |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
195 global $sqlTables; |
519 | 196 |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
197 echo "Migrating tables...\n"; |
519 | 198 $status = TRUE; |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
199 $dbName = $outDB->getAttribute(PDO::ATTR_DRIVER_NAME); |
581 | 200 stDBBeginTransaction($outDB); |
519 | 201 |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
202 foreach ($sqlTables as $table => $schema) |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
203 { |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
204 // Do not migrate excluded tables (or excluded tables with old names) |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
205 $sequences = array(); |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
206 $inTable = $upgrade ? stUpgradeMap("table", $table) : $table; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
207 if (in_array($inTable, $excluded) || in_array($table, $excluded)) |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
208 continue; |
504
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
209 |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
210 // Process each row of the input table |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
211 echo " - '".$table."' "; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
212 foreach (stDBExecSQL($inDB, "SELECT * FROM ".$inTable) as $row) |
504
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
213 { |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
214 // Convert to new schema, as needed |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
215 $avals = array(); |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
216 $acols = array(); |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
217 |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
218 foreach ($schema as $col) |
504
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
219 { |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
220 // If input has schema column, add it to output |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
221 if (isset($row[$col[0]])) |
504
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
222 { |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
223 $avals[] = stGetSQLTypeParam($outDB, $col[1], $row[$col[0]]); |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
224 $acols[] = $col[0]; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
225 } |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
226 |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
227 // If the column should have autoincrement, add it to sequences |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
228 if (in_array("AUTOINCREMENT", $col)) |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
229 $sequences[] = $col[0]; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
230 } |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
231 |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
232 $sql = "INSERT INTO ".$table." (".implode(",", $acols).") VALUES (".implode(",", $avals).")"; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
233 if (stDBExecSQL($outDB, $sql) === false) |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
234 { |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
235 $status = FALSE; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
236 break; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
237 } |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
238 echo "."; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
239 } |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
240 |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
241 // Perform some specialities here |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
242 switch ($dbName) |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
243 { |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
244 case "pgsql": |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
245 // For PostgreSQL we need to update sequences |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
246 foreach ($sequences as $seq) |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
247 { |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
248 if (($max_id = stDBFetchSQLColumn($outDB, "SELECT MAX(".$seq.") FROM ".$table)) !== false && |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
249 ($seq_id = stDBFetchSQLColumn($outDB, "SELECT nextval('".$table."_".$seq."_seq')")) !== false && |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
250 ($seq_id <= $max_id)) |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
251 { |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
252 echo "SEQFIX"; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
253 stDBExecSQL($outDB, "SELECT setval('".$table."_".$seq."_seq', ".$max_id.")"); |
540
ab08640b4302
Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents:
533
diff
changeset
|
254 } |
504
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
255 } |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
256 break; |
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
257 } |
504
a491865e0684
Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
503
diff
changeset
|
258 |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
259 echo "\n"; |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
260 } |
519 | 261 |
581 | 262 stDBCommitTransaction($outDB); |
519 | 263 |
264 return $status; | |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
265 } |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
266 |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
267 |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
268 function stSetDBPermissions($spec) |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
269 { |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
270 if (substr($spec, 0, 7) == "sqlite:") |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
271 { |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
272 $filename = substr($spec, 7); |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
273 echo |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
274 "NOTICE! It seems you have SQLite database in use, changing permission ". |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
275 "of the target file '".$filename."' to 0600, for security. You may have to ". |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
276 "loosen up that for the things to actually work, but be careful. Having your ". |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
277 "database world-readable in the web is NOT good.\n"; |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
278 |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
279 if (chmod($filename, 0600) === FALSE) |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
280 { |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
281 echo "ERROR! Could not set permissions of '".$filename."!\n"; |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
282 } |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
283 } |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
284 } |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
285 |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
286 |
36 | 287 // |
288 // Main program starts | |
289 // | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
290 if ($argc < 2) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
291 { |
482
e0fd4c7ae8fb
Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents:
479
diff
changeset
|
292 echo |
529
ddbc84031a7b
Rename createdb.php to managedb.php
Matti Hamalainen <ccr@tnsp.org>
parents:
528
diff
changeset
|
293 "ManageDB - Manage FAPWeb SQL database\n". |
565 | 294 "(C) Copyright 2012-2014 ccr/TNSP\n". |
482
e0fd4c7ae8fb
Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents:
479
diff
changeset
|
295 "\n". |
e0fd4c7ae8fb
Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents:
479
diff
changeset
|
296 "Usage: ".$argv[0]." <mode> [args]\n". |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
297 "Where mode is one of following:\n". |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
298 "\n". |
525
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
299 " new <dbspec> Create a new database with given PDO spec\n". |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
300 " or default to the one in mconfig.inc.php\n". |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
301 "\n". |
525
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
302 " test <dbspec> Like new, but add initial test data.\n". |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
303 "\n". |
525
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
304 " upgrade <input_dbspec> <output_dbspec>\n". |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
305 " Upgrade current database, if possible.\n". |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
306 " Output to new database (DO NOT USE SAME as current!)\n". |
516 | 307 "\n". |
525
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
308 " migrate <input_dbspec> <output_dbspec>\n". |
516 | 309 " Like upgrade, but no version check. Creates\n". |
310 " a copy of the database to the output spec.\n". | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
311 "\n"; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
312 exit; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
313 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
314 |
541
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
315 // Validate tables data |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
316 $errors = FALSE; |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
317 foreach ($sqlTables as $table => $data) |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
318 { |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
319 if (strtolower($table) != $table) |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
320 { |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
321 echo "Invalid table definition '".$table."', table name must be lower case.\n"; |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
322 $errors = TRUE; |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
323 } |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
324 |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
325 foreach ($data as $def) |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
326 if (strtolower($def[0]) != $def[0]) |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
327 { |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
328 echo "Invalid table definition '".$table."', column key '".$def[0]."' must be lower case.\n"; |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
329 $errors = TRUE; |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
330 } |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
331 } |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
332 |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
333 if ($errors) |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
334 die("Errors in table definitions.\n"); |
e5a088dd3a4b
Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents:
540
diff
changeset
|
335 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
336 |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
337 // Act according to specified command |
489 | 338 $addTestData = FALSE; |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
339 $upgrade = FALSE; |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
340 |
27
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
341 switch (stCArgLC(1)) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
342 { |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
343 case "test": |
489 | 344 $addTestData = TRUE; |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
345 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
346 case "new": |
525
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
347 // Try to connect to database |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
348 if (($inSpec = stCArg(2)) === false) |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
349 die("No PDO database spec specified.\n"); |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
350 |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
351 if (($inDB = stConnectSQLDBSpec($inSpec)) === false) |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
352 die("Could not connect to SQL database '".$inSpec."'.\n"); |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
353 |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
354 echo "Using database spec '".$inSpec."'.\n"; |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
355 |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
356 // Create tables, add defaults |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
357 if (stCreateTables($inDB, FALSE)) |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
358 { |
555
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
359 stAddSettings($inDB, $inDB, $dbMetaData, "dbmeta", FALSE); |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
360 stAddSettings($inDB, $inDB, $siteDefaults, "settings", FALSE); |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
541
diff
changeset
|
361 stAddSettings($inDB, $inDB, $siteDisplayVars, "display_vars", FALSE); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
362 } |
27
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
363 |
489 | 364 if ($addTestData) |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
365 stAddTestData($inDB); |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
366 |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
367 stSetDBPermissions($inSpec); |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
368 break; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
369 |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
370 case "upgrade": |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
371 $upgrade = TRUE; |
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
372 |
516 | 373 case "migrate": |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
374 // |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
375 // Attempt to upgrade database |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
376 // |
525
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
377 if ($argc < 4) |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
378 die("Usage: ".$argv[0]." upgrade <input_dbspec> <output_dbspec>\n"); |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
379 |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
380 $inSpec = stCArg(2); |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
381 $outSpec = stCArg(3); |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
382 |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
383 if ($outSpec == $inSpec) |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
384 die("The input and output databases CAN NOT BE SAME.\nBe VERY CAREFUL to not accidentally specify same db!\n"); |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
385 |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
386 echo "Using database spec '".$inSpec."'.\n"; |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
387 |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
388 if (($inDB = stConnectSQLDBSpec($inSpec)) === false) |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
389 die("Could not connect to SQL database '".$inSpec."'.\n"); |
d7302b3a479e
Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
390 |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
391 // Check the current version first ... |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
392 if (($currVersion = stGetDBMeta($inDB, "dbVersion")) === FALSE) |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
393 $currVersion = -1; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
394 |
516 | 395 if ($currVersion == $dbVersion && stCArgLC(1) == "upgrade") |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
396 { |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
397 echo "Database is already version ".$dbVersion.", no upgrading needed.\n"; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
398 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
399 else |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
400 { |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
401 // Okay, we shall create an upgraded version .. |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
402 if (($outDB = stConnectSQLDBSpec($outSpec)) === false) |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
403 die("Could not connect to SQL database '".$outSpec."'.\n"); |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
404 |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
405 echo "Database at version ".$currVersion.", upgrading to ".$dbVersion."\n"; |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
406 echo "Using OUTPUT database spec '".$outSpec."'.\n"; |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
407 |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
408 // Possibly bail out incompatible upgrades here |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
409 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
410 // Create tables |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
411 if (!stCreateTables($outDB, TRUE)) |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
412 exit; |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
413 |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
414 // Migrate data from setting tables .. |
552 | 415 if (!stAddSettings($inDB, $outDB, $siteDefaults, "settings", TRUE)) |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
416 exit; |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
417 |
552 | 418 if (!stAddSettings($inDB, $outDB, $siteDisplayVars, "display_vars", TRUE)) |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
419 exit; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
420 |
555
206196b610fd
Move site specific things to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
553
diff
changeset
|
421 stAddSettings($inDB, $outDB, $dbMetaData, "dbmeta", TRUE); |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
422 |
503
3232f682f0d2
Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents:
502
diff
changeset
|
423 // Migrate other tables |
551
bed441ced78e
Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents:
549
diff
changeset
|
424 if (!stMigrateTables($inDB, $outDB, $upgrade, array("settings", "display_vars", "dbmeta"))) |
503
3232f682f0d2
Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents:
502
diff
changeset
|
425 exit; |
553
f13e7a513db1
Fix sequences after database upgrade or migration.
Matti Hamalainen <ccr@tnsp.org>
parents:
552
diff
changeset
|
426 |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
427 echo "Setting dbVersion.\n"; |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
428 stSetDBMeta($outDB, "dbVersion", $dbVersion); |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
429 echo "Upgrade complete.\n"; |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
430 |
502
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
431 stSetDBPermissions($inSpec); |
d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents:
500
diff
changeset
|
432 stSetDBPermissions($outSpec); |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
433 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
434 break; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
435 |
27
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
436 default: |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
437 echo "ERROR! Invalid operation mode '".stCArg(1)."'.\n"; |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
438 break; |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
439 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
440 |
28 | 441 |
442 // | |
443 // Clean up permissions | |
444 // | |
529
ddbc84031a7b
Rename createdb.php to managedb.php
Matti Hamalainen <ccr@tnsp.org>
parents:
528
diff
changeset
|
445 foreach (array("managedb.php") as $filename) |
28 | 446 { |
447 if (chmod($filename, 0700) === FALSE) | |
448 { | |
490
505f46b8bb14
Separate variable from string flow.
Matti Hamalainen <ccr@tnsp.org>
parents:
489
diff
changeset
|
449 echo "ERROR! Could not set permissions for '".$filename."'!\n"; |
28 | 450 } |
451 } | |
452 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
453 ?> |