website/users.php

57 lines
1.9 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style.css">
<title>Users | ~vern</title>
</head>
<body>
<?php
$total = $on = 0;
$list = '';
$onlist = array();
$users = explode(' ', shell_exec('users /sshfs/var/run/utmp'));
$handle = opendir('/sshfs/home');
while (($subdir = readdir($handle)) !== false) {
$online = '<b><span class=';
if ($subdir != '.' && $subdir != '..') {
$is_online = false;
foreach ($users as $val)
if (trim($val) == $subdir && !in_array($subdir, $onlist)) {
$online .= 'green';
$is_online = true;
$on++;
array_push($onlist, $subdir);
}
if (!$is_online) $online .= 'red';
$online .= '>•</span></b> ';
$list .= ' <li>' . $online;
$ph_index = '/sshfs/home/' . $subdir . '/public_html/index.';
if (is_readable($ph_index . 'html') ||
is_readable($ph_index . 'php') ||
is_readable($ph_index . 'cgi') ||
is_readable($ph_index . 'py') ||
is_readable($ph_index . 'sh') ||
is_readable($ph_index . 'pl') ||
is_readable($ph_index . 'lua')) // There must be a better way to do this
$list .= "<a href='//$subdir.vern.cc'>$subdir</a>";
else $list .= $subdir;
$list .= "</li>\n";
$total++;
}
}
closedir($handle);
?>
<!--#include file="nav.html" -->
<div class=h><h1 id=users>Users</h1> <a aria-hidden=true href=#users>#users</a></div>
<p>This is a list of all ~vern users, and whether they are online (<b><span class=green>•</span></b>) or not (<b><span class=red>•</span></b>) in order of joining. There are currently a total of <?php echo $total; ?> members, <?php echo $on; ?> of which <?php echo $on !== 1 ? are : is ?> online.</p>
<ol>
<?php echo $list; ?>
</ol>
<!--#include file="footer.html" -->
</body>
</html>