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

Contents of /newmaint/gpgplace.wml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.34 - (hide annotations) (download)
Sat Nov 17 22:44:30 2001 UTC (11 years, 6 months ago) by weasel
Branch: MAIN
Changes since 1.33: +4 -0 lines
Forward ppl to pgpmain.php after adding/removing an entry using meta refresh
1 tbm 1.1 <?
2     session_start();
3     include("gpgconfig.inc");
4     include("common.inc");
5     include("gpgcommon.inc");
6    
7 tbm 1.33 $html_end = "</TD>\n</TR>\n</TABLE>\n</BODY>\n</HTML>";
8 tbm 1.1 ?>
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 tbm 1.11 <?
16     return FALSE;
17     } else {
18 tbm 1.1 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    
29 tbm 1.17 # user pressed submit
30    
31     if ($city || $country) {
32 tbm 1.25 $sql = "SELECT id FROM people WHERE email = '$s_username'";
33 tbm 1.17 if (! ($result = pg_exec($db, $sql))) {
34     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
35     return FALSE;
36     }
37     if (pg_NumRows($result) != 1) {
38     echo "That e-mail address is wicked.";
39     return FALSE;
40     }
41     $row = pg_Fetch_Array($result, 0);
42     $who = $row["id"];
43    
44 tbm 1.30 $now = strftime('%Y-%m-%d');
45     $sql = "UPDATE people SET last_update = '$now' WHERE id = '$who'";
46     if (! ($result = pg_exec($db, $sql))) {
47     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
48     return FALSE;
49     }
50    
51 tbm 1.22 if (! $id) {
52     $sql = "INSERT INTO places (who, city, country) VALUES ($who, '$city', '$country')";
53     if (! ($result = pg_exec($db, $sql))) {
54     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
55     return FALSE;
56     }
57 tbm 1.23 $oid = pg_getlastoid($result);
58     } else {
59 tbm 1.24 $sql = "UPDATE places SET city = '$city', country = '$country' WHERE id = '$id'";
60 tbm 1.23 if (! ($result = pg_exec($db, $sql))) {
61     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
62     return FALSE;
63     }
64    
65 tbm 1.24 $sql = "SELECT oid FROM places WHERE id = '$id'";
66 tbm 1.23 if (! ($result = pg_exec($db, $sql))) {
67     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
68     return FALSE;
69     }
70     if (pg_NumRows($result) == 1) {
71     $row = pg_Fetch_Array($result, 0);
72     $oid = $row["oid"];
73     } else {
74 tbm 1.24 echo "Cannot find OID for ID.";
75 tbm 1.23 return FALSE;
76     }
77    
78     }
79    
80     if ($begin_year == "always") {
81     $begin = "";
82     } else {
83 tbm 1.26 $begin = sprintf("%4d-%02d-%02d", $begin_year, $begin_month, $begin_day);
84 tbm 1.22 }
85    
86 tbm 1.23 if ($begin) {
87 tbm 1.24 $sql = "UPDATE places SET begin = '$begin' WHERE oid = '$oid'";
88 tbm 1.23 } else {
89 tbm 1.24 $sql = "UPDATE places SET begin = NULL WHERE oid = '$oid'";
90 tbm 1.23 }
91     if (! ($result = pg_exec($db, $sql))) {
92     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
93     return FALSE;
94     }
95    
96     if ($end_year == "always") {
97     $end = "";
98     } else {
99 tbm 1.26 $end = sprintf("%4d-%02d-%02d", $end_year, $end_month, $end_day);
100 tbm 1.23 }
101    
102     if ($end) {
103 tbm 1.24 $sql = "UPDATE places SET finish = '$end' WHERE oid = '$oid'";
104 tbm 1.23 } else {
105 tbm 1.24 $sql = "UPDATE places SET finish = NULL WHERE oid = '$oid'";
106 tbm 1.23 }
107     if (! ($result = pg_exec($db, $sql))) {
108     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
109     return FALSE;
110     }
111 tbm 1.1
112 weasel 1.34 echo "<META http-equiv=\"refresh\" content=\"0;URL=gpgmain.php?";
113    
114 tbm 1.28 echo "Thanks for the entry.";
115     echo " Click <A href=\"gpgmain.php?\""; ?><?=SID?><?
116     echo ">here</A> to add new entries or view the current ones.";
117 tbm 1.33 echo $html_end;
118 tbm 1.28
119 tbm 1.17 return TRUE;
120     }
121 tbm 1.1
122    
123 tbm 1.31 if ($remove && $id) {
124     $sql = "DELETE FROM places WHERE id = '$id'";
125     if (! ($result = pg_exec($db, $sql))) {
126     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
127     return FALSE;
128     }
129    
130 tbm 1.32 if (! ($result = pg_exec($db, $sql))) {
131     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
132 tbm 1.31 return FALSE;
133     }
134 weasel 1.34
135     echo "<META http-equiv=\"refresh\" content=\"0;URL=gpgmain.php?";
136 tbm 1.31
137     echo "Successfully removed entry.";
138     echo " Click <A href=\"gpgmain.php?\""; ?><?=SID?><?
139     echo ">here</A> to add new entries or view the current ones.";
140 tbm 1.33 echo $html_end;
141 tbm 1.31
142     return TRUE;
143    
144     }
145    
146    
147 tbm 1.17 # user wants to fill out the form
148 tbm 1.1
149     # modify an entry (if $id exists), or add a new one)
150     if ($id) {
151     $sql = "SELECT begin, finish, city, country FROM places WHERE id = '$id'";
152     if (! ($result = pg_exec($db, $sql))) {
153     echo "Problem with query", pg_ErrorMessage($db), "<BR>";
154     return FALSE;
155     }
156    
157     if (pg_NumRows($result) != 1) {
158     echo "Not enough or too many results. That should not happen.";
159     return FALSE;
160     }
161    
162     $row = pg_Fetch_Array($result, 0);
163     $begin = $row["begin"];
164     $finish = $row["finish"];
165     $city = $row["city"];
166     $country = $row["country"];
167     } else {
168 tbm 1.2 $begin = $finish = "";
169     $city = $country = "";
170 tbm 1.1 }
171 tbm 1.2
172 tbm 1.1 ?>
173 tbm 1.2
174     <div align="center">
175     <TABLE summary="">
176 tbm 1.18 <FORM method="post" action="gpgplace.php">
177 tbm 1.4
178    
179     <?
180    
181 tbm 1.12 function print_date($title, $name, $date) {
182    
183 tbm 1.14 $parsed_date = split("-", $date);
184     $year = $parsed_date[0];
185     $month = $parsed_date[1];
186     $day = $parsed_date[2];
187 tbm 1.12
188 tbm 1.13 echo "<TR><TD>$title</TD><TD><SELECT name = \"";
189 tbm 1.12 echo $name;
190     echo "_year\">";
191    
192     $years = array("2001", "2002", "2003", "always");
193     foreach ($years as $i) {
194     echo "<OPTION";
195 tbm 1.27 if ($year == $i || (!$year && $i == "always")) {
196 tbm 1.12 echo " SELECTED";
197     }
198     echo ">$i\n";
199 tbm 1.4 }
200    
201 tbm 1.12 echo "</SELECT></TD>";
202     echo "<TD><SELECT name = \"";
203     echo $name;
204     echo "_month\">";
205    
206     $months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
207     $counter = 1;
208     foreach ($months as $i) {
209     echo "<OPTION value=$counter";
210     if ($month == $counter) {
211     echo " SELECTED";
212     }
213     echo ">$i\n";
214     $counter = $counter + 1;
215 tbm 1.4 }
216    
217 tbm 1.12 echo "</SELECT></TD>";
218 tbm 1.15 echo "<TD><SELECT name = \"";
219 tbm 1.12 echo $name;
220     echo "_day\">";
221    
222     for ($i = 1; $i < 32; $i++) {
223     echo "<OPTION";
224     if ($day == $i) {
225     echo " SELECTED";
226     }
227 tbm 1.15 echo ">$i";
228 tbm 1.12 }
229     echo "</SELECT></TD>";
230     echo "</TR>";
231     echo "\n";
232 tbm 1.16 }
233 tbm 1.6 ?>
234 tbm 1.7
235 tbm 1.9 <?
236 tbm 1.12
237     print_date("Begin", "begin", $begin);
238     print_date("End", "end", $finish);
239 tbm 1.19
240     if ($id) {
241 tbm 1.21 echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
242 tbm 1.19 }
243 tbm 1.12
244 tbm 1.9 ?>
245    
246 tbm 1.4
247 tbm 1.29 <TR><TD><B>City</B></TD><TD><INPUT name = "city" type = "text" value="<? echo $city ?>"></TD>
248     <TD>city and/or event (e.g. a computer conference)</TD></TR>
249     <TR><TD><B>Country</B></TD><TD><INPUT name = "country" type = "text" value="<? echo $country ?>"></TD>
250     <TD>Do NOT leave this empty!</TD></TR>
251 tbm 1.17 <TR><TD> </TD><TD><INPUT type="submit" value="Submit"></TD></TR>
252 tbm 1.2 </FORM>
253 tbm 1.33
254     <?
255     echo $html_end;
256     ?>
257 tbm 1.1

  ViewVC Help
Powered by ViewVC 1.1.5