PHP Web Host - Quality Web Hosting For All PHP Applications Clan Themes! We make clans look good!!
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
hopper
New Member
New Member


Joined: Dec 05, 2007
Posts: 12

PostPosted: Sat Aug 15, 2009 9:56 pm Reply with quote Back to top

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___
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16976
Location: Kansas

PostPosted: Sat Aug 15, 2009 10:38 pm Reply with quote Back to top

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.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2404
Location: Pennsylvania

PostPosted: Sat Aug 15, 2009 11:25 pm Reply with quote Back to top

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.
View user's profile Send private message Visit poster's website
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2404
Location: Pennsylvania

PostPosted: Sat Aug 15, 2009 11:40 pm Reply with quote Back to top

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;
      }
   }
View user's profile Send private message Visit poster's website
hopper
New Member
New Member


Joined: Dec 05, 2007
Posts: 12

PostPosted: Sun Aug 16, 2009 2:03 am Reply with quote Back to top

Thanks alot changing those lines in the files worked.
It works fine now.

Thanks !

Wink
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16976
Location: Kansas

PostPosted: Sun Aug 16, 2009 6:00 am Reply with quote Back to top

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!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2404
Location: Pennsylvania

PostPosted: Sun Aug 16, 2009 1:28 pm Reply with quote Back to top

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;
   }
View user's profile Send private message Visit poster's website
hopper
New Member
New Member


Joined: Dec 05, 2007
Posts: 12

PostPosted: Sun Aug 16, 2009 3:10 pm Reply with quote Back to top

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
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2404
Location: Pennsylvania

PostPosted: Sun Aug 16, 2009 5:16 pm Reply with quote Back to top

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.
View user's profile Send private message Visit poster's website
hopper
New Member
New Member


Joined: Dec 05, 2007
Posts: 12

PostPosted: Sun Aug 16, 2009 5:28 pm Reply with quote Back to top

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

Cheers
View user's profile Send private message
montego
Former Admin in Good Standing


Joined: Aug 29, 2004
Posts: 9071
Location: Arizona

PostPosted: Sat Aug 22, 2009 8:16 am Reply with quote Back to top

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!
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum