Changeset 256


Ignore:
Timestamp:
Jan 16, 2019, 7:06:35 PM (5 years ago)
Author:
roby
Message:
 
Location:
trunk
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/footer.php

    r230 r256  
    1212    die();
    1313}
    14 echo "</td></tr><tr><td>";
     14echo "</td></tr><tr><td colspan=\"2\">";
    1515include("versione.php");
    1616
  • trunk/admin/modules/Elezioni/backup.php

    r2 r256  
    55if (isset($param['id_comune']))
    66         $id_comune2=intval($param['id_comune']);
    7 $result = mysql_query("select descrizione from ".$prefix."_ele_consultazione  where id_cons_gen='$id_cons_gen2'", $dbi);
    8 list($nomeFile) = mysql_fetch_row($result);
     7$sql="select descrizione from ".$prefix."_ele_consultazione  where id_cons_gen='$id_cons_gen2'";
     8$sth = $dbi->prepare("$sql");
     9$sth->execute();       
     10$row = $sth->fetch(PDO::FETCH_BOTH);
     11$nomeFile=$row[0];
    912#$nomeFile="backup";
    1013header( 'Content-Type: application/octet-stream' );
  • trunk/admin/modules/Elezioni/controllo_votanti.php

    r64 r256  
    2424$perms=ChiSei($id_cons_gen);
    2525if ($perms<16 or !$id_cons_gen) die("$perms ".$_SESSION['id_comune'].$_SESSION['aid'].";Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
    26 $res = mysql_query("SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'" , $dbi);
    27 list($tipo_cons,$id_cons) = mysql_fetch_row($res);
    28 $res = mysql_query("SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
    29         list($genere) = mysql_fetch_row($res);
     26
     27        $sql="SELECT t1.descrizione,t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
     28        $sth = $dbi->prepare("$sql");
     29        $sth->execute();       
     30        $row = $sth->fetch(PDO::FETCH_BOTH);
     31$descr_consultazione=$row[0];
     32$tipo_cons=$row[1];
     33$id_cons=$row[2];
     34        $sql="SELECT genere FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' ";
     35        $sth = $dbi->prepare("$sql");
     36        $sth->execute();       
     37        $row = $sth->fetch(PDO::FETCH_BOTH);   
     38        $genere = $row[0];
    3039if (isset($param['ops'])) get_magic_quotes_gpc() ? $ops=$param['ops']:$ops=addslashes($param['ops']); else $ops='';
    3140if (isset($param['pag'])) $pag=intval($param['pag']); else $pag=0;
     
    5463                if (!IsSet($num_ref)) {
    5564                        $num_ref=1;
    56                         $resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
    57                         $num_refs= mysql_num_rows($resg); //quante pagine?
    58                 }
    59                 $resg = mysql_query("SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref", $dbi);
    60                 list($idg,$numg) = mysql_fetch_row($resg);
     65                        $sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons";
     66                        $sth = $dbi->prepare("$sql");
     67                        $sth->execute();
     68                        $num_refs= $sth->rowCount(); //quante pagine?
     69                }
     70                        $sql="SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref";
     71                        $sth = $dbi->prepare("$sql");
     72                        $sth->execute();
     73                        $row = $sth->fetch(PDO::FETCH_BOTH);   
     74                        $idg=$row[0];
     75                        $numg=$row[1];
    6176                $id_gruppo=$idg;
    6277                $cond= "and id_gruppo=$id_gruppo";
     
    6479        }
    6580        $i=1;
    66         $res = mysql_query("SELECT num_sez,id_sez,t1.id_sede, t2.id_circ,maschi,femmine,(maschi+femmine) as elettori FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez", $dbi);
    67         while ($linka[$i++] = mysql_fetch_array($res));
    68         $num_sez = mysql_num_rows($res); //numero totale delle sezioni
     81        $sql"SELECT num_sez,id_sez,t1.id_sede, t2.id_circ,maschi,femmine,(maschi+femmine) as elettori FROM ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez";
     82        $sth = $dbi->prepare("$sql");
     83        $sth->execute();
     84        while ($linka[$i++] = $sth->fetch(PDO::FETCH_BOTH));
     85        $num_sez = $sth->rowCount(); //numero totale delle sezioni
    6986        $tot_compl=0;$tot_u=0;$tot_d=0;
    7087//      $ar['riga1'][0]="<hr>";
     
    85102        $ar['perc'][1]=" ";
    86103//      $ar['riga2'][1]="<hr>";
    87                 $resuo = mysql_query("SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1", $dbi);
    88                 list($ultora,$ultdata)=mysql_fetch_row($resuo);
    89 
    90         $resril = mysql_query("SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario", $dbi);
    91         $num_ril= mysql_num_rows($resril);  //numero delle rilevazioni previste
     104        $sql="SELECT orario,data FROM ".$prefix."_ele_rilaff where id_cons_gen=$id_cons_gen order by data desc,orario desc limit 0,1";
     105        $sth = $dbi->prepare("$sql");
     106        $sth->execute();
     107        $row = $sth->fetch(PDO::FETCH_BOTH);   
     108        $ultora=$row[0];
     109        $ultdata=$row[1];
     110
     111        $sql = "SELECT data,orario FROM ".$prefix."_ele_rilaff where id_cons_gen='$id_cons_gen' order by data,orario";
     112        $resril = $dbi->prepare("$sql");
     113        $resril->execute();     
     114        $num_ril = $resril->rowCount();  //numero delle rilevazioni previste
    92115        echo "\n<table border=\"0\" width=\"100%\"  align=\"center\">";
    93116        echo "<tr bgcolor=\"$bgcolor1\" align=\"center\"><td width=\"5%\"><b>"._SEZIONI."</b></td><td><b>"._ISCRITTI."<br>"._INSEZ."</b></td>";
    94         $ressomma = mysql_query("SELECT  data,orario,sum(voti_complessivi),sum(voti_uomini),sum(voti_donne) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons $cond group by data,orario", $dbi);
    95         while (list($data,$ora,$somma,$votiu,$votid) = mysql_fetch_row($ressomma)) {
     117        $sql="SELECT  data,orario,sum(voti_complessivi),sum(voti_uomini),sum(voti_donne) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons $cond group by data,orario";
     118        $sth = $dbi->prepare("$sql");
     119        $sth->execute();
     120        while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
     121                $data=$row[0];
     122                $ora=$row[1];
     123                $somma=$row[2];
     124                $votiu=$row[3];
     125                $votid=$row[4];
    96126                $perc_u='';$perc_d='';$perc_c='';
    97127#               if($votiu or $votid)
     
    107137        }
    108138        $ud=0;$ora_rif="";
    109         while (list($data1,$ora1) = mysql_fetch_row($resril))
     139        while ($row2 = $resril->fetch(PDO::FETCH_BOTH))
    110140        {
     141                $data1=$row2[0];
     142                $ora1=$row2[1];
    111143                $ud++; 
    112144                list($hour, $minute, $second) = explode(":", $ora1);
     
    115147                if ($ud==$num_ril) {$ora_rif="$data1.$ora1";}
    116148                echo ">".form_data($data1)."<br>"._ORE." ".$ora_ril;
    117                 $resaff = mysql_query("SELECT count(data) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $cond", $dbi);
    118                 list($num_scr) = mysql_fetch_row($resaff);  //numero delle sezioni inserite
     149                $sql="SELECT count(data) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and data='$data1' and orario='$ora_ril' $cond";
     150                $resaff = $dbi->prepare("$sql");
     151                $resaff->execute();
     152                $num_scr=$resaff->rowCount(); //numero delle sezioni inserite
    119153                echo "<br>"._SEZIONI." $num_scr "._SU." $num_sez";
    120154                if ($ud==$num_ril) echo "<br>\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\">"._UOMINI."</td><td width=\"30%\">"._DONNE."</td><td>"._COMPLESSIVI."</td></tr></table>\n";
     
    142176        }
    143177        }
    144         $resvoti = mysql_query("SELECT  data,orario,t2.num_sez,voti_uomini, voti_donne, voti_complessivi from ".$prefix."_ele_voti_parziale as t1, ".$prefix."_ele_sezioni as t2 where t1.id_cons=$id_cons and t1.id_sez=t2.id_sez $cond order by data,orario,t2.num_sez", $dbi);
     178        $sql="SELECT  data,orario,t2.num_sez,voti_uomini, voti_donne, voti_complessivi from ".$prefix."_ele_voti_parziale as t1, ".$prefix."_ele_sezioni as t2 where t1.id_cons=$id_cons and t1.id_sez=t2.id_sez $cond order by data,orario,t2.num_sez";
     179        $sth = $dbi->prepare("$sql");
     180        $sth->execute();
    145181        $ud=0;
    146         while (list($data,$ora,$numsez,$uomini,$donne,$complessivi) = mysql_fetch_row($resvoti)) {
     182        while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
     183                $data=$row[0];
     184                $ora=$row[1];
     185                $numsez=$row[2];
     186                $uomini=$row[3];
     187                $donne=$row[4];
     188                $complessivi=$row[5];
    147189                if ($ora_rif=="$data.$ora")
    148190                        $ar[$numsez][$data.$ora]="\n<table width=\"100%\"><tr align=\"center\"><td width=\"30%\">$uomini</td><td width=\"30%\">$donne</td><td>$complessivi</td></tr></table>\n";
  • trunk/admin/modules/Elezioni/controllo_voti.php

    r254 r256  
    2626$perms=ChiSei($id_cons_gen);
    2727if ($perms<16 or !$id_cons_gen) die("$perms Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
    28 $res = mysql_query("SELECT t1.tipo_cons,t2.id_cons,t2.solo_gruppo,t2.disgiunto FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'" , $dbi);
    29 list($tipo_cons,$id_cons,$dettnulli,$disgiunto) = mysql_fetch_row($res);
    30 $res = mysql_query("SELECT genere,voto_g,voto_l FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons' " , $dbi);
    31         list($genere,$votog,$votol) = mysql_fetch_row($res);
    32 
     28        $sql="SELECT t1.tipo_cons,t2.id_cons,t2.solo_gruppo,t2.disgiunto FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune'";
     29        $sth = $dbi->prepare("$sql");
     30        $sth->execute();       
     31        $row = $sth->fetch(PDO::FETCH_BOTH);
     32        list($tipo_cons,$id_cons,$dettnulli,$disgiunto) = explode($row);
     33        $sql="SELECT genere,voto_g,voto_l FROM ".$prefix."_ele_tipo where tipo_cons='$tipo_cons'";
     34        $sth = $dbi->prepare("$sql");
     35        $sth->execute();       
     36        $row = $sth->fetch(PDO::FETCH_BOTH);
     37        list($genere,$votog,$votol) = explode($row);
    3338include("modules/Elezioni/funzionidata.php");
    3439include("modules/Elezioni/ele.php");
     
    4449 
    4550    global $prefix, $dbi,$fascia,$limite;
    46         $res = mysql_query("SELECT sum(maschi),sum(femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'", $dbi);
    47         list($totm,$totf) = mysql_fetch_row($res);
     51        $sql="SELECT sum(maschi),sum(femmine) FROM ".$prefix."_ele_sezioni where id_cons='$id_cons'";
     52        $sth = $dbi->prepare("$sql");
     53        $sth->execute();       
     54        $row = $sth->fetch(PDO::FETCH_BOTH);
     55        list($totm,$totf) =  explode($row);
    4856        $totel=$totm+$totf;
    4957        if (!IsSet($pag)) {$pag=0;} //inizializza il numero di pagina
    5058        if (!IsSet($num_ref)) {
    5159                $num_ref=1;
    52                 $resg = mysql_query("SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
    53                 $num_refs= mysql_num_rows($resg); //quante pagine?
     60                $sql="SELECT id_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons";
     61                $sth = $dbi->prepare("$sql");
     62                $sth->execute();       
     63                $row = $sth->fetch(PDO::FETCH_BOTH);
     64                $num_refs= $sth->rowCount(); //quante pagine?
    5465        }
    5566        if((($genere!=4) and $pag==0 and !$votog) or $genere==1 or $genere==2){ //diverso da liste a piu' candidati
     
    5970        }
    6071        OpenTable();
    61         $resg = mysql_query("SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref", $dbi);
    62         list($idg,$numg) = mysql_fetch_row($resg);
    63         $res = mysql_query("SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez", $dbi);
    64         $num_sez = mysql_num_rows($res); //quante sezioni?
     72                $sql="SELECT id_gruppo,num_gruppo from ".$prefix."_ele_gruppo where id_cons=$id_cons and num_gruppo=$num_ref";
     73                $sth = $dbi->prepare("$sql");
     74                $sth->execute();       
     75                $row = $sth->fetch(PDO::FETCH_BOTH);
     76                list($idg,$numg) = explode($row);
     77                $sql="SELECT id_sez,num_sez,t1.id_sede as id_sede,t2.id_circ as id_circ FROM ".$prefix."_ele_sezioni as t1,".$prefix."_ele_sede as t2 where t1.id_cons='$id_cons' and t1.id_sede=t2.id_sede order by num_sez";
     78                $sth = $dbi->prepare("$sql");
     79                $sth->execute();
     80                $num_sez = $sth->rowCount();  //quante sezioni?
    6581for ($i=1;$i<=$num_sez;$i++){
    66                 $sezione[$i]=mysql_fetch_array($res, 3); //inizializza l'array delle sezioni
     82                $sezione[$i]== $sth->fetch(PDO::FETCH_BOTH); //inizializza l'array delle sezioni
    6783                $ar[$i]=0;
    6884        }
     
    88104                $riga1= "<tr><td>\n<table border=\"0\" width=\"100%\" bgcolor=\"$bgcolor1\" ><tr><td align=\"center\">"._SEZSCR." "._CONSULTAZIONE." N. ".$numg."</td></tr></table></td></tr>\n";
    89105        }
    90         $res = mysql_query("$tab ", $dbi);
    91         $num_scr = mysql_num_rows($res);
     106        $sth = $dbi->prepare("$tab ");
     107                        $sth->execute();
     108        $num_scr = $sth->rowCount();
    92109        $riga2= "<tr><td>\n<table border=\"0\" width=\"100%\" bgcolor=\"$bgcolor1\" ><tr><td align=\"center\">"._SEZIONI." $num_scr "._SU." $num_sez</td></tr></table></td></tr>\n";//sezioni scrutinate
    93110        $riga2 .= "<tr><td>\n<table border=\"0\" width=\"100%\"  align=\"center\">";
     
    106123//              $riga3 .= "<td><b>"._PREFLIS."</b></td>";
    107124        $riga3 .= "<td><b>"._STATO."</b></td></tr>\n";
    108         $res = mysql_query("$tab ", $dbi);//die($tab);
    109         $num_scr = mysql_num_rows($res);
    110125        $righe= "";
    111126        $scrutinate=1;
    112127//      if ($genere>1 and $pag==1) $ops=3;
    113128        $tot_u=0;$tot_d=0;$tot_voti=0; $tot_si=0;$tot_no=0;$tot_validi=0;$tot_nulli=0;$tot_bianchi=0;$tot_contestati=0;$tgrup_pref=0;$tot_voti_nulli=0;$tot_val_lista=0;$tot_vot_nul_lis=0;$tot_cont_lis=0;$tot_solog=0;$tot_solol=0;$errors=0;
    114         while (list($id_gruppo,$id,$num,$si,$no,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo,$voti_nulli,$val_lista,$vot_nul_lis,$cont_lis,$solog,$solol) = mysql_fetch_row($res)){
     129        while ( $row = $sth->fetch(PDO::FETCH_BOTH)){
     130//controllare
     131        list($id_gruppo,$id,$num,$si,$no,$validi,$nulli,$bianchi,$contestati,$id_circ,$id_sede,$gruppo,$voti_nulli,$val_lista,$vot_nul_lis,$cont_lis,$solog,$solol) = explode($row);
    115132        // inserimento numeri di sez non scrutinate
    116133                while ($scrutinate < $num) {
     
    121138        // fine inserimento     
    122139                if (($genere==2 or $genere==3 or $genere==5) and !$votog and !$dettnulli) {
    123                         $respref = mysql_query("select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id'", $dbi);
    124                         list ($gruppref) = mysql_fetch_row($respref);
     140                        $sql="select sum(voti) from ".$prefix."_ele_voti_gruppo where id_sez='$id'";
     141                        $sth2 = $dbi->prepare("$sql");
     142                        $sth2->execute();       
     143                        $row2 = $sth2->fetch(PDO::FETCH_BOTH);
     144                        list ($gruppref) = explode($row2);
    125145                        $tgrup_pref += $gruppref;
    126146                }
    127147                $tab2="SELECT max(voti_donne),max(voti_uomini),max(voti_complessivi) FROM ".$prefix."_ele_voti_parziale where id_cons='$id_cons' and id_sez='$id'";
    128148                if ($genere==0) $tab2 .= " and id_gruppo=$id_gruppo";
    129                 $res2 = mysql_query($tab2, $dbi);
    130                 list($votid,$votiu,$voti) = mysql_fetch_row($res2);
     149                        $sth2 = $dbi->prepare("$tab2");
     150                        $sth2->execute();       
     151                        $row2 = $sth2->fetch(PDO::FETCH_BOTH);
     152                        list($votid,$votiu,$voti) = explode($row2);
    131153//              $voti=$votiu+$votid;
    132154               
     
    161183                if($genere==5 and !$votog) #$validi+$nulli+$bianchi+$vcont+$vn
    162184                        if($pag==0 and !$votog or $fascia<=$limite) {$controllo1=$validi+$nulli+$bianchi+$contestati+$voti_nulli;} else { $controllo1=$val_lista+$nulli+$bianchi+$contestati+$voti_nulli+$cont_lis+$vot_nul_lis+$solog;$controllo2=$si+$no-$solol+$cont_lis+$vot_nul_lis;}
    163                 $cerr=mysql_query("select stato_lis from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id'", $dbi);
    164                 list($crlis)=mysql_fetch_row($cerr);
     185                        $sth2 = $dbi->prepare("select stato_lis from ".$prefix."_ele_controllosez where id_cons='$id_cons' and id_sez='$id'");
     186                        $sth2->execute();       
     187                        $row2 = $sth2->fetch(PDO::FETCH_BOTH);
     188                        list($crlis) = explode($row2);
     189
    165190                if ($voti==$controllo1 and $validi==$controllo2 and !$g_err and $crlis!=-1){
    166191                        $righe .= "<td>"._OK."</td></tr>\n";
  • trunk/admin/modules/Elezioni/ele.php

    r255 r256  
    6464        $bgcolor1='#e7e7e7';
    6565        $row=descr_comune();$descr_comu=$row['descrizione'];
    66 #       $sqlcomu="select descrizione from ".$prefix."_ele_comuni where id_comune='$id_comune'";
    67 #       $res = mysql_query($sqlcomu);
    68 #       list($descr_comu)=mysql_fetch_row($res);
    69         $sqlcomu="select fascia from ".$prefix."_ele_cons_comune where id_cons='$id_cons'";
    70         $res = mysql_query($sqlcomu);
    71         if ($res)
    72         list($fascia)=mysql_fetch_row($res);
     66
     67        $row=daticonscom();
     68        if ($row['fascia']) $fascia=$row['fascia'];
    7369        else
    7470        $fascia=0;
     
    109105        // controllo delle opzioni utilizzabili: sono quelle che hanno genitori in quella precedente
    110106        // esempio si possono inserire i candidati solo se prima sono state inserite le liste
    111         $resq = mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons", $dbi);
    112         if ($resq) list($nrcirco)=mysql_fetch_row($resq); else $nrcirco=0;
    113         $resq = mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons=$id_cons", $dbi);
    114         if ($resq) list($nrsede)=mysql_fetch_row($resq); else $nrsede=0;
    115         $resq = mysql_query("select count(0) from ".$prefix."_ele_gruppo where id_cons=$id_cons", $dbi);
    116         if ($resq) list($nrgruppo)=mysql_fetch_row($resq); else $nrgruppo=0;
    117         $resq = mysql_query("select count(0) from ".$prefix."_ele_lista where id_cons=$id_cons", $dbi);
    118         if ($resq) list($nrlista)=mysql_fetch_row($resq); else $nrlista=0;
    119         $resq = mysql_query("SELECT sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons", $dbi);
    120         if ($resq) list($nraff)=mysql_fetch_row($resq); else $nraff=0;
     107        $sql="select count(0) from ".$prefix."_ele_circoscrizione where id_cons=$id_cons";
     108        try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrcirco=$row[0];}
     109        catch(PDOException $e) {$nrcirco=0; }   
     110        $sql="select count(0) from ".$prefix."_ele_sede where id_cons=$id_cons";
     111        try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrsede=$row[0];}
     112        catch(PDOException $e) {$nrsede=0; }   
     113        $sql="select count(0) from ".$prefix."_ele_gruppo where id_cons=$id_cons";
     114        try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrgruppo=$row[0];}
     115        catch(PDOException $e) {$nrgruppo=0; }         
     116        $sql = "select count(0) from ".$prefix."_ele_lista where id_cons=$id_cons";
     117        try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrlista=$row[0];}
     118        catch(PDOException $e) {$nrlista=0; }   
     119        $sql = "SELECT sum(voti_complessivi) from ".$prefix."_ele_voti_parziale where id_cons=$id_cons";
     120        try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH); $nraff=$row[0];}
     121        catch(PDOException $e) {$nraff=0; }     
    121122        if ($genere==0) $tmpval='voti_ref'; else $tmpval='sezioni';
    122         $resq = mysql_query("SELECT sum(validi) from ".$prefix."_ele_$tmpval where id_cons=$id_cons", $dbi);
    123         if ($resq) list($nrvoti)=mysql_fetch_row($resq); else $nrvoti=0;
    124         unset($resq);
     123        $sql = "SELECT sum(validi) from ".$prefix."_ele_$tmpval where id_cons=$id_cons";
     124        try { $sth = $dbi->prepare("$sql"); $sth->execute(); $row = $sth->fetch(PDO::FETCH_BOTH);$nrvoti=$row[0];}
     125        catch(PDOException $e) {$nrvoti=0; }   
     126        unset($row);
    125127        if ($perms==256) // il superuser puo' scegliere il comune su cui lavorare
    126128        {
     
    178180
    179181                <a href=\"admin.php?op=rec_add_aff&amp;id_cons_gen=$id_cons_gen\">$bullet"._AFFLUENZE."</a><br>
    180                 <a href=\"admin.php?op=associazioni&amp;id_cons_gen=$id_cons_gen\">$bullet"._INSCOMUNE."</a><br/>
     182                <a href=\"admin.php?op=associazioni&amp;id_cons_gen=$id_cons_gen\">$bullet"._INSCOMUNE."</a><br>
    181183                <a href=\"http://www.eleonline.it/portal/segnala.php?tmp=test123\" target=\"_blank\">$bullet_red <b>"._SEGNALA."</b></a>
    182184                </td></tr>";
  • trunk/admin/modules/Elezioni/ele_affluenze.php

    r255 r256  
    135135                $sth = $dbi->prepare("$sql");
    136136                $sth->execute();       
    137                 $row = $sth->fetchAll();
     137#               $row = $sth->fetchAll();
    138138                $tipo= $sth->rowCount();
    139139                if(($tipo==0) and ($dadata <= $cdata) and ($adata >= $cdata)){
  • trunk/admin/modules/Elezioni/ele_associazioni.php

    r254 r256  
    7171     echo "} \n";
    7272     echo "else document.getElementById('trspunta').style.visibility='visible' \n";
    73 #     echo "if (document.getElementById('chiusa').options[3].selected==false) { \n";
    7473     echo "if (document.getElementById('chiusa').selectedIndex!=3) { \n";
    7574     echo "document.getElementById('add').value=\""._MODIFY."\" \n";
     
    124123        echo "<table width=\"100%\" border=\"3\">";
    125124        echo "<tr align=\"center\"><td bgcolor=\"$bgcolor1\"><b>"._CONSULTA."</b></td>";
    126 #       echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
    127125        echo "<td bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
    128126        echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
     
    135133        echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
    136134        echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
    137 #       echo "<input type=\"hidden\" name=\"pag_cons\" value=\"admin.php?op=associazioni&amp;id_cons_gen=\">";
    138135        echo "</tr>";
    139136        echo "<tr align=\"center\"><td>";
    140137        echo "<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
    141138        echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">$descr_cons</td>";
    142 #       $ressede = mysql_query("SELECT id_collegio, descrizione from ".$prefix."_ele_collegi where id_cons_gen='$id_cons_gen' order by descrizione desc", $dbi);
    143 #       if ($num_coll=mysql_num_rows($ressede)){
    144 #               echo "<td><select name=\"id_collegio\">";
    145 #               while(list($id,$descr_coll)=mysql_fetch_row($ressede)){
    146 #                       $sel= ($id == $id_collegio) ? "selected":"";
    147 #                       echo "<option value=\"$id\" $sel>$descr_coll";
    148 #               }
    149 #               echo "</select></td>";
    150 #       } else echo "<td></td>";
    151139        $rescomu = mysql_query("SELECT id_comune, descrizione from ".$prefix."_ele_comuni order by descrizione asc", $dbi);
    152140        echo "<td>";
     
    241229                echo "<input type=\"submit\" id=\"add\" name=\"add\" value=\""._MODIFY."\" ></td></tr>";
    242230                echo "<tr><td colspan=\"5\"><fieldset><legend>"._SPUNTALABEL1."</legend><label id=\"prov1\">"._SPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd3\" name=\"pwd3\" value=\"\" onclick=\"javascript:del_cons()\"></label></fieldset></td></tr>";
    243 # <div  id=\"trspunta\" style=\"visibility:hidden\">   </div>
    244231                echo "<tr id=\"trspunta\" style=\"visibility:hidden\"><td colspan=\"4\"><fieldset><legend>"._SPUNTALABEL2."</legend><label id=\"prov\">"._VIASPUNTAELIMINA." <input type=\"checkbox\" id=\"pwd4\" name=\"pwd4\" value=\"1\" onclick=\"javascript:del_cons()\"></label></fieldset>";
    245232        }else{
     
    249236        $i=0;
    250237        echo "</td></tr></table></form>";
    251 ############
    252238        echo "<hr><br><table width=\"100%\" border=\"3\">";
    253239        echo "<tr align=\"center\"><td width=\"15%\" bgcolor=\"$bgcolor1\"><b>"._CONSULTA."TEST:$id_cons_comu</b></td>";
    254 #       echo "<td bgcolor=\"$bgcolor1\"><b>"._COLLEGI."</b></td>";
    255240        echo "<td width=\"20%\" bgcolor=\"$bgcolor1\"><b>"._DEFCOMUNE."</b></td>";
    256241        echo "<td width=\"10%\" bgcolor=\"$bgcolor1\"><b>"._PREFERENZE."</b></td>";
     
    263248        echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._ASOLO_GRUPPO."</b></td>";
    264249        echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._DISGIUNTO."</b></td>";
    265 #       echo "<td width=\"10%\" bgcolor=\"$bgcolor1\" align=\"center\"><b>"._SG."</b></td>";
    266         echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b>&nbsp;"._FUNZIONI."</td></tr>";
    267 ###############
    268 
    269 #       if ($num_coll>0)
    270 #       $resmod = mysql_query("SELECT t1.id_collegio,t1.id_comune,t2.descrizione as descr,t1.id_cons, t3.descrizione, t4.chiusa,t4.id_conf FROM ".$prefix."_ele_comu_collegi as t1, ".$prefix."_ele_collegi as t2, ".$prefix."_ele_comuni as t3, ".$prefix."_ele_cons_comune as t4 where t1.id_cons_gen='$id_cons_gen' and t1.id_collegio=t2.id_collegio and t1.id_comune=t3.id_comune and t1.id_comune=t4.id_comune and t2.id_cons_gen=t4.id_cons_gen order by t2.descrizione, t3.descrizione", $dbi);
    271 #       else
     250        echo "<td width=\"10\" bgcolor=\"$bgcolor1\"><b>&nbsp;"._FUNZIONI."</b></td></tr>";
     251
    272252        $resmod = mysql_query("SELECT '',t1.id_comune,'',t1.id_cons, t2.descrizione, t1.chiusa, t1.id_conf, preferenze,t1.id_fascia,t1.vismf,t1.solo_gruppo,t1.disgiunto FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons_gen='$id_cons_gen' and t1.id_comune=t2.id_comune order by t2.descrizione", $dbi);
    273253        while (list($id_collegio,$id_comune2,$descr_coll,$id_cons_comu,$descr_comu, $chiusa,$id_conf,$preferenze2,$fasciacom,$vismf2,$sg2,$disgiunto2) = mysql_fetch_row($resmod)){ //elenco dei modelli inseriti
     
    276256                $i++;
    277257                $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
    278                 if($tipo_cons==3) echo "<tr><td colspan=\"8\">"; else echo "<tr><td colspan=\"8\">";
     258                echo "<tr align=\"center\" bgcolor=\"$bgcolor1\">";
     259                echo "<td><b>$descr_cons</b></td>";
     260                echo "<td><b>$descr_comu</b></td>";
     261                echo "<td><b>$preferenze2</b></td>";
     262                $stato['0']=_ATTIVA;
     263                $stato['1']=_CHIUSA;
     264                $stato['2']=_NULLA;
     265                echo "<td><b>".$stato[$chiusa]."</b></td>";
     266                if($tipo_cons==3){
     267                        echo "<td><b>".$descr_conf."</b></td>";
     268                        $rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
     269                        $inffascia=0;
     270                        if (mysql_num_rows($rescomu)==0) echo "<td></td>";
     271                        while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
     272                                $sel='';
     273                                if ($id == $fasciacom)
     274                                        echo "<td>$inffascia - $abitanti</td>";
     275                                $inffascia=$abitanti;
     276                        }
     277
     278                }
     279                if ($vismf2==0) $sel=_NO; else $sel=_SI;
     280                echo "<td>$sel</td>";
     281                if ($sg2==0) $sel=_NO; else $sel=_SI;
     282                echo "<td>$sel</td>";
     283                if ($disgiunto2==0) $sel=_NO; else $sel=_SI;
     284                echo "<td>$sel</td>";
     285                echo "<td>";
    279286                echo "<form name=\"modello$i\" action=\"admin.php\">"
    280                         ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
    281 //              echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
    282 #               echo "<input type=\"hidden\" name=\"id_collegio\" value=\"$id_collegio\">";
     287                ."<input type=\"hidden\" name=\"op\" value=\"associazioni\">";
     288                echo "<input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\">";
    283289                echo "<input type=\"hidden\" name=\"idcomune\" value=\"$id_comune2\">";
    284290                echo "<input type=\"hidden\" name=\"id_cons_comu\" value=\"$id_cons_comu\">";
     
    287293                echo "<input type=\"hidden\" name=\"preferenze\" value=\"$preferenze2\">";
    288294                echo "<input type=\"hidden\" name=\"chiusa\" value=\"$chiusa\">";
    289                 echo "<table width=\"100%\"><tr align=\"center\" bgcolor=\"$bgcolor1\">";
    290                 echo "<td width=\"15%\"><b>$descr_cons</b></td>";
    291                 echo "<td width=\"20%\"><b>$descr_comu</b></td>";
    292                 echo "<td width=\"10%\"><b>$preferenze2</b></td>";
    293                 $stato['0']=_ATTIVA;
    294                 $stato['1']=_CHIUSA;
    295                 $stato['2']=_NULLA;
    296                 echo "<td  width=\"10%\"><b>".$stato[$chiusa]."</b></td>";
    297                 if($tipo_cons==3){
    298                         echo "<td width=\"20%\"><input type=\"hidden\" name=\"id_conf\" value=\"$id_conf\"><b>".$descr_conf."</b></td>";
    299                         $rescomu = mysql_query("SELECT id_fascia,abitanti from ".$prefix."_ele_fasce where id_conf='$id_conf'", $dbi);
    300                         $inffascia=0;
    301                         while(list($id,$abitanti)=mysql_fetch_row($rescomu)){
    302                                 $sel='';
    303                                 if ($id == $fasciacom)
    304                                         echo "<td width=\"20%\">$inffascia - $abitanti</td>";
    305                                 $inffascia=$abitanti;
    306                         }
    307 
    308                 }
    309                 if ($vismf2==0) $sel=_NO; else $sel=_SI;
    310                 echo "<td width=\"10%\">$sel</td>";
    311                 if ($sg2==0) $sel=_NO; else $sel=_SI;
    312                 echo "<td width=\"10%\">$sel</td>";
    313                 if ($disgiunto2==0) $sel=_NO; else $sel=_SI;
    314                 echo "<td width=\"10%\">$sel</td>";
    315 #               if ($sg==0) $sel=_NO; else $sel=_SI;
    316 #               echo "<td width=\"10%\">$sel</td>";
    317                 echo "<td width=\"10\"><input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
    318                         ."</td></tr></table></form></td></tr>\n";
    319         }
    320                 echo "</table></td></tr>";
    321                 echo "</table></td></tr>";
     295                echo "<input type=\"hidden\" name=\"ok\" value=0><input type=\"submit\" name=\"edit$i\" value=\""._EDIT."\">"
     296                        ."</form></td></tr>\n";
     297        }
     298                echo "</table></td></tr></table>";
    322299        CloseTable();
    323 #       echo "</div>";
    324300        }
    325301
     
    386362
    387363
    388 #       die ("do:$do - id_cons:$id_cons_comu - idcomune:$id_comune - new: $idcomunenew");
    389364       
    390365//****************************
  • trunk/admin/modules/Elezioni/ele_configurazione.php

    r255 r256  
    1515// Offset - visualizza il numero di elementi per pagina
    1616$offset=5;
    17 
     17global $dbi;
    1818$aid=$_SESSION['aid'];
    19 $dbi=$_SESSION['dbi'];
    2019$prefix=$_SESSION['prefix'];
    2120$currentlang=$_SESSION['lang'];
     
    2625
    2726$id_comune=$_SESSION['id_comune'];
     27
     28include("modules/Elezioni/funzionidata.php");
     29include("modules/Elezioni/ele.php");
    2830$row=cur_cons();
    2931$tipo_cons=$row[0];$id_cons=$row[1];
    30 
    31 include("modules/Elezioni/funzionidata.php");
    32 include("modules/Elezioni/ele.php");
    3332
    3433if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
     
    7372        echo "<form name=\"gruppo2\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\">"
    7473        ."<input type=\"hidden\" name=\"op\" value=\"confconsiglio\">";
    75         $resl = mysql_query("SELECT * FROM ".$prefix."_config", $dbi);
    76         $gru=mysql_fetch_array($resl);
     74        $sql="SELECT * FROM ".$prefix."_config";
     75        $sth = $dbi->prepare("$sql");
     76        $sth->execute();       
     77        $gru = $sth->fetch(PDO::FETCH_BOTH);   
    7778        echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
    7879        echo "<input type=\"hidden\" name=\"op\" value=\"configurazione\">";
     
    8990
    9091       
    91         $resmod = mysql_query("SELECT tema FROM ".$prefix."_ele_temi order by tema", $dbi);
    92 
     92        $sql="SELECT tema FROM ".$prefix."_ele_temi order by tema";
     93        $sth = $dbi->prepare("$sql");
     94        $sth->execute();       
     95        $row = $sth->fetchAll();
    9396        echo "<td><select name=\"tema2\">\n";
    94 
    95         while (list($desc) = mysql_fetch_row($resmod)){
     97        foreach($row as $com) {$desc=$com[0];
    9698                        if (!$gru['tema']) $gru['tema']=$desc;
    9799                                $sel= ($gru['tema']==$desc) ? "selected":"";
     
    117119        echo"<td><b>"._SITENAME."</b></td><td><input type=\"text\" name=\"sitename\" value=\"".$gru['sitename']."\"></td></tr>";
    118120
    119         $resmod = mysql_query("SELECT id_comune,descrizione FROM ".$prefix."_ele_comuni order by descrizione", $dbi);
     121        $sql = "SELECT id_comune,descrizione FROM ".$prefix."_ele_comuni order by descrizione";
     122        $sth = $dbi->prepare("$sql");
     123        $sth->execute();       
     124        $row = $sth->fetchAll();
    120125        echo "<tr><td><b>"._SITEISTAT."</b></td>";
    121126        echo "<td><select name=\"siteistat\"><option value=\"\">";
    122         while (list($id_comune2,$desc) = mysql_fetch_row($resmod)){
     127        foreach($row as $com)
     128        {$id_comune2=$com[0];$desc=$com[1];
    123129                        if (!$gru['siteistat']) $gru['siteistat']=$id_comune2;
    124130                        $sel= ($gru['siteistat']==$id_comune2) ? "selected":"";
     
    187193#displayerrors='$displayerrors',
    188194#per il momento non Ú usato: , site_logo='$site_logo'
    189                 $result = mysql_query("update  ".$prefix."_config set sitename='$sitename', testata='$stemmablob', nome_testata='$stemmanome', blocco='$blocco', multicomune='$multicomune', language='$language2', siteistat='$siteistat', adminmail='$adminmail', siteurl='$siteurl', flash='$flash2', tema='$tema2',gkey='$gkey',ed_user='$ed_user',googlemaps='$googlemaps',editor='$editor',tema_on='$tema_on'", $dbi) || die("Errore di aggiornamento dei dati!".mysql_error());
     195        $sql = "update  ".$prefix."_config set sitename='$sitename', testata='$stemmablob', nome_testata='$stemmanome', blocco='$blocco', multicomune='$multicomune', language='$language2', siteistat='$siteistat', adminmail='$adminmail', siteurl='$siteurl', flash='$flash2', tema='$tema2',gkey='$gkey',ed_user='$ed_user',googlemaps='$googlemaps',editor='$editor',tema_on='$tema_on'";
     196        $sth = $dbi->prepare("$sql");
     197        $sth->execute();
    190198        if ($tema2=='facebook')
    191199                $_SESSION['tema']=$tema2;
     
    223231                if ( (preg_match('/^([_0-9a-zA-Z]+)([_0-9a-zA-Z]{3})$/',$tlist[$i])) ) $files=$tlist[$i];
    224232                   if($files!=''){
    225                         $sql = mysql_query("SELECT id FROM ".$prefix."_ele_temi where tema='$files'", $dbi);
    226                                 if($sql){
    227                                         list($idwid) = mysql_fetch_row($sql);
    228                                         $id = intval($idwid);
    229                                 }
     233                        $sql = "SELECT id FROM ".$prefix."_ele_temi where tema='$files'";
     234                                $sth = $dbi->prepare("$sql");
     235                                $sth->execute();
     236                                $row = $sth->fetch(PDO::FETCH_BOTH);
     237                                $id = intval($row[0]);
     238                               
    230239                        if (empty($id)) { // inserisce widget db se non esiste
    231                         $result = mysql_query("insert into ".$prefix."_ele_temi (id,tema) values ( NULL,'$files')", $dbi);
     240                                $sql="insert into ".$prefix."_ele_temi (id,tema) values ( NULL,'$files')";
     241                                $sth = $dbi->prepare("$sql");
     242                                $sth->execute();
    232243                  }
    233                 }
     244                        }
    234245                 
    235246                 
     
    243254 
    244255                  # se non esiste cancella dal db
    245                   $sql2 = mysql_query("SELECT * FROM ".$prefix."_ele_temi", $dbi);
    246                   while ($row = mysql_fetch_array($sql2)) {
     256                $sql = "SELECT * FROM ".$prefix."_ele_temi";
     257                $sth = $dbi->prepare("$sql");
     258                $sth->execute();
     259                $sql2 = $sth->fetch(PDO::FETCH_BOTH);
     260                foreach($sql2 as $row){
    247261                        $esi=0;
    248262                        for ($i=0; $i < sizeof($tlist); $i++) {
     
    251265                        }
    252266                        if($esi!=1){
    253                               $del=mysql_query("DELETE FROM ".$prefix."_ele_tema WHERE id = '$row[id]'",$dbi);
     267                            $sql="DELETE FROM ".$prefix."_ele_temi WHERE id = '$row[id]'";
     268                                $sth = $dbi->prepare("$sql");
     269                                $sth->execute();
    254270                      }
    255271                }
  • trunk/admin/modules/Elezioni/ele_cons_comuni.php

    r122 r256  
    1313}
    1414
     15global $dbi;
    1516$aid=$_SESSION['aid'];
    16 $dbi=$_SESSION['dbi'];
    1717$prefix=$_SESSION['prefix'];
    1818if($param)
     
    2323$perms=ChiSei(0);
    2424if ($perms<64 or !$id_cons_gen) die("Non hai i permessi per inserire dati, o non hai scelto la consultazione!");
    25 $res = mysql_query("SELECT tipo_cons,descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' " , $dbi);
    26 list($tipo_cons,$descr_cons) = mysql_fetch_row($res);
    2725include("modules/Elezioni/funzionidata.php");
    2826include("modules/Elezioni/ele.php");
     27$row=descr_cons();
     28$tipo_cons=$row[0];$descr_cons=$row[2];
     29
    2930if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
    3031if (isset($param['ok'])) get_magic_quotes_gpc() ? $ok=$param['ok']:$ok=addslashes($param['ok']); else $ok='';
     
    4849
    4950        if (isset($help)) include("language/$language/ele_cons_comuni.html");
    50 
     51        $row=descr_comune();
    5152        $res = mysql_query("SELECT id_cons FROM ".$prefix."_ele_comuni where id_comune=$id_comune", $dbi);
    52         if (isset($res)) list($idpred) = mysql_fetch_row($res); else $idpred='';
    53         $res = mysql_query("SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' " , $dbi);
    54         $max = mysql_num_rows($res);
     53        if (count($row)) $idpred = $row[2]; else $idpred='';
     54#       $res = mysql_query("SELECT t1.id_cons, t2.descrizione FROM ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_consultazione as t2 on t1.id_cons_gen=t2.id_cons_gen where t1.id_comune='$id_comune' " , $dbi);
     55        $row=elenco_cons_comune();
     56       
     57        $max = count($row);
    5558        echo "<table border=\"0\" width=\"100%\" align=\"left\"><tr><td>";
    5659        echo "<form name=\"imppred\" action=\"admin.php\">";
     
    5861        ."&nbsp;<b>"._CONSPRED."</b>&nbsp;</td><td><select name=\"predefinita\">";
    5962        echo "<option value=\"\">";
    60         while($arr=mysql_fetch_array($res,3)){
     63        foreach($row as $arr){
    6164                $sel='';
    6265                if (($idpred))
     
    7780        ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._COPIA." "._NUM." "._ELETTORI."</b></td>"
    7881        ."<td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._FUNZIONI."</b></td></tr>";
    79         $result = mysql_query("select t2.chiusa,t2.id_cons,t1.* from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t2.id_comune='$id_comune' and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons!=$id_cons ORDER BY data_fine desc LIMIT $min,$offset", $dbi);
     82        $sql = "select t2.chiusa,t2.id_cons,t1.* from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.tipo_cons=t3.tipo_cons and t2.id_comune='$id_comune' and t1.id_cons_gen=t2.id_cons_gen and t2.id_cons!=$id_cons ORDER BY data_fine desc LIMIT $min,$offset";
     83        $sth = $dbi->prepare("$sql");
     84        $sth->execute();       
     85        $row = $sth->fetchAll();
    8086        $i=0;
    81         while(list($chiusa,$id_cons2,$idconsgen2, $descr_cons, $data_inizio, $data_fine,$tipo) = mysql_fetch_row($result)) {
     87        foreach($row as $arr) {
     88                $chiusa=$arr[0];$id_cons2=$arr[1];$idconsgen2=$arr[2]; $descr_cons=$arr[3]; $data_inizio=$arr[4]; $data_fine=$arr[5];$tipo=$arr[6];
    8289                $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1'];
    83                 $ressez = mysql_query("select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'", $dbi);
    84                 list($somma)=mysql_fetch_row($ressez);
     90                $sql = "select count(id_cons) from ".$prefix."_ele_sezioni where id_cons='$id_cons2'";
     91                $sth = $dbi->prepare("$sql");
     92                $sth->execute();       
     93                $row = $sth->fetch(PDO::FETCH_BOTH);
     94                $somma=$row[0];
    8595                $data_inizio=form_data($data_inizio);$data_fine=form_data($data_fine);
    8696                echo "<tr bgcolor=\"$bgcolor1\" align=\"center\" ><td align=\"left\" ><a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$idconsgen2\"><b>$descr_cons</b></a></td>"
     
    141151if ($perms>32) {
    142152        $sql="select id_cons from ".$prefix."_ele_cons_comune where id_cons_gen='$id_cons_gen' and id_comune=$id_comune";
    143         $res=mysql_query("$sql",$dbi);
    144         list($id_consulta)=mysql_fetch_row($res);
     153        $sth = $dbi->prepare("$sql");
     154        $sth->execute();       
     155        $row = $sth->fetch(PDO::FETCH_BOTH);
     156        $id_consulta=$row[0];
    145157        $sql="select t1.descrizione from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t2.id_cons='$id_cons2' and t1.id_cons_gen=t2.id_cons_gen";
    146         $res=mysql_query("$sql",$dbi);
    147         list($descr_cons2)=mysql_fetch_row($res);
     158        $sth = $dbi->prepare("$sql");
     159        $sth->execute();       
     160        $row = $sth->fetch(PDO::FETCH_BOTH);
     161               
     162        $descr_cons2=$row[0];
    148163        if ($do == "add") {
    149164                if ($id_cons2) {
    150165                        // copia circoscrizione
    151                         $res=mysql_query("select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'", $dbi);
    152                         while (list($id,$idcirc,$num,$des2)=mysql_fetch_row($res)){
    153                         $des=addslashes($des2);
    154  $resconnew=mysql_query("select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'", $dbi);
    155 list($contr_circ)=mysql_fetch_row($resconnew);
    156 if (! $contr_circ){
    157                                 mysql_query("insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')", $dbi) || die("Impossibile inserire i dati delle circoscrizioni! ".mysql_error());
    158 }
    159                                 $res0=mysql_query("select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num", $dbi);
    160                                 list($id_circ)=mysql_fetch_row($res0);
     166                        $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_consulta'";
     167                        $sth = $dbi->prepare("$sql");
     168                        $sth->execute();       
     169                        $row = $sth->fetchAll();
     170                        foreach($row as $arr){
     171                                $id=$arr[0];$idcirc=$arr[1];$num=$arr[2];$des2=$arr[3];
     172                                $des=addslashes($des2);
     173                                $sql="select count(0) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons2' and num_circ='$num'";
     174                                $sth = $dbi->prepare("$sql");
     175                                $sth->execute();       
     176                                $row = $sth->fetch(PDO::FETCH_BOTH);
     177                                $contr_circ=$row[0];
     178                                if (! $contr_circ){
     179                                        sql="insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons2',$num,'$des')";
     180                                        $sth = $dbi->prepare("$sql");
     181                                        $sth->execute();       
     182
     183                                }
     184                                $sql="select id_circ from ".$prefix."_ele_circoscrizione where id_cons=$id_cons2 and num_circ=$num";
     185                                $sth = $dbi->prepare("$sql");
     186                                $sth->execute();       
     187                                $row = $sth->fetch(PDO::FETCH_BOTH);
     188                                $id_circ=$row[0];
    161189                                // copia sede
    162                                 $res1=mysql_query("select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'", $dbi);
    163                                 while(list($id1,$idsede1,$idcirc1,$ind2,$tel,$tel2,$fax,$resp,$mappa2,$filemappa2)=mysql_fetch_row($res1)){
     190                                $sql="select * from ".$prefix."_ele_sede where id_cons='$id_consulta' and id_circ='$idcirc'";
     191                                $sth = $dbi->prepare("$sql");
     192                                $sth->execute();       
     193                                $row = $sth->fetchAll();
     194                                foreach($row as $row2) {
     195                                        $id1=$row2[0];$idsede1=$row2[1];$idcirc1=$row2[2];$ind2=$row2[3];$tel=$row2[4];$tel2=$row2[5];$fax=$row2[6];$resp=$row2[7];$mappa2=$row2[8];$filemappa2=$row2[9];
    164196                                        $filemappa=addslashes($filemappa2);
    165197                                        $mappa=addslashes($mappa2);
    166198                                        $ind=addslashes($ind2);
    167  $ressednew=mysql_query("select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'", $dbi);
    168 list($contr_sed)=mysql_fetch_row($ressednew);
    169 if (! $contr_sed){
    170                                         mysql_query("insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons2','$id_circ','$ind','$tel','$tel2','$fax','$resp','$mappa','$filemappa')", $dbi) || die("Impossibile inserire i dati delle sedi! ".mysql_error());
    171 }
    172                                         $res2=mysql_query("select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'", $dbi);
     199                                        $sql="select count(0) from ".$prefix."_ele_sede where id_cons='$id_cons2' and indirizzo='$ind'";
     200                                        $sth = $dbi->prepare("$sql");
     201                                        $sth->execute();       
     202                                        $row = $sth->fetch(PDO::FETCH_BOTH);
     203                                        $contr_sed=$row[0];
     204                                        if (! $contr_sed){
     205                                                $sql="insert into ".$prefix."_ele_sede (id_cons,id_circ,indirizzo,telefono1,telefono2,fax,responsabile,mappa,filemappa) values ('$id_cons2','$id_circ','$ind','$tel','$tel2','$fax','$resp','$mappa','$filemappa')";
     206                                                $sth = $dbi->prepare("$sql");
     207                                                $sth->execute();       
     208                                        }
     209                                        $sql"select id_sede from ".$prefix."_ele_sede where id_cons=$id_cons2 and id_circ=$id_circ and indirizzo='$ind'";
    173210                                        list($id_sede)=mysql_fetch_row($res2);
     211                                        $sth = $dbi->prepare("$sql");
     212                                        $sth->execute();       
     213                                        $row = $sth->fetch(PDO::FETCH_BOTH);
     214                                        $id_sede=$row[0];
    174215                                        //copia sezione
    175                                         $res3=mysql_query("select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1", $dbi);
    176                                         while (list($id3,$idsez3,$idsede3,$numero,$maschi3,$femmine3,$validi3,$nulli3,
    177                                                 $bianchi3,$contest3,$sg3,$aut_m,$aut_f)=mysql_fetch_row($res3)){
     216                                        $sql="select * from ".$prefix."_ele_sezioni where id_cons=$id_consulta and id_sede=$idsede1";
     217                                        $sth = $dbi->prepare("$sql");
     218                                        $sth->execute();       
     219                                        $row = $sth->fetchAll();
     220                                        foreach($row as $arr2)
     221                                        {
     222                                                $id3=$arr2[0];$idsez3=$arr2[1];$idsede3=$arr2[2];$numero=$arr2[3];$maschi3=$arr2[4];$femmine3=$arr2[5];$validi3=$arr2[6];$nulli3=$arr2[7];
     223                                                $bianchi3=$arr2[8];$contest3=$arr2[9];$sg3,$aut_m=$arr2[10];$aut_f=$arr2[11];
    178224                                                if ($elettori=='true') $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez,maschi,femmine) values ('$id_cons2','$id_sede','$numero','$maschi3','$femmine3')";
    179225                                                else $sql="insert into ".$prefix."_ele_sezioni (id_cons,id_sede,num_sez) values ('$id_cons2','$id_sede','$numero')";
    180                                                 mysql_query("$sql", $dbi) || die("Impossibile inserire i dati delle sezioni! ".mysql_error());
     226                                                $sth = $dbi->prepare("$sql");
     227                                                $sth->execute();       
     228
    181229                                        }
    182230                                }
     
    191239                        echo "[ <a href=\"admin.php?op=cons_comuni&amp;id_cons_gen=$id_cons_gen\">"._NO."</a> ] - [<a href=\"admin.php?op=cons_comuni&amp;do=elettori&amp;id_cons_gen=$id_cons_gen&amp;id_cons2=$id_cons2&amp;ok=1\">"._YES."</a> ]";exit;
    192240                }else{
    193                 $result = mysql_query("update ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sezioni as t2 set t1.maschi=t2.maschi, t1.femmine=t2.femmine WHERE t1.id_cons=$id_cons2 and t2.id_cons=$id_consulta and t1.num_sez=t2.num_sez", $dbi);
     241                $sql="update ".$prefix."_ele_sezioni as t1, ".$prefix."_ele_sezioni as t2 set t1.maschi=t2.maschi, t1.femmine=t2.femmine WHERE t1.id_cons=$id_cons2 and t2.id_cons=$id_consulta and t1.num_sez=t2.num_sez";
     242                $sth = $dbi->prepare("$sql");
     243                $result=$sth->execute();       
     244
    194245                if (!$result) return;
    195246                Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
     
    198249        if ($do == "update") {
    199250                if ($predefinita)
    200                         $result = mysql_query("update  ".$prefix."_ele_comuni set  id_cons='$predefinita' WHERE id_comune='$id_comune'", $dbi);
    201                 else
    202                         $result = mysql_query("update  ".$prefix."_ele_cons_comune set  chiusa='$chiusa' WHERE id_cons2='$id_cons2'", $dbi);
    203                 if (!$result) return;
     251                {
     252                        $sql="update  ".$prefix."_ele_comuni set  id_cons='$predefinita' WHERE id_comune='$id_comune'";
     253                        $sth = $dbi->prepare("$sql");
     254                        $result=$sth->execute();       
     255                }else{
     256                        $sql"update  ".$prefix."_ele_cons_comune set  chiusa='$chiusa' WHERE id_cons2='$id_cons2'";
     257                        $sth = $dbi->prepare("$sql");
     258                        $result=$sth->execute();       
     259                }
     260                        if (!$result) return;
    204261                Header("Location: admin.php?op=cons_comuni&id_cons_gen=$id_cons_gen");
    205262        }
  • trunk/admin/modules/Elezioni/ele_widget.php

    r53 r256  
    1515// Offset - visualizza il numero di elementi per pagina
    1616$offset=5;
    17 
     17global $dbi;
    1818$aid=$_SESSION['aid'];
    19 $dbi=$_SESSION['dbi'];
    2019$prefix=$_SESSION['prefix'];
    2120$currentlang=$_SESSION['lang'];
     
    2625
    2726$id_comune=$_SESSION['id_comune'];
    28 $res = mysql_query("SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune' " , $dbi);
    29 list($tipo_cons,$id_cons) = mysql_fetch_row($res);
     27#$res = mysql_query("SELECT t1.tipo_cons,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons_gen='$id_cons_gen' and t2.id_comune='$id_comune' " , $dbi);
    3028
    3129include("modules/Elezioni/funzionidata.php");
    3230include("modules/Elezioni/ele.php");
     31$row=cur_cons();
     32$tipo_cons=$row[0];$id_cons=$row[1];
    3333
    3434if (isset($param['do'])) get_magic_quotes_gpc() ? $do=$param['do']:$do=addslashes($param['do']); else $do='';
     
    6464                    $files=$tlist[$i];
    6565                   
    66                     $sql = mysql_query("SELECT id FROM ".$prefix."_ele_widget where nome_file='$files'", $dbi);
    67                     list($idwid) = mysql_fetch_row($sql);
     66                    $sql = "SELECT id FROM ".$prefix."_ele_widget where nome_file='$files'";
     67                        $sth = $dbi->prepare("$sql");
     68                        $sth->execute();
     69                        $row = $sth->fetch(PDO::FETCH_BOTH);
     70                    $idwid=$row[0];
    6871                    $id = intval($idwid);
    6972
    70 
    7173                    if (empty($id)) { // inserisce widget db se non esiste
    72                         $result = mysql_query("insert into ".$prefix."_ele_widget (id,nome_file,titolo,pos_or,pos_ver, attivo) values ( NULL,'$files', '$files','1','','0')", $dbi);
    73                   }
     74                        $sql="insert into ".$prefix."_ele_widget (id,nome_file,titolo,pos_or,pos_ver, attivo) values ( NULL,'$files', '$files','1','','0')";
     75                        $sth = $dbi->prepare("$sql");
     76                        $sth->execute();                  }
    7477                 
    7578                 
     
    8487 
    8588                  # se non esiste cancella dal db
    86                   $sql2 = mysql_query("SELECT * FROM ".$prefix."_ele_widget", $dbi);
    87                   while ($row = mysql_fetch_array($sql2)) {
     89                  $sql="SELECT * FROM ".$prefix."_ele_widget";
     90                        $sth = $dbi->prepare("$sql");
     91                        $sth->execute();       
     92                        $row2 = $sth->fetchAll();
     93                        foreach($row2 as $row){
    8894                        $esi=0;
    8995                        for ($i=0; $i < sizeof($tlist); $i++) {
     
    9298                        }
    9399                        if($esi!=1){
    94                               $del=mysql_query("DELETE FROM ".$prefix."_ele_widget WHERE id = '$row[id]'",$dbi);
     100                            $sql="DELETE FROM ".$prefix."_ele_widget WHERE id = '$row[id]'";
     101                                $sth = $dbi->prepare("$sql");
     102                                $sth->execute();       
    95103                      }
    96104                }
     
    105113
    106114       
    107         $result = mysql_query("SELECT * FROM ".$prefix."_ele_widget order by pos_or,pos_ver asc", $dbi);
    108        
     115        $sql="SELECT * FROM ".$prefix."_ele_widget order by pos_or,pos_ver asc";
     116        $sth = $dbi->prepare("$sql");
     117        $sth->execute();       
     118        $row2 = $sth->fetchAll();       
    109119       
    110120
     
    113123        echo "<br><table border=\"0\" width=\"100%\">";
    114124        echo "<tr bgcolor=\"$bgcolor2\"><td align=\"center\"><b>"._CONFIGWIDGET."</b></td></tr></table>";
    115        
    116         while ($row = mysql_fetch_array($result)) {
     125        foreach($row2 as $row) {
    117126            echo "<form name=\"widget\" enctype=\"multipart/form-data\" method=\"post\" action=\"admin.php\">";
    118127            echo "<input type=\"hidden\" name=\"do\" value=\"update\">";
     
    163172        if ($perms >128) {
    164173                               
    165                 $result = mysql_query("update  ".$prefix."_ele_widget set titolo='$titolo', pos_or='$pos_or', pos_ver='$pos_ver', attivo='$attivo' where id='$idw'", $dbi) || die("Errore di aggiornamento dei dati!".mysql_error());
     174                $sql="update  ".$prefix."_ele_widget set titolo='$titolo', pos_or='$pos_or', pos_ver='$pos_ver', attivo='$attivo' where id='$idw'";
     175                $sth = $dbi->prepare("$sql");
     176                $sth->execute();
    166177
    167178                Header("Location: admin.php?id_cons_gen=$id_cons_gen&op=widget");
     
    185196function make_db_widget(){
    186197global $dbi,$prefix;
    187 $result = mysql_query("CREATE TABLE IF NOT EXISTS ".$prefix."_ele_widget (
     198$sql="CREATE TABLE IF NOT EXISTS ".$prefix."_ele_widget (
    188199  `id` int(10) NOT NULL auto_increment,
    189200  `nome_file` varchar(255) NOT NULL default '',
     
    193204 `attivo` int(1) NOT NULL default '0',
    194205  PRIMARY KEY  (`id`)
    195 )",$dbi);
     206)";
     207$sth = $dbi->prepare("$sql");
     208$sth->execute();
    196209
    197210
  • trunk/admin/temi/default/index.php

    r2 r256  
    1010$bgcolor="#b0b0b0";
    1111$nometema=$tema;
     12
    1213function testata($tema){
    1314global $nometema,$id_comune,$id_cons_gen,$aid,$dbi,$prefix;
    1415$nometema=$tema;
    15 $res_com = mysql_query("SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune'",$dbi);
    16 $res_cons = mysql_query("SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen'",$dbi);
    17 list($descr_comune) = mysql_fetch_row($res_com);
    18 list($descr_consultazione) = mysql_fetch_row($res_cons);
     16        $sql="SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' ";
     17        $sth = $dbi->prepare("$sql");
     18        $sth->execute();       
     19        $row = $sth->fetch(PDO::FETCH_BOTH);
     20$descr_consultazione=$row[0];
     21$sql="select descrizione from ".$prefix."_ele_comuni where id_comune='$id_comune'";
     22        $sth = $dbi->prepare("$sql");
     23        $sth->execute();       
     24        $row = $sth->fetch(PDO::FETCH_BOTH);
     25$descr_comune=$row[0];
    1926
    2027echo "<div class=\"container\"><table width=\"95%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"table-main\">
  • trunk/client/temi/Futura2/index.php

    r253 r256  
    207207####################################### menu risultati
    208208function risultati(){
    209 global $id_comune,$id_cons_gen,$genere,$tipo_cons,$colortheme;
     209global $id_comune,$id_cons_gen,$genere,$tipo_cons,$colortheme,$votoc;
    210210echo '<div data-role="content" data-theme="'.$colortheme.'">
    211211<a href="modules.php?op=affluenze_all&id_comune='.$id_comune.'&id_cons_gen='.$id_cons_gen.'" data-role="button" data-theme="'.$colortheme.'" data-icon="arrow-right" data-iconpos="right">Affluenze</a>
     
    215215        if($genere==3  OR $genere==5)
    216216                echo '<a href="modules.php?op=liste_mob&id_comune='.$id_comune.'&id_cons_gen='.$id_cons_gen.'" " data-role="button" data-theme="'.$colortheme.'" data-icon="arrow-right" data-iconpos="right">'._LISTA.'</a>';
    217         if(($genere==3 OR $genere==5) and $tipo_cons!="1" or $tipo_cons>="11")
     217        if(($genere==3 OR $genere==5) and !$votoc)
    218218                echo '<a href="modules.php?op=candidato_mob&id_comune='.$id_comune.'&id_cons_gen='.$id_cons_gen.'" " data-role="button" data-theme="'.$colortheme.'" data-icon="arrow-right" data-iconpos="right">'._CANDIDATO.'</a>';
    219219
Note: See TracChangeset for help on using the changeset viewer.