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

Back to archive index

Yoshihisa Fukuhara higef****@users*****
2005年 6月 20日 (月) 20:04:45 JST


Index: affelio/apps/album/Album.pm
diff -u affelio/apps/album/Album.pm:1.2 affelio/apps/album/Album.pm:1.3
--- affelio/apps/album/Album.pm:1.2	Mon Jun 20 00:24:12 2005
+++ affelio/apps/album/Album.pm	Mon Jun 20 20:04:45 2005
@@ -33,17 +33,19 @@
 	my $this = {};
 	$this->{afap}  = $afap;
 	$this->{uname} = $afap->{af}->{site__username};
-	$this->{dbpath}= "$databasedir/$this->{uname}";
+#	$this->{dbpath}= "$databasedir/$this->{uname}";
+	$this->{dbpath}= $afap->get_userdata_dir()."/DB.sqlite";
 	$this->{dbh} = undef;
 
         # 初期化
-	unless(-e $this->{dbpath}) {
-		local (*F);
-		open(F, "> $this->{dbpath}"); close(F);
-		chmod 0666, $this->{dbpath};
-		$this->{dbh} = DBI->connect("dbi:SQLite:dbname=".$this->{dbpath})
-			or die("cannot open db: ".$this->{dbpath});
-		
+#	unless(-e $this->{dbpath}) {
+	if (-z $this->{dbpath}){
+#	    local (*F);
+#		open(F, "> $this->{dbpath}"); close(F);
+#		chmod 0666, $this->{dbpath};
+#		$this->{dbh} = DBI->connect("dbi:SQLite:dbname=".$this->{dbpath})
+#			or die("cannot open db: ".$this->{dbpath});
+	    $this->{dbh} = $afap->get_userdata_dbh();
 		# 日記テーブル
 		$this->{dbh}->do("CREATE TABLE $album_table (
 			id		INTEGER PRIMARY KEY,
@@ -84,8 +86,9 @@
 		$this->{dbh}->disconnect;
 	}
 	else {
-	    $this->{dbh} = DBI->connect("dbi:SQLite:dbname=".$this->{dbpath})
-			or die("cannot open db: ".$this->{dbpath});
+#	    $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;
@@ -126,7 +129,7 @@
 	$this->{dbh}->do("INSERT INTO $album_table (title, contents, timestamp, update_time, user, afid, pswd, ord) VALUES ('$title', '$contents', $time, $time, '$user', '$afid', '', '')");
   	$id = $this->getColumn("SELECT MAX(id) FROM $album_table");
 
-        my $data_dir="./data/";
+        my $data_dir=$this->{afap}->get_userdata_dir()."/";
   	$data_dir.= $id;
       	if (!-d $data_dir){
         	mkdir $data_dir, 0777;
@@ -214,7 +217,7 @@
 	$this->{dbh}->do("DELETE FROM $album_table WHERE id = $id");
 	$this->{dbh}->do("DELETE FROM $album_comment_table WHERE id = $id");
 	$this->{dbh}->do("DELETE FROM $album_image_table WHERE id = $id");
-        my $data_dir="./data/".$id."/";
+        my $data_dir=$this->{afap}->get_userdata_dir()."/".$id."/";
        	my $thumb_dir=$data_dir."thumbnail/";
   	foreach(@ret){
     		unlink($thumb_dir.$_->{image});
@@ -235,7 +238,7 @@
 
 sub removeImage {
 	my ($this, $id, @pkey) = @_;
-        my $data_dir="./data/".$id."/";
+        my $data_dir=$this->{afap}->get_userdata_dir()."/".$id."/";
        	my $thumb_dir=$data_dir."thumbnail/";
   	my @ret;
   	foreach(@pkey){
Index: affelio/apps/album/show_album.cgi
diff -u affelio/apps/album/show_album.cgi:1.1 affelio/apps/album/show_album.cgi:1.2
--- affelio/apps/album/show_album.cgi:1.1	Sun Jun 19 18:14:17 2005
+++ affelio/apps/album/show_album.cgi	Mon Jun 20 20:04:45 2005
@@ -49,8 +49,10 @@
   		fileparse_set_fstype("MSDOS"); #IE対策。うまく動かないかも?!
   		my $basename  = basename($filehandle,"");
   		if ($basename =~ /^[a-zA-Z0-9\.\-\_]{1,32}$/ ){#ファイル名チェック
-			my $fname='./data/'.$id.'/'.$basename;#保存するファイル名を指定
-			my $thumb_fname='./data/'.$id.'/thumbnail/'.$basename;#保存するファイル名を指定
+			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){#同名ファイルが存在
Index: affelio/apps/album/show_image.cgi
diff -u affelio/apps/album/show_image.cgi:1.1 affelio/apps/album/show_image.cgi:1.2
--- affelio/apps/album/show_image.cgi:1.1	Sun Jun 19 18:14:17 2005
+++ affelio/apps/album/show_image.cgi	Mon Jun 20 20:04:45 2005
@@ -20,9 +20,9 @@
   my $type = $afap->{cgi}->param('type');
   my $filepath;
   if ($type eq "thumbnail") {
-	$filepath = "./data/".$id."/thumbnail/".$image;
+	$filepath = $afap->get_userdata_dir()."/".$id."/thumbnail/".$image;
   }elsif($type eq "large"){
-	$filepath = "./data/".$id."/".$image;
+	$filepath = $afap->get_userdata_dir()."/".$id."/".$image;
   }else{
 	$filepath = "./resource/emp.jpg";
   }


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