#!/usr/local/bin/perl # ###################################################################### ### ### ### CGIフォームメール送信 T-FormMail Ver.1.03 ### [2/3] 管理用 (tfmadmin.cgi) ### (c) 1996-2002 Takahiro Nishida ### http://www.mytools.net/ ### ### ###################################################################### ### 変数設定部 (詳細は上記ページをご覧下さい) ###################### $password = "TFMail103"; ### 変数設定部 (ここまで)########################################### require './tfmlib.pl'; print "Content-type: text/html\n\n"; &main; sub main{ &tfmlib'lock; &init_variables; &open_datafile; &check_input; &exec_action; &update_files; &show_html; &tfmlib'unlock; } ########## 変数の初期化 sub init_variables{ $basedir = $tfmlib'basedir; $datafile = "$basedir/tfmdata.txt"; $logfile = "$basedir/tfmlog.txt"; $backurl = $tfmlib'backurl; $noact = "何も変更されませんでした。"; $actmsg = "パスワードが違います。$noact"; } ########## データファイルのオープン sub open_datafile{ &tfmlib'openfile($datafile, *datas); } ########## 入力内容のチェック sub check_input{ &tfmlib'parseform; $pwd = $tfmlib'F{'pwd'}; $mode = $tfmlib'F{'mode'}; $act = $tfmlib'F{'act'}; $fcode = $tfmlib'F{'fcode'}; (!$fcode) || ($fcode =~ /^\w+$/) || &tfmlib'error(8, "コード"); } ########## 作業の実行 sub exec_action{ ### パスワードチェック if ($pwd ne $password){ $actmsg = ($pwd) ? "パスワードが間違っています。$noact" : "作業を選択し、パスワードを入力して「作業実行」を押してください。"; $mode = "top"; return; } ### modeごとの処理へ if($mode eq 'data'){ $actmsg = "登録済の情報を表\示しています。"; if($act eq 'new' || $act eq 'fix'){ &fix_data; } } elsif($mode eq 'log'){ $actmsg = "最新 $tfmlib'log_max 件の送信ログを表\示しています。"; } } ########## データの修正 sub fix_data{ ### 入力の受け取り $fsendto = &tfmlib'decode($tfmlib'F{'fsendto'}); $ffsend = $tfmlib'F{'ffsend'}; $ffemail = $tfmlib'F{'ffemail'}; $ffshow = $tfmlib'F{'ffshow'}; $ffhost = $tfmlib'F{'ffhost'}; $fmname = &tfmlib'decode($tfmlib'F{'fmname'}); $fmname = &tfmlib'TagToValue($fmname); $fbackurl = &tfmlib'decode($tfmlib'F{'fbackurl'}); $fsubject = &tfmlib'decode($tfmlib'F{'fsubject'}); $ffinmsg = &tfmlib'decode($tfmlib'F{'ffinmsg'}); $fcolor = &tfmlib'decode($tfmlib'F{'fcolor'}); $fdel = $tfmlib'F{'fdel'}; ### 項目詳細の改行をスペースに変換 $fmname =~ s/\n+/\ /g; ### 入力のチェック ($fcode) || &tfmlib'error(8, "コード"); ($fsendto =~ /^[\w\-\+\.]+\@[\w\-\+\.]+$/) || &tfmlib'error(8, "送り先"); ($ffsend =~ /^[10]$/) || &tfmlib'error(8, "E-Mail必須"); ($ffemail =~ /^[10]$/) || &tfmlib'error(8, "送り先表示"); ($ffshow =~ /^[10]$/) || &tfmlib'error(8, "メール表示"); ($ffhost =~ /^[10]$/) || &tfmlib'error(8, "ホスト記録"); ($fmname =~ /^(\w+###.+###[01]###.*\s*)+$/) || &tfmlib'error(8, "項目詳細 = $fmname"); ($fbackurl =~ /^http:\/\/.+$/) || &tfmlib'error(8, "戻り先"); ### 色が未入力の場合デフォルト ($fcolor) || ($fcolor = "#FFFFFF,#000000,#FF0000,#000099,"); ### 書換対象の行番号 $target = -1; for(0..$#datas){ ($datas[$_] =~ /^$fcode\t/) && ($target = $_); } if($act eq 'new'){ ($target == -1) || &local_error("指定されたコード($fcode)は既に使用されています"); $target = $#datas + 1; $actmsg = "$fcode を新規作成しました。"; } else{ ($target != -1) || &local_error("指定されたコード($fcode)の項目が見つかりません"); $actmsg = "$fcode を修正しました。"; } ### 削除 if($fdel){ splice(@datas, $target, 1); $actmsg = "$fcode を削除しました。"; } ### 修正、新規 else{ $newline = "$fcode\t$fsendto\t$ffsend$ffemail$ffshow$ffhost\t$fmname\t$fbackurl\t$fsubject\t$ffinmsg\t$fcolor\t\n"; $datas[$target] = $newline; } $flag_data = 1; } ########## ファイルの更新 sub update_files{ ($flag_data) && &tfmlib'updatefile($datafile, *datas); } ########## 表示 sub show_html{ if($mode eq 'data'){ $tablebuf = &html_table; $formbuf = &html_form; } elsif($mode eq 'log'){ $tablebuf = &html_log; } else{ $formbuf = &html_top; } $hcopy = &tfmlib'copyright; print " T-FormMail - 管理用ページ [戻る] [管理トップ]

T-FormMail 管理用ページ


作業状況: $actmsg
$formbuf $tablebuf
$hcopy
"; } ########## トップ画面 sub html_top{ "
パスワード
メールフォーム新規作成、修正、削除
送信ログ閲覧
"; } ########## 修正用フォーム sub html_form{ local($htmlbuf, $dact, $dtitle, $dcode); local($code, $sendto, $frags, $mname, $backurl, $subject, $finmsg, $scode, $schk); local($fsend, $femail, $fshow, $fhost); local($csend1, $csend0, $cemail1, $cemail0, $cshow1, $cshow0, $chost1, $chost0); foreach (@datas){ $scode = (split("\t"))[0]; ($schk) = ($scode eq $fcode) ? "SELECTED" : ""; $options .= "