#!/usr/bin/perl # # 日記CGI # # 版本定義 $Ver="2004/09/27c"; $www="."; $cgipath="./index.cgi"; $vDir="."; sub InitialNicky { # 最新X日數之顯示 $PrintDay=5; $PageCnt=5; # 最新X日數之顯示(iMODE) $PrintiDay=1; $PageiCnt=3; # 顯示順序キ # Exp:依日期 $Age="r" # 依寫入時間 $Age="t" $Age="r"; # 顯示日記時的畫面寬度 $NickyWidth="80%"; $NickyLineWidth="1"; $NickyLineSpan="12"; # 年月日顯示 $Year='年'; $Month='月'; $Day='日'; # 星期之顯示 $WEEK=0; # 日記內文顯示 $HonbunColor="#000000"; $HonbunSize="2"; # 日記內文背景色 $HonbunBgColor="#ffffff"; # 日記標題背景色 $TitleBgColor="#4386b1"; # 標題高度 $TSize="12"; # 標題前方追加之文字 $TitleHead="■"; # 輸出連結用標籤 $LinkTH="No"; # 日期顏色 $DateFontColor="#FFFFFF"; # 日期字形大小 $DateSize="2"; # 日記標題文字色 $TitleFontColor="#CCEDFF"; # 日記標題字形大小 $TitleSize="2"; # 強調內文之文字與顏色 $EffectSTR1="#"; $EffectSTR2=">"; $EffectSTR3="("; $EffectSTR4="#"; $EffectCOL1="#FF0000"; $EffectCOL2="#00FF00"; $EffectCOL3="#0000FF"; $EffectCOL4="#00FFFF"; $LinkOpen="No"; $Fit_size=200; $Fit="OFF"; # 意見欄預設高度 $CommentRecv="1"; $CommentSTRlen="1024"; $CMNT_NameWidth="10"; $CommentMessageWidth="50"; $CommentStrSize="2 color=#000000"; $CMNT_NameStrSize="2 color=#000000"; # 意見欄背景色 $CommentBgColor="#F1F5FA"; # 意見欄姓名顏色 $CMNT_NameColor="#975580"; # 意見欄姓名字形大小 $CMNT_NameSize="2"; # 意見欄內文顏色 $CommentFontColor="#3A75AF"; # 意見欄內文字形大小 $CommentFontSize="2"; # 意見欄文字列 $CommentStr="回應及感想"; # 意見欄邊框顏色 $CommentFlColor="#C5D6EB"; # URL自動加入超連結 #$UrlLink="Yes"; # 時間顯示 $PutTimeDefault="Yes"; # 過去記錄用字 $MsgNew="<< NEW"; $MsgOld="OLD >>"; $MsgOldLog="過去記錄"; $MsgOldNEWks="["; $MsgOldNEW="最新"; $MsgOldNEWke="]"; $MsgOldOLDks="["; $MsgOldOLD="最舊"; $MsgOldOLDke="]"; $MsgOldOBgCol="#FFFFFF"; $MsgOldBetween="TitleList"; $MsgOldCol="#000000"; $MsgOldSize="2"; $MsgOldYBgCol="#FFFFFF"; $MsgOldYFnCol="#000000"; $MsgOldMBgCol="#FFFFFF"; $MsgOldYear="年"; $MsgOldMonth="月"; $MsgOldForm="0"; $MsgOld1st="0"; $MsgOldcelp="0"; $MsgOldcels="0"; $MonthSort="UP"; $SaveHTML="ON"; $LogFname="nicky"; $ks="["; $ke="]"; $MsgPageOut=1; #繪圖板JavaApplet $image_width=300; $image_height=300; $ReplaySTR="Replay"; $ContinueSTR="Continue"; $undoNum=60; $layerNum=5; $Quality=0; $JPEG_border="60"; $CompressL="10"; #TitleList $MsgOldTG="."; $TitleListSort="DOWN"; $TLyear="年"; $TLmonth="月"; $TLday="日"; $TLyearsz="5"; $TLmonthsz="4"; $TLdaysz="2"; # 其他 # 在CGI加入搜尋功能 $PutSerchTagFlag=1; # 最新日記檔名 $NickyHtml="nicky.html"; $tagpl=$taglt=$tagbr=$tagmode=$anker=""; $tag2lf="

"; $tag3lf="


