16 |
# along with this program; if not, write to the Free Software |
# along with this program; if not, write to the Free Software |
17 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
18 |
# 02111-1307, USA. |
# 02111-1307, USA. |
19 |
|
# |
20 |
|
# $Id$ |
21 |
|
# |
22 |
|
|
23 |
use integer; |
use integer; |
24 |
use diagnostics; |
use diagnostics; |
28 |
|
|
29 |
use CGI qw/:standard/; |
use CGI qw/:standard/; |
30 |
|
|
31 |
|
# people in the database |
32 |
my %people; |
my %people; |
33 |
|
|
34 |
|
# directory containing the marker files for xplanet |
35 |
|
# named thecommunity.mark |
36 |
my $markerdir='@markerdir@'; |
my $markerdir='@markerdir@'; |
37 |
|
|
38 |
|
# markerfile |
39 |
|
# format : |
40 |
|
# latitude longitude "name" #password, date, email |
41 |
my $filename; |
my $filename; |
42 |
|
|
43 |
|
# |
44 |
|
# Syntax of CGI calls : |
45 |
|
# |
46 |
|
# coposys?community='thecommunity' : displays main form |
47 |
|
# coposys?add&name=&password=&password2=&latitude=&longitude=&email=&community= |
48 |
|
# coposys?update&name=&password=&latitude=&longitude=&email=&community= |
49 |
|
# coposys?delete&name=&del_password=&community= |
50 |
|
# |
51 |
|
|
52 |
print header; |
print header; |
53 |
|
|
54 |
if (param('community')) { |
if (param('community')) { |
55 |
|
|
56 |
$filename = $markerdir . '/' . param('community') . '.mark'; |
$filename = $markerdir . '/' . param('community') . '.mark'; |
57 |
|
|
58 |
display_add_form(); |
print "<b>Coposys $Revision$ </b>\n\n", |
59 |
|
"Manage members of a community </b>\n\n"; |
60 |
|
|
61 |
|
# form for adding a new member of the community |
62 |
|
display_add_update_forms(); |
63 |
|
|
64 |
|
# display a refresh button |
65 |
display_list_form(); |
display_list_form(); |
66 |
|
|
67 |
treat_args(); |
treat_args(); |
68 |
|
|
69 |
|
# displays a list of members of the community, with a password field next to each to allow modifications |
70 |
display_community(); |
display_community(); |
71 |
|
|
72 |
} |
} |
78 |
|
|
79 |
################################################################ |
################################################################ |
80 |
|
|
81 |
sub display_add_form { |
sub display_add_update_forms { |
82 |
my $date = localtime(); |
my $date = localtime(); |
83 |
|
|
84 |
print start_html('Coposys.'), |
print start_html('Coposys.'); |
85 |
|
|
86 |
|
# Add part of the form |
87 |
|
print "<table border=\"1\">\n"; |
88 |
|
print " <tr><td>", |
89 |
|
|
90 |
|
"<b>Use this form to register in the community <i>", |
91 |
|
param('community'), "</i></b> \n", |
92 |
|
|
93 |
start_form, |
start_form, |
94 |
|
|
95 |
" Full Name ", textfield('name'), "\n ", p, |
" Full Name ", textfield('name'), "\n ", p, |
96 |
|
|
97 |
"Password ", |
"Password ", |
98 |
password_field({name=>'password',size=>'8',maxlength=>8}), "\n ", p, |
password_field({name=>'password',size=>'8',maxlength=>8}), "\n ", p, |
99 |
"Password (again for add, blank for update) ", |
|
100 |
|
"Password (again) ", |
101 |
password_field({name=>'password2',size=>8,maxlength=>8}), "\n ", p, |
password_field({name=>'password2',size=>8,maxlength=>8}), "\n ", p, |
102 |
|
|
103 |
"Latitude ", textfield('latitude'), "\n ", p, |
"Latitude ", textfield('latitude'), "\n ", p, |
104 |
|
|
105 |
"Longitude ", textfield('longitude'), "\n ", p, |
"Longitude ", textfield('longitude'), "\n ", p, |
106 |
|
|
107 |
hidden({name=>'community'}), "\n ", |
hidden({name=>'community'}), "\n ", |
108 |
|
|
109 |
hidden({name=>'date',default=>$date}), "\n", |
hidden({name=>'date',default=>$date}), "\n", |
110 |
" Email", textfield('email'), "\n ", p, |
|
111 |
|
" Email ", textfield('email'), "\n ", p, |
112 |
|
|
113 |
submit({name=>'add'}), "\n", |
submit({name=>'add'}), "\n", |
|
submit({name=>'update'}), "\n", |
|
114 |
end_form, "\n\n"; |
end_form, "\n\n"; |
115 |
|
|
116 |
|
print "</td>"; |
117 |
|
|
118 |
|
|
119 |
|
# Update part of the form |
120 |
|
print "<td>", |
121 |
|
|
122 |
|
"<b>Use this form to update your registration in the community <i>", |
123 |
|
param('community'), "</i></b> \n", |
124 |
|
|
125 |
|
start_form, |
126 |
|
|
127 |
|
" Full Name ", textfield('name'), "\n ", p, |
128 |
|
|
129 |
|
"Password ", |
130 |
|
password_field({name=>'password',size=>'8',maxlength=>8}), "\n ", p, |
131 |
|
|
132 |
|
"Latitude ", textfield('latitude'), "\n ", p, |
133 |
|
|
134 |
|
"Longitude ", textfield('longitude'), "\n ", p, |
135 |
|
|
136 |
|
hidden({name=>'community'}), "\n ", |
137 |
|
|
138 |
|
hidden({name=>'date',default=>$date}), "\n", |
139 |
|
|
140 |
|
" Email ", textfield('email'), "\n ", p, |
141 |
|
|
142 |
|
submit({name=>'update'}), "\n", |
143 |
|
|
144 |
|
"</td></tr>\n", |
145 |
|
|
146 |
|
"</table>\n"; |
147 |
|
|
148 |
} |
} |
149 |
|
|
150 |
|
# displays an HTML form containing the refresh button |
151 |
sub display_list_form { |
sub display_list_form { |
152 |
print start_form, "\n ", |
print start_form, "\n ", |
153 |
hidden({name=>'community'}), "\n ", |
hidden({name=>'community'}), "\n ", |
154 |
|
# displays a refresh button |
155 |
submit({name=>'refresh'}), "\n", |
submit({name=>'refresh'}), "\n", |
156 |
end_form, "\n"; |
end_form, "\n"; |
157 |
} |
} |
158 |
|
|
159 |
|
# execute actions depending on the form called |
160 |
sub treat_args { |
sub treat_args { |
161 |
if ( param('add') ) { |
if ( param('add') ) { |
162 |
if ( |
if ( |
199 |
sub update_name { |
sub update_name { |
200 |
my ($latitude, $longitude, $name, $password, $date, $email); |
my ($latitude, $longitude, $name, $password, $date, $email); |
201 |
|
|
202 |
load_config(); |
load_data(); |
203 |
|
|
204 |
# check if the name already exists.. |
# check if the name already exists.. |
205 |
if (!defined $people{param('name')} ) { |
if (!defined $people{param('name')} ) { |
272 |
|
|
273 |
sub add_name { |
sub add_name { |
274 |
|
|
275 |
load_config(); |
load_data(); |
276 |
|
|
277 |
# check if we don't already have it |
# check if we don't already have it |
278 |
if ( defined $people{param('name')} ) { |
if ( defined $people{param('name')} ) { |
336 |
sub display_community { |
sub display_community { |
337 |
my ($latitude, $longitude, $name, $password, $date, $email); |
my ($latitude, $longitude, $name, $password, $date, $email); |
338 |
|
|
339 |
load_config(); |
load_data(); |
340 |
|
|
341 |
Delete('name'); |
Delete('name'); |
342 |
|
|
343 |
|
print "<b>Members of the community <i>", param('community'), "</i> :</b> \n"; |
344 |
|
|
345 |
print "<table border=\"1\">\n"; |
print "<table border=\"1\">\n"; |
346 |
print " <tr><td>Name</td><td>Latitude</td><td>Longitude</td>" ; |
print " <tr><td>Name</td><td>Latitude</td><td>Longitude</td>" ; |
347 |
print "<td>Last update</td><td>Email</td></tr>\n"; |
print "<td>Last update</td><td>Email</td></tr>\n"; |
360 |
print " <td>$date</td>\n"; |
print " <td>$date</td>\n"; |
361 |
print " <td>$email</td>\n"; |
print " <td>$email</td>\n"; |
362 |
|
|
363 |
|
# print the piece of form allowing deletion of the name |
364 |
print " <td>\n " . start_form, " ", |
print " <td>\n " . start_form, " ", |
365 |
"password: ", |
"password: ", |
366 |
password_field({name=>'del_password',size=>8,maxlength=>8}), "\n ", |
password_field({name=>'del_password',size=>8,maxlength=>8}), "\n ", |
375 |
|
|
376 |
} |
} |
377 |
|
|
378 |
sub load_config { |
sub load_data { |
379 |
my ($latitude, $longitude, $name, $password, $date, $email); |
my ($latitude, $longitude, $name, $password, $date, $email); |
380 |
|
|
381 |
unless (open (CFG, $filename)) { |
unless (open (CFG, $filename)) { |
398 |
sub delete_name { |
sub delete_name { |
399 |
my ($latitude, $longitude, $name, $crypted_passwd, $date, $email); |
my ($latitude, $longitude, $name, $crypted_passwd, $date, $email); |
400 |
|
|
401 |
load_config(); |
load_data(); |
402 |
|
|
403 |
# check if password match |
# check if password match |
404 |
($crypted_passwd) = (split /,/ , $people{param('name')})[3]; |
($crypted_passwd) = (split /,/ , $people{param('name')})[3]; |