OSDN Git Service

まちBBSで削除レスがあるレス番号とスレの件数がずれる不具合を修正
[gikonavigoeson/gikonavi.git] / BoardGroup.pas
index 0412d9b..cfe191a 100644 (file)
@@ -41,6 +41,7 @@ type
                function Find(key: string): TCategory;
                function FindBBSID(const BBSID: string): TBoard;
                function FindBoardFromTitle(const Title: string): TBoard;
+               function FindBoardFromTitleAndCategory(const CategoryTitle: string; const BoardTitle: string): TBoard;
                function FindBoardFromURL(const inURL: string): TBoard;
                function FindThreadFromURL(const inURL : string ) : TThreadItem;
                function FindThreadItem(const BBSID, FileName: string): TThreadItem;
@@ -279,7 +280,7 @@ type
        public
                constructor Create(const inPlugIn : TBoardPlugIn; const inBoard : TBoard; inURL : string ); overload;
                constructor Create(const inPlugIn : TBoardPlugIn; const inBoard : TBoard;
-                                        inURL : string; inExist: Boolean; const inFilename: string ); overload;
+                                        const inURL : string; inExist: Boolean; const inFilename: string ); overload;
 
                destructor Destroy; override;
 
@@ -287,6 +288,11 @@ type
                function GetDatgzURL: string;
 //             function GetOldDatgzURL: string;
                function GetOfflawCgiURL(const SessionID: string): string;
+//////////////// 2013/10/13 ShiroKuma\91Î\89\9e zako Start ///////////////////////////
+        function GetOfflaw2SoURL: string;
+//////////////// 2013/10/13 ShiroKuma\91Î\89\9e zako End /////////////////////////////
+        function GetRokkaURL(const SessionID: string): string;  // Rokka\91Î\89\9e  
+               function GetExternalBoardKakoDatURL: string; // \8aO\95\94\94Â\89ß\8b\8e\83\8d\83OURL\8eæ\93¾
                function GetSendURL: string;
                procedure DeleteLogFile;
                function GetThreadFileName: string;
@@ -341,6 +347,17 @@ type
         procedure Clear; overload;
     end;
 
+    // \83X\83\8c\83b\83h\96¼NG\83\8f\81[\83h\83\8a\83X\83g
+       TThreadNgList = class(TStringList)
+    private
+        FFilePath: String;
+    public
+               constructor Create;
+        procedure Load;
+        procedure Save;
+        function IsNG(const Title: String): Boolean;
+    end;
+
        function        BBSsFindBoardFromBBSID( inBBSID : string ) : TBoard;
        function        BBSsFindBoardFromURL( inURL : string ) : TBoard;
        function        BBSsFindBoardFromTitle( inTitle : string ) : TBoard;
@@ -353,7 +370,9 @@ var
        BBSs            : array of TBBS;
     BoardGroups : array of TBoardGroup;
     SpecialBBS  : TBBS;
-    
+    SpecialBoard: TSpecialBoard;
+    ThreadNgList: TThreadNgList;
+
 implementation
 
 uses
@@ -371,6 +390,8 @@ const
        SETTINGTXT_FILENAME:            string = 'SETTING.TXT';
     HEADTXT_FILENAME:          string = 'head.html';
        //DEFAULT_LIST_COUNT:           Integer = 100;
+       THREAD_NG_FILE: String = 'ThreadNg.txt';
+    
 
 //! \83\8d\83O\82ð\8e\9d\82Á\82Ä\82¢\82é\82È\82ç\90^\82ð\95Ô\82·
 function CountLog(Item: TThreadItem): Boolean;
@@ -656,6 +677,25 @@ begin
 end;
 
 //*************************************************************************
+// \83J\83e\83S\83\8a\96¼\82Æ\94Â\96¼\82Ì\88ê\92v\82·\82é\94Â\82ð\92T\82·
+//*************************************************************************)
+function TBBS.FindBoardFromTitleAndCategory(const CategoryTitle: string; const BoardTitle: string): TBoard;
+var
+       i: Integer;
+begin
+       if not IsBoardFileRead then
+       GikoSys.ReadBoardFile( Self );
+       for i := Count - 1 downto 0 do begin
+        if AnsiCompareStr(Items[ i ].Title, CategoryTitle) = 0 then begin
+            Result := Items[ i ].FindBoardFromTitle(BoardTitle);
+            if Result <> nil then
+                Exit;
+       end;
+       end;
+       Result := nil;
+end;
+
+//*************************************************************************
 // URL \82ð\8eó\82¯\95t\82¯\82é\94Â\82ð\92T\82·
 //*************************************************************************)
 function TBBS.FindBoardFromURL(const inURL: string): TBoard;
