PDA

View Full Version : The first vBulletin hack! -- the memberlist


04-20-2000, 06:02 AM
:) Yup, I'm quick. 2 days after the program is released and people (well, me) are already releasing hacks.

This is a port of the memberlist hack from UBB. But it also has a decent search feature too. Copy all the code into memberlist.php and put it in your main vBulletin directory. Here is my demo: http://www.magic-singles.com/cpa/forums/memberlist.php

(NOTE: THIS IS THE TEMPLATE-IZED VERSION)

Now, here's the code:

<?

require("global.php");

//TOP POSTERS AMOUNT
$topposternum = 10;

if ($numperpage=="") {
// NUMBER OF RECORDS PER PAGE
$numperpage = 30;
}

$numperpage2 = $numperpage;
$numperpage -= 1;

if (isset($action)==0 or $action=="") {
$action="getall";
}

if ($action=="getall") {
$cssinclude = gettemplate("cssinclude");

$condition="1=1";
if ($ausername!="") {
$condition.=" AND INSTR(username,'".$ausername."')>0";
}
if ($email!="") {
$condition.=" AND INSTR(email,'".$email."')>0";
}
if ($homepage!="") {
$condition.=" AND INSTR(homepage,'".$homepage."')>0";
}
if ($icq!="") {
$condition.=" AND INSTR(icq,'".$icq."')>0";
}
if ($aim!="") {
$condition.=" AND INSTR(aim,'".$aim."')>0";
}
if ($yahoo!="") {
$condition.=" AND INSTR(yahoo,'".$yahoo."')>0";
}
if ($biography!="") {
$condition.=" AND INSTR(biography,'".$biography."')>0";
}
if ($joindateafter!="") {
$condition.=" AND joindate>'".$joindate."'";
}
if ($joindatebefore!="") {
$condition.=" AND joindate<'".$joindatebefore."'";
}
if ($postslower!="") {
$condition.=" AND posts>$postslower";
}
if ($postsupper!="") {
$condition.=" AND posts<$postsupper";
}
if ($orderby=="") {
$orderby="username";
}
if ($limitstart=="") {
$limitstart=0;
} else {
$limitstart--;
}
if ($limitnumber=="") {
$limitnumber=($numperpage + 1);
}

$memberlistbit = "";
$temp = 0;
$users=$DB_site->query("SELECT userid,username,email,icq,aim,yahoo,biography,post s,joindate FROM user WHERE $condition ORDER BY $orderby $direction LIMIT $limitstart,$limitnumber");
while ($user=$DB_site->fetch_array($users)) {
$temp = $temp + 1;
$username = $user[username];
$userid = $user[userid];
$joindate = $user[joindate];
$posts = $user[posts];
$bio = str_replace(",", ", ", $user[biography]);
$bio = str_replace("\n", "\n<BR>", $bio);
if ($user[icq]!="") {
$icqM = "<a href=\"http://wwp.icq.com/$user[icq]#pager\" target=_blank><img src=\"http://online.mirabilis.com/scripts/online.dll?icq=$user[icq]&img=5\" alt=\"$user[username]\'s ICQ status\" border=0></a>";
} else {
$icqM = "&nbsp;";
}
if ($user[aim]!="") {
$aimM = "<a href=\"javascript:aimwindow('$user[aim]')\"><img src=\"images/aim.gif\" alt=\"Send a AIM message to $user[username]\" border=0></a>";
} else {
$aimM = "&nbsp;";
}
if ($user[yahoo]!="") {
$yahooM = "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=\$yahoohandle&.src=pg\" target=\"_blank\"><img src=\"http://opi.yahoo.com/online?u=$user[yahoo]&m=g&t=1\" alt=\"Send a message to $user[username]\" border=0></a>";
} else {
$yahooM = "&nbsp;";
}
eval("\$memberlistbit .= \"".gettemplate("memberlistbit")."\";");
} #end while

if ($top!="true") {
$memberlistpages = "Page: ";
$numbersmembers=$DB_site->query_first("SELECT COUNT(userid) AS users FROM user WHERE $condition");
$numbermembers=$numbersmembers[users];
$blah = $numbermembers / $numperpage;
$temp2 = intval($blah);
if ($numperpage!=1) {
$temp2 += 1;
}
if (($numbermembers % $numperpage)==0) {
$temp2 -= 2;
}
$temp3 = 1;
while ($temp3 <= $temp2) {
$thisstart = (($temp3 - 1) * $numperpage) + 2;
$thisstart2 = $thisstart - 1;
if ($thisstart==2) {
$thisstart = 1;
} #end if 0
if ((($thisstart==1) && ($limitstart==0)) || ($thisstart2==$limitstart)) {
$memberlistpages .= "$temp3 \n";
} else {
$memberlistpages .= "<a href=\"memberlist.php?action=$action&limitnumber=$limitnumber&limitstart=$thisstart&numperpage=$numperpage2&orderby=$orderby&ausername=$ausername&homepage=$homepage&icq=$icq&aim=$aim&yahoo=$yahoo&biography=$biography&joindateafter=$joindateafter&joindatebefore=$joindatebefore&lastvisitafter=$lastvisitafter&lastvisitbefore=$lastvisitbefore&lastpostafter=$lastpostafter&lastpostbefore=$lastpostbefore&postslower=$postslower&postsupper=$postsupper&direction=$direction\">$temp3</a> \n";
} #end if
$temp3++;
} #end while
} else {
$memberlistpages = "Page: 1";
} #end if ($top!="true)

eval("echo dovars(\"".gettemplate("memberlist")."\");");

} #end if ($action=="getall")

