/*
LibreSSL - CAcert web application
Copyright (C) 2004-2008 CAcert Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ ?>
exit;
if($_GET['action'] != "update")
{
$total1 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `users`.`id`=`notary`.`to`
group by `notary`.`to` HAVING SUM(`points`) >= 100"));
$town = mysql_escape_string(stripslashes($_GET['town']));
$start = intval($_GET['start']);
$limit = 25;
echo "
\n- ";
echo ""._("Home")." ("._("Listed").": $total1)\n";
$display = "";
$ccid=intval($_GET['ccid']);
$locid=intval($_GET['locid']);
$regid=intval($_GET['regid']);
if($locid > 0)
{
$total4 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `locid`='".$locid."' and
`users`.`id`=`notary`.`to` group by `notary`.`to` HAVING SUM(`points`) >= 100"));
$loc = mysql_fetch_assoc(mysql_query("select * from `locations` where `id`='".$locid."'"));
$display = "
\n- \n".
"$loc[name] ("._("Listed").": $total4)\n".
$display;
$regid = $loc['regid'];
}
if($regid > 0)
{
$total3 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `regid`='".$regid."' and
`users`.`id`=`notary`.`to` group by `notary`.`to` HAVING SUM(`points`) >= 100"));
$reg = mysql_fetch_assoc(mysql_query("select * from `regions` where `id`='".$regid."'"));
$display = "
\n- \n".
"$reg[name] ("._("Listed").": $total3)\n".
$display;
$ccid = $reg['ccid'];
}
if($ccid > 0)
{
$total2 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and
`ccid`='".$ccid."' and `users`.`id`=`notary`.`to`
group by `notary`.`to` HAVING SUM(`points`) >= 100"));
$cnt = mysql_fetch_assoc(mysql_query("select * from `countries` where `id`='".$ccid."'"));
$display = "
\n- \n".
"$cnt[name] ("._("Listed").": $total2)\n".
$display;
}
if($display)
echo $display;
if($ccid <= 0)
{
echo "
\n";
$query = "select * from `countries` order by `name`";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res))
echo "- $row[name]
\n";
echo "
\n \n
\n
\n";
} elseif($regid <= 0) {
echo "\n";
$query = "select * from `regions` where `ccid`='".$ccid."' order by `name`";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res))
echo "- $row[name]
\n";
echo "
\n\n\n\n\n
\n";
} elseif($locid <= 0) {
echo "\n";
if($town != "")
{
$query = "select * from `locations` where `regid`='".$regid."' and `name` < '$town'";
$start = mysql_num_rows(mysql_query($query));
}
$query = "select * from `locations` where `regid`='".$regid."' order by `name` limit $start, $limit";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res))
echo "- $row[name]
\n";
echo "
\n\n\n\n\n
\n";
$rc = mysql_num_rows(mysql_query("select * from `locations` where `regid`='".$regid."'"));
if($start > 0)
{
$prev = $start - $limit;
if($prev < 0)
$prev = 0;
$st = "[ << Start ] ";
$prev = "[ < Previous $limit ] ";
}
if($start < $rc - $limit)
{
$next = $start + $limit;
$last = $rc - $limit;
$next = "[ Next $limit > ] ";
$end = "[ End >> ]";
}
echo "$st
$end
\n";
echo "$prev
$next
\n";
?>
} else {
echo "\n\n\n\n\n\n\n
\n";
echo "";
echo _("Make my location here");
echo "
\n";
echo ""._("If you are happy with this location, click 'Make my location here' to update your location details.")."
\n";
}
} else {
$total1 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `users`.`id`=`notary`.`to`
group by `notary`.`to` HAVING SUM(`points`) >= 100"));
if($locid > 0)
{
$total4 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `locid`='".$locid."' and
`users`.`id`=`notary`.`to` group by `notary`.`to` HAVING SUM(`points`) >= 100"));
$loc = mysql_fetch_assoc(mysql_query("select * from `locations` where `id`='".$locid."'"));
$regid = $loc['regid'];
}
if($regid) > 0)
{
$total3 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and `regid`='".$regid."' and
`users`.`id`=`notary`.`to` group by `notary`.`to` HAVING SUM(`points`) >= 100"));
$reg = mysql_fetch_assoc(mysql_query("select * from `regions` where `id`='".$regid."'"));
$ccid = $reg['ccid'];
}
$total2 = mysql_num_rows(mysql_query("select * from `users`,`notary` where `listme`='1' and
`ccid`='".$ccid."' and `users`.`id`=`notary`.`to`
group by `notary`.`to` HAVING SUM(`points`) >= 100"));
$_SESSION['profile']['ccid'] = $ccid;
$_SESSION['profile']['regid'] = $regid;
$_SESSION['profile']['locid'] = $locid;
mysql_query("update `users` set `ccid`='".$ccid."',`regid`='".$regid."',`locid`='".$locid."'
where `id`='".$_SESSION['profile']['id']."'");
echo _("Your details have been updated.");
}
?>