日志文件行
4/10/2024--06:00pm guest 192.168.1.2 https://nixnut.nz/home/accounts/hosting.cgi?action=getonline Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0
在 logview 文件中我有
open (FILE, "tail -$form{'howmany'} $file | tail -$form{'howmany'} |") or die "Opening $file: $!";
while (<FILE>) {
chomp;
s/^\"//;
s/\"$//;
my ($date, $user, $host, $page, $browser) = split(' ', $_);
print "<tr bgcolor=black>";
print "<td bgcolor=white align=left valign=top>$font $date</td>";
print "<td bgcolor=white align=left valign=top><a href=http://nixnut.nz/$user target=_blank>$font $user</a></td>";
print "<td bgcolor=white align=left valign=top>$font <a href=https://www.iptolocation.io/ip-lookup/$host target=_blank>$host</a></td>";
print "<td bgcolor=white align=left valign=top>$font <a href=http://$host target=_blank>$host</a></td>";
print "<td bgcolor=white align=left valign=top><a href=$page target=_blank>$font $page</a></td>";
print "<td bgcolor=white align=left valign=top>$font $browser</td>";
print "</tr>\n";
}
close (FILE);
输出是
4/10/2024--06:00pm guest 192.168.1.2 192.168.1.2 https://nixnut.nz/home/accounts/hosting.cgi?action=getonline Mozilla/5.0
由于空格而缺少完整的用户代理
Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0