if ($action=="search") {

$cssinclude = gettemplate("cssinclude");
eval("echo dovars(\"".gettemplate("memberlistsearch")."\");");

} #end if ($action=="search")

?>

There are 2 variables you need to set:
//TOP POSTERS AMOUNT
$topposternum = 10;

and

// NUMBER OF RECORDS PER PAGE
$numperpage = 30;

-----
Now, I know some of this code isn't real efficient -- I did somethings, forgot I did them, then compensated in other places. :( Anyway, hopefully I'll be able to release some updates.

Enjoy! Give me feedback please! ;)

[Edited by Ed Sullivan on 04-20-2000 at 03:38 PM]

[Edited by Ed Sullivan on 04-20-2000 at 05:28 PM]

[Edited by Ed Sullivan on 04-21-2000 at 09:37 PM]

04-20-2000, 06:07 AM
:( I just realized the AIM javascript doesn't work. I looked at it and didn't really see anything wrong. Now, I'm not real good at javascript, so if someone could take a look at it, that'd be great! :)

[edit: I fixed this too!! :)]

[Edited by Ed Sullivan on 04-20-2000 at 05:29 PM]

04-20-2000, 06:11 AM
Dammit! I just accidently killed another feature -- the paging doesn't work on any page other than the first. *sigh*

[edit: I fixed this feature and changed the line of code up there --^]

[Edited by Ed Sullivan on 04-20-2000 at 03:39 PM]

04-20-2000, 06:27 AM
Well done - I have not tried it yet, but I'm sure it will be good. As hacks come in, I will try to include a template-ised version of it in the next major release - accredited to the author of course. BTW, how much of that code did you borrow from the control panel :)

Keep 'em coming,
John

04-20-2000, 06:32 AM
Control panel? What control panel? ;)

I borrowed entirely too much -- but hey, if its there for ya, why not use it :)

04-20-2000, 06:14 PM
LOL :D

I like the hack very much :)
a great job sofar. It looks alot cleaner then the ubb one, I must say

04-20-2000, 11:57 PM
Dammit! I just accidently killed another feature -- the paging doesn't work on any page other than the first. *sigh*

[edit: I fixed this feature and changed the line of code up there --^]

[Edited by Ed Sullivan on 04-20-2000 at 03:39 PM]


That's the way programming goes ya added a new feajure and kill another one someplace! HEHEHEHE

04-21-2000, 12:34 PM
Well done - I have not tried it yet, but I'm sure it will be good. As hacks come in, I will try to include a template-ised version of it in the next major release - accredited to the author of course.

