Yoshihisa Fukuhara
higef****@users*****
2005年 8月 25日 (木) 00:31:44 JST
Index: affelio/apps/album/AF_app.cfg
diff -u affelio/apps/album/AF_app.cfg:1.4 affelio/apps/album/AF_app.cfg:1.5
--- affelio/apps/album/AF_app.cfg:1.4 Fri Jul 1 09:02:50 2005
+++ affelio/apps/album/AF_app.cfg Thu Aug 25 00:31:44 2005
@@ -3,11 +3,11 @@
[application]
app_name=album
-app_version=1.2
-app_desc=ãã©ãã¢ã«ãã ã¢ããªã±ã¼ã·ã§ã³
+app_version=1.3
+app_desc=tHgAo
app_author=Affelio project
-guest_index=list_album.cgi
-owner_index=owner_mode.cgi
+guest_index=index.cgi
+owner_index=owner.cgi
action_types=add_image, write_comment
-action_types_desc=ç»åç»é², ã³ã¡ã³ãæ¸ãè¾¼ã¿
+action_types_desc=æo^,Rg«Ý
Index: affelio/apps/album/Album.pm
diff -u affelio/apps/album/Album.pm:1.16 affelio/apps/album/Album.pm:1.17
--- affelio/apps/album/Album.pm:1.16 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/Album.pm Thu Aug 25 00:31:44 2005
@@ -17,54 +17,43 @@
package Album;
use strict;
-
-use lib '../../extlib';
-use lib '../../lib';
-
-use lib '.';
-use Album::L10N;
-
use DBI;
use Jcode;
-use LWP::UserAgent;
-use HTTP::Request::Common qw(POST);
-#use XML::RSS;
-use AffelioApp;
use HTML::Template;
use Config::Tiny;
-
-our $max_entries = 3000;
+#use File::Basename;
+use Album::L10N;
##############################################
# Constructor
##############################################
-
sub new {
my ($proto, $afap) = @_;
unless ($afap) { die("Album::new: Error: missing username\n"); }
- my $this = {};
- $this->{afap} = $afap;
- $this->{tmpfile}= $afap->get_userdata_dir()."/.sqltmp";
- $this->{album_tb}= "album_$afap->{install_name}_entries";
- $this->{image_tb}= "album_$afap->{install_name}_images";
- $this->{comment_tb}= "album_$afap->{install_name}_comments";
- $this->{dbh} = undef;
+ my $self = {};
+ $self->{afap} = $afap;
+ $self->{tmpfile}= $afap->get_userdata_dir()."/.sqltmp";
+ $self->{album_tb}= "album_$afap->{install_name}_entries";
+ $self->{image_tb}= "album_$afap->{install_name}_images";
+ $self->{comment_tb}= "album_$afap->{install_name}_comments";
+ $self->{dbh} = undef;
#initialize
###########################
#Locale init
###########################
- $this->{lh} = Album::L10N->get_handle(($afap->get_site_info("locale"),"en_us"));
+ $self->{lh} = Album::L10N->get_handle(($afap->get_site_info("locale"),
+ $afap->get_site_info("locale")));
###########################
- unless(-f $this->{tmpfile}) {
- open(TMP,"> $this->{tmpfile}");
+ unless(-f $self->{tmpfile}) {
+ open(TMP,"> $self->{tmpfile}");
close(TMP);
- $this->{dbh} = $afap->get_userdata_dbh();
+ $self->{dbh} = $afap->get_userdata_dbh();
#Album table
my $query;
- $query="id INTEGER".get_query_primarykey($this)."
+ $query="id INTEGER".get_query_primarykey($self)."
title TEXT,
contents TEXT,
timestamp INTEGER,
@@ -74,10 +63,10 @@
pswd TEXT,
ord INTEGER";
- $this->{dbh}->do("CREATE TABLE $this->{album_tb} ($query)");
+ $self->{dbh}->do("CREATE TABLE $self->{album_tb} ($query)");
#Comment table
- $query="pkey INTEGER".get_query_primarykey($this)."
+ $query="pkey INTEGER".get_query_primarykey($self)."
id INTEGER,
user TEXT,
afid TEXT,
@@ -85,12 +74,12 @@
pswd TEXT,
timestamp INTEGER";
- $this->{dbh}->do("CREATE TABLE $this->{comment_tb} ($query)");
+ $self->{dbh}->do("CREATE TABLE $self->{comment_tb} ($query)");
# Image table
- $query="pkey INTEGER".get_query_primarykey($this)."
+ $query="pkey INTEGER".get_query_primarykey($self)."
id INTEGER,
image TEXT,
title TEXT,
@@ -100,15 +89,15 @@
pswd TEXT,
timestamp INTEGER";
- $this->{dbh}->do("CREATE TABLE $this->{image_tb} ($query)");
+ $self->{dbh}->do("CREATE TABLE $self->{image_tb} ($query)");
}
else {
- $this->{dbh} = $afap->get_userdata_dbh();
+ $self->{dbh} = $afap->get_userdata_dbh();
}
- bless $this, $proto;
- return $this;
+ bless $self, $proto;
+ return $self;
}
##############################################
@@ -116,8 +105,8 @@
##############################################
sub DESTROY {
- my $this = shift;
- $this->{dbh}->disconnect;
+ my $self = shift;
+ $self->{dbh}->disconnect;
}
@@ -126,25 +115,18 @@
##############################################
sub addAlbum {
- my ($this, $title, $contents, $user, $afid, $time) = @_;
+ my ($self, $title, $contents, $user, $afid, $time) = @_;
unless ($time) { $time = time; }
-# my ($sec, $min, $hour, $mday, $mon, $year) = localtime($time);
-# $year += 1900; $mon += 1;
- my $id = $this->getColumn("SELECT MAX(id) FROM $this->{album_tb}");
- $title = $this->validate($title);
- $user = $this->validate($user);
-# $contents = $this->validate_entry($id, $title, $contents);
- $contents = $this->validate($contents);
-
- #
-# my @same = $this->getall("SELECT id FROM $this->{album_tb} WHERE title = $title AND contents = $contents");
-# if($#same >= 0) { return; }
+ my $id = $self->getColumn("SELECT MAX(id) FROM $self->{album_tb}");
+ $title = $self->validate($title);
+ $user = $self->validate($user);
+ $contents = $self->validate($contents);
- $this->{dbh}->do("INSERT INTO $this->{album_tb} (title, contents, timestamp, update_time, user, afid, pswd, ord) VALUES ($title, $contents, $time, $time, $user, '$afid', '', '')");
- $id = $this->getColumn("SELECT MAX(id) FROM $this->{album_tb}");
+ $self->{dbh}->do("INSERT INTO $self->{album_tb} (title, contents, timestamp, update_time, user, afid, pswd, ord) VALUES ($title, $contents, $time, $time, $user, '$afid', '', '')");
+ $id = $self->getColumn("SELECT MAX(id) FROM $self->{album_tb}");
- my $data_dir=$this->{afap}->get_userdata_dir()."/";
+ my $data_dir=$self->{afap}->get_userdata_dir()."/";
$data_dir.= $id;
if (!-d $data_dir){
mkdir $data_dir, 0777;
@@ -160,23 +142,19 @@
##############################################
sub addImage {
- my ($this, $id, $title, $user, $afid, $comment, $image) = @_;
+ my ($self, $id, $title, $user, $afid, $comment, $image) = @_;
my $time = time;
-# my $id = $this->getID;
- $title = $this->validate($title);
- $comment = $this->validate($comment);
- $image = $this->validate($image);
- $user = $this->validate($user);
+ $title = $self->validate($title);
+ $comment = $self->validate($comment);
+ $image = $self->validate($image);
+ $user = $self->validate($user);
- #
-# my @same = $this->getall("SELECT id FROM $this->{image_tb} WHERE title = '$title' AND comment = '$comment'");
-# if($#same >= 0) { return; }
- my @same = $this->getall("SELECT id FROM $this->{image_tb} WHERE id = $id AND image = $image");
+ my @same = $self->getall("SELECT id FROM $self->{image_tb} WHERE id = $id AND image = $image");
if($#same > 0) {
- $this->{dbh}->do("UPDATE $this->{image_tb} SET title = $title, comment=$comment, user=$user, afid='$afid', time=$time WHERE id = $id AND image=$image");
+ $self->{dbh}->do("UPDATE $self->{image_tb} SET title = $title, comment=$comment, user=$user, afid='$afid', time=$time WHERE id = $id AND image=$image");
}else{
- $this->{dbh}->do("INSERT INTO $this->{image_tb} (id, image, title, user, afid, comment, pswd, timestamp) VALUES ($id, $image, $title, $user, '$afid', $comment, '', $time)");
+ $self->{dbh}->do("INSERT INTO $self->{image_tb} (id, image, title, user, afid, comment, pswd, timestamp) VALUES ($id, $image, $title, $user, '$afid', $comment, '', $time)");
}
}
@@ -187,11 +165,11 @@
##############################################
sub updateEntry {
- my ($this, $id, $title, $contents) = @_;
- $title = $this->validate($title);
- $contents = $this->validate($contents);
+ my ($self, $id, $title, $contents) = @_;
+ $title = $self->validate($title);
+ $contents = $self->validate($contents);
my $time = time;
- $this->{dbh}->do("UPDATE $this->{album_tb} SET title = $title, contents = $contents, update_time=$time WHERE id = $id");
+ $self->{dbh}->do("UPDATE $self->{album_tb} SET title = $title, contents = $contents, update_time=$time WHERE id = $id");
}
##############################################
@@ -199,12 +177,12 @@
##############################################
sub updateImage {
- my ($this, $id, $title, $comment, $image) = @_;
- $title = $this->validate($title);
- $comment = $this->validate($comment);
- $image = $this->validate($image);
+ my ($self, $id, $title, $comment, $image) = @_;
+ $title = $self->validate($title);
+ $comment = $self->validate($comment);
+ $image = $self->validate($image);
my $time = time;
- $this->{dbh}->do("UPDATE $this->{image_tb} SET title = $title, comment = $comment WHERE id = $id AND image=$image");
+ $self->{dbh}->do("UPDATE $self->{image_tb} SET title = $title, comment = $comment WHERE id = $id AND image=$image");
}
##############################################
@@ -212,9 +190,9 @@
##############################################
sub updateTimestamp {
- my ($this, $id) = @_;
+ my ($self, $id) = @_;
my $time = time;
- $this->{dbh}->do("UPDATE $this->{album_tb} SET update_time=$time WHERE id = $id");
+ $self->{dbh}->do("UPDATE $self->{album_tb} SET update_time=$time WHERE id = $id");
}
@@ -223,12 +201,12 @@
##############################################
sub removeAlbum {
- my ($this, $id) = @_;
- my @ret = $this->getall("SELECT * FROM $this->{image_tb} WHERE id = $id");
- $this->{dbh}->do("DELETE FROM $this->{album_tb} WHERE id = $id");
- $this->{dbh}->do("DELETE FROM $this->{comment_tb} WHERE id = $id");
- $this->{dbh}->do("DELETE FROM $this->{image_tb} WHERE id = $id");
- my $data_dir=$this->{afap}->get_userdata_dir()."/".$id."/";
+ my ($self, $id) = @_;
+ my @ret = $self->getall("SELECT * FROM $self->{image_tb} WHERE id = $id");
+ $self->{dbh}->do("DELETE FROM $self->{album_tb} WHERE id = $id");
+ $self->{dbh}->do("DELETE FROM $self->{comment_tb} WHERE id = $id");
+ $self->{dbh}->do("DELETE FROM $self->{image_tb} WHERE id = $id");
+ my $data_dir=$self->{afap}->get_userdata_dir()."/".$id."/";
my $thumb_dir=$data_dir."thumbnail/";
foreach(@ret){
unlink($thumb_dir.$_->{image});
@@ -247,13 +225,13 @@
##############################################
sub removeImage {
- my ($this, $id, @pkey) = @_;
- my $data_dir=$this->{afap}->get_userdata_dir()."/".$id."/";
+ my ($self, $id, @pkey) = @_;
+ my $data_dir=$self->{afap}->get_userdata_dir()."/".$id."/";
my $thumb_dir=$data_dir."thumbnail/";
my @ret;
foreach(@pkey){
- @ret = $this->getall("SELECT * FROM $this->{image_tb} WHERE id = $id AND pkey=$_");
- $this->{dbh}->do("DELETE FROM $this->{image_tb} WHERE id = $id AND pkey=$_");
+ @ret = $self->getall("SELECT * FROM $self->{image_tb} WHERE id = $id AND pkey=$_");
+ $self->{dbh}->do("DELETE FROM $self->{image_tb} WHERE id = $id AND pkey=$_");
unlink($data_dir.$ret[0]->{image});
unlink($thumb_dir.$ret[0]->{image});
@@ -265,9 +243,9 @@
##############################################
sub removeComment {
- my ($this, $id, @pkey) = @_;
+ my ($self, $id, @pkey) = @_;
foreach(@pkey){
- $this->{dbh}->do("DELETE FROM $this->{comment_tb} WHERE id = $id AND pkey=$_");
+ $self->{dbh}->do("DELETE FROM $self->{comment_tb} WHERE id = $id AND pkey=$_");
}
}
@@ -277,8 +255,8 @@
##############################################
sub getEntry {
- my ($this, $id) = @_;
- my @ret = $this->getall("SELECT * FROM $this->{album_tb} WHERE id = $id");
+ my ($self, $id) = @_;
+ my @ret = $self->getall("SELECT * FROM $self->{album_tb} WHERE id = $id");
return $ret[0];
}
@@ -287,18 +265,18 @@
##############################################
sub getImage {
- my ($this, $id, $pkey) = @_;
- my @ret = $this->getall("SELECT * FROM $this->{image_tb} WHERE id = $id AND pkey=$pkey");
+ my ($self, $id, $pkey) = @_;
+ my @ret = $self->getall("SELECT * FROM $self->{image_tb} WHERE id = $id AND pkey=$pkey");
return $ret[0];
}
sub getAllImage {
- my ($this, $id) = @_;
- return $this->getall("SELECT * FROM $this->{image_tb} WHERE id = $id");
+ my ($self, $id) = @_;
+ return $self->getall("SELECT * FROM $self->{image_tb} WHERE id = $id");
}
sub checkImagefile {
- my ($this, $id, $image) = @_;
- my @ret = $this->getall("SELECT * FROM $this->{image_tb} WHERE id = $id AND image='$image'");
+ my ($self, $id, $image) = @_;
+ my @ret = $self->getall("SELECT * FROM $self->{image_tb} WHERE id = $id AND image='$image'");
return $ret[0];
}
@@ -307,9 +285,9 @@
##############################################
sub getNewestEntries {
- my ($this, $num) = @_;
+ my ($self, $num) = @_;
unless ($num) { $num = 5; }
- return $this->getall("SELECT * FROM $this->{album_tb} ORDER BY update_time DESC LIMIT $num");
+ return $self->getall("SELECT * FROM $self->{album_tb} ORDER BY update_time DESC LIMIT $num");
}
##############################################
@@ -317,8 +295,8 @@
##############################################
sub getNewestAlbumId {
- my ($this) = @_;
- my @ret = $this->getall("SELECT MAX(id) as id FROM $this->{album_tb}");
+ my ($self) = @_;
+ my @ret = $self->getall("SELECT MAX(id) as id FROM $self->{album_tb}");
return $ret[0];
}
@@ -327,8 +305,8 @@
##############################################
sub getAllEntries {
- my ($this) = @_;
- return $this->getall("SELECT * FROM $this->{album_tb} ORDER BY update_time DESC");
+ my ($self) = @_;
+ return $self->getall("SELECT * FROM $self->{album_tb} ORDER BY update_time DESC");
}
@@ -337,40 +315,41 @@
##############################################
sub addComment {
- my ($this, $id, $user, $afid, $comment) = @_;
+ my ($self, $id, $user, $afid, $comment) = @_;
my $time = time;
- $user = $this->validate($user);
- $comment = $this->validate($comment);
+ $user = $self->validate($user);
+ $comment = $self->validate($comment);
#
- my @same = $this->getall("SELECT id FROM $this->{comment_tb} WHERE user = $user AND comment = $comment");
+ my @same = $self->getall("SELECT id FROM $self->{comment_tb} WHERE user = $user AND comment = $comment");
if($#same >= 0) { return; }
- $this->{dbh}->do("INSERT INTO $this->{comment_tb} (id, user, afid, comment, pswd, timestamp) VALUES ($id, $user, '$afid', $comment, '', $time)");
+ $self->{dbh}->do("INSERT INTO $self->{comment_tb} (id, user, afid, comment, pswd, timestamp) VALUES ($id, $user, '$afid', $comment, '', $time)");
}
##############################################
# getComments
##############################################
-
sub getComments {
- my ($this, $id) = @_;
- return $this->getall("SELECT * FROM $this->{comment_tb} WHERE id = $id ORDER BY timestamp");
+ my ($self, $id) = @_;
+ return $self->getall("SELECT * FROM $self->{comment_tb} WHERE id = $id ORDER BY timestamp");
}
##############################################
# getCommentsNo
##############################################
-
sub getCommentsNo {
- my ($this, $id) = @_;
- return $this->getColumn("SELECT COUNT(*) FROM $this->{comment_tb} WHERE id = $id");
+ my ($self, $id) = @_;
+ return $self->getColumn("SELECT COUNT(*) FROM $self->{comment_tb} WHERE id = $id");
}
+##############################################
+# getColumn
+##############################################
sub getColumn {
- my ($this, $query) = @_;
- my $sth = $this->{dbh}->prepare($query);
+ my ($self, $query) = @_;
+ my $sth = $self->{dbh}->prepare($query);
$sth->execute;
my $num;
$sth->bind_columns(undef, \$num);
@@ -384,173 +363,29 @@
}
}
-
-##############################################
-# getRSS
-##############################################
-
-#sub getRSS {
-# my ($this, $entno) = @_;
-# unless ($entno) { $entno = 10; }
-
-# my $rss = new XML::RSS (version => '1.0');
-# $rss->channel(
-# title => "$this->{afap}->{af}->{user__nickname}'s Diary",
-# link => "$this->{afap}->{af}->{site__web_root}/apps/diary/list_diary.pl",
-# description => "$this->{afap}->{af}->{user__nickname}'s Affelio Diary",
-# dc => {
-# creator => $this->{afap}->{af}->{user__nickname}
-# }
-# );
-
-# my @entries = $this->getNewestEntries($entno);
-# foreach(@entries) {
-# my $time = $_->{timestamp};
-# my ($sec, $min, $hour, $mday, $mon, $year) = localtime($time);
-# $year += 1900; $mon += 1;
-# my $contents = $_->{contents};
-# $contents =~ s/<br \/>/\n/g;
-# $rss->add_item(
-# title => $_->{title},
-# link => "$this->{afap}->{af}->{site__web_root}/apps/diary/list_diary.pl?year=$year&month=$mon&day=$mday",
-# description => $contents,
-# dc => {
-# date => sprintf("%4d-%02d-%02dT%02d:%02d+09:00", $year, $mon, $mday, $hour, $min),
-# creator => $this->{afap}->{af}->{nickname},
-# },
-# trackback => {
-# ping => $this->{afap}->{af}->{site__web_root}."/apps/diary/tb/tb.cgi/$_->{id}",
-# }
-# );
-# }
-
-# return $rss->as_string;
-#}
-
-
##############################################
-# getTrackbacks
+# get all columns
##############################################
+sub getall {
+ my ($self, $query) = @_;
-sub getTrackbacks {
- my ($this, $id) = @_;
- local (*IN);
-
- unless( -e "data/$id" . ".xml") { return (); }
-
- open(IN, "data/$id" . ".xml");
- my @data = <IN>;
- close(IN);
+ my $sth = $self->{dbh}->prepare($query);
+ $sth->execute;
my @ret;
- for my $i (0 .. $#data) {
- if($data[$i] =~ /^<item>/) {
- my $title = $data[$i];
- my $link = $data[++$i];
- my $description = $data[++$i];
-
- $title =~ s/^<item><title>([^>]+)<\/title>/$1/;
- $link =~ s/^<link>([^>]+)<\/link>/$1/;
- $description =~ s/^<description>([^>]+)<\/description>/$1/;
-
- push @ret, { TITLE => $title, LINK => $link, DESCRIPTION => $description };
- }
+ while(my $row = $sth->fetchrow_hashref) {
+ push @ret, $row;
}
+ $sth->finish;
+
return @ret;
}
-
-##############################################
-# getTrackbacksNo
##############################################
-
-sub getTrackbacksNo {
- my ($this, $id) = @_;
- local (*IN);
-
- unless( -e "./data/$id".".xml") { return 0; }
-
- open(IN, "./data/$id".".xml");
- my @data = <IN>;
- close(IN);
-
- my $num = 0;
- foreach(@data) {
- if($_ =~ /<item>/) { $num++; }
- }
-
- return $num;
-}
-
-
-##############################################
-# getURLDescription
-##############################################
-
-sub getURLDescription {
- my ($this, $id) = @_;
-
- my ($entry) = $this->getall("SELECT * FROM $this->{album_tb} WHERE id = $id");
- my $tmpl = new HTML::Template(filename => "./templates/tpingrdf.tmpl");
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($entry->{timestamp});
- $year += 1900; $mon += 1;
-
- $tmpl->param(
- TITLE => $entry->{title},
- TURL => "$this->{afap}->{af}->{site__web_root}/apps/diary/tb/tb.cgi/$id",
- IDENT => "$this->{afap}->{af}->{site__web_root}/apps/diary/show_diary.cgi?id=$id",
- DESCRIPTION => $entry->{contents},
- CREATOR => $this->{afap}->{af}->{user__nickname},
- DATE => sprintf("%4d-%02d-%02dT%02d:%02d+09:00", $year, $mon, $mday, $hour, $min),
- );
-
- return $tmpl->output;
-}
-
-# get unique ID
-#sub getID {
-# local (*F);
-# my $count = 0;
-
-# open(F, "+< $idfile");
-# flock(F, 2);
-# $count = <F>;
-# $count++;
-# seek(F, 0, 0);
-# print F $count;
-# flock(F, 8);
-# close(F);
-
-# return $count;
-#}
-
-# put trackback ping automaticaly
-sub validate_entry {
- my ($this, $id, $title, $contents) = @_;
- my @urls = $contents =~ /(s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/g;
-
- foreach(@urls) {
- my $url = $this->discover_tb($_);
- if($url) {
- my %form = (
- title => $title,
- excerpt => $contents,
- url => "$this->{afap}->{af}->{site__web_root}/apps/album/show_album.cgi?id=$id",
- blog_name => "$this->{afap}->{af}->{user__nickname}",
- );
- my $req = POST($url, [%form]);
- my $ua = new LWP::UserAgent;
- my $res = $ua->request($req);
- my $str = $res->as_string;
- }
- }
-
- return $this->validate($contents);
-}
-
# validate
+##############################################
sub validate {
- my ($this, $str) = @_;
+ my ($self, $str) = @_;
$str =~ s/'/"/g;
$str =~ s/"/"/g;
@@ -559,84 +394,18 @@
$str =~ s/\r\n/<br \/>/g;
$str =~ s/[\r\n]/<br \/>/g;
$str =~ s/(s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/<a href="$1">$1<\/a>/g;
- $str = $this->{dbh}->quote($str);
+ $str = $self->{dbh}->quote($str);
return $str;
}
-# get all columns
-sub getall {
- my ($this, $query) = @_;
-
- my $sth = $this->{dbh}->prepare($query);
- $sth->execute;
-
- my @ret;
- while(my $row = $sth->fetchrow_hashref) {
- push @ret, $row;
- }
- $sth->finish;
-
- return @ret;
-}
-
-# get calender
-sub weekly_days {
- my ($this, $year, $mon) = @_;
- my @weeks;
- my @mday = (31,31,28,31,30,31,30,31,31,30,31,30,31);
- if (($year % 4 == 0) and ($year % 100) or ($year % 400 == 0)) { $mday[2] = 29 };
-
- my $lastday = $mday[$mon];
- @mday = (1 .. $mday[$mon]);
- if($mon < 3){ $mon += 12; $year--; }
- my $first_day = ($year+int($year/4)-int($year/100)+int($year/400)+int((13*$mon+8)/5)+1)% 7;
-
- my $day = 1;
- for my $week (0 .. 7) {
- my @days;
- for(my $i = 0; $i < 7; $i++) {
- push @days,
- (($week == 0 and $i < $first_day) or ($day > $lastday)) ?
- '' : $day++;
- }
- $weeks[$week] = \@days;
- }
-
- return @weeks;
-}
-
-# get trackback ping.
-# refer to http://lowlife.jp/yasusii/stories/8.html
-
-sub discover_tb {
- my ($this, $url) = @_;
- my $ua = LWP::UserAgent->new;
- $ua->agent('TrackBack/1.0');
- $ua->parse_head(0);
- $ua->timeout(15);
- my $req = HTTP::Request->new(GET => $url);
- my $res = $ua->request($req);
- return unless $res->is_success;
- my $c = $res->content;
- (my $url_no_anchor = $url) =~ s/#.*$//;
- my $item;
- while ($c =~ m!(<rdf:RDF.*?</rdf:RDF>)!sg) {
- my $rdf = $1;
- my($perm_url) = $rdf =~ m!dc:identifier="([^"]+)"!;
- next unless $perm_url eq $url || $perm_url eq $url_no_anchor;
- if ($rdf =~ m!trackback:ping="([^"]+)"!) {
- return $1;
- } elsif ($rdf =~ m!about="([^"]+)"!) {
- return $1;
- }
- }
-}
+############################################################################
# get primary key for DBs
+############################################################################
sub get_query_primarykey {
- my ($this) = @_;
+ my ($self) = @_;
my $DBConfig = Config::Tiny->new();
- $DBConfig = Config::Tiny->read("$this->{afap}->{af}->{site__user_dir}/db.cfg");
+ $DBConfig = Config::Tiny->read("$self->{afap}->{af}->{site__user_dir}/db.cfg");
my $db_type = $DBConfig->{db}->{type};
my $query;
@@ -682,8 +451,27 @@
}
return($mesg);
}
-############################################################################
+############################################################################
+#Show Error
+############################################################################
+sub errorExit {
+ my ($self,$msg) = @_;
+ my $affelio_id = $self->{afap}->get_visitor_info("afid");
+ my $visitor_type=$self->{afap}->get_visitor_info("type");
+
+ if($visitor_type eq ""){
+ $visitor_type="pb";
+ }
+ my $tmpl = HTML::Template->new(filename => "./templates/error.tmpl");
+ $tmpl->param(V_TYPE => $visitor_type);
+ $tmpl->param(AF_ID => $affelio_id);
+ $tmpl->param(MSG => $msg);
+
+ print $self->translate_templateL10N( $tmpl->output );
+ print $self->{afap}->get_HTML_footer();
+ exit;
+}
1;
Index: affelio/apps/album/add_album.cgi
diff -u affelio/apps/album/add_album.cgi:1.4 affelio/apps/album/add_album.cgi:removed
--- affelio/apps/album/add_album.cgi:1.4 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/add_album.cgi Thu Aug 25 00:31:44 2005
@@ -1,55 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-our $mymode="owner";
-require './common/header.pl';
-unless ($afap->get_visitor_info("type") eq "self"){
- &errorExit('<AF_M text="Access denied">');
- }
-
-my $tmpl = HTML::Template->new(filename => "./templates/add_album.tmpl");
-
-my $title = $afap->{cgi}->param("title");
-my $contents = $afap->{cgi}->param("contents");
-my $user = $afap->get_visitor_info("nickname");
-my $afid = $afap->get_visitor_info("afid");
-
-$tmpl->param(TITLE => $title);
-$tmpl->param(CONTENTS => $contents);
-
-# Add new album
-if($afap->{cgi}->param("submit")) {
- $tmpl->param(SUBMIT => "1");
- $album->addAlbum($title, $contents, $user, $afid);
- my $ret = $album->getNewestAlbumId;
- $tmpl->param(ID => $ret->{id});
-}
-
-# Confirm
-elsif($afap->{cgi}->param("confirm")) {
- $tmpl->param(CONFIRM => "1");
-}
-
-# Edit mode
-else {
- $tmpl->param(EDIT => "1");
-}
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require './common/footer.pl';
Index: affelio/apps/album/album.cgi
diff -u /dev/null affelio/apps/album/album.cgi:1.1
--- /dev/null Thu Aug 25 00:31:44 2005
+++ affelio/apps/album/album.cgi Thu Aug 25 00:31:44 2005
@@ -0,0 +1,358 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2005 FishGrove Inc.
+#
+# 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.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#use strict;
+use lib("../../extlib");
+use lib("../../lib");
+use HTML::Template;
+use CGI;
+use Cwd;
+use File::Basename;
+use AffelioApp;
+use Album;
+
+##############################################
+# Initialize AFAP & put header
+##############################################
+our $cgi = new CGI();
+our $afap = new AffelioApp(ConfigDir => Cwd::getcwd(), cgi => $cgi);
+our $album = new Album($afap);
+
+# put Content-type
+print "Content-type: text/html; charset=UTF-8\n";
+print "Pragma: no-cache", "\n\n";
+# put HTML Header
+print $afap->get_HTML_header("Affelio Photo Album");
+# check access
+unless ($afap->check_access("DF_access")) {
+ $album->errorExit('<AF_M text="Access denied">');
+}
+
+##############################################
+# Image Viewer
+##############################################
+if ($cgi->param("mode") eq "image_view"){
+ my $id = $afap->{cgi}->param("id");
+ my $afid = $afap->get_visitor_info("afid");
+ my $pkey=$afap->{cgi}->param("pkey");
+ my $entry = $album->getEntry($id);
+ my $image_data = $album->getImage($id,$pkey);
+ my $tmpl = HTML::Template->new(filename => "./templates/image_view.tmpl");
+
+#Content Owner can edit it
+ if($afap->check_access("add_image")){
+ if($image_data->{afid} eq $afid || $afap->get_visitor_info("type") eq "self") {
+ $tmpl->param(EDIT_COMMENT => 1);
+ }
+ }
+
+# Album info
+ $tmpl->param(
+ TITLE => $entry->{title},
+ ID => $id,
+ PKEY => $pkey,
+ );
+
+ my $user_uri='';
+ if ($image_data->{user} eq ''){
+ $user_uri="Èȵ³ñ";
+ }else{
+ $user_uri='<A HREF="'.$afap->get_site_info("web_root").'/outgoing.cgi?dest_url='.$image_data->{afid}.'">'.$image_data->{user}."</A>";
+ }
+
+ $tmpl->param(IMAGE_OWNER => $user_uri);
+ if ($image_data->{title}){
+ $tmpl->param(HAS_TITLE => '1');
+ $tmpl->param(IMAGE_TITLE => $image_data->{title});
+ }
+ if ($image_data->{comment}){
+ $tmpl->param(HAS_COMMENT => '1');
+ $tmpl->param(IMAGE_COMMENT => $image_data->{comment});
+ }
+ if ($image_data->{image}){
+ $tmpl->param(HAS_IMAGE => '1');
+ $tmpl->param(IMAGE => $image_data->{image});
+ }
+
+#show image
+ my @image_files;
+ my @image_row;
+ my @image_filelist=$album->getAllImage($id);
+ $i=0;
+ $max=$#image_filelist;
+ foreach(@image_filelist){
+ if ($_->{pkey} eq $pkey){
+ if ($i>0){
+ $tmpl->param(
+ HAS_PREV => 1,
+ PREV_IMAGE=> $image_filelist[$i-1]->{pkey}
+ );
+ }
+ if ($i<$max){
+ $tmpl->param(
+ HAS_NEXT => 1,
+ NEXT_IMAGE=> $image_filelist[$i+1]->{pkey}
+ );
+ }
+ }
+ $i++;
+ }
+
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+
+##############################################
+# Edit a caption (Image Viewer)
+##############################################
+}elsif ($cgi->param("mode") eq "edit_caption"){
+ my $id = $afap->{cgi}->param("id");
+ my $afid = $afap->get_visitor_info("afid");
+ my $pkey = $afap->{cgi}->param("pkey");
+ my $image_data = $album->getImage($id,$pkey);
+
+# owner can edit it
+ if($afap->check_access("add_image")){
+ unless($image_data->{afid} eq $afid || $afap->get_visitor_info("type") eq "self") {
+ $album->errorExit('<AF_M text="Access denied">');
+ }
+ }
+
+ my $tmpl = HTML::Template->new(filename => "./templates/edit_caption.tmpl");
+
+ $tmpl->param(ID => $id, PKEY => $pkey);
+
+# done edit
+ if($afap->{cgi}->param("edit")) {
+ $album->updateImage($id, $afap->{cgi}->param("title"),
+ $afap->{cgi}->param("comment"),
+ $image_data->{image});
+ $tmpl->param(DONE => "1");
+ }
+
+# edit comment
+ elsif ($afap->{cgi}->param("comment_edit")){
+ $tmpl->param(EDIT => "1");
+ my $entry = $album->getImage($id,$pkey);
+ $entry->{comment} =~ s/<br \/>/\n/g;
+ $tmpl->param(
+ TITLE => $entry->{title},
+ COMMENT => $entry->{comment},
+ PKEY => $entry->{pkey},
+ );
+ }
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+
+##############################################
+# Write a comment (Thumbnail Viewer)
+##############################################
+}elsif ($cgi->param("mode") eq "write_comment"){
+ unless ($afap->check_access("write_comment")){
+ $album->errorExit('<AF_M text="Access denied">');
+ }
+
+ my $comment = $afap->{cgi}->param('comment');
+ my $tmpl = HTML::Template->new(filename => "./templates/write_comment.tmpl");
+ my $id = $afap->{cgi}->param('id') or exit;
+ my $user = $afap->get_visitor_info("nickname");
+ my $afid = $afap->get_visitor_info("afid");
+ my $user_uri="";
+
+ if(!$user){
+ $user = "";
+ $user_uri = 'Guest';
+ $afid="";
+ }
+ else{
+ $user_uri='<A HREF="'.$afap->get_site_info("web_root").'/outgoing.cgi?dest_url='.$afid.'">'.$user."</A>";
+ }
+
+# confirm comment
+ if($afap->{cgi}->param('comment_confirm')) {
+ $tmpl->param(CONFIRM => "1", COMMENT => $comment, ID => $id, USER_NAME => $user_uri);
+ }
+
+# submit comment
+ elsif($afap->{cgi}->param('comment_commit')) {
+ $album->addComment($id, $user, $afid, $comment);
+ $album->updateTimestamp($id);
+ $tmpl->param(COMMIT => "1", ID => $id);
+ }
+
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+
+##############################################
+# Default (Show Thumbnails)
+##############################################
+}else{
+ my $id = $afap->{cgi}->param("id");
+ my $entry = $album->getEntry($id);
+ my $edit = 0;
+ my $save_file=0;
+
+ if($afap->check_access("add_image")) {
+ $edit = 1;
+ }
+
+ my $tmpl = HTML::Template->new(filename => "./templates/album.tmpl");
+ my $col_num=4;
+
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($entry->{timestamp});
+ my ($up_sec, $up_min, $up_hour, $up_mday, $up_mon, $up_year) = localtime($entry->{update_time});
+ $mon+=1;
+ $year+=1900;
+ $up_mon+=1;
+ $up_year+=1900;
+
+# Album info
+ $tmpl->param(
+ YEAR => $year,
+ MONTH => $mon,
+ DAY => $mday,
+ UP_YEAR => $up_year,
+ UP_MONTH=> $up_mon,
+ UP_DAY => $up_mday,
+ TITLE => $entry->{title},
+ CONTENTS=> $entry->{contents},
+ ID => $id,
+ EDITABLE=> $edit,
+ );
+
+# upload image
+ if ($afap->{cgi}->param("image_upload")){
+ my $filehandle=$cgi->param("uploadingfile"); #Get file handle
+ if ($filehandle){
+ fileparse_set_fstype("MSDOS"); #For IE user
+ my $basename = basename($filehandle,"");
+ if ($basename =~ /^[a-zA-Z0-9\.\-\_]{1,32}$/ ){ #Check Filename
+ my $fname=$afap->get_userdata_dir().'/'.$id.'/'.$basename;
+ my $thumb_fname=$afap->get_userdata_dir().'/'.$id.'/thumbnail/'.$basename;
+ my $chkFile = $album->checkImagefile($id,$basename);
+ if ($chkFile->{image} eq $basename){
+ unless ($afap->{cgi}->param("rewrite")){
+ $tmpl->param(EXIST_SAMEFILE => 1);
+ $tmpl->param(UPLOAD_IMAGE => $basename);
+ }else{#override(not yet)
+ $save_file=2;
+ }
+ }else{
+ $save_file=1;
+ }
+
+ if ($save_file){
+ # Save file
+ open (OUT,">$fname") or die "Can't make serverside file!\n";
+ while (my $bytesread = read($filehandle,my $buffer,1024)){
+ print OUT $buffer;
+ }
+ close(OUT);
+
+ (eval 'use Image::Magick; 1;' ) ? ( $tmpl->param(IMAGEMAGICK => 0) ) : ( $tmpl->param(IMAGEMAGICK =>1) );
+ my $image = Image::Magick->new;
+ $image->Read( $fname );
+ $image->Resize( geometry=>"100x100" );
+ $image->Set( quality=>75 );
+ $image->Write( $thumb_fname );
+
+ my $title = $afap->{cgi}->param("title");
+ my $comment = $afap->{cgi}->param("comment");
+ my $user = $afap->get_visitor_info("nickname");
+ my $afid = $afap->get_visitor_info("afid");
+
+ if(!$user){
+ $user = '';
+ $afid = '';
+ }
+ if ($save_file=1){
+ $album->addImage($id, $title, $user, $afid, $comment, $basename);
+ }elsif($save_file=2){
+ $album->updateImage($id, $title, $comment, $basename);
+ }
+ $album->updateTimestamp($id);
+ $tmpl->param(DONE_UPLOAD => 1);
+ $tmpl->param(UPLOAD_IMAGE => $basename);
+ }
+ }else{
+ $tmpl->param(ERR_FILENAME => 1);
+ }
+ }
+ else{
+ $tmpl->param(NO_FILENAME => 1);
+ }
+ }
+
+#Show thumbnail
+ my @image_files;
+ my @image_row;
+ my @image_filelist=$album->getAllImage($id);
+ if ($#image_filelist>=0){
+ $tmpl->param(HAS_IMAGE => 1);
+ for (my $i=0; $i<($#image_filelist+1)%$col_num; $i++){
+ push @image_filelist, "";
+ }
+
+ for (my $i=0; $i<($#image_filelist+1)/$col_num; $i++){
+ my $i_num=$i*$col_num;
+ for (my $j=0; $j<$col_num; $j++){
+ push @image_files,
+ {
+ IMAGE => $image_filelist[$i_num+$j]->{image},
+ ID2 => $id,
+ PKEY => $image_filelist[$i_num+$j]->{pkey},
+ };
+ }
+ push @image_row,
+ {IMG => [@image_files[$i_num..($i_num+($col_num-1))]]};
+
+ }
+ $tmpl->param(THUMBNAIL => \@image_row);
+ }
+
+# Show Comment
+ if($album->getCommentsNo($id) > 0) {
+ $tmpl->param(HAS_COMMENTS => 1);
+ my $user_uri;
+ my @comments_param;
+ my @comments = $album->getComments($id);
+ foreach(@comments) {
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{timestamp});
+ $mon += 1;
+ if ($_->{user} eq ''){
+ $user_uri="Èȵ³ñ";
+ }else{
+ $user_uri='<A HREF="'.$afap->get_site_info("web_root").'/outgoing.cgi?dest_url='.$_->{afid}.'">'.$_->{user}."</A>";
+ }
+ push @comments_param,
+ {
+ UNAME => $user_uri,
+ COMMENT_TIME => "$mon$mdayú$hour:$min",
+ COMMENT => $_->{comment}
+ };
+ }
+ $tmpl->param(COMMENTS => \@comments_param);
+ }
+
+ if($afap->check_access("write_comment")){
+ $tmpl->param("comment_write" => "true");
+ }
+
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+}
+
+
Index: affelio/apps/album/delete_comment.cgi
diff -u affelio/apps/album/delete_comment.cgi:1.6 affelio/apps/album/delete_comment.cgi:removed
--- affelio/apps/album/delete_comment.cgi:1.6 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/delete_comment.cgi Thu Aug 25 00:31:44 2005
@@ -1,37 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require './common/header.pl';
-unless ($afap->get_visitor_info("type") eq "self"){
- &errorExit('<AF_M text="Access denied">');
-}
-
-my $tmpl = HTML::Template->new(filename => "./templates/delete_comment.tmpl");
-
-my $id = $afap->{cgi}->param("id");
-my @pkey = $afap->{cgi}->param("delete_comment");
-
-#Done
-if($afap->{cgi}->param("delete")) {
- $album->removeComment($id, @ pkey);
- $tmpl->param(DONE => "1");
-}
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require './common/footer.pl';
Index: affelio/apps/album/delete_image.cgi
diff -u affelio/apps/album/delete_image.cgi:1.6 affelio/apps/album/delete_image.cgi:removed
--- affelio/apps/album/delete_image.cgi:1.6 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/delete_image.cgi Thu Aug 25 00:31:44 2005
@@ -1,40 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require './common/header.pl';
-unless ($afap->get_visitor_info("type") eq "self"){
- &errorExit('<AF_M text="Access denied">');
- }
-
-my $tmpl = HTML::Template->new(filename => "./templates/delete_image.tmpl");
-
-my $id = $afap->{cgi}->param("id");
-my @pkey = $afap->{cgi}->param("delete_image");
-
-#$tmpl->param(ID => $id);
-
-
-# Done
-if($afap->{cgi}->param("delete")) {
- $album->removeImage($id, @ pkey);
- $tmpl->param(DONE => "1");
-}
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require './common/footer.pl';
Index: affelio/apps/album/edit_album.cgi
diff -u affelio/apps/album/edit_album.cgi:1.6 affelio/apps/album/edit_album.cgi:removed
--- affelio/apps/album/edit_album.cgi:1.6 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/edit_album.cgi Thu Aug 25 00:31:44 2005
@@ -1,116 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require './common/header.pl';
-unless ($afap->get_visitor_info("type") eq "self"){
- &errorExit('<AF_M text="Access denied">');
- }
-
-
-my $tmpl = HTML::Template->new(filename => "./templates/edit_album.tmpl");
-
-my $id = $afap->{cgi}->param("id");
-
-$tmpl->param(ID => $id);
-
-# done edit
-if($afap->{cgi}->param("edit")) {
- $album->updateEntry($id, $afap->{cgi}->param("title"), $afap->{cgi}->param("contents"));
- $tmpl->param(DONE => "1", DONE_LABEL => '<AF_M text="Information was updated.">');
-}
-
-# done delete
-elsif($afap->{cgi}->param("delete")) {
- $album->removeAlbum($id);
- $tmpl->param(DONE => "1", DONE_LABEL => '<AF_M text="The album was deleted">');
-}
-
-# confirm
-elsif($afap->{cgi}->param("delete_confirm")) {
- $tmpl->param(DELETE_CONFIRM => "1");
-}
-
-# comment edit
-elsif ($afap->{cgi}->param("comment_edit")){
- $tmpl->param(EDIT => "1");
- my $entry = $album->getEntry($id);
- $entry->{contents} =~ s/<br \/>/\n/g;
- $tmpl->param(
- TITLE => $entry->{title},
- CONTENTS => $entry->{contents},
-# DATETIME => "$entry->{year}å¹´$entry->{month}æ$entry->{day}æ¥",
- );
-}
-
-# image edit
-elsif ($afap->{cgi}->param("image_arrange")){
- $tmpl->param(ARRANGE => "1");
-
-# show thumbnails
-my $col_num=4;
-my @image_files;
-my @image_row;
-my @image_filelist=$album->getAllImage($id);
-if ($#image_filelist>=0){
- $tmpl->param(HAS_IMAGE => 1);
- for (my $i=0; $i<($#image_filelist+1)%$col_num; $i++){
- push @image_filelist, "";
- }
-
- for (my $i=0; $i<($#image_filelist+1)/$col_num; $i++){
- $i_num=$i*$col_num;
- for (my $j=0; $j<$col_num; $j++){
- push @image_files,
- {
- IMAGE => $image_filelist[$i_num+$j]->{image},
- ID2 => $id,
- PKEY=> $image_filelist[$i_num+$j]->{pkey}
- };
- }
- push @image_row,
- {IMG => [@image_files[$i_num..($i_num+($col_num-1))]]};
-
- }
- $tmpl->param(THUMBNAIL => \@image_row);
-}
-
-# comment
-if($album->getCommentsNo($id) > 0) {
- $tmpl->param(HAS_COMMENTS => 1);
- my @comments_param;
- my @comments = $album->getComments($id);
- foreach(@comments) {
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{timestamp});
- $mon += 1;
- push @comments_param,
- {
- UNAME => $_->{user},
- COMMENT_TIME => "$monæ$mdayæ¥$hour:$min",
- COMMENT => $_->{comment},
- PKEY=> $_->{pkey}
- };
- }
- $tmpl->param(COMMENTS => \@comments_param);
-}
-
-
-}
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require './common/footer.pl';
Index: affelio/apps/album/edit_comment.cgi
diff -u affelio/apps/album/edit_comment.cgi:1.6 affelio/apps/album/edit_comment.cgi:removed
--- affelio/apps/album/edit_comment.cgi:1.6 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/edit_comment.cgi Thu Aug 25 00:31:44 2005
@@ -1,64 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require './common/header.pl';
-my $id = $afap->{cgi}->param("id");
-my $pkey = $afap->{cgi}->param("pkey");
-
-# owner can edit it
-my $image_data = $album->getImage($id,$pkey);
-my $afid = $afap->get_visitor_info("afid");
-
-if($afap->check_access("add_image")){
- unless($image_data->{afid} eq $afid || $afap->get_visitor_info("type") eq "self") {
- &errorExit('<AF_M text="Access denied">');
- }
-}
-
-my $tmpl = HTML::Template->new(filename => "./templates/edit_comment.tmpl");
-
-$tmpl->param(ID => $id);
-$tmpl->param(PKEY => $pkey);
-
-
-# done edit
-if($afap->{cgi}->param("edit")) {
-#my $afid = $afap->get_visitor_info("afid");
-
-$album->updateImage($id, $afap->{cgi}->param("title"),
- $afap->{cgi}->param("comment"),
- $image_data->{image});
-#$tmpl->param(DONE => "1", DONE_LABEL => "<AF_M text="Your comment was updated.">");
-$tmpl->param(DONE => "1");
-}
-
-# edit comment
-elsif ($afap->{cgi}->param("comment_edit")){
- $tmpl->param(EDIT => "1");
- my $entry = $album->getImage($id,$pkey);
- $entry->{comment} =~ s/<br \/>/\n/g;
- $tmpl->param(
- TITLE => $entry->{title},
- COMMENT => $entry->{comment},
- PKEY => $entry->{pkey},
- );
-}
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require './common/footer.pl';
Index: affelio/apps/album/index.cgi
diff -u /dev/null affelio/apps/album/index.cgi:1.1
--- /dev/null Thu Aug 25 00:31:44 2005
+++ affelio/apps/album/index.cgi Thu Aug 25 00:31:44 2005
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2005 FishGrove Inc.
+#
+# 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.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+use strict;
+use lib("../../extlib");
+use lib("../../lib");
+use HTML::Template;
+use CGI;
+use Cwd;
+#use File::Basename;
+use AffelioApp;
+#
+use Album;
+
+
+#Initialize AFAP
+our $cgi = new CGI();
+our $afap = new AffelioApp(ConfigDir => Cwd::getcwd(), cgi => $cgi);
+our $album = new Album($afap);
+
+# put Content-type
+print "Content-type: text/html; charset=UTF-8\n";
+print "Pragma: no-cache", "\n\n";
+# put HTML Header
+print $afap->get_HTML_header("Affelio Photo Album");
+# check access
+unless ($afap->check_access("DF_access")) {
+ $album->errorExit('<AF_M text="Access denied">');
+}
+
+my $user = $afap->{cgi}->param("user");
+
+my $tmpl;
+###############################################################
+# Owner can add album
+ my $edit = 0;
+ if ($afap->get_visitor_info("type") eq "self"){
+ $edit = 1;
+ }
+
+ $tmpl = HTML::Template->new(filename => "./templates/index.tmpl");
+ my @entries_param;
+ my @entries;
+ my @images;
+ @entries = $album->getAllEntries;
+ $tmpl->param(install_title => $afap->get_app_info("install_title"), EDITABLE => $edit);
+
+ foreach(@entries) {
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{update_time});
+ $mon+=1;
+ $year+=1900;
+ @images = $album->getAllImage($_->{id});
+
+ push @entries_param,
+ {
+ MONTH => $mon,
+ DAY => $mday,
+ #TIME => sprintf("%02d:%02d", $hour, $min),
+ TITLE => $_->{title},
+ CONTENTS=> $_->{contents},
+ COMMENT_NO => $album->getCommentsNo($_->{id}),
+ ID => $_->{id},
+ IMAGE => $images[0]->{image},
+ };
+ }
+ $tmpl->param(ENTRIES => \@entries_param);
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
Index: affelio/apps/album/large_image.cgi
diff -u affelio/apps/album/large_image.cgi:1.7 affelio/apps/album/large_image.cgi:removed
--- affelio/apps/album/large_image.cgi:1.7 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/large_image.cgi Thu Aug 25 00:31:44 2005
@@ -1,94 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require './common/header.pl';
-my $id = $afap->{cgi}->param("id");
-my $pkey=$afap->{cgi}->param("pkey");
-my $entry = $album->getEntry($id);
-my $edit = 0;
-my $image_data = $album->getImage($id,$pkey);
-my $tmpl = HTML::Template->new(filename => "./templates/large_image.tmpl");
-
-#Content Owner can edit it
-my $afid = $afap->get_visitor_info("afid");
-if($afap->check_access("add_image") && ($image_data->{afid} eq $afid)) {
- $tmpl->param(EDIT_COMMENT => 1);
-}
-#Site Owner can edit it
-if ($afap->get_visitor_info("type") eq "self"){
- $tmpl->param(EDIT_COMMENT => 1);
-}
-
-
-# Album info
-$tmpl->param(
- TITLE => $entry->{title},
- ID => $id,
- PKEY => $pkey,
-);
-
-my $user_uri='';
-if ($image_data->{user} eq ''){
- $user_uri="ãªãªããã";
-}else{
- $user_uri='<A HREF="'.$afap->get_site_info("web_root").'/outgoing.cgi?dest_url='.$image_data->{afid}.'">'.$image_data->{user}."</A>";
-}
-
-$tmpl->param(IMAGE_OWNER => $user_uri);
-if ($image_data->{title}){
- $tmpl->param(HAS_TITLE => '1');
- $tmpl->param(IMAGE_TITLE => $image_data->{title});
-}
-if ($image_data->{comment}){
- $tmpl->param(HAS_COMMENT => '1');
- $tmpl->param(IMAGE_COMMENT => $image_data->{comment});
-}
-if ($image_data->{image}){
- $tmpl->param(HAS_IMAGE => '1');
- $tmpl->param(IMAGE => $image_data->{image});
-}
-
-
-
-#show image
-my @image_files;
-my @image_row;
-my @image_filelist=$album->getAllImage($id);
-$i=0;
-$max=$#image_filelist;
-foreach(@image_filelist){
- if ($_->{pkey} eq $pkey){
- if ($i>0){
- $tmpl->param(
- HAS_PREV => 1,
- PREV_IMAGE=> $image_filelist[$i-1]->{pkey}
- );
- }
- if ($i<$max){
- $tmpl->param(
- HAS_NEXT => 1,
- NEXT_IMAGE=> $image_filelist[$i+1]->{pkey}
- );
- }
- }
- $i++;
-}
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require './common/footer.pl';
Index: affelio/apps/album/list_album.cgi
diff -u affelio/apps/album/list_album.cgi:1.8 affelio/apps/album/list_album.cgi:removed
--- affelio/apps/album/list_album.cgi:1.8 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/list_album.cgi Thu Aug 25 00:31:44 2005
@@ -1,104 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require('./common/header.pl');
-my $user = $afap->{cgi}->param("user");
-my $edit = 0;
-my $col_num=4;
-
-# Owner can add album
-if ($afap->get_visitor_info("type") eq "self"){
- $edit = 1;
-}
-
-my $tmpl = HTML::Template->new(filename => "./templates/list_album.tmpl");
-my @entries_param;
-my @entries;
-my @images;
- @ entries = $album->getAllEntries;
-$tmpl->param(install_title => $afap->get_app_info("install_title"));
-$tmpl->param(EDITABLE => $edit);
-
-if ($afap->{cgi}->param("mode") eq "thumbnail"){
- $tmpl->param(THUMB => 1);
-
-#show thumbnails
-my @image_filelist;
-my @image_files;
-my @image_row;
- foreach(@entries){
- my $album_data = $album->getEntry($_->{id});
- push @image_filelist,
- {
- IMAGE => $album_data->{image},
- ID2 => $_->{id}
- }
- }
-
- for (my $i=0; $i<($#image_filelist+1)%$col_num; $i++){
- push @image_filelist, "";
- }
-
- for (my $i=0; $i<($#image_filelist+1)/$col_num; $i++){
- $i_num=$i*$col_num;
- for (my $j=0; $j<$col_num; $j++){
- my @images=$album->getAllImage($entries[$i_num+$j]->{id});
- push @image_files,
- {
-# IMAGE => $image_filelist[$i_num+$j]->{image},
- IMAGE => $images[0]->{image},
- ID2 => $id,
- };
- }
- push @image_row,
- {IMG => [@image_files[$i_num..($i_num+($col_num-1))]]};
-
- }
- $tmpl->param(THUMBNAIL => \@image_row);
-
-
-
-}else{
- my $i = 0;
- foreach(@entries) {
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{update_time});
- $mon+=1;
- $year+=1900;
- @images = $album->getAllImage($_->{id});
-
- push @entries_param,
- {
- MONTH => $mon,
- DAY => $mday,
- #TIME => sprintf("%02d:%02d", $hour, $min),
- TITLE => $_->{title},
- CONTENTS=> $_->{contents},
- COMMENT_NO => $album->getCommentsNo($_->{id}),
- TRACKBACKS => $album->getTrackbacksNo($_->{id}),
- ID => $_->{id},
- IMAGE => $images[0]->{image},
- #EDITABLE=> $edit
- };
- }
- $tmpl->param(ENTRIES => \@entries_param);
-}
-
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require("./common/footer.pl");
Index: affelio/apps/album/owner.cgi
diff -u /dev/null affelio/apps/album/owner.cgi:1.1
--- /dev/null Thu Aug 25 00:31:44 2005
+++ affelio/apps/album/owner.cgi Thu Aug 25 00:31:44 2005
@@ -0,0 +1,251 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2005 FishGrove Inc.
+#
+# 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.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#use strict;
+use lib("../../extlib");
+use lib("../../lib");
+use HTML::Template;
+use CGI;
+use Cwd;
+use AffelioApp;
+use Album;
+
+
+##############################################
+#Initialize AFAP & put header
+##############################################
+our $cgi = new CGI();
+our $afap = new AffelioApp(ConfigDir => Cwd::getcwd(), cgi => $cgi);
+our $album = new Album($afap);
+
+# put Content-type
+print "Content-type: text/html; charset=UTF-8\n";
+print "Pragma: no-cache", "\n\n";
+# put HTML Header
+print $afap->get_HTML_header("Affelio Photo Album");
+# check access
+unless ($afap->get_visitor_info("type") eq "self"){
+ $album->errorExit('<AF_M text="Access denied">');
+}
+
+##############################################
+# Add new album
+##############################################
+if ($cgi->param("mode") eq "add_album"){
+ my $tmpl = HTML::Template->new(filename => "./templates/owner/add_album.tmpl");
+ my $title = $afap->{cgi}->param("title");
+ my $contents = $afap->{cgi}->param("contents");
+ my $user = $afap->get_visitor_info("nickname");
+ my $afid = $afap->get_visitor_info("afid");
+
+ $tmpl->param(TITLE => $title, CONTENTS => $contents);
+
+ if($afap->{cgi}->param("submit")) {
+ $tmpl->param(SUBMIT => "1");
+ $album->addAlbum($title, $contents, $user, $afid);
+ my $ret = $album->getNewestAlbumId;
+ $tmpl->param(ID => $ret->{id});
+ }
+# Confirm information
+ elsif($afap->{cgi}->param("confirm")) {
+ $tmpl->param(CONFIRM => "1");
+ }
+# Edit infomation
+ else {
+ $tmpl->param(EDIT => "1");
+ }
+
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+
+##############################################
+# Delete the album
+##############################################
+}elsif ($cgi->param("mode") eq "delete_album"){
+ my $tmpl = HTML::Template->new(filename => "./templates/owner/delete_album.tmpl");
+ my $id = $afap->{cgi}->param("id");
+ $tmpl->param(ID => $id);
+
+# done delete
+ if($afap->{cgi}->param("delete")) {
+ $album->removeAlbum($id);
+ $tmpl->param(DONE => "1", DONE_LABEL => '<AF_M text="The album was deleted">');
+ }
+# confirm
+ elsif($afap->{cgi}->param("delete_confirm")) {
+ $tmpl->param(DELETE_CONFIRM => "1");
+ }
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+
+##############################################
+# Update album infomation (Title and caption)
+##############################################
+}elsif ($cgi->param("mode") eq "edit_album_caption"){
+ my $tmpl = HTML::Template->new(filename => "./templates/owner/edit_album_caption.tmpl");
+ my $id = $afap->{cgi}->param("id");
+ $tmpl->param(ID => $id);
+# done edit
+ if($afap->{cgi}->param("edit")) {
+ $album->updateEntry($id, $afap->{cgi}->param("title"), $afap->{cgi}->param("contents"));
+ $tmpl->param(DONE => "1", DONE_LABEL => '<AF_M text="Information was updated.">');
+ }
+
+# comment edit
+ elsif ($afap->{cgi}->param("comment_edit")){
+ $tmpl->param(EDIT => "1");
+ my $entry = $album->getEntry($id);
+ $entry->{contents} =~ s/<br \/>/\n/g;
+ $tmpl->param(
+ TITLE => $entry->{title},
+ CONTENTS => $entry->{contents},
+ );
+ }
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+
+##############################################
+# Manage Contents (Show thumbnail and comments)
+##############################################
+}elsif ($cgi->param("mode") eq "manage_album_content"){
+ my $tmpl = HTML::Template->new(filename => "./templates/owner/manage_album.tmpl");
+ my $id = $afap->{cgi}->param("id");
+ $tmpl->param(ID => $id);
+# image edit
+# if ($afap->{cgi}->param("image_arrange")){
+# $tmpl->param(ARRANGE => "1");
+
+# show thumbnails
+ my $col_num=4;
+ my @image_files;
+ my @image_row;
+ my @image_filelist=$album->getAllImage($id);
+ if ($#image_filelist>=0){
+ $tmpl->param(HAS_IMAGE => 1);
+ for (my $i=0; $i<($#image_filelist+1)%$col_num; $i++){
+ push @image_filelist, "";
+ }
+
+ for (my $i=0; $i<($#image_filelist+1)/$col_num; $i++){
+ my $i_num=$i*$col_num;
+ for (my $j=0; $j<$col_num; $j++){
+ push @image_files,
+ {
+ IMAGE => $image_filelist[$i_num+$j]->{image},
+ ID2 => $id,
+ PKEY=> $image_filelist[$i_num+$j]->{pkey}
+ };
+ }
+ push @image_row,
+ {IMG => [@image_files[$i_num..($i_num+($col_num-1))]]};
+ }
+ $tmpl->param(THUMBNAIL => \@image_row);
+ }
+
+# comment
+ if($album->getCommentsNo($id) > 0) {
+ $tmpl->param(HAS_COMMENTS => 1);
+ my @comments_param;
+ my @comments = $album->getComments($id);
+ foreach(@comments) {
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{timestamp});
+ $mon += 1;
+ push @comments_param,
+ {
+ UNAME => $_->{user},
+ COMMENT_TIME => "$mona??$mdaya?\$hour:$min",
+ COMMENT => $_->{comment},
+ PKEY=> $_->{pkey}
+ };
+ }
+ $tmpl->param(COMMENTS => \@comments_param);
+ }
+# }
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+
+##############################################
+# Delete Comments
+##############################################
+}elsif ($cgi->param("mode") eq "delete_comment"){
+ my $tmpl = HTML::Template->new(filename => "./templates/owner/delete_comment.tmpl");
+ my $id = $afap->{cgi}->param("id");
+ my @pkey = $afap->{cgi}->param("delete_comment");
+#Done
+ if($afap->{cgi}->param("delete")) {
+ $album->removeComment($id, @ pkey);
+ $tmpl->param(ID => "$id");
+ $tmpl->param(DONE => "1");
+ }
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+
+##############################################
+# Delete Images
+##############################################
+}elsif ($cgi->param("mode") eq "delete_image"){
+ my $tmpl = HTML::Template->new(filename => "./templates/owner/delete_image.tmpl");
+ my $id = $afap->{cgi}->param("id");
+ my @pkey = $afap->{cgi}->param("delete_image");
+# Done
+ if($afap->{cgi}->param("delete")) {
+ $album->removeImage($id, @ pkey);
+ $tmpl->param(ID => "$id");
+ $tmpl->param(DONE => "1");
+ }
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+
+##############################################
+# Default (Owner mode)
+##############################################
+}else{
+ my $tmpl = HTML::Template->new(filename => "./templates/owner/owner.tmpl");
+ $tmpl->param(access_control_URL => $afap->get_URL("access_control"));
+
+ my @entries_param;
+ my $year = $afap->{cgi}->param("year");
+ my $month = $afap->{cgi}->param("month");
+ my $day = $afap->{cgi}->param("day");
+ my @entries;
+ my @images;
+ @entries = $album->getAllEntries;;
+
+ my $i = 0;
+ foreach(@entries) {
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{update_time});
+ $mon+=1;
+ $year+=1900;
+ @images = $album->getAllImage($_->{id});
+
+ push @entries_param,
+ {
+ MONTH => $mon,
+ DAY => $mday,
+ #TIME => sprintf("%02d:%02d", $hour, $min),
+ TITLE => $_->{title},
+ CONTENTS=> $_->{contents},
+ ID => $_->{id},
+ IMAGE => $images[0]->{image},
+ EDITABLE=> 1
+ };
+ }
+ $tmpl->param(ENTRIES => \@entries_param, EDITABLE => 1);
+ $tmpl->param(install_title => $afap->get_app_info("install_title"));
+ print $album->translate_templateL10N( $tmpl->output );
+ print $afap->get_HTML_footer();
+}
Index: affelio/apps/album/owner_mode.cgi
diff -u affelio/apps/album/owner_mode.cgi:1.6 affelio/apps/album/owner_mode.cgi:removed
--- affelio/apps/album/owner_mode.cgi:1.6 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/owner_mode.cgi Thu Aug 25 00:31:44 2005
@@ -1,66 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-our $mymode="owner";
-require './common/header.pl';
-unless ($afap->get_visitor_info("type") eq "self"){
- &errorExit('<AF_M text="Access denied">');
- }
-
-my $user = $afap->{cgi}->param("user");
-my $edit = 1;
-
-# $user = $afap->get_owner_info("nickname");
-
-my $tmpl = HTML::Template->new(filename => "./templates/owner_mode.tmpl");
-$tmpl->param(access_control_URL => $afap->get_URL("access_control"));
-
-my @entries_param;
-my $year = $afap->{cgi}->param("year");
-my $month = $afap->{cgi}->param("month");
-my $day = $afap->{cgi}->param("day");
-my @entries;
-my @images;
- @ entries = $album->getAllEntries;;
-
-my $i = 0;
-foreach(@entries) {
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{update_time});
- $mon+=1;
- $year+=1900;
- @images = $album->getAllImage($_->{id});
-
- push @entries_param,
- {
- MONTH => $mon,
- DAY => $mday,
- #TIME => sprintf("%02d:%02d", $hour, $min),
- TITLE => $_->{title},
- CONTENTS=> $_->{contents},
- ID => $_->{id},
- IMAGE => $images[0]->{image},
- EDITABLE=> $edit
- };
-}
-$tmpl->param(ENTRIES => \@entries_param, EDITABLE => $edit);
-
-$tmpl->param(install_title => $afap->get_app_info("install_title"));
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require("./common/footer.pl");
Index: affelio/apps/album/show_album.cgi
diff -u affelio/apps/album/show_album.cgi:1.9 affelio/apps/album/show_album.cgi:removed
--- affelio/apps/album/show_album.cgi:1.9 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/show_album.cgi Thu Aug 25 00:31:44 2005
@@ -1,183 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require './common/header.pl';
-use File::Basename;
-my $id = $afap->{cgi}->param("id");
-my $entry = $album->getEntry($id);
-my $edit = 0;
-my $save_file=0;
-
-# Owner can edit it
-if($afap->check_access("add_image")) {
- $edit = 1;
-}
-
-my $tmpl = HTML::Template->new(filename => "./templates/show_album.tmpl");
-
-my $col_num=4;
-
-my ($sec, $min, $hour, $mday, $mon, $year) = localtime($entry->{timestamp});
-my ($up_sec, $up_min, $up_hour, $up_mday, $up_mon, $up_year) = localtime($entry->{update_time});
-$mon+=1;
-$year+=1900;
-$up_mon+=1;
-$up_year+=1900;
-
-# Album info
-$tmpl->param(
- YEAR => $year,
- MONTH => $mon,
- DAY => $mday,
- UP_YEAR => $up_year,
- UP_MONTH=> $up_mon,
- UP_DAY => $up_mday,
- TITLE => $entry->{title},
- CONTENTS=> $entry->{contents},
- ID => $id,
- EDITABLE=> $edit,
-);
-
-# upload image
-if ($afap->{cgi}->param("image_upload")){
- my $filehandle=$cgi->param("uploadingfile"); #Get file handle
- if ($filehandle){
- fileparse_set_fstype("MSDOS"); #For IE user
- my $basename = basename($filehandle,"");
- if ($basename =~ /^[a-zA-Z0-9\.\-\_]{1,32}$/ ){ #Check Filename
- my $fname=$afap->get_userdata_dir().'/'.$id.'/'.$basename;
- my $thumb_fname=$afap->get_userdata_dir().'/'.$id.'/thumbnail/'.$basename;
- my $chkFile = $album->checkImagefile($id,$basename);
-# if(-e $fname){
- if ($chkFile->{image} eq $basename){#
- unless ($afap->{cgi}->param("rewrite")){
- $tmpl->param(EXIST_SAMEFILE => 1);
- $tmpl->param(UPLOAD_IMAGE => $basename);
- }else{#override(not yet)
- $save_file=2;
- }
- }else{
- $save_file=1;
- }
-
- if ($save_file){
- # Save file
- open (OUT,">$fname") or die "Can't make serverside file!\n";
- while ($bytesread = read($filehandle,$buffer,1024)){
- print OUT $buffer;
- }
- close(OUT);
-
- (eval 'use Image::Magick; 1;' ) ? ( $tmpl->param(IMAGEMAGICK => 0) ) : ( $tmpl->param(IMAGEMAGICK =>1) );
- my $image = Image::Magick->new;
- $image->Read( $fname );
- $image->Resize( geometry=>"100x100" );
- $image->Set( quality=>75 );
- $image->Write( $thumb_fname );
-
- my $title = $afap->{cgi}->param("title");
- my $comment = $afap->{cgi}->param("comment");
- $user = $afap->get_visitor_info("nickname");
- $afid = $afap->get_visitor_info("afid");
-
- if(!$user){
- $user = '';
- $afid = '';
- }
- if ($save_file=1){
- $album->addImage($id, $title, $user, $afid, $comment, $basename);
- }elsif($save_file=2){
- $album->updateImage($id, $title, $comment, $basename);
- }
- $album->updateTimestamp($id);
- $tmpl->param(DONE_UPLOAD => 1);
- $tmpl->param(UPLOAD_IMAGE => $basename);
- }
- }else{
- $tmpl->param(ERR_FILENAME => 1);
- }
- }
- else{
- $tmpl->param(NO_FILENAME => 1);
- }
-}
-
-#Show thumbnail
-my @image_files;
-my @image_row;
- @ image_filelist=$album->getAllImage($id);
-if ($#image_filelist>=0){
- $tmpl->param(HAS_IMAGE => 1);
- for (my $i=0; $i<($#image_filelist+1)%$col_num; $i++){
- push @image_filelist, "";
- }
-
- for (my $i=0; $i<($#image_filelist+1)/$col_num; $i++){
- $i_num=$i*$col_num;
- for (my $j=0; $j<$col_num; $j++){
- push @image_files,
- {
- IMAGE => $image_filelist[$i_num+$j]->{image},
- ID2 => $id,
- PKEY => $image_filelist[$i_num+$j]->{pkey},
-# PICT=> $i_num+$j
- };
- }
- push @image_row,
- {IMG => [@image_files[$i_num..($i_num+($col_num-1))]]};
-
- }
- $tmpl->param(THUMBNAIL => \@image_row);
-}
-
-# Comment
-if($album->getCommentsNo($id) > 0) {
- $tmpl->param(HAS_COMMENTS => 1);
- my $user_uri;
- my @comments_param;
- my @comments = $album->getComments($id);
- foreach(@comments) {
- my ($sec, $min, $hour, $mday, $mon, $year) = localtime($_->{timestamp});
- $mon += 1;
- if ($_->{user} eq ''){
- $user_uri="ãªãªããã";
- }else{
- $user_uri='<A HREF="'.$afap->get_site_info("web_root").'/outgoing.cgi?dest_url='.$_->{afid}.'">'.$_->{user}."</A>";
- }
- push @comments_param,
- {
- UNAME => $user_uri,
- COMMENT_TIME => "$monæ$mdayæ¥$hour:$min",
- COMMENT => $_->{comment}
- };
- }
- $tmpl->param(COMMENTS => \@comments_param);
-}
-
-if($afap->check_access("write_comment")){
- $tmpl->param("comment_write" => "true");
-}
-
-
-#TrackbackURL(NotYet)
-
-print $album->getURLDescription($id);
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require './common/footer.pl';
Index: affelio/apps/album/show_image.cgi
diff -u affelio/apps/album/show_image.cgi:1.10 affelio/apps/album/show_image.cgi:1.11
--- affelio/apps/album/show_image.cgi:1.10 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/show_image.cgi Thu Aug 25 00:31:44 2005
@@ -18,13 +18,12 @@
use strict;
use lib("../../extlib");
+use lib("../../lib");
use CGI;
use Cwd;
-use lib("../../lib");
use AffelioApp;
our $cgi = new CGI();
-
our $afap = new AffelioApp(ConfigDir => Cwd::getcwd(),
cgi => $cgi);
Index: affelio/apps/album/write_comment.cgi
diff -u affelio/apps/album/write_comment.cgi:1.8 affelio/apps/album/write_comment.cgi:removed
--- affelio/apps/album/write_comment.cgi:1.8 Wed Jul 6 22:33:17 2005
+++ affelio/apps/album/write_comment.cgi Thu Aug 25 00:31:44 2005
@@ -1,53 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2005 FishGrove Inc.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require './common/header.pl';
-&errorExit('<AF_M text="Access denied">') unless $afap->check_access("write_comment");
-
-my $comment = $afap->{cgi}->param('comment');
-my $tmpl = HTML::Template->new(filename => "./templates/write_comment.tmpl");
-my $id = $afap->{cgi}->param('id') or exit;
-my $user = $afap->get_visitor_info("nickname");
-my $afid = $afap->get_visitor_info("afid");
-my $user_uri="";
-
- if(!$user){
- $user = "";
- $user_uri = 'Guest';
- $afid="";
- }
- else{
- $user_uri='<A HREF="'.$afap->get_site_info("web_root").'/outgoing.cgi?dest_url='.$afid.'">'.$user."</A>";
- }
-
-
-# confirm comment
-if($afap->{cgi}->param('comment_confirm')) {
- $tmpl->param(CONFIRM => "1", COMMENT => $comment, ID => $id, USER_NAME => $user_uri);
-}
-
-# submit comment
-elsif($afap->{cgi}->param('comment_commit')) {
- $album->addComment($id, $user, $afid, $comment);
- $album->updateTimestamp($id);
- $tmpl->param(COMMIT => "1", ID => $id);
-}
-
-print $album->translate_templateL10N( $tmpl->output );
-
-require './common/footer.pl';