#!/usr/bin/perl #------------------------------- # padname.cgi (ShiftJIS) # 2001.11. 6 MIYAMORI Yoshimasa # 1999. 2.13 MIYAMORI Yoshimasa # (kan_ta@amcsys.com) #------------------------------- require 'padres.pl'; require $myReqPadlib; require $myReqJcode; $myTitle = 'padname: ' . $padresMyTitle; $myUrl = $padresMyUrl . 'padname.cgi'; &main; exit; sub main { if ($ENV{'REQUEST_METHOD'} eq 'HEAD') { &dispMsg('Request method: HEAD.'); return; } if (&chkBusy) { &dispMsg($myMsgBusy); return; } &setBusy(1); if (&chkEnv) { &dispMsg($myMsgDeny); &setBusy(0); return; } &parseQry(*in); $in{'hp'} = '' if ($in{'hp'} eq 'http://'); if (!$in{'name'}) { &dispMsg($myMsgName); &setBusy(0); return; } &delName($in{'name'}); &putName($in{'name'}, $in{'ml'}, $in{'hp'}) if (!$in{'mode'}); &dispName; &setBusy(0); return; } # $PAD_TOP の位置に 名前, メール, ホームページを書く. # 文字列に $PAD_SEP が含まれているときは ',' に置き換える. sub putName { local($name, $ml, $hp) = @_; local($all, $s); $name =~ s/$PAD_SEP/,/go; $ml =~ s/$PAD_SEP/,/go; $hp =~ s/$PAD_SEP/,/go; $all = join($PAD_SEP, $name, $ml, $hp); open(TMP, "|$myOut >$tmpFile") || &exitPadCgi('error: putName().'); open(FILE, "$myIn <$nameFile |") || &exitPadCgi('error: putName().'); while () { if (/^$PAD_TOP/io) { print TMP $PAD_TOP, "\n"; print TMP $all, '
', "\n"; last; } else { print TMP $_; } } while () { print TMP $_; } close TMP; close FILE; $s = "mv $tmpFile $nameFile"; system($s); chmod $myChmod, $nameFile; } # はじめのフィールドが $key の行をすべて削除する. sub delName { local($key) = @_; local($eucKey, $line); local($a, $b, $c, $s); open(TMP, "|$myOut >$tmpFile") || &exitPadCgi('error: delName().'); open(FILE, "$EUC <$nameFile |") || &exitPadCgi('error: delName().'); while () { print TMP $_; last if (/^$PAD_TOP/io); } $eucKey = &toEuc($key); while () { $line = $_; ($a, $b, $c) = split(/$PAD_SEP/, $line, 3); print TMP $line if ($eucKey ne $a); } close TMP; close FILE; $s = "mv $tmpFile $nameFile"; system($s); chmod $myChmod, $nameFile; }