1

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 smile

Steve

Last edited by kinkyspace.net (2007-07-30 01:35:43)

2

Re: MOD: Photo thumbnail for avatars in punbb

Hey man, I'm getting this error:

Warning: readfile(): URL file-access is disabled in the server configuration in /home/content/b/i/r/bironltd/html/sites/tryingforlove/forums/viewthumb.php on line 60

Warning: readfile(http://www.tryingforlove.com.com/media/uploads/t_picture_1znx6yuvs2xresmefja7tx26h44h.gif): failed to open stream: no suitable wrapper could be found in /home/content/b/i/r/bironltd/html/sites/tryingforlove/forums/viewthumb.php on line 60



I try to actually view the address of that file and it won't let me display it either.  Is there something I need to change somehow?  Or is it server related?

www.gametimearcade.com
www.arcadeoutlaw.com
www.bombgaming.com
www.tryingforlove.com

3

Re: MOD: Photo thumbnail for avatars in punbb

Looks like how php is configured on the server. Easily fixed though, change the following line from:

$imageloc = "http://www.yoursite.com/media/uploads/";

To:

$imageloc = "./media/uploads/";

And

$nophotoimage ="http://www.yoursite.com/templates/modern/media/user_picture_none.gif";

To:

$nophotoimage ="./templates/modern/media/user_picture_none.gif";

Just modify the path to where you place the viewthumb.php file. In the example above viewthumb.php would be located in the vld root directory but just change the path as needed. Also modify the path for the no photo picture to whatever you want the nophoto image to be.

Let me know how you go.

Steve

Last edited by kinkyspace.net (2007-08-02 00:56:23)

4

Re: MOD: Photo thumbnail for avatars in punbb

That's awesome, thanks a lot man.

www.gametimearcade.com
www.arcadeoutlaw.com
www.bombgaming.com
www.tryingforlove.com

5

Re: MOD: Photo thumbnail for avatars in punbb

No worries mate

I just had a look at the forum on your site and it's working well. It's good to know somebody is using this mod besides me smile


Steve

6

Re: MOD: Photo thumbnail for avatars in punbb

well I was getting frustrated trying to get the avatars to auto resize, trying to setup a gdlbrary script, but this mod is way better and easier.

www.gametimearcade.com
www.arcadeoutlaw.com
www.bombgaming.com
www.tryingforlove.com

7

Re: MOD: Photo thumbnail for avatars in punbb

Great mod thank you - I added a link below the avatar to the members profile on the dating site

Around line 325 in viewtopic.php

    <a href='../<?php echo $cur_post['username'] ?>'/>View Dating Profile</a>

8

Re: MOD: Photo thumbnail for avatars in punbb

It's good to know people like the mod smile

I was going to do something similar photoads but I haven't got around to it yet.

Steve

9

Re: MOD: Photo thumbnail for avatars in punbb

Steve - would you be able to share how you add the members username to the <title></title> in the members profile page? This is great for SEO as then all pages are different?

Grovel grovel

10

Re: MOD: Photo thumbnail for avatars in punbb

photoads wrote:

Steve - would you be able to share how you add the members username to the <title></title> in the members profile page? This is great for SEO as then all pages are different?

Grovel grovel

Sorry about the late reply, on holiday in another part of Australia

This is what I use in the header.tpl:

Replace:

<title>{app_title} | {app_page}</title>

With:

<!-- IF active_module == "member_profile" -->
<title>{app_title} | {member_username}'s profile</title>
<!-- ELSE -->
<title>{app_title} | {app_page}</title>
<!-- ENDIF -->

The header on all the pages stays the same except for members profiles which displays the site name and members username's profile on the end.

Steve

11

Re: MOD: Photo thumbnail for avatars in punbb

Hi there smile

I'm using this mod on my website site so thank you for that.
As I'm using the iframe to use it my template... I figured people would need this:

Paste following code on line 324

<a target='_top' href='../<?php echo $cur_post['username'] ?>'/>View Dating Profile</a>

this way, you won't get the profile in the Iframe wink

12

Re: MOD: Photo thumbnail for avatars in punbb

Hi Boys
I'm planning to use this extension in my PunBB forum, but have some questions about it before.

How did you solved the 'Avatar' upload from PunBB profile settings? Did you allowed avatar uploads for members? Do they need to mark the use of avatar for it to show in forums, in that case did you and how did you deleted the 'Change avatar 'option?

And under Profile settings, Privacy there is an option for members to choose if the forum system will 'Remember them' so they dont need to login. I want to have that to 'No' by default and delete that option from Privacy choises.
How to do that?

The files are just not html in PunBB and i'm not so familiar with php, and i have a feeling they are a little bit messy too, not at all like Vld's so i got errors all time when tried to remove them.

Regards

Last edited by kalluu (2007-08-31 10:41:42)

kalluu

13

Re: MOD: Photo thumbnail for avatars in punbb

kalluu wrote:

How did you solved the 'Avatar' upload from PunBB profile settings? Did you allowed avatar uploads for members? Do they need to mark the use of avatar for it to show in forums, in that case did you and how did you deleted the 'Change avatar 'option?

I just set "Use Avatars" in the punbb cp to No. This mod will automatically show whatever their default vld photo is for their avatar in punbb. It is the same photo that would show up in a search etc... in vld.

Steve

14

Re: MOD: Photo thumbnail for avatars in punbb

How to setup avatar in phpbb2?

15

Re: MOD: Photo thumbnail for avatars in punbb

603603 wrote:

How to setup avatar in phpbb2?

Do you mean normal punbb avatars or do you mean using the extension I wrote to show the users vld photo as an avatar in punbb? If it's the 2nd option all the info is in the first post of the thread.

Steve

16

Re: MOD: Photo thumbnail for avatars in punbb

found out the way:)) thx. nice mod

