<?php
/*
Questo file contiene le funzioni generiche
dataodierna() restituisce la data odierna nel formato mysql AAAA-MM-GG
dataoraodierna() restituisce la dataora odierna nel formato mysql AAAA-MM-GG HH:MM:SS
*/
function dataodierna() {
/*
Questa funzione restituisce la data odierna nel formato mysql
*/
$today = getdate();
$month = $today['mon'];
$day = $today['mday'];
$year = $today['year'];
return $year."-".$month."-".$day;
}
function dataoraodierna() {
/*
Questa funzione restituisce la dataora odierna nel formato mysql
*/
$today = getdate();
$month = $today['mon'];
$day = $today['mday'];
$year = $today['year'];
$hours = $today['hours'];
$minutes = $today['minutes'];
$seconds = $today['seconds'];
return $year."-".$month."-".$day." ".$hours.":".$minutes.":".$seconds;
}
function logga($stringa,$id) {
/*
Questa funzione prende in input una stringa e un id crea/riempie il file di log relativo all'id con la stringa
*/
if (!file_exists(base_log_path)) {
mkdir(base_log_path, 0777);
}
if ($id<0) {
if ($hn=fopen(base_log_path."debug_log","a")) {
$stringa=dataoraodierna()." - ".$stringa."\n";
fwrite($hn,$stringa);
}
} else {
if ($hn=fopen(base_log_path.base_log_file.$id,"a")) {
$stringa=dataoraodierna()." - ".$stringa."\n";
fwrite($hn,$stringa);
}
}
}
?>