Skip to content

Commit

Permalink
Add logging system
Browse files Browse the repository at this point in the history
  • Loading branch information
anas-araid committed Dec 2, 2018
1 parent 37f62f9 commit edcd5ba
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.csv
log.txt
vigili.sql
2 changes: 1 addition & 1 deletion core/checkPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$_SESSION['include'] = 'core/reports.php';
echo "
<script>
flatAlert('Accesso eseguito con successo', '', 'success', 'index.php');
flatAlert('Accesso eseguito con successo', '', 'success', 'core/log.php');
</script>";
}
if (!$esistenzaUtente){
Expand Down
2 changes: 1 addition & 1 deletion core/createPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function validaPassword() {
$_SESSION['include'] = 'core/reports.php';
echo "
<script>
flatAlert('Accesso eseguito con successo', '', 'success', 'index.php');
flatAlert('Accesso eseguito con successo', '', 'success', 'core/log.php');
</script>";
}

Expand Down
17 changes: 17 additions & 0 deletions core/log.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
session_start();
$ipaddress = $_SERVER['REMOTE_ADDR'];
$timestamp = date('d/m/Y H:i:s');
$browser = $_SERVER['HTTP_USER_AGENT'];
$line = "Connessione: [".$timestamp."] - ".$_SESSION['Nome']." ".$_SESSION['Cognome']." - ".$ipaddress." - ".$browser."\n";
$filename = "log.txt";
$filedir = "../$filename";
if (!file_exists($filedir)){
$log = fopen($filedir, "w");
}else{
$log = fopen($filedir, "a+");
}
fwrite($log, $line);
fclose($log);
header("location:../index.php");
?>
2 changes: 1 addition & 1 deletion stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ function updateYears() {
}else{
$inter = "interventi";
}
print_r($interventi);

$tipoIntervento = $interventi[$i][0];
$totInterventi = $interventi[$i][1];
$tuttiInterventi .= "<b>$tipoIntervento: </b> $totInterventi $inter <br>";
Expand Down

0 comments on commit edcd5ba

Please sign in to comment.