6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent, IdComponent,
8 IdTCPConnection, IdTCPClient, IdHTTP, IDException, StdCtrls, IniFiles,
9 GikoSystem, BoardGroup;
12 TNewBoardItem = record
13 FResponseCode: Integer;
17 TNewBoardDialog = class(TForm)
20 UpdateButton: TButton;
23 IdAntiFreeze: TIdAntiFreeze;
25 BoardURLComboBox: TComboBox;
27 EditIgnoreListsButton: TButton;
29 procedure UpdateButtonClick(Sender: TObject);
30 procedure StopButtonClick(Sender: TObject);
31 procedure CloseButtonClick(Sender: TObject);
32 procedure FormCreate(Sender: TObject);
33 procedure EditIgnoreListsButtonClick(Sender: TObject);
34 procedure FormClose(Sender: TObject; var Action: TCloseAction);
37 IgnoreLists : TStringList;
39 function BoardDownload(const URL: String): TNewBoardItem;
40 function BoardLoardFromFile(const FilePath: String): String;
41 function UpdateURL(s: string): boolean;
42 procedure SetIgnoreCategory(b: boolean);
43 procedure EditIgnoreList(Sender: TObject);
44 procedure UpdateIgnoreList(Sender: TObject);
50 NewBoardDialog: TNewBoardDialog;
55 uses Giko, IdHeaderList, MojuUtils, GikoDataModule;
59 procedure TNewBoardDialog.UpdateButtonClick(Sender: TObject);
63 protocol, host, path, document, port, bookmark: String;
67 GikoSys.Setting.BoardURLSelected := BoardURLComboBox.ItemIndex + 1;
69 UpdateButton.Enabled := False;
70 StopButton.Enabled := True;
71 CloseButton.Enabled := False;
72 EditIgnoreListsButton.Enabled := False;
73 URL := BoardURLComboBox.Text;
74 GikoSys.ParseURI(URL, protocol, host, path, document, port, bookmark);
75 if (protocol = '') then begin
76 Item.FContent := BoardLoardFromFile(URL);
77 end else if (AnsiPos('http', protocol) > 0) then begin
78 Item := BoardDownload(URL);
80 StopButton.Enabled := False;
83 if Item.FContent <> '' then begin
84 GikoDM.TabsSaveAction.Tag := 1;
85 GikoDM.TabsOpenAction.Tag := 1;
86 GikoDM.TabsSaveAction.Execute;
87 if (UpdateURL(Item.FContent)) then begin
90 GikoDM.TabsSaveAction.Tag := 0;
91 GikoDM.TabsOpenAction.Tag := 0;
93 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ª
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½[' + IntToStr(Item.FResponseCode) + ']');
95 UpdateButton.Enabled := True;
96 StopButton.Enabled := False;
97 CloseButton.Enabled := True;
98 EditIgnoreListsButton.Enabled := True;
102 procedure TNewBoardDialog.StopButtonClick(Sender: TObject);
105 Indy.DisconnectSocket;
108 procedure TNewBoardDialog.CloseButtonClick(Sender: TObject);
113 function TNewBoardDialog.BoardDownload(const URL: String): TNewBoardItem;
115 Stream: TMemoryStream;
120 Indy.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
121 Indy.ProxyParams.BasicAuthentication := False;
122 if GikoSys.Setting.ReadProxy then begin
123 if GikoSys.Setting.ProxyProtocol then
124 Indy.ProtocolVersion := pv1_1
126 Indy.ProtocolVersion := pv1_0;
127 Indy.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
128 Indy.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
129 Indy.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
130 Indy.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
131 if GikoSys.Setting.ReadProxyUserID <> '' then
132 Indy.ProxyParams.BasicAuthentication := True;
134 if GikoSys.Setting.Protocol then
135 Indy.ProtocolVersion := pv1_1
137 Indy.ProtocolVersion := pv1_0;
138 Indy.ProxyParams.ProxyServer := '';
139 Indy.ProxyParams.ProxyPort := 80;
140 Indy.ProxyParams.ProxyUsername := '';
141 Indy.ProxyParams.ProxyPassword := '';
143 //URL := GikoSys.Setting.BoardURL2ch;
144 //URL := BoardURLComboBox.Text;
145 Indy.Request.UserAgent := GikoSys.GetUserAgent;
146 Indy.Request.Referer := '';
147 Indy.Request.AcceptEncoding := 'gzip';
149 Indy.Request.CacheControl := 'no-cache';
150 Indy.Request.CustomHeaders.Add('Pragma: no-cache');
153 Stream := TMemoryStream.Create;
156 MessageMemo.Lines.Add('
\88È
\89º
\82Ì
\8fê
\8f\8a\82©
\82ç
\8eæ
\93¾
\82µ
\82Ü
\82·');
157 //MessageMemo.Lines.Add(GikoSys.Setting.BoardURL2ch);
158 MessageMemo.Lines.Add(URL);
159 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ð
\8aJ
\8en
\82µ
\82Ü
\82·');
160 IdAntiFreeze.Active := True;
162 Indy.Get(URL, Stream);
164 IdAntiFreeze.Active := False;
166 Result.FContent := GikoSys.GzipDecompress(Stream, Indy.Response.ContentEncoding);
167 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ª
\8a®
\97¹
\82µ
\82Ü
\82µ
\82½');
169 on E: EIdConnectException do begin
170 MessageMemo.Lines.Add('');
171 MessageMemo.Lines.Add('
\90Ú
\91±
\82ª
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\89ñ
\90ü
\82â
\83v
\83\8d\83L
\83V
\81AFW
\82Ì
\8fó
\91Ô
\82ð
\92²
\82×
\82Ä
\82
\82¾
\82³
\82¢');
172 MessageMemo.Lines.Add('FW
\82ð
\93ü
\82ê
\82Ä
\82¢
\82é
\90l
\82Í
\90Ý
\92è
\82ð
\8am
\94F
\82µ
\82Ä
\82
\82¾
\82³
\82¢');
173 MessageMemo.Lines.Add('NEC
\82ÌPC
\82Ì
\8fê
\8d\87\82ÍPC GATE
\82ª
\88«
\82³
\82ð
\82µ
\82Ä
\82¢
\82é
\89Â
\94\
\90«
\82ª
\8d\82\82¢
\82Å
\82·');
174 MessageMemo.Lines.Add('Message: ' + E.Message);
176 on E: Exception do begin
178 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ð
\92\86\92f
\82µ
\82Ü
\82µ
\82½')
180 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ª
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½');
181 MessageMemo.Lines.Add('ResponseCode: ' + IntToStr(Indy.ResponseCode));
182 MessageMemo.Lines.Add('Message: ' + E.Message);
183 MessageMemo.Lines.Add('------------------------');
184 for i := 0 to Indy.Response.RawHeaders.Count - 1 do begin
185 s := Indy.Response.RawHeaders.Names[i];
186 s := s + ': ' + Indy.Response.RawHeaders.Values[s];
187 MessageMemo.Lines.Add(s);
189 MessageMemo.Lines.Add('------------------------');
193 Result.FResponseCode := Indy.ResponseCode;
199 function TNewBoardDialog.UpdateURL(s: string): boolean;
213 oldURLs : TStringList;
214 newURLs : TStringList;
217 MessageMemo.Lines.Add('
\90V
\94Â
\81A
\94ÂURL
\95Ï
\8dX
\83`
\83F
\83b
\83N
\82ð
\8aJ
\8en
\82µ
\82Ü
\82·');
218 MessageMemo.Lines.Add('');
219 s := CustomStringReplace(s, '<B>', '<b>', true);
220 s := CustomStringReplace(s, '<BR>', '<br>', true);
221 s := CustomStringReplace(s, '</B>', '</b>', true);
222 s := CustomStringReplace(s, '<A HREF', '<a href', true);
223 s := CustomStringReplace(s, '</A', '</a', true);
226 oldURLs := TStringList.Create;
227 newURLs := TStringList.Create;
231 GikoSys.ForceDirectoriesEx(GikoSys.GetConfigDir);
232 ini := TMemIniFile.Create(GikoSys.GetBoardFileName);
235 //
\8dí
\8f\9c\83I
\83v
\83V
\83\87\83\93\82ª
\91I
\91ð
\82³
\82ê
\82Ä
\82¢
\82é
\8fê
\8d\87\82Í
\83N
\83\8a\83A
240 idx1 := AnsiPos('<b>', s);
241 idx2 := AnsiPos('<a', s);
242 if (idx1 = 0) and (idx2 = 0) then Break;
244 if idx1 < idx2 then begin
246 idx := AnsiPos('</b>', s);
247 if idx = 0 then begin
248 s := Copy(s, idx1 + 4, Length(s));
251 tmp := Copy(s, idx1, (idx - idx1) + 4);
252 tmp := CustomStringReplace(tmp, '<b>', '');
253 tmp := CustomStringReplace(tmp, '</b>', '');
255 for i := 0 to IgnoreLists.Count - 1 do begin
256 if tmp = Trim(IgnoreLists[i]) then begin
258 s := Copy(s, idx + 5, Length(s));
266 if (tmp = '
\82¨
\82·
\82·
\82ß') or
267 (tmp = '
\93Á
\95Ê
\8aé
\89æ') or
268 (tmp = '
\82Ü
\82¿
\82a
\82a
\82r') or
269 (tmp = '
\83`
\83\83\83b
\83g') or
270 (tmp = '
\82¨
\8aG
\82©
\82«') or
271 (tmp = '
\89^
\89c
\88Ä
\93à') or
272 (tmp = '
\83c
\81[
\83\8b\97Þ') or
273 (tmp = '
\91¼
\82Ì
\83T
\83C
\83g') then begin
275 s := Copy(s, idx + 5, Length(s));
279 s := Copy(s, idx + 5, Length(s));
283 if cate = '' then begin
284 s := Copy(s, idx2 + 2, Length(s));
286 idx := AnsiPos('</a>', s);
287 tmp := Copy(s, idx2, (idx - idx2) + 4);
288 tmp := CustomStringReplace(tmp, '<a href=', '');
289 tmp := CustomStringReplace(tmp, '</a>', '');
290 tmp := CustomStringReplace(tmp, 'TARGET=_blank', '');
291 i := AnsiPos('>', tmp);
293 URL := Copy(tmp, 1, i - 1);
294 Title := Copy(tmp, i + 1, Length(tmp));
295 Board := BBSs[ 0 ].FindBoardFromTitle(Title);
296 if Board = nil then begin
297 MessageMemo.Lines.Add('
\90V
\94Â
\92Ç
\89Á
\81u' + Title + '(' + URL + ')
\81v');
298 ini.WriteString(cate, Title, URL);
301 if Board.URL <> URL then begin
302 MessageMemo.Lines.Add('URL
\95Ï
\8dX
\81u' + Board.Title + '(' + URL +')
\81v');
303 ini.WriteString(cate, Title, URL);
304 oldURLs.Add(Board.URL);
308 ini.WriteString(cate, Title, URL);
312 s := Copy(s, idx2 + 2, Length(s));
315 s := Copy(s, idx + 5, Length(s));
324 MessageMemo.Lines.Add('');
326 GikoForm.FavoritesURLReplace(oldURLs, newURLs);
327 GikoForm.RoundListURLReplace(oldURLs, newURLs);
328 GikoForm.TabFileURLReplace(oldURLs, newURLs);
329 MessageMemo.Lines.Add('
\90V
\94Â
\81A
\94ÂURL
\95Ï
\8dX
\83`
\83F
\83b
\83N
\82ª
\8a®
\97¹
\82µ
\82Ü
\82µ
\82½');
330 MessageMemo.Lines.Add('
\81u
\95Â
\82¶
\82é
\81v
\83{
\83^
\83\93\82ð
\89\9f\82µ
\82Ä
\82
\82¾
\82³
\82¢');
332 MessageMemo.Lines.Add('
\90V
\94Â
\81A
\94ÂURL
\95Ï
\8dX
\82Í
\82 \82è
\82Ü
\82¹
\82ñ
\82Å
\82µ
\82½');
340 procedure TNewBoardDialog.FormCreate(Sender: TObject);
342 StopButton.Enabled := False;
343 BoardURLComboBox.Clear;
344 BoardURLComboBox.Items.AddStrings(GikoSys.Setting.BoardURLs);
346 BoardURLComboBox.ItemIndex := GikoSys.Setting.BoardURLSelected - 1;
348 BoardURLComboBox.ItemIndex := 0;
350 SetIgnoreCategory(false);
352 //
\94Â
\8dX
\90V
\82Ì
\8f\9c\8aO
\83J
\83e
\83S
\83\8a\83\8a\83X
\83g
\82Ì
\93o
\98^
353 {['
\82¨
\82·
\82·
\82ß', '
\93Á
\95Ê
\8aé
\89æ', '
\82Ü
\82¿
\82a
\82a
\82r', '
\83`
\83\83\83b
\83g', '
\82¨
\8aG
\82©
\82«', '
\89^
\89c
\88Ä
\93à', '
\83c
\81[
\83\8b\97Þ', '
\91¼
\82Ì
\83T
\83C
\83g']}
354 procedure TNewBoardDialog.SetIgnoreCategory(b: boolean);
356 IgnoreLists := TStringList.Create;
357 if not( FileExists(GikoSys.Setting.GetIgnoreFileName) ) or ( b )then begin
358 IgnoreLists.Add('
\82¨
\82·
\82·
\82ß');
359 IgnoreLists.Add('
\93Á
\95Ê
\8aé
\89æ');
360 IgnoreLists.Add('
\82Ü
\82¿
\82a
\82a
\82r');
361 IgnoreLists.Add('
\83`
\83\83\83b
\83g');
362 IgnoreLists.Add('
\82¨
\8aG
\82©
\82«');
363 IgnoreLists.Add('
\89^
\89c
\88Ä
\93à');
364 IgnoreLists.Add('
\83c
\81[
\83\8b\97Þ');
365 IgnoreLists.Add('
\91¼
\82Ì
\83T
\83C
\83g');
368 IgnoreLists.LoadFromFile(GikoSys.Setting.GetIgnoreFileName);
371 SetIgnoreCategory(true);
376 procedure TNewBoardDialog.EditIgnoreListsButtonClick(Sender: TObject);
378 EditIgnoreList(Sender);
379 EditIgnoreListsButton.OnClick := UpdateIgnoreList;
381 procedure TNewBoardDialog.EditIgnoreList(Sender: TObject);
385 EditIgnoreListsButton.Caption := '
\8f\9c\8aO
\83J
\83e
\83S
\83\8a\81[
\8dX
\90V';
386 Label2.Caption := '
\8ae
\82P
\8ds
\82É
\83J
\83e
\83S
\83\8a\96¼
\82ð
\8bL
\93ü
\82µ
\82Ä
\82
\82¾
\82³
\82¢
\81B
\81i
\89ü
\8ds
\82ÍCtrl+Enter
\81j';
387 UpdateButton.Enabled := false;
388 //MessageMemo.ReadOnly := false;
390 for i := 0 to IgnoreLists.Count - 1 do
391 MessageMemo.Lines.Add(IgnoreLists[i]);
393 procedure TNewBoardDialog.UpdateIgnoreList(Sender: TObject);
397 Label2.Caption := '';
398 UpdateButton.Enabled := true;
399 EditIgnoreListsButton.Caption := '
\8f\9c\8aO
\83J
\83e
\83S
\83\8a\81[
\95Ò
\8fW';
401 for i := 0 to MessageMemo.Lines.Count - 1 do
402 IgnoreLists.Add(MessageMemo.Lines[i]);
403 IgnoreLists.SaveToFile(GikoSys.Setting.GetIgnoreFileName);
405 SetIgnoreCategory(false);
406 //MessageMemo.ReadOnly := true;
408 EditIgnoreListsButton.OnClick := EditIgnoreListsButtonClick;
411 procedure TNewBoardDialog.FormClose(Sender: TObject;
412 var Action: TCloseAction);
416 //!
\83\8d\81[
\83J
\83\8b\83t
\83@
\83C
\83\8b\82ð
\83\8d\81[
\83h
\82·
\82é
417 function TNewBoardDialog.BoardLoardFromFile(const FilePath: String): String;
422 //
\83t
\83@
\83C
\83\8b\82ª
\91¶
\8dÝ
\82µ
\82Ä
\82¢
\82é
\82©
\83`
\83F
\83b
\83N
423 if (FileExists(FilePath)) then begin
424 html := TStringList.Create();
426 html.LoadFromFile(FilePath);