-
Notifications
You must be signed in to change notification settings - Fork 10
/
widget.php
147 lines (120 loc) · 3.56 KB
/
widget.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
require_once ('../../varie.php');
if (array_key_exists ('html', $_GET) == true)
$html = $_GET ['html'];
else
$html = false;
$head = 'true';
$head_color = '000080';
$foot = 'true';
if ($html == true)
$endline = '';
else
$endline = "\\";
$page =<<<PAGE
<div style="border: 3px solid #000000; font-family: Helvetica; font-size: 12px; text-align: center;"> $endline
PAGE;
/**
REGIONE NON VALIDA
**/
if (array_key_exists ('region', $_GET) == false || (in_array ($_GET ['region'], array_keys ($elenco_regioni)) == false) && $_GET ['region'] != 'all') {
$page .=<<<PAGE
<div style="margin: 5px; padding: 3px; background-color: #F54B4B;"> $endline
<p>Oops, non hai specificato alcuna regione valida.</p> $endline
</div>
PAGE;
}
else {
if ($_GET ['region'] == 'all') {
$lugs = array ();
foreach (glob ('../../db/*.txt') as $db_file) {
$lugs = array_merge ($lugs, file ($db_file));
sort ($lugs);
}
$regionname = 'tutta Italia';
}
else {
$lugs = file ('../../db/' . ($_GET ['region']) . '.txt', FILE_IGNORE_NEW_LINES);
$regionname = $elenco_regioni [$_GET ['region']];
}
/**
REGIONE SENZA LUG
**/
if ($lugs == false || count ($lugs) == 0) {
$page .=<<<PAGE
<div style="margin: 5px; padding: 3px; background-color: #F54B4B;"> $endline
<p>Non sembrano esserci LUG in $regionname.</p> $endline
<p><a style="text-decoration: none;" href="http://www.badpenguin.org/italian-lug-howto" target="_blank">Creane uno!</a></p> $endline
</div>
PAGE;
}
/**
ELENCO VALIDO
**/
else {
if (array_key_exists ('head', $_GET) == true)
$head = $_GET ['head'];
if (array_key_exists ('head_color', $_GET) == true)
$head_color = $_GET ['head_color'];
if (array_key_exists ('foot', $_GET) == true)
$foot = $_GET ['foot'];
if ($head == 'true') {
$page .=<<<PAGE
<div style="font-weight: bold; background-color: $head_color; color: #FFFFFF; border: 1px solid black; padding: 5px;"> $endline
<p>Cerchi un Linux Users Group in $regionname?</p> $endline
</div> $endline
PAGE;
}
$page .=<<<PAGE
<table style="border-collapse: collapse; margin: auto; padding: 10px; width: 100%;">
PAGE;
$nriga = 0;
while (list ($nriga, $lug) = each ($lugs)) {
$data = explode ('|', $lug);
if ($nriga % 2)
$css = 'background-color: #EEEEEE';
else
$css = 'background-color: #DDDDDD';
$city = ($html == false) ? addslashes ($data [0]) : $data [0];
$name = ($html == false) ? addslashes ($data [1]) : $data [1];
$link = ($html == false) ? addslashes ($data [3]) : $data [3];
$page .=<<<PAGE
<tr style="font-family: Helvetica; font-size: 12px; text-align: center; $css;"> $endline
<td style="padding: 5px; border: 1px solid black; font-weight: bold;">$city</td> $endline
<td style="padding: 5px; border: 1px solid black;"><a style="text-decoration: none;" href="$link" target="_blank">$name</a></td> $endline
</tr>
PAGE;
}
$page .=<<<PAGE
</table>
PAGE;
}
}
/**
FOOTER COMUNE
**/
if ($foot == 'true') {
$page .=<<<PAGE
<div style="margin-top: 5px; font-style: italic; color: #000000; font-weight: bold;"> $endline
Powered by <a style="color: #FF0000; text-decoration: none;" href="http://lugmap.it/">lugmap.it</a> $endline
</div> $endline
</div>
PAGE;
}
if ($html == true) {
echo $page;
}
else {
header ('Content-Type: application/javascript');
?>
function renderLugMap () {
var holder = document.getElementById('lugmap');
map = document.createElement('div');
map.innerHTML = '<?php echo $page ?>';
holder.parentNode.insertBefore(map, holder);
holder.parentNode.removeChild(holder);
map.setAttribute('id', 'lugmap');
}
<?php
}
?>