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 | //URL
|
---|
30 | $PHP_SELF=$_SERVER['PHP_SELF'];
|
---|
31 | $siteurl.=$PHP_SELF;
|
---|
32 |
|
---|
33 | echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
---|
34 | echo "<rss version=\"2.0\" \n";
|
---|
35 | echo " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
|
---|
36 | echo " xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"\n";
|
---|
37 | echo " xmlns:admin=\"http://webns.net/mvcb/\"\n";
|
---|
38 | echo " xmlns:atom=\"http://www.w3.org/2005/Atom\"\n";
|
---|
39 | echo " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n\n";
|
---|
40 | echo "<channel>\n";
|
---|
41 | echo "<title>".htmlspecialchars($descr_com)." - $descr_cons</title>\n";
|
---|
42 | echo "<link>https://".htmlspecialchars($siteurl)."</link>\n";
|
---|
43 | echo "<description>".$sitename."</description>\n";
|
---|
44 | echo "<dc:language>it-IT</dc:language>\n";
|
---|
45 | echo "<dc:creator>".$adminmail."</dc:creator>\n";
|
---|
46 | echo "<dc:date>".$now."</dc:date>\n\n";
|
---|
47 | echo "<sy:updatePeriod>hourly</sy:updatePeriod>\n";
|
---|
48 | echo "<sy:updateFrequency>1</sy:updateFrequency>\n";
|
---|
49 | echo "<sy:updateBase>".$now."</sy:updateBase>\n\n";
|
---|
50 | echo "<atom:link href=\"https://$siteurl?op=rss&rss=1&name=Elezioni&id_comune=$id_comune&file=index&id_cons_gen=$id_cons_gen\" rel=\"self\" type=\"application/rss+xml\" />\n";
|
---|
51 |
|
---|
52 | $id_gruppo = isset($param['id_gruppo']) ? intval($param['id_gruppo']) : 0;
|
---|
53 | list ($gruppo,$pro,$titolo,$idg)=grupporss();
|
---|
54 | #else
|
---|
55 | # list ($gruppo,$pro,$titolo,$idg)=grupporss();
|
---|
56 |
|
---|
57 |
|
---|
58 | for($x=0;$x<count($gruppo);$x++){
|
---|
59 |
|
---|
60 | // format: 2004-08-02T12:15:23-06:00
|
---|
61 | //$date = date("Y-m-d\TH:i:s", strtotime($time));
|
---|
62 | //$date = $date . $gmtstr;
|
---|
63 |
|
---|
64 | echo "<item>\n";
|
---|
65 | echo "<title>".$gruppo[$x]." ".$pro[$x] ."% </title>\n";
|
---|
66 | if ($genere==4){
|
---|
67 | echo "<link>https://$siteurl?op=rss&rss=1&name=Elezioni&id_comune=$id_comune&file=index&id_cons_gen=$id_cons_gen&id_lista=$idg[$x]</link>\n";
|
---|
68 | echo "<guid>https://$siteurl?op=rss&rss=1&name=Elezioni&id_comune=$id_comune&file=index&id_cons_gen=$id_cons_gen&id_lista=$idg[$x]</guid>\n";
|
---|
69 | }else{
|
---|
70 | echo "<link>https://$siteurl?op=rss&rss=1&name=Elezioni&id_comune=$id_comune&file=index&id_cons_gen=$id_cons_gen&id_gruppo=$idg[$x]</link>\n";
|
---|
71 | echo "<guid>https://$siteurl?op=rss&rss=1&name=Elezioni&id_comune=$id_comune&file=index&id_cons_gen=$id_cons_gen&id_gruppo=$idg[$x]</guid>\n";
|
---|
72 | }
|
---|
73 | # echo "<description><![CDATA['aa']]></description>\n";
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 |
|
---|
79 | //echo "<guid isPermaLink=\"false\">noreply@ciao.it</guid>\n";
|
---|
80 | echo "<dc:subject>$titolo</dc:subject>\n";
|
---|
81 | echo "<dc:date>".$now."</dc:date>\n";
|
---|
82 | echo "<dc:creator>Postato da ".$sitename."</dc:creator>\n";
|
---|
83 | echo "</item>\n\n";
|
---|
84 | }
|
---|
85 |
|
---|
86 | echo "</channel>\n";
|
---|
87 | echo "</rss>\n";
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 | // gruppo
|
---|
93 | function grupporss(){
|
---|
94 | 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,$id_gruppo;
|
---|
95 | if ($genere!=0){$tab="ele_voti_gruppo";}
|
---|
96 | if ($genere==4){$tab="ele_voti_lista";}
|
---|
97 | if ($votog or $id_gruppo){$tab="ele_voti_lista";}
|
---|
98 | if($id_gruppo) $idgrp="and t1.id_gruppo='$id_gruppo'"; else $idgrp='';
|
---|
99 | $sql="select id_sez from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
|
---|
100 | $res = $dbi->prepare("$sql");
|
---|
101 | $res->execute();
|
---|
102 | if ($res) $numero=$res->rowCount();else $numero=0;
|
---|
103 | $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";
|
---|
104 | $res = $dbi->prepare("$sql");
|
---|
105 | $res->execute();
|
---|
106 | if ($res) $sezioni=$res->rowCount();else $sezioni=0;
|
---|
107 | if ($numero>0){
|
---|
108 | if ($genere!=0){
|
---|
109 | // tot voti
|
---|
110 | if (!$circo)
|
---|
111 | $sql="select sum(voti) from ".$prefix."_$tab where id_cons=$id_cons ";
|
---|
112 | if ($votog)
|
---|
113 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons ";
|
---|
114 | $restotv = $dbi->prepare("$sql");
|
---|
115 | $restotv->execute();
|
---|
116 | list($tot) = $restotv->fetch(PDO::FETCH_NUM);
|
---|
117 | $i=0;
|
---|
118 | // lista o gruppo
|
---|
119 | if ($genere!=4 and !$id_gruppo){
|
---|
120 | if ($votog){
|
---|
121 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
122 | from ".$prefix."_ele_gruppo as t1,
|
---|
123 | ".$prefix."_ele_voti_lista as t2,
|
---|
124 | ".$prefix."_ele_lista as t3
|
---|
125 | where t1.id_cons='$id_cons'
|
---|
126 | and t2.id_lista=t3.id_lista
|
---|
127 | and t1.id_gruppo=t3.id_gruppo
|
---|
128 | group by t1.id_gruppo
|
---|
129 | order by somma desc";
|
---|
130 | $res = $dbi->prepare("$sql");
|
---|
131 | $res->execute();
|
---|
132 | $cosa='id_gruppo';
|
---|
133 | }else{
|
---|
134 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
135 | from ".$prefix."_ele_gruppo as t1
|
---|
136 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
137 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
138 | group by t1.id_gruppo,t1.num_gruppo,t1.descrizione
|
---|
139 | order by somma desc";
|
---|
140 | $res = $dbi->prepare("$sql");
|
---|
141 | $res->execute();
|
---|
142 | $cosa='id_gruppo';
|
---|
143 | }
|
---|
144 | }else{
|
---|
145 | $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
|
---|
146 | from ".$prefix."_ele_lista as t1
|
---|
147 | left join ".$prefix."_$tab as t2 on (t1.id_lista=t2.id_lista)
|
---|
148 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $idgrp
|
---|
149 | group by t1.id_lista,t1.num_lista,t1.descrizione
|
---|
150 | order by somma desc";
|
---|
151 | $res = $dbi->prepare("$sql");
|
---|
152 | $res->execute();
|
---|
153 | $cosa='id_lista';
|
---|
154 | }
|
---|
155 |
|
---|
156 | # $gruppinum=$res->fetch(PDO::FETCH_NUM);
|
---|
157 | $altrivoti=0;
|
---|
158 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
159 | // funz per il taglio corretto della frase 13 feb 2007
|
---|
160 | $gruppo[$i]=substr($descrizione,0,25);
|
---|
161 | //if (strlen($descrizione)>25) $gruppo[$i].="...";
|
---|
162 | $pro[$i]=number_format($voti*100/$tot,2);
|
---|
163 | $idg[$i]=$id;
|
---|
164 | $i++;
|
---|
165 | }
|
---|
166 | include_once("language/lang-$lang.php");
|
---|
167 | $titolo=""._PERCE." "._VOTIE."";
|
---|
168 | return array($gruppo,$pro,$titolo,$idg);
|
---|
169 | }
|
---|
170 | }
|
---|
171 | }
|
---|
172 |
|
---|
173 | ?>
|
---|