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, MojuUtils;
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: TNewBoardItem;
40 procedure UpdateURL(s: string);
41 procedure SetIgnoreCategory(b: boolean);
42 procedure EditIgnoreList(Sender: TObject);
43 procedure UpdateIgnoreList(Sender: TObject);
49 NewBoardDialog: TNewBoardDialog;
54 uses Giko, IdHeaderList;
58 procedure TNewBoardDialog.UpdateButtonClick(Sender: TObject);
63 GikoSys.Setting.BoardURLSelected := BoardURLComboBox.ItemIndex + 1;
65 UpdateButton.Enabled := False;
66 StopButton.Enabled := True;
67 CloseButton.Enabled := False;
68 EditIgnoreListsButton.Enabled := False;
69 Item := BoardDownload;
70 StopButton.Enabled := False;
73 if Item.FContent <> '' then begin
74 GikoForm.TabsSaveAction.Tag := 1;
75 GikoForm.TabsOpenAction.Tag := 1;
76 GikoForm.TabsSaveAction.Execute;
77 UpdateURL(Item.FContent);
79 GikoForm.TabsSaveAction.Tag := 0;
80 GikoForm.TabsOpenAction.Tag := 0;
82 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ª
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½[' + IntToStr(Item.FResponseCode) + ']');
84 UpdateButton.Enabled := True;
85 StopButton.Enabled := False;
86 CloseButton.Enabled := True;
87 EditIgnoreListsButton.Enabled := True;
91 procedure TNewBoardDialog.StopButtonClick(Sender: TObject);
94 Indy.DisconnectSocket;
97 procedure TNewBoardDialog.CloseButtonClick(Sender: TObject);
102 function TNewBoardDialog.BoardDownload: TNewBoardItem;
105 Stream: TMemoryStream;
111 Indy.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
112 Indy.ProxyParams.BasicAuthentication := False;
113 if GikoSys.Setting.ReadProxy then begin
114 if GikoSys.Setting.ProxyProtocol then
115 Indy.ProtocolVersion := pv1_1
117 Indy.ProtocolVersion := pv1_0;
118 Indy.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
119 Indy.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
120 Indy.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
121 Indy.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
122 if GikoSys.Setting.ReadProxyUserID <> '' then
123 Indy.ProxyParams.BasicAuthentication := True;
125 if GikoSys.Setting.Protocol then
126 Indy.ProtocolVersion := pv1_1
128 Indy.ProtocolVersion := pv1_0;
129 Indy.ProxyParams.ProxyServer := '';
130 Indy.ProxyParams.ProxyPort := 80;
131 Indy.ProxyParams.ProxyUsername := '';
132 Indy.ProxyParams.ProxyPassword := '';
134 //URL := GikoSys.Setting.BoardURL2ch;
135 URL := BoardURLComboBox.Text;
136 Indy.Request.UserAgent := GikoSys.GetUserAgent;
137 Indy.Request.Referer := '';
138 Indy.Request.AcceptEncoding := 'gzip';
140 Indy.Request.CacheControl := 'no-cache';
141 Indy.Request.CustomHeaders.Add('Pragma: no-cache');
144 Stream := TMemoryStream.Create;
147 MessageMemo.Lines.Add('
\88È
\89º
\82Ì
\8fê
\8f\8a\82©
\82ç
\8eæ
\93¾
\82µ
\82Ü
\82·');
148 //MessageMemo.Lines.Add(GikoSys.Setting.BoardURL2ch);
149 MessageMemo.Lines.Add(URL);
150 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ð
\8aJ
\8en
\82µ
\82Ü
\82·');
151 IdAntiFreeze.Active := True;
153 Indy.Get(URL, Stream);
155 IdAntiFreeze.Active := False;
157 Result.FContent := GikoSys.GzipDecompress(Stream, Indy.Response.ContentEncoding);
158 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ª
\8a®
\97¹
\82µ
\82Ü
\82µ
\82½');
160 on E: EIdConnectException do begin
161 MessageMemo.Lines.Add('');
162 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¢');
163 MessageMemo.Lines.Add('FW
\82ð
\93ü
\82ê
\82Ä
\82¢
\82é
\90l
\82Í
\90Ý
\92è
\82ð
\8am
\94F
\82µ
\82Ä
\82
\82¾
\82³
\82¢');
164 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·');
165 MessageMemo.Lines.Add('Message: ' + E.Message);
167 on E: Exception do begin
169 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ð
\92\86\92f
\82µ
\82Ü
\82µ
\82½')
171 MessageMemo.Lines.Add('
\83_
\83E
\83\93\83\8d\81[
\83h
\82ª
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½');
172 MessageMemo.Lines.Add('ResponseCode: ' + IntToStr(Indy.ResponseCode));
173 MessageMemo.Lines.Add('Message: ' + E.Message);
174 MessageMemo.Lines.Add('------------------------');
175 for i := 0 to Indy.Response.RawHeaders.Count - 1 do begin
176 s := Indy.Response.RawHeaders.Names[i];
177 s := s + ': ' + Indy.Response.RawHeaders.Values[s];
178 MessageMemo.Lines.Add(s);
180 MessageMemo.Lines.Add('------------------------');
184 Result.FResponseCode := Indy.ResponseCode;
190 procedure TNewBoardDialog.UpdateURL(s: string);
205 oldURLs : TStringList;
206 newURLs : TStringList;
209 MessageMemo.Lines.Add('
\90V
\94Â
\81A
\94ÂURL
\95Ï
\8dX
\83`
\83F
\83b
\83N
\82ð
\8aJ
\8en
\82µ
\82Ü
\82·');
210 MessageMemo.Lines.Add('');
211 s := CustomStringReplace(s, '<B>', '<b>', true);
212 s := CustomStringReplace(s, '<BR>', '<br>', true);
213 s := CustomStringReplace(s, '</B>', '</b>', true);
214 s := CustomStringReplace(s, '<A HREF', '<a href', true);
215 s := CustomStringReplace(s, '</A', '</a', true);
218 oldURLs := TStringList.Create;
219 newURLs := TStringList.Create;
223 GikoSys.ForceDirectoriesEx(GikoSys.GetConfigDir);
224 ini := TMemIniFile.Create(GikoSys.GetBoardFileName);
227 //
\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
232 idx1 := AnsiPos('<b>', s);
233 idx2 := AnsiPos('<a', s);
234 if (idx1 = 0) and (idx2 = 0) then Break;
236 if idx1 < idx2 then begin
238 idx := AnsiPos('</b>', s);
239 if idx = 0 then begin
240 s := Copy(s, idx1 + 4, Length(s));
243 tmp := Copy(s, idx1, (idx - idx1) + 4);
244 tmp := CustomStringReplace(tmp, '<b>', '');
245 tmp := CustomStringReplace(tmp, '</b>', '');
247 for i := 0 to IgnoreLists.Count - 1 do begin
248 if tmp = Trim(IgnoreLists[i]) then begin
250 s := Copy(s, idx + 5, Length(s));
258 if (tmp = '
\82¨
\82·
\82·
\82ß') or
259 (tmp = '
\93Á
\95Ê
\8aé
\89æ') or
260 (tmp = '
\82Ü
\82¿
\82a
\82a
\82r') or
261 (tmp = '
\83`
\83\83\83b
\83g') or
262 (tmp = '
\82¨
\8aG
\82©
\82«') or
263 (tmp = '
\89^
\89c
\88Ä
\93à') or
264 (tmp = '
\83c
\81[
\83\8b\97Þ') or
265 (tmp = '
\91¼
\82Ì
\83T
\83C
\83g') then begin
267 s := Copy(s, idx + 5, Length(s));
271 s := Copy(s, idx + 5, Length(s));
275 if cate = '' then begin
276 s := Copy(s, idx2 + 2, Length(s));
278 idx := AnsiPos('</a>', s);
279 tmp := Copy(s, idx2, (idx - idx2) + 4);
280 tmp := CustomStringReplace(tmp, '<a href=', '');
281 tmp := CustomStringReplace(tmp, '</a>', '');
282 tmp := CustomStringReplace(tmp, 'TARGET=_blank', '');
283 i := AnsiPos('>', tmp);
285 URL := Copy(tmp, 1, i - 1);
286 Title := Copy(tmp, i + 1, Length(tmp));
287 Board := BBSs[ 0 ].FindBoardFromTitle(Title);
288 if Board = nil then begin
289 MessageMemo.Lines.Add('
\90V
\94Â
\92Ç
\89Á
\81u' + Title + '(' + URL + ')
\81v');
290 ini.WriteString(cate, Title, URL);
293 if Board.URL <> URL then begin
294 MessageMemo.Lines.Add('URL
\95Ï
\8dX
\81u' + Board.Title + '(' + URL +')
\81v');
295 ini.WriteString(cate, Title, URL);
296 oldURLs.Add(Board.URL);
300 ini.WriteString(cate, Title, URL);
304 s := Copy(s, idx2 + 2, Length(s));
307 s := Copy(s, idx + 5, Length(s));
316 MessageMemo.Lines.Add('');
318 GikoForm.FavoritesURLReplace(oldURLs, newURLs);
319 GikoForm.RoundListURLReplace(oldURLs, newURLs);
320 GikoForm.TabFileURLReplace(oldURLs, newURLs);
321 MessageMemo.Lines.Add('
\90V
\94Â
\81A
\94ÂURL
\95Ï
\8dX
\83`
\83F
\83b
\83N
\82ª
\8a®
\97¹
\82µ
\82Ü
\82µ
\82½');
322 MessageMemo.Lines.Add('
\81u
\95Â
\82¶
\82é
\81v
\83{
\83^
\83\93\82ð
\89\9f\82µ
\82Ä
\82
\82¾
\82³
\82¢');
324 MessageMemo.Lines.Add('
\90V
\94Â
\81A
\94ÂURL
\95Ï
\8dX
\82Í
\82 \82è
\82Ü
\82¹
\82ñ
\82Å
\82µ
\82½');
331 procedure TNewBoardDialog.FormCreate(Sender: TObject);
333 StopButton.Enabled := False;
334 BoardURLComboBox.Clear;
335 BoardURLComboBox.Items.AddStrings(GikoSys.Setting.BoardURLs);
337 BoardURLComboBox.ItemIndex := GikoSys.Setting.BoardURLSelected - 1;
339 BoardURLComboBox.ItemIndex := 0;
341 SetIgnoreCategory(false);
343 //
\94Â
\8dX
\90V
\82Ì
\8f\9c\8aO
\83J
\83e
\83S
\83\8a\83\8a\83X
\83g
\82Ì
\93o
\98^
344 {['
\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']}
345 procedure TNewBoardDialog.SetIgnoreCategory(b: boolean);
347 IgnoreLists := TStringList.Create;
348 if not( FileExists(GikoSys.Setting.GetIgnoreFileName) ) or ( b )then begin
349 IgnoreLists.Add('
\82¨
\82·
\82·
\82ß');
350 IgnoreLists.Add('
\93Á
\95Ê
\8aé
\89æ');
351 IgnoreLists.Add('
\82Ü
\82¿
\82a
\82a
\82r');
352 IgnoreLists.Add('
\83`
\83\83\83b
\83g');
353 IgnoreLists.Add('
\82¨
\8aG
\82©
\82«');
354 IgnoreLists.Add('
\89^
\89c
\88Ä
\93à');
355 IgnoreLists.Add('
\83c
\81[
\83\8b\97Þ');
356 IgnoreLists.Add('
\91¼
\82Ì
\83T
\83C
\83g');
359 IgnoreLists.LoadFromFile(GikoSys.Setting.GetIgnoreFileName);
362 SetIgnoreCategory(true);
367 procedure TNewBoardDialog.EditIgnoreListsButtonClick(Sender: TObject);
369 EditIgnoreList(Sender);
370 EditIgnoreListsButton.OnClick := UpdateIgnoreList;
372 procedure TNewBoardDialog.EditIgnoreList(Sender: TObject);
376 EditIgnoreListsButton.Caption := '
\8f\9c\8aO
\83J
\83e
\83S
\83\8a\81[
\8dX
\90V';
377 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';
378 UpdateButton.Enabled := false;
379 //MessageMemo.ReadOnly := false;
381 for i := 0 to IgnoreLists.Count - 1 do
382 MessageMemo.Lines.Add(IgnoreLists[i]);
384 procedure TNewBoardDialog.UpdateIgnoreList(Sender: TObject);
388 Label2.Caption := '';
389 UpdateButton.Enabled := true;
390 EditIgnoreListsButton.Caption := '
\8f\9c\8aO
\83J
\83e
\83S
\83\8a\81[
\95Ò
\8fW';
392 for i := 0 to MessageMemo.Lines.Count - 1 do
393 IgnoreLists.Add(MessageMemo.Lines[i]);
394 IgnoreLists.SaveToFile(GikoSys.Setting.GetIgnoreFileName);
396 SetIgnoreCategory(false);
397 //MessageMemo.ReadOnly := true;
399 EditIgnoreListsButton.OnClick := EditIgnoreListsButtonClick;
402 procedure TNewBoardDialog.FormClose(Sender: TObject;
403 var Action: TCloseAction);