#!/usr/bin/perl use strict; use warnings; use 5.10.0; # we'll use this to filter out people who haven't logged in. # pretty silly! my %whitelist; my (@lastlog) = split /\n/, `lastlog | grep -v Never | awk '{ print \$1; }'`; foreach my $user (@lastlog) { $whitelist{$user} = 1; } my $hostname = `hostname`; chomp $hostname; opendir(my $dh, '/home/') or die "could not open /home/: $!"; my %dirs; my %titles; while (my $dir = readdir $dh) { next if $dir =~ /^[.]/; next unless $whitelist{$dir}; my $index_html_path = "/home/$dir/public_html/index.html"; if (-e $index_html_path) { $dirs{$dir} = (stat $index_html_path)[9]; # mtime $titles{$dir} = get_title_from_file($index_html_path); } } close $dh; sub sort_by_time { $dirs{$b} <=> $dirs{$a}; } my $list = "
~' . $key . ' | ' . '' . $titles{$key} . ' | ' . '' . $dirs{$key} . ' | ' . "