OSDN Git Service

This commit was manufactured by cvs2svn to create tag 'v1_62_0_809'.
[gikonavigoeson/gikonavi.git] / Dolib.pas
index 3c34f7a..a4ac2f3 100644 (file)
--- a/Dolib.pas
+++ b/Dolib.pas
@@ -33,7 +33,7 @@ unit Dolib;
 interface
 
 uses
-       Windows, SysUtils, WinInet;
+       Windows, SysUtils, WinInet, YofUtils;
 
 type
        TDolibSession = class(TObject)
@@ -58,7 +58,6 @@ type
                FPassword: string;
                FProxyAddress: string;
                FClientUA: string;
-               FDolibURL: string;
                function GetSessionID: string;
                function GetVersion: string;
                function GetUserAgent: string;
@@ -84,19 +83,19 @@ type
                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 }
 
@@ -228,6 +227,7 @@ var
        Buf: array[0..4096] of Char;
        UserInfo: string;
        UserAgent: string;
+    Header: string;
        cb: DWORD;
        Delim: Integer;
 begin
@@ -249,16 +249,18 @@ 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
@@ -319,7 +321,7 @@ 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);