1 library MachiBBSPlugIn;
5 \82Ü
\82¿BBS
\8f\88\97\9d\83\86\83j
\83b
\83g
9 Windows, SysUtils, Classes, Math, DateUtils,
11 PlugInMain in 'PlugInMain.pas',
12 ThreadItem in 'ThreadItem.pas',
13 BoardItem in 'BoardItem.pas',
14 FilePath in 'FilePath.pas',
15 MojuUtils in '..\..\MojuUtils.pas';
20 // =========================================================================
21 // TMachiBBSThreadItem
22 // =========================================================================
23 TMachiBBSThreadItem = class(TThreadItem)
25 FIsTemporary : Boolean;
29 constructor Create( inInstance : DWORD );
30 destructor Destroy; override;
33 function Download : TDownloadState;
34 function Write( inName : string; inMail : string; inMessage : string ) : TDownloadState;
35 function GetRes( inNo : Integer ) : string;
36 function GetHeader( inOptionalHeader : string ) : string;
37 function GetFooter( inOptionalFooter : string ) : string;
38 function GetBoardURL : string;
40 procedure To2chDat( ioHTML : TStringList; inStartNo : Integer = 1 );
43 function ReadURL : string;
46 // =========================================================================
48 // =========================================================================
49 TMachiBBSBoardItem = class(TBoardItem)
51 FIsTemporary : Boolean;
55 constructor Create( inInstance : DWORD );
56 destructor Destroy; override;
59 function Download : TDownloadState;
60 function CreateThread( inSubject : string; inName : string; inMail : string; inMessage : string ) : TDownloadState;
61 function ToThreadURL( inFileName : string ) : string;
62 procedure EnumThread( inCallBack : TBoardItemEnumThreadCallBack );
64 function SubjectURL : string;
67 // =========================================================================
68 //
\83T
\83u
\83W
\83F
\83N
\83g
\83\8c\83R
\81[
\83h
69 // =========================================================================
77 LOG_DIR = 'MachiBBS\';
78 SUBJECT_NAME = 'subject.txt';
80 PLUGIN_NAME = 'MachiBBSPlugIn';
83 RELEASE_VERSION = 'beta';
84 REVISION_VERSION = 11;
86 // =========================================================================
88 // =========================================================================
90 // *************************************************************************
91 //
\83e
\83\93\83|
\83\89\83\8a\82È
\83p
\83X
\82Ì
\8eæ
\93¾
92 // *************************************************************************
93 function TemporaryFile : string;
95 tempPath : array [0..MAX_PATH] of char;
98 GetTempPath( SizeOf(tempPath), tempPath );
100 Result := tempPath + IntToStr( Random( $7fffffff ) );
101 until not FileExists( Result );
105 // *************************************************************************
106 //
\82Ü
\82¿BBS
\97p
\83\8d\83O
\83t
\83H
\83\8b\83_
\8eæ
\93¾
107 // *************************************************************************
108 function MyLogFolder : string;
114 if Length( folder ) = 0 then
117 Result := folder + LOG_DIR;
121 (*************************************************************************
122 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
123 *************************************************************************)
124 function DirectoryExistsEx(const Name: string): Boolean;
128 Code := GetFileAttributes(PChar(Name));
129 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
132 (*************************************************************************
133 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
134 *************************************************************************)
135 function ForceDirectoriesEx(Dir: string): Boolean;
138 if Length(Dir) = 0 then
139 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
140 Dir := ExcludeTrailingPathDelimiter(Dir);
141 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
142 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
143 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
146 //
\82Æ
\82è
\82 \82¦
\82¸
\82Ì
\91ã
\97p
\95i
\82È
\82Ì
\82Å chrWhite
\82ð
\8dl
\97¶
\82µ
\82Ä
\82¢
\82È
\82¢
\82±
\82Æ
\82É
\92\8d\88Ó
\81I
\81I
\81I
147 procedure ExtractHttpFields(
148 const chrSep : TSysCharSet;
149 const chrWhite : TSysCharSet;
150 const strValue : string;
151 var strResult : TStringList;
152 unknownFlag : boolean = false
155 last, p, strLen : Integer;
158 strLen := Length( strValue );
165 if strValue[ p ] in chrSep then
167 strResult.Add( Copy( strValue, last, p - last ) );
176 strResult.Add( Copy( strValue, last, strLen - last + 1 ) );
180 \rfunction HttpEncode(
181 \r const strValue : string
189 kHexCode : array [0..15] of char = (
190 '0', '1', '2', '3', '4', '5', '6', '7',
191 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' );
194 strLen := Length( strValue );
200 case strValue[ i ] of
201 '0' .. '9', 'a' .. 'z', 'A' .. 'Z', '*', '-', '.', '@', '_':
203 strResult := strResult + strValue[ i ];
207 b := Integer( strValue[ i ] );
208 strResult := strResult + '%'
209 + kHexCode[ b div $10 ]
210 + kHexCode[ b mod $10 ];
224 // =========================================================================
226 // =========================================================================
228 // *************************************************************************
229 //
\83v
\83\89\83O
\83C
\83\93\82Ì
\83o
\81[
\83W
\83\87\83\93\82ð
\97v
\8b\81\82³
\82ê
\82½
230 // *************************************************************************
231 procedure OnVersionInfo(
232 var outAgent : PChar; //
\83o
\81[
\83W
\83\87\83\93\82ð
\88ê
\90Ø
\8aÜ
\82Ü
\82È
\82¢
\8f\83\90\88\82È
\96¼
\8fÌ
233 var outMajor : DWORD; //
\83\81\83W
\83\83\81[
\83o
\81[
\83W
\83\87\83\93
234 var outMinor : DWORD; //
\83}
\83C
\83i
\81[
\83o
\81[
\83W
\83\87\83\93
235 var outRelease : PChar; //
\83\8a\83\8a\81[
\83X
\92i
\8aK
\96¼
236 var outRevision : DWORD //
\83\8a\83r
\83W
\83\87\83\93\83i
\83\93\83o
\81[
241 outAgent := CreateResultString( PChar( PLUGIN_NAME ) );
242 outMajor := MAJOR_VERSION;
243 outMinor := MINOR_VERSION;
244 outRelease := CreateResultString( PChar( RELEASE_VERSION ) );
245 outRevision := REVISION_VERSION;
256 // *************************************************************************
257 //
\8ew
\92è
\82µ
\82½ URL
\82ð
\82±
\82Ì
\83v
\83\89\83O
\83C
\83\93\82Å
\8eó
\82¯
\95t
\82¯
\82é
\82©
\82Ç
\82¤
\82©
258 // *************************************************************************
259 function OnAcceptURL(
260 inURL : PChar //
\94»
\92f
\82ð
\8bÂ
\82¢
\82Å
\82¢
\82é URL
261 ): TAcceptType; stdcall; // URL
\82Ì
\8eí
\97Þ
264 uriList : TStringList;
267 BBS_HOST = 'machi.to';
268 THREAD_MARK = '/bbs/read.pl';
272 //
\83z
\83X
\83g
\96¼
\82ª machi.to
\82Å
\8fI
\82í
\82é
\8fê
\8d\87\82Í
\8eó
\82¯
\95t
\82¯
\82é
\82æ
\82¤
\82É
\82µ
\82Ä
\82¢
\82é
273 uri := TIdURI.Create( inURL );
274 uriList := TStringList.Create;
276 ExtractHttpFields( ['/'], [], uri.Path, uriList );
277 foundPos := AnsiPos( BBS_HOST, uri.Host );
278 if (foundPos > 0) and (Length( uri.Host ) - foundPos + 1 = Length( BBS_HOST )) then begin
279 foundPos := Pos( THREAD_MARK, inURL );
282 else if (uriList.Count > 1) and (uri.Path <> '/') then //
\8dÅ
\8cã
\82ª '/'
\82Å
\95Â
\82ß
\82ç
\82ê
\82Ä
\82é
\82È
\82ç 3
287 Result := atNoAccept;
294 Result := atNoAccept;
301 // =========================================================================
302 // TMachiBBSThreadItem
303 // =========================================================================
305 // *************************************************************************
306 //
\83R
\83\93\83X
\83g
\83\89\83N
\83^
307 // *************************************************************************
308 constructor TMachiBBSThreadItem.Create(
313 uriList : TStringList;
318 OnDownload := Download;
321 OnGetHeader := GetHeader;
322 OnGetFooter := GetFooter;
323 OnGetBoardURL := GetBoardURL;
326 FIsTemporary := False;
328 URL := ReadURL + '&LAST=50';
330 uri := TIdURI.Create( URL );
331 uriList := TStringList.Create;
333 // http://hokkaido.machi.to/bbs/read.pl?BBS=hokkaidou&KEY=1061764446&LAST=50
336 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
337 FileName := uriList.Values[ 'KEY' ] + '.dat';
338 FilePath := MyLogFolder + uriList.Values[ 'BBS' ] + '\' + uriList.Values[ 'KEY' ] + '.dat';
339 IsLogFile := FileExists( FilePath );
347 // *************************************************************************
348 //
\83f
\83X
\83g
\83\89\83N
\83^
349 // *************************************************************************
350 destructor TMachiBBSThreadItem.Destroy;
355 //
\88ê
\8e\9e\83t
\83@
\83C
\83\8b\82Ì
\8fê
\8d\87\82Í
\8dí
\8f\9c\82·
\82é
357 DeleteFile( FilePath );
363 // *************************************************************************
364 //
\8ew
\92è
\82µ
\82½ URL
\82Ì
\83X
\83\8c\83b
\83h
\82Ì
\83_
\83E
\83\93\83\8d\81[
\83h
\82ð
\8ew
\8e¦
\82³
\82ê
\82½
365 // *************************************************************************
366 function TMachiBBSThreadItem.Download : TDownloadState;
370 downResult : TStringList;
371 content : TStringList;
372 responseCode : Longint;
373 logStream : TFileStream;
375 uriList : TStringList;
378 procedure downAndParse;
380 responseCode := InternalDownload( PChar( datURL ), modified, tmp, 0 );
383 if responseCode = 200 then begin
384 downResult := TStringList.Create;
386 downResult.Text := string( tmp );
388 //
\83^
\83C
\83g
\83\8b\82Ì
\8eæ
\93¾
389 foundPos := AnsiPos( '<title>', downResult.Text ) + Length( '<title>' );
393 AnsiPos( '</title>', downResult.Text ) - foundPos );
395 //
\83\8c\83X
\82Ì
\8aJ
\8en
\88Ê
\92u
396 foundPos := AnsiPos( '<dt', downResult.Text );
397 downResult.Text := Copy( downResult.Text, foundPos, Length( downResult.Text ) );
398 if foundPos > 0 then begin
399 //
\83\8c\83X
\82Ì
\8fI
\97¹
\88Ê
\92u
400 foundPos := AnsiPos( '<table', downResult.Text ) - 1;
402 downResult.Text := Copy( downResult.Text, 1, foundPos );
404 //
\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Å
405 //
\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¤
406 To2chDat( downResult, Count + 1 );
407 content.Text := content.Text + downResult.Text;
413 Result := dsNotModify;
417 DisposeResultString( tmp );
424 uri := TIdURI.Create( URL );
425 uriList := TStringList.Create;
426 content := TStringList.Create;
430 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
431 FileName := uriList.Values[ 'KEY' ] + '.dat';
432 if MyLogFolder = '' then begin
433 //
\82Ç
\82±
\82É
\95Û
\91¶
\82µ
\82Ä
\82¢
\82¢
\82Ì
\82©
\95ª
\82©
\82ç
\82È
\82¢
\82Ì
\82Å
\88ê
\8e\9e\83t
\83@
\83C
\83\8b\82É
\95Û
\91¶
434 FilePath := TemporaryFile;
435 FIsTemporary := True;
437 FilePath := MyLogFolder + uriList.Values[ 'BBS' ] + '\' + uriList.Values[ 'KEY' ] + '.dat';
438 FIsTemporary := False;
441 //
\95Û
\91¶
\97p
\82Ì
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ð
\8c@
\82é
442 ForceDirectoriesEx( Copy( FilePath, 1, LastDelimiter( '\', FilePath ) ) );
444 //
\93Æ
\8e©
\82É
\83_
\83E
\83\93\83\8d\81[
\83h
\82â
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\8ds
\82í
\82È
\82¢
\8fê
\8d\87\82Í
445 // InternalDownload
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
446 modified := LastModified;
450 uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
451 'BBS=' + uriList.Values[ 'BBS' ] + '&KEY=' + uriList.Values[ 'KEY' ] +
452 '&START=' + IntToStr( 1 )
454 //
\90V
\92\85\82Ì
\82Ý
456 uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
457 'BBS=' + uriList.Values[ 'BBS' ] + '&KEY=' + uriList.Values[ 'KEY' ] +
458 '&START=' + IntToStr( Count + 1 ) + '&NOFIRST=TRUE';
459 //
\83_
\83E
\83\93\83\8d\81[
\83h
462 if content.Count > 0 then begin
463 if Count <= 0 then begin
464 Result := dsComplete;
465 //
\90V
\8bK
\8f\91\82«
\8d\9e\82Ý
466 content[ 0 ] := content[ 0 ] + Title;
467 logStream := TFileStream.Create( FilePath, fmCreate or fmShareDenyWrite );
469 logStream.Position := logStream.Size;
470 logStream.Write( PChar( content.Text )^, Length( content.Text ) );
475 Count := content.Count;
477 Result := dsDiffComplete;
479 logStream := TFileStream.Create( FilePath, fmOpenReadWrite or fmShareDenyWrite );
481 logStream.Position := logStream.Size;
482 logStream.Write( PChar( content.Text )^, Length( content.Text ) );
486 NewReceive := Count + 1;
487 Count := Count + content.Count;
490 // CGI
\82©
\82ç
\82Í
\90³
\82µ
\82¢
\93ú
\95t
\82ª
\93¾
\82ç
\82ê
\82È
\82¢
\82Ì
\82Å
\8c»
\8dÝ
\82É
\90Ý
\92è
492 NewResCount := content.Count;
494 Result := dsNotModify;
504 // *************************************************************************
505 //
\8f\91\82«
\8d\9e\82Ý
\82ð
\8ew
\8e¦
\82³
\82ê
\82½
506 // *************************************************************************
507 function TMachiBBSThreadItem.Write(
508 inName : string; //
\96¼
\91O(
\83n
\83\93\83h
\83\8b)
509 inMail : string; //
\83\81\81[
\83\8b\83A
\83h
\83\8c\83X
510 inMessage : string //
\96{
\95¶
511 ) : TDownloadState; //
\8f\91\82«
\8d\9e\82Ý
\82ª
\90¬
\8c÷
\82µ
\82½
\82©
\82Ç
\82¤
\82©
517 uriList : TStringList;
520 uri := TIdURI.Create( URL );
521 uriList := TStringList.Create;
525 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
527 postURL := uri.Protocol + '://' + uri.Host + '/bbs/write.cgi';
529 'NAME=' + HttpEncode( inName ) +
530 '&MAIL=' + HttpEncode( inMail ) +
531 '&MESSAGE=' + HttpEncode( inMessage ) +
532 '&BBS=' + uriList.Values[ 'BBS' ] +
533 '&KEY=' + uriList.Values[ 'KEY' ] +
534 '&TIME=' + IntToStr( DateTimeToUnix( Now ) ) +
535 '&submit=' + HttpEncode( '
\8f\91\82«
\8d\9e\82Þ' );
537 //
\93Æ
\8e©
\82É
\92Ê
\90M
\82µ
\82È
\82¢
\8fê
\8d\87\82Í InternalPost
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
538 InternalPost( PChar( postURL ), PChar( postData ), postResult );
539 DisposeResultString( postResult );
549 // *************************************************************************
550 //
\83\8c\83X
\94Ô
\8d\86 inNo
\82É
\91Î
\82·
\82é html
\82ð
\97v
\8b\81\82³
\82ê
\82½
551 // *************************************************************************
552 function TMachiBBSThreadItem.GetRes(
553 inNo : Integer //
\97v
\8b\81\82³
\82ê
\82½
\83\8c\83X
\94Ô
\8d\86
554 ) : string; //
\91Î
\89\9e\82·
\82é HTML
560 //
\93Æ
\8e©
\82É
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\8ds
\82í
\82È
\82¢
\8fê
\8d\87\82Í
561 // InternalAbon
\82¨
\82æ
\82Ñ Dat2HTML
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
563 if FDat = nil then begin
564 //
\83\8d\83O
\82É
\91¶
\8dÝ
\82µ
\82È
\82¢
\82Ì
\82Å
\82±
\82Ì
\82Ü
\82Ü
\8fI
\97¹
568 res := FDat[ inNo - 1 ];
569 tmp := InternalAbonForOne( PChar( res ), PChar(FilePath), inNo);
571 Result := Dat2HTML( string( tmp ), inNo );
573 DisposeResultString( tmp );
578 // *************************************************************************
579 //
\83X
\83\8c\83b
\83h
\82Ì
\83w
\83b
\83_ html
\82ð
\97v
\8b\81\82³
\82ê
\82½
580 // *************************************************************************
581 function TMachiBBSThreadItem.GetHeader(
582 inOptionalHeader : string
586 //
\93Æ
\8e©
\82É
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\8ds
\82í
\82È
\82¢
\8fê
\8d\87\82Í
587 // InternalHeader
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
588 Result := InternalHeader(
589 '<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">' +
593 // GetRes
\82ð
\8cÄ
\82Î
\82ê
\82é
\82±
\82Æ
\82ª
\97\
\91z
\82³
\82ê
\82é
\82Ì
\82Å FDat
\82ð
\90¶
\90¬
\82µ
\82Ä
\82¨
\82
602 // *************************************************************************
603 //
\83X
\83\8c\83b
\83h
\82Ì
\83t
\83b
\83^ html
\82ð
\97v
\8b\81\82³
\82ê
\82½
604 // *************************************************************************
605 function TMachiBBSThreadItem.GetFooter(
606 inOptionalFooter : string
610 //
\93Æ
\8e©
\82É
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\8ds
\82í
\82È
\82¢
\8fê
\8d\87\82Í
611 // InternalFooter
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
612 Result := InternalFooter( inOptionalFooter );
614 //
\82à
\82¤ GetRes
\82Í
\8cÄ
\82Î
\82ê
\82È
\82¢
\82Æ
\8ev
\82¤
\82Ì
\82Å FDat
\82ð
\8aJ
\95ú
\82µ
\82Ä
\82¨
\82
622 // *************************************************************************
623 //
\82±
\82Ì ThreadItem
\82ª
\91®
\82·
\82é
\94Â
\82Ì URL
\82ð
\97v
\8b\81\82³
\82ê
\82½
624 // *************************************************************************
625 function TMachiBBSThreadItem.GetBoardURL : string;
628 uriList : TStringList;
631 if Copy( URL, Length( URL ), 1 ) = '/' then
632 uri := TIdURI.Create( URL )
634 uri := TIdURI.Create( URL + '/' );
635 uriList := TStringList.Create;
639 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
640 FileName := uriList.Values[ 'KEY' ] + '.dat';
641 // http://hokkaido.machi.to/bbs/read.pl?BBS=hokkaidou&KEY=1061764446
642 // http://hokkaido.machi.to/hokkaidou/
643 Result := CreateResultString(
644 uri.Protocol + '://' + uri.Host + '/' + uriList.Values[ 'BBS' ] + '/' );
652 // *************************************************************************
653 //
\82Ü
\82¿BBS
\82Ì HTML
\82ð 2ch
\82Ì dat
\8c`
\8e®
\82É
654 // *************************************************************************
655 procedure TMachiBBSThreadItem.To2chDat(
656 ioHTML : TStringList;
657 inStartNo : Integer = 1
666 MAIL_TAG = '<a href="mailto:';
669 //===== 2ch
\82Ì dat
\8c`
\8e®
\82É
\95Ï
\8a·
670 //
\83z
\83X
\83g
\96¼
\82Ì
\8cã
\82Å
\89ü
\8ds
\82³
\82ê
\82Ä
\82¢
\82½
\82è
\82·
\82é
\82Ì
\82Å
\89ü
\8ds
\82ð
\82·
\82×
\82Ä
\8eæ
\82è
\8f\9c\82
671 ioHTML.Text := CustomStringReplace( ioHTML.Text, #13#10, '');
672 //StringReplace( ioHTML.Text, #13#10, '', [rfReplaceAll] );
673 //
\91ã
\82í
\82è
\82É <dt>
\82ð
\8ds
\82Ì
\8bæ
\90Ø
\82è
\82É
\82·
\82é
674 ioHTML.Text := CustomStringReplace( ioHTML.Text, '<dt>', #10 );
675 //StringReplace( ioHTML.Text, '<dt>', #10, [rfReplaceAll] );
676 // <dt>
\82©
\82ç
\8en
\82Ü
\82Á
\82Ä
\82¢
\82é
\82Ì
\82Å
\8dÅ
\8f\89\82Í
\8bó
\82Ì
\82Í
\82¸
677 if Length( ioHTML[ 0 ] ) = 0 then
680 //
\8cy
\82
\82 \82Ú
\81[
\82ñ
\83`
\83F
\83b
\83N
681 //
\81¦
\91å
\8eG
\94c
\82¾
\82©
\82ç
\82¿
\82á
\82ñ
\82Æ
\8fo
\97\88\82Ä
\82È
\82¢
\82©
\82à
684 while i < ioHTML.Count do begin
685 foundPos := AnsiPos( ' ', ioHTML[ i ] );
686 if foundPos > 0 then begin
687 no := StrToInt( Copy( ioHTML[ i ], 1, foundPos - 1 ) );
688 if inStartNo < no then
689 ioHTML.Insert( i, '<><><><>' );
695 //
\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Å
698 //
\83g
\83\8a\83b
\83v
\82Ì
\8cã
\82Ì '<b> </b>'
\82ð
\8bó
\82É
699 ioHTML.Text := CustomStringReplace( ioHTML.Text, '<b> </b>', '', true );
700 //StringReplace( ioHTML.Text, '<b> </b>', '', [rfReplaceAll, rfIgnoreCase] );
701 // '<b>'
\82Í
\83\81\81[
\83\8b\82Æ
\96¼
\91O
\82Ì
\8bæ
\90Ø
\82è
702 ioHTML.Text := CustomStringReplace( ioHTML.Text, '<b>', '<>', true );
703 //StringReplace( ioHTML.Text, '<b>', '<>', [rfReplaceAll, rfIgnoreCase] );
704 //
\83\81\81[
\83\8b\82Æ
\96¼
\91O
\82É
\82Â
\82¢
\82Ä
\82
\82é
\95Â
\82¶
\83^
\83O
\82ð
\93\8a\8de
\93ú
\82Æ
\82Ì
\8bæ
\90Ø
\82è
\82É
705 ioHTML.Text := CustomStringReplace( ioHTML.Text, '</b></a>', '<>', true );
706 //StringReplace( ioHTML.Text, '</b></a>', '<>', [rfReplaceAll, rfIgnoreCase] );
707 ioHTML.Text := CustomStringReplace( ioHTML.Text, '</b>', '<>', true );
708 //StringReplace( ioHTML.Text, '</b>', '<>', [rfReplaceAll, rfIgnoreCase] );
709 // '<dd>'
\82ð
\96{
\95¶
\82Æ
\82Ì
\8bæ
\90Ø
\82è
\82É
710 ioHTML.Text := CustomStringReplace( ioHTML.Text, '<dd>', '<>', true );
711 //StringReplace( ioHTML.Text, '<dd>', '<>', [rfReplaceAll, rfIgnoreCase] );
713 res := TStringList.Create;
715 bound := ioHTML.Count - 1;
716 for i := 0 to bound do begin
717 res.Text := CustomStringReplace( ioHTML[ i ], '<>', #10 );
718 //StringReplace( ioHTML[ i ], '<>', #10, [rfReplaceAll] );
719 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ß
720 foundPos := AnsiPos( MAIL_TAG, res[ 0 ] );
721 if foundPos > 0 then begin
722 //
\83\81\81[
\83\8b\83A
\83h
\83\8c\83X
\82ð
\94²
\82«
\8fo
\82·
723 foundPos := foundPos + Length( MAIL_TAG );
724 res[ 0 ] := Copy( res[ 0 ], foundPos, Length( res[ 0 ] ) );
725 strTmp := Copy( res[ 0 ], 1, AnsiPos( '">', res[ 0 ] ) - 1 );
726 //
\83\81\81[
\83\8b\82Æ
\96¼
\91O
\82ª
\8bt
\82È
\82Ì
\82Å
\82Ð
\82Á
\82
\82è
\95Ô
\82µ
\82Ä
\96ß
\82·
727 res[ 0 ] := res[ 1 ];
730 //
\83\81\81[
\83\8b\82Æ
\96¼
\91O
\82ª
\8bt
\82È
\82Ì
\82Å
\82Ð
\82Á
\82
\82è
\95Ô
\82·
731 res[ 0 ] := res[ 1 ];
734 res[ 2 ] := StringReplace( res[ 2 ], '[', 'IP:', [] );
735 res[ 2 ] := StringReplace( res[ 2 ], ']', '', [] );
737 ioHTML[ i ] := CustomStringReplace( res.Text, #13#10, '<>');
738 //StringReplace( res.Text, #13#10, '<>', [rfReplaceAll] );
746 // *************************************************************************
748 // *************************************************************************
749 procedure TMachiBBSThreadItem.LoadDat;
752 if FDat = nil then begin
753 if IsLogFile then begin
754 // dat
\82Ì
\93Ç
\82Ý
\8d\9e\82Ý
755 FDat := TStringList.Create;
756 FDat.LoadFromFile( FilePath );
762 // *************************************************************************
764 // *************************************************************************
765 procedure TMachiBBSThreadItem.FreeDat;
768 if FDat <> nil then begin
775 // *************************************************************************
776 //
\88À
\91S
\82È( '/'
\82Å
\8fI
\82í
\82é )
\93Ç
\82Ý
\8d\9e\82Ý
\82Ì URL
777 // *************************************************************************
778 function TMachiBBSThreadItem.ReadURL : string;
781 uriList : TStringList;
785 foundPos := AnsiPos( '?', URL );
786 if foundPos > 0 then begin
787 uri := TIdURI.Create( URL );
788 uriList := TStringList.Create;
790 ExtractHttpFields( ['&'], [], Copy( URL, foundPos + 1, MaxInt ), uriList );
792 uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
793 'BBS=' + uriList.Values[ 'BBS' ] + '&KEY=' + uriList.Values[ 'KEY' ];
802 // *************************************************************************
803 // TThreadItem
\82ª
\90¶
\90¬
\82³
\82ê
\82½
\8fê
\8d\87\82Ì
\8f\88\92u(TMachiBBSThreadItem
\82ð
\90¶
\90¬
\82·
\82é)
804 // *************************************************************************
805 procedure ThreadItemOnCreateOfTMachiBBSThreadItem(
809 threadItem : TMachiBBSThreadItem;
812 threadItem := TMachiBBSThreadItem.Create( inInstance );
813 ThreadItemSetLong( inInstance, tipContext, DWORD( threadItem ) );
817 // *************************************************************************
818 // TThreadItem
\82ª
\94j
\8aü
\82³
\82ê
\82½
\8fê
\8d\87\82Ì
\8f\88\92u(TMachiBBSThreadItem
\82ð
\94j
\8aü
\82·
\82é)
819 // *************************************************************************
820 procedure ThreadItemOnDisposeOfTMachiBBSThreadItem(
824 threadItem : TMachiBBSThreadItem;
827 threadItem := TMachiBBSThreadItem( ThreadItemGetLong( inInstance, tipContext ) );
832 // =========================================================================
833 // TMachiBBSBoardItem
834 // =========================================================================
836 // *************************************************************************
837 //
\83R
\83\93\83X
\83g
\83\89\83N
\83^
838 // *************************************************************************
839 constructor TMachiBBSBoardItem.Create(
844 uriList : TStringList;
849 OnDownload := Download;
850 OnCreateThread := CreateThread;
851 OnEnumThread := EnumThread;
852 OnFileName2ThreadURL := ToThreadURL;
855 FIsTemporary := False;
858 uri := TIdURI.Create( SubjectURL );
859 uriList := TStringList.Create;
861 ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
862 // http://hokkaido.machi.to/hokkaidou/subject.txt
863 FilePath := MyLogFolder + uriList[ 1 ] + '\' + uri.Document;
864 IsLogFile := FileExists( FilePath );
872 // *************************************************************************
873 //
\83f
\83X
\83g
\83\89\83N
\83^
874 // *************************************************************************
875 destructor TMachiBBSBoardItem.Destroy;
878 if FDat <> nil then begin
886 //
\88ê
\8e\9e\83t
\83@
\83C
\83\8b\82Ì
\8fê
\8d\87\82Í
\8dí
\8f\9c\82·
\82é
888 DeleteFile( FilePath );
894 // *************************************************************************
895 //
\8ew
\92è
\82µ
\82½
\83X
\83\8c\88ê
\97\97\82Ì
\83_
\83E
\83\93\83\8d\81[
\83h
\82ð
\97v
\8b\81\82³
\82ê
\82½
896 // *************************************************************************
897 function TMachiBBSBoardItem.Download : TDownloadState;
901 responseCode : Longint;
903 uriList : TStringList;
908 if FDat <> nil then begin
915 FDat := TStringList.Create;
916 uri := TIdURI.Create( SubjectURL );
917 uriList := TStringList.Create;
918 //
\93Æ
\8e©
\82É
\83_
\83E
\83\93\83\8d\81[
\83h
\82â
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\8ds
\82í
\82È
\82¢
\8fê
\8d\87\82Í
919 // InternalDownload
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
920 modified := LastModified;
921 responseCode := InternalDownload( PChar( uri.URI ), modified, downResult );
923 if responseCode = 200 then begin
925 //
\83p
\83X
\82ð
\8eZ
\8fo
926 ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
927 if MyLogFolder = '' then begin
928 //
\82Ç
\82±
\82É
\95Û
\91¶
\82µ
\82Ä
\82¢
\82¢
\82Ì
\82©
\95ª
\82©
\82ç
\82È
\82¢
\82Ì
\82Å
\88ê
\8e\9e\83t
\83@
\83C
\83\8b\82É
\95Û
\91¶
929 FilePath := TemporaryFile;
930 FIsTemporary := True;
932 FilePath := MyLogFolder + uriList[ 1 ] + '\' + uri.Document;
933 FIsTemporary := False
936 //
\95Û
\91¶
\97p
\82Ì
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ð
\8c@
\82é
937 ForceDirectoriesEx( Copy( FilePath, 1, LastDelimiter( '\', FilePath ) ) );
939 FDat.Text := string( downResult );
941 FDat.SaveToFile( FilePath );
945 LastModified := modified;
951 Result := dsComplete;
954 DisposeResultString( downResult );
959 // *************************************************************************
960 //
\83X
\83\8c\97§
\82Ä
\82ð
\8ew
\8e¦
\82³
\82ê
\82½
961 // *************************************************************************
962 function TMachiBBSBoardItem.CreateThread(
963 inSubject : string; //
\83X
\83\8c\83^
\83C
964 inName : string; //
\96¼
\91O(
\83n
\83\93\83h
\83\8b)
965 inMail : string; //
\83\81\81[
\83\8b\83A
\83h
\83\8c\83X
966 inMessage : string //
\96{
\95¶
967 ) : TDownloadState; //
\8f\91\82«
\8d\9e\82Ý
\82ª
\90¬
\8c÷
\82µ
\82½
\82©
\82Ç
\82¤
\82©
973 uriList : TStringList;
976 uri := TIdURI.Create( URL );
977 uriList := TStringList.Create;
981 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
983 postURL := uri.Protocol + '://' + uri.Host + '/bbs/write.cgi';
985 'SUBJECT=' + HttpEncode( inSubject ) +
986 '&NAME=' + HttpEncode( inName ) +
987 '&MAIL=' + HttpEncode( inMail ) +
988 '&MESSAGE=' + HttpEncode( inMessage ) +
989 '&BBS=' + uriList[ 1 ] +
990 '&TIME=' + IntToStr( DateTimeToUnix( Now ) ) +
991 '&submit=' + HttpEncode( '
\90V
\8bK
\8f\91\82«
\8d\9e\82Ý' );
993 //
\93Æ
\8e©
\82É
\92Ê
\90M
\82µ
\82È
\82¢
\8fê
\8d\87\82Í InternalPost
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
994 InternalPost( PChar( postURL ), PChar( postData ), postResult );
995 DisposeResultString( postResult );
1005 // *************************************************************************
1006 //
\83X
\83\8c\88ê
\97\97\82Ì URL
\82©
\82ç
\83X
\83\8c\83b
\83h
\82Ì URL
\82ð
\93±
\82«
\8fo
\82·
1007 // *************************************************************************
1008 function TMachiBBSBoardItem.ToThreadURL(
1009 inFileName : string //
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\96¼
1010 ) : string; //
\83X
\83\8c\83b
\83h
\82Ì URL
1014 uriList : TStringList;
1018 found := AnsiPos( '.', inFileName );
1020 inFileName := Copy( inFileName, 1, found - 1 );
1022 uri := TIdURI.Create( SubjectURL );
1023 uriList := TStringList.Create;
1026 // http://hokkaido.machi.to/hokkaidou/
1027 // http://hokkaido.machi.to/bbs/read.pl?BBS=hokkaidou&KEY=1061764446&LAST=50
1028 ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
1029 threadURL := uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
1030 'BBS=' + uriList[ 1 ] + '&KEY=' + inFileName + '&LAST=50';
1031 Result := threadURL;
1042 // *************************************************************************
1043 //
\82±
\82Ì
\94Â
\82É
\82¢
\82
\82Â
\82Ì
\83X
\83\8c\82ª
\82 \82é
\82©
\97v
\8b\81\82³
\82ê
\82½
1044 // *************************************************************************
1045 procedure TMachiBBSBoardItem.EnumThread(
1046 inCallBack : TBoardItemEnumThreadCallBack
1050 uriList : TStringList;
1054 if FDat = nil then begin
1055 FDat := TStringList.Create;
1057 uri := TIdURI.Create( SubjectURL );
1058 uriList := TStringList.Create;
1060 //
\83p
\83X
\82ð
\8eZ
\8fo
1061 ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
1062 // http://hokkaido.machi.to/hokkaidou/subject.txt
1063 FilePath := MyLogFolder + uriList[ 1 ] + '\' + uri.Document;
1064 if FileExists( FilePath ) then
1065 //
\93Ç
\82Ý
\8d\9e\82Ý
1066 FDat.LoadFromFile( FilePath );
1073 //
\93Æ
\8e©
\82É
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\8ds
\82í
\82È
\82¢
\8fê
\8d\87\82Í EnumThread
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
1074 inherited EnumThread( inCallBack, CustomStringReplace( FDat.Text, ',', '<>' ) );
1080 // *************************************************************************
1081 //
\83X
\83\8c\88ê
\97\97\82Ì URL
\82ð
\8b\81\82ß
\82é
1082 // *************************************************************************
1083 function TMachiBBSBoardItem.SubjectURL : string;
1086 uriList : TStringList;
1089 uri := TIdURI.Create( URL );
1090 uriList := TStringList.Create;
1092 if uri.Document <> SUBJECT_NAME then begin
1093 if Copy( URL, Length( URL ), 1 ) = '/' then
1094 Result := URL + SUBJECT_NAME
1096 Result := URL + '/' + SUBJECT_NAME;
1098 //
\82±
\82±
\82É
\82Í
\97\88\82È
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
1108 // *************************************************************************
1109 // TBoardItem
\82ª
\90¶
\90¬
\82³
\82ê
\82½
\8fê
\8d\87\82Ì
\8f\88\92u(TMachiBBSBoardItem
\82ð
\90¶
\90¬
\82·
\82é)
1110 // *************************************************************************
1111 procedure BoardItemOnCreateOfTMachiBBSBoardItem(
1115 boardItem : TMachiBBSBoardItem;
1118 boardItem := TMachiBBSBoardItem.Create( inInstance );
1119 BoardItemSetLong( inInstance, bipContext, DWORD( boardItem ) );
1123 // *************************************************************************
1124 // TBoardItem
\82ª
\94j
\8aü
\82³
\82ê
\82½
\8fê
\8d\87\82Ì
\8f\88\92u(TMachiBBSBoardItem
\82ð
\94j
\8aü
\82·
\82é)
1125 // *************************************************************************
1126 procedure BoardItemOnDisposeOfTMachiBBSBoardItem(
1130 boardItem : TMachiBBSBoardItem;
1133 boardItem := TMachiBBSBoardItem( BoardItemGetLong( inInstance, bipContext ) );
1140 // =========================================================================
1141 //
\83G
\83\93\83g
\83\8a\83|
\83C
\83\93\83g
1142 // =========================================================================
1144 ul_reason_for_call : DWORD
1150 case ul_reason_for_call of
1155 module := GetModuleHandle( nil );
1157 LoadInternalAPI( module );
1158 LoadInternalFilePathAPI( module );
1159 LoadInternalThreadItemAPI( module );
1160 LoadInternalBoardItemAPI( module );
1162 // =====
\83C
\83\93\83X
\83^
\83\93\83X
\82Ì
\8eæ
\82è
\88µ
\82¢
\82ð TThreadItem
\82©
\82ç TMachiBBSThreadItem
\82É
\95Ï
\8dX
\82·
\82é
1163 ThreadItemOnCreate := ThreadItemOnCreateOfTMachiBBSThreadItem;
1164 ThreadItemOnDispose := ThreadItemOnDisposeOfTMachiBBSThreadItem;
1165 // =====
\83C
\83\93\83X
\83^
\83\93\83X
\82Ì
\8eæ
\82è
\88µ
\82¢
\82ð TBoardItem
\82©
\82ç TMachiBBSBoardItem
\82É
\95Ï
\8dX
\82·
\82é
1166 BoardItemOnCreate := BoardItemOnCreateOfTMachiBBSBoardItem;
1167 BoardItemOnDispose := BoardItemOnDisposeOfTMachiBBSBoardItem;
1186 DllProc := @DLLEntry;
1187 DLLEntry( DLL_PROCESS_ATTACH );