I was wondering weather I could change info of how many files you have in x amount of categories with x amount of comments and x amount of views
for example: 2517 files in 54 albums and 2 categories with 0 comments viewed 849 times
I want to change it to: 2517 files viewed 849 times
I also want to add the amount of disk space the x amount of files is using
for example: 2517 files viewed 849 times total space 1.2GB
I would be greatful if anybody can help ;D
You can modify the string in your language file. Remove the parts you don't want and add an extra placeholder for the new info. Modify one of the db queries to pull the sum(total_filesize), convert to GB, and add it into the strtr.
Code to change is in index.php
// Gather gallery statistics
if ($cat == 0) {
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE 1" . $album_filter);
$nbEnr = mysql_fetch_array($result);
$album_count = $nbEnr[0];
mysql_free_result($result);
$sql = "SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON a.aid=p.aid ' . 'WHERE 1' . $pic_filter . ' AND approved=\'YES\'';
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$picture_count = $nbEnr[0];
mysql_free_result($result);
$sql = "SELECT count(*) FROM {$CONFIG['TABLE_COMMENTS']} as c " . 'LEFT JOIN ' . $CONFIG['TABLE_PICTURES'] . ' as p ' . 'ON c.pid=p.pid ' . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON a.aid=p.aid ' . 'WHERE 1' . $pic_filter;
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$comment_count = $nbEnr[0];
mysql_free_result($result);
$sql = "SELECT count(*) FROM {$CONFIG['TABLE_CATEGORIES']} WHERE 1";
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$cat_count = $nbEnr[0] - $HIDE_USER_CAT;
mysql_free_result($result);
$sql = "SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON p.aid=a.aid ' . 'WHERE 1' . $pic_filter;
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$hit_count = (int)$nbEnr[0];
mysql_free_result($result);
if (count($cat_data)) {
$statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => $picture_count,
'[albums]' => $album_count,
'[cat]' => $cat_count,
'[comments]' => $comment_count,
'[views]' => $hit_count));
} else {
$STATS_IN_ALB_LIST = true;
$statistics = strtr($lang_list_categories['stat3'], array('[pictures]' => $picture_count,
'[albums]' => $album_count,
'[comments]' => $comment_count,
'[views]' => $hit_count));
}
} elseif ($cat >= FIRST_USER_CAT && $ALBUM_SET) {
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE 1 $current_album_set");
$nbEnr = mysql_fetch_array($result);
$album_count = $nbEnr[0];
mysql_free_result($result);
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set AND approved='YES'");
$nbEnr = mysql_fetch_array($result);
$picture_count = $nbEnr[0];
mysql_free_result($result);
$result = cpg_db_query("SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set");
$nbEnr = mysql_fetch_array($result);
$hit_count = (int)$nbEnr[0];
mysql_free_result($result);
$statistics = strtr($lang_list_categories['stat2'], array('[pictures]' => $picture_count,
'[albums]' => $album_count,
'[views]' => $hit_count));
} else {
$statistics = '';
}
I've added the following to strtr but what do I put after $
'[total_filesize]' =>$
Thanks ;D
Changed code for index.php would be like this:
$sql = "SELECT sum(hits), sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON p.aid=a.aid ' . 'WHERE 1' . $pic_filter;
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$hit_count = (int)$nbEnr[0];
$total_filesize = (int)$nbEnr[1];
mysql_free_result($result);
if (count($cat_data)) {
$statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => $picture_count,
'[albums]' => $album_count,
'[cat]' => $cat_count,
'[comments]' => $comment_count,
'[views]' => $hit_count,
'[total_filesize]' => round($total_filesize/1024/1024/1024, 2)
));
} else {
I get this error when changing the code in index.php
Parse error: parse error, unexpected ';' in /home/content/w/i/l/willtaka05/html/gallery/index.php on line 312
Do I need to change anything in the english.php lang file ???
The code I posted replaces
$sql = "SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON p.aid=a.aid ' . 'WHERE 1' . $pic_filter;
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$hit_count = (int)$nbEnr[0];
mysql_free_result($result);
if (count($cat_data)) {
$statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => $picture_count,
'[albums]' => $album_count,
'[cat]' => $cat_count,
'[comments]' => $comment_count,
'[views]' => $hit_count));
} else {
Line 312 should not contain a semi colon if you did it correctly.
Quote from: will on February 13, 2007, 12:19:37 AM
Do I need to change anything in the english.php lang file ???
You need to add [total_filesize] and corresponding descriptive words into the lang file (stat1)
sorry to ask you to basically do it for me but I'm useless at coding, anyway it has worked wonders, thanks alot ;D
Great. If you wanted 1.2 instead of 1.15 then change the 2 to 1 here
'[total_filesize]' => round($total_filesize/1024/1024/1024, ***2***)
for some reason the total filesize has stopped at 2GB and has been like that for about 10 uploads now ???
Adjust the rounding if you want to see such small changes.
I mean it hasn't increased since about 10 uploads, normally after 2-3 uploads it goes from 1GB to 1.10GB and so one but it hasn't since ???
Depends on the size of files you are uploading...
It looks like its not working, how do I remove it so I don't get an error ;D