📄 msnloginclient.cpp
字号:
pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,strObject,0,1,0,0,dwHttpRequestFlags);
pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
pFile->QueryInfoStatusCode(dwRet);
unsigned long ContentStrLen = 4023;
char alText[4024];
memset(alText,0x00,sizeof(alText));
pFile->QueryInfo(HTTP_QUERY_STATUS_TEXT ,alText,&ContentStrLen);
FileLog("QueryInfo=[%d] %s",ContentStrLen,alText);
//HTTP_QUERY_RAW_HEADERS_CRLF 22 // special: all headers
memset(alText,0x00,sizeof(alText));
ContentStrLen = 4023;
pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF,alText,&ContentStrLen);
FileLog("QueryInfo all headers:[%d] \n%s",ContentStrLen,alText);
//Authentication-Info: Passport1.4 da-status=success,from-PP='t=6i74VouBNHsO1Z5RJNulJBswkNts5lPEiTXvqZaOuh8fPTvhncTY5FKZZZfch4pXCmyclLdkYpUgeWczNmzu1*3FGWUU5pRU3Gvs*472Oi!y3SkGWzuy!Gxc1qWW2gHxYx6oFxID57eng$&p=6hQ!wH4YGFc!nnfg2kyLEs0N!6HWbEeXo8sHmcWXB6uJXAHPHtyvtLauKmUA9h472zg4CfaJLUVUKXVM5ibNfwzOtcpM1RHs85D4NZseNiXYd1b3jwwPtqo268KVKdICylCyiiPSKcznYawOMc5lUkyH0AvS85rFKi1YCkYD2mpsJVT0FyovDk8Q$$',ru=http://messenger.msn.com
unsigned int i=0,iBegin=0,iEnd=0;
for( i = 10; i< ContentStrLen; i++ )
{
if( memcmp( alText + i , "from-PP='",9 ) == 0 ) iBegin= i+9;
else if( memcmp( alText + i , "',ru=",5 ) == 0 )
{
iEnd = i ;
break;
}
}
FileLog("Authentication-Info: %d %d",iBegin,iEnd);
if( iEnd > iBegin )
{
memcpy(alTmp4,alText+iBegin, iEnd-iBegin );
alTmp4[iEnd-iBegin]=0x00;
}
if (dwRet == HTTP_STATUS_OK)
{
FileLog("http ret=[%d]",dwRet);
/***********
UINT nRead = pFile->Read(szBuf, 1023);
while (nRead > 0)
{
szBuf[nRead]=0;
FileLog("http ret=[%d],%s",nRead, szBuf );//read file...
HexLog(szBuf, nRead);
}
*********************/
}
else FileLog("http Err ret=[%d]",dwRet);
delete pFile;
delete pServer;
}
//catch (CInternetException* pEx)
catch (CException* pEx)
{
pEx->GetErrorMessage(alTmp4,255,NULL);
FileLog("CException: %s",alTmp4 ); //catch errors from WinInet
}
session.Close();
FileLog("DoHTTPSAuthentication:从认证服务器得到的(入场券)[%s]", alTmp4);
return 0;
}
int CMsnLoginClient::DoMD5(char *aIn, char *aOut)
{
//Client ID string Client ID code
//msmsgs@msnmsgr.com Q1P7W2E4J9R8U3S5
//PROD0038W!61ZTF9 VT6PX?UQTM4WM%YR
//PROD0058#7IL2{QD QHDCY@7R1TB6W?5B
//PROD0061VRRZH@4F JXQ6J@TUOGYV@N0M
FileLog("Client ID string=[PROD0038W!61ZTF9],Client ID code=[VT6PX?UQTM4WM%YR]");
FileLog("CHL challenge =[%s]", aIn );
int iLen = strlen(aIn );
memcpy( aIn + iLen , "VT6PX?UQTM4WM%YR", 16 );
aIn[ iLen + 16 ] = 0x00;
FileLog("CHL challenge + Client ID code =[%s]", aIn );
MD5String( aIn, aOut);
FileLog("QRY MD5 string=[%s]", aOut );
return 0;
}
int CMsnLoginClient::DoTimerPNG()
{
char buf[10];
if( m_pSocket == NULL) return -1;
if( m_iLoginOk==0 ) return -2;
memset(buf,0x00,sizeof(buf));
sprintf(buf, "PNG\r\n");
m_pSocket->Send( (void*)buf, strlen(buf));
return 0;
}
int CMsnLoginClient::DoLST(CString aIn)
{
//[LST tcpip_2005@126.com 动力通信工作组 11 1]
char alTmp0[1000],alTmp1[300],alTmp2[300],alTmp3[300],alTmp4[1000];
unsigned int i=0;
memset(alTmp0,0x00,sizeof(alTmp0));
memset(alTmp1,0x00,sizeof(alTmp1));
memset(alTmp2,0x00,sizeof(alTmp2));
memset(alTmp3,0x00,sizeof(alTmp3));
memset(alTmp4,0x00,sizeof(alTmp4));
sprintf(alTmp0,"%s", (LPCTSTR)aIn);
sscanf(alTmp0,"%s %s %s",alTmp1,alTmp2,alTmp3 );
FileLog("LST : %s %s %s",alTmp1,alTmp2,alTmp3 );
m_MsnUser[m_iCountUser] = new CMsnUser();
m_MsnUser[m_iCountUser]->m_iUserNo = m_iCountUser ;
m_MsnUser[m_iCountUser]->m_strEmail.Format("%s",alTmp2);
m_MsnUser[m_iCountUser]->m_strNickName.Format("%s",alTmp3);
m_MsnUser[m_iCountUser]->m_strStatus=_T("HDN");
m_MsnUser[m_iCountUser]->m_pLoginClient=this;
m_iCountUser ++;
return 0;
}
int CMsnLoginClient::DispMainPage()
{
//int ilPageName,ilPageStatus,ilPageUser,ilPageEnd;
char alTmp1[4048];
int ilBytes;
CFile fLog;
CString sFile;
CString strBuf;
sFile.Format("%s\\html\\MainPage.htm",agCurDir);
if( !fLog.Open(sFile, CFile::modeRead))
{
FileLog("Failed to read %s.", sFile );
}
else
{
memset(alTmp1,0,4048);
//fLog.Seek(-600,CFile::end);
ilBytes = fLog.Read(alTmp1,4040);
FileLog("Read Bytes: %d ",ilBytes);
fLog.Close();
}
FileLog( " DispMainPage() ... " );
strBuf.Format("%s", alTmp1 );
strBuf.Replace("_VAR_Email",(LPCTSTR)m_strMyNickName);
strBuf.Replace("_VAR_Nick",(LPCTSTR)m_strNick);
strBuf.Replace("_VAR_Status","<option value=\"NLN\" selected>Online</option>");
ilBytes = 0 ;
int iIn=strBuf.Find("_VAR_Users");
for( int i=0;i<m_iCountUser; i ++ )
{
memset(alTmp1,0,2048);
sprintf(alTmp1+ilBytes,"<img border=\"0\" src=\"%s.jpg\" ><a href=\"http://sim.msnmessenger.com.cn/OpenUser.asp?UserNo=%d\">%s(%s)</a><br>\n",
(LPCTSTR)m_MsnUser[i]->m_strStatus,i,
(LPCTSTR)m_MsnUser[i]->m_strNickName,
(LPCTSTR)m_MsnUser[i]->m_strEmail);
strBuf.Insert(iIn,alTmp1);
}
strBuf.Replace("_VAR_Users","<br>");
sFile.Format("%s\\html\\MainPage_0.htm",agCurDir);
if( !fLog.Open(sFile, CFile::modeCreate|CFile::modeWrite))
{
FileLog("Failed to write %s .", sFile );
}
else
{
fLog.Write((LPCTSTR)strBuf,strBuf.GetLength());
fLog.Close();
FileLog("Write Bytes: %d",strBuf.GetLength());
}
FileLog("PostMessage(WPARAM, LPARAM lParam DispMainPage)");
LPARAM lpTmp= 1;
AfxGetApp()->m_pMainWnd->PostMessage( WM_MY_MESSAGE, 0, (LPARAM)lpTmp );
return 0;
}
int CMsnLoginClient::DoUserInput(const char *aInCmd, int iInUserNo)
{
if( memcmp( aInCmd, "REA" , 3 ) == 0 )
{
//C->S 0076 [REA 14 free_2005@sina.com.cn %25e5%25ae%25
char buf[300];
if( m_pSocket == NULL) return -1;
if( m_iLoginOk==0 ) return -2;
memset(buf,0x00,sizeof(buf));
m_iSendXh++;
sprintf(buf, "REA %d %s %s\r\n",m_iSendXh,
(LPCTSTR)m_strMyNickName,(LPCTSTR)m_strNick);
m_pSocket->Send( (void*)buf, strlen(buf));
}
else if( memcmp( aInCmd, "OpenUser" , 8 ) == 0 )
{
if( m_pSocket == NULL) return -1;
if( m_iLoginOk==0 ) return -2;
return DispUserPage(iInUserNo);
}
else if( memcmp( aInCmd, "AddUser" , 3 ) == 0 )
{
//[ADD 13 FL tcpip_2005@126.com tcpip_2005@126.com 1%0d%0a]
char buf[300];
if( m_pSocket == NULL) return -1;
if( m_iLoginOk==0 ) return -2;
memset(buf,0x00,sizeof(buf));
m_iSendXh++;
sprintf(buf, "ADD %d FL %s %s 0\r\n",m_iSendXh,
aInCmd+8,aInCmd+8);
m_pSocket->Send( (void*)buf, strlen(buf));
}
else if( memcmp( aInCmd, "DelUser" , 3 ) == 0 )
{
//20050529 10:00:49:540 [768] : C->S 0037 [REM 14 FL tcpip_2005@126.com 1%0d%0a]
//20050529 10:00:49:870 [768] : S->C 0039 [REM 14 FL 1 tcpip_2005@126.com 1%0d%0a]
char buf[300];
if( m_pSocket == NULL) return -1;
if( m_iLoginOk==0 ) return -2;
memset(buf,0x00,sizeof(buf));
m_iSendXh++;
sprintf(buf, "REM %d FL %s 0\r\n",m_iSendXh, aInCmd+8 );
m_pSocket->Send( (void*)buf, strlen(buf));
}
return 0;
}
int CMsnLoginClient::DispUserPage(int iInUserNo)
{
//int ilPageName,ilPageStatus,ilPageUser,ilPageEnd;
char alTmp1[2048],alTmp2[300];
int ilBytes;
CFile fLog;
CString sFile;
CString strBuf;
sFile.Format("%s\\html\\user_frm.htm",agCurDir);
if( !fLog.Open(sFile, CFile::modeRead))
{
FileLog("Failed to read %s.", sFile );
}
else
{
memset(alTmp1,0,2048);
//fLog.Seek(-600,CFile::end);
ilBytes = fLog.Read(alTmp1,2040);
FileLog("Read Bytes: %d ",ilBytes);
fLog.Close();
}
memset(alTmp2,0x00,sizeof(alTmp2));
sprintf( alTmp2,"%d_user_left.htm", iInUserNo );
strBuf.Format("%s", alTmp1 );
strBuf.Replace("user_left.htm",alTmp2);
memset(alTmp2,0x00,sizeof(alTmp2));
sprintf( alTmp2,"%d_user_bottom.htm", iInUserNo );
strBuf.Replace("user_bottom.htm",alTmp2);
sFile.Format("%s\\html\\%d_user_frm.htm",agCurDir,iInUserNo);
if( !fLog.Open(sFile, CFile::modeCreate|CFile::modeWrite))
{
FileLog("Failed to write %s .", sFile );
}
else
{
fLog.Write((LPCTSTR)strBuf,strBuf.GetLength());
fLog.Close();
FileLog("Write Bytes: %d",strBuf.GetLength());
}
sFile.Format("%s\\html\\user_bottom.htm",agCurDir);
if( !fLog.Open(sFile, CFile::modeRead))
{
FileLog("Failed to read %s.", sFile );
}
else
{
memset(alTmp1,0,2048);
ilBytes = fLog.Read(alTmp1,2040);
FileLog("Read Bytes: %d ",ilBytes);
fLog.Close();
}
memset(alTmp2,0x00,sizeof(alTmp2));
sprintf( alTmp2,"%d", iInUserNo );
strBuf.Format("%s", alTmp1 );
strBuf.Replace("_VAR_UserNo",alTmp2);
sFile.Format("%s\\html\\%d_user_bottom.htm",agCurDir,iInUserNo);
if( !fLog.Open(sFile, CFile::modeCreate|CFile::modeWrite))
{
FileLog("Failed to write %s .", sFile );
}
else
{
fLog.Write((LPCTSTR)strBuf,strBuf.GetLength());
fLog.Close();
FileLog("Write Bytes: %d",strBuf.GetLength());
}
FILE *fp;
char fname1[300];
sprintf(fname1,"%s\\html\\%d_user_left.htm",agCurDir,iInUserNo);
if (( fp = fopen(fname1,"w")) != NULL)
{
fprintf( fp,"<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
fprintf( fp,"<title>UserPages</title></head><body>");
fprintf( fp,"<p><font face=\"宋体\" size=\"2\">" );
fclose( fp );
}
FileLog("PostMessage(WPARAM, LPARAM lParam DispMainPage)");
LPARAM lpTmp= iInUserNo+100;
AfxGetApp()->m_pMainWnd->PostMessage( WM_MY_MESSAGE, 1, (LPARAM)lpTmp );
return 0;
}
int CMsnLoginClient::DoUserXfrSB(int iInUserNo)
{
char buf[300];
if( m_pSocket == NULL) return -1;
if( m_iLoginOk==0 ) return -2;
m_iXfrSbUserNo=iInUserNo;
memset(buf,0x00,sizeof(buf));
m_iSendXh++;
sprintf(buf, "XFR %d SB\r\n",m_iSendXh);
m_pSocket->Send( (void*)buf, strlen(buf));
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -