#!/usr/bin/perl #****************************************************************************** #ranklink.cgi - Ranking Link Ver.1.86 # #Version :1.86 #modified :2002/01/31 #Copyright :The Room #E-Mail :dream@lib.net #URL :http://dream.lib.net/ # #これはフリー素材です。 #転載・商用目的の利用の際には、メールをお願いします。 # #****************************************************************************** #1行目のperlのディレクトリ指定は、サーバによって異なります。 #詳しくは、管理者にお聞きください。 #****************************************************************************** require './rl_prf.cgi'; require $jcode; #データ受け取り $cl = $ENV{"CONTENT_LENGTH"}; if( $cl > 0 ){ read(STDIN, $qs, $cl ); }else{ $qs = $ENV{"QUERY_STRING"}; } @contents = split(/&/,$qs); foreach $i (0 .. $#contents) { local($key,$text)= split(/=/,$contents[$i]); $text =~ s/\+/ /g; $text =~ s/%(..)/pack("c",hex($1))/ge; &jcode::convert(\$text,'sjis'); $id = $text if $key eq 'id'; $action = $text if $key eq 'action'; $action2 = $text if $key eq 'action2'; $url = $text if $key eq 'url'; $ssd = $text if $key eq 'ssd'; } if ($action eq "htmlindi"){&htmlindi($url);} if ($id ne ""){ if (!-e "$datadir/$id.dat"){ &error("ID:$idは登録されていません。"); } if (&filelock(1)){ open (IN,"+<$rankfile"); eval{flock(IN,2)}; $a1=;$a1=;@rankset=split(/<>/,scalar()); close(IN); &rankin; } } if ($pagetype > 1){ if ($metajump == 0){ print "Location: $jumppage\n\n"; }else{ &metaindi($jumppage); } } elsif ($htmlindi == 0){ if ($metajump == 0){ print "Location: $abshtmldir/index.$outputfile\n\n"; }else{ &metaindi("$abshtmldir/index.$outputfile\n\n"); } }else{ &htmlindi("index"); } exit; #***************************************************************************** sub rankin{ #INカウント追加 my ($voteflag,$a1,$a2,$i,@temp1,@temp2); my $buf="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; if ($pagetype % 2 == 1){ $a1 = 1; open(IO,"+<$sessiondir/$id.dat"); eval{flock(IO,2)}; while(){ @temp2 = (split(/<>/,$_))[0,1]; if ($temp2[0] eq $ssd){$a1 = 0;} elsif ($temp2[1] > time()){push(@temp1,$_);} } if ($a1){ $ssd = ""; for($i=0;$i<=7;$i++){$ssd.=substr($buf,int(rand(62)),1);} push(@temp1,$ssd."<>".(time()+$session_enable)."<>\n"); } truncate(IO,0); seek(IO,0,0); print IO @temp1; close(IO); if (($vote_refcheck) && ($referer !~ /$scriptdir/i)){$a1 = 1;} if ($a1){ &fileunlock; &changehtml("voteform","id","ssd"); } } if ($vote_terminal == 0){$voteflag = 1;} else{ $a1 = $ENV{'HTTP_USER_AGENT'}; if (($a1 =~ /^DoCoMo\//) ||($a1 =~ /^J-PHONE\//) ||($a1 =~ /^UP\.Browser/) ||($a1 =~ /^ASTEL\//) ||($a1 =~ /^PDXGW\//)){ if ($vote_terminal == 1){$voteflag = 0;}else{$voteflag = 1;} } elsif ($vote_terminal == 1){$voteflag = 1;}else{$voteflag = 0;} } $a1 = ""; if (($voteflag) && ($cookiecheck)){ &getcookie; $a1="<>".$cookie{'IN'}; if ($a1 =~ /<>$id<>/){ $voteflag = 0; }else{ $cookie{'IN'}.= $id."<>"; &setcookie; } } if (($voteflag) && ($ipcheck)){ open(IO,"+<$ipdir/$id.dat"); eval{flock(IO,2)}; while(){ if ($_ =~ /in<>$ip<>\n/){ $voteflag = 0; last; }else{ push(@temp1,$_); } } if ($voteflag){ truncate(IO,0); seek(IO,0,0); print IO "in<>$ip<>\n"; print IO @temp1; } close(IO); } if ($voteflag){ open (IO,"+<$datadir/$id.dat"); eval{flock(IO,2)}; @temp1 = split(/<>/,); @temp1 = split(/<>/,&backupload($id)) if $temp1[0] eq ""; if ($temp1[0] ne "datamissing"){ $temp1[0] = time(); $temp1[10]++; $temp1[12]++; $temp1[14]++; truncate(IO,0); seek(IO,0,0); foreach(@temp1){print IO $_."<>";} close(IO); }else{ close(IO); &syslog("AUTO","データ消失(ID:$id)"); &dataerase($id); } } if ($rankset[6] < time()){ &syslog("AUTO","自動更新"); require './rl_renew.cgi'; } &fileunlock; } #******************************************************************************