OSDN Git Service

1.60.0.783をマージ
[gikonavigoeson/gikonavi.git] / res / ExternalBoardPlugIn / MachiBBSPlugIn.dpr
index 033b628..1956c36 100644 (file)
@@ -83,7 +83,7 @@ const
        MAJOR_VERSION                   = 1;
        MINOR_VERSION                   = 0;
        RELEASE_VERSION         = 'beta';
-       REVISION_VERSION        = 15;
+       REVISION_VERSION        = 20;
 
 // =========================================================================
 // \8eG\97p\8aÖ\90\94
@@ -269,6 +269,7 @@ var
 const
        BBS_HOST                = 'machi.to';
        THREAD_MARK     = '/bbs/read.pl';
+    THREAD_MARK2= '/bbs/read.cgi';
 begin
 
        try
@@ -280,6 +281,10 @@ begin
                        foundPos := AnsiPos( BBS_HOST, uri.Host );
                        if (foundPos > 0) and (Length( uri.Host ) - foundPos + 1 = Length( BBS_HOST )) then begin
                                foundPos := Pos( THREAD_MARK, inURL );
+                if (foundPos = 0) then begin
+                    // \90VURL\91Î\89\9e
+                    foundPos := Pos( THREAD_MARK2, inURL );
+                end;
                                if foundPos > 0 then
                                        Result := atThread
                                else if (uriList.Count > 1) and (uri.Path <> '/') then  // \8dÅ\8cã\82ª '/' \82Å\95Â\82ß\82ç\82ê\82Ä\82é\82È\82ç 3
