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: getting my statistic  (Read 4431 times)

0 Members and 1 Guest are viewing this topic.

pelhrimak

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 49
    • satelite photos of world
getting my statistic
« on: February 25, 2006, 12:45:08 pm »

Hello, I have a queston.
How do I get a statistic ? (number of cat, albums, comments, views) + size of all images
« Last Edit: February 26, 2006, 04:53:12 pm by Stramm »
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: getting my statistic
« Reply #1 on: February 26, 2006, 04:00:27 pm »

I guess you already know you have all that stats exc except filesize
two changes need to be done

index.php
find
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 {


replace with
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);

        $sql = "SELECT sum(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);
        $size_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,
                    '[size]' => $size_count,
                    '[views]' => $hit_count));
        } else {

in lang/english.php (or the language file your using) find $lang_list_categories, few lines below replace the line starting with
Code: [Select]
  'stat1' with
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, size <b>[size]</b>k',

pelhrimak

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 49
    • satelite photos of world
Re: getting my statistic
« Reply #2 on: February 26, 2006, 04:26:14 pm »

Thank and How Do I do a statistic.php with the statistic ?

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: getting my statistic
« Reply #3 on: February 26, 2006, 04:49:23 pm »

in config enable your anycontent block and add this to it
Code: [Select]
<?php
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

starttable("100%""Welcome");

    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;
        
$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);

        
$sql "SELECT sum(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);
        
$size_count = (int)$nbEnr[0];
        
mysql_free_result($result);

echo 
"<tr><td>Albs:"$album_count." - Pics:".$picture_count." - Comments:".$comment_count." - Cats:".$cat_count." - Hits:".$hit_count." - Filesize:".$size_count."</td></tr>";
}
endtable();

?>

pelhrimak

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 49
    • satelite photos of world
Re: getting my statistic
« Reply #4 on: February 26, 2006, 04:51:43 pm »

Thanks
else
Code: [Select]
/ (1024*1024), 2) ." MB"; please .. this is super statistic

pelhrimak

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 49
    • satelite photos of world
Re: getting my statistic
« Reply #5 on: February 26, 2006, 05:10:51 pm »

new anycontentm.php
Code: [Select]
<?php
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

starttable("100%""Statistic this gallery");

    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;
        
$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);

        
$sql "SELECT sum(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);
        
$size_count = (int)$nbEnr[0];
        
mysql_free_result($result);

echo 
"<tr><td>Albs:"$album_count." - Pics:".$picture_count." - Comments:".$comment_count." - Cats:".$cat_count." - Hits:".$hit_count." - Filesize:"round ($size_count  / (1024*1024), 2). " MB</td></tr>";
}
endtable();

?>

pelhrimak

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 49
    • satelite photos of world
Re: getting my statistic
« Reply #6 on: February 26, 2006, 05:19:12 pm »

IN MB no bytes ...
index.php
find
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 {


replace with
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);

        $sql = "SELECT sum(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);
        $size_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,
                    '[size]' => round ($size_count  / (1024*1024), 2),
                    '[views]' => $hit_count));
        } else {

in lang/english.php (or the language file your using) find $lang_list_categories, few lines below replace the line starting with
Code: [Select]
  'stat1' with
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, size <b>[size]</b>k',
Pages: [1]   Go Up
 

Page created in 0.027 seconds with 15 queries.