[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 |
|
---|
| 10 |
|
---|
| 11 | /*******************************************************
|
---|
| 12 | #'Pagina precedente' e 'Pagina Successiva' #
|
---|
| 13 | immettere nel file da dividere la lettura
|
---|
| 14 | del numero complessivo dei dati:
|
---|
| 15 | Es: $max=sql_num_rows($res);
|
---|
| 16 |
|
---|
| 17 | l'offset settato al numero dei dati da
|
---|
| 18 | visualizzare per pagina:
|
---|
| 19 | Es: $offset=5;
|
---|
| 20 |
|
---|
| 21 | l'azzeramento della variabile $min
|
---|
| 22 | Es: if (!isset($min)) $min=0;
|
---|
| 23 |
|
---|
| 24 | il nome del file (opzione) da ricaricare)
|
---|
| 25 | Es: $file="gruppopercsez"; // nome op per pagine
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | function page($id_cons,$go,$max,$min,$prev,$next,$offset,$file){
|
---|
| 33 | global $lettera,$ordine,$id_comune;
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | echo"<br /><div class=\"modulo\">";
|
---|
| 37 | $prev=$min-$offset;
|
---|
| 38 | if ($prev>=0) {
|
---|
| 39 | echo "<a href=\"modules.php?name=Elezioni&op=$go&min=$prev&id_cons_gen=$id_cons&id_comune=$id_comune&file=$file&lettera=$lettera&ordine=$ordine\">";
|
---|
| 40 | echo "[ <b>$offset "._PREV_MATCH."</b> ]</a>";
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | $next=$min+$offset;
|
---|
| 44 | if ($next>=($offset-1)) {
|
---|
| 45 | if($next>=$max) $next = $max;
|
---|
| 46 | else {
|
---|
| 47 |
|
---|
| 48 | echo "<a href=\"modules.php?name=Elezioni&op=$go&min=$next&id_cons_gen=$id_cons&id_comune=$id_comune&file=$file&lettera=$lettera&ordine=$ordine\">";
|
---|
| 49 | echo " [<b>$offset "._NEXT_MATCH."</b> ] </a>";
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
| 52 | echo "</div><br /><br/>";
|
---|
| 53 |
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | // *********************************
|
---|
| 61 | // Funzioni formattazione data
|
---|
| 62 | // ***********************************
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | function giorno()
|
---|
| 66 | {
|
---|
| 67 | $giorni= array('--','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');
|
---|
| 68 | foreach($giorni as $gi)
|
---|
| 69 | $giorno .= "<option value=$gi>$gi</option>";
|
---|
| 70 | $giorno .= "</select>";
|
---|
| 71 | echo "$giorno";
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 | function mese()
|
---|
| 76 | {
|
---|
| 77 | $mesi= array('--','01','02','03','04','05','06','07','08','09','10','11','12');
|
---|
| 78 | foreach($mesi as $me)
|
---|
| 79 | $mese .= "<option value=$me>$me </option>";
|
---|
| 80 | $mese .= "</select>";
|
---|
| 81 | echo "$mese";
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | function anno()
|
---|
| 85 | {
|
---|
| 86 | $curr=date("Y",time());
|
---|
| 87 | $anni=array('--',$curr--,$curr--,$curr--,$curr--,$curr--,$curr--,$curr--);
|
---|
| 88 | foreach($anni as $an)
|
---|
| 89 | $anno .= "<option value=$an>$an</option>";
|
---|
| 90 | $anno .= "</select>";
|
---|
| 91 | echo "$anno";
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | function ore()
|
---|
| 95 | {
|
---|
| 96 | $ore= array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24');
|
---|
| 97 | foreach($ore as $ori)
|
---|
| 98 | $ore .= "<option value=$ori>$ori</option>";
|
---|
| 99 | $ore .= "</select>";
|
---|
| 100 | echo "$ore";
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | function minuti()
|
---|
| 105 | {
|
---|
| 106 | $minuti= array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14',
|
---|
| 107 | '15', '16', '17', '18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33',
|
---|
| 108 | '34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50',
|
---|
| 109 | '51','52','53','54','55','56','57','58','59');
|
---|
| 110 | foreach($minuti as $minu)
|
---|
| 111 | $minuti .= "<option value=$minu>$minu </option>";
|
---|
| 112 | $minuti .= "</select>";
|
---|
| 113 | echo "$minuti";
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | function secondi()
|
---|
| 117 | {
|
---|
| 118 | $secondi= array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14',
|
---|
| 119 | '15', '16', '17', '18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33',
|
---|
| 120 | '34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50',
|
---|
| 121 | '51','52','53','54','55','56','57','58','59');
|
---|
| 122 | foreach($secondi as $sec)
|
---|
| 123 | $secondi .= "<option value=$sec>$sec</option>";
|
---|
| 124 | $secondi .= "</select>";
|
---|
| 125 | echo "$secondi";
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 |
|
---|
| 130 | function form_data($data)
|
---|
| 131 |
|
---|
| 132 | {
|
---|
| 133 | list($anno,$mese,$giorno) = explode("-", $data) ;
|
---|
| 134 | if ($giorno>0)
|
---|
| 135 | return("$giorno-$mese-$anno");
|
---|
| 136 | else
|
---|
| 137 | return(" ");
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 | function taglio($parole,$descrizione)
|
---|
| 142 | {
|
---|
| 143 |
|
---|
| 144 | /* funzione per il taglio di una frase giusta senza
|
---|
| 145 | troncare le parole by luc 13 febbraio 2007
|
---|
| 146 | uso:
|
---|
| 147 | taglio(numero di parole, frase)
|
---|
| 148 | */
|
---|
| 149 |
|
---|
| 150 | $lunghezza=strlen($descrizione);
|
---|
| 151 | $altra='0';
|
---|
| 152 | $testo='';
|
---|
| 153 | $lettera='';
|
---|
| 154 |
|
---|
| 155 |
|
---|
| 156 | for ($x=0;$x<$parole;$x++){
|
---|
| 157 | if($testo!='')$testo .=" ";
|
---|
| 158 |
|
---|
| 159 | for ($j=$altra;$j<$lunghezza;$j++){
|
---|
[344] | 160 | $lettera=$descrizione[$j];
|
---|
[2] | 161 | if ($lettera!=" "){
|
---|
| 162 | $testo .=$lettera;
|
---|
| 163 | }else{
|
---|
| 164 | $altra=$j+1; $j=$lunghezza;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | }
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 |
|
---|
| 171 | return "$testo";
|
---|
| 172 |
|
---|
| 173 | }
|
---|
| 174 | #### legge freed rss 1.0
|
---|
| 175 |
|
---|
| 176 | function readrss($url) {
|
---|
| 177 |
|
---|
| 178 |
|
---|
| 179 | $rdf = parse_url($url);
|
---|
| 180 | $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
|
---|
| 181 | if (!$fp) {
|
---|
| 182 | $content = "";
|
---|
| 183 | echo $content;
|
---|
| 184 | return;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | if ($fp) {
|
---|
| 188 | if (!empty($rdf['query']))
|
---|
| 189 | $rdf['query'] = "?" . $rdf['query'];
|
---|
| 190 |
|
---|
| 191 | fputs($fp, "GET " . $rdf['path'] . $rdf['query'] . " HTTP/1.0\r\n");
|
---|
| 192 | fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
|
---|
| 193 | $string = "";
|
---|
| 194 |
|
---|
| 195 | while(!feof($fp)) {
|
---|
| 196 | $pagetext = fgets($fp,300);
|
---|
| 197 | $string .= chop($pagetext);
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 |
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | fputs($fp,"Connection: close\r\n\r\n");
|
---|
| 204 | fclose($fp);
|
---|
| 205 | $items = explode("</item>",$string);
|
---|
| 206 | $content ="<h5>Risultati </h5>";
|
---|
| 207 | $content .= "<span class=\"content\">";
|
---|
| 208 |
|
---|
| 209 | for ($i=0;$i<20;$i++) {
|
---|
[25] | 210 | $link = preg_replace("/.*<link>/","",$items[$i]);
|
---|
[26] | 211 | $link = preg_replace("/</link>.*/","",$link);
|
---|
[25] | 212 | $title2 = preg_replace("/.*<title>/","",$items[$i]);
|
---|
| 213 | $title2 = preg_replace("/</title>.*/","",$title2);
|
---|
[2] | 214 | $title2 = stripslashes($title2);
|
---|
[25] | 215 | $descr = preg_replace("/.*<description>/","",$items[$i]);
|
---|
| 216 | $descr = preg_replace("/</description>.*/","",$descr );
|
---|
[2] | 217 | $descr = stripslashes($descr );
|
---|
| 218 |
|
---|
| 219 | if (empty($items[$i]) AND $cont != 1) {
|
---|
| 220 | $content = "";
|
---|
| 221 |
|
---|
| 222 | $cont = 0;
|
---|
| 223 |
|
---|
| 224 | echo $content;
|
---|
| 225 | return;
|
---|
| 226 | } else {
|
---|
| 227 | if (strcmp($link,$title2) AND !empty($items[$i])) {
|
---|
| 228 | $cont = 1;
|
---|
| 229 | $content .= "<strong><big>·</big></strong> <a href=\"$link\" target=\"new\">$title2</a> $descr<br />\n";
|
---|
| 230 | }
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 |
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | if (($cont == 0) OR (empty($content))) {
|
---|
| 239 | $content = "<span class=\"content\">Problema feed rss</span>";
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | echo $content;
|
---|
| 243 |
|
---|
| 244 | }
|
---|
| 245 | ### legge i risultati e li reinvia
|
---|
| 246 | ### richiamare con
|
---|
| 247 | ### list ($gruppo,$pro)=grupporss();
|
---|
| 248 |
|
---|
| 249 | function grupporss() {
|
---|
| 250 | 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 ;
|
---|
| 251 |
|
---|
[384] | 252 | if($circo and !$id_circ) $id_circ=$_SESSION['id_circ'];
|
---|
| 253 | if($genere=='4' || $votog) $tab="ele_voti_lista";
|
---|
| 254 | else $tab="ele_voti_gruppo";
|
---|
| 255 | if($circo and !$circondt1) $circondt1="and t1.id_circ=$id_circ";
|
---|
[2] | 256 |
|
---|
| 257 |
|
---|
[318] | 258 | $sql="select id_sez from ".$prefix."_$tab where id_cons='$id_cons' group by id_sez ";
|
---|
[265] | 259 | $res = $dbi->prepare("$sql");
|
---|
| 260 | $res->execute();
|
---|
| 261 |
|
---|
[279] | 262 | $numero=$res->rowCount();
|
---|
[265] | 263 | $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";
|
---|
| 264 | $res = $dbi->prepare("$sql");
|
---|
| 265 | $res->execute();
|
---|
| 266 |
|
---|
| 267 | if ($res) $sezioni=$res->rowCount();else $sezioni=0;
|
---|
[384] | 268 | $pro=array(); $gruppo=array();
|
---|
[2] | 269 | if ($numero>0){
|
---|
| 270 | if ($genere!=0){
|
---|
[265] | 271 | $sql="select sum(voti) from ".$prefix."_$tab where id_cons='$id_cons' ";
|
---|
[384] | 272 | $restotv = $dbi->prepare("$sql");
|
---|
| 273 | $restotv->execute();
|
---|
[265] | 274 |
|
---|
| 275 | list($tot) = $restotv->fetch(PDO::FETCH_NUM);
|
---|
[2] | 276 | $i=0;
|
---|
| 277 | // lista o gruppo
|
---|
| 278 | if ($genere!=4){
|
---|
| 279 | if ($votog){
|
---|
[265] | 280 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
[228] | 281 | from ".$prefix."_ele_gruppo as t1,
|
---|
| 282 | ".$prefix."_ele_voti_lista as t2,
|
---|
| 283 | ".$prefix."_ele_lista as t3
|
---|
| 284 | where t1.id_cons='$id_cons'
|
---|
| 285 | and t2.id_lista=t3.id_lista
|
---|
| 286 | and t1.id_gruppo=t3.id_gruppo
|
---|
[318] | 287 | group by t1.id_gruppo, t1.num_gruppo, t1.descrizione
|
---|
[265] | 288 | order by somma desc";
|
---|
[2] | 289 | }else{
|
---|
[265] | 290 | $sql="select t1.id_gruppo, t1.num_gruppo, t1.descrizione, sum(t2.voti) as somma
|
---|
[228] | 291 | from ".$prefix."_ele_gruppo as t1
|
---|
| 292 | left join ".$prefix."_ele_voti_gruppo as t2 on (t1.id_gruppo=t2.id_gruppo)
|
---|
| 293 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons $circondt1
|
---|
[318] | 294 | group by t1.id_gruppo, t1.num_gruppo, t1.descrizione
|
---|
[265] | 295 | order by somma desc";
|
---|
[228] | 296 | }
|
---|
[2] | 297 | }else{
|
---|
[265] | 298 | $sql="select t1.id_lista, t1.num_lista, t1.descrizione, sum(t2.voti) as somma
|
---|
[2] | 299 | from ".$prefix."_ele_lista as t1
|
---|
| 300 | left join ".$prefix."_$tab as t2 on (t1.id_lista=t2.id_lista)
|
---|
| 301 | where t1.id_cons='$id_cons' and t1.id_cons=t2.id_cons
|
---|
[318] | 302 | group by t1.id_lista, t1.num_lista, t1.descrizione
|
---|
[265] | 303 | order by somma desc";
|
---|
[2] | 304 | }
|
---|
[265] | 305 | $res = $dbi->prepare("$sql");
|
---|
| 306 | $res->execute();
|
---|
| 307 | $gruppinum=$res->rowCount();
|
---|
[2] | 308 | $altrivoti=0;
|
---|
[70] | 309 | ###### gestione percentuali
|
---|
| 310 | $arperc=array();
|
---|
| 311 | $arval=array();
|
---|
| 312 | $arvaltot=0;
|
---|
[265] | 313 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[228] | 314 | $arval[$id]=$voti;
|
---|
| 315 | $arvaltot+=$voti;
|
---|
[70] | 316 | }
|
---|
| 317 | $arperc=arrayperc($arval,$arvaltot);
|
---|
[265] | 318 | $res = $dbi->prepare("$sql");
|
---|
| 319 | $res->execute();
|
---|
| 320 | while (list($id,$num,$descrizione,$voti) = $res->fetch(PDO::FETCH_NUM)){
|
---|
[228] | 321 | // funz per il taglio corretto della frase 13 feb 2007
|
---|
| 322 | $descrizione=substr($descrizione,0,20);
|
---|
| 323 | $gruppo[$i]=ucwords(strtolower($descrizione));
|
---|
| 324 | if ($tot!='' and $tot!='0')
|
---|
| 325 | $pro[$i]=number_format($voti*100/$tot,3);
|
---|
| 326 | $pro[$i]=number_format($arperc[$id],2); // arrotondamento
|
---|
| 327 | $i++;
|
---|
| 328 | }
|
---|
[2] | 329 |
|
---|
| 330 |
|
---|
| 331 |
|
---|
| 332 |
|
---|
| 333 | $titolo=""._PERCE." "._VOTIE."";
|
---|
| 334 | return array($gruppo,$pro);
|
---|
[228] | 335 | }
|
---|
[2] | 336 |
|
---|
| 337 | }
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | function caricablocchi(){
|
---|
| 341 | #### carica i blocchi presenti in modules/Elezioni/blocchi
|
---|
| 342 | #### nome del file da carica xx_nome.php
|
---|
| 343 | #### dove xx sta per un numero per visualizzare in ordine
|
---|
| 344 | ### 01_votanto.php Ú un nome valido
|
---|
| 345 | ### off_votanto.php per disabilitare la visualizzazione
|
---|
| 346 |
|
---|
| 347 |
|
---|
| 348 |
|
---|
| 349 | $list = array();
|
---|
| 350 | $bl=opendir('modules/Elezioni/blocchi');
|
---|
| 351 | while ($file = readdir($bl)) {
|
---|
[17] | 352 | if (!is_dir("modules/Elezioni/blocchi/$file") and (!preg_match('/^\./',$file)) and !stristr($file,"off_")) {
|
---|
[2] | 353 | array_push($list, $file);
|
---|
| 354 | }
|
---|
| 355 | }
|
---|
| 356 | closedir($bl);
|
---|
| 357 |
|
---|
| 358 | if(count($list)>0)
|
---|
| 359 | sort($list);
|
---|
| 360 | for ($item_num=0; $item_num < count($list); $item_num++) {
|
---|
[17] | 361 | $tmp=preg_replace('/^[0-9][0-9]_/i',"",$list[$item_num]);
|
---|
[2] | 362 | $title=str_replace("_"," ",str_replace(".php","",$tmp));
|
---|
| 363 | // backward theme compatibility
|
---|
| 364 |
|
---|
| 365 | include ("modules/Elezioni/blocchi/$list[$item_num]");
|
---|
| 366 |
|
---|
| 367 | //echo "<br />";
|
---|
| 368 | }
|
---|
| 369 | }
|
---|
| 370 |
|
---|
| 371 | function block($pos){
|
---|
| 372 |
|
---|
| 373 | global $prefix,$dbi;
|
---|
| 374 |
|
---|
| 375 | if($pos=="dx") $p=0; elseif($pos=="sx")$p=1;else $p='';
|
---|
[101] | 376 |
|
---|
[274] | 377 | $sql="SELECT nome_file FROM ".$prefix."_ele_widget where pos_or='$p' and attivo='1' order by pos_ver asc";
|
---|
| 378 | $resp = $dbi->prepare("$sql");
|
---|
| 379 | $resp->execute();
|
---|
| 380 | if($resp->rowCount()){
|
---|
| 381 | while (list($nome) = $resp->fetch(PDO::FETCH_NUM)) {
|
---|
| 382 | # $nome=$row['nome_file'];
|
---|
[2] | 383 | include ("modules/Elezioni/blocchi/$nome");
|
---|
| 384 | }
|
---|
| 385 | }
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | function check_block($pos){
|
---|
| 389 | # verifica se ci sono blocchi nel db
|
---|
| 390 | global $prefix,$dbi;
|
---|
| 391 | if($pos=="dx") $p=0; elseif($pos=="sx")$p=1;else $p='';
|
---|
[101] | 392 |
|
---|
[265] | 393 | $sql="SELECT * FROM ".$prefix."_ele_widget where pos_or='$p' and attivo='1' order by pos_ver asc";
|
---|
| 394 | $res = $dbi->prepare("$sql");
|
---|
| 395 | $res->execute();
|
---|
| 396 | if ($res) $numero=$res->rowCount();else $numero=0;
|
---|
[2] | 397 |
|
---|
| 398 | return $numero;
|
---|
| 399 |
|
---|
| 400 | }
|
---|
[65] | 401 |
|
---|
[105] | 402 |
|
---|
[65] | 403 | function arrayperc($temp,$sevaltot)
|
---|
| 404 | {
|
---|
[105] | 405 |
|
---|
[75] | 406 | $temp2tot=0;$temp2=array();$temp3=array();
|
---|
[344] | 407 |
|
---|
| 408 | foreach($temp as $key=>$voti) {
|
---|
[76] | 409 | if($sevaltot>0){
|
---|
[78] | 410 | $temp4=(ceil($voti*10000/$sevaltot)-($voti*10000/$sevaltot));
|
---|
| 411 | if ($temp4) $temp2[$key]=$temp4;
|
---|
[76] | 412 | $valperc=number_format($voti*100/$sevaltot,2);
|
---|
| 413 | $temp3[$key]=$valperc;
|
---|
| 414 | $temp2tot+=$valperc;
|
---|
| 415 | }
|
---|
[65] | 416 | }
|
---|
[180] | 417 | if($temp2tot>100 && ($temp2tot-100)>0.01)
|
---|
| 418 | //if($temp2tot>100)
|
---|
[65] | 419 | while ($temp2tot>100){
|
---|
| 420 | foreach ($temp2 as $key => $val) {
|
---|
[66] | 421 | if ($val == max($temp2)) {$temp3[$key]-=0.01;$temp2tot-=0.01;$temp2[$key]=0; break;}
|
---|
[65] | 422 | }
|
---|
| 423 | }
|
---|
[75] | 424 | if("$temp2tot"=="100" or $temp2tot==0) return($temp3);
|
---|
[66] | 425 | while ($temp2tot<100.00){
|
---|
[65] | 426 | foreach ($temp2 as $key => $val) {
|
---|
| 427 | if ($val == min($temp2)) {$temp3[$key]+=0.01;$temp2tot+=0.01;$temp2[$key]=1;break;}
|
---|
| 428 | }
|
---|
| 429 |
|
---|
| 430 | }
|
---|
| 431 | return($temp3);
|
---|
| 432 |
|
---|
[105] | 433 |
|
---|
[65] | 434 | }
|
---|
[105] | 435 |
|
---|
| 436 | # ritorna l'estensione del file
|
---|
| 437 | function file_extension($filename)
|
---|
| 438 | {
|
---|
| 439 | $path_info = pathinfo($filename);
|
---|
| 440 | return $path_info['extension'];
|
---|
| 441 | }
|
---|
| 442 |
|
---|
| 443 |
|
---|
| 444 | # verifica stemma e lo salva come file per pdf e grafici
|
---|
| 445 | function verificasimbolo()
|
---|
| 446 | {
|
---|
| 447 | global $prefix,$dbi,$id_comune,$ins_logo;
|
---|
| 448 | if($ins_logo=="0"){
|
---|
[376] | 449 | $logo="vuoto.png"; //var nel config.php
|
---|
[105] | 450 | }else{
|
---|
| 451 |
|
---|
[265] | 452 | $sql="SELECT simbolo,stemma FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
|
---|
| 453 | $res = $dbi->prepare("$sql");
|
---|
| 454 | $res->execute();
|
---|
| 455 | list($simbolo,$stemma) = $res->fetch(PDO::FETCH_NUM);
|
---|
[105] | 456 | if($simbolo!=''){
|
---|
| 457 | if (!file_exists("modules/Elezioni/images/$simbolo")) {
|
---|
[370] | 458 | if(!is_writeable("modules/Elezioni/images"))
|
---|
| 459 | $logo="logo.gif";
|
---|
| 460 | else {
|
---|
| 461 | $filename=$simbolo;
|
---|
| 462 | $file=fopen("modules/Elezioni/images/$filename",'w');
|
---|
| 463 | if (fwrite($file,$stemma));
|
---|
| 464 | $close = fclose($file);
|
---|
| 465 | $logo=$simbolo;
|
---|
| 466 | }
|
---|
| 467 | } else $logo=$simbolo;
|
---|
[105] | 468 | }else{
|
---|
| 469 | $logo="logo.gif";
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | }return $logo;
|
---|
| 473 | }
|
---|
| 474 |
|
---|
[139] | 475 | # funzione per verifica se esiste il voto disgunto tra sindaco e lista nelle amministrative siciliane
|
---|
| 476 | function isdisgiunto(){
|
---|
| 477 | global $prefix,$dbi,$id_cons,$limite,$fascia,$ops;
|
---|
| 478 | #voti di lista e di gruppo completamente disgiunti
|
---|
[265] | 479 | $sql="select infdisgiunto, supdisgiunto from ".$prefix."_ele_conf as t2 left join ".$prefix."_ele_cons_comune as t1 on t1.id_conf=t2.id_conf where id_cons = '$id_cons' ";
|
---|
| 480 | $result = $dbi->prepare("$sql");
|
---|
| 481 | $result->execute();
|
---|
[139] | 482 | $glsep='';
|
---|
| 483 | if ($result) {
|
---|
[265] | 484 | list($infdis,$supdis)=$result->fetch(PDO::FETCH_NUM);
|
---|
[139] | 485 | if((($fascia>$limite and $supdis) or ($fascia<$limite and $infdis)) and $ops==3)
|
---|
| 486 | $glsep='_lista';
|
---|
| 487 | }
|
---|
| 488 | return $glsep;
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 |
|
---|
[233] | 492 | # funzione per il titolo della pagina
|
---|
| 493 | function pagetitle($op,$info){
|
---|
[242] | 494 | $pagetitle='';
|
---|
[233] | 495 |
|
---|
| 496 | if($op=="consiglieri")$pagetitle="Proiezione del Consiglio Comunale"; //mettere l'elenco
|
---|
| 497 | if($op=="gruppo_circo")$pagetitle="Risultati per Circoscrizioni";
|
---|
| 498 | if($op=="gruppo_sezione")$pagetitle="Risultati per Sezione";
|
---|
| 499 | if($op=="lista_circo")$pagetitle="Risultati Lista per Circoscrizione";
|
---|
| 500 | if($op=="lista_sezione")$pagetitle="Risultati Lista per Sezione";
|
---|
| 501 | if($op=="candidato_circo")$pagetitle="Risultati Candidati per Circoscrizione";
|
---|
| 502 | if($op=="candidato_sezione")$pagetitle="Risultati Candidati per Sezione";
|
---|
| 503 |
|
---|
| 504 |
|
---|
| 505 |
|
---|
| 506 | if($op=="affluenze_graf")$pagetitle="Grafici Affluenze";
|
---|
| 507 | if($op=="graf_votanti")$pagetitle="Grafici Votanti";
|
---|
| 508 | if($op=="graf_candidato")$pagetitle="Grafici Candidati";
|
---|
| 509 | if($op=="graf_gruppo")$pagetitle="Grafico Principale";
|
---|
| 510 | if($op=="graf_lista")$pagetitle="Grafico Lista";
|
---|
| 511 |
|
---|
| 512 | if($op=="gruppo")$pagetitle="Quadro elezioni riassuntivo";
|
---|
| 513 | if($op=="liste")$pagetitle="Voti Liste";
|
---|
| 514 | if($op=="partiti")$pagetitle="Voti Partito";
|
---|
| 515 | if($op=="contatti")$pagetitle="Contatti";
|
---|
| 516 |
|
---|
| 517 |
|
---|
| 518 | if($info=="come")$pagetitle="Come si vota";
|
---|
| 519 | if($info=="numeri")$pagetitle="Numeri Utili";
|
---|
| 520 | if($info=="servizi")$pagetitle="Servizi elettorali";
|
---|
| 521 | if($info=="link")$pagetitle="Link Utili";
|
---|
| 522 | if($info=="dati")$pagetitle="Dati Generali";
|
---|
| 523 |
|
---|
| 524 | return $pagetitle;
|
---|
| 525 | }
|
---|
| 526 |
|
---|
| 527 |
|
---|
| 528 |
|
---|
| 529 |
|
---|
[2] | 530 | ?>
|
---|