OSDN Git Service

1.60.2.794
[gikonavigoeson/gikonavi.git] / GikoSystem.pas
index 3a7fcac..6541887 100644 (file)
@@ -181,7 +181,7 @@ type
 
                procedure MenuFont(Font: TFont);
 
-               function RemoveToken(var s:string; const delimiter:string):string;
+//             function RemoveToken(var s:string; const delimiter:string):string;
                function GetTokenIndex(s: string; delimiter: string; index: Integer): string;
 
                function GetShortName(const LongName: string; ALength: integer): string;
@@ -213,13 +213,11 @@ type
                procedure GetPopupResNumber(URL : string; var stRes, endRes : Int64);
 
                property Bayesian : TGikoBayesian read FBayesian write FBayesian;
-               function GetSameIDResAnchor(const AID : string; ThreadItem: TThreadItem; limited: Integer):string; overload;
-               function GetSameIDResAnchor(AIDNum : Integer; ThreadItem: TThreadItem; limited: Integer):string; overload;
+        function CreateResAnchor(var Numbers: TStringList; ThreadItem: TThreadItem; limited: Integer):string;
                procedure GetSameIDRes(const AID : string; ThreadItem: TThreadItem;var body: TStringList); overload;
                procedure GetSameIDRes(AIDNum : Integer; ThreadItem: TThreadItem;var body: TStringList); overload;
-               function GetSameIDResCount(const AID : string; ThreadItem: TThreadItem):Integer; overload;
-               function GetSameIDResCount(AIDNum : Integer; ThreadItem: TThreadItem):Integer; overload;
         function GetResID(AIDNum: Integer; ThreadItem: TThreadItem): String;
+        function ExtructResID(ADateStr: String): String;
                //! \92P\8cê\89ð\90Í
                procedure SpamCountWord( const text : string; wordCount : TWordCount );
                //! \8aw\8fK\83N\83\8a\83A
@@ -228,8 +226,6 @@ type
                procedure SpamLearn( wordCount : TWordCount; isSpam : Boolean );
                //! \83X\83p\83\80\93x\90\94
                function SpamParse( const text : string; wordCount : TWordCount ) : Extended;
-               //\88ø\90\94\82ª\81A\93ú\95t\82Å\82à\8e\9e\8d\8f\82Å\82à\82È\82¢\82±\82Æ\82ð\92²\82×\82é
-               function NotDateorTimeString(const AStr : string): boolean;
 
                //! \88ø\90\94\82É\91\97\82ç\82ê\82Ä\82«\82½\93ú\95t/ID\95\94\82ÉBE\82Ì\95\8e\9a\97ñ\82ª\82 \82Á\82½\82ç\81A\83v\83\8d\83t\83@\83C\83\8b\82Ö\82Ì\83\8a\83\93\83N\82ð\92Ç\89Á
                function AddBeProfileLink(AID : string; ANum: Integer): string;
@@ -268,7 +264,7 @@ const
        ZERO_DATE: Integer      = 25569;
        BETA_VERSION_NAME_E = 'beta';
        BETA_VERSION_NAME_J = 'ÊÞÀ';
-       BETA_VERSION                            = 58;
+       BETA_VERSION                            = 60;
        BETA_VERSION_BUILD      = '';                           //!< debug\94Å\82È\82Ç
        APP_NAME                                                = 'gikoNavi';
        BE_PHP_URL = 'http://be.2ch.net/test/p.php?i=';
@@ -649,7 +645,7 @@ begin
                                        end;
                                end;
 
-                               ThreadItem.BeginUpdate;
+                               //ThreadItem.BeginUpdate;
                                if (datFileCheck) and (islog) then
                                        FileList.Delete( Index );
 
@@ -674,7 +670,7 @@ begin
                                Node := FavoriteDM.TreeView.Items.AddChildObject( FavoriteDM.TreeView.Items.Item[0], ThreadItem.Title, FavoThreadItem);
                                *}
 
-                               ThreadItem.EndUpdate;
+                               //ThreadItem.EndUpdate;
                                Board.Add(ThreadItem);
 
                                if (ThreadItem.UnRead) and (ThreadItem.IsLogFile) then
