source: trunk/client/modules/Elezioni/rss.php@ 418

Last change on this file since 418 was 418, checked in by roby, 6 months ago
  • CLIENT

-- attivato l'rss per la pagina principale
-- eliminata una query non più in uso per il tema Futura2

  • INSTALL

-- corretta la creazione di una tabella del db

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