Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
Darrell3831
Worker
Worker


Joined: Feb 18, 2004
Posts: 244

PostPosted: Mon Oct 31, 2005 7:07 am Reply with quote

Hi,

I've noticed a few small potential bugs in block-User_Info.php version 2.1.1.

First line 40 allows you the oppertunity to set the maximum display length of a current guest's name.

Example:
Code:
$nameMaxLength           = 13; //Max length for username display.  Will truncate with ....


Then down at about line 96 we use this variable for the first time.

Example:
Code:
$sessionNameModified = strlen($member_result['username'])<$nameMaxLength?$member_result['username']:substr($member_result['username'],0,10)."...";


I apologize if I'm wrong, but this looks like a terinary opperator to me. $sessionNameModified will be assigned one of two values depending on the result of the strlen() function call.

If strlen() is less than $nameMaxLength were good. It's assigned the full username. However if the strlen() is greater than $nameMaxLength the substr() assigns a hard coded length of 10 characters instead of $nameMaxLength characters.

Suggested Fix:
Code:
$sessionNameModified = strlen($member_result['username'])<$nameMaxLength?$member_result['username']:substr($member_result['username'],0,$nameMaxLength)."...";


Further down in the code we again get ready to display a username into the user info box but there dosent appear to be any comparison whatsoever to the $nameMaxLength variable this time.

Example - Line 227:
Code:
$content .= "<img src=\"images/blocks/ur-moderator.gif\" height=\"14\" width=\"17\" alt=\"\" /> "._BLATEST.": <a href=\"modules.php?name=Your_Account&amp;op=userinfo&amp;username=$lastusername\"><img src=\"images/blocks/icon_mini_profile.gif\" border=\"0\" title=\""._ALT_CHKPROFILE."\" alt=\""._ALT_CHKPROFILE."\"></a> <a href=\"forums.html?amp;file=profile&amp;mode=viewprofile&amp;u=$lastuser\"><b>$lastusername</b></a><br />\n";


At the extreme end of this line we are actually displaying the $lastusername in bold without modifying it's lenght if it's too long.

Following suit with your terinary operator I have created a new variable and assigned the value we wish to display.

It requires two edits for this suggested fix.

Part 1 - Change line 227 to this:
Code:
$content .= "<img src=\"images/blocks/ur-moderator.gif\" height=\"14\" width=\"17\" alt=\"\" /> "._BLATEST.": <a href=\"modules.php?name=Your_Account&amp;op=userinfo&amp;username=$lastusername\"><img src=\"images/blocks/icon_mini_profile.gif\" border=\"0\" title=\""._ALT_CHKPROFILE."\" alt=\""._ALT_CHKPROFILE."\"></a> <a href=\"forums.html?amp;file=profile&amp;mode=viewprofile&amp;u=$lastuser\"><b>$lastusernameModified</b></a><br />\n";


Part 2 - Add this new line after Line 78:
Code:
$lastusernameModified = strlen($row['username'])<$nameMaxLength?$row['username']:substr($row['username'],0,$nameMaxLength)."...";



This should now force the userinfo block to honor the variable $nameMaxLength which is set in line 40.

It's working for me.

Please let me know if you see any problems with this.

Thanks,
Darrell

_________________
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17086

PostPosted: Mon Oct 31, 2005 2:11 pm Reply with quote

You are indeed correct with the first observation Wink - I will incorporate that into v2.1.3, soon to be released. However, the second observation/omission was intentional as that is on a separate line and the length was never an issue as you can/should limit the max length of a user name anyway (at least I do). But, for consistency sake, I will include it too. Thanks!
 
View user's profile Send private message
Darrell3831
PostPosted: Mon Oct 31, 2005 2:31 pm Reply with quote

Hi Raven,

I'm glad to be of help.

I'm at whatever the default username lenght is for Nuke 7.5, and that second line was an issue with most of the stock themes.

Not sure what the default is, but it's high.. Like 25 or 30 characters...

Depending on the theme and font, that dosent even fit on a line by itself, not to mention bold extending it a few pixils...

Thanks,
Darrell
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©