Another Bug in 2.3.7? Avatars (General)

by Magma, Thursday, November 24, 2016, 18:44 (303 days ago)

Since the update to 2.3.7 the avatar system seems to be very funky and not working as it was. Can you confirm?

Opera -
you click "edit avatar" in your profile
pop up box shows
you click delete avatar, which deletes it
you choose a file
it shows right on your profile, so you close the pop up box
you can then refresh the page and it shows the old avatar again


Chrome -
user 'a' is not seeing other user 'b' new avatar, user 'a' is seeing the older avatar
Some users on their profile see older avatar and if they click 'edit avatar' the pop up box shows the new avatar


IE11 -
you click "edit avatar" in your profile
pop up box shows
you click delete avatar, which deletes it
you choose a file
new image does not show at all, you need to refresh the page

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Thursday, November 24, 2016, 19:39 (303 days ago) @ Magma

Hi,

Since the update to 2.3.7 the avatar system seems to be very funky and not working as it was. Can you confirm?

Do you see my new avatar in opera? Do you save the user settings after changing the avatar image (button at page end)?

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Another Bug in 2.3.7? Avatars

by Magma, Thursday, November 24, 2016, 19:54 (303 days ago) @ Milo

Do you see my new avatar in opera? Do you save the user settings after changing the avatar image (button at page end)?

/Micha

I see a 9 box grid avatar for yours. I've never had to click save when changing only the avatar but even if I do the page refreshes with the older avatar. If I click the 'edit avatar' then the popup box shows the new avatar.

Another Bug in 2.3.7? Avatars

by Magma, Thursday, November 24, 2016, 20:03 (303 days ago) @ Magma

I can go to a users profile, refresh the page many times and still see the old avatar, I can then right click on the avatar and open image in new tab and it will show the new avatar :lookaround:

Only the new image is in the avatar folder on the server.

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Thursday, November 24, 2016, 20:07 (303 days ago) @ Magma

Hi,

Only the new image is in the avatar folder on the server.

Sounds like a caching issue of your browser.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Another Bug in 2.3.7? Avatars

by Magma, Thursday, November 24, 2016, 20:18 (303 days ago) @ Milo

The problem has only surfaced since the update to 2.3.7 for users in IE, Chrome and Opera.

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Thursday, November 24, 2016, 20:33 (303 days ago) @ Magma

The problem has only surfaced since the update to 2.3.7 for users in IE, Chrome and Opera.

we don't change code in this area.

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Another Bug in 2.3.7? Avatars

by Magma, Thursday, November 24, 2016, 21:37 (303 days ago) @ Milo
edited by Magma, Thursday, November 24, 2016, 22:05

The problem has only surfaced since the update to 2.3.7 for users in IE, Chrome and Opera.


we don't change code in this area.

I don't know what to say then. It even happens when using private browsing in both Chrome and Opera. So it doesn't happen with your live 2.3.7 site? I may have to rollback and see what happens as the avatars feature at the moment is messed up.

edited:
I also noticed with this problem:

if the old image was say 100x150 - you upload a new image 150x150 - the old image will still show but it will be 150x150

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Friday, November 25, 2016, 09:50 (303 days ago) @ Magma

Hi,

I will try it on my own forum at the weekend and report my results.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Another Bug in 2.3.7? Avatars

by Auge ⌂ @, Friday, November 25, 2016, 14:27 (302 days ago) @ Magma

Hello

The problem has only surfaced since the update to 2.3.7 for users in IE, Chrome and Opera.


we don't change code in this area.


I don't know what to say then.

So far I know, you degraded your installation from version 2.3.7 to 2.3.6.1. Did you delete the content of the directory templates_c?

Tschö, Auge

--
further development of mlf1

Another Bug in 2.3.7? Avatars

by Magma, Friday, November 25, 2016, 15:02 (302 days ago) @ Auge

Hello

The problem has only surfaced since the update to 2.3.7 for users in IE, Chrome and Opera.


we don't change code in this area.


I don't know what to say then.


So far I know, you degraded your installation from version 2.3.7 to 2.3.6.1. Did you delete the content of the directory templates_c?

Tschö, Auge

I have not gone back to 2.3.6.1 yet. I'm still on 2.3.7 at the moment and when I upgraded I did delete the contents of templates_c directory apart from the .dummy file.

I also cannot manually add a user in the admin since upgrading to 2.3.7


Getting back to the avatar problem. Not being a web coder I'm not sure how it works but when a page refreshes doesn't the script grab the avatar image from the server via the url of the image?

I don't understand how a page can load with the old avatar if the old avatar image is no longer in the images/avatars folder. How is that possible?

