// // http://www.chezgreg.net/coppermine/ // // ------------------------------------------------------------------------- // // Based on PHPhotoalbum by Henning Střverud // // 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. // // ------------------------------------------------------------------------- // include("include/init.inc.php"); /************************************************************************** * Local functions definition **************************************************************************/ function caption_from_fname() { global $row; if ($row['filename'][0] == '@') return strtr(preg_replace("/@(.+)\..*?\Z/", "\\1", $row['filename']), "_", " ")."
"; else return ""; } function get_caption() { global $row, $CONFIG; $result = db_query("SELECT msg_body FROM {$CONFIG['TABLE_COMMENTS']} where msg_id={$row['caption']}"); if ($caption = mysql_fetch_array($result)) { return stripslashes($caption['msg_body'])."
"; } else { return ""; } } function album_pic_query($limit) { global $CONFIG, $album, $USER; switch (isset($USER['sort']) ? $USER['sort'] : $CONFIG['default_sort_order']){ case 'na': $sort_order="filename asc"; break; case 'nd': $sort_order="filename desc"; break; case 'dd': $sort_order="pid desc"; break; case 'da': $sort_order="pid asc"; break; default: $sort_order="pid asc"; break; } return mysql_query("SELECT * from $CONFIG[TABLE_PICTURES] WHERE aid='$album' ORDER BY $sort_order $limit"); } function album_caption($pid) { global $CONFIG, $row; $caption = caption_from_fname(); if ($CONFIG['caption_in_thumbview']) $caption .= get_caption(); $ant_cmts = count_pic_comments($pid, $row['caption']); if ($ant_cmts > 0) $caption .= "$ant_cmts " . plural($ant_cmts, "comment"); return $caption; } function topn_pic_query($limit) { global $CONFIG, $album; return mysql_query("SELECT * FROM $CONFIG[TABLE_PICTURES] ORDER BY hits DESC $limit"); } function topn_caption($pid) { global $row; return caption_from_fname().$row['hits'].plural($row['hits']," hit"); } function lastup_pic_query($limit) { global $CONFIG, $album; return mysql_query("SELECT DATE_FORMAT(ctime, \"%Y-%m-%d\") as time, pid, aid, filepath, filename, filesize, pwidth, pheight FROM $CONFIG[TABLE_PICTURES] ORDER BY pid DESC $limit"); } function lastup_caption($pid) { global $row; return caption_from_fname()."$row[time]"; } function lasthits_pic_query($limit) { global $CONFIG, $album; return mysql_query("SELECT DATE_FORMAT(mtime, \"%Y-%m-%d %H:%i\") as time, pid, aid, filepath, filename, filesize, pwidth, pheight, hits FROM $CONFIG[TABLE_PICTURES] ORDER BY time DESC $limit"); } function lasthits_caption($pid) { global $row; return caption_from_fname()."$row[time]
($row[hits]".plural($row['hits']," hit").")"; } function lastcom_pic_query($limit) { global $CONFIG; return mysql_query("SELECT $CONFIG[TABLE_PICTURES].pid as pid,aid,filepath,filename,filesize,pwidth,pheight,hits,msg_author as name,DATE_FORMAT(msg_date, \"%Y-%m-%d %H:%i\") as time FROM $CONFIG[TABLE_PICTURES], $CONFIG[TABLE_COMMENTS] WHERE $CONFIG[TABLE_COMMENTS].pid=$CONFIG[TABLE_PICTURES].pid GROUP BY pid ORDER BY time DESC $limit"); } function lastcom_caption($pid) { global $row; return "$row[time]
$row[name]"; } function show_picturemenu_small($id) { echo "
DELETE
"; } // Prints thumbnails of all pictures in an album function thumbnails($album, $header, $thumbcols, $thumbrows, $page, $picture_query, $caption, $nbPic) { global $CONFIG, $AUTHORIZED, $row, $REQUEST_URI; if (!isset($album)) { echo "
You have to choose an album.

\n"; echo "- List of albums"; exit; } $totalPages = ceil($nbPic / ($thumbcols * $thumbrows)); if ($page =='' || $page <= 0 || $page > $totalPages ) $page = 1; $thumb_per_page = $thumbcols * $thumbrows; $lower_limit = ($page-1) * $thumb_per_page; $upper_limit = min($nbPic, $page * $thumb_per_page); $limit = "LIMIT ". $lower_limit . "," . ($upper_limit-$lower_limit); $result = $picture_query($limit); $count = mysql_num_rows($result); if (is_numeric($album)){ echo <<

$header

NAME  +   - 
DATE  +   - 
EOT; } else { echo <<

$header

EOT; } echo "\n"; $i = 0; // Img counter. $prepend = ''; $cell_width = 1.65*$CONFIG['thumb_width']-10; // Displays thumbs if the query returns a result. if ($count > 0) { while ($row = mysql_fetch_array($result)) { $i++; $pic_title = "Filename: ".$row['filename']."\n". "Size: ".($row['filesize'] >> 10)."kb\n". "Dimensions: ".$row['pwidth']."x".$row['pheight']; if ($row['ctime']) $pic_title .= "\nDate: ".$row['ctime']; $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); echo "$prepend
"; echo ""; echo "\"$row[filename]\""; $pic_caption=$caption($row['pid']); if ($pic_caption != "") echo "
$pic_caption
"; if ($AUTHORIZED) show_picturemenu_small($row["pid"]); echo "
\n"; if (!($i % $thumbcols)) { $prepend = "\n\n"; } else { $prepend = ""; } } for (;($i % $thumbcols) && ($i > $thumbcols); $i++) echo " \n"; echo "\n"; $maxTab = $CONFIG['max_tabs']; if ($totalPages > 1) { $navbuttons = ''."\n"; $navbuttons .= '\n"; $navbuttons .= ''; $navbuttons .= '\n"; if ($totalPages > $maxTab){ $start = max(2, $page - floor(($maxTab -2)/2)); $start = min($start, $totalPages - $maxTab +2); $end = $start + $maxTab -3; } else { $start = 2; $end = $totalPages-1; } for ($currPage = $start ; $currPage <= $end; $currPage++) { $navbuttons .= ''; if ($currPage == $page) { $navbuttons .= '\n"; } if ($totalPages > 1){ $navbuttons .= ''; $navbuttons .= '\n"; } $navbuttons .= "
'; $navbuttons .= "$nbPic pictures on $totalPages ".plural($totalPages, "page")."'; $navbuttons .= "1"; } else { $navbuttons .= ''; $navbuttons .= "$currPage"; } else { $navbuttons .= ''; $navbuttons .= "$totalPages"; } else { $navbuttons .= '
\n"; echo "$navbuttons\n"; } else { echo "$nbPic pictures\n"; } } else { echo ""; echo "
No image to display in this album

\n"; echo "\n"; } } /************************************************************************** * Main code **************************************************************************/ global $page; if (isset($sort)) $USER['sort'] = $sort; pageheader("Album $album"); starttable((2*$CONFIG['thumbcols']-1)*$CONFIG['thumb_width']); switch($album){ case 'topn': $nbPic = min($CONFIG['number_in_toplist'], count_pics()); $name = "Top ".$CONFIG['number_in_toplist']." pictures"; thumbnails($album, $name, $CONFIG['thumbcols'], $CONFIG['thumbrows'], $page, 'topn_pic_query', 'topn_caption', $nbPic); break; case 'lastup': $nbPic = min($CONFIG['number_in_toplist'], count_pics()); $name = "Last uploads"; thumbnails($album, $name, $CONFIG['thumbcols'], $CONFIG['thumbrows'], $page, 'lastup_pic_query', 'lastup_caption', $nbPic); break; case 'lasthits': $nbPic = min($CONFIG['number_in_toplist'], count_pics()); $name = "Last hits"; thumbnails($album, $name, $CONFIG['thumbcols'], $CONFIG['thumbrows'], $page, 'lasthits_pic_query', 'lasthits_caption', $nbPic); break; case 'lastcom': $result = lastcom_pic_query(""); $nbPic = min($CONFIG['number_in_toplist'], mysql_num_rows($result)); $name = "Last comments"; thumbnails($album, $name, $CONFIG['thumbcols'], $CONFIG['thumbrows'], $page, 'lastcom_pic_query', 'lastcom_caption', $nbPic); break; default : $album_name = get_album_name($album); $res = mysql_query("SELECT count(*) from $CONFIG[TABLE_PICTURES] WHERE aid='$album'"); $nbrec = mysql_fetch_array($res); $nbPic = $nbrec[0]; thumbnails($album, $album_name, $CONFIG['thumbcols'], $CONFIG['thumbrows'], $page, 'album_pic_query', 'album_caption', $nbPic); break; } endtable(); if (strval(intval($album)) != "$album"){ starttable(); include ("picstat.php"); endtable(); } pagefooter("100%"); ?>