Author |
Message |
hopper
New Member


Joined: Dec 05, 2007
Posts: 12
|
Posted:
Sat Aug 15, 2009 9:56 pm |
|
Hello
I hope this is the right place to post this, as I believe this happened after I upgraded.
Recently I upgraded to RN 2.30.01 from RN 2.10.01
When I was at 2.10.01 everything was fine, users where linking to offsite avatars without a problem. The upgrade went well and for the most part everything is just fine. But some members brought it to my attention that they weren't able to link to offsite avatars after the upgrade. All you get is a half loaded page without any words or blocks, just the header and like the background of the theme.
I enabled the Upload avatar to site and it worked and my members where happy. But I've been doing some reading around and I don't think I want to have that enabled anymore.
So I set Display Errors to TRUE in config and these are the errors I get.
When I try to Link to an offsite avatar through the My_Account/Change_Info
this is what I get.
Code:Fatal error: Call to undefined function: get_headers() in /home/changedthis/ichangedthis/mysite.com/modules/Forums/includes/usercp_avatar.php on line 113
|
When I try to link to an offsite avatar through the Forum/Profile this is what I get.
Code:Fatal error: Call to undefined function: get_headers() in /home/changedthis/ichangedthis/mysite.com/modules/Your_Account/public/avatarlinksave.php on line 60
|
I looked up the lines in each of those files and they are the same:
Code:$avatar_filesize = array_change_key_case(get_headers($avatar, 1),CASE_LOWER);
|
Any help would be much appreciated. Thank you all for your time.
__Hopper___ |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Sat Aug 15, 2009 10:38 pm |
|
In v2.3 we moved all the forum files from includes/*.* to modules/Forums/includes. My guess would be that you may have missed a step or 2 in the upgrade process and/or you have some hard-coded links that aren't pointing to the right folder. |
|
|
|
 |
Palbin
Site Admin

Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Sat Aug 15, 2009 11:25 pm |
|
This is a mistake on my part. He is running php 4 and get_headers() is a php 5 function :/
Give me a few minutes and I'll get you fixed up. |
_________________ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. |
|
|
 |
Palbin

|
Posted:
Sat Aug 15, 2009 11:40 pm |
|
The code in question was implemented to control file size of remote avatars. Since you are running a version of php less than 5.1.3 you will just have to go with out that check. Let me know if the below code changes work for you.
Find lines 59-69 of /modules/Your_Account/public/avatarlinksave.php:
Code:
//Palbin - Added to make remote avatars comply file size limits
$avatar_filesize = array_change_key_case(get_headers($avatar, 1),CASE_LOWER);
$avatar_filesize = $avatar_filesize['content-length'];
$avatar_filesize = round($avatar_filesize / (1024));
if ( $avatar_filesize > round($board_config['avatar_filesize'] / 1024) ) {
$l_avatar_size = sprintf(_AVATAR_FILESIZE, round($board_config['avatar_filesize'] / 1024));
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
|
Change to:
Code:
//Palbin - Added to make remote avatars comply file size limits
if (strnatcmp(phpversion(),'5.1.3') >= 0) {
$avatar_filesize = array_change_key_case(get_headers($avatar, 1),CASE_LOWER);
$avatar_filesize = $avatar_filesize['content-length'];
$avatar_filesize = round($avatar_filesize / (1024));
if ( $avatar_filesize > round($board_config['avatar_filesize'] / 1024) ) {
$l_avatar_size = sprintf(_AVATAR_FILESIZE, round($board_config['avatar_filesize'] / 1024));
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
}
|
Find lines 112-121 of /modules/Forums/includes/usercp_avatar.php:
Code:
//Palbin - Added to make remote avatars comply file size limits
$avatar_filesize = array_change_key_case(get_headers($avatar_filename, 1),CASE_LOWER);
$avatar_filesize = $avatar_filesize['content-length'];
$avatar_filesize = round($avatar_filesize / (1024));
if ( $avatar_filesize > round($board_config['avatar_filesize'] / 1024) )
{
$l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
|
Change to:
Code:
//Palbin - Added to make remote avatars comply file size limits
if (strnatcmp(phpversion(),'5.1.3') >= 0) {
$avatar_filesize = array_change_key_case(get_headers($avatar_filename, 1),CASE_LOWER);
$avatar_filesize = $avatar_filesize['content-length'];
$avatar_filesize = round($avatar_filesize / (1024));
if ( $avatar_filesize > round($board_config['avatar_filesize'] / 1024) ) {
$l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
}
|
|
|
|
|
 |
hopper

|
Posted:
Sun Aug 16, 2009 2:03 am |
|
Thanks alot changing those lines in the files worked.
It works fine now.
Thanks !
 |
|
|
|
 |
Raven

|
Posted:
Sun Aug 16, 2009 6:00 am |
|
Palbin, I know I have seen a class or at least a forum mod that will do the same for PHP4. Can you check that out? Thanks! |
|
|
|
 |
Palbin

|
Posted:
Sun Aug 16, 2009 1:28 pm |
|
hopper, if possible can you give this code a try. It is a better fix because the avatars are still checked for file size.
Replace the two instances of:
Code:
//Palbin - Added to make remote avatars comply file size limits
if (strnatcmp(phpversion(),'5.1.3') >= 0) {
$avatar_filesize = array_change_key_case(get_headers($avatar_filename, 1),CASE_LOWER);
$avatar_filesize = $avatar_filesize['content-length'];
$avatar_filesize = round($avatar_filesize / (1024));
if ( $avatar_filesize > round($board_config['avatar_filesize'] / 1024) ) {
$l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
}
|
With this:
Code:
//Palbin - Added to make remote avatars comply with file size limits
$ch = curl_init($avatar);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //not necessary unless the file redirects (like the PHP example we're using here)
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
$error = true;
$error_msg = 'cURL failed';
}
$contentLength = 'unknown';
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$contentLength = (int)$matches[1];
}
$avatar_filesize = round($contentLength / (1024));
if ( $avatar_filesize > round($board_config['avatar_filesize'] / 1024) ) {
$l_avatar_size = sprintf(_AVATAR_FILESIZE, round($board_config['avatar_filesize'] / 1024));
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
|
|
|
|
|
 |
hopper

|
Posted:
Sun Aug 16, 2009 3:10 pm |
|
Palbin I changed the two instances of that.
In the My_Account/Change_Info it works fine.
In the Forums/Profile I get: Error cURL failed |
|
|
|
 |
Palbin

|
Posted:
Sun Aug 16, 2009 5:16 pm |
|
Find this line in /modules/Forums/includes/usercp_avatar.php:
Code:
$ch = curl_init($avatar);
|
Change to:
Code:
$ch = curl_init($avatar_filename);
|
That should fix it up. |
|
|
|
 |
hopper

|
Posted:
Sun Aug 16, 2009 5:28 pm |
|
Yes. Thanks again Palbin.
That fixed it up.
I am now able to link to offsite avatrs through both the
Forum/Profile and the Your_Account/Change_info
 |
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Sat Aug 22, 2009 8:16 am |
|
And we now have an even better RavenNuke(tm) because of your help in reporting the issue and assisting us with the fix. THANK YOU! |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
|