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';
19 // =========================================================================
20 // TMachiBBSThreadItem
21 // =========================================================================
22 TMachiBBSThreadItem = class(TThreadItem)
24 FIsTemporary : Boolean;
28 constructor Create( inInstance : DWORD );
29 destructor Destroy; override;
32 function Download : TDownloadState;
33 function Write( inName : string; inMail : string; inMessage : string ) : TDownloadState;
34 function GetRes( inNo : Integer ) : string;
35 function GetHeader( inOptionalHeader : string ) : string;
36 function GetFooter( inOptionalFooter : string ) : string;
37 function GetBoardURL : string;
39 procedure To2chDat( ioHTML : TStringList; inStartNo : Integer = 1 );
42 function ReadURL : string;
45 // =========================================================================
47 // =========================================================================
48 TMachiBBSBoardItem = class(TBoardItem)
50 FIsTemporary : Boolean;
54 constructor Create( inInstance : DWORD );
55 destructor Destroy; override;
58 function Download : TDownloadState;
59 function CreateThread( inSubject : string; inName : string; inMail : string; inMessage : string ) : TDownloadState;
60 function ToThreadURL( inFileName : string ) : string;
61 procedure EnumThread( inCallBack : TBoardItemEnumThreadCallBack );
63 function SubjectURL : string;
66 // =========================================================================
67 //
\83T
\83u
\83W
\83F
\83N
\83g
\83\8c\83R
\81[
\83h
68 // =========================================================================
76 LOG_DIR = 'MachiBBS\';
77 SUBJECT_NAME = 'subject.txt';
79 PLUGIN_NAME = 'MachiBBSPlugIn';
82 RELEASE_VERSION = 'beta';
83 REVISION_VERSION = 11;
85 // =========================================================================
87 // =========================================================================
89 // *************************************************************************
90 //
\83e
\83\93\83|
\83\89\83\8a\82È
\83p
\83X
\82Ì
\8eæ
\93¾
91 // *************************************************************************
92 function TemporaryFile : string;
94 tempPath : array [0..MAX_PATH] of char;
97 GetTempPath( SizeOf(tempPath), tempPath );
99 Result := tempPath + IntToStr( Random( $7fffffff ) );
100 until not FileExists( Result );
104 // *************************************************************************
105 //
\82Ü
\82¿BBS
\97p
\83\8d\83O
\83t
\83H
\83\8b\83_
\8eæ
\93¾
106 // *************************************************************************
107 function MyLogFolder : string;
113 if Length( folder ) = 0 then
116 Result := folder + LOG_DIR;
120 (*************************************************************************
121 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ª
\91¶
\8dÝ
\82·
\82é
\82©
\83`
\83F
\83b
\83N
122 *************************************************************************)
123 function DirectoryExistsEx(const Name: string): Boolean;
127 Code := GetFileAttributes(PChar(Name));
128 Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
131 (*************************************************************************
132 *
\83f
\83B
\83\8c\83N
\83g
\83\8a\8dì
\90¬
\81i
\95¡
\90\94\8aK
\91w
\91Î
\89\9e\81j
133 *************************************************************************)
134 function ForceDirectoriesEx(Dir: string): Boolean;
137 if Length(Dir) = 0 then
138 raise Exception.Create('
\83t
\83H
\83\8b\83_
\82ª
\8dì
\90¬
\8fo
\97\88\82Ü
\82¹
\82ñ');
139 Dir := ExcludeTrailingPathDelimiter(Dir);
140 if (Length(Dir) < 3) or DirectoryExistsEx(Dir)
141 or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
142 Result := ForceDirectoriesEx(ExtractFilePath(Dir)) and CreateDir(Dir);
145 //
\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
146 procedure ExtractHttpFields(
147 const chrSep : TSysCharSet;
148 const chrWhite : TSysCharSet;
149 const strValue : string;
150 var strResult : TStringList;
151 unknownFlag : boolean = false
154 last, p, strLen : Integer;
157 strLen := Length( strValue );
164 if strValue[ p ] in chrSep then
166 strResult.Add( Copy( strValue, last, p - last ) );
175 strResult.Add( Copy( strValue, last, strLen - last + 1 ) );
179 \rfunction HttpEncode(
180 \r const strValue : string
188 kHexCode : array [0..15] of char = (
189 '0', '1', '2', '3', '4', '5', '6', '7',
190 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' );
193 strLen := Length( strValue );
199 case strValue[ i ] of
200 '0' .. '9', 'a' .. 'z', 'A' .. 'Z', '*', '-', '.', '@', '_':
202 strResult := strResult + strValue[ i ];
206 b := Integer( strValue[ i ] );
207 strResult := strResult + '%'
208 + kHexCode[ b div $10 ]
209 + kHexCode[ b mod $10 ];
223 // =========================================================================
225 // =========================================================================
227 // *************************************************************************
228 //
\83v
\83\89\83O
\83C
\83\93\82Ì
\83o
\81[
\83W
\83\87\83\93\82ð
\97v
\8b\81\82³
\82ê
\82½
229 // *************************************************************************
230 procedure OnVersionInfo(
231 var outAgent : PChar; //
\83o
\81[
\83W
\83\87\83\93\82ð
\88ê
\90Ø
\8aÜ
\82Ü
\82È
\82¢
\8f\83\90\88\82È
\96¼
\8fÌ
232 var outMajor : DWORD; //
\83\81\83W
\83\83\81[
\83o
\81[
\83W
\83\87\83\93
233 var outMinor : DWORD; //
\83}
\83C
\83i
\81[
\83o
\81[
\83W
\83\87\83\93
234 var outRelease : PChar; //
\83\8a\83\8a\81[
\83X
\92i
\8aK
\96¼
235 var outRevision : DWORD //
\83\8a\83r
\83W
\83\87\83\93\83i
\83\93\83o
\81[
240 outAgent := CreateResultString( PChar( PLUGIN_NAME ) );
241 outMajor := MAJOR_VERSION;
242 outMinor := MINOR_VERSION;
243 outRelease := CreateResultString( PChar( RELEASE_VERSION ) );
244 outRevision := REVISION_VERSION;
255 // *************************************************************************
256 //
\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©
257 // *************************************************************************
258 function OnAcceptURL(
259 inURL : PChar //
\94»
\92f
\82ð
\8bÂ
\82¢
\82Å
\82¢
\82é URL
260 ): TAcceptType; stdcall; // URL
\82Ì
\8eí
\97Þ
263 uriList : TStringList;
266 BBS_HOST = 'machi.to';
267 THREAD_MARK = '/bbs/read.pl';
271 //
\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é
272 uri := TIdURI.Create( inURL );
273 uriList := TStringList.Create;
275 ExtractHttpFields( ['/'], [], uri.Path, uriList );
276 foundPos := AnsiPos( BBS_HOST, uri.Host );
277 if (foundPos > 0) and (Length( uri.Host ) - foundPos + 1 = Length( BBS_HOST )) then begin
278 foundPos := Pos( THREAD_MARK, inURL );
281 else if (uriList.Count > 1) and (uri.Path <> '/') then //
\8dÅ
\8cã
\82ª '/'
\82Å
\95Â
\82ß
\82ç
\82ê
\82Ä
\82é
\82È
\82ç 3
286 Result := atNoAccept;
293 Result := atNoAccept;
300 // =========================================================================
301 // TMachiBBSThreadItem
302 // =========================================================================
304 // *************************************************************************
305 //
\83R
\83\93\83X
\83g
\83\89\83N
\83^
306 // *************************************************************************
307 constructor TMachiBBSThreadItem.Create(
312 uriList : TStringList;
317 OnDownload := Download;
320 OnGetHeader := GetHeader;
321 OnGetFooter := GetFooter;
322 OnGetBoardURL := GetBoardURL;
325 FIsTemporary := False;
327 URL := ReadURL + '&LAST=50';
329 uri := TIdURI.Create( URL );
330 uriList := TStringList.Create;
332 // http://hokkaido.machi.to/bbs/read.pl?BBS=hokkaidou&KEY=1061764446&LAST=50
335 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
336 FileName := uriList.Values[ 'KEY' ] + '.dat';
337 FilePath := MyLogFolder + uriList.Values[ 'BBS' ] + '\' + uriList.Values[ 'KEY' ] + '.dat';
338 IsLogFile := FileExists( FilePath );
346 // *************************************************************************
347 //
\83f
\83X
\83g
\83\89\83N
\83^
348 // *************************************************************************
349 destructor TMachiBBSThreadItem.Destroy;
354 //
\88ê
\8e\9e\83t
\83@
\83C
\83\8b\82Ì
\8fê
\8d\87\82Í
\8dí
\8f\9c\82·
\82é
356 DeleteFile( FilePath );
362 // *************************************************************************
363 //
\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½
364 // *************************************************************************
365 function TMachiBBSThreadItem.Download : TDownloadState;
369 downResult : TStringList;
370 content : TStringList;
371 responseCode : Longint;
372 logStream : TFileStream;
374 uriList : TStringList;
377 procedure downAndParse;
379 responseCode := InternalDownload( PChar( datURL ), modified, tmp, 0 );
382 if responseCode = 200 then begin
383 downResult := TStringList.Create;
385 downResult.Text := string( tmp );
387 //
\83^
\83C
\83g
\83\8b\82Ì
\8eæ
\93¾
388 foundPos := AnsiPos( '<title>', downResult.Text ) + Length( '<title>' );
392 AnsiPos( '</title>', downResult.Text ) - foundPos );
394 //
\83\8c\83X
\82Ì
\8aJ
\8en
\88Ê
\92u
395 foundPos := AnsiPos( '<dt', downResult.Text );
396 downResult.Text := Copy( downResult.Text, foundPos, Length( downResult.Text ) );
397 if foundPos > 0 then begin
398 //
\83\8c\83X
\82Ì
\8fI
\97¹
\88Ê
\92u
399 foundPos := AnsiPos( '<table', downResult.Text ) - 1;
401 downResult.Text := Copy( downResult.Text, 1, foundPos );
403 //
\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Å
404 //
\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¤
405 To2chDat( downResult, Count + 1 );
406 content.Text := content.Text + downResult.Text;
412 Result := dsNotModify;
416 DisposeResultString( tmp );
423 uri := TIdURI.Create( URL );
424 uriList := TStringList.Create;
425 content := TStringList.Create;
429 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
430 FileName := uriList.Values[ 'KEY' ] + '.dat';
431 if MyLogFolder = '' then begin
432 //
\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¶
433 FilePath := TemporaryFile;
434 FIsTemporary := True;
436 FilePath := MyLogFolder + uriList.Values[ 'BBS' ] + '\' + uriList.Values[ 'KEY' ] + '.dat';
437 FIsTemporary := False;
440 //
\95Û
\91¶
\97p
\82Ì
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ð
\8c@
\82é
441 ForceDirectoriesEx( Copy( FilePath, 1, LastDelimiter( '\', FilePath ) ) );
443 //
\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Í
444 // InternalDownload
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
445 modified := LastModified;
449 uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
450 'BBS=' + uriList.Values[ 'BBS' ] + '&KEY=' + uriList.Values[ 'KEY' ] +
451 '&START=' + IntToStr( 1 )
453 //
\90V
\92\85\82Ì
\82Ý
455 uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
456 'BBS=' + uriList.Values[ 'BBS' ] + '&KEY=' + uriList.Values[ 'KEY' ] +
457 '&START=' + IntToStr( Count + 1 ) + '&NOFIRST=TRUE';
458 //
\83_
\83E
\83\93\83\8d\81[
\83h
461 if content.Count > 0 then begin
462 if Count <= 0 then begin
463 Result := dsComplete;
464 //
\90V
\8bK
\8f\91\82«
\8d\9e\82Ý
465 content[ 0 ] := content[ 0 ] + Title;
466 logStream := TFileStream.Create( FilePath, fmCreate or fmShareDenyWrite );
468 logStream.Position := logStream.Size;
469 logStream.Write( PChar( content.Text )^, Length( content.Text ) );
474 Count := content.Count;
476 Result := dsDiffComplete;
478 logStream := TFileStream.Create( FilePath, fmOpenReadWrite or fmShareDenyWrite );
480 logStream.Position := logStream.Size;
481 logStream.Write( PChar( content.Text )^, Length( content.Text ) );
485 NewReceive := Count + 1;
486 Count := Count + content.Count;
489 // CGI
\82©
\82ç
\82Í
\90³
\82µ
\82¢
\93ú
\95t
\82ª
\93¾
\82ç
\82ê
\82È
\82¢
\82Ì
\82Å
\8c»
\8dÝ
\82É
\90Ý
\92è
491 NewResCount := content.Count;
493 Result := dsNotModify;
503 // *************************************************************************
504 //
\8f\91\82«
\8d\9e\82Ý
\82ð
\8ew
\8e¦
\82³
\82ê
\82½
505 // *************************************************************************
506 function TMachiBBSThreadItem.Write(
507 inName : string; //
\96¼
\91O(
\83n
\83\93\83h
\83\8b)
508 inMail : string; //
\83\81\81[
\83\8b\83A
\83h
\83\8c\83X
509 inMessage : string //
\96{
\95¶
510 ) : TDownloadState; //
\8f\91\82«
\8d\9e\82Ý
\82ª
\90¬
\8c÷
\82µ
\82½
\82©
\82Ç
\82¤
\82©
516 uriList : TStringList;
519 uri := TIdURI.Create( URL );
520 uriList := TStringList.Create;
524 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
526 postURL := uri.Protocol + '://' + uri.Host + '/bbs/write.cgi';
528 'NAME=' + HttpEncode( inName ) +
529 '&MAIL=' + HttpEncode( inMail ) +
530 '&MESSAGE=' + HttpEncode( inMessage ) +
531 '&BBS=' + uriList.Values[ 'BBS' ] +
532 '&KEY=' + uriList.Values[ 'KEY' ] +
533 '&TIME=' + IntToStr( DateTimeToUnix( Now ) ) +
534 '&submit=' + HttpEncode( '
\8f\91\82«
\8d\9e\82Þ' );
536 //
\93Æ
\8e©
\82É
\92Ê
\90M
\82µ
\82È
\82¢
\8fê
\8d\87\82Í InternalPost
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
537 InternalPost( PChar( postURL ), PChar( postData ), postResult );
538 DisposeResultString( postResult );
548 // *************************************************************************
549 //
\83\8c\83X
\94Ô
\8d\86 inNo
\82É
\91Î
\82·
\82é html
\82ð
\97v
\8b\81\82³
\82ê
\82½
550 // *************************************************************************
551 function TMachiBBSThreadItem.GetRes(
552 inNo : Integer //
\97v
\8b\81\82³
\82ê
\82½
\83\8c\83X
\94Ô
\8d\86
553 ) : string; //
\91Î
\89\9e\82·
\82é HTML
559 //
\93Æ
\8e©
\82É
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\8ds
\82í
\82È
\82¢
\8fê
\8d\87\82Í
560 // InternalAbon
\82¨
\82æ
\82Ñ Dat2HTML
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
562 if FDat = nil then begin
563 //
\83\8d\83O
\82É
\91¶
\8dÝ
\82µ
\82È
\82¢
\82Ì
\82Å
\82±
\82Ì
\82Ü
\82Ü
\8fI
\97¹
567 res := FDat[ inNo - 1 ];
568 tmp := InternalAbonForOne( PChar( res ), PChar(FilePath), inNo);
570 Result := Dat2HTML( string( tmp ), inNo );
572 DisposeResultString( tmp );
577 // *************************************************************************
578 //
\83X
\83\8c\83b
\83h
\82Ì
\83w
\83b
\83_ html
\82ð
\97v
\8b\81\82³
\82ê
\82½
579 // *************************************************************************
580 function TMachiBBSThreadItem.GetHeader(
581 inOptionalHeader : string
585 //
\93Æ
\8e©
\82É
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\8ds
\82í
\82È
\82¢
\8fê
\8d\87\82Í
586 // InternalHeader
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
587 Result := InternalHeader(
588 '<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">' +
592 // GetRes
\82ð
\8cÄ
\82Î
\82ê
\82é
\82±
\82Æ
\82ª
\97\
\91z
\82³
\82ê
\82é
\82Ì
\82Å FDat
\82ð
\90¶
\90¬
\82µ
\82Ä
\82¨
\82
601 // *************************************************************************
602 //
\83X
\83\8c\83b
\83h
\82Ì
\83t
\83b
\83^ html
\82ð
\97v
\8b\81\82³
\82ê
\82½
603 // *************************************************************************
604 function TMachiBBSThreadItem.GetFooter(
605 inOptionalFooter : string
609 //
\93Æ
\8e©
\82É
\83t
\83B
\83\8b\83^
\83\8a\83\93\83O
\82ð
\8ds
\82í
\82È
\82¢
\8fê
\8d\87\82Í
610 // InternalFooter
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
611 Result := InternalFooter( inOptionalFooter );
613 //
\82à
\82¤ GetRes
\82Í
\8cÄ
\82Î
\82ê
\82È
\82¢
\82Æ
\8ev
\82¤
\82Ì
\82Å FDat
\82ð
\8aJ
\95ú
\82µ
\82Ä
\82¨
\82
621 // *************************************************************************
622 //
\82±
\82Ì ThreadItem
\82ª
\91®
\82·
\82é
\94Â
\82Ì URL
\82ð
\97v
\8b\81\82³
\82ê
\82½
623 // *************************************************************************
624 function TMachiBBSThreadItem.GetBoardURL : string;
627 uriList : TStringList;
630 if Copy( URL, Length( URL ), 1 ) = '/' then
631 uri := TIdURI.Create( URL )
633 uri := TIdURI.Create( URL + '/' );
634 uriList := TStringList.Create;
638 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
639 FileName := uriList.Values[ 'KEY' ] + '.dat';
640 // http://hokkaido.machi.to/bbs/read.pl?BBS=hokkaidou&KEY=1061764446
641 // http://hokkaido.machi.to/hokkaidou/
642 Result := CreateResultString(
643 uri.Protocol + '://' + uri.Host + '/' + uriList.Values[ 'BBS' ] + '/' );
651 // *************************************************************************
652 //
\82Ü
\82¿BBS
\82Ì HTML
\82ð 2ch
\82Ì dat
\8c`
\8e®
\82É
653 // *************************************************************************
654 procedure TMachiBBSThreadItem.To2chDat(
655 ioHTML : TStringList;
656 inStartNo : Integer = 1
665 MAIL_TAG = '<a href="mailto:';
668 //===== 2ch
\82Ì dat
\8c`
\8e®
\82É
\95Ï
\8a·
669 //
\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
670 ioHTML.Text := CustomStringReplace( ioHTML.Text, #13#10, '');
671 //StringReplace( ioHTML.Text, #13#10, '', [rfReplaceAll] );
672 //
\91ã
\82í
\82è
\82É <dt>
\82ð
\8ds
\82Ì
\8bæ
\90Ø
\82è
\82É
\82·
\82é
673 ioHTML.Text := CustomStringReplace( ioHTML.Text, '<dt>', #10 );
674 //StringReplace( ioHTML.Text, '<dt>', #10, [rfReplaceAll] );
675 // <dt>
\82©
\82ç
\8en
\82Ü
\82Á
\82Ä
\82¢
\82é
\82Ì
\82Å
\8dÅ
\8f\89\82Í
\8bó
\82Ì
\82Í
\82¸
676 if Length( ioHTML[ 0 ] ) = 0 then
679 //
\8cy
\82
\82 \82Ú
\81[
\82ñ
\83`
\83F
\83b
\83N
680 //
\81¦
\91å
\8eG
\94c
\82¾
\82©
\82ç
\82¿
\82á
\82ñ
\82Æ
\8fo
\97\88\82Ä
\82È
\82¢
\82©
\82à
683 while i < ioHTML.Count do begin
684 foundPos := AnsiPos( ' ', ioHTML[ i ] );
685 if foundPos > 0 then begin
686 no := StrToInt( Copy( ioHTML[ i ], 1, foundPos - 1 ) );
687 if inStartNo < no then
688 ioHTML.Insert( i, '<><><><>' );
694 //
\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Å
697 //
\83g
\83\8a\83b
\83v
\82Ì
\8cã
\82Ì '<b> </b>'
\82ð
\8bó
\82É
698 ioHTML.Text := CustomStringReplace( ioHTML.Text, '<b> </b>', '', true );
699 //StringReplace( ioHTML.Text, '<b> </b>', '', [rfReplaceAll, rfIgnoreCase] );
700 // '<b>'
\82Í
\83\81\81[
\83\8b\82Æ
\96¼
\91O
\82Ì
\8bæ
\90Ø
\82è
701 ioHTML.Text := CustomStringReplace( ioHTML.Text, '<b>', '<>', true );
702 //StringReplace( ioHTML.Text, '<b>', '<>', [rfReplaceAll, rfIgnoreCase] );
703 //
\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É
704 ioHTML.Text := CustomStringReplace( ioHTML.Text, '</b></a>', '<>', true );
705 //StringReplace( ioHTML.Text, '</b></a>', '<>', [rfReplaceAll, rfIgnoreCase] );
706 ioHTML.Text := CustomStringReplace( ioHTML.Text, '</b>', '<>', true );
707 //StringReplace( ioHTML.Text, '</b>', '<>', [rfReplaceAll, rfIgnoreCase] );
708 // '<dd>'
\82ð
\96{
\95¶
\82Æ
\82Ì
\8bæ
\90Ø
\82è
\82É
709 ioHTML.Text := CustomStringReplace( ioHTML.Text, '<dd>', '<>', true );
710 //StringReplace( ioHTML.Text, '<dd>', '<>', [rfReplaceAll, rfIgnoreCase] );
712 res := TStringList.Create;
714 bound := ioHTML.Count - 1;
715 for i := 0 to bound do begin
716 res.Text := CustomStringReplace( ioHTML[ i ], '<>', #10 );
717 //StringReplace( ioHTML[ i ], '<>', #10, [rfReplaceAll] );
718 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ß
719 foundPos := AnsiPos( MAIL_TAG, res[ 0 ] );
720 if foundPos > 0 then begin
721 //
\83\81\81[
\83\8b\83A
\83h
\83\8c\83X
\82ð
\94²
\82«
\8fo
\82·
722 foundPos := foundPos + Length( MAIL_TAG );
723 res[ 0 ] := Copy( res[ 0 ], foundPos, Length( res[ 0 ] ) );
724 strTmp := Copy( res[ 0 ], 1, AnsiPos( '">', res[ 0 ] ) - 1 );
725 //
\83\81\81[
\83\8b\82Æ
\96¼
\91O
\82ª
\8bt
\82È
\82Ì
\82Å
\82Ð
\82Á
\82
\82è
\95Ô
\82µ
\82Ä
\96ß
\82·
726 res[ 0 ] := res[ 1 ];
729 //
\83\81\81[
\83\8b\82Æ
\96¼
\91O
\82ª
\8bt
\82È
\82Ì
\82Å
\82Ð
\82Á
\82
\82è
\95Ô
\82·
730 res[ 0 ] := res[ 1 ];
733 res[ 2 ] := StringReplace( res[ 2 ], '[', 'IP:', [] );
734 res[ 2 ] := StringReplace( res[ 2 ], ']', '', [] );
736 ioHTML[ i ] := CustomStringReplace( res.Text, #13#10, '<>');
737 //StringReplace( res.Text, #13#10, '<>', [rfReplaceAll] );
745 // *************************************************************************
747 // *************************************************************************
748 procedure TMachiBBSThreadItem.LoadDat;
751 if FDat = nil then begin
752 if IsLogFile then begin
753 // dat
\82Ì
\93Ç
\82Ý
\8d\9e\82Ý
754 FDat := TStringList.Create;
755 FDat.LoadFromFile( FilePath );
761 // *************************************************************************
763 // *************************************************************************
764 procedure TMachiBBSThreadItem.FreeDat;
767 if FDat <> nil then begin
774 // *************************************************************************
775 //
\88À
\91S
\82È( '/'
\82Å
\8fI
\82í
\82é )
\93Ç
\82Ý
\8d\9e\82Ý
\82Ì URL
776 // *************************************************************************
777 function TMachiBBSThreadItem.ReadURL : string;
780 uriList : TStringList;
784 foundPos := AnsiPos( '?', URL );
785 if foundPos > 0 then begin
786 uri := TIdURI.Create( URL );
787 uriList := TStringList.Create;
789 ExtractHttpFields( ['&'], [], Copy( URL, foundPos + 1, MaxInt ), uriList );
791 uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
792 'BBS=' + uriList.Values[ 'BBS' ] + '&KEY=' + uriList.Values[ 'KEY' ];
801 // *************************************************************************
802 // TThreadItem
\82ª
\90¶
\90¬
\82³
\82ê
\82½
\8fê
\8d\87\82Ì
\8f\88\92u(TMachiBBSThreadItem
\82ð
\90¶
\90¬
\82·
\82é)
803 // *************************************************************************
804 procedure ThreadItemOnCreateOfTMachiBBSThreadItem(
808 threadItem : TMachiBBSThreadItem;
811 threadItem := TMachiBBSThreadItem.Create( inInstance );
812 ThreadItemSetLong( inInstance, tipContext, DWORD( threadItem ) );
816 // *************************************************************************
817 // TThreadItem
\82ª
\94j
\8aü
\82³
\82ê
\82½
\8fê
\8d\87\82Ì
\8f\88\92u(TMachiBBSThreadItem
\82ð
\94j
\8aü
\82·
\82é)
818 // *************************************************************************
819 procedure ThreadItemOnDisposeOfTMachiBBSThreadItem(
823 threadItem : TMachiBBSThreadItem;
826 threadItem := TMachiBBSThreadItem( ThreadItemGetLong( inInstance, tipContext ) );
831 // =========================================================================
832 // TMachiBBSBoardItem
833 // =========================================================================
835 // *************************************************************************
836 //
\83R
\83\93\83X
\83g
\83\89\83N
\83^
837 // *************************************************************************
838 constructor TMachiBBSBoardItem.Create(
843 uriList : TStringList;
848 OnDownload := Download;
849 OnCreateThread := CreateThread;
850 OnEnumThread := EnumThread;
851 OnFileName2ThreadURL := ToThreadURL;
854 FIsTemporary := False;
857 uri := TIdURI.Create( SubjectURL );
858 uriList := TStringList.Create;
860 ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
861 // http://hokkaido.machi.to/hokkaidou/subject.txt
862 FilePath := MyLogFolder + uriList[ 1 ] + '\' + uri.Document;
863 IsLogFile := FileExists( FilePath );
871 // *************************************************************************
872 //
\83f
\83X
\83g
\83\89\83N
\83^
873 // *************************************************************************
874 destructor TMachiBBSBoardItem.Destroy;
877 if FDat <> nil then begin
885 //
\88ê
\8e\9e\83t
\83@
\83C
\83\8b\82Ì
\8fê
\8d\87\82Í
\8dí
\8f\9c\82·
\82é
887 DeleteFile( FilePath );
893 // *************************************************************************
894 //
\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½
895 // *************************************************************************
896 function TMachiBBSBoardItem.Download : TDownloadState;
900 responseCode : Longint;
902 uriList : TStringList;
907 if FDat <> nil then begin
914 FDat := TStringList.Create;
915 uri := TIdURI.Create( SubjectURL );
916 uriList := TStringList.Create;
917 //
\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Í
918 // InternalDownload
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
919 modified := LastModified;
920 responseCode := InternalDownload( PChar( uri.URI ), modified, downResult );
922 if responseCode = 200 then begin
924 //
\83p
\83X
\82ð
\8eZ
\8fo
925 ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
926 if MyLogFolder = '' then begin
927 //
\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¶
928 FilePath := TemporaryFile;
929 FIsTemporary := True;
931 FilePath := MyLogFolder + uriList[ 1 ] + '\' + uri.Document;
932 FIsTemporary := False
935 //
\95Û
\91¶
\97p
\82Ì
\83f
\83B
\83\8c\83N
\83g
\83\8a\82ð
\8c@
\82é
936 ForceDirectoriesEx( Copy( FilePath, 1, LastDelimiter( '\', FilePath ) ) );
938 FDat.Text := string( downResult );
940 FDat.SaveToFile( FilePath );
944 LastModified := modified;
950 Result := dsComplete;
953 DisposeResultString( downResult );
958 // *************************************************************************
959 //
\83X
\83\8c\97§
\82Ä
\82ð
\8ew
\8e¦
\82³
\82ê
\82½
960 // *************************************************************************
961 function TMachiBBSBoardItem.CreateThread(
962 inSubject : string; //
\83X
\83\8c\83^
\83C
963 inName : string; //
\96¼
\91O(
\83n
\83\93\83h
\83\8b)
964 inMail : string; //
\83\81\81[
\83\8b\83A
\83h
\83\8c\83X
965 inMessage : string //
\96{
\95¶
966 ) : TDownloadState; //
\8f\91\82«
\8d\9e\82Ý
\82ª
\90¬
\8c÷
\82µ
\82½
\82©
\82Ç
\82¤
\82©
972 uriList : TStringList;
975 uri := TIdURI.Create( URL );
976 uriList := TStringList.Create;
980 Copy( uri.Params, AnsiPos( '?', uri.Params ) + 1, Length( uri.Params ) ), uriList );
982 postURL := uri.Protocol + '://' + uri.Host + '/bbs/write.cgi';
984 'SUBJECT=' + HttpEncode( inSubject ) +
985 '&NAME=' + HttpEncode( inName ) +
986 '&MAIL=' + HttpEncode( inMail ) +
987 '&MESSAGE=' + HttpEncode( inMessage ) +
988 '&BBS=' + uriList[ 1 ] +
989 '&TIME=' + IntToStr( DateTimeToUnix( Now ) ) +
990 '&submit=' + HttpEncode( '
\90V
\8bK
\8f\91\82«
\8d\9e\82Ý' );
992 //
\93Æ
\8e©
\82É
\92Ê
\90M
\82µ
\82È
\82¢
\8fê
\8d\87\82Í InternalPost
\82É
\94C
\82¹
\82é
\82±
\82Æ
\82ª
\8fo
\97\88\82é
993 InternalPost( PChar( postURL ), PChar( postData ), postResult );
994 DisposeResultString( postResult );
1004 // *************************************************************************
1005 //
\83X
\83\8c\88ê
\97\97\82Ì URL
\82©
\82ç
\83X
\83\8c\83b
\83h
\82Ì URL
\82ð
\93±
\82«
\8fo
\82·
1006 // *************************************************************************
1007 function TMachiBBSBoardItem.ToThreadURL(
1008 inFileName : string //
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\96¼
1009 ) : string; //
\83X
\83\8c\83b
\83h
\82Ì URL
1013 uriList : TStringList;
1017 found := AnsiPos( '.', inFileName );
1019 inFileName := Copy( inFileName, 1, found - 1 );
1021 uri := TIdURI.Create( SubjectURL );
1022 uriList := TStringList.Create;
1025 // http://hokkaido.machi.to/hokkaidou/
1026 // http://hokkaido.machi.to/bbs/read.pl?BBS=hokkaidou&KEY=1061764446&LAST=50
1027 ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
1028 threadURL := uri.Protocol + '://' + uri.Host + '/bbs/read.pl?' +
1029 'BBS=' + uriList[ 1 ] + '&KEY=' + inFileName + '&LAST=50';
1030 Result := threadURL;
1041 // *************************************************************************
1042 //
\82±
\82Ì
\94Â
\82É
\82¢
\82
\82Â
\82Ì
\83X
\83\8c\82ª
\82 \82é
\82©
\97v
\8b\81\82³
\82ê
\82½
1043 // *************************************************************************
1044 procedure TMachiBBSBoardItem.EnumThread(
1045 inCallBack : TBoardItemEnumThreadCallBack
1049 uriList : TStringList;
1053 if FDat = nil then begin
1054 FDat := TStringList.Create;
1056 uri := TIdURI.Create( SubjectURL );
1057 uriList := TStringList.Create;
1059 //
\83p
\83X
\82ð
\8eZ
\8fo
1060 ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
1061 // http://hokkaido.machi.to/hokkaidou/subject.txt
1062 FilePath := MyLogFolder + uriList[ 1 ] + '\' + uri.Document;
1063 if FileExists( FilePath ) then
1064 //
\93Ç
\82Ý
\8d\9e\82Ý
1065 FDat.LoadFromFile( FilePath );
1072 //
\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é
1073 inherited EnumThread( inCallBack, CustomStringReplace( FDat.Text, ',', '<>' ) );
1079 // *************************************************************************
1080 //
\83X
\83\8c\88ê
\97\97\82Ì URL
\82ð
\8b\81\82ß
\82é
1081 // *************************************************************************
1082 function TMachiBBSBoardItem.SubjectURL : string;
1085 uriList : TStringList;
1088 uri := TIdURI.Create( URL );
1089 uriList := TStringList.Create;
1091 if uri.Document <> SUBJECT_NAME then begin
1092 if Copy( URL, Length( URL ), 1 ) = '/' then
1093 Result := URL + SUBJECT_NAME
1095 Result := URL + '/' + SUBJECT_NAME;
1097 //
\82±
\82±
\82É
\82Í
\97\88\82È
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
1107 // *************************************************************************
1108 // TBoardItem
\82ª
\90¶
\90¬
\82³
\82ê
\82½
\8fê
\8d\87\82Ì
\8f\88\92u(TMachiBBSBoardItem
\82ð
\90¶
\90¬
\82·
\82é)
1109 // *************************************************************************
1110 procedure BoardItemOnCreateOfTMachiBBSBoardItem(
1114 boardItem : TMachiBBSBoardItem;
1117 boardItem := TMachiBBSBoardItem.Create( inInstance );
1118 BoardItemSetLong( inInstance, bipContext, DWORD( boardItem ) );
1122 // *************************************************************************
1123 // TBoardItem
\82ª
\94j
\8aü
\82³
\82ê
\82½
\8fê
\8d\87\82Ì
\8f\88\92u(TMachiBBSBoardItem
\82ð
\94j
\8aü
\82·
\82é)
1124 // *************************************************************************
1125 procedure BoardItemOnDisposeOfTMachiBBSBoardItem(
1129 boardItem : TMachiBBSBoardItem;
1132 boardItem := TMachiBBSBoardItem( BoardItemGetLong( inInstance, bipContext ) );
1139 // =========================================================================
1140 //
\83G
\83\93\83g
\83\8a\83|
\83C
\83\93\83g
1141 // =========================================================================
1143 ul_reason_for_call : DWORD
1149 case ul_reason_for_call of
1154 module := GetModuleHandle( nil );
1156 LoadInternalAPI( module );
1157 LoadInternalFilePathAPI( module );
1158 LoadInternalThreadItemAPI( module );
1159 LoadInternalBoardItemAPI( module );
1161 // =====
\83C
\83\93\83X
\83^
\83\93\83X
\82Ì
\8eæ
\82è
\88µ
\82¢
\82ð TThreadItem
\82©
\82ç TMachiBBSThreadItem
\82É
\95Ï
\8dX
\82·
\82é
1162 ThreadItemOnCreate := ThreadItemOnCreateOfTMachiBBSThreadItem;
1163 ThreadItemOnDispose := ThreadItemOnDisposeOfTMachiBBSThreadItem;
1164 // =====
\83C
\83\93\83X
\83^
\83\93\83X
\82Ì
\8eæ
\82è
\88µ
\82¢
\82ð TBoardItem
\82©
\82ç TMachiBBSBoardItem
\82É
\95Ï
\8dX
\82·
\82é
1165 BoardItemOnCreate := BoardItemOnCreateOfTMachiBBSBoardItem;
1166 BoardItemOnDispose := BoardItemOnDisposeOfTMachiBBSBoardItem;
1185 DllProc := @DLLEntry;
1186 DLLEntry( DLL_PROCESS_ATTACH );