annotate createdb.php @ 72:63a6caf59e5c

Fix creation of boolean settings, and add '%b' formatter into stPrepareSQL().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 17 Oct 2013 15:01:20 +0300
parents 23eba98e1575
children c70c2650f790
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 <?
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 require "mconfig.inc.php";
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 require "msite.inc.php";
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
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
6 //
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 // CLI utility helper functions
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 //
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 function stCArg($index)
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 {
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 global $argc, $argv;
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 if ($index < $argc)
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 return $argv[$index];
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
14 else
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
15 return FALSE;
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
16 }
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
17
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
18 function stCArgLC($index)
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
19 {
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
20 global $argc, $argv;
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
21 if ($index < $argc)
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
22 return strtolower($argv[$index]);
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
23 else
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
24 return FALSE;
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
25 }
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
26
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
27
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
28 function stCSQLError($sql)
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
29 {
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
30 global $db;
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
31 die("Error executing SQL query: ".implode("; ", $db->errorInfo())." in statement \"".$sql."\"\n");
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
32 exit;
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
33 }
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
34
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
35
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
36 // 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
37 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
38 {
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
39 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
40 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
41 }
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
42
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 // The defaults we put in
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 $siteDefaults = array(
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
47 "maxAttendees" => array(VT_INT, 30, "Maximum attendees (soft limit)"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
49 "userTimeout" => array(VT_INT, 120, "User pages (voting, entry submission) timeout in minutes"),
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
50 "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
51
62
101cde58b267 Add a new setting for ASCII vs. HTML table output for compo results.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
52 "showAdmin" => array(VT_BOOL, false, "Always show administration interface link on the menu"),
17
b015c0dea42c Minor improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
53 "showAttendees" => array(VT_BOOL, false, "Show attendees list"),
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
54 "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
55 "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
56
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
57 "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
58 "showResultsASCII" => array(VT_BOOL, true, "Show results as ASCII instead of HTML table"),
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
59 "showResAuthors" => array(VT_BOOL, false, "Show entry authors on results page"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
61 "requireEMail" => array(VT_BOOL, false, "Require e-mail address in registrations"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
62
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
63 "registerInfoText" => array(VT_TEXT, "<p>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
64 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
65 If you plan on joining the IRC channel
63
922b5192b2ff Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
66 (<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
67 <b>e-mail</b> is not required either.
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
68 </p>", "Registration page info text"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
69
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
70 "registerPostText" => array(VT_TEXT, "<p>Now go make a demo about it!</p>", "Successful post-registration note text"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
71
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
72 "registerPostNoEmail" => array(VT_TEXT, "
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
73 <h2>By the way ...</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
74 <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
75 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
76 some other means (IRC, for example.)</p>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
77 ", "No e-mail address registration note"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
78
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
79 "eventDescription" => array(VT_TEXT, "
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
80 <h1>Event program &amp; schedule</h1>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
81 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
82 <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
83 <li>.. and possible additional live acts. More info to come.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
84 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
85
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
86 <h2>Friday 30.11.</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
87 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
88 <li><b>18:00</b> - <i>Doors open</i>.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
89 <li><b>22:00</b> - DJ set by Aegis.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
90 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
91
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
92 <h2>Saturday 1.12.</h2>
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 <li><b>14:00</b> - Deadline for remote entries.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
95 <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
96 <li><b>20:00</b> - Competitions start.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
97 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
98
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
99 Competition schedule and voting deadline will depend on number of entries.
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
100
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
101 <h2>Sunday 2.12.</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
102 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
103 <li><b>12:00</b> - Party over?</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
104 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
105 ", "Event general description / timetables etc."),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
106
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
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
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
128
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
129
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
130 "siteInfoText" => array(VT_TEXT, "
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
131 <a href=\"news\">
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
132 <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
133 <div id=\"date\">
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
134 5.-8.12.2013<br />
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
135 Helsinki, Finland<br />
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
136 @ old location<br />
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
137 <span class=\"notice\">Entry 15 EUR + prod</span>
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
138 </div>", "Site header text"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
139
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
140
9
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
141 "newsDescription" => array(VT_TEXT, "
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
142 <div style=\"text-align: center;\">
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
143 <img src=\"img/fap.png\" alt=\"FAP\" />
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
144 <p>
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
145 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
146 <br />
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
147 <span class=\"notice\">
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
148 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
149 </span>
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
150 </p>
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
151 </div>",
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
152 "News page header text"),
29
4b5a176805e2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
153
4b5a176805e2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
154
4b5a176805e2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
155 "entrySubmitInfo" => array(VT_TEXT, "Rules for entry submission ... ", "Entry submission information blurb"),
43
66ab7d43f8a1 Add a new setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
156
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
157 "siteMenuHeader" => array(VT_TEXT, "<div>13.FAP:> <span class=\"mblink\">&#9632;</span></div>", "Site menu header text"),
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
158 "siteMenuFooter" => array(VT_TEXT, "", "Site menu footer text"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 );
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 $sqlTables = array(
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 "news" => "id INTEGER PRIMARY KEY AUTOINCREMENT, utime INT, title VARCHAR(128), text VARCHAR(4096), author VARCHAR(64), persist INT DEFAULT 0",
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
163 "attendees" => "id INTEGER PRIMARY KEY AUTOINCREMENT, regtime INT, name VARCHAR(64), groups VARCHAR(64), oneliner VARCHAR(64), email VARCHAR(80), key VARCHAR(64), active INT DEFAULT 0",
55
4fac95384753 Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
164 "compos" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(128), description VARCHAR(4096), visible INT DEFAULT 0, voting INT DEFAULT 0, showAuthors INT DEFAULT 0",
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
165 "entries" => "id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(64), author VARCHAR(64), compo_id INT DEFAULT NULL, filename VARCHAR(256) DEFAULT NULL",
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 "votes" => "id INTEGER PRIMARY KEY AUTOINCREMENT, entry_id INT DEFAULT NULL, voter_id INT DEFAULT NULL, value INT DEFAULT 0",
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
167 "settings" => "key VARCHAR(32) PRIMARY KEY, vtype INT, vstr VARCHAR(128), vtext TEXT, vint INT, desc VARCHAR(128)",
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 );
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 //
36
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
172 // Helper functions
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 //
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 function stConnectDB($dbspec)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 global $db;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 try {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 $db = new PDO($dbspec);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 catch (PDOException $e) {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 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
182 return FALSE;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 return TRUE;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
188 function stCreateOneTable($name, $schema)
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
189 {
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
190 return (stExecSQL("CREATE TABLE ".$name." (".$schema.")") !== FALSE) ? TRUE : FALSE;
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
191 }
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
192
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
193
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 function stCreateTables()
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 global $sqlTables;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 echo "Creating tables...\n";
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 foreach ($sqlTables as $name => $schema)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 echo " - '".$name."'\n";
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
201 if (!stCreateOneTable($name, $schema))
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 return FALSE;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 return TRUE;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 function stAddSettings()
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 global $siteDefaults;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 echo "Adding settings to settings table.\n";
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 foreach ($siteDefaults as $key => $value)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 switch ($value[0])
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 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
217 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
218 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
219 case VT_INT: $type = "%d"; $var = "vint"; break;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 $sql = stPrepareSQL(
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
223 "INSERT INTO settings (key,vtype,".$var.",desc) VALUES (%s,%d,".$type.",%s)",
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
224 $key, $value[0], $value[1], $value[2]);
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 stExecSQL($sql);
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230
36
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
231 //
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
232 // Main program starts
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
233 //
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 if ($argc < 2)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 echo "Usage: ".$argv[0]." <mode> [args]\n".
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 "Where mode is one of following:\n".
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 "\n".
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 " 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
240 " 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
241 "\n".
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 " reset [dbspec] Reset settings (similar to 'new').\n".
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 "\n";
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 exit;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 if (($spec = stCArg(2)) === FALSE)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 $spec = $siteSettings["sqlDB"];
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 if (!stConnectDB($spec))
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 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
254
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 echo "Using database spec '".$spec."'.\n";
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
257 switch (stCArgLC(1))
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 case "new":
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 if (stCreateTables())
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 stAddSettings();
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
262
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
263 if (substr($spec, 0, 7) == "sqlite:")
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
264 {
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
265 $filename = substr($spec, 7);
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
266 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
267 "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
268 "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
269 "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
270
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
271 if (chmod($filename, 0600) === FALSE)
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
272 {
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
273 echo "ERROR! Could not set permissions!\n";
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
274 }
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
275 }
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 break;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 case "reset":
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 echo "Deleting old settings.\n";
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
280 stExecSQL("DROP TABLE settings");
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
281
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
282 if (stCreateOneTable("settings", $sqlTables["settings"]))
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
283 stAddSettings();
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 break;
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
285
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
286 default:
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
287 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
288 break;
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290
28
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
291
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
292 //
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
293 // Clean up permissions
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
294 //
67
23eba98e1575 Remove keygen.php from permission cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
295 foreach (array("createdb.php") as $filename)
28
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
296 {
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
297 if (chmod($filename, 0700) === FALSE)
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
298 {
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
299 echo "ERROR! Could not set permissions for '$filename'!\n";
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
300 }
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
301 }
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
302
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 ?>