17

Re: MOD: Photo thumbnail for avatars in punbb

Oops, I misread your post. I thought you said punbb. As you probably found out this mod works for any bulletin board, all you need to do is edit the appropriate file and it's smooth sailing from there smile

18

Re: MOD: Photo thumbnail for avatars in punbb

I changed all the settings but in version 2.41 I can only get the "no photo" image to show and not the users default photo from VLD. Did something change in the new update?

Last edited by barry4821 (2008-06-22 00:39:55)

19

Re: MOD: Photo thumbnail for avatars in punbb

kinkyspace.net wrote:

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 smile

Steve

this works like a charm

only a small question now

is it possible that if you click on the avatar that you get redirected to the users profile page?

that would be the ultimate forum mod!

thanks for all!

20

Re: MOD: Photo thumbnail for avatars in punbb

Hi Steve,

   I tried your mod but for some reason it's not working for me. Is this mod for version before 2.4.1? I have the latest and the avatar show missing image. Please give me some pointers on how I can get it to work with the latest version.

Thank you in advance,
Sid

21

Re: MOD: Photo thumbnail for avatars in punbb

Took me a bit but I got this worked out. In the viewthumb.php that Steve posted, I had to change

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    $row['picture'] = $row['picture'] ? $imageloc . 't_' . 'picture_' . $row['picture'] : '';
    $thumb = $row['picture'];
}


To

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    $row['picture'] = $row['picture'] ? $imageloc . 'picture_' . $row['picture'] : '';
    $thumb = $row['picture'];
}

I removed the 't_' .  and everything works like a charm.

Thanks Steve.

22

Re: MOD: Photo thumbnail for avatars in punbb

had to change picture to photo to get it to work for me. I don't think its a good idea to remove the "t" because you will be loading huge files if you do.

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    $row['picture'] = $row['picture'] ? $imageloc . 't_' . 'photo_' . $row['picture'] : '';
    $thumb = $row['picture'];
}

23

Re: MOD: Photo thumbnail for avatars in punbb

Could it be that this doesn't work on the new punbb version 1.3.4 ?
I cannot find that line in viewtopic.php even not the variables...?

24

Re: MOD: Photo thumbnail for avatars in punbb

works on al version it's just a call you have to place to viewthumb.php

25

Re: MOD: Photo thumbnail for avatars in punbb

yes, i've found the error :-) thx !