| Server IP : 159.223.102.202 / Your IP : 216.73.216.193 Web Server : nginx/1.26.0 System : Linux Gen1-cloudpanel2ubuntu2404-1vcpu-1gb-nyc1-01 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 User : albasshbotta ( 1021) PHP Version : 8.2.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /home/bottaingenieriaUep/htdocs/www.bottaingenieria.com.ar/licen/ |
Upload File : |
<?php
/*
log.class.php
by dabu@centrum.cz
http://dabu.dhs.org/
simple logging class
logs: date, ip, script name, additional text
additional: display_log(), does not log duplicate entries
within $toler seconds, resolves real ip for proxies
usability: to log php access to phpscipt or events by client
notice: make sure that $log_file has write privilege for webserver
example:
$l = new simplelog;
$l->entry();
$l->display_log();
*/
class simplelog {
var $notify = 1;
var $notify_mail = 'hernan@bottaingenieria.com.ar';
var $from = 'logacceso@bottaingenieria.com.ar';
var $notify_mail_subj = 'Log de acceso';
var $log_file = '.access.log';
var $toler = 120;
var $ip;
var $xcache;
var $date;
var $page;
var $text;
var $dolog = false;
// inicializace
function simplelog() {
if ($_SERVER["HTTP_X_FORWARDED_FOR"]) {
$this->ip = gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]);
$this->xcache = gethostbyaddr($_SERVER["REMOTE_ADDR"]);
}
else {
$this->ip = gethostbyaddr($_SERVER["REMOTE_ADDR"]);
$this->xcache = '';
}
$this->date = date("d.m.Y H:i:s");
$this->page = $_SERVER["SCRIPT_NAME"];
$this->text = "";
$this->dolog = 1;
}
// zobrazi log
function display_log() {
echo ("<FONT size=1><b>Access log:</b><br>");
$fp=@fopen($this->log_file, "r");
if ($fp) {
while ($buf=fgets($fp,4096)) {
echo chop($buf)."<br>";
}
fclose($fp);
}
echo ("</FONT>");
}
// test jestli v logu neni zpetne ($toler sekund) stejny IP
function check_entry() {
if (file_exists($this->log_file)) {
$fp=@fopen($this->log_file, "r");
if ($this->xcache) $logtext = "(x: ".$this->xcache.") ".$this->text;
else $logtext = $this->text;
if ($fp) {
while ($buf=fgets($fp,4096)) {
if (strlen($buf)>3) {
// extrahuje casti dat cas ip
preg_match("/^([0-9.]+) ([0-9:]+) ([-a-z0-9.]*) ([^ ]*) ?(.*)\n$/i", $buf, $ret);
//jde o stejneho navstevnika ?
if (($ret[3] == $this->ip) && ($ret[5] == $logtext)) {
$fnd=1;
$dif=0;
$oldts = strtotime(substr($ret[1],6,4).'-'.substr($ret[1],3,2).'-'.substr($ret[1],0,2).' '.$ret[2]);
// hledam nejmensi diferenci mezi posledni navstevou a nynejsi navstevou
if ( $dif < (time() - $oldts) ) { $dif = time() - $oldts; }
}
}
}
fclose($fp);
}
// logovat pouze pokud tu byl pred vice jak $toler sekundama
if ($fnd && !($dif > $this->toler)) { $this->dolog = 0; }
else { $this->dolog = 1; }
}
}
// podminecny zalogovani do fajle (IP tu bylo recently?)
function entry() {
$this->check_entry();
if ($this->dolog) $this->write_log();
}
// bezpodminecny zalogovani do fajle
function write_log() {
if ($this->xcache) $logtext = "(x: ".$this->xcache.") ".$this->text;
else $logtext = $this->text;
$fp=@fopen($this->log_file, "a+");
if ($fp) {
fputs($fp,$this->date." ".$this->ip." ".$this->page." ".$logtext."\n");
fclose($fp);
}
$script = "http://". $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$script = $script . "/../" . $this->log_file ;
if ($this->notify) {
@mail($this->notify_mail, $this->notify_mail_subj, $this->date."\n".$this->ip."\n".$script."\n".$logtext, "From: $from");
}
}
}
?>