Changeset b8095d1
- Timestamp:
- Dec 7, 2025, 7:46:01 PM (11 hours ago)
- Branches:
- main
- Parents:
- a1f2a9f
- Location:
- admin
- Files:
-
- 11 edited
-
includes/query.php (modified) (1 diff)
-
login.php (modified) (3 diffs)
-
modules/cambio_password.php (modified) (3 diffs)
-
modules/elenco_utenti.php (modified) (1 diff)
-
modules/gestione_consultazioni.php (modified) (1 diff)
-
modules/gestione_utenti.php (modified) (5 diffs)
-
modules/modules.php (modified) (3 diffs)
-
modules/salva_config_sito.php (modified) (3 diffs)
-
modules/salva_utente.php (modified) (3 diffs)
-
modules/setup_sito.php (modified) (10 diffs)
-
principale.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
admin/includes/query.php
ra1f2a9f rb8095d1 4 4 else 5 5 require_once 'includes/check_access.php'; 6 7 function cambio_password($pass)8 {9 global $id_cons_gen,$id_comune,$prefix,$dbi;10 $aid=$_SESSION['username'];11 $mpass=md5($pass);12 if($_SESSION['ruolo']=='superuser') $id='0'; else $id=$id_comune;13 $sql="update ".$prefix."_authors set pwd='$mpass' where id_comune=$id and aid='$aid'";14 $sth = $dbi->prepare("$sql");15 $sth->execute();16 $row = $sth->rowCount();17 return($row);18 }19 6 20 7 function configurazione() -
admin/login.php
ra1f2a9f rb8095d1 4 4 5 5 # Inserimento accesso al db 6 6 global $id_comune; 7 7 if (file_exists("config/config.php")){ 8 8 $install="0"; @require_once("config/config.php"); … … 52 52 $sth->execute(); 53 53 $row = $sth->fetch(PDO::FETCH_ASSOC); 54 $_SESSION['id_comune']=$id_comune; 54 55 $multicomune=$row['multicomune']; 55 56 $_SESSION['multicomune']=$multicomune; … … 69 70 $mpwd=md5($pwd); 70 71 if (isset($_POST['id_comune']) and intval($_POST['id_comune'])>0) $id_comune=intval($_POST['id_comune']); else $id_comune=$row['siteistat']; 71 $sth = $dbi->prepare("select pwd,adminop,adminsuper,counter,admlanguage from ".$prefix."_authors where binary aid='$aid' and pwd='$mpwd' and (id_comune='$id_comune' or adminsuper='1')");72 $sth->execute();73 $esiste=$sth->rowCount();74 $row = $sth->fetch(PDO::FETCH_ASSOC);75 if(!$esiste) {76 $_SESSION['msglogout']=2;77 header("Location: ../logout.php");78 }else{79 if ($row['pwd']!=$mpwd) {80 $msglogout=3;81 header("Location: ../logout.php");82 }83 $counter = $row['counter'];84 $counter++;72 $sth = $dbi->prepare("select pwd,adminop,admincomune,adminsuper,counter,admlanguage from ".$prefix."_authors where binary aid='$aid' and pwd='$mpwd' and (id_comune='$id_comune' or adminsuper='1')"); 73 $sth->execute(); 74 $esiste=$sth->rowCount(); 75 $row = $sth->fetch(PDO::FETCH_ASSOC); 76 if(!$esiste) { 77 $_SESSION['msglogout']=2; 78 header("Location: ../logout.php"); 79 }else{ 80 if ($row['pwd']!=$mpwd) { 81 $msglogout=3; 82 header("Location: ../logout.php"); 83 } 84 $counter = $row['counter']; 85 $counter++; 85 86 # $tmplang=$row['admlanguage']; 86 87 # if(strlen($tmplang)==2) $language=$tmplang; 87 $sth = $dbi->prepare("update ".$prefix."_authors set counter=$counter where aid='$aid' and pwd='$mpwd' and id_comune='$id_comune'");88 $sth->execute();89 $_SESSION['id_comune']=$id_comune;90 $id_cons_gen=intval(default_cons());91 $_SESSION['id_cons_gen']=$id_cons_gen;92 }88 $sth = $dbi->prepare("update ".$prefix."_authors set counter=$counter where aid='$aid' and pwd='$mpwd' and id_comune='$id_comune'"); 89 $sth->execute(); 90 $_SESSION['id_comune']=$id_comune; 91 $id_cons_gen=intval(default_cons()); 92 $_SESSION['id_cons_gen']=$id_cons_gen; 93 } 93 94 if($row['adminsuper']) $role='superuser'; 94 95 elseif($row['admincomune']) $role='admin'; -
admin/modules/cambio_password.php
ra1f2a9f rb8095d1 3 3 4 4 // Simulazione utente loggato 5 $_SESSION['username'] = $_SESSION['username'] ?? 'mario.rossi';5 //$_SESSION['username'] = $_SESSION['username'] ?? 'mario.rossi'; 6 6 $username = $_SESSION['username']; 7 7 $messaggio = ''; … … 9 9 // Connessione MySQL con PDO (commentata) 10 10 // require_once '../includes/db_connection.php'; // Assicurati che questo file definisca $pdo 11 if (!function_exists('cambio_password')) {11 #if (!function_exists('cambio_password')) { 12 12 function cambio_password($vecchia_password, $nuova_password) { 13 // Esempio con MySQL (decommenta per usare) 14 /* 15 global $pdo; 13 global $prefix,$aid,$dbi,$id_comune; 16 14 $username = $_SESSION['username']; 17 15 # $vecchia_password=md5($vecchia_password);# die("UPDATE ".$prefix."_authors SET pwd = '$hash' WHERE aid = '$username'"); 18 16 // Recupero hash corrente 19 $stmt = $ pdo->prepare("SELECT password FROM utenti WHERE username = :username");20 $stmt->execute( ['username' => $username]);17 $stmt = $dbi->prepare("SELECT pwd FROM ".$prefix."_authors WHERE aid = '$username'"); 18 $stmt->execute(); 21 19 $row = $stmt->fetch(PDO::FETCH_ASSOC); 22 if (!$row || !password_verify($vecchia_password, $row['password'])) {20 if (!$row || $vecchia_password!=$row['pwd']) { 23 21 return 'Vecchia password errata.'; 24 22 } 25 26 23 // Aggiornamento con nuova password 27 $hash = password_hash($nuova_password, PASSWORD_DEFAULT); 28 $stmt = $pdo->prepare("UPDATE utenti SET password = :hash WHERE username = :username"); 29 $successo = $stmt->execute(['hash' => $hash, 'username' => $username]); 30 return $successo ? true : 'Errore durante l\'aggiornamento.'; 31 */ 32 33 // Simulazione: sempre successo 24 # $hash = md5($nuova_password); 25 $stmt = $dbi->prepare("UPDATE ".$prefix."_authors SET pwd = '$nuova_password' WHERE aid = '$username'"); 26 $stmt->execute(); 27 if($stmt->rowCount()) 34 28 return true; 29 else return 'Errore durante l\'aggiornamento.'; 30 35 31 } 36 }32 #} 37 33 38 34 if ($_SERVER['REQUEST_METHOD'] === 'POST') { … … 46 42 $messaggio = '<div class="alert alert-warning">La nuova password deve contenere almeno 8 caratteri, una maiuscola, una minuscola, un numero e un carattere speciale.</div>'; 47 43 } else { 48 $test = cambio_password( $vecchia_password, $nuova_password);44 $test = cambio_password(md5($vecchia_password), md5($nuova_password)); 49 45 if ($test === true) 50 46 $messaggio = <<<HTML 51 <div id="overlay-success"> 52 <div class="overlay-bg"></div> 53 <div class="overlay-msg"> 54 ✅ Password aggiornata con successo! 55 </div> 56 </div> 57 <style> 58 #overlay-success { 59 position: fixed; 60 top: 0; left: 0; 61 width: 100vw; height: 100vh; 62 display: flex; 63 align-items: center; 64 justify-content: center; 65 z-index: 9999; 66 } 67 .overlay-bg { 68 position: absolute; 69 top: 0; left: 0; 70 width: 100%; height: 100%; 71 background: rgba(0, 0, 0, 0.7); 72 } 73 .overlay-msg { 74 position: relative; 75 background: #fff; 76 padding: 30px 40px; 77 font-size: 1.5rem; 78 font-weight: bold; 79 border-radius: 10px; 80 z-index: 10000; 81 box-shadow: 0 0 10px #000; 82 text-align: center; 83 } 84 </style> 47 alert(<?= $test ?>) 48 85 49 HTML; 86 50 -
admin/modules/elenco_utenti.php
ra1f2a9f rb8095d1 9 9 foreach($row as $key=>$val){ 10 10 $key++; 11 echo "<tr id=\"riga$key\"><td id=\"username$key\">".$val['aid']."</td><td style=\"display:none;\" id=\" password$key\">".$val['pwd']."</td><td id=\"email$key\">".$val['email']."</td><td id=\"nominativo$key\">".$val['name']."</td><td><button class=\"btn btn-sm btn-warning me-1\" onclick=\"editUser($key)\">Modifica</button>";11 echo "<tr id=\"riga$key\"><td id=\"username$key\">".$val['aid']."</td><td style=\"display:none;\" id=\"admin$key\">".$val['admincomune']."</td><td style=\"display:none;\" id=\"password$key\">".$val['pwd']."</td><td id=\"email$key\">".$val['email']."</td><td id=\"nominativo$key\">".$val['name']."</td><td><button class=\"btn btn-sm btn-warning me-1\" onclick=\"editUser($key)\">Modifica</button>"; 12 12 if($currentUserRole != 'operatore' and $val['adminsuper']!=1 and $val['admincomune']!='1') echo "<button class=\"btn btn-sm btn-danger\" onclick=\"deleteUser($key)\">Elimina</button>"; echo"</td></tr>"; 13 13 } #die("TEST: --- ".count($row)); -
admin/modules/gestione_consultazioni.php
ra1f2a9f rb8095d1 214 214 risultato.innerHTML = data; // Mostra la risposta del server 215 215 myForm.reset(); 216 document.getElementById ( "id_cons_gen" ).value = '' 216 217 document.getElementById ( "submitBtn" ).textContent = "Aggiungi Consultazione" 217 218 -
admin/modules/gestione_utenti.php
ra1f2a9f rb8095d1 21 21 <div class="form-group col-md-3"> 22 22 <label>Password*</label> 23 <input type="password" class="form-control" id="password" required>23 <input type="password" class="form-control" id="password" onfocus="select()" required> 24 24 </div> 25 25 <div class="form-group col-md-3"> … … 31 31 <input type="text" class="form-control" id="nominativo"> 32 32 </div> 33 </div> 33 <?php if($_SESSION['ruolo']=='superuser') $nascondi=''; else $nascondi="d-none"; ?> 34 <div class="form-group form-check <?= $nascondi ?>" > 35 <input type="checkbox" class="form-check-input" id="admin" name="admin"> 36 <label class="form-check-label" for="preferita">Admin</label> 37 </div> 38 </div> 34 39 35 40 … … 63 68 64 69 function editUser(id) { 70 if(document.getElementById ( "admin"+id ).innerText==1) 71 document.getElementById ( "admin" ).checked = true 72 else 73 document.getElementById ( "admin" ).checked = false 65 74 document.getElementById('username').value = document.getElementById('username'+id).innerText; 66 75 document.getElementById('password').value = '********'; … … 75 84 e.preventDefault(); 76 85 86 const admin = document.getElementById('admin').checked; 77 87 const username = document.getElementById ( "username" ).value 78 88 const password = document.getElementById ( "password" ).value … … 83 93 const formData = new FormData(); 84 94 formData.append('funzione', 'salvaUtente'); 95 formData.append('admin', admin); 85 96 formData.append('username', username); 86 97 formData.append('password', password); -
admin/modules/modules.php
ra1f2a9f rb8095d1 5 5 require_once '../access.php'; 6 6 # Inserimento accesso al db 7 global $id_comune; 7 8 8 9 if (file_exists("../config/config.php")){ … … 11 12 $install="1"; 12 13 } 13 14 #if(!isset($_SESSION['id_comune'])) 15 $_SESSION['id_comune']=$id_comune; 14 16 # verifica se effettuata la configurazione 15 17 if(empty($dbname) || $install=="1") { … … 55 57 $versione=$row[0]['versione']; 56 58 $patch=$row[0]['patch']; 57 if($versione ==3) {59 if($versione<4) { 58 60 require_once '../includes/aggiornadbTo4.php'; 59 61 } -
admin/modules/salva_config_sito.php
ra1f2a9f rb8095d1 11 11 } 12 12 13 global $prefix,$fileout,$aid,$id_cons_gen,$id_comune; 13 14 15 if (isset($_GET['siteIstat'])) $siteIstat=$_GET['siteIstat']; else $siteIstat=$id_comune; 14 16 if (isset($_GET['siteName'])) $siteName=$_GET['siteName']; else $siteName=''; 15 17 if (isset($_GET['siteUrl'])) $siteUrl=$_GET['siteUrl']; else $siteUrl=''; … … 23 25 24 26 25 global $prefix,$fileout,$aid,$id_cons_gen;26 27 $id_cons=$_SESSION['id_cons']; 27 28 $salvato=1; 28 29 29 $sql="update ".$prefix."_config set site name='$siteName', siteurl='$siteUrl', adminmail='$emailAdmin', siteistat='$defaultComune', multicomune='$multicomune', googlemaps='$mapsProvider', gkey='$googleApiKey'";30 $sql="update ".$prefix."_config set siteistat='$siteIstat',sitename='$siteName', siteurl='$siteUrl', adminmail='$emailAdmin', multicomune='$multicomune', googlemaps='$mapsProvider', gkey='$googleApiKey'"; 30 31 31 32 try { … … 39 40 } 40 41 if($salvato){ 41 echo "<br><button id=\"bottoneStato\" style=\"background-color:aquamarine;\" onfocusout=\"document.getElementById('bottoneStato').style.display='none'\" > Dati salvati correttamente </button>";42 echo "<br><button id=\"bottoneStato\" style=\"background-color:aquamarine;\" onfocusout=\"document.getElementById('bottoneStato').style.display='none'\" > Dati salvati correttamente $id_comune</button>"; 42 43 }else{ 43 44 echo "Errore di inserimento dati"; -
admin/modules/salva_utente.php
ra1f2a9f rb8095d1 17 17 if (isset($param['nominativo'])) $nominativo=addslashes($param['nominativo']); else $nominativo=''; 18 18 if (isset($param['op'])) $op=addslashes($param['op']); else $op=''; 19 19 if (isset($param['admin'])) $admin=addslashes($param['admin']); else $admin='0'; 20 if($admin == 'true') { $admin=1; $operatore=0;} 21 else $operatore=1; 20 22 global $prefix,$aid,$dbi,$id_comune; 21 23 $salvato=0; … … 25 27 if($res->rowCount()) { 26 28 if($op=='salva') { 27 if($password =='********') $pass="pwd='$password'";else $pass="";29 if($password!='********') {$password=md5($password); $pass=",pwd='$password'"; }else $pass=""; 28 30 #update 29 $sql="update ".$prefix."_authors set name='$nominativo', email='$email',$pass where aid='$username'";31 $sql="update ".$prefix."_authors set name='$nominativo',adminop='$operatore',admincomune='$admin', email='$email' $pass where aid='$username'"; 30 32 $compl = $dbi->prepare("$sql"); 31 33 $compl->execute(); … … 40 42 }else{ 41 43 #insert 42 $sql="insert into ".$prefix."_authors values( '$username','$nominativo','$id_comune','$email','$password',' ','1','0','0','it')";44 $sql="insert into ".$prefix."_authors values( '$username','$nominativo','$id_comune','$email','$password','0','$operatore','$admin','0','it')"; 43 45 $compl = $dbi->prepare("$sql"); 44 46 $compl->execute(); -
admin/modules/setup_sito.php
ra1f2a9f rb8095d1 2 2 require_once '../includes/check_access.php'; 3 3 4 4 global $id_comune; 5 5 $row=configurazione(); 6 6 $SITE_NAME = $row[0]['sitename']; … … 8 8 $EMAIL_ADMIN = $row[0]['adminmail']; 9 9 $MAP_PROVIDER = $row[0]['googlemaps']==='1' ? 'google' : 'openstreetmap' ; 10 $MULTICOMUNE = $row[0]['multicomune']; #==='1' ? 'si' : 'no'; 10 #$SITE_COMUNE = $row[0]['siteistat']>0 ? $row[0]['siteistat'] : $id_comune; 11 #$MULTICOMUNE = $row[0]['multicomune']; #==='1' ? 'si' : 'no'; 11 12 $gru = [ 12 13 'google_api_key' => $row[0]['gkey'] … … 15 16 $GOOGLE_API_KEY = !empty($gru['google_api_key']) ? htmlspecialchars($gru['google_api_key']) : ''; 16 17 $GOOGLE_API_KEY = $row[0]['gkey']; 17 $SITE_ISTAT=$row[0]['siteistat'] ;18 $SITE_ISTAT=$row[0]['siteistat']>0 ? $row[0]['siteistat'] : $_SESSION['id_comune']; 18 19 $row=elenco_comuni(); 19 20 foreach($row as $key=>$val){ … … 24 25 #$comuni_disponibili = ['Comune di Roma', 'Comune di Milano', 'Comune di Napoli']; 25 26 #$DEFAULT_COMUNE = 'Comune di Roma'; 26 27 #echo "TEST:$SITE_ISTAT: $id_comune:".$_SESSION['id_comune']; 27 28 28 29 if(is_file('../logo.jpg')) $SITE_IMAGE = '../logo.jpg'; … … 38 39 <form id="configSitoForm" onsubmit="aggiornaDati(event)"> 39 40 <!-- LOGO + ANTEPRIMA --> 41 <input type="hidden" name="siteIstat" id="siteIstat" value="<?= $SITE_ISTAT ?>"> 40 42 <div class="mb-3 d-flex align-items-center"> 41 43 <div id="previewImageDiv" … … 142 144 function aggiornaDati(e) { 143 145 e.preventDefault(); 146 const siteIstat = document.getElementById('siteIstat').value; 144 147 const siteName = document.getElementById('siteName').value; 145 148 const siteUrl = document.getElementById('siteUrl').value; … … 147 150 const mapsProvider = document.getElementById('maps_provider').value; 148 151 const googleApiKey = document.getElementById('googleApiKey').value; 149 const multicomune = document.getElementById('multicomune').value;150 const defaultComune = document.getElementById('defaultComune').value;151 152 152 153 // Salvataggio nel DB (commentato) … … 158 159 } 159 160 } 160 xmlhttp.open("GET","../principale.php?funzione=salvaConfigSito&site Name="+siteName+"&siteUrl="+siteUrl+"&emailAdmin="+emailAdmin+"&mapsProvider="+mapsProvider+"&googleApiKey="+googleApiKey+"&multicomune="+multicomune+"&defaultComune="+defaultComune,true);161 xmlhttp.open("GET","../principale.php?funzione=salvaConfigSito&siteIstat="+siteIstat+"&siteName="+siteName+"&siteUrl="+siteUrl+"&emailAdmin="+emailAdmin+"&mapsProvider="+mapsProvider+"&googleApiKey="+googleApiKey,true); 161 162 xmlhttp.send(); 162 163 } … … 170 171 171 172 toggleApiKeyField(); 172 toggleComuneDefault();173 173 }); 174 174 … … 194 194 document.getElementById('apikey_row').style.display = (provider === 'google') ? '' : 'none'; 195 195 } 196 197 // Mostra/nasconde campo Comune default198 function toggleComuneDefault() {199 const multicomune = document.getElementById('multicomune').value;200 document.getElementById('defaultComuneRow').style.display = (multicomune === '1') ? '' : 'none';201 }202 196 203 197 function nascondiElemento() { -
admin/principale.php
ra1f2a9f rb8095d1 11 11 define('APP_RUNNING', true); 12 12 #die("Errore"); 13 global $dbi,$prefix ;13 global $dbi,$prefix,$id_comune; 14 14 // gestione sessione 15 15 if (!isset($_SESSION))
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/eleonline4/chrome/common/trac_banner.png)