OSDN Git Service

終了化で呼び出すダウロードスレッド群の処理を修正
[gikonavigoeson/gikonavi.git] / Editor.pas
index 862b4fc..afd5a03 100644 (file)
@@ -212,7 +212,7 @@ type
                procedure Preview;
                function Check: Boolean;
                procedure SetNameList(sName, sMail: string);
-               procedure Send(ACOOKIE: string; SPID: string; PON: string; FirstWriting: Boolean);
+               procedure Send(const ACOOKIE: string; const SPID: string; const PON: string; FirstWriting: Boolean);
                function GetActiveControlHandle: THandle;
                procedure GetSendData(Source: TStringStream);
                procedure SaveSendFile;
@@ -235,7 +235,7 @@ type
                                //HEAD.TXT\8e©\93®\95\\8e¦
                                procedure ShowBoardHead(ABoard: TBoard; AMemo: TMemo);
                                //LocalFusianaTrapAlart
-                               function LFusianaGet(s: String): Boolean;
+                               function LFusianaGet(const s: String): Boolean;
                // Cookie\82Ì\8eæ\93¾
                procedure GetCookie(Rawtext: String; ABoard: TBoard);
                //! \93ü\97Í\83A\83V\83X\83g\82Ì\83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
@@ -252,6 +252,22 @@ type
         procedure SetExtraTab;
         //! \94Â\8eæ\93¾
         function GetBoard : TBoard;
+        //! URL\82Ì\83f\81[\83^\82ðstream\82É\8eæ\82è\8d\9e\82Þ 
+        procedure GetWebData(const URL: string; const RefURL: string;
+             Modified: TDateTime; stream: TStream);
+        //! GikoForm\82É\90V\92\85\83\81\83b\83Z\81[\83W\82ð\92Ç\89Á\82·\82é
+        procedure AddFormMessageNew(icon: TGikoMessageIcon);
+        //! \83\8d\81[\83J\83\8bfusiana\83g\83\89\83b\83v
+        function isLocalFusianaTrap: Boolean;
+        //! \83\8d\81[\83J\83\8bfusiana\83g\83\89\83b\83v
+        function isRemoteFusianaTrap: Boolean;
+        //! Header\95\8e\9a\97ñ\8eæ\93¾
+        function getHeaderStr(const ACOOKIE: string; const SPID : string;
+            const PON : string; Board : TBoard) : string;
+        //! fusiana\8cx\8d\90\83_\83C\83A\83\8d\83O
+        function FusianaMsgBox: Integer;
+        //! sent.ini\83t\83@\83C\83\8b\82Ì\90\90¬
+        function CreateSentIniFile: TMemIniFile;
        protected
                procedure CreateParams(var Params: TCreateParams); override;
        public
@@ -726,75 +742,34 @@ begin
        DrawMenuBar(Handle);
 end;
 
-procedure TEditorForm.Send(ACOOKIE: string; SPID: string; PON: string; FirstWriting: Boolean);
-const
-       MSG_FUSIANA : string =  '\83\8a\83\82\81[\83g\83z\83X\83g\82ð\95\\8e¦\82·\82é\8b@\94\\82ª\8eg\82í\82ê\82Ä\82¢\82Ü\82·'#13#10 +
-               '\82à\82µ\82à\8aÔ\88á\82Á\82Ä\82±\82Ì\95û\96@\82Å\83z\83X\83g\82ª\95\\8e¦\82³\82ê\82½\82Æ\82µ\82Ä\82à\81A\8e©\8cÈ\90Ó\94C\82È\82Ì\82Å\8dí\8f\9c\88Ë\97\8a\82É\82Í\89\9e\82\82Ü\82¹\82ñ\81B' +
-               #13#10#13#10'\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H';
+procedure TEditorForm.Send( const ACOOKIE: string; const SPID: string;
+ const PON: string; FirstWriting: Boolean);
 var
        TextStream: TStringStream;
        Source: TStringStream;
        ResponseText: string;
        URL: string;
-       RefURL: string;
        State: TGikoDownloadState;
        ResultType: TGikoResultType;
        MsgResult: Integer;
-       Cookie: string;
        Board: TBoard;
        sysMenu : HMENU;
-       //fusianasan\83g\83\89\83b\83v by\92è\8aú\95Ö
-       Namae : String;
-       body : TStringList;
-       Remote : String;
-       ABoard : TBoard;
     {Protocol,Host, Path, Document, Port, Bookmark : String;}
 begin
        FAbort := False;
        State := gdsError;
-       Namae := THTMLCreate.RepHtml(NameComboBox.Text);
     Board := GetBoard;
 
 
