[Affelio-cvs 89] CVS update: affelio/lib/Affelio/App/Admin

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 6月 21日 (火) 17:45:25 JST


Index: affelio/lib/Affelio/App/Admin/EditSkins.pm
diff -u affelio/lib/Affelio/App/Admin/EditSkins.pm:1.2 affelio/lib/Affelio/App/Admin/EditSkins.pm:1.3
--- affelio/lib/Affelio/App/Admin/EditSkins.pm:1.2	Fri Jun 17 18:56:50 2005
+++ affelio/lib/Affelio/App/Admin/EditSkins.pm	Tue Jun 21 17:45:25 2005
@@ -6,17 +6,19 @@
 #    http://affelio.jp/ (Japan)
 #    http://affelio.jp/ (USA and other area)
 #
-# $Id: EditSkins.pm,v 1.2 2005/06/17 09:56:50 slash5234 Exp $
+# $Id: EditSkins.pm,v 1.3 2005/06/21 08:45:25 slash5234 Exp $
 
 package Affelio::App::Admin::EditSkins;
 {
     use strict;
 
+    use Fcntl;
     use lib("../../../../extlib/");
     use lib("../../../");
     use Affelio;
     use Affelio::misc::CGIError;
     use Affelio::misc::Debug qw(debug_print);
+    use Affelio::misc::WebInput;
 
     use Exporter;
     @Affelio::App::Admin::EditSkins::ISA = "Exporter";
@@ -28,8 +30,9 @@
     sub choose_skin{
 	my $af = shift;
 	my $cgi = shift;
+	my $wi = new Affelio::misc::WebInput;
 
-	$af->{userpref__skin} = $cgi->param("skin_list");
+	$af->{userpref__skin} = $wi->PTN_word($cgi->param("skin_list"));
 	$af->write_user_prefs();
 
 	return;
@@ -42,7 +45,7 @@
 	my $af = shift;
 	my $cgi = shift;
 
-	open(FILEOUT, "> $af->{site__fs_root}/skins/$af->{userpref__skin}/style.css");
+	sysopen(FILEOUT, "$af->{site__fs_root}/skins/$af->{userpref__skin}/style.css", O_WRONLY|O_TRUNC|O_CREAT, 0755);
 	print FILEOUT $cgi->param("style.css");
 	close(FILEOUT);
 	return;
@@ -57,6 +60,8 @@
 	my $cgi = shift;
 	use File::Basename;
 
+	my $wi = new Affelio::misc::WebInput;
+
 	debug_print("EditSkins:upload: start.");
 	
 	my $filename = $cgi->param('uploadingfile');
@@ -85,6 +90,8 @@
 	debug_print("EditSkins:upload: filename = $filename");
 	debug_print("EditSkins:upload: basename = $basename");
 
+	$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
+
 	if($filetype =~ /zip/ || $filename =~ /\.[zip|ZIP]$/){
 	    debug_print("EditSkins:upload: OK. This is a zip file. ");
 	    debug_print("EditSkins:upload: Extracting [$basename]...");
@@ -117,10 +124,10 @@
 	my $af = shift;
 	my $cgi = shift;
 
-	#CHECK INPUT!!!!
+	my $wi = new Affelio::misc::WebInput();
 
-	my $skin_name = $cgi->param("selected_skin");
-	my $specified_name = $cgi->param("archive_name");
+	my $skin_name = $wi->PTN_word($cgi->param("selected_skin"));
+	my $specified_name = $wi->PTN_word($cgi->param("archive_name"));
 
 	debug_print("EditSkin:backup skin_name = $skin_name");
 	debug_print("EditSkin:backup specified_name = $specified_name");
@@ -128,6 +135,8 @@
 	my $archive_file_name = "";
 	my $archive_dir ="";
 
+	$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
+
 	if($specified_name ne ""){
 	    system("cp -rf $af->{site__fs_root}/skins/$skin_name $af->{site__fs_root}/skins/$specified_name");
 	    $archive_file_name = $specified_name . ".zip";
@@ -146,7 +155,7 @@
 __EOF__
 #;
 
-        open(FILEIN, "< $af->{site__fs_root}/skins/$archive_file_name");
+        sysopen(FILEIN, "$af->{site__fs_root}/skins/$archive_file_name", O_RDONLY);
 	binmode(OUT);
 	print while read FILEIN, $_, 1024;
 	close FILEIN;
@@ -159,167 +168,6 @@
 
 
     #######################################################################
-    #save_skins
-    #######################################################################    
-    sub save_skins{
-	my $af = shift;
-	my $cgi = shift;
-
-	open(OUT, "> $af->{site__user_dir}/af_skins/header.aftmpl");
-	print OUT $cgi->param("header.aftmpl");
-	close(OUT);
-
-	open(OUT, "> $af->{site__user_dir}/af_skins/footer.aftmpl");
-	print OUT $cgi->param("footer.aftmpl");
-	close(OUT);
-
-	open(OUT, "> $af->{site__user_dir}/af_skins/right.aftmpl");
-	print OUT $cgi->param("right.aftmpl");
-	close(OUT);
-
-	open(OUT, "> $af->{site__user_dir}/af_skins/left.aftmpl");
-	print OUT $cgi->param("left.aftmpl");
-	close(OUT);
-
-	open(OUT, "> $af->{site__user_dir}/af_skins/body_index.aftmpl");
-	print OUT $cgi->param("body_index.aftmpl");
-	close(OUT);
-
-	open(OUT, "> $af->{site__user_dir}/af_skins/body_flist.aftmpl");
-	print OUT $cgi->param("body_flist.aftmpl");
-	close(OUT);
-
-	open(OUT, "> $af->{site__user_dir}/af_skins/body_profile.aftmpl");
-	print OUT $cgi->param("body_profile.aftmpl");
-	close(OUT);
-
-#	open(OUT, "> $af->{site__user_dir}/af_skins/style.css");
-#	print OUT $cgi->param("style.css");
-#	close(OUT);
-
-    }
-
-
-    #######################################################################
-    #rebuild
-    #######################################################################    
-    sub rebuild{
-	my $af = shift;
-	my $output_data_ref = shift;
-
-	debug_print("rebuild: start.");
-
-	################################
-	#Prep
-
-	#Open the header template file in userdata dir
-	my $header="";
-	open(HEADER, "$af->{site__user_dir}/af_skins/header.aftmpl");
-	while(<HEADER>){$header .=$_;}
-	close(HEADER);
-
-	#Open the left template file in userdata dir
-	my $left="";
-	open(LEFT, "$af->{site__user_dir}/af_skins/left.aftmpl");
-	while(<LEFT>){$left .=$_;}
-	close(LEFT);
-
-	#Open the right template file in userdata dir
-	my $right="";
-	open(RIGHT, "$af->{site__user_dir}/af_skins/right.aftmpl");
-	while(<RIGHT>){$right .=$_;}
-	close(RIGHT);
-
-	#Open the footer template file in userdata dir
-	my $footer="";
-	open(FOOTER, "$af->{site__user_dir}/af_skins/footer.aftmpl");
-	while(<FOOTER>){$footer .=$_;}
-	close(FOOTER);
-
-	################################
-	#Main loop.  For each body template....
-	my $from_template_file = "";
-	opendir(DIR1, "$af->{site__user_dir}/af_skins");
-	while (defined($from_template_file = readdir(DIR1))) {
-
-	    if($from_template_file =~ /\.aftmpl/){
-
-		debug_print("rebuild: Source file=[$from_template_file]");
-
-		my $from_contents="";
-		open(BODY, 
-		     "$af->{site__user_dir}/af_skins/$from_template_file");
-		while(<BODY>){$from_contents .=$_;}
-		close(BODY);
-
-		my $template_name = $from_template_file;
-		$template_name =~ s/\.aftmpl//g;
-		if($from_template_file =~ /body.*\.aftmpl/){
-		    #Body template files....
-		    $template_name =~ s/body_//g;
-		}		    
-		
-		my $output_contents ="";
-		if($from_template_file =~ /body.*\.aftmpl/){
-		    #Concatenate 3 files.
-		    $output_contents = $header . $left 
-			. $from_contents . $right . $footer;
-		}else{
-		    $output_contents = $from_contents;
-		}
-
-		###################################################
-		#Replacement
-		###################################################
-		#  (1)s/AF_VAR/TMPL_VAR/g
-		$output_contents =~ s/AF_VAR/TMPL_VAR/g;
-
-		#  (2)AF_BLOCK
-		my $aftag_file;
-		opendir(DIR2, "$af->{site__fs_root}/lib/Affelio/App/Admin/AFTemplateBlocks");
-		while (defined($aftag_file = readdir(DIR2))) {
-		    #print "$aftag_file;
-		    if(($aftag_file ne '.') && ($aftag_file ne '..') 
-		       && ($aftag_file ne 'CVS')){
-			
-			debug_print("rebuild:\taf_tag file = $aftag_file");
-			my $tagname = $aftag_file;
-			$tagname =~s/\.aftag//g;
-			#debug_print("rebuild: Replace AF_BLOCK=$tagname");
-			my $tagcontent="";
-			open(TAGCONTENT, 
-			     "$af->{site__fs_root}/lib/Affelio/App/Admin/AFTemplateBlocks/$aftag_file");
-			while(<TAGCONTENT>){$tagcontent .=$_;}
-			close(TAGCONTENT);
-			
-			my $rep = '<AF_BLOCK NAME="' . $tagname . '">';
-			$output_contents =~ s/$rep/$tagcontent/g;
-		    }#if
-		}#while
-
-		###################################################
-		#Save to file in skins_dyn/ dir
-		###################################################
-		open(OUT, "> $af->{site__fs_root}/skins_dyn/$template_name.tmpl");
-		print OUT $output_contents;
-		close(OUT);
-		
-	    }#if
-	}#while(for each file...)
-
-#	debug_print("rebuild: Copying style.css..."); 
-#	system("cp -f $af->{site__user_dir}/af_skins/style.css $af->{site__fs_root}/skins_dyn/");
-
-	debug_print("rebuild: header+left => Header"); 
-	system("cat $af->{site__fs_root}/skins_dyn/header.tmpl  $af->{site__fs_root}/skins_dyn/left.tmpl > $af->{site__fs_root}/skins_dyn/Header.tmpl");
-
-	debug_print("rebuild: right+footer => Footer"); 
-	system("cat $af->{site__fs_root}/skins_dyn/right.tmpl  $af->{site__fs_root}/skins_dyn/footer.tmpl > $af->{site__fs_root}/skins_dyn/Footer.tmpl");
-
-	debug_print("rebuild: end.");
-    }
-
-    #######################################################################
     #show
     #######################################################################    
     sub show{
@@ -356,12 +204,22 @@
 	#Selected skin's CSS file
 	###############################
 	my $css_body="";
-	open(IN, "$af->{site__fs_root}/skins/$af->{userpref__skin}/style.css");
+	sysopen(IN, 
+		"$af->{site__fs_root}/skins/$af->{userpref__skin}/style.css",
+		O_RDONLY);
+	if(-w "$af->{site__fs_root}/skins/$af->{userpref__skin}/style.css"){
+	    $output_ref->{'current_css_mode'} = "";
+	}else{
+	    $output_ref->{'current_css_mode'} = "readonly";
+	}
+
 	while(<IN>){$css_body .=$_;}
 	close(IN);
 	$output_ref->{'current_css_body'} = $css_body;
 
 	$output_ref->{'current_skin_name'} = $af->{userpref__skin};
+
+
     }
 
 }
Index: affelio/lib/Affelio/App/Admin/EditTemplates.pm
diff -u affelio/lib/Affelio/App/Admin/EditTemplates.pm:1.1.1.1 affelio/lib/Affelio/App/Admin/EditTemplates.pm:1.2
--- affelio/lib/Affelio/App/Admin/EditTemplates.pm:1.1.1.1	Tue Jun 14 12:53:29 2005
+++ affelio/lib/Affelio/App/Admin/EditTemplates.pm	Tue Jun 21 17:45:25 2005
@@ -6,7 +6,7 @@
 #    http://affelio.jp/ (Japan)
 #    http://affelio.jp/ (USA and other area)
 #
-# $Id: EditTemplates.pm,v 1.1.1.1 2005/06/14 03:53:29 slash5234 Exp $
+# $Id: EditTemplates.pm,v 1.2 2005/06/21 08:45:25 slash5234 Exp $
 
 package Affelio::App::Admin::EditTemplates;
 {
@@ -14,9 +14,11 @@
 
     use lib("../../../../extlib/");
     use lib("../../../");
+    use Fcntl;
     use Affelio;
     use Affelio::misc::CGIError;
     use Affelio::misc::Debug qw(debug_print);
+    use Affelio::misc::WebInput;
 
     use Exporter;
     @Affelio::App::Admin::EditTemplates::ISA = "Exporter";
@@ -29,38 +31,33 @@
 	my $af = shift;
 	my $cgi = shift;
 
-	open(OUT, "> $af->{site__user_dir}/af_templates/header.aftmpl");
+	sysopen(OUT, "$af->{site__user_dir}/af_templates/header.aftmpl", O_WRONLY);
 	print OUT $cgi->param("header.aftmpl");
 	close(OUT);
 
-	open(OUT, "> $af->{site__user_dir}/af_templates/footer.aftmpl");
+	sysopen(OUT, "$af->{site__user_dir}/af_templates/footer.aftmpl", O_WRONLY);
 	print OUT $cgi->param("footer.aftmpl");
 	close(OUT);
 
-	open(OUT, "> $af->{site__user_dir}/af_templates/right.aftmpl");
+	sysopen(OUT, "$af->{site__user_dir}/af_templates/right.aftmpl", O_WRONLY);
 	print OUT $cgi->param("right.aftmpl");
 	close(OUT);
 
-	open(OUT, "> $af->{site__user_dir}/af_templates/left.aftmpl");
+	sysopen(OUT, "$af->{site__user_dir}/af_templates/left.aftmpl", O_WRONLY);
 	print OUT $cgi->param("left.aftmpl");
 	close(OUT);
 
-	open(OUT, "> $af->{site__user_dir}/af_templates/body_index.aftmpl");
+	sysopen(OUT, "$af->{site__user_dir}/af_templates/body_index.aftmpl", O_WRONLY);
 	print OUT $cgi->param("body_index.aftmpl");
 	close(OUT);
 
-	open(OUT, "> $af->{site__user_dir}/af_templates/body_flist.aftmpl");
+	sysopen(OUT, "$af->{site__user_dir}/af_templates/body_flist.aftmpl", O_WRONLY);
 	print OUT $cgi->param("body_flist.aftmpl");
 	close(OUT);
 
-	open(OUT, "> $af->{site__user_dir}/af_templates/body_profile.aftmpl");
+	sysopen(OUT, "$af->{site__user_dir}/af_templates/body_profile.aftmpl", O_WRONLY);
 	print OUT $cgi->param("body_profile.aftmpl");
 	close(OUT);
-
-#	open(OUT, "> $af->{site__user_dir}/af_templates/style.css");
-#	print OUT $cgi->param("style.css");
-#	close(OUT);
-
     }
 
 
@@ -71,6 +68,8 @@
 	my $af = shift;
 	my $output_data_ref = shift;
 
+	my $wi = new Affelio::misc::WebInput;
+
 	debug_print("rebuild: start.");
 
 	################################
@@ -78,41 +77,43 @@
 
 	#Open the header template file in userdata dir
 	my $header="";
-	open(HEADER, "$af->{site__user_dir}/af_templates/header.aftmpl");
+	sysopen(HEADER, "$af->{site__user_dir}/af_templates/header.aftmpl", O_RDONLY);
 	while(<HEADER>){$header .=$_;}
 	close(HEADER);
 
 	#Open the left template file in userdata dir
 	my $left="";
-	open(LEFT, "$af->{site__user_dir}/af_templates/left.aftmpl");
+	sysopen(LEFT, "$af->{site__user_dir}/af_templates/left.aftmpl", O_RDONLY);
 	while(<LEFT>){$left .=$_;}
 	close(LEFT);
 
 	#Open the right template file in userdata dir
 	my $right="";
-	open(RIGHT, "$af->{site__user_dir}/af_templates/right.aftmpl");
+	sysopen(RIGHT, "$af->{site__user_dir}/af_templates/right.aftmpl", O_RDONLY);
 	while(<RIGHT>){$right .=$_;}
 	close(RIGHT);
 
 	#Open the footer template file in userdata dir
 	my $footer="";
-	open(FOOTER, "$af->{site__user_dir}/af_templates/footer.aftmpl");
+	sysopen(FOOTER, "$af->{site__user_dir}/af_templates/footer.aftmpl", O_RDONLY);
 	while(<FOOTER>){$footer .=$_;}
 	close(FOOTER);
 
+
 	################################
 	#Main loop.  For each body template....
 	my $from_template_file = "";
 	opendir(DIR1, "$af->{site__user_dir}/af_templates");
 	while (defined($from_template_file = readdir(DIR1))) {
 
+	    $from_template_file = $wi->PTN_basefilename($from_template_file);
+
 	    if($from_template_file =~ /\.aftmpl/){
 
 		debug_print("rebuild: Source file=[$from_template_file]");
 
 		my $from_contents="";
-		open(BODY, 
-		     "$af->{site__user_dir}/af_templates/$from_template_file");
+		sysopen(BODY, "$af->{site__user_dir}/af_templates/$from_template_file", O_RDONLY);
 		while(<BODY>){$from_contents .=$_;}
 		close(BODY);
 
@@ -164,19 +165,17 @@
 		###################################################
 		#Save to file in templates_dyn/ dir
 		###################################################
-		open(OUT, "> $af->{site__fs_root}/templates_dyn/$template_name.tmpl");
+		sysopen(OUT, "$af->{site__fs_root}/templates_dyn/$template_name.tmpl", O_WRONLY);
 		print OUT $output_contents;
 		close(OUT);
 		
 	    }#if
 	}#while(for each file...)
 
-#	debug_print("rebuild: Copying style.css..."); 
-#	system("cp -f $af->{site__user_dir}/af_templates/style.css $af->{site__fs_root}/templates_dyn/");
+	$ENV{PATH} = "/bin:/usr/bin";
 
 	debug_print("rebuild: header+left => Header"); 
 	system("cat $af->{site__fs_root}/templates_dyn/header.tmpl  $af->{site__fs_root}/templates_dyn/left.tmpl > $af->{site__fs_root}/templates_dyn/Header.tmpl");
-
 	debug_print("rebuild: right+footer => Footer"); 
 	system("cat $af->{site__fs_root}/templates_dyn/right.tmpl  $af->{site__fs_root}/templates_dyn/footer.tmpl > $af->{site__fs_root}/templates_dyn/Footer.tmpl");
 
@@ -192,52 +191,47 @@
 	my $output_ref = shift;
 
 	my $body="";
-	open(IN, "$af->{site__user_dir}/af_templates/header.aftmpl");
+	sysopen(IN, "$af->{site__user_dir}/af_templates/header.aftmpl", O_RDONLY);
 	while(<IN>){$body .=$_;}
 	close(IN);
 	$output_ref->{'header_template'} = $body;
 
 	$body="";
-	open(IN, "$af->{site__user_dir}/af_templates/footer.aftmpl");
+	sysopen(IN, "$af->{site__user_dir}/af_templates/footer.aftmpl", O_RDONLY);
 	while(<IN>){$body .=$_;}
 	close(IN);
 	$output_ref->{'footer_template'} = $body;
 
 	$body="";
-	open(IN, "$af->{site__user_dir}/af_templates/left.aftmpl");
+	sysopen(IN, "$af->{site__user_dir}/af_templates/left.aftmpl", O_RDONLY);
 	while(<IN>){$body .=$_;}
 	close(IN);
 	$output_ref->{'left_template'} = $body;
 
 	$body="";
-	open(IN, "$af->{site__user_dir}/af_templates/right.aftmpl");
+	sysopen(IN, "$af->{site__user_dir}/af_templates/right.aftmpl", O_RDONLY);
 	while(<IN>){$body .=$_;}
 	close(IN);
 	$output_ref->{'right_template'} = $body;
 
 	$body="";
-	open(IN, "$af->{site__user_dir}/af_templates/body_index.aftmpl");
+	sysopen(IN, "$af->{site__user_dir}/af_templates/body_index.aftmpl", O_RDONLY);
 	while(<IN>){$body .=$_;}
 	close(IN);
 	$output_ref->{'body_template__index'} = $body;
 
 	$body="";
-	open(IN, "$af->{site__user_dir}/af_templates/body_flist.aftmpl");
+	sysopen(IN, "$af->{site__user_dir}/af_templates/body_flist.aftmpl", O_RDONLY);
 	while(<IN>){$body .=$_;}
 	close(IN);
 	$output_ref->{'body_template__flist'} = $body;
 
 	$body="";
-	open(IN, "$af->{site__user_dir}/af_templates/body_profile.aftmpl");
+	sysopen(IN, "$af->{site__user_dir}/af_templates/body_profile.aftmpl", O_RDONLY);
 	while(<IN>){$body .=$_;}
 	close(IN);
 	$output_ref->{'body_template__profile'} = $body;
 	
-#	$body="";
-#	open(IN, "$af->{site__user_dir}/af_templates/style.css");
-#	while(<IN>){$body .=$_;}
-#	close(IN);
-#	$output_ref->{'stylesheet_template'} = $body;
     }
 
 }
Index: affelio/lib/Affelio/App/Admin/Messaging.pm
diff -u affelio/lib/Affelio/App/Admin/Messaging.pm:1.1.1.1 affelio/lib/Affelio/App/Admin/Messaging.pm:1.2
--- affelio/lib/Affelio/App/Admin/Messaging.pm:1.1.1.1	Tue Jun 14 12:53:29 2005
+++ affelio/lib/Affelio/App/Admin/Messaging.pm	Tue Jun 21 17:45:25 2005
@@ -6,7 +6,7 @@
 #    http://affelio.jp/ (Japan)
 #    http://affelio.jp/ (USA and other area)
 #
-# $Id: Messaging.pm,v 1.1.1.1 2005/06/14 03:53:29 slash5234 Exp $
+# $Id: Messaging.pm,v 1.2 2005/06/21 08:45:25 slash5234 Exp $
 
 package Affelio::App::Admin::Messaging;
 {
@@ -19,19 +19,22 @@
     use Affelio::misc::Debug qw(debug_print);
     use Affelio::misc::Encoding qw(db_encode db_decode);
     use Affelio::misc::Time qw(timestamp2string);
+    use Affelio::misc::WebInput;
 
     use Exporter;
     @Affelio::App::Admin::Messaging::ISA = "Exporter";
     @Affelio::App::Admin::Messaging::EXPORT = qw (show_message_list show_message mark_as_read get_new);
 
-
-
     #######################################################################
     #mark_as_read
     #######################################################################    
     sub mark_as_read{
+	my $wi = new Affelio::misc::WebInput;
+
 	my $af = shift;
 	my $mid = shift;
+	$mid = $wi->PTN_num($mid);
+
 	debug_print("marK_as_read: start");
 
 	my $ret= $af->{mesgm}->mark_as_read($mid);
@@ -57,8 +60,11 @@
     #show_message
     #######################################################################    
     sub show_message{
+	my $wi = new Affelio::misc::WebInput;
+
 	my $af = shift;
 	my $mid = shift;
+	$mid = $wi->PTN_num($mid);
 	my $output_ref = shift;
 
 	debug_print("show_message: start.");


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