LogManager.php
<?php
class LogManager{
public function __construct(){ } public function setLog($msg){ if(!file_exists(LOG_PATH.LOG_FILE_NAME)){ $log= fopen(LOG_PATH.LOG_FILE_NAME, "w") or die ("Worning!: log file non creato."); fwrite($log, date("Y-m-d H:i:s")."] LogManager\n\n"); }else{ $log= fopen(LOG_PATH.LOG_FILE_NAME, "a"); fwrite($log, date("Y-m-d H:i:s"). " - ".$msg."\n"); fclose($log); } }}
?>
DBManager.php
<?php
require_once('DB.php');
class DBManager{
//*********************** CONNESSIONE ******************************************
public function getConn(){
try{
$db= mysql_connect($this->host, $this->user, $this->password);
mysql_select_db($this->name);
//*********************** QUERY ******************************************
public function runQuery($db, $query){ $data= array(); try{ $dataObj= mysql_query($query, $db); while($row= mysql_fetch_assoc($dataObj)){ $data[]= $row; } }catch (Exception $e){ $logManager= new LogManager(); $logManager->setLog("Errore query: ".$query); } return $data; } public function runInsert($db, $query){ try{ mysql_query($query, $db); $lastId=mysql_insert_id(); return $lastId; }catch (Exception $e){ $logManager= new LogManager(); $logManager->setLog("Errore query: ".$query); } } public function runQueryUpDel($db, $query){ try{ mysql_query($query, $db); }catch (Exception $e){ $logManager= new LogManager(); $logManager->setLog("Errore query: ".$query); } }//*********************** QUERY ******************************************
}
?>
header.php e visualizza.php sono inutili. la prima contiene un header con un javascript per i pulsanti del menù, la seconda è vuota.