Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Slideshow and view count  (Read 21545 times)

0 Members and 1 Guest are viewing this topic.

gregik

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Slideshow and view count
« on: August 24, 2004, 12:30:57 pm »

Is it a feature or is a bug but slaidshow does not count as picture view.




edit: sorry, I think this post is in wrong category
« Last Edit: October 12, 2005, 03:44:40 pm by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Slaidshow and view count
« Reply #1 on: August 25, 2004, 10:45:06 am »

neither feature nor bug: using the slideshow a JavaScript is being used to pull the images - the images are being pre-loaded, but actually the server doesn't "know" what images have been viewed (the user might have stopped the slideshow without having viewed all files in the album). That's why the images are not counted. It's a limitation by design. You're welcome to look into it and post modifications if you find a way to overcome this.

GauGau
Logged

jerx

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: Slaidshow and view count
« Reply #2 on: October 12, 2005, 10:45:31 am »

I also want the slideshow to be counted as views.

Do you mean by limitation that you cannot use Javascript to write into the database or do you mean that the pic counts would be unreliable, because the user might have stopped the slideshow already?

I think even though the pic counts are not accurate, it is still better to count the pre-loaded pictures. There should only be a few pictures which haven' t been displayed but counted as views. If you don' t count the slideshow your stats are even more inaccurate, because usually you have much more displayed pictures than pre-loaded images which haven' t been displayed.

Does anybody know how to modify the code to count the slideshow? Do you have to use php instead of javascript?
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Slaidshow and view count
« Reply #3 on: October 12, 2005, 01:23:13 pm »

the workaround you're asking for is something I wouldn't even think about. Mainly cause I have a lot of pictures in my albums and I know that when viewing a slidshow in most cases only a handful images get served. So eg view count for 1000 images get raised while only 5 pictures got viewed. Here I don't agree with you. Therefore you'd have to rewrite the entire slideshow function.... hmm, maybe when I'm bored. But if you really need it ask on the freelancers board.

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Slaidshow and view count
« Reply #4 on: October 12, 2005, 01:43:39 pm »

Ok, here is the solution using XML HTTP Request.

Edit include/slideshow.inc.php

Add

Code: [Select]
var x1;

x1 = createRequestObject();

function createRequestObject() {
  var x = false;

  try {
    x = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      x = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      x = false;
    }
  }

  if (!x && typeof XMLHttpRequest != "undefined") {
    x = new XMLHttpRequest();
  }

  return x;
}

function addHit(pid) {
  x1.open('get','addHit.php?pid='+pid);
  x1.onreadystatechange = function() {
    if (x1.readyState == 4) {
      return (x1.responseText);
    }
  }
  x1.send(null);
}

just after

Code: [Select]
<script language="JavaScript" type="text/JavaScript">

then Add
Code: [Select]
var Pid = new Array()

just After
Code: [Select]
var Pic = new Array() // don't touch this

Add
Code: [Select]
echo "Pid[$i] = '" . $picture['pid'] . "'\n";

just after
Code: [Select]
echo "Pic[$i] = '" . $picture_url . "'\n";

then Replace
Code: [Select]
        if (xIE4Up){
           document.images.SlideShow.filters.blendTrans.Play()
        }

with
Code: [Select]
        if (xIE4Up){
           document.images.SlideShow.filters.blendTrans.Play()
        }
        addHit(Pid[j])

Then create a new file addHit.php having the following code. Place this file in your coppermine folder.

Code: [Select]
<?php
define
('IN_COPPERMINE'true);

require(
'include/init.inc.php');

