forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Statistics => Topic started by: Bruz on March 01, 2004, 11:24:45 am

Title: [Done] statistics as an image - have a look
Post by: Bruz on March 01, 2004, 11:24:45 am
It's hard for me do describe in the topic what this mod is exactly about - just have a look!

Hi!

I had the idea to crate an image which contains the statistics of my coppermine-album.
The really best thing would be, I've thought, if it's possible to show on the very left a random picture and right beside it some informations about my album:
[list=1]The album name
total pictures
total comments
total viewed[/list:o]
Title: [Done] statistics as an image - have a look
Post by: Bruz on March 01, 2004, 11:57:39 am
I've thought of ssi.php and used it - thanks to the developer!


And thats what it finally looks like:
----
(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fwww.kingbruz.de%2FFotos%2Fsignatur_cpg.php&hash=b7bf1fbae41c2d8c534416d10d32fe51619697d7)
----

EDIT:
If anybody is interested in this mod, please tell me. I've rewritten it completely as you see above - now it creates even a full-color-image!
Title: [Done] statistics as an image - have a look
Post by: sourabh on March 02, 2004, 02:31:30 am
I am interested :)
Title: [Done] statistics as an image - have a look
Post by: Bruz on March 02, 2004, 07:04:35 am
And here's the mod:                        [last updated: 07.03.2004]

First, get you a copy of the ssi.php which is contained in this file:
http://prdownloads.sourceforge.net/coppermine/cpg1.1mod_ssi.zip?download

Rename the ssi.php to signature_cgp.php and store it in your coppermine-root-dir.

Open signature_cpg.php

find:
Code: [Select]
/////////////////// edit the following lines //////////////////////////////

edit the following lines to match your album / your language (you don't really need to fill in your language, it's not needet for this mod)

find
Code: [Select]
print <<<EOT
till
Code: [Select]
EOT;
(lines 34-40)
and delete it.

find
Code: [Select]
$return_value.= "<img src=\"".$url_of_cpg_dir.$cpg_album_path.$row['filepath'].$cpg_thumb_pfx.$row['filename']."\" border=\"0\" alt=\"\" title=\"";

replace with
Code: [Select]
$return_value.= "".$url_of_cpg_dir.$cpg_album_path.$row[rawurlencode('filepath')].rawurlencode($cpg_thumb_pfx.$row['filename']);

delete the following 8 Lines ("if ($row['title']!="")" till "$return_value.=$td_end."\n";")

find
Code: [Select]
function cpg_random()
{
return cpg_thumb(1,1,1,"",1);
}


after, add
Code: [Select]
function random_picture()
{
return cpg_thumb(0,0,1,"",1);
}


find
Code: [Select]
//function taken from functions.inc.php
function db_connect()
{
        global $CONFIG;
        $result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
        if (!$result)
                return false;
        if (!mysql_select_db($CONFIG['dbname']))
                return false;
        return $result;
}


after, add
Code: [Select]
$total_pics = cpg_total_pics("");
$total_albums = cpg_total_albums();
$total_comments = cpg_total_comments();
$total_views = cpg_total_views("");
$random_picture = random_picture();

$im = ImageCreateTrueColor (375, 75);
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$farbe_text = ImageColorAllocate ($im, 0, 0, 132);
$farbe_online = ImageColorAllocate ($im, 255, 0, 0);
$tc = ImageColorAllocate ($im, 3, 5, 17);
ImageFilledRectangle ($im, 0, 0, 375, 75 ,$bgc);
ImageString($im, 3, 105, 7, "Statistics of [your album-name here]", $farbe_text);
ImageString($im, 2, 105, 20, "$total_pics Pictures", $tc);
ImageString($im, 2, 105, 30, "$total_albums Albums", $tc);
ImageString($im, 2, 105, 40, "$total_comments Comments", $tc);
ImageString($im, 2, 105, 50, "viewed $total_views times", $tc);

imagecolortransparent($im, $bgc);

$background = $im ;
$insert = imagecreatefromjpeg($random_picture);

imagecolortransparent($insert, imagecolorexact($insert,255,0,255));

$insert_x = imagesx($insert);
$insert_y = imagesy($insert);

imagecopymerge($background,$insert,0,0,0,0,$insert_x,$insert_y,100);

header("Content-Type: image/png");
imagepng($background,"",100);
ImageDestroy ($im);


save the file.

Now you can add the statistic-image with
Code: [Select]
[img]http://yourdomain/your-path-to-coppermine/signature_cpg.php[/img]
or with the HTML equivalents.

You're done!
Title: [Done] statistics as an image - have a look
Post by: MaThIbUs on March 03, 2004, 02:20:23 pm
Looks cool. Is there a way to change the font?
Title: [Done] statistics as an image - have a look
Post by: Nibbler on March 03, 2004, 02:43:10 pm
Font is the second parameter to the ImageString function. You can use 1 to 5 to select from the built-in fonts.
Title: What does your image looks like?
Post by: Bruz on March 06, 2004, 06:13:57 pm
THX for your answer, Nibbler!

I'm interested in what your statistics-image looks like - would be nice, if every user who is unsing this hack could post his image!
Title: [Done] statistics as an image - have a look
Post by: thoth on March 06, 2004, 07:14:10 pm
wish i could show it to you, but unfortunately there's a problem:

http://fotografie.meewezen.nl:8080/coppermine/signature_cgp.php

running W2k3, apache. there also seems to be a problem with this line:

Quote
$return_value.= "".$url_of_cpg_dir.$cpg_album_path.$row['filepath'].rawurlencode($cpg_thumb_pfx.$row['filename']);


which i could not find in the downloaded ssi.php  :(  (other version?)
i deleted the 8 lines following a line that was similar.

please help, b/c i would love to use this hack.
Title: [Done] statistics as an image - have a look
Post by: Bruz on March 06, 2004, 08:31:27 pm
I'm sorry - you're right!

Instead, look for
Code: [Select]
$return_value.= "<img src=\"".$url_of_cpg_dir.$cpg_album_path.$row['filepath'].$cpg_thumb_pfx.$row['filename']."\" border=\"0\" alt=\"\" title=\"";

and replace with:
Code: [Select]
$return_value.= "".$url_of_cpg_dir.$cpg_album_path.$row['filepath'].rawurlencode($cpg_thumb_pfx.$row['filename']);
and delete the following 8 lines - this lines are:
Code: [Select]
if ($row['title']!="") {$return_value.= $row['title']." ";}
if ($row['caption']!="") {$return_value.= $row['caption']." ";}
if ($row['keywords']!="") {$return_value.= $cpg_lang_keywords . ": " . $row['keywords']." ";}
if ($row['hits']!="") {$return_value.= $row['hits']." ".$cpg_lang_views." ";}
if($cpg_random=="1")  {$return_value.= $cpg_lang_random;}
$return_value.= "\" align=\"left\" class=\"padright\">";
if ($cpg_include_link==1){$return_value.="</a>";}
$return_value.=$td_end."\n";


I have corrected the line in my post above - thanks thoth!
Title: [Done] statistics as an image - have a look
Post by: thoth on March 06, 2004, 10:59:09 pm
thanks Bruz this is great!!

(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Ffotos.meewezen.nl%2Fsignature_cpg.php&hash=63e6ebfc554c8ae1f3c1404734b2f72ace5502b9)
Title: [Done] statistics as an image - have a look
Post by: Bruz on March 13, 2004, 03:43:45 pm
I've done some researches on it, but without succsess..
I'd like to have the background of the image transparent, but the commands seems not to work correctly with 'ImageCreateTrueColor'

Anybody able to fix this?
Title: [Done] statistics as an image - have a look
Post by: christian on March 19, 2004, 08:55:23 pm
Quote from: "Bruz"
Now you can add the statistic-image with
Code: [Select]
http://yourdomain/your-path-to-coppermine/signature_cpg.php or with the HTML equivalents.


What is the equivalent HTML code? I have tried different versions without any result. Please help - I would like to implement this genious mod on our site  8)

Thanks,
Christian
Title: [Done] statistics as an image - have a look
Post by: Rodinou on March 19, 2004, 11:29:17 pm
Test :)

(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fwww.sortons.net%2Fphotos%2Fsignature_cpg.php&hash=427c5b535b6d24869e9e7060ba1a833f6e6933b2)


Ok ... don't work for me : what a pity :)
Title: Found a solution
Post by: christian on March 19, 2004, 11:38:10 pm
I did find a solution:  
Code: [Select]
<img src="http://www.site.url/path/file.php">

Thanks again, Christian
Title: [Done] statistics as an image - have a look
Post by: turtleboy on April 06, 2004, 03:10:54 am
(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fskylinedesigns.net%2Ffoto%2Ffoto-gallery%2Fsignature_cgp.php&hash=644acf5d744e8e1211fd72aa4f8ac788b2f799ae)

uhh.. I kinda got it to work.. what am I doing wrong?
Title: [Done] statistics as an image - have a look
Post by: Joachim Müller on April 06, 2004, 08:32:24 am
hard to say without a link and your actual code... :(

GauGau
Title: [Done] statistics as an image - have a look
Post by: Frank on April 06, 2004, 04:56:31 pm
Could you post the full source, with modifications done in the ssi file? It would be helpful for everyone, instead of having to modify ssi.php ourselves.

Thanks, Frank
Title: [Done] statistics as an image - have a look
Post by: Bruz on April 09, 2004, 02:21:18 pm
Quote from: "Frank"
Could you post the full source, with modifications done in the ssi file? It would be helpful for everyone, instead of having to modify ssi.php ourselves.

Thanks, Frank


Sure, but you have to do some modifications - or it will show the stats of my gallery ;)
So, change the lines after
Code: [Select]
/////////////////// edit the following lines ////////////////////////////// to match your settings!

@ php-coders: I think it is possible to delete some stuff out of the orginal ssi.php - this would make the file smaller.

You will need to put this code in a new file called 'signatur.php' (or something else) and put it in your coppermine-root-dir.

Code: [Select]

