#!/usr/local/bin/perl ###################################################### #BooLinkMaker,v1.38 / this program is value software.# #(C) BooBooClub 1997-2011 # ###################################################### #set data $page='./links.html'; $reload='http://url_to_link.html'; $back = 'bgcolor="#ffffff"'; $pinfo = 'on'; #read lib require './jcode.pl'; #lock &lock; #read if ($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else{ $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\,//g; $value =~ s//>/ig; $value =~ s/\r\n|[\r\n]//ig; &jcode'convert(*value,'sjis'); $FORM{$name} = $value; } $FORM{'url'} =~ s/^http:\/\///i; #branch if ($pinfo eq 'on' && $FORM{'name'} && $FORM{'mail'} && $FORM{'url'} && $FORM{'title'} && $FORM{'memo'}){ &submit; } elsif ($pinfo ne 'on' && $FORM{'url'} && $FORM{'title'} && $FORM{'memo'}){ &submit; } else { &txterror; } sub submit{ open (IHTML,"$page"); @lines = ; close (IHTML); $check = '
  • '; foreach $line (@lines) { if($line =~ /$check/){ &wsubmit; } } open (OHTML,">$page"); foreach $line (@lines) { if($line =~ //){ print OHTML "\n"; if($pinfo eq 'on'){ print OHTML '
  • '."$FORM{'title'}".' ['."$FORM{'name'}".']'; } else{ print OHTML '
  • '."$FORM{'title'}".''; } print OHTML '
    '."$FORM{'memo'}".'

    '."\n"; } else { print OHTML "$line"; } } close (OHTML); } sub wsubmit{ print "Content-type:text/html\n\n"; print ''."\n"; print ''."\n"; print "Submit Error\n"; print "

    登録しようとしたURLは既に登録済みです。



    \n"; print "ブラウザのバックボタンで戻って下さい
    \n"; print "\n"; unlink("$lockfile"); exit 0; } sub txterror{ print "Content-type:text/html\n\n"; print ''."\n"; print ''."\n"; print "Submit Error\n"; print "

    入力されていない項目があります



    \n"; print "ブラウザのバックボタンで戻って下さい
    \n"; print "\n"; unlink("$lockfile"); exit 0; } unlink("$lockfile"); print "Location: $reload\n\n"; exit 0; sub lock{ $lockfile='./lock/lockfile'; $retry = 1; until (symlink("$page", "$lockfile")) { if (++$retry >= 30) { unlink("$lockfile"); exit 0; } sleep(1); } }