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 | if(isset($gruppo) and count($gruppo)){
|
---|
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 | //echo "<guid isPermaLink=\"false\">noreply@ciao.it</guid>\n";
|
---|
75 | echo "<dc:subject>$titolo</dc:subject>\n";
|
---|
76 | echo "<dc:date>".$now."</dc:date>\n";
|
---|
77 | echo "<dc:creator>Postato da ".$sitename."</dc:creator>\n";
|
---|
78 | echo "</item>\n\n";
|
---|
79 | }
|
---|
80 | }else{
|
---|
81 | echo "<item>\n";
|
---|
82 | echo "<title>Attendere l'inizio dello scrutinio</title>\n";
|
---|
83 | echo "<link>https://$siteurl?op=rss&rss=1&name=Elezioni&id_comune=$id_comune&file=index&id_cons_gen=$id_cons_gen</link>\n";
|
---|
84 | echo "<guid>https://$siteurl?op=rss&rss=1&name=Elezioni&id_comune=$id_comune&file=index&id_cons_gen=$id_cons_gen</guid>\n";
|
---|
85 | echo "<dc:subject>$titolo</dc:subject>\n";
|
---|
86 | echo "<dc:date>".$now."</dc:date>\n";
|
---|
87 | echo "<dc:creator>Postato da ".$sitename."</dc:creator>\n";
|
---|
88 | echo "</item>\n\n";
|
---|
89 | }
|
---|
90 | echo "</channel>\n";
|
---|
91 | echo "</rss>\n";
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 | // gruppo
|
---|
97 | function grupporss(){
|
---|
98 | 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;
|
---|
99 | $gruppo=array();$pro=array();$idg=array();$titolo='';
|
---|
100 | if ($genere!=0){$tab="ele_voti_gruppo";}
|
---|
101 | if ($genere==4){$tab="ele_voti_lista";}
|
---|
102 | if ($votog or $id_gruppo){$tab="ele_voti_lista";}
|
---|
103 | if($id_gruppo) $idgrp="and t1.id_gruppo='$id_gruppo'"; else $idgrp='';
|
---|
104 | $sql="select id_sez from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
|
---|
105 | $res = $dbi->prepare("$sql");
|
---|
106 | $res->execute();
|
---|
107 | if ($res) $numero=$res->rowCount();else $numero=0;
|
---|
108 | $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";
|
---|
109 | $res = $dbi->prepare("$sql");
|
---|
110 | $res->execute();
|
---|
111 | if ($res) $sezioni=$res->rowCount();else $sezioni=0;
|
---|
112 | if ($numero>0){
|
---|
113 | if ($genere!=0){
|
---|
114 | // tot voti
|
---|
115 | if (!$circo)
|
---|
116 | $sql="select sum(voti) from ".$prefix."_$tab where id_cons=$id_cons ";
|
---|
117 | if ($votog)
|
---|
118 | $sql="select sum(voti) from ".$prefix."_ele_voti_lista where id_cons=$id_cons ";
|
---|
119 | $restotv = $dbi->prepare("$sql");
|
---|
120 | $restotv->execute();
|
---|
121 | list($tot) = $restotv->fetch(PDO::FETCH_NUM);
|
---|
122 | $i=0;
|
---|
123 | // lista o gruppo
|
---|
124 | if ($genere!=4 and !$id_gruppo){
|
---|
125 | if ($votog){
|
---|
126 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
127 | from ".$prefix."_ele_gruppo as t1,
|
---|
128 | ".$prefix."_ele_voti_lista as t2,
|
---|
129 | ".$prefix."_ele_lista as t3
|
---|
130 | where t1.id_cons='$id_cons'
|
---|
131 | and t2.id_lista=t3.id_lista
|
---|
132 | and t1.id_gruppo=t3.id_gruppo
|
---|
133 | group by t1.id_gruppo
|
---|
134 | order by somma desc";
|
---|
135 | $res = $dbi->prepare("$sql");
|
---|
136 | $res->execute();
|
---|
137 | $cosa='id_gruppo';
|
---|
138 | }else{
|
---|
139 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
140 | from ".$prefix."_ele_gruppo as t1
|
---|
141 | left join ".$prefix."_$tab as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
142 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
143 | group by t1.id_gruppo,t1.num_gruppo,t1.descrizione
|
---|
144 | order by somma desc";
|
---|
145 | $res = $dbi->prepare("$sql");
|
---|
146 | $res->execute();
|
---|
147 | $cosa='id_gruppo';
|
---|
148 | }
|
---|
149 | }else{
|
---|
150 | $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
|
---|
151 | from ".$prefix."_ele_lista as t1
|
---|
152 | left join ".$prefix."_$tab as t2 on (t1.id_lista=t2.id_lista)
|
---|
153 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $idgrp
|
---|
154 | group by t1.id_lista,t1.num_lista,t1.descrizione
|
---|
155 | order by somma desc";
|
---|
156 | $res = $dbi->prepare("$sql");
|
---|
157 | $res->execute();
|
---|
158 | $cosa='id_lista';
|
---|
159 | }
|
---|
160 |
|
---|
161 | # $gruppinum=$res->fetch(PDO::FETCH_NUM);
|
---|
162 | $altrivoti=0;
|
---|
163 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
164 | // funz per il taglio corretto della frase 13 feb 2007
|
---|
165 | $gruppo[$i]=substr($descrizione,0,25);
|
---|
166 | //if (strlen($descrizione)>25) $gruppo[$i].="...";
|
---|
167 | $pro[$i]=number_format($voti*100/$tot,2);
|
---|
168 | $idg[$i]=$id;
|
---|
169 | $i++;
|
---|
170 | }
|
---|
171 | include_once("language/lang-$lang.php");
|
---|
172 | $titolo=""._PERCE." "._VOTIE."";
|
---|
173 | return array($gruppo,$pro,$titolo,$idg);
|
---|
174 | }
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | ?>
|
---|