@@ -1573,7 +1613,7 @@ end;
 constructor TThreadItem.Create(
        const inPlugIn : TBoardPlugIn;
        const inBoard : TBoard;
-       inURL : string;
+       const inURL : string;
        inExist: Boolean;
        const inFilename: string
 );
@@ -1588,7 +1628,7 @@ begin
                // dat \82Ì\95Û\91\83p\83X\82ð\90Ý\92è
                FileName        := inFilename;
                IsLogFile       := inExist;
-               URL                             := GikoSys.Get2chBrowsableThreadURL( inURL );
+        URL                            := inURL;
        end else begin
                // \83v\83\89\83O\83C\83\93\82É TThreadItem \82ª\8dì\90¬\82³\82ê\82½\82±\82Æ\82ð\93`\82¦\82é
                inPlugIn.CreateThreadItem( DWORD( Self ) );
@@ -1687,6 +1727,66 @@ begin
        end;
 end;
 
+function TThreadItem.GetOfflaw2SoURL: string;
+begin
+    Result := GikoSys.UrlToServer(ParentBoard.URL)
+                    + 'test/offlaw2.so?shiro=kuma&bbs=' + ParentBoard.BBSID
+                    + '&key=' + ChangeFileExt(FileName, '');
+end;
+
+function TThreadItem.GetRokkaURL(const SessionID: string): string;
+var
+    Domain: string;
+    Host: string;
+    Idx: Integer;
+    HostPos: Integer;
+begin
+       if FDownloadHost = '' then begin
+        Idx := AnsiPos('.2ch.net/', ParentBoard.URL);
+        if (Idx > 0) then begin
+            Domain := '2ch.net';
+        end else begin
+            Idx := AnsiPos('.bbspink.com/', ParentBoard.URL);
+            if (Idx > 0) then
+                Domain := 'bbspink.com';
+        end;
+        if (Idx > 0) then begin
+            HostPos := AnsiPos('://', ParentBoard.URL) + 3;
+            Host := Copy(ParentBoard.URL, HostPos, Idx - HostPos);
+        end;
+    end else begin
+        Idx := AnsiPos('.2ch.net', FDownloadHost);
+        if (Idx > 0) then begin
+            Domain := '2ch.net';
+        end else begin
+            Idx := AnsiPos('.bbspink.com', FDownloadHost);
+            if (Idx > 0) then
+                Domain := 'bbspink.com';
+        end;
+        if (Idx > 0) then begin
+            Host := Copy(FDownloadHost, 1, Idx - 1);
+        end;
+    end;
+
+    if ((Domain = '') or (Host = '')) then
+        Result := ''
+    else
+        Result := 'http://rokka.' + Domain + '/' + Host + '/'
+                + ParentBoard.BBSID + '/' + ChangeFileExt(FileName, '')
+                + '/?sid=' + SessionID;
+end;
+
+// \8aO\95\94\94Â\89ß\8b\8e\83\8d\83OURL\8eæ\93¾
+function TThreadItem.GetExternalBoardKakoDatURL: string;
+var
+       DatNo: string;
+begin
+       DatNo := ChangeFileExt(FileName, '');
+       //http://xxx.vip2ch.com/xxx/kako/1234/12345/1234567890.dat
+       Result := Format('%s%s/%.4s/%.5s/%s.dat', [ParentBoard.URL, 'kako', DatNo, DatNo, DatNo]);
+end;
+// \8aO\95\94\94Â\89ß\8b\8e\83\8d\83OURL\8eæ\93¾
+
 function TThreadItem.GetSendURL: string;
 begin
        Result := GikoSys.UrlToServer(ParentBoard.URL)
@@ -1875,5 +1975,52 @@ begin
     Capacity := 0;
 end;
 
+///////////////
+constructor TThreadNgList.Create;
+begin
+       inherited Create;
+
+       FFilePath := GikoSys.GetNGWordsDir;
+       if not DirectoryExists(FFilePath) then
+               ForceDirectories(FFilePath);
+       if (FFilePath[Length(FFilePath)] <> '\') then
+               FFilePath := FFilePath + '\';
+       FFilePath := FFilePath + THREAD_NG_FILE;
+       Load;
+end;
+
+procedure TThreadNgList.Load;
+begin
+       if (FileExists(FFilePath)) then begin
+               try
+                       LoadFromFile(FFilePath);
+               finally
+               end;
+       end;
+end;
+
+procedure TThreadNgList.Save;
+begin
+       try
+               SaveToFile(FFilePath);
+       finally
+       end;
+end;
+
+function TThreadNgList.IsNG(const Title: String): Boolean;
+var
+    Cnt: Integer;
+    MaxCnt: Integer;
+begin
+    MaxCnt := Count - 1;
+    for Cnt := 0 to MaxCnt do begin
+        if (Pos(Strings[Cnt], Title) > 0) then begin
+            Result := True;
+            Exit;
+        end;
+    end;
+    Result := False;
+end;
+
 end.