-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog.php
More file actions
31 lines (28 loc) · 689 Bytes
/
Copy pathlog.php
File metadata and controls
31 lines (28 loc) · 689 Bytes
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
<?php
$url = $_GET["url"];
$ip = $_SERVER["REMOTE_ADDR"];
$now = time();
$fname = "log.txt";
$log = fopen($fname, "r");
$content = trim(fread($log, filesize($fname)));
fclose($log);
$lines = explode("\n", $content);
$found = false;
for ($i = 0; $i < count($lines); $i++) {
$tokens = explode("##", $lines[$i]);
if ($tokens[0] == $url && $tokens[1] == $ip) {
$tokens[2] = $now;
$found = true;
$lines[$i] = implode("##", $tokens);
break;
}
}
if (!$found) {
$tokens = array($url, $ip, $now);
$line = $url . "##" . $ip . "##" . $now;
$lines[] = $line;
}
$log = fopen($fname, "w");
fwrite($log, implode("\n", $lines));
fclose($log);
?>