[Affelio-cvs 122] CVS update: affelio/apps/album

Back to archive index

Yoshihisa Fukuhara higef****@users*****
2005年 6月 22日 (水) 15:38:55 JST


Index: affelio/apps/album/Album.pm
diff -u affelio/apps/album/Album.pm:1.8 affelio/apps/album/Album.pm:removed
--- affelio/apps/album/Album.pm:1.8	Wed Jun 22 15:11:47 2005
+++ affelio/apps/album/Album.pm	Wed Jun 22 15:38:55 2005
@@ -1,649 +0,0 @@
-package Album;
-
-use strict;
-
-use lib '../../extlib';
-use lib '../../lib';
-
-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;
-
-##############################################
-# コンストラクタ
-# AffelioAppを渡します
-##############################################
-
-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;
-        # 初期化
-	
-	unless(-f $this->{tmpfile}) {
-	    open(TMP,"> $this->{tmpfile}");
-	    close(TMP); 	    
-	    $this->{dbh} = $afap->get_userdata_dbh();
-		# 日記テーブル
-	    my $query;
-	    $query="id INTEGER".get_query_primarykey($this)."
-			title		TEXT,
-			contents	TEXT,
-			timestamp	INTEGER,
-			update_time	INTEGER,
-			user		TEXT,
-			afid		TEXT,
-			pswd		TEXT,
-			ord		INTEGER";
-			
-	    $this->{dbh}->do("CREATE TABLE $this->{album_tb} ($query)");
-
-		# コメントテーブル
-
-	    $query="pkey INTEGER".get_query_primarykey($this)."
-			id		INTEGER,
-			user		TEXT,
-			afid		TEXT,
-			comment		TEXT,
-			pswd		TEXT,
-			timestamp	INTEGER";
-		
-	    $this->{dbh}->do("CREATE TABLE $this->{comment_tb} ($query)");
-
-
-		# 画像テーブル
-#
-	    $query="pkey INTEGER".get_query_primarykey($this)."
-			id		INTEGER,
-			image		TEXT,
-			title		TEXT,
-			user		TEXT,
-			afid		TEXT,
-			comment		TEXT,
-			pswd		TEXT,
-			timestamp	INTEGER";
-
-	    $this->{dbh}->do("CREATE TABLE $this->{image_tb} ($query)");
-
-		$this->{dbh}->disconnect;
-	}
-	else {
-#	    $this->{dbh} = DBI->connect("dbi:SQLite:dbname=".$this->{dbpath})
-#			or die("cannot open db: ".$this->{dbpath});
-	    $this->{dbh} = $afap->get_userdata_dbh();
-        }
-
-	bless $this, $proto;
-	return $this;
-}
-
-##############################################
-# デストラクタ
-# DBへの接続を閉じます
-##############################################
-
-sub DESTROY {
-	my $this = shift;
-	$this->{dbh}->disconnect;
-}
-
-
-##############################################
-# addAlbum
-# 日記に新しいエントリを追加します。
-##############################################
-
-sub addAlbum {
-	my ($this, $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);
-
-	# 二重投稿を防ぐ
-#	my @same = $this->getall("SELECT id FROM $this->{album_tb} WHERE title = '$title' AND contents = '$contents'");
-#	if($#same >= 0) { return; }
-
-	$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}");
-
-        my $data_dir=$this->{afap}->get_userdata_dir()."/";
-  	$data_dir.= $id;
-      	if (!-d $data_dir){
-        	mkdir $data_dir, 0777;
-        }
-  	$data_dir.= "/thumbnail";
-      	if (!-d $data_dir){
-	  	mkdir $data_dir, 0777;
-        }
-}
-
-##############################################
-# addImage
-# アルバムDBに新しい画像データを追加します。
-##############################################
-
-sub addImage {
-	my ($this, $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);
-
-	# 二重投稿を防ぐ
-#	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'");
-	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'");
-        }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)");
-      	}
-}
-
-
-
-##############################################
-# updateEntry
-# 指定したIDのエントリを更新します
-##############################################
-
-sub updateEntry {
-	my ($this, $id, $title, $contents) = @_;
-	$title = $this->validate($title);
-	$contents = $this->validate($contents);
-  	my $time = time;
-	$this->{dbh}->do("UPDATE $this->{album_tb} SET title = '$title', contents = '$contents', update_time=$time WHERE id = $id");
-}
-
-##############################################
-# updateImage
-# 指定した画像情報を更新します
-##############################################
-
-sub updateImage {
-	my ($this, $id, $title, $comment, $image) = @_;
-	$title = $this->validate($title);
-	$comment = $this->validate($comment);
-  	my $time = time;
-	$this->{dbh}->do("UPDATE $this->{image_tb} SET title = '$title', comment = '$comment' WHERE id = $id AND image='$image'");
-}
-
-##############################################
-# updateTimestamp
-# 指定したIDのupdate_timeを更新します
-##############################################
-
-sub updateTimestamp {
-	my ($this, $id) = @_;
-  	my $time = time;
-	$this->{dbh}->do("UPDATE $this->{album_tb} SET update_time=$time WHERE id = $id");
-}
-
-
-##############################################
-# removeAlbum
-# 指定したIDのエントリとそれに対するコメントを削除します
-##############################################
-
-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 $thumb_dir=$data_dir."thumbnail/";
-  	foreach(@ret){
-    		unlink($thumb_dir.$_->{image});
-    		unlink($data_dir.$_->{image});
-        }
-	if (-d $thumb_dir){
-      		rmdir $thumb_dir;
-      	}
-	if (-d $data_dir){
-     		rmdir $data_dir;
-      	}
-}
-
-##############################################
-# removeImage
-# 指定した画像情報を削除します。
-##############################################
-
-sub removeImage {
-	my ($this, $id, @pkey) = @_;
-        my $data_dir=$this->{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=$_");
-          	
-  		unlink($data_dir.$ret[0]->{image});
-	  	unlink($thumb_dir.$ret[0]->{image});
-  	}
-}
-
-##############################################
-# removeComment
-# 指定したコメント情報を削除します。
-##############################################
-
-sub removeComment {
-	my ($this, $id, @pkey) = @_;
-  	foreach(@pkey){
-		$this->{dbh}->do("DELETE FROM $this->{comment_tb} WHERE id = $id AND pkey=$_");
-      	}
-}
-
-
-##############################################
-# getEntry
-# 指定したIDのエントリの内容を取得します
-##############################################
-
-sub getEntry {
-	my ($this, $id) = @_;
-	my @ret = $this->getall("SELECT * FROM $this->{album_tb} WHERE id = $id");
-	return $ret[0];
-}
-
-##############################################
-# getImage
-# 指定したIDとimageの内容を取得します
-##############################################
-
-sub getImage {
-	my ($this, $id, $pkey) = @_;
-	my @ret = $this->getall("SELECT * FROM $this->{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");
-}
-
-sub checkImagefile {
-	my ($this, $id, $image) = @_;
-	my @ret = $this->getall("SELECT * FROM $this->{image_tb} WHERE id = $id AND image='$image'");
-	return $ret[0];
-}
-
-##############################################
-# getNewestEntries
-# 日時に関係なく最新のエントリを取得します。
-##############################################
-
-sub getNewestEntries {
-	my ($this, $num) = @_;
-	unless ($num) { $num = 5; }
-	return $this->getall("SELECT * FROM $this->{album_tb} ORDER BY update_time DESC LIMIT $num");
-}
-
-##############################################
-# getNewestAlbumId
-# 最新アルバムのIDを取得。
-##############################################
-
-sub getNewestAlbumId {
-  	my ($this) = @_;
-  	my @ret = $this->getall("SELECT MAX(id) as id FROM $this->{album_tb}");
-  	return $ret[0];
-}
-
-##############################################
-# getAllEntries
-# すべてのエントリを取得します。
-##############################################
-
-sub getAllEntries {
-	my ($this) = @_;
-	return $this->getall("SELECT * FROM $this->{album_tb} ORDER BY update_time DESC");
-}
-
-
-##############################################
-# addComment
-# 指定したIDのエントリにコメントをつけます
-##############################################
-
-sub addComment {
-	my ($this, $id, $user, $afid, $comment) = @_;
-	my $time = time;
-	$user = $this->validate($user);
-#	$comment = $this->validate($comment);
-	
-	# 二重投稿を防ぐ
-	my @same = $this->getall("SELECT id FROM $this->{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)");
-}
-
-
-##############################################
-# getComments
-# 指定したIDのエントリに対するコメントを取得します
-##############################################
-
-sub getComments {
-	my ($this, $id) = @_;
-	return $this->getall("SELECT * FROM $this->{comment_tb} WHERE id = $id ORDER BY timestamp");
-}
-
-##############################################
-# getCommentsNo
-# 指定したIDのエントリに対するコメント数を取得します
-##############################################
-
-sub getCommentsNo {
-	my ($this, $id) = @_;
-	return $this->getColumn("SELECT COUNT(*) FROM $this->{comment_tb} WHERE id = $id");
-}
-
-sub getColumn {
-	my ($this, $query) = @_;
-	my $sth = $this->{dbh}->prepare($query);
-	$sth->execute;
-	my $num;
-	$sth->bind_columns(undef, \$num);
-	$sth->fetch;
-	$sth->finish;
-	if($num) {
-		return $num;
-	}
-	else {
-		return 0;
-	}
-}
-
-
-##############################################
-# getRSS
-# 指定したエントリー分のRDFを取得します
-##############################################
-
-#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&amp;month=$mon&amp;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
-# 指定したエントリーのトラックバックを取得します
-##############################################
-
-sub getTrackbacks {
-	my ($this, $id) = @_;
-	local (*IN);
-
-	unless( -e  "data/$id" . ".xml") { return (); }
-	
-	open(IN, "data/$id" . ".xml");
-	my @data = <IN>;
-	close(IN);
-
-	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 };
-		}
-	}
-	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
-# トラックバックURLを知らせるためのRDFを出力します
-##############################################
-
-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;
-}
-
-# 日記に振るユニークな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;
-#}
-
-# トラックバックPINGを自動的に飛ばす
-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}のAffelioアルバム",
-			);
-			my $req = POST($url, [%form]);
-			my $ua = new LWP::UserAgent;
-			my $res = $ua->request($req);
-			my $str = $res->as_string;
-		}
-	}
-
-	return $this->validate($contents);
-}
-
-# タグ、カンマ、改行の除去
-sub validate {
-	my ($this, $str) = @_;
-
-	$str =~ s/,/、/g;
-	$str =~ s/'/’/g;
-	$str =~ s/"/”/g;
-	$str =~ s/</&lt;/g;
-	$str =~ s/>/&gt;/g;
-	$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;
-	return $str;
-}
-
-# クエリに合致するすべてのカラムを取得
-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;
-}
-
-# 指定した月のカレンダーをとってくる
-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;
-}
-
-# 張られたURLに対してトラックバックPINGURLを取得します
-# 参考: 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;
-		}
-	}
-}
-
-sub get_query_primarykey {
-    my ($this) = @_;
-    my $DBConfig = Config::Tiny->new();
-    $DBConfig = Config::Tiny->read("$this->{afap}->{af}->{site__user_dir}/db.cfg");
-    my $db_type = $DBConfig->{db}->{type};
-    my $query;
-
-    if ($db_type eq "sqlite"){
-	$query = " PRIMARY KEY,";
-    }elsif ($db_type eq "mysql"){
-	$query = " AUTO_INCREMENT PRIMARY KEY,";
-    }
-    return $query;
-}
-
-1;
Index: affelio/apps/album/delete_comment.cgi
diff -u affelio/apps/album/delete_comment.cgi:1.2 affelio/apps/album/delete_comment.cgi:removed
--- affelio/apps/album/delete_comment.cgi:1.2	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/delete_comment.cgi	Wed Jun 22 15:38:55 2005
@@ -1,24 +0,0 @@
-#!/usr/bin/perl
-
-require './common/header.pl';
-unless ($afap->get_visitor_info("type") eq "self"){
-	&errorExit("あなたはこのページにアクセスする権限がありません")
-        }
-
-my $tmpl = HTML::Template->new(filename => "./templates/delete_comment.tmpl");
-
-my $id = $afap->{cgi}->param("id");
-my @pkey = $afap->{cgi}->param("delete_comment");
-
-#$tmpl->param(ID => $id);
-
-
-# 削除完了
-if($afap->{cgi}->param("delete")) {
-	$album->removeComment($id, @ pkey);
-	$tmpl->param(DONE => "1", DONE_LABEL => "削除しました");
-}
-
-print $tmpl->output;
-
-require './common/footer.pl';
Index: affelio/apps/album/delete_image.cgi
diff -u affelio/apps/album/delete_image.cgi:1.2 affelio/apps/album/delete_image.cgi:removed
--- affelio/apps/album/delete_image.cgi:1.2	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/delete_image.cgi	Wed Jun 22 15:38:55 2005
@@ -1,24 +0,0 @@
-#!/usr/bin/perl
-
-require './common/header.pl';
-unless ($afap->get_visitor_info("type") eq "self"){
-	&errorExit("あなたはこのページにアクセスする権限がありません")
-        }
-
-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);
-
-
-# 削除完了
-if($afap->{cgi}->param("delete")) {
-	$album->removeImage($id, @ pkey);
-	$tmpl->param(DONE => "1", DONE_LABEL => "削除しました");
-}
-
-print $tmpl->output;
-
-require './common/footer.pl';
Index: affelio/apps/album/edit_album.cgi
diff -u affelio/apps/album/edit_album.cgi:1.2 affelio/apps/album/edit_album.cgi:removed
--- affelio/apps/album/edit_album.cgi:1.2	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/edit_album.cgi	Wed Jun 22 15:38:55 2005
@@ -1,99 +0,0 @@
-#!/usr/bin/perl
-
-require './common/header.pl';
-unless ($afap->get_visitor_info("type") eq "self"){
-	&errorExit("あなたはこのページにアクセスする権限がありません")
-        }
-
-
-my $tmpl = HTML::Template->new(filename => "./templates/edit_album.tmpl");
-
-my $id = $afap->{cgi}->param("id");
-
-$tmpl->param(ID => $id);
-
-# 編集完了
-if($afap->{cgi}->param("edit")) {
-	$album->updateEntry($id, $afap->{cgi}->param("title"), $afap->{cgi}->param("contents"));
-	$tmpl->param(DONE => "1", DONE_LABEL => "内容を変更しました");
-}
-
-# 削除完了
-elsif($afap->{cgi}->param("delete")) {
-	$album->removeAlbum($id);
-	$tmpl->param(DONE => "1", DONE_LABEL => "削除しました");
-}
-
-# 確認
-elsif($afap->{cgi}->param("delete_confirm")) {
-	$tmpl->param(DELETE_CONFIRM => "1");
-}
-
-# コメント編集画面
-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}日",
-	);
-}
-
-# 画像編集画面
-elsif ($afap->{cgi}->param("image_arrange")){
-	$tmpl->param(ARRANGE => "1");
-
-# サムネイルの表示
-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);
-}
-
-# コメント
-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 $tmpl->output;
-
-require './common/footer.pl';
Index: affelio/apps/album/edit_comment.cgi
diff -u affelio/apps/album/edit_comment.cgi:1.2 affelio/apps/album/edit_comment.cgi:removed
--- affelio/apps/album/edit_comment.cgi:1.2	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/edit_comment.cgi	Wed Jun 22 15:38:55 2005
@@ -1,48 +0,0 @@
-#!/usr/bin/perl
-
-require './common/header.pl';
-my $id = $afap->{cgi}->param("id");
-my $pkey = $afap->{cgi}->param("pkey");
-
-# 本人(編集可)
-# サイトオーナー(編集可)
-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("あなたはこのページにアクセスする権限がありません");
-        }
-}
-
-my $tmpl = HTML::Template->new(filename => "./templates/edit_comment.tmpl");
-
-$tmpl->param(ID => $id);
-$tmpl->param(PKEY => $pkey);
-
-
-# 編集完了
-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 => "内容を変更しました");
-}
-
-# コメント編集画面
-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 $tmpl->output;
-
-require './common/footer.pl';
Index: affelio/apps/album/large_image.cgi
diff -u affelio/apps/album/large_image.cgi:1.2 affelio/apps/album/large_image.cgi:removed
--- affelio/apps/album/large_image.cgi:1.2	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/large_image.cgi	Wed Jun 22 15:38:55 2005
@@ -1,78 +0,0 @@
-#!/usr/bin/perl
-
-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");
-
-# 本人(編集可)
-my $afid = $afap->get_visitor_info("afid");
-if($afap->check_access("add_image") && ($image_data->{afid} eq $afid)) {
-    $tmpl->param(EDIT_COMMENT => 1);
-}
-# サイトオーナー(編集可)
-if ($afap->get_visitor_info("type") eq "self"){
-    $tmpl->param(EDIT_COMMENT => 1);
-}
-
-
-# アルバム情報
-$tmpl->param(
-	TITLE	=> $entry->{title},
-	ID	=> $id,
-  	PKEY	=> $pkey,
-);
-
-my $user_uri='';
-if ($image_data->{user} eq ''){
-	$user_uri="ななしさん";
-}else{
-	$user_uri='<A HREF="'.$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});
-}
-
-
-
-# 画像表示
-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 $tmpl->output;
-
-require './common/footer.pl';
Index: affelio/apps/album/list_album.cgi
diff -u affelio/apps/album/list_album.cgi:1.3 affelio/apps/album/list_album.cgi:removed
--- affelio/apps/album/list_album.cgi:1.3	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/list_album.cgi	Wed Jun 22 15:38:55 2005
@@ -1,87 +0,0 @@
-#!/usr/bin/perl
-
-require('./common/header.pl');
-my $user = $afap->{cgi}->param("user");
-my $edit = 0;
-my $col_num=4;
-
-# 本人(アルバム追加可)
-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);
-
-# サムネイルの表示
-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 $tmpl->output;
-
-require("./common/footer.pl");
Index: affelio/apps/album/owner_mode.cgi
diff -u affelio/apps/album/owner_mode.cgi:1.2 affelio/apps/album/owner_mode.cgi:removed
--- affelio/apps/album/owner_mode.cgi:1.2	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/owner_mode.cgi	Wed Jun 22 15:38:55 2005
@@ -1,50 +0,0 @@
-#!/usr/bin/perl
-
-our $mymode="owner";
-require './common/header.pl';
-unless ($afap->get_visitor_info("type") eq "self"){
-	&errorExit("あなたはこのページにアクセスする権限がありません")
-        }
-
-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 $tmpl->output;
-
-require("./common/footer.pl");
Index: affelio/apps/album/show_album.cgi
diff -u affelio/apps/album/show_album.cgi:1.3 affelio/apps/album/show_album.cgi:removed
--- affelio/apps/album/show_album.cgi:1.3	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/show_album.cgi	Wed Jun 22 15:38:55 2005
@@ -1,169 +0,0 @@
-#!/usr/bin/perl
-
-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;
-
-# 本人(編集可)
-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;
-
-# アルバム情報
-$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,
-);
-
-#画像の登録処理
-if ($afap->{cgi}->param("image_upload")){
- 	my $filehandle=$cgi->param("uploadingfile");#ファイル名(ハンドル)を取得
-  	if ($filehandle){
-  		fileparse_set_fstype("MSDOS"); #IE対策。うまく動かないかも?!
-  		my $basename  = basename($filehandle,"");
-  		if ($basename =~ /^[a-zA-Z0-9\.\-\_]{1,32}$/ ){#ファイル名チェック
-			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{#上書き (未実装)
-				$save_file=2;
-                          }
-                        }else{
-				$save_file=1;
-                        }
-
-                  	if ($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(IMAGE<AGICK =>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);
-      	}
-}
-
-# サムネイルの表示
-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);
-}
-
-# コメント
-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="'.$_->{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");
-}
-
-
-# トラックバックURLの通知
-
-print $album->getURLDescription($id);
-
-print $tmpl->output;
-
-require './common/footer.pl';
Index: affelio/apps/album/show_image.cgi
diff -u affelio/apps/album/show_image.cgi:1.3 affelio/apps/album/show_image.cgi:removed
--- affelio/apps/album/show_image.cgi:1.3	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/show_image.cgi	Wed Jun 22 15:38:55 2005
@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-use strict;
-
-#use lib("../../extlib");
-use CGI;
-use Cwd;
-use lib("../../lib");
-use AffelioApp;
-
-our $cgi = new CGI();
-#AffelioAppを初期化
-our $afap = new AffelioApp(ConfigDir => Cwd::getcwd(),
-			   cgi => $cgi);
-
-# 読み込みアクセス権限をチェック
-if ($afap->check_access("DF_access")) {
-  my $image = $afap->{cgi}->param('image');
-  my $id = $afap->{cgi}->param('id');
-  my $type = $afap->{cgi}->param('type');
-  my $filepath;
-  if ($type eq "thumbnail") {
-	$filepath = $afap->get_userdata_dir()."/".$id."/thumbnail/".$image;
-  }elsif($type eq "large"){
-	$filepath = $afap->get_userdata_dir()."/".$id."/".$image;
-  }else{
-	$filepath = "./resource/emp.jpg";
-  }
-  if ($image eq ""){
-	$filepath = "./resource/emp.jpg";
-  }
-  my $imgtype = 'jpeg';
-
-#// 画像オープン
-  open(IMG, "$filepath") or die;
-
-#// イメージ表示
-  binmode IMG;
-  binmode STDOUT;
-  print "Content-type: image/$imgtype\n\n";
-  print while (<IMG>);
-
-#// 画像クローズ
-  close(IMG);
-}
-  exit(0);
Index: affelio/apps/album/write_comment.cgi
diff -u affelio/apps/album/write_comment.cgi:1.2 affelio/apps/album/write_comment.cgi:removed
--- affelio/apps/album/write_comment.cgi:1.2	Wed Jun 22 15:16:22 2005
+++ affelio/apps/album/write_comment.cgi	Wed Jun 22 15:38:55 2005
@@ -1,38 +0,0 @@
-#!/usr/bin/perl
-
-require './common/header.pl';
-
-&errorExit("あなたはこのページに書き込み権限がありません") 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 = 'ななしさん';
-       $afid="";
-    }
-     else{
-	$user_uri = '<A HREF="' . $afid . '">' . $user . "</A>";
-    }
-
-
-# コメント確認画面
-if($afap->{cgi}->param('comment_confirm')) {
-	$tmpl->param(CONFIRM => "1", COMMENT => $album->validate($comment), ID => $id, USER_NAME => $user_uri);
-}
-
-# コメントをコミット
-elsif($afap->{cgi}->param('comment_commit')) {
-    $album->addComment($id, $user, $afid, $comment);
-    $album->updateTimestamp($id);
-    $tmpl->param(COMMIT => "1", ID => $id);
-}
-
-print $tmpl->output;
-
-require './common/footer.pl';


Affelio-cvs メーリングリストの案内
Back to archive index