-//    tmpRawheader := '';
        InitIdHTTP(Indy);
        if FThreadItem = nil then begin
                URL := FBoard.GetSendURL;
-               RefURL := GikoSys.UrlToServer(FBoard.URL) + 'test/bbs.cgi';
+               Indy.Request.Referer := GikoSys.UrlToServer(FBoard.URL) + 'test/bbs.cgi';
        end else begin
                URL := FThreadItem.GetSendURL;
-               RefURL := FThreadItem.URL;
-       end;
-//     Indy.Request.UserAgent := GikoSys.GetUserAgent;
-       Indy.Request.Referer := RefURL;
-//     Indy.Request.AcceptEncoding := '';
-
-       Cookie := '';
-       if ACOOKIE <> '' then
-          Cookie := ACOOKIE;
-       if SPID <> '' then
-               Cookie := Cookie + 'SPID=' + SPID + '; ';
-       if PON <> '' then
-               Cookie := Cookie + 'PON=' + PON + '; ';
-
-       //\83z\83X\83g\82ª2ch\82Å\81ABe\82ÉLogin\82µ\82Ä\82¢\82ê\82ÎBE\82Ì\83f\81[\83^\82ð\91\97\82é
-       //GikoSys.ParseURI( URL, Protocol,Host, Path, Document, Port, Bookmark );
-       //if GikoSys.Is2chHost(Host) and GikoSys.Setting.BeLogin then
-       if (Board.Is2ch) then begin
-               // \8cÅ\92è\82Ì\83N\83b\83L\81[\82ª\82 \82ê\82Î\90H\82í\82¹\82é
-               if Length(GikoSys.Setting.FixedCookie) > 0 then begin
-                       // \83z\83X\83g\82ª2ch\82Ì\8fê\8d\87\81C\8cÅ\92è\82Ì\83N\83b\83L\81[\82ð\90H\82í\82¹\82é
-                       Cookie := Cookie + GikoSys.Setting.FixedCookie + '; ';
-               end;
-               if (GikoSys.Setting.BeLogin) then begin
-                       Cookie := Cookie + 'MDMD=' + GikoSys.Setting.BeCode + '; '
-                                       + 'DMDM=' + GikoSys.Setting.BeUserID + '; ';
-               end;
-
+               Indy.Request.Referer := FThreadItem.URL;
        end;
 
-       Cookie := 'Cookie: ' + Cookie + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
-
        sysMenu := GetSystemMenu( Handle, false );
        EnableMenuItem( sysMenu, SC_CLOSE, MF_GRAYED );
 {
@@ -807,7 +782,7 @@ begin
        Indy.Request.AcceptLanguage := 'ja';
        Indy.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
        Indy.Request.ContentType := 'application/x-www-form-urlencoded';
-       Indy.Request.CustomHeaders.Add(Cookie);
+       Indy.Request.CustomHeaders.Add(getHeaderStr(ACOOKIE, SPID, PON, Board));
        TextStream := TStringStream.Create('');
        Source := TStringStream.Create('');
        try
@@ -817,64 +792,15 @@ begin
 
                        if (FirstWriting) then begin
                                //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(LocalMode) by \92è\8aú\95Ö
-                               if GikoSys.Setting.LocalTrapAtt then begin
-                                       if LFusianaGet(Namae) then begin
-                                               MsgResult := MsgBox( Handle, MSG_FUSIANA, '\8fî\95ñ',
-                                                       MB_YESNO or MB_ICONQUESTION);
-                                               if MsgResult = IDNO  then begin
-                                                       CancelSend( Board, SysMenu );
-                                                       Exit;
-                                               end;
-                                       end;
-                                       if ((Namae = '\8eR\8dè\8fÂ') or (Namae = 'fusianasan')) then begin
-                                               MsgResult := MsgBox(Handle, MSG_FUSIANA, '\8fî\95ñ',
-                                               MB_YESNO or MB_ICONQUESTION);
-                                               if MsgResult = IDNO  then begin
-                                                       CancelSend( Board, SysMenu );
-                                                       Exit;
-                                               end;
-                                       end;
-                               end;
-
-                               if GikoSys.Setting.RemoteTrapAtt then begin
-                    ABoard := GetBoard;
-
-                                       if ABoard = nil then Exit;
-
-                                       if FileExists(ABoard.GetSETTINGTXTFileName)  then begin
-                                               body := TStringList.Create;
-                                               try
-                                                       body.LoadFromFile(ABoard.GetSETTINGTXTFileName);
-                                                       Remote := GetFusianaName(body, ABoard);
-                                               finally
-                                                       body.Free;
-                                               end;
-                                       end else begin
-                                       //Setting.txt\82ª\82È\82©\82Á\82½\82ç\8eæ\93¾
-                                       //\8eI\82É\95\89\89×\82ª\82©\82©\82è\82»\82¤...
-                                       //if not FileExists(ABoard.GetSETTINGTXTFileName) then begin
-                                               GetSETTINGTXTAction.Execute;
-                                               body := TStringList.Create;
-                                               try
-                                                       if FileExists(ABoard.GetSETTINGTXTFileName) then begin
-                                                               body.LoadFromFile(ABoard.GetSETTINGTXTFileName);
-                                                               Remote := GetFusianaName(body, ABoard);
-                                                       end;
-                                               finally
-                                                       body.Free;
-                                               end;
-                                       end;
-
-                                       if Remote = 'fusianasan' then begin
-                                               MsgResult := MsgBox(
-                                                       Handle, MSG_FUSIANA, '\8fî\95ñ',
-                                                       MB_YESNO or MB_ICONQUESTION);
-                                               if MsgResult = IDNO  then begin
-                                                       CancelSend( Board, SysMenu );
-                                                       Exit;
-                                               end;
-                                       end;
-                               end;
+                if (isLocalFusianaTrap) then begin
+                    CancelSend( Board, SysMenu );
+                    Exit;
+                end;
+                //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(Remote)
+                if (isRemoteFusianaTrap) then begin
+                    CancelSend( Board, SysMenu );
+                    Exit;
+                end;
                        end;
 
                        GetSendData(Source);
@@ -1002,34 +928,23 @@ begin
     if FStatusCode = 302 then begin
         GikoForm.PlaySound('ResEnd');
         SaveSendFile;
-               if FThreadItem = nil then
-                       GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, gmiOK)
-               else
-                       GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, gmiOK);
+        AddFormMessageNew( gmiOK );
         Close;
         Exit;
     end;
        if State = gdsComplete then begin
                GikoForm.PlaySound('ResEnd');
                SaveSendFile;
