[Affelio-cvs 687] CVS update: affelio_farm/admin/skelton/affelio/lib/Affelio/SNS

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 10月 25日 (火) 04:20:55 JST


Index: affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/FriendManager.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/FriendManager.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/FriendManager.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/FriendManager.pm:1.1.1.1	Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/FriendManager.pm	Tue Oct 25 04:20:54 2005
@@ -1,777 +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.
-#
-# $Id: FriendManager.pm,v 1.1.1.1 2005/10/24 19:14:40 slash5234 Exp $
-
-package Affelio::SNS::FriendManager;
-{
-    use strict;
-
-    use lib("../../../extlib");    
-    use DBI;
-    use lib("../../");
-    use Affelio;
-    use Affelio::misc::CGIError;
-    use Affelio::misc::Debug qw(debug_print);
-    use Affelio::misc::Time;
-    use Affelio::misc::DBroutines qw(db_value_replace);
-    use Affelio::exception::DBException;
-
-    ########################################################################
-    #Constructor
-    ########################################################################
-    sub new{
-	my $class = shift;
-	my $af = shift;
-
-	debug_print("FriendManager::new: start.");
-	
-	my $self = {af => $af
-		    };
-	
-	bless $self, $class;
-	
-	debug_print("FriendManager::new: end.");
-	return $self;
-    }
-    
-    ########################################################################
-    #get_F1_count
-    ########################################################################
-    sub get_F1_count{
-	my $self = shift;
-	my $af = $self->{af};
-
-	##############################
-	#retrieve all friend records from DB
-	my $query = 'SELECT count(*) FROM AFuser_CORE_friends';
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	my @row = $sth->fetchrow_array;
-	return($row[0]);
-    }
-
-    ########################################################################
-    #get_F2_count
-    ########################################################################
-    sub get_F2_count{
-	my $self = shift;
-	my $af = $self->{af};
-
-	##############################
-	#retrieve all friend records from DB
-	my $query = 'SELECT count(*) FROM AFuser_CORE_friendsfriends';
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	my @row = $sth->fetchrow_array;
-	return($row[0]);
-    }
-
-
-    ########################################################################
-    #add_friend
-    ########################################################################
-    sub add_friend{                  #returns uid (int)
-	my $self = shift;
-	my $af_id = shift;           #arg(1) af_id     (string)
-	my $nickname = shift;        #arg(2) nickname  (string)
-	my $timestamp = shift;       #arg(3) timestamp (int)
-	my $password = shift;        #arg(4) password  (string)
-
-	Affelio::misc::Debug::debug_print("FM::add_friend: ($af_id $nickname $timestamp $password)");
-	
-	my $af = $self->{af};
-	my $sth;
-	my $query;
-	my @row;
-	my $maxid;
-	my $newid;
-	my $old_uid_in_f2tbl="";
-	my $old_f1list_in_f2tbl=",";
-
-	##############################
-	#Is ($af_id) already in my F1 table?
-	#If so, we DO NOT ignore him. 
-	#We have to update his information.
-	#
-	$query = "SELECT * FROM AFuser_CORE_friends WHERE af_id = '$af_id'";
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	@row = $sth->fetchrow_array;
-	if(@row && @row!=() ){
-
-	    Affelio::misc::Debug::debug_print("FM::add_friend: Already my friend!");
-	      
-	      $query = "update AFuser_CORE_friends set timestamp = '$timestamp', password = '$password' where af_id = '$af_id'";
-	      eval{
-		  $sth = $af->{db}->prepare($query);
-		  $sth->execute();
-	      };
-	      if($@){
-		  throw Affelio::exception::DBException($af->{db}->errstr);
-	      }
-	      Affelio::misc::Debug::debug_print("FM::add_friend:\tUpdated an existing friend.");
-	      Affelio::misc::Debug::debug_print("FM::add_friend: end($row[0]).");		  
-	      ################
-	      #Return
-	      return $row[0]; #return uid.
-	}
-
-	##############################
-	#Get existing max ID
-	$query = 'SELECT max(uid) FROM AFuser_CORE_friends';
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-	@row = $sth->fetchrow_array;
-	$maxid = $row[0];
-	if(defined($row[0])){
-	    $maxid = $row[0];
-	}else{
-	    $maxid = 0;
-	}
-	$newid = $maxid + 1;
-	Affelio::misc::Debug::debug_print("FM::add_friend: new_ID= [$newid]");
-
-	##############################
-	#Is $af_id already in F2 table?
-	#If so, we have to move it from F2 table to F1 table.
-	$query = "SELECT * FROM AFuser_CORE_friendsfriends WHERE af_id = '$af_id'";
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	}; 
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	@row = $sth->fetchrow_array;
-	if(@row && @row !=() ){
-	    ############################################
-	    #I found the record in F2 table.
-	    #Let's move it to the F1 table.
-	    Affelio::misnc::Debug::debug_print("FM::add_friend:\t [@row]");
-	    Affelio::misc::Debug::debug_print("FM::add_friend:\tHe is my friends' friend.");
-	    Affelio::misc::Debug::debug_print("FM::add_friend:\tLet's move him.");
-	      
-	    #Backup data
-	    $old_uid_in_f2tbl = $row[0];
-	    $old_f1list_in_f2tbl = $row[4];
-
-	    #Delete the record in the F2 table.
-	    $query = "DELETE FROM AFuser_CORE_friendsfriends WHERE uid = $old_uid_in_f2tbl";
-	    eval{
-		$sth = $af->{db}->prepare($query);
-		$sth->execute();
-	    };
-	    if($@){
-		throw Affelio::exception::DBException($af->{db}->errstr);
-	    }
-	    Affelio::misc::Debug::debug_print("FM::add_friend:\tRecord($old_uid_in_f2tbl) in F2 tbl deleted.");
-
-	    #Update all other F1 and F2 entries' "flist" column
-	    # from $old_uid_in_f2tbl  to  $newid
-	    #   update sample set data=translate(data,'b','z')
-	    db_value_replace($af->{db},
-			     "AFuser_CORE_friendsfriends",
-			     "uid",
-			     "f1list",
-			     ",$old_uid_in_f2tbl," ,
-			     ",$newid," , 
-			     );
-
-	    db_value_replace($af->{db},
-			     "AFuser_CORE_friends",
-			     "uid",
-			     "f2list",
-			     ",$old_uid_in_f2tbl," ,
-			     ",$newid," , 
-			     );
-
-	    Affelio::misc::Debug::debug_print("FM::add_friend:\tOverwritten id($old_uid_in_f2tbl) -> id($newid)");
-	}
-
-
-	##############################
-	#Insert a new record into my F1 list.
-	$query = "insert into AFuser_CORE_friends(uid, af_id, nickname, timestamp, password, intro, option_pid,lastupdated,f2list) values ($newid, '$af_id', '$nickname', $timestamp, '$password', ' ', -1, 0, '$old_f1list_in_f2tbl')";
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	Affelio::misc::Debug::debug_print("FM::add_friend:\tInserted a new record.");
-	Affelio::misc::Debug::debug_print("FM::add_friend: end($newid).");
-	return($newid);
-    }
-
-
-    ########################################################################
-    #remove_friend
-    ########################################################################
-    sub remove_friend{               #void
-	my $self = shift;
-	my $uid = shift;           #arg(1) uid (int)
-	my $af = $self->{af};
-
-	Affelio::misc::Debug::debug_print("FM::remove_friend:start.");
-
-	#Remove entry(uid) from AFuser_CORE_friends
-	my $q1 = "DELETE FROM AFuser_CORE_friends WHERE uid = $uid";
-	my $s1;
-	eval{
-	    $s1 = $af->{db}->prepare($q1);
-	    $s1->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-	undef($q1);
-	undef($s1);
-	Affelio::misc::Debug::debug_print("FM::remove_friend:\t removed entry($uid) from F1 DB");
-	
-	#Remove uid from friends of others in AFuser_CORE_friends
-	db_value_replace($af->{db},
-			 "AFuser_CORE_friends",
-			 "uid",
-			 "f2list",
-			 ",$uid," ,
-			 ",," , 
-			 );
-	Affelio::misc::Debug::debug_print("FM::remove_friend:\t removed entry($uid) from other's F2list in F1 DB");
-
-	#Remove uid from friends of others in AFuser_CORE_friendsfriends
-	db_value_replace($af->{db},
-			 "AFuser_CORE_friendsfriends",
-			 "uid",
-			 "f1list",
-			 ",$uid," ,
-			 ",," , 
-			 );
-	Affelio::misc::Debug::debug_print("FM::remove_friend:\t removed entry($uid) from other's F1list in F2 DB");
-    }
-
-
-    ########################################################################
-    #save_F2List
-    ########################################################################
-    # We retrieve "friend list" from my friends.
-    # That "friend list" is my "F2 list" (through the friend).
-    # Then, save_F2list is invoked when the retrieved F2 list gets stored.
-    sub save_F2List{
-	my $self = shift;
-	my $datain = shift;     #arg(1) data input
-	my $f1_af_id = shift;   #arg(2) f1_af_id
-	my $af = $self->{af};
-	
-	Affelio::misc::Debug::debug_print("FM::save_F2List: start.");  
-	
-	# Data format:
-	#
-	# [ADD|DEL] $timestamp $af_id\n
-	#
-	my @datalist = split("\n", $datain);
-	
-	my $latest_timestamp =0;
-	
-	#While (each line)
-	foreach my $thisdata (@datalist){
-	    my ($timestamp, $method, $f2_af_id, $nickname) 
-		= split(" ", $thisdata);
-	    
-	    #If the AF_ID is mine, ignore it.
-	    if($f2_af_id eq $af->{site__web_root}){
-		next;
-	    }
-	    
-	    if($timestamp > $latest_timestamp){
-		$latest_timestamp = $timestamp;
-	    }
-	    
-	    Affelio::misc::Debug::debug_print("FM::save_F2List: [$method][$f2_af_id]");  
-	    
-	    if($method eq "ADD"){
-		#######################
-		#ADD 
-		#######################
-		my $sth; 
-		my $query;
-		my @row_in_f1table;
-		my @row_in_f2table;
-		
-		my @row;
-		my $f1_uid ="";
-		my $f1_f2list="";
-		
-		my $f2_uid ="";
-		my $f2_f1list="";
-		
-		my $new_f1_f2list="";
-		my $new_f2_f1list="";
-		
-		#Get F1's info
-		$f1_uid = Affelio::SNS::FriendManager::get_attribute_by_afid($self, $f1_af_id, "uid");
-		$f1_f2list = Affelio::SNS::FriendManager::get_attribute_by_afid($self, $f1_af_id, "f2list");
-		Affelio::misc::Debug::debug_print("FM::save_F2list: F1's F2list = [$f1_f2list]");
-		
-		#The guy with F2_AF_ID is in the Friend table?
-		$query = "SELECT * FROM AFuser_CORE_friends WHERE af_id = '$f2_af_id'";
-		eval{
-		    $sth = $af->{db}->prepare($query);
-		    $sth->execute();
-		};
-		if($@){
-		    throw Affelio::exception::DBException($af->{db}->errstr);
-		}
-
-		@row_in_f1table = $sth->fetchrow_array;
-		undef($sth);
-		undef($query);
-		
-		if(@row_in_f1table && @row_in_f1table !=()){
-		    ###############################################
-		    #This $f2_af_id has been FOUND in our Friend DB.
-		    ###############################################
-		    Affelio::misc::Debug::debug_print("FM::save_F2List: \tF2 person is found in our F1 table");  
-		      my $query2="";
-		      my $sth2="";
-
-		      $f2_uid = $row_in_f1table[0];
-		      $f2_f1list = $row_in_f1table[8];
-		      Affelio::misc::Debug::debug_print("FM::save_F2list: F2's F1list = [$f2_f1list]");
-		      
-		      #Modify "Friend" table
-		      #Add $f2_uid into $f1_af_id's F2list
-		      $new_f1_f2list = $f1_f2list . $f2_uid . ",";
-		      Affelio::misc::Debug::debug_print("FM::save_F2List: \tnew_f1_f2list=[$new_f1_f2list]");
-		      $query2 = "update AFuser_CORE_friends set f2list = '$new_f1_f2list' where uid = '$f1_uid'";
-		      eval{
-			  $sth2 = $af->{db}->prepare($query2);
-			  $sth2->execute();
-		      };
-		      if($@){
-			  throw Affelio::exception::DBException($af->{db}->errstr);
-		      }
-
-		      Affelio::misc::Debug::debug_print("FM::save_F2list: New F1($f1_uid)'s F2list = [$new_f1_f2list]");
-		      
-		      #Modify "Friend" table
-		      #Add $f1_af_id into $f2_uid's F1list
-		      $new_f2_f1list = $f2_f1list . $f1_uid . ",";
-		      Affelio::misc::Debug::debug_print("FM::save_F2List: \tnew_f2_f1list=[$new_f2_f1list]");
-		      $query2 = "update AFuser_CORE_friends set f2list = '$new_f2_f1list' where uid = $f2_uid";
-		      eval{
-			  $sth2 = $af->{db}->prepare($query2);
-			  $sth2->execute();
-		      };
-		      if($@){
-			  throw Affelio::exception::DBException($af->{db}->errstr);
-		      }
-		      Affelio::misc::Debug::debug_print("FM::save_F2list: New F2($f2_uid)'s F1list = [$new_f2_f1list]");
-		      
-		  }else{
-		      my $query2="";
-		      my $sth2="";
-
-		      #The guy with F2_AF_ID is in the FriendsFriends table?
-		      $query2 = "SELECT * FROM AFuser_CORE_friendsfriends WHERE af_id = '$f2_af_id'";
-		      eval{
-			  $sth2 = $af->{db}->prepare($query2);
-			  $sth2->execute();
-		      };
-		      if($@){
-			  throw Affelio::exception::DBException($af->{db}->errstr);
-		      }
-
-		      @row_in_f2table = $sth2->fetchrow_array;
-		      
-		      if(!@row_in_f2table || @row_in_f2table==()){
-			  ###############################################
-			  #This $f2_af_id has NOT been FOUND anywhere
-			  ###############################################
-			  Affelio::misc::Debug::debug_print("FM::save_F2List:\t F2 person is NOT Found anywhere. Brand new!");  
-			    my $query3="";
-			    my $sth3="";
-			    
-			    ##############################
-			    #Get existing min ID
-			    $query3 = 'SELECT min(uid) FROM AFuser_CORE_friendsfriends';
-			    eval{
-				$sth3 = $af->{db}->prepare($query3);
-				$sth3->execute();
-			    };
-			    if($@){
-				throw Affelio::exception::DBException($af->{db}->errstr);
-			    }
-
-			    @row = $sth3->fetchrow_array;
-			    my $minid = $row[0];
-			    if(defined($row[0])){
-				$minid = $row[0];
-			    }else{
-				$minid = -1;
-			    }    
-			    
-			    ##############################
-			    #Insert a new record
-			    my $tmpnewid = $minid-1;
-			    $query3 = "insert into AFuser_CORE_friendsfriends (uid, af_id, nickname, timestamp, f1list) values ('$tmpnewid', '$f2_af_id', '$nickname', $timestamp, ',')";
-			    eval{
-				$sth3 = $af->{db}->prepare($query3);
-				$sth3->execute();
-			    };
-			    if($@){
-				throw Affelio::exception::DBException($af->{db}->errstr);
-			    }
-
-			    $f2_uid = $minid - 1;  #F2 UID is negative!
-			    $f2_f1list = ",";
-			    Affelio::misc::Debug::debug_print("FM::save_F2List:\tCreated F2 entry id=$f2_uid");
-			}else{
-			    ###############################################
-			    #This $f2_af_id has been FOUND in FriendsFriends DB.
-			    ###############################################
-			    $f2_uid = $row_in_f2table[0];
-			    $f2_f1list = $row_in_f2table[4];
-			    Affelio::misc::Debug::debug_print("FM::save_F2List:\t F2 person is FOUND in our F2 table.");  
-			    Affelio::misc::Debug::debug_print("FM::save_F2List:\t F2uid  = [$f2_uid]");
-			    Affelio::misc::Debug::debug_print("FM::save_F2List:\t F1List = [$f2_f1list]");
-			}
-		      
-		      #Modify "Friend" table
-		      #Add $f2_uid into $f1_af_id's F2list
-		      $new_f1_f2list = $f1_f2list . $f2_uid . ",";
-		      Affelio::misc::Debug::debug_print("FM::save_F2List:\tnew_f1_f2list=[$new_f1_f2list]");
-		      $query2 = "update AFuser_CORE_friends set f2list = '$new_f1_f2list' where uid = $f1_uid";
-		      eval{
-			  $sth2 = $af->{db}->prepare($query2); 
-			  $sth2->execute();
-		      };
-		      if($@){
-			  throw Affelio::exception::DBException($af->{db}->errstr);
-		      }
-		      
-		      #Modify "FriendsFriends" table
-		      #Add $f1_af_id into $f2_uid's F1list
-		      $new_f2_f1list = $f2_f1list . $f1_uid . ",";
-		      Affelio::misc::Debug::debug_print("FM::save_F2List:\tnew_f2_f1list=[$new_f2_f1list]");
-		      $query2 = "update AFuser_CORE_friendsfriends set f1list = '$new_f2_f1list' where uid = $f2_uid";
-		      eval{
-			  $sth2 = $af->{db}->prepare($query2);
-			  $sth2->execute();
-		      };
-		      if($@){
-			  throw Affelio::exception::DBException($af->{db}->errstr);
-		      }
-		      
-		  }#if
-		      Affelio::misc::Debug::debug_print("FM::save_F2List: [$method] DONE.");
-		
-	    }elsif($method eq "DEL"){
-		#######################
-		#DEL
-		#######################
-		#XXX Not implemented
-		
-	    }elsif($method eq "MOV"){
-		#######################
-		#MOV
-		#######################
-		#XXX Not implemented
-
-	    }#if(method)
-
-	}#foreach
-
-	Affelio::misc::Debug::debug_print("FM::save_F2List: Latest timestamp=[$latest_timestamp]");
-	#Updating "lastupdated" attribute of this friend...
-	my $f1_uid = get_attribute_by_afid($self, $f1_af_id, "uid");
-
-	set_attribute_by_id($self, $f1_uid, "lastupdated", $latest_timestamp);
-    }
-
-
-    ########################################################################
-    #get_updated_friends
-    ########################################################################
-    sub get_updated_friends{          #return string result
-	my $self = shift;
-	my $req_timestamp = shift;    #arg(1) timestamp
-	my $af = $self->{af};
-
-	##############################
-	#retrieve a friend record from DB
-	my $query = "SELECT af_id, timestamp, nickname FROM AFuser_CORE_friends WHERE timestamp > " . $req_timestamp;
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query); 
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	my $retmsg="";
-	my @row=();
-	my $af_id="";
-	my $timestamp="";
-	my $nickname="";
-	while( ($af_id, $timestamp, $nickname) = $sth->fetchrow_array){
-	    $retmsg .= "$timestamp ADD $af_id $nickname\n";
-	}
-
-	##############################
-	#retrieve erased friend record from DB
-	#XXX Not implemented
-
-	##############################
-	#Sort by time
-	#XXX Not implemented
-
-	debug_print("FM::get_updated_friends: ret=[$retmsg]");
-	return($retmsg);
-    }
-
-
-    ########################################################################
-    #get_all_friend_list
-    ########################################################################
-    sub get_all_friend_list{          #return SQL_result
-	my $self = shift;
-	my $af = $self->{af};
-
-	##############################
-	#retrieve all friend records from DB
-	my $query = 'SELECT * FROM AFuser_CORE_friends order by uid desc';
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	return($sth);
-    }
-
-
-    ########################################################################
-    #get_friend_by_uid
-    #  arg(1) uid
-    #  returns array(0uid, 1af_id, 2nickname, 3timestamp, 
-    #                4password, 5intro, 6option_pid)
-    ########################################################################
-    sub get_friend_by_uid{                #return an SQL array
-	my $self = shift;
-	my $uid = shift;                  #arg(1) uid    (int)
-	
-	my $af = $self->{af};
-
-	##############################
-	#retrieve a friend record from DB
-	my $query = "SELECT * FROM AFuser_CORE_friends WHERE uid = $uid";
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-	my @row = $sth->fetchrow_array;
-	if(@row==()) {undef @row};
-	return(@row);
-    }
-
-
-    ########################################################################
-    #get_friend_by_afid
-    #  arg(1) afid
-    #  returns array(0uid, 1af_id, 2nickname, 3timestamp, 
-    #                4password, 5intro, 6option_pid
-    ########################################################################
-    sub get_friend_by_afid{             #return an SQL array
-	my $self = shift;
-	my $af_id = shift;              #arg(1) afid    (string)
-	
-	my $af = $self->{af};
-
-	##############################
-	#retrieve a friend record from DB
-	my $query = "SELECT * FROM AFuser_CORE_friends WHERE af_id = '$af_id'";
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	my @row = $sth->fetchrow_array;
-	if(@row==()) {undef @row};
-	return(@row);
-    }
-    
-
-    ########################################################################
-    #get_attribute_by_uid
-    ########################################################################
-    sub get_attribute_by_uid{            #return a value
-	my $self = shift;
-	my $uid = shift;                 #arg(1) uid  (int)
-	my $attr = shift;                #arg(2) attr (string)
-	
-	my $af = $self->{af};
-
-	##############################
-	#retrieve a friend record from DB
-	Affelio::misc::Debug::debug_print("FM::get_attr_by_uid(uid=$uid, attr=$attr)");
-	my $query = "SELECT $attr FROM AFuser_CORE_friends WHERE uid = '$uid'";
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	my @row = $sth->fetchrow_array;
-	return($row[0]);
-    }
-
-
-    ########################################################################
-    #F2_get_attribute_by_uid
-    ########################################################################
-    sub F2_get_attribute_by_uid{            #return a value
-	my $self = shift;
-	my $uid = shift;                 #arg(1) uid  (int)
-	my $attr = shift;                #arg(2) attr (string)
-	
-	my $af = $self->{af};
-
-	##############################
-	#retrieve a friend record from DB
-	my $query = "SELECT $attr FROM AFuser_CORE_friendsfriends WHERE uid = $uid";
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute();
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-	my @row = $sth->fetchrow_array;
-	return($row[0]);
-    }
-
-    ########################################################################
-    #get_attribute_by_afid
-    ########################################################################
-    sub get_attribute_by_afid{           #return a value
-	my $self = shift;
-	my $af_id = shift;               #arg(1) afid (string) 
-	my $attr = shift;                #arg(2) attr (string)
-
-	my $af = $self->{af};
-	$af_id = $af->{db}->quote($af_id);
-	
-	##############################
-	#retrieve a friend record from DB
-	my $query = "SELECT $attr FROM AFuser_CORE_friends WHERE af_id = $af_id";
-
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute;
-	};
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-	my @row = $sth->fetchrow_array;
-	my $size = @row;
-	return($row[0]);
-    }
-
-    ########################################################################
-    #set_attribute_by_id
-    ########################################################################
-    sub set_attribute_by_id{        #void
-	my $self = shift;
-	my $uid = shift;            #arg(1) uid (string) 
-	my $attr = shift;           #arg(2) attr (string)
-	my $value = shift;          #arg(3) value (string)
-
-	my $af = $self->{af};
-	if(($attr eq "password") 
-	   || ($attr eq "af_id") 
-	   || ($attr eq "nickname") 
-	   || ($attr eq "intro") ){
-	    $value = $af->{db}->quote($value);
-	}
-
-	##############################
-	#set value into DB
-	my $query = "update AFuser_CORE_friends set $attr = $value where uid = $uid";
-	my $sth;
-	eval{
-	    $sth = $af->{db}->prepare($query);
-	    $sth->execute;
-	}; 
-	if($@){
-	    throw Affelio::exception::DBException($af->{db}->errstr);
-	}
-
-    }
-
-
-
-    ########################################################################
-
-}#package
-1;
-
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_c.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_c.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_c.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_c.pm:1.1.1.1	Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_c.pm	Tue Oct 25 04:20:54 2005
@@ -1,285 +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.
-#
-# $Id: Handshaker_c.pm,v 1.1.1.1 2005/10/24 19:14:40 slash5234 Exp $
-
-package Affelio::SNS::Handshaker_c;
-{
-    #use strict;
-    use lib("../../../extlib/");
-    use XMLRPC::Lite;
-    use Error qw(:try);
-    use Crypt::DH;
-    use MIME::Base64::Perl;
-
-    use lib("../../../lib/");
-    use Affelio::misc::CGIError;
-    use Affelio::misc::Debug;
-    use Affelio::misc::MyCrypt;
-    use Affelio::misc::Time;
-    use Affelio::exception::Exception;
-    use Affelio::exception::InvalidInputException;
-    use Affelio::exception::IOException;
-    use Affelio::exception::NetworkException;
-
-    use Exporter;
-    @ISA = "Exporter";
-    @EXPORT = qw (send_HandShake reply_HandShake get_F2List post_Message);
-
-    #################################################################
-    # post_Message
-    # proto_ver: 1
-    #################################################################
-    sub post_Message{
-	my %arg = @_;
-	#arg (part 1)
-	my $proto_ver = 1.0;
-	my $dest_uri = $arg{dest_uri};
-	my $src = $arg{src};
-	my $password = $arg{password};
-
-	#arg (part 2)
-	my $msg_from = $arg{msg_from};
-	my $msg_from_nickname = $arg{msg_from_nickname};
-	my $msg_to = $arg{msg_to};
-	my $msg_timestamp = $arg{msg_timestamp};
-	my $MIMed_msg_title = encode_base64($arg{msg_title});
-	my $MIMed_msg_body = encode_base64($arg{msg_body});
-
-	debug_print("C::post_Message: dest=[$dest_uri]");
-	debug_print("C::post_Message: $msg_from, $msg_from_nickname, $msg_to, $msg_timestamp, [$MIMed_msg_title], [$MIMed_msg_body]");
-
-	############################
-	#Generate XML
-	############################
-	my $XMLbody = <<EOT;
-<message>
-<header>
-<from>$msg_from</from>
-<from_nickname>$msg_from_nickname</from_nickname>
-<to>$src</to>
-<timestamp>$msg_timestamp</timestamp>
-<title>$MIMed_msg_title</title>
-</header>
-<body>
-<text>$MIMed_msg_body</text>
-</body>
-</message>
-<src>$src</src>
-EOT
-	############################
-	#Encryption
-	############################
-	my $encrypted = msg_encrypt($XMLbody, $password);
-
-	############################
-	#MIME encode
-	############################
-	my $MIMed = encode_base64($encrypted);
-	debug_print("C::post_Message: [$MIMed]");
-
-	############################
-	#Send to the destination through XMLRPC
-	############################
-	my $result = eval {
-	    XMLRPC::Lite
-		->proxy($dest_uri) #XML
-		->call(
-		       'affelio.post_Message', 
-		       $proto_ver,
-		       get_timestamp(),
-		       $src,
-		       $MIMed
-		       )
-		->result;
-	  };
-	debug_print("C::post_Message: RPC returned.\n");
-	if ($@) {
-	    throw Affelio::exception::NetworkException($@);
-	}
-	if($result->{flerror} ne "0"){
-	    throw Affelio::exception::NetworkException("XML-RPC Error: " . $result->{message});
-	}
-
-	debug_print("post_Message: OK : $result->{message}\n");
-	debug_print("post_Message: OK : [$result->{flerror}]\n");
-	return $result;
-    }
-
-
-    #################################################################
-    # get_F2List(dest_uri, timestamp)
-    # proto_ver: 1
-    #################################################################
-    sub get_F2List {
-	my %arg = @_;
-	my $proto_ver = 1.0;
-	my $dest_uri = $arg{dest_uri};
-	my $timestamp = $arg{timestamp};
-
-	debug_print("get_F2List: $dest_uri $proto_ver $timestamp");
-
-	if ($dest_uri !~ /^http/) {
-	    throw Affelio::exception::InvalidInputException("dest_url");
-	}
-
-	my $result = eval {
-	    XMLRPC::Lite
-		->proxy($dest_uri)
-		->call(
-		       'affelio.F2List', 
-		       $proto_ver,
-		       $timestamp,
-		       )
-		->result;
-	  };
-	debug_print("C::get_F2List: RPC returned.\n");
-	if ($@) {
-	    throw Affelio::exception::NetworkException($@);
-	}
-	if($result->{flerror} ne "0"){
-	    throw Affelio::exception::NetworkException($result->{message});
-	}
-
-	debug_print("get_F2List: OK : $result->{message}\n");
-	debug_print("get_F2List: OK : [$result->{flerror}]\n");
-	return $result;
-    }
-
-
-    #################################################################
-    # send_HandShake(dest_url =>  $dest_uri, 
-    #                timestamp => $timestamp,
-    #                my_nickname => my_nickname,
-    #                my_AFID => my_AFID,
-    #                DH_pub_key_str => DH_pub_key_str,
-    #                mesg => mesg);
-    # proto_ver: 1.1
-    #################################################################
-    sub send_HandShake {
-	my %arg = @_;
-	my $dest_uri = $arg{dest_uri};
-	#
-	my $proto_ver = 1.1;
-	my $timestamp = $arg{timestamp};
-	#
-	my $my_nickname = $arg{my_nickname};
-	my $my_AFID = $arg{my_AFID};
-	my $my_DH_pub_key_str = $arg{DH_pub_key_str};
-	my $my_mesg = $arg{mesg};
-	my $MIMed_mesg = encode_base64($my_mesg);
-
-	debug_print("send_HandShake: size=[" . length($my_mesg));
-	debug_print("send_HandShake: size=[" . length($MIMed_mesg));
-	debug_print("send_HandShake: [$dest_uri $proto_ver $timestamp $my_domain $my_nickname $my_AFID $my_DH_pub_key_str $my_mesg]");
-
-	#################################
-	#Arg check
-	#################################
-	if ($dest_uri !~ /^http/) {
-	    throw Affelio::exception::InvalidInputException("dest_url");
-	}
- 
-	#################################
-	#Execute XMLRPC
-	#################################
-	my $result = eval {
-	    XMLRPC::Lite
-		->proxy($dest_uri)
-		->call(
-		       'affelio.HandShake', 
-		       $proto_ver,
-		       $timestamp,
-		       $my_nickname,
-		       $my_AFID,
-		       $my_DH_pub_key_str,
-		       $MIMed_mesg)
-		->result;
-	  };
-	debug_print("send_HandShake: RPC returned.\n");
-	if ($@) {
-	    throw Affelio::exception::NetworkException($@);
-	}
-	if($result->{flerror} ne "0"){
-	    throw Affelio::exception::NetworkException($result->{message});
-	}
-
-	debug_print("send_HandShake: OK : $result->{message}\n");
-	debug_print("send_HandShake: OK : $result->{flerror}\n");
-	return $result;
-    }
-
-    #################################################################
-    # reply_HandShake(dest_url =>  $dest_uri, 
-    #                 timestamp => $timestamp,
-    #                 my_nickname => my_nickname,
-    #                 my_AFID => my_AFID,
-    #                 DH_pub_key_str => DH_pub_key_str,
-    #                 my_mesg => mesg);
-    # proto_ver: 1.1
-    #################################################################
-    sub reply_HandShake {
-	my %arg = @_;
-	#
-	my $proto_ver = 1.1;
-	my $dest_uri = $arg{dest_uri};
-	my $timestamp = $arg{timestamp};
-	#
-	my $my_nickname = $arg{my_nickname};
-	my $my_AFID = $arg{my_AFID};
-	my $my_DH_pub_key_str = $arg{DH_pub_key_str};
-	my $my_mesg = $arg{mesg};
-
-	debug_print("reply_HandShake: [$dest_uri $proto_ver $timestamp $my_domain $my_nickname $my_AFID $my_DH_pub_key_str $my_mesg]");
-	
-	#################################
-	#Arg check
-	#################################
-	if ($dest_uri !~ /^http/) {
-	    throw Affelio::exception::InvalidInputException("dest_url");
-	}
-	
-	#################################
-	#Execute XMLRPC
-	#################################
-	my $result = eval {
-	    XMLRPC::Lite
-		->proxy($dest_uri)
-		->call(
-		       'affelio.HandShakeReply', 
-		       $proto_ver,
-		       $timestamp,
-		       $my_nickname,
-		       $my_AFID,
-		       $my_DH_pub_key_str,
-		       $my_mesg
-		       )
-		->result;
-	  };
-	debug_print("reply_HandShake: RPC returned.\n");
-	if ($@) {
-	    throw Affelio::exception::NetworkException($@);
-	}
-	if($result->{flerror} ne "0"){
-	    throw Affelio::exception::NetworkException($result->{message});
-	}
-
-	debug_print("reply_HandShake: $result->{message}\n");
-	debug_print("reply_HandShake: $result->{flerror}\n");
-	return $result;
-    }
-}
-1;
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_s.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_s.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_s.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_s.pm:1.1.1.1	Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_s.pm	Tue Oct 25 04:20:55 2005
@@ -1,451 +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.
-#
-# $Id: Handshaker_s.pm,v 1.1.1.1 2005/10/24 19:14:40 slash5234 Exp $
-
-use strict;
-use lib("../../../extlib/");
-use XMLRPC::Transport::HTTP;
-use DBI;
-use Crypt::RC5;
-use Crypt::DH;
-use MIME::Base64::Perl;
-use Error qw(:try);
-use lib("../../");
-use Affelio;
-use Affelio::SNS::FriendManager;
-use Affelio::SNS::Handshaker_tmpDB;
-use Affelio::SNS::Handshaker_c qw(get_F2List);
-use Affelio::Managing::MessageManager;
-use Affelio::misc::CGIError;
-use Affelio::misc::Debug;
-use Affelio::misc::MyCrypt;
-use Affelio::misc::NetMisc;
-use Affelio::misc::Time;
-use Affelio::misc::Sanitizer;
-
-########################################################################
-package Affelio::SNS::Handshaker_s::Util;
-{
-    sub af_new {
-	my $cfg_dir = $Affelio::SNS::Handshaker_s::AF_DIR . "config/";
-	Affelio::misc::Debug::debug_print("Starting AF($cfg_dir)...");
-	my $af = Affelio->new( ConfigDir => $cfg_dir )
-	    or die "Cannot start Affelio";
-	return($af);
-    }
-}
-
-########################################################################
-package Affelio::SNS::Handshaker_s;
-{
-    use strict;
-    use Exporter;
-    @Affelio::SNS::Handshaker_s::ISA = "Exporter";
-    @Affelio::SNS::Handshaker_s::EXPORT = qw (HandShake HandShakeReply F2List post_Message get_services);
-
-    use vars qw( $AF_DIR);
-
-    ##################################################################
-    #server.get_services
-    # proto_ver: 1
-    ##################################################################
-    sub get_services{
-	my $self = shift;
-	my ($proto_ver) = @_;
-
-	if($proto_ver > 1.0){
-	    return {
-		flerror => XMLRPC::Data->type('boolean', 1),
-		message => "ERR:102 UnsupportedProtoVer 1.0"
-		};
-	}
-
-	my $msg= <<EOT;
-<?xml version="1.0"?>
-<services type="core">
-<service name="AffelioHandshaker">
-<version>1.1</version>
-</service>
-<service name="AffelioMessaging">
-<version>1.0</version>
-</service>
-<service name="AffelioFriendList">
-<version>1.0</version>
-</service>
-</services>
-EOT
-          return {
-	    flerror => XMLRPC::Data->type('boolean', 0),
-	    message => $msg
-	    };
-    }
-
-    ##################################################################
-    #server.F2List
-    # proto_ver: 1
-    ##################################################################
-    sub F2List {
-	my $self = shift;
-	my ($proto_ver, $req_timestamp) = @_;
-
-	my $af = Affelio::SNS::Handshaker_s::Util::af_new();
-
-	$req_timestamp 
-	    = Affelio::misc::Sanitizer::sanitize_number($req_timestamp);
-
-	Affelio::misc::Debug::debug_print("server.F2List: proto_ver=$proto_ver, timestamp=$req_timestamp");
-
-	##################################
-	#Retrieve friends whose
-	#     timestamp > req_timestamp
-	#Retrieve erased friends whose
-	#     timestamp > req_timestamp
-	my $retmsg = $af->{fm}->get_updated_friends($req_timestamp);
-
-	Affelio::misc::Debug::debug_print("server.F2List: ret=[$retmsg]");
-	Affelio::misc::Debug::debug_print("server.F2List: end.");
-
-	return {
-	    flerror => XMLRPC::Data->type('boolean', 0),
-	    message => $retmsg
-	    };
-    }
-
-    ##################################################################
-    #server.post_Message
-    # proto_ver:1
-    ##################################################################
-    sub post_Message {
-	my $self = shift;
-	my $af = Affelio::SNS::Handshaker_s::Util::af_new();
-
-	Affelio::misc::Debug::debug_print("server.postMesg: starg.");
-
-        ##################################################
-	#Distill args
-        ##################################################
-	my ($proto_ver, 
-	    $timestamp, 
-	    $peer_afid, 
-	    $MIMed_mesg) = @_;
-
-	my $passAB = $af->{fm}->get_attribute_by_afid($peer_afid, "password");
-	if(!defined($passAB) || $passAB eq ""){
-	    return {
-		flerror => XMLRPC::Data->type('boolean', 1),
-		message => "ERR:100 Youre not my friend."
-	    };
-	}
-
-        ##################################################
-	#Decode MIME
-        ##################################################
-	my $encrypted = MIME::Base64::Perl::decode_base64($MIMed_mesg);
-
-        ##################################################
-	#Decrypt
-        ##################################################
-	my $rc5 = Crypt::RC5->new($passAB, 12 );
-	my $plain = $rc5->decrypt($encrypted);
-
-        ##################################################
-	#Parse XML
-        ##################################################
-	my $src;
-	if($plain =~ /<src>(.+)<\/src>/){
-	    $src = $1;
-	}
-	Affelio::misc::Debug::debug_print("server.postMesg: src: $src"); 
-
-	my $msg_from;
-	if($plain =~ /<from>(.+)<\/from>/){
-	    $msg_from = $1;
-	}
-	Affelio::misc::Debug::debug_print("server.postMesg: from: $msg_from"); 
-
-	my $msg_from_nickname;
-	if($plain =~ /<from_nickname>(.+)<\/from_nickname>/){
-	    $msg_from_nickname = $1;
-	}
-	Affelio::misc::Debug::debug_print("server.postMesg: nick: $msg_from_nickname"); 
-
-	my $msg_to;
-	if($plain =~ /<to>(.+)<\/to>/){
-	    $msg_to = $1;
-	}
-	Affelio::misc::Debug::debug_print("server.postMesg: to: $msg_to");
-
-	my $msg_timestamp;
-	if($plain =~ /<timestamp>(.+)<\/timestamp>/){
-	    $msg_timestamp = $1;
-	}
-	Affelio::misc::Debug::debug_print("server.postMesg: TIME: $msg_timestamp");
-
-	my $msg_MIMed_title;
-	if($plain =~ /<title>(.*)<\/title>/ms){
-	    $msg_MIMed_title = $1;
-	}
-	Affelio::misc::Debug::debug_print("server.postMesg: title: $msg_MIMed_title");
-
-	my $msg_MIMed_body;
-	if($plain =~ /<text>(.*)<\/text>/ms){
-	    $msg_MIMed_body = $1;
-	}
-	Affelio::misc::Debug::debug_print("server.postMesg: body: $msg_MIMed_body");
-
-        ##################################################
-	#Encryption integrity check
-        ##################################################
-	if($src ne $peer_afid){
-	    return {
-		flerror => XMLRPC::Data->type('boolean', 1),
-		message => "ERR:101 Invalid Encryption."
-		};
-	}
-
-        ##################################################
-	#MIM decode for title and body
-        ##################################################
-	my $msg_title = MIME::Base64::Perl::decode_base64($msg_MIMed_title);
-	my $msg_body  = MIME::Base64::Perl::decode_base64($msg_MIMed_body);
-
-        ###########################################
-        # Post this message to Message Manager
-        ###########################################
-	Affelio::misc::Debug::debug_print("server.PostMesg: $proto_ver, $msg_from $msg_from_nickname $msg_to $msg_timestamp $msg_title $msg_body");
-
-	$msg_from = '<A HREF="' .  $msg_from . '">' . $msg_from_nickname . '</A>';
-
-	$af->{mesgm}->post_message($msg_from,
-				   $msg_title,
-				   "UserToUser/OneToOne",
-				   $msg_body);
-	undef($af);
-	
-        ###########################################
-        # Reply to client
-        ###########################################
-	my $msg = "OK: Thanks for your message.";
-	return {
-	    flerror => XMLRPC::Data->type('boolean', 0),
-	    message => $msg
-	    };
-    }
-
-
-    ##################################################################
-    #server.HandShake
-    # proto_ver:1.1
-    # Accept HandShake from a client
-    ##################################################################
-    sub HandShake {
-	my $self = shift;
-
-        ##################################################
-	#Distill args
-        ##################################################
-	my ($proto_ver, $timestamp, $peer_nickname, 
-	    $peer_af_id, $peer_DH_pub_key_str, $MIMed_mesg) = @_;
-	my $peer_domain = Affelio::misc::NetMisc::get_remote_domain(%ENV);
-	my $sessionid = "$$" . "$timestamp";
-	Affelio::misc::Debug::debug_print("server.HandShake: size=["
-					  . length($MIMed_mesg));
-
-	Affelio::misc::Debug::debug_print("server.HandShake: $proto_ver, $timestamp, $peer_domain, $peer_nickname, $peer_af_id, $peer_DH_pub_key_str [$MIMed_mesg]\n");
-	##################################################
-	#Version check
-	##################################################
-	if($proto_ver > 1.1){
-	    return {
-		flerror => XMLRPC::Data->type('boolean', 1),
-		message => "ERR:102 UnsupportedProtoVer 1.1"
-		};
-	}
-
-        ###########################################
-        # Instantiate Affelio
-        ###########################################
-	my $af = Affelio::SNS::Handshaker_s::Util::af_new();
-
-        ###########################################
-        # Send a message to MessageManager
-        ###########################################
-	my $message_body= 
-	    MIME::Base64::Perl::encode_base64("You got a link request from $peer_nickname ( $peer_af_id ). \n\nMessage from the user is...\n")
-	    . "$MIMed_mesg\n"
-	    . MIME::Base64::Perl::encode_base64("\n\nClick following link to approve this request.\n\n$af->{site__web_root}/bin/recv_mail_ack.cgi?id=$sessionid");
-
-	$af->{mesgm}->post_message("Your Affelio",
-				   "Link Request from $peer_nickname",
-				   "SystemToUser/LinkRequest/Encode-Base64",
-				   $message_body);
-
-        ###########################################
-        # Save peer's info into "received_Handshake" DB
-        ###########################################
-	my $tmpdb= new Affelio::SNS::Handshaker_tmpDB($af);
-	$tmpdb->add_received_Handshake($sessionid,
-				       $peer_af_id,
-				       $peer_nickname,
-				       $timestamp,
-				       $peer_DH_pub_key_str);
-
-	Affelio::misc::Debug::debug_print("server.HandShake: DB(W) $sessionid\n");
-
-	undef($af);
-        ###########################################
-        # Reply to client
-        ###########################################
-	my $msg = "OK: Thanks for your HandShake.";
-	return {
-	    flerror => XMLRPC::Data->type('boolean', 0),
-	    message => $msg
-	    };
-	
-    }#method
-
-
-    ##################################################################
-    #server.HandShakeReply
-    # proto_ver:1.1
-    # Accept HandshakeReply from a client
-    ##################################################################
-    sub HandShakeReply {
-	my $self = shift;
-	
-        ###########################################
-	#Distill args
-        ###########################################
-	my ($proto_ver, $timestamp, $peer_nickname, 
-	    $peer_af_id, $peer_DH_pub_key_str, $mesg) = @_;
-	Affelio::misc::Debug::debug_print("server.HandShakeReply: $proto_ver, $timestamp, $peer_nickname, $peer_af_id, $peer_DH_pub_key_str $mesg\n");
-	
-	##################################################
-	#Version check
-	##################################################
-	if($proto_ver > 1.1){
-	    return {
-		flerror => XMLRPC::Data->type('boolean', 1),
-		message => "ERR:102 UnsupportedProtoVer 1.1"
-		};
-	}
-
-        ###########################################
-        # Instantiate Affelio
-        ###########################################
-	my $af = Affelio::SNS::Handshaker_s::Util::af_new();
-
-        ###########################################
-        # check peer's info in "received_Handshake" DB
-        ###########################################
-	Affelio::misc::Debug::debug_print("server.HandShakeReply: searching... $peer_af_id => $timestamp\n");
-
-	my $tmpdb= new Affelio::SNS::Handshaker_tmpDB($af);
-	my @ret= $tmpdb->remove_sent_Handshake($timestamp);
-
-	my $my_DH_pri_key_str;
-	my $dummy1;
-	my $dummy2;
-	my $dummy3;
-	my $dummy4;
-
-	if(!defined(@ret)){
-	    #No such session exists!!
-	    Affelio::misc::Debug::debug_print("server.HandShakeReply: sent-Handshake session NOT Found!\n");
-	      return {
-		  flerror => XMLRPC::Data->type('boolean', 1),
-		  message => "ERR:103 HandShakeReply denied."
-		  };
-	}else{
-	    ($dummy1, $dummy2, $dummy3, $dummy4, $my_DH_pri_key_str) = @ret;
-	    Affelio::misc::Debug::debug_print("server.HandShakeReply: my DH_pri_key = $my_DH_pri_key_str");
-	    Affelio::misc::Debug::debug_print("server.HandShakeReply: sent-Handshake session Found. OK. Let's Move on.");
-	}
-	
-        ###########################################
-        #generate password
-        ###########################################
-	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);
-
-	$mydh->priv_key(Math::BigInt->new($my_DH_pri_key_str) );
-	my $pass 
-	    = $mydh->compute_key(Math::BigInt->new($peer_DH_pub_key_str))->bstr;
-	Affelio::misc::Debug::debug_print("server.HandShakeReply: PASSWORD=[$pass]\n");
-
-        ###########################################
-        #Add peer to my friends list.
-        ###########################################
-	my $uid = $af->{fm}->add_friend($peer_af_id, 
-					$peer_nickname,
-					$timestamp,
-					$pass);
-	Affelio::misc::Debug::debug_print("server.HandShakeReply: add_friend finished.\n");
-
-	eval{
-	    $af->{db}->commit;
-	    $af->{db}->disconnect;
-	    undef($af);
-	};
-	if($@){
-	    Affelio::misc::Debug::debug_print($@);
-	}
-
-        ###########################################
-        #Get peer's friends list.
-        ###########################################
-	# "peer's friends" = my F2 friends
-	Affelio::misc::Debug::debug_print("server.HandshakeReply: Let's download peer's flist!");
-	my $ret = Affelio::SNS::Handshaker_c::get_F2List(dest_uri =>  "$peer_af_id/bin/xml-rpc-serv.cgi", timestamp => 0);
-	Affelio::misc::Debug::debug_print("server.HandshakeReply: get_F2List finished.");
-	Affelio::misc::Debug::debug_print("server.HandshakeReply: List I've got is [$ret]");
-	
-        ###########################################
-        #Save the F2 list into my DB
-        ###########################################
-	$af = Affelio::SNS::Handshaker_s::Util::af_new();
-	Affelio::misc::Debug::debug_print("server.HandshakeReply: Let's save peer's flist!");
-        $af->{fm}->save_F2List($ret, $peer_af_id);
-	Affelio::misc::Debug::debug_print("server.HandshakeReply: save_F2List finished.");
-	#Make a new instance of Affelio
-
-        ###########################################
-        #Reply to client
-        ###########################################
-	return {
-	    flerror => XMLRPC::Data->type('boolean', 0),
-	    message => "OK: Thanks for your HandShakeReply." 
-	    };
-    }
-
-}
-
-
-########################################################################
-{    
-    package affelio;
-    BEGIN { @affelio::ISA = qw( Affelio::SNS::Handshaker_s ); }
-}
-
-
-########################################################################
-1;
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_tmpDB.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_tmpDB.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_tmpDB.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_tmpDB.pm:1.1.1.1	Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/SNS/Handshaker_tmpDB.pm	Tue Oct 25 04:20:55 2005
@@ -1,139 +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.
-#
-# $Id: Handshaker_tmpDB.pm,v 1.1.1.1 2005/10/24 19:14:40 slash5234 Exp $
-
-use strict;
-use lib("../../../extlib/");
-use DBI;
-use lib("../../");
-use Affelio;
-use Affelio::misc::Debug;
-use Affelio::misc::CGIError;
-
-########################################################################
-package Affelio::SNS::Handshaker_tmpDB;
-{
-    ####################################################################
-    #Constructor
-    ####################################################################
-    sub new{
-	my $class = shift;
-	my $af = shift;
-
-	Affelio::misc::Debug::debug_print("Handshaker_tmpDB::new: start.");
-
-	my $self = {af => $af
-		    };
-
-	bless $self, $class;
-
-	Affelio::misc::Debug::debug_print("Handshaker_tmpDB::new: end.");
-	return $self;
-    }
-
-    ####################################################################
-    #add_received_Handshake
-    ####################################################################
-    sub add_received_Handshake{
-	Affelio::misc::Debug::debug_print("add_received_Handshake: start.");
-	return adddb(@_, "AFuser_SNS_tmp_recvd_hs");
-    }
-
-    ####################################################################
-    #remove_received_Handshake
-    ####################################################################
-    sub remove_received_Handshake{
-	Affelio::misc::Debug::debug_print("remove_received_Handshake: start.");
-	return removedb(@_, "AFuser_SNS_tmp_recvd_hs");
-    }
-
-    ####################################################################
-    #add_sent_Handshake
-    ####################################################################
-    sub add_sent_Handshake{
-	Affelio::misc::Debug::debug_print("add_sent_Handshake: start.");
-	return adddb(@_, "AFuser_SNS_tmp_sent_hs");
-    }
-
-    ####################################################################
-    #remove_sent_Handshake
-    ####################################################################
-    sub remove_sent_Handshake{
-	Affelio::misc::Debug::debug_print("remove_sent_Handshake: start.");
-	return removedb(@_, "AFuser_SNS_tmp_sent_hs");
-    }
-
-    ####################################################################
-    #adddb
-    ####################################################################
-    sub adddb{
-	my $self = shift;
-	my $sessionid = shift;       #arg(1) session no. (string)
-	my $af_id = shift;           #arg(2) af_id     (string)
-	my $nickname = shift;        #arg(3) nickname  (string)
-	my $timestamp = shift;       #arg(4) timestamp (string) 
-	my $DH_key_str = shift;      #arg(5) DH key (string)
-	my $dbname = shift;          #arg(6) DBname (string)
-
-	Affelio::misc::Debug::debug_print("add: $af_id $nickname $timestamp $DH_key_str $dbname");
-	
-	my $af = $self->{af};
-
-	my $str = "insert into $dbname (sessionid, timestamp, af_id, nickname, DH_key_str) values ('$sessionid', '$timestamp', '$af_id', '$nickname', '$DH_key_str')";
-	my $sth = $af->{db}->prepare($str);
-	$sth->execute() or die $af->{db}->errstr;
-
-	Affelio::misc::Debug::debug_print("add: end.");
-	return;
-    }
-
-    ####################################################################
-    #removedb
-    ####################################################################
-    sub removedb{
-	my $self = shift;
-	my $sessionid = shift;       #arg(1) session no. (string)
-	my $dbname = shift;
-
-	my $af = $self->{af};
-
-	Affelio::misc::Debug::debug_print("removedb: $sessionid");
-
-	my $str = "SELECT sessionid, timestamp, af_id, nickname, DH_key_str FROM $dbname WHERE sessionid= '$sessionid'";
-	my $sth = $af->{db}->prepare($str) or die $af->{db}->errstr;
-	$sth->execute() or die $af->{db}->errstr;
-        my @row = $sth->fetchrow_array;
-
-        if(!defined(@row)){
-            Affelio::misc::Debug::debug_print("removedb: No such session.");
-            return;
-        }
-
-	my $str = "DELETE FROM $dbname WHERE sessionid=?";
-	my $sth = $af->{db}->prepare($str) or die $af->{db}->errstr;
-	$sth->execute($sessionid);
-
-	Affelio::misc::Debug::debug_print("removedb: end.");
-	return @row;
-    }
-
-
-}
-
-
-########################################################################
-1;


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