Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/NewBoard.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.9 - (show annotations) (download) (as text)
Sat Mar 6 08:43:34 2004 UTC (20 years, 1 month ago) by h677
Branch: MAIN
CVS Tags: b46
Changes since 1.8: +1 -1 lines
File MIME type: text/x-pascal
・ォ・ニ・エ・熙ホアソアト、ャアソアトーニニ筅ヒハムケケ、ヒ、ハ、テ、ソ、ホ、ヌ、ス、ホス、タオ

1 unit NewBoard;
2
3 interface
4
5 uses
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;
10
11 type
12 TNewBoardItem = record
13 FResponseCode: Integer;
14 FContent: string;
15 end;
16
17 TNewBoardDialog = class(TForm)
18 Label1: TLabel;
19 MessageMemo: TMemo;
20 UpdateButton: TButton;
21 CloseButton: TButton;
22 Indy: TIdHTTP;
23 IdAntiFreeze: TIdAntiFreeze;
24 StopButton: TButton;
25 Label2: TLabel;
26 BoardURLComboBox: TComboBox;
27 Label13: TLabel;
28 procedure UpdateButtonClick(Sender: TObject);
29 procedure StopButtonClick(Sender: TObject);
30 procedure CloseButtonClick(Sender: TObject);
31 procedure FormCreate(Sender: TObject);
32 private
33 { Private ツ静ゥツ固セ }
34 FAbort: Boolean;
35 function BoardDownload: TNewBoardItem;
36 procedure UpdateURL(s: string);
37 public
38 { Public ツ静ゥツ固セ }
39 end;
40
41 var
42 NewBoardDialog: TNewBoardDialog;
43
44 implementation
45
46 uses Giko, IdHeaderList;
47
48 {$R *.dfm}
49
50 procedure TNewBoardDialog.UpdateButtonClick(Sender: TObject);
51 var
52 Item: TNewBoardItem;
53 begin
54 try
55 GikoSys.Setting.BoardURLSelected := BoardURLComboBox.ItemIndex + 1;
56 FAbort := False;
57 UpdateButton.Enabled := False;
58 StopButton.Enabled := True;
59 CloseButton.Enabled := False;
60 Item := BoardDownload;
61 StopButton.Enabled := False;
62 if FAbort then
63 Exit;
64 if Item.FContent <> '' then begin
65 UpdateURL(Item.FContent);
66 GikoForm.ReloadBBS;
67 end else
68 MessageMemo.Lines.Add('ツダツウツδ督δ債ーツドツで楪篠クツ敗ツてセツづ慊てセツね拏' + IntToStr(Item.FResponseCode) + ']');
69 finally
70 UpdateButton.Enabled := True;
71 StopButton.Enabled := False;
72 CloseButton.Enabled := True;
73 end;
74 end;
75
76 procedure TNewBoardDialog.StopButtonClick(Sender: TObject);
77 begin
78 FAbort := True;
79 Indy.DisconnectSocket;
80 end;
81
82 procedure TNewBoardDialog.CloseButtonClick(Sender: TObject);
83 begin
84 Close;
85 end;
86
87 function TNewBoardDialog.BoardDownload: TNewBoardItem;
88 var
89 URL: string;
90 Stream: TMemoryStream;
91 s: string;
92 i: Integer;
93 begin
94 MessageMemo.Clear;
95 Indy.Request.Clear;
96 Indy.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
97 Indy.ProxyParams.BasicAuthentication := False;
98 if GikoSys.Setting.ReadProxy then begin
99 if GikoSys.Setting.ProxyProtocol then
100 Indy.ProtocolVersion := pv1_1
101 else
102 Indy.ProtocolVersion := pv1_0;
103 Indy.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
104 Indy.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
105 Indy.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
106 Indy.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
107 if GikoSys.Setting.ReadProxyUserID <> '' then
108 Indy.ProxyParams.BasicAuthentication := True;
109 end else begin
110 if GikoSys.Setting.Protocol then
111 Indy.ProtocolVersion := pv1_1
112 else
113 Indy.ProtocolVersion := pv1_0;
114 Indy.ProxyParams.ProxyServer := '';
115 Indy.ProxyParams.ProxyPort := 80;
116 Indy.ProxyParams.ProxyUsername := '';
117 Indy.ProxyParams.ProxyPassword := '';
118 end;
119 //URL := GikoSys.Setting.BoardURL2ch;
120 URL := BoardURLComboBox.Text;
121 Indy.Request.UserAgent := GikoSys.GetUserAgent;
122 Indy.Request.Referer := '';
123 Indy.Request.AcceptEncoding := 'gzip';
124
125 Indy.Request.CacheControl := 'no-cache';
126 Indy.Request.CustomHeaders.Add('Pragma: no-cache');
127
128 // s := '';
129 Stream := TMemoryStream.Create;
130 try
131 try
132 MessageMemo.Lines.Add('ツ案個嫁淞て堋焼卍渉環で?ツづァツ柴?毒セツてセツづ慊ね?#39;);
133 //MessageMemo.Lines.Add(GikoSys.Setting.BoardURL2ch);
134 MessageMemo.Lines.Add(URL);
135 MessageMemo.Lines.Add('ツダツウツδ督δ債ーツドツて堕開ツ始ツてセツづ慊ね?#39;);
136 Indy.Get(URL, Stream);
137 Result.FContent := GikoSys.GzipDecompress(Stream, Indy.Response.ContentEncoding);
138 MessageMemo.Lines.Add('ツダツウツδ督δ債ーツドツで楪看スツ稜。ツてセツづ慊てセツね?#39;);
139 except
140 on E: EIdConnectException do begin
141 MessageMemo.Lines.Add('');
142 MessageMemo.Lines.Add('ツ静堋惰?で楪篠クツ敗ツてセツづ慊てセツね ツ嫁?静シツづ「ツプツδ債キツシツ、FWツて堋湘ウツ妥板て堕塚崢づ猟づ?つュツでセツでつね?#39;);
143 MessageMemo.Lines.Add('FWツて堕禿シツて卍づ?ね伉づゥツ人ツづ債静敖墜債て堕確ツ認ツてセツづ?つュツでセツでつね?#39;);
144 MessageMemo.Lines.Add('NECツて啀Cツて堋焼卍債?づ恒C GATEツで楪闇、ツでつて堕てセツづ?ね伉づゥツ嘉つ能ツ税、ツで楪債つね伉てケツね?#39;);
145 MessageMemo.Lines.Add('Message: ' + E.Message);
146 end;
147 on E: Exception do begin
148 if FAbort then
149 MessageMemo.Lines.Add('ツダツウツδ督δ債ーツドツて堕陳?断ツてセツづ慊てセツね?#39;)
150 else begin
151 MessageMemo.Lines.Add('ツダツウツδ督δ債ーツドツで楪篠クツ敗ツてセツづ慊てセツね?#39;);
152 MessageMemo.Lines.Add('ResponseCode: ' + IntToStr(Indy.ResponseCode));
153 MessageMemo.Lines.Add('Message: ' + E.Message);
154 MessageMemo.Lines.Add('------------------------');
155 for i := 0 to Indy.Response.RawHeaders.Count - 1 do begin
156 s := Indy.Response.RawHeaders.Names[i];
157 s := s + ': ' + Indy.Response.RawHeaders.Values[s];
158 MessageMemo.Lines.Add(s);
159 end;
160 MessageMemo.Lines.Add('------------------------');
161 end;
162 end;
163 end;
164 Result.FResponseCode := Indy.ResponseCode;
165 finally
166 Stream.Free;
167 end;
168 end;
169
170 procedure TNewBoardDialog.UpdateURL(s: string);
171 var
172 i: Integer;
173 idx: Integer;
174 idx1: Integer;
175 idx2: Integer;
176 n: Integer;
177 tmp: string;
178 URL: string;
179 Title: string;
180 cate: string;
181 Board: TBoard;
182 Change: Boolean;
183 ini: TMemIniFile;
184 oldURLs : TStringList;
185 newURLs : TStringList;
186 begin
187 Change := False;
188 MessageMemo.Lines.Add('ツ新ツ氾つ、ツ氾6RLツ米篠更ツチツェツッツクツて堕開ツ始ツてセツづ慊ね?#39;);
189 MessageMemo.Lines.Add('');
190 s := CustomStringReplace(s, '<B>', '<b>', true);
191 s := CustomStringReplace(s, '<BR>', '<br>', true);
192 s := CustomStringReplace(s, '</B>', '</b>', true);
193 s := CustomStringReplace(s, '<A HREF', '<a href', true);
194 s := CustomStringReplace(s, '</A', '</a', true);
195 cate := '';
196
197 oldURLs := TStringList.Create;
198 newURLs := TStringList.Create;
199
200 try
201
202 GikoSys.ForceDirectoriesEx(GikoSys.GetConfigDir);
203 ini := TMemIniFile.Create(GikoSys.GetBoardFileName);
204 try
205 //
206 //ツ催ュツ渉慊オツプツシツδ?δ督で楪選ツ惰堕でつて卍づ?ね伉づゥツ焼卍債?づ債クツδ環ア
207
208 ini.Clear;
209
210 while True do begin
211 idx1 := AnsiPos('<b>', s);
212 idx2 := AnsiPos('<a', s);
213 if (idx1 = 0) and (idx2 = 0) then Break;
214
215 if idx1 < idx2 then begin
216 //<br>
217 idx := AnsiPos('</b>', s);
218 if idx = 0 then begin
219 s := Copy(s, idx1 + 4, Length(s));
220 continue;
221 end;
222 tmp := Copy(s, idx1, (idx - idx1) + 4);
223 tmp := CustomStringReplace(tmp, '<b>', '');
224 tmp := CustomStringReplace(tmp, '</b>', '');
225
226 if (tmp = 'ツつィツね?ね?づ?#39;) or
227 (tmp = 'ツ禿?米伉甘ゥツ夏?#39;) or
228 (tmp = 'ツづ慊でシツBツBツS') or
229 (tmp = 'ツチツδδッツト') or
230 (tmp = 'ツつィツ絵ツで?ツで、') or
231 (tmp = 'ツ運ツ営ツ暗?毒?#39;) or
232 (tmp = 'ツツツーツδ仰稜「') or
233 (tmp = 'ツ打コツて堋サツイツト') then begin
234 cate := '';
235 s := Copy(s, idx + 5, Length(s));
236 Continue;
237 end;
238 s := Copy(s, idx + 5, Length(s));
239 cate := tmp;
240 end else begin
241 //<a href=
242 if cate = '' then begin
243 s := Copy(s, idx2 + 2, Length(s));
244 end else begin
245 idx := AnsiPos('</a>', s);
246 tmp := Copy(s, idx2, (idx - idx2) + 4);
247 tmp := CustomStringReplace(tmp, '<a href=', '');
248 tmp := CustomStringReplace(tmp, '</a>', '');
249 tmp := CustomStringReplace(tmp, 'TARGET=_blank', '');
250 i := AnsiPos('>', tmp);
251 if i <> 0 then begin
252 URL := Copy(tmp, 1, i - 1);
253 Title := Copy(tmp, i + 1, Length(tmp));
254 Board := BBSs[ 0 ].FindBoardFromTitle(Title);
255 if Board = nil then begin
256 MessageMemo.Lines.Add('ツ新ツ氾つ津?嘉?「' + Title + '(' + URL + ')ツ」');
257 ini.WriteString(cate, Title, URL);
258 Change := True;
259 end else begin
260 if Board.URL <> URL then begin
261 MessageMemo.Lines.Add('URLツ米篠更ツ「' + Board.Title + '(' + URL +')ツ」');
262 ini.WriteString(cate, Title, URL);
263 oldURLs.Add(Board.URL);
264 newURLs.Add(URL);
265 Change := True;
266 end else begin
267 ini.WriteString(cate, Title, URL);
268 end;
269 end;
270 end else begin
271 s := Copy(s, idx2 + 2, Length(s));
272 Continue;
273 end;
274 s := Copy(s, idx + 5, Length(s));
275 end;
276 end;
277 end;
278 finally
279 if Change then
280 ini.UpdateFile;
281 ini.Free;
282 end;
283 MessageMemo.Lines.Add('');
284 if Change then begin
285 GikoForm.FavoritesURLReplace(oldURLs, newURLs);
286 MessageMemo.Lines.Add('ツ新ツ氾つ、ツ氾6RLツ米篠更ツチツェツッツクツで楪看スツ稜。ツてセツづ慊てセツね?#39;);
287 MessageMemo.Lines.Add('ツ「ツ陛つで崢づゥツ」ツボツタツδ督て堕可淞てセツづ?つュツでセツでつね?#39;);
288 end else
289 MessageMemo.Lines.Add('ツ新ツ氾つ、ツ氾6RLツ米篠更ツづ ツつ?ツて債づ慊で。ツで?てケツてセツね?#39;);
290 finally
291 oldURLs.Free;
292 newURLs.Free;
293 end;
294 end;
295
296 procedure TNewBoardDialog.FormCreate(Sender: TObject);
297 begin
298 StopButton.Enabled := False;
299 BoardURLComboBox.Clear;
300 BoardURLComboBox.Items.AddStrings(GikoSys.Setting.BoardURLs);
301 try
302 BoardURLComboBox.ItemIndex := GikoSys.Setting.BoardURLSelected - 1;
303 except
304 BoardURLComboBox.ItemIndex := 0;
305 end;
306 end;
307
308 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26