-               if FThreadItem = nil then
-                       GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, gmiOK)
-               else
-                       GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, gmiOK);
+        AddFormMessageNew( gmiOK );
                Close;
        end else if State = gdsError then begin
-               if FThreadItem = nil then
-                       GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, gmiOK)
-               else
-                       GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, gmiOK);
-
+        AddFormMessageNew( gmiOK );
                EditorPage.ActivePage := PreviewTab;
                SetContent(ResponseText, Browser);
        end else if State = gdsAbort then begin
                GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiSAD);
        end;
 end;
-
 function TEditorForm.GetResultType(ResponseText: string): TGikoResultType;
 begin
        if AnsiPos('\8f\91\82«\82±\82Ý\82ª\8fI\82í\82è\82Ü\82µ\82½', ResponseText) <> 0 then
@@ -1108,31 +1023,60 @@ var
        sDate: string;
        ini: TMemIniFile;
 begin
-       ini := TMemIniFile.Create(GikoSys.GetSentFileName);
-       try
-               sDate := IntToStr(GikoSys.DateTimeToInt(Now));
-
-               ini.WriteString(sDate, 'Name', NameComboBox.Text);
-               ini.WriteString(sDate, 'EMail', MailComboBox.Text);
-               ini.WriteString(sDate, 'Body', HttpEncode(BodyEdit.Text));
-               ini.WriteInteger(sDate, 'Status', FStatusCode);
-               ini.WriteDateTime(sDate, 'Date', Now);
-               if FThreadItem = nil then begin
-                       ini.WriteString(sDate, 'Title', MojuUtils.Sanitize(TitleEdit.Text));
-                       ini.WriteString(sDate, 'BBS', FBoard.BBSID);
-                       ini.WriteInteger(sDate, 'NewThread', 1);
-               end else begin
-                       ini.WriteString(sDate, 'Title', FThreadItem.Title);
-                       ini.WriteString(sDate, 'BBS', FThreadItem.ParentBoard.BBSID);
-                       ini.WriteString(sDate, 'Key', ChangeFileExt(FThreadItem.FileName, ''));
-               end;
-
-               ini.UpdateFile;
-       finally
-               ini.Free;
-       end;
+       ini := CreateSentIniFile;
+    if (ini <> nil) then begin
+        try
+            sDate := IntToStr(GikoSys.DateTimeToInt(Now));
+
+            ini.WriteString(sDate, 'Name', NameComboBox.Text);
+            ini.WriteString(sDate, 'EMail', MailComboBox.Text);
+            ini.WriteString(sDate, 'Body', HttpEncode(BodyEdit.Text));
+            ini.WriteInteger(sDate, 'Status', FStatusCode);
+            ini.WriteDateTime(sDate, 'Date', Now);
+            if FThreadItem = nil then begin
+                ini.WriteString(sDate, 'Title', MojuUtils.Sanitize(TitleEdit.Text));
+                //ini.WriteString(sDate, 'BBS', FBoard.BBSID);
+                ini.WriteString(sDate, 'URL', FBoard.URL);
+                ini.WriteInteger(sDate, 'NewThread', 1);
+            end else begin
+                ini.WriteString(sDate, 'Title', FThreadItem.Title);
+                //ini.WriteString(sDate, 'BBS', FThreadItem.ParentBoard.BBSID);
+                ini.WriteString(sDate, 'URL', FThreadItem.URL);
+                ini.WriteString(sDate, 'Key', ChangeFileExt(FThreadItem.FileName, ''));
+            end;
+
+            ini.UpdateFile;
+        finally
+            ini.Free;
+        end;
+    end;
+end;
+function TEditorForm.CreateSentIniFile: TMemIniFile;
+var
+    maxSize, fileSize, i: Integer;
+    newName: String;
+begin
+    Result := nil;
+    // MB -> bytes
+    maxSize := GikoSys.Setting.SentIniFileSize * 1024 * 1024;
+    // \83t\83@\83C\83\8b\83T\83C\83Y\82ª0\82Ì\8fê\8d\87\82Í\81Asent.ini\82É\8f\91\82«\8d\9e\82Ü\82È\82¢\82Ì\82Ånil\82ð\95Ô\82·
+    if (maxSize > 0) then begin
+        fileSize := GikoSys.GetFileSize(GikoSys.Setting.GetSentFileName);
+        // \8dÅ\91å\83T\83C\83Y\82ð\92´\82¦\82Ä\82¢\82½\8fê\8d\87\82Í\83\8a\83l\81[\83\80\82·\82é
+        if (fileSize >= maxSize) then begin
+            i := 0;
+            // \8d¡\82Ì\8e\9e\8d\8f\82ð\83t\83@\83C\83\8b\96¼\82Ì\8cã\82ë\82É\82Â\82¯\82é
+            repeat
+                // 10\89ñ\88È\8fã\8e¸\94s\82µ\82½\82ç\82 \82«\82ç\82ß\82é
+                if (i > 10) then break;
+                DateTimeToString(newName, 'yyhhnnsszzz', Now());
+                Inc(i);
+            until RenameFile(GikoSys.Setting.GetSentFileName,
+                GikoSys.Setting.GetSentFileName + '.' + newName);
+        end;
+        Result := TMemIniFile.Create(GikoSys.Setting.GetSentFileName);
+    end;
 end;
