Is it possible to easily get the total view count to be used elsewhere? Is it possible to easily get the total view count to be used elsewhere?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Is it possible to easily get the total view count to be used elsewhere?

Started by Longshadow, July 18, 2020, 10:56:56 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Longshadow

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.

phill104

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.
It is a mistake to think you can solve any major problems just with potatoes.

Longshadow

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

Longshadow

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.

ron4mac

Quote from: Longshadow on July 29, 2020, 04:00:40 PM
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

Longshadow

> 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

ron4mac

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

Longshadow

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

ron4mac

Maybe this will help you:

at line 533 in the index.php file, insert 1 line to write the value to a file
            $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 )

Longshadow

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

ron4mac

Quote from: Longshadow on September 05, 2020, 04:58:29 AM
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?

Longshadow

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?

ron4mac

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.

Longshadow

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.

Longshadow

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.

Longshadow

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.

Longshadow

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...

Longshadow

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!

Longshadow

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!