Advanced search  

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]

Pages: [1]   Go Down

Author Topic: [Solved]: Remove Partial Stats  (Read 4071 times)

0 Members and 1 Guest are viewing this topic.

ShiversOfHorror

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 60
[Solved]: Remove Partial Stats
« on: April 13, 2008, 11:19:08 pm »

I've seen posts to remove 'x files in x albums and x categories with x comments viewed x times' over and over again, but I have not come across a recent one in my many searches for what I want.

I want to keep 'x files viewed x times' and eleminate the rest. Is this even possible?

I am working with my own theme based off water drop.

I did read this, http://forum.coppermine-gallery.net/index.php/topic,25060.msg115233.html#msg115233 but its either not what I'm looking for or I just don't understand it, but it sounds like that one is to remove all those stats.

I also read: http://forum.coppermine-gallery.net/index.php/topic,43616.0.html but it didn't really tell me how to solve it, and I would like to save on the queries if possible.

So then I found this thread: http://forum.coppermine-gallery.net/index.php/topic,7228.0.html - but its a very very old thread, and I'm not sure the fix would still be the same, plus I'd be removing more stuff.

I just want to make sure I am correct (but I also don't know what stat2 would edit) - so in that above post the person wrote to change the following two lines.

Code: [Select]
'stat1' => '<b>[pictures]</b> files in <b>[albums]</b> albums and <b>[cat]</b> categories with <b>[comments]</b> comments viewed <b>[views]</b> times',
Code: [Select]
'stat3' => '<b>[pictures]</b> files in <b>[albums]</b> albums with <b>[comments]</b> comments viewed <b>[views]</b> times',
should I change them to:

Code: [Select]
'stat1' => '<b>[pictures]</b> files <b>[views]</b> times',
Code: [Select]
'stat3' => '<b>[pictures]</b> files <b>[views]</b> times',
Would that be correct?

Thanks
« Last Edit: April 14, 2008, 09:33:53 am by Joachim Müller »
Logged

Nibbler

  • Guest
Re: Remove Partial Stats
« Reply #1 on: April 13, 2008, 11:35:21 pm »

You need to change the code too, otherwise you'll get error messages. stat2 is the stats line used in user galleries. In index.php find

Code: [Select]
    // Gather gallery statistics
    if ($cat == 0) {
        $result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE 1" . $album_filter);
        $nbEnr = mysql_fetch_array($result);
        $album_count = $nbEnr[0];
        mysql_free_result($result);

        $sql = "SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON a.aid=p.aid ' . 'WHERE 1' . $pic_filter . ' AND approved=\'YES\'';
        $result = cpg_db_query($sql);
        $nbEnr = mysql_fetch_array($result);
        $picture_count = $nbEnr[0];
        mysql_free_result($result);

        $sql = "SELECT count(*) FROM {$CONFIG['TABLE_COMMENTS']} as c " . 'LEFT JOIN ' . $CONFIG['TABLE_PICTURES'] . ' as p ' . 'ON c.pid=p.pid ' . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON a.aid=p.aid ' . 'WHERE 1' . $pic_filter;
        $result = cpg_db_query($sql);
        $nbEnr = mysql_fetch_array($result);
        $comment_count = $nbEnr[0];
        mysql_free_result($result);

        $sql = "SELECT count(*) FROM {$CONFIG['TABLE_CATEGORIES']} WHERE 1";
        $result = cpg_db_query($sql);
        $nbEnr = mysql_fetch_array($result);
        $cat_count = $nbEnr[0] - $HIDE_USER_CAT;
        mysql_free_result($result);

        $sql = "SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON p.aid=a.aid ' . 'WHERE 1' . $pic_filter;
        $result = cpg_db_query($sql);
        $nbEnr = mysql_fetch_array($result);
        $hit_count = (int)$nbEnr[0];
        mysql_free_result($result);

        if (count($cat_data)) {
            $statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => $picture_count,
                    '[albums]' => $album_count,
                    '[cat]' => $cat_count,
                    '[comments]' => $comment_count,
                    '[views]' => $hit_count));
        } else {
            $STATS_IN_ALB_LIST = true;
            $statistics = strtr($lang_list_categories['stat3'], array('[pictures]' => $picture_count,
                    '[albums]' => $album_count,
                    '[comments]' => $comment_count,
                    '[views]' => $hit_count));
        }
    } elseif ($cat >= FIRST_USER_CAT && $ALBUM_SET) {
        $result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE 1 $current_album_set");
        $nbEnr = mysql_fetch_array($result);
        $album_count = $nbEnr[0];
        mysql_free_result($result);

        $result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set AND approved='YES'");
        $nbEnr = mysql_fetch_array($result);
        $picture_count = $nbEnr[0];
        mysql_free_result($result);

        $result = cpg_db_query("SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set");
        $nbEnr = mysql_fetch_array($result);
        $hit_count = (int)$nbEnr[0];
        mysql_free_result($result);

        $statistics = strtr($lang_list_categories['stat2'], array('[pictures]' => $picture_count,
                '[albums]' => $album_count,
                '[views]' => $hit_count));
    } else {
        $statistics = '';
    }

and change to this

Code: [Select]
    // Gather gallery statistics
    if ($cat == 0) {

        $sql = "SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON a.aid=p.aid ' . 'WHERE 1' . $pic_filter . ' AND approved=\'YES\'';
        $result = cpg_db_query($sql);
        $nbEnr = mysql_fetch_array($result);
        $picture_count = $nbEnr[0];
        mysql_free_result($result);

        $sql = "SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON p.aid=a.aid ' . 'WHERE 1' . $pic_filter;
        $result = cpg_db_query($sql);
        $nbEnr = mysql_fetch_array($result);
        $hit_count = (int)$nbEnr[0];
        mysql_free_result($result);

        if (count($cat_data)) {
            $statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => $picture_count,
                    '[views]' => $hit_count));
        } else {
            $STATS_IN_ALB_LIST = true;
            $statistics = strtr($lang_list_categories['stat3'], array('[pictures]' => $picture_count,
                    '[views]' => $hit_count));
        }
    } elseif ($cat >= FIRST_USER_CAT && $ALBUM_SET) {

        $result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set AND approved='YES'");
        $nbEnr = mysql_fetch_array($result);
        $picture_count = $nbEnr[0];
        mysql_free_result($result);

        $result = cpg_db_query("SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set");
        $nbEnr = mysql_fetch_array($result);
        $hit_count = (int)$nbEnr[0];
        mysql_free_result($result);

        $statistics = strtr($lang_list_categories['stat2'], array('[pictures]' => $picture_count,
                '[views]' => $hit_count));
    } else {
        $statistics = '';
    }

Then your changes to the lang file will be correct and you won't be running pointless queries.
Logged

ShiversOfHorror

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 60
Re: Remove Partial Stats
« Reply #2 on: April 13, 2008, 11:59:39 pm »

Thanks so much. I'll give it a try and let you know how it works.
Logged

ShiversOfHorror

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 60
Re: [Solved]: Remove Partial Stats
« Reply #3 on: April 15, 2008, 04:56:01 am »

Sorry, didn't get to try it till just now. Works great, although I left out 'viewed' in my code so had to re-edit it. But not a big deal.  :D

Thanks again  ;D
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 19 queries.