Changeset 360 for trunk/admin/admin.php
- Timestamp:
- Mar 14, 2022, 5:13:56 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/admin.php
r359 r360 139 139 140 140 try{ 141 $dbi = new PDO("mysql:host=$dbhost;charset= latin1", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));141 $dbi = new PDO("mysql:host=$dbhost;charset=utf8", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION)); 142 142 $sql = "use $dbname"; 143 143 $dbi->exec($sql); … … 147 147 echo $sql . "<br>" . $e->getMessage(); 148 148 } 149 150 149 $sth = $dbi->prepare("SET SESSION character_set_connection = 'utf8' "); 150 $sth->execute(); 151 $sth = $dbi->prepare("SET SESSION character_set_client = 'utf8' "); 152 $sth->execute(); 153 $sth = $dbi->prepare("SET SESSION character_set_database = 'utf8' "); 154 $sth->execute(); 155 $sth = $dbi->prepare("SET CHARACTER SET utf8"); 156 $sth->execute(); 157 158 $sth = $dbi->prepare("SET NAMES 'utf8'"); 159 $sth->execute(); 160 $sth = $dbi->prepare("select * from ".$prefix."_config"); 161 $sth->execute(); 162 151 163 # $dbi=mysql_connect($dbhost, $dbuname, $dbpass) or die("Connessione non riuscita: " . mysql_error()); 152 164 # mysql_select_db($dbname)or die("Connessione non riuscita:" . mysql_error()); … … 264 276 $id_comune=$_SESSION['id_comune']; 265 277 if($id_comune==0) $rifcomune='58047'; else $rifcomune=$id_comune; 266 if (isset($_GET['id_cons_gen'])) $id_cons_gen=intval($_GET['id_cons_gen']);278 if (isset($_GET['id_cons_gen'])) {$id_cons_gen=intval($_GET['id_cons_gen']);} 267 279 else { 268 $sql="SELECT t1.id_cons_gen FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons=t2.id_cons and t2.id_comune='$id_comune'"; 269 $sth = $dbi->prepare($sql); 270 $sth->execute(); 271 $row = $sth->fetch(PDO::FETCH_BOTH); 272 if($sth->rowCount()) 273 $id_cons_gen=$row[0]; 274 else 275 $id_cons_gen=0; #die("TEST IN CORSO : idconsgen: $id_cons_gen -- sql:select id_cons_gen from ".$prefix."_ele_cons_comune where preferita='1' and (id_comune='$id_comune' or id_comune=0)"); 276 } 280 $oggi=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-3,date("Y"))); 281 $sql="select t1.id_cons_gen from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune=$id_comune and t1.data_fine>'$oggi' and t2.id_cons in (select id_cons from ".$prefix."_ele_operatori where aid='$aid' and id_sez>0 and permessi>0) limit 0,1"; 282 $rese = $dbi->prepare("$sql"); 283 $rese->execute(); 284 if($rese->rowCount()) 285 {list($id_cons_gen)=$rese->fetch(PDO::FETCH_NUM); } 286 else { 287 $sql="SELECT t1.id_cons_gen FROM ".$prefix."_ele_cons_comune as t1, ".$prefix."_ele_comuni as t2 where t1.id_cons=t2.id_cons and t2.id_comune='$id_comune'"; 288 $sth = $dbi->prepare($sql); 289 $sth->execute(); 290 $row = $sth->fetch(PDO::FETCH_BOTH); 291 if($sth->rowCount()) 292 $id_cons_gen=$row[0]; 293 else 294 $id_cons_gen=0; #die("TEST IN CORSO : idconsgen: $id_cons_gen -- sql:$sql"); 295 } 296 } 277 297 $currentlang=$_SESSION['lang']; 278 298 #$bgcolor1=$_SESSION['bgcolor1']; … … 281 301 $session=$_SESSION['remote']; 282 302 283 $perms=ChiSei($id_cons_gen); 284 if($perms==0) logout();303 $perms=ChiSei($id_cons_gen); #die("qui".$_SESSION['aid']); 304 if($perms==0) {logout();} 285 305 } 286 306 … … 296 316 $pwd=$_SESSION['pwd']; 297 317 $id_comune=$_SESSION['id_comune']; 298 299 318 300 319 $perms=0; … … 325 344 if($row[0]==0) $msglogout=1; 326 345 if ($sth->rowCount()==1) $perms=$row[0]; else { $msglogout=1; $perms=0; } 346 327 347 return $perms; 328 348 #} else return 0; … … 404 424 Header("Location: admin.php?id_comune=$id_comune&language=$lang"); 405 425 */ 426 406 427 global $siteistat,$perms,$msglogout; 407 428 $language=$_SESSION['lang']; … … 432 453 $sth = $dbi->prepare("$sql"); 433 454 $sth->execute(); 434 if ($sth->rowCount()) list($id_cons) = $sth->fetch(PDO::FETCH_NUM); 435 $_SESSION['id_cons']=$id_cons; 455 if ($sth->rowCount()) { 456 list($id_cons) = $sth->fetch(PDO::FETCH_NUM); 457 $_SESSION['id_cons']=$id_cons; 458 } 436 459 } 437 460 if(isset($id_cons)) { 438 $sql="SELECT id_sez FROM ".$prefix."_ele_operatori where id_ cons=$id_consand aid='$aid' and id_comune=$id_comune";461 $sql="SELECT id_sez FROM ".$prefix."_ele_operatori where id_sez>0 and aid='$aid' and id_comune=$id_comune"; 439 462 $resmod = $dbi->prepare("$sql"); 440 463 $resmod->execute(); 441 list($id_sez) = $resmod->fetch(PDO::FETCH_NUM); 442 if($id_sez) $tema='Futura2';#die( "TEST id_cons:$id_cons:"); 443 $_SESSION['tema']=$tema; 464 list($id_sez) = $resmod->fetch(PDO::FETCH_NUM); #die("qui:$id_sez:$sql"); 465 if($id_sez) { 466 $oggi=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-3,date("Y"))); 467 $sql="select t1.id_cons_gen,t1.descrizione,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_comune=$id_comune and t1.data_fine>'$oggi' and t2.id_cons in (select id_cons from ".$prefix."_ele_operatori where aid='$aid' and id_sez>0 and permessi>0)"; 468 $resmod = $dbi->prepare("$sql"); 469 $resmod->execute(); 470 if ($resmod->rowCount()>0) { 471 $tema='Futura2'; #die( "TEST id_cons:$id_cons:".$_SESSION['aid']); 472 $_SESSION['tema']=$tema; 473 } else logout(); 474 } 444 475 } 445 476 } … … 449 480 if (isset($param['op'])) $op=addslashes($param['op']); else $op='ele'; 450 481 //if (isset($param['op'])) $op=$param['op']; else $op='ele'; 451 #die( "OP: $op"); 482 # 483 #die("TEST: qui $aid $id_cons $id_sez ".$_SESSION['aid']); 452 484 if (isset($_SESSION['aid']) AND $_SESSION['remote']==$_SERVER['REMOTE_ADDR']) { 453 485 if($tema=='Futura2' and $op!='logout')
Note:
See TracChangeset
for help on using the changeset viewer.