Sunday, October 28, 2007

Drupal Hack:: Show users email addresses

I was looking through all the spam registrants of a drupal site I maintain. Alot of usernames of zhzjshsk are very suspicious, and also emily and kate, and worst of all, sorry russia, but email addresses from .ru are HUGE sources of spam. Doesn't your country have a valid source of revenue? Can't you just up the production of vodka a little? I don't think stoli sales are as high as they could be.

Anyways, I modified my modules/user.module so that when in the administrative mode of view my users I can see certain info at a glance.

username, email address, status, member since, last online, ...

It doesn't have built in showing of email address, so I hacked modules/user.module to give that feature.


function user_admin_account() {
$header = array(
array('data' => t('Username'), 'field' => 'u.name'),
array('data' => t('Email'), 'field' => 'u.mail'),

array('data' => t('Status'), 'field' => 'u.status'),
array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
array('data' => t('Last access'), 'field' => 'u.access'),
t('Operations')
);
$sql = 'SELECT u.uid, u.name, u.mail, u.status, u.created, u.access FROM {users} u WHERE uid != 0';
$sql .= tablesort_sql($header);
$result = pager_query($sql, 50);

$status = array(t('blocked'), t('active'));
while ($account = db_fetch_object($result)) {
$rows[] = array(theme('username', $account),
$account->mail,
$status[$account->status],
format_interval(time() - $account->created),
$account->access ? t('%time ago', array('%time' => format_interval(time() - $account->access))) : t('never'),
l(t('edit'), "user/$account->uid/edit", array()));
}

1 comment:

  1. Happy belated birthday. I have mail for you. I will send as soon as I get it together. Don't hold your breath.
    Nadine

    ReplyDelete

Note: Only a member of this blog may post a comment.