#! /usr/bin/perl
##
## 開発時: #!c:/perl/bin/perl.exe
## 転送時: #! /usr/local/bin/perl
## 転送時: #! /usr/bin/perl
##
#############################################################################
require './jcode.pl';
require './mimew.pl';
#############################################################################
## システム変更定義
#############################################################################
#############################################################################
## 固定値定義
#############################################################################
# メール送信の定義
$sendmail = '/usr/sbin/sendmail';
$fromAddress = "demand\@k-systemtrading.com";
@toAddress = (
#############################################
## ここに転送先のアドレスを登録していく
#############################################
## 受け取るアドレス @マークの前には'\'が必要
"contact\@k-systemtrading.com",
);
@ngIPAndID = (
#############################################
## 投稿禁止
#############################################
## 受け取るアドレス @マークの前には'\'が必要
"58.183.177.24" , ##
"Ve.FQAtnRuU" , ##
### "112.138.28.76" ,
);
@okDom = (
#############################################
## 投稿禁止
#############################################
## 受け取るアドレス @マークの前には'\'が必要
"jp" , ##
"net" , ##
"com" , ##
);
@ngLogIP = (
#############################################
## ログ保存
#############################################
"static.theplanet.com" , ##
"reverse.softlayer.com" , ##
"yandex.ru" , ##
"altushost.com" , ##
);
# このファイルの名前
$thiscgi = "index.cgi";
$systemname = "bbscookie";
##$systemname = "bbscookie_test";
# フォルダ定義
$datadir = "./wdata";
$masterfile = "./wdata/master.txt";
$nguserfile = "./wdata/nguser.txt";
$updatefile = "./wdata/update.txt";
$handlefile = "./wdata/handle.txt";
$newupdfile = "./wdata/newupd.txt";
$batnewdir = "./bdata";
$visitorFile = "./visitor.log";
# ↓保存されるファイルの漢字コード( windows='sjis' linux,unix='euc' 'jis' のいずれか)
$kanjicode = 'sjis';
# フォントスタイル
$fonttype = "span";
$fontstyleE = "style=\"font-size: 13px ; color: #ff0000 ; font-weight: bold\"";
$fontstyleH = "style=\"font-size: 13px ; color: #282860\"";
$fontstyleN = "style=\"font-size: 15px ; color: #404040\"";
###$masterFlag = 0;
$masterId = "ahXch5k9t8z";
$masterPass = "kata0222";
$masterPass2 = "kata9999";
$masterName = "管理人";
$cryptstr = "xn";
$cookiever = 100314;
$useName = "匿名";
$cr = "";
&main();
exit(0);
#############################################################################
## ここからプログラム ( わからない人は触ってはダメ )
#############################################################################
sub main
{
###########################################
#### 初期処理
###########################################
( $browserGrp , $browserAgn ) = &getBrowser();
( $today , $nowtime , $weekstr ) = &getLocalTime();
( $host , $addr ) = &getHost( $ENV{'REMOTE_HOST'} , $ENV{'REMOTE_ADDR'} );
&initForm( $kanjicode );
###########################################
#### ファイルサイズを調べて大きくなっているならメールする
###########################################
$maxsize = 1024 * 256;
if ( -s $visitorFile > $maxsize ){
## ファイルがサイズmaxに達している場合
&hostMail();
## 削除
unlink( $visitorFile );
}
if ( $ENV{'HTTP_REFERER'} =~ /k-systemtrading.com/ ){
}else{
$ngLog = 0;
for ( $i = 0 ; $i <= $#ngLogIP ; $i++ ){
if ( $host =~ $ngLogIP[$i] ||
$addr =~ $ngLogIP[$i] ){
$ngLog = 1;
last;
}
}
if ( $ngLog eq 0 ){
&addFile( $visitorFile );
}
}
###########################################
#### マスター処理
###########################################
if ( defined( $form{ 'delmasterip' } )){
unlink( $masterfile );
}
if ( defined( $form{ 'setmasterip' } )){
if ( open( FILE , ">$masterfile" )){
print FILE "$addr";
close( FILE );
chmod( 0600 , "$masterfile" );
}
}
if ( !( -e $masterfile )){
## マスターファイルが無い
}else{
@dataList = &filePaser( $masterfile );
if ( $dataList[ 0 ] eq $addr ){
$COOKIE{ 'master' } = "on";
}
}
###########################################
#### cookie処理
###########################################
$outId = &getWriteId();
### if ( $addr eq "112.138.28.76" ){
### $COOKIE{ 'master' } = "on";
### }
### if ( defined( $form{ 'delcookie' } )){
### $cookieSW = "del";
### &delCookie();
### ### &setCookie( "" );
###
### }elsif ( defined( $form{ 'setcookie' } )){
### $cookieSW = "set";
### $COOKIE{ 'comid' } = time;
### $COOKIE{ 'outid' } = $outId;
### &setCookie( "ver,$cookiever,comid,$COOKIE{ 'comid' },outid,$COOKIE{ 'outid' },master,on" );
###
### }else{
&getCookie();
$COOKIE{ 'comid' } = $COOKIE{ 'comid' } + 0;
if ( $cookiever ne $COOKIE{ 'ver' } ){
$cookieSW = "off";
$COOKIE{ 'comid' } = time;
$COOKIE{ 'outid' } = $outId;
&setCookie( "ver,$cookiever,comid,$COOKIE{ 'comid' },outid,$COOKIE{ 'outid' }" );
}else{
$cookieSW = "on";
}
### }
###########################################
#### 画面表示処理
###########################################
&setContentType( $kanjicode );
&batWrite();
### print "----------
";
### foreach $wrd ( keys %ENV ){
### print "$wrd = $ENV{ $wrd }
";
### }
### print "$host
";
### $form{ 'g' } = 1;
### $form{ 'f' } = 1;
### $form{ 'sort' } = 0;
### $form{ 'div' } = 5;
if ( defined( $form{ 't_dep' } )){
}else{
$form{ 't_dep' } = 0;
}
if ( defined( $form{ 't_grp' } )){
}else{
$form{ 't_grp' } = 0;
}
if ( defined( $form{ 't_tre' } )){
}else{
$form{ 't_tre' } = 0;
}
if ( defined( $form{ 't_mes' } )){
}else{
$form{ 't_mes' } = 0;
}
### google検索エンジン対策「許容 ドローダウン」
if ( $form{'t_dep'} eq 1 && $form{'t_grp'} eq 201 && $form{'t_tre'} eq 1 ){
$form{'t_dep'} = 1;
$form{'t_grp'} = 301;
$form{'t_tre'} = 1;
}
### print "$ENV{'HTTP_USER_AGENT'}
";
### print "--->$browserGrp
";
### print "--->$browserAgn
";
### print "----------
";
### foreach $wrd ( keys %form ){
### print "$wrd = $form{ $wrd }
";
### }
### print "----------
";
### print "$ENV{'HTTP_COOKIE'}
";
### print "$cookieSW
";
### foreach $wrd ( keys %COOKIE ){
### print "$wrd = $COOKIE{ $wrd }
";
### }
### print "----------
";
&mainDraw();
### print "";
exit( 0 );
}
####sub getWriteId
####{
#### local( $tmp0 , $id );
#### $tmp0 = $addr;
#### $tmp0 =~ s/\.//g; #.を抜く
#### $tmp0 = crypt( $tmp0 , $cryptstr );
#### $id = substr( $tmp0 , 2 , length( $tmp0 ) - 2 );
#### return $id;
####}
sub batWrite
{
local( $sFlag , $uFlag );
if ( defined( $form{ 'input_upddel'} ) ||
defined( $form{ 'check_new'} ) ||
defined( $form{ 'check_upddel'} ) ||
defined( $form{ 'exect_new'} ) ||
defined( $form{ 'exect_upddel'} )){
### print "quit
";
### print "quit
";
### print "quit
";
### print "quit
";
return;
}
if ( defined( $form{ 't_dep' } ) ||
defined( $form{ 't_grp' } ) ||
defined( $form{ 't_tre' } ) ||
defined( $form{ 't_mes' } ) ){
### print "quit
";
return;
}
if ( $form{ 'm_delpass'} ne '' ||
$form{ 'm_handle' } ne '' ||
$form{ 'm_frame' } ne '' ||
$form{ 'm_title' } ne '' ){
return;
}
### print "batWrite:start
";
if ( opendir( DIR , $batnewdir )){
undef @filesA;
@filesA = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
@filesA = sort { $a cmp $b } @filesA; # 古い順
### @filesA = sort { $b cmp $a } @filesA; # 新しい順
closedir( DIR );
foreach $filename ( @filesA ) {
## 01234567
## b001.txt
if ( 8 eq length( $filename ) &&
'b' eq substr( $filename , 0 , 1 ) &&
'.txt' eq substr( $filename , 4 , 4 ) ){
### ターゲットファイルの場合
###print "---->b:$filename<----
";
$targetFile = "$batnewdir/$filename";
@dataList = &filePaser( $targetFile );
$sFlag = 0;
$tmp_grp = "";
$tmp_tre = "";
$tmp_name = "";
$tmp_time = "";
$tmp_title = "";
$tmp_mess = "";
for ( $i = 0 ; $i <= $#dataList ; $i++ ){
######12345678
if ( 'NAME:' eq substr( $dataList[$i] , 0 , 5 )){
$tmp_name = substr( $dataList[$i] , 5 , length( $dataList[$i] ) - 5 );
next;
}
######12345678
if ( 'TITLE:' eq substr( $dataList[$i] , 0 , 6 )){
$tmp_title = substr( $dataList[$i] , 6 , length( $dataList[$i] ) - 6 );
next;
}
######12345678
if ( 'TIME:' eq substr( $dataList[$i] , 0 , 5 )){
$tmp_time = substr( $dataList[$i] , 5 , length( $dataList[$i] ) - 5 );
next;
}
######12345678
if ( 'GRP:' eq substr( $dataList[$i] , 0 , 4 )){
$tmp_grp = substr( $dataList[$i] , 4 , length( $dataList[$i] ) - 4 );
next;
}
######12345678
if ( 'TRE:' eq substr( $dataList[$i] , 0 , 4 )){
$tmp_tre = substr( $dataList[$i] , 4 , length( $dataList[$i] ) - 4 );
next;
}
######12345678
if ( 'START:' eq substr( $dataList[$i] , 0 , 6 )){
$sFlag = 1;
next;
}
if ( $sFlag eq 1 ){
$tmp_mess .= "$dataList[$i]\r\n";
}
}
## print "step:1
";
if ( $sFlag eq 0 ){
next;
}
## print "step:2
";
if ( $tmp_time eq '' ){
next;
}
## print "step:3:$tmp_grp:$tmp_tre
";
if ( $tmp_grp eq '' || $tmp_tre eq '' ){
next;
}
## print "step:4
";
$uFlag = 0;
$tmp_now = "$today $nowtime";
## print "now:$tmp_now
";
if ( $tmp_time lt $tmp_now ){ ## $date0 < $tmp_now
$uFlag = 1;
}elsif ( $tmp_time gt $tmp_now ){ ## $date0 > $tmp_now
}else{ ## $date0 == $tmp_now
}
if ( $uFlag eq 1 ){
### print "name:$tmp_name
";
### print "time:$tmp_time
";
### print "mess:$tmp_mess
";
## funa
$form{ 't_grp' } = $tmp_grp;
$form{ 't_tre' } = $tmp_tre;
$form{ 'm_delpass'} = $masterPass2;
$form{ 'm_handle' } = $tmp_name;
$form{ 'm_frame' } = "mess";
$form{ 'm_commflag' } = "";
$form{ 'm_title' } = $tmp_title;
$form{ 'm_input' } = $tmp_mess;
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree";
if ( !( -e "$fullPath" )){
## フォルダが無いのはおかしい
}else{
$form{ 't_mes' } = &getFreeMessNo( $fullPath ) + 0;
if ( $form{ 't_mes' } ne 0 ){
$dataFile = sprintf( 'm%04d.txt' , $form{ 't_mes' } );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
if ( &updMessageFile( $fullPath , "new" , $tmp_time )){
&addNewUpdFile( $form{ 'm_frame' } , "new" , $form{ 't_grp' } + 0 , $form{ 't_tre' } + 0 , $form{ 't_mes' } + 0 , $tmp_time );
}
unlink( $targetFile );
### print "$targetFile
";
}
}
}
}
}
}
undef $form{ 't_grp' };
undef $form{ 't_tre' };
undef $form{ 't_mes' };
### print "batWrite:end
";
return 0;
}
sub getWriteId
{
local( $tmp00 , $tmpA0 , $tmpB0 , $tmpC0 , $tmpD0 , $tmpZZ , $id );
local( $tmpA1 , $tmpA2 , $tmpA3 , $tmpB1 , $tmpB2 , $tmpB3 , $tmpC1 , $tmpC2 , $tmpC3 , $tmpD1 , $tmpD2 , $tmpD3 );
$tmp00 = $addr;
( $tmpA0 , $tmpB0 , $tmpC0 , $tmpD0 ) = split( /\./ , $addr );
$tmpA0 = sprintf( '%03d' , $tmpA0 );
$tmpB0 = sprintf( '%03d' , $tmpB0 );
$tmpC0 = sprintf( '%03d' , $tmpC0 );
$tmpD0 = sprintf( '%03d' , $tmpD0 );
$tmpA1 = substr( $tmpA0 , 0 , 1 );
$tmpA2 = substr( $tmpA0 , 1 , 1 );
$tmpA3 = substr( $tmpA0 , 2 , 1 );
$tmpB1 = substr( $tmpB0 , 0 , 1 );
$tmpB2 = substr( $tmpB0 , 1 , 1 );
$tmpB3 = substr( $tmpB0 , 2 , 1 );
$tmpC1 = substr( $tmpC0 , 0 , 1 );
$tmpC2 = substr( $tmpC0 , 1 , 1 );
$tmpC3 = substr( $tmpC0 , 2 , 1 );
$tmpD1 = substr( $tmpD0 , 0 , 1 );
$tmpD2 = substr( $tmpD0 , 1 , 1 );
$tmpD3 = substr( $tmpD0 , 2 , 1 );
### print "$tmpA0:$tmpA1$tmpA2$tmpA3
";
### print "$tmpB0:$tmpB1$tmpB2$tmpB3
";
### print "$tmpC0:$tmpC1$tmpC2$tmpC3
";
### print "$tmpD0:$tmpD1$tmpD2$tmpD3
";
$tmpZZ = "z$tmpA1";
$tmp00 = "";
$tmp00 .= "$tmpD1$tmpC1$tmpB1";
$tmp00 .= "$tmpA2$tmpC2$tmpB2$tmpD2";
$tmp00 .= "$tmpA3$tmpB3$tmpC3$tmpD3";
### print "$tmp00
";
$tmp00 = crypt( $tmp00 , $tmpZZ );
### print "$tmp00
";
$id = substr( $tmp00 , 2 , length( $tmp00 ) - 2 );
### print "$id
";
return $id;
}
#############################################################################
# 画面表示
# use:
# &mainDraw();
#############################################################################
sub mainDraw
{
undef @templateList;
$templateFile = "./top.html";
if ( !( -e $templateFile )){
print "テンプレートファイルがありません。$templateFile";
return;
}
@templateList = &filePaser( $templateFile );
undef @headTable;
@headTable = (
'\[表示欄\]' ,
);
for ( $i = 0 ; $i <= $#headTable ; $i++ ){
$value = $headTable[ $i ];
&jcode'convert(*value, 'euc');
$headTable[ $i ] = $value;
}
for ( $i = 0 ; $i <= $#templateList ; $i++ ){
undef @value;
$value = $templateList[$i];
&jcode'convert(*value, 'euc');
$line = $value;
for ( $j = 0 ; $j <= $#headTable ; $j++ ){
if ( $line =~ /$headTable[$j]/ ){
( @tmps ) = split( /$headTable[$j]/ , $line );
$value = $tmps[ 0 ] , &jcode'convert(*value, 'sjis') , print "$value$cr";
undef $tmps[ 0 ];
$line = join( "" , @tmps );
if ( $j eq 0 ){
&headDraw();
&messageDraw();
#### &inputFromDraw();
#### if ( $mode eq "std" ){
#### &stdDraw(); # 基本
#### }elsif ( $mode eq "upd" ){
#### &updDraw(); # 基本
#### }elsif ( $mode eq "new" ){
#### &newDraw(); # 基本
#### }
}
}
}
$value = $line;
&jcode'convert(*value, 'sjis');
print "$value$cr";
}
}
sub messageDraw
{
local( $tmp );
####################
# ID表示
####################
if ( defined( $form{ 'id'} )){
&idAllDraw();
goto messageDrawEND;
}
####################
# 修正
####################
if ( defined( $form{ 'input_upddel'} )){
&inputFromDraw( "old" , $form{'m_frame'} , "input" );
goto messageDrawEND;
}
####################
# 書き込みの確認
####################
if ( defined( $form{ 'check_new'} )){
&inputFromDraw( "new" , $form{'m_frame'} , "check" );
goto messageDrawEND;
}
if ( defined( $form{ 'check_upddel'} )){
&inputFromDraw( "old" , $form{'m_frame'} , "check" );
goto messageDrawEND;
}
####################
# 書き込みの更新
####################
if ( defined( $form{ 'exect_new'} )){
if ( &inputFromDraw( "new" , $form{'m_frame'} , "exect" )){
if ( $form{'m_frame'} eq 'none' ){
$form{'m_frame'} = 'grop';
$form{ 't_dep' } = $form{ 't_tre' } = 0;
goto messageDrawGrp;
}
if ( $form{'m_frame'} eq 'mess' ){
&updDraw("書き込みが完了しました。");
$form{ 't_dep' } = 1;
goto messageDrawTre;
}
if ( $form{'m_frame'} eq 'tree' ){
&updDraw("書き込みが完了しました。");
$form{ 't_dep' } = 1;
goto messageDrawTre;
}
if ( $form{'m_frame'} eq 'grop' ){
&updDraw("書き込みが完了しました。");
$form{ 't_dep' } = 0;
goto messageDrawGrp;
}
}
goto messageDrawEND;
}
if ( defined( $form{ 'exect_upddel'} )){
if ( &inputFromDraw( "old" , $form{'m_frame'} , "exect" )){
if ( $form{ $label } eq '削除' ){
if ( $form{'m_frame'} eq 'none' ){
$form{'m_frame'} = 'grop';
$form{ 't_dep' } = $form{ 't_tre' } = 0;
goto messageDrawGrp;
}
if ( $form{'m_frame'} eq 'tree' ){
&updDraw("スレッドを削除しました。");
$form{ 't_dep' } = 0;
goto messageDrawGrp;
}
if ( $form{'m_frame'} eq 'mess' ){
&updDraw("コメントを削除しました。");
$form{ 't_mes' } = 0;
goto messageDrawTre;
}
}
if ( $form{ $label } eq '訂正' ){
if ( $form{'m_frame'} eq 'none' ){
$form{'m_frame'} = 'grop';
$form{ 't_dep' } = $form{ 't_tre' } = 0;
goto messageDrawGrp;
}
if ( $form{'m_frame'} eq 'mess' ){
&updDraw("編集が完了しました。");
$form{ 't_dep' } = 1;
goto messageDrawTre;
}
if ( $form{'m_frame'} eq 'tree' ){
&updDraw("編集が完了しました。");
$form{ 't_dep' } = 1;
goto messageDrawTre;
}
if ( $form{'m_frame'} eq 'grop' ){
&updDraw("編集が完了しました。");
$form{ 't_dep' } = 0;
goto messageDrawGrp;
}
}
}
goto messageDrawEND;
}
####################
# スレッドの表示
####################
if ( $form{ 't_dep' } eq 1 ){
messageDrawTre:
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$dataFile = sprintf( 'm%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
if ( !( -e $fullPath )){
goto messageDrawNoGrp;
}
@messData = &messPaser( $fullPath );
$messData{'f_index'} = 0;
###print "スレッドスレッドスレッド
";
&oneDraw();
&mesDraw();
###
$form{ 'm_delpass' } = "";
$form{ 'm_handle' } = "";
$form{ 'm_title' } = "";
$form{ 'm_input' } = "";
&inputFromDraw( "new" , "mess" , "input" );
goto messageDrawEND;
}
####################
# グループの表示
####################
if ( $form{ 't_dep' } eq 0 ){
messageDrawGrp:
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$fullPath = "$datadir/$dataGrop";
if ( !( -e $fullPath )){
goto messageDrawNoGrp;
}
$dataFile = sprintf( 'g%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataFile";
@messData = &messPaser( $fullPath );
$messData{'f_index'} = 0;
### print "グループグループグループグループ $fullPath
";
&oneDraw();
if ( $messData{'f_commflag'} eq '許可' ){
&treDraw();
$form{ 'm_delpass' } = "";
$form{ 'm_handle' } = "";
$form{ 'm_title' } = "";
$form{ 'm_input' } = "";
&inputFromDraw( "new" , "tree" , "input" );
}
$tmp = $form{ 't_grp' } + 0;
if ( 0 eq $tmp ){
&newupdDraw();
}
goto messageDrawEND;
}
messageDrawNoGrp:
if ( $COOKIE{ 'master' } eq "on" ){
$tmp = $fullPath;
$tmp =~ s/\//i/g;
$tmp =~ s/\./t/g;
print "データがありません。($tmp)
";
&inputFromDraw( "new" , "grop" , "input" );
}else{
$tmp = $fullPath;
$tmp =~ s/\//i/g;
$tmp =~ s/\./t/g;
print "コンテンツが作成されていません。($tmp)
";
}
messageDrawEND:
}
sub getFileCount
{
local( $fullPath ) = @_;
if ( opendir( DIR , $fullPath )){
undef @filesA;
@filesA = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
closedir( DIR );
return $#filesA;
}
return 0;
}
sub treDraw
{
local( $i , $fmax , $dirmax );
$dirmax = 0;
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$fullPath = "$datadir/$dataGrop";
if ( opendir( DIR , $fullPath )){
undef @files;
@files = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
### @files = sort { $a cmp $b } @files; # 古い順
@files = sort { $b cmp $a } @files; # 新しい順
closedir( DIR );
foreach $filename ( @files ) {
### if ( -d $filename ){
### print "---->DIR:$filename<----
";
### }else{
### print "---->FLE:$filename<----
";
### }
if ( 5 eq length( $filename ) && 't' eq substr( $filename , 0 , 1 )){
$fmax = &getFileCount( "$datadir/$dataGrop/$filename" );
### ターゲットフォルダの場合
###print "---->a:$filename<----
";
$tmpId = substr( $filename , 1 , 4 ) + 0;
$fullPath = "$datadir/$dataGrop/$filename";
$dirlist[ $dirmax ] = "$fullPath,$tmpId,$fmax";
$dirmax++;
}
}
}
if ( $dirmax eq 0 ){
return;
}
print <<"_HTML_";
|
_HTML_
for ( $i = 0 ; $i < $dirmax ; $i++ ){
( $fullPath , $tmpId , $fmax ) = split( /,/ , $dirlist[ $i ] );
$dataFile = sprintf( 'm%04d.txt' , 0 );
$fullPath = "$fullPath/$dataFile";
@messData = &messPaser( $fullPath );
###############
print " | ";
print "";
$tmpURL = "$thiscgi?t_dep=1&t_grp=$form{'t_grp'}&t_tre=$tmpId";
print "$messData{ 'f_title' }";
print " | ";
print "";
print "投稿数 : $fmax件";
print " | ";
print "
";
}
print <<"_HTML_";
|
_HTML_
}
sub idAllDraw
{
local( $updFlag , $idxMax , $idx , $hand , $dpass );
print "$cr";
print "$cr";
print "$cr";
print "[ $form{'id'} ] さんの投稿一覧$cr";
print " | $cr";
print "
$cr";
print "
$cr";
print "$cr";
#########################
#########################
$idxMax = 0;
$grpPath = "$datadir";
if ( opendir( DIR , $grpPath )){
undef @grpFiles;
@grpFiles = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
@grpFiles = sort { $a cmp $b } @grpFiles; # 古い順
### @grpFiles = sort { $b cmp $a } @grpFiles; # 新しい順
closedir( DIR );
foreach $grpname ( @grpFiles ) {
if ( 5 eq length( $grpname ) &&
'g' eq substr( $grpname , 0 , 1 ) ){
### print "$grpname
";
#################
$trePath = "$datadir/$grpname";
if ( opendir( DIR , $trePath )){
undef @treFiles;
@treFiles = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
@treFiles = sort { $a cmp $b } @treFiles; # 古い順
### @treFiles = sort { $b cmp $a } @treFiles; # 新しい順
closedir( DIR );
foreach $trename ( @treFiles ) {
if ( 5 eq length( $trename ) &&
't' eq substr( $trename , 0 , 1 ) ){
$updFlag = 0;
### print "--$trename
";
#################
$mesPath = "$datadir/$grpname/$trename";
if ( opendir( DIR , $mesPath )){
undef @mesFiles;
@mesFiles = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
@mesFiles = sort { $a cmp $b } @mesFiles; # 古い順
### @mesFiles = sort { $b cmp $a } @mesFiles; # 新しい順
closedir( DIR );
foreach $mesname ( @mesFiles ) {
if ( 9 eq length( $mesname ) &&
'm' eq substr( $mesname , 0 , 1 ) &&
'.txt' eq substr( $mesname , 5 , 4 ) ){
### print "----$mesname
";
$mesFile = "$datadir/$grpname/$trename/$mesname";
@messData = &messPaser( $mesFile );
if ( $form{'id'} eq $messData{'f_id'} ){
$handPass[$idxMax] = "$messData{'f_handle'},$messData{'f_delpass'}";
$idxMax++;
}
}
}
}
}
}
}
}
}
}
if ( $idxMax eq 0 ){
return;
}
#########################
#########################
$grpPath = "$datadir";
if ( opendir( DIR , $grpPath )){
undef @grpFiles;
@grpFiles = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
@grpFiles = sort { $a cmp $b } @grpFiles; # 古い順
### @grpFiles = sort { $b cmp $a } @grpFiles; # 新しい順
closedir( DIR );
foreach $grpname ( @grpFiles ) {
if ( 5 eq length( $grpname ) &&
'g' eq substr( $grpname , 0 , 1 ) ){
### print "$grpname
";
#################
$trePath = "$datadir/$grpname";
if ( opendir( DIR , $trePath )){
undef @treFiles;
@treFiles = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
@treFiles = sort { $a cmp $b } @treFiles; # 古い順
### @treFiles = sort { $b cmp $a } @treFiles; # 新しい順
closedir( DIR );
foreach $trename ( @treFiles ) {
if ( 5 eq length( $trename ) &&
't' eq substr( $trename , 0 , 1 ) ){
$updFlag = 0;
### print "--$trename
";
#################
$mesPath = "$datadir/$grpname/$trename";
if ( opendir( DIR , $mesPath )){
undef @mesFiles;
@mesFiles = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
@mesFiles = sort { $a cmp $b } @mesFiles; # 古い順
### @mesFiles = sort { $b cmp $a } @mesFiles; # 新しい順
closedir( DIR );
foreach $mesname ( @mesFiles ) {
if ( 9 eq length( $mesname ) &&
'm' eq substr( $mesname , 0 , 1 ) &&
'.txt' eq substr( $mesname , 5 , 4 ) ){
### print "----$mesname
";
$tmpId = substr( $mesname , 1 , 4 ) + 0;
$mesFile = "$datadir/$grpname/$trename/$mesname";
@messData = &messPaser( $mesFile );
for ( $idx = 0 ; $idx < $idxMax ; $idx++ ){
( $hand , $dpass ) = split(/,/, $handPass[$idx] );
if ( $form{ 'id'} eq $messData{'f_id'} || ( $hand ne '' && $hand eq $messData{'f_handle'} && $dpass eq $messData{'f_delpass'} )){
$form{ 't_grp' } = substr( $grpname , 1 , 4 ) + 0;
$form{ 't_tre' } = substr( $trename , 1 , 4 ) + 0;
if ( $updFlag eq 0 ){
&headDraw();
@messData = &messPaser( $mesFile );
}
$messData{'f_index'} = $tmpId;
$form{ 't_mes' } = $tmpId;
$form{ 't_dep' } = 2;
&oneDraw();
$updFlag = 1;
last;
}
}
}
}
}
}
}
}
}
}
}
}
sub headDraw
{
local( $tmpNo );
print "$cr";
print "$cr";
print "$cr";
print "$cr";
print "TOP$cr";
$tmpNo = $form{ 't_grp' } + 0;
if ( $tmpNo ne 0 ){
######################
## グループ
######################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataFile = sprintf( 'g%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataFile";
if ( !( -e "$fullPath" )){
goto headDrawEND;
}
@messData = &messPaser( $fullPath );
$tmpURL = "$thiscgi?t_dep=0&t_grp=$form{'t_grp'}&t_tre=0";
print " > $messData{ 'f_title' }";
######################
## ツリー
######################
$tmpNo = $form{ 't_grp' } + 0;
if ( $tmpNo ne 0 ){
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$dataFile = sprintf( 'm%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
if ( !( -e "$fullPath" )){
goto headDrawEND;
}
@messData = &messPaser( $fullPath );
$tmpURL = "$thiscgi?t_dep=1&t_grp=$form{'t_grp'}&t_tre=$form{ 't_tre' }";
print " > $messData{ 'f_title' }";
}
}
headDrawEND:
print " | ";
print "
";
print "$cr";
print " | ";
print "
$cr";
### print "$cr";
### print "1つ戻る";
### print " | ";
}
sub cmADraw
{
local( $nowho );
if ( $COOKIE{ 'master' } eq "on" ){
}else{
$nowho = ( substr( $nowtime , 0 , 2 ) + 0 ) % 3;
###
### if ( $nowho eq 0 ){
print <<"_HTML_";
_HTML_
### }else{
### print <<"_HTML_";
###
### |
###
### |
###
###
### |
###
### プロフェッショナルを目指すシステムトレード構\築セミナーDVD!
### 2週間で100席が満席となった幻のセミナー!
### |
###
###
###
###_HTML_
### }
}
}
sub updDraw
{
local( $mess ) = @_;
print "
$cr";
print "$cr";
print "$cr";
print "$cr";
print " ";
print " ";
print "$mess$cr";
print "
";
print " |
";
print "$cr";
print " | ";
print "
$cr";
print "
$cr";
}
sub mesDraw
{
local( $tmpId );
### print "mesDraw
";
### print "mesDraw
";
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree";
if ( opendir( DIR , $fullPath )){
undef @files;
@files = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
@files = sort { $a cmp $b } @files; # 古い順
### @files = sort { $b cmp $a } @files; # 新しい順
closedir( DIR );
foreach $filename ( @files ) {
###print ".....$filename
";
if ( 9 eq length( $filename ) &&
'm' eq substr( $filename , 0 , 1 ) &&
'.txt' eq substr( $filename , 5 , 4 ) ){
$tmpId = substr( $filename , 1 , 4 ) + 0;
if ( $tmpId ne 0 ){
$fullPath = "$datadir/$dataGrop/$dataTree/$filename";
### print "$fullPath
";
@messData = &messPaser( $fullPath );
$messData{'f_index'} = $tmpId;
$form{ 't_mes' } = $tmpId;
$form{ 't_dep' } = 2;
&oneDraw();
}
}
}
}
## print "mesDrawEnd
";
## print "mesDrawEnd
";
}
sub oneDraw
{
local( $i , $j , $line , $updFlag );
###########################################
#### 変更有効期限
###########################################
$updFlag = 1;
if ( $COOKIE{ 'master' } eq "on" ){
}else{
( $yyy , $mmm , $ddd ) = &addDay( substr( $messData{'f_date'} , 0 , 4 ) , substr( $messData{'f_date'} , 5 , 2 ) , substr( $messData{'f_date'} , 8 , 2 ) , 5 );
$date0 = sprintf( '%04d.%02d.%02d', $yyy , $mmm , $ddd );
if ( $date0 lt $today ){ ## $date0 < $today
$updFlag = 0;
}elsif ( $date0 gt $today ){ ## $date0 > $today
}else{ ## $date0 == $today
}
}
###########################################
### ヘッダ
###########################################
print "$cr";
print "$cr";
print "
";
}
sub checkInput
{
local( $newflag , $frame , $step , $secretid ) = @_;
local( $i , $flag );
local( $result0 , $result1 );
$result0 = $result1 = 0;
####################
# phaser対策
####################
if ( $step eq "exect" ){
$label = "m_secretid";
if ( $form{$label} =~ /<|>|\"|,/ ){
$formErr{'m_input'} = "phaser対策番号入力エラー";
$result0 = 1;
$result1 = 1;
}
if ( $form{$label} ne &getSecretId( $secretid )){
$formErr{'m_input'} = "phaser対策番号入力エラー";
$result0 = 1;
$result1 = 1;
}
}
####################
# マスターパスワード
####################
if ( $frame eq 'grop' ){
$label = "m_masterpass";
if ( $form{$label} ne $masterPass ){
$formErr{$label} = "入力エラー";
$result0 = 1;
$result1 = 1;
}
}
####################
# ハンドル名
####################
$label = "m_handle";
if ( $form{$label} =~ /<|>|\"|,/ ){
$formErr{$label} = "入力エラー";
$result0 = 1;
}
if ( $useName eq $form{$label} ){
$formErr{$label} = "利用できないハンドル名";
$result0 = 1;
}
if ( $frame eq 'grop' || $frame eq 'tree' ){
if ( $form{$label} eq '' ){
$formErr{$label} = "入力エラー";
$result0 = 1;
}
}
####################
# タイトル名
####################
$label = "m_title";
if ( $form{$label} =~ /<|>|\"|,/ ){
$formErr{$label} = "入力エラー";
$result0 = 1;
}
if ( $frame eq 'grop' || $frame eq 'tree' ){
if ( $form{$label} eq '' ){
$formErr{$label} = "入力エラー";
$result0 = 1;
}
}
if ( length( $form{$label} ) > 60 ){
$formErr{$label} = "文字数エラー(全角30文字)";
$result0 = 1;
}
####################
# 削除パス
####################
if ( $newflag eq "old" ){
$label = "m_delpass";
if ( $form{$label} =~ /<|>|\"|,/ ){
$formErr{$label} = "入力エラー1";
$result0 = 1;
}
if ( $form{$label} ne $messData{'f_delpass'} ){
$formErr{$label} = "入力エラー2";
$result0 = 1;
$result1 = 1;
}
}else{
$label = "m_delpass";
if ( $form{$label} =~ /<|>|\"|,/ ){
$formErr{$label} = "入力エラー3";
$result0 = 1;
}
if ( $form{$label} eq '' ){
$formErr{$label} = "入力エラー4";
$result0 = 1;
}
if ( $frame eq 'grop' ){
if ( $form{$label} ne $masterPass ){
$formErr{$label} = "入力エラー5";
$result0 = 1;
}
}
if ( 4 <= length( $form{$label} ) && length( $form{$label} ) <= 8 ){
}else{
$formErr{$label} = "4〜8文字";
$result0 = 1;
}
}
####################
# メッセージ
####################
$label = "m_input";
if ( $cookieSW ne "on" ){
##なにもしない
$formErr{$label} = "クッキー設定がoffのブラウザでは投稿ができません";
$result0 = 1;
}
### if ( $masterFlag eq 1 ){
### }els
if ( $form{'m_delpass'} eq $masterPass ){
}else{
if ( $form{$label} eq '' ){
$formErr{$label} = "入力エラー";
$result0 = 1;
}
if ( $COOKIE{ 'master' } eq "on" ){
}else{
if ( length( $form{$label} ) > 1600 ){
$formErr{$label} = "文字数エラー(全角800文字)";
$result0 = 1;
}
if ( $form{$label} =~ /<|\"|,/ ){
$formErr{$label} = "使用禁止文字エラー";
$result0 = 1;
}
}
}
####################
# ハンドル名chk
####################
### print "hcheck 1
";
if ( $result0 eq 0 ){
### print "hcheck 2
";
if ( $form{'m_delpass'} eq $masterPass ){
}else{
if ( $form{'m_handle'} ne '' ){
if ( length( $form{'m_handle'} ) > 20 ){
$formErr{'m_handle'} = "文字数エラー(全角10文字)";
$result0 = 1;
}
if ( &useHandleFile( $form{'m_handle'} , $form{'m_delpass'} )){
$formErr{'m_handle'} = "誰かが使用しているハンドル名です";
$result0 = 1;
}
}
}
}
####################
# 書込み禁止
####################
if ( $result0 eq 0 ){
####################
# 国内ドメイン
####################
$flag = 0;
@doms = split( /\./ , $host );
for ( $i = 0 ; $i <= $#okDom ; $i++ ){
if ( $okDom[$i] eq $doms[ $#doms ] ){
$flag = 1;
}
}
if ( $flag eq 0 ){
##なにもしない
$formErr{$label} = "投稿できません";
$result0 = 1;
}
}
if ( $result0 eq 0 ){
####################
# 禁止リスト
####################
for ( $i = 0 ; $i <= $#ngIPAndID ; $i++ ){
if ( $ngIPAndID[$i] eq $COOKIE{ 'outid' } ||
$ngIPAndID[$i] eq $addr ){
##なにもしない
$formErr{$label} = "投稿に失敗しました";
$result0 = 1;
}
}
}
####################
# 何回もエラー対策
####################
if ( 15 < &chkNGUserFile()){
$formErr{'m_input'} = "書き込みエラー";
$result0 = 1;
$result1 = 0; ## ファイル書き込みをさせない
}
return( $result0 , $result1 );
}
sub getFreeMessNo
{
local( $fullPath ) = @_;
local( $i , $tmpId , $maxId );
### print "getFreeMessNo
";
### print "getFreeMessNo
";
$maxId = 0;
if ( opendir( DIR , $fullPath )){
undef @files;
@files = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
### @files = sort { $a cmp $b } @files; # 古い順
@files = sort { $b cmp $a } @files; # 新しい順
closedir( DIR );
foreach $filename ( @files ) {
if ( 9 eq length( $filename ) &&
'm' eq substr( $filename , 0 , 1 ) &&
'.txt' eq substr( $filename , 5 , 4 ) ){
$tmpId = substr( $filename , 1 , 4 ) + 0;
### print "$tmpId:$filename
";
if ( $maxId < $tmpId ){
$maxId = $tmpId;
}
}
}
}
$maxId = $maxId + 1;
### print "getFreeMessNoEnd
";
### print "getFreeMessNoEnd
";
return $maxId;
}
sub getFreeTreeNo
{
local( $fullPath ) = @_;
local( $i , $tmpId , $maxId );
$maxId = 0;
if ( opendir( DIR , $fullPath )){
undef @files;
@files = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
### @files = sort { $a cmp $b } @files; # 古い順
@files = sort { $b cmp $a } @files; # 新しい順
closedir( DIR );
foreach $filename ( @files ) {
if ( 5 eq length( $filename ) && 't' eq substr( $filename , 0 , 1 )){
$tmpId = substr( $filename , 1 , 4 ) + 0;
if ( $maxId < $tmpId ){
$maxId = $tmpId;
}
}
}
}
$maxId = $maxId + 1;
return $maxId;
}
sub saveMessageFile
{
local( $newflag , $frame ) = @_;
local( $tmp );
if ( $frame eq 'mess' ){
if ( $newflag eq "new" ){
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree";
if ( !( -e "$fullPath" )){
## フォルダが無いのはおかしい
$formErr{'m_input'} = "書き込み排他エラー(なし,0)";
return 0;
}
$form{ 't_mes' } = &getFreeMessNo( $fullPath ) + 0;
if ( $form{ 't_mes' } ne 0 ){
$dataFile = sprintf( 'm%04d.txt' , $form{ 't_mes' } );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
if ( &updMessageFile( $fullPath , $newflag )){
&addNewUpdFile( $frame , $newflag , $form{ 't_grp' } + 0 , $form{ 't_tre' } + 0 , $form{ 't_mes' } + 0 , "" );
}
return 1;
}
}
if ( $newflag eq "old" ){
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree";
if ( !( -e "$fullPath" )){
## フォルダが無いのはおかしい
$formErr{'m_input'} = "書き込み排他エラー(なし,0)";
return 0;
}
$tmp = $form{ 't_mes' } + 0;
if ( $tmp ne 0 ){
$dataFile = sprintf( 'm%04d.txt' , $tmp );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
if ( &updMessageFile( $fullPath , $newflag )){
&addNewUpdFile( $frame , $newflag , $form{ 't_grp' } + 0 , $form{ 't_tre' } + 0 , $form{ 't_mes' } + 0 , "" );
}
return 1;
}
}
}
if ( $frame eq 'tree' ){
if ( $newflag eq "new" ){
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$fullPath = "$datadir/$dataGrop";
if ( !( -e "$fullPath" )){
## フォルダが無いのはおかしい
$formErr{'m_input'} = "書き込み排他エラー(なし,0)";
return 0;
}
$form{ 't_tre' } = &getFreeTreeNo( $fullPath );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree";
if ( -e $fullPath ){
## フォルダがあるのはおかしい
$formErr{'m_input'} = "書き込み排他エラー(あり,1)";
return 0;
}
####################
## フォルダ作成
####################
mkdir( $fullPath , 0755 );
### print "mkdir $fullPath
";
####################
## ファイル作成
####################
$dataFile = sprintf( 'm%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
if ( &updMessageFile( $fullPath , $newflag )){
&addNewUpdFile( $frame , $newflag , $form{ 't_grp' } + 0 , $form{ 't_tre' } + 0 , 0 , "" );
}
return 1;
}
if ( $newflag eq "old" ){
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$fullPath = "$datadir/$dataGrop";
if ( !( -e "$fullPath" )){
## フォルダが無いのはおかしい
$formErr{'m_input'} = "書き込み排他エラー(なし,2)";
return 0;
}
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree";
if ( !( -e "$fullPath" )){
## フォルダが無いのはおかしい
$formErr{'m_input'} = "書き込み排他エラー(なし,3)";
return 0;
}
####################
## ファイル作成
####################
$dataFile = sprintf( 'm%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
if ( &updMessageFile( $fullPath , $newflag )){
&addNewUpdFile( $frame , $newflag , $form{ 't_grp' } + 0 , $form{ 't_tre' } + 0 , 0 , "" );
}
return 1;
}
}
if ( $frame eq 'grop' ){
if ( $newflag eq "new" ){
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$fullPath = "$datadir/$dataGrop";
if ( -e $fullPath ){
$formErr{'m_input'} = "書き込み排他エラー(あり,4)";
return 0;
}
####################
## フォルダ作成
####################
mkdir( $fullPath , 0755 );
### print "mkdir $fullPath
";
####################
## ファイル作成
####################
$dataFile = sprintf( 'g%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataFile";
if ( &updMessageFile( $fullPath , $newflag )){
&addNewUpdFile( $frame , $newflag , $form{ 't_grp' } + 0 , 0 , 0 , "" );
}
return 1;
}
if ( $newflag eq "old" ){
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$fullPath = "$datadir/$dataGrop";
if ( !( -e "$fullPath" )){
$formErr{'m_input'} = "書き込み排他エラー(なし,5)";
return 0;
}
####################
## ファイル更新
####################
$dataFile = sprintf( 'g%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataFile";
if ( &updMessageFile( $fullPath , $newflag )){
&addNewUpdFile( $frame , $newflag , $form{ 't_grp' } + 0 , 0 , 0 , "" );
}
return 1;
}
}
}
sub updMessageFile
{
local( $fileName , $newflag , $setTime ) = @_;
local( $tmp0 , $tmp1 , $message , $id , $oldTime , $oldId , $updFlag );
@noputenv = (
"SCRIPT_NAME" ,
"SERVER_NAME" ,
"SERVER_ADMIN" ,
"HTTP_ACCEPT_ENCODING" ,
"HTTP_CONNECTION" ,
"REQUEST_METHOD" ,
"HTTP_ACCEPT" ,
"SCRIPT_FILENAME" ,
"SERVER_SOFTWARE" ,
"TZ" ,
"QUERY_STRING" ,
"SERVER_PORT" ,
"HTTP_ACCEPT_LANGUAGE" ,
"SERVER_PROTOCOL" ,
"PATH" ,
"REQUEST_URI" ,
"GATEWAY_INTERFACE" ,
"SERVER_ADDR" ,
"DOCUMENT_ROOT" ,
"HTTP_HOST" ,
"CONTENT_TYPE" ,
"HTTP_REFERER" ,
"CONTENT_LENGTH" ,
);
if ( $form{'m_delpass'} eq $masterPass ){
$id = $masterId;
}elsif ( $form{'m_delpass'} eq $masterPass2 ){
$id = 0;
if ( $form{ 'm_handle' } ne '' ){
if ( 'ID999:' eq substr( $form{ 'm_handle' } , 0 , 6 )){
$id = substr( $form{ 'm_handle' } , 6 , length( $form{ 'm_handle' } ) - 6 );
$form{ 'm_handle' } = "";
}else{
$id = &getHandle2OutId( $form{ 'm_handle' } , $form{'m_delpass'} );
}
}
if ( $id eq 0 ){
$tmp1 = time;
$tmp1= substr( $tmp1 , length( $tmp1 ) - 2 , 2 );
$tmp0 = $addr;
$tmp0 =~ s/\.//g; #.を抜く
$tmp0 = crypt( $tmp0 , $tmp1 );
$id = substr( $tmp0 , 2 , length( $tmp0 ) - 2 );
}
}else{
$id = $COOKIE{ 'outid' };
}
################################
################################
if ( $COOKIE{ 'master' } eq "on" && $form{'m_delpass'} ne $masterPass && $newflag eq 'old' ){
( $oldTime , $oldId ) = &getMessTimeId( $fileName );
if ( $oldId ne '' ){
$id = $oldId;
}
}else{
$oldTime = "";
}
################################
################################
if ( open( FILE , ">$fileName" )){
$message = "";
$message .= "SHEAD:\n";
$message .= "f_id,$id\n";
$message .= "f_frame,$form{ 'm_frame' }\n";
$message .= "f_commflag,$form{ 'm_commflag' }\n";
$message .= "f_title,$form{ 'm_title' }\n";
if ( $setTime ne '' ){
$message .= "f_date,$setTime\n";
}elsif ( $oldTime ne '' ){
$message .= "f_date,$oldTime\n";
}else{
$message .= "f_date,$today $nowtime\n";
}
$message .= "f_ip,$addr\n";
$message .= "f_host,$host\n";
$message .= "f_handle,$form{ 'm_handle' }\n";
$message .= "f_delpass,$form{ 'm_delpass' }\n";
$message .= "EHEAD:\n";
$message .= "$form{ 'm_input' }";
################################
print FILE "$message";
close( FILE );
chmod( 0600 , "$fileName" );
################################
################################
undef @upFile;
$subject = "【シストレを語ろう】書き込み";
$message .= "\n\n";
$message .= "FILE:$fileName\n";
$message .= "\n\n";
$message .= "-----------------------\n\n";
foreach $wrd ( keys %ENV ){
$updFlag = 1;
for ( $ii = 0 ; $ii <= $#noputenv ; $ii++ ){
if ( $noputenv[$ii] eq $wrd ){
$updFlag = 0;
last;
}
}
if ( $updFlag eq 1 ){
$message .= "$wrd = $ENV{ $wrd }\n";
}
}
if ( $form{'m_delpass'} eq $masterPass ){
}elsif ( $form{'m_delpass'} eq $masterPass2 ){
}else{
for ( $ii = 0 ; $ii <= $#toAddress ; $ii++ ){
&sendMailEx( $fromAddress , $toAddress[$ii] , $subject , $message , @upFile );
}
}
################################
################################
if ( $form{ 'm_handle' } ne '' ){
&addHandleFile( $form{ 'm_handle' } , $form{ 'm_delpass' } , $id );
}
return 1;
}
return 0;
}
sub delMessageFile
{
local( $frame ) = @_;
local( $push1 );
if ( $frame eq 'mess' ){
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree";
if ( !( -e "$fullPath" )){
## フォルダが無いのはおかしい
$formErr{'m_input'} = "削除排他エラー(なし,1)";
return 0;
}
$dataFile = sprintf( 'm%04d.txt' , $form{ 't_mes' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
unlink( $fullPath );
}
if ( $frame eq 'tree' ){
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree";
if ( !( -e "$fullPath" )){
## フォルダが無いのはおかしい
$formErr{'m_input'} = "削除排他エラー(なし,1)";
return 0;
}
if ( opendir( DIR , $fullPath )){
undef @filesA;
@filesA = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
### @filesA = sort { $a cmp $b } @filesA; # 古い順
@filesA = sort { $b cmp $a } @filesA; # 新しい順
closedir( DIR );
foreach $filenameA ( @filesA ) {
$fullPath = "$datadir/$dataGrop/$dataTree/$filenameA";
### print "delfile:$fullPath
";
unlink( $fullPath );
}
}
$fullPath = "$datadir/$dataGrop/$dataTree";
### print "deldir:$fullPath
";
rmdir( $fullPath );
}
if ( $frame eq 'grop' ){
####################
## フォルダ確認
####################
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$fullPath = "$datadir/$dataGrop";
if ( !( -e "$fullPath" )){
## フォルダが無いのはおかしい
$formErr{'m_input'} = "削除排他エラー(なし,1)";
return 0;
}
if ( opendir( DIR , $fullPath )){
undef @filesB;
@filesB = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
### @filesB = sort { $a cmp $b } @filesB; # 古い順
@filesB = sort { $b cmp $a } @filesB; # 新しい順
closedir( DIR );
foreach $filenameB ( @filesB ) {
if ( 5 eq length( $filenameB ) && 't' eq substr( $filenameB , 0 , 1 )){
$push1 = $form{ 't_tre' };
$form{ 't_tre' } = substr( $filenameB , 1 , 4 ) + 0;
### print "jump:$form{ 't_tre' }
";
&delMessageFile( 'tree' );
$form{ 't_tre' } = $push1;
}
}
}
$dataFile = sprintf( 'g%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataFile";
### print "delfile:$fullPath
";
unlink( $fullPath );
}
}
sub inputFromDraw
{
local( $newflag , $frame , $step ) = @_;
local( $next , $i , $j , $line );
&cmADraw();
## $newflag = "new";
## $frame = "tree";
## $frame = "mess";
## $frame = "grop";
## $step = "input";
## $step = "error";
## $step = "check";
## $step = "exect";
if ( $newflag eq "old" ){
if ( $form{ 't_dep' } eq 0 ){
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataFile = sprintf( 'g%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataFile";
}
if ( $form{ 't_dep' } eq 1 ){
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$dataFile = sprintf( 'm%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
}
if ( $form{ 't_dep' } eq 2 ){
$dataGrop = sprintf( 'g%04d' , $form{ 't_grp' } + 0 );
$dataTree = sprintf( 't%04d' , $form{ 't_tre' } + 0 );
$dataFile = sprintf( 'm%04d.txt' , $form{ 't_mes' } + 0 );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
}
@messData = &messPaser( $fullPath );
if ( $step eq "input" ){
if ( $COOKIE{ 'master' } eq 'on' ){
$form{ 'm_delpass' } = $messData{ 'f_delpass' };
}
$form{ 'm_frame' } = $messData{ 'f_frame' };
$form{ 'm_commflag' } = $messData{ 'f_commflag' };
$form{ 'm_title' } = $messData{ 'f_title' };
$form{ 'm_handle' } = $messData{ 'f_handle' };
$form{ 'm_input' } = $messData{ 'f_input' };
### $form{ 'm_input' } =~ s/
/\r\n/g; #改行コードを変更する
$frame = $messData{ 'f_frame' };
}
}
if ( $step eq "input" ){
$secretid = time;
}
if ( $step eq "check" ){
### if ( $form{'mstmode'} ne 'on' && $form{'delpass'} eq $masterPass ){
### $form{'delpass'} = $messData{'f_delpass'};
### $masterFlag = 1;
### }
$secretid = $form{'m_sid'};
( $result0 , $result1 ) = checkInput( $newflag , $frame , $step );
if ( $result1 ){
&addNGUserFile();
}
if ( $result0 ){
$secretid = time;
$step = "error";
}
}
if ( $step eq "exect" ){
( $result0 , $result1 ) = checkInput( $newflag , $frame , $step , $form{'m_sid'} );
if ( $result1 ){
&addNGUserFile();
}
if ( $result0 ){
$secretid = time;
$step = "error";
}else{
##############
##############
if ( &chkUpdateFile( $form{'m_sid'} )){
$form{'m_frame'} = 'none';
return 1;
}
&addUpdateFile( $form{'m_sid'} );
##############
##############
if ( $newflag eq "new" ){
if ( !&saveMessageFile( $newflag , $frame )){
$secretid = time;
$step = "error";
}else{
return 1;
}
}else{
$label = "m_updmode";
if ( $form{ $label } eq '訂正' ){
if ( !&saveMessageFile( $newflag , $frame )){
$secretid = time;
$step = "error";
}else{
return 1;
}
}
if ( $form{ $label } eq '削除' ){
&delMessageFile( $frame );
return 1;
}
}
}
}
### print "----------
";
### foreach $wrd ( keys %formErr ){
### print "$wrd = $formErr{ $wrd }
";
### }
###########################################
#### ここから表示
###########################################
print "$cr";
###########################################
### 禁止事項を表示
###########################################
print <<"_HTML_";
|
|
■ 同じハンドル名を継続して使用する場合は、訂正/削除パスを毎回同じものにしてください。
■ 訂正/削除パスは、適当でかまいませんので必ず入力してください。
■ タグ開始文字の <\; は使用できません。
■ 個人攻撃、騙り行為、自作自演行為、荒らし行為は厳禁です。
|
|
_HTML_
return 0;
}
sub addUpdateFile
{
local( $chkId ) = @_;
local( $flag , $i );
if ( !( -e "$updatefile" )){ # ファイルが無い場合は新規で作成する
open( FILE , ">$updatefile" );
close( FILE );
chmod( 0600 , "$updatefile" );
}
if ( open( FILE , "<$updatefile" )){
@filedata = ;
close( FILE );
if ( open( FILE , ">$updatefile" )){
$flag = 0;
for ( $i = 0 ; $i <= $#filedata ; $i++ ){
$filedata[$i] =~ s/\r//g; #改行を抜く
$filedata[$i] =~ s/\n//g; #改行を抜く
( $date , $ip , $updid ) = split(/,/, $filedata[ $i ] );
if ( $today eq $date ){ #今日の分だけ残す
print FILE "$filedata[$i]\n"; # そのまま書き戻す
}
}
print FILE "$today,$addr,$chkId\n";
close( FILE );
}
}
}
sub chkUpdateFile
{
local( $chkId ) = @_;
local( $i );
if ( open( FILE , "<$updatefile" )){
@filedata = ;
close( FILE );
for ( $i = 0 ; $i <= $#filedata ; $i++ ){
$filedata[$i] =~ s/\r//g; #改行を抜く
$filedata[$i] =~ s/\n//g; #改行を抜く
( $date , $ip , $updid ) = split(/,/, $filedata[ $i ] );
if ( $today eq $date ){
if ( $ip eq $addr && $updid eq $chkId ){
return 1; ## 既に更新済み
}
}
}
}
return 0;
}
sub addNGUserFile
{
local( $flag , $i );
if ( !( -e "$nguserfile" )){ # ファイルが無い場合は新規で作成する
open( FILE , ">$nguserfile" );
close( FILE );
chmod( 0600 , "$nguserfile" );
}
if ( open( FILE , "<$nguserfile" )){
@filedata = ;
close( FILE );
if ( open( FILE , ">$nguserfile" )){
$flag = 0;
for ( $i = 0 ; $i <= $#filedata ; $i++ ){
$filedata[$i] =~ s/\r//g; #改行を抜く
$filedata[$i] =~ s/\n//g; #改行を抜く
( $date , $ip , $count ) = split(/,/, $filedata[ $i ] );
if ( $today eq $date ){
if ( $ip ne $addr ){
print FILE "$filedata[$i]\n"; # そのまま書き戻す
}else{
$flag = 1;
$count++;
print FILE "$date,$ip,$count\n";
}
}
}
if ( $flag eq 0 ){
print FILE "$today,$addr,1\n";
}
close( FILE );
}
}
}
sub chkNGUserFile
{
local( $i );
if ( open( FILE , "<$nguserfile" )){
@filedata = ;
close( FILE );
for ( $i = 0 ; $i <= $#filedata ; $i++ ){
$filedata[$i] =~ s/\r//g; #改行を抜く
$filedata[$i] =~ s/\n//g; #改行を抜く
( $date , $ip , $count ) = split(/,/, $filedata[ $i ] );
if ( $today eq $date ){
if ( $ip eq $addr ){
return $count;
}
}
}
}
return 0;
}
#### sub updMessageFile
#### {
#### local( $tmp0 , $tmp1 , $message );
####
#### $dataGrup = sprintf( 'd%04d' , $form{ 'g' } + 0 );
#### $dataFile = sprintf( '%s.txt' , $form{ 'target' } );
#### $fullPath = "$datadir/$dataGrup/$dataFile";
#### if ( open( FILE , ">$fullPath" )){
#### if ( $masterFlag eq 1 ){
#### $id = $masterId;
#### }elsif ( $form{'delpass'} eq $masterPass ){
#### $id = $masterId;
#### }elsif ( $form{'delpass'} eq $masterPass2 ){
#### $tmp1 = time;
#### $tmp1= substr( $tmp1 , length( $tmp1 ) - 2 , 2 );
#### $tmp0 = $addr;
#### $tmp0 =~ s/\.//g; #.を抜く
#### $tmp0 = crypt( $tmp0 , $tmp1 );
#### $id = substr( $tmp0 , 2 , length( $tmp0 ) - 2 );
#### }else{
#### $tmp0 = $addr;
#### $tmp0 =~ s/\.//g; #.を抜く
#### $tmp0 = crypt( $tmp0 , "en" );
#### $id = substr( $tmp0 , 2 , length( $tmp0 ) - 2 );
#### }
#### ################################
#### $message = "";
#### $message .= "SHEAD:\n";
#### $message .= "id,$id\n";
#### $message .= "comm,$form{ 'comm' }\n";
#### $message .= "title,$form{ 'title' }\n";
#### $message .= "date,$today $nowtime\n";
#### $message .= "ip,$addr\n";
#### $message .= "host,$host\n";
#### $message .= "name,$form{ 'handle' }\n";
#### $message .= "delpass,$form{ 'delpass' }\n";
#### ### $message .= "tree,$form{ 'treename' }\n";
#### $message .= "EHEAD:\n";
#### $message .= "$form{ 'message' }";
#### ################################
#### print FILE "$message";
#### close( FILE );
####
#### ################################
#### ################################
#### undef @upFile;
#### $subject = "【シストレを語ろう】書き込み";
#### $message .= "\n\n";
#### $message .= "FILE:$fullPath\n";
#### $message .= "\n\n";
#### for ( $ii = 0 ; $ii <= $#toAddress ; $ii++ ){
#### &sendMailEx( $fromAddress , $toAddress[$ii] , $subject , $message , @upFile );
#### }
#### }
#### }
####sub delMessageFile
####{
#### $dataGrup = sprintf( 'd%04d' , $form{ 'g' } + 0 );
#### $dataFile = sprintf( '%s.txt' , $form{ 'target' } );
#### $fullPath = "$datadir/$dataGrup/$dataFile";
#### if ( -e "$fullPath" ){
#### unlink( $fullPath );
#### }
####
#### $maxidx = 0;
#### $dataGrup = sprintf( 'd%04d' , $form{ 'g' } + 0 );
#### $fileDir = "$datadir/$dataGrup/";
#### if ( opendir( DIR , $fileDir )){
#### undef @files;
#### @files = grep { !m/^(\.|\.\.)$/g } readdir( DIR );
####### @files = sort { $a cmp $b } @files; # 古い順
#### @files = sort { $b cmp $a } @files; # 新しい順
#### closedir( DIR );
#### foreach $filename ( @files ) {
#### $maxidx++;
#### }
#### }
#### if ( $maxidx eq 0 ){
#### rmdir( $fileDir );
#### }
####}
##################################################################################
###### use:
###### &stdDraw
##################################################################################
#####sub stdDraw
#####{
##### local( $i , $mflag , $commTmp );
#####
##### ###########################################
##### #### 基本データを読みだす
##### ###########################################
##### $commTmp = "許可";
##### $dataGrup = sprintf( 'd%04d' , $form{ 'g' } + 0 );
##### $dataFile = sprintf( 'd%04d.txt' , 0 );
##### $fullPath = "$datadir/$dataGrup/$dataFile";
##### if ( !( -e $fullPath )){
##### $tmp = $fullPath;
##### $tmp =~ s/\//i/g;
##### $tmp =~ s/\./t/g;
##### print "データがありません。($tmp)
";
##### $form{'mstmode'} = 'on';
##### }else{
##### @messData = &messPaser( $fullPath );
##### $messData{'f_index'} = 0;
##### $messData{'f_target'} = substr( $dataFile , 0 , 5 );
##### $commTmp = $messData{'f_commflag'};
##### ### &xxxTreDraw();
##### &xxxAllDraw();
#####
##### ###########################################
##### #### 基本データ以下10件を表示
##### ###########################################
##### if ( $form{ 'sort' } eq 1 ){
##### for ( $i = $form{ 'f' } + $form{ 'div' } - 1 ; $i >= $form{ 'f' } + 0 ; $i-- ){
##### $dataFile = sprintf( 'd%04d.txt' , $i );
##### $fullPath = "$datadir/$dataGrup/$dataFile";
##### if ( !( -e $fullPath )){
##### next;
##### }
##### @messData = &messPaser( $fullPath );
##### $messData{'f_index'} = $i;
##### $messData{'f_target'} = substr( $dataFile , 0 , 5 );
##### &xxxAllDraw();
##### }
##### }else{
##### for ( $i = $form{ 'f' } + 0 ; $i < $form{ 'f' } + $form{ 'div' } ; $i++ ){
##### $dataFile = sprintf( 'd%04d.txt' , $i );
##### $fullPath = "$datadir/$dataGrup/$dataFile";
##### if ( !( -e $fullPath )){
##### next;
##### }
##### @messData = &messPaser( $fullPath );
##### $messData{'f_index' } = $i;
##### $messData{'f_target'} = substr( $dataFile , 0 , 5 );
##### &xxxAllDraw();
##### }
##### }
##### }
#####
##### ###########################################
##### #### 基本データ削除
##### ###########################################
##### if ( $commTmp eq '許可' ){
##### undef %messData;
##### $step = "input";
##### $mode = "new";
##### &inputDraw();
##### }
#####}
#############################################################################
# use:
# &updDraw
#############################################################################
#####sub updDraw
####{
#### local( $i );
####
#### ###########################################
#### #### 基本データを読みだす
#### ###########################################
#### $dataGrup = sprintf( 'd%04d' , $form{ 'g' } + 0 );
#### $dataFile = sprintf( '%s.txt' , $form{ 'target' } );
#### $fullPath = "$datadir/$dataGrup/$dataFile";
#### if ( !( -e $fullPath )){
#### print "データファイルがありません。$fullPath
";
#### }
#### @messData = &messPaser( $fullPath );
#### $messData{'f_index'} = 0;
#### $messData{'f_target'} = substr( $dataFile , 0 , 5 );
####### &xxxTreDraw();
#### &xxxAllDraw();
#### &inputDraw();
####}
##################################################################################
###### use:
###### &newDraw
##################################################################################
#####sub newDraw
#####{
##### local( $i );
#####
##### ###########################################
##### #### 基本データを読みだす
##### ###########################################
##### &inputDraw();
#####}
#####sub inputDraw
#####{
##### ###########################################
##### ###########################################
##### print "
\n";
##### print "
\n";
#####
##### ###########################################
##### ###########################################
##### if ( $step eq "input" ){
##### $secretid = time;
##### }
##### if ( $step eq "check" ){
##### if ( $form{'mstmode'} ne 'on' && $form{'delpass'} eq $masterPass ){
##### $form{'delpass'} = $messData{'f_delpass'};
##### $masterFlag = 1;
##### }
##### $secretid = $form{'sid'};
##### ( $result0 , $result1 ) = checkInput();
##### if ( $result1 ){
##### &addNGUserFile();
##### }
##### if ( $result0 ){
##### $secretid = time;
##### $step = "error";
##### }
##### }
##### if ( $step eq "exect" ){
##### $secretid = $form{'sid'};
##### ( $result0 , $result1 ) = checkInput();
##### if ( $result1 ){
##### &addNGUserFile();
##### }
##### if ( $result0 ){
##### $secretid = time;
##### $step = "error";
##### }else{
##### if ( $form{'mmode'} eq '訂正' ){
##### &updMessageFile();
##### }
##### if ( $form{'mmode'} eq '削除' ){
##### &delMessageFile();
##### }
##### if ( $form{'mmode'} eq '新規' ){
##### &newMessageFile();
##### }
##### }
##### }
#####
####### $secretcd = &getSecretId( $secretid );
####### $mode = "upd";
####### $step = "input";
####### $step = "check";
####### $step = "exec";
#####
##### ###########################################
##### ###########################################
##### if ( $mode eq 'upd' && $step eq "input" ){
##### $form{ 'm_comm' } = $messData{'f_comm'};
##### $form{ 'm_handle' } = $messData{'f_handle'};
##### $form{ 'm_title' } = $messData{'f_title'};
##### $form{ 'm_input'} = $messData{'f_message'};
##### $form{ 'm_input'} =~ s/
/\r\n/g; #改行を変換
##### }
##### if ( $form{'mstmode'} eq 'on' && $step eq "input" ){
##### $form{ 'handle' } = $masterName;
##### }
#####
##### ###########################################
##### ### ヘッダ
##### ###########################################
##### print "\n";
##### }else{
##### print "\n";
##### }
#####}
sub getSecretId
{
local( $base ) = @_;
local( $i , $tmp , $len , $data );
$len = length( $base );
for ( $i = 0 ; $i < $len ; $i++ ){
$tmp[ $len - $i - 1 ] = substr( $base , $i , 1 ) + 0;
}
### for ( $i = 0 ; $i <= $#tmp ; $i++ ){
### print "$i -> $tmp[$i]
";
### }
$tmp[ 2 ] = (( $tmp[ 2 ] + $tmp[ 0 ] + 1 ) % 10 ) * 10000;
$tmp[ 4 ] = (( $tmp[ 4 ] + $tmp[ 0 ] + 2 ) % 10 ) * 1000;
$tmp[ 5 ] = (( $tmp[ 5 ] + $tmp[ 0 ] + 3 ) % 10 ) * 100;
$tmp[ 3 ] = (( $tmp[ 3 ] + $tmp[ 0 ] + 4 ) % 10 ) * 10;
$tmp[ 1 ] = (( $tmp[ 1 ] + $tmp[ 0 ] + 5 ) % 10 ) * 1;
$data = $tmp[ 1 ] + $tmp[ 3 ] + $tmp[ 5 ] + $tmp[ 4 ] + $tmp[ 2 ];
return $data;
}
sub xxxTreDraw
{
### print "\n";
### print "\n";
### print "";
### print "$messData{'tree'}";
### print " | \n";
### print "
\n";
### print "
\n";
### print "
\n";
}
sub xxxAllDraw
{
local( $i , $j , $line );
###########################################
### ヘッダ
###########################################
print "\n";
if ( $mode eq "std" ){
print "";
}
print "
\n";
}
#############################################################################
# 確認ファイルにデータを追加
# use:
# &addFile();
#############################################################################
sub addFile
{
local( $addFileName ) = @_;
if ( !( -e "$addFileName" )){ # ファイルが無い場合は新規で作成する
open( FILE , ">$addFileName" );
close( FILE );
chmod( 0600 , "$addFileName" );
}
if ( open( FILE , ">>$addFileName" )){ # 追加モードで開く
#######################
#今回のデータを追加
print FILE "$today,"; # 0:日付
print FILE "$nowtime,"; # 1:時間
print FILE "$host,"; # 2:ドメイン
print FILE "$addr,"; # 3:IP
$data = $form{'a'};
$data =~ s/\,/,/g;
print FILE "$data,"; # 4:アフェリエイト番号
$data = $ENV{'REQUEST_URI'};
$data =~ s/\,/,/g;
print FILE "$data,"; # 5:どんな指示できたのか?
$data = $ENV{'HTTP_REFERER'};
$data =~ s/\,/,/g;
print FILE "$data,"; # 6:どこから来たのか?
$data = $ENV{'HTTP_COOKIE'};
$data =~ s/\,/,/g;
print FILE "$data,"; # 7:クッキー
print FILE "\n"; # 改行
close( FILE );
}
}
#############################################################################
# ユーザーへのメール送信
# use:
# &hostMail
#############################################################################
sub hostMail
{
local( $ii );
#############################
# 管理者に送るメール
#############################
undef @upFile;
$subject = "【語ろう】アクセスログ削除連絡 − メイン";
$message = "";
$message .= "■アクセス者\n";
$message .= "$host $addr\n\n";
$message .= "■日時\n";
$message .= "$today $nowtime\n\n";
$message .= "━━━━━━━━\n";
$message .= "このメールはシステムより自動配信されています。\n";
$message .= "このメールへの返信は絶対に行わないで下さい。\n";
$message .= "\n\n";
$upFile[0] = $visitorFile;
for ( $ii = 0 ; $ii <= $#toAddress ; $ii++ ){
&sendMailEx( $fromAddress , $toAddress[$ii] , $subject , $message , @upFile );
}
}
#############################################################################
# use:
# &sendMailEx();
#############################################################################
sub sendMailEx
{
local( $fromAddress , $toAddr , $subject , $message , @upFile ) = @_;
local( $i , $header , $body );
$bound = time; # 適当な文字列
undef @base64Data;
for ( $i = 0 ; $i <= $#upFile ; $i++ ){
if ( open( TMPFILE , "<$upFile[$i]" )){
$sdata = join('',);
close( TMPFILE );
$base64Data[$i] = &bodyencode($sdata, "b64");
$base64Data[$i] .= &benflush("b64");
}
@datas = split(/\//,$upFile[$i]);
$upFile[$i] = $datas[ $#datas ];
$upFile[$i] =~ tr/A-Z/a-z/;
}
###########################
$header = "";
## $header .= "FormMailer: FormMail\n";
$header .= "Return-Path: $fromAddress\n";
$header .= "To: $toAddr\n";
$header .= "From: $fromAddress\n";
$header .= "Subject: $subject\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=\"$bound\"\n";
$body = "";
$body .= "--$bound\n";
$body .= "Content-Type: text/plain; charset=\"iso-2022-jp\"\n";
$body .= "Content-Transfer-Encoding: 7bit\n\n";
$body .= "$message\n";
$body .= "\n";
for ( $i = 0 ; $i <= $#upFile ; $i++ ){
$body .= "--$bound\n";
$body .= "Content-Type: application/octet-stream; name=\"$upFile[$i]\"\n";
$body .= "Content-Transfer-Encoding: base64\n";
$body .= "Content-Disposition: attachment; filename=\"$upFile[$i]\"\n";
$body .= "\n";
$body .= "$base64Data[$i]\n";
$body .= "\n";
}
$body .= "--$bound--\n\n\n";
&jcode::convert(*header,'jis');
&jcode::convert(*body,'jis');
$header .= "Content-length: " . length($body) . "\n\n";
if ( $ENV{ 'HTTP_HOST' } ne 'localhost' ){
if ( !open( MAIL , "| $sendmail -t")){
goto sendMailEx_end;
}
print MAIL "$header\n$body";
close(MAIL);
}else{
if ( !open( MAIL , "|C:/bin/sendmail -t")){
goto sendMailEx_end;
}
print MAIL "From: $fromAddress\n";
print MAIL "To: $toAddr\n";
print MAIL "Subject: $subject\n\n";
print MAIL "$message\n";
for ( $i = 0 ; $i <= $#upFile ; $i++ ){
print MAIL "$upFile[$i]\n";
}
print MAIL "\n\n";
close(MAIL);
}
return 1;
sendMailEx_end:
print "<$fonttype $fontstyleE>メール送信に失敗しました$fonttype>\n";
return 0;
}
#############################################################################
# ファイルの解体汎用
# use:
# &messPaser()
#############################################################################
sub messPaser
{
local ( $fullPath ) = @_;
local( $upFlag , $sFlag , $dFlag , $tagFlag , $nouFlag , $i );
undef %messData;
@dataList = &filePaser( $fullPath );
$upFlag = $tagFlag = $sFlag = $dFlag = 0;
for ( $i = 0 ; $i <= $#dataList ; $i++ ){
######123456
if ( 'SHEAD:' eq substr( $dataList[$i] , 0 , 6 )){
$sFlag = 1;
next;
}
######123456
if ( 'EHEAD:' eq substr( $dataList[$i] , 0 , 6 )){
$sFlag = 0;
$dFlag = 1;
$tagFlag = 0;
next;
}
$nouFlag = 0;
######1234567890
if ( '' eq substr( $dataList[$i] , 0 , 8 )){
if ( $upFlag eq 1 ){
$upFlag = 0;
}else{
$upFlag = 1;
}
}
######12345678
if ( '' eq substr( $dataList[$i] , 0 , 8 )){
$tagFlag = 0;
$nouFlag = 1;
}
######1234567
if ( '' eq substr( $dataList[$i] , 0 , 7 )){
$tagFlag = 1;
$nouFlag = 1;
}
if ( $sFlag eq 1 ){
( $label , $data ) = split( /,/ , $dataList[$i] );
$messData{ $label } = $data;
}
if ( $dFlag eq 1 ){
$messData{'f_input'} .= "$dataList[$i]";
####
if ( $upFlag eq 0 ){
$tmp = $dataList[$i];
$tmp =~ s/str.toresume.com/www.torezista.com/g; #特殊コードを変更する 2012/09/12
if ( $nouFlag eq 1 ){
$tmp =~ s///g; #特殊コードを変更する
$tmp =~ s///g; #特殊コードを変更する
}
if ( $tagFlag eq 0 ){
$tmp =~ s/>/>\;/g;
}
$messData{'f_message'} .= $tmp;
if ( $tagFlag eq 0 ){
$messData{'f_message'} .= "
";
}
}
}
}
return %messData;
}
sub getMessTimeId
{
local ( $fullPath ) = @_;
local( $i , $label , $data , $fdate , $fid );
$fdate = "$today $nowtime";
$fid = "";
@dataList = &filePaser( $fullPath );
for ( $i = 0 ; $i <= $#dataList ; $i++ ){
######123456
if ( 'SHEAD:' eq substr( $dataList[$i] , 0 , 6 )){
next;
}
######123456
if ( 'EHEAD:' eq substr( $dataList[$i] , 0 , 6 )){
last;
}
( $label , $data ) = split( /,/ , $dataList[$i] );
if ( $label eq 'f_date' ){
$fdate = $data;
}
if ( $label eq 'f_id' ){
$fid = $data;
}
}
return( $fdate , $fid );
}
#############################################################################
# ファイルの解体汎用
# use:
# &filePaser();
#############################################################################
sub filePaser
{
local( $filename ) = @_;
local( $i );
undef @tmpdata;
if ( open( TMPFILE , "<$filename" )){
@tmpdata = ;
close( TMPFILE );
for ( $i = 0 ; $i <= $#tmpdata ; $i++ ){
$tmpdata[$i] =~ s/\n//g; #改行を抜く
}
}
return @tmpdata;
}
#############################################################################
# 漢字コード処理
# use:
# &setContentType( 'sjis' );
#############################################################################
sub setContentType
{
local( $code ) = @_;
####漢字コードをあわせる
if ( $code eq 'sjis' ){
print "Content-type: text/html; charset=shift_jis\n\n";
}elsif ( $code eq 'euc' ){
print "Content-type: text/html; charset=euc-jp\n\n";
} elsif ( $code eq 'jis' ){
print "Content-type: text/html; charset=iso-2022-jp\n\n";
}
}
#############################################################################
# フォームからの情報を連想配列 %form に入れる
# &initForm('euc');
#############################################################################
sub initForm
{
local($query, @assocarray, $assoc, $property, $value, $charcode, $method);
$charcode = $_[0];
$method = $ENV{'REQUEST_METHOD'};
$method =~ tr/A-Z/a-z/;
if ($method eq 'post') {
read(STDIN, $query, $ENV{'CONTENT_LENGTH'});
} else {
### 「GET」はセキュリティの為非対応にする
$query = $ENV{'QUERY_STRING'};
}
@assocarray = split(/&/, $query);
foreach $assoc (@assocarray) {
($property, $value) = split(/=/, $assoc);
if ( $property ne 'ls' ){ ## しかし ls の場合は+を使いたいのでspaceは困る
$value =~ tr/+/ /; ## 文章入力時に必要になるのではずせない…
}
$value =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("C", hex($1))/eg;
&jcode'convert(*value, $charcode);
$form{$property} = $value;
}
}
#############################################################################
# 時間を得る
# use:
# ( $today , $nowtime , $weekstr ) = &getLocalTime();
#############################################################################
sub getLocalTime
{
local( @week ) = ( "日" , "月" , "火" , "水" , "木" , "金" , "土" );
local( $sec , $min , $hour , $day , $mon , $year , $weekday );
$ENV{'TZ'} = "JST-9";
( $sec , $min , $hour , $day , $mon , $year , $weekday ) = localtime( time );
$mon++;
$year += 1900;
if ( $mon <= 9 ){
$mon = "0$mon";
}
if ( $day <= 9 ){
$day = "0$day";
}
if ( $hour <= 9 ){
$hour = "0$hour";
}
if ( $min <= 9 ){
$min = "0$min";
}
return( "$year.$mon.$day" , "$hour:$min" , $week[ $weekday ] );
}
#############################################################################
# ヘッダ表示
# use:
# &getBrowser();
#############################################################################
sub getBrowser
{
local( $agent2 , $agent , $group );
$agent2 = $agent = $ENV{'HTTP_USER_AGENT'};
if ($agent =~ /AOL/) { $group = '' ; $agent = 'AOL'; }
elsif ($agent =~ /Opera/i) { $group = '' ; $agent = 'Opera'; }
elsif ($agent =~ /MSIE 3/i) { $group = 'IE' ; $agent = 'MSIE3'; }
elsif ($agent =~ /MSIE 4/i) { $group = 'IE' ; $agent = 'MSIE4'; }
elsif ($agent =~ /MSIE 5/i) { $group = 'IE' ; $agent = 'MSIE5'; }
elsif ($agent =~ /MSIE 6/i) { $group = 'IE' ; $agent = 'MSIE6'; }
elsif ($agent =~ /MSIE 7/i) { $group = 'IE' ; $agent = 'MSIE7'; }
elsif ($agent =~ /MSIE 8/i) { $group = 'IE' ; $agent = 'MSIE8'; }
elsif ($agent =~ /Chrome\/5/i) { $group = 'CH' ; $agent = 'Chrome'; }
elsif ($agent =~ /Mozilla\/2/i) { $group = 'NS' ; $agent = 'Netscape 2'; }
elsif ($agent =~ /Mozilla\/3/i) { $group = 'NS' ; $agent = 'Netscape 3'; }
elsif ($agent =~ /Mozilla\/4/i) { $group = 'NS' ; $agent = 'Netscape 4'; }
elsif ($agent =~ /Netscape ?6/i) { $group = 'NS' ; $agent = 'Netscape 6'; }
elsif ($agent =~ /Netscape\/7/i) { $group = 'NS' ; $agent = 'Netscape 7'; }
elsif ($agent =~ /Netscape\/8/i) { $group = 'NS' ; $agent = 'Netscape 8'; }
elsif ($agent =~ /Mozilla\/5/i) { $group = 'FX' ; $agent = 'Mozilla'; }
elsif ($agent =~ /Netscape/i && $agent =~ /Gecko/i) { $group = '' ; $agent = 'Mozilla'; }
elsif ($agent =~ /Lynx/i) { $group = '' ; $agent = 'Lynx'; }
elsif ($agent =~ /Cuam/i) { $group = '' ; $agent = 'Cuam'; }
elsif ($agent =~ /Ninja/i) { $group = '' ; $agent = 'Ninja'; }
elsif ($agent =~ /WWWC/i) { $group = '' ; $agent = 'WWWC'; }
elsif ($agent =~ /DoCoMo/i) { $group = '' ; $agent = 'DoCoMo'; }
elsif ($agent =~ /J-PHONE/i) { $group = '' ; $agent = 'J-PHONE'; }
elsif ($agent =~ /UP\.Browser/i) { $group = '' ; $agent = 'EZweb'; }
elsif ($agent =~ /L\-mode/i) { $group = '' ; $agent = 'L-mode'; }
elsif ($agent =~ /ASTEL/i) { $group = '' ; $agent = 'ASTEL'; }
elsif ($agent =~ /PDXGW/i) { $group = '' ; $agent = 'H"'; }
return( $group , $agent );
}
#############################################################################
# ホスト名を得る
# use:
# ( $host , $addr ) = &host( $ENV{'REMOTE_HOST'} , $ENV{'REMOTE_ADDR'} );
#############################################################################
sub getHost
{
local( $host , $addr ) = @_;
if ($host eq "" || $host eq $addr) {
$host = gethostbyaddr(pack("C4",split(/\./,$addr)),2) || $addr;
}
if ($host =~ /(.*)\.(\d+)$/) { ; }
elsif ($host =~ /(.*)\.(.*)\.(.*)\.(.*)$/) { $host = "\*\.$2\.$3\.$4"; }
elsif ($host =~ /(.*)\.(.*)\.(.*)$/) { $host = "\*\.$2\.$3"; }
return( $host , $addr );
}
#############################################################################
# カンマ編集
#############################################################################
sub kanma
{
local( $subdt ) = @_;
local( $b , $i , $c , $j );
@b = split(//,$subdt);
$i=@b;
$i--;
$c=0;
$subdt="";
for ($j=$i ;$j>=0;$j--) {
$c++;
$subdt=$b[$j].$subdt;
if ($c ==3 && $j>0) {
$subdt=",$subdt";$c=0
}
} # end of for
return $subdt;
} # end of sub
#############################################################################
# x日経過するといつになるか
# use:
# ( $dyear , $dmonth , $dday ) = &addDay( 2005 , 4 , 16 , 4 )
#############################################################################
sub addDay
{
local( $year , $month , $day , $x ) = @_;
local( $max , $i );
local( $dyear , $dmonth , $dday );
$dyear = $year;
$dmonth = $month;
$dday = $day;
for ( $i = 0 ; $i < $x ; $i++ ){
$max = &getMaxMonth( $dyear , $dmonth );
if (( $dday + 1 ) > $max ){
$dday = 1;
$dmonth += 1;
if ( $dmonth eq 13 ){
$dmonth = 1;
$dyear += 1;
}
}else{
$dday++;
}
}
return( $dyear , $dmonth , $dday );
}
#############################################################################
# その月の日数
# use:
# &getMaxMonth( 2005 , 4 );
#############################################################################
sub getMaxMonth
{
local( $year , $month ) = @_;
local(@damy) = (
"0","31","28","31","30","31","30","31","31","30","31","30","31"
);
if ( &IsUruu( $year ) eq 1 && $month eq 2 ){
return 29;
}
return $damy[$month];
}
#############################################################################
# 閏年かどうかの判定 < 閏年 return 1 その他 return 0 >
# use:
# &IsUruu( 2005 );
#############################################################################
sub IsUruu
{
local( $year ) = @_;
local( $flag );
$flag = 0;
if (( $year % 4 ) == 0 ){
$flag = 1
}
if (( $year % 100 ) == 0 ){
$flag = 0;
}
if (( $year % 400 ) == 0 ){
$flag = 1;
}
return $flag;
}
#############################################################################
# x分経過すると何時になるか
# use:
# ( $addday , $hour , $minute ) = &addMinute( 23 , 16 , 45 )
#############################################################################
sub addMinute
{
local( $hour , $minute , $x ) = @_;
local( $addday );
$addday = 0;
$minute += $x;
if ( $minute >= 60 ){
$hour = $hour + int( $minute / 60 );
$minute = $minute % 60;
if ( $hour >= 24 ){
$addday = int( $hour / 24 );
$hour = $hour % 24;
}
}
return( $addday , $hour , $minute );
}
#############################################################################
# 排他制御 解除
# use:
# &lockExecute( ファイル名 );
#############################################################################
sub lockExecute
{
local( $filename ) = @_;
if ( $lockuse eq 1 ){
if ( open( LOCKFILE, ">$filename")){ # 新規で作成
flock( LOCKFILE , 2 );
print LOCKFILE "lock!";
$locksts = 1;
}
}
}
#############################################################################
# 排他制御 解除
# use:
# &unlockExecute();
#############################################################################
sub unlockExecute
{
if ( $lockuse eq 1 ){
if ( $locksts eq 1 ){
close( LOCKFILE );
flock( LOCKFILE , 8 );
$locksts = 0;
}
}
}
#############################################################################
# use:
# &getHtmlStyle();
#############################################################################
sub getHtmlStyle
{
local( $mes ) = @_;
$mes =~ s/\"/"/g;
$mes =~ s/<\;/g;
$mes =~ s/>/>\;/g;
$mes =~ s/\r\n/
/g; #改行を抜く
$mes =~ s/\n/
/g; #改行を抜く
$mes =~ s/a;/
/g; #改行を抜く
return $mes;
}
#############################################################################
# use:
# &getFileStyle();
#############################################################################
sub getFileStyle
{
local( $mes ) = @_;
$mes =~ s/<\;//g;
$mes =~ s/"/\"/g;
$mes =~ s/\r\n/\n/g; #改行を抜く
$mes =~ s/a;/\n/g; #改行を抜く
return $mes;
}
#############################################################################
# use:
# &getInputStyle();
#############################################################################
sub getInputStyle
{
local( $mes ) = @_;
$mes =~ s/<\;//g;
$mes =~ s/"/\"/g;
$mes =~ s/\r\n/\n/g; #改行を抜く
$mes =~ s/a;/\n/g; #改行を抜く
return $mes;
}
#############################################################################
# use:
# &getHiddenStyle();
#############################################################################
sub getHiddenStyle
{
local( $mes ) = @_;
$mes =~ s/<\;/g;
$mes =~ s/>/>\;/g;
$mes =~ s/\"/"/g;
$mes =~ s/\r\n/\n/g; #改行を抜く
## $mes =~ s/\r\n/a;/g; #改行を抜く
## $mes =~ s/\n/a;/g; #改行を抜く
return $mes;
}
#############################################################################
# クッキーの発行
# use:
# &setCookie()
#############################################################################
sub setCookie
{
local( $cookstring ) = @_;
($secg,$ming,$hourg,$mdayg,$mong,$yearg,$wdayg,$ydayg,$isdstg) = gmtime(time + 30*24*60*60);
$yearg += 1900;
if($secg < 10){$secg = "0$secg";}
if($ming < 10){$ming = "0$ming";}
if($hourg < 10){$hourg = "0$hourg";}
if($mdayg < 10){$mdayg = "0$mdayg";}
$month = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$mong];
$youbi = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')[$wdayg];
$date_gmt = "$youbi, $mdayg\-$month\-$yearg $hourg:$ming:$secg GMT";
### $date_gmt = "expires=Tue, 1-Jan-2030 00:00:00 GMT";
print "Set-Cookie: $systemname=$cookstring; expires=$date_gmt;\n";
}
sub delCookie
{
print "Set-Cookie: $systemname=\"\"; expires=Thu, 1-Jan-1970 00:00:00 GMT;\n";
}
#############################################################################
# クッキーの取得
# use:
# &getCookie()
#############################################################################
####sub getCookie
####{
#### local( $tmp , $i , $name , $value );
#### $cookies = $ENV{'HTTP_COOKIE'};
#### @pairs = split(/;/,$cookies);
#### foreach $pair (@pairs){
#### ($name, $value) = split(/=/, $pair);
#### $name =~ s/ //g;
#### $DUMMY{ $name } = $value;
#### ### print "$name<----->$value
";
#### }
#### @pairs = split(/,/,$DUMMY{ $systemname });
#### for ( $i = 0 ; $i <= $#pairs ; $i+=2 ){
#### $name = $pairs[ $i + 0 ];
#### $value = $pairs[ $i + 1 ];
#### $COOKIE{ $name } = $value;
#### }
####}
sub getCookie
{
local( $tmp , $i , $name , $value );
$cookies = $ENV{'HTTP_COOKIE'};
undef %DUMMY;
@pairs = split(/;/,$cookies);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$name =~ s/ //g;
if ( defined( $DUMMY{ $name } )){
### print "OFF:$name<----->$value
";
}else{
$DUMMY{ $name } = $value;
### print "SET:$name<----->$value
";
}
}
@pairs = split(/,/,$DUMMY{ $systemname });
for ( $i = 0 ; $i <= $#pairs ; $i+=2 ){
$name = $pairs[ $i + 0 ];
$value = $pairs[ $i + 1 ];
$COOKIE{ $name } = $value;
}
}
sub addHandleFile
{
local( $handleName , $delPass , $outId ) = @_;
local( $updFlag , $i , $delFlag );
if ( !( -e "$handlefile" )){ # ファイルが無い場合は新規で作成する
open( FILE , ">$handlefile" );
close( FILE );
chmod( 0600 , "$handlefile" );
}
if ( open( FILE , "<$handlefile" )){
@filedata = ;
close( FILE );
if ( open( FILE , ">$handlefile" )){
$updFlag = 0;
for ( $i = 0 ; $i <= $#filedata ; $i++ ){
$filedata[$i] =~ s/\r//g; #改行を抜く
$filedata[$i] =~ s/\n//g; #改行を抜く
( $date0 , $hname , $hpass , $hid ) = split(/,/, $filedata[ $i ] );
##############################
## 日付を調べる
##############################
( $yyy , $mmm , $ddd ) = &addDay( substr( $date0 , 0 , 4 ) , substr( $date0 , 5 , 2 ) , substr( $date0 , 8 , 2 ) , 90 );
$date0 = sprintf( '%04d.%02d.%02d', $yyy , $mmm , $ddd );
$delFlag = 0;
if ( $date0 lt $today ){ ## $date0 < $today
if ( $hpass eq $masterPass ){
}elsif ( $hpass eq $masterPass2 ){
}else{
$delFlag = 1;
}
}elsif ( $date0 gt $today ){ ## $date0 > $today
}else{ ## $date0 == $today
}
if ( $delFlag eq 1 ){
## 更新しない
}else{
if ( $hname eq $handleName && $hpass eq $delPass ){
print FILE "$today,$handleName,$delPass,$outId\n";
$updFlag = 1;
}else{
print FILE "$filedata[$i]\n"; # そのまま書き戻す
}
}
}
if ( $updFlag eq 0 ){
print FILE "$today,$handleName,$delPass,$outId\n";
}
close( FILE );
}
}
}
sub useHandleFile
{
local( $handleName , $delPass ) = @_;
local( $i );
if ( open( FILE , "<$handlefile" )){
@filedata = ;
close( FILE );
for ( $i = 0 ; $i <= $#filedata ; $i++ ){
$filedata[$i] =~ s/\r//g; #改行を抜く
$filedata[$i] =~ s/\n//g; #改行を抜く
( $date0 , $hname , $hpass , $hid ) = split(/,/, $filedata[ $i ] );
if ( $hname eq $handleName && $hpass ne $delPass ){
#################################
## 既に誰かが使用している
#################################
return 1; ## 使用できないハンドル名
}
}
}
return 0;
}
sub getHandle2OutId
{
local( $handleName , $delPass ) = @_;
local( $i );
if ( open( FILE , "<$handlefile" )){
@filedata = ;
close( FILE );
for ( $i = 0 ; $i <= $#filedata ; $i++ ){
$filedata[$i] =~ s/\r//g; #改行を抜く
$filedata[$i] =~ s/\n//g; #改行を抜く
( $date0 , $hname , $hpass , $hid ) = split(/,/, $filedata[ $i ] );
if ( $hname eq $handleName && $hpass eq $delPass ){
#################################
## 既に誰かが使用している
#################################
return $hid;
}
}
}
return 0;
}
sub newupdDraw
{
local( $i , $updcount );
####
print <<"_HTML_";
|
|
さあ、現在の株ランキングは何位? 「株システムトレードを語ろう!」は、株ランキングに参加中です! |
|
|
本サイトは、特定商品を薦めたり、購入に誘導しようとする疑いのある投稿を禁止しています。
例としては、以下のようなケースが該当しますのでご注意ください。
少しでも特定商品に誘導していると感じた場合は、管理人権限で投稿を訂正/削除させていただきます。
・ Aは悪い、Bは良い、だからBをお勧め
・ Aは悪い、Bは良い、だからBが無難
・ Aは悪い、Bは良い、だからAはやめた方がよい
投稿する場合は、特定商品に誘導しない形で投稿してください。
例としては、以下のような内容でお願いします。
・ Aは悪い
・ Bは良い
Aを語る場でBを推薦する行為、Aを語る場でBを非難する行為は、特定商品に誘導していると判断します。
Aの話題はAの語り場で、Bの話題はBの語り場で、それぞれ別々に行ってください。
|
|
_HTML_
$updcount = 0;
if ( open( FILE , "<$newupdfile" )){
@filedata = ;
close( FILE );
for ( $i = $#filedata ; $i > -1 ; $i-- ){
$filedata[$i] =~ s/\r//g; #改行を抜く
$filedata[$i] =~ s/\n//g; #改行を抜く
( $date0 , $time0 , $sp_frame , $sp_newflag , $sp_groupNO , $sp_treeNO , $sp_messNO ) = split(/,/, $filedata[ $i ] );
############
$dataGrop = sprintf( 'g%04d' , $sp_groupNO );
$dataFile = sprintf( 'g%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataFile";
@messData = &messPaser( $fullPath );
$grpTitle = $messData{ 'f_title' };
############
if ( $sp_frame eq 'grop' ){
$dataGrop = sprintf( 'g%04d' , $sp_groupNO );
$dataFile = sprintf( 'g%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataFile";
$tmpURL = "$thiscgi?t_grp=$sp_groupNO";
}
if ( $sp_frame eq 'tree' ){
$dataGrop = sprintf( 'g%04d' , $sp_groupNO );
$dataTree = sprintf( 't%04d' , $sp_treeNO );
$dataFile = sprintf( 'm%04d.txt' , 0 );
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
$tmpURL = "$thiscgi?t_dep=1&t_grp=$sp_groupNO&t_tre=$sp_treeNO";
}
if ( $sp_frame eq 'mess' ){
$dataGrop = sprintf( 'g%04d' , $sp_groupNO );
$dataTree = sprintf( 't%04d' , $sp_treeNO );
### $dataFile = sprintf( 'm%04d.txt' , $sp_messNO );
$dataFile = sprintf( 'm%04d.txt' , 0 ); ## Treeを紹介する
$fullPath = "$datadir/$dataGrop/$dataTree/$dataFile";
$tmpURL = "$thiscgi?t_dep=1&t_grp=$sp_groupNO&t_tre=$sp_treeNO";
### $tmpURL = "$thiscgi?t_dep=1&t_grp=$sp_groupNO&t_tre=$sp_treeNO#idx$sp_messNO";
}
if ( !( -e "$fullPath" )){
next;
}
@messData = &messPaser( $fullPath );
####
print " | ";
print "";
print "$date0 $time0 | ";
print "";
if ( $sp_frame eq 'grop' ){
if ( $sp_newflag eq 'new' ){
$tmp = "作成";
}elsif ( $sp_newflag eq 'old' ){
$tmp = "変更";
}else{
}
}elsif ( $sp_frame eq 'tree' ){
if ( $sp_newflag eq 'new' ){
$tmp = "新規";
}elsif ( $sp_newflag eq 'old' ){
$tmp = "変更";
}else{
}
}elsif ( $sp_frame eq 'mess' ){
if ( $sp_newflag eq 'new' ){
$tmp = "投稿";
}elsif ( $sp_newflag eq 'old' ){
$tmp = "変更";
}else{
}
}
print "$tmp | ";
print "";
print "$grpTitle > $messData{ 'f_title' }";
print " | ";
print "
";
$updcount++;
}
}
if ( $updcount eq 0 ){
print " | ";
print "";
print "なし | ";
print "";
print " | ";
print "";
print " | ";
print "
";
}
print <<"_HTML_";
|
_HTML_
}
sub addNewUpdFile
{
local( $frame , $newflag , $groupNO , $treeNO , $messNO , $setTime ) = @_;
local( $updFlag , $i , $delFlag );
if ( $COOKIE{ 'master' } eq "on" && $form{'m_delpass'} ne $masterPass && $newflag eq 'old' ){
return 0;
}
if ( $frame eq 'grop' ){
return 0;
}
if ( !( -e "$newupdfile" )){ # ファイルが無い場合は新規で作成する
open( FILE , ">$newupdfile" );
close( FILE );
chmod( 0600 , "$newupdfile" );
}
if ( open( FILE , "<$newupdfile" )){
@filedata = ;
close( FILE );
if ( open( FILE , ">$newupdfile" )){
$updFlag = 0;
for ( $i = 0 ; $i <= $#filedata ; $i++ ){
$filedata[$i] =~ s/\r//g; #改行を抜く
$filedata[$i] =~ s/\n//g; #改行を抜く
( $date0 , $time0 , $sp_frame , $sp_newflag , $sp_groupNO , $sp_treeNO , $sp_messNO ) = split(/,/, $filedata[ $i ] );
##############################
## 日付を調べる
##############################
( $yyy , $mmm , $ddd ) = &addDay( substr( $date0 , 0 , 4 ) , substr( $date0 , 5 , 2 ) , substr( $date0 , 8 , 2 ) , 90 );
$date0 = sprintf( '%04d.%02d.%02d', $yyy , $mmm , $ddd );
$delFlag = 0;
if ( $#filedata < 30 ){
}else{
if ( $date0 lt $today ){ ## $date0 < $today
$delFlag = 1;
}elsif ( $date0 gt $today ){ ## $date0 > $today
}else{ ## $date0 == $today
}
}
if ( $delFlag eq 1 ){
## 削除
}elsif (
## $frame eq $sp_frame &&
## $newflag eq $sp_newflag &&
$groupNO eq $sp_groupNO &&
$treeNO eq $sp_treeNO ){
## $messNO eq $sp_messNO ){
## 削除
}else{
print FILE "$filedata[$i]\n"; # そのまま書き戻す
}
}
if ( $updFlag eq 0 ){
if ( $setTime ne '' ){
### 0123456789012345
### 2010.04.13 10:02
$tmp00 = substr( $setTime , 0 , 10 );
$tmp01 = substr( $setTime , 11 , 5 );
print FILE "$tmp00,$tmp01,$frame,$newflag,$groupNO,$treeNO,$messNO\n";
}else{
print FILE "$today,$nowtime,$frame,$newflag,$groupNO,$treeNO,$messNO\n";
}
}
close( FILE );
}
}
}