Welcome to Geeklog, Anonymous Wednesday, December 04 2024 @ 04:47 pm EST
Geeklog Forums
New Block: Members gone AWOL
Status: offline
jmichael
Forum User
Chatty
Registered: 04/08/04
Posts: 47
Hey, there! Being new to Geeklog, never having touched PHP and my last SQL statements about 10 years old, I figured I'd go about creating a little block. I copied the whosnew block and sort of reversed its operation. It now finds members who haven't logged on in a configurable number of days. Maybe somebody can use it.
function phpblock_goneawol() {
global $_CONF,$_TABLES,$_DB_table_prefix;
// Set the number of new members to show
$numToShow = 7; // max number of members to show in list
$AWOLafter = 5; // number of days after which a member is considered AWOL
// get regular members (not anon,admin,moderator) who haven't logged in for more than $AWOLafter days.
$sql = "SELECT username, lastlogin FROM `".$_DB_table_prefix."users`, `".$_DB_table_prefix."userinfo` "
. "WHERE ".$_DB_table_prefix."users.uid = ".$_DB_table_prefix."userinfo.uid AND ".$_DB_table_prefix."users.uid > 3 "
. "AND (".time()."- lastlogin)/86400 > $AWOLafter ORDER BY lastlogin ASC LIMIT $numToShow";
$result = DB_query( $sql );
$nrows = DB_numRows($result);
if ($nrows == 0) {
$retval = "All members are accounted for";
} else {
$retval = '<b>Oldest first</b><br>';
for ($i = 1; $i <= $nrows; $i++) {
$A = DB_fetchArray($result);
$tdiff = intval((time() - $A['lastlogin']) / 86400);
$retval .= $A['username'] .' ('.$tdiff.' days)<br>';
}
}
return $retval;
}
Text Formatted Code
function phpblock_goneawol() {
global $_CONF,$_TABLES,$_DB_table_prefix;
// Set the number of new members to show
$numToShow = 7; // max number of members to show in list
$AWOLafter = 5; // number of days after which a member is considered AWOL
// get regular members (not anon,admin,moderator) who haven't logged in for more than $AWOLafter days.
$sql = "SELECT username, lastlogin FROM `".$_DB_table_prefix."users`, `".$_DB_table_prefix."userinfo` "
. "WHERE ".$_DB_table_prefix."users.uid = ".$_DB_table_prefix."userinfo.uid AND ".$_DB_table_prefix."users.uid > 3 "
. "AND (".time()."- lastlogin)/86400 > $AWOLafter ORDER BY lastlogin ASC LIMIT $numToShow";
$result = DB_query( $sql );
$nrows = DB_numRows($result);
if ($nrows == 0) {
$retval = "All members are accounted for";
} else {
$retval = '<b>Oldest first</b><br>';
for ($i = 1; $i <= $nrows; $i++) {
$A = DB_fetchArray($result);
$tdiff = intval((time() - $A['lastlogin']) / 86400);
$retval .= $A['username'] .' ('.$tdiff.' days)<br>';
}
}
return $retval;
}
11
11
Quote
All times are EST. The time is now 04:47 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content