Tadashi Okoshi
slash****@users*****
2005年 10月 25日 (火) 04:20:44 JST
Index: affelio_farm/admin/skelton/affelio/apps/album/AF_app.cfg
diff -u affelio_farm/admin/skelton/affelio/apps/album/AF_app.cfg:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/album/AF_app.cfg:removed
--- affelio_farm/admin/skelton/affelio/apps/album/AF_app.cfg:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/album/AF_app.cfg Tue Oct 25 04:20:44 2005
@@ -1,13 +0,0 @@
-[this_installation]
-title=Album
-
-[application]
-app_name=album
-app_version=1.3
-app_desc=ãã©ãã¢ã«ãã
-app_author=Affelio project
-guest_index=index.cgi
-owner_index=owner.cgi
-action_types=add_image, write_comment
-action_types_desc=ç»åç»é²,ã³ã¡ã³ãæ¸ãè¾¼ã¿
-
Index: affelio_farm/admin/skelton/affelio/apps/album/Album.pm
diff -u affelio_farm/admin/skelton/affelio/apps/album/Album.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/album/Album.pm:removed
--- affelio_farm/admin/skelton/affelio/apps/album/Album.pm:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/album/Album.pm Tue Oct 25 04:20:44 2005
@@ -1,480 +0,0 @@
-# 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.
-
-package Album;
-
-use strict;
-use DBI;
-use Jcode;
-use HTML::Template;
-use Config::Tiny;
-use Album::L10N;
-
-##############################################
-# Constructor
-##############################################
-sub new {
- my ($proto, $afap) = @_;
- unless ($afap) { die("Album::new: Error: missing username\n"); }
-
- 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
- ###########################
- $self->{lh} = Album::L10N->get_handle(($afap->get_site_info("locale"),
- $afap->get_site_info("locale")));
- ###########################
-
- unless(-f $self->{tmpfile}) {
- open(TMP,"> $self->{tmpfile}");
- close(TMP);
- $self->{dbh} = $afap->get_userdata_dbh();
- #Album table
- my $query;
- $query="id INTEGER".get_query_primarykey($self)."
- title TEXT,
- contents TEXT,
- timestamp INTEGER,
- update_time INTEGER,
- user TEXT,
- afid TEXT,
- pswd TEXT,
- ord INTEGER";
-
- $self->{dbh}->do("CREATE TABLE $self->{album_tb} ($query)");
-
- #Comment table
- $query="pkey INTEGER".get_query_primarykey($self)."
- id INTEGER,
- user TEXT,
- afid TEXT,
- comment TEXT,
- pswd TEXT,
- timestamp INTEGER";
-
- $self->{dbh}->do("CREATE TABLE $self->{comment_tb} ($query)");
-
-
-
- # Image table
- $query="pkey INTEGER".get_query_primarykey($self)."
- id INTEGER,
- image TEXT,
- title TEXT,
- user TEXT,
- afid TEXT,
- comment TEXT,
- pswd TEXT,
- timestamp INTEGER";
-
- $self->{dbh}->do("CREATE TABLE $self->{image_tb} ($query)");
-
- }
- else {
- $self->{dbh} = $afap->get_userdata_dbh();
- }
-
- bless $self, $proto;
- return $self;
-}
-
-##############################################
-# destructor
-##############################################
-
-sub DESTROY {
- my $self = shift;
- $self->{dbh}->disconnect;
-}
-
-
-##############################################
-# addAlbum
-##############################################
-
-sub addAlbum {
- my ($self, $title, $contents, $user, $afid, $time) = @_;
- unless ($time) { $time = time; }
-
- my $id = $self->getColumn("SELECT MAX(id) FROM $self->{album_tb}");
- $title = $self->validate($title);
- $user = $self->validate($user);
- $contents = $self->validate($contents);
-
- $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=$self->{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
-##############################################
-
-sub addImage {
- my ($self, $id, $title, $user, $afid, $comment, $image) = @_;
- my $time = time;
-
- $title = $self->validate($title);
- $comment = $self->validate($comment);
- $image = $self->validate($image);
- $user = $self->validate($user);
-
- my @same = $self->getall("SELECT id FROM $self->{image_tb} WHERE id = $id AND image = $image");
- if($#same > 0) {
- $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{
- $self->{dbh}->do("INSERT INTO $self->{image_tb} (id, image, title, user, afid, comment, pswd, timestamp) VALUES ($id, $image, $title, $user, '$afid', $comment, '', $time)");
- }
-}
-
-
-
-##############################################
-# updateEntry
-##############################################
-
-sub updateEntry {
- my ($self, $id, $title, $contents) = @_;
- $title = $self->validate($title);
- $contents = $self->validate($contents);
- my $time = time;
- $self->{dbh}->do("UPDATE $self->{album_tb} SET title = $title, contents = $contents, update_time=$time WHERE id = $id");
-}
-
-##############################################
-# updateImage
-##############################################
-
-sub updateImage {
- my ($self, $id, $title, $comment, $image) = @_;
- $title = $self->validate($title);
- $comment = $self->validate($comment);
- $image = $self->validate($image);
- my $time = time;
- $self->{dbh}->do("UPDATE $self->{image_tb} SET title = $title, comment = $comment WHERE id = $id AND image=$image");
-}
-
-##############################################
-# updateTimestamp
-##############################################
-
-sub updateTimestamp {
- my ($self, $id) = @_;
- my $time = time;
- $self->{dbh}->do("UPDATE $self->{album_tb} SET update_time=$time WHERE id = $id");
-}
-
-
-##############################################
-# removeAlbum
-##############################################
-
-sub removeAlbum {
- 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});
- unlink($data_dir.$_->{image});
- }
- if (-d $thumb_dir){
- rmdir $thumb_dir;
- }
- if (-d $data_dir){
- rmdir $data_dir;
- }
-}
-
-##############################################
-# removeImage
-##############################################
-
-sub removeImage {
- my ($self, $id, @pkey) = @_;
- my $data_dir=$self->{afap}->get_userdata_dir()."/".$id."/";
- my $thumb_dir=$data_dir."thumbnail/";
- my @ret;
- foreach(@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});
- }
-}
-
-##############################################
-# removeComment
-##############################################
-
-sub removeComment {
- my ($self, $id, @pkey) = @_;
- foreach(@pkey){
- $self->{dbh}->do("DELETE FROM $self->{comment_tb} WHERE id = $id AND pkey=$_");
- }
-}
-
-
-##############################################
-# getEntry
-##############################################
-
-sub getEntry {
- my ($self, $id) = @_;
- my @ret = $self->getall("SELECT * FROM $self->{album_tb} WHERE id = $id");
- return $ret[0];
-}
-
-##############################################
-# getImage
-##############################################
-
-sub getImage {
- 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 ($self, $id) = @_;
- return $self->getall("SELECT * FROM $self->{image_tb} WHERE id = $id");
-}
-
-sub checkImagefile {
- my ($self, $id, $image) = @_;
- my @ret = $self->getall("SELECT * FROM $self->{image_tb} WHERE id = $id AND image='$image'");
- return $ret[0];
-}
-
-##############################################
-# getNewestEntries
-##############################################
-
-sub getNewestEntries {
- my ($self, $num) = @_;
- unless ($num) { $num = 5; }
- return $self->getall("SELECT * FROM $self->{album_tb} ORDER BY update_time DESC LIMIT $num");
-}
-
-##############################################
-# getNewestAlbumId
-##############################################
-
-sub getNewestAlbumId {
- my ($self) = @_;
- my @ret = $self->getall("SELECT MAX(id) as id FROM $self->{album_tb}");
- return $ret[0];
-}
-
-##############################################
-# getAllEntries
-##############################################
-
-sub getAllEntries {
- my ($self) = @_;
- return $self->getall("SELECT * FROM $self->{album_tb} ORDER BY update_time DESC");
-}
-
-
-##############################################
-# addComment
-##############################################
-
-sub addComment {
- my ($self, $id, $user, $afid, $comment) = @_;
- my $time = time;
- $user = $self->validate($user);
- $comment = $self->validate($comment);
-
- #
- my @same = $self->getall("SELECT id FROM $self->{comment_tb} WHERE user = $user AND comment = $comment");
- if($#same >= 0) { return; }
-
- $self->{dbh}->do("INSERT INTO $self->{comment_tb} (id, user, afid, comment, pswd, timestamp) VALUES ($id, $user, '$afid', $comment, '', $time)");
-}
-
-
-##############################################
-# getComments
-##############################################
-sub getComments {
- my ($self, $id) = @_;
- return $self->getall("SELECT * FROM $self->{comment_tb} WHERE id = $id ORDER BY timestamp");
-}
-
-##############################################
-# getCommentsNo
-##############################################
-sub getCommentsNo {
- my ($self, $id) = @_;
- return $self->getColumn("SELECT COUNT(*) FROM $self->{comment_tb} WHERE id = $id");
-}
-
-##############################################
-# getColumn
-##############################################
-sub getColumn {
- my ($self, $query) = @_;
- my $sth = $self->{dbh}->prepare($query);
- $sth->execute;
- my $num;
- $sth->bind_columns(undef, \$num);
- $sth->fetch;
- $sth->finish;
- if($num) {
- return $num;
- }
- else {
- return 0;
- }
-}
-
-##############################################
-# get all columns
-##############################################
-sub getall {
- my ($self, $query) = @_;
-
- my $sth = $self->{dbh}->prepare($query);
- $sth->execute;
-
- my @ret;
- while(my $row = $sth->fetchrow_hashref) {
- push @ret, $row;
- }
- $sth->finish;
-
- return @ret;
-}
-
-##############################################
-# validate
-##############################################
-sub validate {
- my ($self, $str) = @_;
-
- $str =~ s/[\t\a]//g;
- $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;
- $str = $self->{dbh}->quote($str);
- return $str;
-}
-
-
-############################################################################
-# get primary key for DBs
-############################################################################
-sub get_query_primarykey {
- my ($self) = @_;
- my $DBConfig = Config::Tiny->new();
- $DBConfig = Config::Tiny->read("$self->{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;
-}
-
-
-############################################################################
-#L10N added by slash
-############################################################################
-sub translate_templateL10N{
- my $af=shift;
- my $mesg = shift;
-
- my $tag_body ="";
- my $text_value="";
- my $param_value="";
-
- while( $mesg =~ /<AF_M ([^>]+)>/ ){
- $tag_body = $1;
-
- $tag_body =~ /text(\s*)=(\s*)["']([^"']*)["'](\s*)param(\s*)=(\s*)["']([^"']*)["']/;
- $text_value=$3;
- $param_value=$7;
- if($text_value eq ""){
- $tag_body =~ /text(\s*)=(\s*)["']([^"']*)["']/;
- $text_value=$3;
- }
-
- my $sbst = $af->{lh}->maketext($text_value, $param_value);
-
-# debug_print("Album::translate tag_body = [$tag_body]\n");
-# debug_print("Album::translate \t text=[$text_value]\n");
-# debug_print("Album::translate \t param=[$param_value]\n");
-# debug_print("Album::translate \t sbst=[$sbst]\n");
-
- $mesg =~ s/\Q<AF_M $tag_body>\E/$sbst/g;
- }
- 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_farm/admin/skelton/affelio/apps/album/album.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/album/album.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/album/album.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/album/album.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/album/album.cgi Tue Oct 25 04:20:44 2005
@@ -1,362 +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.
-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);
- my $i=0;
- my $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,
- {
- image => "",
- pkey => "",
- }
- }
-
- 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="Guest";
- }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_farm/admin/skelton/affelio/apps/album/index.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/album/index.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/album/index.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/album/index.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/album/index.cgi Tue Oct 25 04:20:44 2005
@@ -1,80 +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.
-use strict;
-use lib("../../extlib");
-use lib("../../lib");
-use HTML::Template;
-use CGI;
-use Cwd;
-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_farm/admin/skelton/affelio/apps/album/owner.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/album/owner.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/album/owner.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/album/owner.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/album/owner.cgi Tue Oct 25 04:20:44 2005
@@ -1,255 +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.
-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,
- {
- image => "",
- pkey => "",
- }
- }
-
- 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 => "$mon/$mday/$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_farm/admin/skelton/affelio/apps/album/show_image.cgi
diff -u affelio_farm/admin/skelton/affelio/apps/album/show_image.cgi:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/album/show_image.cgi:removed
--- affelio_farm/admin/skelton/affelio/apps/album/show_image.cgi:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/album/show_image.cgi Tue Oct 25 04:20:44 2005
@@ -1,60 +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.
-
-use strict;
-use lib("../../extlib");
-use lib("../../lib");
-use CGI;
-use Cwd;
-use AffelioApp;
-
-our $cgi = new CGI();
-our $afap = new AffelioApp(ConfigDir => Cwd::getcwd(),
- cgi => $cgi);
-
-# Check access
-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 image file
- open(IMG, "$filepath") or die;
-
-# show image
- binmode IMG;
- binmode STDOUT;
- print "Content-type: image/$imgtype\n\n";
- print while (<IMG>);
-
-# close image
- close(IMG);
-}
- exit(0);
Index: affelio_farm/admin/skelton/affelio/apps/album/style.css
diff -u affelio_farm/admin/skelton/affelio/apps/album/style.css:1.1.1.1 affelio_farm/admin/skelton/affelio/apps/album/style.css:removed
--- affelio_farm/admin/skelton/affelio/apps/album/style.css:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/apps/album/style.css Tue Oct 25 04:20:44 2005
@@ -1,16 +0,0 @@
-.photo_table{
- width: auto;
- margin: 0px;
- padding 0px;
- border-style: none;
- background-color: #fff;
-}
-.photo_frame{
- width: 160px;
- height: 160px;
- background-image: url("./resource/photo_frame.gif");
- background-repeat: no-repeat;
- background-position: center;
- text-align: center;
- text-valign: middle;
-}
\ No newline at end of file