annotate createdb.php @ 504:a491865e0684

Implement tables migration.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 07 Dec 2013 19:35:01 +0200
parents 3232f682f0d2
children f66aa0cdb666
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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";
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
479
86ee2b42a995 Move CLI helper functions to msitegen, again.
Matti Hamalainen <ccr@tnsp.org>
parents: 426
diff changeset
6 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
7
426
249631e194c8 Bump db version again.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
8 $dbVersion = 10;
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
9
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
10 $dbMeta = array(
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
11 "dbVersion" => array(VT_INT, $dbVersion, "Database version"),
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
12 );
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
13
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
499
408effd4e9ea Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 490
diff changeset
15 //
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 // The defaults we put in
499
408effd4e9ea Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 490
diff changeset
17 //
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 $siteDefaults = array(
268
feed47a72df4 Update some setting descriptions.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
19 "maxAttendeesHard" => array(VT_INT, 60, "Maximum attendees (HARD limit, <= 0 means no limit)"),
feed47a72df4 Update some setting descriptions.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
20 "maxAttendeesSoft" => array(VT_INT, 50, "Maximum attendees (soft limit, <= 0 means no limit)"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
158
96aae4beb558 Clean up some references to entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
22 "userTimeout" => array(VT_INT, 120, "User pages (voting) timeout in minutes"),
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
23 "admTimeout" => array(VT_INT, 15, "Administration interface timeout in minutes"),
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
24
62
101cde58b267 Add a new setting for ASCII vs. HTML table output for compo results.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
25 "showAdmin" => array(VT_BOOL, false, "Always show administration interface link on the menu"),
119
99e7569c9f4f Change the default of some boolean settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
26 "showAttendees" => array(VT_BOOL, true, "Show attendees list"),
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
27 "allowRegister" => array(VT_BOOL, false, "Enable event registration"),
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
28 "allowVoting" => array(VT_BOOL, false, "Enable voting (individual compos must be enabled as well)"),
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
29
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
30 "showResults" => array(VT_BOOL, false, "Enable results page"),
62
101cde58b267 Add a new setting for ASCII vs. HTML table output for compo results.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
31 "showResultsASCII" => array(VT_BOOL, true, "Show results as ASCII instead of HTML table"),
119
99e7569c9f4f Change the default of some boolean settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
32 "showResAuthors" => array(VT_BOOL, true, "Show entry authors on results page"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
34 "requireEMail" => array(VT_BOOL, false, "Require e-mail address in registrations"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
35
123
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
36 "showNews" => array(VT_BOOL, true, "Enable News link on main menu"),
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
37 "showNewsOnAbout" => array(VT_BOOL, true, "Show latest news item on About page"),
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
38
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
39 "registerInfoText" => array(VT_TEXT, "<p>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
40 Only your <b>handle</b> and the answer to the botcheck are strictly required.
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
41 If you plan on joining the IRC channel
63
922b5192b2ff Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
42 (<a href=\"irc://#fap2013@ircnet\">#fap2013 @ IRCNet</a>) or staying up to date by other means,
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
43 <b>e-mail</b> is not required either.
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
44 </p>", "Registration page info text"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
45
182
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
46 "registerPostText" => array(VT_TEXT, "
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
47 <h1>Registration successful</h1>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
48 <p>Now go make a demo about it!</p>",
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
49 "Successful post-registration note text"),
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
50
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
51 "registerLimitExceeded" => array(VT_TEXT, "
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
52 <h1>Sorry, registration disabled!</h1>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
53 <p>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
54 Registration to the event is not available at this time due to
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
55 number of attendees limit having been reached. <b>:(</b>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
56 </p>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
57 ",
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
58 "Registration attendee limit exceeded note text"),
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
59
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
60 "registerNotEnabled" => array(VT_TEXT, "
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
61 <h1>Sorry, registration disabled!</h1>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
62 <p>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
63 Registration to the event is not enabled at this time.
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
64 </p>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
65 ",
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
66 "Registration not enabled note text"),
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
67
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
68 "registerPostNoEmail" => array(VT_TEXT, "
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
69 <h2>By the way ...</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
70 <p>As you did not specify an e-mail contact address, you'll have to get updates
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
71 and information about the location (if you don't already know it) by
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
72 some other means (IRC, for example.)</p>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
73 ", "No e-mail address registration note"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
74
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
75 "eventDescription" => array(VT_TEXT, "
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
76 <h1>Event program &amp; schedule</h1>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
77 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
78 <li><b>Aegis</b> of DSS and FAG will be performing a DJ gig.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
79 <li>.. and possible additional live acts. More info to come.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
80 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
81
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
82 <h2>Friday 30.11.</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
83 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
84 <li><b>18:00</b> - <i>Doors open</i>.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
85 <li><b>22:00</b> - DJ set by Aegis.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
86 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
87
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
88 <h2>Saturday 1.12.</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
89 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
90 <li><b>14:00</b> - Deadline for remote entries.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
91 <li><b>18:00</b> - Deadline for the entries delivered on location.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
92 <li><b>20:00</b> - Competitions start.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
93 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
94
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
95 Competition schedule and voting deadline will depend on number of entries.
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
96
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
97 <h2>Sunday 2.12.</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
98 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
99 <li><b>12:00</b> - Party over?</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
100 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
101 ", "Event general description / timetables etc."),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
102
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
103
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
104 "compoDescription" => array(VT_TEXT, "
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
105 <h1>General</h1>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
106 <p class=\"notice\">
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
107 YOU <b>MUST</b> HAVE AT LEAST ONE ENTRY TO COMPETITIONS IF YOU COME TO THE PARTY.
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
108 </p>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
109
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
110 <p class=\"note\">
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
111 If there are enough entries, then AGA/OCS/ECS demos will be run in separate compos.
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
112 <br />
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
113 Remote entries are welcome!
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
114 </p>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
115
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
116 <p>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
117 The compo machine will be an <b>A1200 with an 060/50 and lots of
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
118 RAM</b>. An <b>A500 1.3 512k/512k</b> will also be available if your
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
119 prod is not AGA compatible.
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
120 </p>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
121
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
122 <h1>Compos</h1>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
123 ", "Compo general description"),
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
124
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
125
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
126 "siteInfoText" => array(VT_TEXT, "
150
4b91002a9900 Fix default header image link.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
127 <a href=\"about\">
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
128 <img src=\"img/fapsm.png\" alt=\"Finnish Amiga Party 2013\" class=\"logo\" /></a>
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
129 <div id=\"date\">
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
130 5.-8.12.2013<br />
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
131 Helsinki, Finland<br />
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
132 @ old location<br />
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
133 <span class=\"notice\">Entry 15 EUR + prod</span>
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
134 </div>", "Site header text"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
135
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
136
123
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
137 "newsHeader" => array(VT_TEXT, "", "News page header text"),
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
138
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
139
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
140 "aboutDescription" => array(VT_TEXT, "
9
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
141 <div style=\"text-align: center;\">
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
142 <img src=\"img/fap.png\" alt=\"FAP\" />
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
143 <p>
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
144 Pure Amiga demoscene party, all traditional Amiga compos and purely Amiga-oriented program.
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
145 <br />
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
146 <span class=\"notice\">
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
147 YOU <b>MUST</b> HAVE AT LEAST ONE ENTRY TO COMPETITIONS IF YOU COME TO THE PARTY.
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
148 </span>
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
149 </p>
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
150 </div>",
123
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
151 "About page text"),
29
4b5a176805e2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
152
224
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
153 "voteFinishedText" => array(VT_TEXT, "
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
154 <h1>Yay, you have voted!</h1>
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
155 <p>Now go FAP some more! And make a demo about it.</p>",
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
156 "Message shown after successful voting."),
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
157
104
c7b1eb993240 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
158 "siteMenuHeader" => array(VT_TEXT, "<div>13.FAP:&gt; <span class=\"mblink\">&#9632;</span></div>", "Site menu header text"),
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
159 "siteMenuFooter" => array(VT_TEXT, "", "Site menu footer text"),
106
324f3a415237 Add extra HTML + sponsors box to layout.
Matti Hamalainen <ccr@tnsp.org>
parents: 104
diff changeset
160 "siteExtraHTML" => array(VT_TEXT, "<div id=\"sponsors\">Gentle Eye</div>", "Extra global HTML code (f.e. sponsors box)"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 );
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 $sqlTables = array(
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
164 //
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
165 // Database metadata
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
166 //
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
167 "dbmeta" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
168 array("key" , "VARCHAR(32)", "PRIMARY KEY"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
169 array("vtype" , "INTEGER"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
170 array("vstr" , "VARCHAR(128)"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
171 array("vtext" , "TEXT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
172 array("vint" , "INTEGER"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
173 array("desc" , "VARCHAR(128)"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
174 ),
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
175
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
176 //
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
177 // Site settings
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
178 //
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
179 "settings" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
180 array("key" , "VARCHAR(32)", "PRIMARY KEY"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
181 array("vtype" , "INTEGER"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
182 array("vstr" , "VARCHAR(128)"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
183 array("vtext" , "TEXT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
184 array("vint" , "INTEGER"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
185 array("desc" , "VARCHAR(128)"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
186 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
187
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
188 "news" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
189 array("id" , "INTEGER", "PRIMARY KEY AUTOINCREMENT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
190 array("utime" , "INTEGER"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
191 array("title" , "VARCHAR(".SET_LEN_NEWS_TITLE.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
192 array("text" , "VARCHAR(".SET_LEN_NEWS_TEXT.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
193 array("author" , "VARCHAR(".SET_LEN_NEWS_AUTHOR.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
194 array("persist" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
195 ),
73
c70c2650f790 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
196
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
197 "compos" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
198 array("id" , "INTEGER", "PRIMARY KEY AUTOINCREMENT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
199 array("name" , "VARCHAR(".SET_LEN_COMPO_NAME.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
200 array("description" , "VARCHAR(".SET_LEN_COMPO_DESC.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
201 array("visible" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
202 array("voting" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
203 array("showAuthors" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
204 array("type" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
205 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
206
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
207 "entries" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
208 array("id" , "INTEGER", "PRIMARY KEY AUTOINCREMENT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
209 array("show_id" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
210 array("name" , "VARCHAR(".SET_LEN_ENTRY_NAME.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
211 array("author" , "VARCHAR(".SET_LEN_ENTRY_AUTHOR.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
212 array("compo_id" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
213 array("filename" , "VARCHAR(".SET_LEN_ENTRY_FILENAME.")", "DEFAULT NULL"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
214 array("info" , "VARCHAR(".SET_LEN_ENTRY_INFO.")", "DEFAULT NULL"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
215 array("flags" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
216 ),
73
c70c2650f790 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
217
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
218 "attendees" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
219 array("id" , "INTEGER", "PRIMARY KEY AUTOINCREMENT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
220 array("regtime" , "INTEGER"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
221 array("name" , "VARCHAR(".SET_LEN_USERNAME.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
222 array("groups" , "VARCHAR(".SET_LEN_GROUPS.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
223 array("oneliner" , "VARCHAR(".SET_LEN_ONELINER.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
224 array("email" , "VARCHAR(".SET_LEN_EMAIL.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
225 array("key_id" , "INTEGER", "DEFAULT NULL"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
226 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
227
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
228 "votekeys" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
229 array("id" , "INTEGER", "PRIMARY KEY AUTOINCREMENT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
230 array("key" , "VARCHAR(".SET_LEN_VOTEKEY.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
231 array("active" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
232 ),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
233
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
234 "votes" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
235 array("id" , "INTEGER", "PRIMARY KEY AUTOINCREMENT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
236 array("entry_id" , "INTEGER", "DEFAULT NULL"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
237 array("key_id" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
238 array("value" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
239 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
240
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
241 //
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
242 // Information system tables
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
243 //
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
244 "displayVars" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
245 array("key" , "VARCHAR(32)", "PRIMARY KEY"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
246 array("vtype" , "INTEGER"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
247 array("vstr" , "VARCHAR(128)"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
248 array("vtext" , "TEXT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
249 array("vint" , "INTEGER"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
250 array("desc" , "VARCHAR(128)"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
251 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
252
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
253 "displaySlides" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
254 array("id" , "INTEGER", "PRIMARY KEY AUTOINCREMENT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
255 array("title" , "VARCHAR(".SET_LEN_DISP_SLIDE_TITLE.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
256 array("text" , "VARCHAR(".SET_LEN_DISP_SLIDE_TEXT.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
257 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
258
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
259 "rotationListData" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
260 array("id" , "INTEGER", "PRIMARY KEY AUTOINCREMENT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
261 array("name" , "VARCHAR(".SET_LEN_ROT_LIST_NAME.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
262 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
263
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
264 "rotationListSlides" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
265 array("id" , "INTEGER", "PRIMARY KEY AUTOINCREMENT"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
266 array("list_id" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
267 array("slide_id" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
268 array("order_num" , "INTEGER", "DEFAULT 0"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
269 ),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
270 );
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
271
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
272 $siteDisplayVars = array(
148
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
273 "showMode" => array(VT_INT, 0, "Currently active display mode"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
274 "rotateDuration" => array(VT_INT, 15, "Slide rotation time per slide (seconds)"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
275
393
14cdbeb331b6 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 355
diff changeset
276 "tempDuration" => array(VT_INT, 5, "Temporary slide display time (minutes)"),
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
277 "tempSlide" => array(VT_INT, 0, "Temporary slide ID"),
148
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
278
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
279 "compoID" => array(VT_INT, 0, "Compo ID of current compo"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
280 "compoPrevEntry" => array(VT_INT, 0, "Previously shown compo entry"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
281 "compoCurrEntry" => array(VT_INT, 0, "Current / next compo entry to be shown"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
282
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
283 // Not user-manageable
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
284 "tempSlideSet" => array(VT_BOOL, false, "Temporary slide set"),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
285
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
286 "activeSlideMode" => array(VT_INT, 0, "Current active slide display mode"),
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
287 "activeSlide" => array(VT_INT, 0, "Current active slide"),
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
288 "activeSlideExpire" => array(VT_INT, 0, "Expiration timestamp of current slide"),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
289
142
d2e9285b69ad More work on the party info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
290 "rotateList" => array(VT_INT, 0, "Current rotation list ID"),
d2e9285b69ad More work on the party info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
291 "rotateListIndex" => array(VT_INT, 0, "Current index in rotation list"),
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
292
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
293 "lastUpdate" => array(VT_INT, 0, "Timestamp of last slide update"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 );
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
296 $siteTestData = array(
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
297 "news" => array(
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
298 "utime,title,text,author",
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
299 time().",%s,%s,%s",
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
300 array("Today's news", "We. Are. Back.", "orgaz"),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
301 array("Good news, everybody!", "...", "The Professor"),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
302 ),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
303
88
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
304 "votekeys" => array(
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
305 "key",
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
306 "%s",
120
2c594958050e Make test vote keys "testN" where N >= 1
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
307 array("test1"),
2c594958050e Make test vote keys "testN" where N >= 1
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
308 array("test2"),
88
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
309 array("7jjnqt5z"),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
310 array("c7jcfk1G"),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
311 ),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
312
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
313 "attendees" => array(
88
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
314 "regtime,name,groups,oneliner,email",
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
315 "%d,%s,%s,%s,%s",
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
316 array(time()-0, "man with no alias", "supergroup", "foo-bar", "c@supergroup.com"),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
317 array(time()-15, "man with alias", "supergroup", "hi!", "c@supergroup.com"),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
318 array(time()-30, "alias with a man", "supergroup", "mega super kewl rulets", "x@microsoft.com"),
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
319 ),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
320
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
321 "compos" => array(
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
322 "name,description,visible,voting",
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
323 "%s,%s,1,1",
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
324 array("Graphics", "Anything in standard resolutions."),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
325 array("Protracker music", "Standard 4-channel Protracker MOD music."),
170
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
326 array("4k intro", "4k intro competition"),
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
327 ),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
328
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
329 "entries" => array(
170
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
330 "name,author,compo_id,filename,info",
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
331 "%s,%s,%d,%s,%s",
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
332 array("Donkey Dong", "electric/extend", 1, "donkey.lbm", "amigaaaah!"),
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
333 array("Your kondom", "ccr/TNSP", 1, "kondom.lbm", "oh my god, it's full of cocks!"),
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
334 array("Penis song", "reed/flt", 2, "penis.mod", "laulu rakkaudelle"),
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
335 array("jenkka", "aegis", 2, "jenkka.mod", ""),
220
db433a1d22b4 Fix test data creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
336 array("Fungiform 2", "mfx", 3, "mfx-fungiform2.lzh", "OCS-only"),
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
337 ),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
338
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
339 "displaySlides" => array(
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
340 "title,text",
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
341 "%s,%s",
414
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
342 array("Next Up 4k", "<h1>Next up: 4k intro</h1><h2>4k intro compo is about to begin</h2>... in about 10 minutes."),
142
d2e9285b69ad More work on the party info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
343 array("Astu to infodesk", "<b>Astu</b> - please come to info desk!"),
d2e9285b69ad More work on the party info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
344 array("Gentle Eye mainos", "<b>Buy Amiga stuff!</b><br />Gentle Eye Oy is selling Amiga-related stuff near organizer desk!"),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
345 ),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
346
416
876846d8ed5b Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents: 414
diff changeset
347 "rotationListData" => array(
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
348 "name",
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
349 "%s",
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
350 array("Main rotation"),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
351 array("Next Up"),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
352 ),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
353
416
876846d8ed5b Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents: 414
diff changeset
354 "rotationListSlides" => array(
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
355 "list_id,slide_id",
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
356 "%d,%d",
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
357 array(1,2),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
358 array(1,3),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
359 array(2,1),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
360 ),
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
361 );
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362
88
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
363
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 //
36
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
365 // Helper functions
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 //
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
367 function stGetTableSchema($data)
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
368 {
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
369 $res = array();
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
370
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
371 foreach ($data as $col)
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
372 $res[] = implode(" ", $col);
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
373
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
374 return implode(", ", $res);
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
375 }
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
376
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
377
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
378 function stCreateOneTable($dbh, $name, $schema)
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
379 {
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
380 return (stDBExecSQL($dbh, "CREATE TABLE IF NOT EXISTS ".$name." (".$schema.")") !== FALSE) ? TRUE : FALSE;
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
381 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
382
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
383
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
384 function stCreateTables($dbh, $upgrade)
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 global $sqlTables;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 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
388 foreach ($sqlTables as $name => $schemaData)
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 echo " - '".$name."'\n";
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
391 if (!stCreateOneTable($dbh, $name, stGetTableSchema($schemaData)) && !$upgrade)
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 return FALSE;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 return TRUE;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
398 $upgradeMappings = array(
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
399 // "" => array("key" => "", value => ""),
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
400 );
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
401
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
402
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
403 function stUpgradeMap($type, $name, $value = FALSE)
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 global $upgradeMappings;
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
406
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
407 if (isset($upgradeMappings[$name]))
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
408 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
409 if (isset($upgradeMappings[$name][$type]))
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
410 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
411 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
412 else
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
413 die("Upgrade failed due to missing or invalid upgrade definition: ".$type." ".$name." from version X to Y.\n");
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
414 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
415 else
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
416 switch ($type)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
417 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
418 case "key": return $name;
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
419 case "value": return $value;
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
420 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
421 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
422
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
423
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
424 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
425 {
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
426 echo ($upgrade ? "Adding settings to" : "Upgrading settings in")." '".$table."' table.";
80
e51205f2bdd0 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
427
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
428 foreach ($settings as $key => $data)
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
429 {
80
e51205f2bdd0 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
430 switch ($data[0])
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
431 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432 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
433 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
434 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
435 case VT_INT: $type = "%d"; $var = "vint"; break;
80
e51205f2bdd0 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
436 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
437 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
439 $inKey = stUpgradeMap("key", $key);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
440
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
441 if ($upgrade && ($res = stDBFetchSQL($inDB, stDBPrepareSQL($inDB, "SELECT * FROM ".$table." WHERE key=%s", $inKey))) !== FALSE)
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
442 {
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
443 echo ".";
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
444
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
445 if ($res["vtype"] != $data[0])
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
446 die("Oops! Data type of '".$key."' does not match in table '".$table.". DB upgrade failed.\n");
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
447
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
448 $sql = stDBPrepareSQL($outDB,
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
449 "INSERT INTO ".$table." (key,vtype,".$var.",desc) VALUES (%s,%d,".$type.",%s)",
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
450 $key, $data[0], stUpgradeMap("value", $key, $res[$var]), $data[2]);
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
451 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
452 else
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
453 {
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
454 echo "+";
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
455 $sql = stDBPrepareSQL($outDB,
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
456 "INSERT INTO ".$table." (key,vtype,".$var.",desc) VALUES (%s,%d,".$type.",%s)",
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
457 $key, $data[0], $data[1], $data[2]);
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
458 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
459
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
460 if (stDBExecSQL($outDB, $sql) === FALSE)
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
461 return FALSE;
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
462 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
463 echo "\n";
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
464 return TRUE;
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
465 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
466
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
467
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
468 function stAddTestData($dbh)
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
469 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
470 global $siteTestData;
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
471 echo "Adding test data.\n";
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
472
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
473 foreach ($siteTestData as $table => $data)
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
474 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
475 echo " - ".$table."...\n";
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
476 if (count($data) >= 3)
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
477 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
478 for ($n = 2; $n < count($data); $n++)
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
479 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
480 $arr = array_merge(
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
481 array($dbh, "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
482 $data[$n]);
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
483
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
484 $sql = call_user_func_array('stDBPrepareSQL', $arr);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
485 stDBExecSQL($dbh, $sql);
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
486 }
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
487 }
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
488 else
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
489 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
490 echo " Invalid table / data definition.\n";
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
491 }
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
492 }
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
493 }
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
494
499
408effd4e9ea Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 490
diff changeset
495
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
496 function stGetSQLTypeParam($dbh, $def, $value)
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
497 {
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
498 switch (substr($def, 0, 3))
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
499 {
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
500 case "INT":
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
501 return intval($value);
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
502
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
503 case "VAR":
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
504 case "TEX":
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
505 return $dbh->quote($value);
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
506
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
507 default: die("Unknown type ".$col[1].".\n");
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
508 }
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
509 }
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
510
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
511 function stMigrateTables($inDB, $outDB, $excluded)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
512 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
513 global $sqlTables;
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
514 echo "Migrating tables...\n";
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
515 foreach ($sqlTables as $name => $schema)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
516 if (!in_array($name, $excluded))
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
517 {
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
518 echo " - '".$name."' ";
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
519
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
520 foreach (stDBExecSQL($inDB, "SELECT * FROM ".$name) as $row)
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
521 {
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
522 $avals = array();
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
523 $acols = array();
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
524
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
525 foreach ($schema as $col)
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
526 {
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
527 if (isset($row[$col[0]]))
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
528 {
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
529 $avals[] = stGetSQLTypeParam($outDB, $col[1], $row[$col[0]]);
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
530 $acols[] = $col[0];
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
531 }
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
532 }
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
533
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
534 $sql = "INSERT INTO ".$name." (".implode(",", $acols).") VALUES (".implode(",", $avals).")";
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
535 if (stDBExecSQL($outDB, $sql) === false) die("Error!");
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
536 echo ".";
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
537 }
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
538 echo "\n";
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
539 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
540 return TRUE;
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
541 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
542
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
543
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
544 function stSetDBPermissions($spec)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
545 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
546 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
547 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
548 $filename = substr($spec, 7);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
549 echo
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
550 "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
551 "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
552 "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
553 "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
554
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
555 if (chmod($filename, 0600) === FALSE)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
556 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
557 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
558 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
559 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
560 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
561
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
562
36
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
563 //
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
564 // Main program starts
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
565 //
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 if ($argc < 2)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
567 {
482
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
568 echo
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
569 "CreateDB - Manage FAPWeb SQL database\n".
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
570 "(C) Copyright 2012-2013 ccr/TNSP\n".
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
571 "\n".
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
572 "Usage: ".$argv[0]." <mode> [args]\n".
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
573 "Where mode is one of following:\n".
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
574 "\n".
482
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
575 " new 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
576 " 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
577 "\n".
482
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
578 " test 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
579 "\n".
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
580 " upgrade <output dbspec>\n".
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
581 " 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
582 " Output to new database (DO NOT USE SAME as current!)\n".
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
583 "\n";
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
584 exit;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
585 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
586
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
587
81
491c03e3a2bc Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
588 // Try to connect to database
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
589 $inSpec = stGetSetting("sqlDB");
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
590 if (($inDB = stConnectSQLDBSpec($inSpec)) === false)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
591 die("Could not connect to SQL database '".$inSpec."'.\n");
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
592
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
593 echo "Using INPUT database spec '".$inSpec."'.\n";
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
594
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
595
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
596 // Act according to specified command
489
aa65fe63072e Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 482
diff changeset
597 $addTestData = FALSE;
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
598 switch (stCArgLC(1))
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
599 {
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
600 case "test":
489
aa65fe63072e Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 482
diff changeset
601 $addTestData = TRUE;
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
602
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
603 case "new":
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
604 if (stCreateTables($inDB, FALSE))
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
605 {
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
606 stAddSettings($inDB, $inDB, $dbMeta, "dbmeta", FALSE);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
607 stAddSettings($inDB, $inDB, $siteDefaults, "settings", FALSE);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
608 stAddSettings($inDB, $inDB, $siteDisplayVars, "displayVars", FALSE);
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
609 }
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
610
489
aa65fe63072e Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 482
diff changeset
611 if ($addTestData)
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
612 stAddTestData($inDB);
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
613
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
614 stSetDBPermissions($inSpec);
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
615 break;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
616
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
617 case "upgrade":
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
618 //
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
619 // Attempt to upgrade database
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
620 //
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
621 // Check the current version first ...
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
622 if (($currVersion = stGetDBMeta($inDB, "dbVersion")) === FALSE)
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
623 $currVersion = -1;
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
624
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
625 if ($currVersion == $dbVersion)
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
626 {
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
627 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
628 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
629 else
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
630 {
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
631 // 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
632 if ($argc < 3)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
633 die("Usage: ".$argv[0]." upgrade <output dbspec>\n");
355
4ced04d29858 Database format change.
Matti Hamalainen <ccr@tnsp.org>
parents: 301
diff changeset
634
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
635 $outSpec = stCArg(2);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
636 if ($outSpec == $inSpec)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
637 die("The input and output databases CAN NOT BE SAME.\n");
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
638
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
639 if (($outDB = stConnectSQLDBSpec($outSpec)) === false)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
640 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
641
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
642 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
643 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
644
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
645 // Possibly bail out incompatible upgrades here
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
646
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
647 // Create tables
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
648 if (!stCreateTables($outDB, TRUE))
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
649 exit;
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
650
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
651 // Migrate data from setting tables ..
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
652 if (!stAddSettings($inDB, $outDB, $siteDefaults, "settings", TRUE))
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
653 exit;
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
654
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
655 if (!stAddSettings($inDB, $outDB, $siteDisplayVars, "displayVars", TRUE))
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
656 exit;
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
657
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
658 stAddSettings($inDB, $outDB, $dbMeta, "dbmeta", TRUE);
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
659
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
660 // Migrate other tables
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
661 if (!stMigrateTables($inDB, $outDB, array("settings", "displayVars", "dbmeta")))
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
662 exit;
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
663
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
664 echo "Setting dbVersion.\n";
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
665 stSetDBMeta($outDB, "dbVersion", $dbVersion);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
666 echo "Upgrade complete.\n";
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
667
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
668 stSetDBPermissions($inSpec);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
669 stSetDBPermissions($outSpec);
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
670 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
671 break;
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
672
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
673 default:
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
674 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
675 break;
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
676 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
677
28
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
678
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
679 //
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
680 // Clean up permissions
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
681 //
67
23eba98e1575 Remove keygen.php from permission cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
682 foreach (array("createdb.php") as $filename)
28
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
683 {
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
684 if (chmod($filename, 0700) === FALSE)
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
685 {
490
505f46b8bb14 Separate variable from string flow.
Matti Hamalainen <ccr@tnsp.org>
parents: 489
diff changeset
686 echo "ERROR! Could not set permissions for '".$filename."'!\n";
28
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
687 }
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
688 }
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
689
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
690 ?>