-
Notifications
You must be signed in to change notification settings - Fork 1
/
logging.php
executable file
·61 lines (51 loc) · 1.61 KB
/
logging.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/*
* Создан: 13.08.2007 18:11:14
* Автор: Александр Перов
*/
$conf['logdir'] = "logs/";
$filename = $conf['logdir'].date("d_m_Y");
$loggingtext = "/-\n/ ".date("H:i:s")."\n/-\n";
$loggingtext .= "/ IP: ";
$loggingtext .= $_SERVER['REMOTE_ADDR']." ";
if (isset($_SERVER['HTTP_VIA']))
$loggingtext .= "HTTP_VIA:".$_SERVER['HTTP_VIA']." ";
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$loggingtext .= "HTTP_X_FORWARDED_FOR:".$_SERVER['HTTP_X_FORWARDED_FOR']." ";
$loggingtext .= "\n/-\n";
foreach($_REQUEST as $k => $v) {
if ($k=="password" || $k=="password2" || $k=="phpbb2mysql_data" ||
$k=="phpbb2mysql_sid" || $k=="PHPSESSID" || $k=="oldpassword" ||
$k=="sid") {
} else { $loggingtext .= "$k - $v\n"; }
}
$loggingtext .= $_SERVER["REQUEST_URI"]."\n";
$loggingtext .= "\n";
if (!file_exists($filename))
{
$fp = fopen($filename.time(),"a");
fputs($fp, $loggingtext);
fclose($fp);
} else
{
// добавляем в архив
$dir = $conf['logdir'];
if(!($res=opendir($dir))) exit(_("Нет такой директории..."));
while(($file=readdir($res))==TRUE)
if($file!="." && $file!=".."
&& $file!='.htaccess'
&& $file!='.htpass'
&& $file!='errorLog.txt'
&& $file!='archive'
&& $file!=date("d_m_Y"))
{
$data = implode("", file($conf['logdir'].$file));
$gzdata = gzencode($data, 3);
$fp = fopen($conf['logdir']."archive/".$file.".gz", "w");
fwrite($fp, $gzdata);
fclose($fp);
unlink($conf['logdir'].$file);
}
closedir($res);
}
?>