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

Last change on this file since 392 was 390, checked in by roby, 21 months ago
  • CLIENT
  • aggiunta la visualizzazione dei voti al solo gruppo nelle schede dei risultati
File size: 5.8 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
[390]15#header('Content-Type: text/html;');
[2]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
[265]24$sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
25$res = $dbi->prepare("$sql");
26$res->execute();
[2]27
[265]28 list($descr_com) = $res->fetch(PDO::FETCH_NUM);
[2]29
30
[265]31
[2]32echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
33echo "<rss version=\"2.0\" \n";
34echo " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
35echo " xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"\n";
36echo " xmlns:admin=\"http://webns.net/mvcb/\"\n";
37echo " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n\n";
38echo "<channel>\n";
39echo "<title>".htmlspecialchars($descr_com)." - $descr_cons</title>\n";
40echo "<link>".htmlspecialchars($siteurl)."</link>\n";
41echo "<description>".$sitename."</description>\n";
42echo "<dc:language>it-IT</dc:language>\n";
43echo "<dc:creator>".$adminmail."</dc:creator>\n";
44echo "<dc:date>".$now."</dc:date>\n\n";
45echo "<sy:updatePeriod>hourly</sy:updatePeriod>\n";
46echo "<sy:updateFrequency>1</sy:updateFrequency>\n";
47echo "<sy:updateBase>".$now."</sy:updateBase>\n\n";
48
[390]49list ($gruppo,$pro,$titolo)=grupporss();
[2]50
51
52for($x=0;$x<count($gruppo);$x++){
53
54 // format: 2004-08-02T12:15:23-06:00
[145]55 //$date = date("Y-m-d\TH:i:s", strtotime($time));
56 //$date = $date . $gmtstr;
[2]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&amp;name=Elezioni&amp;id_comune=$id_comune&amp;file=index</link>\n";
61
[390]62# echo "<description><![CDATA['aa']]></description>\n";
[2]63
64
65
66
67
68 //echo "<guid isPermaLink=\"false\">noreply@ciao.it</guid>\n";
[390]69 echo "<dc:subject>$titolo</dc:subject>\n";
[145]70 echo "<dc:date>".$now."</dc:date>\n";
[2]71 echo "<dc:creator>Postato da ".$sitename."</dc:creator>\n";
72 echo "</item>\n\n";
73}
74
75echo "</channel>\n";
76echo "</rss>\n";
77
78
79
80
81// gruppo
82function grupporss(){
[390]83global $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;
[2]84
85
[390]86
[2]87
88 if ($genere!=0){$tab="ele_voti_gruppo";}
89 if ($genere==4){$tab="ele_voti_lista";}
90 if ($votog){$tab="ele_voti_lista";}
[265]91 $sql="select * from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
92 $res = $dbi->prepare("$sql");
93 $res->execute();
94
[2]95
[265]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;
[2]102
103 if ($numero>0){
104 if ($genere!=0){
105 // tot voti
106 if (!$circo)
[265]107 $sql="select sum(voti) from ".$prefix."_$tab where id_cons=$id_cons ";
[2]108 if ($votog)
[265]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);
[2]113
114 $i=0;
115 // lista o gruppo
116 if ($genere!=4){
117
118 if ($votog){
119
[265]120 $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
[2]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
[265]128 order by somma desc";
129 $res = $dbi->prepare("$sql");
130 $res->execute();
131 $cosa='id_gruppo';
[2]132
133 }else{
134
135
[265]136 $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
[2]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
[265]141 order by somma desc";
142 $res = $dbi->prepare("$sql");
143 $res->execute();
144 $cosa='id_gruppo';
[2]145 }
146
147
148 }else{
[265]149 $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
[2]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
[265]154 order by somma desc";
155 $res = $dbi->prepare("$sql");
156 $res->execute();
157 $cosa='id_lista';
[2]158 }
159
160
161
[390]162# $gruppinum=$res->fetch(PDO::FETCH_NUM);
[2]163 $altrivoti=0;
[265]164 while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
[2]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
[390]189 include_once("language/lang-$lang.php");
[2]190 $titolo=""._PERCE." "._VOTIE."";
191
192
193
194
195
196
197
[390]198 return array($gruppo,$pro,$titolo);
[2]199
200
201
202 }
203
204 }
205
206
207}
208
209
210
211?>
Note: See TracBrowser for help on using the repository browser.