forked from seanlebeck/site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cities.inc.php
128 lines (90 loc) · 3.37 KB
/
cities.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
require_once("initvars.inc.php");
require_once("config.inc.php");
?>
<center>
<table><tr><td valign="top" align="left">
<?php
// Show city list
if($location_sort)
{
$sort1 = "ORDER BY countryname";
$sort2 = "ORDER BY cityname";
}
else
{
$sort1 = "ORDER BY c.pos";
$sort2 = "ORDER BY ct.pos";
}
if ($show_region_adcount || $show_city_adcount)
{
// First get ads per city and country
$country_adcounts = array();
$city_adcounts = array();
$sql = "SELECT ct.cityid, c.countryid, COUNT(*) as adcnt
FROM $t_ads a
INNER JOIN $t_cities ct ON ct.cityid = a.cityid AND ($visibility_condn)
INNER JOIN $t_countries c ON ct.countryid = c.countryid
WHERE ct.enabled = '1' AND c.enabled = '1'
GROUP BY ct.cityid";
$res = mysql_query($sql) or die(mysql_error().$sql);
while($row=mysql_fetch_array($res))
{
$country_adcounts[$row['countryid']] += $row['adcnt'];
$city_adcounts[$row['cityid']] += $row['adcnt'];
}
$sql = "SELECT ct.cityid, c.countryid, COUNT(*) as adcnt
FROM $t_events a
INNER JOIN $t_cities ct ON ct.cityid = a.cityid AND ($visibility_condn)
INNER JOIN $t_countries c ON ct.countryid = c.countryid
WHERE ct.enabled = '1' AND c.enabled = '1'
GROUP BY ct.cityid";
$res = mysql_query($sql) or die(mysql_error().$sql);
while($row=mysql_fetch_array($res))
{
$country_adcounts[$row['countryid']] += $row['adcnt'];
$city_adcounts[$row['cityid']] += $row['adcnt'];
}
}
$sql = "SELECT * FROM $t_countries c INNER JOIN $t_cities ct ON c.countryid = ct.countryid AND ct.enabled = '1' WHERE c.enabled = '1' GROUP BY c.countryid $sort1";
$resc = mysql_query($sql);
$country_count = mysql_num_rows($resc);
//$split_at = ($country_count%3?((int)($country_count/3))+2:($country_count/3)+1);
$percol = floor($country_count/$location_cols);
$percolA = array();
for($i=1;$i<=$location_cols;$i++) $percolA[$i]=$percol+($i<=$country_count%$location_cols?1:0);
$i = 0; $j = 0;
$col = 1;
while($country = mysql_fetch_array($resc))
{
$country_url = buildURL("main", array((0-$country['countryid']), $country['countryname']));
?>
<div style="padding:3px;"><a STYLE="font-size:14px;font-weight:bold;" href="<?php echo $country_url; ?>" class=""><?php echo $country['countryname']; ?> <?php if($show_region_adcount) echo "(".(0+$country_adcounts[$country['countryid']]).")"; ?></a></div>
<?php
if($country['countryid'] == $xcountryid || !$expand_current_region_only)
{
$sql = "SELECT * FROM $t_cities ct WHERE countryid = $country[countryid] AND enabled = '1' $sort2";
$resct = mysql_query($sql);
$citycount = mysql_num_rows($resct);
while($city=mysql_fetch_array($resct))
{
if ($shortcut_regions && $citycount == 1
&& $city['cityname'] == $country['countryname']) {
continue;
}
$city_url = buildURL("main", array($city['cityid'], $city['cityname']));
/* End Version 5.0 */
?>
<span style="color:orange;">•</span><a href="<?php echo $city_url; ?>" class=""><?php echo $city['cityname']; ?> <?php if($show_city_adcount) echo "(".(0+$city_adcounts[$city['cityid']]).")"; ?></a><br>
<?php
}
}
?>
<?php
$i++; $j++;
//if($i%$split_at == 0) echo "</td><td valign=\"top\">";
if ($j%$percolA[$col]==0 && $i<$country_count) { echo "</td><td valign=\"top\">"; $col++; $j=0; }
}
?>
</td></tr></table>
</center>