1 | <?php
|
---|
2 |
|
---|
3 | /************************************************************************/
|
---|
4 | /* Eleonline - Raccolta e diffusione dei dati elettorali */
|
---|
5 | /* by Luciano Apolito & Roberto Gigli */
|
---|
6 | /* http://www.eleonline.it */
|
---|
7 | /* info@eleonline.it luciano@aniene.net rgigli@libero.it */
|
---|
8 | /************************************************************************/
|
---|
9 | /* Ultima modifica 22 aprile 2008 */
|
---|
10 |
|
---|
11 | $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ?
|
---|
12 | $_GET : $_POST;
|
---|
13 |
|
---|
14 |
|
---|
15 | #header('Content-Type: text/html;');
|
---|
16 | header("Content-Type: text/xml");
|
---|
17 |
|
---|
18 | // data
|
---|
19 | $gmtdiff = date("O", time());
|
---|
20 | $gmtstr = substr($gmtdiff, 0, 3) . ":" . substr($gmtdiff, 3, 9);
|
---|
21 | $now = date("Y-m-d\TH:i:s", time());
|
---|
22 | $now = $now . $gmtstr;
|
---|
23 | // comune
|
---|
24 | $sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
|
---|
25 | $res = $dbi->prepare("$sql");
|
---|
26 | $res->execute();
|
---|
27 |
|
---|
28 | list($descr_com) = $res->fetch(PDO::FETCH_NUM);
|
---|
29 |
|
---|
30 |
|
---|
31 |
|
---|
32 | echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
|
---|
33 | echo "<rss version=\"2.0\" \n";
|
---|
34 | echo " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
|
---|
35 | echo " xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"\n";
|
---|
36 | echo " xmlns:admin=\"http://webns.net/mvcb/\"\n";
|
---|
37 | echo " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n\n";
|
---|
38 | echo "<channel>\n";
|
---|
39 | echo "<title>".htmlspecialchars($descr_com)." - $descr_cons</title>\n";
|
---|
40 | echo "<link>".htmlspecialchars($siteurl)."</link>\n";
|
---|
41 | echo "<description>".$sitename."</description>\n";
|
---|
42 | echo "<dc:language>it-IT</dc:language>\n";
|
---|
43 | echo "<dc:creator>".$adminmail."</dc:creator>\n";
|
---|
44 | echo "<dc:date>".$now."</dc:date>\n\n";
|
---|
45 | echo "<sy:updatePeriod>hourly</sy:updatePeriod>\n";
|
---|
46 | echo "<sy:updateFrequency>1</sy:updateFrequency>\n";
|
---|
47 | echo "<sy:updateBase>".$now."</sy:updateBase>\n\n";
|
---|
48 |
|
---|
49 | list ($gruppo,$pro,$titolo)=grupporss();
|
---|
50 |
|
---|
51 |
|
---|
52 | for($x=0;$x<count($gruppo);$x++){
|
---|
53 |
|
---|
54 | // format: 2004-08-02T12:15:23-06:00
|
---|
55 | //$date = date("Y-m-d\TH:i:s", strtotime($time));
|
---|
56 | //$date = $date . $gmtstr;
|
---|
57 |
|
---|
58 | echo "<item>\n";
|
---|
59 | echo "<title>".$gruppo[$x]." ".$pro[$x] ."% </title>\n";
|
---|
60 | echo "<link>$siteurl/modules.php?id_cons_gen=$id_cons_gen&name=Elezioni&id_comune=$id_comune&file=index</link>\n";
|
---|
61 |
|
---|
62 | # echo "<description><![CDATA['aa']]></description>\n";
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 | //echo "<guid isPermaLink=\"false\">noreply@ciao.it</guid>\n";
|
---|
69 | echo "<dc:subject>$titolo</dc:subject>\n";
|
---|
70 | echo "<dc:date>".$now."</dc:date>\n";
|
---|
71 | echo "<dc:creator>Postato da ".$sitename."</dc:creator>\n";
|
---|
72 | echo "</item>\n\n";
|
---|
73 | }
|
---|
74 |
|
---|
75 | echo "</channel>\n";
|
---|
76 | echo "</rss>\n";
|
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|
80 |
|
---|
81 | // gruppo
|
---|
82 | function grupporss(){
|
---|
83 | global $admin, $bgcolor1, $bgcolor5, $prefix, $dbi, $offset, $min,$descr_cons,$genere,$votog,$votol,$votoc,$circo, $id_cons,$id_cons_gen,$id_comune,$id_circ,$tipo_cons,$w,$l,$op,$siteistat,$flash,$circondt1,$lang;
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 | if ($genere!=0){$tab="ele_voti_gruppo";}
|
---|
89 | if ($genere==4){$tab="ele_voti_lista";}
|
---|
90 | if ($votog){$tab="ele_voti_lista";}
|
---|
91 | $sql="select * from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
|
---|
92 | $res = $dbi->prepare("$sql");
|
---|
93 | $res->execute();
|
---|
94 |
|
---|
95 |
|
---|
96 | if ($res) $numero=$res->rowCount();else $numero=0;
|
---|
97 | $sql="select t2.* from ".$prefix."_ele_sezioni as t2, ".$prefix."_ele_sede as t1 where t2.id_cons='$id_cons' and t1.id_sede=t2.id_sede $circondt1";
|
---|
98 | $res = $dbi->prepare("$sql");
|
---|
99 | $res->execute();
|
---|
100 |
|
---|
101 | if ($res) $sezioni=$res->rowCount();else $sezioni=0;
|
---|
102 |
|
---|
103 | if ($numero>0){
|
---|
104 | if ($genere!=0){
|
---|
105 | // tot voti
|
---|
106 | if (!$circo)
|
---|
107 | $sql="select sum(voti) from ".$prefix."_$tab where id_cons=$id_cons ";
|
---|
108 | if ($votog)
|
---|
109 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons ";
|
---|
110 | $restotv = $dbi->prepare("$sql");
|
---|
111 | $restotv->execute();
|
---|
112 | list($tot) = $restotv->fetch(PDO::FETCH_NUM);
|
---|
113 |
|
---|
114 | $i=0;
|
---|
115 | // lista o gruppo
|
---|
116 | if ($genere!=4){
|
---|
117 |
|
---|
118 | if ($votog){
|
---|
119 |
|
---|
120 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
121 | from ".$prefix."_ele_gruppo as t1,
|
---|
122 | ".$prefix."_ele_voti_lista as t2,
|
---|
123 | ".$prefix."_ele_lista as t3
|
---|
124 | where t1.id_cons='$id_cons'
|
---|
125 | and t2.id_lista=t3.id_lista
|
---|
126 | and t1.id_gruppo=t3.id_gruppo
|
---|
127 | group by t1.id_gruppo
|
---|
128 | order by somma desc";
|
---|
129 | $res = $dbi->prepare("$sql");
|
---|
130 | $res->execute();
|
---|
131 | $cosa='id_gruppo';
|
---|
132 |
|
---|
133 | }else{
|
---|
134 |
|
---|
135 |
|
---|
136 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
137 | from ".$prefix."_ele_gruppo as t1
|
---|
138 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
139 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
140 | group by t2.id_gruppo
|
---|
141 | order by somma desc";
|
---|
142 | $res = $dbi->prepare("$sql");
|
---|
143 | $res->execute();
|
---|
144 | $cosa='id_gruppo';
|
---|
145 | }
|
---|
146 |
|
---|
147 |
|
---|
148 | }else{
|
---|
149 | $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
|
---|
150 | from ".$prefix."_ele_lista as t1
|
---|
151 | left join ".$prefix."_$tab as t2 on (t1.id_lista=t2.id_lista)
|
---|
152 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons
|
---|
153 | group by t2.id_lista
|
---|
154 | order by somma desc";
|
---|
155 | $res = $dbi->prepare("$sql");
|
---|
156 | $res->execute();
|
---|
157 | $cosa='id_lista';
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 |
|
---|
162 | # $gruppinum=$res->fetch(PDO::FETCH_NUM);
|
---|
163 | $altrivoti=0;
|
---|
164 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
165 |
|
---|
166 |
|
---|
167 |
|
---|
168 | // funz per il taglio corretto della frase 13 feb 2007
|
---|
169 |
|
---|
170 | $gruppo[$i]=substr($descrizione,0,25);
|
---|
171 |
|
---|
172 | //if (strlen($descrizione)>25) $gruppo[$i].="...";
|
---|
173 |
|
---|
174 | $pro[$i]=number_format($voti*100/$tot,2);
|
---|
175 |
|
---|
176 |
|
---|
177 |
|
---|
178 |
|
---|
179 |
|
---|
180 |
|
---|
181 |
|
---|
182 |
|
---|
183 |
|
---|
184 | $i++;
|
---|
185 | }
|
---|
186 |
|
---|
187 |
|
---|
188 |
|
---|
189 | include_once("language/lang-$lang.php");
|
---|
190 | $titolo=""._PERCE." "._VOTIE."";
|
---|
191 |
|
---|
192 |
|
---|
193 |
|
---|
194 |
|
---|
195 |
|
---|
196 |
|
---|
197 |
|
---|
198 | return array($gruppo,$pro,$titolo);
|
---|
199 |
|
---|
200 |
|
---|
201 |
|
---|
202 | }
|
---|
203 |
|
---|
204 | }
|
---|
205 |
|
---|
206 |
|
---|
207 | }
|
---|
208 |
|
---|
209 |
|
---|
210 |
|
---|
211 | ?>
|
---|