OSDN Git Service

ハ゛タ62の変更点を追加
[gikonavigoeson/gikonavi.git] / Editor.pas
index 93b311e..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
@@ -1931,14 +1955,17 @@ begin
                 ABoard.SPID := Cookie.Value;
                 ABoard.Expires := GMTToLocalDateTime(Cookie.Expires);
             end else if ( Cookie.CookieName = VAL_HAP ) then begin
-                GikoSys.SetBoukenCookie(Cookie.Value, Cookie.Domain);
-                // \96`\8c¯\82Ì\8f\91\82Ì\95Û\91
-                GikoSys.Setting.WriteBoukenSettingFile;
+                // HAP\8dí\8f\9c\97p\82ÌCookie\82ª\94z\95z\82³\82ê\82é\82Ì\82Å\81A\97L\8cø\8aú\8cÀ\82ð\83`\83F\83b\83N\82·\82é
+                if CompareDateTime(GMTToLocalDateTime(Cookie.Expires) ,Now) > 0 then begin
+                    GikoSys.SetBoukenCookie(Cookie.Value, Cookie.Domain);
+                    // \96`\8c¯\82Ì\8f\91\82Ì\95Û\91
+                    GikoSys.Setting.WriteBoukenSettingFile;
+                end;
             end else 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);
@@ -1946,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
@@ -2488,7 +2515,7 @@ begin
        Result := 'Cookie: ' + Result + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
 
     if HAP <> '' then
-       Result := Result + #13#10'Cookie: HAP=' + HAP + '; ';
+       Result := Result + '; HAP=' + HAP + '; ';
 
 end;