Advanced search  

News:

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

Pages: [1] 2 3 4 5   Go Down

Author Topic: MOD: Detailed Gallery Statistics  (Read 89237 times)

0 Members and 1 Guest are viewing this topic.

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
MOD: Detailed Gallery Statistics
« on: November 22, 2005, 05:34:56 am »

I always wondered about what image in my gallery had the most comments or what time most of the files were uploaded at so I made this page that displays a lot of statistics about the gallery.

Tested with 1.4.x

theme.php

Add:
Code: [Select]
$template_sub_menu = <<<EOT
          {BUTTONS}$template_sys_menu_spacer
  <a href="galleryStats.php">Gallery Statistics<font color="#FF0000">(NEW)</font></a>
EOT;



Extract and upload galleryStats.php to your server and test.

Note: See reply #9 for 1.3.x compatible version.

See Reply #18 for 1.4.x rewritten version
See Reply #22  for 1.3.x rewritten version


The page is too big for a grab showing what it looks like so here is the demo
« Last Edit: July 06, 2006, 10:15:42 am by GauGau »
Logged

ganeshcp

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: MOD: Detailed Gallery Statistics
« Reply #1 on: November 22, 2005, 08:01:02 am »

doesnt seem to work on 1.3.5

Fatal error: Call to undefined function: cpg_db_query() in
........./public_html/galleryStats.php on line 114
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: MOD: Detailed Gallery Statistics
« Reply #2 on: November 22, 2005, 08:04:22 am »

that's why it's labelled to be for cpg1.4.x only.
Reason: renamed function. If you know your way around, you could try renaming all function calls in the mod.
Logged

ganeshcp

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: MOD: Detailed Gallery Statistics
« Reply #3 on: November 22, 2005, 08:08:51 am »

i think i need to upgrade to 1.4  ;D
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: MOD: Detailed Gallery Statistics
« Reply #4 on: November 22, 2005, 08:12:55 am »

cpg1.4.x currently goes unsupported, not recommended for production use yet, and only recommended for experienced users. I'd wait a few days, we're currently preparing the stable release.
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #5 on: November 22, 2005, 08:13:52 am »

Even if you renamed cpg_db_query() this would not work on 1.3.5 unless you removed some of the other features as well.  That reminds me of something I forgot to mention.  Detailed logging must be turned on in order for this to work completely.  Some of the data is taken from TABLE_VOTES and TABLE_HIT_STATS.
« Last Edit: November 23, 2005, 05:24:14 am by pslawinski »
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #6 on: November 22, 2005, 08:16:27 am »

Does anyone know how difficult it would be to turn some of the stats I have shown ex: Most Commented Images into an album?
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
Re: MOD: Detailed Gallery Statistics
« Reply #7 on: November 22, 2005, 08:39:44 am »

Fairly simple - file functions.inc.php is your friend - look at the function get_pic_data - then look at the index.php file to see how Meta Albums are handled
Logged
SANIsoft PHP applications for E Biz

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #8 on: November 22, 2005, 09:02:12 am »

Quote
functions.inc.php

Yeah, saw the functions.  I guess I just didn't feel like writing the code to make it work at the time so I just wrote some code to display the four images.

I'll try and get to that sometime soon and if I do I'll post the code.
« Last Edit: November 22, 2005, 10:33:11 am by pslawinski »
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #9 on: November 22, 2005, 10:28:19 am »

Quote
doesnt seem to work on 1.3.5

Ok, I think this new version will work with previous versions.  I only tested to make sure it was still compatible with 1.4.x.  I need someone else to test for 1.3.x as I do not have a working version on my server.

All I did was create a wrappers for cpg_db_query() and cpg_db_fetch_rowset() if the functions are not defined.  I also made sure the last two charts are not attempted to be displayed if the tables do not exist.

If anyone gets this working on a 1.3.x gallery please let me know or post a link.

EDIT: 11/22/05

I tested the mod with version 1.3.5 and it works.  The updated file is attached to this post
« Last Edit: November 22, 2005, 07:36:42 pm by pslawinski »
Logged

claude258

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 150
    • Album photos Brière
Re: MOD: Detailed Gallery Statistics
« Reply #10 on: November 26, 2005, 05:27:28 am »

I saw in your file that we can display ''Viewing Activity By Time'' but I dont see it when I use it. All other stats are there but not ''Viewing Activity By Time''.
Is there something I should do to be able to display this stats?
I'm using version 1.3.5.

Thanks.
 
Logged

claude258

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 150
    • Album photos Brière
Re: MOD: Detailed Gallery Statistics
« Reply #11 on: November 26, 2005, 06:40:42 am »

Is it possible that custom thumbnails are not displayed? I have a video with a custom thumb in the ''most voted'' stats and I see a red X instead of the thumb. The same thing apply to the video album which is in the ''most viewd album'' stats (this album only contains videos with custom thumb).
Otherwise, all those thumbs are displayed properly everywhere else (outside gallerystats.php).

Claude   
Logged

ganeshcp

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: MOD: Detailed Gallery Statistics
« Reply #12 on: November 26, 2005, 06:55:00 am »

If anyone gets this working on a 1.3.x gallery please let me know or post a link.

Yes it works now :)

http://www.bollyville.com/galleryStats.php
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #13 on: November 27, 2005, 04:43:53 am »

I saw in your file that we can display ''Viewing Activity By Time'' but I dont see it when I use it.
Ok, viewing activity only works with version 1.4.x and then only if you have detailed view stats enabled.
« Last Edit: November 27, 2005, 06:33:53 am by pslawinski »
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #14 on: November 27, 2005, 04:52:04 am »

Is it possible that custom thumbnails are not displayed?

Did you install a mod for custom thumbnails?  If so then it will likely not work with that.
« Last Edit: November 27, 2005, 06:34:41 am by pslawinski »
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #15 on: November 27, 2005, 06:52:48 am »

Yes it works now :)

http://www.bollyville.com/galleryStats.php

I see on your site you do not have an image for the bar graphs.  Perhaps I forgot to mention how to fix that.  Here is how to do that:

Find:
Code: [Select]
//Start Upload Activity By Time
activityGraph("ctime", $CONFIG['TABLE_PICTURES'], "Upload Activity By Time", "images/siteLayout/Contentpanel_Sidebar_05.gif");
//End Upload Activity By Time

//Start Comment Activity By Time
activityGraph("msg_date", $CONFIG['TABLE_COMMENTS'], "Comment Posting By Time", "images/siteLayout/Contentpanel_Sidebar_05.gif", true);
//End Comment Activity By Time

//Start Vote Activity By Time
//check to make sure votes table exists
if(isset($CONFIG['TABLE_VOTES']))
{
activityGraph("vote_time", $CONFIG['TABLE_VOTES'], "Voting Activity By Time", "images/siteLayout/Contentpanel_Sidebar_05.gif");
}
//End Vote Activity By Time

//Start Viewing Activity By Time
//check to make sure hit_stats table exists
if(isset($CONFIG['TABLE_HIT_STATS']))
{
activityGraph("sdate", $CONFIG['TABLE_HIT_STATS'], "Viewing Activity By Time", "images/siteLayout/Contentpanel_Sidebar_05.gif");
}
//End Viewing Activity By Time

First let me explain the function activityGraph($cellName, $tableName, $title, $barTile, $notCtime=false).

First argument is the coloum to select from, the second argument is the name of the table to select from, the third argument is the title of the graph e.g. "Upload Activity by Time", the fourth argument defines the location of the image to use for the bars, and the last argument is optional.  When the last argument is set to true the function assumes that the data for date and time is in the MM/DD/YY HH:MM:SS format.

To change the image displayed change the values for the four function calls above to an image of your choosing.

EX:
Code: [Select]
activityGraph("exRow", $config['EXAMPLE_TABLE'], "Title of Graph", "images/myImage.jpg");

Attached to this post is an image you can use for the bars, just upload it to somewhere like images/tile.gif
« Last Edit: November 27, 2005, 06:57:49 am by pslawinski »
Logged

claude258

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 150
    • Album photos Brière
Re: MOD: Detailed Gallery Statistics
« Reply #16 on: November 27, 2005, 03:11:48 pm »

Is it possible that custom thumbnails are not displayed?

Did you install a mod for custom thumbnails?  If so then it will likely not work with that.

My custom thumbnails are made manualy as describe in the Coppermine doc. Is there a mod for custom thumb?

Claude
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #17 on: November 27, 2005, 05:27:55 pm »

My custom thumbnails are made manualy as describe in the Coppermine doc. Is there a mod for custom thumb?

I'm in the process of rewriting this whole script.  All the thumbs will be generated by coppermine defined functions.  I will make several meta albums availible in the process.  I've completed work on one check it out here.
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #18 on: November 28, 2005, 08:41:40 am »

Rewritten script:

1.4.x Version if you want the 1.3.x version see Replay #22:

Update 11/30: Made a few minor changes to improve appearance.

Let me know if you encounter any problems.

Demo here

theme.php
Add:
Code: [Select]
$template_sub_menu = <<<EOT
          {BUTTONS}$template_sys_menu_spacer
  <a href="galleryStats.php">Gallery Statistics<font color="#FF0000">(NEW)</font></a>
EOT;


include/functions.inc.php
Find:
Code: [Select]
function build_caption(&$rowset,$must_have=array())

Replace With:
Code: [Select]
function build_caption(&$rowset,$must_have=array(), $custInfo=array(), $indexType='')

Find:
Code: [Select]
        $rowset[$key]['caption_text'] = $caption;

Replace with:
Code: [Select]
if($custInfo != '')
{
switch($indexType)
{
case 'usrcom':
$index = $row['owner_id'];
$caption .= "<span class=\"thumb_num_comments\">".sprintf($lang_get_pic_data['n_comments'], $custInfo[$index]);
$caption .='</span>';
break;

case 'usrvot':
$index = $row['owner_id'];
$caption .= "<span class=\"thumb_caption\">".sprintf($lang_get_pic_data['n_votes'], $custInfo[$index]);
$caption .='</span>';
break;

case 'usrvie':
$index = $row['owner_id'];
$caption .= "<span class=\"thumb_title\">".sprintf($lang_get_pic_data['n_views'], $custInfo[$index]);
$caption .='</span>';
break;

case 'albcom':
$index = $row['aid'];
$caption .= "<span class=\"thumb_num_comments\">".sprintf($lang_get_pic_data['n_comments'], $custInfo[$index]);
$caption .='</span>';
break;

case 'albvot':
$index = $row['aid'];
$caption .= "<span class=\"thumb_caption\">".sprintf($lang_get_pic_data['n_votes'], $custInfo[$index]);
$caption .='</span>';
break;

case 'albvie':
$index = $row['aid'];
$caption .= "<span class=\"thumb_title\">".sprintf($lang_get_pic_data['n_views'], $custInfo[$index]);
$caption .='</span>';
break;
}

}

        $rowset[$key]['caption_text'] = $caption;


Find:
Code: [Select]
default : // Invalid meta album

Replace with
Code: [Select]

        case 'mostcom': //Most Commented Images

$album_name = "Most Commented Images";

$query = "SELECT pid FROM {$CONFIG['TABLE_COMMENTS']}";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);

foreach($rowset as $row)
{
$index = $row[0];
$mostCommented[$index] = @$mostCommented[$index] + 1;
}

$count = count($mostCommented);

arsort($mostCommented, SORT_NUMERIC);
foreach(array_slice(array_keys($mostCommented),$limit1,$limit2) as $image)
{
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} as p WHERE p.pid = '$image' ";
$result = cpg_db_query($query);
$rowsets[] = cpg_db_fetch_rowset($result);
mysql_free_result($result);
}

$rowset = array();
foreach($rowsets as $row)
{
$rowset[] = $row[0];
}

$preVal = $CONFIG['display_comment_count'];
$CONFIG['display_comment_count'] = 1;
                if ($set_caption) build_caption($rowset,array('ctime'));
$CONFIG['display_comment_count'] = $preVal;

                return $rowset;
                break;

        case 'mostvot': // Most Voted on Images

$album_name = "Most Voted on Images";

$query = "SELECT pid, votes FROM {$CONFIG['TABLE_PICTURES']}";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);

foreach($rowset as $row)
{
if($row[1] != 0) $mostVoted[$row[0]] = $row[1];
}

$count = count($mostVoted);

arsort($mostVoted, SORT_NUMERIC);
foreach(array_slice(array_keys($mostVoted),$limit1,$limit2) as $image)
{
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} as p WHERE p.pid = '$image' ";
$result = cpg_db_query($query);
$rowsets[] = cpg_db_fetch_rowset($result);
mysql_free_result($result);
}

$rowset = array();
foreach($rowsets as $row)
{
$rowset[] = $row[0];
}

                if ($set_caption) build_caption($rowset,array('ctime', 'pic_rating'));

                return $rowset;
                break;

        case 'mostcomusr': // Most Commented Users

$album_name = "Most Commented Users";

$query = "SELECT owner_id FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE c.pid = p.pid";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);

foreach($rowset as $row)
{
$mostCommentedUser[$row[0]] = @$mostCommentedUser[$row[0]] + 1;
}

$count = count($mostCommentedUser);

arsort($mostCommentedUser, SORT_NUMERIC);
foreach(array_slice(array_keys($mostCommentedUser),$limit1,$limit2) as $user)
{
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} as p WHERE p.owner_id = '$user' ";
$result = cpg_db_query($query);
$rowsets[] = cpg_db_fetch_rowset($result);
mysql_free_result($result);
}

$rowset = array();
foreach($rowsets as $row)
{
$rowset[] = $row[0];
}

                if ($set_caption) build_caption($rowset,array(), $mostCommentedUser, 'usrcom');

                return $rowset;
                break;

        case 'mostvotusr': // Most Voted on Users

$album_name = "Most Voted on Users";

$query = "SELECT owner_id, votes FROM {$CONFIG['TABLE_PICTURES']}";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);

foreach($rowset as $row)
{
if($row[1] != 0) $mostVotedUser[$row[0]] = @$mostVotedUser[$row[0]] + $row[1];
}

$count = count($mostVotedUser);

arsort($mostVotedUser, SORT_NUMERIC);
foreach(array_slice(array_keys($mostVotedUser),$limit1,$limit2) as $user)
{
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} as p WHERE p.owner_id = '$user' ";
$result = cpg_db_query($query);
$rowsets[] = cpg_db_fetch_rowset($result);
mysql_free_result($result);
}

$rowset = array();
foreach($rowsets as $row)
{
$rowset[] = $row[0];
}

                if ($set_caption) build_caption($rowset,array(), $mostVotedUser, 'usrvot');

                return $rowset;
                break;

        case 'mostvieusr': // Users With the Most Views

$album_name = "Users With the Most Views";

$query = "SELECT owner_id, hits FROM {$CONFIG['TABLE_PICTURES']}";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);

foreach($rowset as $row)
{
if($row[1] != 0) $mostViewedUser[$row[0]] = @$mostViewedUser[$row[0]] + $row[1];
}

$count = count($mostViewedUser);

arsort($mostViewedUser, SORT_NUMERIC);
foreach(array_slice(array_keys($mostViewedUser),$limit1,$limit2) as $user)
{
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} as p WHERE p.owner_id = '$user' ";
$result = cpg_db_query($query);
$rowsets[] = cpg_db_fetch_rowset($result);
mysql_free_result($result);
}

$rowset = array();
foreach($rowsets as $row)
{
$rowset[] = $row[0];
}

                if ($set_caption) build_caption($rowset,array(), $mostViewedUser, 'usrvie');

                return $rowset;
                break;

        case 'topcom': // Top Commenters

$album_name = "Top Commenters";

$query = "SELECT author_id FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE c.pid = p.pid";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);

foreach($rowset as $row)
{
$mostCommentingUser[$row[0]] = @$mostCommentingUser[$row[0]] + 1;
}

$count = count($mostCommentingUser);

arsort($mostCommentingUser, SORT_NUMERIC);
foreach(array_slice(array_keys($mostCommentingUser),$limit1,$limit2) as $user)
{
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} as p WHERE p.owner_id = '$user' ";
$result = cpg_db_query($query);
$rowsets[] = cpg_db_fetch_rowset($result);
mysql_free_result($result);
}

$rowset = array();
foreach($rowsets as $row)
{
if($row[0] != NULL) $rowset[] = $row[0];
}

                if ($set_caption) build_caption($rowset,array(), $mostCommentingUser, 'usrcom');


                return $rowset;
                break;

        case 'mostcomalb': // Most Commented Album

$album_name = "Most Commented Album";

$query = "SELECT aid FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE c.pid = p.pid";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);

foreach($rowset as $row)
{
$mostCommentedAlbum[$row[0]] = @$mostCommentedAlbum[$row[0]] + 1;
}

$count = count($mostCommentedAlbum);

arsort($mostCommentedAlbum, SORT_NUMERIC);
foreach(array_slice(array_keys($mostCommentedAlbum),$limit1,$limit2) as $album)
{
$query = "SELECT *,a.title AS title FROM {$CONFIG['TABLE_PICTURES']} as p, {$CONFIG['TABLE_ALBUMS']} as a WHERE p.aid = '$album' AND a.aid = '$album' ";
$result = cpg_db_query($query);
$rowsets[] = cpg_db_fetch_rowset($result);
mysql_free_result($result);
}

$rowset = array();
foreach($rowsets as $row)
{
if($row[0] != NULL) $rowset[] = $row[0];
}

                if ($set_caption) build_caption($rowset,array(), $mostCommentedAlbum, 'albcom');


                return $rowset;
                break;

        case 'mostvotalb': // Most Voted on Album

$album_name = "Most Voted on Album";

$query = "SELECT aid, votes FROM {$CONFIG['TABLE_PICTURES']}";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);

foreach($rowset as $row)
{
if($row[1] != 0) $mostVotedAlbum[$row[0]] = @$mostVotedAlbum[$row[0]] + $row[1];
}

$count = count($mostVotedAlbum);

arsort($mostVotedAlbum, SORT_NUMERIC);
foreach(array_slice(array_keys($mostVotedAlbum),$limit1,$limit2) as $album)
{
$query = "SELECT *,a.title AS title FROM {$CONFIG['TABLE_PICTURES']} as p, {$CONFIG['TABLE_ALBUMS']} as a WHERE p.aid = '$album' AND a.aid = '$album' ";
$result = cpg_db_query($query);
$rowsets[] = cpg_db_fetch_rowset($result);
mysql_free_result($result);
}

$rowset = array();
foreach($rowsets as $row)
{
if($row[0] != NULL) $rowset[] = $row[0];
}

                if ($set_caption) build_caption($rowset,array(), $mostVotedAlbum, 'albvot');


                return $rowset;
                break;

        case 'mostviealb': // Most Viewed Album

$album_name = "Most Viewed Album";

$query = "SELECT aid, hits FROM {$CONFIG['TABLE_PICTURES']}";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);

foreach($rowset as $row)
{
if($row[1] != 0) $mostViewedAlbum[$row[0]] = @$mostViewedAlbum[$row[0]] + $row[1];
}

$count = count($mostViewedAlbum);

arsort($mostViewedAlbum, SORT_NUMERIC);
foreach(array_slice(array_keys($mostViewedAlbum),$limit1,$limit2) as $album)
{
$query = "SELECT *,a.title AS title FROM {$CONFIG['TABLE_PICTURES']} as p, {$CONFIG['TABLE_ALBUMS']} as a WHERE p.aid = '$album' AND a.aid = '$album' ";
$result = cpg_db_query($query);
$rowsets[] = cpg_db_fetch_rowset($result);
mysql_free_result($result);
}

$rowset = array();
foreach($rowsets as $row)
{
if($row[0] != NULL) $rowset[] = $row[0];
}

                if ($set_caption) build_caption($rowset,array(), $mostViewedAlbum, 'albvie');


                return $rowset;
                break;

        default : // Invalid meta album



Create:
galleryStats.php
Code: [Select]
<?php

define
('IN_COPPERMINE'true);

require(
'include/init.inc.php');
pageheader("Gallery Statistics");

//Activity Graph Function
function activityGraph($cellName$tableName$title$barTile$notCtime=false)
{
global $CONFIG;
starttable("100%"$title25);
$query "SELECT $cellName FROM $tableName";
$result cpg_db_query($query);
$rowset cpg_db_fetch_rowset($result);
mysql_free_result($result);
$uploadTimes = array();
$total 0;
foreach($rowset as $row)
{
if($notCtime)
{
//Get hours from date/time string
$split1 explode(' '$row[0]);
$split2 explode(':'$split1[1]);
$hour $split2[0];
}
else
{
$hour strftime("%H",$row[0]);
}
switch($hour)
{
case '00':
$index 0;
break;
case '01':
$index 1;
break;
case '02':
$index 2;
break;
case '03':
$index 3;
break;
case '04':
$index 4;
break;
case '05':
$index 5;
break;
case '06':
$index 6;
break;
case '07':
$index 7;
break;
case '08':
$index 8;
break;
case '09':
$index 9;
break;
default:
$index $hour;
}
$uploadTimes[$index] = @$uploadTimes[$index] + 1;
$total++;
}

ksort($uploadTimesSORT_NUMERIC);

print('<tr><td align="center" colspan="26"><b>Time of Day (GMT'.$CONFIG['time_offset'].')</b></td></tr>');
print('<tr><td align="center" colspan="26" height="2"></td></tr>');
print('<tr><td align="center" colspan="26" height="2" bgcolor="#000000"></td></tr>');
print('<tr><td align="center" colspan="26" height="1"></td></tr>');
print('<tr><td height="100" width="1" valign="bottom"><img src="images/spacer.gif" width="1" height="200" /></td>');
for($i '0'$i <= '23'$i++)
{
if(isset($uploadTimes[$i]))
{
print('<td height="100" width="4%" valign="bottom" align="center" style="font-size: 80%">'.round($uploadTimes[$i]/$total*'100',0).'%<br /><img src="'.$barTile.'" border="1" alt="" width="15" height="'.round($uploadTimes[$i]/$total*'200',0).'" /></td>');
}
else
{
print('<td height="100" width="4%"></td>');
}
}
print('<td height="100" width="1" valign="bottom"><img src="images/spacer.gif" width="1" height="200" /></td></tr>');
print('<tr><td align="center" colspan="26" height="1"></td></tr>');
print('<tr><td align="center" colspan="26" height="2" bgcolor="#000000"></td></tr>');
print('<tr><td align="center" colspan="26" height="1"></td></tr>');
print('<tr><td></td>');
for($i '0'$i <= '23'$i++)
{
print('<td width="4%" align="center">'.$i.'</td>');
}
print('<td></td></tr>');

endtable();
print('<img src="images/spacer.gif" alt="" height="17 width="1" />');
}


//Start Most Commented
display_thumbnails('mostcom'$cat1$CONFIG['thumbcols'], 1false);
//End Most Commented

