source code taken from cacert-20100805.tar.bz2
[cacert-devel.git] / pages / wot / 7-old.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 exit;
20 if($_GET['action'] != "update")
21 {
22 $total1 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `users`.`id`=`notary`.`to`
23 group by `notary`.`to` HAVING SUM(`points`) >= 100"));
24
25 $town = mysql_escape_string(stripslashes($_GET['town']));
26 $start = intval($_GET['start']);
27 $limit = 25;
28
29 echo "<div id='listshow'><ul class='top'>\n<li>";
30 echo "<a href='wot.php?id=7'>"._("Home")." ("._("Listed").": $total1)</a>\n";
31
32 $display = "";
33 $ccid=intval($_GET['ccid']);
34 $locid=intval($_GET['locid']);
35 $regid=intval($_GET['regid']);
36
37 if($locid > 0)
38 {
39 $total4 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `locid`='".$locid."' and
40 `users`.`id`=`notary`.`to` group by `notary`.`to` HAVING SUM(`points`) >= 100"));
41 $loc = mysql_fetch_assoc(mysql_query("select * from `locations` where `id`='".$locid."'"));
42 $display = "<ul class='top'>\n<li>\n".
43 "<a href='wot.php?id=7&locid=".$locid."'>$loc[name] ("._("Listed").": $total4)</a>\n".
44 $display;
45 $regid = $loc['regid'];
46 }
47
48 if($regid > 0)
49 {
50 $total3 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `regid`='".$regid."' and
51 `users`.`id`=`notary`.`to` group by `notary`.`to` HAVING SUM(`points`) >= 100"));
52 $reg = mysql_fetch_assoc(mysql_query("select * from `regions` where `id`='".$regid."'"));
53 $display = "<ul class='top'>\n<li>\n".
54 "<a href='wot.php?id=7&regid=".$regid."'>$reg[name] ("._("Listed").": $total3)</a>\n".
55 $display;
56 $ccid = $reg['ccid'];
57 }
58
59 if($ccid > 0)
60 {
61 $total2 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and
62 `ccid`='".$ccid."' and `users`.`id`=`notary`.`to`
63 group by `notary`.`to` HAVING SUM(`points`) >= 100"));
64 $cnt = mysql_fetch_assoc(mysql_query("select * from `countries` where `id`='".$ccid."'"));
65 $display = "<ul class='top'>\n<li>\n".
66 "<a href='wot.php?id=7&ccid=".$ccid."'>$cnt[name] ("._("Listed").": $total2)</a>\n".
67 $display;
68 }
69
70 if($display)
71 echo $display;
72
73 if($ccid <= 0)
74 {
75 echo "<ul>\n";
76 $query = "select * from `countries` order by `name`";
77 $res = mysql_query($query);
78 while($row = mysql_fetch_assoc($res))
79 echo "<li><a href='wot.php?id=7&ccid=$row[id]'>$row[name]</a></li>\n";
80
81 echo "</ul>\n</li>\n</ul></div>\n<br>\n";
82 } elseif($regid <= 0) {
83 echo "<ul>\n";
84 $query = "select * from `regions` where `ccid`='".$ccid."' order by `name`";
85 $res = mysql_query($query);
86 while($row = mysql_fetch_assoc($res))
87 echo "<li><a href='wot.php?id=7&regid=$row[id]'>$row[name]</a></li>\n";
88
89 echo "</ul>\n</li>\n</ul>\n</li>\n</ul></div>\n<br>\n";
90 } elseif($locid <= 0) {
91 echo "<ul>\n";
92 if($town != "")
93 {
94 $query = "select * from `locations` where `regid`='".$regid."' and `name` < '$town'";
95 $start = mysql_num_rows(mysql_query($query));
96 }
97 $query = "select * from `locations` where `regid`='".$regid."' order by `name` limit $start, $limit";
98 $res = mysql_query($query);
99 while($row = mysql_fetch_assoc($res))
100 echo "<li><a href='wot.php?id=7&locid=$row[id]'>$row[name]</a></li>\n";
101
102 echo "</ul>\n</li>\n</ul>\n</li>\n</ul></div>\n<br>\n";
103 $rc = mysql_num_rows(mysql_query("select * from `locations` where `regid`='".$regid."'"));
104 if($start > 0)
105 {
106 $prev = $start - $limit;
107 if($prev < 0)
108 $prev = 0;
109
110 $st = "[ <a href='wot.php?id=7&regid=".$regid."'><< Start</a> ] ";
111 $prev = "[ <a href='wot.php?id=7&regid=".$regid."&start=$prev'>< Previous $limit</a> ] ";
112 }
113 if($start < $rc - $limit)
114 {
115 $next = $start + $limit;
116 $last = $rc - $limit;
117
118 $next = "[ <a href='wot.php?id=7&regid=".$regid."&start=$next'>Next $limit ></a> ] ";
119 $end = "[ <a href='wot.php?id=7&regid=".$regid."&start=$last'>End >></a> ]";
120 }
121 echo "<div id='search1'>$st</div><div id='search3'>$end</div>\n";
122 echo "<div id='search2'>$prev</div><div id='search4'>$next</div>\n";
123 ?>
124 <div align="left">
125 <form method="get" action="wot.php">
126 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper" width="200">
127 <tr>
128 <td colspan="2" class="title"><?=_("Search this region")?></td>
129 </tr>
130 <tr>
131 <td class="DataTD" width="125"><?=_("Location Name")?>: </td>
132 <td class="DataTD" width="125"><input type="text" name="town" value="<?=sanitizeHTML($_GET['town'])?>" size="10"></td>
133 </tr>
134 <tr>
135 <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?=_("Search")?>"></td>
136 </tr>
137 </table>
138 <input type="hidden" name="regid" value="<?=$regid?>">
139 <input type="hidden" name="id" value="7">
140 </form>
141 </div>
142 <?
143 } else {
144 echo "</ul>\n</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n<br>\n";
145 echo "<p><a href='wot.php?id=7&action=update&locid=".$locid."'>";
146 echo _("Make my location here");
147 echo "</a></p>\n";
148 echo "<p>"._("If you are happy with this location, click 'Make my location here' to update your location details.")."</p><br>\n";
149 }
150 } else {
151 $total1 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `users`.`id`=`notary`.`to`
152 group by `notary`.`to` HAVING SUM(`points`) >= 100"));
153
154 if($locid > 0)
155 {
156 $total4 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `locid`='".$locid."' and
157 `users`.`id`=`notary`.`to` group by `notary`.`to` HAVING SUM(`points`) >= 100"));
158 $loc = mysql_fetch_assoc(mysql_query("select * from `locations` where `id`='".$locid."'"));
159 $regid = $loc['regid'];
160 }
161
162 if($regid) > 0)
163 {
164 $total3 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `regid`='".$regid."' and
165 `users`.`id`=`notary`.`to` group by `notary`.`to` HAVING SUM(`points`) >= 100"));
166 $reg = mysql_fetch_assoc(mysql_query("select * from `regions` where `id`='".$regid."'"));
167 $ccid = $reg['ccid'];
168 }
169
170 $total2 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and
171 `ccid`='".$ccid."' and `users`.`id`=`notary`.`to`
172 group by `notary`.`to` HAVING SUM(`points`) >= 100"));
173
174 $_SESSION['profile']['ccid'] = $ccid;
175 $_SESSION['profile']['regid'] = $regid;
176 $_SESSION['profile']['locid'] = $locid;
177
178 mysql_query("update `users` set `ccid`='".$ccid."',`regid`='".$regid."',`locid`='".$locid."'
179 where `id`='".$_SESSION['profile']['id']."'");
180
181 echo _("Your details have been updated.");
182 }
183 ?>