PHP logging system

0

I wanted to record everything that happens on my site, from logins, record creation (insert), update and deletion. Home Looked like this:

  

[14-05-2016 17:53] User andre registered with IP: 111.111.111.111
  [14-05-2016 17:54] User andre eliminated client with ID 2
  [14-05-2016 17:55] User andre created client with ID 3

I created a script in php to write the records in a file log.log
Content of file regista.php

<?php
date_default_timezone_set('Europe/Lisbon'); $cache_new = date("\[d-m-Y H:i\] ");
header('Content-Type: text/html; charset=utf-8');

$cache_new .= $_GET['q']; 

$file = "C:\xampp\htdocs\pap\registos\log.log"; 
$cache_new .= "\n";
$handle = fopen($file, "r+") or die ();
$len = strlen($cache_new);
$final_len = filesize($file) + $len;
$cache_old = fread($handle, $len);
rewind($handle);
$i = 1;
while (ftell($handle) < $final_len) {
  fwrite($handle, $cache_new);
  $cache_new = $cache_old;
  $cache_old = fread($handle, $len);
  fseek($handle, $i * $len);
  $i++;
}
?>

If I go to http://meusite/registo/regista.php?q=Utilizador fez login it will register to the file. Home But I wanted to auto, for example the file eliminar.php , after the delete script the database client will log in.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://omeusite/registos/regista.php?q=Utilizador fez login");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($ch);
curl_close($ch);
echo $output;

When you put this in eliminar.php , after executing the query in the database the page is extremely slow and does not register the entry. What did I do wrong?

    
asked by anonymous 14.05.2016 / 19:06

0 answers