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
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);
[418]29//URL
30$PHP_SELF=$_SERVER['PHP_SELF'];
31$siteurl.=$PHP_SELF;
[2]32
[418]33echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
[2]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";
[418]38echo " xmlns:atom=\"http://www.w3.org/2005/Atom\"\n";
[2]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";
[418]42echo "<link>https://".htmlspecialchars($siteurl)."</link>\n";
[2]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";
[418]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";
[2]51
[418]52list ($gruppo,$pro,$titolo,$idg)=grupporss();
[2]53
54
55for($x=0;$x<count($gruppo);$x++){
56
57 // format: 2004-08-02T12:15:23-06:00
[145]58 //$date = date("Y-m-d\TH:i:s", strtotime($time));
59 //$date = $date . $gmtstr;
[2]60
61 echo "<item>\n";
62 echo "<title>".$gruppo[$x]." ".$pro[$x] ."% </title>\n";
[418]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";
[2]65
[390]66# echo "<description><![CDATA['aa']]></description>\n";
[2]67
68
69
70
71
72 //echo "<guid isPermaLink=\"false\">noreply@ciao.it</guid>\n";
[390]73 echo "<dc:subject>$titolo</dc:subject>\n";
[145]74 echo "<dc:date>".$now."</dc:date>\n";
[2]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(){
[390]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;
[2]88
89
[390]90
[2]91
92 if ($genere!=0){$tab="ele_voti_gruppo";}
93 if ($genere==4){$tab="ele_voti_lista";}
94 if ($votog){$tab="ele_voti_lista";}
[418]95 $sql="select id_sez from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
[265]96 $res = $dbi->prepare("$sql");
97 $res->execute();
98
[2]99
[265]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;
[2]106
107 if ($numero>0){
108 if ($genere!=0){
109 // tot voti
110 if (!$circo)
[265]111 $sql="select sum(voti) from ".$prefix."_$tab where id_cons=$id_cons ";
[2]112 if ($votog)
[265]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);
[2]117
118 $i=0;
119 // lista o gruppo
120 if ($genere!=4){
121
122 if ($votog){
123
[265]124 $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
[2]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
[265]132 order by somma desc";
133 $res = $dbi->prepare("$sql");
134 $res->execute();
135 $cosa='id_gruppo';
[2]136
137 }else{
138
139
[265]140 $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
[2]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
[418]144 group by t1.id_gruppo,t1.num_gruppo,t1.descrizione
[265]145 order by somma desc";
146 $res = $dbi->prepare("$sql");
147 $res->execute();
148 $cosa='id_gruppo';
[2]149 }
150
151
152 }else{
[265]153 $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
[2]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
[418]157 group by t1.id_lista,t1.num_lista,t1.descrizione
[265]158 order by somma desc";
159 $res = $dbi->prepare("$sql");
160 $res->execute();
161 $cosa='id_lista';
[2]162 }
163
164
165
[390]166# $gruppinum=$res->fetch(PDO::FETCH_NUM);
[2]167 $altrivoti=0;
[265]168 while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
[2]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
[418]182 $idg[$i]=$id;
[2]183
184
185
186
187
188 $i++;
189 }
190
191
192
[390]193 include_once("language/lang-$lang.php");
[2]194 $titolo=""._PERCE." "._VOTIE."";
195
196
197
198
199
200
201
[418]202 return array($gruppo,$pro,$titolo,$idg);
[2]203
204
205
206 }
207
208 }
209
210
211}
212
213
214
215?>
Note: See TracBrowser for help on using the repository browser.