@@ -309,9 +314,10 @@ procedure OnExtractBoardURL(
 var
        uri                     : TIdURI;
        uriList         : TStringList;
-       URL                     : String;
+       URL         : String;
 const
        THREAD_MARK     = '/bbs/read.pl';
+    THREAD_MARK2= '/bbs/read.cgi';
 begin
        URL := string(inURL);
        if AnsiPos(THREAD_MARK, URL) > 0 then begin
@@ -333,6 +339,27 @@ begin
                        uri.Free;
                        uriList.Free;
                end;
+    end else if AnsiPos(THREAD_MARK2, URL) > 0 then begin
+               if Copy( inURL, Length( inURL ), 1 ) = '/' then
+                       uri := TIdURI.Create( URL )
+               else
+                       uri := TIdURI.Create( URL + '/' );
+
+        uriList := TStringList.Create;
+               try
+                       // http://kanto.machi.to/bbs/read.cgi/kana/1215253035/l50
+                       // http://kanto.machi.to/kana/
+            uriList.Delimiter := '/';
+            uriList.DelimitedText  := uri.Path;
+                       URL := uri.Protocol + '://' + uri.Host + '/';
+            if (uriList.Count >= 4) then begin
+                URL := URL + uriList[3] + '/';
+            end;
+                       outURL := CreateResultString(URL);
+               finally
+                       uri.Free;
+            uriList.Free;
+               end;
        end else begin
        outURL := CreateResultString(URL);
        end;
@@ -445,7 +472,6 @@ var
                                                foundPos := AnsiPos( '<table', downResult.Text ) - 1;
                                                if foundPos > 0 then
                                                        downResult.Text := Copy( downResult.Text, 1, foundPos );
-
                                                // \82Ü\82¿BBS\82Í dat \92¼\93Ç\82Ý\82ª\8fo\97\88\82È\82¢\82µ\81Acgi \88È\8aO\82É\8d·\95ª\93Ç\82Ý\8d\9e\82Ý\82Ì\95û\96@\82ª\82 \82é\82í\82¯\82Å\82à\96³\82¢\82Ì\82Å
                                                // \91f\82Ì\82Ü\82Ü\82ð\96³\97\9d\82É\95Û\82Æ\82¤\82Æ\82Í\82¹\82¸\82É 2ch \82Ì dat \8c`\8e®\82É\95Ï\8a·\82µ\82½\82à\82Ì\82ð\95Û\91\82µ\82Ä\82µ\82Ü\82¤
                                                To2chDat( downResult, Count + 1 );
@@ -492,13 +518,13 @@ begin
                if Count = 0 then
                        // 1\81`
                        datURL          :=
-                               uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
+                               uri.Protocol + '://' + uri.Host + '/bbs/read.cgi?' +
                                'BBS=' + uriList.Values[ 'BBS' ] + '&KEY=' + uriList.Values[ 'KEY' ] +
                                '&START=' + IntToStr( 1 )
                else
                        // \90V\92\85\82Ì\82Ý
                        datURL          :=
-                               uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
+                               uri.Protocol + '://' + uri.Host + '/bbs/read.cgi?' +
                                'BBS=' + uriList.Values[ 'BBS' ] + '&KEY=' + uriList.Values[ 'KEY' ] +
                                '&START=' + IntToStr( Count + 1 ) + '&NOFIRST=TRUE';
                // \83_\83E\83\93\83\8d\81[\83h
@@ -519,22 +545,27 @@ begin
                                NewReceive      := 1;
                                Count                           := content.Count;
                        end else begin
-                               Result := dsDiffComplete;
-                               // \92Ç\8bL
-                               logStream := TFileStream.Create( FilePath, fmOpenReadWrite or fmShareDenyWrite );
-                               try
-                                       logStream.Position      := logStream.Size;
-                                       logStream.Write( PChar( content.Text )^, Length( content.Text ) );
-                               finally
-                                       logStream.Free;
-                               end;
-                               NewReceive      := Count + 1;
-                               Count                           := Count + content.Count;
+                if (content.Count > 1) or (Trim(content.Text) <> '') then begin
+                               Result := dsDiffComplete;
+                    // \92Ç\8bL
+                    logStream := TFileStream.Create( FilePath, fmOpenReadWrite or fmShareDenyWrite );
+                    try
+                        logStream.Position     := logStream.Size;
+                        logStream.Write( PChar( content.Text )^, Length( content.Text ) );
+                    finally
+                        logStream.Free;
+                    end;
+                    NewReceive := Count + 1;
+                    Count                              := Count + content.Count;
+                end else begin
+                    Result := dsNotModify;
+                end;
                        end;
-
-                       // CGI \82©\82ç\82Í\90³\82µ\82¢\93ú\95t\82ª\93¾\82ç\82ê\82È\82¢\82Ì\82Å\8c»\8dÝ\82É\90Ý\92è
-                       LastModified    := Now;
-                       NewResCount             := content.Count;
+            if (Result <> dsNotModify) then begin
+                       // CGI \82©\82ç\82Í\90³\82µ\82¢\93ú\95t\82ª\93¾\82ç\82ê\82È\82¢\82Ì\82Å\8c»\8dÝ\82É\90Ý\92è
+                       LastModified    := Now;
+                       NewResCount             := content.Count;
+            end;
                end else begin
                        Result := dsNotModify;
                end;
@@ -735,7 +766,7 @@ procedure   TMachiBBSThreadItem.To2chDat(
 );
 var
        i, bound                        : Integer;
-       foundPos                        : Integer;
+       foundPos,foundPos2                      : Integer;
        strTmp                          : string;
        res                                             : TStringList;
        no                                              : Integer;
@@ -772,6 +803,7 @@ begin
                // \82 \82Ú\81[\82ñ\83`\83F\83b\83N\82Å\96â\91è\82ª\94­\90\82µ\82Ä\82à\90æ\82Ö\90i\82ß\82½\82¢\82Ì\82Å
        end;
 
+
        // \83g\83\8a\83b\83v\82Ì\8cã\82Ì '<b> </b>' \82ð\8bó\82É
     if AnsiPos('\81\9f</b>', ioHTML.Text) <> 0 then begin
        ioHTML.Text     := CustomStringReplace( ioHTML.Text, '<b> </b></font>', '</b></font>', true );
@@ -796,6 +828,7 @@ begin
        try
                bound := ioHTML.Count - 1;
                for i := 0 to bound do begin
+            // \83X\83N\83\8a\83v\83g\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82½\82ç\8dí\8f\9c\82·\82é\81i\8dL\8d\90\91Î\8dô\81j
                        res.Text := CustomStringReplace( ioHTML[ i ], '<>', #10 );
                                                //StringReplace( ioHTML[ i ], '<>', #10, [rfReplaceAll] );
                        if res.Count >= 3 then begin    // 3 \96¢\96\9e\82Í\82 \82è\82¦\82È\82¢\82Æ\8ev\82¤\82¯\82Ç\88À\91S\82Ì\82½\82ß
@@ -823,7 +856,15 @@ begin
                 end;
                        end;
                        ioHTML[ i ] := CustomStringReplace( res.Text, #13#10, '<>');
-                       //StringReplace( res.Text, #13#10, '<>', [rfReplaceAll] );
+            // \8dL\8d\90\83X\83N\83\8a\83v\83g\91Î\8dô
+            foundPos := Pos( '<script', ioHTML[ i ] );
+            if foundPos > 0 then begin
+                foundPos2 := Pos( '</script>', ioHTML[ i ] );
+                if (foundPos2 > foundPos) then begin
+                    ioHTML[ i ] := Copy(ioHTML[ i ], 1, foundPos-1) +
+                                   Copy(ioHTML[ i ], foundPos2 + 9, Length(ioHTML[ i ]));
+                end;
+            end;
                end;
        finally
                res.Free;
@@ -868,6 +909,8 @@ var
        uri                             : TIdURI;
        uriList         : TStringList;
        foundPos        : Integer;
+const
+    THREAD_MARK2= '/bbs/read.cgi';
 begin
 
        foundPos := AnsiPos( '?', URL );
@@ -883,7 +926,26 @@ begin
                        uri.Free;
                        uriList.Free;
                end;
-       end;
+       end else begin
+        // \90V\8c`\8e® ?
+        foundPos := AnsiPos(THREAD_MARK2, URL);
+       if (foundPos > 0) then begin
+            uri := TIdURI.Create( URL );
+            uriList := TStringList.Create;
+            try
+                uriList.Delimiter := '/';
+                uriList.DelimitedText  := uri.Path;
+                if (uriList.Count >= 5) then begin
+                           Result :=
+                                   uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
+                                   'BBS=' + uriList[3] + '&KEY=' + uriList[4];
+                end;
+            finally
+                       uri.Free;
+                       uriList.Free;
+            end;
+        end;
+    end;
 
 end;