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: Is it possible to easily get the total view count to be used elsewhere?  (Read 12600 times)

0 Members and 1 Guest are viewing this topic.

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye

I would like to grab the total view count (90,874) as displayed on the gallery main (index) page:

"723 files in 34 albums and 8 categories with 9 comments viewed 90,874 times."

I would like to use that number in another "visits" display.

Thanks.
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me

What version of Coppermine are you using? 1.4.x has been unsupported for a very long time now. It has some known security issues. If you can update to 1.6.x then that would be a very good move. Then we can advise how you can read the view count from the database and display it on another page. If you need help in upgrading then please ask on the CPG 1.6.x upgrading forum.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye

Thanks for your reply.
I'm currently using v1.5.48.

If I can access the file and do a read via PHP, hopefully all I need is the file name where the info is stored.
I'm guessing I can parse the info to obtain the number.
Did they change the file name for that data in v1.6?

Bill
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye

It seems that the upgrade/install procedure has changed?
I used to push all the files except anycontent and albums to the server and run update.php.
I can only find instructions for installing v1.5, and they appear vague to me.
I'm not going to do 1.6 yet for fear of screwing up what I have.
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026

It seems that the upgrade/install procedure has changed?
I used to push all the files except anycontent and albums to the server and run update.php.
I can only find instructions for installing v1.5, and they appear vague to me.
I'm not going to do 1.6 yet for fear of screwing up what I have.

I moved your previous, similar post here:
https://forum.coppermine-gallery.net/index.php/topic,80241.msg388303/topicseen.html#msg388303
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #5 on: September 03, 2020, 10:22:09 pm »

> Phill Luckhurst:

I've upgraded to 1.6.08.  Can you tell me where the visit counter is stored so I might be able to acquire the count?

Thanks,
Bill
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #6 on: September 04, 2020, 03:51:04 am »

Those statistics are calculated on each home page display with PHP code in the index.php file beginning on line 480.
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #7 on: September 04, 2020, 10:34:09 pm »

Key operator here: easy

I was looking through some files (index and anycontent) to find the code that generated the text (that builds the output string) "723 files in 34 albums and 8 categories with 9 comments viewed 90,874 times." to see what variable represents the 90,874. If it is a summation of many variables from a few files, na, I don't need it that badly. Having it would just be a nicety.

Being retired I have the time, having reverse engineered 6800 machine code in the past, I have the ability, but not so much the desire (chemo brain is nasty), to go on a scavenger hunt and do the reverse engineering now.
 Maybe one day.

Thanks,
Bill
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #8 on: September 05, 2020, 01:09:34 am »

Maybe this will help you:

at line 533 in the index.php file, insert 1 line to write the value to a file
Code: [Select]
            $hit_count = (int)$nbEnr[0];
file_put_contents('total_views.txt', $hit_count);     // <-- insert this line
            if (count($cat_data)) {
then you can just pull that file contents into some other place.
( of course, you would have to enter that again after a CPG update )
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #9 on: September 05, 2020, 04:58:29 am »

Thanks very much Ron, I'll try that in a bit.

I just noticed something different in v1.6.08.
The last thing before the custom footer include is a "standard table" code that displays ..:... on the left of the screen.
I'll look in the forum to see if anyone else has that anomaly. If not, should I start another thread for it?
I just did a "view source" in the browser, so I'll have to see if it is in a CPG file, and which one.

Bill
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #10 on: September 05, 2020, 02:18:58 pm »

The last thing before the custom footer include is a "standard table" code that displays ..:... on the left of the screen.
That's where those statistics usually show. Did you change something in the index.php or language file?
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #11 on: September 05, 2020, 03:53:31 pm »

I changed nothing after upgrading. (Using eyeball theme)

The statistics show on the left just after the album list in the index page; right before the Last Additions list.
(MyMindsEye.US/gallery)

These characters are between Last Additions and the custom footer only on the index page.
It seems like the "build" of the index page contains:

<!-- Start standard table -->
<table align="center" width="100%" cellspacing="0" cellpadding="0" class="maintable ">
<tr><td class="tableb">.&nbsp;
.&nbsp;
:   .&nbsp;
.&nbsp;
.</td></tr></table>
<!-- End standard table -->

"Standard Table" is is not a connotation of mine and appears to be a CPG notation.
Superfluous code or is something missing?
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #12 on: September 05, 2020, 04:18:06 pm »

It would seem it's coming from one of your plugins. Disable them one at a time until you find which. Remember to clear cache before each test.
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #13 on: September 05, 2020, 05:19:09 pm »

I'm not intentionally using any plug-ins in the gallery, at least none that I am aware.
Since the "final" (working) index page is built from many "modules" under many "conditions", I'm going to have a devil of a time finding where that code resides or is created.

It's not an operational problem, just aesthetic.
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #14 on: September 05, 2020, 05:45:47 pm »

Wow, four enabled:
- online stats
- Core H5A upload
- Core SWF upload
- Core SGL upload

Will disable one at a time then check the index page each time.
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #15 on: September 05, 2020, 06:03:41 pm »

Okay, the characters go away when I disabled the online stats plugin- (onlinestats): v2.7.
(Originally created by Nibbler, i18n by Frantz)

Now to see if it is one of these, or the actual plugin.

anycontent/breadcrumb/catlist/alblist/lastup,2/onlinestats

OnlineStats appears to work.
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #16 on: September 05, 2020, 07:12:04 pm »

I removed each of anycontent/breadcrumb/catlist/alblist/lastup,2/onlinestats
one by one; the "..:..." still appears on the bottom left of the index page.

It only goes away when I disable the plugin.

Interesting that this plugin is not listed for v1.5 or v1.6.
I was hoping for an update.

Thanks Ron for the suggestion to look at the plugins.
I must have installed this back with v1.4 or earlier.
(I set it and forgot it.)

 I have to look through my files to see if I can find what the code looks like.
For right now I'll leave things as they are...
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #17 on: September 05, 2020, 08:37:01 pm »

Not gonna believe this....
All fixed! ! !
 I found another thread regarding the "Online Stats", under a v1.6 thread yet. It had a link to updated files on github.
(No Way was I going to be able to reverse engineer this one!)

Renamed the old, downloaded & copied the new, WALLA!
This is what was missing on my index page:

>>> Who is online?    
There are 9 registered users.  The newest registered user is Family.  In total there are 2 visitors online: 0 registered users and 2 guests.  Most users ever online: 62 on 03/19/20 at 15:17.  Registered users who have been online in the past 10 minutes: .


NOW I see the "..:..." , Obvious now! :o ::)

A million thanks Ron for the direction to investigate!
Now on to the total image view counter task.
Have a great day!
Logged

Longshadow

  • Coppermine newbie
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • My Mind's Eye
Re: Is it possible to easily get the total view count to be used elsewhere?
« Reply #18 on: September 07, 2020, 12:27:29 am »

Okay..... Confusion over.
The "file put" line of code (above) to save the hit count, needs to be placed at line 533 in the original index.php file, before update.php is run, correct?

Evidently the index.php actually in use is either built or modified during the update process?
In my index.php that is active on the server, this line needed to be inserted at line number 595. Maybe because I use anycontent?

Am I correct in understanding that the change recommended at line 533 is before update is run? (Process reference for the next update, and I realize it may be a different line number for the next update release.)

I did find, in my active version of index.php, the before and after lines referenced above, and inserted the file put between them, it works nicely! (after clearing the browser page cache).
 THANK YOU!
Logged
Pages: [1]   Go Up
 

Page created in 0.026 seconds with 19 queries.