Topic: php beginner- punbb avatar intergration (yes i have used search)

i am a beginner with php i need a way to get the users avatar if they are logged in to show on the main page of the site . i have managed to intergrate the login but i am stumped with how to get there avatar.
ps. this is the code i used for login intergration

<?php define('PUN_ROOT', './forum/');?>
      <?php require PUN_ROOT.'include/common.php';?>
      <?php require('login.php'); ?>
     <?php login_menu(); ?>

and in login.php :

<?php
    function login_menu()
        {
        global $pun_user;
        if ($pun_user['is_guest'])
            {
            $stroutput= '<form id="login" method="post" action="'.PUN_ROOT.'login.php?action=in" onsubmit="return process_form(this)"><style type="text/css">
<!--
body {
    background-color: #CCCCCC;
}
-->
</style>

            <input type="hidden" name="form_sent" value="1" />
            <input type="hidden" name="redirect_url" value="'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'" />
            <label for="req_username">Username: </label>
            <input type="text" id="req_username" name="req_username" size="4" maxlength="25" />
            <label for="req_password">Password: </label>
            <input type="password" id="req_password" name="req_password" size="4" maxlength="16" />
            <input type="submit" name="login" value="Login" />
            [<a href="'.PUN_ROOT.'register.php">Register</a>]
            </form>';

            echo $stroutput;   
            }
        else
            {
            $stroutput= ''.pun_htmlspecialchars($pun_user['username']).' ('.$pun_user['g_user_title'].') [<a href="'.PUN_ROOT.'login.php?action=out&amp;id='.$pun_user['id'].'&amp;csrf_token='.sha1($pun_user['id'].sha1(get_remote_address())).'">'.$lang_common['Logout'].'Logout</a>]</p>';
            echo $stroutput;   
            }
        }
?>

hopefully that helps someone help me

thanks in advanced sam

Re: php beginner- punbb avatar intergration (yes i have used search)

I think user avatars are stored in 'img/avatars/{user_id}.{format}' on PunBB 1.2.

If so, use this PunBB 1.3 function:

function generate_avatar_markup($user_id)
{
    global $pun_config;

    $filetypes = array('jpg', 'gif', 'png');
    $avatar_markup = '';

    foreach ($filetypes as $cur_type)
    {
        $path = $pun_config['o_avatars_dir'].'/'.$user_id.'.'.$cur_type;

        if (file_exists(PUN_ROOT.$path) && $img_size = @getimagesize(PUN_ROOT.$path))
        {
            $avatar_markup = '<img src="'.$pun_config['o_base_url'].'/'.$path.'" '.$img_size[3].' alt="" />';
            break;
        }
    }

    return $avatar_markup;
}

Then, just figure out who's online and use that function to get their avatar's HTML.

Re: php beginner- punbb avatar intergration (yes i have used search)

Garciat,
I'm looking for a code block that I paste into my viewtopic.php and viewforum.php files so that a list of online user avatars is listed within the main.tpl file.

Are you able to help with that? I'm on 1.3. If you can please see my topic in "feature requests"

THANKS!