/*
---------------------------------------------------
PHP-Fusion - Content Management System
-------------------------------------------
© Nick Jones (Digitanium) 2002-2004
http://www.php-fusion.co.uk
nick@php-fusion.co.uk
-------------------------------------------
Released under the terms and conditions of
the GNU General Public License (Version 2)
---------------------------------------------------
Photogallery written by CrappoMan
simonpatterson@dsl.pipex.com
---------------------------------------------------
*/
@require "fusion_config.php";
require "header.php";
require "subheader.php";
require fusion_langdir."photogallery.php";
require fusion_langdir."comments.php";
require "side_left.php";
if (isset($_POST['post_comment'])) {
if (dbrows(dbquery("SELECT photo_id FROM ".$fusion_prefix."photos WHERE photo_id='$photo'"))==0) {
header("Location: ".fusion_basedir."index.php");
exit;
}
if (Member()) {
$comment_name = $userdata['user_id'];
} elseif ($settings['guestposts'] == "1") {
$comment_name = stripinput($_POST['comment_name']);
if (is_numeric($comment_name)) $comment_name="";
}
$comment_message = stripinput($_POST['comment_message']);
if ($comment_name != "" && $comment_message != "") {
$result = dbquery("INSERT INTO ".$fusion_prefix."comments VALUES('', '$photo', 'P', '$comment_name', '$comment_message', '".time()."', '$user_ip')");
}
header("Location: ".$PHP_SELF."?photo=$photo");
}
if(!isset($rowstart)) $rowstart=0;
if(isset($photo)){
$result=dbquery("UPDATE ".$fusion_prefix."photos SET photo_views=(photo_views+1) WHERE photo_id='$photo'");
$result=dbquery(
"SELECT tp.*, user_name FROM ".$fusion_prefix."photos AS tp
INNER JOIN ".$fusion_prefix."users USING (user_id) WHERE photo_id='".$photo."'"
);
if(dbrows($result)!=0){
$data=dbarray($result);
$phototitle=stripslashes($data['photo_title']);
opentable(LAN_419.$phototitle);
$img_filename="$gallery_dir/$photo.jpg";
if(file_exists($img_filename)){
echo "
";
$pixsize=getimagesize($img_filename);
echo "".LAN_420.$pixsize[0]." x ".$pixsize[1].LAN_421."(".parseByteSize(filesize($img_filename)).")
";
echo LAN_422."".$data['user_name']."".LAN_423."".strftime($settings['shortdate'], $data['photo_date']+($settings['timeoffset']*3600)).".
";
echo LAN_424."".$data['photo_views']."".LAN_425."
";
}else{
echo "
";
}
}
closetable();
echo "";
if($settings['album_comments']=="1"){
$comment_type = "P"; $comment_item_id = "$photo"; $comment_link = "$PHP_SELF?photo=$photo";
require fusion_basedir."fusion_core/comments_panel.php";
}
}elseif(isset($album)){
$data=dbarray(dbquery(
"SELECT ta.*, COUNT(photo_id) as photo_count, MAX(photo_date) as max_date, user_name
FROM ".$fusion_prefix."photo_albums AS ta
LEFT JOIN ".$fusion_prefix."photos USING (album_id)
LEFT JOIN ".$fusion_prefix."users USING (user_id)
WHERE ta.album_id='".$album."' GROUP BY album_id"
));
$piccnt=$data['photo_count'];
$albumtitle=stripslashes($data['album_title']);
$albuminfo=stripslashes($data['album_info']);
opentable(LAN_408.$albumtitle);
echo "";
echo " ";
echo " | ".($albuminfo==""?$albumtitle:$albuminfo)." |
";
echo " ".LAN_409."";
if($data[photo_count]>0){
echo "$data[photo_count] ".LAN_410."".strftime($settings['shortdate'], $data['max_date']+($settings['timeoffset']*3600))."".LAN_411."".$data['user_name']."";
}else{
echo LAN_412."
";
}
echo " |
";
closetable();
tablebreak();
opentable(LAN_413);
echo "";
$result=dbquery(
"SELECT tp.*, COUNT(comment_item_id) AS comment_count
FROM ".$fusion_prefix."photos AS tp LEFT JOIN ".$fusion_prefix."comments
ON photo_id = comment_item_id AND comment_type='P'
WHERE album_id='".$album."' GROUP BY photo_id
ORDER BY photo_order LIMIT ".$rowstart.",".$settings['thumbs_per_page']
);
if(dbrows($result)>0){
$img_cnt=0;
while($data=dbarray($result)){
$phototitle=stripslashes($data['photo_title']);
echo "";
echo " ";
echo "$phototitle ".LAN_414."";
if($data['photo_views']==0){
echo LAN_412;
}else{
echo $data['photo_views'];
}
echo " ";
if($data['comment_count']==0){
echo LAN_415;
}else{
echo "".$data['comment_count']." ".($data['comment_count']==1?LAN_416:LAN_417);
}
echo "";
$img_cnt++;
if(($img_cnt%$settings['thumbs_per_row'])==0) echo " |
";
}
}else{
echo "".LAN_418." | ";
}
echo "
";
closetable();
echo "".makePageNav($rowstart,$settings['thumbs_per_page'],$piccnt,3,"$PHP_SELF?album=$album&")."
\n";
echo "";
}else{
opentable(LAN_400);
$albcnt=dbresult(dbquery("SELECT COUNT(album_id) FROM ".$fusion_prefix."photo_albums"), 0);
if($albcnt!=0){
$result=dbquery(
"SELECT COUNT(photo_id) AS photo_count, MAX(photo_date) AS max_date, ta.*
FROM ".$fusion_prefix."photo_albums AS ta LEFT JOIN ".$fusion_prefix."photos USING (album_id)
GROUP BY album_id ORDER BY album_order LIMIT ".$rowstart.",".$settings[albums_per_page]
);
echo "";
$img_cnt=0;
while($data=dbarray($result)){
$albumtitle=stripslashes($data['album_title']);
$albuminfo=stripslashes($data['album_info']);
echo "";
echo " ";
echo " $albumtitle ";
if($data['photo_count']!=0){
echo $data['photo_count'].($data['photo_count']==1?LAN_403:LAN_404)." ".LAN_402.strftime($settings['shortdate'], $data['max_date']+($settings['timeoffset']*3600));
}else{
echo LAN_401;
}
if($data['max_date']!=NULL && (time()-604800) < $data['max_date']){
echo " ".LAN_406."";
}
echo "";
$img_cnt++;
if(($img_cnt%$settings['albums_per_row'])==0) echo " |
";
}
echo "
";
closetable();
echo "".makePageNav($rowstart,$settings['albums_per_page'],$albcnt,3)."
\n";
}else{
echo "
".LAN_407."
\n";
closetable();
}
}
require "side_right.php";
require "footer.php";
?>