@@ -703,7 +699,7 @@ begin
        Board.IsThreadDatRead := True;
 {$IFDEF DEBUG}
        rt := GetTickCount - st;
-       Writeln('Read Done.' + IntToStr(rt) + ' ms');
+       Writeln('Read Done.' + Board.Title + ':' + IntToStr(rt) + ' ms');
 {$ENDIF}
 end;
 {!
@@ -947,7 +943,7 @@ begin
        Result.FLastModified := IntToDateTime(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), ZERO_DATE));
        Result.FKokomade := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), -1);
        Result.FNewReceive := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
-       RemoveToken(Line, #1);//9: ;    //\96¢\8eg\97p
+       MojuUtils.RemoveToken(Line, #1);//9: ;  //\96¢\8eg\97p
        Result.FUnRead := IntToBool(StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0));
        Result.FScrollTop := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
        Result.FAllResCount := StrToIntDef('$' + MojuUtils.RemoveToken(Line, #1), 0);
@@ -1102,8 +1098,8 @@ begin
                Delim := ','
        else
                Delim := '<>';
-       Result.FFileName := RemoveToken(Line, Delim);
-       Result.FTitle := Trim(RemoveToken(Line, Delim));
+       Result.FFileName := MojuUtils.RemoveToken(Line, Delim);
+       Result.FTitle := Trim(MojuUtils.RemoveToken(Line, Delim));
 
        ws := Result.FTitle;
        if Copy(ws, Length(ws), 1) = ')' then begin
@@ -1367,7 +1363,7 @@ end;
 
 \82Ç\82±\82©\82Ì\83T\83C\83g\82©\82ç\82Ì\83p\83N\83\8a
 }
-function TGikoSys.RemoveToken(var s: string;const delimiter: string): string;
+{function TGikoSys.RemoveToken(var s: string;const delimiter: string): string;
 var
        p: Integer;
 begin
@@ -1378,7 +1374,7 @@ begin
                Result := Copy(s, 1, p - 1);
        Delete(s, 1, Length(Result) + Length(delimiter));
 end;
-
+}
 
 {!
 \brief n \8cÂ\96Ú\82Ì\83g\81[\83N\83\93\82ð\90Ø\82è\8fo\82µ
@@ -1394,7 +1390,7 @@ var
 begin
        Result := '';
        for i := 0 to index do
-               Result := RemoveToken(s, delimiter);
+               Result := MojuUtils.RemoveToken(s, delimiter);
 end;
 
 
@@ -1636,7 +1632,7 @@ begin
        SI.cbReserved2 := 0;
        SI.lpReserved2 := nil;
        SI.dwysize               := 0;
-       Windows.CreateProcess(nil,
+    if Windows.CreateProcess(nil,
                                                                PChar(Path),
                                                                nil,
                                                                nil,
@@ -1645,7 +1641,11 @@ begin
                                                                nil,
                                                                nil,
                                                                SI,
-                                                               PI);
+                                                               PI) then
+    begin
+        CloseHandle(PI.hProcess);
+    end;
+
 end;
 
 {!
@@ -1654,14 +1654,45 @@ end;
 \param BrowserType \83u\83\89\83E\83U\82Ì\83^\83C\83v(IE \82©\82Ç\82¤\82©)
 }
 procedure TGikoSys.OpenBrowser(URL: string; BrowserType: TGikoBrowserType);
+var
+    i, j : Integer;
+    path, arg : String;
+    params : TStringList;
 begin
        case BrowserType of
                gbtIE:
                        HlinkNavigateString(nil, PWideChar(WideString(URL)));
                gbtUserApp, gbtAuto:
-                       if (Setting.URLApp) and (FileExists(Setting.URLAppFile)) then
-                               GikoSys.CreateProcess(Setting.URLAppFile, URL)
-                       else
+                       if (Setting.URLApp) then begin
+                if (FileExists(Setting.URLAppFile)) then begin
+                               GikoSys.CreateProcess(Setting.URLAppFile, URL)
+                end else begin
+                    // \8bN\93®\83p\83\89\83\81\81[\83^\95t\82«\91Î\8dô
+                    path := '';
+                    params := TStringList.Create;
+                    try
+                        params.Delimiter := ' ';
+                        params.DelimitedText := Setting.URLAppFile;
+                        for i := 0 to params.Count - 1 do begin
+                            path := TrimLeft(path + ' ' + params[i]);
+                            if (FileExists(path)) then begin
+                                arg := '';
+                                for j := i + 1 to params.Count - 1 do begin
+                                    arg := arg + ' ' + params[j];
+                                end;
+                                break;
+                            end;
+                        end;
+                        if i < params.Count then begin
+                            GikoSys.CreateProcess(path, arg + ' ' + URL);
+                        end else begin
+                            HlinkNavigateString(nil, PWideChar(WideString(URL)));
+                        end;
+                    finally
+                        params.Free;
+                    end;
+                end;
+                       end else
                                HlinkNavigateString(nil, PWideChar(WideString(URL)));
        end;
 end;
@@ -1895,84 +1926,93 @@ http://2ch.net/
 \82Ì\8fê\8d\87 stRef = 32, endRes = 50 \82É\82È\82é
 }
 procedure TGikoSys.GetPopupResNumber(URL : string; var stRes, endRes : Int64);
+const
+    START_NAME : array[0..1] of String = ('st=', 'start=');
+    END_NAME : array[0..1] of String = ('to=', 'end=');
+    RES_NAME : array[0..0] of String = ('res=');
 var
        buf : String;
        convBuf : String;
        ps : Int64;
        pch : PChar;
+    bufList : TStringList;
+    i, j, idx : Integer;
 begin
        URL := Trim(LowerCase(URL));
-       if (AnsiPos('&st=', URL ) <> 0) and ( AnsiPos( '&to=',URL) <> 0 ) then begin
-               stRes := 0;
-               endRes := 0;
-               try
-                       buf := Copy( URL, AnsiPos('&st=', URL ) + 4, AnsiPos( '&to=',URL) - AnsiPos('&st=', URL ) - 4 );
-                       if buf <> '' then
-                               stRes := StrToInt64( buf );
-                       if AnsiPos( '&nofirst=',URL) <> 0 then begin
-                               buf := Copy( URL, AnsiPos('&to=', URL ) + 4, AnsiPos( '&nofirst=',URL) - AnsiPos('&to=', URL ) - 4);
-                       end else begin
-                               buf := Copy( URL, AnsiPos('&to=', URL ) + 4, Length( URL ) - AnsiPos('&to=', URL ) - 4 + 1 );
-                               ps := 0;
-                               pch := PChar(buf);
-                               while  ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
-                               buf := Copy( buf, 1, ps );
-                       end;
-                       try
-                               if buf <> '' then
-                                       endRes := StrToInt64(buf)
-                       except
-                               endRes := 0;
-                       end;
-               except
-                       stRes := 0;
-               end;
-               if (stRes <> 0) and (endRes = 0) then
-                       endRes := stRes + MAX_POPUP_RES
-               else if (stRes = 0) and (endRes <> 0) then begin
-                       stRes := endRes - MAX_POPUP_RES;
-                       if stRes < 1 then
-                               stRes := 1;
-               end;
-               GikoSys.GetBrowsableThreadURL( URL );
-       end else if( AnsiPos('&res=', URL ) <> 0 ) then begin
-               endRes := 0;
-               buf := Copy( URL, AnsiPos('&res=', URL ) + 5, Length( URL ) - AnsiPos('&res=', URL ) - 5 + 1 );
-               ps := 0;
-               pch := PChar(buf);
-               while  ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
-               buf := Copy( buf, 1, ps );
-               try
-                       if buf <> '' then
-                               stRes := StrToInt(buf)
-                       else begin
-                               stRes := 0;
-                       end;
-               except
-                       stRes := 0;
-               end;
-       end else if (AnsiPos('&start=', URL ) <> 0) and ( AnsiPos( '&end=',URL) <> 0 ) then begin
-               try
-                       stRes := StrToInt64( Copy( URL, AnsiPos('&start=', URL ) + 7, AnsiPos( '&end=',URL) - AnsiPos('&start=', URL ) - 7 ) );
-                       if AnsiPos( '&nofirst=',URL) <> 0 then begin
-                               buf := Copy( URL, AnsiPos('&end=', URL ) + 5, AnsiPos( '&nofirst=',URL) - AnsiPos('&end=', URL ) - 5);
-                       end else begin
-                               buf := Copy( URL, AnsiPos('&end=', URL ) + 5, Length( URL ) - AnsiPos('&to=', URL ) - 5 + 1 );
-                               ps := 0;
-                               pch := PChar(buf);
-                               while  ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
-                               buf := Copy( buf, 1, ps );
-                       end;
-                       try
-                               if buf <> '' then
-                                       endRes := StrToInt64(buf);
-                       except
-                               endRes := 0;
-                       end;
-               except
-                       stRes := 0;
-               end;
-       end else if ( AnsiPos('.html',URL) <> Length(URL) -4 ) and ( AnsiPos('.htm',URL) <> Length(URL) -3 ) then begin
+    for i := 0 to Length(START_NAME) -1 do begin
+        idx := AnsiPos(START_NAME[i], URL);
+        if (idx <> 0) then begin
+            break;
+        end;
+        idx := AnsiPos(END_NAME[i], URL);
+        if (idx <> 0) then begin
+            break;
+        end;
+
+    end;
+
+    if (idx <> 0) then begin
+        idx := AnsiPos('?', URL);
+        if (idx = 0) then begin
+            idx := LastDelimiter('/', URL);
+        end;
+        stRes := 0;
+        endRes := 0;
+        bufList := TStringList.Create();
+        try
+            bufList.Delimiter := '&';
+            bufList.DelimitedText := Copy(URL, idx + 1, Length(URL));
+            for  i := 0 to bufList.Count - 1 do begin
+                convBuf := '';
+                // \8aJ\8en\83\8c\83X\94Ô\82Ì\8c\9f\8dõ
+                if (stRes = 0) then begin
+                    for j := 0 to Length(START_NAME) - 1 do begin
+                        idx := AnsiPos(START_NAME[j], bufList[i]);
+                        if (idx = 1) then begin
+                            convBuf := Copy(bufList[i], idx + Length(START_NAME[j]), Length(bufList[i]));
+                            stRes := StrToInt64Def( convBuf, 0 );
+                            break;
+                        end;
+                    end;
+                end;
+                // \8fI\97¹\83\8c\83X\94Ô\82Ì\8c\9f\8dõ
+                if (convBuf = '') and (endRes = 0) then begin
+                    for j := 0 to Length(END_NAME) - 1 do begin
+                        idx := AnsiPos(END_NAME[j], bufList[i]);
+                        if (idx = 1) then begin
+                            convBuf := Copy(bufList[i], idx + Length(END_NAME[j]), Length(bufList[i]));
+                            endRes := StrToInt64Def( convBuf, 0 );
+                            break;
+                        end;
+                    end;
+                end;
+                // \83\8c\83X\94Ô\82Ì\8c\9f\8dõ
+                if ((stRes = 0) and (endRes = 0) and (convBuf = '')) then begin
+                  for j := 0 to Length(RES_NAME) - 1 do begin
+                      idx := AnsiPos(RES_NAME[j], bufList[i]);
+                      if (idx = 1) then begin
+                          convBuf := Copy(bufList[i], idx + Length(RES_NAME[j]), Length(bufList[i]));
+                          stRes := StrToInt64Def( convBuf, 0 );
+                          endRes := stRes;
+                          break;
+                      end;
+                  end;
+                end;
+            end;
+
+            if (stRes <> 0) and (endRes = 0) then begin
+                       endRes := stRes + MAX_POPUP_RES;
+               end else if (stRes = 0) and (endRes <> 0) then begin
+                stRes := endRes - MAX_POPUP_RES;
+                       if stRes < 1 then begin
+                               stRes := 1;
+                end;
+            end;
+        finally
+            bufList.clear;
+            bufList.free;
+        end;
+    end else if ( AnsiPos('.html',URL) <> Length(URL) -4 ) and ( AnsiPos('.htm',URL) <> Length(URL) -3 ) then begin
                buf := Copy(URL, LastDelimiter('/',URL)+1,Length(URL)-LastDelimiter('/',URL)+1);
                if  Length(buf) > 0 then begin
                        if AnsiPos('-', buf) = 1 then begin
@@ -1981,15 +2021,10 @@ begin
                                ps := 0;
                                pch := PChar(buf);
                                while  ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
-                               try
-                                       convBuf := Copy( buf, 1, ps );
-                                       if convBuf <> '' then
-                                               endRes := StrToInt64(convBuf)
-                                       else
-                                               endRes := 0;
-                               except
-                                       endRes := 0;
-                               end;
+                convBuf := Copy( buf, 1, ps );
+                if convBuf <> '' then begin
+                    endRes := StrToInt64Def(convBuf, 0);
+                end;
                                if endRes <> 0 then begin
                                        stRes := endRes - MAX_POPUP_RES;
                                        if stRes < 1 then
@@ -2007,15 +2042,10 @@ begin
                                                ps := 0;
                                                pch := PChar(buf);
                                                while  ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
-                                               try
-                                                       convBuf := Copy( buf, 1, ps );
-                                                       if convBuf <> '' then
-                                                               endRes := StrToInt64(convBuf)
-                                                       else
-                                                               endRes := 0;
-                                               except
-                                                       endRes := 0;
-                                               end;
+                        convBuf := Copy( buf, 1, ps );
+                        if convBuf <> '' then begin
+                            endRes := StrToInt64Def(convBuf, 0);
+                        end;
                                        end else begin
                                                stRes := 0;
                                        end;
@@ -2025,9 +2055,6 @@ begin
                                end;
                        end;
                end;
-       end else begin
-               //stRes := 0;
-               //endRes := 0;
        end;
 end;
 
@@ -2512,6 +2539,7 @@ procedure TGikoSys.ListBoardFile;
 var
        boardFileList   : TStringList;
        i, l                    : Integer;
+    sCategory       : TCategory;
 begin
        // BBS \82Ì\8aJ\95ú
        try
@@ -2554,6 +2582,20 @@ begin
                BoardFileList.Free;
          end;
        end;
+
+    // \93Á\8eê\97p\93rBBS\90\90¬
+    // \8aù\82É\91\8dÝ\82·\82é\8fê\8d\87\82Í\8dí\8f\9c\82·\82é
+    DestorySpecialBBS(BoardGroup.SpecialBBS);
+    SpecialBBS := TBBS.Create('');
+    SpecialBBS.Title := '\93Á\8eê\97p\93r(\94ñ\95\\8e¦)';
+    sCategory := TCategory.Create;
+    sCategory.No := 1;
+    sCategory.Title := '\93Á\8eê\97p\93r(\94ñ\95\\8e¦)';
+    SpecialBBS.Add(sCategory);
+    BoardGroup.SpecialBoard := TSpecialBoard.Create(nil, 'http://localhost/gikonavi/special/index.html');
+    BoardGroup.SpecialBoard.Title := '\83^\83u\88ê\97\97';
+    BoardGroup.SpecialBoard.IsThreadDatRead := True;
+    sCategory.Add(BoardGroup.SpecialBoard);
 end;
 
 {!
@@ -2751,20 +2793,18 @@ function TGikoSys.GetSambaFileName : string;
 begin
        Result := Setting.GetSambaFileName;
 end;
-
 {!
-\brief \93¯\82\93\8a\8de ID \82ð\8e\9d\82Â\83\8c\83X\82ð\83A\83\93\83J\81[\82É\82µ\82Ä\97ñ\8b\93
-\param AID        \8cÂ\90l\82ð\93Á\92è\82·\82é\93\8a\8de ID
+\brief \97ñ\8b\93\82³\82ê\82½\83\8c\83X\94Ô\8d\86\82Ö\82Ì\83A\83\93\83J\81[\97pHTML\8dì\90¬
+\param Numbers    \97ñ\8b\93\82³\82ê\82½\83\8c\83X\94Ô\8d\86
 \param ThreadItem \97ñ\8b\93\82·\82é\83X\83\8c\83b\83h
 \param limited    \97ñ\8b\93\82·\82é\90\94\82ð\90§\8cÀ\82·\82é\82È\82ç1\88È\8fã
 \return           \97ñ\8b\93\82³\82ê\82½\83\8c\83X\83A\83\93\83J\81[
 }
-function TGikoSys.GetSameIDResAnchor(
-    const AID : string; ThreadItem: TThreadItem;
+function TGikoSys.CreateResAnchor(
+    var Numbers: TStringList; ThreadItem: TThreadItem;
     limited: Integer):string;
 var
        i: integer;
-       body: TStringList;
     Res: TResRec;
     ResLink : TResLinkRec;
 begin
@@ -2772,29 +2812,22 @@ begin
     Res.FBody := '';
     Res.FType := glt2chNew;
 
-               Result := '';
-               if (not IsNoValidID(AID)) and
-                       (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin
-                               body := TStringList.Create;
-                               try
-                                               GetSameIDRes(AID, ThreadItem, body);
-                                               if (limited > 0) and (body.Count > limited) then begin
-                                                               for i := body.Count - limited to body.Count - 1 do begin
-                                                                               Res.FBody := Res.FBody + '&gt;' + body[i] + ' ';
-                                                               end;
-                                               end else begin
-                                                               for i := 0 to body.Count - 1 do begin
-                                                                               Res.FBody := Res.FBody + '&gt;' + body[i] + ' ';
-                                                               end;
-                                               end;
-                               finally
-                                               body.Free;
-                               end;
+       Result := '';
+       if (Numbers <> nil) and (Numbers.Count > 0) then begin
+        if (limited > 0) and (Numbers.Count > limited) then begin
+            for i := Numbers.Count - limited to Numbers.Count - 1 do begin
+                Res.FBody := Res.FBody + '&gt;' + Numbers[i] + ' ';
+            end;
+        end else begin
+            for i := 0 to Numbers.Count - 1 do begin
+                Res.FBody := Res.FBody + '&gt;' + Numbers[i] + ' ';
+            end;
+        end;
         ResLink.FBbs := ThreadItem.ParentBoard.BBSID;
         ResLink.FKey := ChangeFileExt(ThreadItem.FileName, '');
         HTMLCreater.ConvRes(@Res, @ResLink, false);
         Result := Res.FBody;
-               end;
+    end;
 end;
 
 {!
@@ -2809,6 +2842,22 @@ var
        ReadList: TStringList;
        Res: TResRec;
        boardPlugIn : TBoardPlugIn;
+
+    procedure CheckSameID(const AID:String; const Target: String; no: Integer);
+    var
+        pos: Integer;
+    begin
+        pos := AnsiPos('id:', LowerCase(Target));
+        if (pos > 0) then begin
+            if(AnsiPos(AID, Copy(Target, pos-1, Length(Target))) > 0) then begin
+                body.Add(IntToStr(no));
+            end;
+        end else begin
+            if(AnsiPos(AID, Target) > 0) then begin
+                body.Add(IntToStr(no));
+            end;
+        end;
+    end;
 begin
        if (not IsNoValidID(AID)) and
        (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin
@@ -2821,9 +2870,7 @@ begin
                        for i := 0 to threadItem.Count - 1 do begin
                                // \83\8c\83X
                                THTMLCreate.DivideStrLine(boardPlugIn.GetDat(DWORD( threadItem ), i + 1), @Res);
-                               if(AnsiPos(AID, Res.FDateTime) > 0) then begin
-                                       body.Add(IntToStr(i+1));
-                               end;
+                CheckSameID(AID, Res.FDateTime, i+1);
                        end;
                end else begin
                        ReadList := TStringList.Create;
@@ -2831,9 +2878,7 @@ begin
                                ReadList.LoadFromFile(ThreadItem.GetThreadFileName);
                                for i := 0 to ReadList.Count - 1 do begin
                                        THTMLCreate.DivideStrLine(ReadList[i], @Res);
-                                       if AnsiPos(AID, Res.FDateTime) > 0 then begin
-                                               body.Add(IntToStr(i+1));
-                                       end;
+                    CheckSameID(AID, Res.FDateTime, i+1);
                                end;
                        finally
                                ReadList.Free;
@@ -2846,50 +2891,6 @@ end;
 \brief \93¯\82\93\8a\8de ID \82ð\8e\9d\82Â\83\8c\83X\82ð\97ñ\8b\93
 \param AIDNum     \8cÂ\90l\82ð\93Á\92è\82·\82é\93\8a\8de ID
 \param ThreadItem \97ñ\8b\93\82·\82é\83X\83\8c\83b\83h
-\param limited    \97ñ\8b\93\82·\82é\90\94\82ð\90§\8cÀ\82·\82é\82È\82ç1\88È\8fã
-\return
-}
-function TGikoSys.GetSameIDResAnchor(AIDNum : Integer;
-     ThreadItem: TThreadItem;
-     limited: Integer):string;
-var
-       i: integer;
-       body: TStringList;
-    Res: TResRec;
-    ResLink : TResLinkRec;
-begin
-    // body\88È\8aO\82Í\8eg\97p\82µ\82È\82¢\82Ì\82Å\8f\89\8aú\89»\82µ\82È\82¢
-    Res.FBody := '';
-    Res.FType := glt2chNew;
-
-       Result := '';
-       if (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin
-               body := TStringList.Create;
-               try
-                       GetSameIDRes(AIDNum, ThreadItem, body);
-            if (limited > 0) and ( body.Count > limited) then begin
-                for i := body.Count - 20 to body.Count - 1 do begin
-                    Res.FBody := Res.FBody + '&gt;' + body[i] + ' ';
-                end;
-            end else begin
-                       for i := 0 to body.Count - 1 do begin
-                               Res.FBody := Res.FBody + '&gt;' + body[i] + ' ';
-                       end;
-            end;
-               finally
-                       body.Free;
-               end;
-        ResLink.FBbs := ThreadItem.ParentBoard.BBSID;
-        ResLink.FKey := ChangeFileExt(ThreadItem.FileName, '');
-        HTMLCreater.ConvRes(@Res, @ResLink, false);
-        Result := Res.FBody;
-       end;
-end;
-
-{!
-\brief \93¯\82\93\8a\8de ID \82ð\8e\9d\82Â\83\8c\83X\82ð\97ñ\8b\93
-\param AIDNum     \8cÂ\90l\82ð\93Á\92è\82·\82é\93\8a\8de ID
-\param ThreadItem \97ñ\8b\93\82·\82é\83X\83\8c\83b\83h
 \param body       OUT:\97ñ\8b\93\82³\82ê\82½\83\8c\83X\94Ô\8d\86\82ª\95Ô\82é
 }
 procedure TGikoSys.GetSameIDRes(AIDNum : Integer; ThreadItem: TThreadItem;var body: TStringList);
@@ -2911,8 +2912,6 @@ function TGikoSys.GetResID(AIDNum: Integer; ThreadItem: TThreadItem): String;
 var
        Res: TResRec;
        boardPlugIn : TBoardPlugIn;
-       stList: TStringList;
-       i : Integer;
 begin
     Result := '';
        if (ThreadItem <> nil) and (ThreadItem.IsLogFile)
@@ -2926,96 +2925,40 @@ begin
                end else begin
                        THTMLCreate.DivideStrLine( ReadThreadFile(ThreadItem.GetThreadFileName, AIDNum), @Res);
                end;
-               Result := Res.FDateTime;
-               if AnsiPos('id', AnsiLowerCase(Result)) > 0 then begin
-                       Result := Copy(Result, AnsiPos('id', AnsiLowerCase(Result)) - 1, 11);
-            if AnsiPos(' be:', AnsiLowerCase(Result)) > 0 then begin
-               Result := Copy(Result, 1, AnsiPos(' BE:', AnsiLowerCase(Result)) - 1)
-            end;
-               end else begin
-                       stlist := TStringList.Create;
-                       try
-                               stList.DelimitedText := Result;
-                Result := '';
-                               for i := 0 to stList.Count - 1 do
-                                       if Length(WideString(stList[i])) = 8 then begin
-                                               if NotDateorTimeString(stList[i]) then begin
-                                                       Result := stList[i];
-                                                       break;
-                                               end;
-                                       end;
-                       finally
-                               stList.Free;
-                       end;
-               end;
+               Result := ExtructResID(Res.FDateTime);
        end;
 end;
 {!
-\brief \93¯\82\93\8a\8de ID \82ð\8e\9d\82Â\83\8c\83X\82ð\83J\83E\83\93\83g
-\param AID        \8cÂ\90l\82ð\93Á\92è\82·\82é\93\8a\8de ID
-\param ThreadItem \97ñ\8b\93\82·\82é\83X\83\8c\83b\83h
-\return           \93¯\82¶ ID \82ð\8e\9d\82Â\83\8c\83X\82Ì\90\94
+\brief \83\8c\83X\82Ì\8e\9e\8d\8f\95\94\82©\82çID\82ð\92\8a\8fo\82·\82é
+\param ADateStr \8e\9e\8d\8f\95\94\82Ì\95\8e\9a\97ñ
+\return     ID(ID\82Æ\82Ý\82È\82¹\82é\95\94\95ª\82ª\82È\82¢\82Æ\82«\82Í\8bó\95\8e\9a\97ñ)
 }
-function TGikoSys.GetSameIDResCount(const AID : string; ThreadItem: TThreadItem):Integer;
+function TGikoSys.ExtructResID(ADateStr: String): String;
 var
-       body: TStringList;
+    stlist : TStringList;
 begin
-    Result := 0;
-       if (not IsNoValidID(AID))
-     and (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin
-               body := TStringList.Create;
-               try
-                       GetSameIDRes(AID, ThreadItem, body);
-                       Result := body.Count;
-               finally
-                       body.Free;
-               end;
-       end;
-
-end;
-
-{!
-\brief \93¯\82\93\8a\8de ID \82ð\8e\9d\82Â\83\8c\83X\82ð\83J\83E\83\93\83g
-\param AIDNum     \8cÂ\90l\82ð\93Á\92è\82·\82é\93\8a\8de ID
-\param ThreadItem \97ñ\8b\93\82·\82é\83X\83\8c\83b\83h
-\return           \93¯\82¶ ID \82ð\8e\9d\82Â\83\8c\83X\82Ì\90\94
-}
-function TGikoSys.GetSameIDResCount(AIDNum : Integer; ThreadItem: TThreadItem):Integer;
-var
-       body: TStringList;
-begin
-       Result := 0;
-       if (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin
-               body := TStringList.Create;
-               try
-                       GetSameIDRes(AIDNum, ThreadItem, body);
-            Result := body.Count;
-               finally
-                       body.Free;
-               end;
-       end;
-end;
-
-{!
-\brief \8e\9e\8d\8f\82ð\8e¦\82·\95\8e\9a\97ñ\82Å\82Í\96³\82¢\82©\82Ç\82¤\82©
-\param AStr \92²\82×\82é\95\8e\9a\97ñ
-\return     \8e\9e\8d\8f\82Å\82Í\96³\82¢\82È\82ç True
-\todo \94Û\92è\8c`(Not)\82æ\82è\8dm\92è\8cn(Is)
-}
-function TGikoSys.NotDateorTimeString(const AStr : string): boolean;
-begin
-       Result := false;
-       try
-               StrToDate(AStr);
-       except
-               try
-                       StrToTime(AStr);
-                       Result := false;
-               except
-                       Result := true;
-               end;
-       end;
-
+    Result := '';
+    if AnsiPos('id', AnsiLowerCase(ADateStr)) > 0 then begin
+        Result := Copy(ADateStr, AnsiPos('id', AnsiLowerCase(ADateStr)), Length(ADateStr));
+        if AnsiPos(' ', Result) > 0 then begin
+            Result := Copy(Result, 1, AnsiPos(' ', Result) - 1);
+        end;
+        Result := ' ' + Result;
+    end else begin
+        stlist := TStringList.Create;
+        try
+            stList.Delimiter := ' ';
+            stList.DelimitedText := ADateStr;
+            // \93ú\95\8e\9e\8d\8f ID \91¼\81@\82Æ\8cÅ\92è\82Å\8dl\82¦\82é
+            if (stList.Count >= 3) then begin
+                if Length(stList[3 - 1]) >= 7 then begin
+                    Result := stList[3 - 1];
+                end;
+            end;
+        finally
+            stList.Free;
+        end;
+    end;
 end;
 
 {!
@@ -3485,8 +3428,10 @@ begin
 end;
 
 procedure TGikoSys.ShowRefCount(msg: String; unk: IUnknown);
+{$IFDEF DEBUG}
 var
     count : integer;
+{$ENDIF}
 begin
     if not Assigned(unk) then
         Exit;