Commit a844deb5 authored by Leigh Stoller's avatar Leigh Stoller

A couple of additional changes that were originally requested by Jay;

Add the days idle (web and users) to the long listing of users.
parent d10548aa
......@@ -120,11 +120,14 @@ main(int argc, char **argv)
warn("Seeking to %ld", seekoff);
exit(-1);
}
rval = doentry(fp, uid, 1);
rval = 0;
if (doentry(fp, uid, 1) <= 0)
rval = -1;
}
else {
rval = 0;
for (uid = 0; ; uid++) {
if (rval = doentry(fp, uid, 0))
if ((rval = doentry(fp, uid, 0)) <= 0)
break;
}
}
......@@ -143,7 +146,7 @@ doentry(FILE *fp, uid_t uid, int umode)
fprintf(stderr, "Error reading entry %u\n", uid);
return -1;
}
return 1;
return 0;
}
if (ll.ll_time) {
......@@ -153,8 +156,8 @@ doentry(FILE *fp, uid_t uid, int umode)
if (umode)
printf("%s\n", buf);
else
printf("%u %s\n", uid, buf);
printf("%u %s\n", uid, buf);
}
return 0;
return 1;
}
......@@ -227,7 +227,17 @@ function LASTUSERSLOGIN($uid) {
if ($uid) {
return $output[0];
}
return $output;
#
# Convert to a hash table.
#
$hashtable = array();
for ($i = 0; $i < count($output); $i++) {
$parts = explode(" ", $output[$i]);
$hashtable["$parts[0]"] = "$parts[1] $parts[2]";
}
return $hashtable;
}
#
......
......@@ -47,14 +47,22 @@ if (mysql_num_rows($query_result) == 0) {
}
}
echo "<table width=\"100%\" border=2 cellpadding=0 cellspacing=2
#
# Grab the login info. If we cannot get the login info, then just
# proceed without it.
#
$loginarray = LASTUSERSLOGIN(0);
echo "<table width=\"100%\" border=2 cellpadding=1 cellspacing=0
align='center'>\n";
echo "<tr>
<td>&nbsp</td>
<td>UID</td>
<td>Name</td>
<td>Projects</td>
<td align=center>Approved?</td>\n";
<td>Web<br>Idle</td>
<td>Users<br>Idle</td>\n";
#
# Admin users get a "delete" and a "modify" option.
......@@ -69,6 +77,8 @@ while ($row = mysql_fetch_array($query_result)) {
$thisuid = $row[uid];
$name = $row[usr_name];
$status = $row[status];
$unix_uid = $row[unix_uid];
$lastweblogin = LASTWEBLOGIN($thisuid);
#
# Suck out a list of projects too.
......@@ -76,8 +86,17 @@ while ($row = mysql_fetch_array($query_result)) {
$projmemb_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM proj_memb where uid='$thisuid' order by pid");
echo "<tr>
<td><A href='showuser.php3?target_uid=$thisuid'>$thisuid</A></td>
echo "<tr>\n";
if (strcmp($status, "active") == 0 ||
strcmp($status, "unverified") == 0) {
echo "<td align=center><img alt=\"Y\" src=\"greenball.gif\"></td>\n";
}
else {
echo "<td align=center><img alt=\"N\" src=\"redball.gif\"></td>\n";
}
echo "<td><A href='showuser.php3?target_uid=$thisuid'>$thisuid</A></td>
<td>$name</td>\n";
if ($count = mysql_num_rows($projmemb_result)) {
......@@ -95,12 +114,29 @@ while ($row = mysql_fetch_array($query_result)) {
echo "<td>--</td>\n";
}
if (strcmp($status, "active") == 0 ||
strcmp($status, "unverified") == 0) {
echo "<td align=center><img alt=\"Y\" src=\"greenball.gif\"></td>\n";
#
# Sleazy! Use mysql query to convert dates to days and subtract!
#
if ($lastweblogin) {
$idle_query = mysql_db_query($TBDBNAME,
"SELECT TO_DAYS(CURDATE()) - TO_DAYS(\"$lastweblogin\")");
$idle_row = mysql_fetch_row($idle_query);
echo "<td>$idle_row[0]</td>\n";
}
else {
echo "<td align=center><img alt=\"N\" src=\"redball.gif\"></td>\n";
echo "<td>N/A</td>\n";
}
if ($loginarray && isset($loginarray["$unix_uid"])) {
$lastuserslogin = $loginarray["$unix_uid"];
$idle_query = mysql_db_query($TBDBNAME,
"SELECT TO_DAYS(CURDATE()) - TO_DAYS(\"$lastuserslogin\")");
$idle_row = mysql_fetch_row($idle_query);
echo "<td>$idle_row[0]</td>\n";
}
else {
echo "<td>N/A</td>\n";
}
if ($isadmin) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment