[Solved]: how may i show coppermine stats on the phpBB login page? [Solved]: how may i show coppermine stats on the phpBB login page?
 

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

[Solved]: how may i show coppermine stats on the phpBB login page?

Started by blueboy, May 07, 2004, 05:28:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blueboy

dear guru,

I have installed coppermine and phpBB and they seem to be working together, more or less perfectly. I have replaced the phpBB login page with a custom version and included the statistics that normally appear on the index page. These stats relate to registered users and board postings etc. What I also want to do is include coppermine stats in the same HTML table, so all the stats are shown together.

I tried a dirty hack that brought the system down and so hope that someone may be able to direct me, and hopefully not ask me to redirect to the coppermine login page since I already use variable calls that are particular to phpBB (such as hidden fields, login and register values etc.)

I should add that I need to present the stats separately, and not to concatenate them within one string such as:
"19 files in 1 albums and 3 categories with 0 comments viewed 29 times"
In other words, I need to include variables for each of those values, which will be placed within their own table cell.


Look forward to hearing from you.

Many thanks.
Richard


Joachim Müller

I'm not sure what your question actually is, but I guess you just want to know what queries to run.
I guess you have already established a connection to the cpg database, so I'll just paste some code snippets in that are used in ssi.php to create stats:
function cpg_total_albums()
{
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
 $query = "SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE 1";
 $result = mysql_query($query);
 $nbEnr = mysql_fetch_array($result);
 $album_count = $nbEnr[0];
 mysql_free_result($result);
 return number_format($album_count,0,$cpg_decimal_point,$cpg_thousands_separator);
}

function cpg_total_comments()
{
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
 $query = "SELECT count(*) FROM {$CONFIG['TABLE_COMMENTS']} WHERE 1";
 $result = mysql_query($query);
 $nbEnr = mysql_fetch_array($result);
 $comments_count = $nbEnr[0];
 mysql_free_result($result);
 return number_format($comments_count,0,$cpg_decimal_point,$cpg_thousands_separator);
}

function cpg_total_cats()
{
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
 $query = "SELECT count(*) FROM {$CONFIG['TABLE_CATEGORIES']} WHERE 1";
 $result = mysql_query($query);
 $nbEnr = mysql_fetch_array($result);
 $cats_count = $nbEnr[0];
 mysql_free_result($result);
 return number_format($cats_count,0,$cpg_decimal_point,$cpg_thousands_separator);
}

function cpg_stats()
{
GLOBAL $CONFIG;
$result=mysql_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$album_count = $nbEnr[0];
mysql_free_result($result);

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

$result=mysql_query("SELECT count(*) FROM {$CONFIG['TABLE_COMMENTS']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$comment_count = $nbEnr[0];
mysql_free_result($result);

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

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


print $picture_count.", ".$album_count.", ".$cat_count.", ".$comment_count.", ".$hit_count;
}


GauGau

blueboy

Thanks GauGau,

Just to elaborate on the queston, which is largely based on ignorance. Both phpBB and CPG databases are maintained within the same server, but they are given different instances. My question is how do I connect and query the CPG instance once I am on the homepage, which is already set up to connect to the phpBB instance. The CONFIG parameters within the CPG code you pasted would, I assume, draw on phpBB variables - or fail if I did not include or specify which configuration I am relating to. So, my question would be, based on the code you gave me: if I include this code on my homepage how do I declare the config and variables necessary for it to work - and retreive CPG statistics?

I hope this is clearer.
Many thanks for your help.

Richard

Joachim Müller


blueboy

many thanks GauGau, that seems to be what I was looking for.
Richard