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&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
-# æå®ããã¨ã³ããªã¼ã®ãã©ãã¯ããã¯ãåå¾ãã¾ã
-##############################################
-
-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/</</g;
- $str =~ s/>/>/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';