modification of rating-Plugin

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

  • acrylian Administrator, Developer
    Sorry, 1.2.2 is so old that I don't even remember what was different back then. IF you want to us e the same users on your forum and on your Zenphoto install you should take a look at federated_logon plugin instead.
  • Hi acrylian,

    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. :)
  • acrylian Administrator, Developer
    Sorry, I cannot dig into this specific problem. The data is submitted via ajax so you might need to add something.
  • Thank you for your reply, acrylian. However, I think that ajax only submitts the stars rating value but not the IP. Or am I wrong?
  • acrylian Administrator, Developer
    Haven't looked at it for quite some time but it does use the IP. It has however an option to hash the IP as storing purely it is considered a privacy issue in countries of the EU. So maybe you have enabled that.
  • When using the IP, what is not my intention, the database shows this entry:
    `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?
  • You want the `Disguise IP` rating option. However, it will not work in the released Zenphoto as it was apparently only encrypting the IP in one place, not all places needed.

    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.
  • I am not sure what you mean with "Disguise IP", sorry.

    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. :(
  • Well, as I said the `Disguise IP` option will really not do what you want. But that is the name of the option you asked about above. It is an option of the ratings plugin and is inteneded to scramble IP addresses so that no one can complain that you are collecting them. It does NOT allow you to use distinguish among multiple users all having the same IP address.

    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.
  • Thank you for your reply.

    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.... ;)
  • Zenphoto will do the `session_start()` if the gallery sessions option is selected. Placing your user id into the sessions array as you did will propegate it to all scripts that are part of that session.

    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.
  • I guess, I am going to lose this battle.... :-/

    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.....
  • I am not exactly sure what your problem is:

    `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
  • Thank you for your patience, sbillard! I really appreciate it.

    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.
  • Well, I really do not know what to say. The database items you show are serialized arrays of what is stored as the voters. They translate as follows. (The array index is the voter, the value is the vote.)
    `
    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.
  • Thank you everybody for supporting my request. My changed rating-system is working now! I guess I had some cache problems but now it seems that everything is fine. :)

    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!
Sign In or Register to comment.