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

Last change on this file since 250 was 145, checked in by luciano, 13 years ago

correzione data nel feed

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