Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 10:24 pm EDT

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.

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;
}

 
 Quote

All times are EDT. The time is now 10:24 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