UseBB Community

The official board for UseBB help and discussion

UseBB Community » Resources & Customization » Avatar upload mod

Avatar upload mod

Moderators: Gaia.

Page: 1

Author Post
Member
Registered: Jan 2007
Posts: 5
I tryed to make this mod by myself... here is the code
Open sources\panel_profile.php


Find (at or around line 129):
$avatar_type = 0;
$avatar_remote = '';
}


After add:

if ( !empty($userfile) ) {
$max_image_width = 120;
$max_image_height = 120;
$max_image_size = 24 * 1024;
$valid_types = array("gif","jpg", "JPG","JPEG", "png", "jpeg");
if (isset($userfile)) {
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { $up_av='';
$filename = $_FILES['userfile']['tmp_name'];
$ext = substr($_FILES['userfile']['name'],
1 + strrpos($_FILES['userfile']['name'], "."));
if (filesize($filename) > $max_image_size) {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Error'],
'content' => sprintf($lang['TooBigFile'])
));
} elseif (!in_array($ext, $valid_types)) {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Error'],
'content' => sprintf($lang['TypeError'])
));
} else {
$size = GetImageSize($filename);
if (($size) && ($size[0] < $max_image_width)
&& ($size[1] < $max_image_height)) {

if (@move_uploaded_file($filename, "/home/my_forum/www/avatars/".$session->sess_info['user_info']['id'].".".$ext)) {
$up_av = 'http://my_forum/avatars/'.$session->sess_info['user_info']['id'].".".$ext;

} else
{
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Error'],
'content' => sprintf($lang['Error'])
));
}
} else {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Error'],
'content' => sprintf($lang['LargeSize'])
));
}
}
} else {
$template->parse('msgbox', 'global', array(
'box_title' => $lang['Error'],
'content' => sprintf($lang['EmptyFile'])
));
}
} $avatar_type = 1;
$avatar_remote = $up_av; }

Replace /home/my_forum/www/avatars/ and http://my_forum/avatars/ to yours
=========================================================


Open templates\default\panel.tpl.php


Find (at or around line 116):
<tr>
<td class="fieldtitle">{l_RealName}</td><td>{real_name_input}</td>
</tr>


After add:
<tr>
<td class="fieldtitle">{l_Avatar_Upl}</td><td>{avatar_upl}</td>
</tr>


=========================================================

Open languages\lang_English.php

Add before ?>
$lang['Avatar_Upl'] = 'Upload Avatar';
$lang['EmptyFile'] = 'Empty File';
$lang['LargeSize'] = 'Too large sizes. Maximally possible sizes: 120*120. ';
$lang['TypeError'] = 'Incorrect file type. Possible types of files: gif, jpg, png, jpeg';
$lang['TooBigFile'] = 'File is too big';

Note: add in same manner for other languages.


Excuse me for my "english", its not very good.
« Last edit by Ilig on Sun Jan 21, 2007 7:26 pm. »
Member
Registered: May 2005
Posts: 298
Location: 98671
Thank you, am trying it, but all I get after adding all code is {avatar_upl} in edit profile, something missing.

This is all is needed to make my forum better, nothing else matters, at least for now, anyway.
Member
Registered: Jan 2007
Posts: 5
Oooops. I'm sorry! I missed some part of the code.
Look up in the sources\panel_profile.php code
'avatar_input'     => '<input type="text" size="50" maxlength="255" name="avatar_remote" value="'.unhtml(stripslashes($user_info['avatar_remote'])).'" />',



And add before or after this one


'avatar_upl'     =>'<input name="userfile"  size="50" type="file">',
Member
Registered: May 2005
Posts: 298
Location: 98671
Thanks for the correction, but nothing is happening, I looked and looked at the code for anything, just do not know enough about it.
Member
Registered: May 2005
Posts: 298
Location: 98671
I even tried and .php file (not in allowed types) and it goes through like code was never added, something is missing, I have no idea what.
Member
Registered: Jan 2007
Posts: 5
I've tested it on PHP version 4.3.10 or higher. Maybe in some other version the other syntax....
Member
Registered: May 2005
Posts: 298
Location: 98671
I have PHP version 4.4.2, will look more at the code, but I know very little PHP, learning slowly though.
Member
Registered: May 2005
Posts: 298
Location: 98671
After much thought, removed forum, may be another time.
Moderator
Registered: Oct 2005
Posts: 449
Location: canada
Ok i am completely off topic, and i'm sorry, but i need to mention it :p. William, you might want to check your website footer in Firefox 2.0 ;).
Member
Registered: Mar 2007
Posts: 27
Hi Ilig,

i tried your script, but after filling out the upload field and saving the profil, nothing happens.
Any idea?

with best regards
Christiane
Member
Registered: May 2007
Posts: 1
Hi all, I am a newbie and would like the Avatar Upload Mod to work.

This is my very first post on a BB site.
I am new to BB stuff and if I am reading it right this thread ended in a question with no answers. I am learning PHP and studying the UseBB code. I am good at installing PHP scripts and modifying them with good instructions.

I was looking at a XAMPP install on my laptop of both UseBB and MercuryBoard. I like the MercuryBoard's Avatar upload and resize feature. Is there a mod somewhere or is anyone actively pursuing a mod with similar features for UseBB? I am trying to develop a site with a BB for newbies and a URL field to add an avatar simply will not do, it will go over their heads. An upload option for an avatar is a must for a newbie.
Developer
Registered: Apr 2004
Posts: 2218
Location: Belgium
UseBB 1 does not have avatar upload functionality, the above mod is the only possibility.

Note mods are unsupported and not guaranteed to work in new versions.
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Moderator
Registered: Oct 2005
Posts: 449
Location: canada
Released my own version of an uploadable avatar modification.

http://usebbzone.com/file.php?fid=48

Page: 1

UseBB Community » Resources & Customization » Avatar upload mod

UseBB Community is powered by UseBB 1 Forum Software