miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

Avatar from URL (with image size & filesize limitation)

 
Author jontrac
Partaker
#1 | Posted: 18 Nov 2009 12:20 
Note:
- I'm not a programmer. The codes from this plugin are collected around the Internet
- The plugin may not be secured
- The plugin may be poorly coded

Features:
- Allow members to use a remote image file as their avatar
→ save disk-space and prevent never-come-back members' avatars to be forever stored in the server
- Avatar's height > 70 pixels → set height = 70, else height = avatar's height
- Avatar's filesize > 30KB → noavatar.png is used
- No link provided → noavatar.png is used
- Broken link → noavatar.png is used
- Not an image link → noavatar.png is used

Installation:
1. Open setup_options.php, add in $userInfoInPosts:
$dbUserSheme['user_custom2'][1]

Example: $userInfoInPosts=array($dbUserSheme['user_custom2'][1]);
Please change user_costom2 to other field that you use to store avatar link.
Open bb_plugins.php, add before ?>:
/* Avatar from URL by jontrac */
function parseUserInfo_user_custom2($av){
if($av!='') {
$res = (($ftest = @fopen($av, 'r')) === false) ? false : @fclose($ftest);
if($res == true) {
if (substr($av,0,4)=='http') {
$x = array_change_key_case(get_headers($av, 1),CASE_LOWER);
if ( strcasecmp($x[0], 'HTTP/1.1 200 OK') != 0 ) {
$x = $x['content-length'][1];
}
else $x = $x['content-length'];
}
else $x = @filesize($av);
if($x <= 31000 and $size = getimagesize($av)) {
if($size[1] > 70) {
$av='<img src="'.$av.'" height="70" border="0" alt="">';
return $av;
}
else {
$av='<img src="'.$av.'" border="0" alt="">';
return $av;
}
}
else {
$av='<img src="https://www.minibb.com/forums/img/noavatar.png" height="70" border="0" alt="">';
return $av;
}
}
else {
$av='<img src="https://www.minibb.com/forums/img/noavatar.png" height="70" border="0" alt="">';
return $av;
}
}
else {
$av='<img src="https://www.minibb.com/forums/img/noavatar.png" height="70" border="0" alt="">';
return $av;
}
}

/* --Avatar from URL by jontrac */
Open main_post_cell.html, add in the following code to where you want the avatar to be at:

{$userInfo_user_custom2[$poster_id]}
Open user_dataform.html, find:
<tr>
<td class="tbClCp">{$l_userInterest}</td>
<td class="caption5"><input type="text" name="interest" maxlength="150" size="20" value="{$interest}" class="textForm" style="width:200px;" /></td>
</tr>
Add bellow:
<!-- Avatar from URL by jontrac -->
<tr>
<td class="tbClCp">Avatar</td>
<td class="caption5">
<input type="text" name="user_custom2" maxlength="100" size="0" value="{$user_custom2}" class="textForm" style="width:317px;" />
<span class="txtSm"><br />URL to avatar | Max filesize: 30 KB</span>
</td>
</tr>
<!-- /Avatar from URL by jontrac-->
Recommendations for code improvements are always welcome!

Author Nalinith
Partaker
#2 | Posted: 18 Nov 2009 20:28 
I haven't had the chance to try it or mess around with it, but it would be nice. I'm not sure why the original avatar modification didn't include remote avatars. Nice Job.

Author Paul
Lead Developer 
#3 | Posted: 19 Nov 2009 02:37 
Nalinith:
why the original avatar modification didn't include remote avatars
It's really insecured, guys. As you might know, I could provide intrusion code even in a jpg file. I guess the script should someway determine, if the graphical file was really provided.

Additionally... with this code... you probably are joking to include such thing in the official add-on :-) It appears that the script is remotely reading the provided URL each time when you load the thread page!! It could be acceptable for forums with 1-2 persons being online, but not for forums when 100 users per second are able to view the same thread... it will be really slow, and eat server's resources like for piece of sake... it's probably vBulletin's approach, not miniBB's :-)

And imagine now what: the script will try to read an not-existing file each time... which has been deleted. Still, it will spend whole resources for it. And what if the whole domain not available anymore? The script could hang-up...

You must use kind of cache or something... and it's still better to store avatars on the local server. Comparing to the overall traffic 5-10 Kb file doesn't take huge space, but it provides more secured, more fast application...

Author jontrac
Partaker
#4 | Posted: 19 Nov 2009 02:52 
You are right, Paul. This script may slow down the page's load-time. However, for small boards, like mine, a customer support center, it is fine and fun to have this feature for our members.

Since I have absolutely not taken any programming classes, what I was able to do was to to collect the codes around the internet (it is still a dam hard process) and implemented them to this plugin.

This plugin involves several codes from different authors, all credits are given to them. Hopefully someone with small boards may like it. That is all I can contribute to MiniBB at the moment. :D

Author Paul
Lead Developer 
#5 | Posted: 19 Nov 2009 04:03 
This is the most important thing about programming nowadays... yes, even not being a classified/experienced programmer you may collect codes from Internet and build kind-of your own app. However without knowing what these code mean and how they execute, and what they could cause, it's really dangerous. Basically, almost 50% of open source apps are built that way. That's why we do not involve anybody into the developing of the miniBB core... we're enough to see "coders" which just combine others code without a deep knowledge of what they do... At least we know what we do.

I hope in the future such 3rd party codes will at least explain something in comments ;-)

Additionally... if you think your board will be always small, it's a wrong thinking. You should plan in advance that your board will be heavy, that you will have a lot of customers :-) That's the plan we have in mind constantly when developing any parts of miniBB...

Thanks anyway... learning never stops.

Author Nalinith
Partaker
#6 | Posted: 19 Nov 2009 16:32 
Ah, okay thanks Paul.

Author astass
Partaker
#7 | Posted: 30 Nov 2009 15:38 
Where would be correct to put this line? I can not do the right thing. Icon does not appear. Need help.
jontrac:
Open main_post_cell.html, add in the following code to where you want the avatar to be at:

{$userInfo_user_custom2[$poster_id]}
Below is my code.

<table class="forumsmb">
<tr valign="top">
<td class="caption1 pauthor" style="vertical-align:top"><img src="https://www.minibb.com/forums/img/s.gif" style="width:12px;height:9px;padding-top:6px" alt="{$l_author}" /></td>
<td class="pauthor" style="width:50%"><span class="username">{$pLink1}{$posterName}{$pLink2}</span><span class="txtSm"><br />{$viewReg}</span></td>
<td class="txtR noWrap pauthor" style="width:50%"><div class="txtSm"><a name="msg{$cols[6]}" href="#msg{$cols[6]}" class="txtSm">#{$anchor2}</a> {$l_sepr} {$l_posted}: {$postDate}{$editedBy}{$viewIP}<br />{$eachReply}<script type="text/javascript">getQuotation('{$posterNameJs}');</script>{$allowed}</div></td>
</tr>
<tr valign="top" class="tbCel1">
<td class="caption1" colspan="3"><div class="postedText">{$posterText}</div>{$deleteBox}</td>
</tr>
</table>

Author tom322
Active Member
#8 | Posted: 30 Nov 2009 16:01 
You can put it right after:

<td class="pauthor" style="width:50%">, so

<td class="pauthor" style="width:50%"> {$userInfo_user_custom2[$poster_id]} ...

Author astass
Partaker
#9 | Posted: 30 Nov 2009 23:08 
tom322:
You can put it right after:
thanks

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 Avatar from URL (with image size & filesize limitation)
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Proceed with the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