Avatar

Another Bug in 2.3.7? Avatars

by Auge ⌂ @, Friday, November 25, 2016, 15:29 (302 days ago) @ Magma

Hello

So far I know, you degraded your installation from version 2.3.7 to 2.3.6.1.

I have not gone back to 2.3.6.1 yet. I'm still on 2.3.7 at the moment and when I upgraded I did delete the contents of templates_c directory apart from the .dummy file.

Aha, two days ago you told me, you've reverted to 2.3.6.1. Maybe I misinterpreted you.

Getting back to the avatar problem. Not being a web coder I'm not sure how it works but when a page refreshes doesn't the script grab the avatar image from the server via the url of the image?

Yes it does. The problem in this case is the fact, that the file name of the avatar is a compound of the user-ID and the file-ending. Milos ID is 25 and he uses a GIF, so the avatars file name is 25.gif. If your user replaces the old avatar with a new image of the same file type, the file name will be identical. The browser might use it's old, cached version instead the new one.

I don't understand how a page can load with the old avatar if the old avatar image is no longer in the images/avatars folder. How is that possible?

It's a question of the implementation of the browser, if he asks for a new version of the file, when he has a file with the same name from the same source in his cache. I would expect such problems especially, when the browser is in the private mode.

Tschö, Auge

--
further development of mlf1

Another Bug in 2.3.7? Avatars

by Magma, Friday, November 25, 2016, 17:40 (302 days ago) @ Auge

Aha, two days ago you told me, you've reverted to 2.3.6.1. Maybe I misinterpreted you.

No I just reverted the file regarding the other problem with 2.3.7 temp_block_ip_after_repeated_failed_logins

Yes it does. The problem in this case is the fact, that the file name of the avatar is a compound of the user-ID and the file-ending. Milos ID is 25 and he uses a GIF, so the avatars file name is 25.gif. If your user replaces the old avatar with a new image of the same file type, the file name will be identical. The browser might use it's old, cached version instead the new one.

But I can't get my head around why this problem is occurring now for me and my users since updating to 2.3.7 did you change the way this is handled then? All the previous versions (3 or 4 version updates I've been through) and never had this problem come up.

Is there a way of sidestepping the cache so avatars download fresh every refresh? As some users are seeing 3 images old avatars.

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Saturday, November 26, 2016, 10:26 (302 days ago) @ Magma

Hi,

So it doesn't happen with your live 2.3.7 site?

No, I'm sorry. It works as designet. Take a try

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Another Bug in 2.3.7? Avatars

by Magma, Saturday, November 26, 2016, 11:52 (301 days ago) @ Milo

Hi,

So it doesn't happen with your live 2.3.7 site?


No, I'm sorry. It works as designet. Take a try

/Micha


Your website has exactly the same problem as mine. I setup a user Magmatest on your website:


went to profile settings
changed language to english
clicked 'edit avatar'
uploaded image 1
refreshed the page
clicked 'edit avatar'
clicked delete avatar in pop up box
chose image 2
clicked save
page refreshed with image 1
clicked 'edit avatar'
pop up box shows image 2

Avatar

Another Bug in 2.3.7? Avatars

by Magma, Saturday, November 26, 2016, 12:02 (301 days ago) @ Magma

Your website has exactly the same problem as mine. I setup a user Magmatest on your website:


went to profile settings
changed language to english
clicked 'edit avatar'
uploaded image 1
refreshed the page
clicked 'edit avatar'
clicked delete avatar in pop up box
chose image 2
clicked save
page refreshed with image 1
clicked 'edit avatar'
pop up box shows image 2


Ok I just did exactly the same procedure on this mylittle forum which is running 2.3.5 and the problem does not exist, the avatar changes no problem like it did before 2.3.7

I think that kind of proves it :confused:

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Saturday, November 26, 2016, 13:44 (301 days ago) @ Magma
edited by Milo, Saturday, November 26, 2016, 14:01

Hi,

went to profile settings
changed language to english
clicked 'edit avatar'
uploaded image 1
refreshed the page
clicked 'edit avatar'
clicked delete avatar in pop up box
chose image 2
clicked save
page refreshed with image 1
clicked 'edit avatar'
pop up box shows image 2

Ok I just did exactly the same procedure on this mylittle forum which is running 2.3.5 and the problem does not exist, the avatar changes no problem like it did before 2.3.7

Okay, I did it in the same way (without changing the language). I upload a new image and close the popup window. I saw my new avatar on my profile. I refresh my profile via [ctrl] + [F5] and via [ctrl]+[shift]+[R] (windows system) and my new avatar is still shown. I click on 'edit avatar' and the popup shows my new avatar, too.