<?php
// ------------------------------------------------------------------------- //
//  include script for CPG &#40;c&#41; 2003 GauGau &#40;mail@gaugau.de&#41; V1.4             //
//  http&#58;//gaugau.de/   changed by Bruz                                                     //
// ------------------------------------------------------------------------- //
//  Coppermine Photo Gallery v1.1                                     //
// ------------------------------------------------------------------------- //
//  Copyright &#40;C&#41; 2002,2003  Gr&eacute;gory DEMAR <gdemar@wanadoo.fr>               //
//  http&#58;//www.chezgreg.net/coppermine/                                      //
// ------------------------------------------------------------------------- //
//  Based on PHPhotoalbum by Henning Stųverud <henning@stoverud.com>         //
//  http&#58;//www.stoverud.com/PHPhotoalbum/                                    //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  &#40;at your option&#41; any later version.                                      //
// ------------------------------------------------------------------------- //

/////////////////// edit the following lines //////////////////////////////
$url_of_cpg_dir='http&#58;//www.yourpath';    // full path to your coppermine gallery &#40;with trailing slash&#41;
$absolute_path_to_coppermine='/yourpath/'// absolute path on your server to coppermine gallery &#40;with trailing slash&#41;
// to find more about absolute paths, check http&#58;//www.php.net/manual/en/function.phpinfo.php and look for 'DOCUMENT_ROOT' in your phpinfo.php
$cpg_decimal_point=","//what character is used to separate decimals in your country, e.g. in Germany ",", in GB "."
$cpg_thousands_separator="."//what character is used to separate thousands in your country, e.g. in Germany ".", in GB & US ",", in France " "
$cpg_lang_pics "Bilder"//translate this
$cpg_lang_views "mal angesehen"//translate this
$cpg_lang_random "Zufallsbild"//translate this
$cpg_lang_keywords "Keywords"//translate this
/////// don't edit below this line unless you know what your're doing /////////

include_once&#40; $absolute_path_to_coppermine.'/include/config.inc.php'&#41;;

