Tadashi Okoshi
slash****@users*****
2006年 2月 23日 (木) 21:41:36 JST
Index: affelio/bin/get_content.cgi
diff -u affelio/bin/get_content.cgi:1.32 affelio/bin/get_content.cgi:1.33
--- affelio/bin/get_content.cgi:1.32 Sat Jan 28 17:47:22 2006
+++ affelio/bin/get_content.cgi Thu Feb 23 21:41:36 2006
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-# $Id: get_content.cgi,v 1.32 2006/01/28 08:47:22 slash5234 Exp $
+# $Id: get_content.cgi,v 1.33 2006/02/23 12:41:36 slash5234 Exp $
use strict;
@@ -29,6 +29,7 @@
use lib("../lib");
use Affelio;
+use Affelio::App::Env;
use Affelio::App::FriendRoutines qw(get_summed_permission_list);
use Affelio::misc::CGIError;
use Affelio::misc::Debug qw(debug_print);
Index: affelio/bin/loginexec.cgi
diff -u affelio/bin/loginexec.cgi:1.16 affelio/bin/loginexec.cgi:1.17
--- affelio/bin/loginexec.cgi:1.16 Sat Jan 28 17:47:22 2006
+++ affelio/bin/loginexec.cgi Thu Feb 23 21:41:36 2006
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-# $Id: loginexec.cgi,v 1.16 2006/01/28 08:47:22 slash5234 Exp $
+# $Id: loginexec.cgi,v 1.17 2006/02/23 12:41:36 slash5234 Exp $
use strict;
@@ -28,6 +28,7 @@
use lib("../lib");
use Affelio;
+use Affelio::App::Env;
use Affelio::misc::CGIError;
use Affelio::misc::Debug;
use Affelio::misc::Time;
@@ -38,6 +39,8 @@
my $q = new CGI;
+debug_print("loginexec.cgi: **start.");
+
############################################################################
#Load Affelio
############################################################################
@@ -53,20 +56,45 @@
my $wi = new Affelio::misc::WebInput;
############################################################################
-#Prep
+#Prep (1) input args
############################################################################
-#input data
+#mode
my $mode = $wi->PTN_mode($q->url_param("mode"));
+
+#username or affelio_url
my $affelio_url = $wi->PTN_through($q->param("affelio_url"));
my $username = $wi->PTN_word($q->param("username"));
+
+#password
my $password = $wi->PTN_through($q->param("password"));
+
+#forward_URL
+# After authentication, browser must be forwarded to $forward_URL
+# Usually, $forward_URL is the user's AFLink person's page.
my $forward_URL = $wi->PTN_URL($q->url_param("forward_URL"));
+#aftergo_URL
+# After browser is forwarded to $forward_URL (after auth.),
+# $aftergo_URL is one more further URL that the browser needs
+# to be fowarded to.
my $aftergo_URL = $wi->PTN_URL($q->url_param("aftergo_URL"));
+
+#type from FORM
my $submit_type = $wi->PTN_mode($q->param("submittype"));
-#Make farm URL in which this Affelio belongs to.
-my $farm_URL = $af->{site__web_root};
-$farm_URL =~ s|/([A-Za-z0-9\-\_]*)$|/|;
+############################################################################
+#Prep (2) misc
+############################################################################
+#farm_users_root
+# This Affelio's 1-step parent URL.
+# e.g. this Affelio : http://my.affelio.jp/user/foo
+# e.g. farm_users_root : http://my.affelio.jp/user/
+my $farm_users_root = $af->{site__user_afid};
+$farm_users_root =~ s|/$||;
+$farm_users_root =~ s|/([A-Za-z0-9\-\_]+)$|/|;
+
+#output data
+my $issued_cookie="";
+my $next_url;
debug_print("\t\tmode = $mode");
debug_print("\t\taffelio_url= $affelio_url");
@@ -74,11 +102,7 @@
debug_print("\t\tpassword = $password");
debug_print("\t\tforward = $forward_URL");
debug_print("\t\taftergo = $aftergo_URL");
-debug_print("\t\tfarm_URL = $farm_URL");
-
-#output data
-my $issued_cookie="";
-my $next_url;
+debug_print("\t\tfarm_users_root = $farm_users_root");
############################################################################
#Already logined?
@@ -91,7 +115,8 @@
if($mode eq ""){
###################################################################
- #OLD protocol (V1)
+ #Protocol V1
+ ###################################################################
if( (verify_password($password, $af->{site__password}) > 0)
&& ($username eq $af->{site__username}) ){
debug_print("loginexec.cgi: AUTH OK.\n");
@@ -102,7 +127,7 @@
my $TMPL_FILE = "$af->{site__fs_root}/templates/$af->{site__template}/owner_side/loginfailed.tmpl";
my $tmpl = new HTML::Template( filename => $TMPL_FILE);
- $tmpl->param("forward_URL" => $af->{site__web_root});
+ $tmpl->param("forward_URL" => $af->{site__user_afid});
$tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}");
print "Content-type: text/html; charset=UTF-8\n\n";
print $af->translate_templateL10N($tmpl->output);
@@ -113,23 +138,22 @@
}elsif($mode eq "s0"){
####################################################################
- #Phase S0 (V2 protocol)
-
+ #Phase V2: Phase S0
+ ####################################################################
if($affelio_url eq $af->{site__username}){
##################################
#input URL = site owner's nickname
##################################
-
show_checkpassword_screen(mode => "login_as_owner");
exit(1);
}else{
##################################
- #Format adjustment of AffelioURL
+ #Else
##################################
$affelio_url =~ /^([A-Za-z0-9\-\_]*)$/;
if ($1 eq $affelio_url){
- $affelio_url = $farm_URL . $affelio_url;
+ $affelio_url = $farm_users_root . $affelio_url;
}
if($affelio_url !~ /^(http:\/\/)/){
@@ -140,12 +164,11 @@
}
debug_print("loginexec.cgi($mode): formated Affelio URL= [$affelio_url]");
- if($affelio_url eq $af->{site__web_root}){
+ if($affelio_url eq $af->{site__user_afid}){
show_checkpassword_screen(mode => "login_as_owner");
exit(1);
}
-
##################################
#Determine aftergo_URL
##################################
@@ -158,7 +181,7 @@
#Determine forward_URL
##################################
if($forward_URL eq ""){
- $forward_URL= $af->{site__web_root};
+ $forward_URL= $af->{site__user_afid};
}
##################################
@@ -174,21 +197,22 @@
}elsif($mode eq "s1"){
####################################################################
- #Phase S1 (V2 protocol)
- #(password input phase)
-
+ #Phase V2: Phase S1
+ # (password input phase)
+ ####################################################################
show_checkpassword_screen(mode => "back_from_friend");
debug_print("loginexec.cgi($mode): end.");
exit(1);
}elsif($mode eq "s2"){
- #####################################################################
- #Phase S2 (V2 protocol)
- #(auth check phase)
+ ####################################################################
+ #Phase V2: Phase S2
+ # (auth check phase)
+ ####################################################################
debug_print("loginexec.cgi($mode): submit_type= $submit_type");
if($submit_type eq "Cancel"){
if($aftergo_URL eq ""){
- print $q->redirect( -url => $af->{site__web_root});
+ print $q->redirect( -url => $af->{site__user_afid});
exit;
}else{
print $q->redirect( -url => $aftergo_URL);
@@ -224,7 +248,7 @@
#######################################################################
#Startup new session
#######################################################################
- $af->getSM->startup_session(user_afid => $af->{site__web_root},
+ $af->getSM->startup_session(user_afid => $af->{site__user_afid},
user_nickname => $af->{user__nickname},
type => "self");
$af->getSM->get_session->expire("+3d");
@@ -236,7 +260,6 @@
$issued_cookie = $af->getSM->issue_cookie();
}
-
############################################################################
#Check if forward_URL is my friend
############################################################################
@@ -258,10 +281,10 @@
show_askmakefriend_screen();
exit;
}else{
- $next_url= "$af->{site__web_root}/outgoing.cgi?dest_url=$forward_URL&dest_url2=$aftergo_URL";
+ $next_url= "$af->{site__user_afid}/outgoing.cgi?dest_url=$forward_URL&dest_url2=$aftergo_URL";
}
}else{
- $next_url= "$af->{site__web_root}/admin.cgi";
+ $next_url= "$af->{site__user_afid}/admin.cgi";
}
if($issued_cookie){
@@ -274,9 +297,8 @@
-
-
-
+############################################################################
+# sub show_askmakefriend_screen
############################################################################
sub show_askmakefriend_screen{
my $TMPL_FILE = "$af->{site__fs_root}/templates/$af->{site__template}/owner_side/ask_makefriend.tmpl";
@@ -284,14 +306,16 @@
die_on_bad_params => 0);
$tmpl->param("owner_nickname" => $af->{user__nickname});
$tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}");
- $tmpl->param("admin_path" => "$af->{site__web_root}/admin.cgi?mode=makefriend&dest_url=$forward_URL");
+ $tmpl->param("admin_path" => "$af->{site__user_afid}/admin.cgi?mode=makefriend&dest_url=$forward_URL");
$tmpl->param("dest_affelio_URL" => $forward_URL);
print "Content-type: text/html; charset=UTF-8\n\n";
print $af->translate_templateL10N($tmpl->output);
}
-
+############################################################################
+# sub show_checkpassword_screen
+############################################################################
sub show_checkpassword_screen{
my %args = @_;
@@ -300,10 +324,11 @@
die_on_bad_params => 0);
$tmpl->param("owner_nickname" => $af->{user__nickname});
$tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}");
- $tmpl->param("cgi_path" => "$af->{site__web_root}/bin/loginexec.cgi?mode=s2&forward_URL=$forward_URL&aftergo_URL=$aftergo_URL");
+ $tmpl->param("cgi_path" => "$af->{site__user_afid}/bin/loginexec.cgi?mode=s2&forward_URL=$forward_URL&aftergo_URL=$aftergo_URL");
$tmpl->param($args{mode} => "true");
$tmpl->param(error => $args{error});
print "Content-type: text/html; charset=UTF-8\n\n";
print $af->translate_templateL10N($tmpl->output);
}
+############################################################################
Index: affelio/bin/logoutexec.cgi
diff -u affelio/bin/logoutexec.cgi:1.7 affelio/bin/logoutexec.cgi:1.8
--- affelio/bin/logoutexec.cgi:1.7 Sat Jan 28 17:47:22 2006
+++ affelio/bin/logoutexec.cgi Thu Feb 23 21:41:36 2006
@@ -16,20 +16,19 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-# $Id: logoutexec.cgi,v 1.7 2006/01/28 08:47:22 slash5234 Exp $
+# $Id: logoutexec.cgi,v 1.8 2006/02/23 12:41:36 slash5234 Exp $
use strict;
use lib("../extlib");
use CGI qw(-unique_headers);
-$CGI::DISABLE_UPLOADS = 1;
-$CGI::POST_MAX = 102_400;
use CGI::Session; #qw(-ip_match);
use HTML::Template;
use Error qw(:try);
use lib("../lib");
use Affelio;
+use Affelio::App::Env;
use Affelio::SNS::Handshaker_c;
use Affelio::misc::CGIError;
use Affelio::misc::Debug;
@@ -37,6 +36,8 @@
use Affelio::misc::MyCrypt;
use Affelio::misc::Time;
+debug_print("logoutexec.cgi: start.");
+
my $q = new CGI;
############################################################################
#Load Affelio
@@ -44,7 +45,8 @@
my $cfg_dir = "../config/";
my $af;
try{
- $af = new Affelio(ConfigDir => $cfg_dir);
+ $af = new Affelio(ConfigDir => $cfg_dir,
+ CGI => $q);
}catch Error with{
my $e = shift;
error($q, "Affelio load error.\n" . $e);
@@ -55,10 +57,7 @@
#Check session w/ cookie
############################################################################
my $sid = $q->cookie("affelio-$af->{user__nickname}");
-my $session = new CGI::Session(undef,
- $sid,
- {Directory=> $af->{site__session_dir}});
-
+my $session = $af->getSM->get_session();
if($session){
#Output expired cookie and redirect the user to index.
@@ -67,13 +66,10 @@
undef($session);
#Output expired cookie and redirect the user to index.
- my $cookie = $q->cookie ( -name => "affelio-$af->{user__nickname}",
- -value => $sid,
- -path => URL2path($af->{site__web_root}),
- -expires => "-1d"
- );
+}
- print $q->redirect( -url => $af->{site__web_root},
- -cookie => $cookie);
+print $q->redirect( -url => $af->{site__user_afid});
+
+debug_print("logoutexec.cgi: end.");
+exit(1);
-}
Index: affelio/bin/recv_mail_ack.cgi
diff -u affelio/bin/recv_mail_ack.cgi:1.12 affelio/bin/recv_mail_ack.cgi:1.13
--- affelio/bin/recv_mail_ack.cgi:1.12 Thu Jan 19 16:18:08 2006
+++ affelio/bin/recv_mail_ack.cgi Thu Feb 23 21:41:36 2006
@@ -15,193 +15,14 @@
# 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.
-
-# $Id: recv_mail_ack.cgi,v 1.12 2006/01/19 07:18:08 slash5234 Exp $
-
+#
+# $Id: recv_mail_ack.cgi,v 1.13 2006/02/23 12:41:36 slash5234 Exp $
use strict;
+use lib("../lib");
use lib("../extlib");
-use CGI qw(-unique_headers);
-$CGI::DISABLE_UPLOADS = 1;
-$CGI::POST_MAX = 102_400;
-use CGI::Session; #qw(-ip_match);
-use HTML::Template;
-use File::Copy;
-use Crypt::DH;
-use Error qw(:try);
-
-use lib("../lib/");
-use Affelio;
-use Affelio::misc::CGIError;
-use Affelio::misc::Debug;
-use Affelio::misc::MyCrypt;
-use Affelio::SNS::Handshaker_c;
-use Affelio::SNS::Handshaker_tmpDB;
-use Affelio::exception::Exception;
-use Affelio::exception::IOException;
-use Affelio::misc::WebInput;
-
-my $q = new CGI;
-
-############################################################################
-#Load Affelio
-my $cfg_dir = "../config/";
-my $af;
-try{
- $af = new Affelio(ConfigDir => $cfg_dir);
-}catch Error with{
- my $e = shift;
- error($q, "Affelio load error.\n" . $e);
-};
-my $wi = new Affelio::misc::WebInput;
-
-############################################################################
-#Sesion check (as admin)
-my $sid = $q->cookie("affelio-$af->{user__nickname}");
-my $session = new CGI::Session(undef,
- $sid,
- {Directory=> $af->{site__session_dir}});
-
-my $TMPL_FILE="";
-if( (!$session) || ($session->param("type") ne "self") ){
- # Is the session alive?
- # Is the user the admin of this site?
- # if not....
- debug_print("recv_mail_ack.cgi: login is needed.");
-
- $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.");
- $tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}/owner_side/");
- print "Content-type: text/html; charset=UTF-8\n\n";
- print $af->translate_templateL10N($tmpl->output);
- exit(1);
-}
-debug_print("recv_mail_ack.cgi: Session as the admin is OK.");
-
-
-############################################################################
-#Read CGI input
-my $session_id="";
-$session_id = $wi->PTN_word($q->param("id"));
-if(!$session_id){
- die "id is not defined. [$session_id]";
-}
-debug_print("recv_mail_ack: $session_id\n");
-
-
-############################################################################
-#Read temporarily-saved session
-my $dummy;
-my $timestamp;
-my $peer_af_id;
-my $peer_name;
-my $peer_nickname;
-my $peer_DH_pub_key_str;
-my $peer_DH_pub_key;
-
-############################################################################
-#remove a record from tmpDB
-my $tmpdb= new Affelio::SNS::Handshaker_tmpDB($af);
-my @ret= $tmpdb->remove_received_Handshake($session_id);
-
-if(!defined(@ret)){
- #No such session exists!!
- debug_print("recv_mail_ack: session not found.\n");
- error($q, "Affelio load error.\nNo such session exists!");
-}else{
- ($dummy, $timestamp, $peer_af_id,
- $peer_nickname, $peer_DH_pub_key_str) = @ret;
-
- $peer_DH_pub_key = Math::BigInt->new($peer_DH_pub_key_str);
-}
-debug_print("recv_mail_ack: $session_id, $timestamp, $peer_af_id, $peer_nickname, $peer_DH_pub_key_str\n");
-
-############################################################################
-#DH key generation
-my $mydh = Crypt::DH->new;
-#RFC 2412 - The OAKLEY Key Determination Protocol
-#Group 1: A 768 bit prime
-my $DH_g="2";
-my $DH_p="1552518092300708935130918131258481755631334049434514313202351194902966239949102107258669453876591642442910007680288864229150803718918046342632727613031282983744380820890196288509170691316593175367469551763119843371637221007210577919";
-$mydh->g($DH_g);
-$mydh->p($DH_p);
-#
-#Step (1): create my public_key
-$mydh->generate_keys;
-my $my_DH_pub_key = $mydh->pub_key;
-my $my_DH_pub_key_str = $mydh->pub_key->bstr;
-
-
-############################################################################
-#send FriendshipReply
-my $ret="";
-try{
- $ret = reply_HandShake(dest_uri => "$peer_af_id",
- timestamp => $timestamp,
- my_nickname => $af->{user__nickname},
- my_domain => $af->{user__domain},
- my_AFID => $af->{site__web_root},
- DH_pub_key_str => $my_DH_pub_key_str
- );
-}catch Error with {
- my $E = shift;
- error($q, "HandShake reply output an error!\n$E");
-};
-
-debug_print("recv_mail_ack: reply_HandShake finished.");
-
-############################################################################
-#generate Password
-my $pass = $mydh->compute_key($peer_DH_pub_key)->bstr;
-debug_print("recv_mail_ack: PASSWORD=[$pass]\n");
-
-############################################################################
-#Add peer to my friends list.
-try{
- $af->getFM->add_friend($peer_af_id,
- $peer_nickname,
- $timestamp,
- $pass);
-}catch Error with{
- my $E = shift;
- error($q, "Error from FriendManager\n$E\n");
-};
-debug_print("recv_mail_ack: added to my friends list.");
-sleep(2);
-
-############################################################################
-#Get peer's friends list.
-try{
- $ret = get_F2List(dest_uri => "$peer_af_id",
- timestamp => 0);
-}catch Error with {
- my $E = shift;
- error($q, "HandShake was successful!\n But, get_F2List reply output an error!\n$E");
-};
-debug_print("recv_mail_ack: get_F2List finished.");
-debug_print("recv_mail_ack: List I've got is [$ret]");
-#
-#
-##################################################
-#Save the F2 list into my DB
-#$af->{fm}->save_F2List($ret, $peer_af_id);
-
-my $urlencoded_title = url_encode($af->translate_templateL10N('<AF_M text="_HandshakeReply_SentBack_message_title">'));
-
-############################################################################
-#print output HTML
-my $TMPL_FILE = "../templates/$af->{site__template}/owner_side/mail_ack_recved.tmpl";
-my $tmpl = new HTML::Template( filename => $TMPL_FILE);
-$tmpl->param(peer_af_id => $af->{site__web_root} . "/outgoing.cgi?dest=".$peer_af_id);
-$tmpl->param(peer_nickname => $peer_nickname);
-
-$tmpl->param(next_url => $af->{site__web_root} . "/admin.cgi?mode=messages&action=compose&to_url=" . $peer_af_id . "&title=" . $urlencoded_title);
-
-$tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}");
-
-print "Content-type: text/html; charset=UTF-8\n\n";
-print $af->translate_templateL10N($tmpl->output);
+use Affelio::App::Env;
+use Affelio::App::Public;
+my $public = new Affelio::App::Public();
+$public->run(App=> "Bin::recv_mail_ack");
Index: affelio/bin/send_handshake.cgi
diff -u affelio/bin/send_handshake.cgi:1.7 affelio/bin/send_handshake.cgi:1.8
--- affelio/bin/send_handshake.cgi:1.7 Thu Jan 19 16:18:08 2006
+++ affelio/bin/send_handshake.cgi Thu Feb 23 21:41:36 2006
@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-# $Id: send_handshake.cgi,v 1.7 2006/01/19 07:18:08 slash5234 Exp $
+# $Id: send_handshake.cgi,v 1.8 2006/02/23 12:41:36 slash5234 Exp $
use strict;
use lib("../extlib");
@@ -128,7 +128,7 @@
$ret = send_HandShake(dest_uri => $target_url,
timestamp => $cur_time,
my_nickname => $af->{user__nickname},
- my_AFID => $af->{site__web_root},
+ my_AFID => $af->{site__user_afid},
DH_pub_key_str => $my_DH_pub_key_str
);
}catch Affelio::exception::IOException with{
@@ -161,7 +161,7 @@
my $TMPL_FILE = "../templates/$af->{site__template}/owner_side/handshake_sent.tmpl";
my $tmpl = new HTML::Template( filename => $TMPL_FILE);
$tmpl->param(target_url => $target_url);
-$tmpl->param(mypage_url => "$af->{site__web_root}/admin.cgi");
+$tmpl->param(mypage_url => "$af->{site__user_afid}/admin.cgi");
$tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}");
print "Content-type: text/html; charset=UTF-8\n\n";
Index: affelio/bin/xml-rpc-serv.cgi
diff -u affelio/bin/xml-rpc-serv.cgi:1.2 affelio/bin/xml-rpc-serv.cgi:1.3
--- affelio/bin/xml-rpc-serv.cgi:1.2 Fri Jul 1 10:49:01 2005
+++ affelio/bin/xml-rpc-serv.cgi Thu Feb 23 21:41:36 2006
@@ -16,21 +16,30 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-# $Id: xml-rpc-serv.cgi,v 1.2 2005/07/01 01:49:01 slash5234 Exp $
+# $Id: xml-rpc-serv.cgi,v 1.3 2006/02/23 12:41:36 slash5234 Exp $
use strict;
+use lib("lib");
+use lib("extlib");
+use lib("../lib");
+use lib("../extlib");
my($AF_DIR);
BEGIN {
-# if ($0 =~ m!(.*[/\\])!) {
-# $AF_DIR = $1;
-# } else {
- $AF_DIR = '../';
-# }
+ $AF_DIR='../';
unshift @INC, $AF_DIR . 'lib/';
unshift @INC, $AF_DIR . 'extlib/';
}
+my $script_dir = $ENV{'SCRIPT_NAME'};
+$script_dir =~ s|^(.*)/([A-Za-z0-9\_\-\.]+)$|$1/|;
+#Affelio's lib dir
+#eval "use lib($script_dir/lib);";
+#Affelio's extlib dir
+#eval "use lib(\"$script_dir/extlib\");";
+
+use Affelio::App::Env;
+
use XMLRPC::Transport::HTTP;
use Affelio::SNS::Handshaker_s;