if (isset(
$_GET['pid'])) {
  
// Add 1 to hit counter
  
$pid = (int)$_GET['pid'];
  if (!
in_array($pid$USER['liv']) && isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_data'])) {
      
add_hit($pid);
      if (
count($USER['liv']) > 4array_shift($USER['liv']);
      
array_push($USER['liv'], $pid);
      
user_save_profile();
  }  
}
?>


This should work.

Note: The hit will be counted for only those images which have been served.

Abbas
Logged
Chief Geek at Ranium Systems

jerx

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: Slaidshow and view count
« Reply #5 on: October 12, 2005, 03:26:04 pm »

Stramm, I didn' t know that all pictures get pre-loaded at the same time. I thought it only pre-loads a couple of pictures. If it is like this, I agree with you.

Abbas Ali,

Thank you very much for the quick modification!

Unfortunately views are not counted. I don' t get any error message. I double checked my modifications and they are as instructed (3 additions and 1 replacement). The file is named addHit.php and I copied it to the coppermine root directory. Any ideas what could be wrong?

Edit: Sorry, the code works perfect. The pictures I compared have already been viewed by me, so the slideshow view wasn' t counted. I tested it on another album which I haven' t viewed today and there all picture counts have been raised by 1. Thanks again for your help!!!
« Last Edit: October 12, 2005, 03:40:48 pm by jerx »
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Slaidshow and view count
« Reply #6 on: October 12, 2005, 03:37:26 pm »

no it doesn't preload the pictures... it preloads a list with all URLs to the pictures in that album. Means it only has to connect once to the db when the slideshow's started.

Wow, nice hack ;)
I'd written something that uses a meta refresh and connects to the db with each pic

jerx

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: Slaidshow and view count
« Reply #7 on: October 12, 2005, 03:43:45 pm »

Yes, it is a really great hack! You should implement it in future releases of coppermine!
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Slideshow and view count
« Reply #8 on: October 12, 2005, 07:36:23 pm »

@devs - What you all say? Not necessarily this mod but we should do something to count the slideshow views in future versions.
Logged
Chief Geek at Ranium Systems

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Slideshow and view count
« Reply #9 on: October 12, 2005, 08:30:05 pm »

yes, I agree - preferably as an admin option ("increase view counter during slideshow").
Logged

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Re: Slideshow and view count
« Reply #10 on: October 12, 2005, 08:37:20 pm »

@devs - What you all say? Not necessarily this mod but we should do something to count the slideshow views in future versions.

Good job, Abbas.  I like it.  I vote "yes", as well. Agreeing with Gaugau, that it should be as an admin option.

Dennis
Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Slideshow and view count
« Reply #11 on: October 13, 2005, 04:37:05 am »

Ditto... that it be an admin option.
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Slideshow and view count
« Reply #12 on: October 13, 2005, 12:02:58 pm »

When already adding new features to the slideshow wouldn't it be great to optimize it for huge albums too ?

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Slideshow and view count
« Reply #13 on: September 07, 2006, 01:28:49 am »

Added feature to devel branch. 

Devs, please review my check in addHit.php - I have replaced
Code: [Select]
if (isset($_GET['pid'])) {from Abbas' original code with
Code: [Select]
if (isset($_GET['pid']) && !GALLERY_ADMIN_MODE && $CONFIG['slideshow_hits'] != 0) {
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Slideshow and view count
« Reply #14 on: September 07, 2006, 02:03:06 pm »

Working as expected in Mozilla and FF.

@Joachim: Did you tested it in IE? I have ie4linux and it is not working in it. Maybe it will work on windoz.
Logged
Chief Geek at Ranium Systems

Nibbler

  • Guest
Re: Slideshow and view count
« Reply #15 on: September 07, 2006, 02:19:12 pm »

We're not using $HTTP_COOKIE_VARS any more remember.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Slideshow and view count
« Reply #16 on: September 07, 2006, 02:33:32 pm »

I have ie4linux and it is not working in it.
There is IE on Linux :o? Never heard of that.
No, I haven't tested thoroughly, just added the code last night at work while I was doing a file server maintenance job that left me with some time to waste while robocopy did it's job. I'll test it with all browsers I can get hold of (which is IE, FF, Opera on Windows and Konqueror, Trillian and Firefox on Linux).

We're not using $HTTP_COOKIE_VARS any more remember.
k, so this needs testing and modifications. I'd love to see you look into it. I confess that I was lazy and just added the code to devel without looking much into it, sorry.
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Slideshow and view count
« Reply #17 on: September 07, 2006, 02:42:07 pm »

[ot]
IE4Linux
[/ot]
Logged
Chief Geek at Ranium Systems
Pages: [1]   Go Up
 

Page created in 0.032 seconds with 20 queries.