#############################################################
#  LeoBoard ver.5000 / LB5000 / 雷傲超級論壇 ver.5000
#
#  版權所有: 雷傲工作室(原藍寶石軟件工作室)
#
#  製作人  : 山鷹糊 (Shining Hu)
#            花無缺 (Ifairy Han)
#           
#  首頁網址: http://www.CGIer.com/      CGI 編程者之家
#	     http://www.LeoBoard.com/   雷傲論壇支援首頁
#	     http://www.leoBBS.com/     本論壇直通車
#            
#############################################################

sub updateuserinfo {  #利用變化量來更新會員資料
        my($nametocheck,$cposts, $creplys, $crating,$cjinyan,$cmeili,$cmoney,$cpostdel) = @_;
#	會員名稱，發表文章數變化量，回覆數變化量，威望變化量，經驗變化量，魅力變化量，金錢變化量，文章被刪除數變化量

	$cposts  = 0 if ($cposts  eq "");
	$creplys = 0 if ($creplys eq "");
	$crating = 0 if ($crating eq "");
	$cjinyan = 0 if ($cjinyan eq "");
	$cmeili	 = 0 if ($cmeili  eq "");
	$cmoney	 = 0 if ($cmoney  eq "");
	$cpostdel= 0 if ($postdel eq "");

	my $nametochecktemp = $nametocheck;
	$nametocheck =~ s/ /\_/g;
	$nametocheck =~ tr/A-Z/a-z/;
	$userregistered = "";
	my $filetoopen = "$lbdir" . "$memdir/$nametocheck.cgi";
	$filetoopen = &stripMETA($filetoopen);
	if (-e $filetoopen) {
	    &winlock($filetoopen) if (($OS_USED eq "Unix")||($OS_USED eq "Nt"));
	    open(FILE,"$filetoopen");
	    flock (FILE, 1) if ($OS_USED eq "Unix");
            my $filedata = <FILE>;
            close(FILE);
	    chomp($filedata);
	    (my $membername, my $password, my $membertitle, my $membercode, my $numberofposts, my $emailaddress, my $showemail, my $ipaddress, my $homepage, my $oicqnumber, my $icqnumber ,my $location ,my $interests, my $joineddate, my $lastpostdate, my $signature, my $timedifference, my $privateforums, my $useravatar, my $userflag,my  $userxz, my $usersx, my $personalavatar, my $personalwidth, my $personalheight, my $rating, my $lastgone, my $visitno,my  $addjy,my  $meili, my $mymoney, my $postdel, my $sex, my $education, my $marry, my $work, my $born, my $chatlevel,my  $chattime, my $jhmp,my $useradd3,my $useradd4,my $useradd5,my $userquestion, my $useradd6, my $useradd7, my $useradd8) = split(/\t/,$filedata);

	    (my $totleposts, my $totlecreplys) = split(/\|/,$numberofposts);

	    $totleposts   += $cposts;
	    $totlecreplys += $creplys;
	    $totleposts   = 0 if($totleposts   < 0);
	    $totlecreplys = 0 if($totlecreplys < 0);
	    $numberofposts = "$totleposts|$totlecreplys";

	    $rating  += $crating;
	    $addjy   += $cjinyan;
	    $meili   += $cmeili;
	    $mymoney += $cmoney;
	    $postdel += $cpostdel;

	    $postdel = 0 if ($postdel <0 );
	    $rating = -5 if ($rating < -5);
	    $rating = $maxweiwang  if ($rating >  $maxweiwang);

	    if (($membername ne "")&&($password ne "")) {
	      if (open(FILE,">$filetoopen")) {
	        flock (FILE, 2) if ($OS_USED eq "Unix");
	        $lastgone=time;
	        print FILE "$nametochecktemp\t$password\t$membertitle\t$membercode\t$numberofposts\t$emailaddress\t$showemail\t$ipaddress\t$homepage\t$oicqnumber\t$icqnumber\t$location\t$interests\t$joineddate\t$lastpostdate\t$signature\t$timedifference\t$privateforums\t$useravatar\t$userflag\t$userxz\t$usersx\t$personalavatar\t$personalwidth\t$personalheight\t$rating\t$lastgone\t$visitno\t$addjy\t$meili\t$mymoney\t$postdel\t$sex\t$education\t$marry\t$work\t$born\t$chatlevel\t$chattime\t$jhmp\t$useradd3\t$useradd4\t$useradd5\t$userquestion\t$useradd6\t$useradd7\t$useradd8\t\n";
	        close(FILE);
	      }
	    }
	    &winunlock($filetoopen) if (($OS_USED eq "Unix")||($OS_USED eq "Nt"));
	}
}
1;
