This is one (well parts of) I was shown for PhpBB
Should look easier for PunBB as we have the IP stored ...
// note before: these are snippets taken directly from an admin script; I'm not going to show everything!
// `$cnx' is the connection resource for the phpBB2 db
// `sudoers' needs to be setup before to allow the `sudo` CLI command to work
$C_USR_WHERE = "(`user_active` > 0) and (`user_posts` < 1) and ((`user_website` > '') or (`user_sig` > ''))";
$C_USR_MAN_ON = ( mysql_result( mysql_query("SELECT COUNT(*) FROM users WHERE $C_USR_WHERE", $cnx ), 0 ) > 0 )
? TRUE
: FALSE;
...
$select = '*';
$from = 'users';
$where = $C_USR_WHERE;
$order = 'user_id';
$r = mysql_query("
SELECT $select
FROM $from
WHERE $where
ORDER BY $order
LIMIT $cStart, $ShowRows
", $cnx );
$users = array();
while( $row = mysql_fetch_assoc( $r )) {
$users['user_id'][] = $row['user_id'];
$users['username'][] = $row['username'];
$users['user_website'][] = $row['user_website'];
$users['user_sig'][] = $row['user_sig'];
$users['user_interests'][] = $row['user_interests'];
$users['user_email'][] = $row['user_email'];
$users['time'][] = (( $row['user_lastvisit'] > $row['user_session_time'])
? $row['user_lastvisit']
: (( $row['user_session_time'] > $row['user_regdate'])
? $row['user_session_time']
: $row['user_regdate']
)
);
$oldSetting = ignore_user_abort( TRUE ); // in case it takes forever
if( !empty( $users['username'])) foreach( $users['username'] as $key => $username ) {
// phpBB2 does not store IPs in user record
// first check if there is a chance of getting it
if( $users['time'][ $key ] > $five_weeks_ago ) {
$str = "/bin/egrep -hm 1 '\"$username\"' /var/log/httpd/access_log /var/log/httpd/access_log.1 /var/log/httpd/access_log.2 /var/log/httpd/access_log.3 /var/log/httpd/access_log.4";
if(
( $str = trim(`sudo $str 2>&1`)) and
(( $pos = strpos( $str, ' ')) !== FALSE )
) {
$users['user_ip'][ $key ] = substr( $str, 0, $pos );
} else {
$users['user_ip'][ $key ] = '';
}
} else {
$users['user_ip'][ $key ] = '';
}
$userHidden->val = $users['user_id'][ $key ];
$Cip->val = $users['user_ip'][ $key ];
$Submit->val = 'Remove';
$remove = $Form->show( $userHidden->show() . $Cip->show() . $Start->show() . $Submit->show());
$Submit->val = 'Clear';
$clear = $Form->show( $userHidden->show() . $Clear->show() . $Start->show() . $Submit->show());
$rowStyleTog = ( $rowStyleTog ) ? FALSE : TRUE;
$Rows .= hTR(
hTD( $remove ).
hTD( $username ).
hTD( $users['user_email'][ $key ]).
hTD( $users['user_website'][ $key ]).
hTD( $users['user_sig'][ $key ]).
hTD( $users['user_interests'][ $key ]).
hTD( $clear )
,'','','','','','','','', (( $rowStyleTog ) ? $StyleHi : ''));
}
ignore_user_abort( $oldSetting ); // don't mind user-abort now
$TableHead = $Form->show( hTHead(
hTR( hTD( $search->show(), 6 )).
$NavHead.
hTR( hTD('', 6 )).
hTR(
hTH().
hTH('Username '. _T_DESC ).
hTH('Email Address').
hTH('Website').
hTH('Signature').
hTH('Interests').
hTH()
)
,'', 'middle'));