1 (edited by n3Twork 2005-04-20 21:15)

Topic: Show avatar in php page extern to punbb ...

Hello,

I want to show the avatar, with the Login of the member in a page php, the login there is no problem, but for the avatar I do not arrive has to show it. 

if ($pun_config['o_avatars'] == '1')
    {
        if ($user['use_avatar'] == '1')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.gif'))
                $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.gif" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.jpg'))
                $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.jpg" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.png'))
                $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.png" '.$img_size[3].' alt="" />';
            else
                $avatar_field = $lang_profile['No avatar'];
        }
        else
            $avatar_field = $lang_profile['No avatar'];
    }
<?php echo $avatar_field ?>

What is the code to show the avatar of a member?

I pass by GET (members.php?id=10 for example)

thx
(sorry for bad English i am french...)

Re: Show avatar in php page extern to punbb ...

I'm guessing it's a path problem? Put the path to the avatar directory instead of $pun_config['o_avatars_dir']

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Show avatar in php page extern to punbb ...

I not arrive... hmm

He never shows the avatar ...

i don't Understand

Re: Show avatar in php page extern to punbb ...

But what goes wrong? Does it output the "No avatar" text or what?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Show avatar in php page extern to punbb ...

are you including the common.php file? if not thoes varibles will not work.

6 (edited by miowpro 2005-04-25 03:12)

Re: Show avatar in php page extern to punbb ...

i just tryed

<img src="http://www.strictlyleft.co.uk/forum/img/avatars/<?php print $pun_user['use_avatar'];?>.jpg">

the avatar for the user i tested it with is 10 but 'use_avatar' returns 1

why is this

Re: Show avatar in php page extern to punbb ...

because $pun_user['use_avatar'] is the setting for the avatar, 1 if they have one, 0 if they don't you need to use the $pun_user['id']

Re: Show avatar in php page extern to punbb ...

yes i havre including the common.php file ... but 'No avatars" is show ....

Re: Show avatar in php page extern to punbb ...

There was the answer I was looking for. If it outputs "No avatar", it simply means one of two things:

1. The user doesn't have an avatar.
2. The path in which it looks for avatars is not correct. You will have to edit the paths used to search for avatars in the code you posted above. $pun_config['o_avatars_dir'] is probably img/avatars, but that only makes sense if you are actually in the forum root directory.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

10 (edited by n3Twork 2005-04-26 19:06)

Re: Show avatar in php page extern to punbb ...

the user have a avatar ...

the page is in index...

..membre.php
..forums/
..forums/index.php
.
.
.

11 (edited by n3Twork 2005-04-26 20:39)

Re: Show avatar in php page extern to punbb ...

Code of membre.php  :

>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
</head>
<body>


        
                
<?php
define('PUN_ROOT', './forums/');
require PUN_ROOT.'include/common.php';
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id < 2)
    message($lang_common['Bad request']);
    

require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';
$pun_config['o_avatars_dir']="forums/img/avatar";

if ($pun_config['o_avatars'] == '1')
    {
        if ($user['use_avatar'] == '1')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.gif'))
                $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.gif" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.jpg'))
                $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.jpg" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.png'))
                $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.png" '.$img_size[3].' alt="" />';
            else
                $avatar_field = $lang_profile['No avatar'];
        }
        else
            $avatar_field = $lang_profile['No avatar'];
    }

$result = $db->query('SELECT u.id, u.username, u.email, u.url, u.msn, u.signature, u.use_avatar, u.location FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
    message($lang_common['Bad request']);

$user = $db->fetch_assoc($result);
if ($user['signature'] != '')
{
    require PUN_ROOT.'include/parser.php';
    $parsed_signature = parse_signature($user['signature']);
}
    
?>
<div class="box4">
<p align="center"><?php echo $avatar_field ?><br>
<td><b><?php echo $lang_common['Username'] ?></b>: <?php echo pun_htmlspecialchars($user['username']) ?></td></p>
<p align="left">
<td><b><?php echo $lang_profile['Location'] ?></b>: <?php echo ($user['location'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['location']) : $user['location']) : $lang_profile['Unknown']; ?></td><br>
<td><b><?php echo $lang_profile['Website'] ?></b>: <?php echo pun_htmlspecialchars($user['url']) ?></td><br>
<td><b><?php echo $lang_common['E-mail'] ?></b>: <?php echo pun_htmlspecialchars($user['email']) ?></td><br>
<td><b><?php echo $lang_profile['MSN'] ?></b>: <?php echo ($user['msn'] !='') ? pun_htmlspecialchars(($pun_config['o_censoring'] == '1') ? censor_words($user['msn']) : $user['msn']) : $lang_profile['Unknown']; ?></td>
</p>
<div align="left">
    <dt>------ <?php echo $lang_profile['Signature'] ?>: ------</dt>
<td><b><?php echo isset($parsed_signature) ? $parsed_signature : $lang_profile['No sig']; ?></td>
<p align="center">
<a href="forums/message_send.php?id=<?php echo pun_htmlspecialchars($user['id']) ?>">Envoyer un message privée à <?php echo pun_htmlspecialchars($user['username']) ?></a><br /></div>
</p></body></html>

Re: Show avatar in php page extern to punbb ...

up smile

Re: Show avatar in php page extern to punbb ...

n3twork: Difficult for us to help. It's your code. Try outputting some debug info. Remove the @ before the calls to getimagesize() so that it will output any errors it encounters.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Show avatar in php page extern to punbb ...

You might want to put this:

n3Twork wrote:
<?php
define('PUN_ROOT', './forums/');
require PUN_ROOT.'include/common.php';

before anything else in the document, including:

n3Twork wrote:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
</head>
<body>

Just a thought

-Steve

Re: Show avatar in php page extern to punbb ...

Oh wow, I must have gotten onto an old page - Looks like some old Code tongue

-Steve