-
 procedure TEditorForm.SendActionExecute(Sender: TObject);
 const
        TITLE_SAMBA : string = 'Samba24\8cx\8d\90';
@@ -1494,12 +1438,13 @@ end;
 
 procedure TEditorForm.BoardTopClick(Sender: TObject);
 var
-       ini: TIniFile;
+       ini: TMemIniFile;
 begin
-       ini := TIniFile.Create(GikoSys.Setting.GetFileName);
+       ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
        try
                BoardtopTab.TabVisible := BoardTop.Checked;
                ini.WriteBool('EditorForm', 'BoardTopTab', BoardtopTab.TabVisible);
+        ini.UpdateFile;
        finally
                ini.Free;
        end;
@@ -1508,65 +1453,59 @@ end;
 
 procedure TEditorForm.GetSETTINGTXTActionExecute(Sender: TObject);
 var
+       memStream: TMemoryStream;
        URL, RefURL: string;
        settingBody: TStringList;
        tmpBoard: TBoard;
 begin
+       if not FWork then begin
+       FWork := True;
 
-       if FWork then begin
-               Exit;
-       end;
-
-       FWork := True;
-
-       InitIdHTTP(Indy);
-    tmpBoard := GetBoard;
-
-       if tmpBoard = nil then Exit;
-
-       RefURL  := tmpBoard.URL;
-       if RefURL[Length(RefURL)] <> '/' then
-               URL     := RefURL + '/' + 'SETTING.TXT'
-       else
-               URL     := RefURL + 'SETTING.TXT';
-
-       Indy.Request.LastModified := tmpBoard.SETTINGTXTTime;
-       Indy.Request.Referer := RefURL;
-       Screen.Cursor := crHourGlass;
-       settingBody := TStringList.Create;
-       try
-               StatusBar.Panels[0].Text := 'SETTING.TXT\83_\83E\83\93\83\8d\81[\83h\92\86';
-               try
-                       IdAntiFreeze.Active := True;
-                       try
-                               settingBody.Text := Indy.Get(URL);
-                       finally
-                               IdAntiFreeze.Active := False;
-                       end;
-                       if( Indy.ResponseCode = 200 ) then begin
-                               settingBody.SaveToFile(tmpBoard.GetSETTINGTXTFileName);
-                               tmpBoard.SETTINGTXTTime := Indy.Response.LastModified;
-                               tmpBoard.IsSETTINGTXT := true;
-                               tmpBoard.TitlePictureURL := GetTitlePictureURL(settingBody, tmpBoard);
-                               tmpBoard.Modified := true;
-                               StatusBar.Panels[0].Text := 'SETTING.TXT\8eæ\93¾\8a®\97¹(' + IntToStr(Indy.ResponseCode) + ')';
-                       end;
-               except
-                       on E: EIdException do begin
-                               if( AnsiPos('304', E.Message) > 0 ) then
-                                       StatusBar.Panels[0].Text := 'SETTING.TXT\8dX\90V\96³\82µ(' + IntToStr(Indy.ResponseCode) + ')'
-                               else
-                                       StatusBar.Panels[0].Text := 'SETTING.TXT\8eæ\93¾\83G\83\89\81[(' + IntToStr(Indy.ResponseCode) + ')';
-                       end;
-               end;
-       finally
-               settingBody.Free;
-               Screen.Cursor := crDefault;
-               FWork := False;
-       end;
-       ShowBoardInformation(tmpBoard, BoardInformationMemo);
-
-
+        tmpBoard := GetBoard;
+        if tmpBoard <> nil then begin
+
+            RefURL     := tmpBoard.URL;
+            if RefURL[Length(RefURL)] <> '/' then
+                URL    := RefURL + '/' + 'SETTING.TXT'
+            else
+                URL    := RefURL + 'SETTING.TXT';
+            Screen.Cursor := crHourGlass;
+            memStream := TMemoryStream.Create;
+            try
+                try
+                    StatusBar.Panels[0].Text := 'SETTING.TXT\83_\83E\83\93\83\8d\81[\83h\92\86';
+                    GetWebData(URL, RefURL, tmpBoard.SETTINGTXTTime, memStream);
+                    if( Indy.ResponseCode = 200 ) then begin
+                        settingBody := TStringList.Create;
+                        try
+                            memStream.Seek(0, soFromBeginning);
+                            settingBody.LoadFromStream(memStream);
+                            settingBody.SaveToFile(tmpBoard.GetSETTINGTXTFileName);
+                            tmpBoard.SETTINGTXTTime := Indy.Response.LastModified;
+                            tmpBoard.IsSETTINGTXT := true;
+                            tmpBoard.TitlePictureURL := GetTitlePictureURL(settingBody, tmpBoard);
+                            tmpBoard.Modified := true;
+                        finally
+                            settingBody.Free;
+                        end;
+                        StatusBar.Panels[0].Text := 'SETTING.TXT\8eæ\93¾\8a®\97¹(' + IntToStr(Indy.ResponseCode) + ')';
+                    end;
+                except
+                    on E: EIdException do begin
+                        if( AnsiPos('304', E.Message) > 0 ) then
+                            StatusBar.Panels[0].Text := 'SETTING.TXT\8dX\90V\96³\82µ(' + IntToStr(Indy.ResponseCode) + ')'
+                        else
+                            StatusBar.Panels[0].Text := 'SETTING.TXT\8eæ\93¾\83G\83\89\81[(' + IntToStr(Indy.ResponseCode) + ')';
+                    end;
+                end;
+            finally
+                memStream.Free;
+                Screen.Cursor := crDefault;
+            end;
+            ShowBoardInformation(tmpBoard, BoardInformationMemo);
+        end;
+        FWork := False;
+    end;
 end;
 
 procedure TEditorForm.ShowBoardInformation(ABoard: TBoard; AMemo: TMemo);