I think that kind of proves it :confused:

No, it works as expected. Again, you have to clean-up your browser cache.

/Micha

P.S. Your current avatar is a dog on my page

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Another Bug in 2.3.7? Avatars

by Magma, Saturday, November 26, 2016, 14:04 (301 days ago) @ Milo

Okay, I did it in the same way (without changing the language). I upload a new image and close the popup window. I saw my new avatar on my profile. I refresh my profile via [ctrl] + [F5] (windows system) and my new avatar is still shown. I click on 'edit avatar' and the popup shows my new avatar, too.

And you're using the latest version of Opera or Chrome?

No, it works as expected. Again, you have to clean-up your browser cache.

I've cleaned the cache, I've even reinstalled the browser. It's not just my problem but all my users since 2.3.7

Can you explain why mylittleforum.net does not have the problem then? yet your 2.3.7 and my 2.3.7 site has the problem.

If it was a cache issue this site would do the same as ours.

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Saturday, November 26, 2016, 14:15 (301 days ago) @ Magma
edited by Milo, Saturday, November 26, 2016, 14:21

Hi,

And you're using the latest version of Opera or Chrome?

Opera:

Version: 41.0.2353.69
Update-Stream: Stable
Betriebssystem: Windows 10 64-bit (WoW64)

Can you explain why mylittleforum.net does not have the problem then? yet your 2.3.7 and my 2.3.7 site has the problem.

Can you explain why I don't habe the problem anywhere? By telling us Only the new image is in the avatar folder on the server, you confirmed the correctness of the software. In short: No old image are available on the server, thus, the source of your problem must be outside the server/forum.

If it was a cache issue this site would do the same as ours.

No, not necessarily. The server can force the download.

Let's have a try as suggested by Auge. Create/save the first avatar as a JPG and second one as GIF or PNG. Repeat your procedure and change the image.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Another Bug in 2.3.7? Avatars

by Magma, Saturday, November 26, 2016, 14:43 (301 days ago) @ Milo

Let's have a try as suggested by Auge. Create/save the first avatar as a JPG and second one as GIF or PNG. Repeat your procedure and change the image.

/Micha

Changing the .jpg avatar for a .png works with no issue but changing again to another .jpg brings problems again, showing 2 times older avatars

Clearing the cache and changing a .jpg avatar for .jpg avatar brings the problems.

Ok if you think it's a cache issue but users shouldn't have to think about clearing the cache just to change their avatar

I think what I will do is go back to the previous version, is it the same process as updating?

thanks again

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Saturday, November 26, 2016, 14:52 (301 days ago) @ Magma

Hi,

Clearing the cache and changing a .jpg avatar for .jpg avatar brings the problems.

You have to clear the cache between the changes.

Ok if you think it's a cache issue but users shouldn't have to think about clearing the cache just to change their avatar

It is a forum: Is the avatar the only reason to use your forum?

I think what I will do is go back to the previous version, is it the same process as updating?

No, it is a downgrade. There is no script to do it this way. So, you have to do it manually.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Another Bug in 2.3.7? Avatars

by Magma, Saturday, November 26, 2016, 15:04 (301 days ago) @ Milo

You have to clear the cache between the changes.

So any time you want to change your avatar using mylittleforum software you have to clear your browser cache? really? and I've never done that up to 2.3.7

It is a forum: Is the avatar the only reason to use your forum?

Don't know how to reply to that. If it's a feature of the software I want it to work.

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Saturday, November 26, 2016, 15:15 (301 days ago) @ Magma
edited by Milo, Saturday, November 26, 2016, 15:31

Hi Magma,

So any time you want to change your avatar using mylittleforum software you have to clear your browser cache? really?

