Hi,
I run Zenphoto 1.2.2 for a very long time successfully including a modification of the rating-plugin. This modification did a replacement of the user-IP by an user-ID (integer value) which I got from my MyBB-forum settings. This is necessary because our forum has several users with different user-IDs but the same IP. On the other side I don't want to get the same user being able to rate an image again and again by using a different IP.
After upgrading to PHP5.3 I had to upgrade Zenphoto as well and tried to integrate my ID-modification for the rating plugin again. However, it seems that something at the rating plugin changed fundamentely. :-/
I have been trying to get rid of this problems by several weeks but didn't succeed. Therefore, I would be very glad to get any hints how to exchange the IP by an integer value (user-ID) again at the rating plugin.
Thank you very much in advance.
Comments
Thank you very much for your answer. I don't blame you for not remembering about this old version...
I suppose that your proposed plugin might be too much for my purpose. The gallery can be accessed by logged in users only and upload of image and creating albums is restricted to admins.
It was charming to avoid the user-IP and using their ID instead.
Therefore I intend not to work with
$ip = getUserIP();
but with
$ip = sanitize($_SESSION['GalleryUser'], 0);
as well in the rating.php and the update.php as well.
var_dump($ip) shows that the user-ID is existing but it seems that the update.php doesn't get it.
Whereas the original database entry (including IP) looks like
a:1:{s:14:"XX.YYY.ZZZ.193";i:5;}
my actual entry (trying to use the user-ID) looks like
a:1:{s:0:"";i:5;}
Any help would really much appreciated as the gallery is really amazing and most welcome in my forum.
`a:1:{s:14:"XX.YYY.ZZZ.193";i:5;}`
Therefore, I don't think that the IP will be hashed.
Nevertheless, is the IP-hash done by zenphoto and if yes, where could I find the setting for this?
The latter is fixed in the nightly build tonight.
Of course, this will not help in the situation you describe as it simply hashes the IP address so that the paranoid EU cannot complain.
You will need to replace the `getUserIP()` function calls in the rating plugin scripts with your code above. BTW, `$_SESSION['GalleryUser']` is not something that Zenphoto is maintaining, so be sure that it works for any visitor to your site.
As described above, replacing the getUserIP() function in the rating plugin was my original intention and the way I how I did it in the 1.2.2 zenphoto version.
I inlude the global variables from the MyBB software to be able to read the uid of the user by using
`$_SESSION['GalleryUser'] = $mybb->user['uid'];`
`$ip = sanitize($_SESSION['GalleryUser'], 0);`
This seems to work for the rating.php file as by using
`echo var_dump($ip);`
I see the correct user-ID. However, I fail to get this written in the database after submitting the rate.
I tried to use `session_start()` to have the $ip available at function_rating.php and upgrade.php as well but it doesn't work as well.
Replacing the `getUserIP()` function calls (note the plural) is indeed what you need to do. If you are storing the user data in a session variable then sessions must be enabled for the Zenphoto front end. You can do that by checking the `enable gallery sessions` check box on the gallery options tab.
As far as I see there are two getUserIP() calls to replace. One in the rating.php and one in the upgrade.php. I have enabled the gallery sessions as well. Are you able to tell me if I need to set session_start() in these two files as well or will be `$_SESSION['GalleryUser']` "transfered" by the zenphoto session?
I am still hoping to get rid of the problem by myself....
However, sessions can expire, etc. This depends on PHP settings. Your other option is to store the user id in a cookie. That does not require sessions, thus does not need the gallery sessions option.
1. db-entry: `a:1:{i:1;d:5;}` => User-ID 1
2. db-entry: `a:2:{i:1;d:5;i:3;d:3;}` => User-ID 3
3. db-entry: `a:3:{i:5;s:1:"4";i:3;s:1:"4";i:4;d:5;}` => User-ID 4
4. db-entry: `a:4:{i:5;s:1:"4";i:3;s:1:"4";i:4;d:5;i:6;d:2;}` => User-ID 6
I can't get it work.....
`a:1:{i:1;d:5;}` => user 1 rating 5
`a:2:{i:1;d:5;i:3;d:3;}` => user 1 rating 5; user 3 rating 3
`a:3:{i:5;s:1:"4";i:3;s:1:"4";i:4;d:5;}` => user 5 rating "4"; user 3 rating "4"; user 4 rating 5
`a:4:{i:5;s:1:"4";i:3;s:1:"4";i:4;d:5;i:6;d:2;}` => user 5 rating "4"; user 3 rating "4"; user 4 rating 5; user 6 rating 2
I hope to be able to explain where my problems are.
For the lines 'a:1...' and 'a2:...' I understand you explanation.
However, with the following updated entries of 'a3:...' and 'a4:...' I don't understand the change of the listing (rating within double quote and the entry of "s:1"). And where is the rating and the user-ID of user 1 at the entry of 'a3:...' and 'a4:...'?
Line a1 shows the first rating of user 1 and line a4 shows the last rating of user 6 (including the rating of users 1, 3, 4 and 6).
A user with ID 5 has not rated any image.
`
a:1:{i:1;d:5;}array
1 => float 5
a:2:{i:1;d:5;i:3;d:3;}array
1 => float 5
3 => float 3
a:3:{i:5;s:1:"4";i:3;s:1:"4";i:4;d:5;}array
5 => string '4' (length=1)
3 => string '4' (length=1)
4 => float 5
a:4:{i:5;s:1:"4";i:3;s:1:"4";i:4;d:5;i:6;d:2;}array
5 => string '4' (length=1)
3 => string '4' (length=1)
4 => float 5
6 => float 2
`
So if a user 5 has not rated your image then you have some problem with your user management since clearly there is an entry for a 5 in your data.
I will now move the zenphoto-gallery to my live system, hoping that everything will keep working as well....
Thank you again for all your assistance and last but not least your patience!