@@ -1640,38 +1579,53 @@ begin
                Exit;
 
        FWork := True;
-
-       InitIdHTTP(Indy);
        memStream := TMemoryStream.Create;
        try
         tmpBoard := GetBoard;
 
-               Indy.Request.Referer := tmpBoard.URL;
-               if      tmpBoard.TitlePictureURL <> '' then begin
+               if (tmpBoard <> nil) and (tmpBoard.TitlePictureURL <> '') then begin
                        StatusBar.Panels[0].Text := '\94Â\83g\83b\83v\89æ\91\9c\83_\83E\83\93\83\8d\81[\83h\92\86';
                        Screen.Cursor := crHourGlass;
                        try
-                               IdAntiFreeze.Active := True;
-                               try
-                                       Indy.Get(tmpBoard.TitlePictureURL, memStream);
-                               finally
-                                       IdAntiFreeze.Active := False;
-                               end;
+                // URL\82ð\8ew\92è\82µ\82Ä\83\81\83\82\83\8a\82É\93Ç\82Ý\8d\9e\82Þ
+                GetWebData(tmpBoard.TitlePictureURL, tmpBoard.URL,
+                    ZERO_DATE, memStream);
                                if Indy.ResponseCode = 200 then begin
                                        memStream.SaveToFile(tmpBoard.GetTitlePictureFileName);
                                        ShowTitlePicture();
                                        tmpBoard.Modified := true;
                                end;
