[Affelio-cvs 306] CVS update: affelio

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 6月 30日 (木) 04:32:38 JST


Index: affelio/admin.cgi
diff -u affelio/admin.cgi:1.16 affelio/admin.cgi:1.17
--- affelio/admin.cgi:1.16	Wed Jun 29 19:40:16 2005
+++ affelio/admin.cgi	Thu Jun 30 04:32:38 2005
@@ -6,15 +6,15 @@
 #    http://affelio.jp/ (Japan)
 #    http://affelio.jp/ (USA and other area)
 #
-# $Id: admin.cgi,v 1.16 2005/06/29 10:40:16 slash5234 Exp $
+# $Id: admin.cgi,v 1.17 2005/06/29 19:32:38 slash5234 Exp $
 
 use strict;
 
 use lib("./extlib");
 use CGI qw(-unique_headers);
-use Error qw(:try);
 $CGI::DISABLE_UPLOADS = 0;
 $CGI::POST_MAX = 1024_000;
+use Error qw(:try);
 use CGI::Session qw(-ip_match);
 use HTML::Template;
 use Fcntl;
@@ -34,7 +34,16 @@
 debug_print("admin.cgi: start.");
 
 my $cfg_dir = ".";
-my $af = new Affelio(ConfigDir => $cfg_dir);
+my $af;
+try{
+    $af = new Affelio(ConfigDir => $cfg_dir);
+}catch Error with{
+    my $e = shift;
+    print "Content-type: text/html; charset=UTF-8\n";
+    print "Pragma: no-cache", "\n\n";
+    print "<HTML><PRE>Affelio load error.<BR>$e</PRE></HTML>";
+    exit(1);
+};
 debug_print("admin.cgi: AF loaded.");
 my $wi = new Affelio::misc::WebInput();
 
@@ -48,7 +57,6 @@
 			       $sid, 
 			       {Directory=> $af->{site__session_dir}});
 
-
 debug_print("admin:cgi Existing session: [" . $session->id . "]");
 
 if( (!$session) || ($session->param("type") ne "self")  ){
@@ -61,8 +69,7 @@
     print "Pragma: no-cache", "\n\n";
     print get_HTML_header();
 
-    $TMPL_FILE 
-	= "$af->{site__fs_root}/templates/$af->{site__template}/owner_side/login.tmpl";
+    $TMPL_FILE = "$af->{site__fs_root}/templates/$af->{site__template}/owner_side/login.tmpl";
     my $tmpl = new HTML::Template( filename => $TMPL_FILE,
 				   die_on_bad_params => 0);
     $tmpl->param(reason_msg => "You haven't been authenticated.");
@@ -71,15 +78,16 @@
     $tmpl->param("forward_URL" => $q->self_url);
 
     print $af->translate_templateL10N($tmpl->output);
-
     print get_HTML_footer();
-
     exit(1);
 }
 
 debug_print("admin.cgi: Session as the admin is OK.");
 $session->expire('+12h');
 
+############################################################################
+#Going to the owner mode
+############################################################################
 #Set this Affelio as owner mode.
 $af->set_owner_mode();
 
@@ -88,9 +96,8 @@
 #Invoking models
 ############################################################################
 use Affelio::App::Admin::Messaging;
