/[webwml]/newmaint/gpgplace.wml
ViewVC logotype

Contents of /newmaint/gpgplace.wml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.44 - (show annotations) (download)
Sun Dec 14 12:16:33 2003 UTC (9 years, 5 months ago) by tbm
Branch: MAIN
Changes since 1.43: +1 -1 lines
Update which years to display.
1 <?
2 session_start();
3 include("gpgconfig.inc");
4 include("common.inc");
5 include("gpgcommon.inc");
6
7 $html_end = "</TD>\n</TR>\n</TABLE>\n</BODY>\n</HTML>";
8 ?>
9 #use wml::gpgpage title="GPG Signing Coordination - Your profile"
10 <?
11 if (!session_is_registered("s_username")) {
12 ?>
13 <STRONG>
14 You should not be here!</STRONG>
15 <?
16 return FALSE;
17 } else {
18 session_register("s_username");
19 }
20 ?>
21
22 <?
23 if (! ($db = open_db())) {
24 echo "<P>Cannot open database.</P>";
25 return FALSE;
26 }
27
28 # If you change this array, also change the info text about "State/Province"
29 $country_with_states = array("AU", "CA", "US");
30
31 # user pressed submit
32
33 if ($city || $country) {
34 $sql = "SELECT id FROM people WHERE email = '$s_username'";
35 if (! ($result = pg_exec($db, $sql))) {
36 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
37 return FALSE;
38 }
39 if (pg_NumRows($result) != 1) {
40 echo "That e-mail address is wicked.";
41 return FALSE;
42 }
43 $row = pg_Fetch_Array($result, 0);
44 $who = $row["id"];
45
46 $now = strftime('%Y-%m-%d');
47 $sql = "UPDATE people SET last_update = '$now' WHERE id = '$who'";
48 if (! ($result = pg_exec($db, $sql))) {
49 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
50 return FALSE;
51 }
52
53 if (! $id) {
54 if (in_array($country, $country_with_states)) {
55 $sql = "INSERT INTO places (who, city, country, state, url) VALUES ($who, '$city', '$country', '$state', '$url')";
56 } else {
57 $sql = "INSERT INTO places (who, city, country, url) VALUES ($who, '$city', '$country', '$url')";
58 }
59 if (! ($result = pg_exec($db, $sql))) {
60 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
61 return FALSE;
62 }
63 $oid = pg_getlastoid($result);
64 } else {
65 if (in_array($country, $country_with_states)) {
66 $sql = "UPDATE places SET city = '$city', country = '$country', state = '$state', url = '$url' WHERE id = '$id'";
67 } else {
68 $sql = "UPDATE places SET city = '$city', country = '$country', url = '$url' WHERE id = '$id'";
69 }
70 if (! ($result = pg_exec($db, $sql))) {
71 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
72 return FALSE;
73 }
74
75 $sql = "SELECT oid FROM places WHERE id = '$id'";
76 if (! ($result = pg_exec($db, $sql))) {
77 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
78 return FALSE;
79 }
80 if (pg_NumRows($result) == 1) {
81 $row = pg_Fetch_Array($result, 0);
82 $oid = $row["oid"];
83 } else {
84 echo "Cannot find OID for ID.";
85 return FALSE;
86 }
87
88 }
89
90 if ($begin_year == "always") {
91 $begin = "";
92 } else {
93 $begin = sprintf("%4d-%02d-%02d", $begin_year, $begin_month, $begin_day);
94 }
95
96 if ($begin) {
97 $sql = "UPDATE places SET begin = '$begin' WHERE oid = '$oid'";
98 } else {
99 $sql = "UPDATE places SET begin = NULL WHERE oid = '$oid'";
100 }
101 if (! ($result = pg_exec($db, $sql))) {
102 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
103 return FALSE;
104 }
105
106 if ($end_year == "always") {
107 $end = "";
108 } else {
109 $end = sprintf("%4d-%02d-%02d", $end_year, $end_month, $end_day);
110 }
111
112 if ($end) {
113 $sql = "UPDATE places SET finish = '$end' WHERE oid = '$oid'";
114 } else {
115 $sql = "UPDATE places SET finish = NULL WHERE oid = '$oid'";
116 }
117 if (! ($result = pg_exec($db, $sql))) {
118 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
119 return FALSE;
120 }
121
122 echo "<META http-equiv=\"refresh\" content=\"0;URL=gpgmain.php?";
123
124 echo "Thanks for the entry.";
125 echo " Click <A href=\"gpgmain.php?\""; ?><?=SID?><?
126 echo ">here</A> to add new entries or view the current ones.";
127 echo $html_end;
128
129 return TRUE;
130 }
131
132
133 if ($remove && $id) {
134 $sql = "DELETE FROM places WHERE id = '$id'";
135 if (! ($result = pg_exec($db, $sql))) {
136 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
137 return FALSE;
138 }
139
140 if (! ($result = pg_exec($db, $sql))) {
141 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
142 return FALSE;
143 }
144
145 echo "<META http-equiv=\"refresh\" content=\"0;URL=gpgmain.php?";
146
147 echo "Successfully removed entry.";
148 echo " Click <A href=\"gpgmain.php?\""; ?><?=SID?><?
149 echo ">here</A> to add new entries or view the current ones.";
150 echo $html_end;
151
152 return TRUE;
153
154 }
155
156
157 # user wants to fill out the form
158
159 # modify an entry (if $id exists), or add a new one)
160 if ($id) {
161 $sql = "SELECT begin, finish, city, country, state, url FROM places WHERE id = '$id'";
162 if (! ($result = pg_exec($db, $sql))) {
163 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
164 return FALSE;
165 }
166
167 if (pg_NumRows($result) != 1) {
168 echo "Not enough or too many results. That should not happen.";
169 return FALSE;
170 }
171
172 $row = pg_Fetch_Array($result, 0);
173 $begin = $row["begin"];
174 $finish = $row["finish"];
175 $city = $row["city"];
176 $country = $row["country"];
177 $state = $row["state"];
178 $url = $row["url"];
179 } else {
180 $begin = $finish = "";
181 $city = $country = "";
182 }
183
184 ?>
185
186 <div align="center">
187 <TABLE summary="">
188 <FORM method="post" action="gpgplace.php">
189
190
191 <?
192
193 function print_date($title, $name, $date) {
194
195 $parsed_date = split("-", $date);
196 $year = $parsed_date[0];
197 $month = $parsed_date[1];
198 $day = $parsed_date[2];
199
200 echo "<TR><TD>$title</TD><TD><SELECT name = \"";
201 echo $name;
202 echo "_year\">";
203
204 $years = array("2004", "2005", "always");
205 foreach ($years as $i) {
206 echo "<OPTION";
207 if ($year == $i || (!$year && $i == "always")) {
208 echo " SELECTED";
209 }
210 echo ">$i\n";
211 }
212
213 echo "</SELECT></TD>";
214 echo "<TD><SELECT name = \"";
215 echo $name;
216 echo "_month\">";
217
218 $months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
219 $counter = 1;
220 foreach ($months as $i) {
221 echo "<OPTION value=$counter";
222 if ($month == $counter) {
223 echo " SELECTED";
224 }
225 echo ">$i\n";
226 $counter = $counter + 1;
227 }
228
229 echo "</SELECT></TD>";
230 echo "<TD><SELECT name = \"";
231 echo $name;
232 echo "_day\">";
233
234 for ($i = 1; $i < 32; $i++) {
235 echo "<OPTION";
236 if ($day == $i) {
237 echo " SELECTED";
238 }
239 echo ">$i";
240 }
241 echo "</SELECT></TD>";
242 echo "</TR>";
243 echo "\n";
244 }
245 ?>
246
247 <?
248
249 print_date("Begin", "begin", $begin);
250 print_date("End", "end", $finish);
251
252 if ($id) {
253 echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
254 }
255
256 ?>
257
258
259 <TR>
260 <TD><B>City</B></TD>
261 <TD><INPUT name = "city" type = "text" maxlength="30" value="<? echo $city ?>"></TD>
262 <TD>city and/or event (e.g. a conference)</TD>
263 </TR>
264 <TR>
265 <TD><B>URL</B></TD>
266 <TD><INPUT name = "url" type = "text" maxlength="100" size=50 value="<? echo $url ?>"></TD>
267 <TD>URL (in case of a conference etc.)</TD>
268 </TR>
269 <TR>
270 <TD><B>Country</B></TD>
271
272 <?
273 echo "<TD><SELECT name = \"country\">";
274 foreach ($iso as $key => $value) {
275 echo "<OPTION VALUE=\"$key\"";
276 if ($country == $key) {
277 echo " SELECTED";
278 }
279 echo ">$value";
280 }
281 echo "</SELECT></TD>";
282 echo "</TR>";
283 echo "\n";
284 ?>
285
286 <TR><TD><B>State/Province</B></TD><TD><INPUT name = "state" type = "text" maxlength="3" value="<? echo $state ?>"></TD>
287 <TD>Australia/Canada/USA only - use 2-3 letter code</TD></TR>
288
289 </TR>
290 <TR><TD> </TD><TD><INPUT type="submit" value="Submit"></TD></TR>
291 </FORM>
292
293 <?
294 echo $html_end;
295 ?>
296

  ViewVC Help
Powered by ViewVC 1.1.5