#############################################################
#  LeoBoard ver.5000 / LB5000 / 雷傲超级论坛 ver.5000
#
#  版权所有: 雷傲工作室(原蓝宝石软件工作室)
#
#  制作人  : 山鹰糊 (Shining Hu)
#            花无缺 (Ifairy Han)
#           
#  主页地址: http://www.CGIer.com/      CGI 编程者之家
#	     http://www.LeoBoard.com/   雷傲论坛支持主页
#	     http://www.leoBBS.com/     本论坛直通车
#            
#############################################################

sub getlastvisit {
    my $lv = $query->cookie("templastvisit");
    if (! $lv) {
        $lv = $query->cookie("lastvisit");
        if (! $lv) { $lv = "$inforum-$currenttime--"; }
        $tempvisitcookie = cookie(-name => "templastvisit", -path => "$cookiepath/", -expires => "+30d", -value => "$lv");
    }
    my @pairs = split(/\--/,$lv);
    foreach (@pairs) {
        my ($n, $val) = split(/\-/,$_);
        $lastvisitinfo{$n} = "$val";
    }
}

sub setlastvisit {
    local($tinfo) = @_;
    my ($tid, $tv, $mv)   = split(/\,/,$tinfo);
    my @newv = "";
    my $u = "0";
    my @pairs = split(/\--/, $query->cookie("lastvisit"));
    foreach (@pairs) {
        ($n, $val) = split(/\-/,$_);
        if ("$tid" eq "$n") { $u = "1"; $val = $tv; }
        push(@newv, "$n-$val--");
    }

    if ($u eq "0" && $tinfo ne "") { push(@newv,"$tid-$tv--"); }
    my $nfo = join("",@newv);
    $permvisitcookie = cookie(-name => "lastvisit", -value => "$nfo", -path => "$cookiepath/", -expires => "+30d");
    if ($mv eq "1") { $tempvisitcookie = cookie(-name => "templastvisit", -value => "$nfo", -expires => "+30d", -path => "$cookiepath/"); }
}

###########################
# Forum Jump
sub forumjump {
    $jumphtml .= qq~<SCRIPT LANGUAGE="JavaScript">
function surfto1(list){
var myindex1  = document.jump.selectedIndex;
if (myindex1 != 0){
var URL = document.jump.jumpto.options[document.jump.jumpto.selectedIndex].value;
top.location.href = URL; target = '_self';
}}
</SCRIPT>
<form action="forums.cgi" method="post" name="jump">
<select name="jumpto" onchange="surfto1(this)">
<option value="leoboard.cgi">跳转论坛至...</option>
~;

    if ($#forums < 1) {
	open(FILE, "${lbdir}data/allforums.cgi");
	@forums = <FILE>;
	close(FILE);
    }

    $a=0;
    foreach my $forum (@forums) { #start foreach @forums
	$a  = sprintf("%09d",$a);
	chomp $forum;
	next if ($forum eq "");
	(my $forumid, my $category, my $categoryplace, my $forumname, my $forumdescription, my $tmp , $tmp , $tmp , $tmp,  $tmp , $tmp , $tmp,  $tmp,  $tmp,  $tmp, $tmp, $tmp, $tmp,my $hiddenforum,$tmp,$tmp,$tmp, $fgwidth, $fgheight, $miscadd3, $miscadd4, $miscad5) = split(/\t/,$forum);
	next if ($forumid !~ /^[0-9]+$/);
	next if ($categoryplace !~ /^[0-9]+$/);
	$categoryplace  = sprintf("%09d",$categoryplace);
	$rearrange = ("$categoryplace\t$a\t$category\t$forumname\t$forumdescription\t$forumid\t$forumgraphic\t$ratings\t$misc\t$forumpass\t$hiddenforum\t$indexforum\t$teamlogo\t$teamurl\t$fgwidth\t$fgheight\t$miscadd3\t$miscadd4\t$miscad5\t");
	push (@rearrangedforums, $rearrange);
	$a++;
    }

    @finalsortedforums = sort (@rearrangedforums);

foreach my $sortedforums (@finalsortedforums) {
    (my $categoryplace, my $a, my $category, my $forumname, my $forumdescription, my $forumid, my $forumgraphic, my $ratings, my $misc, my $forumpass, my $hiddenforum, my $indexforum,my $teamlogo,my $teamurl,my $fgwidth,my $fgheight,my $miscadd3,my $miscadd4,my $miscad5) = split(/\t/,$sortedforums);
    $categoryplace  = sprintf("%01d",$categoryplace);
    if ($categoryplace ne $lastcategoryplace) {
        $jumphtml .= "<option value=\"forums.cgi?forum=$forumid\" style=background-color:$titlecolor>╋$category\n</option>";
    }
    if ($hiddenforum eq "yes"){ $hidden="(隐含)" ; }else{ $hidden=""; } 
    $jumphtml .= "<option value=\"forums.cgi?forum=$forumid\">　├$forumname$hidden\n</option>" if (($disphideboard eq "yes")||($hidden eq "")||($membercode eq "ad")||($membercode eq "smo")||($membercode eq "mo"));
    $lastcategoryplace = $categoryplace;
}
$jumphtml .= qq~</select>\n~;
}

1;