interface
uses
- Windows, SysUtils, WinInet;
+ Windows, SysUtils, WinInet, YofUtils;
type
TDolibSession = class(TObject)
FPassword: string;
FProxyAddress: string;
FClientUA: string;
- FDolibURL: string;
function GetSessionID: string;
function GetVersion: string;
function GetUserAgent: string;
property UserAgent: string read GetUserAgent;
property ErrorCode: integer read GetErrorCode;
property ErrorMsg: string read GetErrorMsg;
- property DolibURL: string read FDolibURL write FDolibURL;
end;
implementation
const
DOLIB_VERSION = $10000;
DOLIB_LOGIN_UA = 'DOLIB/1.00';
- DOLIB_LOGIN_HOST = 'tiger2.he.net';
-// DOLIB_LOGIN_URL = '/~tora3n2c/futen.cgi';
+ DOLIB_LOGIN_HOST = '2chv.tora3.net';
+ DOLIB_LOGIN_URL = '/futen.cgi';
DOLIB_2CH_UA = 'X-2ch-UA:';
// DOLIB_2CH_UA = 'X-2ch-UA: gikoNavi/1.00'#13#10;
DOLIB_ENOMEM_STRING = '\83\81\83\82\83\8a\82ª\91«\82è\82Ü\82¹\82ñ\81B';
DOLIB_LOGIN_ERROR = 'ERROR:';
+// https://2chv.tora3.net/futen.cgi
{ TDolib }
Buf: array[0..4096] of Char;
UserInfo: string;
UserAgent: string;
+ Header: string;
cb: DWORD;
Delim: Integer;
begin
if not Assigned(hConnect) then
MakeError(FSession, GetLastError())
else begin
- hRequest := HttpOpenRequest(hConnect, 'POST', PChar(FDolibURL),
+ hRequest := HttpOpenRequest(hConnect, 'POST', DOLIB_LOGIN_URL,
nil, nil, nil,
INTERNET_FLAG_NO_CACHE_WRITE or INTERNET_FLAG_NO_COOKIES or
INTERNET_FLAG_NO_UI or INTERNET_FLAG_SECURE, 0);
if not Assigned(hRequest) then
MakeError(FSession, GetLastError())
else begin
- UserInfo := Format('ID=%s&PW=%s', [ID, Pass]);
+ UserInfo := Format('ID=%s&PW=%s', [HttpEncode(ID), HttpEncode(Pass)]);
+ Header := 'Content-Type: application/x-www-form-urlencoded'#13#10;
UserAgent := Format('%s %s', [DOLIB_2CH_UA, ClientUA]) + #13#10;
- if not HttpSendRequest(hRequest, PChar(UserAgent), DWORD(-1), PChar(UserInfo), Length(UserInfo)) then
+ Header := Header + UserAgent;
+ if not HttpSendRequest(hRequest, PChar(Header), DWORD(-1), PChar(UserInfo), Length(UserInfo)) then
MakeError(FSession, GetLastError())
else begin
if not InternetReadFile(hRequest, @Buf, SizeOf(Buf), cb) then
if not Assigned(hConnect) then
MakeError(FSession, GetLastError())
else begin
- hRequest := HttpOpenRequest(hConnect, 'POST', PChar(FDolibURL),
+ hRequest := HttpOpenRequest(hConnect, 'POST', DOLIB_LOGIN_URL,
nil, nil, nil,
INTERNET_FLAG_NO_CACHE_WRITE or INTERNET_FLAG_NO_COOKIES or
INTERNET_FLAG_NO_UI or INTERNET_FLAG_SECURE, 0);