annotate msite.inc.php @ 7:d76020022881

Various fixes, cleanups and improvements.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 05 Dec 2012 09:35:30 +0200
parents 76c3b89d7b11
children 4c5f651aa107
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 //
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 // Nothing to touch after this, mostly
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 //
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 $errorSet = FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 $errorMsg = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 function stError($msg)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 global $errorSet, $errorMsg;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 $errorSet = TRUE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 $errorMsg .= "<li>".$msg."</li>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 function stCheckHTTPS()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 return isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != "" && $_SERVER["HTTPS"] != "off");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
22 function stSetupCacheControl()
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
23 {
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
24 header("Cache-Control: private");
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
25 header("Cache-Control: must-revalidate");
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
26 header("Cache-Control: no-store");
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
27 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
28
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
29
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
30 function stSessionExpire($type)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 {
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
32 // Check for session expiration
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
33 if (!isset($_SESSION["expires"]))
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
34 {
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
35 if (stGetSetting("debug")) error_log("Session $type expires due to expire time not set.");
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
36 return FALSE;
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
37 }
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
38
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
39 if ($_SESSION["expires"] < time())
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
40 {
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
41 if (stGetSetting("debug")) error_log("Session $type / ".session_id()." expires due to timeout ".$_SESSION["expires"]." < ".time());
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
42 return FALSE;
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
43 }
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
44
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
45 // Add more time to expiration
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
46 if (stGetSetting("debug")) error_log("Adding more time to $type session ".session_id()." :: ".stGetSetting($type));
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
47 $_SESSION["expires"] = time() + stGetSetting($type);
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
48 return TRUE;
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
49 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
50
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
51
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
52 function stSessionEnd($ok)
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
53 {
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
54 if (stGetSetting("debug")) error_log("END session ".$_SESSION["type"]." / ".$_SESSION["expires"]." == ".$ok);
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
55 $_SESSION = array();
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
56 if (ini_get("session.use_cookies"))
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
57 {
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
58 $params = session_get_cookie_params();
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
59 setcookie(session_name(), "", time() - 242000,
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
60 $params["path"], $params["domain"],
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
61 $params["secure"], $params["httponly"]
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
62 );
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
63 }
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
64 @session_destroy();
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
65 return $ok;
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
66 }
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
67
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
68
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
69 function stAdmSessionAuth()
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
70 {
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
71 if (@session_start() === TRUE && isset($_SESSION["admPassword"]) &&
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
72 $_SESSION["admPassword"] == stGetSetting("admPassword"))
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
73 {
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
74 if (stGetSetting("debug")) error_log("AUTH admin session.");
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
75 return stSessionExpire("admTimeout");
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
76 }
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
77 else
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
78 return FALSE;
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
79 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
80
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
81
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
82 function stAdmSessionStart()
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
83 {
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
84 if (@session_start() === TRUE)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 {
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
86 if (stGetSetting("debug")) error_log("START admin session OK.");
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
87 $_SESSION["type"] = "admin";
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
88 $_SESSION["admPassword"] = stGetSetting("admPassword");
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
89 $_SESSION["expires"] = time() + stGetSetting("admTimeout");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 return TRUE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 else
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
93 {
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
94 if (stGetSetting("debug")) error_log("START admin session --FAILED--");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 return FALSE;
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
96 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
100 function stVoteSessionAuth()
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
101 {
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
102 if (@session_start() === TRUE && isset($_SESSION["key"]) && isset($_SESSION["votes"]))
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
103 return stSessionExpire("voteTimeout");
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
104 else
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
105 return FALSE;
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
106 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
107
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
108
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
109 function stVoteSessionStart()
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 if (@session_start() === TRUE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 {
7
d76020022881 Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
113 $_SESSION["type"] = "vote";
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
114 $_SESSION["expires"] = time() + stGetSetting("voteTimeout");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 return TRUE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
122 function stSetVoteStatus($st)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 {
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
124 $_SESSION["status"] = $st;
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
125 }
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
126
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
127
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
128 function stGetSetting($name)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 {
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
130 global $siteSettings, $siteDefaults;
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 if (isset($siteSettings[$name]))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 return $siteSettings[$name];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 else
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
134 if (isset($siteDefaults[$name]))
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
135 return $siteDefaults[$name];
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
136 else
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
137 die("No config value or default for '".$name."'.\n");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 function stChkSetting($name)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 global $siteSettings;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 return isset($siteSettings[$name]) && $siteSettings[$name];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 function stSpecURL($id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 global $specURLs;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 if (isset($specURLs[$id]))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 return "<a href=\"".$specURLs[$id][0]."\">".$specURLs[$id][1]."</a>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 return "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 function stPrintSpecURL($id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 echo stSpecURL($id);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 function dhentities($str)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 return str_replace(array("&lt;","&gt;"), array("<", ">"), htmlentities($str, ENT_NOQUOTES, "UTF-8"));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 function chentities($str)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 return htmlentities($str, ENT_NOQUOTES, "UTF-8");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 function stGetFormCheckBoxInput($name, $id, $prefix, $checked, $label, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 "<input ".$extra." type=\"checkbox\" id=\"".$prefix.$name.$id."\" ".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 "name=\"".$prefix.$name.$id."\" ".($checked ? "checked=\"checked\" " : "")." />".
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
181 ($label != "" ? "<label for=\"".$prefix.$name.$id."\">".$label."</label>" : "");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 function stGetFormButtonInput($name, $id, $prefix, $label, $onclick = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 "<input type=\"button\" id=\"".$prefix.$name.$id."\" ".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 "name=\"".$name."\" value=\"".$label."\" ".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 ($onclick != "" ? "onClick=\"".$onclick."\"" : "")." />";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 function stGetFormTextArea($rows, $cols, $name, $id, $prefix, $value, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 "<textarea ".$extra." id=\"".$prefix.$name.$id."\" ".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 "name=\"".$name."\" rows=\"".$rows."\" cols=\"".$cols."\">".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 (isset($value) ? chentities($value) : "").
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 "</textarea>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 function stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 "<input ".$extra." type=\"text\" id=\"".$prefix.$name.$id."\" ".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 "name=\"".$name."\" size=\"".$size."\" maxlength=\"".$len."\"".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 (isset($value) ? " value=\"".chentities($value)."\"" : "").
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 " />";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 function stGetFormPasswordInput($name, $id, $prefix)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 "<input type=\"password\" id=\"".$prefix.$name.$id.
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 "\" name=\"".$name."\" />";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 function stGetFormHiddenInput($name, $value)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 return "<input type=\"hidden\" name=\"".$name."\" value=\"".chentities($value)."\" />";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 function stGetTDEditTextItem($edit, $size, $len, $name, $id, $prefix, $value, $extra = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231 "<td class=\"".$name."\">".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 ($edit ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 "</td>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 function stPrintFormTextInput($text1, $text2, $size, $len, $name, $extra="")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 echo " <tr><th>".chentities($text1)."</th><td>".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 stGetFormTextInput($size, $len, $name, "", "", $_REQUEST[$name], $extra).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 "</td><td>".chentities($text2)."</td></tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 function stPrintFormHiddenInput($name, $value)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 echo " ".stGetFormHiddenInput($name, $value)."\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 function stPrintAttendee($item, $row, $edit, $eclass = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 $id = $item["id"];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 $prefix = "at";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 echo " ".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 "<tr class=\"".($row % 2 == 1 ? "rodd" : "reven").$eclass."\" id=\"attendee".$id."\">".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 stGetTDEditTextItem(FALSE, 20, 40, "name", $id, $prefix, $item["name"]).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 stGetTDEditTextItem(FALSE, 20, 40, "groups", $id, $prefix, $item["groups"]).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 "<td class=\"regtime\">".date("d M Y / H:i", $item["regtime"])."</td>".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 stGetTDEditTextItem($edit, 30, 64, "oneliner", $id, $prefix, $item["oneliner"], "autocomplete=\"off\"");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 if ($edit)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 echo
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 stGetTDEditTextItem($edit, 20, 40, "email", $id, $prefix, $item["email"], "autocomplete=\"off\"").
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 "<td>".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 "<button class=\"button\" id=\"atupd".$id."\" type=\"button\" onclick=\"updateAttendee(".$id.")\">Update</button>".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 "<button class=\"button\" id=\"atdel".$id."\" type=\"button\" onclick=\"deleteAttendee(".$id.")\">Delete</button>".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269 "</td>";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 echo "</tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 function stPrintNewsItem($item, $edit = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 echo
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 "<div class=\"newsitem\" id=\"news".$item["id"]."\">\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 " <h2>".chentities($item["title"])."</h2>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 " <div class=\"text\">".dhentities($item["text"])."</div>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 " <div class=\"sig\">-- ".chentities($item["author"])."<br />".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 date("d M Y / H:i", $item["utime"]).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 $edit."</div>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 "</div>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 function stChkDataItem($name)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 return !isset($_REQUEST[$name]) || strlen(trim($_REQUEST[$name])) < 1;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 function stChkRequestItem($name)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 return isset($_REQUEST[$name]);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 function stGetRequestItem($name, $default = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 return isset($_REQUEST[$name]) ? trim($_REQUEST[$name]) : $default;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 function stGetDRequestItem($name, $default = "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 return trim(urldecode(stGetRequestItem($name, $default)));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 function stLogSQLError($sql)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 error_log("SQL error ".implode("; ", $db->errorInfo())." in statement \"".$sql."\"");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 function stConnectSQLDB()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 try {
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
324 $db = new PDO("sqlite:".stGetSetting("sqlDBfilename"));
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 catch (PDOException $e) {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 error_log("Could not connect to SQL database: ".$e->getMessage().".");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 return TRUE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 function stGetSQLParam($type, $value)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 switch ($type)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 case "d":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 return intval($value);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 case "s":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 return $db->quote($value);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 case "D":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 return intval(stGetRequestItem($value));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 case "S":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 return $db->quote(stGetDRequestItem($value));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 case "Q":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 return $db->quote(stripslashes(stGetDRequestItem($value)));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 case "B":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 return intval(stGetRequestItem($value)) ? 1 : 0;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 function stPrepareSQL()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 $argc = func_num_args();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 $argv = func_get_args();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 if ($argc < 1)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 error_log("Invalid stPrepareSQL() call, no arguments!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 $fmt = $argv[0];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 $len = strlen($fmt);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 $sql = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373 $argn = 1;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 $pos = 0;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 while ($pos < $len)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 if ($fmt[$pos] == "%")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 if ($argn < $argc)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 $sql .= stGetSQLParam($fmt[++$pos], $argv[$argn++]);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 error_log("Invalid SQL statement format string '".$fmt.
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 "', not enough parameters specified (".$argn." of ".$argc.")");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 $sql .= $fmt[$pos];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 $pos++;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 return $sql;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 function stPrepareSQLUpdate($table, $cond, $pairs)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 $sql = array();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 foreach ($pairs as $name => $attr)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 $sql[] = $name."=".stGetSQLParam($attr, $name);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404 return
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 "UPDATE ".$table." SET ".implode(",", $sql).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406 ($cond != "" ? " ".$cond : "");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 function stExecSQL($sql)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 if (($res = $db->query($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414 return $res;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417 stLogSQLError($sql);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418 stError("Oh noes! SQL error #23!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
420 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
422
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424 function stFetchSQL($sql)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
425 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
427 if (($res = $db->query($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
428 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
429 return $res->fetch();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
430 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
431 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
433 stLogSQLError($sql);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
434 stError("Oh noes! SQL error #31!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
435 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
436 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
437 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
440 function stFetchSQLColumn($sql, $column = 0)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 global $db;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443 if (($res = $db->query($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
444 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445 return $res->fetchColumn($column);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
447 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
449 stLogSQLError($sql);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
450 stError("Oh noes! SQL error #81!");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
451 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
452 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
456 function stGetCompoList($all)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
457 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
458 global $compos;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
460 // Get entries and competitions into an array structure
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
461 $sql = "SELECT * FROM compos ".($all ? "" :"WHERE enabled<>0 ")."ORDER BY name DESC";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
462 foreach (stExecSQL($sql) as $compo)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
463 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464 $id = $compo["id"];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
466 $compos[$compo["id"]] = array(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467 "name" => $compo["name"],
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
468 "entries" => array()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469 );
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
470
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471 $sql = stPrepareSQL("SELECT * FROM entries WHERE compo_id=%d", $id);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
472 foreach (stExecSQL($sql) as $entry)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
473 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
474 $compos[$id]["entries"][$entry["id"]] = $entry;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
475 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
476 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
477 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
478
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
479
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
480 function stConvSwitchMode(&$str, &$mode, $newMode)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
481 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
482 if ($newMode != $mode)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
483 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 if ($mode != "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
485 $str .= "\n</".$mode.">\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
487 $mode = $newMode;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
489 if ($mode != "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
490 $str .= "<".$mode.">\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
491 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
492 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
494
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
495 function stConvertCompoDesc($desc)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
496 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 global $stDescConversion;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 $str = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
499 $mode = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
500
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
501 foreach (explode("\n", $desc) as $line)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
502 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503 if (preg_match("/^\s*\s*\*(.+)$/", $line, $m))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
504 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505 stConvSwitchMode($str, $mode, "ol");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506 $str .= "<li>".$m[1]."</li>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509 if (preg_match("/^\s*-\s*(.+)$/", $line, $m))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
510 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
511 stConvSwitchMode($str, $mode, "ul");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
512 $str .= "<li>".$m[1]."</li>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
514 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
515 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516 stConvSwitchMode($str, $mode, "p");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
517 $str .= $line;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
518 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
519 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
520
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521 stConvSwitchMode($str, $mode, "");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523 return $str;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526 ?>