753b4af43c6c0ec043827ce3d774f278358cf802
[cacert-devel.git] / pages / account / 54.php
1 <? /*
2 LibreSSL - CAcert web application
3 Copyright (C) 2004-2008 CAcert Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */ ?>
18 <?
19 $ccid = array_key_exists('ccid',$_REQUEST)?intval($_REQUEST['ccid']):0;
20 $regid = array_key_exists('regid',$_REQUEST)?intval($_REQUEST['regid']):0;
21 $locid = array_key_exists('locid',$_REQUEST)?intval($_REQUEST['locid']):0;
22 $name = array_key_exists('name',$_REQUEST)?mysql_escape_string($_REQUEST['name']):"";
23
24 if($ccid > 0 && $_REQUEST['action'] == "add") { ?>
25 <form method="post" action="account.php">
26 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
27 <tr>
28 <td colspan="2" class="title"><?=_("Add Region")?></td>
29 </tr>
30 <tr>
31 <td class="DataTD"><?=_("Region")?>:</td>
32 <td class="DataTD"><input type="text" name="name" value="<?=sanitizeHTML($name)?>"></td>
33 </tr>
34 <tr>
35 <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?=_("Add")?>"></td>
36 </tr>
37 </table>
38 <input type="hidden" name="action" value="add">
39 <input type="hidden" name="ccid" value="<?=$ccid?>">
40 <input type="hidden" name="oldid" value="54">
41 </form>
42 <? } if($regid > 0 && $_REQUEST['action'] == "edit") {
43 $query = "select * from `regions` where `id`='$regid' order by `name`";
44 $row = mysql_fetch_assoc(mysql_query($query));
45 $name = $row['name'];
46 ?>
47 <form method="post" action="account.php">
48 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
49 <tr>
50 <td colspan="2" class="title"><?=_("Edit Region")?></td>
51 </tr>
52 <tr>
53 <td class="DataTD"><?=_("Region")?>:</td>
54 <td class="DataTD"><input type="text" name="name" value="<?=sanitizeHTML($name)?>"></td>
55 </tr>
56 <tr>
57 <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?=_("Update")?>"></td>
58 </tr>
59 </table>
60 <input type="hidden" name="action" value="edit">
61 <input type="hidden" name="regid" value="<?=$regid?>">
62 <input type="hidden" name="oldid" value="54">
63 </form>
64 <? } if($regid > 0 && $_REQUEST['action'] == "add") { ?>
65 <form method="post" action="account.php">
66 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
67 <tr>
68 <td colspan="2" class="title"><?=_("Add Location")?></td>
69 </tr>
70 <tr>
71 <td class="DataTD"><?=_("Location")?>:</td>
72 <td class="DataTD"><input type="text" name="name" value="<?=sanitizeHTML($name)?>"></td>
73 </tr>
74 <tr>
75 <td class="DataTD"><?=_("Longitude")?>:</td>
76 <td class="DataTD"><input type="text" name="longitude" value="<?=array_key_exists('longitude',$_REQUEST)?sanitizeHTML($_REQUEST['longitude']):""?>"></td>
77 </tr>
78 <tr>
79 <td class="DataTD"><?=_("Latitude")?>:</td>
80 <td class="DataTD"><input type="text" name="latitude" value="<?=array_key_exists('latitude',$_REQUEST)?sanitizeHTML($_REQUEST['latitude']):""?>"></td>
81 </tr>
82 <tr>
83 <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?=_("Add")?>"></td>
84 </tr>
85 </table>
86 <input type="hidden" name="action" value="add">
87 <input type="hidden" name="regid" value="<?=$regid?>">
88 <input type="hidden" name="oldid" value="54">
89 </form>
90 <? } if($locid > 0 && $_REQUEST['action'] == "edit") {
91 $query = "select * from `locations` where `id`='$locid'";
92 $row = mysql_fetch_assoc(mysql_query($query));
93
94 if($name == "")
95 $name = $row['name'];
96 if(!array_key_exists('longitude',$_REQUEST) || $_REQUEST['longitude'] == "")
97 $_REQUEST['longitude'] = $row['long'];
98 if(!array_key_exists('latitude',$_REQUEST) || $_REQUEST['latitude'] == "")
99 $_REQUEST['latitude'] = $row['lat'];
100 ?>
101 <form method="post" action="account.php">
102 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
103 <tr>
104 <td colspan="2" class="title"><?=_("Edit Location")?></td>
105 </tr>
106 <tr>
107 <td class="DataTD"><?=_("Location")?>:</td>
108 <td class="DataTD"><input type="text" name="name" value="<?=sanitizeHTML($name)?>"></td>
109 </tr>
110 <tr>
111 <td class="DataTD"><?=_("Longitude")?>:</td>
112 <td class="DataTD"><input type="text" name="longitude" value="<?=sanitizeHTML($_REQUEST['longitude'])?>"></td>
113 </tr>
114 <tr>
115 <td class="DataTD"><?=_("Latitude")?>:</td>
116 <td class="DataTD"><input type="text" name="latitude" value="<?=sanitizeHTML($_REQUEST['latitude'])?>"></td>
117 </tr>
118 <tr>
119 <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?=_("Update")?>"></td>
120 </tr>
121 </table>
122 <input type="hidden" name="action" value="edit">
123 <input type="hidden" name="locid" value="<?=$locid?>">
124 <input type="hidden" name="oldid" value="54">
125 </form>
126 <? } if($locid > 0 && $_REQUEST['action'] == "aliases") {
127 $query = "select * from `localias` where `locid`='".intval($locid)."'";
128 $res = mysql_query($query);
129 $rc = mysql_num_rows($res);
130 ?>
131 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
132 <tr>
133 <td colspan="2" class="title"><?=_("Location Aliases")?> - <a href="javascript:Show_Stuff()"><?=_("Add")?></a></td>
134 </tr>
135 <tr ID="display1">
136 <td colspan="2" class="DataTD">
137 <form method="post" action="account.php" ACCEPTCHARSET="utf-8">
138 <?=_("Location Alias")?>: <input type="text" name="name"> <input type="submit" value="Add">
139 <input type="hidden" name="action" value="alias">
140 <input type="hidden" name="locid" value="<?=intval($locid)?>">
141 <input type="hidden" name="oldid" value="54">
142 </form>
143 </td>
144 </tr>
145 <?
146 while($row = mysql_fetch_assoc($res))
147 {
148 ?>
149 <tr>
150 <td class="DataTD"><?=$row['name']?></td>
151 <td class="DataTD"><a href="account.php?id=54&amp;locid=<?=$locid?>&amp;name=<?=($row['name'])?>&amp;action=delalias" onclick="return confirm('Are you sure you want to delete this location alias?');"><?=_("Delete")?></td>
152 </tr>
153 <? } ?>
154 </table>
155 <script language="JavaScript" type="text/javascript">
156 <!--
157 function Show_Stuff()
158 {
159 if (document.getElementById("display1").style.display == "none")
160 {
161 document.getElementById("display1").style.display = "";
162 } else {
163 document.getElementById("display1").style.display = "none";
164 }
165 }
166
167 document.getElementById("display1").style.display = "none";
168 -->
169 </script>
170 <? } if($locid > 0 && $_REQUEST['action'] == "move") {
171 $query = "select * from `locations` where `id`='$locid'";
172 $row = mysql_fetch_assoc(mysql_query($query));
173 $newreg = $_REQUEST['newreg'] = $row['regid'];
174 ?>
175 <form method="post" action="account.php">
176 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
177 <tr>
178 <td colspan="2" class="title"><?=_("Move Location")?></td>
179 </tr>
180 <tr>
181 <td class="DataTD"><?=_("Location")?>:</td>
182 <td class="DataTD"><?=$row['name']?></td>
183 </tr>
184 <tr>
185 <td class="DataTD"><?=_("Set Region")?>:</td>
186 <td class="DataTD"><select name="newreg">
187 <?
188 $query = "select * from `regions` where `ccid`='".intval($row['ccid'])."' order by `name`";
189 $res = mysql_query($query);
190 while($row = mysql_fetch_assoc($res))
191 {
192 echo "<option value='".intval($row['id'])."'";
193 if($_REQUEST['newreg'] == $row['id'])
194 echo " selected='selected'";
195 echo ">$row[name]</option>\n";
196 }
197 ?>
198 </select></td>
199 </tr>
200 <tr>
201 <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?=_("Update")?>"></td>
202 </tr>
203 </table>
204 <input type="hidden" name="action" value="move">
205 <input type="hidden" name="locid" value="<?=$locid?>">
206 <input type="hidden" name="oldid" value="54">
207 </form>
208 <? } ?>
209