Read through the comments for ways to tweak/adjust and things you need to set.
Create prefixes named Registration_Mult & Registration_BAN
I use [MULT] and [BAN], you can use whatever you want.
**Note these were intended for use in a forum with a table mod, so if you don't have one you'll need to adjust them to some other style of conveying the same info, or install one.
Create templates:
registration_iplog_results
HTML Code:
<vb:if condition="$item[banned] == 'False'">[url="{vb:raw vboptions.bburl}/member.php?u={vb:raw userid}"]{vb:raw username}[/url]|{vb:raw userid}|{vb:raw ipaddress}|{vb:raw firstuse}|{vb:raw lastuse}|{vb:raw banned}<vb:else />[url="{vb:raw vboptions.bburl}/member.php?u={vb:raw userid}"]{vb:raw username}[/url]|{vb:raw userid}|{vb:raw ipaddress}|{vb:raw firstuse}|{vb:raw lastuse}|[BG="RED"]{vb:raw banned}[/BG]</vb:if>
registration_iplog
HTML Code:
UserName : {vb:raw username}
Member Link: [URL="{vb:raw memberlink}"]{vb:raw memberlink}[/URL]
Email Address : {vb:raw email}
IP Address: {vb:raw ipaddress}
Proxy For: {vb:raw proxyfor}
[table="head;"]UserName|UserID|IPAddress|FirstUse|LatestUse|CurrentlyBanned
{vb:raw resultlist}
[/table]
Create a plugin
Hook: register_addmember_complete
PHP Code:
$ipaddress = IPADDRESS;
// Declaritive proxy?
$proxyfor = $_SERVER['HTTP_X_FORWARDED_FOR'];
$memberlink = fetch_seo_url('member|nosession', array('userid' => $userid, 'username' => htmlspecialchars_uni($vbulletin->GPC['username'])));
$memberlink = $vbulletin->options['bburl'] . $memberlink;
$db->hide_errors();
// This query may be slow if you do not have an index on ipaddress in both users and posts.
$query = "select u.username, l.userid, l.ipaddress, min(l.firstuse) firstuse, max(l.lastuse) lastuse, case COALESCE((select min(liftdate) from userban where userid = u.userid and ( UNIX_TIMESTAMP() between bandate and liftdate OR liftdate = 0 ) ),1) when 1 then 'False' when 0 then 'Perma' else 'True' end as banned from (select userid, ipaddress, min(joindate) firstuse, max(joindate) lastuse from user group by userid, ipaddress UNION ALL select userid, ipaddress, min(dateline) firstuse, max(dateline) lastuse from post group by userid, ipaddress ) l left outer join user u on l.userid = u.userid where l.IpAddress = '$ipaddress' group by u.username, l.userid, l.ipaddress order by max(lastuse) desc";
$result = $vbulletin->db->query_read( $query );
$prefix = '';
// Loop through all results
while ($item = $vbulletin->db->fetch_array($result))
{
if ( $item[banned] != 'False')
$prefix = 'Registrations_BAN';
if ($prefix == '')
$prefix = 'Registration_Mult';
// Generate Variables to be used
$templater = vB_Template::create('registration_iplog_results');
$templater->register('username', $item[username]);
$templater->register('userid', $item[userid]);
$templater->register('ipaddress', $item[ipaddress]);
$templater->register('firstuse', $item[firstuse]);
$templater->register('lastuse', $item[lastuse]);
$templater->register('banned', $item[banned]);
$resultlist .= $templater->render();
}
// Unset the row returned.
unset($item);
// free the resultset
$db->free_result($result);
$templater = vB_Template::create('registration_iplog');
$templater->register_page_templates();
$templater->register('username', $username);
$templater->register('memberlink', $memberlink);
$templater->register('email', $email);
$templater->register('ipaddress', $ipaddress);
$templater->register('proxyfor', $proxyfor);
$templater->register('resultlist', $resultlist);
$postmessage = $templater->render();
// The forum you wish to post threads to
$forumid = 9999;
$foruminfo = fetch_foruminfo( $forumid );
$dataman =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_SILENT, 'threadpost');
$dataman->set_info('forum', $foruminfo);
$dataman->set_info('is_automated', true);
$dataman->set('showsignature', true);
$dataman->set_info('mark_thread_read', true);
$dataman->set('allowsmilie', true);
// We're making them post as themselves to avoid IPs being attributed to the bot in this example
// Uncomment this and assign it to a user id you wish these to show up as being by if you don't want them to show up as the user.
//$posterid = 3;
$dataman->setr('userid', $userid);
$dataman->set('title', $username);
$dataman->setr('pagetext', $postmessage);
$dataman->set('prefixid', $prefix);
// Uncomment this if you want to use a static account instead of the registering account.
//$dataman->set('ipaddress', '127.0.0.1');
$dataman->setr('forumid', $foruminfo['forumid']);
$dataman->set('visible', true);
$threadid = $dataman->save();