Count hits of registered users

Is it possible to set up the hitcounter function so that the views number increases when any user (except the admin) views an image?
I have admin rights so when I click on an image the hits number stays the same, I logged in with an account with user rights thinking the hits number would increase but it doesn't, it's as if I'm the admin.

Comments

  • The script /zp-core/zp-extensions/hitcounter.php includes a check to see if the current user has rights to the album, only counting hits if they do not. For the different page types, you'll see something like:

    `if (!isMyALbum($_zp_current_album->name, LIST_ALBUM_RIGHTS))`

    The syntax varies depending on whether it is checking rights to a page, news item, album, or image. You can modify these checks to not care if the object in question belongs to the current user.

    I'm guessing the logic behind this was that the counter should show how many "visitors" viewed an object, without counting hits by the owner who may simply be verifying that the object looks correct on the page. Seeing that an image was hit 5,000 times isn't all that helpful if you don't also take into account that 4,500 of those hits was from the person looking at it themself :-)

    I have modified my hitcounter.php to exclude hits from the same IP address as the server. I run my own server on the development machine, and I often verify that changes to the site work correctly for both logged-in users and visitors, but I don't want my own hits counting there either.
  • the counter will not increment for album "owners". for all other users it will increment. you can, of course, change that by making yooyr own custom version if the plugin.
  • For what it's worth, I'd planned to submit an update to the plugin that presents some admin-configurable options, such as a list of IPs to exclude or known searchbot user-agents, so I didn't have to be careful about overwriting my changes with the SVN copy all the time. I could also modify the plugin to include an option for whether object owner hits are counted.
  • acrylian Administrator, Developer
    Sure, right on, we won't stop your current run...;-) Even if it is too late for 1.3 anyway and if we may not include it officially there is always room for alternative third party plugin versions.
  • Issue created: http://www.zenphoto.org/trac/ticket/1511

    I added a patch, which should work, and at least doesn't seem to crash! I have to double-check the modified logic for ignoring object owners if configured to do so, and determine how effective the current method of detecting bots/crawlers is. Feedback welcome.
  • Barbara Member
    Oh great, thank you! So glad you were already working on this.
    Just one question as I'm not familiar with this patch thing, could you explain how this would be implemented if I wanted to use it now?
    I suppose I have to replace the old hitcounter.php with the updated patch. Do I also need to change something else around or just that it's enough?
  • The patch is just a list of changes to the file, not the file itself, so you would need a program to modify the existing file with the patch to implement the changes. I don't know of any such programs for Windows off the top of my head, but I'm sure you could find one through Google (try "Windows apply patch").

    However, I would advise not to use the existing patch as it is likely to cause your site to become slower as it is implemented now.
  • kagutsuchi, thanks for the feedback on the patch in that ticket (meant to comment here also).

    Barbara, the free Windows utility WinMerge is a good choice. Once I have made some changes to the patch as suggested, I can also attach both the patch and a full copy of the file for you. How much slower the existing implementation would make your site depends on a few things, including how many hits it normally gets. Those small inefficiencies, multiplied by millions of hits, definitely add up!
  • I've posted an updated script, taking your advice, and also making the list of search crawler user-agents configurable. Let me know how it looks now... Thanks!
  • Hey! I had the chance to test this only now. I'd say it works perfectly, many many thanks for the help. :D
Sign In or Register to comment.