Merge branch 'bug-1394' into testserver-stable
[cacert-devel.git] / pages / account / 53.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 $town = array_key_exists('town',$_REQUEST)?mysql_real_escape_string(stripslashes($_REQUEST['town'])):"";
20 $regid = array_key_exists('regid',$_REQUEST)?intval($_REQUEST['regid']):0;
21 $ccid = array_key_exists('ccid',$_REQUEST)?intval($_REQUEST['ccid']):0;
22 $start = array_key_exists('start',$_REQUEST)?intval($_REQUEST['start']):0;
23 $limit = 25;
24
25 echo "<div id='listshow'><ul class='top'>\n<li>";
26 echo "<a href='account.php?id=53'>"._("Home")."</a>\n";
27
28 $display = "";
29
30 if($regid > 0)
31 {
32 $reg = mysql_fetch_assoc(mysql_query("select * from `regions` where `id`='$regid'"));
33 $display = "<ul class='top'>\n<li>\n".
34 "<a href='account.php?id=53&amp;regid=$regid'>".sanitizeHTML($reg['name'])."</a> - <a href='account.php?action=add&amp;id=54&amp;regid=$regid'>"._("Add")."</a>\n".
35 $display;
36 $ccid = $_REQUEST['ccid'] = intval($reg['ccid']);
37 }
38
39 if($ccid > 0)
40 {
41 $cnt = mysql_fetch_assoc(mysql_query("select * from `countries` where `id`='$ccid'"));
42 $display = "<ul class='top'>\n<li>\n".
43 "<a href='account.php?id=53&amp;ccid=$ccid'>".sanitizeHTML($cnt['name'])."</a> - <a href='account.php?action=add&amp;id=54&amp;ccid=$ccid'>"._("Add")."</a>\n".
44 $display;
45 }
46
47 if($display)
48 echo $display;
49
50 if($ccid <= 0)
51 {
52 echo "<ul>\n";
53 $query = "select * from `countries` order by `name`";
54 $res = mysql_query($query);
55 while($row = mysql_fetch_assoc($res))
56 echo "<li><a href='account.php?id=53&amp;ccid=".intval($row['id'])."'>".sanitizeHTML($row['name'])."</a></li>\n";
57
58 echo "</ul>\n</li>\n</ul></div>\n<br>\n";
59 } elseif($regid <= 0) {
60 echo "<ul>\n";
61 $query = "select * from `regions` where `ccid`='$ccid' order by `name`";
62 $res = mysql_query($query);
63 while($row = mysql_fetch_assoc($res))
64 {
65 echo "<li>( <a href='account.php?action=edit&amp;id=54&regid=".intval($row['id'])."'>"._("edit")."</a> |";
66 echo " <a href='account.php?action=delete&amp;id=53&regid=".intval($row['id'])."'";
67 echo " onclick=\"return confirm('"._("Are you sure you want to delete this region and all connected locations?")."');\">"._("delete")."</a> )";
68 echo " <a href='account.php?id=53&amp;regid=".intval($row['id'])."'>".sanitizeHTML($row['name'])."</a></li>\n";
69 }
70
71 echo "</ul>\n</li>\n</ul>\n</li>\n</ul></div>\n<br>\n";
72 } elseif(intval(array_key_exists('locid',$_REQUEST)?$_REQUEST['locid']:0) <= 0) {
73 echo "<ul>\n";
74 if($town != "")
75 {
76 $query = "select * from `locations` where `regid`='$regid' and `name` < '$town'";
77 $start = mysql_num_rows(mysql_query($query));
78 }
79 $query = "select * from `locations` where `regid`='$regid' order by `name` limit $start, $limit";
80 $res = mysql_query($query);
81 while($row = mysql_fetch_assoc($res))
82 {
83 echo "<li>( <a href='account.php?action=move&amp;id=54&amp;locid=".intval($row['id'])."'>"._("move")."</a> |";
84 echo " <a href='account.php?action=aliases&amp;id=54&amp;locid=".intval($row['id'])."'>"._("aliases")."</a> |";
85 echo " <a href='account.php?action=edit&amp;id=54&amp;locid=".intval($row['id'])."'>"._("edit")."</a> |";
86 echo " <a href='account.php?action=delete&amp;id=53&amp;locid=".intval($row['id'])."'";
87 echo " onclick=\"return confirm('Are you sure you want to delete this location?');\">"._("delete")."</a> ) ".sanitizeHTML($row['name'])." (".sanitizeHTML($row['lat']).",".sanitizeHTML($row['long']).")</li>\n";
88 }
89
90 echo "</ul>\n</li>\n</ul>\n</li>\n</ul></div>\n<br>\n";
91 $st="";$prev="";$end="";$next="";
92 $rc = mysql_num_rows(mysql_query("select * from `locations` where `regid`='$regid'"));
93 if($start > 0)
94 {
95 $prev = $start - $limit;
96 if($prev < 0)
97 $prev = 0;
98
99 $st = "[ <a href='account.php?id=53&amp;regid=$regid'><< "._("Start")."</a> ] ";
100 $prev = "[ <a href='account.php?id=53&amp;regid=$regid&amp;start=$prev'>< "._("Previous")." $limit</a> ] ";
101 }
102 if($start < $rc - $limit)
103 {
104 $next = $start + $limit;
105 $last = $rc - $limit;
106
107 $next = "[ <a href='account.php?id=53&amp;regid=$regid&amp;start=$next'>"._("Next")." $limit ></a> ] ";
108 $end = "[ <a href='account.php?id=53&amp;regid=$regid&amp;start=$last'>"._("End")." >></a> ]";
109 }
110 echo "<div id='search1'>$st</div><div id='search3'>$end</div>\n";
111 echo "<div id='search2'>$prev</div><div id='search4'>$next</div>\n";
112 }
113 ?>