I'm sorry, but I don't have this "problem". What is happens, if you right-click on the image (using Opera) and choose the option "open image in new tab" (I don't know the right translation). Do you get the right image? If not, what is happens, if you force a refresh by [ctrl] + [F5] or/and [ctrl]+[shift]+[R]?

What is happens, if you change your avatar and reopen the forum on another system that you never used before to visit the forum (e.g. mobile phone): Do you get your new or your old avatar?

and I've never done that up to 2.3.7

As you said: Only the new image is in the avatar folder on the server.

If it's a feature of the software I want it to work.

Yes, I can confirm but ... it works.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Another Bug in 2.3.7? Avatars

by Magma, Saturday, November 26, 2016, 16:24 (301 days ago) @ Milo

I'm sorry, but I don't have this "problem". What is happens, if you right-click on the image (using Opera) and choose the option "open image in new tab" (I don't know the right translation). Do you get the right image? If not, what is happens, if you force a refresh by [ctrl] + [F5] or/and [ctrl]+[shift]+[R]?

If I right click the image and open in a new tab I see the older avatar, If I refresh this tab I then see the newer image but if I close this tab and refresh the profile page I see the older image.

What is happens, if you change your avatar and reopen the forum on another system that you never used before to visit the forum (e.g. mobile phone): Do you get your new or your old avatar?


If I upload an image on the profile page and click save, the page refreshes with the older image showing still but it has the pixel size of the new image I can then click 'edit avatar' again and it will show the new image in the pop up box

If I then go to a completely different computer and go to said profile, the old image shows with the pixel size of the new image

Could it be something to do with the script that automatically changes the size of the avatar?


I've tried a completely fresh install of opera and the moment you change your profile image for the second time it messes up.


Thanks

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Saturday, November 26, 2016, 16:48 (301 days ago) @ Magma

Hi,

my test-case: I use two jpg images (one is a modification of the other one).

  • went to my profile settings
  • clicked 'edit avatar'
  • uploaded image 1
  • close the popup
  • the new avatar is shown
  • clicked 'edit avatar'
  • clicked delete avatar in pop up box
  • chose image 2
  • clicked save
  • close the popup
  • refresh profile settings via F5 --> the old one is shown (because of my browser cache)
  • refresh profile settings via [ctrl]+[F5] --> the new one is shown

and refresh the profile page I see the older image.

HOW do you refresh the page? Do you really use the keys-combination [CTRL]+[F5]?

Could it be something to do with the script that automatically changes the size of the avatar?

Hmm, maybe, but we don't change the code in this part of the software. Maybe smarty (the template engine) cached the image size too. Anyway, can you confirm that you used the suggested keys-combination [CTRL]+[F5] to refresh the page?

I've tried a completely fresh install of opera and the moment you change your profile image for the second time it messes up.

No, don't do it! It is not a problem with your browser software, it is a feature of any browser to cache the page to reduce traffic. So, if you reinstall your browser, nothing will changed.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Another Bug in 2.3.7? Avatars

by Magma, Saturday, November 26, 2016, 19:24 (301 days ago) @ Milo

When I press [CTRL]+[F5] it does show the right image but

What normal user is going to know to press [CTRL]+[F5] once they've upload a new image. A user is uploading a new image, pressing save and then seeing the old image which is not right.

Like I said before, in the whole time of using MLF I've never had to press [CTRL]+[F5] or clear the cache when changing an avatar until I updated recently.

I don't fully know how it works but maybe if the newly uploaded avatar image is given a more unique filename when upload (userid-date-timeInHoursMinutesSeconds.jpg) would that alleviate a cache problem?


Like I said though I've never had this problem with MLF until now.

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Saturday, November 26, 2016, 21:59 (301 days ago) @ Magma
edited by Milo, Sunday, November 27, 2016, 13:30

Hi Magma,

When I press [CTRL]+[F5] it does show the right image but

Okay.

A user is uploading a new image, pressing save and then seeing the old image which is not right.

Yes, you are totally right!

Like I said before, in the whole time of using MLF I've never had to press [CTRL]+[F5] or clear the cache when changing an avatar until I updated recently.

Okay, but we don't touch the code. Thus, two reason are possible:
1. The caching function of the browser is changed e.g. by an update.
2. The caching function of SMARTY is changed.

Because you confirmed that [CTRL]+[F5] solves the problem, it is not likely that SMARTY is the source of the problem.

I don't fully know how it works but maybe if the newly uploaded avatar image is given a more unique filename when upload (userid-date-timeInHoursMinutesSeconds.jpg) would that alleviate a cache problem?

Yes, this should work and solves the problem.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Another Bug in 2.3.7? Avatars

by Milo ⌂, Sunday, November 27, 2016, 13:27 (300 days ago) @ Magma

Hi,

I add a solution to the master branch. I update my own forum, so please check the behaviour and let me know any problems: http://forum.derletztekick.com

regards
Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Seems Fixed

by Magma, Sunday, November 27, 2016, 18:19 (300 days ago) @ Milo
edited by Magma, Sunday, November 27, 2016, 18:25

Hi, I just checked your site and it seems to work perfectly. I changed the avatar for a jpg 3 times then png and back to a jpg and each time the new avatar showed up when refreshed in IE, Opera and Chrome.

Can I download the adjusted files somewhere? or can I copy and paste the full code from the 5x files at https://github.com/ilosuna/mylittleforum/pull/114/files

appreciate your help thanks

Avatar

Seems Fixed

by Milo ⌂, Sunday, November 27, 2016, 18:56 (300 days ago) @ Magma

Hi,

Can I download the adjusted files somewhere?

I upload the files from my forum tmp. here.

or can I copy and paste the full code from the 5x files at https://github.com/ilosuna/mylittleforum/pull/114/files

I'm not sure. Maybe, there are some more changes for the upcoming release. So, I think it is better, if you use the above zip-file.

Please make a copy of your original files to roll-back if necessary!

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Seems Fixed

by Milo ⌂, Sunday, November 27, 2016, 23:33 (300 days ago) @ Milo

Hi,

I found an error in my reg expression. Please update the function getAvatar in function.inc.php (or use the new file in zip)


function getAvatar($user_id) {
 $avatar_images_path = 'images/avatars/';
 $fileIterator = new FilesystemIterator($avatar_images_path);
 $regexFileFilterIterator = new RegexIterator($fileIterator, "/\D+(".preg_quote(intval($user_id), '/')."(_\d+)?\.(jpg|gif|png|jpeg)$)/i", RegexIterator::GET_MATCH);
 $regexFileFilterIterator->rewind();
 $filename = ($regexFileFilterIterator->valid() && count($regexFileFilterIterator->current()) > 1) ? $regexFileFilterIterator->current()[1] : false;
 if ($filename === false || !file_exists($avatar_images_path.$filename))
  return false;
 return array($avatar_images_path, $filename, $avatar_images_path.$filename);
} 


/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Seems not so Fixed for me

by Magma, Monday, November 28, 2016, 10:52 (299 days ago) @ Milo

Replacing the 5 files then brings up a http 500 error, site becomes unreachable.

Avatar

Seems not so Fixed for me

by Milo ⌂, Monday, November 28, 2016, 14:23 (299 days ago) @ Magma

Hi,

Replacing the 5 files then brings up a http 500 error, site becomes unreachable.

I'll provide my changes here within the next days. I'm sorry for getting the 500er.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Step by step introduction

by Milo ⌂, Monday, November 28, 2016, 17:20 (299 days ago) @ Magma

Hi,

backup your files!

Step by step introduction:

avatar.inc.php
replace this file with the file from the ZIP archive.

functions.inc.php
add new function (no specific line):

/**
 * Returns the avatar image by user id
 *
 * @param int user_id
 * @return array [path, filename, path/filename] or false if not exists
 */ 
function getAvatar($user_id) {
 $avatar_images_path = 'images/avatars/';
 $fileIterator = new FilesystemIterator($avatar_images_path);
 $regexFileFilterIterator = new RegexIterator($fileIterator, "/\D+(".preg_quote(intval($user_id), '/')."(_\d+)?\.(jpg|gif|png|jpeg)$)/i", RegexIterator::GET_MATCH);
 $regexFileFilterIterator->rewind();
 $filename = ($regexFileFilterIterator->valid() && count($regexFileFilterIterator->current()) > 1) ? $regexFileFilterIterator->current()[1] : false;
 if ($filename === false || !file_exists($avatar_images_path.$filename))
  return false;
 return array($avatar_images_path, $filename, $avatar_images_path.$filename);
}

entry.inc.php
look for this code part (line 54ff)

       if($settings['avatars']==2)
        {
         if(file_exists('images/avatars/'.$entrydata['user_id'].'.jpg')) $avatar['image'] = 'images/avatars/'.$entrydata['user_id'].'.jpg';
         elseif(file_exists('images/avatars/'.$entrydata['user_id'].'.png')) $avatar['image'] = 'images/avatars/'.$entrydata['user_id'].'.png';
         elseif(file_exists('images/avatars/'.$entrydata['user_id'].'.gif')) $avatar['image'] = 'images/avatars/'.$entrydata['user_id'].'.gif';
         if(isset($avatar))
          {
           $image_info = getimagesize($avatar['image']);
           $avatar['width'] = $image_info[0];
           $avatar['height'] = $image_info[1];
           $smarty->assign('avatar', $avatar);
          }
        }


and replace it by the new code:

   if($settings['avatars']==2) {
    $avatarInfo = getAvatar($entrydata['user_id']);
    $avatar['image'] = $avatarInfo === false ? false : $avatarInfo[2];
 
    if(isset($avatar) && $avatar['image'] !== false) {
     $image_info = getimagesize($avatar['image']);
     $avatar['width']  = $image_info[0];
     $avatar['height'] = $image_info[1];
     $smarty->assign('avatar', $avatar);
    }
   }


thread.inc.php
Look for this code part (line 133ff)

        if($settings['avatars']==2)
         {
          if(file_exists('images/avatars/'.$data['user_id'].'.jpg')) $avatar['image'] = 'images/avatars/'.$data['user_id'].'.jpg';
          elseif(file_exists('images/avatars/'.$data['user_id'].'.png')) $avatar['image'] = 'images/avatars/'.$data['user_id'].'.png';
          elseif(file_exists('images/avatars/'.$data['user_id'].'.gif')) $avatar['image'] = 'images/avatars/'.$data['user_id'].'.gif';
          if(isset($avatar))
           {
            $image_info = getimagesize($avatar['image']);
            $avatar['width'] = $image_info[0];
            $avatar['height'] = $image_info[1];
            $data['avatar'] = $avatar;
            unset($avatar);
           }
         }

and replace it by

   if($settings['avatars']==2){
    $avatarInfo = getAvatar($data['user_id']);
    $avatar['image'] = $avatarInfo === false ? false : $avatarInfo[2];
    if(isset($avatar) && $avatar['image'] !== false) {
     $image_info = getimagesize($avatar['image']);
     $avatar['width']  = $image_info[0];
     $avatar['height'] = $image_info[1];
     $data['avatar']   = $avatar;
     unset($avatar);
    }
   }

user.inc.php
Look for this code part (line 256ff)

       if($settings['avatars']>0)
        {
         if(file_exists('images/avatars/'.$id.'.jpg')) $avatar['image'] = 'images/avatars/'.$id.'.jpg';
         elseif(file_exists('images/avatars/'.$id.'.png')) $avatar['image'] = 'images/avatars/'.$id.'.png';
         elseif(file_exists('images/avatars/'.$id.'.gif')) $avatar['image'] = 'images/avatars/'.$id.'.gif';
         if(isset($avatar))
          {
           $image_info = getimagesize($avatar['image']);
           $avatar['width'] = $image_info[0];
           $avatar['height'] = $image_info[1];
           $smarty->assign('avatar', $avatar);
          }
        }

and replace it by

  if($settings['avatars']>0) {
   $avatarInfo = getAvatar($id);
   $avatar['image'] = $avatarInfo === false ? false : $avatarInfo[2];
 
   if(isset($avatar) && $avatar['image'] !== false) {
    $image_info = getimagesize($avatar['image']);
    $avatar['width']  = $image_info[0];
    $avatar['height'] = $image_info[1];
    $smarty->assign('avatar', $avatar);
   }
  }


user.inc.php
Look for this code part (line 462ff)

       if($settings['avatars']>0)
        {
         if(file_exists('images/avatars/'.$_SESSION[$settings['session_prefix'].'user_id'].'.jpg')) $avatar['image'] = 'images/avatars/'.$_SESSION[$settings['session_prefix'].'user_id'].'.jpg';
         elseif(file_exists('images/avatars/'.$_SESSION[$settings['session_prefix'].'user_id'].'.png')) $avatar['image'] = 'images/avatars/'.$_SESSION[$settings['session_prefix'].'user_id'].'.png';
         elseif(file_exists('images/avatars/'.$_SESSION[$settings['session_prefix'].'user_id'].'.gif')) $avatar['image'] = 'images/avatars/'.$_SESSION[$settings['session_prefix'].'user_id'].'.gif';
 
         if(isset($avatar))
          {
           $image_info = getimagesize($avatar['image']);
           $avatar['width'] = $image_info[0];
           $avatar['height'] = $image_info[1];
           $smarty->assign('avatar', $avatar);
          }
        }

and replace it by

  if($settings['avatars']>0) {
   $avatarInfo = getAvatar($_SESSION[$settings['session_prefix'].'user_id']);
   $avatar['image'] = $avatarInfo === false ? false : $avatarInfo[2];
 
   if(isset($avatar) && $avatar['image'] !== false) {
    $image_info = getimagesize($avatar['image']);
    $avatar['width'] = $image_info[0];
    $avatar['height'] = $image_info[1];
    $smarty->assign('avatar', $avatar);
   }
  }

regards
Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Step by step introduction, still failed

by Magma, Monday, November 28, 2016, 19:51 (299 days ago) @ Milo

Thanks for your detailed instruction, I did it exactly as you explained but still get the same http 500 error. I've replaced the edited files and the site is back up.

Avatar

Step by step introduction, still failed

by Milo ⌂, Monday, November 28, 2016, 22:12 (299 days ago) @ Magma

Hi,

Thanks for your detailed instruction, I did it exactly as you explained but still get the same http 500 error.

What is your current PHP version? You need at least 5.3.0 because of the FilesystemIterator

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Step by step introduction, still failed

by Milo ⌂, Monday, November 28, 2016, 23:00 (299 days ago) @ Magma

Hi,

maybe this modified getAvatar()-function works instead of the modern one:

function getAvatar($user_id) {
 $avatar_images_path = 'images/avatars/';
 $fileList = glob( $avatar_images_path . intval($user_id) . "[_.]*{png,jpg,jpeg,gif,bmp}" , GLOB_BRACE);
 if (isset($fileList) && count($fileList) > 0) {
  foreach ($fileList as $file) {
   if (preg_match("/^(" . preg_quote($avatar_images_path, '/') . ")(" . preg_quote(intval($user_id)) . "(_\d+)?\.(jpg|gif|png|jpeg,bmp))$/", $file, $matches)) {
    //var_dump($matches);
    $filename = $matches[2];
    if (file_exists($avatar_images_path.$filename))
     return array($avatar_images_path, $filename, $avatar_images_path.$filename);
   }
  }
 }
 return false;
}

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Step by step introduction, still failed

by Magma, Tuesday, November 29, 2016, 01:11 (299 days ago) @ Milo

Hi,

maybe this modified getAvatar()-function works instead of the modern one:

function getAvatar($user_id) {
$avatar_images_path = 'images/avatars/';
$fileList = glob( $avatar_images_path . intval($user_id) . "[_.]*{png,jpg,jpeg,gif,bmp}" , GLOB_BRACE);
if (isset($fileList) && count($fileList) > 0) {
foreach ($fileList as $file) {
if (preg_match("/^(" . preg_quote($avatar_images_path, '/') . ")(" . preg_quote(intval($user_id)) . "(_\d+)?\.(jpg|gif|png|jpeg,bmp))$/", $file, $matches)) {
//var_dump($matches);
$filename = $matches[2];
if (file_exists($avatar_images_path.$filename))
return array($avatar_images_path, $filename, $avatar_images_path.$filename);
}
}
}
return false;
}


On PHP 5.3.29

Once I changed the quoted code the homepage showed (which is more than I got before) but when you clicked on any thread links the site goes down.

Avatar

Step by step introduction, still failed

by Milo ⌂, Tuesday, November 29, 2016, 08:59 (299 days ago) @ Magma

Hi,

Once I changed the quoted code the homepage showed (which is more than I got before) but when you clicked on any thread links the site goes down.

I have two installation of the forum. Both ones have no problems... The 500er is hard to debug. I'll write a test file to locate the reason of your error. Maybe Auge can take a closer look to my changes. I'll add the new function (getAvatar) to the master branch for full support of PHP 5.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Test file with getAvatar-Function

by Milo ⌂, Tuesday, November 29, 2016, 18:27 (298 days ago) @ Magma

Hi,

please create a test.php file with the following content and load up this file to the root directory of your forum:

<?php
 
function getAvatar($user_id) {
 $avatar_images_path = 'images/avatars/';
 $fileList = glob( $avatar_images_path . intval($user_id) . "[_.]*{png,jpg,jpeg,gif,bmp}" , GLOB_BRACE);
 if (isset($fileList) && count($fileList) > 0) {
  foreach ($fileList as $file) {
   if (preg_match("/^(" . preg_quote($avatar_images_path, '/') . ")(" . preg_quote(intval($user_id)) . "(_\d+)?\.(jpg|gif|png|jpeg,bmp))$/", $file, $matches)) {
    //var_dump($matches);
    $filename = $matches[2];
    if (file_exists($avatar_images_path.$filename))
     return array($avatar_images_path, $filename, $avatar_images_path.$filename);
   }
  }
 }
 return false;
}
 
$user_id = 1; // <---- Set this value to a valid user id.
var_dump(getAvatar($user_id));
 
?>

Edit the $user_id to a valid user id with existing avatar image. Call http://<yourForumAdress>/test.php. What is happens?

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

Test file with getAvatar-Function

by Magma, Tuesday, November 29, 2016, 22:44 (298 days ago) @ Milo
edited by Auge, Wednesday, November 30, 2016, 07:54

I did this, all I can see is the following text:

array(3) { [0]=> string(15) "images/avatars/" [1]=> string(7) "243.png" [2]=> string(22) "images/avatars/243.png" }
Avatar

Test file with getAvatar-Function

by Milo ⌂, Wednesday, November 30, 2016, 08:40 (298 days ago) @ Magma

Hi,

I did this, all I can see is the following text:

Okay, the function works fine without problems. The path, the image name and the path with image is returned.

We know, this function works, so, can you add it to the function.inc.php

function getAvatar($user_id) {
 $avatar_images_path = 'images/avatars/';
 $fileList = glob( $avatar_images_path . intval($user_id) . "[_.]*{png,jpg,jpeg,gif,bmp}" , GLOB_BRACE);
 if (isset($fileList) && count($fileList) > 0) {
  foreach ($fileList as $file) {
   if (preg_match("/^(" . preg_quote($avatar_images_path, '/') . ")(" . preg_quote(intval($user_id)) . "(_\d+)?\.(jpg|gif|png|jpeg,bmp))$/", $file, $matches)) {
    //var_dump($matches);
    $filename = $matches[2];
    if (file_exists($avatar_images_path.$filename))
     return array($avatar_images_path, $filename, $avatar_images_path.$filename);
   }
  }
 }
 return false;
}


After adding this code, the forum should still running without an error because the function is never called. Is this right?

Now, please add a sample output. Please edit the avatar.inc.php. Look for:

if($settings['avatars']>0 && isset($_SESSION[$settings['session_prefix'].'user_id']))
 {
  if(isset($_GET['delete']))
   {

and add the function call behind the first if-statement

if($settings['avatars']>0 && isset($_SESSION[$settings['session_prefix'].'user_id']))
 {
  // START NEW LINE
  var_dump(getAvatar($_SESSION[$settings['session_prefix'].'user_id']));
  // END NEW LINE
  if(isset($_GET['delete']))
   {


Please visit your user profile and click on the link to change your avatar. You should get an output like:

array(3) { [0]=> string(15) "images/avatars/" [1]=> string(7) "243.png" [2]=> string(22) "images/avatars/243.png" }

Do you get the output (or a similar one)?

Please remove the line from avatar.inc.php, if the check is done. ;-)

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

I think it's fixed now

by Magma, Wednesday, November 30, 2016, 15:05 (297 days ago) @ Milo

Ok I tried again.

I replaced the 5 files from your download then edited the functions.inc from this:

function getAvatar($user_id) {
 $avatar_images_path = 'images/avatars/';
 $fileIterator = new FilesystemIterator($avatar_images_path);
 $regexFileFilterIterator = new RegexIterator($fileIterator, "/\D+(".preg_quote(intval($user_id), '/')."(_\d+)?\.(jpg|gif|png|jpeg)$)/i", RegexIterator::GET_MATCH);
 $regexFileFilterIterator->rewind();
 $filename = ($regexFileFilterIterator->valid() && count($regexFileFilterIterator->current()) > 1) ? $regexFileFilterIterator->current()[1] : false;
 if ($filename === false || !file_exists($avatar_images_path.$filename))
  return false;
 return array($avatar_images_path, $filename, $avatar_images_path.$filename);
}


to this

function getAvatar($user_id) {
 $avatar_images_path = 'images/avatars/';
 $fileList = glob( $avatar_images_path . intval($user_id) . "[_.]*{png,jpg,jpeg,gif,bmp}" , GLOB_BRACE);
 if (isset($fileList) && count($fileList) > 0) {
  foreach ($fileList as $file) {
   if (preg_match("/^(" . preg_quote($avatar_images_path, '/') . ")(" . preg_quote(intval($user_id)) . "(_\d+)?\.(jpg|gif|png|jpeg,bmp))$/", $file, $matches)) {
    //var_dump($matches);
    $filename = $matches[2];
    if (file_exists($avatar_images_path.$filename))
     return array($avatar_images_path, $filename, $avatar_images_path.$filename);
   }
  }
 }
 return false;
}


and it seems to be working now. I have not tried

Now, please add a sample output. Please edit the avatar.inc.php. Look for:


Do I need to do this?
Thanks

Avatar

I think it's fixed now

by Milo ⌂, Wednesday, November 30, 2016, 16:16 (297 days ago) @ Magma

Hi,

and it seems to be working now.

What do you mean with: it works? Yesterday, you told me that the modified function didn't solve the problem?!

Now, please add a sample output. Please edit the avatar.inc.php. Look for:

Do I need to do this?

I'm not sure, what do you did. If it works fine: means, the avatar is changed and displayed in the correct way, all is fine.

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation

Avatar

I think it's fixed now

by Magma, Thursday, December 01, 2016, 14:13 (296 days ago) @ Milo

I did contact my hosting company about the problem in-between it not working, maybe they changed something their end. All seems to be working now though. Look forward to the 2.4 release update :-D Thanks

RSS Feed of thread
powered by my little forum