-my %output_data = (
-		   "tmpl_path",  "$af->{site__web_root}/templates/$af->{site__template}/owner_side/",
-		   "style_path",  $af->{site__web_root} . "/skins/" . $af->{userpref__skin},
+my %output_data = ("tmpl_path", "$af->{site__web_root}/templates/$af->{site__template}/owner_side/",
+		   "style_path", $af->{site__web_root} . "/skins/" . $af->{userpref__skin},
 		   "site_web_root", "$af->{site__web_root}",
 		   "my_nickname", $af->{user__nickname},
 		   "my_currentstatus", $af->{user__currentstatus},
@@ -102,80 +109,80 @@
 my $ret_msg="";
 my $err_msg="";
 
-####################
-#admin_mode
-####################
 my $admin_mode = $wi->PTN_mode($q->url_param("mode"));
 
+#####################################################################
+#Affelio Configuration
+#####################################################################
 if($admin_mode eq "config_affelio"){
 
-    debug_print("admin.cgi: mode=[config_affelio]");
-    #######################
-    #Affelio Configuration
-    #######################
     use Affelio::App::Admin::Configuration;
 
     my $sub_mode = $wi->PTN_mode($q->url_param("action"));
     if($sub_mode eq "submit" ){
-	Affelio::App::Admin::Configuration::configure($af, $q);
+	try{
+	    Affelio::App::Admin::Configuration::configure($af, $q);
+	}catch Error with{
+	    my $e = shift;
+	    $err_msg .= $e;
+	};
     }
 
     $TMPL_FILE = "$af->{site__fs_root}/templates/" .
 	         "$af->{site__template}/owner_side/admin_affelio_config.tmpl";
     Affelio::App::Admin::Configuration::show($af,\%output_data);
 
+#####################################################################
+#Access Log
+#####################################################################
 }elsif($admin_mode eq "accesslog"){
 
-    debug_print("admin.cgi: mode=[accesslog]");
-    #######################
-    #AccessLog
-    #######################
     use Affelio::App::Admin::AccessLog;
 
     $TMPL_FILE = "$af->{site__fs_root}/templates/" .
 	         "$af->{site__template}/owner_side/admin_access_log.tmpl";
     Affelio::App::Admin::AccessLog::show($af,$q,\%output_data);
 
-
+#####################################################################
+#Upload Image
+#####################################################################
 }elsif($admin_mode eq "uploadimage"){
 
-    debug_print("admin.cgi: mode=[uploadimage]");
-    #######################
-    #Upload image
-    #######################
     $TMPL_FILE = "$af->{site__fs_root}/templates/" .
 	         "$af->{site__template}/owner_side/admin_uploadimage.tmpl";
 
     my $sub_mode = $wi->PTN_mode($q->url_param("action"));
     if($sub_mode eq "submit" ){
+	try{
+	    $q->cgi_error 
+		and error($q, "File transfer failed." . $q->cgi_error);
 
-	$q->cgi_error 
-	    and error($q, "File transfer failed." . $q->cgi_error);
-
-	my $uploaded_filename = $wi->PTN_jpg_filename($q->param("file"))
-	    || error($q, "File has not been transfered to server.");
-	my $fh = $q->upload( "file" );
+	    my $uploaded_filename = $wi->PTN_jpg_filename($q->param("file"))
+		|| error($q, "File has not been transfered to server.");
+	    my $fh = $q->upload( "file" );
 	
-	sysopen(OUT, "$af->{site__user_dir}/profile_face.jpg", 
-		O_WRONLY|O_TRUNC|O_CREAT, 0755);
-	binmode $fh;
-	binmode OUT;
-	my $buffer="";
-	while (read ($fh, $buffer, 16384)){
-	    print OUT $buffer;
-	}
-	close OUT;
+	    sysopen(OUT, "$af->{site__user_dir}/profile_face.jpg", 
+		    O_WRONLY|O_TRUNC|O_CREAT, 0755);
+	    binmode $fh;
+	    binmode OUT;
+	    my $buffer="";
+	    while (read ($fh, $buffer, 16384)){
+		print OUT $buffer;
+	    }
+	    close OUT;
+	}catch Error with{
+	    my $e = shift;
+	    $err_msg='<AF_M text="Error in uploading the image"><BR>' . $e;
+	};
 
     }else{
-	
     }
 
+#####################################################################
+#Messages
+#####################################################################
 }elsif($admin_mode eq "messages"){
 
-    debug_print("admin.cgi: mode=[messages]");
-    #######################
-    #Show Messages 
-    #######################
     use Affelio::App::Admin::Messaging;
 
     if( $q->url_param("action") eq "send_message" ){
@@ -202,7 +209,6 @@
 						$q,
 						\%output_data);
 
-
     }elsif( $q->url_param("action") eq "show" ){
 	$TMPL_FILE = "$af->{site__fs_root}/templates/" .
 	    "$af->{site__template}/owner_side/admin_showmessage.tmpl";
@@ -222,12 +228,11 @@
 							  \%output_data);
     }
 
+#####################################################################
+#Edit skin
+#####################################################################
 }elsif($admin_mode eq "edit_skins"){
 
-    debug_print("admin.cgi: mode=[edit_skins]");
-    #######################
-    #Edit skins
-    #######################
     use Affelio::App::Admin::EditSkins;
 
     if( $q->url_param("action") eq "submitcss" ){
@@ -259,13 +264,11 @@
 
     Affelio::App::Admin::EditSkins::show($af, \%output_data);
 
-
+#####################################################################
+#Edit templates
+#####################################################################
 }elsif($admin_mode eq "edit_templates"){
 
-    debug_print("admin.cgi: mode=[edit_templates]");
-    #######################
-    #Edit templates
-    #######################
     use Affelio::App::Admin::EditTemplates;
 
     if( $q->url_param("action") eq "submit" ){
@@ -288,12 +291,11 @@
 
     Affelio::App::Admin::EditTemplates::show_templates($af, \%output_data);
 
+#####################################################################
+#Friends graph
+#####################################################################
 }elsif($admin_mode eq "friendsgraph"){
 
-    debug_print("admin.cgi: mode=[friendsgraph]");
-    #######################
-    #Show friends graph
-    #######################
     use Affelio::App::Admin::FriendsGraph;
 
     if( $q->url_param("action") eq "retrieve" ){
@@ -309,12 +311,11 @@
 
     Affelio::App::Admin::FriendsGraph::show_friendsgraph($af, \%output_data);
 
+#####################################################################
+#Edit Profile
+#####################################################################
 }elsif($admin_mode eq "editprofile"){
 
-    debug_print("admin.cgi: mode=[editprofile]");
-    #######################
-    #Edit profile page
-    #######################
     use Affelio::App::Admin::EditProfile;
 
     $TMPL_FILE = "$af->{site__fs_root}/templates/" .
@@ -329,13 +330,11 @@
 
     Affelio::App::Admin::EditProfile::show_profileeditor($af, \%output_data);
 
-
+#####################################################################
+#Group Member Table
+#####################################################################
 }elsif($admin_mode eq "group_member_table"){
 
-    debug_print("admin.cgi: mode=[group_member_table]");
-    #######################
-    #Group Member Table
-    #######################
     use Affelio::App::Admin::GroupMemberTable;
 
     debug_print("admin.cgi: mode2=[" . $q->url_param("mode2"));
@@ -348,13 +347,11 @@
 
     show_GroupMember_table($af, \%output_data);
 
-
+#####################################################################
+#Manage Friend
+#####################################################################
 }elsif($admin_mode eq "manage_friends"){
 
-    debug_print("admin.cgi: mode=[manage_friends]");
-    #######################
-    #Manage friends
-    #######################
     use Affelio::App::Admin::ManageFriend;
 
     debug_print("admin.cgi: mode2=[" . $q->url_param("mode2"));
@@ -415,13 +412,11 @@
 	Affelio::App::Admin::ManageFriend::manage_top($af, \%output_data);
     }
 
-
+#####################################################################
+#Manage Groups
+#####################################################################
 }elsif($admin_mode eq "manage_groups"){
 
-    debug_print("admin.cgi: mode=[manage_groups]");
-    #######################
-    #Manage groups
-    #######################
     use Affelio::App::Admin::ManageGroup;
 
     debug_print("admin.cgi: mode2=[" . $q->url_param("mode2"));
@@ -469,13 +464,11 @@
 	Affelio::App::Admin::ManageGroup::manage_top($af, \%output_data);
     }
 
-
+#####################################################################
+#Access Control
+#####################################################################
 }elsif($admin_mode eq "access_control"){
     
-    debug_print("admin.cgi: mode=[access_control]");
-    #######################
-    #Access Control (core)
-    #######################
     use Affelio::App::Admin::AccessControl;
     
     if($q->url_param("mode2") eq "submit"){
@@ -488,12 +481,11 @@
     show_GroupAttribute_table($af, \%output_data);
 
 
+#####################################################################
+#Application Access Control
+#####################################################################
 }elsif($admin_mode eq "access_control_apps"){
 
-    debug_print("admin.cgi: mode=[access_control_apps]");
-    #######################
-    #Access Control (Apps)
-    #######################
     use Affelio::App::Admin::ManageApplication;
 
     if($q->url_param("mode2") eq "modify_app"){
@@ -522,12 +514,11 @@
     }
 
 
+#####################################################################
+#Send Invitation
+#####################################################################
 }elsif($admin_mode eq "send_invitation"){
 
-    debug_print("admin.cgi: mode=[send_invitation]");
-    #######################
-    #Send invitation
-    #######################
     use Affelio::App::Admin::SendInvitation;
     send_invitation($af, $q->param("dest_address"), \%output_data);
 
@@ -535,37 +526,39 @@
 	         "$af->{site__template}/owner_side/admin_top.tmpl";
 
 
+#####################################################################
+#Send Handshake
+#####################################################################
 }elsif($admin_mode eq "send_handshake"){
 
-    debug_print("admin.cgi: mode=[send_handshake]");
-    #######################
-    #Send handshake
-    #######################
     use Affelio::App::Admin::SendHandshake;
-    Affelio::App::Admin::SendHandshake::send($af, $q, \%output_data);
+    try{
+	Affelio::App::Admin::SendHandshake::send($af, $q, \%output_data);
+      }catch Error with{
+	  my $e = shift;
+	  $err_msg='<AF_M text="Error in handshaking"><BR>' . $e;
+      };
 
     $TMPL_FILE = "$af->{site__fs_root}/templates/" .
 	"$af->{site__template}/owner_side/handshake_sent.tmpl";
 
+#####################################################################
+#MyStatus
+#####################################################################
 }elsif($admin_mode eq "post_mystatus"){
 
-    debug_print("admin.cgi: mode=[post_mystatus]");
-    #######################
-    #Post my_status 
-    #######################
-
     use Affelio::App::Admin::MyStatus;
 
     Affelio::App::Admin::MyStatus::post($af, $q->param("my_currentstatus"));
     $HTTP_forward_flag = 1;
     $forward_URL = "$af->{site__web_root}/admin.cgi";
 
+
+#####################################################################
+#Top
+#####################################################################
 }else{
 
-    debug_print("admin.cgi: mode=[admin_top]");
-    #######################
-    #Admin page top.
-    #######################
     $TMPL_FILE = "$af->{site__fs_root}/templates/" .
 	         "$af->{site__template}/owner_side/admin_top.tmpl";
 
@@ -583,7 +576,6 @@
     print "Location: $forward_URL", "\n\n";
 
 }else{
-
     print "Content-type: text/html; charset=UTF-8\n";
     print "Pragma: no-cache", "\n\n";
     print get_HTML_header();
@@ -597,13 +589,18 @@
     } 
     $tmpl->param("err_msg" => $err_msg);
     $tmpl->param("site__locale" => $af->{site__locale});
-    
+
     print $af->translate_templateL10N($tmpl->output);
 
     print get_HTML_footer();
 }
 
 
+
+####################
+#Hmmmmmm
+####################
+
     ######################################################################
     #Get_HTML_header
     ######################################################################
@@ -658,3 +655,6 @@
         return($final_out);
     }
     
+
+
+    


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