+                StatusBar.Panels[0].Text := '\94Â\83g\83b\83v\89æ\91\9c (' + IntToStr(Indy.ResponseCode) + ')';
                        except
                        end;
                end;
        finally
-               Screen.Cursor := crDefault;
-               StatusBar.Panels[0].Text := '\94Â\83g\83b\83v\89æ\91\9c (' + IntToStr(Indy.ResponseCode) + ')';
                memStream.Free;
+        FWork := False;
+               Screen.Cursor := crDefault;
        end;
+end;
+{
+\brief  URL\82Ì\83f\81[\83^\82ðstream\82É\93Ç\82Ý\8d\9e\82Þ
+\param  URL \93Ç\82Ý\8d\9e\82Þ\90æ
+\param  RefURL   referer\82É\90Ý\92è\82·\82é
+\param  Modified    Modified\82É\90Ý\92è\82·\82é
+\param  stream  \93Ç\82Ý\8d\9e\82ñ\82¾\83f\81[\83^\82Ì\95Û\91\90æ
+}
+procedure TEditorForm.GetWebData(const URL: string; const RefURL: string;
+             Modified: TDateTime; stream: TStream);
+begin
+    InitIdHTTP(Indy);
+    Indy.Request.Referer := RefURL;
+    Indy.Request.LastModified := Modified;
+    
+    IdAntiFreeze.Active := True;
+    try
+        Indy.Get(URL, stream);
+    finally
+        IdAntiFreeze.Active := False;
+    end;
 
-        FWork := False;
 end;
 procedure TEditorForm.ShowTitlePicture();
 var
@@ -1708,69 +1662,63 @@ var
        URL, RefURL: string;
        settingBody: TStringList;
        tmpBoard: TBoard;
+       memStream: TMemoryStream;
 begin
-        if FWork then
-               Exit;
+    if not FWork then begin
         FWork := True;
 
-       InitIdHTTP(Indy);
-
-    tmpBoard := GetBoard;
-
-       if tmpBoard = nil then Exit;
-
-       RefURL  := tmpBoard.URL;
-       if RefURL[Length(RefURL)] <> '/' then
-               URL     := RefURL + '/' + 'head.txt'
-       else
-               URL     := RefURL + 'head.txt';
-
-       if FileExists(tmpBoard.GETHEADTXTFileName) then
-               Indy.Request.LastModified := tmpBoard.HEADTXTTime
-       else
-               Indy.Request.LastModified := ZERO_DATE;
-
-       Indy.Request.Referer := RefURL;
-       Screen.Cursor := crHourGlass;
-       settingBody := TStringList.Create;
-       try
-               StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b(head.txt)\83_\83E\83\93\83\8d\81[\83h\92\86';
-               try
-                       IdAntiFreeze.Active := True;
-                       try
-                               settingBody.Text := Indy.Get(URL);
-                       finally
-                               IdAntiFreeze.Active := False;
-                       end;
-                       if( Indy.ResponseCode = 200 ) then begin
-                               settingBody.Insert(0, '<HTML lang="ja"><HEAD>');
-                               settingBody.Insert(1, '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">');
-                               settingBody.Insert(2, '<TITLE>' + tmpBoard.Title + '</TITLE>');
-                               settingBody.Insert(3, '<base href="' + RefURL + '"></HEAD><BODY>');
-                               settingBody.Add('</BODY></HTML>');
-                               settingBody.SaveToFile(tmpBoard.GETHEADTXTFileName);
-                               tmpBoard.HEADTXTTime := Indy.Response.LastModified;
-                               tmpBoard.IsHEADTXT := true;
-                               tmpBoard.Modified := true;
-                               StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾\8a®\97¹(' + IntToStr(Indy.ResponseCode) + ')';
-                       end;
-               except
-                       on E: EIdException do begin
-                               if( AnsiPos('304', E.Message) > 0 ) then
-                                       StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8dX\90V\96³\82µ(' + IntToStr(Indy.ResponseCode) + ')'
-                               else
-                                       StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾\83G\83\89\81[(' + IntToStr(Indy.ResponseCode) + ')';
-                       end;
-               end;
-       finally
-               settingBody.Free;
-               Screen.Cursor := crDefault;
+        tmpBoard := GetBoard;
+        if (tmpBoard <> nil) then begin
+
+            RefURL     := tmpBoard.URL;
+            if RefURL[Length(RefURL)] <> '/' then
+                URL    := RefURL + '/' + 'head.txt'
+            else
+                URL    := RefURL + 'head.txt';
+
+            Screen.Cursor := crHourGlass;
+            memStream := TMemoryStream.Create;
+            try
+                StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b(head.txt)\83_\83E\83\93\83\8d\81[\83h\92\86';
+                try
+                    GetWebData(URL, RefURL, tmpBoard.HEADTXTTime, memStream);
+                    if( Indy.ResponseCode = 200 ) then begin
+                        settingBody := TStringList.Create;
+                        try
+                            memStream.Seek(0, soFromBeginning);
+                            settingBody.LoadFromStream(memStream);
+                            settingBody.Insert(0, '<HTML lang="ja"><HEAD>');
+                            settingBody.Insert(1, '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">');
+                            settingBody.Insert(2, '<TITLE>' + tmpBoard.Title + '</TITLE>');
+                            settingBody.Insert(3, '<base href="' + RefURL + '"></HEAD><BODY>');
+                            settingBody.Add('</BODY></HTML>');
+                            settingBody.SaveToFile(tmpBoard.GETHEADTXTFileName);
+                            tmpBoard.HEADTXTTime := Indy.Response.LastModified;
+                            tmpBoard.IsHEADTXT := true;
+                            tmpBoard.Modified := true;
+                        finally
+                            settingBody.Free;
+                        end;
+                        StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾\8a®\97¹(' + IntToStr(Indy.ResponseCode) + ')';
+                    end;
+                except
+                    on E: EIdException do begin
+                        if( AnsiPos('304', E.Message) > 0 ) then
+                            StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8dX\90V\96³\82µ(' + IntToStr(Indy.ResponseCode) + ')'
+                        else
+                            StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾\83G\83\89\81[(' + IntToStr(Indy.ResponseCode) + ')';
+                    end;
+                end;
+            finally
+                memStream.Free;
+                Screen.Cursor := crDefault;
+            end;
+            if tmpBoard.IsHEADTXT then begin
+                ShowBoardHead(tmpboard, LocalEdit);
+            end;
+        end;
         FWork := False;
-       end;
-       if tmpBoard.IsHEADTXT then begin
-                               ShowBoardHead(tmpboard, LocalEdit);
-       end;
-
+    end;
 
 end;
 
@@ -1839,6 +1787,7 @@ var
        Action: TAction;
 begin
        s := MouseGesture.GetGestureStr;
+    MouseGesture.Clear;
        Action := GikoSys.Setting.Gestures.GetGestureAction(s);
        if Action <> nil then
                Action.Execute;
@@ -1883,12 +1832,14 @@ begin
        KotehanCheckBox.Enabled := SaveNameMailAction.Checked;
 end;
 
-function TEditorForm.LFusianaGet(s: String): Boolean;
+function TEditorForm.LFusianaGet(const s: String): Boolean;
+const
+    FUSIANA = 'fusianasan';
 var
        i: Integer;
 begin
-               i := AnsiPos('fusianasan', s);
-               if (i > 0) then Result := True else Result := False;
+    i := AnsiPos(FUSIANA, s);
+    Result := (i > 0);
 end;
 
 procedure TEditorForm.BeLogInOutEActionExecute(Sender: TObject);
@@ -2277,5 +2228,130 @@ begin
         Result := FThreadItem.ParentBoard;
     end;
 end;
+{
+\brief  GikoForm\82É\83\81\83b\83Z\81[\83W\82ð\92Ç\89Á\82·\82é
+\param  icon    \83\81\83b\83Z\81[\83W\82É\82Â\82­\83A\83C\83R\83\93
+}
+procedure TEditorForm.AddFormMessageNew(icon: TGikoMessageIcon);
+begin
+    if FThreadItem = nil then begin
+        GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, icon)
+    end else begin
+        GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, icon);
+    end;
+
+end;
+{
+\brief  \83\8d\81[\83J\83\8bfusiana\83g\83\89\83b\83v
+\return true:\91\97\90M\92\86\8e~ false:\91\97\90M
+}
+function TEditorForm.isLocalFusianaTrap: Boolean;
+var
+    Namae : string;
+begin
+    Result := False;
+    if GikoSys.Setting.LocalTrapAtt then begin
+        Namae := THTMLCreate.RepHtml(NameComboBox.Text);
+        if (LFusianaGet(Namae)) or (Namae = '\8eR\8dè\8fÂ') then begin
+            if FusianaMsgBox = IDNO  then begin
+                Result := True;
+            end;
+        end;
+    end;
+end;
+{
+\brief  \83\8a\83\82\81[\83gfusiana\83g\83\89\83b\83v
+\return true:\91\97\90M\92\86\8e~ false:\91\97\90M
+}
+function TEditorForm.isRemoteFusianaTrap: Boolean;
+var
+    Namae : string;
+    Board : TBoard;
+    Remote: string;
+    body : TStringList;
+begin
+    Result := False;
+    Namae := THTMLCreate.RepHtml(NameComboBox.Text);
+    if (GikoSys.Setting.RemoteTrapAtt) and (Length(Namae) = 0) then begin
+        Board := GetBoard;
+
+        if Board = nil then Exit;
+
+        if not FileExists(Board.GetSETTINGTXTFileName)  then begin
+            //Setting.txt\82ª\82È\82©\82Á\82½\82ç\8eæ\93¾
+            //\8eI\82É\95\89\89×\82ª\82©\82©\82è\82»\82¤...
+            try
+                GetSETTINGTXTAction.Execute;
+            except
+            end;
+        end;
+
+        Remote := '';
+        if FileExists(Board.GetSETTINGTXTFileName)  then begin
+            body := TStringList.Create;
+            try
+                body.LoadFromFile(Board.GetSETTINGTXTFileName);
+                Remote := GetFusianaName(body, Board);
+            finally
+                body.Free;
+            end;
+        end;
+
+        if LFusianaGet(Remote) then begin
+            if FusianaMsgBox = IDNO  then begin
+                Result := True;
+            end;
+        end;
+    end;
+end;
+{
+\brief  Header\95\8e\9a\97ñ\8eæ\93¾
+\param  ACOOKIE Cookie
+\param  SPID    SPID
+\param  PON    PON
+\param  Board   \94Â
+\return Header\95\8e\9a\97ñ
+}
+function TEditorForm.getHeaderStr(const ACOOKIE: string; const SPID : string;
+    const PON : string; Board : TBoard) : string;
+begin
+       Result := ACOOKIE;
+       if SPID <> '' then
+               Result := Result + 'SPID=' + SPID + '; ';
+       if PON <> '' then
+               Result := Result + 'PON=' + PON + '; ';
+
+       //\83z\83X\83g\82ª2ch\82Å\81ABe\82ÉLogin\82µ\82Ä\82¢\82ê\82ÎBE\82Ì\83f\81[\83^\82ð\91\97\82é
+       //GikoSys.ParseURI( URL, Protocol,Host, Path, Document, Port, Bookmark );
+       //if GikoSys.Is2chHost(Host) and GikoSys.Setting.BeLogin then
+       if (Board.Is2ch) then begin
+               // \8cÅ\92è\82Ì\83N\83b\83L\81[\82ª\82 \82ê\82Î\90H\82í\82¹\82é
+               if Length(GikoSys.Setting.FixedCookie) > 0 then begin
+                       // \83z\83X\83g\82ª2ch\82Ì\8fê\8d\87\81C\8cÅ\92è\82Ì\83N\83b\83L\81[\82ð\90H\82í\82¹\82é
+                       Result := Result + GikoSys.Setting.FixedCookie + '; ';
+               end;
+               if (GikoSys.Setting.BeLogin) then begin
+                       Result := Result + 'MDMD=' + GikoSys.Setting.BeCode + '; '
+                                       + 'DMDM=' + GikoSys.Setting.BeUserID + '; ';
+               end;
+
+       end;
+
+       Result := 'Cookie: ' + Result + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
+
+end;
+{
+\brief fusiana\8cx\8d\90\83_\83C\83A\83\8d\83O
+\return IDYES \8f\91\82«\8d\9e\82Þ IDNO \92\86\8e~
+}
+function TEditorForm.FusianaMsgBox: Integer;
+const
+       MSG_FUSIANA : string =  '\83\8a\83\82\81[\83g\83z\83X\83g\82ð\95\\8e¦\82·\82é\8b@\94\\82ª\8eg\82í\82ê\82Ä\82¢\82Ü\82·'#13#10 +
+               '\82à\82µ\82à\8aÔ\88á\82Á\82Ä\82±\82Ì\95û\96@\82Å\83z\83X\83g\82ª\95\\8e¦\82³\82ê\82½\82Æ\82µ\82Ä\82à\81A\8e©\8cÈ\90Ó\94C\82È\82Ì\82Å\8dí\8f\9c\88Ë\97\8a\82É\82Í\89\9e\82\82Ü\82¹\82ñ\81B' +
+               #13#10#13#10'\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H';
+begin
+    Result := MsgBox(Handle, MSG_FUSIANA, '\8fî\95ñ',
+                MB_YESNO or MB_ICONQUESTION);
+end;
 
 end.