You want a template-ized version? You got it! I was bored today so I template-ized it :) I will edit the code above, but here are the directions for templates.

Create template memberlist -

{htmldoctype}
<html><head><title>Members List</title>
$cssinclude
<script language="javascript">
<!--
function aimwindow(aimid) {
window.open("member.php?action=aimmessage&aim="+aimid,"_blank","toolbar=no,location=no,menubar=no,scrollbars=no,wi dth=175,height=275,resizeable=yes,status=no")
}
// -->
</script></head><BODY>
<table border=0 width=99% cellspacing=1 cellpadding=3>
<tr>
<td align="left"><a href="index.php"><img src="$titleimage" border=0></a></td><td align="center" width=225> <b><largefont>Members List</b></largefont> <BR>
<center><smallfont><a href="memberlist.php?action=search">advanced search</a> |
<a href="memberlist.php?action=getall&orderby=posts&direction=DESC&numperpage=10&top=true">top 10 posters</a> |
<a href="memberlist.php">alphabetical</a> |
<a href="memberlist.php?action=getall&orderby=joindate&direction=DESC">date joined</a></smallfont></td>
</tr>
</table><br><table border=0 width=99% cellspacing=1 cellpadding=3>
<tr>
<td align="center"><font face="Arial" size=2><B>User Name</B></font></td>
<td align="center"><font face="Arial" size=2><B>ICQ</b></font></td>
<td align="center"><font face="Arial" size=2><B>AIM</b></font></td>
<td align="center"><font face="Arial" size=2><B>Yahoo!</b></font></td>
<td align="center"><font face="Arial" size=2><B>Biography</b></font></td>
<td width=68 align="center"><font face="Arial" size=2><B>Join Date</b></font></td>
<td align="center"><font face="Arial" size=2><B>Posts</b></font></td>
</tr>
$memberlistbit
</table>
<div align="right"><smallfont>Page: $memberlistpages</smallfont></div>
</body>
</html>


Put all the code in that one, and now make template memberlistbit -

<tr>
<td bgcolor="{firstaltcolor}"><font face="Arial" size=2><a href="member.php?action=getinfo&userid=$userid">$username</a></font></td>\n<td bgcolor="{secondaltcolor}" align="center">$icqM</td>
<td bgcolor="{firstaltcolor}" align="center">$aimM</td>
<td bgcolor="{secondaltcolor}" align="center">$yahooM</td>
<td bgcolor="{firstaltcolor}"><font face="Arial" size=2>$bio</font></td>
<td bgcolor="{secondaltcolor}" align="center"><font face="Arial" size=2>$joindate</font></td>
<td bgcolor="{firstaltcolor}" align="center"><font face="Arial" size=2>$posts</font></td>
</tr>

Same thing as above. Now create memberlistsearch -

