Hi folks,
After a while of debugging my problems and so on, i managed to get all this worked out.
Let start with the problems I had. After I logged in, I would still get the login form instead of the welcome back message. I fixed that by first making sure that vb3 was setting the cookies for my whole server, by using
.bayareamuscle.com as the domain. I also had to put the initiation code, that calls/requires globals.php, at the very top of the php page:
At the top of my non vb3 page:
PHP Code:
<?
chdir("./forum/");
include('./global.php');
chdir("../");
?>
The rest of the code was the same. I just used that where i needed the login box.
So that fixed my problem witht he login box always showing up.
Now on to the avatar on this page. This was actually very simple, all i had to do was add 3 lines to the current code.
Lets start with the including of the required files:
PHP Code:
<?
chdir("./forum/");
include('./global.php');
// added this line to include the user functions which
// has the fetch_avatar_url() function
include('./includes/functions_user.php');
chdir("../");
?>
PHP Code:
<?
if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
// i assigned the avatar url to the variable $user_av and check to see if it's empty.
$user_av = fetch_avatar_url($bbuserinfo['userid']);
if($user_av!='')
$user_av="/forum/" . $user_av; //replace "/forum/" with your virtual path to your forum pages.
print("<align='center'><span class='sectionheader'>Welcome back, $username!<br>");
//if the avatar url is not empty, display it
if($user_av!='')
print("<img src=\"" . $user_av . "\" vspace=4>");
} else {
?>
<form action='/forum/login.php' method='post' onsubmit='md5hash(vb_login_password,vb_login_md5password)'>
<script type='text/javascript' src='/forum/clientscript/vbulletin_md5.js'></script>
<span class="sectionheader">Username:</span>
<input type='text' class='button' name='vb_login_username' id='navbar_username' size='15' accesskey='u' tabindex='1' value='' onfocus='if (this.value == 'username') this.value = '';' /><br>
<span class="sectionheader">Password: </span>
<input type='password' class='button' name='vb_login_password' size='15' accesskey='p' tabindex='2' /><br>
<input type='checkbox' name='cookieuser' value='1' tabindex='3' id='cb_cookieuser_navbar' accesskey='c' checked='checked' /><span class='sectionheader'>Remember Me</span><br>
<input name="submit" type='submit' class='button' accesskey='s' tabindex='4' title='Log In' value='Log In' />
<input type='hidden' name='do' value='login' />
<input type='hidden' name='forceredirect' value='1' />
<input type='hidden' name='vb_login_md5password' />
</form>
<?
}
?>
Hope this helps. Ofcourse, now you can also use all the other functions in the functions_user.php include, so check out what it offers.
Sorry for the ugly code, but I just came up with it no more than 3 mins ago and since this page was still open, i figured i'd contribute with what i found. now ya can take care of the clean up.
p.s. you can see this work at BayAreaMuscle.com, you are going to have to login as user:
DemoUser and password:
demo, i created an avatar for this demo user.
Pz!