Changeset 358 for trunk/admin/modules/Elezioni/ele_operatori.php
- Timestamp:
- Feb 22, 2022, 10:40:08 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/modules/Elezioni/ele_operatori.php
r344 r358 26 26 if (isset($_GET['passwd'])) $passwd=addslashes($param['passwd']); else $passwd=''; 27 27 if (isset($_GET['passwd2'])) $passwd2=addslashes($param['passwd2']); else $passwd2=''; 28 if (isset($_GET['stato']) && $aid2!='admin') $stato=intval($param['stato']); else $stato=0; 28 29 29 30 include("modules/Elezioni/funzionidata.php"); … … 37 38 global $aid, $offset, $prefix, $dbi,$id_cons,$aid2,$id_sede,$id_cons_gen,$mex,$perms; 38 39 //echo $perms;die(); 40 39 41 $bgcolor1=$_SESSION['bgcolor1']; 40 42 $id_comune=$_SESSION['id_comune']; … … 44 46 $rescom->execute(); 45 47 list($descr_com) = $rescom->fetch(PDO::FETCH_NUM); 46 $sql="SELECT aid,name,email FROM ".$prefix."_authors where aid='$aid2' and id_comune='$id_comune'";48 $sql="SELECT aid,name,email,adminop FROM ".$prefix."_authors where aid='$aid2' and id_comune='$id_comune'"; 47 49 $resmod = $dbi->prepare("$sql"); 48 50 $resmod->execute(); 49 list ($aid2,$name,$email ) = $resmod->fetch(PDO::FETCH_NUM);51 list ($aid2,$name,$email,$attivo) = $resmod->fetch(PDO::FETCH_NUM); 50 52 if (isset($_GET['mex'])){ 51 53 echo "<table align=\"center\"><tr><td style=\"background-color: rgb(255, 0, 0)\">"; … … 65 67 echo "</tr><tr align=\"center\">"; 66 68 echo "<td><input type=\"hidden\" name=\"pag_op\" value=\"admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=\">"; 67 echo "<select name=\"aid2\" onChange=\"top.location.href=this.form.pag_op.value+this.form.aid2.options[this.form.aid2.selectedIndex].value;return false\">";68 echo "<option value=\"\"> ";69 echo "<select id=\"aid2\" name=\"aid2\" onChange=\"top.location.href=this.form.pag_op.value+this.form.aid2.options[this.form.aid2.selectedIndex].value;return false\">"; 70 echo "<option value=\"\">Nuovo Utente"; 69 71 while(list($utente)=$resins->fetch(PDO::FETCH_NUM)){ 70 72 $sel= ($utente == $aid2) ? "selected":""; … … 86 88 echo "<td bgcolor=\"$bgcolor1\"><b>"._NOME."</b></td>" 87 89 ."<td bgcolor=\"$bgcolor1\"><b>"._EMAIL."</b></td>"; 90 echo "<td bgcolor=\"$bgcolor1\"><b>"._STATO."</b></td>"; 91 92 88 93 echo "<td bgcolor=\"$bgcolor1\"><b>"._FUNZIONI."</b></td></tr>"; 89 94 echo "<tr align=\"center\"><td>"; … … 98 103 echo "<td align=\"center\"><input type=password name=\"passwd2\" size=\"12\"></td>"; 99 104 echo "<td><input name=\"name\" value=\"$name\"></td>"; 100 echo "<td><input name=\"email\" value=\"$email\">"; 105 echo "<td><input name=\"email\" value=\"$email\"></td>"; 106 if($attivo==0) {$sel2="selected"; $sel3='';} else {$sel2=''; $sel3="selected";} 107 echo "<td><select name=\"stato\"><option value=\"0\" $sel2>Attivo<option value=\"1\" $sel3>Disattivo<option value=\"2\" >Elimina</select>"; 101 108 echo "<input type=\"hidden\" name=\"id_cons_gen\" value=\"$id_cons_gen\">"; 102 109 echo "<input type=\"hidden\" name=\"ok\" value=0></td>"; … … 113 120 } 114 121 115 function operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune ) {122 function operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune,$stato) { 116 123 global $aid, $prefix, $dbi, $id_cons,$id_cons_gen,$currentlang; 117 124 $perms=ChiSei($id_cons_gen); 125 if($passwd!=$passwd2) { 126 $mex="- Le password non coincidono! -<br>"; 127 header("location:admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2&name=$name&email=$email&mex=$mex&stato=$stato"); 128 } 118 129 119 130 if ($perms!=256) $id_comune=$_SESSION['id_comune']; … … 124 135 $res->execute(); 125 136 $max=$res->rowCount(); 126 if ($ passwd==$passwd2 and $max==0){127 if ($aid2=='admin') $super=' 1,0,0,'; else $super = '0,1,0,';128 $sql="insert into ".$prefix."_authors (aid,name,id_comune,email,pwd,counter,adminop,admincomune,adminsuper,admlanguage) values ('$aid2','$name','$id_comune' , '$email','".md5($passwd)."', 0,$super'$currentlang')";137 if ($max==0){ 138 if ($aid2=='admin') $super='0,1,0,'; else $super = '0,0,0,'; 139 $sql="insert into ".$prefix."_authors (aid,name,id_comune,email,pwd,counter,adminop,admincomune,adminsuper,admlanguage) values ('$aid2','$name','$id_comune' , '$email','".md5($passwd)."','0',$super'$currentlang')"; 129 140 $res = $dbi->prepare("$sql"); 130 141 $res->execute(); … … 133 144 $res = $dbi->prepare("$sql"); 134 145 $res->execute(); 135 136 Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen ");146 } 147 Header("Location: admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2"); 137 148 }else{ 138 149 $mex=''; 139 if($passwd!=$passwd2) $mex="- Le password non coincidono! -<br>";140 150 if($max>0) $mex.=" - Utente <b>$aid2</b> presente in archivio! - "; 141 header("location:admin.php?op=operatori&id_cons_gen=$id_cons_gen&aid2=$aid2&name=$name&email=$email&mex=$mex");142 151 } 143 152 } elseif ($do == "update") { 144 $sql="update ".$prefix."_authors set name='$name',pwd='".md5($passwd)."', email='$email' where id_comune='$id_comune' and aid='$aid2' "; 145 $res = $dbi->prepare("$sql"); 146 $res->execute(); 153 if($passwd!='') $mexpwd="pwd='".md5($passwd)."',"; else $mexpwd=''; 154 if($stato==2){ 155 $sql="delete from ".$prefix."_authors where aid='$aid2' and id_comune=$id_comune"; 156 $res = $dbi->prepare("$sql"); 157 $res->execute(); 158 }else{ 159 $sql="update ".$prefix."_authors set name='$name', $mexpwd email='$email', adminop='$stato' where id_comune='$id_comune' and aid='$aid2' "; 160 $res = $dbi->prepare("$sql"); 161 $res->execute(); 162 } 147 163 $result=$res->rowCount(); 164 if($stato!=0){ 165 $sql="delete from ".$prefix."_ele_operatori where id_comune='$id_comune' and aid='$aid2' "; 166 $res = $dbi->prepare("$sql"); 167 $res->execute(); 168 } 148 169 if (!$result) return; 149 170 if ($aid2==$aid) $_SESSION['pwd']=md5($passwd); … … 157 178 // switch 158 179 //**************************** 159 if ($do) operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune );180 if ($do) operatori($do,$aid2,$name,$email,$passwd,$passwd2,$id_comune,$stato); 160 181 ele(); 161 182 all();
Note:
See TracChangeset
for help on using the changeset viewer.