{htmldoctype}
<html>
<head>
<title>Members List - Advanced Search</title>
$cssinclude
</head>
<BODY>
<table border=0 width=99% cellspacing=1 cellpadding=3>
<tr>
<td align="left"><a href="index.php"><img src="images/ubb/bbtitle5v3.jpg" border=0></a></td>
<td align="center" width=225><largefont>Members List</largefont> <BR>
<center>
<smallfont>advanced search | <a href="memberlist.php?action=getall&orderby=posts&direction=DESC&numperpage=10&top=true">top 10 posters</a> | <a href="memberlist.php">alphabetical</a> | <a href="memberlist.php?action=getall&orderby=joindate&direction=DESC">date joined</a></smallfont></td>
</tr>
</table>
<br><form action="memberlist.php" method="post">
<input type="hidden" name="action" value="getall">
<table border=0><tr>
<td><font face="Arial" size=2>User Name contains</font></td>
<td><input type="text" size="35" name="ausername" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and homepage contains</font></td>
<td><input type="text" size="35" name="homepage" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and ICQ Number contains</font></td>
<td><input type="text" size="35" name="icq" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and AIM Handle contains</font></td>
<td><input type="text" size="35" name="aim" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Yahoo Messenger Handle contains</font></td>
<td><input type="text" size="35" name="yahoo" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Biography contains</font></td>
<td><input type="text" size="35" name="biography" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Join Date is after<br>(Format yyyy-mm-dd, leave blank for today)</font></td>
<td><input type="text" size="35" name="joindateafter" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Join Date is before<br>(Format yyyy-mm-dd, leave blank for today)</font></td>
<td><input type="text" size="35" name="joindatebefore" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Last Visit is after<br>(Format yyyy-mm-dd hh:mm:ss, leave blank for today)</font></td>
<td><input type="text" size="35" name="lastvisitafter" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Last Visit is before<br>(Format yyyy-mm-dd hh:mm:ss, leave blank for today)</font></td>
<td><input type="text" size="35" name="lastvisitbefore" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Last Post is after<br>(Format yyyy-mm-dd hh:mm:ss, leave blank for today)</font></td>
<td><input type="text" size="35" name="lastpostafter" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Last Post is before<br>(Format yyyy-mm-dd hh:mm:ss, leave blank for today)</font></td>
<td><input type="text" size="35" name="lastpostbefore" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Number of Posts is greater than</font></td>
<td><input type="text" size="35" name="postslower" value=""></td>
</tr>
<tr>
<td><font face="Arial" size=2>and Number of Posts is less than</font></td>
<td><input type="text" size="35" name="postsupper" value=""></td>
</tr>
<tr><td colspan=2><hr></td></tr>
<tr><td><font face="Arial" size=2>Order by:</font></td><td>
<select name="orderby">
<option selected>username</option>
<option>joindate</option>
<option>lastpost</option>
<option>posts</option>
</select>
<select name="direction">
<option value="">in ascending order</option>
<option value="DESC">in descending order</option>
</select>
</td></tr>
<tr>
<td><font face="Arial" size=2>Number of records per page:</font></td>
<td><input type="text" size="35" name="numperpage" value="30"></td>
</tr>
</table>
<div align="center"><center>
<table border="0">
<tr>
<td><p align="center"><input type="submit" name="submit" value="Submit"></p></td>
<td><p align="center"><input type="reset" name="reset" value="Reset"></p></td>
</tr>
</table>
</center></div>
</form>
</body></html>

Feel free to edit those :)

04-21-2000, 01:18 PM
but...

the javascript is a killer. People on WebTV have no support for Javascript, nor do Mac people using iCab. Looking at the code, it doesn't seem that it would be too hard to change.:)

(I prefer the javascript version, personally)

04-21-2000, 01:44 PM
About the javascript: hmm... could I do an OS/Browser check in PHP and change the links like that? Might work.

But how should I make the links them? To the profile? Not links, just display the AIM Name?

Hmm.. that brings up another thing, I might want to add a template for AIM, ICQ, and Yahoo! :)

04-21-2000, 02:14 PM
There are already three templates: aim, yahoo and icq.

John

04-21-2000, 06:56 PM
templates: launching a new era of codehacking ;)
This is cool, though, linking hacks to templates.
It makes 'm flexible :D

04-21-2000, 07:01 PM
About the javascript: hmm... could I do an OS/Browser check in PHP and change the links like that? Might work.

But how should I make the links them? To the profile? Not links, just display the AIM Name?

Hmm.. that brings up another thing, I might want to add a template for AIM, ICQ, and Yahoo! :)


I know there's a way to do a direct link with AIM that will pop-up its own message window (or start AIM if you don't have it running) but I don't remember it off the top off my head.
I don't know if such a thing exists for ICQ and/or Yahoo, though...

04-24-2000, 01:56 AM
Found a tiny bug:
In the memberlist template remove: 'Page:', or it will show up twice in memberlist.php :)

05-14-2000, 03:48 AM
This is a very nice hack. Can you please tell me how I would go about adding another three columns -- with an e-mail icon, a homepage icon and a search icom -- the same ones that appear under the post of a user. If I'm to offer the users a full "yellow pages" of my BB's members, I might as well give them the full thing :) :)

Thanks

05-26-2000, 02:32 PM
well? :)

05-27-2000, 01:33 AM
I'll look at it when I get a chance.

Email is already there, somewhat.

Try changing your template to use $user[email] in it. The other 2 involve some simple script changes.