Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
372 righe
11 KiB
372 righe
11 KiB
<?php |
|
require_once ROOT . "/lib/classes/IDataClass.php"; |
|
|
|
/** |
|
* Description of Logs |
|
* |
|
* @author Anselmo |
|
*/ |
|
class Logs extends DataClass { |
|
|
|
const TABLE_NAME = "LOGS"; |
|
const SP_ = "SPLOGSSAVE"; |
|
|
|
public $ID = 0; |
|
public $ID_OPERATORE = ""; |
|
public $IP = ""; |
|
public $USERNAME = ""; |
|
public $DATA = null; |
|
public $MODULE = ""; |
|
public $ACTION = ""; |
|
public $OPERATION = ""; |
|
public $INFO = ""; |
|
public $OLDVALUE = ""; |
|
|
|
|
|
/** |
|
* |
|
* @global type $con |
|
* @param type $src |
|
* @return type |
|
*/ |
|
public function __construct ($src = null) |
|
{ |
|
global $con; |
|
if ($src == null){ |
|
return; |
|
} |
|
if (is_array($src)) |
|
{ |
|
$this->_loadByRow($src, $stripSlashes); |
|
|
|
}elseif (is_numeric($src)) { |
|
// Carichiamo tramite ID |
|
$sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID = :id"; |
|
$query = $con->prepare($sql); |
|
$query->bindParam(":id", $src); |
|
try { |
|
$query->execute(); |
|
$it = $query->fetchAll(PDO::FETCH_ASSOC); |
|
$it[0]['INFO'] = stream_get_contents($it[0]['INFO']); |
|
$it[0]['OPERATION'] = stream_get_contents($it[0]['OPERATION']); |
|
$it[0]['OLDVALUE'] = stream_get_contents($it[0]['OLDVALUE']); |
|
Utils::FillObjectFromRow($this, $it[0]); |
|
} catch (Exception $exc) { |
|
$exc->getMessage(); |
|
} |
|
} |
|
} |
|
|
|
|
|
public function LoadDataTable($searchQuery = "", $searchArray = array(), $columnName = array(), $columnSortOrder = array(), $start = 0, $offset = 0) { |
|
return parent::_loadDataTable(self::TABLE_NAME, $searchQuery, $searchArray, $columnName, $columnSortOrder, $start, $offset); |
|
} |
|
|
|
public static function Load ($Dal = "", $Al = "", $id_operatore = "", $action = "") |
|
{ |
|
global $con; |
|
$where = ""; |
|
$order = " ID desc, DATA desc"; |
|
if ($Dal){ |
|
$Dal = Utils::FormatDate($Dal, DATE_FORMAT_ISO); |
|
} |
|
if ($Al){ |
|
$Al = Utils::FormatDate($Al, DATE_FORMAT_ISO); |
|
} |
|
|
|
if ($Dal && $Al){ |
|
$where = "(DATA BETWEEN :data_dal AND :data_al )"; |
|
}elseif ($Dal){ |
|
$where = "(DATA >= :data_dal)"; |
|
}elseif ($Al){ |
|
$where = "(DATA <= :data_al)"; |
|
} |
|
|
|
if (intval($id_operatore) > 0){ |
|
$where .= ($where == "" ? "" : " AND ") . "ID_OPERATORE = :id_operatore "; |
|
} |
|
|
|
if ($action != ""){ |
|
$where .= ($where == "" ? "" : " AND ") . "ACTION LIKE ':action%'"; |
|
} |
|
|
|
$sql = "SELECT * FROM " . self::TABLE_NAME; |
|
if ($where != ""){ |
|
$sql .= " WHERE $where"; |
|
} |
|
if ($order != ""){ |
|
$sql .= " ORDER BY $order"; |
|
} |
|
|
|
$query = $con->prepare($sql); |
|
|
|
if ($Dal && $Al){ |
|
$query->bindParam(":data_dal", $Dal); |
|
$query->bindParam(":data_al", $Al); |
|
}elseif ($Dal) { |
|
$query->bindParam(":data_dal", $Dal); |
|
}elseif ($Al) { |
|
$query->bindParam(":data_al", $Al); |
|
} |
|
|
|
if (intval($id_operatore) > 0){ |
|
$query->bindParam(":id_operatore", intval($id_operatore)); |
|
} |
|
if ($action !=""){ |
|
$query->bindParam(":action", $action); |
|
} |
|
try { |
|
$query->execute(); |
|
$it = $query->fetchAll(PDO::FETCH_ASSOC); |
|
} catch (Exception $exc) { |
|
$exc->getMessage(); |
|
} |
|
return $it; |
|
|
|
|
|
} |
|
|
|
/** |
|
* Funzione di salvataggio dei logs |
|
* @global type $con |
|
* @return type |
|
*/ |
|
public function Save() |
|
{ |
|
global $con, $LoggedAccount; |
|
|
|
$sql = "CALL " . self::SP_ . " (?,?,?,?,?,?,?,?)"; |
|
|
|
$query = $con->prepare($sql); |
|
|
|
$query->bindParam(1, $this->ID_OPERATORE); |
|
$query->bindParam(2, $this->IP); |
|
$query->bindParam(3, $LoggedAccount->CODICE_FISCALE); |
|
$query->bindParam(4, $this->MODULE); |
|
$query->bindParam(5, $this->ACTION); |
|
$query->bindParam(6, $this->OPERATION, PDO::PARAM_STR, strlen($this->OPERATION)); |
|
$query->bindParam(7, $this->INFO, PDO::PARAM_STR, strlen($this->INFO)); |
|
$query->bindParam(8, $this->OLDVALUE, PDO::PARAM_STR, strlen($this->OLDVALUE)); |
|
|
|
try { |
|
if($query->execute()){ |
|
$it['esito'] = 1; |
|
} |
|
|
|
} catch (Exception $exc) { |
|
$it['erroreDescrizione'] = $exc->getMessage(); |
|
} |
|
return $it; |
|
|
|
} |
|
|
|
/** |
|
* Restituisce la mappatura dei campi con i relativi valori modificati |
|
* @param type $record |
|
* @return type |
|
*/ |
|
public function ParseMessage(&$record) |
|
{ |
|
$testo = $this->INFO; |
|
$classe = $this->MODULE; |
|
$oldValue = $this->OLDVALUE; |
|
|
|
if($classe == "login" || $classe == "logout") |
|
{ |
|
return array(); |
|
} |
|
|
|
$obj = new $classe(json_decode($testo, true)); |
|
|
|
|
|
$record = array(); |
|
|
|
$props = get_class_vars(get_class($obj)); |
|
foreach($props as $k => $value) |
|
{ |
|
|
|
|
|
$fieldLog = array(); |
|
$fieldOldLog = array(); |
|
$obj->Parse($fieldLog, $k); |
|
|
|
$oldObj = new $classe(json_decode($oldValue, TRUE)); |
|
$oldObj->Parse($fieldOldLog, $k); |
|
|
|
if($fieldLog[0]['Campo'] != "") |
|
{ |
|
if(Utils::is_date($fieldLog[0]['Valore'])) |
|
{ |
|
$fieldLog[0]['Valore'] = Utils::FormatDate($fieldLog[0]['Valore'], DATE_FORMAT_ITA); |
|
|
|
} |
|
if(Utils::is_date($fieldOldLog[0]['Valore'])) |
|
{ |
|
$fieldOldLog[0]['Valore'] = Utils::FormatDate($fieldOldLog[0]['Valore'], DATE_FORMAT_ITA); |
|
|
|
} |
|
|
|
if(Utils::is_date($obj->$k)){ |
|
$obj->$k = Utils::FormatDate($fieldOldLog[0]['Valore'], DATE_FORMAT_ITA); |
|
} |
|
if(Utils::is_date($oldObj->$k)){ |
|
$oldObj->$k = Utils::FormatDate($fieldOldLog[0]['Valore'], DATE_FORMAT_ITA); |
|
} |
|
|
|
if(trim($obj->$k) != trim($oldObj->$k)) |
|
{ |
|
|
|
$record[] = array("Campo" => $fieldLog[0]['Campo'], "Valore" => $fieldLog[0]['Valore'], "OldValue" => $fieldOldLog[0]['Valore'], "Variato" => true); |
|
} |
|
else { |
|
$record[] = array("Campo" => $fieldLog[0]['Campo'], "Valore" => $fieldLog[0]['Valore'], "OldValue" => $fieldOldLog[0]['Valore'], "Variato" => false); |
|
|
|
} |
|
|
|
} |
|
} |
|
|
|
return $record; |
|
} |
|
|
|
/** |
|
* Verifica se un campo è stato modificato |
|
* @param type $field |
|
* @param type $valore |
|
* @param type $classe |
|
* @return boolean |
|
*/ |
|
public function fieldModified($field, $valore, $classe) |
|
{ |
|
$record = $this->ParseMessage(); |
|
|
|
if(Utils::is_date($valore)){ |
|
$valore = Utils::FormatDate($valore, DATE_FORMAT_ITA); |
|
} |
|
|
|
foreach($record as $value) |
|
{ |
|
if(trim($value['Campo']) == $field && trim($value['Valore']) != trim($valore)) |
|
{ |
|
return true; |
|
|
|
} |
|
} |
|
return false; |
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class LogsUploadFile extends DataClass { |
|
|
|
const TABLE_NAME = "LOGS_UPLOADFILE"; |
|
const SEQ_NAME = "LOGS_UPLOADFILE_ID_SEQ"; |
|
const SP_ = "SPLOGSFILESAVE"; |
|
|
|
public $ID = 0; |
|
public $ID_DOMANDA = ""; |
|
public $ERRORE = ""; |
|
public $FILEPATH = ""; |
|
public $DATA = null; |
|
public $HASHORIGINALE = ""; |
|
public $HASHESTRATTO = ""; |
|
public $FASE = ""; |
|
|
|
public function __construct($src = null) { |
|
global $con; |
|
if ($src == null){ |
|
return; |
|
} |
|
if (is_array($src)) { |
|
if (isset($src['ID']) && $src['ID'] > 0) { |
|
$this->_loadAndFillObject($src['ID'], self::TABLE_NAME, $src); |
|
} else { |
|
$this->_loadByRow($src, $stripSlashes); |
|
} |
|
} elseif (intval($src)) { |
|
$this->_loadById($src, self::TABLE_NAME, true); |
|
} |
|
} |
|
|
|
public function Save() { |
|
global $con; |
|
|
|
// 1,2,3,4,5,6 |
|
$sql = "CALL " . self::SP_ . " (?,?,?,?,?,?)"; |
|
|
|
$query = $con->prepare($sql); |
|
|
|
$query->bindParam(1, $this->ID_DOMANDA); |
|
$query->bindParam(2, $this->ERRORE); |
|
$query->bindParam(3, $this->FILEPATH); |
|
$query->bindParam(4, $this->HASHORIGINALE); |
|
$query->bindParam(5, $this->HASHESTRATTO); |
|
$query->bindParam(6, $this->FASE); |
|
|
|
try { |
|
if ($query->execute()) { |
|
$it['esito'] = 1; |
|
} |
|
} catch (Exception $exc) { |
|
$it['erroreDescrizione'] = $exc->getMessage(); |
|
} |
|
return $it; |
|
} |
|
|
|
} |
|
|
|
class LogsP7mFile extends DataClass { |
|
|
|
const TABLE_NAME = "LOGS_P7M"; |
|
const SEQ_NAME = "LOGS_P7M_ID_SEQ"; |
|
const SP_ = "SPLOGSP7MSAVE"; |
|
|
|
public $ID = 0; |
|
public $ID_DOMANDA = ""; |
|
public $ERRORE = ""; |
|
public $FILEPATH = ""; |
|
public $DATA = null; |
|
public $FASE = ""; |
|
|
|
public function __construct($src = null) { |
|
global $con; |
|
if ($src == null){ |
|
return; |
|
} |
|
if (is_array($src)) { |
|
if (isset($src['ID']) && $src['ID'] > 0) { |
|
$this->_loadAndFillObject($src['ID'], self::TABLE_NAME, $src); |
|
} else { |
|
$this->_loadByRow($src, $stripSlashes); |
|
} |
|
} elseif (intval($src)) { |
|
$this->_loadById($src, self::TABLE_NAME, true); |
|
} |
|
} |
|
|
|
public function Save() { |
|
global $con; |
|
|
|
// 1,2,3,4 |
|
$sql = "CALL " . self::SP_ . " (?,?,?,?)"; |
|
|
|
$query = $con->prepare($sql); |
|
|
|
$query->bindParam(1, $this->ID_DOMANDA); |
|
$query->bindParam(2, $this->ERRORE); |
|
$query->bindParam(3, $this->FILEPATH); |
|
$query->bindParam(4, $this->FASE); |
|
|
|
try { |
|
if ($query->execute()) { |
|
$it['esito'] = 1; |
|
} |
|
} catch (Exception $exc) { |
|
$it['erroreDescrizione'] = $exc->getMessage(); |
|
} |
|
return $it; |
|
} |
|
|
|
}
|
|
|