// definition taken from init.inc.php
$CONFIG['TABLE_PICTURES'&#93;        = $CONFIG['TABLE_PREFIX'&#93;."pictures";
$CONFIG['TABLE_ALBUMS'&#93;                = $CONFIG['TABLE_PREFIX'&#93;."albums";
$CONFIG['TABLE_COMMENTS'&#93;        = $CONFIG['TABLE_PREFIX'&#93;."comments";
$CONFIG['TABLE_CATEGORIES'&#93;        = $CONFIG['TABLE_PREFIX'&#93;."categories";
$CONFIG['TABLE_CONFIG'&#93;                = $CONFIG['TABLE_PREFIX'&#93;."config";
$CONFIG['TABLE_USERGROUPS'&#93;        = $CONFIG['TABLE_PREFIX'&#93;."usergroups";
$CONFIG['TABLE_VOTES'&#93;                = $CONFIG['TABLE_PREFIX'&#93;."votes";
$CONFIG['TABLE_USERS'&#93;                = $CONFIG['TABLE_PREFIX'&#93;."users";
// Connect to database
db_connect&#40;&#41; || die&#40;"<b>Coppermine critical error</b>&#58;<br />Unable to connect to database !<br /><br />MySQL said&#58; <b>".mysql_error&#40;&#41;."</b>"&#41;;

// get config data
$result mysql_query&#40;"SELECT * from &#123;$CONFIG['TABLE_CONFIG'&#93;&#125; WHERE name='fullpath'"&#41;;
$row mysql_fetch_row&#40;$result&#41;;
$cpg_album_path=$row[1&#93;;
$result mysql_query&#40;"SELECT * from &#123;$CONFIG['TABLE_CONFIG'&#93;&#125; WHERE name='thumb_pfx'"&#41;;
$row mysql_fetch_row&#40;$result&#41;;
$cpg_thumb_pfx=$row['1'&#93;;
$result mysql_query&#40;"SELECT * from &#123;$CONFIG['TABLE_CONFIG'&#93;&#125; WHERE name='thumbcols'"&#41;;
$row mysql_fetch_row&#40;$result&#41;;
$cpg_thumbcols=$row['1'&#93;;


if &#40;$function == 'cpg_thumb' || $function == 'recentTopics' || $function == 'whosOnline' || $function == 'welcome' || $function == 'menubar' || $function == 'logout' || $function == 'login' || $function == 'topBoards' || $function == 'topTopicsViews' || $function == 'topTopicsReplies' || $function == 'latestMember' || $function == 'boardStats'&#41;
&#123;
        
$function&#40;&#41;; // Execute Function
        
exit;
&
#125;

function cpg_thumb&#40;&#41;
&#123;
GLOBAL $CONFIG,$url_of_cpg_dir,$cpg_album_path,$cpg_thumb_pfx,$cpg_thumbcols,$cpg_lang_random,$cpg_lang_views,$cpg_lang_keywords;
$numargs func_num_args&#40;&#41;;
$arg_list func_get_args&#40;&#41;;
if &#40;$numargs > 0&#41; &#123;$cpg_include_link=$arg_list[0&#93;;&#125;
if &#40;$numargs > 1&#41; &#123;$cpg_link_singlepic=$arg_list[1&#93;;&#125;
if &#40;$numargs > 2&#41; &#123;$cpg_how_many=$arg_list[2&#93;;&#125;
if &#40;$numargs > 3&#41; &#123;$cgp_limit_album=$arg_list[3&#93;;&#125;
if &#40;$numargs > 4&#41; &#123;$cpg_random=$arg_list[4&#93;;&#125;
if &#40;$numargs > 5&#41; &#123;$cpg_link_target=$arg_list[5&#93;;&#125;
if &#40;$cpg_link_target==""&#41;&#123;$cpg_link_target="_top";&#125;


//get pic info
$query "SELECT * from &#123;$CONFIG['TABLE_PICTURES'&#93;&#125; WHERE approved='YES' ";
if&
#40;$cgp_limit_album!=""&#41;&#123;$query.="AND aid='".$cgp_limit_album."'";&#125;
$query.=" AND user2!='1' ORDER BY ";
if&
#40;$cpg_random=="1"&#41;&#123;$query.="RAND&#40;&#41;";&#125;else&#123;$query.="ctime";&#125;
$query.=" DESC LIMIT 0,".$cpg_how_many;
$result mysql_query&#40;$query&#41;;
if &#40;$cpg_how_many!=1&#41;
&#123;
$return_value="<table align=\"center\" cellspacing=\"0\" cellpadding=\"10\" align=\"center\" class=\"maintable\" border=\"0\">";
$td_start="<td valign=\"middle\" class=\"thumbnails\" align=\"center\">\n";
$td_end="</td>";
$cpg_table_end="</table>";
$tr_start="<tr>\n";
$tr_end="</tr>\n";
&
#125;
else
&
#123;
$return_value="";
$td_start="";
$td_end="";
$cpg_table_end="";
$tr_start="";
$tr_end="";
&
#125;
$counter=0;
if &
#40;$cpg_thumbcols > $cpg_how_many&#41; &#123;$cpg_thumbcols=$cpg_how_many;&#125;

while &#40;$row = mysql_fetch_array&#40;$result&#41;&#41; &#123;
//------
if &#40;$counter==0&#41;&#123;$return_value.=$tr_start;&#125;
$return_value.=$td_start;
if &
#40;$cpg_include_link==1&#41;
  
&#123;
  
$return_value.= "<a href=\"";
    if &
#40;$cpg_link_singlepic==1&#41;
      
&#123;
       
if &#40;$cpg_link_target=="popup"&#41;
          
&#123;
          
$return_value.="javascript&#58;;\" onClick=\"MM_openBrWindow&#40;'".$url_of_cpg_dir."displayimage.php?pid=".$row['pid'&#93;."&fullsize=1','".uniqid&#40;rand&#40;&#41;&#41;."','toolbar=yes,status=yes,resizable=yes,width=".&#40;$row['pwidth'&#93;+16&#41;.",height=".&#40;$row['pheight'&#93;+16&#41;."'&#41;\"";
          
&#125;
          
else
          &
#123;
          
$return_value.=$url_of_cpg_dir."displayimage.php?&pos=-".$row['pid'&#93;;
          
&#125;
      
&#125;
    
else
      &
#123;
      
$return_value.=$url_of_cpg_dir."thumbnails.php?album=".$row['aid'&#93;;
      
&#125;
  
$return_value.="\" ";

  if&
#40;$cpg_link_target=="popup"&#41;&#123;$return_value.="";&#125;else&#123;$return_value.="target=\"".$cpg_link_target."\"";&#125;
  
$return_value.=">";
  &
#125;
$return_value.= "".$url_of_cpg_dir.$cpg_album_path.$row[rawurlencode&#40;'filepath'&#41;&#93;.rawurlencode&#40;$cpg_thumb_pfx.$row['filename'&#93;&#41;;
//if &#40;$row['title'&#93;!=""&#41; &#123;$return_value.= $row['title'&#93;."&#10;";&#125;
//if &#40;$row['caption'&#93;!=""&#41; &#123;$return_value.= $row['caption'&#93;."&#10;";&#125;
//if &#40;$row['keywords'&#93;!=""&#41; &#123;$return_value.= $cpg_lang_keywords . "&#58; " . $row['keywords'&#93;."&#10;";&#125;
//if &#40;$row['hits'&#93;!=""&#41; &#123;$return_value.= $row['hits'&#93;." ".$cpg_lang_views."&#10;";&#125;
//if&#40;$cpg_random=="1"&#41;  &#123;$return_value.= $cpg_lang_random;&#125;
//$return_value.= "\" align=\"left\" class=\"padright\">";
//if &#40;$cpg_include_link==1&#41;&#123;$return_value.="</a>";&#125;
//$return_value.=$td_end."\n";
$counter++;
if &
#40;$counter==$cpg_thumbcols&#41;&#123;$counter=0;$return_value.=$tr_end;&#125;
&#125;

$return_value.=$cpg_table_end;
return 
$return_value;
&
#125;

function cpg_single&#40;&#41;
&#123;
$numargs func_num_args&#40;&#41;;
$arg_list func_get_args&#40;&#41;;
if &#40;$numargs > 0&#41;&#123;return cpg_thumb&#40;1,1,1,"",0,$arg_list[0&#93;&#41;;&#125;
else&#123;return cpg_thumb&#40;1,1,1,"",0&#41;;&#125;
&#125;

function cpg_total_pics&#40;$cgp_limit_album&#41;
&#123;
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
  
$query "SELECT COUNT&#40;*&#41; from &#123;$CONFIG['TABLE_PICTURES'&#93;&#125; WHERE approved = 'YES'";
  if&
#40;$cgp_limit_album!=""&#41;&#123;$query.=" AND aid='".$cgp_limit_album."'";&#125;
  
$result mysql_query&#40;$query&#41;;
  
$nbEnr mysql_fetch_array&#40;$result&#41;;
  
$pic_count $nbEnr[0&#93;;
  
mysql_free_result&#40;$result&#41;;
  
return number_format&#40;$pic_count,0,$cpg_decimal_point,$cpg_thousands_separator&#41;;
&#125;

function cpg_total_views&#40;$cgp_limit_album&#41;
&#123;
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
  
$query "SELECT sum&#40;hits&#41; FROM &#123;$CONFIG['TABLE_PICTURES'&#93;&#125; WHERE 1";
  if&
#40;$cgp_limit_album!=""&#41;&#123;$query.=" AND aid='".$cgp_limit_album."'";&#125;
  
$result mysql_query&#40;$query&#41;;
  
$nbEnr mysql_fetch_array&#40;$result&#41;;
  
$view_count $nbEnr[0&#93;;
  
mysql_free_result&#40;$result&#41;;
  
return number_format&#40;$view_count,0,$cpg_decimal_point,$cpg_thousands_separator&#41;;
&#125;

function cpg_hit_ratio&#40;$cgp_limit_album&#41;
&#123;
GLOBAL $CONFIG;
//get stats
$result=mysql_query&#40;"SELECT sum&#40;hits&#41; FROM &#123;$CONFIG['TABLE_PICTURES'&#93;&#125; WHERE 1"&#41;;
$nbEnr mysql_fetch_array&#40;$result&#41;;
$hit_count = &#40;int&#41;$nbEnr[0&#93;;
$result=mysql_query&#40;"SELECT count&#40;*&#41; FROM &#123;$CONFIG['TABLE_PICTURES'&#93;&#125; WHERE 1"&#41;;
$nbEnr mysql_fetch_array&#40;$result&#41;;
$picture_count $nbEnr[0&#93;;
$cpg_ratio_string=str_replace&#40;".", ",",&#40;floor&#40;&#40;&#40;str_replace&#40;".", "", cpg_total_views&#40;$cgp_limit_album&#41;&#41;/str_replace&#40;".", "", cpg_total_pics&#40;$cgp_limit_album&#41;&#41;&#41;*10&#41;/&#40;$hit_count/$picture_count&#41;&#41;&#41;/10&#41;;
//$cpg_ratio_string=cpg_total_views&#40;$cgp_limit_album&#41;.'|'.cpg_total_pics&#40;$cgp_limit_album&#41;.'|'.$hit_count.'|'.$picture_count;
return $cpg_ratio_string;


&
#125;

function cpg_stat_string&#40;$cgp_limit_album&#41;
&#123;
GLOBAL $url_of_cpg_dir,$cpg_lang_pics,$cpg_lang_views;
$cpg_stat_string='[<a href="'.$url_of_cpg_dir.'thumbnails.php?album='.$cgp_limit_album.'"><b>';
$cpg_stat_string.=cpg_total_pics&#40;$cgp_limit_album&#41;;
$cpg_stat_string.='</b> ' $cpg_lang_pics '</a>, <a href="'.$url_of_cpg_dir.'thumbnails.php?album=topn&cat=-'.$cgp_limit_album.'"><b>';
$cpg_stat_string.=cpg_total_views&#40;$cgp_limit_album&#41;;
$cpg_stat_string.='</b> ' $cpg_lang_views '</a>';
$cpg_stat_string.=', <span class="tool" title="SF=Spanner-Faktor&#58;&#10;Wie oft sind die Bilder dieses Albums durchschnittlich angeklickt worden, im Vergleich zur gesamten Galerie?">SF&#58; '.cpg_hit_ratio&#40;$cgp_limit_album&#41;.'</span>';
$cpg_stat_string.='&#93;';
return 
$cpg_stat_string;
&
#125;

function cpg_total_albums&#40;&#41;
&#123;
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
  
$query "SELECT count&#40;*&#41; FROM &#123;$CONFIG['TABLE_ALBUMS'&#93;&#125; WHERE 1";
  
$result mysql_query&#40;$query&#41;;
  
$nbEnr mysql_fetch_array&#40;$result&#41;;
  
$album_count $nbEnr[0&#93;;
  
mysql_free_result&#40;$result&#41;;
  
return number_format&#40;$album_count,0,$cpg_decimal_point,$cpg_thousands_separator&#41;;
&#125;

function cpg_total_comments&#40;&#41;
&#123;
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
  
$query "SELECT count&#40;*&#41; FROM &#123;$CONFIG['TABLE_COMMENTS'&#93;&#125; WHERE 1";
  
$result mysql_query&#40;$query&#41;;
  
$nbEnr mysql_fetch_array&#40;$result&#41;;
  
$comments_count $nbEnr[0&#93;;
  
mysql_free_result&#40;$result&#41;;
  
return number_format&#40;$comments_count,0,$cpg_decimal_point,$cpg_thousands_separator&#41;;
&#125;

function cpg_total_cats&#40;&#41;
&#123;
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
  
$query "SELECT count&#40;*&#41; FROM &#123;$CONFIG['TABLE_CATEGORIES'&#93;&#125; WHERE 1";
  
$result mysql_query&#40;$query&#41;;
  
$nbEnr mysql_fetch_array&#40;$result&#41;;
  
$cats_count $nbEnr[0&#93;;
  
mysql_free_result&#40;$result&#41;;
  
return number_format&#40;$cats_count,0,$cpg_decimal_point,$cpg_thousands_separator&#41;;
&#125;


function cpg_random&#40;&#41;
&#123;
return cpg_thumb&#40;1,1,1,"",1&#41;;
&#125;

function random_picture&#40;&#41;
&#123;
return cpg_thumb&#40;0,0,1,"",1&#41;;
&#125;

function cpg_search&#40;$cpg_size,$cpg_question,$cpg_submit_text&#41;
&#123;
GLOBAL $url_of_cpg_dir;
$cpg_search_string "<form method=\"get\" action=\"" $url_of_cpg_dir "thumbnails.php\" name=\"search_cpg\">
<input type=\"hidden\" name=\"album\" value=\"search\" />
<input type=\"hidden\" name=\"type\" value=\"full\" />
<input type=\"input\" name=\"search\" maxlength=\"255\" size=\"" 
$cpg_size "\" value=\"" $cpg_question "\" class=\"textfield\" onfocus=\"this.value=''\" />";
if &
#40;$cpg_submit_text!="" and $cpg_submit_text!="0"&#41;
  
&#123;
  
$cpg_search_string.= " <input type=\"submit\" value=\"" $cpg_submit_text "\" class=\"submit\" />";
  &
#125;
$cpg_search_string.= "</form>";
return 
$cpg_search_string;
&
#125;

function cpg_stats&#40;&#41;
&#123;
GLOBAL $CONFIG;
$result=mysql_query&#40;"SELECT count&#40;*&#41; FROM &#123;$CONFIG['TABLE_ALBUMS'&#93;&#125; WHERE 1"&#41;;
$nbEnr mysql_fetch_array&#40;$result&#41;;
$album_count $nbEnr[0&#93;;
mysql_free_result&#40;$result&#41;;

$result=mysql_query&#40;"SELECT count&#40;*&#41; FROM &#123;$CONFIG['TABLE_PICTURES'&#93;&#125; WHERE 1"&#41;;
$nbEnr mysql_fetch_array&#40;$result&#41;;
$picture_count $nbEnr[0&#93;;
mysql_free_result&#40;$result&#41;;

$result=mysql_query&#40;"SELECT count&#40;*&#41; FROM &#123;$CONFIG['TABLE_COMMENTS'&#93;&#125; WHERE 1"&#41;;
$nbEnr mysql_fetch_array&#40;$result&#41;;
$comment_count $nbEnr[0&#93;;
mysql_free_result&#40;$result&#41;;

$result=mysql_query&#40;"SELECT count&#40;*&#41; FROM &#123;$CONFIG['TABLE_CATEGORIES'&#93;&#125; WHERE 1"&#41;;
$nbEnr mysql_fetch_array&#40;$result&#41;;
$cat_count $nbEnr[0&#93; - $HIDE_USER_CAT;
mysql_free_result&#40;$result&#41;;

$result=mysql_query&#40;"SELECT sum&#40;hits&#41; FROM &#123;$CONFIG['TABLE_PICTURES'&#93;&#125; WHERE 1"&#41;;
$nbEnr mysql_fetch_array&#40;$result&#41;;
$hit_count = &#40;int&#41;$nbEnr[0&#93;;
mysql_free_result&#40;$result&#41;;


print $picture_count.", ".$album_count.", ".$cat_count.", ".$comment_count.", ".$hit_count;
&
#125;


//function taken from functions.inc.php
function db_connect&#40;&#41;
&#123;
        
global $CONFIG;
        
$result = @mysql_connect&#40;$CONFIG['dbserver'&#93;, $CONFIG['dbuser'&#93;, $CONFIG['dbpass'&#93;&#41;;
        
if &#40;!$result&#41;
                
return false;
        if &
#40;!mysql_select_db&#40;$CONFIG['dbname'&#93;&#41;&#41;
                
return false;
        return 
$result;
&
#125;

$total_pics cpg_total_pics&#40;""&#41;;
$total_albums cpg_total_albums&#40;&#41;;
$total_comments cpg_total_comments&#40;&#41;;
$total_views cpg_total_views&#40;""&#41;;
$random_picture random_picture&#40;&#41;;

$im ImageCreateTrueColor &#40;250, 75&#41;;             // Bild $im mit den Abmessungen 250x75 erzeugen 
$bgc ImageColorAllocate &#40;$im, 255, 255, 255&#41;;         // $bgc &#40;Hintergrund&#41; auf "weiß" setzten 
$farbe_text ImageColorAllocate &#40;$im, 0, 0, 132&#41;;         // Textfarbe 
$farbe_online ImageColorAllocate &#40;$im, 255, 0, 0&#41;;     // Textfarbe 
$tc ImageColorAllocate &#40;$im, 3, 5, 17&#41;;             // Textfarbe 
ImageFilledRectangle &#40;$im, 0, 0, 250, 75 ,$bgc&#41;;         // Bild $im mit der Hintergrundfarbe füllen 
ImageString&#40;$im, 3, 105, 7, "Daniel's Fotos", $farbe_text&#41;;     // Ausgabe von Text im Bild $im 
ImageString&#40;$im, 2, 105, 20, "$total_pics Pictures", $tc&#41;;     // Ausgabe von Text im Bild $im 
ImageString&#40;$im, 2, 105, 30, "$total_albums Albums", $tc&#41;;     // Ausgabe von Text im Bild $im 
ImageString&#40;$im, 2, 105, 40, "$total_comments Comments", $tc&#41;;     // Ausgabe von Text im Bild $im 
ImageString&#40;$im, 2, 105, 50, "viewed $total_views times", $tc&#41;;     // Ausgabe von Text im Bild $im 

imagecolortransparent&#40;$im, $bgc&#41;;             // Die Farbe $bgc wird für das Bild $im als transparent gesetzt 

$background $im ;                 // Das Bild $im wird als $background definiert 
$insert imagecreatefromjpeg&#40;$random_picture&#41;;         // Die Variable $random_picture, die eine URL enthält, wird als $insert definiert 


$insert_x imagesx&#40;$insert&#41;; 
$insert_y imagesy&#40;$insert&#41;; 

imagecopymerge&#40;$background,$insert,0,0,0,0,$insert_x,$insert_y,100&#41;; // Die Bilder werden zusammengesetzt 
imagecolortransparent&#40;$insert, $bgc&#41;;                 // Die Farbe $bgc wird für das gesamte Bild als transparent gesetzt 
header&#40;"Content-Type&#58; image/png"&#41;; 
imagepng&#40;$background,"",100&#41;; 
ImageDestroy &#40;$im&#41;; 
?>


Bruz
Title: [Done] statistics as an image - have a look
Post by: turtleboy on April 09, 2004, 10:21:49 pm
Used exact same code you did, but random thumb never comes up with it, although all the stats are correct. Dont know how to fix this.

(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fwww.skylinedesigns.net%2Ffoto%2Ffoto-gallery%2Fsignat.php&hash=dde982adb14e73b4f43536d30099f481afb4250a)

I thought it might be an .htaccess file issue, but it won't work even when viewing it locally, or if i remove the files.
Title: [Done] statistics as an image - have a look
Post by: Bruz on April 12, 2004, 11:52:40 am
Maybe you are using a glib or php version, that doesn't support imagecopymerge...
Title: [Done] statistics as an image - have a look
Post by: luchtzak on April 17, 2004, 02:44:57 pm
Great tool! used it on my front-page on www.luchtzak.be !

I hope it doesn't slow down loading too much...

greetings,

Bart
Title: [Done] statistics as an image - have a look
Post by: futtlui on April 18, 2004, 02:17:29 am
am I right that this one requires GD 2.0 (which I do not have  :cry: ) ???
Is there any chance in getting it done with GD 1.6.2?
Title: [Done] statistics as an image - have a look
Post by: luchtzak on April 18, 2004, 10:41:23 am
How can I change the type of letters into e.g. Verdana ? And what's the code for colour #336699 ? And how can I make the numbers in bold ?

greetings,

Bart
Title: [Done] statistics as an image - have a look
Post by: Joachim Müller on April 18, 2004, 01:27:28 pm
you can't have every font, unless the server is yours to install fonts on. Usually, if you're webhosted, you'll have to go with the fonts that are pre-installed on the server.

GauGau
Title: [Done] statistics as an image - have a look
Post by: photoman13 on April 18, 2004, 04:50:51 pm
if your host has GlyphGate you pretty much got any font at your disposal.

www.glyphgate.com

Maybe ask them or whatever
Title: [Done] statistics as an image - have a look
Post by: Casper on April 18, 2004, 08:08:42 pm
Quote from: "luchtzak"
And what's the code for colour #336699 ?


The RGB code is 51, 102, 153.
The cmyk code is 86, 60, 18, 2.
Title: Re: [Done] statistics as an image - have a look
Post by: aem on April 27, 2004, 01:41:11 pm
I try and edit the code to have the text underneath the pic but it doesnt work.

Anyone have done it?
Title: Re: [Done] statistics as an image - have a look
Post by: Bruz on May 05, 2004, 04:19:11 pm
To have the Text underneath the image you will have

a) to make the background image ($im) bigger (higher to have space under the random-pic)
b) to change the coordinates of the textlines
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 07, 2004, 12:37:43 pm
Okie now i'm stuck with the "coordinate of the textline". Which line is this exactly?

$im = ImageCreateTrueColor (245, 177);
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$farbe_text = ImageColorAllocate ($im, 0, 0, 132);
$farbe_online = ImageColorAllocate ($im, 255, 0, 0);
$tc = ImageColorAllocate ($im, 1, 5, 17);
ImageFilledRectangle ($im, 0, 0, 245, 177,$bgc);
ImageString($im, 3, 135, 10, "Member Gallery", $farbe_text);
ImageString($im, 2, 135, 20, "$total_pics Pictures", $tc);
ImageString($im, 2, 135, 30, "$total_albums Albums", $tc);
ImageString($im, 2, 135, 40, "$total_comments Comments", $tc);
ImageString($im, 2, 135, 50, "viewed $total_views times", $tc);
Title: Re: [Done] statistics as an image - have a look
Post by: Bruz on May 07, 2004, 01:39:46 pm
Okie now i'm stuck with the "coordinate of the textline". Which line is this exactly?

Ok, lets take

Code: [Select]
ImageString($im, 3, 135, 10, "Member Gallery", $farbe_text);
as example.

The first number, the "3" ist the text-style.
The second number, the "135" is the hspace from the left image-border. (Here: the text starts 135 pixles to the right from the left border)
The third number, the "10" is the vspace from the upper image-border. (Here: the text starts 10 pixels under the upper border)

What you'll need to do is to change the coordinates like this:

your random image will be 100 pixels high. So your first textline should start at 10,110 (just try it!) The next should be at 10,120 and so on!
(10,110 means:
Code: [Select]
ImageString($im, 3, 10, 110, "Member Gallery", $farbe_text);
Bruz
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 07, 2004, 02:35:10 pm
Okie that worked.

Also how do i make the thumbnail of the image wider?
Title: Re: [Done] statistics as an image - have a look
Post by: Bruz on May 08, 2004, 11:06:57 am
I think you are talking about the random-image, do you?

Because we are taking a coppermine-generated thumbnail with the with of 100 pixels it would look not very good if this image would be stretched to lets say 200 pixels.

Or did I get you wrong?
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 08, 2004, 01:30:17 pm
Yes you're right, i just double check the config in coppermine and it's optimised at 120. So i cant really make it any bigger without putting it out of focus.  :'( :'(.

Because i wish to have the image larger, i just notice the slide-show photos are abit larger than the random images (as seen when you click on the thumbnail), so now how could i incorporate the slide show photos instead of the thumbnail photos for the statistics random image?
Title: Re: [Done] statistics as an image - have a look
Post by: Bruz on May 09, 2004, 09:50:14 am
Well, you could take the mid-size image - but: how big will your signature be? 400 to 300 Pixels?

Maybe you can post a link, so I can make my a picture of what you are doing?
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 09, 2004, 10:06:45 am
Okie refer to this. (http://www.preludeaustralia.com/forums/index.php?)

Atm, the width of the random inage (in that box) is 120 pixs, the portal box itself has width 189 pixs. What i want to do is incorporate slideshow pics (http://www.gallery04.preludeaustralia.com/displayimage.php?album=lastup&cat=0&pos=2) which has width 169 pixs instead of the random pics. My aim is the take up as much space of the portal box as possible.
Title: Re: [Done] statistics as an image - have a look
Post by: Bruz on May 09, 2004, 11:50:26 am
Ok, I see.

I will change the code for you - but I'm very busy at the moment (school) and so I don't know when I'll be able to do this. (But I think, I'll have time tomorrow)
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 10, 2004, 11:44:13 am
Forever grateful  ;)
Title: Re: [Done] statistics as an image - have a look
Post by: Bizzy on May 16, 2004, 09:04:58 am
I have been looking for almost a week for a MOD to intergade my coppermine,album/pic into my portal page.  Can someone please tell me this is the right place.  Ome  I would like to have exactly what you have on your portal.  "your pic in a block"  is it at all possible if you could send me the code.  I would be forever greatful.
*On my knee's begging*
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 16, 2004, 11:23:55 am
It's just a table frame

Quote
<tr><td>
<table border="8" cellpadding="2" cellspacing="5" align="center">
<td>
<div align="center">[img]http://www.*.com/signature_cgp.php[/img}
</table></td></tr>

} should be ]
Title: Re: [Done] statistics as an image - have a look
Post by: Bizzy on May 16, 2004, 11:36:57 am
Oh no I'm sorry I should have explained myself better.  I need the code to add block and pic onto my ezportal
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 16, 2004, 12:41:41 pm
Are you talking to me or someone else?  :)
Title: Re: [Done] statistics as an image - have a look
Post by: Bizzy on May 16, 2004, 09:55:03 pm
Yes you
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 17, 2004, 12:34:04 am
Still not 100% sure what you mean but here is the changes i've made. Compare it to the original script.

Quote
$im = ImageCreateTrueColor (120, 150);
$bgc = ImageColorAllocate ($im, 223, 230, 239);
$farbe_text = ImageColorAllocate ($im, 0, 0, 132);
$farbe_online = ImageColorAllocate ($im, 255, 0, 0);
$tc = ImageColorAllocate ($im, 1, 5, 17);
ImageFilledRectangle ($im, 0, 0, 120, 150,$bgc);
ImageString($im, 3, 10, 90, "Member Gallery", $farbe_text);
ImageString($im, 2, 10, 100, "$total_pics Pictures", $tc);
ImageString($im, 2, 10, 110, "$total_albums Albums", $tc);
ImageString($im, 2, 10, 120, "$total_comments Comments", $tc);
ImageString($im, 2, 10, 130, "viewed $total_views times", $tc);
Title: Re: [Done] statistics as an image - have a look
Post by: Bizzy on May 17, 2004, 05:03:32 am
You see how you have a pic on your website, you are using a portal right?  Smartor ezPortal  I would also like to have the block with a pic coming from my coppermine album as well.  I was hoping  you could share the code with me, how you did it.  I would like to have 2 pic's horisontal on my Portal.  Help if you can please.
Thank you
Title: Re: [Done] statistics as an image - have a look
Post by: Bizzy on May 17, 2004, 05:08:04 am
You see how you have a pic on your website, you are using a portal right?  Smartor ezPortal  I would also like to have the block with a pic coming from my coppermine album as well.  I was hoping  you could share the code with me, how you did it.  I would like to have 2 pic's horisontal on my Portal.  Help if you can please.
Thank you
No sorry not across going down  the right side of my portal
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 17, 2004, 07:54:05 am
The code/script is made by Bruz. It's on the first page of this thread. Details are all there (4th post down).

The code is for one pic...

Bruz, have you got that amendment for me man? ;)
Title: Re: [Done] statistics as an image - have a look
Post by: Bizzy on May 17, 2004, 09:12:03 am
And how do I place it in a "block"  in my portal page?  I know how to do a "block"  but how I connect signature.php to my portal with block.  hope you understand me.  please forgive me, i'm new to this. :(
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 17, 2004, 10:57:58 am
I was right about not 100% sure about what you're trying to say. ;D

Do u know how to make new portal boxes with your potal? if so just put the table code i gave earlier in the text area of the new box (assumming your portal box allows for htmls) along with your working script.

If you read this thread from the begining you would know that the code/script was made to work with image tags.

If you still have probs, PMe me your portal admin logon (ie IDs and password) and hopefully i can do it for you.
Title: Re: [Done] statistics as an image - have a look
Post by: Bizzy on May 21, 2004, 12:49:25 pm
AEM..........please help!  I have tried installing this album on my portal page. running ezportal "smartor" I have failed miserably over and over.  I have a block with lastest upload, but I did it manually.
Lots of work chaging pic every time my user uploads one.
MY question is AEM......can I give you my info and you config this for me please.  I would like to have a block on my portal.php page with recent pic uploaded.
If you could help it be awsome.
Title: Re: [Done] statistics as an image - have a look
Post by: aem on May 22, 2004, 02:01:32 pm
I can try. At the moment i'm still not sure what you are trying to achieve.

PM me the details (access details) and i see what i can do.
Title: Re: [Done] statistics as an image - have a look
Post by: luchtzak on June 02, 2004, 11:51:31 am
I have a question, one of my members asked me this: http://www.luchtzak.be/modules.php?name=Forums&file=viewtopic&p=41306#41306

is this possible to program something in the signature.php ?
Title: Re: [Done] statistics as an image - have a look
Post by: seros on July 07, 2004, 07:07:43 pm
luchtzak: I got a question, how to add more information on the image? The total user, Last pic, ...?
thanks
Title: Re: [Done] statistics as an image - have a look
Post by: nukeworker on July 08, 2004, 12:49:11 am
The post that included "all of the code edited" had html where some important characters went. here is the correct code:

Code: [Select]
<?
// ------------------------------------------------------------------------- //
//  include script for CPG (c) 2003 GauGau (mail@gaugau.de) V1.4             //
//  http://gaugau.de/                                                        //
// ------------------------------------------------------------------------- //
//  Coppermine Photo Gallery v1.1                                     //
// ------------------------------------------------------------------------- //
//  Copyright (C) 2002,2003  Gr&eacute;gory DEMAR <gdemar@wanadoo.fr>               //
//  http://www.chezgreg.net/coppermine/                                      //
// ------------------------------------------------------------------------- //
//  Based on PHPhotoalbum by Henning Stųverud <henning@stoverud.com>         //
//  http://www.stoverud.com/PHPhotoalbum/                                    //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
// ------------------------------------------------------------------------- //

/////////////////// edit the following lines //////////////////////////////
$url_of_cpg_dir='http://url of your coppermine/';    // full path to your coppermine gallery (with trailing slash)
$absolute_path_to_coppermine='/path to your coppermine/'; // absolute path on your server to coppermine gallery (with trailing

slash)
// to find more about absolute paths, check http://www.php.net/manual/en/function.phpinfo.php and look for 'DOCUMENT_ROOT' in your

phpinfo.php
$cpg_decimal_point="."; //what character is used to separate decimals in your country, e.g. in Germany ",", in GB "."
$cpg_thousands_separator=","; //what character is used to separate thousands in your country, e.g. in Germany ".", in GB & US ",", in France

" "
$cpg_lang_pics = "Pictures"; //translate this
$cpg_lang_views = "view"; //translate this
$cpg_lang_random = "Random pic of this album"; //translate this
$cpg_lang_keywords = "Keywords"; //translate this

/////// don't edit below this line unless you know what your're doing /////////

include_once( $absolute_path_to_coppermine.'/include/config.inc.php');

// definition taken from init.inc.php
$CONFIG['TABLE_PICTURES']        = $CONFIG['TABLE_PREFIX']."pictures";
$CONFIG['TABLE_ALBUMS']                = $CONFIG['TABLE_PREFIX']."albums";
$CONFIG['TABLE_COMMENTS']        = $CONFIG['TABLE_PREFIX']."comments";
$CONFIG['TABLE_CATEGORIES']        = $CONFIG['TABLE_PREFIX']."categories";
$CONFIG['TABLE_CONFIG']                = $CONFIG['TABLE_PREFIX']."config";
$CONFIG['TABLE_USERGROUPS']        = $CONFIG['TABLE_PREFIX']."usergroups";
$CONFIG['TABLE_VOTES']                = $CONFIG['TABLE_PREFIX']."votes";
$CONFIG['TABLE_USERS']                = $CONFIG['TABLE_PREFIX']."users";
// Connect to database
db_connect() || die("<b>Coppermine critical error</b>:<br />Unable to connect to database !<br /><br />MySQL said:

<b>".mysql_error()."</b>");

// get config data
$result = mysql_query("SELECT * from {$CONFIG['TABLE_CONFIG']} WHERE name='fullpath'");
$row = mysql_fetch_row($result);
$cpg_album_path=$row[1];
$result = mysql_query("SELECT * from {$CONFIG['TABLE_CONFIG']} WHERE name='thumb_pfx'");
$row = mysql_fetch_row($result);
$cpg_thumb_pfx=$row['1'];
$result = mysql_query("SELECT * from {$CONFIG['TABLE_CONFIG']} WHERE name='thumbcols'");
$row = mysql_fetch_row($result);
$cpg_thumbcols=$row['1'];


if ($function == 'cpg_thumb' || $function == 'recentTopics' || $function == 'whosOnline' || $function == 'welcome' || $function == 'menubar'

|| $function == 'logout' || $function == 'login' || $function == 'topBoards' || $function == 'topTopicsViews' || $function ==

'topTopicsReplies' || $function == 'latestMember' || $function == 'boardStats')
{
        $function(); // Execute Function
        exit;
}

function cpg_thumb()
{
GLOBAL $CONFIG,$url_of_cpg_dir,$cpg_album_path,$cpg_thumb_pfx,$cpg_thumbcols,$cpg_lang_random,$cpg_lang_views,$cpg_lang_keywords;
$numargs = func_num_args();
$arg_list = func_get_args();
if ($numargs > 0) {$cpg_include_link=$arg_list[0];}
if ($numargs > 1) {$cpg_link_singlepic=$arg_list[1];}
if ($numargs > 2) {$cpg_how_many=$arg_list[2];}
if ($numargs > 3) {$cgp_limit_album=$arg_list[3];}
if ($numargs > 4) {$cpg_random=$arg_list[4];}
if ($numargs > 5) {$cpg_link_target=$arg_list[5];}
if ($cpg_link_target==""){$cpg_link_target="_top";}


//get pic info
$query = "SELECT * from {$CONFIG['TABLE_PICTURES']} WHERE approved='YES' ";
if($cgp_limit_album!=""){$query.="AND aid='".$cgp_limit_album."'";}
$query.=" AND user2!='1' ORDER BY ";
if($cpg_random=="1"){$query.="RAND()";}else{$query.="ctime";}
$query.=" DESC LIMIT 0,".$cpg_how_many;
$result = mysql_query($query);
if ($cpg_how_many!=1)
{
$return_value="<table align=\"center\" cellspacing=\"0\" cellpadding=\"10\" align=\"center\" class=\"maintable\" border=\"0\">";
$td_start="<td valign=\"middle\" class=\"thumbnails\" align=\"center\">\n";
$td_end="</td>";
$cpg_table_end="</table>";
$tr_start="<tr>\n";
$tr_end="</tr>\n";
}
else
{
$return_value="";
$td_start="";
$td_end="";
$cpg_table_end="";
$tr_start="";
$tr_end="";
}
$counter=0;
if ($cpg_thumbcols > $cpg_how_many) {$cpg_thumbcols=$cpg_how_many;}

while ($row = mysql_fetch_array($result)) {
//------
if ($counter==0){$return_value.=$tr_start;}
$return_value.=$td_start;
if ($cpg_include_link==1)
  {
  $return_value.= "<a href=\"";
    if ($cpg_link_singlepic==1)
      {
       if ($cpg_link_target=="popup")
          {
          $return_value.="javascript:;\"

onClick=\"MM_openBrWindow('".$url_of_cpg_dir."displayimage.php?pid=".$row['pid']."&fullsize=1','".uniqid(rand())."','toolbar=yes,status=yes,r

esizable=yes,width=".($row['pwidth']+16).",height=".($row['pheight']+16)."')\"";
          }
          else
          {
          $return_value.=$url_of_cpg_dir."displayimage.php?&pos=-".$row['pid'];
          }
      }
    else
      {
      $return_value.=$url_of_cpg_dir."thumbnails.php?album=".$row['aid'];
      }
  $return_value.="\" ";

  if($cpg_link_target=="popup"){$return_value.="";}else{$return_value.="target=\"".$cpg_link_target."\"";}
  $return_value.=">";
  }
$return_value.= "".$url_of_cpg_dir.$cpg_album_path.$row[rawurlencode('filepath')].rawurlencode($cpg_thumb_pfx.$row['filename']);
//if ($row['title']!="") {$return_value.= $row['title']."&#10;";}
//if ($row['caption']!="") {$return_value.= $row['caption']."&#10;";}
//if ($row['keywords']!="") {$return_value.= $cpg_lang_keywords . ": " . $row['keywords']."&#10;";}
//if ($row['hits']!="") {$return_value.= $row['hits']." ".$cpg_lang_views."&#10;";}
//if($cpg_random=="1")  {$return_value.= $cpg_lang_random;}
//$return_value.= "\" align=\"left\" class=\"padright\">";
//if ($cpg_include_link==1){$return_value.="</a>";}
//$return_value.=$td_end."\n";
$counter++;
if ($counter==$cpg_thumbcols){$counter=0;$return_value.=$tr_end;}
}

$return_value.=$cpg_table_end;
return $return_value;
}

function cpg_single()
{
$numargs = func_num_args();
$arg_list = func_get_args();
if ($numargs > 0){return cpg_thumb(1,1,1,"",0,$arg_list[0]);}
else{return cpg_thumb(1,1,1,"",0);}
}

function cpg_total_pics($cgp_limit_album)
{
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
  $query = "SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES'";
  if($cgp_limit_album!=""){$query.=" AND aid='".$cgp_limit_album."'";}
  $result = mysql_query($query);
  $nbEnr = mysql_fetch_array($result);
  $pic_count = $nbEnr[0];
  mysql_free_result($result);
  return number_format($pic_count,0,$cpg_decimal_point,$cpg_thousands_separator);
}

function cpg_total_views($cgp_limit_album)
{
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
  $query = "SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1";
  if($cgp_limit_album!=""){$query.=" AND aid='".$cgp_limit_album."'";}
  $result = mysql_query($query);
  $nbEnr = mysql_fetch_array($result);
  $view_count = $nbEnr[0];
  mysql_free_result($result);
  return number_format($view_count,0,$cpg_decimal_point,$cpg_thousands_separator);
}

function cpg_hit_ratio($cgp_limit_album)
{
GLOBAL $CONFIG;
//get stats
$result=mysql_query("SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$hit_count = (int)$nbEnr[0];
$result=mysql_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$picture_count = $nbEnr[0];
$cpg_ratio_string=str_replace(".", ",",(floor(((str_replace(".", "", cpg_total_views($cgp_limit_album))/str_replace(".", "",

cpg_total_pics($cgp_limit_album)))*10)/($hit_count/$picture_count)))/10);
//$cpg_ratio_string=cpg_total_views($cgp_limit_album).'|'.cpg_total_pics($cgp_limit_album).'|'.$hit_count.'|'.$picture_count;
return $cpg_ratio_string;


}

function cpg_stat_string($cgp_limit_album)
{
GLOBAL $url_of_cpg_dir,$cpg_lang_pics,$cpg_lang_views;
$cpg_stat_string='[<a href="'.$url_of_cpg_dir.'thumbnails.php?album='.$cgp_limit_album.'"><b>';
$cpg_stat_string.=cpg_total_pics($cgp_limit_album);
$cpg_stat_string.='</b> ' . $cpg_lang_pics . '</a>, <a href="'.$url_of_cpg_dir.'thumbnails.php?album=topn&cat=-'.$cgp_limit_album.'"><b>';
$cpg_stat_string.=cpg_total_views($cgp_limit_album);
$cpg_stat_string.='</b> ' . $cpg_lang_views . '</a>';
$cpg_stat_string.=', <span class="tool" title="SF=Spanner-Faktor:&#10;Wie oft sind die Bilder dieses Albums durchschnittlich angeklickt

worden, im Vergleich zur gesamten Galerie?">SF: '.cpg_hit_ratio($cgp_limit_album).'</span>';
$cpg_stat_string.=']';
return $cpg_stat_string;
}

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_random()
{
return cpg_thumb(1,1,1,"",1);
}

function random_picture()
{
return cpg_thumb(0,0,1,"",1);
}

function cpg_search($cpg_size,$cpg_question,$cpg_submit_text)
{
GLOBAL $url_of_cpg_dir;
$cpg_search_string = "<form method=\"get\" action=\"" . $url_of_cpg_dir . "thumbnails.php\" name=\"search_cpg\">
<input type=\"hidden\" name=\"album\" value=\"search\" />
<input type=\"hidden\" name=\"type\" value=\"full\" />
<input type=\"input\" name=\"search\" maxlength=\"255\" size=\"" . $cpg_size . "\" value=\"" . $cpg_question . "\" class=\"textfield\"

onfocus=\"this.value=''\" />";
if ($cpg_submit_text!="" and $cpg_submit_text!="0")
  {
  $cpg_search_string.= " <input type=\"submit\" value=\"" . $cpg_submit_text . "\" class=\"submit\" />";
  }
$cpg_search_string.= "</form>";
return $cpg_search_string;
}

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;
}


//function taken from functions.inc.php
function db_connect()
{
        global $CONFIG;
        $result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
        if (!$result)
                return false;
        if (!mysql_select_db($CONFIG['dbname']))
                return false;
        return $result;
}

$total_pics = cpg_total_pics("");
$total_albums = cpg_total_albums();
$total_comments = cpg_total_comments();
$total_views = cpg_total_views("");
$random_picture = random_picture();

$im = ImageCreateTrueColor (375, 150);
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$farbe_text = ImageColorAllocate ($im, 0, 0, 132);
$farbe_online = ImageColorAllocate ($im, 255, 0, 0);
$tc = ImageColorAllocate ($im, 3, 5, 17);
ImageFilledRectangle ($im, 0, 0, 375, 150 ,$bgc);
ImageString($im, 3, 155, 7, "Your name here Statistics", $farbe_text);
ImageString($im, 2, 155, 20, "$total_pics Pictures", $tc);
ImageString($im, 2, 155, 30, "$total_albums Albums", $tc);
ImageString($im, 2, 155, 40, "$total_comments Comments", $tc);
ImageString($im, 2, 155, 50, "viewed $total_views times", $tc);

imagecolortransparent($im, $bgc);

$background = $im ;
$insert = imagecreatefromjpeg($random_picture);

imagecolortransparent($insert, imagecolorexact($insert,255,0,255));

$insert_x = imagesx($insert);
$insert_y = imagesy($insert);

imagecopymerge($background,$insert,0,0,0,0,$insert_x,$insert_y,100);

header("Content-Type: image/png");
imagepng($background,"",100);
ImageDestroy ($im);
?>

Edit it with your path...
Title: Re: [Done] statistics as an image - have a look
Post by: cerberus on July 19, 2004, 04:38:59 pm
nukeworker, well done! :)
I've started to clean the code manually, but later I've noticed that you have already done it ;D
Title: Re: [Done] statistics as an image - have a look
Post by: nukeworker on July 19, 2004, 09:28:54 pm
nukeworker, well done! :)
I've started to clean the code manually, but later I've noticed that you have already done it ;D

Thanks,  I didn't translate some of the remarks... Perhaps someone else can.  It might be useful for some people.  I had to play with it a while to work corectly with my image dimentions.
Title: Re: [Done] statistics as an image - have a look
Post by: snork13 on August 08, 2004, 06:24:11 am
works great, thanks

 :D
Title: Re: [Done] statistics as an image - have a look
Post by: ayako on August 17, 2004, 02:58:07 pm
Hello,

I'd already installed this mod into my CPG and it works great.
But I see, this mod allow everyone to see all photos inside the gallery without any restrictions.
For example, all photos inside my private album can be also viewed.
I don't know, do you have ideas to modify this mod to be more less security vulnerabilities? ???

Ayako
Title: Re: [Done] statistics as an image - have a look
Post by: Joachim Müller on August 17, 2004, 03:55:29 pm
this hack is based on my ssi_mod hack, which doesn't take permissions into account - that's why I recommend not using my mod anymore. The same thing applies for all hacks that are based on my mod: if you're concerned about privacy, you shouldn't use it. There's no hack to the hack available that takes permissions into account.

GauGau
Title: Re: [Done] statistics as an image - have a look
Post by: luchtzak on September 08, 2004, 11:12:54 pm
Hi all,

is there a way to make the signature.php so that when a random picture appears, and you click on the image it auto-directs you to that particular image? I have alot of pics on coppermine and it's difficult to locate that image.
Title: Re: [Done] statistics as an image - have a look
Post by: seros on September 18, 2004, 11:26:38 am
Doesn't work for me, my picture is empty :[
Title: Re: [Done] statistics as an image - have a look
Post by: bbbbug on September 18, 2004, 12:53:00 pm
this requires GD 2.0.
is there any based on GD 1.0?
Title: Re: [Done] statistics as an image - have a look
Post by: Lombi on October 01, 2004, 12:59:11 am
Nice, works swell.
Title: Re: [Done] statistics as an image - have a look
Post by: neeth on February 11, 2005, 06:34:12 pm
i have one problem..

the random pic is over stats..

please see

http://www.neeth.info/galerija/signature_cpg.php


tnx..
Title: Re: [Done] statistics as an image - have a look
Post by: joelgomez on March 09, 2005, 05:27:53 pm
i have one problem..

the random pic is over stats..

please see

http://www.neeth.info/galerija/signature_cpg.php


tnx..

I have the SAME problem! http://www.galeria4x4.com.mx/photos/signature_cpg.php

Besides, the thumb looks desproportionate, I mean, wider that it should be. Is there a way to tell the script: "Please respect the size of the original thumb and display it in its original size"???
Title: Re: [Done] statistics as an image - have a look
Post by: joelgomez on March 09, 2005, 06:17:54 pm
NEETH!!!! I found and corrected the problem, please find the following lines in your code:

Quote
ImageString($im, 3, 155, 7, "Galeria4x4.com.mx", $farbe_text);
ImageString($im, 2, 155, 20, "$total_pics Fotos", $tc);
ImageString($im, 2, 155, 30, "vistas $total_views veces", $tc);
ImageString($im, 2, 155, 40, "$total_albums Albums", $tc);
ImageString($im, 2, 155, 50, "$total_comments Comentarios", $tc);

The "155" was "105" originaly. Play with this numbers, they give the instructions as where to place the text. I guess "155" is 155 pixels from left to right.

However, I still believe that the thumb looks desproportionate, I mean, wider that it should be.
Title: Re: [Done] statistics as an image - have a look
Post by: Nibbler on March 09, 2005, 06:23:03 pm
Maybe you should adjust the ssi to only grab jpegs, or the background bit to allow use of imagecreatefromgif() if appropriate.
Title: Re: [Done] statistics as an image - have a look
Post by: joelgomez on March 09, 2005, 06:33:51 pm
Maybe you should adjust the ssi to only grab jpegs, or the background bit to allow use of imagecreatefromgif() if appropriate.

Thanks Nibbler, any suggestion on how to do it? Just let me know which lines of code should I find and I'll play with them to restrict to jpeg grabbing.

Cya...

PS.- The forum in which I want to use this signature doesn't let me include "png" pictures in my signatures. It seems the [ IMG ] function only takes .gifs and .jpegs... any ideas in how to fool or trick the system?
Title: Re: [Done] statistics as an image - have a look
Post by: Tranz on March 09, 2005, 06:39:41 pm
I have the same problem since phpbb doesn't accept php files in img. Put this into an .htaccess file:
Code: [Select]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule sig.png sig.php [L]

syntax is what is the fake extension and what to actually point it to.
Title: Re: [Done] statistics as an image - have a look
Post by: joelgomez on March 09, 2005, 06:53:07 pm
I'm sorry for asking this stupid question, but what is a ".htaccess file"?  ??? ??? ???

Thanks for the help again TranzNDance, I'll use it as soon as I figure what is an .htaccess file.

Cya...
Title: Re: [Done] statistics as an image - have a look
Post by: Tranz on March 09, 2005, 07:00:42 pm
Sorry, I forgot to add the disclaimer that not everyone can edit the .htaccess file. You should ask your webhost if you can do it so you don't waste time trying something you can't do.
Title: Re: [Done] statistics as an image - have a look
Post by: joelgomez on March 09, 2005, 07:23:35 pm
Quote
Joel: Can I edit the .htaccess file?

Brad: Yes you can edit the .htaccess file. Please do so in your Site Admin Panel

Joel: THANKSSSS!!!

Brad: You can edit it in the File Manager in your Site Admin Panel

 ;D ;D ;D
Title: Re: [Done] statistics as an image - have a look
Post by: Tranz on March 09, 2005, 07:42:17 pm
.htaccess is a configuration file for the webserver. It lets you make changes to your account without affecting other accounts on the same server. If you put into the root of your web docs folder, whatever it may be called, the settings will be inherited by all subfolders. Since this extension manipulation is something you are unlikely to want to happen to all files, you should only use it specifically for one folder.

Put the .htaccess file with the above content, edited to suit your file names/extensions, into the same folder that you want to apply the settings.
Title: Re: [Done] statistics as an image - have a look
Post by: joelgomez on March 09, 2005, 08:07:17 pm
W O W ! ! ! It's WORKING now!!! Thank you very much TranzNDance!!!
Title: Re: [Done] statistics as an image - have a look
Post by: SBSTechInc on May 24, 2005, 07:07:44 pm
I have applied all the changes to the signature_cpg.php and uploaded it to my coppermine dir at http://yourdomain.com/cpg

I'm getting a red x as a display and when i get the property for the x it points to signature_cpg.php ..

I think it's has to do with the following settings:

$url_of_cpg_dir='http://yourdomain.com/cpg/';    // full path to your coppermine gallery (with trailing slash)
$absolute_path_to_coppermine='cpg/';    // absolute path on your server to coppermine gallery (with trailing slash)
Title: Re: [Done] statistics as an image - have a look
Post by: Tranz on May 24, 2005, 07:39:28 pm
Absolute path would look something like this, depending on if your server is running linux or windows:
/home/user/public_html/cpg/

That's just an example.
Title: Re: [Done] statistics as an image - have a look
Post by: SBSTechInc on May 25, 2005, 04:45:54 pm
Firstly, thanks TranzNDance for the explanation of the absolute path..

I copied the codes re-written by nukeworker and overwrite my signature_cpg.php and placed the file in the root of my coppermine dir..

I changed of course the 2 lines to my album:

$url_of_cpg_dir='http://yourdomain.com/cpg/';    // full path to your coppermine gallery (with trailing slash)
$absolute_path_to_coppermine='/home/user/public_html/path/cpg/'; // absolute path on your server to coppermine gallery (with trailing slash)

I also added the image path to my template.html:
Code: [Select]
       <td valign="top" bordercolor="#666666" bgcolor="#FFFFFF" style="border: 1px solid;">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                       <tr>
                                <td width="100%" align="center">
                                        <h1>{GAL_NAME}</h1>
                                        <h3>{GAL_DESCRIPTION}</h3><br />
                                        {MAIN_MENU}<br /></td>
                        </tr>

<tr><td>
<table border="8" cellpadding="2" cellspacing="5" align="center">
<td>
<div align="center"><img src="'http://yourdomain.com/cpg/signature_cgp.php">
</table></td></tr>
                </table>

I still get the red x as an image..  What am I doing wrong?
Title: Re: [Done] statistics as an image - have a look
Post by: Tranz on May 25, 2005, 06:40:09 pm
Are you using the correct absolute path for your server? You need to confirm with your webhost as it varies.
Title: Re: [Done] statistics as an image - have a look
Post by: SBSTechInc on May 25, 2005, 07:22:16 pm
Yes, the absolute path is correct..  When I right-click and select properties on the red x it shows the correct path to the signature_cpg.php..

Example of my configuration:

$url_of_cpg_dir='http://yourdomain.com/phpbb/cpg/';    // full path to your coppermine gallery (with trailing slash)
$absolute_path_to_coppermine='/home/sbstechinc/public_html/phpbb/cpg/'; // absolute path on your server to coppermine gallery (with trailing slash)
Title: Re: [Done] statistics as an image - have a look
Post by: blobnl on June 14, 2005, 05:14:16 pm
get this error message:

Parse error: parse error, unexpected T_VARIABLE in c:\ibserver\www\fotoforum\signature_cgp.php on line 26
Title: Re: [Done] statistics as an image - have a look
Post by: adik on September 22, 2005, 01:11:23 am
Remove "" from 28 line ...

I have another question. How to change script to get image only from one selected album ???
Title: Re: [Done] statistics as an image - have a look
Post by: nukeworker on September 22, 2005, 11:42:28 pm
I have another question. How to change script to get image only from one selected album ???

Find this:
Code: [Select]
//get pic info
$query = "SELECT * from {$CONFIG['TABLE_PICTURES']} WHERE approved='YES' ";


Change to this:
Quote
//get pic info
$query = "SELECT * from {$CONFIG['TABLE_PICTURES']} WHERE approved='YES' AND aid=x";

Replace the x with your album number.
Title: Re: [Done] statistics as an image - have a look
Post by: just_some_guy on October 13, 2007, 10:12:49 pm
Hey, looks like a great mod. I have followed the instructions and i just get:

"No input file specified."

file: http://mysimtractor.com/cpg1412/signature_cgp.php (http://mysimtractor.com/cpg1412/signature_cgp.php)

heres the file:

Code: [Select]
<?
// ------------------------------------------------------------------------- //
//  include script for CPG (c) 2003 GauGau (mail@gaugau.de) V1.4             //
//  http://gaugau.de/                                                        //
// ------------------------------------------------------------------------- //
//  Coppermine Photo Gallery v1.1                                     //
// ------------------------------------------------------------------------- //
//  Copyright (C) 2002,2003  Gr&eacute;gory DEMAR <gdemar@wanadoo.fr>               //
//  http://www.chezgreg.net/coppermine/                                      //
// ------------------------------------------------------------------------- //
//  Based on PHPhotoalbum by Henning Stųverud <henning@stoverud.com>         //
//  http://www.stoverud.com/PHPhotoalbum/                                    //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
// ------------------------------------------------------------------------- //

/////////////////// edit the following lines //////////////////////////////
$url_of_cpg_dir='http://www.mysimtractor.com/cpg1412/';    // full path to your coppermine gallery (with trailing slash)
$absolute_path_to_coppermine='/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/'; // absolute path on your server to coppermine gallery (with trailing slash)
// to find more about absolute paths, check http://www.php.net/manual/en/function.phpinfo.php and look for 'DOCUMENT_ROOT' in your phpinfo.php
$cpg_decimal_point="."; //what character is used to separate decimals in your country, e.g. in Germany ",", in GB "."
$cpg_thousands_separator=","; //what character is used to separate thousands in your country, e.g. in Germany ".", in GB & US ",", in France " "
$cpg_lang_pics = "Pictures"; //translate this
$cpg_lang_views = "view"; //translate this
$cpg_lang_random = "Random pic of this album"; //translate this
$cpg_lang_keywords = "Keywords"; //translate this
/////// don't edit below this line unless you know what your're doing /////////

include_once( $absolute_path_to_coppermine.'/include/config.inc.php');


// definition taken from init.inc.php
$CONFIG['TABLE_PICTURES']        = $CONFIG['TABLE_PREFIX']."pictures";
$CONFIG['TABLE_ALBUMS']                = $CONFIG['TABLE_PREFIX']."albums";
$CONFIG['TABLE_COMMENTS']        = $CONFIG['TABLE_PREFIX']."comments";
$CONFIG['TABLE_CATEGORIES']        = $CONFIG['TABLE_PREFIX']."categories";
$CONFIG['TABLE_CONFIG']                = $CONFIG['TABLE_PREFIX']."config";
$CONFIG['TABLE_USERGROUPS']        = $CONFIG['TABLE_PREFIX']."usergroups";
$CONFIG['TABLE_VOTES']                = $CONFIG['TABLE_PREFIX']."votes";
$CONFIG['TABLE_USERS']                = $CONFIG['TABLE_PREFIX']."users";
// Connect to database
db_connect() || die("<b>Coppermine critical error</b>:<br />Unable to connect to database !<br /><br />MySQL said: <b>".mysql_error()."</b>");

// get config data
$result = mysql_query("SELECT * from {$CONFIG['TABLE_CONFIG']} WHERE name='fullpath'");
$row = mysql_fetch_row($result);
$cpg_album_path=$row[1];
$result = mysql_query("SELECT * from {$CONFIG['TABLE_CONFIG']} WHERE name='thumb_pfx'");
$row = mysql_fetch_row($result);
$cpg_thumb_pfx=$row['1'];
$result = mysql_query("SELECT * from {$CONFIG['TABLE_CONFIG']} WHERE name='thumbcols'");
$row = mysql_fetch_row($result);
$cpg_thumbcols=$row['1'];


if ($function == 'cpg_thumb' || $function == 'recentTopics' || $function == 'whosOnline' || $function == 'welcome' || $function == 'menubar' || $function == 'logout' || $function == 'login' || $function == 'topBoards' || $function == 'topTopicsViews' || $function == 'topTopicsReplies' || $function == 'latestMember' || $function == 'boardStats')
{
        $function(); // Execute Function
        exit;
}

function cpg_thumb()
{
GLOBAL $CONFIG,$url_of_cpg_dir,$cpg_album_path,$cpg_thumb_pfx,$cpg_thumbcols,$cpg_lang_random,$cpg_lang_views,$cpg_lang_keywords;
$numargs = func_num_args();
$arg_list = func_get_args();
if ($numargs > 0) {$cpg_include_link=$arg_list[0];}
if ($numargs > 1) {$cpg_link_singlepic=$arg_list[1];}
if ($numargs > 2) {$cpg_how_many=$arg_list[2];}
if ($numargs > 3) {$cgp_limit_album=$arg_list[3];}
if ($numargs > 4) {$cpg_random=$arg_list[4];}
if ($numargs > 5) {$cpg_link_target=$arg_list[5];}
if ($cpg_link_target==""){$cpg_link_target="_top";}


//get pic info
$query = "SELECT * from {$CONFIG['TABLE_PICTURES']} WHERE approved='YES' ";
if($cgp_limit_album!=""){$query.="AND aid='".$cgp_limit_album."'";}
$query.=" AND user2!='1' ORDER BY ";
if($cpg_random=="1"){$query.="RAND()";}else{$query.="ctime";}
$query.=" DESC LIMIT 0,".$cpg_how_many;
$result = mysql_query($query);
if ($cpg_how_many!=1)
{
$return_value="<table align=\"center\" cellspacing=\"0\" cellpadding=\"10\" align=\"center\" class=\"maintable\" border=\"0\">";
$td_start="<td valign=\"middle\" class=\"thumbnails\" align=\"center\">\n";
$td_end="</td>";
$cpg_table_end="</table>";
$tr_start="<tr>\n";
$tr_end="</tr>\n";
}
else
{
$return_value="";
$td_start="";
$td_end="";
$cpg_table_end="";
$tr_start="";
$tr_end="";
}
$counter=0;
if ($cpg_thumbcols > $cpg_how_many) {$cpg_thumbcols=$cpg_how_many;}

while ($row = mysql_fetch_array($result)) {
//------
if ($counter==0){$return_value.=$tr_start;}
$return_value.=$td_start;
if ($cpg_include_link==1)
  {
  $return_value.= "<a href=\"";
    if ($cpg_link_singlepic==1)
      {
       if ($cpg_link_target=="popup")
          {
          $return_value.="javascript:;\" onClick=\"MM_openBrWindow('".$url_of_cpg_dir."displayimage.php?pid=".$row['pid']."&fullsize=1','".uniqid(rand())."','toolbar=yes,status=yes,resizable=yes,width=".($row['pwidth']+16).",height=".($row['pheight']+16)."')\"";
          }
          else
          {
          $return_value.=$url_of_cpg_dir."displayimage.php?&pos=-".$row['pid'];
          }
      }
    else
      {
      $return_value.=$url_of_cpg_dir."thumbnails.php?album=".$row['aid'];
      }
  $return_value.="\" ";

  if($cpg_link_target=="popup"){$return_value.="";}else{$return_value.="target=\"".$cpg_link_target."\"";}
  $return_value.=">";
  }
$return_value.= "".$url_of_cpg_dir.$cpg_album_path.$row['filepath'].rawurlencode($cpg_thumb_pfx.$row['filename']);

$counter++;
if ($counter==$cpg_thumbcols){$counter=0;$return_value.=$tr_end;}
}

$return_value.=$cpg_table_end;
return $return_value;
}

function cpg_single()
{
$numargs = func_num_args();
$arg_list = func_get_args();
if ($numargs > 0){return cpg_thumb(1,1,1,"",0,$arg_list[0]);}
else{return cpg_thumb(1,1,1,"",0);}
}

function cpg_total_pics($cgp_limit_album)
{
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
  $query = "SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES'";
  if($cgp_limit_album!=""){$query.=" AND aid='".$cgp_limit_album."'";}
  $result = mysql_query($query);
  $nbEnr = mysql_fetch_array($result);
  $pic_count = $nbEnr[0];
  mysql_free_result($result);
  return number_format($pic_count,0,$cpg_decimal_point,$cpg_thousands_separator);
}

function cpg_total_views($cgp_limit_album)
{
GLOBAL $CONFIG,$cpg_decimal_point,$cpg_thousands_separator;
  $query = "SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1";
  if($cgp_limit_album!=""){$query.=" AND aid='".$cgp_limit_album."'";}
  $result = mysql_query($query);
  $nbEnr = mysql_fetch_array($result);
  $view_count = $nbEnr[0];
  mysql_free_result($result);
  return number_format($view_count,0,$cpg_decimal_point,$cpg_thousands_separator);
}

function cpg_hit_ratio($cgp_limit_album)
{
GLOBAL $CONFIG;
//get stats
$result=mysql_query("SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$hit_count = (int)$nbEnr[0];
$result=mysql_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$picture_count = $nbEnr[0];
$cpg_ratio_string=str_replace(".", ",",(floor(((str_replace(".", "", cpg_total_views($cgp_limit_album))/str_replace(".", "", cpg_total_pics($cgp_limit_album)))*10)/($hit_count/$picture_count)))/10);
//$cpg_ratio_string=cpg_total_views($cgp_limit_album).'|'.cpg_total_pics($cgp_limit_album).'|'.$hit_count.'|'.$picture_count;
return $cpg_ratio_string;


}

function cpg_stat_string($cgp_limit_album)
{
GLOBAL $url_of_cpg_dir,$cpg_lang_pics,$cpg_lang_views;
$cpg_stat_string='[<a href="'.$url_of_cpg_dir.'thumbnails.php?album='.$cgp_limit_album.'"><b>';
$cpg_stat_string.=cpg_total_pics($cgp_limit_album);
$cpg_stat_string.='</b> ' . $cpg_lang_pics . '</a>, <a href="'.$url_of_cpg_dir.'thumbnails.php?album=topn&cat=-'.$cgp_limit_album.'"><b>';
$cpg_stat_string.=cpg_total_views($cgp_limit_album);
$cpg_stat_string.='</b> ' . $cpg_lang_views . '</a>';
$cpg_stat_string.=', <span class="tool" title="SF=Spanner-Faktor:Wie oft sind die Bilder dieses Albums durchschnittlich angeklickt worden, im Vergleich zur gesamten Galerie?">SF: '.cpg_hit_ratio($cgp_limit_album).'</span>';
$cpg_stat_string.=']';
return $cpg_stat_string;
}

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_random()
{
return cpg_thumb(1,1,1,"",1);
}
function random_picture()
{
return cpg_thumb(0,0,1,"",1);
}
function cpg_search($cpg_size,$cpg_question,$cpg_submit_text)
{
GLOBAL $url_of_cpg_dir;
$cpg_search_string = "<form method=\"get\" action=\"" . $url_of_cpg_dir . "thumbnails.php\" name=\"search_cpg\">
<input type=\"hidden\" name=\"album\" value=\"search\" />
<input type=\"hidden\" name=\"type\" value=\"full\" />
<input type=\"input\" name=\"search\" maxlength=\"255\" size=\"" . $cpg_size . "\" value=\"" . $cpg_question . "\" class=\"textfield\" onfocus=\"this.value=''\" />";
if ($cpg_submit_text!="" and $cpg_submit_text!="0")
  {
  $cpg_search_string.= " <input type=\"submit\" value=\"" . $cpg_submit_text . "\" class=\"submit\" />";
  }
$cpg_search_string.= "</form>";
return $cpg_search_string;
}

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;
}


//function taken from functions.inc.php
function db_connect()
{
        global $CONFIG;
        $result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
        if (!$result)
                return false;
        if (!mysql_select_db($CONFIG['dbname']))
                return false;
        return $result;
}
$total_pics = cpg_total_pics("");
$total_albums = cpg_total_albums();
$total_comments = cpg_total_comments();
$total_views = cpg_total_views("");
$random_picture = random_picture();

$im = ImageCreateTrueColor (375, 75);
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$farbe_text = ImageColorAllocate ($im, 0, 0, 132);
$farbe_online = ImageColorAllocate ($im, 255, 0, 0);
$tc = ImageColorAllocate ($im, 3, 5, 17);
ImageFilledRectangle ($im, 0, 0, 375, 75 ,$bgc);
ImageString($im, 3, 105, 7, "Statistics of [your album-name here]", $farbe_text);
ImageString($im, 2, 105, 20, "$total_pics Pictures", $tc);
ImageString($im, 2, 105, 30, "$total_albums Albums", $tc);
ImageString($im, 2, 105, 40, "$total_comments Comments", $tc);
ImageString($im, 2, 105, 50, "viewed $total_views times", $tc);

imagecolortransparent($im, $bgc);

$background = $im ;
$insert = imagecreatefromjpeg($random_picture);

imagecolortransparent($insert, imagecolorexact($insert,255,0,255));

$insert_x = imagesx($insert);
$insert_y = imagesy($insert);

imagecopymerge($background,$insert,0,0,0,0,$insert_x,$insert_y,100);

header("Content-Type: image/png");
imagepng($background,"",100);
ImageDestroy ($im);



?>

Thanks and i would appreciate the help.
Title: Re: [Done] statistics as an image - have a look
Post by: just_some_guy on October 13, 2007, 11:19:28 pm
The signature ins:

http://mysimtractor.com/cpg1412/signature_cpg.php (http://mysimtractor.com/cpg1412/signature_cpg.php)

the error i get is:

Code: [Select]
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: function in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined variable: cpg_link_target in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>76</b><br />
‰PNG


IHDRwKmPĖtRNS˙˙˙7X}<br />
<b>Warning</b>:  imagepng() [<a href='function.imagepng'>function.imagepng</a>]: gd-png:  fatal libpng error: zlib error in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>338</b><br />
<br />
<b>Warning</b>:  imagepng() [<a href='function.imagepng'>function.imagepng</a>]: gd-png error: setjmp returns error condition in <b>/home/fhlinux164/m/mysimtractor.com/user/htdocs/cpg1412/signature_cpg.php</b> on line <b>338</b><br />

Title: Re: [Done] statistics as an image - have a look
Post by: Joachim Müller on October 15, 2007, 09:22:18 am
Leave notices_display turned off if you don't know what they mean. Make sure that you have png support in GD
Title: Re: [Done] statistics as an image - have a look
Post by: just_some_guy on October 17, 2007, 02:33:47 pm
i checked my phpinfo and gd png is enabled.