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: File Info  (Read 6019 times)

0 Members and 1 Guest are viewing this topic.

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
File Info
« on: February 11, 2007, 11:05:20 pm »

I was wondering weather I could change info of how many files you have in x amount of categories with x amount of comments and x amount of views

for example: 2517 files in 54 albums and 2 categories with 0 comments viewed 849 times

I want to change it to: 2517 files viewed 849 times

I also want to add the amount of disk space the x amount of files is using

for example: 2517 files viewed 849 times total space 1.2GB

I would be greatful if anybody can help ;D
« Last Edit: February 13, 2007, 12:47:24 am by Nibbler »
Logged

Nibbler

  • Guest
Re: File Info
« Reply #1 on: February 11, 2007, 11:27:31 pm »

You can modify the string in your language file. Remove the parts you don't want and add an extra placeholder for the new info. Modify one of the db queries to pull the sum(total_filesize), convert to GB, and add it into the strtr.

Code to change is in index.php

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 = '';
    }
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: File Info
« Reply #2 on: February 12, 2007, 11:41:22 pm »

I've added the following to strtr but what do I put after $

'[total_filesize]' =>$

Thanks ;D
Logged

Nibbler

  • Guest
Re: File Info
« Reply #3 on: February 13, 2007, 12:00:09 am »

Changed code for index.php would be like this:

Code: [Select]
        $sql = "SELECT sum(hits), sum(total_filesize) 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];
        $total_filesize = (int)$nbEnr[1];
        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,
                    '[total_filesize]' => round($total_filesize/1024/1024/1024, 2)
                    ));
        } else {
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: File Info
« Reply #4 on: February 13, 2007, 12:19:37 am »

I get this error when changing the code in index.php

Parse error: parse error, unexpected ';' in /home/content/w/i/l/willtaka05/html/gallery/index.php on line 312

Do I need to change anything in the english.php lang file ???
Logged

Nibbler

  • Guest
Re: File Info
« Reply #5 on: February 13, 2007, 12:24:32 am »

The code I posted replaces

Code: [Select]
        $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 {

Line 312 should not contain a semi colon if you did it correctly.
Logged

Nibbler

  • Guest
Re: File Info
« Reply #6 on: February 13, 2007, 12:26:01 am »

Do I need to change anything in the english.php lang file ???

You need to add [total_filesize] and corresponding descriptive words into the lang file (stat1)
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: File Info
« Reply #7 on: February 13, 2007, 12:38:59 am »

sorry to ask you to basically do it for me but I'm useless at coding, anyway it has worked wonders, thanks alot ;D
Logged

Nibbler

  • Guest
Re: File Info
« Reply #8 on: February 13, 2007, 12:48:21 am »

Great. If you wanted 1.2 instead of 1.15 then change the 2 to 1 here

Code: [Select]
'[total_filesize]' => round($total_filesize/1024/1024/1024, ***2***)
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: File Info
« Reply #9 on: February 21, 2007, 10:29:41 pm »

for some reason the total filesize has stopped at 2GB and has been like that for about 10 uploads now ???
Logged

Nibbler

  • Guest
Re: File Info
« Reply #10 on: February 21, 2007, 10:38:46 pm »

Adjust the rounding if you want to see such small changes.
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: File Info
« Reply #11 on: February 21, 2007, 10:40:24 pm »

I mean it hasn't increased since about 10 uploads, normally after 2-3 uploads it goes from 1GB to 1.10GB and so one but it hasn't since ???
Logged

Nibbler

  • Guest
Re: File Info
« Reply #12 on: February 21, 2007, 10:41:56 pm »

Depends on the size of files you are uploading...
Logged

will

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 263
Re: File Info
« Reply #13 on: February 21, 2007, 11:09:05 pm »

It looks like its not working, how do I remove it so I don't get an error ;D
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 19 queries.