OSDN Git Service

冒険の書→忍法帖
authorh677 <h677>
Sun, 27 Feb 2011 01:25:25 +0000 (01:25 +0000)
committerh677 <h677>
Sun, 27 Feb 2011 01:25:25 +0000 (01:25 +0000)
すいとんされた時に、Cookieを削除するように修正

Editor.pas
GikoSystem.pas
Setting.pas
gikoNavi.res

index a8a6381..4258d8d 100644 (file)
@@ -22,7 +22,7 @@ uses
 type
 //     TSetLayeredWindowAttributes = function(wnd: HWND; crKey: DWORD; bAlpha: BYTE; dwFlag: DWORD): Boolean; stdcall;
        //\8f\91\82«\8d\9e\82Ý\96ß\82è\92l\83^\83C\83v
-       TGikoResultType = (grtOK, grtCookie, grtCheck, grtError, grtBouken, grtBoukenErr);
+       TGikoResultType = (grtOK, grtCookie, grtCheck, grtError, grtNinpou, grtNinpouErr, grtSuiton);
 
        TEditorForm = class(TForm)
                MainMenu: TMainMenu;
@@ -220,6 +220,7 @@ type
                FInputAssistKey: String;        ///< \93ü\97Í\83A\83V\83X\83g\82Ì\83L\81[
                FResistWords: TStringList;      ///< \93ü\97Í\83A\83V\83X\83g\82Ì\8e«\8f\91\82©\82ç\82Ì\8c\9f\8dõ\8c\8b\89Ê
         FSambaTimer: TSambaTimer;   ///< Samba\91Î\8dô\82Ì\83^\83C\83}\81[
+        FCookieDomain: string;        ///< \94E\96@\92\9f\83h\83\81\83C\83\93
                procedure Preview;
                function Check: Boolean;
                procedure SetNameList(sName, sMail: string);
@@ -784,7 +785,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(getHeaderStr(ACOOKIE, SPID, PON, GikoSys.GetBoukenCookie(URL), Board));
+       Indy.Request.CustomHeaders.Add(getHeaderStr(ACOOKIE, SPID, PON, GikoSys.GetBouken(URL, FCookieDomain), Board));
        TextStream := TStringStream.Create('');
        Source := TStringStream.Create('');
        try
@@ -887,23 +888,40 @@ begin
                                        CancelSend( Board, SysMenu );
                                        Exit;
                                end;
-                       end else if ResultType = grtBouken then begin
+                       end else if ResultType = grtNinpou then begin
                                MsgBox( Handle,
-                                               '\8bM\95û\82Ì\96`\8c¯\82Ì\8f\91\82ð\8dì\90¬\92\86\82Å\82·\81B\88ø\82«\95Ô\82·\82È\82ç\82¢\82Ü\82¾\81B(\82Q\95ª\82Ù\82Ç\82©\82©\82è\82Ü\82·)' + #13#10
+                                               '\8bM\95û\82Ì\94E\96@\92\9f\82ð\8dì\90¬\92\86\82Å\82·\81B\88ø\82«\95Ô\82·\82È\82ç\82¢\82Ü\82¾\81B(\82Q\95ª\82Ù\82Ç\82©\82©\82è\82Ü\82·)' + #13#10
                                                , '\8am\94F',
-                                               MB_OK or MB_ICONQUESTION);
+                                               MB_OK or MB_ICONINFORMATION);
+                               if (GikoSys.Setting.UseSamba)  and  (FSambaTimer.Enabled) then
+                begin
+                                       FSambaTimer.WriteSambaTime(Now());
+                end;
                 Board.PON  := '';
                 Board.SPID := '';
                 Board.Cookie := '';
                 GetCookie(Indy.CookieManager, Board);
                                Exit;
+            end else if ResultType = grtSuiton then begin
+                               MsgBox( Handle,
+                                               '\8bM\95û\82Ì\94E\96@\92\9f\82Í\8fÄ\82©\82ê\82Ü\82µ\82½\81B' + #13#10 +
+                        '\94E\96@\92\9f\82ð\8dí\8f\9c\82µ\82Ü\82µ\82½\81A\8dÄ\91\97\90M\82µ\82Ä\82­\82¾\82³\82¢\81B'
+                                               , '\8am\94F',
+                                               MB_OK or MB_ICONINFORMATION);
+                // \94E\96@\92\9f\8aª\95¨\82ð\8fÁ\82·
+                GikoSys.DelBoukenCookie(FCookieDomain);
+                GikoSys.Setting.WriteBoukenSettingFile;
+                Board.PON  := '';
+                Board.SPID := '';
+                Board.Cookie := '';
+                Exit;
                        end else begin
                                if (GikoSys.Setting.UseSamba)  and  (FSambaTimer.Enabled) then
                 begin
                                        FSambaTimer.WriteSambaTime(Now());
                 end;
-                // \96`\8c¯\82Ì\8f\91\83G\83\89\81[\82ÍCookie\82ð\8dX\90V\82·\82é
-                if ResultType = grtBoukenErr then begin
+                // \94E\96@\92\9f\8aª\95¨\83G\83\89\81[\82ÍCookie\82ð\8dX\90V\82·\82é
+                if ResultType = grtNinpouErr then begin
                     GetCookie(Indy.CookieManager, Board);
                 end;
                                State := gdsError;
@@ -981,13 +999,17 @@ function TEditorForm.GetResultType(ResponseText: string): TGikoResultType;
 begin
        if AnsiPos('\8f\91\82«\82±\82Ý\82ª\8fI\82í\82è\82Ü\82µ\82½', ResponseText) <> 0 then
                Result := grtOK
-    else if (AnsiPos('\82d\82q\82q\82n\82q\81F\8bM\95û\82Ì\96`\8c¯\82Ì\8f\91\82ð\8dì\90¬\92\86\82Å\82·', ResponseText) > 0)
+    else if ( (AnsiPos('<b>\82æ\82¤\82±\82»\81F\8bM\95û\82Ì\94E\96@\92\9f\82ð\8dì\90¬\82µ\82Ü\82·\81B\82Q\95ª\8cã\82É\8dÄ\93x\8f\91\82«\8d\9e\82Þ\82©\81A\82¨\8bA\82è\82­\82¾\82³\82¢', ResponseText) > 0) or
+              (AnsiPos('\82d\82q\82q\82n\82q\81F\8bM\95û\82Ì\96`\8c¯\82Ì\8f\91\82ð\8dì\90¬\92\86\82Å\82·', ResponseText) > 0) )
                 and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)         then
-        Result := grtBouken
+        Result := grtNinpou
     else if ( (AnsiPos('\82d\82q\82q\82n\82q\81F\8fC\8ds\82ª\91«\82è\82Ü\82¹\82ñ', ResponseText) > 0) or   // \83G\83\89\81[\88µ\82¢
               (AnsiPos('\82d\82q\82q\82n\82q\81FLv\82ª\91«\82è\82È\82­\82Ä\83X\83\8c\83b\83h\97§\82Ä', ResponseText) > 0) ) // \83G\83\89\81[\88µ\82¢
               and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)   then
-        Result := grtBoukenErr
+        Result := grtNinpouErr
+    else if( AnsiPos('<b>\82â\82ç\82ê\82½\82Å\82²\82´\82é\81FLv=0 <br>\82³\82Ä\8e©\97Í\82Å\95\9c\8a\88\82Å\82«\82é\82©\82È?', ResponseText) > 0) 
+              and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)   then
+        Result := grtSuiton
        else if ( AnsiPos('\83N\83b\83L\81[\82ª\82È\82¢\82©\8aú\8cÀ\90Ø\82ê\82Å\82·', ResponseText) > 0) or
                                        (AnsiPos('<title>\83N\83b\83L\81[\8am\94F\81I</title>', ResponseText) > 0)    or
                                        (AnsiPos('<title>\81¡\83N\83b\83L\81[\8am\94F\81I\81¡</title>', ResponseText) > 0) or
