Topic: MOD: Photo thumbnail for avatars in punbb
This is a mod that will show a users default vld photo thumbnail as an avatar in punbb. This php script should be able to be used for any of the forum integrations as it just needs to be called like an image.
Eg.
<img src="http://www.yoursite.com/viewthumb.php?user=somebodysusername">Edit the top of the php script and add your database name, username, password, and if needed the database prefix. Then modify the image location where your user images are stored and the default no photo image and save it as viewthumb.php.
Then edit the punbb file viewtopic.php and change line 219 from:
$user_avatar = '';To:
$user_avatar = '<img src="http://www.yoursite.com/viewthumb.php?user='.$cur_post['username'].'" />';Here is the code for viewthumb.php:
<?php
/*
View user thumbnails from anywhere (viewthumb.php)
Author: Steve
Website: www.kinkyspace.net
*/
$username = "username";
$password = "password";
$database = "database";
$dbprefix = "vld_";
$imageloc = "http://www.yoursite.com/media/uploads/";
$nophotoimage ="http://www.yoursite.com/templates/modern/media/user_picture_none.gif";
/*
Don't Edit below this line unless you know what you are doing
*/
$user = $_GET['user'];
if (preg_match("/^\w{1,30}$/", $user, $matches)) {
}
else // Could be a SQL injection so we don't go any further, goodbye
{
exit();
}
$dbcnx = @mysql_connect("localhost", $username, $password);
if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}
if (! @mysql_select_db($database) ) {
echo( "<P>Unable to locate the " .
"database at this time.</P>" );
exit();
}
$sql = "SELECT m.* FROM " . $dbprefix . "members AS m WHERE m.username='$user'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$row['picture'] = $row['picture'] ? $imageloc . 't_' . 'picture_' . $row['picture'] : '';
$thumb = $row['picture'];
}
mysql_close($dbcnx);
if ($thumb == "")
{
readfile($nophotoimage);
}
else
{
readfile($thumb);
}
?>Enjoy and let me know if you like it ![]()
Steve
Last edited by kinkyspace.net (2007-07-30 01:35:43)