forked from BlackMac/timetrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.php
28 lines (22 loc) · 644 Bytes
/
log.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
<?php
if (!isset($_GET['h']) || strlen($_GET['h']) != 32) {
echo "No Hash given";
exit;
}
$logtime=date("Y-m-d\TH:i:s");
$action="#";
if ($_GET['d']=="in") $action="+";
if ($_GET['d']=="out") $action="-";
$logline=$action.'['.$logtime.'] ***'.$_GET['d'].'***'."\r\n";
if(is_file('logs/'.$_GET['h'].'.log')) {
$filename = 'logs/'.$_GET['h'].'.log';
} elseif(is_dir('logs/'.$_GET['h'])) {
$filename = 'logs/'.$_GET['h'].'/month_'. date('Ym') .'.log';
} else {
mkdir('logs/'.$_GET['h']);
$filename = 'logs/'.$_GET['h'].'/month_'. date('Ym') .'.log';
}
$file=fopen($filename, 'a');
fputs($file, $logline);
fclose($file);
echo $logline;