@@ -1920,6 +1942,8 @@ begin
     curCookies := TStringList.Create;
     curCookies.Delimiter := ';';
     curCookies.DelimitedText := ABoard.Cookie;
+    curCookies.Sort;
+    curCookies.Duplicates := dupIgnore;
        ABoard.Cookie := '';
     try
         for i := 0 to CookieMng.CookieCollection.Count - 1 do begin
@@ -1941,7 +1965,7 @@ begin
                 if Length( curCookies.Values[ Cookie.CookieName ] ) > 0 then begin
                     // \8aù\91\92l\82Ì\95t\82¯\91Ö\82¦
                     curCookies[curCookies.IndexOfName(Cookie.CookieName)] :=
-                        Cookie.Value;
+                        Cookie.ClientCookie;
                 end else begin
                     // \92Ç\89Á
                     curCookies.Add(Cookie.ClientCookie);
@@ -1949,8 +1973,8 @@ begin
             end;
         end;
         for i := 0 to curCookies.Count - 1 do begin
-            if (curCookies.Strings[i] <> '') then begin
-                ABoard.Cookie := ABoard.Cookie + curCookies.Strings[i] + '; ';
+            if (curCookies[i] <> '') then begin
+                ABoard.Cookie := ABoard.Cookie + curCookies[i] + '; ';
             end;
         end;
     finally
index 1a0b414..2c1e4d7 100644 (file)
@@ -265,6 +265,8 @@ type
         procedure DelBoukenCookie(ADomain: String);
         //! \96`\8c¯\82Ì\8f\91Domain\88ê\97\97\8eæ\93¾
         procedure GetBoukenDomain(var ADomain: TStringList);
+        //! \96`\8c¯\82Ì\8f\91\83h\83\81\83C\83\93\96¼Cookie\8eæ\93¾
+        function GetBouken(AURL: String; var Domain: String): String;
        end;
 
 var
@@ -3497,7 +3499,19 @@ begin
         end;
     end;
 end;
-
+function TGikoSys.GetBouken(AURL: String; var Domain: String): String;
+var
+       Protocol, Host, Path, Document, Port,Bookmark : String;
+    Cookie : String;
+begin
+    Domain := '';
+    Cookie := '';
+    GikoSys.ParseURI(AURL, Protocol, Host, Path, Document, Port,Bookmark);
+    if ( Length(Host) > 0 ) then begin
+        Setting.GetBouken(Host, Domain, Cookie);
+        Result := Cookie;
+    end;
+end;
 
 initialization
        GikoSys := TGikoSys.Create;
index 27b66fa..cfbf9ec 100644 (file)
@@ -550,6 +550,7 @@ type
         function GetExtprevieFileName: String;
         function GetBoukenCookie(AHostName: String): String;
         procedure SetBoukenCookie(ACookieValue, AHostName: String);
+        procedure GetBouken(AHostName: String; var Domain:String; var Cookie:String);
         {
         \brief  \83\8a\83\93\83N\97\9a\97ð\82Ì\95Û\8e\9d\83T\83C\83Y\82Ìsetter
         \param  AVal    \90Ý\92è\82·\82é\83T\83C\83Y( >0)
@@ -2503,5 +2504,19 @@ begin
         FBoukenCookieList.Add(AHostName + '=' + ACookieValue);
     end;
 end;
+procedure TSetting.GetBouken(AHostName: String; var Domain:String; var Cookie:String);
+var
+    i : Integer;
+begin
+    Cookie := '';
+    for i := 0 to FBoukenCookieList.Count - 1 do begin
+        if ( AnsiPos(FBoukenCookieList.Names[i], AHostName) > 0 ) then begin
+            Domain := FBoukenCookieList.Names[i];
+            Cookie := FBoukenCookieList.Values[FBoukenCookieList.Names[i]];
+            Break;
+        end;
+    end;
+end;
+
 end.
 
index 3c48b28..b9e03a8 100644 (file)
Binary files a/gikoNavi.res and b/gikoNavi.res differ