"; # 使用者自訂模式 $UserN=$UserL=$UserR=$UserU=$UserD=$UserLC=$UserRC=$UserUC=$UserDC=$UserCmnt="No"; } # 日記內文輸出 sub PutNickyOneDay { local($size,$pch,$GrpPath,$PchPath,$ImgLINK,$ImgTAG,$TrTAG,$Msg); local($w,$h,$alt, $tbTag); local($fn, $fn1, $ext, $wpx, $hpx); local($continue, $ContinuePath, $apIn); local($TitleHeadL, $pt, $flag_uc, $wops); local($iTS)=" 0 代表有圖片檔 $size=$pch=0; if( $GrpFileName ){ &IsApplet(); $apIn=$spsize+$PBsize; &MakeNickyDir(); $GrpPath="$NickyDir/$GrpFileName"; $ext=$GrpPath; $ext=~s/^.*\.//; $fn1=$GrpFileName; $fn1=~s/\..*$//; $fn="$NickyDir/$fn1"; $size=(stat($GrpPath))[7]; if( $size > 0 ){ ($w, $h)=&GetImageSize($GrpPath); if( $w && $h ){ local($sz); $sz=int($size/1024).K; $bw=$w; $bh=$h; $p1=rindex($GrpPath,"\/"); $p2=rindex($GrpPath,"\/", $p1-1); $bg=substr($GrpPath, $p2+1); undef $ThmPath; if( (stat("$fn.thumb.jpg"))[7] > 0 ){ $ThmPath="$fn.thumb.jpg"; }elsif( (stat("$fn.thumb.gif"))[7] > 0 ){ $ThmPath="$fn.thumb.gif"; }elsif( (stat("$fn.thumb.png"))[7] > 0 ){ $ThmPath="$fn.thumb.png"; } if($ThmPath){ my($ow,$oh); $ow=$w+20; $oh=$h+26; $GrpPath=$ThmPath; ($w, $h)=&GetImageSize($GrpPath); $fw=" onclick=$wops,width=$ow,height=$oh\');return false;\""; }elsif( ($FitCheck eq "ON") && ($w != $fit_size) && ($h != $fit_size) ){ my($pw, $ph, $fit_width, $fit_height); $fiw=$w+20; $fih=$h+26; $pw=$fit_size/$w; $ph=$fit_size/$h; if( $pw > $ph ){ $fit_width=int($w*$ph); $fit_height=int($h*$ph); }else{ $fit_width=int($w*$pw); $fit_height=int($h*$pw); } $p1=rindex($GrpPath,"\/"); $p2=rindex($GrpPath,"\/", $p1-1); $gm=substr($GrpPath, $p2); $ImgURL="$www$gm"; if( ($w == $fit_width) && ($h == $fit_height) ){ undef $fw; }else{ $fw=" onclick=$wops,width=$fiw,height=$fih\');return false;\""; } $w=$fit_width; $h=$fit_height; }else{ undef $fw; } $p1=rindex($GrpPath,"\/"); $p2=rindex($GrpPath,"\/", $p1-1); $gm=substr($GrpPath, $p2); $ImgURL="$www$gm"; $alt=" width=\"$w\" height=\"$h\" alt=\"$GrpFileName $bw﹣$bh $sz\""; } # $w=$w."px"; # $h=$h."px"; } # 是否有 pch 檔案 $PchPath="$fn.pch"; $pch=(stat($PchPath))[7]; if( !$pch ){ $PchPath="$fn.spch"; $pch=(stat($PchPath))[7]; } # 即使沒有pch,jpeg或giff亦可繼續繪圖 if(!$pch && ($GrpFileName =~ /\.jpg$|\.jpeg$|\.gif$|\.giff$|\.png$/i)){ $ContinuePath=$GrpPath; $continue=(stat($ContinuePath))[7]; } } # 確定檔名後取得日期 if( $NickyFname ){ &GetDateFromFname(); &MakeNickyFname(); } $week=$Week[&GetWeek($year, $month, $day)]; # 將內文及圖片輸出至指定格式 $HonbunHead=""; $HonbunHud=""; $Msg=&Effect($Message); $Honbun=$HonbunHead.$Msg.$HonbunHud; $Msg1=$Honbun; $TrTAG=""; # 有pch檔案則加入再生tag $dlink="DATE=$year$month$day$daysub"; $ctgp="ctgry=$Category?" if( $Category ); if( $pch ){ my($ww,$hh); if( $RepLayout eq "CHECKED" ){ $ww=$bw+90;$hh=$bh*2+120; $rpl="\?RepLayout=CHECKED"; }else{ $ww=$bw*2+90;$hh=$bh+160; $rpl=""; } $PchPath=~s/$vDir\///; if( $apOP eq "Yes" ){ $ImgLINK="$ReplaySTR"; }else{ $ImgLINK="$ReplaySTR"; } if(($Admin) && (select eq "main::STDOUT") && $apIn){ $ImgLINK.="/$ContinueSTR"; } }elsif( $continue && ($Admin) && (select eq "main::STDOUT") && $apIn){ $ImgLINK="$ContinueSTR"; } # 圖像位於左上或右上時加入align標籤 if( $Layout == 4 ){ # 圖像位於左上 $ImgLINK="$ImgLINK$br" if( $ImgLINK ); if( $taglt eq "strict" ){ $ImgTAG="$ImgLINK" if( $ImgLINK ); if( $taglt eq "strict" ){ $ImgTAG="$ImgTAG" if( $fw ); }else{ $ImgTAG="$ImgTAG" if( $fw ); } # 超連結用標籤 $pt="$year$month$day$daysub"; if( $LinkTH eq "Yes" ){ # if( $mkHTML && ($SaveHTML eq "ON") ){ # $TitleHeadL="$TitleHead"; # }else{ if( $tagmode eq "xhtml" ){ $TitleHeadL="$TitleHead"; }else{ $TitleHeadL="$TitleHead"; } # } }else{ $TitleHeadL=$TitleHead; } $bkt=$TitleHead; $bktl=$TitleHeadL; undef $TitleHead if( !$Title ); undef $TitleHeadL if( !$Title ); $wpx=$w."px"; $hpx=$h."px"; # 作好準備之後便輸出 if( $anker ne "no" ){ if( $tagmode eq "xhtml" ){ print "\n"; }else{ print "\n"; } } # 使用者自訂模式 $flag_uc=&ReqUserCustom(); if( $tbRcv eq "Yes" ){ $tbnum=&getTBnum($pt); if( $tbnum || ($tbPast eq "Yes") || !$saveExec && ($Mode ne "MONTH") && !$page){ $tbTag=$tbTAG; $tbTag=~s/%tbnum/$tbnum/g; $tbTag=~s/%pt/$pt/g; }else{ $tbTag=""; } }else{ $tbTag=""; } #$pt=sprintf("%s_%08x", $pt, $Category) if( $Category ); if( $flag_uc && ($size <= 0) && ($UserN eq "Yes") ){ &CustomNprint(); }elsif( $flag_uc && ($Layout == 0) && ($UserL eq "Yes") ){ &CustomLprint(); }elsif( $flag_uc && ($Layout == 1) && ($UserR eq "Yes") ){ &CustomRprint(); }elsif( $flag_uc && ($Layout == 2) && ($UserU eq "Yes") ){ &CustomUprint(); }elsif( $flag_uc && ($Layout == 3) && ($UserD eq "Yes") ){ &CustomDprint(); }elsif( $flag_uc && ($Layout == 4) && ($UserLC eq "Yes") ){ &CustomLCprint(); }elsif( $flag_uc && ($Layout == 5) && ($UserRC eq "Yes") ){ &CustomRCprint(); }elsif( $flag_uc && ($Layout == 6) && ($UserUC eq "Yes") ){ &CustomUCprint(); }elsif( $flag_uc && ($Layout == 7) && ($UserDC eq "Yes") ){ &CustomDCprint(); } # 使用者自訂模式到此為止 else{ local($hdt); if( $Title ){ $hdt="$Title\n"; }else{ $hdt=""; } print <
$TitleHeadL$Date $hdt
HTML if( $size > 0 ){ # 設定輸出位置在右方 if( $Layout == 1 ){ print "$TrTAG"; } # 設定輸出位置在上方 elsif( ($Layout == 2) || ($Layout == 6) ) { print "$TrTAG$TrTAG"; } # 設定輸出位置在下方 elsif( ($Layout == 3) || ($Layout == 7) ){ print "$TrTAG$TrTAG"; } # 設定輸出位置在左方($Layout=0) elsif( $Layout == 0 ){ print "$TrTAG"; } # 設定輸出位置在右上($Layout=5) elsif( $Layout == 5 ){ print "$TrTAG"; } # 設定輸出位置在左上($Layout=4) else{ print "$TrTAG"; } }else{ # 沒有圖像便只顯示文字 print "$TrTAG"; } print "
$Honbun$ImgLINK$ImgTAG
"; if( $Layout == 6 ){ print "
$ImgLINK$ImgTAG
"; #上方中央 }else{ print "$ImgLINK$ImgTAG"; } print "
$Honbun
$Honbun
"; if( $Layout == 7 ){ print "
$ImgLINK$ImgTAG
"; }else{ print "$ImgLINK$ImgTAG"; } print "
$ImgLINK$ImgTAG$Honbun
$ImgLINK$ImgTAG$Honbun
$ImgLINK$ImgTAG$Honbun
$Honbun
\n"; if( $tbRcv eq "Yes" ){ print "
$tbTag
\n" if( $tbnum || ($tbPast eq "Yes") || !$saveExec && ($Mode ne "MONTH") && !$page); } } $TitleHead=$bkt; $TitleHeadL=$bktl; # # 意見欄 # if( ($CommentRecv) || ($Mode eq "CMNTEDIT") ){ local($cf_size); print "\n

\n"; print "" if( $Mode eq "CPREVIEW" ); &InsertDateTag(); print "" if( $Mode eq "CPREVIEW" ); $cf_size=(stat($NickyComment))[7]; if( (($ModeSub == 16) || ($Mode eq "CMNTEDIT")) && (($CIRCV eq "ON") || ($cf_size !=0 || (($Mode ne "MONTH") && !$page && !$saveExec))) ){ if( $UserCmnt ne "Yes" ){ print "\n"; print "
"; print "\n"; print "\n"; &PutComment(); print "
$CommentStr
"; if( $Mode ne "CMNTEDIT" ){ if( ($CIRCV eq "ON") || ($CIRCV ne "ON") && ($Mode ne "MONTH") && !$page && !$saveExec ){ $CMNT_Name=$CommentCName if(!$CMNT_Name && $CommentCName); print ""; print ""; print "Name "; print $CMNT_MSG if( $flagCMNT == 1 ); print ""; } print "$br確定後請按送出鍵" if( $flagCMNT == 1 ); print " $iTS\"CPREVIEW\" value=\"預覽\" class=\"button\"$e"; print " $iTS\"CINPUT\" value=\"送出\" class=\"button\"$e"; } } print "
\n"; }else{ &PutCustomComment(); } } print "
"; } # # 根據不同模式加入操作按鍵 # 本來想設為其他關數 # 但過度複雜將無法管理 # # ModeSub # 1=EDIT/選擇要編輯的日記 # 2=DELETE/選擇要刪除的日記 # 4=EDIT/每天只寫一次的狀況 # 8=KAKUNIN/確認 # 16=WRITE/寫入 # if( ($ModeSub == 1) || ($ModeSub == 2) || ($Mode eq "CMNTEDIT") ){ print "
"; } if( ($ModeSub == 16) && ($Admin) && (select eq "main::STDOUT") ){ print "\n
"; &InsertDateTag(); $tagctl="$iTS\"PANEL\" VALUE=\"編輯分類\"$e" if( $ctgedit ); print < CNTLTAG } print "\n"; } sub PutCustomComment { $flag_ucmnt = &ReqUserCustomCmnt(); if( $flag_ucmnt ){ local($name, $msg, $time); &CustomCmntHprint(); if( $cf_size > 0 ){ open(RDC, $NickyComment); binmode(RDC); while(){ local($str2, $ctloop); $ctloop=0; ($name, $msg, $time)=split/\x01/; while( $time == "" ){ ($str2, $time)=split(/\x01/, ); $msg.=$str2; $ctloop++; last if( $ctloop > 50 ); } chop $time; $msg=~s/\n/$br/g; $msg=&ConvertMsg($msg); $msg=&Effect($msg); $msg=~s/$br$//; &CustomCmntAprint(); } close(RDC); } #Kano1 if( ($Mode =~ /CPREVIEW/) && ($CMNT_Name || $CMNT_MSG) ){ $msg=$CMNT_MSG; $msg=~s/\n/$br/g; $msg=&ConvertMsg($msg); $msg=&Effect($msg); $msg=~s/$br$//; $name=$CMNT_Name; $time=&MakeCommentTime(); &CustomCmntAprint(); } $CMNT_Name=$CommentCName if(!$CMNT_Name && $CommentCName); # 顯示條件 # 過去記錄也接受意見輸入 # 顯示最新頁 if( ($CIRCV ne "OFF") || ($CIRCV eq "OFF") && (!$page && !$saveExec) && ($Mode ne "MONTH") ){ if( $Mode =~ /CPREVIEW|CINPUT/ ){ if( ($Mode eq "CINPUT") && ($MNLflag) || $saveExec){ eval('&CustomCmntOprint();'); }else{ eval('&CustomCmntPprint();'); } }else{ eval('&CustomCmntOprint();'); } } &CustomCmntFprint(); } } sub getTBnum{ local($tb_id)=@_; local($tbfn, $num, $bak); $tbfn="./tbdir/$year$month.cgi"; $bak=$/; $/="\x02"; $num=0; if( open(RD, "$tbfn") ){ binmode RD; while(){ $num++ if( $_ =~ /^$tb_id\x01/ ); } close(RD); } $/=$bak; $num; } sub PutNickyOneDayIMODE { local($b); &GetDateFromFname(); print ""; $b="$month$Month$day$Day"; $b.=" $hour:$min" if( $hour >=0 ); if( &ReqJcode() ){ &jcode'euc2sjis(\$b); $str=$Title; &zenkakuhankaku(); $Title=$str; $str=$Message; &zenkakuhankaku(); $Message=$str; } print "$b\n"; print "
"; print "
$Title
" if( $Title ); print "
$Message"; if( $GrpFileName ){ my($fn, $fn1, $ext, $sstr); &MakeNickyDir(); $GrpPath="$NickyDir/$GrpFileName"; $size=(stat($GrpPath))[7]; if( $size > 0 ){ $ext=&GetExt($GrpPath); if( $size<1024 ){ $sstr=$size."byte"; }else{ $sstr=int($size/1024).K; } print "$br$ext$sstr"; $fn1=$GrpFileName; $fn1=~s/\..*$//; $fn="$NickyDir/$fn1"; $thumb=""; if( stat("$fn.thumb.jpg") ){ $thumb="$fn.thumb.jpg"; }elsif( stat("$fn.thumb.gif") ){ $thumb="$fn.thumb.gif"; }elsif( stat("$fn.thumb.png") ){ $thumb="$fn.thumb.png"; } if( $thumb ){ $size=(stat($thumb))[7]; if( $size<1024 ){ $sstr=$size."byte"; }else{ $sstr=int($size/1024).K; } $ext=&GetExt($thumb); $sstr=int($size/1024).K; print ":$ext$sstr"; } } } print "
"; if( ($CommentRecv) || ($Mode eq "CMNTEDIT") ){ print "\n
\n"; $str="$CommentStr$br"; &zenkakuhankaku(); print $str; &PutCommentIMODE(); &InsertDateTag(); if( $Mode ne "CMNTEDIT" ){ $str="Name "; $str.=$CMNT_MSG if( $flagCMNT == 1 ); $str.=""; } $str.=" "; } $str.="
"; &zenkakuhankaku(); print $str; } print "$br"; } sub ReqUserCustom { if( !$flag_customread ){ $status_customread=eval("require '$CustomCGI'"); $flag_customread=1; } return $status_customread; } sub ReqUserCustomCmnt { if( !$flag_cmnt_customread ){ $status_cmnt_customread=eval("require '$CustomCmntCGI'"); $flag_cmnt_customread=1; } return $status_cmnt_customread; } sub IsApplet{ $spsize=(stat("$vDir/spainter.jar"))[7] if( $spsize == -3 ); $PBsize=(stat("$vDir/PaintBBS.jar"))[7] if( $PBsize == -3 ); } # # 產生日期 # sub MakeDateStr { if( !$Date ){ $week=$Week[&GetWeek($year, $month, $day)]; $Date="$year$Year$month$Month$day$Day$week"; if( ($hour >= 0) && ($PutTime eq "Yes") ){ $Date.="$hour:$min"; } } } # # 輸出至指定檔案 # sub PutFile{ my($f)=@_; my $dat; if( open(FILE, $f) ){ binmode(FILE); while(){$dat.=$_;} close(FILE); } $dat; } # # ColorSample # sub PutColorSample { local($i, $j, $k, $col); &PutHTMLheader(); print "色彩樣本\n\n\n"; print "色彩樣本$br$br\n"; print "
  • HTML的顏色通常都以#RedGreenBlue(各為16進位)進行設定。
\n
\n"; for($k=0; $k<0x100; $k+=0x10){ print "
\n"; $str=sprintf("Blue=%02X", $k); print ""; print "\n"; print "\n"; for($i=0; $i<0x100; $i+=0x10){ printf("", $i); } print "\n"; print "\n"; for($i=0; $i < 0x100; $i+=0x10) { print "\n" if( $i ); printf("", $i); for($j=0; $j < 0x100; $j+=0x10){ $col=sprintf("#%02x%02x%02x", $i, $j, $k); print ""; } print "\n"; } print "
($str)Green
%02X
Red
%02X
\n
\n"; } print "\n"; } # # 標題一覽 # sub PutTitleListSub { local($tcnt)=$_[0]; my($a, $yd, $i, $j); $j=0; print ""; if( $tcnt ){ print ""; for $a(@grplist){ print "$a$br"; } print ""; print ""; for $a(@daylist){ print "$a$br"; $yd=$ddlist[$j]; $j++; } print ""; print ""; for $a(@titlelist){ print "$a$br"; } print ""; }else{ my(@gpl, @ddl, @dyl); $yd=$j=0; if( $TitleListSort eq "UP" ){ @gpl=reverse(@grplist); @ddl=reverse(@ddlist); @dyl=reverse(@daylist); }else{ @gpl=@grplist; @ddl=@ddlist; @dyl=@daylist; } print ""; for $a(@gpl){ if( $ddl[$j] != $yd ){ for($i=0; $i<($ddl[$j]-$yd-1); $i++){ print "$br"; } print "$a $dyl[$j]$br"; } $yd=$ddl[$j++]; } print ""; undef @gpl; undef @ddl; undef @dyl; } print ""; undef @daylist; undef @titlelist; undef @grplist; undef @ddlist; } sub PutTitleList { local($i, $fname, $fn, $yr, $mn, $flag_1st,$dtlink); local($mdstr, $clm, $tcnt, $brcnt); local(@daylist, @titlelist, @grplist, @ddlist); my($opt, $gfn, $tp, $ctgl); $tp="x" if( $tagmode eq "xhtml" ); $ctgl="\?ctg=$ctg" if( $ctg ); $tnct=$brcnt=0; &nickyGetHead(); if( $UseListHD eq "Yes" ){ print &put_macro($head2nd); }else{ print &put_macro($head); } print ""; if( $TitleListSort eq "UP" ){ $opt="r"; }else{ $opt="tr"; } for $gfn( &GetNickyList($opt) ){ $NickyFname=$$gfn[0]; &GetDateFromFname(); &GetNickyFile("$vDir/$NickyFname"); $mdstr=""; if( $yr != $year ){ if( $flag_1st ){ &PutTitleListSub($tcnt); print "\n"; } print ""; if( $Title ){ print ""; }else{ print ""; } print "\n"; print ""; $yr=$year; $mn=$month; $flag_1st=1; $i=0; $clm=0; $tcnt=0; }elsif( $mn != $month ){ &PutTitleListSub($tcnt); if( !$tcnt ){ if($clm++ > 4){ print "\n"; $clm=0; } }else{ print "\n"; } print ""; print "
"; print "$mdstr$year$TLyear
$mdstr$month$TLmonth"; print "
$mdstr$month$TLmonth"; $mn=$month; $i=0; $tcnt=0; } if( $GrpFileName ){ $grplist[$i]=$MsgOldTG; }else{ $grplist[$i]=""; } $daylist[$i]="$mdstr$day$TLday"; $ddlist[$i]=$day; if( $Title ){ $titlelist[$i]="$mdstr$Title"; $tcnt++; } $i++; } &PutTitleListSub($tcnt); print "
"; if( $UseListFT eq "Yes" ){ print &put_macro($foot2nd); }else{ print &put_macro($foot); } } sub PutTitleListIdx { local($i, $fname, $fn, $yr, $mn, $flag_1st,$dtlink); local($mdstr, $clm, $tcnt, $brcnt, $pt); local(@daylist, @titlelist, @grplist, @ddlist, @idxl, @lst); my($opt, $gfn, $data, $tp, $ctgl); $tp="x" if( $tagmode eq "xhtml" ); $ctgl="\?ctg=$ctg" if( $ctg ); $tnct=$brcnt=0; &nickyGetHead(); if( $UseListHD eq "Yes" ){ print &put_macro($head2nd); }else{ print &put_macro($head); } print ""; @idxl=&GetIndexList(); @lst = sort @idxl; if( $TitleListSort eq "UP" ){ @lst=reverse(@lst); } for $gfn( @lst ){ $year=substr($gfn, 8, 4); $month=substr($gfn, 12,2); open(RDI, "$vDir/$gfn"); binmode(RDI); while(){ $data=$_; $data=~s/\n//g; ($day, $daysub, $Title, $GrpFileName)=split(/\x01/, $data); &MakeNickyFname(); if( $MsgOldForm !~ /1/ ){ $pt=&MakeMonthFname($year, $month); $mdstr=""; }else{ $pt="$year$month$day$daysub"; $mdstr=""; } if( $yr != $year ){ if( $flag_1st ){ &PutTitleListSub($tcnt); print "\n"; } print ""; if( $Title ){ print ""; }else{ print ""; } print "\n"; print ""; $yr=$year; $mn=$month; $flag_1st=1; $i=0; $clm=0; $tcnt=0; }elsif( $mn != $month ){ &PutTitleListSub($tcnt); if( !$tcnt ){ if($clm++ > 4){ print "\n"; $clm=0; } }else{ print "\n"; } print ""; print "
"; print "$mdstr$year$TLyear
$mdstr$month$TLmonth"; print "
$mdstr$month$TLmonth"; $mn=$month; $i=0; $tcnt=0; } if( $GrpFileName ){ $grplist[$i]=$MsgOldTG; }else{ $grplist[$i]=""; } $daylist[$i]="$mdstr$day$TLday"; $ddlist[$i]=$day; if( $Title ){ $titlelist[$i]="$mdstr$Title"; $tcnt++; } $i++; } close(RDI); } &PutTitleListSub($tcnt); print "
"; if( $UseListFT eq "Yes" ){ print &put_macro($foot2nd); }else{ print &put_macro($foot); } } # 就是所謂的 basename # 其實BaseName作成req就好了 sub BaseName{ my($p)=@_; my($c); for (split(/\/|\\|\:/, $p)){$c = $_;} $c; } # 取得副檔名 sub GetExt{ local($p1, $n); $p1=""; $n=rindex($_[0], "\."); $p1=substr($_[0], $n+1) if( ($n > 0) && (length($_[0]) > $n) ); $p1; } sub GetDir{ my($s)=@_; my($p, $n); $p=""; $n=rindex($s, "/"); if( $n >= 0 ){ $p=substr($s, 0, $n+1); }else{ $p="\./"; } $p; } sub zenkakuhankaku { &jcode'z2h_euc(\$str); &jcode'tr(\$str, "0123456789(", "0123456789("); &jcode'tr(\$str, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); &jcode'tr(\$str, "abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"); &jcode'tr(\$str, "♀⊙↓﹋﹌﹥ ̄≡※∴﹉-≒←×~∩〝〃→”“﹞﹡+▼", "!#\$%&()\=|-^\\`{+*}<>\?_@;:,[]\/"); &jcode'euc2sjis(\$str); } # 產生預設檔頭 sub MakeDefaultHead { local($a); $a=< 我的日記
我的日記
DefaultHead_EOF ; $a; } # # 產生預設檔尾 # sub MakeDefaultFoot { local($a); $a=<

DefaultFoot_EOF ; $a; } # # 產生預設檔頭(iMODE) # sub MakeDefaultHeadIMODE{ local($a); $a=< Diary MakeDefaultHeadIMODE_EOF ; $a; } # # 產生預設檔尾(iMODE) # sub MakeDefaultFootIMODE{ local($a); $a=""; $a; } # # 產生編輯頁預設檔頭 # sub MakeDefaultEfoot{ local($a); $a=<\n回日記首頁/ 檔頭&檔尾設定/ 個人設定/ 密碼重設 EFOOT $a; } # # 日記檔頭輸出為檔案 # sub nicky_write_head{ my($dat)="$head$TMN$foot$TMN$iHead$TMN$iFoot$TMN$efoot$TMN$head2nd$TMN$foot2nd$TMN$Use2ndHD$TMN$UseListHD$TMN$UseSearchHD$TMN$Use2ndFT$TMN$UseListFT$TMN$UseSearchFT"; $dat=~s/\r//g; open(WD, ">./NickyHFdat.cgi"); binmode(WD); print WD $dat; close(WD); $dat; } # # 抽出日記檔頭之檔案 # sub nickyGetHead{ my($hffn)=@_; local $all=""; if( $hffn && open(IN, $hffn) ){ while(){$all.=$_;} close(IN); }elsif( open(IN, $NickyHF) ){ while(){$all.=$_;} close(IN); } ($head,$foot,$iHead,$iFoot,$efoot,$head2nd,$foot2nd,$Use2ndHD,$UseListHD,$UseSearchHD,$Use2ndFT,$UseListFT,$UseSearchFT)=split(/$TMN/, $all); $UseSearchFT=~s/\r|\n//g; if( !$head ){ $head=&MakeDefaultHead(); } if( !$foot ){ $foot=&MakeDefaultFoot(); } if( !$iHead ){ $iHead=&MakeDefaultHeadIMODE(); } if( !$iFoot ){ $iFoot=&MakeDefaultFootIMODE(); } if( !$efoot ){ $efoot=&MakeDefaultEfoot(); } } sub put_macro{ my($hd)=@_; my($bkmonth, $bkday, $bkyear, $bkfn, $bksub, $bkmsg, $bktitle); my($bkgf, $bkly, $bkcr, $bkfs, $bkrl, $bktr, $bkdate); my($bkh, $bkm, $bkf, $bkcate); my($hd1, $hd2, $cal); my($dat, $f, $i, $p_zero, $str); $bkfn=$NickyFname;$bkmonth=$month;$bkday=$day;$bkyear=$year; $bksub=$daysub;$bktitle=$Title;$bkmsg=$Message;$bkdate=$Date; $bkgf=$GrpFileName;$bkly=$Layout;$bkcr=$CommentRecv; $bkfs=$fit_size;$bkrl=$RepLayout;$bktr=$tbRcv; $bkh=$hour;$bkm=$min;$bkf=$FitCheck;$bkcate=$Category; for($i=1;$i<6;$i++){ $f="header$i.cgi"; if( $hd =~ /%$f%/ ){ ($hd1, $hd2)=split(/%$f%/, $hd); $dat=&PutFile($f); $hd="$hd1$dat$hd2"; } } if( $hd =~ /%Calendar%/ ){ ($hd1, $hd2)=split(/%Calendar%/, $hd); if( ($Mode ne "DELETEOK") && ($Mode ne "WRITE") && (!$YR || !$MON) ){ $YR=$bkyear;$MON=$bkmonth;$p_zero=1; } $list_req=1; eval('require("./minili.cgi")'); &goto_end($@) if( $@ ); $lang=3; $clnum=1; $vect="ON"; $cal=eval('&PutCalendarT()'); $list_req=0; $hd="$hd1$cal$hd2"; } if( $hd =~ /%TitleList%/ ){ ($hd1, $hd2)=split(/%TitleList%/, $hd); if( $MsgOldForm == 1 ){ if( $Mode eq "MONTH" ){ } elsif( (($Mode ne "PageOut") && !$ctg ) && !$DT && !$page ){ $num=20;undef $YR;undef $MON; }elsif( (($Mode ne "PageOut") && !$ctg ) && !$DT && !$page ){ $num=20;undef $YR;undef $MON; }else{ undef $YR; undef $MON; } }elsif( $p_zero && !$DT && !$page ){ $num=20;undef $YR;undef $MON; } $list_req=1; eval('require("./minili.cgi")'); &goto_end($@) if( $@ ); $cal=&PutTitleList2(); $list_req=0; $hd="$hd1$cal$hd2"; } if( $hd =~ /%Category%/ ){ my($ct, $lst, $linedat, $j, $i, $ckd, $put_type, $catebtn); my($ctname, $snum, $putok, $lstr, $ctgid); my(@ff); ($hd1, $hd2)=split(/%Category%/, $hd); $dat=$cal=""; $put_type="link"; if( $ctg && open(RD, "./catelist.cgi") ){ binmode RD; for $linedat(){ my(@f); $linedat=~s/\r|\n//; next if( !$linedat ); if( $j == 0 ){ $put_type = $linedat; last if( $put_type eq "link" ); }elsif( $j == 1 ){ $catebtn=$linedat; }else{ @f=($ctname, $snum, $put_ok, $lstr, $ctgid)=split(/,/, $linedat); $f[0]=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ego; $f[3]=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ego; $i=$j-2; $ff[$i]=\@f; } $j++; } close RD; } if( $put_type eq "link" || !$ctg ){ $cal=&PutFile("./ctgput.cgi"); }else{ @ff=sort{$$a[1] <=> $$b[1]} @ff; $cal="
\n"; $cal.="" if( $put_type =~ /chkbox|sel/ ); $cal.="\n" if( $put_type eq "sel" ); $cal.="
\n"; } $hd="$hd1$cal$hd2"; } if( $hd =~ /%admin%/ ){ $cal=""; ($hd1, $hd2)=split(/%admin%/, $hd); if( $Admin && !$mkHTML ){ $cal=&PutFile("./admin.cgi"); } $hd="$hd1$cal$hd2"; } $NickyFname=$bkfn;$month=$bkmonth;$day=$bkday;$year=$bkyear; $daysub=$bksub;$Title=$bktitle;$Message=$bkmsg;$Date=$bkdate; $GrpFileName=$bkgf;$Layout=$bkly;$CommentRecv=$bkcr; $fit_size=$bkfs;$RepLayout=$bkrl;$tbRcv=$bktr; $hour=$bkh;$min=$bkm;$FitCheck=$bkf;$Category=$bkcate; $hd; } # # 抽出個人設定化格式 # sub nickyGetCustomText{ my($all); $all=""; if( open(IN, $CustomText) ){ binmode(IN); while(){ $all.=$_; } close(IN); ($CustomN,$CustomL,$CustomR,$CustomU,$CustomD,$CustomLC,$CustomRC,$CustomUC,$CustomDC, $CustomHead, $CustomFoot, $CustomTB)=split(/$TMN/, $all); } } sub NickyGetCustomCmntText { my($all); $all=""; if( open(IN, $CustomCmntText) ){ binmode(IN); while(){ $all.=$_; } close(IN); ($CustomCmntH,$CustomCmntA,$CustomCmntF,$CustomCmntO,$CustomCmntP)=split(/$TMN/, $all); } } # # 日記檔頭修改 # sub NickyHead { &nickyGetHead("./NickyHFdat.cgi"); $head=&tagenc($head); $foot=&tagenc($foot); $head2nd=&tagenc($head2nd); $foot2nd=&tagenc($foot2nd); $iHead=&tagenc($iHead); $iFoot=&tagenc($iFoot); $efoot=&tagenc($efoot); &PutHTMLheader(); print <日記檔頭&檔尾編輯
檔頭&檔尾編輯$br$br
● 檔頭$br $br$br● 檔尾$br $br
$br$br ● 檢查使用檔頭的頁面→ 第二頁以後\n"; print " 標題一覽\n"; print " 搜尋$br\n"; print ""; print "$br$br● 檢查使用檔尾的頁面→"; print " 第二頁以後\n"; print " 標題一覽\n"; print " 搜尋$br\n"; print <$foot2nd $br
$br$br ● iMODE用檔頭$br $br$br● iMODE用檔尾$br $br $br● 編輯畫面最下方使用之語法標籤$br $br
$br
HD2_EOF ; } # # 寫入日記檔頭&檔尾 # sub NickyHeadWrite { my $dat; $dat=&nicky_write_head(); &create_exec($dat, $NickyHF, "nHF"); &MakeNickyLast(); } sub goto_end{ my($par)=@_; print "$par\n"; exit; } sub create_exec{ my($dat, $outfile, $exe)=@_; my $stylecgi="./$exe.cgi"; $dat=~s/\@/\\@/g; open(WD, ">$stylecgi"); print WD "sub put_$exe(){\nopen(WD, \">$outfile\");\n"; print WD "print WD<){ $styledat.=$_; } close(RD); &create_exec($styledat,"$vDir/d.css", "cssdat"); } # # Setup相關 # sub ReadSetup { &InitialNicky(); # 有遺漏之設定項目時 # 先自行輸入適合的設定 if( open(RD, "./NickyConf.cgi") ){ binmode(RD); while(){ chop; ($arg,$val)=split(/=/,$_,2); ${$arg}=$val; } close(RD); } $mtap=$MTApath; $mto=$MailTo; $flag_savehtml=$SaveHTML; if( $WEEK == 1 ){ @Week=('(Sun)','(Mon)','(Tue)','(Wed)','(Thu)','(Fri)','(Sat)'); }else{ @Week=('(日)','(一)','(二)','(三)','(四)','(五)','(六)'); } $MsgSize=$HonbunSize; $MsgColor=$HonbunColor; $MsgBgColor=$HonbunBgColor; } # # 儲存使用者設定 # sub SaveUserCustomizeDone { my($str, $subname)=($_[0], $_[1]); my($substrcgi, $a, $b); $customtext.="$str$TMN"; $str=~s/\"/\\\"/g; $str=~s/\r//g; if( $subname !~ /Head$|Foot$/ ){ $a=$UserCustomHead; $a=~s/\"/\\\"/g; $a=~s/\r//g; $b=$UserCustomFoot; $b=~s/\"/\\\"/g; $b=~s/\r//g; $str=~s/\$UserCustomHead/$a/; $str=~s/\$UserCustomFoot/$b/; } $str=~s/\n/\";\nprint \"/g; undef $substrcgi; if( $subname !~ /Head$|Foot$/ ){ $substrcgi= "sub $subname\n"; $substrcgi.= "{\n"; } $substrcgi.= "print \"$str\"\;\n"; if( $subname !~ /Head$|Foot$/ ){ $substrcgi.= "}\n"; $substrcgi.=$TMN; } $substrcgi; } sub SaveUserCustomize { my($str,$uhh, $uff); $customtext=""; $uh=&SaveUserCustomizeDone($UserCustomHead, "UserCustomHead"); $uhh=$customtext; $customtext=""; $uf=&SaveUserCustomizeDone($UserCustomFoot, "UserCustomFoot"); $uff=$customtext; $customtext=""; $str=&SaveUserCustomizeDone($UserCustomN, "CustomNprint"); $str.=&SaveUserCustomizeDone($UserCustomL, "CustomLprint"); $str.=&SaveUserCustomizeDone($UserCustomR, "CustomRprint"); $str.=&SaveUserCustomizeDone($UserCustomU, "CustomUprint"); $str.=&SaveUserCustomizeDone($UserCustomD, "CustomDprint"); $str.=&SaveUserCustomizeDone($UserCustomLC, "CustomLCprint"); $str.=&SaveUserCustomizeDone($UserCustomRC, "CustomRCprint"); $str.=&SaveUserCustomizeDone($UserCustomUC, "CustomUCprint"); $str.=&SaveUserCustomizeDone($UserCustomDC, "CustomDCprint"); $customtext.=$uhh.$uff; $customtext.=$UserCustomTB; $UserCustomTB=~s/\"/\\\"/g; $UserCustomTB=~s/\r//g; $UserCustomTB=~s/\n/\\n/g; $UserCustomTB=~s/\$tbnum/%tbnum/g; $UserCustomTB=~s/\$pt/%pt/g; $str.="\$tbTAG=\"$UserCustomTB\"\;"; $str.="\n1;\n"; open(WD, ">$CustomText"); binmode(WD); print WD $customtext; close(WD); open(WD, ">$CustomCGI"); binmode(WD); print WD $str; close(WD); &SaveNickyConf(); } sub SaveUserCustomizeC { local($str); undef $uf; undef $uh; $customtext=""; $str=&SaveUserCustomizeDone($UserCustomCmntH, "CustomCmntHprint"); $str.=&SaveUserCustomizeDone($UserCustomCmntA, "CustomCmntAprint"); $str.=&SaveUserCustomizeDone($UserCustomCmntF, "CustomCmntFprint"); $str.=&SaveUserCustomizeDone($UserCustomCmntO, "CustomCmntOprint"); $str.=&SaveUserCustomizeDone($UserCustomCmntP, "CustomCmntPprint"); $str.="\n1;\n"; open(WD, ">$CustomCmntText"); binmode(WD); print WD $customtext; close(WD); open(WD, ">$CustomCmntCGI"); binmode(WD); print WD $str; close(WD); &SaveNickyConf(); } # # 使用者自訂模式 # 因為w3m規定textare內無法使用table標籤,因此不使用table。 # sub PutUserCustomize { my($nm, $ag, $ta, $textdata)=($_[0], $_[1], $_[2], $_[3]); if( ($CustomMode eq "Custom") && ($nm !~ /^UserHead$|^UserFoot$|^UserTB$/) ){ print " 自訂模式使用\n"; print " 不使用\n"; } $textdata=&tagenc($textdata); print "$br\n$br\n"; } sub UserCustomize { local($i); $CustomMode="Custom"; &PutHTMLheader(); &nickyGetCustomText(); print "使用者自訂模式\n\n"; print ""; print "
使用者自訂模式
\n"; print "
\n"; print "日記檔頭(使用變數\$UserCustomHead)\n"; &PutUserCustomize("UserHead", $UserHead, "UserCustomHead", $CustomHead); print "日記檔尾(使用變數\$UserCustomFoot)\n"; &PutUserCustomize("UserFoot", $UserFoot, "UserCustomFoot", $CustomFoot); print "
無圖像\n"; &PutUserCustomize("UserN", $UserN, "UserCustomN", $CustomN); print "
圖像置左\n"; &PutUserCustomize("UserL", $UserL, "UserCustomL", $CustomL); print "
圖像置右\n"; &PutUserCustomize("UserR", $UserR, "UserCustomR", $CustomR); print "
圖像置上\n"; &PutUserCustomize("UserU", $UserU, "UserCustomU", $CustomU); print "
圖像置下\n"; &PutUserCustomize("UserD", $UserD, "UserCustomD", $CustomD); print "
圖像置左上\n"; &PutUserCustomize("UserLC", $UserLC, "UserCustomLC", $CustomLC); print "
圖像置右上\n"; &PutUserCustomize("UserRC", $UserRC, "UserCustomRC", $CustomRC); print "
圖像置上中\n"; &PutUserCustomize("UserUC", $UserUC, "UserCustomUC", $CustomUC); print "
下中\n"; &PutUserCustomize("UserDC", $UserDC, "UserCustomDC", $CustomDC); if( (stat("./tb.cgi"))[7] || $CustomTB ){ print "
加入TrackBack(使用變數\$tbTag)\n"; &PutUserCustomize("UserTB", "Yes", "UserCustomTB", $CustomTB); } print "
\n"; } sub UserCustomizeCmnt { local($i); $CustomMode="CustomC"; &PutHTMLheader(); &NickyGetCustomCmntText(); print "意見欄自訂模式\n\n"; print ""; print "
意見欄自訂模式\n"; print "
"; print "\n 意見欄自訂模式使用\n"; print " 不使用\n"; print "$br$br"; print "$br檔頭\n"; &PutUserCustomize("UserCmntH", $UserCmntH, "UserCustomCmntH", $CustomCmntH); print "$br意見欄內文\n"; &PutUserCustomize("UserCmntA", $UserCmntA, "UserCustomCmntA", $CustomCmntA); print "$br輸入欄(顯示用)\n"; &PutUserCustomize("UserCmntO", $UserCmntO, "UserCustomCmntO", $CustomCmntO); print "$br輸入欄(預覽用)\n"; &PutUserCustomize("UserCmntP", $UserCmntP, "UserCustomCmntP", $CustomCmntP); print "$br檔尾\n"; &PutUserCustomize("UserCmntF", $UserCmntF, "UserCustomCmntF", $CustomCmntF); print "
"; } sub tagenc{ my($str)=@_; $str=~s/&/&/g; $str=~s//>/g; $str=~s/\"/"/g; $str; } # # 個人設定 # sub MakeSetup { my($i, $sizea, $jpsz, $str, $imp, $appp, $b2, $ITT, $IRT); my($hap1, $hap2, $hap3, $hap4, $hap5, $hap6, $hap7, $hap8, $hap9, $hap10), $hap11, $hap12; my($sizetb, $tbtag, $ck); my $v="value="; my $s="size="; &IsApplet(); $sizea=$spsize+$PBsize; $ck=" CHECKED"; $sizetb=(stat("./tb.cgi"))[7]; if( -e "$vDir/jcode.pl" ){ $jpsz=1; $imp="
  • iMODE相關
  • "; } if( $sizetb ){ $tbtag="
  • TrackBack相關
  • "; } $appp="
  • 繪圖板程式$br" if( $sizea ); $b2="$br$br"; $ITT="
    nicky!Setup
    Ver.$Ver$br 色彩樣本$br
    Perl Ver$]
    $br
    --- Menu ---
    1. 關於日記整體的設定
    2. 關於日記標題的設定
    3. 關於日記內文的設定
    4. 關於意見欄的設定
    5. 關於過去記錄的設定
    6. 關於標題列表的設定
    7. 其他
    $tbtag $imp$appp
    $br
    關於日記標題的設定
    最新的一頁顯示 篇日記$b2"; $hap1=$hap2=$hap3=$hap4=$hap5=$hap6=$hap7=""; if( ($Age ne "t") && ($Age ne "tc") ){ $hap1=$ck; }elsif( $Age eq "t" ){$hap2=$ck;}else{$hap3=$ck;} if( $WEEK != 1 ){$hap4=$ck;}else{$hap5=$ck;} if( $PutTimeDefault eq "Yes" ){$hap6=$ck;}else{$hap7=$ck;} print <依照日期$br $IRT"Age" $v"t" $hap2>依照寫入時間$br $IRT"Age" $v"tc" $hap3>包含意見欄寫入時間$br$br 日記在畫面上的寬度$ITT"NickyWidth" $v"$NickyWidth" $s"8">$b2 框線粗細$ITT"NickyLineWidth" $v"$NickyLineWidth" $s"4">$b2 框線與內文間隔$ITT"NickyLineSpan" $v"$NickyLineSpan" $s"4">
    $br設定$b2
    關於日記標題的設定
    日記標題之背景色$ITT"TitleBgColor" $v"$TitleBgColor" $s"10">$br$br 標題框高度$ITT"TSize" $v"$TSize" $s"6">$b2 日期顯示 年$ITT"Year" $v"$Year" $s"6"> 月$ITT"Month" $v"$Month" $s"6"> 日$ITT"Day" $v"$Day" $s"6">$b2 星期顯示$br 一~日$br $IRT"WEEK" $v"1"$hap5>Sun~Sat$b2 日期文字大小 $ITT"DateSize" $v"$DateSize" $s"6">$b2 日期文字顏色 $ITT"DateFontColor" $v"$DateFontColor" $s"10">$b2 時間顯示(預設)$br $IRT"PutTimeDefault" $v"Yes"$hap6>顯示$br $IRT"PutTimeDefault" $v"No\"$hap7>不顯示$b2 日記標題文字大小 $ITT"TitleSize" $v"$TitleSize" $s"6">$b2 日記標題前方加入的文字 MkSt2_EOF $str=&tagenc($TitleHead); print "$ITT\"TitleHead\" $v\"$str\" $s\"15\">$b2\n"; # # 加入超連結標籤 # print "自動為URL加入超連結$br "; print "$IRT\"LinkTH\" $v\"Yes\""; print $ck if( $LinkTH eq "Yes" ); print ">使用$br "; print "$IRT\"LinkTH\" $v\"No\""; print $ck if( $LinkTH ne "Yes" ); print ">不使用$b2\n"; if( $LinkOpen eq "Yes" ){$hap1=$ck; $hap2=""; }else{$hap2=$ck; $hap1="";} if( $Fit eq "ON" ){$hap3=$ck; $hap4="";}else{ $hap4=$ck; $hap3="";} print <
    $br設定$b2
    關於日記內文的設定
    日記內文字形大小 $ITT"HonbunSize" $v"$HonbunSize" $s"6">$b2 日記內文顏色 $ITT"HonbunColor" $v"$HonbunColor" $s"10">$b2 日記內文背景色 $ITT"HonbunBgColor" $v"$HonbunBgColor" $s"10">$b2 自動加入之連結標籤設為在新視窗開啟$br $IRT"LinkOpen" $v"Yes"$hap1>是$br $IRT"LinkOpen" $v"No"$hap2>否$b2 預設圖像的顯示尺寸 $ITT"Fit_size" $v"$Fit_size" $s"3" CLASS="button2"> $IRT"Fit" $v"ON"$hap3>有效 $IRT"Fit" $v"No"$hap4>無效$b2 HTML_EOF # # 日記內文特效 # print < 顏色$ITT"EffectCOL1" $v"$EffectCOL1" $s"8">$b2 日記內文特效 文字$ITT"EffectSTR2" $v"$EffectSTR2" $s"4"> 顏色$ITT"EffectCOL2" $v"$EffectCOL2" $s"8">$b2 日記內文特效 文字$ITT"EffectSTR3" $v"$EffectSTR3" $s"4"> 顏色$ITT"EffectCOL3" $v"$EffectCOL3" $s"8">$b2 日記內文特效 文字$ITT"EffectSTR4" $v"$EffectSTR4" $s"4"> 顏色$ITT"EffectCOL4" $v"$EffectCOL4" $s"8">
    *指定特效文字時不可使用(/\\/[等半形文字。$b2
    意見欄相關
    意見欄預留行數(預設)$b2\n"; $hap1=$hap2=""; if( $CIRCV ne "OFF" ){ $hap1=$ck;}else{$hap2=$ck;} print <$b2 過去記錄頁是否顯示意見輸入欄$br $IRT"CIRCV" $v"ON"$hap1>是$br $IRT"CIRCV" $v"OFF"$hap2>否$b2 意見輸入欄寬度$br Name$ITT"CMNT_NameWidth" $v"$CMNT_NameWidth" $s"8"> Message$ITT"CommentMessageWidth" $v"$CommentMessageWidth" $s"8">$b2 意見欄邊框顏色 $ITT"CommentFlColor" $v"$CommentFlColor" $s"10">$b2 意見欄預設文字 $ITT"CommentStr" $v"$CommentStr" $s"30">$b2 意見欄字形大小 $ITT"CommentStrSize" $v"$CommentStrSize" $s"16">$b2 Name, Message之字形大小 $ITT"CMNT_NameStrSize" $v"$CMNT_NameStrSize" $s"16">$b2
    意見輸出欄設定
    意見欄背景色 $ITT"CommentBgColor" $v"$CommentBgColor" $s"10"> $br$br\n輸入者姓名顏色 $ITT"CMNT_NameColor" $v"$CMNT_NameColor" $s"10">$br 輸入者姓名字形大小 $ITT"CMNT_NameSize" $v"$CMNT_NameSize" $s"5">$b2 意見欄內文顏色 $ITT"CommentFontColor" $v"$CommentFontColor" $s"10">$br 意見欄內文字形大小 $ITT"CommentFontSize" $v"$CommentFontSize" $s"5">$b2
    有新意見時以mail通知
    sendmail路徑 $ITT"MTApath" $v"$MTApath" $s"20">$br 管理者mail信箱 $ITT"MailTo" $v"$MailTo" $s"20">$br
    MkSt4_EOF print "$br設定$b2\n"; # # 過去記錄 # print "\n"; print ""; print ""; print "
    關於過去記錄的設定
    "; print "顯示形式$br"; print " $IRT\"MsgOldForm\" $v\"2\" "; print $ck if( $MsgOldForm == 2 ); print ">依照月份(上)"; print " $IRT\"MsgOldForm\" $v\"0\" "; print $ck if( $MsgOldForm == 0 ); print ">依照月份(下)"; print " $IRT\"MsgOldForm\" $v\"4\" "; print $ck if( $MsgOldForm == 4 ); print ">依照月份(上+下)"; print "$br $IRT\"MsgOldForm\" $v\"1\" "; print $ck if( $MsgOldForm == 1 ); print ">依照件數$b2\n"; print "最新一頁是否顯示過去記錄列表$br $IRT\"MsgOld1st\" $v\"0\" "; print $ck if( !$MsgOld1st ); print ">顯示$br"; print " $IRT\"MsgOld1st\" $v\"1\" "; print $ck if( $MsgOld1st == 1 ); print ">不顯示$br"; print " $IRT\"MsgOld1st\" $v\"2\" "; print $ck if( $MsgOld1st == 2 ); print ">完全不顯示\n"; print "$b2將日記儲存為HTML"; print "$IRT\"SaveHTML\" $v\"ON\" "; print $ck if( $SaveHTML eq "ON" ); print ">是 "; print "$IRT\"SaveHTML\" $v\"OFF\" "; print $ck if( $SaveHTML ne "ON" ); print ">否$br"; print " 過去記錄的儲存檔名"; print " $ITT\"LogFname\" $v\"$LogFname\" $s\"8\">"; print "
    以下為所有顯示形式之共通設定
    "; $str=&tagenc($MsgOld); print "過去記錄(Old)$ITT\"MsgOld\" $v\"$str\" $s\"20\">"; print "$br(用於最新一頁不顯示過去記錄時)$b2\n"; $str=&tagenc($MsgOldSize); print "過去記錄之文字大小$ITT\"MsgOldSize\" $v\"$str\" $s\"20\">"; print "
    以下適用於依照件數排列時
    "; $str=&tagenc($MsgNew); print "過去記錄(New)$ITT\"MsgNew\" $v\"$str\" $s\"20\">$b2"; print "過去記錄顯示件數"; print "$b2"; print "是否顯示詳細頁數$br $IRT\"MsgPageOut\" $v\"1\" "; print $ck if( $MsgPageOut ); print ">顯示$br     [最新]之文字 $ITT\"MsgOldNEWks\" $v\"$MsgOldNEWks\" $s\"3\"> $ITT\"MsgOldNEW\" $v\"$MsgOldNEW\" SIZE=\"20\"> $ITT\"MsgOldNEWke\" $v\"$MsgOldNEWke\" $s\"3\">$b2"; print "     [最舊]之文字 $ITT\"MsgOldOLDks\" $v\"$MsgOldOLDks\" size=\"3\"> $ITT\"MsgOldOLD\" $v\"$MsgOldOLD\" SIZE=\"20\"> $ITT\"MsgOldOLDke\" $v\"$MsgOldOLDke\" $s\"3\">$b2"; print "     頁面括弧 $ITT\"ks\" $v\"$ks\" $s\"3\"> $ITT\"ke\" $v\"$ke\" $s\"3\">$b2"; print " $IRT\"MsgPageOut\" $v\"0\" "; print $ck if( !$MsgPageOut ); $str=&tagenc($MsgOldBetween); print ">不顯示$br     過去記錄New與Old之間的顯示$br"; print "        $ITT\"MsgOldBetween\" $v\"$str\" $s\"40\">"; if( $MonthSort eq "UP" ){ $hap1=$ck; $hap2="";}else{ $hap2=$ck; $hap1="";} $hap3=&tagenc($MsgOldYear); $hap4=&tagenc($MsgOldMonth); print <
    以下適用於依照月份排列時
    顯示順序$br $IRT"MonthSort" $v"UP" $hap1>昇冪 $IRT"MonthSort" $v"DOWN" $hap2>降冪$b2 過去記錄之$ITT"MsgOldLog" $v"$MsgOldLog" $s"20">背景顏色$ITT"MsgOldOBgCol" $v"$MsgOldOBgCol" $s"8">文字顏色$ITT"MsgOldCol" $v"$MsgOldCol" $s"8">$b2     年之$ITT"MsgOldYear" $v"$hap3" $s"20">背景顏色$ITT"MsgOldYBgCol" $v"$MsgOldYBgCol" $s"8">文字顏色$ITT"MsgOldYFnCol" $v"$MsgOldYFnCol" $s"8">$b2     月之$ITT"MsgOldMonth" $v"$hap4" $s"20">背景顏色$ITT"MsgOldMBgCol" $v"$MsgOldMBgCol" $s"8">$b2     cellpadding$ITT"MsgOldcelp" $v"$MsgOldcelp"> cellspacing$ITT"MsgOldcels" $v"$MsgOldcels">
    HTML_EOFML print "$br設定$b2\n"; # # 關於標題列表的設定 # print "\n"; print ""; print "\n"; print "
    關於標題列表的設定
    \n"; print "年$ITT\"TLyear\" $v\"$TLyear\" $s\"5\">"; print "月$ITT\"TLmonth\" $v\"$TLmonth\" $s\"5\">"; print "日$ITT\"TLday\" $v\"$TLday\" $s\"5\">$b2"; $str=&tagenc($TLyearsz); print "年的字形大小$ITT\"TLyearsz\" $v\"$str\" $s\"5\">$br"; $str=&tagenc($TLmonthsz); print "月的字形大小$ITT\"TLmonthsz\" $v\"$str\" $s\"5\">$br"; $str=&tagenc($TLdaysz); print "日的字形大小$ITT\"TLdaysz\" $v\"$str\" $s\"5\">$b2"; print "顯示順序$br\n"; print "$IRT\"TitleListSort\" $v\"UP\" "; print $ck if( $TitleListSort eq "UP" ); print ">昇冪$br"; print "$IRT\"TitleListSort\" $v\"DOWN\" "; print $ck if( $TitleListSort ne "UP" ); print ">降冪$b2"; $str=&tagenc($MsgOldTG); print "註明該篇有圖像的標記$ITT\"MsgOldTG\" $v\"$str\" $s\"20\">"; print "
    \n$b2"; # # 其他 # if( $PutSerchTagFlag ){ $hap1=$ck;$hap2=""; }else{ $hap2=$ck;$hap1="";} $hap3=$hap4=$hap5=$hap6=$hap7=$hap8=$hap9=$hap10=$hap11=$hap12=""; if( $tagpl eq "strict" ){ $hap4=$ck; }else{ $hap3=$ck; } if( $taglt eq "strict" ){ $hap6=$ck; }else{ $hap5=$ck; } if( $tagbr eq "p" ){ $hap8=$ck; }else{ $hap7=$ck; } if( $tagmode eq "xhtml" ){ $hap10=$ck; }else{ $hap9=$ck; } if( $anker eq "no" ){ $hap12=$ck; }else{ $hap11=$ck; } $tag2lf=&tagenc($tag2lf); $tag3lf=&tagenc($tag3lf); print <
    其他
    連至過去記錄的連結標籤$br $IRT"tagpl" $v"tra"$hap3>Transitional $IRT"tagpl" $v"strict"$hap4>Strict/XHTML $b2指定圖像置於右上&左上的標籤$br $IRT"taglt" $v"tra"$hap5>Transitional $IRT"taglt" $v"strict"$hap6>Strict/XHTML $b2允\許\重複換行$br
    $IRT"tagbr" $v"p"$hap8>是$br 換行兩次時 $ITT"tag2lf" $v"$tag2lf">
    換行三次時 $ITT"tag3lf" $v"$tag3lf">
    $IRT"tagbr" $v"br"$hap7>否
    $br標籤模式$br $IRT"tagmode" $v"html"$hap9>HTML $IRT"tagmode" $v"xhtml"$hap10>XHTML $b2將anker輸出至CGI$br $IRT"anker" $v"yes"$hap11>是 $IRT"anker" $v"no"$hap12>否 $b2在CGI放入搜尋功\能$br $IRT"PutSerchTagFlag" $v"1"$hap1>是 $IRT"PutSerchTagFlag" $v"0"$hap2>否$b2 最新輸出之HTML檔案名稱 $ITT"NickyHtml" $v"$NickyHtml" $s"16">
    \n$b2 HTML_EOF_OTH # Trackback if( $sizetb ){ $hap1=$hap2=$hap3=$hap4=""; if( $tbPast eq "Yes" ){$hap1=$ck;$hap2="";}else{$hap2=$ck;$hap1="";} if( $tbRcvDef eq "Yes" ){$hap3=$ck;$hap4="";}else{$hap4=$ck;$hap3="";} print <
    TrackBack相關
    TrackBack設定$br $IRT"tbRcvDef" $v"Yes" $hap3>接受 $IRT"tbRcvDef" $v"No" $hap4>不接受 $br$br 過去記錄中的記事沒有TrackBack記錄時$br $IRT"tbPast" $v"Yes" $hap1>顯示 $IRT"tbPast" $v"No" $hap2>不顯示
    TBEOF print "$br設定$br$br"; } # iMODE相關 if( $jpsz ) { print "\n"; print "\n"; print "
    iMODE相關
    "; if( &ReqJcode() ){ print "每頁顯示件數"; print "$b2"; print "過去記錄顯示件數"; print ""; }else{ print "jcode.pl安裝失敗"; } print "
    $b2\n"; } #JavaApplete系 if( $sizea > 0 ) { if( $apOP eq "Yes" ){$hap1=$ck;$hap2="";}else{$hap2=$ck;$hap1="";} print <
    繪圖板設定
    預設大小 寬度$ITT"image_width" $v"$image_width" $s"4">高度$ITT"image_height" $v"$image_height" $s"4">$b2 圖層 $ITT"layerNum" $v"$layerNum" $s"3">張 Undo次數 $ITT"undoNum" $v"$undoNum" $s"3">次 Quality $ITT"Quality" $v"$Quality" $s"3">$b2 播放之文字 $ITT"ReplaySTR" $v"$ReplaySTR" $s"10"> $b2繼續之文字 $ITT"ContinueSTR" $v"$ContinueSTR" $s"10"> $b2檔案大小限制 $ITT"JPEG_border" $v"$JPEG_border" $s"5">K $b2壓縮率 $ITT"CompressL" $v"$CompressL" $s"5"> $b2播放時開新視窗$br $IRT"apOP" $v"Yes"$hap1>是 $IRT"apOP" $v"No"$hap2>否
    MkStAP_EOF } # # SUBMIT # print "$br設定"; print " 恢復預設值"; print ""; print "
    "; print "\n"; } # # Save to ConfigFile # sub SaveNickyConf { if( -e "./panel.cgi" ){ $ctgedit=1; }else{ $ctgedit=0; } open(WDCNF, ">./NickyConf.cgi"); binmode(WDCNF); print WDCNF <){$str .= $_;} close(RRDD); } ($Date, $Title, $Message, $GrpFileName, $Layout, $CommentRecv, $fit_size, $RepLayout, $tbRcv) = split(/\x01/, $str); if( $fit_size ){ $FitCheck = "ON"; }else{ undef $FitCheck; } if( substr($Date,-5) =~ /[0-9][0-9]:[0-9][0-9]/ ){ $hour=substr($Date,-5,2); $min=substr($Date,-2,2); }else{ $hour=$min=-1; } } sub MakeCommentTime{ my($cdate); my($csec,$cmin,$chour,$cday,$cmon,$cyear,$cwday,$cyday,$cisdst) = localtime; sprintf("%04d/%02d/%02d %02d:%02d", $cyear+1900, $cmon+1, $cday, $chour, $cmin); } sub cut_str{ my($str, $len)=@_; if( length($str) > $len ){ $str=substr($str, 0, $len); $str.=" "; } $str; } sub getNickyFname{ ($year, $month, $day, $daysub, $Category)=@_; my(@dmy, $gomi1, $gomi2); &MakeNickyFname(); if( !$Category ){ @dmy=&GetFileList("\/$year\/$year\/$month$day$daysub.*\.nky\$"); ($gomi1, $gomi2)=split(/_/, $dmy[0]); if( $gomi2 ){ $Category=substr($gomi2, 0, 8); $NickyFname="$vDir/$year/$month$day$daysub"."_"."$Category\.nky"; } } ($NickyFname, $Category); } sub NickyInputComment{ my($cdate, $error, $gomi1, $gomi2, $gomi3, $ille, @dmy); &getNickyFname($year, $month, $day, $daysub, $Category); $CMNT_Name=~s/\r|\n//g; $CMNT_MSG=~s/\r//g; $CMNT_MSG=~s/\n(\n+)/\n\n/g; $CMNT_MSG=~s/\n(\n+)$//; $CMNT_Name=&cut_str($CMNT_Name, 50); $CMNT_MSG=&cut_str($CMNT_MSG, $CommentSTRlen); if( $CMNT_Name && $CMNT_MSG && ($Mode ne "CPREVIEW") ){ if( open(RDC, $NickyComment) ){ binmode(RDC); while(){ local($str2, $ctloop); $ctloop=0; ($name, $msg, $time)=split/\x01/; while( $time == "" ){ ($str2, $time)=split(/\x01/, ); $msg.=$str2; $ctloop++; last if( $ctloop > 50 ); } } close(RDC); } if( ($msg ne $CMNT_MSG) || ($name ne $CMNT_Name) ){ $cdate=&MakeCommentTime(); if( ($CMNT_MSG =~ /\x01/) || ($CMNT_Name =~ /\x01/) ){ $ille = 1; }else{ $ille = 0; open(WDC, ">>$NickyComment"); binmode(WDC); print WDC "$CMNT_Name\x01"; print WDC "$CMNT_MSG\x01"; print WDC "$cdate\n"; close( WDC ); } if( $mtap && $mto ){ open(PIPE, "|$mtap -t -Fnicky!"); if( $error == 0 ){ print PIPE "To: $mto\n"; print PIPE "Subject: nicky!Notice ReciveCommentMessage\n\n"; print PIPE "Recieve Date : $cdate\n"; print PIPE "from : $ENV{REMOTE_HOST}($ENV{REMOTE_ADDR})\n"; print PIPE "agent : $ENV{HTTP_USER_AGENT}\n\n"; print PIPE "http://$ENV{HTTP_HOST}$ENV{SCRIPT_NAME}\?DT=$year$month$day$daysub#$year$month$day$daysub\n\n"; print PIPE "illegal post\n" if( $ille ); close(PIPE); } } } undef $CMNT_MSG; undef $CMNT_Name; &MakeHTMLone($year, $month, $day, $daysub, 0); &MakeNickyLast(); }else{ &nickyGetHead(); if( &IsIMODE() ){ $sts=&ReqJcode(); &jcode'euc2sjis(\$iHead) if( $sts ); }else{ print &put_macro($head); } $flagCMNT=1; $ModeSub=16; &GetNickyFile($NickyFname); if( &IsIMODE() ){ &PutNickyOneDayIMODE(); &jcode'euc2sjis(\$iFoot) if( $sts ); }else{ &PutNickyOneDay(); print &put_macro($foot); } } } # # 產生日記編修用表 # (2002/02/10 提供 http://sugarplum.vis.ne.jp/) # sub PutEditNicky { my($str, $fitstr); local($size1,$size4); my $h2="style=\"color:#333; font-size:medium; padding:5px; margin-bottom:10px; border-bottom:3 double #808080;text-align:left;\"\n"; my $sc="style=\"text-align:center\""; my $IT=""; $para = $_[0]; print "
    \n"; if( $para eq "WRITE" ){ print "

    $IT\"submit\" class=\"button1\" name=\"WRITE\" value=\"寫入\">

    \n"; # print "$HRSTR\n"; } $lg=$lg."k"; print "

    日記撰寫及編輯

    \n"; print "
    \n"; print "

    內文

    \n"; print ""; print "\n"; } print "\n"; $Title=&tagenc($Title); print "\n"; print "\n"; print "\n"; print "
    日期\n"; if( $first eq "Yes" ){ undef $daysub; $Category=0; }else{ local($yd); &MakeNickyFname(); &MakeDateStr(); $yd=sprintf("%04d%02d%02d%s%s%s_%08x",$year,$month,$day,$daysub,$hour,$min,$Category); print "$IT\"HIDDEN\" name=\"DATE\" value=\"$yd\">\n"; } $nCategory=$Category if( !$stage2nd ); $lg=$lg."y"; print "年"; print "月"; print "日\n"; if( $hour >= 0 ){ print "$IT\"CHECKBOX\" name=\"PutTime\" class=\"button4\" value=\"Yes\""; print " CHECKED" if( $PutTime eq "Yes" ); print ">顯示時間\n"; } print "$IT\"HIDDEN\" name=\"hour\" value=\"$hour\">\n"; print "$IT\"HIDDEN\" name=\"min\" value=\"$min\">\n"; if( $para =~ /KAKUNIN/ ){ print "$IT\"submit\" name=\"CMNTEDIT\" class=\"button1\" value=\"編修該日日記\">\n"; print ""; if( open(RD, "./catelist.cgi") ){ my($cn, $num, $pk, $lstr, $idstr); my(@ff); my $i=0; my $str,$catedat,$hp; binmode RD; for $str(){ my(@f); $str=~s/\r|\n//; next if( !$str ); $i++; next if( $i < 3 ); ($cn, $num, $pk, $lstr, $idstr)=split(/,/, $str); $j=$i-3; @f=($cn, $num, $pk, $lstr, $idstr); $ff[$j]=\@f; } close RD; @ff=sort{$$a[1] <=> $$b[1]} @ff; for $str(@ff){ $idstr=$$str[4]; next if( $idstr eq "idrst" ); next if( $idstr == 0 ); if( $idstr > 1 ){ $j=1<<($idstr-1) }else{ $j=$idstr; } if( $nCategory & $j ){ $hp=" checked";}else{$hp="";} $catedat.="$IT\"checkbox\" name=\"nCategory\" value=\"$j\"$hp>"; $catedat.="$$str[0]$br"; } if( $catedat ){ print "

    分類

    \n"; print "$catedat"; } # print "\n"; # print ""; print ""; } print "
    標題$IT\"TEXT\" size=\"60\" name=\"Title\" value=\"$Title\">"; print "
    內文 色彩樣本$br\n"; $message=&tagenc($message); print "\n"; print $inpute; print "
    意見欄行數: "; if( (stat("./tb.cgi"))[7] ){ print "$IT\"checkbox\" name=\"tbRcv\" value=\"Yes\""; print " CHECKED" if( $tbRcv eq "Yes" ); print ">接受Trackback"; } print " $IT\"CHECKBOX\" name=\"UrlLink\" value=\"Yes\""; print " CHECKED" if( $UrlLink eq "Yes" ); print ">URL自動加入超連結\n
    \n"; $fit_size=$Fit_size if( !$fit_size ); $fitstr="顯示寬度 $IT\"TEXT\" name=\"fit_size\" value=\"$fit_size\" size=\"3\" class=\"button2\">fit$IT\"CHECKBOX\" name=\"FitCheck\" value=\"ON\""; print "

    圖像關連

    "; print ""; $size1=(stat("$vDir/PaintBBS.jar"))[7]; $size4=(stat("$vDir/spainter.jar"))[7]; if( $GrpFileName ){ my(@fl,$evf); local($flag, $p2, $n); print ""; }else{ print ""; } print ""; $str="$HRSTR
    • 若是想更換圖像,請先刪除舊圖像之後再重新上傳或描繪。
    • 若是勾選「刪除附屬圖像」,按下確認也會把圖像刪除。
    \n"; }else{ print ""; print ""; if( $size1+$size4 > 0 ){ print""; } } print "
    $IT\"HIDDEN\" name=\"GrpFileName\" value=\"$GrpFileName\">"; $n=rindex($GrpFileName, "\."); $p2=substr($GrpFileName, 0, $n); @fl=&GetFileList("\\$NickyDir\\/$p2\\."); $flag=0; for (@fl){ if( ($_ ne "./$year/$GrpFileName") && ($_ ne "./$year/$p2.nky") && ($_ ne "./$year/$p2.cmnt") ){ $flag=1; $evf=$_; last; } } if( !$flag ){ print "event/spch/thumbnail: $IT\"FILE\" name=\"EventFile\" size=\"45\" MaxLength=\"200\">"; if( !$ThmPath ){ print $fitstr; print "CHECKED" if( $FitCheck eq "ON" ); print ">"; } print "
    刪除附屬圖像$IT\"CHECKBOX\" name=\"GrpFileDel\" value=\"Delete\">"; if( $flag ){ print " 刪除event/spcsh/thumbnail$IT\"CHECKBOX\" name=\"EventFileDel\" value=\"Delete\">"; if( !$ThmPath ){ print $fitstr; print "CHECKED" if( $FitCheck eq "ON" ); print ">"; } if( $evf =~ /pch$|spch$/ ){ print " $IT\"CHECKBOX\" class=\"button3\" name=\"RepLayout\" value=\"CHECKED\" $RepLayout>播放(上下)"; } } print "
    圖像檔案: $IT\"FILE\" name=\"GrpFile\" size=\"45\" MaxLength=\"200\" class=\"button1\">
    event/spch/thumbnail: $IT\"FILE\" name=\"EventFile\" size=\"45\" MaxLength=\"200\" class=\"button1\">"; print $fitstr; print "CHECKED" if( $FitCheck eq "ON" ); print ">
    呼叫繪圖板: "; if( $size1 > 0 ){ print "$IT\"submit\" name=\"Mode\" class=\"button1\" value=\"PaintBBS\">"; } if( $size4 > 0 ){ print " $IT\"submit\" name=\"Mode\" class=\"button1\" value=\"SPAINTER:Normal\">"; print " $IT\"submit\" name=\"Mode\" class=\"button1\" value=\"SPAINTER:Pro\">"; } print "
    "; print " 寬度 $IT\"TEXT\" name=\"image_width\" value=\"$image_width\" size=\"3\" class=\"button2\">"; print " 高度 $IT\"TEXT\" name=\"image_height\" value=\"$image_height\" size=\"3\" class=\"button2\">"; $layerNum=9 if( !$layerNum ); print " 圖層 $IT\"TEXT\" name=\"layerNum\" value=\"$layerNum\" size=\"3\" class=\"button2\">"; print " 壓縮率 $IT\"TEXT\" class=\"button3\" name=\"CompressL\" value=\"$CompressL\" size=\"3\">"; print " Quality $IT\"TEXT\" class=\"button3\" name=\"Quality\" value=\"$Quality\" size=\"3\">"; print " $IT\"CHECKBOX\" class=\"button3\" name=\"AnimeSave\" value=\"True\" CHECKED>可播放"; print " $IT\"CHECKBOX\" class=\"button3\" name=\"RepLayout\" value=\"CHECKED\" $RepLayout>播放(上下)"; print "
    圖像顯示位置:"; @a=("左 ","右 ","上 ","下 ", "左上 ", "右上 ", "上中 ", "下中 "); for($i=0; $i<8; $i++){ print "$IT\"RADIO\" class=\"button2\" name=\"Layout\" value=\"$i\""; print " CHECKED" if( $i == $Layout ); print " >$a[$i]"; } print "
    "; print "

    $IT\"submit\" class=\"button1\" name=\"KAKUNIN\" value=\"預覽\"> "; print "$IT\"submit\" class=\"button1\" name=\"KAKUNINH\" value=\"加上檔頭預覽\"> "; print "$IT\"submit\" class=\"button1\" name=\"WRITE\" value=\"寫入\">"; print "

    \n\n
    $str"; &nickyGetHead(); $efoot=~s/\$passwd/$pass/g; print "
    $efoot
    "; print "\n"; } sub put_editstyle{ print < html_eof } # #日記編寫 # sub Nicky{ &GetDateLocaltime(); &PutHTMLheader(); print "nicky!日記編寫"; &put_editstyle(); &get_inputarea(); print $inputh; print ""; print ""; $PutTime=$PutTimeDefault; $FitCheck=$Fit; $tbRcv=$tbRcvDef; $UrlLink="Yes"; $Category="-1"; &PutEditNicky(KAKUNIN); } sub ReqJcode { local($ret); $ret = 0; if( !$flag_jcode ){ if( eval("require '$vDir/jcode.pl'") ){ $flag_jcode=1; $ret=1; }else{ $flag_jcode=2; } }elsif( $flag_jcode == 1 ){ $ret=1; } $ret; } # # 日記編寫(iMODE版) # sub NickyIMODE { my($opt)=@_; my($optmsg); local($str); if( $opt eq "edit" ){ $optmsg=""; }else{ $optmsg=""; } $ITT=""; if( $daysub ){ my($ct); $ct=sprintf("_%08x") if( $Category ); $str.=<$ITT"GrpFileName" value="$GrpFileName">$ITT"Layout" value="$Layout">$ITT"CommentRecv" value="$CommentRecv">$ITT"fit_size" value="$fit_size">$ITT"FitCheck" value="$FitCheck">$ITT"RepLayout" value="$RepLayout"> NIMS_EOF ; } $str.=<$br內文$br $br PassWord$br $optmsg NIM_EOF ; &jcode'euc2sjis(\$str) if( &ReqJcode() ); print $str; } # # 日記編輯(iMODE) # sub NickyEditIMODE{ my($opt)=@_; my(@lst); if( $daysub ){ &MakeNickyFname(); }else{ @lst=&GetNickyList("r"); $gfn=$lst[0]; $NickyFname=$$gfn[0]; &GetDateFromFname(); } &GetNickyFile("$vDir/$NickyFname"); $Message=&message_br($Message); &NickyIMODE($opt); } # # 由iMODE接收 # sub RecvIMODE{ if( &ReqJcode() ){ &jcode'sjis2euc(\$Title); &jcode'sjis2euc(\$Message); &jcode'sjis2euc(\$passwd); } if( &AdminCheck($passwd) ){ &GetDateLocaltime() if( !$daysub ); $hour=sprintf("%02d", $hour); $min=sprintf("%02d", $min); $PutTime=$PutTimeDefault; &NickyRight(); }else{ &NickyIMODE("edit"); } } sub DeleteImode{ if( &AdminCheck($passwd) ){ &NickyDelete("true"); }else{ &PutHTMLheaderSJIS(); print "Invalid PassWord\n"; } exit; } # # 意見欄輸出 # sub PutComment { my($name, $msg, $time, $ctloop); if( ($cf_size > 0) || $CMNT_Name || $CMNT_MSG ){ print "
      "; if( $cf_size ){ open(RDC, $NickyComment); binmode(RDC); while(){ local($str2); $ctloop=0; ($name, $msg, $time)=split/\x01/; while( $time == "" ){ ($str2, $time)=split(/\x01/, ); $msg.=$str2; $ctloop++; last if( $ctloop > 50 ); } chop $time; $msg=~s/\n/$br/g; $msg=&ConvertMsg($msg); $msg=&Effect($msg); if($msg!~/url|href/){ print "
    • $name($time)$br\n"; print "$msg\n"; } } close(RDC); } #Kano1 if( ($Mode =~ /CPREVIEW/) && ($CMNT_Name || $CMNT_MSG) ){ $msg=$CMNT_MSG; $msg=~s/\n/$br/g; $msg=&ConvertMsg($msg); $msg=&Effect($msg); $name=$CMNT_Name; $time=&MakeCommentTime(); if($msg!~/url|href/){ print "
    • $name($time)$br\n"; print "$msg\n"; } } if($msg!~/url|href/){ print "
    \n"; } } } # # 意見欄輸出(iMODE) # sub PutCommentIMODE { local($name, $msg, $time, $size, $ctloop); $size=(stat($NickyComment))[7]; if( $size > 0 ){ print "
      "; open(RDC, $NickyComment); binmode(RDC); while(){ local($str2); $ctloop=0; ($name, $msg, $time)=split/\x01/; while( $time == "" ){ ($str2, $time)=split(/\x01/, ); $msg.=$str2; $ctloop++; last if( $ctloop > 50 ); } chop $time; $msg=~s/\n/$br/g; $str="
    • $name($time)$br"; &zenkakuhankaku(); print $str; $str=$msg; &zenkakuhankaku(); print $str; } close(RDC); print "
    \n"; } } # # 意見編輯 # sub EditComment { local($cnt, $ctloop); &PutHTMLheader(); &MakeNickyFname(); print "意見欄編輯\n\n\n"; print "$br意見欄編輯$br$br\n"; print "※刪除發言人姓名即可刪除該意見$br$br\n"; print "
    \n"; &InsertDateTag(); $cnt=0; open(RDC, $NickyComment); binmode(RDC); while(){ local($str2); s/\"/"/g; $ctloop=0; ($name, $msg, $time)=split/\x01/; while( $time == "" ){ ($str2, $time)=split(/\x01/, ); $msg.=$str2; $ctloop++; last if( $ctloop > 50 ); } chop $time; print "Name \n"; print "Date \n"; $msg=~s/&/&/g; print "Message \n"; print "$br\n"; $cnt++; } print "\n"; print "\n"; print "\n"; } # # 寫入編輯好之意見 # sub WriteComment { my($i); &MakeNickyFname(); open(WDC, '>'.$NickyComment); binmode(WDC); for($i=0; $i <= $CmntCnt; $i++){ if( $CmntName[$i] && $CmntMsg[$i] && $CmntTime[$i] ){ # $CmntMsg[$i]=~s/&/&/g; print WDC "$CmntName[$i]\x01$CmntMsg[$i]\x01$CmntTime[$i]\n"; } } close(WDC); &MakeHTMLone($year, $month, $day, $daysub, 0); &MakeNickyLast(); } # # 由$NickyFname取得日期 # sub GetDateFromFname { local($gomi, $fname); local($gomi1, $p1, $p2); $p1=rindex($NickyFname, "\/",); $p2=rindex($NickyFname, "\/",$p1-1); $gomi1=substr($NickyFname, $p2); ($gomi, $year, $fname)=split(/\//, $gomi1); $month=substr($fname,0,2); $day=substr($fname,2,2); $daysub=substr($fname,4,1); if( substr($fname,5,1) eq "_" ){ $Category=hex(substr($fname,6,8)); $a=substr($fname,6,8); #print "::Category=$Category, a=[$a], fname=[$fname], NF=[$NickyFname]
    \n"; }else{ $Category=""; } } # # 加入日期標籤 # sub InsertDateTag { my($ct); $ct=sprintf("_%08x", $Category); print "\n|
    /i, $data) ){ $add=$ade=""; if( ($EffectSTR1) && ($honbun =~ /^$EffectSTR1/) ){ $add = ""; $ade=""; }elsif( ($EffectSTR2) && ($honbun =~ /^$EffectSTR2/) ){ $add = ""; $ade=""; }elsif( ($EffectSTR3) && ($honbun =~ /^$EffectSTR3/) ){ $add = ""; $ade=""; }elsif( ($EffectSTR4) && ($honbun =~ /^$EffectSTR4/) ){ $add = ""; $ade=""; } # $honbun =~ s/$tag2lf|$tag3lf/$ade$&/; # if( $honbun !~ /$|<\/td>|<\/tr>|$tag2lf|$tag3lf/i ){ if( $honbun !~ /$|<\/td>|<\/tr>||<\/dt>|<\/dd>|<\/p>|<\/li>||/i ){ $honbun.="$br"; } $ret.="$add$honbun$ade"; } $ret=~s/$br$//i; $ret; } # # 日記確認 # sub NickyKakunin { my($para)=@_; $HRSTR="
    "; &get_inputarea(); if( $para eq "NORMAL" ){ &PutHTMLheader(); &put_editstyle(); }else{ &nickyGetHead(); $head=~s/<\/head>/$inputh<\/head>/i; print &put_macro($head); } $message = $Message; $Message =~ s/\n/$br/g; &MakeDateStr(); $lg=$lg."c"; if( $para eq "NORMAL" ){ # print ""; print "確認$inputh
    確定後請按「寫入」按鍵。$HRSTR
    $br$br\n"; &PutNickyOneDay(); print "
    "; }else{ &PutNickyOneDay(); } &PutEditNicky(WRITE); } sub message_br{ my($dat)=@_; $dat=~s/\r//g; if( $tagbr eq "p" ){ $dat=~s/$tag3lf/\n\n\n/g; $dat=~s/$tag2lf/\n\n/g; } $dat=~s/
    /\n/ig; $dat=~s/
    /\n/ig; $dat; } # # 編輯指定時間的日記 # sub NickyEdit { my(@fl, $fn); if( (!$year) && ($nyear) ){ $year=$nyear; $month=$nmonth; $day=$nday; $Category=$nCategory; undef $daysub; } $UrlLink="Yes"; $PutTime=$PutTimeDefault; $FitCheck=$Fit; if( !$daysub ){ &PutHTMLheader(); print "日記編輯\n\n"; $NickySPath=sprintf("$vDir/%04d/%02d%02d*\\.nky", $year, $month, $day); @fl=&GetFileList($NickySPath); $find=$#fl; if( $find > 0 ){ $ModeSub=1; for $fn(@fl){ $NickyFname="$vDir/$fn"; &GetNickyFile($NickyFname); &PutNickyOneDay(); print "$br$br"; } print ""; exit; } $daysub="A"; } $ModeSub=4; &MakeNickyFname(); &GetNickyFile($NickyFname); $Message=&message_br($Message); &NickyKakunin(NORMAL); } # # 刪除指定的日記 TRUE=unlink(Grp); # sub NickyDelete { my($flag)=@_; my($oldFname, $o, $n, $p, @fl); my($op, $np); my($f, $cnt, $fn, $dmy, $ctg); &MakeNickyFname(); &GetNickyFile($NickyFname); # 取得圖像檔名 unlink($NickyFname); # 刪除內文 $f="$month$day"; if( ($GrpFileName) && ($flag) ){ $n=rindex($GrpFileName, "\."); $oldFname=substr($GrpFileName,0,$n); @fl=&GetFileList("$NickyDir/$oldFname\\."); for $p(@fl){ unlink("$vDir/$p"); } } unlink($NickyComment); $dsub=ord($daysub)-0x41; $cnt=0; $oldFname=$NickyFname; @fl=&GetFileList($NickySPath); for $p(@fl){ $cnt++; if( $cnt > $dsub ){ $NickyFname="$vDir/$p"; $p=sprintf("$year/$f%c",$cnt+0x40); ($dmy, $ctg)=split(/_/, $NickyFname); if( !$ctg ){ $fn="$p.nky"; }else{ $fn="$p\_$ctg"; } rename($NickyFname, "$vDir/$fn"); # 以下將意見欄改名 $n="$vDir/$p.cmnt"; $o=sprintf("$vDir/$year/$f%c.cmnt", $cnt+0x41); rename($o, $n); # 意見欄改名到此為止 $oldFname="$vDir/$p"; } } if( $flag ){ eval('require("./tb.cgi")'); unless( $@ ){ del_daytb($year, $month, $day, $daysub); } # &GetDateFromFname(); &MakeHTMLone($year, $month, $day, $daysub, 1); &MakeNickyLast(); } } # # 確定刪除指定之日記 # sub NickyDeleteConfirm { &MakeNickyFname(); &GetNickyFile($NickyFname); $ModeSub=2; &PutNickyOneDay(); print "$br您將要刪除本篇日記$br確定的話請按下刪除鍵。"; } # # 寫入日記檔 # sub WriteNickyFile{ my($r, $p); $r=rindex($NickyFname, "\/"); $p=substr($NickyFname, 0, $r); mkdir($p, 0777) if( !-e $p ); undef $fit_size if( $FitCheck ne "ON" ); open(WR, ">$NickyFname"); binmode(WR); print WR "$Date\x01"; print WR "$Title\x01"; print WR "$Message\x01"; print WR "$GrpFileName\x01"; print WR "$Layout\x01"; print WR "$CommentRecv\x01"; print WR "$fit_size\x01"; print WR "$RepLayout\x01"; print WR "$tbRcv\x01"; close(WR); } sub WriteNicky { $Message=~s/\r//g; if( $tagbr eq "p" ){ $Message=~s/\n\n\n/$tag3lf/g; $Message=~s/\n\n/$tag2lf/g; $Message=~s/\n$/$br/; } $Message=~s/\n/$br/ig; &MakeDateStr(); &MakeNickyFname(); &WriteNickyFile(); } # # That's Right!! # sub NickyRight { &WriteNicky(); &MakeNickyLast(); } sub GetFileList { my($opt)=@_; my($i, @pt, $dirname, $fname, $f, $p1, $p2); $p1=rindex($opt,"\/"); $p2=rindex($opt,"\/", $p1-1); $opt=substr($opt, $p2); $i=0; undef @pt; opendir(RDD, "$vDir/$year/"); for $fname( readdir(RDD) ){ $f="./$year/$fname"; $pt[$i++]=$f if( $f =~ /$opt/ ); } close(RDD); @pt; } sub GetNickyList{ my($opt)=@_; my($i, $tmp, @pt, $ctry, $hexctg); if( ($opt eq "r") || ($opt eq "t") || ($opt eq "tr") ){ $tmp="^[0-1][0-9][0-3][0-9][A-Za-z].*\\.nky\$"; }else{ $tmp="^[0-1][0-9][0-3][0-9][A-Za-z].*\\.nky\$|^[0-1][0-9][0-3][0-9][A-Za-z]\\.cmnt\$"; } $i=0; undef @pt; if( opendir(RD, "$vDir/") ){ for $dirname( readdir(RD) ){ if( $dirname =~ /^[1-9][0-9][0-9][0-9]$/ ){ opendir(RDD, "$vDir/$dirname"); for $fname( readdir(RDD) ){ my(@fn, $f); if( $fname =~ /$tmp/ ){ if( $ctg ){ my($fn, $ctg1)=split(/_/, $fname); my($ctgdat, $dummy)=split(/\./, $ctg1); next if( !($ctg & hex($ctgdat)) ); } $f="/$dirname/$fname"; @fn=($f, (stat("$vDir/$dirname/$fname"))[10]); $pt[$i]=\@fn; $i++; } } close(RDD); } } } close(RD); return sort{$$b[1] cmp $$a[1]} @pt if( ($opt eq "t") || ($opt eq "tc") ); if( $opt eq "tr" ){ return reverse(sort{$$b[0] cmp $$a[0]} @pt); }else{ return sort{$$b[0] cmp $$a[0]} @pt; } } # 尋找指定的日記在第幾頁 sub SerchPageFromDate { local($gomi, $fn, $fname, @oldname, $gyear, @oldyear); local($cnt, $page, $gfn); local($syear, $smonth, $sday, $sdaysub, $i); my($ofn, $p1, $p2); $syear=$year;$smonth=$month;$sday=$day;$sdaysub=$daysub; $Category=$ctg if( $ctg ); &MakeNickyFname(); $p1=rindex($NickyFname, "\/"); $ofn=substr($NickyFname, $p1+1, 5); $cnt=0; @nli=&GetNickyList($Age) if( !@nli ); for $gfn(@nli){ next if( $$gfn[0] !~ /\.nky$/ ); $NickyFname=$$gfn[0]; ($gomi, $gyear, $fname)=split(/\//, $$gfn[0]); ($fn, $gomi)=split(/\./, $fname); last if( ($year == $gyear) && (substr($fn, 0, 5) eq $ofn) ); $oldyear[$i]=$gyear; $oldname[$i]=$fn; $cnt++; } if( !&IsIMODE() ){ if( $cnt < $PrintDay ){ $page=0; }else{ $page=(($cnt+1)-$PrintDay)/$PageCnt; $page++ if( $page != int((($cnt+1)-$PrintDay)/$PageCnt) ); } $PageNo=int($page); &NickyPageOut($PageNo); }else{ if( $cnt < $PrintiDay ){ $page=0; }else{ $page=(($cnt+1)-$PrintiDay)/$PageiCnt; $page++ if( $page != int((($cnt+1)-$PrintiDay)/$PageiCnt) ); } $PageNo=int($page); &NickyPageOutIMODE($PageNo); } } sub GetIndexList{ my($i, @pt, $fname); undef @pt; if( opendir(RD, "$vDir/") ){ for $fname( readdir(RD) ){ if( $fname =~ /^nkyIndex[1-9][0-9][0-9][0-9][0-1][0-9]\.cgi$/ ){ $pt[$i]=$fname; $i++; } } } close(RD); @pt; } sub GetHTMLlist{ my($i, @pt, $fname); undef @pt; opendir(RD, "$vDir/"); { for $fname( readdir(RD) ){ if( $MsgOldForm !~ /1/ ){ if( $fname =~ /^$LogFname[1-9][0-9][0-9][0-9][0-1][0-9]\.html$/ ){ $pt[$i]=$fname; $i++; } }else{ if( $fname =~ /^$LogFname[0-9][0-9][0-9][0-9][0-9]\.html$/ ){ $pt[$i]=$fname; $i++; } } } } close(RD); @pt; } # # 頁面輸出模式 # 取得參數之後將頁面輸出 # $PrintDay=最新顯示件數 # $PageCnt =指定過去記錄件數時所顯示之件數 # sub NickyPageOut { local($gomi, $fn, $fname, @oldname, @oldyear); local($cnt, $outcnt, $startno, $find); local($pageno, $flaglog, $gfn); my(@fl, $hd, $ft, $out_1st, $ctgl); &nickyGetHead(); $pageno=$_[0]; # 計算開始輸出的編號 if( $pageno == 0 ){ $startno=0; $hd=$head; $ft=$foot; }else{ $startno=$PrintDay+($pageno-1)*$PageCnt; if( $Use2ndHD eq "Yes" ){ $hd=$head2nd; }else{ $hd=$head; } if( $Use2ndFT eq "Yes" ){ $ft=$foot2nd; }else{ $ft=$foot; } } $outcnt = $page == 0 ? $PrintDay:$PageCnt; $outcnt+=$startno; $ModeSub=16; $cnt=$flaglog=0; unless( @nli ){ @nli=&GetNickyList($Age) }else{ if( $mkHTML ){ if( ($Age eq "t") || ($Age eq "tc") ){ @nli=sort{$$b[1] cmp $$a[1]} @nli; }elsif( $Age eq "tr" ){ @nli=reverse(sort{$$b[0] cmp $$a[0]} @nli); }else{ @nli=sort{$$b[0] cmp $$a[0]} @nli; } } } for $gfn(@nli){ ($gomi, $year, $fname)=split(/\//, $$gfn[0]); ($fn, $gomi)=split(/\./, $fname); $flag=0; for($i=0; $i<$cnt; $i++){ if( ($oldyear[$i] eq $year) && ($oldname[$i] eq $fn) ){ $flag=1; last; } } if( $flag == 0 ){ $oldyear[$i]=$year; $oldname[$i]=$fn; if( $cnt >= $startno ){ $NickyFname="$vDir/$year/$fn.nky"; if( $cnt >= $outcnt ){ $flaglog=1; last; } &GetNickyFile($NickyFname); next if(!$Title && !$Message && (!$Admin || $mkHTML)); $NickyComment="$vDir/$year/$fn.cmnt"; if( !$out_1st ){ $month=substr($fn, 0, 2); print &put_macro($hd); if( ($MsgOldForm == 2) || ($MsgOldForm == 4) ){ &PutMonthTag("UP", ""); print "$br\n"; } $out_1st=1; } &PutNickyOneDay(); print $br; } $cnt++; } } print &put_macro($hd) if( !$out_1st ); # $MsgOldForm:0,2=月, 1=件數 # $MsgOld1st:將最新頁面設入過去記錄 0是, 1否, 2完全不列入 $ctgl="\?ctg=$ctg" if( $ctg ); if( ($page == 0) && ($MsgOld1st == 2) ){ }elsif( $MsgOldForm == 1 ){ print "
    \n"; if( !$mkHTML || $SaveHTML ne "ON" ){ print "$MsgNew " if( $pageno ); if( ($pageno!=0) || ($MsgOld1st==0) ){ if( $MsgPageOut ){ &PutPageTag(); }else{ print $MsgOldBetween; } } print "$MsgOld" if( $flaglog ) ; }else{ # 當成page=0就行 my($target, $fnh); $cnt=@nli-$PrintDay; $target=int($cnt/$PageCnt); $target-- if( !($cnt % $PageCnt) ); $fnh=&MakePageFname($target); $gfn=$nli[$PrintDay]; ($gomi, $year, $fname)=split(/\//, $$gfn[0]); ($fn, $gomi)=split(/\./, $fname); print "$MsgOld" if( $flaglog ) ; } print "\n
    \n"; print "$br$br一覽 / 搜尋 " if( $PutSerchTagFlag ); }else{ local($fn, $str, $cyear, $cmon, $mh); undef $str; if( ($Age eq "t") || ($Age eq "tc") ){ $gomi=$fl[0]; $fn=$$gomi[0]; $cyear=substr($fn, 2, 4); $cmon=substr($fn, 7, 2); if( !$mkHTML || ($SaveHTML ne "ON") ){ $str=sprintf("$cgipath?DATE=%04d%02d$ctgl?MODE=MONTH", $cyear, $cmon); }else{ $mh=&MakeMonthFname($cyear, $cmon); $str="$www/$mh"; } }elsif( $Age eq "r" ){ if( $NickyFname ){ &GetDateFromFname(); if( !$mkHTML || ($SaveHTML ne "ON") ){ $str=sprintf("$cgipath?DATE=%04d%02d$ctgl?MODE=MONTH#%04d%02d%02d%s", $year, $month, $year, $month, $day, $daysub); }else{ $mh=&MakeMonthFname($year, $month); $str=sprintf("$www/$mh#%04d%02d%02d%s", $year, $month, $day, $daysub); } } } if( $MsgOld1st == 0 ){ &PutMonthTag("DOWN", $str) if( ($MsgOldForm == 0) || ($MsgOldForm == 4) ); }elsif( $str ){ print "\n"; } } print &put_macro($ft); } # # 頁面輸出模式(iMODE版) # 取得參數之後將頁面輸出 # sub NickyPageOutIMODE { local($pageno)=@_; local($gomi, $fn, $fname, @oldname, @oldyear); local($cnt, $outcnt, $startno, $find, $gfn); local($flaglog, $sts); my($pgout); $PrintDay=$PrintiDay; # 第一頁顯示篇數 $PageCnt=$PageiCnt; # 其他頁面顯示篇數 # 計算開始輸出的編號 if( $pageno == 0 ){ $startno=0; }else{ $startno=$PrintDay+($pageno-1)*$PageCnt; } $outcnt = $page == 0 ? $PrintDay:$PageCnt; $outcnt+=$startno; $ModeSub=16; # 輸出檔頭 &nickyGetHead(); $sts=&ReqJcode(); &jcode'euc2sjis(\$iHead) if( $sts ); print $iHead; print "
    "; $cnt=$flaglog=0; for $gfn(&GetNickyList($Age)){ ($gomi, $year, $fname)=split(/\//, $$gfn[0]); ($fn, $gomi)=split(/\./, $fname); $flag=0; for($i=0; $i<$cnt; $i++){ if( ($oldyear[$i] eq $year) && ($oldname[$i] eq $fn) ){ $flag=1; last; } } if( $flag == 0 ){ $oldyear[$i]=$year; $oldname[$i]=$fn; if( $cnt >= $startno ){ if( $cnt >= $outcnt ){ $flaglog=1; last; } $NickyFname="$vDir/$year/$fn.nky"; &GetNickyFile($NickyFname); ($fn, $gomi)=split(/_/, $fn); $NickyComment="$vDir/$year/$fn.cmnt"; &PutNickyOneDayIMODE(); } $cnt++; } } # $MsgOldForm:0,2=月, 1=件數 # $MsgOld1st:將最新頁面設入過去記錄 0是, 1否 if( $pageno ){ $pgout=$MsgNew; &jcode'euc2sjis(\$pgout); print "$pgout "; } if( $flaglog ){ $pgout=$MsgOld; &jcode'euc2sjis(\$pgout); print "$pgout"; } close(RDD); &jcode'euc2sjis(\$iFoot) if( $sts ); print $iFoot; } # # 按月輸出模式 # 輸出 $year, $month 所指定的月份 # sub NickyMonthOut { my($sp, $gomi, $fn, $fname); my($tuki, $nen, @list); my($dmy, $ctgd, $ctgh); $nen=$year; $tuki=$month; $ModeSub=16; # 輸出檔頭 &nickyGetHead(); if( $Use2ndHD eq "Yes" ){ print &put_macro($head2nd); }else{ print &put_macro($head); } if( ($MsgOldForm == 2) || ($MsgOldForm == 4) ){ &PutMonthTag("UP", ""); print "$br\n"; } $i=0; $year=$nen; $sp=sprintf("^./%04d/%02d...*\\.nky\$", $nen, $tuki); @list=&GetFileList($sp); @list=sort @list; @list=reverse(@list) if( $MonthSort eq "UP" ); print "\n\n"; for $fn(@list){ if( $ctg ){ ($dmy, $ctgd)=split(/_/, $fn); next unless( $ctgd ); $ctgh=hex(substr($ctgd, 0, 8)); next unless( $ctg & $ctgh ); } $NickyFname="$vDir/$fn"; &GetNickyFile($NickyFname); next if( !$Title && !$Message && (!$Admin || $mkHTML) ); if( $saveExec || $Admin && $mkHTML ){ &GetDateFromFname(); print WDI "$day\x01$daysub\x01$Title\x01$GrpFileName\n"; } $NickyComment="$vDir/$year/$fn.cmnt"; &PutNickyOneDay(); print "$br"; } print "\n\n"; &PutMonthTag("DOWN", "") if( ($MsgOldForm == 0) || ($MsgOldForm == 4) ); if( $Use2ndFT eq "Yes" ){ print &put_macro($foot2nd); }else{ print &put_macro($foot); } } sub MakeIndex{ my($y, $m)=@_; local($aaa,@list, $fname, $fn); $year=$y; $aaa=sprintf("^./%04d/%02d...*\\.nky\$", $year,$m); @list=&GetFileList($aaa); @list=sort @list; @list=reverse(@list) if( $MonthSort eq "UP" ); $fn=&MakeMonthIndexFname($y, $m); open(WDI, ">$vDir/$fn"); for $fname(@list){ $NickyFname="$vDir/$fname"; &GetNickyFile($NickyFname); next if( !$Title && !$Message ); if( $Admin && $mkHTML ){ &GetDateFromFname(); print WDI "$day\x01$daysub\x01$Title\x01$GrpFileName\n"; } } close(WDI); } #Kano3 sub MakeMonthFname{ my($y, $m)=@_; my($str); $str=sprintf("$LogFname%04d%02d.html", $y, $m); $str; } sub MakeMonthIndexFname{ my($y, $m)=@_; my($str); $str=sprintf("nkyIndex%04d%02d.cgi", $y, $m); $str; } sub SaveMonthHTMLone{ my($y, $m)=@_; my($fn); $saveExec=1; $fn=&MakeMonthIndexFname($y, $m); open(WDI, ">$vDir/$fn"); $fnHTML=&MakeMonthFname($y, $m); open(WD, ">$vDir/$fnHTML"); binmode WD; select WD; &NickyMonthOut(); close(WD); close(WDI); select STDOUT; $saveExec=0; } sub MakeDummyIndex{ my($para)=@_; my($gfn, $fn); local(@mnl); if( @nli ){ @mnl=@nli; }else{ @mnl = &GetNickyList("tr") if( !@mnl ); } $omon=$oyear=0; for $gfn( @mnl ){ ($gomi, $year, $fname)=split(/\//, $$gfn[0]); $mon=substr($fname, 0, 2); if( ($oyear != $year) || ($omon != $mon) ){ if( $oyear != $year ){ $oyear=$year; $omon=0; } if( $para ){ &MakeIndex($year, $mon); }else{ $fn=&MakeMonthIndexFname($year, $mon); open(WDI, ">$vDir/$fn"); close(WDI); } $omon=$mon; } } } #$flag = 0: 只變更符合的內容 # = 1: 對應所有內容 sub MakeHTMLone{ local($y, $m, $d, $ds, $flag)=@_; return if( $SaveHTML ne "ON" ); ($year, $month, $day, $daysub)=($y, $m, $d, $ds) unless( $year ); $mkHTML=1; if( $MsgOldForm !~ /1/ ){ &SaveMonthHTMLone($y, $m); }else{ local($p, $p1, $y2, $m2, $d2, $ds2, $nday, $nday2, $i, $j, $pnum); @nli=&GetNickyList("tr") if( !@nli ); unless( $flag ){ $p="/$year/$month$day$daysub.nky"; $j=0; for $p1(@nli){ last if( $$p1[0] eq $p ); $j++; } $pnum=int($j/$PageCnt); &MakeOnePageHTML($pnum, 0); }else{ $i=$#nli; $p1=$nli[$i]; $p=rindex($$p1[0], "\/"); $m2=substr($$p1[0], $p+1,2); $d2=substr($$p1[0], $p+3,2); $ds2=substr($$p1[0], $p+5,1); $y2=substr($$p1[0], $p-4, 4); $nday=$y*100000+$m*1000+$d*10+ord($ds)-0x41; $nday2=$y2*100000+$m2*1000+$d2*10+ord($ds2)-0x41; if( $nday >= $nday2 ){ $pnum=int($i/$PageCnt); if( !($i % $PageCnt) && $i ){ $pnum-=1; &MakeOnePageHTML($pnum, 1); $pnum++; } &MakeOnePageHTML($pnum, 1); }else{ &MakePageHTML(); } } } $mkHTML=0; } sub MakePageFname{ my($pageno)=@_; sprintf("$vDir/$LogFname%05d.html", $pageno); } # # 頁面輸出模式 # 取得參數之後將頁面輸出 # $PrintDay=最新顯示件數 # $PageCnt =指定過去記錄件數時所顯示之件數 # sub MakeOnePageHTML { my($pageno, $para)=@_; local($gomi, $fn, $fname, @oldname, $cnt); local($flaglog, $gfn, $hfname); my($hd, $ft, $i, $newfname, $oldfname, $out_1st); $saveExec=1; $hfname=&MakePageFname($pageno); open(WD, ">$vDir/$hfname"); binmode WD; select WD; &nickyGetHead(); if( $Use2ndHD eq "Yes" ){ $hd=$head2nd; }else{ $hd=$head; } if( $Use2ndFT eq "Yes" ){ $ft=$foot2nd; }else{ $ft=$foot; } $ModeSub=16; $flaglog=0; $cnt=($pageno+1)*$PageCnt-1; for($i=$cnt; $i>$cnt-$PageCnt; $i--){ $gfn=$nli[$i]; ($gomi, $year, $fname)=split(/\//, $$gfn[0]); ($fn, $gomi)=split(/\./, $fname); unless( $fn ){$flaglog=1;next;} $NickyFname="$vDir/$year/$fn.nky"; &GetNickyFile($NickyFname); $NickyComment="$vDir/$year/$fn.cmnt"; next if( !$Title && !$Message ); &GetDateFromFname(); if( !$out_1st ){ $out_1st=1; print &put_macro($hd); print "\n\n"; } &PutNickyOneDay(); if( $para ){ &MakeIndex($year, $month); $para=0; } print "$br"; } if( !$out_1st ){ print &put_macro($hd); print "\n\n"; } print "\n\n"; $flaglog=1 if( $pageno == int($#nli/$PageCnt) ); $newfname=&MakePageFname($pageno+1); $oldfname=&MakePageFname($pageno-1); print "$MsgNew " if( !$flaglog ); print $MsgOldBetween; print "$MsgOld" if( $pageno ); print "$br$br一覽 / 搜尋 " if( $PutSerchTagFlag ); print &put_macro($ft); close(WD); select STDOUT; $saveExec=0; } sub MakePageHTML { my($i, $j, $pageno, $str, $cnt, $cntl, $lastpage, $oy, $om); $mkHTML=1; # 全件數計算 @nli=&GetNickyList("tr") if( !@nli ); $i=$#nli; &MakeDummyIndex(1); # 從舊的頁面開始製作.最舊=2 $pageno=0; $om=$oy=-1; for($j=0;$j<$i;$j+=$PageCnt){ &MakeOnePageHTML($pageno, 0); $pageno++; } } sub MakeMonthHTML{ my($gfn, $fn); local(@mnl, $fnHTML, $bakmode); $mkHTML=1; $bakmode=$Mode; $Mode="MONTH"; &MakeDummyIndex(0); @mnl = &GetNickyList("tr") if( !@mnl ); $omon=$oyear=0; for $gfn( @mnl ){ ($gomi, $year, $fname)=split(/\//, $$gfn[0]); $mon=substr($fname, 0, 2); if( ($oyear != $year) || ($omon != $mon) ){ if( $oyear != $year ){ $oyear=$year; $omon=0; } $month=$mon; &SaveMonthHTMLone($year, $month); $omon=$mon; } } $Mode=$bakmode; } sub PutMonthTag_sub{ my($oyear, $omon, $mon, $dat)=@_; my($fn,$fe, $ctgt); $fe="
    " if( $tagpl ne "strict" ); if( $oyear != $year ){ $ycnt++; if( $oyear ){ $dat="$dat$fe\n"; } if( $tagpl eq "strict" ){ $dat="$dat$year$MsgOldYear"; }else{ $dat="$dat$year$MsgOldYear$fe"; } } if( ($SaveHTML eq "ON") && $mkHTML && !$ctg){ $fn=&MakeMonthFname($year, $mon); $dat="$dat$mon$MsgOldMonth "; }else{ $ctgl="\?ctg=$ctg" if( $ctg ); $dat="$dat$mon$MsgOldMonth "; } $dat; } # 視為過去記錄,以每月為單位輸出連結標籤 # para="DOWN":下 sub PutMonthTag { my($para, $lnk)=@_; my($gfn, $dat, $ycnt); local($dummy, $dummy2, $fe, $fname, $oyear, $omon, $mon, @mnl, @idxl); $oyear=$omon=0; if( ($SaveHTML eq "ON" ) && !$ctg ){ @idxl=&GetIndexList(); for $gfn( sort @idxl ){ #nkyIndex200402.cgi $year=substr($gfn, 8, 4); $mon=substr($gfn, 12,2); if( ($oyear != $year) || ($omon != $mon) ){ $dat=&PutMonthTag_sub($oyear, $omon, $mon, $dat); if( $oyear != $year ){ $ycnt++; $oyear=$year; $omon=0; } $omon=$mon; } } }else{ @mnl = &GetNickyList("tr") if( !@mnl ); for $gfn( @mnl ){ ($dummy, $year, $fname)=split(/\//, $$gfn[0]); $mon=substr($fname, 0, 2); if( ($oyear != $year) || ($omon != $mon) ){ $dat=&PutMonthTag_sub($oyear, $omon, $mon, $dat); if( $oyear != $year ){ $ycnt++; $oyear=$year; $omon=0; } $omon=$mon; } } } if( $tagpl eq "strict" ){ $dummy="class=\"mtable\""; $dummy2="class=\"pastmsg\""; $fe=""; }else{ $dummy="border=\"0\" bgcolor=\"$MsgOldOBgCol\""; $dummy2=" bgcolor=\"$MsgOldOBgCol\""; $fe=""; } print "\n$dat"; print "$fe\n
    \n$MsgOldLog "; print "" if( $lnk ); print "
    "; print "一覽 / 搜尋" if( $PutSerchTagFlag && ($para eq "DOWN")); } # 輸出頁面指定標籤 sub PutPageTag { local($i, $j, $str, $cnt, $cntl, $lastpage, $fs, $fe); my($ctgl); $ctgl="\?ctg=$ctg" if( $ctg ); $fs=$fe=""; if( $tagpl ne "strict" ){ $fs=""; $fe=""; } # 全件數計算 @nli=&GetNickyList("r") if( !@nli ); $i=$#nli+1; # 照件數份量連結 print $fs; if( ($i > $PrintDay) && ($PageNo) ){ print "$MsgOldNEWks$MsgOldNEW$MsgOldNEWke"; } $j=$i-$PrintDay; $lastpage=$j/$PageCnt; if( $j%$PageCnt ){ $lastpage=($j-($j%$PageCnt))/$PageCnt; $lastpage++; } $lastpage=0 if( $lastpage < 0 ); $maxpage=10; $cnt=$PageNo-($maxpage/2); $cntl=0; if( $cnt + $maxpage > $lastpage ){ $cnt=$lastpage-$maxpage; } if( $cnt < 1 ){ $cnt = 1; } for($j=$PrintDay+$cnt*$PageCnt; ($j<$i+$PaneCnt) && ($cntl<$maxpage) ; $j+=$PageCnt){ $str=$cnt; if( $cnt != $PageNo ){ print "$ks$str$ke"; }else{ print "$ks$str$ke"; } $cnt++; $cntl++; } print "$MsgOldOLDks$MsgOldOLD$MsgOldOLDke" if($lastpage!=$PageNo); print "$fe\n"; } sub write_exec{ if( open(RD, "./exelist.cgi") ){ my($f); while(){ $f=$_; eval(require($f)); goto_end($@) if( $@ ); } close RD; } } # # 製作最新X日數的日記 # sub MakeLastHTMLsub{ $mkHTML=1; open(WR, ">$vDir/$NickyHtml"); binmode(WR); select WR; &NickyPageOut(0, $PrintDay); close(WR); select STDOUT; &write_exec(); $mkHTML=0; } sub MakeNickyLast{ my($cn, $ccn); $MNLflag=1; $cn=$CMNT_Name; $ccn=$CommentCName; $CMNT_Name=""; $CommentCName=""; &MakeLastHTMLsub(); $CMNT_Name=$cn; $CommentCName=$ccn; if( &IsIMODE() ){ &NickyPageOutIMODE(0, $PrintDay); }else{ if( $Admin ){ &NickyPageOut(0, $PrintDay); }else{ print &PutFile("$vDir/$NickyHtml"); } } $MNLflag=0; } sub MakeLastHTMLcheck{ my($data, $hd, $ft); print "Content-type: text/html\n\n"; &MakeNickyFname(); if( !-e "$NickyFname" ){ print "file not found [$NickyFname]\n"; exit; } exit unless( open(RD, "$vDir/$NickyHtml") ); binmode(RD); while(){ $data.=$_; } close RD; ($hd, $ft)=split(/name=\"$year$month$day$daysub\"/, $data); if( $ft ){ print "exist"; exit; } if( $SaveHTML eq "ON" ){ &MakeHTMLone($year, $month, $day, $daysub, 0); } &MakeLastHTMLsub(); print "OK\n"; exit; } # # 將最新X日數的日記輸出為HTML # sub MakeLastHTML{ my($flg); $flg=0; &mobile_load(); if( $BBSmode eq "BBS" ){ $flg=1; }elsif( &AdminCheck($password) ){ $flg=1; } if( $flg ){ if( $daysub ){ &MakeLastHTMLcheck(); }else{ &MakeLastHTMLsub(); } } exit; } # # 返回 # sub NickyReturn { print "\n

    "; print "
    回日記頁
    "; print "
    \n"; } # # 搜尋關鍵字設定 # sub NickySetSearch { &nickyGetHead(); if( $UseSearchHD eq "Yes" ){ print &put_macro($head2nd); }else{ print &put_macro($head); } print "
    "; print " 搜尋關鍵字 "; print " "; print "
    \n"; &NickyReturn(); if( $UseSearchFT eq "Yes" ){ print &put_macro($foot2nd); }else{ print &put_macro($foot); } } sub SearchHTML() { my($a, @lst, $fn, @news, $day, $gomi, $b); @lst=&GetHTMLlist(); @lst=sort @lst; for $fn(@lst){ open(RDM, "$vDir/$fn"); binmode(RDM); $a=""; while(){ $a.=$_; } close(RDM); ($gomi, $b)=split(/<\/a>/, $a,2); ($a, $gomi)=split(/<\/a>/, $b,2); if( $tagmode eq "xhtml" ){ @news=split(/<\/a>/, $a); }else{ @news=split(/<\/a>/, $a); } for $day(@news){ print $day if( $day =~ /$SerchWord/ ); } } } # # 搜尋 # sub NickySerch { local($aaa, $gomi, $fn, $fname, $gfn); local($cnt, $find, $startno); local($pageno, $flaglog); $ModeSub=16; $Mode=MONTH; # 輸出檔頭 &nickyGetHead(); if( $UseSearchHD eq "Yes" ){ print &put_macro($head2nd); }else{ print &put_macro($head); } print "$br搜尋關鍵字「$SerchWord」的結果如下:$br

    \n"; $SerchWord=~s/\"/\\\"/g; $SerchWord=~s/\'/\\\'/g; $SerchWord=~s/\`/\\\`/g; $SerchWord=~s/ /\.\*/g; $SerchWord=~s/﹛/\.\*/g; $SerchWord=~s/\\/\\\\/g; $SerchWord=~s/\|/\\\|/g; $SerchWord=~s/\?/\\\?/g; $SerchWord=~s/\//\\\//g; $SerchWord=~s/\-/\\\-/g; $SerchWord=~s/\*/\\\*/g; $SerchWord=~s/\=/\\\=/g; $SerchWord=~s/\&/\\\&/g; $SerchWord=~s/\,/\\\,/g; $SerchWord=~s/\(/\\\(/g; $SerchWord=~s/\)/\\\)/g; if( $SaveHTML eq "ON" ){ &SearchHTML(); }else{ @nli=&GetNickyList("tr") if( !@nli ); for $gfn(@nli){ $NickyFname="$vDir/$$gfn[0]"; &GetDateFromFname(); &GetNickyFile($NickyFname); next if( !$Title && !$Message ); $msg=$SerchWord; next if( ($Message !~ /$SerchWord/) && ($Title !~ /$SerchWord/) ); &PutNickyOneDay(); print "$br"; } } &NickyReturn(); if( $UseSearchFT eq "Yes" ){ print &put_macro($foot2nd); }else{ print &put_macro($foot); } } # # 從日期計算星期 # sub GetWeek{ local($y,$m,$d)=@_; local($hour,$min,$sec, $i,$j,$dday, @monday, $gmt,$mm,$h,$s,$hg); @monday=('dummy','31','28','31','30','31','30','31','31','30','31','30','31'); $gmt = 1970; $mm = 1; $hg = 0; $hour=12;$min=0;$sec=0; for($i=$gmt;$i<$y;$i=$i+1){ if ((($i % 4 == 0) && ($i % 100 != 0)) || ($i % 400 == 0)){ $monday[2] = 29; }else{ $monday[2] = 28; } # 計算年 if($i == $gmt){ for($j=$mm;$j<13;$j=$j+1){ if($mm == $j){ $dday = $dday + $monday[$j]-1; }else{ $dday = $dday +$monday[$j]; } } }else{ for($j=1;$j<13;$j=$j+1){ $dday = $dday +$monday[$j]; } } } if ((($y % 4 == 0) && ($y % 100 != 0)) || ($y % 400 == 0)){ $monday[2] = 29; }else{ $monday[2] = 28; } # 計算月 for($i=1;$i<$m;$i++){ $dday += $monday[$i]; } $dday=$dday+$d; ($dday-3)%7; } sub GetJpegWHSub{ local($c1,$c2,$ch,$s,$le, $dummy); local($a,$b,$c,$d); if( read(RD, $c1, 1) && read(RD, $c2, 1) && (ord($c1) == 0xFF) && (ord($c2) == 0xD8) ){ while( ord($ch) != 0xDA ){ while(ord($ch) != 0xFF) { return(0,0) unless read(RD, $ch, 1); } while(ord($ch) == 0xFF) { return(0,0) unless read(RD, $ch, 1); } if ((ord($ch) >= 0xC0) && (ord($ch) <= 0xC3)){ return(0,0) unless read (RD, $dummy, 3); return(0,0) unless read(RD, $s, 4); ($a,$b,$c,$d)=unpack("C"x4,$s); return ($c<<8|$d, $a<<8|$b ); }else{ return(0,0) unless read (RD, $s, 2); ($c1, $c2) = unpack("C"x2,$s); $le = $c1<<8|$c2; last if (!defined($le) || $le < 2); read(RD, $dummy, $le-2); } } } return (0,0); } sub GetJpegWH{ local($x, $y); if(open(RD, $_[0])){ binmode(RD); ($x, $y)=GetJpegWHSub(); close(RD); } return($x, $y); } sub GetGiffWH{ local($type,$a,$b,$c,$d,$s); if(open(RD, $_[0])){ binmode(RD); if( read(RD, $type, 6) && $type =~ /GIF8[7,9]a/ && read(RD, $s, 4) == 4 ){ ($a,$b,$c,$d)=unpack("C"x4,$s); close(RD); return ($b<<8|$a,$d<<8|$c); } close(RD); } return (0,0); } # # 寬度及高度置入$image_height跟$image_width # sub GetImageSize { local($fname)=@_; if( $fname =~ /\.png$/i ){ if( open(RD, $fname) ){ local($w, $fn, $k, $w1, $w2, $w3, $w4); local($h, $h1, $h2, $h3, $h4, $str); binmode(RD); read(RD,$str,0x18); close(RD); ($k,$w1,$w2,$w3,$w4, $h1,$h2,$h3,$h4)=unpack("H32 C8",$str); $w=$w1*0x1000000+$w2*0x10000+$w3*0x100+$w4; $h=$h1*0x1000000+$h2*0x10000+$h3*0x100+$h4; ($w, $h); } }elsif( $fname =~ /\.jpeg$|\.jpg$/i ){ &GetJpegWH($fname); }elsif( $fname =~ /\.giff$|\.gif$/i ){ &GetGiffWH($fname); } } sub GetImageSizePch { if( $Pch_File ){ if( $Pch_File =~ /\.pch$|\.spch$/ ){ $fn=$Pch_File; $fn=~s/\.pch$|\.spch$/\.png/; if( (stat($fn))[7] > 0 ){ ($image_width, $image_height)=&GetImageSize($fn); }else{ $fn=$Pch_File; $fn=~s/\.pch$|\.spch$/\.jpg/; if( (stat($fn))[7] > 0 ){ ($image_width, $image_height)=&GetJpegWH($fn); }else{ $fn=$Pch_File; $fn=~s/\.pch$|\.spch$/\.jpeg/; if( (stat($fn))[7] > 0 ){ ($image_width, $image_height)=&GetJpegWH($fn); }else{ $fn=$Pch_File; $fn=~s/\.pch$|\.spch$/\.gif/; ($image_width, $image_height)=&GetGiffWH($fn) if( (stat($fn))[7] > 0 ); } } } }elsif( $Pch_File =~ /\.jpeg$|\.jpg$/i ){ ($image_width, $image_height)=&GetJpegWH($Pch_File); }elsif( $Pch_File =~ /\.giff$|\.gif$/i ){ ($image_width, $image_height)=&GetGiffWH($Pch_File); }elsif( $Pch_File =~ /\.png$/i ){ ($image_width, $image_height)=&GetImageSize($Pch_File); } } } # # HTML檔頭輸出 # sub PutHTMLheaderSJIS { print "\n\n\n"; } sub IsPCH() { my($ret); if( ($Pch_File) && ($Pch_File !~ /\.pch$|\.spch$/) ){ if( $Mode eq "ContinuePaintBBS" ){ $ret=1; }else{ $ret=2; } }else{ my($dmy, $dm1, $dm2, @prm); undef $layer_count; @prm=('layer_count', 'layer_max', 'layer_last', 'count_lines', 'quality', 'end_param'); if( open(RD, $Pch_File) ){ $dmy="1"; while( $dmy ){ $dmy=; $dmy=~s/\r|\n//g; ($dm1,$dm2) = split(/=/,$dmy); for $parm(@prm){ if( $parm eq $dm1 ){ ${$dm1}=$dm2; } } } close(RD); } $ret=2 if( $layer_count ); } $ret; } sub CallApplet(){ my($PaintBBS,$spainter,$jud, $PBBStag, $SPTRtag, $Ctag, $Qtag, $Pstr, $Qstr, $Prostr); $Pch_File="$vDir/$Pch_File" if( $Pch_File ); &IsApplet(); $jud=&IsPCH(); $Ctag=""; $Pstr=""; $Prostr="$Ctag﹛"; $Qstr="Quality "; if( ($Pch_File !~ /\.pch$|\.spch$/) && ($PBsize) ){ if( ($jud != 2) || (!$spsize) ){ $PBBStag=$Pstr; }else{ $Qtag=$Qstr; $PBBStag=$Pstr; $SPTRtag=$Prostr; } }elsif( ($jud != 2) && ($PBsize) ){ $PBBStag=$Ctag; }elsif( ($jud == 2) && ($spsize) ){ $SPTRtag=$Prostr; $Qtag=$Qstr; } &PutHTMLheader(); print <

    壓縮率 $Qtag $br $PBBStag $SPTRtag
    print "$ctg, $ctgry, $Category"; ca_eof ; } # # 呼叫PaintBBS(再生) # sub CallPaintBBSDraw { local($w, $h, $jud, $pch); my($o1, $o2, $p1, $p2, $ft); $Pch_File="$vDir/$Pch_File" if( $Pch_File ); if( !$Pch_Speed ){ $Pch_Speed=-1; } if( ($pch_width) && ($pch_height) ){ $image_width=$pch_width; $image_height=$pch_height; }else{ &GetImageSizePch(); } $w=$image_width; if( $w < 120 ){ $w=120; } $h=$image_height+25; &PutHTMLheaderSJIS(); $jud=&IsPCH(); $p1=rindex($fn, "\/"); $p2=rindex($fn, "\/", $p1-1); $fn=substr($fn, $p2); if( $RepLayout eq "CHECKED" ){ $hrsize=$w+30; $hrs=""; $o1="
    "; $o2="
    "; }else{ $hrsize=$w*2+30; $hrs="

    "; $o1=""; $o2="$hrs
    "; } print <Replay
    $hrs $o1 ANIME_VIEW_EOF1 #新PCHViewer 可以使用既有程式碼 if( (stat("$vDir/PCHViewer.jar"))[7] ){ if( $jud == 2 ){ print ""; }else{ print ""; } }else{ print ""; } $p1=rindex($Pch_File, "\/"); $p2=rindex($Pch_File, "\/", $p1-1); $Pch_File=substr($Pch_File, $p2); if( $apOP eq "Yes" ){ $ft="onclick=\"window.close()\" value=\"Close\""; }else{ $ft="onclick=\"history.go(-1)\" value=\"Return\""; } print "\n$o2
    \n"; } # # 呼叫PaintBBS(繪圖) # sub CallPaintBBS { my($psec,$pmin,$phour,$pday,$pmon,$pyear,$wday,$yday,$isdst); my($palette,$w,$h,$fn,$jud,$ssmp,$scmp,$sstd,$hp,$tlstr); my($AppleteMode,$p1,$p2,$cry,$wd,$key,$szt, $vms, $apl); $apl="applet"; $vms="$apl alt=\"JavaApplet\""; $Pch_File="$vDir/$Pch_File" if( $Pch_File ); ($psec,$pmin,$phour,$pday,$pmon,$pyear,$wday,$yday,$isdst) = localtime; if( (!$year) && ($nyear) ){ $year=$nyear; $month=$nmonth; $day=$nday; $Category=$nCategory; } $pmon+=1; if( $Pch_File ){ $GrpFileName=$Pch_File; $GrpFileName=~s/^.*\///; $GrpFileName=~s/\.pch$|\.spch$|\.jpg$|\.jpeg$|\.gif$|\.giff$|\.png$//i; }else{ my($nmstr); if( $Mode =~ /SPAINTER/ ){ $nmstr="snormal" if( $Mode =~ /Nor/ ); $nmstr="spro" if( $Mode =~ /Pro/ ); }else{ $nmstr="PaintBBS"; } $GrpFileName=sprintf("$nmstr%02d%02d%02d%02d%02d", $pmon,$pday,$phour,$pmin,$psec); } if( $Admin && (($Message) || ($Title)) ){ &WriteNicky(); }else{ &MakeDateStr(); } &MakeNickyFname(); $key=int(rand(999)); $cry=int(rand(9999)); $wd=crypt($cry, $key); &PutHTMLheaderSJIS(); if( !$Admin ){ print "\n"; exit; } open(WR, ">./PaintBBS.cgi"); binmode(WR); print WR "$wd\n"; print WR "$NickyDir\n"; print WR "$NickyFname\n"; print WR "$GrpFileName\n"; print WR $Date; close(WR); print "\n"; $palette=(stat("$vDir/palette.js"))[7]; print "\n" if( $palette > 0 ); print "Draw!\n\n\n"; print "
    \n\n\n"; &GetImageSizePch(); $w=$image_width+150; $w=400 if( $w < 400 ); $h=$image_height+150; $h=500 if( $h < 500 ); if( $Mode =~ /^Continue|^SPAINTER|^PaintBBS/ ){ $ssmp="\n"; print "\n" if( $palette > 0 ); } print "\n
    \n<$vms code=\"c.ShiPainter.class\" name=\"paintbbs\" archive=\"$www/spainter.jar,$www/res/normal.zip\" width=\"$w\" height=\"$h\">"; $hp=$h+300; $sstd="\n<$vms code=\"c.ShiPainter.class\" name=\"paintbbs\" archive=\"$www/spainter.jar,$www/res/pro.zip\" width=\"$w\" height=\"$hp\">"; $scmp=""; if( $layerNum ){ $layerNum = 255 if( $layerNum > 255 ); $scmp.=""; } if( ($Mode =~ /^Continue/) || ($Mode =~ /^PaintBBS/) ){ $jud=&IsPCH(); if( $jud == 2 ){ if( $Mode =~ /Pro/ ){ print "$sstd$scmp"; }else{ print "$ssmp$scmp"; } }else{ print "\n<$vms CODE=\"pbbs.PaintBBS.class\" ARCHIVE=\"$www/PaintBBS.jar\" NAME=\"paintbbs\" WIDTH=\"$w\" HEIGHT=\"$h\">"; } }elsif( $Mode =~ /Nor/ ){ print "$ssmp$scmp"; }else{ print "$sstd$scmp"; } if( ($Mode =~ /^SPAINTER/) || ($jud == 2) ){ $AppleteMode="Savespainter"; if( $layer_max ){ print ""; print ""; print ""; } }else{ $AppleteMode="SavePaintBBS"; } $undoNum=60 if( !$undoNum ); if( $Quality < 3 ){ $undoNum = int(($undoNum+1)/3)*3 if( $undoNum % 3 ); $undoNum = 3 if( $undoNum < 3 ); $undomg=$undoNum/3; }else{ $undoNum = int(($undoNum+1)/2)*2 if( $undoNum % 2 ); $undoNum = 2 if( $undoNum < 2 ); $undomg=$undoNum/2; } undef $qa; undef $qt; if( $Quality ){ $qt=$Quality; }elsif( $quality ){ $qt=$quality; } $qa="" if( $qt ); print "$qa"; if( $Message || $Mode =~ /^Continue/ ){ print ""; }else{ print ""; } if( (($AnimeSave eq "True") && (($Mode eq "PaintBBS") || ($Mode =~ /^SPAINTER/))) || ((($Mode =~ /^Continue/) && ($Pch_File =~/\.pch$|\.spch$/) && (stat($Pch_File))[7])) ){ print ""; } $szt=""; if( $Pch_File ){ $p1=rindex($Pch_File, "\/"); $p2=rindex($Pch_File, "\/", $p1-1); $Pch_File=substr($Pch_File, $p2); if( $Pch_File =~ /\.pch$|\.spch$/i ){ print ""; if( $Pch_File =~ /\.pch$/ ){ print "$szt\n"; } }else{ print "$szt"; } }else{ print "$szt"; } print "\n\n\n
    \n
    \n\n\n"; } # # Recv Data from PaintBBS # sub SavePaintBBS { my($key,$cry,$mode); local($dir, $fname, $date, $path, $crcv, $wd); print "Content-type: text/html\n\n"; if( open(RD, "./PaintBBS.cgi") ){ binmode(RD); $wd=; $wd=~s/\r|\n//g; }else{ exit; } ($cry,$key,$mode) = split(/\?/, $ENV{'QUERY_STRING'}); if( $wd ne crypt($cry, $key) ){ open(WD, ">./PaintBBS_error.cgi"); print WD "$ENV{'REMOTE_ADDR'}"; close(WD); exit; } $dir=; chop $dir; $NickyFname=; chop $NickyFname; $fname=; chop $fname; $path=$dir.'/'.$fname; $date=; close(RD); $crcv=$CommentRecv; &GetNickyFile($NickyFname); $Date=$date if( $Date eq ""); $CommentRecv=$crcv if( !$CommentRecv ); $a=; $data=""; while( ){$data.=$_;} unlink("$dir/$GrpFileName") if( $GrpFileName =~ /\.jpeg$|\.jpg$|\.gif$|\.giff$|\.png$/i ); $GrpFileName=$fname; if( substr($data,1,3) eq "PNG" ){ $GrpFileName.=".png"; ($img,$pch)=split(/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/,$data,2); }else{ $GrpFileName.=".jpg"; ($img,$pch)=split(/\xff\xd9[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/,$data,2); } # Save to image file open(WD, '>'.$dir.'/'.$GrpFileName); binmode(WD); print WD $img; print WD "\xff\xd9" if( $GrpFileName =~ /jpg$/ ); close( WD ); # Save to process file if( length($pch) > 17 ){ if( $Mode eq "SavePaintBBS" ){ open(WD, ">$path.pch"); }elsif( $Mode eq "Savespainter" ){ open(WD, ">$path.spch"); } binmode(WD); print WD $pch; close WD; } &initial2nd(); &GetDateFromFname(); &WriteNicky(); if( $Message && $Title ){ open(WR, ">$vDir/$NickyHtml"); binmode(WR); select WR; &NickyPageOut(0, $PrintDay); close(WR); } open(WR, ">./PaintBBS.cgi"); print WR "\n"; close(WR); } # # 自動編輯日記內文 # sub ConvertMsg { local($msg,$flag,$j,$i,$line,$url, $str, @field, $flagB); $flag=0; $msg=""; $j=0; @field=split(/http:\/\/|HTTP:\/\//,$_[0]); for $line( @field ){ if( $j==0 ){ $j++; $msg.=$line; next; } if( substr($line,7) !~ /\w|#|\?|\/|\:|\.|\~|\%|\-|\&|\=|\+|\,|\;/ ){ $j++; $msg.=$line; next; } $flag=1; $line="http://".$line; if( $line !~ /<\/A>|<\/a>/ ){ # 從$url抽出網址 $flagB=0; $str=substr($line,0,1); $url=$str; for($i=1; $str ne "\n"; $i++){ $str=substr($line, $i, 1); if( $str =~ /\w|#|\?|\/|\:|\.|\~|\%|\-|\&|\=|\+|\,|\;/ ){ $url.=$str; }else{ $str=substr($line, $i); $flagB=1 if( $str =~ /^\"/ ); last; } } #對URL加入超連結 if( $flagB == 0 ){ my($tg); if( $LinkOpen eq "Yes" ){ $tg="target=\"_blank\""; }else{ $tg=""; } $str=$line; $line="$url"; $line.=substr($str,$i); } } $msg.=$line; $j++; } if( $flag == 0 ){ $_[0]; }else{ $msg; } } # # 日記內文自動編輯 # sub AutoEditNicky { local($data)=@_; local($msg, $str); $msg=""; for $str(split(/\n/,$data)){ if( $UrlLink eq "Yes" ){ $msg.=&ConvertMsg($str)."\n"; }else{ $msg.="$str\n"; } } $msg; } # # 取得目前時間 # sub GetDateLocaltime { my($isdst, $yday); ($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime; $year+=1900; $month=sprintf("%02d", $month+1); $day=sprintf("%02d", $day); $week=$Week[$wday]; $first="Yes"; } # # 以POST獲得的數值設入各變數 # sub NickySetValue { local($gomi, $cnt); if( $arg eq "MODE" ){ $Mode=$val; }elsif( $arg =~ /WRITE|KAKUNIN|EDIT|DELETE|DELETEOK|CMNTEDIT|HEADEDIT|INPUT|MakeSetup|SETUP|CMNTGO|CMNTWRITE|CPREVIEW|PANEL|del/ ){ $Mode=$arg; }elsif( $arg eq "month" ){ $month=sprintf("%02d", $val); }elsif( $arg eq "day" ){ $day=sprintf("%02d", $val); }elsif( $arg eq "hour" ){ $hour=sprintf("%02d", $val); }elsif( $arg eq "min" ){ $min=sprintf("%02d", $val); }elsif( $arg eq "CommentRecv" ){ if( $val eq "No" ){ $val = 0 } elsif( $val eq "Yes" ){ $val = 1 } $CommentRecv=$val; }elsif( $arg eq "CMNT_MSG" ){ $CMNT_MSG=$val; $CMNT_MSG=~s//>/g; }elsif( $arg eq "CMNT_Name" ){ $CMNT_Name=$val; $CMNT_Name=~s//>/g; }elsif( !$Admin && ($arg =~ /^Effect|^Msg|^ks$|^ke$|^ReplaySTR$|^ContinueSTR$|^TL|^User|^CommentSTRlen|^tag/)){ }elsif( $arg eq "HEADDER" ){ $head=$val; }elsif( $arg eq "GrpFile" ){ $GrpData=$val if( $val !~ /^$/ ); }elsif( $arg eq "EventFile" ){ $EventData=$val if( $val !~ /^$/ ); }elsif( $arg =~ /^CmntName/ ){ ($gomi, $cnt)=split(/ZZZ/, $arg, 2); $CmntName[$cnt]=$val; $CmntCnt=$cnt if( $CmntCnt < $cnt ); }elsif( $arg =~ /^CmntTime/ ){ ($gomi, $cnt)=split(/ZZZ/, $arg, 2); $CmntTime[$cnt]=$val; }elsif( $arg =~ /^CmntMsg/ ){ ($gomi, $cnt)=split(/ZZZ/, $arg, 2); $CmntMsg[$cnt]=$val; }elsif( $arg eq "Category" ){ $Category+=$val; }elsif( $arg eq "nCategory" ){ $nCategory+=$val; }elsif( $arg eq "ctgry" ){ $ctgry+=$val; }elsif( ($arg eq "DATE") || ($arg eq "DT") ){ $year=substr($val,0,4); $month=substr($val,4,2); $day=substr($val,6,2); $daysub=substr($val,8,1); $hour=substr($val,9,2); $min=substr($val,11,2); $Category=hex(substr($val,14,8)); $DT=$val; }elsif( $arg !~ /^$|Admin|vDir|mtap|mto|cgipath|^[0-9]/ ){ ${$arg}=$val; } } # # Cookie罹允﹝ # sub WriteCookie { local($key,$pss); local($sec,$min,$hour,$mday,$mon,$year,$wday); if( $pass || $password ){ ($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime(time + 60*24*60*60); $wday = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday') [$wday]; $mon = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$mon]; $datec = sprintf("%s, %02d\-%s\-%04d %02d:%02d:%02d GMT",$wday,$mday,$mon,$year+1900,$hour,$min,$sec); $key=$ENV{REQUEST_URI}; $key=$ENV{SCRIPT_NAME} if( $key eq "" ); if( $password ){ $pss=$password; }else{ $pss=$pass; } print "Set-Cookie: Nicky=pass:$pss; expires=$datec;path=$key;\n"; } } # # 與$NickyAdmin做比較 # sub AdminCheck { my($pass)=@_; my($str, $key); if( open(RD, "./NickyAdmin.cgi") ){ binmode(RD); $str=; close(RD); } return 1 if( $str eq crypt($pass, $ENV{SCRIPT_NAME}) ); $key=$ENV{REQUEST_URI}; return 1 if( $str eq crypt($pass, $key) ); $key =~ s/\+/ /g; $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ego; if( $str eq crypt($pass, $key) ){ 1; }else{ 0; } } sub mobile_save{ my($str, $str1, $dummy, $cry, @po, @ps, @org, $i, $j, $key); my($atm, $cnt); $str="popserv=$popserv\npopuser=$popuser\npoppass=$poppass\n"; $str1="$BBSmode,$WriteMode"; if( $BBSmode ne "BBS" ){ $key=$password; }else{ $key=$WriteMode; } $cry=crypt($ENV{DOCUMENT_ROOT}, $key); $crylen=length($cry); @po=unpack("C$crylen", $cry); $pslen=length($str); @ps=unpack("C$pslen", $str); @org=@po; while( $#po < $#ps ){ @po=(@po, @org); } open(WD, ">./MobileUpper.cgi"); binmode WD; for($i=0;$i<$#po;$i++){ print WD $po[$i]+$ps[$i]; print WD ","; } print WD "\n$str1\n"; $cnt=$#AutoLayout+1; $atm=""; for($i=0;$i<$cnt;$i++){ $atm="$AutoLayout[$i],$atm"; } print WD "$atm\n"; print WD "$MobileGallery\n"; close(WD); } sub mobile_load{ my($str, $str1, $cry, $de, $a, @savedat, $i, $j, $key, @ppp, $atm); if( open(RD, "./MobileUpper.cgi") ){ binmode RD; $str=; $str1=; $atm=; $MobileGallery=; close(RD); }else{ return; } $atm=~s/\r|\n//g; $MobileGallery=~s/\r|\n//g; @AutoLayout=split(/,/, $atm); @savedat=split(/,/, $str); ($BBSmode, $WriteMode) = split(/,/, $str1); $WriteMode=~s/\r|\n| //g; if( $BBSmode ne "BBS" ){ if( !$password ){ return; } $key=$password; }else{ $key=$WriteMode; } $cry=crypt($ENV{DOCUMENT_ROOT}, $key); $crylen=length($cry); @po=unpack("C$crylen", $cry); @org=@po; if( ($#po == 0) && ($#savedat) ){ print "error4\n"; exit; } while( $#po < $#savedat ){ @po=(@po, @org); } for($i=0;$i<$#savedat;$i++){ $ppp[$i]=$savedat[$i]-$po[$i]; } $de=pack("C$i", @ppp); for (split(/\n/, $de)){ ($arg, $val)=split(/=/, $_); ${$arg}=$val; } $str="popserv=$popserv\npopuser=$popuser\npoppass=$poppass\n"; $popserv =~ s/\r|\n|\t| //g; $popuser =~ s/\r|\n|\t| //g; $poppass =~ s/\r|\n|\t| //g; } # # 檢查密碼 # sub NickyPassCheck { if( (stat("./NickyAdmin.cgi"))[7] > 0 ){ if( !&AdminCheck($oldpassword) ){ &NickyPassWord(); } } if( $Mode eq "DUMMY PASSWORD" ){ srand; for($password=rand(9999999); $password eq $pass; ){}; &WriteCookie(); if( !$flag_type ){ print "Content-type: text/html\n\n"; $flag_type=1; } $Admin=0; &MakeNickyLast(); exit; } if( $password eq $passwdcf ){ local($i, $key); if( !$password ){ if( $oldpassword ){ $password = $oldpassword; }else{ &NickyPassWord(); } } &nickyGetHead(); select STDOUT; @nli=&GetNickyList($Age) if( !@nli ); if( $#nli < 0 ){ local($str); $str="http://".$ENV{HTTP_HOST}.$ENV{REQUEST_URI}; &GetDateLocaltime(); $Title="歡迎使用"; $Message="本訊息是由index.cgi自動產生的。\n\n本訊息的下方有顯示各種操作按鍵,這是只有管理者輸入密碼後才會顯示的\功\能鍵。\n\n#要撰寫新日記時可點選下方「寫新日記」的按鍵,或是輸入以下的URL:\n$str?New\n#另外若是要進行個人設定,可以點選下方「個人設定」的按鍵,或是輸入以下的URL:\n$str?MakeSetup\n\n另外在公開日記之前,請別忘記要刪除這篇訊息…"; &WriteNicky(); } $key=$ENV{SCRIPT_NAME}; if( $key eq "" ){ $key=$ENV{REQUEST_URI}; $key =~ s/\+/ /g; $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ego; } &WriteCookie(); open(WD, ">./NickyAdmin.cgi"); binmode(WD); print WD crypt($password, $key); close(WD); if( -e "./MobileUpper.cgi" ){ my($p); $p=$password; $password=$oldpassword; &mobile_load(); $password=$p; &mobile_save(); } if( !$flag_type ){ print "Content-type: text/html\n\n"; $flag_type=1; } unless( -e "./NickyAdmin.cgi" ){ print "index.cgi所在之資料夾沒有CGI的行使權限。\n"; exit; } $Admin=1; &MakeNickyLast(); }else{ &NickyPassWord(); } exit; } # # 密碼輸入畫面 # sub NickyPassWord{ if( !$flag_type ){ print "Content-type: text/html\n\n"; $flag_type=1; } &PutHTMLheader(); print "nicky!密碼設定畫面\n\n\n"; print "
    nicky!密碼設定畫面$br
    \n"; print "
    "; if( (stat("./NickyAdmin.cgi"))[7] ){ local($pair, @pairs, $DUMMY, $name, $value); @pairs = split(/;/, $ENV{'HTTP_COOKIE'}); foreach $pair (@pairs) { local($name, $value) = split(/=/, $pair); $name =~ s/ //g; $DUMMY{$name} = $value; } @pairs = split(/,/, $DUMMY{'Nicky'}); foreach $pair (@pairs) { local($name, $value) = split(/:/, $pair); ${$name} = $value; } print "舊密碼 $br\n"; } print <$br 密碼確認 $br$br $br$br$br$br
    \n HTML exit; } # # iMODE判定 # sub IsIMODE{ my($ret); $ret=0; $ret=1 if( $ENV{HTTP_USER_AGENT} =~ /DoCoMo|J-PHONE|DDIPOCKET|UP\.Browser/ ); #$ret=1 if( -e "./imode" ); $ret; } # # 依據Mode判定該做什麼並執行 # sub NickyExec { if( ($Mode eq "SETUP PASSWORD") || ($Mode eq "DUMMY PASSWORD") ){ &NickyPassCheck(); }else{ if( ((stat("./NickyAdmin.cgi"))[7] <= 0) && (!-e "Rinda") ){ &NickyPassWord(); } } if( !$flag_type ){ if( $Mode eq "WRITE" && $Admin ){ $password=$pass; &WriteCookie(); }elsif( $Mode =~ /CINPUT|CPREVIEW/ ){ &WriteCookie(); } print "Content-type: text/html\n\n"; $flag_type=1; } if( $DT && !$Mode ) { if( ($MsgOldForm == 1) || (&IsIMODE()) ) { $Mode="PageOut"; } else { $Mode="MONTH"; } }elsif( $Mode eq "PANEL" ){ $ld="panel.cgi"; $Mode="exec"; }elsif( $ld && !$Mode ){ $Mode="exec"; } $lg=$lg."i"; $Message=&AutoEditNicky($Message); if( $Mode =~ /KAKUNIN/ ){ if( $nyear && (!$year)){ $year=$nyear; $month=$nmonth; $day=$nday; # $Category=$nCategory; } $ModeSub=8; if( $Mode eq "KAKUNIN" ){ &NickyKakunin(NORMAL); }else{ &NickyKakunin(CUSTOM); } }elsif( ($Mode eq "WRITE") && ($Admin) ){ my($oyear, $omonth, $oday, $odaysub, $oCategory, $cfn); $oyear=$year; $omonth=$month; $oday=$day; $odaysub=$daysub; $oCategory=$Category; $Category=$nCategory; if( $nyear ){ undef $Date; $year=$nyear; $month=$nmonth; $day=$nday; undef $daysub if(($oyear)&&(($nyear!=$oyear)||($nmonth!=$omonth)||($nday!=$oday))); &MakeNickyFname(); $ndaysub=$daysub; $cfn=$NickyComment; } &WriteNicky(); &MakeHTMLone($year, $month, $day, $daysub, 1); $nCategory=0 unless( $nCategory ); if(($oyear)&&($nyear)&&(($nyear != $oyear) || ($nmonth != $omonth)||($nday != $oday)) ){ # 變更日期→刪除舊的 $year=$oyear; $month=$omonth; $day=$oday; $daysub=$odaysub; $Category=$oCategory; &MakeNickyFname(); rename($NickyComment, $cfn) if( -e $NickyComment ); &NickyDelete(); &MakeHTMLone($year, $month, $day, $daysub, 1); }elsif( ($oCategory != -1) && ($oCategory ne $nCategory) ){ $Category=$oCategory; $year=$oyear; $month=$omonth; $day=$oday; $daysub=$odaysub; &MakeNickyFname(); unlink($NickyFname); &MakeHTMLone($year, $month, $day, $daysub, 1); } &MakeNickyLast(); }elsif( $arg eq "New" ){ &Nicky(); }elsif( $Mode eq "PageOut" ){ &SerchPageFromDate(); }elsif( $Mode eq "MONTH" ){ &NickyMonthOut(); }elsif( $Mode =~ /^EDIT$|CMNTEDIT/ ){ &NickyEdit(); }elsif( $Mode eq "CMNTGO" ){ &EditComment(); }elsif( $Mode eq "CMNTWRITE" ){ &WriteComment(); }elsif( $Mode eq "MKL" ){ &MakeLastHTML(); }elsif( $Mode eq "DELETE" ){ &NickyDeleteConfirm(); }elsif( ($Mode eq "DELETEOK") && ($Admin) ){ &NickyDelete("TRUE"); }elsif( ($Mode eq "HEADEDIT") && ($Admin) ){ &NickyHead(); }elsif( ($Mode eq "HEADWRITE") && ($Admin) ){ &NickyHeadWrite(); }elsif( $Mode =~ /^CINPUT$|CPREVIEW/ ){ &NickyInputComment(); }elsif( $Mode eq "CINPUTI" ){ if( &ReqJcode() ){ &jcode'sjis2euc(\$CMNT_Name); &jcode'sjis2euc(\$CMNT_MSG); } &NickyInputComment(); }elsif( ($Mode eq "SERCH") || ($SerchWord) ){ &NickySerch(); }elsif( ($Mode eq "MakeSetup") && ($Admin) ){ &MakeSetup(); }elsif( ($Mode eq "SETUP") && ($Admin) ){ my($dat); $MsgSize=$HonbunSize; $MsgColor=$HonbunColor; $MsgBgColor=$HonbunBgColor; &create_style(); &nickyGetHead("NickyHFdat.cgi"); $dat="$head$TMN$foot$TMN$iHead$TMN$iFoot$TMN$efoot$TMN$head2nd$TMN$foot2nd$TMN$Use2ndHD$TMN$UseListHD$TMN$UseSearchHD$TMN$Use2ndFT$TMN$UseListFT$TMN$UseSearchFT"; &create_exec($dat, $NickyHF, "nHF"); &SaveNickyConf(); }elsif( ($Mode eq "INITIAL") && ($Admin) ){ my($dat); unlink($NickyConf); &InitialNicky(); &create_style(); &nickyGetHead("NickyHFdat.cgi"); $dat="$head$TMN$foot$TMN$iHead$TMN$iFoot$TMN$efoot$TMN$head2nd$TMN$foot2nd$TMN$Use2ndHD$TMN$UseListHD$TMN$UseSearchHD$TMN$Use2ndFT$TMN$UseListFT$TMN$UseSearchFT"; &create_exec($dat, $NickyHF, "nHF"); &MakeNickyLast(); }elsif( ($Mode eq "PaintBBS") || ($Mode =~ /^Continue/) || ($Mode =~ /^SPAINTER/) ) { &CallPaintBBS(); }elsif( $Mode eq "PaintBBSDraw" ){ &CallPaintBBSDraw(); }elsif( $Mode eq "CallApplet" ){ &CallApplet(); }elsif( $Mode eq "ColorSample" ){ &PutColorSample(); }elsif( ($Mode eq "UserCustom") && $Admin ){ &UserCustomize(); }elsif( ($Mode eq "Custom") && $Admin ){ &SaveUserCustomize(); }elsif( ($Mode eq "CustomC") && $Admin ){ &SaveUserCustomizeC(); }elsif( $Mode eq "SEND" ){ &RecvIMODE($Mode); }elsif( $Mode eq "delImode" ){ &DeleteImode(); }elsif( ($Mode eq "saveFile") && $Admin ){ &saveFile(); }elsif( ($Mode eq "exec") && $ld ){ if( $ld eq "panel.cgi" ){ $f=1; }elsif( open(RD, "./liblist.cgi") ){ $f=0; while(){$dat.=$_;} close(RD); $dat=~s/\r//g; @nlib=split(/\n/, $dat); for $ln(@nlib){ if( $ln eq $ld ){ $f=1; last; } } } return 0 unless( $f ); undef $dat; undef @nlib; eval('require("$ld")'); if( $@ ){ print "error\n$@"; }else{ $r=rindex($ld, "\."); $abc=substr($ld, 0, $r); &$abc(); } exit; return 0; }else{ return 0; } 1; } sub editFile{ my($fname)=@_; my($dat, $dat0, $dat1, $tmp); $tmp=$fname; $tmp=~s/\.//g; &PutHTMLheader(); &goto_end("bad filename") if( $tmp=~/(\W)/ ); if( open(RD, "./$fname") ){ while(){$dat.=$_;} close(RD); $dat=~s/\r//g; } while( $dat=~s/\n$// ){} $dat=~s/&/&/g; $dat=~s/filename=[$fname]$br

    "; if( $fname eq "inputarea.cgi" ){ ($dat0, $dat, $dat1)=split(/\x01/, $dat); print "
    \n"; print "
    \n"; } print <$dat

    HTML } sub get_inputarea{ my $dat; $inputh=$inpute=""; if( open(RD, "./inputarea.cgi") ){ binmode RD; while(){$dat.=$_;} close RD; ($inputh, $inpute, $inputt)=split(/\x01/, $dat); } } sub saveFile{ if( $libList ){ $libList=~s/\r//g; if( $fname eq "inputarea.cgi" ){ $libList0=~s/\r//g; $libList1=~s/\r|\n//g; $libList="$libList0\x01$libList\x01$libList1"; } if( $fname eq "catelist.cgi" ){ my $dat, $j1, $l, $j2, $i, $j, $str; for $dat(split(/\n/, $libList)){ next if( !$dat ); ($j1, $l, $j2)=split(/,/, $dat); if( $i ){ $j=1<<($i-1); }else{ $j="default"; } $str.="$j1$l"; $i++; } open(WD, ">./category.cgi"); binmode WD; print WD "
    "; print WD $str; # print WD "
    \n"; print WD "\n"; close WD; } } open(WD, ">./$fname"); binmode(WD); print WD $libList; close(WD); if( $fname eq "d.cgi" ){ &create_style; } &NickyPageOut(0, $PrintDay); } # # 輸出HTML檔頭 # sub PutHTMLheader{ print "\n\n\n\n"; } sub initial2nd{ $spsize=$PBsize=-3; $flag_customread=$flag_cmnt_customread=$mkHTML=$saveExec=0; # 日記HTML使用之檔頭/檔尾名稱 $NickyConf="./NickyConf.cgi"; $NickyHF="./NickyHF.cgi"; $NickyAdmin="./NickyAdmin.cgi"; $CustomText="./CustomText.cgi"; $CustomCGI="./CustomCGI.cgi"; $CustomCmntText="./CustomCmntText.cgi"; $CustomCmntCGI="./CustomCmntCGI.cgi"; $TMN="\n#\n#----NickyTerminate----\n#\n"; if( $tagmode eq "xhtml" ){ $br="
    ";$e=" />"; }else{ $br="
    ";$e=">"; } } # # S.Kano # $ENV{TZ}="CST-8"; local($str, $arg, $val); my($newline, $a, $r1, $r2); $r1=rindex($ENV{SCRIPT_NAME}, "/"); $r2=rindex($cgipath, "/"); $Admin=&TrueCheck(); if( substr($ENV{SCRIPT_NAME}, $r1) ne substr($cgipath, $r2) ){1;}else{ binmode(STDIN); binmode(STDOUT); &ReadSetup(); $flag=0; for $str(split(/\?/, $ENV{'QUERY_STRING'})){ ($arg, $val)=split(/=/, $str); $val =~ s/\+/ /g; $val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ego; &NickySetValue() if( $arg ne "CIRCV" ); } if( ($Mode eq "SavePaintBBS") || ($Mode eq "Savespainter" ) ){ &SavePaintBBS(); exit; } if( $#ARGV < 0 ){ eval{ if( $a= ){ $flag=1; if( $a =~ /\r\n/ ){ $newline="\r\n"; }else{ $newline ="\n"; } } }; if( $@ ){ &PutHTMLheader(); print "在本系統無法動作(Ver=$Ver)。\n"; exit; } } if( $flag ){ # # ENCTYPE解析 # $CTYPE=$ENV{CONTENT_TYPE}; if( ($CTYPE =~ /multipart/) && $Admin ){ local($gomi1); ($gomi1, $BOUNDARY)=split(/boundary=/, $CTYPE); while( ){ local($gomi2, $gomi3, $gomi4); ($gomi1, $arg, $gomi2, $gomi3)=split /\"/; $gomi1=; $gomi2=; $gomi4=; if( $arg =~ /^Message$/ ){ $val=$gomi2; while( $gomi4 !~ /$BOUNDARY/ ){ $val.=$gomi4; $gomi4=; } }elsif( ($arg eq "GrpFile") || ($arg eq "EventFile") ){ if( $gomi4 =~ $BOUNDARY ){ $val=""; }else{ if( $gomi1 =~ /^Content-Type:/ ){ $val=$gomi4; }else{ $val=$gomi2.$gomi4; } $gomi4=; while( $gomi4 !~ /$BOUNDARY/ ){ $val.=$gomi4; $gomi4=; } } if( $gomi3 ){ if(($arg eq "GrpFile") || ($arg eq "URLimage")) { if( !$GrpFileName ){ $GrpFileName=&BaseName($gomi3); } }elsif( $gomi3 ){ $EventFileName=&BaseName($gomi3); } } }else{ $val=$gomi2; } $val=~s/$newline$//; &NickySetValue(); } }else{ while(){$a .= $_;} foreach (split(/&/, $a)){ ($arg, $val)=split(/=/, $_); $val =~ s/\+/ /g; $val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/ego; &NickySetValue(); } } # # 刪除圖像檔 # if( ($GrpFileDel eq "Delete") && ($Admin) ){ my($n, $p, $o, @fl); &MakeNickyFname(); $n=rindex($GrpFileName, "\."); $o=substr($GrpFileName,0,$n); @fl=&GetFileList("$NickyDir/$o\\."); for $p(@fl){ if( ($p !~ /\.cmnt$/) && ($p !~ /\.nky$/) ){ unlink("$vDir/$p"); # 刪除圖像檔 } } undef $GrpFileName; undef @fl; } if( ($EventFileDel eq "Delete") && ($Admin) && ($GrpFileName) ){ my($n, $p2, @fl); if( (!$year) && ($nyear) ){ $year=$nyear; $month=$nmonth; $day=$nday; } &MakeNickyFname(); $n=rindex($GrpFileName, "\."); $p2=substr($GrpFileName, 0, $n); @fl=&GetFileList("$NickyDir/$p2\\."); for (@fl){ if( ($_ ne "./$year/$GrpFileName") && ($_ ne "./$year/$p2.nky") && ($_ ne "./$year/$p2.cmnt") ){ unlink("$vDir/$_"); } } } if( ($GrpData) && ($Admin) ){ my($gsec,$gmin,$ghour,$gday,$gmon,$gyear,$gwday,$gyday,$gisdst, $gf); if( (!$year) && ($nyear) ){ $year=$nyear; $month=$nmonth; $day=$nday; } &MakeNickyFname(); mkdir($NickyDir, 0777) if( !-e $NickyDir ); $gf=$GrpFileName; $gf=~s/\.//g; if( (-e "$NickyDir/$GrpFileName") || (($gf=~/\W/) && ($gf!~/[_\-]/)) ){ ($gsec,$gmin,$ghour,$gday,$gmon,$gyear,$gwday,$gyday,$gisdst) = localtime; $gmon++; $ext=&GetExt($GrpFileName); $GrpFileName=sprintf("grp%02d%02d%02d%02d%02d.$ext", $gmon,$gday,$ghour,$gmin,$gsec); } open(WD, ">$NickyDir/$GrpFileName"); binmode(WD); print WD $GrpData; close(WD); } if( ($EventFileName =~ /\.pch$|\.spch$|\.jpg$|\.png$|\.gif$/ ) && ($GrpFileDel ne "Delete") && ($Admin) ){ local($fn1, $ext); if( (!$year) && ($nyear) ){ $year=$nyear; $month=$nmonth; $day=$nday; } &MakeNickyFname(); if( $GrpFileName && -e "$NickyDir/$GrpFileName" ){ $ext=$EventFileName; $ext=~s/^.*\.//; $ext = "thumb\.$ext" if( $ext =~ /jpg|png|gif/i ); $fn1=$GrpFileName; $fn1=~s/\..*$//; open(WD, ">$NickyDir/$fn1.$ext"); binmode(WD); print WD $EventData; close(WD); } } # 僅限於pch if( ( ((&GetExt($EventFileName) =~ /^pch$|^spch$/ ) && (!$GrpData)) || ((&GetExt($GrpFileName) =~ /^pch$|^spch$/ ) && (!$EventData)) ) && ($GrpFileDel ne "Delete") && ($Admin) ){ if( (!$year) && ($nyear) ){ $year=$nyear; $month=$nmonth; $day=$nday; } &MakeNickyFname(); mkdir($NickyDir, 0777) if( !-e $NickyDir ); open(WD, ">$NickyDir/$EventFileName"); binmode(WD); print WD $EventData; close(WD); $Mode="Continue" if( !$GrpFileName ); $Pch_File="$NickyDir/$EventFileName"; } # # 依據Mode判定該做什麼並執行 # &initial2nd(); $ctg = $ctgry if( !$ctg && $ctgry ); if( $Mode eq "MKL" ){ $flag_type=1; &MakeLastHTML(); }elsif( &NickyExec() == 0 ){ &NickyPageOut(0, $PrintDay); } } else { &initial2nd(); $ctg = $ctgry if( !$ctg && $ctgry ); if( $arg eq "PassWord" ){ &NickyPassWord(); }elsif( $Mode eq "MKL" ){ &MakeLastHTML(); }else{ print "Content-type: text/html\n\n"; $flag_type=1; $lg="n"; } if( $arg eq "page" ){ if( !$val ){ $val=0 }; $PageNo=$val; if( &IsIMODE() ){ &NickyPageOutIMODE($PageNo, $PrintDay); }else{ &NickyPageOut($PageNo, $PrintDay); } }elsif( $arg =~ /^SetSerch$|^SetSearch$/ ){ &NickySetSearch(); }elsif( $arg eq "New" ){ if( ( &IsIMODE() ) && ( &ReqJcode() ) ){ &NickyIMODE("edit"); }else{ if( $Admin ){ &Nicky(); }else{ &NickyPageOut(0, $PrintDay); } } }elsif( $arg eq "new" ){ &NickyIMODE("edit"); }elsif( ($arg eq "edit") || ($arg eq "del") ){ &NickyEditIMODE($arg); }elsif( $arg eq "TitleList" ){ # if( $SaveHTML eq "ON" ){ # &PutTitleListIdx(); # }else{ # 一時性的 &PutTitleList(); # } }elsif( ($arg eq "UserCustom") && $Admin ){ &UserCustomize(); }elsif( ($arg eq "MakeSetup") && (($Admin) || (-e "./MakeSetup")) ){ &MakeSetup(); }elsif( ($arg eq "UserCustomC") && $Admin ){ &UserCustomizeCmnt(); }elsif( $arg eq "ColorSample" ){ &PutColorSample(); }elsif( ($arg eq "editexe") && $Admin ){ &editFile("exelist.cgi"); }elsif( ($arg eq "editlib") && $Admin ){ &editFile("liblist.cgi"); }elsif( ($arg eq "editFile") && $Admin ){ &editFile($fname); }elsif( ($arg eq "editreject") && $Admin ){ &editFile("reject_list.cgi"); }elsif( ($arg eq "editcss") && $Admin ){ &editFile("d.cgi"); }elsif( ($arg eq "editcategory") && $Admin ){ &editFile("catelist.cgi"); }elsif( ($arg eq "editinput") && $Admin ){ &editFile("inputarea.cgi"); }elsif( ($arg eq "saveFile") || ($Mode eq "saveFile") ){ }else{ if( &NickyExec() == 0 ){ if( &IsIMODE() ){ &NickyPageOutIMODE(0, $PrintDay); }else{ &NickyPageOut(0, $PrintDay); } } } } } #end of script