Mercurial > hg > fapweb
annotate createdb.php @ 426:249631e194c8
Bump db version again.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Dec 2013 20:21:55 +0200 |
parents | e9f374334efd |
children | 86ee2b42a995 |
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 |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
6 |
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 // Check if we are running from commandline or not |
184a4188555c
Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
8 if (php_sapi_name() != "cli" || !empty($_SERVER["REMOTE_ADDR"])) |
184a4188555c
Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
9 { |
184a4188555c
Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
10 header("Status: 404 Not Found"); |
184a4188555c
Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
11 die(); |
184a4188555c
Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
12 } |
184a4188555c
Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
47
diff
changeset
|
13 |
426 | 14 $dbVersion = 10; |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
15 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
16 $dbMeta = array( |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
17 "dbVersion" => array(VT_INT, $dbVersion, "Database version"), |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
18 ); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
19 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 // The defaults we put in |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 $siteDefaults = array( |
268
feed47a72df4
Update some setting descriptions.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
23 "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
|
24 "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
|
25 |
158
96aae4beb558
Clean up some references to entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
26 "userTimeout" => array(VT_INT, 120, "User pages (voting) timeout in minutes"), |
32 | 27 "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
|
28 |
62
101cde58b267
Add a new setting for ASCII vs. HTML table output for compo results.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
29 "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
|
30 "showAttendees" => array(VT_BOOL, true, "Show attendees list"), |
11
c10bf196390f
Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
31 "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
|
32 "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
|
33 |
11
c10bf196390f
Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
34 "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
|
35 "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
|
36 "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
|
37 |
16 | 38 "requireEMail" => array(VT_BOOL, false, "Require e-mail address in registrations"), |
39 | |
123
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
40 "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
|
41 "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
|
42 |
16 | 43 "registerInfoText" => array(VT_TEXT, "<p> |
44 Only your <b>handle</b> and the answer to the botcheck are strictly required. | |
45 If you plan on joining the IRC channel | |
63 | 46 (<a href=\"irc://#fap2013@ircnet\">#fap2013 @ IRCNet</a>) or staying up to date by other means, |
16 | 47 <b>e-mail</b> is not required either. |
48 </p>", "Registration page info text"), | |
49 | |
182
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
50 "registerPostText" => array(VT_TEXT, " |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
51 <h1>Registration successful</h1> |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
52 <p>Now go make a demo about it!</p>", |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
53 "Successful post-registration note text"), |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
54 |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
55 "registerLimitExceeded" => array(VT_TEXT, " |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
56 <h1>Sorry, registration disabled!</h1> |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
57 <p> |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
58 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
|
59 number of attendees limit having been reached. <b>:(</b> |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
60 </p> |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
61 ", |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
62 "Registration attendee limit exceeded note text"), |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
63 |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
64 "registerNotEnabled" => array(VT_TEXT, " |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
65 <h1>Sorry, registration disabled!</h1> |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
66 <p> |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
67 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
|
68 </p> |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
69 ", |
e227e6a3d46b
Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
70 "Registration not enabled note text"), |
16 | 71 |
72 "registerPostNoEmail" => array(VT_TEXT, " | |
73 <h2>By the way ...</h2> | |
74 <p>As you did not specify an e-mail contact address, you'll have to get updates | |
75 and information about the location (if you don't already know it) by | |
76 some other means (IRC, for example.)</p> | |
77 ", "No e-mail address registration note"), | |
78 | |
79 "eventDescription" => array(VT_TEXT, " | |
80 <h1>Event program & schedule</h1> | |
81 <ul> | |
82 <li><b>Aegis</b> of DSS and FAG will be performing a DJ gig.</li> | |
83 <li>.. and possible additional live acts. More info to come.</li> | |
84 </ul> | |
85 | |
86 <h2>Friday 30.11.</h2> | |
87 <ul> | |
88 <li><b>18:00</b> - <i>Doors open</i>.</li> | |
89 <li><b>22:00</b> - DJ set by Aegis.</li> | |
90 </ul> | |
91 | |
92 <h2>Saturday 1.12.</h2> | |
93 <ul> | |
94 <li><b>14:00</b> - Deadline for remote entries.</li> | |
95 <li><b>18:00</b> - Deadline for the entries delivered on location.</li> | |
96 <li><b>20:00</b> - Competitions start.</li> | |
97 </ul> | |
98 | |
99 Competition schedule and voting deadline will depend on number of entries. | |
100 | |
101 <h2>Sunday 2.12.</h2> | |
102 <ul> | |
103 <li><b>12:00</b> - Party over?</li> | |
104 </ul> | |
105 ", "Event general description / timetables etc."), | |
106 | |
107 | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
108 "compoDescription" => array(VT_TEXT, " |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
109 <h1>General</h1> |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
110 <p class=\"notice\"> |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
111 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
|
112 </p> |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
113 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
114 <p class=\"note\"> |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
115 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
|
116 <br /> |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
117 Remote entries are welcome! |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
118 </p> |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
119 |
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 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
|
122 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
|
123 prod is not AGA compatible. |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
124 </p> |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
125 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
126 <h1>Compos</h1> |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
127 ", "Compo general description"), |
16 | 128 |
129 | |
130 "siteInfoText" => array(VT_TEXT, " | |
150
4b91002a9900
Fix default header image link.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
131 <a href=\"about\"> |
47 | 132 <img src=\"img/fapsm.png\" alt=\"Finnish Amiga Party 2013\" class=\"logo\" /></a> |
16 | 133 <div id=\"date\"> |
47 | 134 5.-8.12.2013<br /> |
16 | 135 Helsinki, Finland<br /> |
136 @ old location<br /> | |
47 | 137 <span class=\"notice\">Entry 15 EUR + prod</span> |
16 | 138 </div>", "Site header text"), |
139 | |
140 | |
123
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
141 "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
|
142 |
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
143 |
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
144 "aboutDescription" => array(VT_TEXT, " |
9
fa9b66f596bb
More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
145 <div style=\"text-align: center;\"> |
fa9b66f596bb
More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
146 <img src=\"img/fap.png\" alt=\"FAP\" /> |
fa9b66f596bb
More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
147 <p> |
fa9b66f596bb
More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
148 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
|
149 <br /> |
fa9b66f596bb
More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
150 <span class=\"notice\"> |
fa9b66f596bb
More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
151 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
|
152 </span> |
fa9b66f596bb
More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
153 </p> |
11
c10bf196390f
Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
154 </div>", |
123
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
120
diff
changeset
|
155 "About page text"), |
29 | 156 |
224
0daedbef5678
Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents:
220
diff
changeset
|
157 "voteFinishedText" => array(VT_TEXT, " |
0daedbef5678
Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents:
220
diff
changeset
|
158 <h1>Yay, you have voted!</h1> |
0daedbef5678
Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents:
220
diff
changeset
|
159 <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
|
160 "Message shown after successful voting."), |
0daedbef5678
Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents:
220
diff
changeset
|
161 |
104 | 162 "siteMenuHeader" => array(VT_TEXT, "<div>13.FAP:> <span class=\"mblink\">■</span></div>", "Site menu header text"), |
47 | 163 "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
|
164 "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
|
165 ); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 $sqlTables = array( |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
168 "dbmeta" => "key VARCHAR(32) PRIMARY KEY, vtype INT, vstr VARCHAR(128), vtext TEXT, vint INT, desc VARCHAR(128)", |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
169 |
73 | 170 "settings" => "key VARCHAR(32) PRIMARY KEY, vtype INT, vstr VARCHAR(128), vtext TEXT, vint INT, desc VARCHAR(128)", |
185
449b2862cc75
Use field sizes in database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
171 "news" => "id INTEGER PRIMARY KEY AUTOINCREMENT, utime INT, title VARCHAR(".SET_LEN_NEWS_TITLE."), text VARCHAR(".SET_LEN_NEWS_TEXT."), author VARCHAR(".SET_LEN_NEWS_AUTHOR."), persist INT DEFAULT 0", |
449b2862cc75
Use field sizes in database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
172 "compos" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(".SET_LEN_COMPO_NAME."), description VARCHAR(".SET_LEN_COMPO_DESC."), visible INT DEFAULT 0, voting INT DEFAULT 0, showAuthors INT DEFAULT 0", |
449b2862cc75
Use field sizes in database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
173 "entries" => "id INTEGER PRIMARY KEY AUTOINCREMENT, show_id INT DEFAULT 0, name VARCHAR(".SET_LEN_ENTRY_NAME."), author VARCHAR(".SET_LEN_ENTRY_AUTHOR."), compo_id INT DEFAULT NULL, filename VARCHAR(".SET_LEN_ENTRY_FILENAME.") DEFAULT NULL, info VARCHAR(".SET_LEN_ENTRY_INFO.") DEFAULT NULL", |
73 | 174 |
185
449b2862cc75
Use field sizes in database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
175 "attendees" => "id INTEGER PRIMARY KEY AUTOINCREMENT, regtime INT, name VARCHAR(".SET_LEN_USERNAME."), groups VARCHAR(".SET_LEN_GROUPS."), oneliner VARCHAR(".SET_LEN_ONELINER."), email VARCHAR(".SET_LEN_EMAIL."), key_id INT DEFAULT NULL", |
73 | 176 |
88
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
177 "votekeys" => "id INTEGER PRIMARY KEY AUTOINCREMENT, key VARCHAR(64), active INT DEFAULT 0", |
301
e13be68e73a7
Layout of the votes table has changed, so add an upgrade path.
Matti Hamalainen <ccr@tnsp.org>
parents:
268
diff
changeset
|
178 "votes" => "id INTEGER PRIMARY KEY AUTOINCREMENT, entry_id INT DEFAULT NULL, key_id INT DEFAULT NULL, value INT DEFAULT 0", |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
179 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
180 "displayVars" => "key VARCHAR(32) PRIMARY KEY, vtype INT, vstr VARCHAR(128), vtext TEXT, vint INT, desc VARCHAR(128)", |
420
e9f6e242c4b9
Define some more SQL field lengths.
Matti Hamalainen <ccr@tnsp.org>
parents:
416
diff
changeset
|
181 "displaySlides" => "id INTEGER PRIMARY KEY AUTOINCREMENT, title VARCHAR(".SET_LEN_DISP_SLIDE_TITLE."), text VARCHAR(".SET_LEN_DISP_SLIDE_TEXT.")", |
e9f6e242c4b9
Define some more SQL field lengths.
Matti Hamalainen <ccr@tnsp.org>
parents:
416
diff
changeset
|
182 "rotationListData" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(".SET_LEN_ROT_LIST_NAME.")", |
416
876846d8ed5b
Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
183 "rotationListSlides" => "id INTEGER PRIMARY KEY AUTOINCREMENT, list_id INT DEFAULT 0, slide_id INT DEFAULT 0, order_num INT DEFAULT 0", |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
184 ); |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
185 |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
186 $siteDisplayVars = array( |
148
6d4325451570
And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents:
145
diff
changeset
|
187 "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
|
188 "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
|
189 |
393 | 190 "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
|
191 "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
|
192 |
6d4325451570
And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents:
145
diff
changeset
|
193 "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
|
194 "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
|
195 "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
|
196 |
6d4325451570
And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents:
145
diff
changeset
|
197 // Not user-manageable |
145
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
198 "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
|
199 |
140
20ca8edfb01a
Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
200 "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
|
201 "activeSlide" => array(VT_INT, 0, "Current active slide"), |
20ca8edfb01a
Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
202 "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
|
203 |
142
d2e9285b69ad
More work on the party info system.
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
204 "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
|
205 "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
|
206 |
66b485431cac
Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
207 "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
|
208 ); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
209 |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
210 $siteTestData = array( |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
211 "news" => array( |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
212 "utime,title,text,author", |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
213 time().",%s,%s,%s", |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
214 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
|
215 array("Good news, everybody!", "...", "The Professor"), |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
216 ), |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
217 |
88
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
218 "votekeys" => array( |
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
219 "key", |
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
220 "%s", |
120
2c594958050e
Make test vote keys "testN" where N >= 1
Matti Hamalainen <ccr@tnsp.org>
parents:
119
diff
changeset
|
221 array("test1"), |
2c594958050e
Make test vote keys "testN" where N >= 1
Matti Hamalainen <ccr@tnsp.org>
parents:
119
diff
changeset
|
222 array("test2"), |
88
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
223 array("7jjnqt5z"), |
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
224 array("c7jcfk1G"), |
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
225 ), |
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
226 |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
227 "attendees" => array( |
88
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
228 "regtime,name,groups,oneliner,email", |
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
229 "%d,%s,%s,%s,%s", |
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 ), |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
234 |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
235 "compos" => array( |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
236 "name,description,visible,voting", |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
237 "%s,%s,1,1", |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
238 array("Graphics", "Anything in standard resolutions."), |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
239 array("Protracker music", "Standard 4-channel Protracker MOD music."), |
170 | 240 array("4k intro", "4k intro competition"), |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
241 ), |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
242 |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
243 "entries" => array( |
170 | 244 "name,author,compo_id,filename,info", |
245 "%s,%s,%d,%s,%s", | |
246 array("Donkey Dong", "electric/extend", 1, "donkey.lbm", "amigaaaah!"), | |
247 array("Your kondom", "ccr/TNSP", 1, "kondom.lbm", "oh my god, it's full of cocks!"), | |
248 array("Penis song", "reed/flt", 2, "penis.mod", "laulu rakkaudelle"), | |
249 array("jenkka", "aegis", 2, "jenkka.mod", ""), | |
220 | 250 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
|
251 ), |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
252 |
140
20ca8edfb01a
Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
253 "displaySlides" => array( |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
254 "title,text", |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
255 "%s,%s", |
414 | 256 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
|
257 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
|
258 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
|
259 ), |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
260 |
416
876846d8ed5b
Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
261 "rotationListData" => array( |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
262 "name", |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
263 "%s", |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
264 array("Main rotation"), |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
265 array("Next Up"), |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
266 ), |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
267 |
416
876846d8ed5b
Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
268 "rotationListSlides" => array( |
140
20ca8edfb01a
Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
269 "list_id,slide_id", |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
270 "%d,%d", |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
271 array(1,2), |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
272 array(1,3), |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
273 array(2,1), |
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
274 ), |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
275 ); |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
276 |
88
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
277 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
278 // |
36 | 279 // Helper functions |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
280 // |
100 | 281 function stCArg($index) |
282 { | |
283 global $argc, $argv; | |
284 if ($index < $argc) | |
285 return $argv[$index]; | |
286 else | |
287 return FALSE; | |
288 } | |
289 | |
290 function stCArgLC($index) | |
291 { | |
292 global $argc, $argv; | |
293 if ($index < $argc) | |
294 return strtolower($argv[$index]); | |
295 else | |
296 return FALSE; | |
297 } | |
298 | |
299 | |
300 function stCSQLError($sql) | |
301 { | |
302 global $db; | |
303 die("Error executing SQL query: ".implode("; ", $db->errorInfo())." in statement \"".$sql."\"\n"); | |
304 exit; | |
305 } | |
306 | |
307 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
308 function stConnectDB($dbspec) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
309 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
310 global $db; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
311 try { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
312 $db = new PDO($dbspec); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
313 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
314 catch (PDOException $e) { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
315 error_log("Could not connect to SQL database '".$dbspec."': ".$e->getMessage()."."); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
316 return FALSE; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
317 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
318 return TRUE; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
319 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
320 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
321 |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
322 function stGetDBMeta($name) |
11
c10bf196390f
Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
323 { |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
324 global $db; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
325 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
326 if (($item = stFetchSQL("SELECT * FROM dbmeta WHERE key=".$db->quote($name))) === FALSE) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
327 return FALSE; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
328 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
329 return stGetSQLSettingData($item); |
11
c10bf196390f
Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
330 } |
c10bf196390f
Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
331 |
c10bf196390f
Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
332 |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
333 function stSetDBMeta($name, $value) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
334 { |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
335 global $db; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
336 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
337 if (($item = stFetchSQL("SELECT * FROM dbmeta WHERE key=".$db->quote($name))) === FALSE) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
338 return FALSE; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
339 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
340 $sql = "UPDATE dbmeta SET ".stGetSettingSQL($item, $value)." WHERE key=".$db->quote($name); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
341 return stExecSQL($sql); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
342 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
343 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
344 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
345 function stCreateOneTable($name, $schema) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
346 { |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
347 return (stExecSQL("CREATE TABLE IF NOT EXISTS ".$name." (".$schema.")") !== FALSE) ? TRUE : FALSE; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
348 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
349 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
350 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
351 function stCreateTables($upgrade) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
352 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
353 global $sqlTables; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
354 echo "Creating tables...\n"; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
355 foreach ($sqlTables as $name => $schema) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
356 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
357 echo " - '".$name."'\n"; |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
358 if (!stCreateOneTable($name, $schema) && !upgrade) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
359 return FALSE; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
360 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
361 return TRUE; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
362 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
363 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
364 |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
365 function stAddSettings($settings, $table, $upgrade) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 { |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
367 echo ($upgrade ? "Adding settings to" : "Upgrading settings in")." '".$table."' table."; |
80 | 368 |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
369 foreach ($settings as $key => $data) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
370 { |
80 | 371 switch ($data[0]) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
372 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
373 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
|
374 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
|
375 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
|
376 case VT_INT: $type = "%d"; $var = "vint"; break; |
80 | 377 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
|
378 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
379 |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
380 if ($upgrade && ($res = stFetchSQL(stPrepareSQL("SELECT * FROM ".$table." WHERE key=%s", $key))) !== FALSE) |
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 echo "."; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
383 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
384 if ($res["vtype"] != $data[0]) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
385 { |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
386 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
|
387 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
388 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
389 $sql = stPrepareSQL( |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
390 "UPDATE ".$table." SET desc=%s WHERE key=%s", |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
391 $data[2], $key); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
392 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
393 else |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
394 { |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
395 echo "+"; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
396 $sql = stPrepareSQL( |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
397 "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
|
398 $key, $data[0], $data[1], $data[2]); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
399 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
400 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
401 if (stExecSQL($sql) === FALSE) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
402 return FALSE; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
403 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
404 echo "\n"; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
405 return TRUE; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
406 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
407 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
408 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
409 function stRenameSettings($mapping, $table) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
410 { |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
411 echo "Upgrading '".$table."' table.\n"; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
412 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
413 foreach ($mapping as $from => $to) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
414 { |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
415 $sql = stPrepareSQL( |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
416 "UPDATE ".$table." SET key=%s WHERE key=%s", |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
417 $to, $from); |
80 | 418 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
419 stExecSQL($sql); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
420 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
421 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
422 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
423 |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
424 function stAddTestData() |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
425 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
426 global $siteTestData; |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
427 echo "Adding test data.\n"; |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
428 |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
429 foreach ($siteTestData as $table => $data) |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
430 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
431 echo " - ".$table."...\n"; |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
432 if (count($data) >= 3) |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
433 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
434 for ($n = 2; $n < count($data); $n++) |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
435 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
436 $arr = array_merge( |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
437 array("INSERT INTO ".$table." (".$data[0].") VALUES (".$data[1].")"), |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
438 $data[$n]); |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
439 |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
440 $sql = call_user_func_array('stPrepareSQL', $arr); |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
441 stExecSQL($sql); |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
442 } |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
443 } |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
444 else |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
445 { |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
446 echo " Invalid table / data definition.\n"; |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
447 } |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
448 } |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
449 } |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
450 |
36 | 451 // |
452 // Main program starts | |
453 // | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
454 if ($argc < 2) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
455 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
456 echo "Usage: ".$argv[0]." <mode> [args]\n". |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
457 "Where mode is one of following:\n". |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
458 "\n". |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
459 " new [dbspec] Create a new database with given PDO spec\n". |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
460 " 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
|
461 "\n". |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
462 " test [dbspec] Like new, but add initial test data.\n". |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
463 "\n". |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
464 " upgrade [dbspec] Upgrade current database, if possible.\n". |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
465 "\n"; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
466 exit; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
467 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
468 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
469 |
94
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
89
diff
changeset
|
470 if (!isset($siteSettings["voteKeyMode"]) || $siteSettings["voteKeyMode"] < 0) |
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
89
diff
changeset
|
471 { |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
472 echo |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
473 "FATAL ERROR! VoteKeyMode not set in site settings! This setting ". |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
474 "MUST be defined and should not be changed after database creation.\n"; |
94
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
89
diff
changeset
|
475 exit; |
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
89
diff
changeset
|
476 } |
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
89
diff
changeset
|
477 |
81 | 478 // Check if database spec provided, if not use default |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
479 if (($spec = stCArg(2)) === FALSE) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
480 $spec = $siteSettings["sqlDB"]; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
481 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
482 |
81 | 483 // Try to connect to database |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
484 if (!stConnectDB($spec)) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
485 die("Could not connect to SQL database '".$spec."'.\n"); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
486 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
487 echo "Using database spec '".$spec."'.\n"; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
488 |
85
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 // Act according to specified command |
88
784953d60ba5
More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
491 $addData = FALSE; |
27
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
492 switch (stCArgLC(1)) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
493 { |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
494 case "test": |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
495 $addData = TRUE; |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
496 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
497 case "new": |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
498 if (stCreateTables(FALSE)) |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
499 { |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
500 stAddSettings($dbMeta, "dbmeta", FALSE); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
501 stAddSettings($siteDefaults, "settings", FALSE); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
502 stAddSettings($siteDisplayVars, "displayVars", FALSE); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
503 } |
27
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
504 |
85
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
505 if ($addData) |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
506 stAddTestData(); |
50d6c69836a1
Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
81
diff
changeset
|
507 |
27
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
508 if (substr($spec, 0, 7) == "sqlite:") |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
509 { |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
510 $filename = substr($spec, 7); |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
511 echo "NOTICE! It seems you have SQLite database in use, changing permission ". |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
512 "of the target file '".$filename."' to 0600, for security. You may have to ". |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
513 "loosen up that for the things to actually work, but be careful. Having your ". |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
514 "database world-readable in the web is NOT good.\n"; |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
515 |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
516 if (chmod($filename, 0600) === FALSE) |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
517 { |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
518 echo "ERROR! Could not set permissions!\n"; |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
519 } |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
520 } |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
521 break; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
522 |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
523 case "upgrade": |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
524 if (($currVersion = stGetDBMeta("dbVersion")) === FALSE) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
525 $currVersion = -1; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
526 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
527 if ($currVersion == $dbVersion) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
528 { |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
529 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
|
530 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
531 else |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
532 { |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
533 echo "Database at version ".$currVersion.", upgrading to ".$dbVersion."\n"; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
534 // Possibly bail out incompatible upgrades here |
301
e13be68e73a7
Layout of the votes table has changed, so add an upgrade path.
Matti Hamalainen <ccr@tnsp.org>
parents:
268
diff
changeset
|
535 if ($currVersion < 6) |
e13be68e73a7
Layout of the votes table has changed, so add an upgrade path.
Matti Hamalainen <ccr@tnsp.org>
parents:
268
diff
changeset
|
536 stExecSQL("DROP TABLE votes"); |
355 | 537 |
416
876846d8ed5b
Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
538 if ($currVersion < 9) |
876846d8ed5b
Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
539 { |
876846d8ed5b
Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
540 stExecSQL("DROP TABLE displayVars"); |
355 | 541 stExecSQL("DROP TABLE displayListSlides"); |
425 | 542 stExecSQL("DROP TABLE displayListData"); |
416
876846d8ed5b
Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
543 } |
199
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
544 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
545 // Create tables |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
546 if (!stCreateTables(TRUE)) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
547 exit; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
548 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
549 // Do renames etc. here |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
550 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
551 // Do upgrading of setting descs |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
552 if (!stAddSettings($siteDefaults, "settings", TRUE)) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
553 exit; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
554 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
555 if (!stAddSettings($siteDisplayVars, "displayVars", TRUE)) |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
556 exit; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
557 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
558 stAddSettings($dbMeta, "dbmeta", TRUE); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
559 |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
560 stSetDBMeta("dbVersion", $dbVersion); |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
561 echo "Upgrade complete.\n"; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
562 } |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
563 break; |
dbc6f214b825
Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
564 |
27
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
565 default: |
b27204653615
Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents:
26
diff
changeset
|
566 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
|
567 break; |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
568 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
569 |
28 | 570 |
571 // | |
572 // Clean up permissions | |
573 // | |
67
23eba98e1575
Remove keygen.php from permission cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
574 foreach (array("createdb.php") as $filename) |
28 | 575 { |
576 if (chmod($filename, 0700) === FALSE) | |
577 { | |
578 echo "ERROR! Could not set permissions for '$filename'!\n"; | |
579 } | |
580 } | |
581 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
582 ?> |