//Start Most Voted
display_thumbnails('mostvot'$cat1$CONFIG['thumbcols'], 1false);
//End Most Voted

//Start Most Viewed
display_thumbnails('topn'$cat1$CONFIG['thumbcols'], 1false);
//End Most Viewed

//Start User Most Commented
display_thumbnails('mostcomusr'$cat1$CONFIG['thumbcols'], 1false);
//End User Most Commented

//Start User Most Voted
display_thumbnails('mostvotusr'$cat1$CONFIG['thumbcols'], 1false);
//End User Most Voted

//Start User Most Viewed
display_thumbnails('mostvieusr'$cat1$CONFIG['thumbcols'], 1false);
//End User Most Viewed

//Start User Most Commenting
display_thumbnails('topcom'$cat1$CONFIG['thumbcols'], 1false);
//End User Most Commenting

//Start Album Most Commented
display_thumbnails('mostcomalb'$cat1$CONFIG['thumbcols'], 1false);
//End Album Most Commented

//Start Album Most Voted
display_thumbnails('mostvotalb'$cat1$CONFIG['thumbcols'], 1false);
//End Album Most Voted


//Start Album Most Viewed
display_thumbnails('mostviealb'$cat1$CONFIG['thumbcols'], 1false);
//End Album Most Viewed

//Start Upload Activity By Time
activityGraph("ctime"$CONFIG['TABLE_PICTURES'], "Upload Activity By Time""images/siteLayout/Contentpanel_Sidebar_05.gif");
//End Upload Activity By Time

//Start Comment Activity By Time
activityGraph("msg_date"$CONFIG['TABLE_COMMENTS'], "Comment Posting By Time""images/siteLayout/Contentpanel_Sidebar_05.gif"true);
//End Comment Activity By Time

//Start Vote Activity By Time
activityGraph("vote_time"$CONFIG['TABLE_VOTES'], "Voting Activity By Time""images/siteLayout/Contentpanel_Sidebar_05.gif");
//End Vote Activity By Time

//Start Viewing Activity By Time
//check to make sure hit_stats table exists
if(isset($CONFIG['TABLE_HIT_STATS']))
{
activityGraph("sdate"$CONFIG['TABLE_HIT_STATS'], "Viewing Activity By Time""images/siteLayout/Contentpanel_Sidebar_05.gif");
}
//End Viewing Activity By Time


pagefooter();

$signature 'Coppermine Photo Gallery ' COPPERMINE_VERSION ' ('COPPERMINE_VERSION_STATUS ')';

?>


« Last Edit: July 05, 2006, 11:02:23 pm by pslawinski »
Logged

pslawinski

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 48
    • Lighting-Gallery.net
Re: MOD: Detailed Gallery Statistics
« Reply #19 on: November 28, 2005, 06:07:46 pm »

You can add the following code in addition to the code in the last post to make the albums used on the galleryStats.php page availible on the front page.  You add them to the front page the same way you would any other meta album ex: topn,2/mostcom,2/mostvot,2

index.php
Find:
Code: [Select]
                    case 'anycontent':


Replace With:
Code: [Select]

                    case 'mostcom':
                        display_thumbnails('mostcom', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'mostvot':
                        display_thumbnails('mostvot', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'mostcomusr':
                        display_thumbnails('mostcomusr', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'mostvotusr':
                        display_thumbnails('mostvotusr', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'mostvieusr':
                        display_thumbnails('mostvieusr', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'topcom':
                        display_thumbnails('topcom', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'mostcomalb':
                        display_thumbnails('mostcomalb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'mostvotalb':
                        display_thumbnails('mostvotalb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'mostviealb':
                        display_thumbnails('mostviealb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
                        flush();
                        break;

                    case 'anycontent':


You can also add links in your gallery sub menu to the albums.
Code: [Select]
<a href="/thumbnails.php?album=exampleAlbum">Example Link</a>
Logged
Pages: [1] 2 3 4 5   Go Up
 

Page created in 0.053 seconds with 27 queries.