请教简单的问题1

oldmonsterman 2001-07-10 09:19:53
请问各位高人:(1)如何用vc编程从服务器上取得网页文件或其他文件的时间属性?
(2)当往一个bbs网页上贴了一个贴子,则它是新建一个网页还是将该网页改变,再存盘(文件的时间是否改变了)?
(3)如何用vc编程在内存中取得一个特定的网页内容?
我的email: gwmboss@263.net
...全文
188 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
once168 2001-11-04
  • 打赏
  • 举报
回复
哈哈!我以前做了一个downLoad陈序----还支持多线程---(csdn 的贴子,我经常用它下载);
BBS 不是一个文件,是server从database中擦旬的记努集----所以没有网页时间的概念,
用CHttpFile 是很好实现的,你看一下MSDN 包你一个晚上成功
oldmonsterman 2001-11-04
  • 打赏
  • 举报
回复
jt
oldmonsterman 2001-07-20
  • 打赏
  • 举报
回复
难道没有其他高人吗
coolstar 2001-07-11
  • 打赏
  • 举报
回复
/*
版权所有:周田鼠
http://www.geocities.com/zhoutianshu
zhoutianshu@yahoo.com
感谢空心菜。
*/


// CRobot classes - Constants

// Error codes

#define CROBOT_ERR_SUCCESS 0
#define CROBOT_ERR_INVALID_URL 1
#define CROBOT_ERR_INVALID_PARAMETER 2
#define CROBOT_ERR_CONNECTION_FAILED 3
#define CROBOT_ERR_TIMED_OUT 4
#define CROBOT_ERR_NOT_FOUND 5
#define CROBOT_ERR_NOT_AUTHORIZED 6
#define CROBOT_ERR_DISK_FILE_ERROR 7

// Base for disk/file error codes
#define CROBOT_ERR_FILE 100


/*
版权所有:周田鼠
http://www.geocities.com/zhoutianshu
zhoutianshu@yahoo.com
感谢空心菜。
*/


////////////////////////////////////////////////////////////////////
//
// CRobotInternet.h - CRobotInternet class declarations
//
// Source: "Programming Robots, Spiders and Intelligent Agents
// Using Visual C++"
//
// Copyright (C) 1999 David Pallmann. All Rights Reserved.

class CRobotInternet
{
public:
BOOL m_bReadFromCache, m_bWriteToCache;
int m_nContext;
CString m_sProxyLogonMethod, m_sProxyLogonUsername, m_sProxyLogonPassword;
CString m_sLogonUsername, m_sLogonPassword;
CString m_sUserAgent;

// Header (httpHeader, httpHeaderFields)
CString m_sHeader;

// Number of header fields (httpHeaderFields)
int m_nHeaderFields;

// Header field names (httpHeaderFields)
CString m_sHeadName[100];

// Header field values (httpHeaderFields)
CString m_sHeadValue[100];

//---- Public functions ----

public:
CRobotInternet();
~CRobotInternet();

//---- HTTP functions ----
BOOL httpPost(const CString& sUrl,
const CString& sData,
CString& sResponse,
int& nResult,
CString& sErrMsg);

//---- FTP functions ----

//---- Generalized functions ----

//---- Private functions ----

private:
CString EncodeTextBase64(const CString& sText);
CString ErrorMessage(const int nError);
CString CreateStandardHeader();

};

////////////////////////////////////////////////////////////////////


/*
版权所有:周田鼠
http://www.geocities.com/zhoutianshu
zhoutianshu@yahoo.com
感谢空心菜。
*/


// mfcapp.h : main header file for the MFCAPP application
//

#if !defined(AFX_MFCAPP_H__A0055F35_C27B_11D3_944F_00A0C9685ADF__INCLUDED_)
#define AFX_MFCAPP_H__A0055F35_C27B_11D3_944F_00A0C9685ADF__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h" // main symbols

/////////////////////////////////////////////////////////////////////////////
// CMfcappApp:
// See mfcapp.cpp for the implementation of this class
//

class CMfcappApp : public CWinApp
{
public:
CMfcappApp();

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMfcappApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL

// Implementation

//{{AFX_MSG(CMfcappApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MFCAPP_H__A0055F35_C27B_11D3_944F_00A0C9685ADF__INCLUDED_)


/*
版权所有:周田鼠
http://www.geocities.com/zhoutianshu
zhoutianshu@yahoo.com
感谢空心菜。
*/


#if !defined(AFX_POSTDLG_H__1FAAECC3_B285_11D3_ACBC_00104B0DC2A6__INCLUDED_)
#define AFX_POSTDLG_H__1FAAECC3_B285_11D3_ACBC_00104B0DC2A6__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PostDlg.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// PostDlg dialog

class PostDlg : public CDialog
{
// Construction
public:
void TransformString(CString &s);
void PostRichwin();
PostDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(PostDlg)
enum { IDD = IDD_DIALOG1 };
CString m_author;
CString m_body;
CString m_subject;
CString m_urlname;
CString m_copyfrom;
CString m_pass;
CString m_refimg;
CString m_refurl;
int m_newORreply;
CString m_refid;
//}}AFX_DATA


// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(PostDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:

// Generated message map functions
//{{AFX_MSG(PostDlg)
virtual void OnOK();
afx_msg void OnRadio1();
afx_msg void OnRadio2();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_POSTDLG_H__1FAAECC3_B285_11D3_ACBC_00104B0DC2A6__INCLUDED_)


//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by mfcapp.rc
//
#define IDD_MFCAPP_DIALOG 102
#define IDR_MAINFRAME 128
#define IDD_DIALOG1 129
#define IDC_REFIMG 1000
#define IDC_EMAIL 1001
#define IDC_TITLE 1002
#define IDC_AUTHOR 1003
#define IDC_BODY 1004
#define IDC_REFURL 1005
#define IDC_PASS 1006
#define IDC_COPYFROM 1007
#define IDC_URLNAME 1008
#define IDC_RADIO1 1009
#define IDC_RADIO2 1010
#define IDC_REFID 1011
#define IDC_REPSTATIC 1012

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1013
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif


/*
版权所有:周田鼠
http://www.geocities.com/zhoutianshu
zhoutianshu@yahoo.com
感谢空心菜。
*/


// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#if !defined(AFX_STDAFX_H__A0055F39_C27B_11D3_944F_00A0C9685ADF__INCLUDED_)
#define AFX_STDAFX_H__A0055F39_C27B_11D3_944F_00A0C9685ADF__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers

#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT


//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__A0055F39_C27B_11D3_944F_00A0C9685ADF__INCLUDED_)


coolstar 2001-07-11
  • 打赏
  • 举报
回复
/*
版权所有:周田鼠
http://www.geocities.com/zhoutianshu
zhoutianshu@yahoo.com
感谢空心菜。
*/


////////////////////////////////////////////////////////////////////
//
// CRobotInternet.cpp - CRobotInternet class implementation
//
// Source: "Programming Robots, Spiders and Intelligent Agents
// using Visual C++"
//
// Copyright (C) 1999 David Pallmann. All Rights Reserved.


#include <stdafx.h>
#include <afxinet.h>
#include "CRobot.h"
#include "CRobotInternet.h"
#define TEXTLENGTH 1024*64

// Constructor

CRobotInternet::CRobotInternet()
{
m_bReadFromCache = false;
m_bWriteToCache = false;
m_nContext = 0;
m_sLogonUsername = "";
m_sLogonPassword = "";
m_sProxyLogonMethod = "";
m_sProxyLogonUsername = "";
m_sProxyLogonPassword = "";
m_sUserAgent = "Mozilla";
}


// Destructor

CRobotInternet::~CRobotInternet()
{
m_sProxyLogonMethod.Empty();
m_sProxyLogonUsername.Empty();
m_sProxyLogonPassword.Empty();
}


////////////////////////////////////////////////////////////////////
//
// Support functions


// ********************** private
// * *
// * EncodeTextBase64 *
// * *
// **********************
// Function: Returns the Base64-encoded version of a text string.

CString CRobotInternet::EncodeTextBase64(const CString& sText)
{
unsigned char cChar[255];
int nIndex1, nIndex2, nIndex3, nIndex4;
int nChars;
CString sBase64 = "";
char cTable[64 + 1];
CString sTemp;

cTable[0] = 'A';
cTable[1] = 'B';
cTable[2] = 'C';
cTable[3] = 'D';
cTable[4] = 'E';
cTable[5] = 'F';
cTable[6] = 'G';
cTable[7] = 'H';
cTable[8] = 'I';
cTable[9] = 'J';
cTable[10] = 'K';
cTable[11] = 'L';
cTable[12] = 'M';
cTable[13] = 'N';
cTable[14] = 'O';
cTable[15] = 'P';

cTable[16] = 'Q';
cTable[17] = 'R';
cTable[18] = 'S';
cTable[19] = 'T';
cTable[20] = 'U';
cTable[21] = 'V';
cTable[22] = 'W';
cTable[23] = 'X';
cTable[24] = 'Y';
cTable[25] = 'Z';
cTable[26] = 'a';
cTable[27] = 'b';
cTable[28] = 'c';
cTable[29] = 'd';
cTable[30] = 'e';
cTable[31] = 'f';

cTable[32] = 'g';
cTable[33] = 'h';
cTable[34] = 'i';
cTable[35] = 'j';
cTable[36] = 'k';
cTable[37] = 'l';
cTable[38] = 'm';
cTable[39] = 'n';
cTable[40] = 'o';
cTable[41] = 'p';
cTable[42] = 'q';
cTable[43] = 'r';
cTable[44] = 's';
cTable[45] = 't';
cTable[46] = 'u';
cTable[47] = 'v';

cTable[48] = 'w';
cTable[49] = 'x';
cTable[50] = 'y';
cTable[51] = 'z';
cTable[52] = '0';
cTable[53] = '1';
cTable[54] = '2';
cTable[55] = '3';
cTable[56] = '4';
cTable[57] = '5';
cTable[58] = '6';
cTable[59] = '7';
cTable[60] = '8';
cTable[61] = '9';
cTable[62] = '+';
cTable[63] = '/';

cTable[64] = '=';

nChars = sText.GetLength();
for (int nPos = 0; nPos < nChars; nPos++)
{
cChar[nPos] = sText.GetAt(nPos);
} // End for

// cChar[nPos] cChar[nPos+1] cChar[nPos+2]
// | | |
// -------+------- -------+------- -------+-------
// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
// | | | | | | | | | | | | | | | | | | | | | | | |
// x x x x x x x x x x x x x x x x x x x x x x x x
// | | | | | | | | | | | | | | | | | | | | | | | |
// 5 4 3 2 1 0 5 4 3 2 1 0 5 4 3 2 1 0 5 4 3 2 1 0
// -----+----- -----+----- -----+----- -----+-----
// | | | |
// nIndex1 nIndex2 nIndex3 nIndex4
//

for (nPos = 0; nPos < nChars; nPos += 3)
{
if (nPos + 1 >= nChars) cChar[nPos + 1] = '0';
if (nPos + 2 >= nChars) cChar[nPos + 2] = '0';
nIndex4 = ( cChar[nPos + 2] & 0x3F ) & 0x3F;
nIndex3 = ( ((cChar[nPos + 1] & 0x0F) << 2)
| ((cChar[nPos + 2] & 0xC0) >> 6) ) & 0x3F;
nIndex2 = ( ((cChar[nPos] & 3) << 4)
| ((cChar[nPos + 1] & 0xF0) >> 4) ) & 0x3F;
nIndex1 = ( (cChar[nPos] & 0xFC) >> 2 ) & 0x3F;
if (nPos + 1 >= nChars)
{
nIndex3 = 64;
nIndex4 = 64;
} // end if
if (nPos + 2 >= nChars)
{
nIndex4 = 64;
} // end if
sTemp.Format("%c%c%c%c",
cTable[nIndex1],
cTable[nIndex2],
cTable[nIndex3],
cTable[nIndex4]);
sBase64 += sTemp;
} // End for

return sBase64;
}


// ********************* private
// * *
// * ResponseMessage *
// * *
// *********************
// Function: Returns a textual message describing
// a TCP/IP response code.




// ****************** private
// * *
// * ErrorMessage *
// * *
// ******************
// Function: Returns a textual message describing a CRobot
// error code.

CString CRobotInternet::ErrorMessage(const int nError)
{
CString sErrMsg = "";

switch (nError)
{
case CROBOT_ERR_SUCCESS:
sErrMsg = "Successful";
break;
case CROBOT_ERR_INVALID_URL:
sErrMsg = "Invalid URL";
break;
case CROBOT_ERR_INVALID_PARAMETER:
sErrMsg = "Invalid parameter";
break;
case CROBOT_ERR_CONNECTION_FAILED:
sErrMsg = "Connection failed";
break;
case CROBOT_ERR_TIMED_OUT:
sErrMsg = "Timed out";
break;
case CROBOT_ERR_NOT_FOUND:
sErrMsg = "Not found";
break;
case CROBOT_ERR_NOT_AUTHORIZED:
sErrMsg = "Not authorized";
break;
case CROBOT_ERR_DISK_FILE_ERROR:
sErrMsg = "Disk/file error";
break;
default:
sErrMsg.Format("CRobotInternet error %d", nError);
break;
} // End switch
return sErrMsg;
}


// **************************************************************
// * *
// * *
// * H T T P F u n c t i o n s *
// * *
// * *
// **************************************************************


// ---------------------------------------------------------------
// ************************** private
// * *
// * CreateStandardHeader *
// * *
// **************************
// Function: Return a standard header to use with OpenURL calls.
// If a call has been made to set proxy logon information,
// the authentication string is included in the header
// that is returned.
//
// This is a private function called by various public functions.

CString CRobotInternet::CreateStandardHeader()
{
CString sHeader;

sHeader = "Accept: */*\r\n";

if (m_sProxyLogonMethod=="basic" && m_sProxyLogonUsername!="")
{
sHeader += "Proxy-authorization: Basic "
+ EncodeTextBase64(m_sProxyLogonUsername
+ ":"
+ m_sProxyLogonPassword)
+ "\r\n";
} // End if

if (m_sLogonUsername != "")
{
/* sHeader += "Authorization: "
+ m_sLogonUsername
+ ":"
+ m_sLogonPassword
+ "\r\n";
*/
sHeader += "Authorization: Basic "
+ EncodeTextBase64(m_sLogonUsername
+ ":"
+ m_sLogonPassword)
+ "\r\n";
} // End if

sHeader += "\r\n";
return sHeader;
}


// --------------------------------------------------------------
// ************** public
// * *
// * httpPost *
// * *
// **************
// Function: Submits a URL and form data/parameters using the POST
// method. Retrieves a response returns it in CString form.
//
// Inputs: sURL - The URL to access
// (example: "www.mysite.com")
// sData - The parameters (or "form data")
// to submit
//
// Outputs: <function_result> - True if data was successfully
// retrieved, false otherwise
// sResponse - The HTML retrieved
// nResult - Completion code. 0 = success,
// n = error (defined in CRobot.h)
// sErrMsg - The error message, if nResult != 0

BOOL CRobotInternet::httpPost(const CString& sUrl,
const CString& sData,
CString& sResponse,
int& nResult, CString& sErrMsg)
{
CInternetSession* pSession;
CHttpConnection* pConnection;
CHttpFile* pHttpFile;
int nRead;
LPSTR pBuffer = NULL;
CString sResult;
CString sWorkingUrl;
CString sHeaders = "";
CString sMsg;
sErrMsg = "";
DWORD dwHttpStatus;
nResult = CROBOT_ERR_SUCCESS;
TCHAR sTemp[TEXTLENGTH];

try
{
pSession = NULL;
pConnection = NULL;
pHttpFile = NULL;
nRead = 0;
pBuffer = new char[TEXTLENGTH];
sResult = "";
sWorkingUrl = sUrl;
sHeaders = _T("Content-Type: "
"application/x-www-form-urlencoded\r\n")
+ CreateStandardHeader();
/*sHeaders = _T("Content-Type: "
"multipart/form-data\r\n")
+ CreateStandardHeader();*/

/* Trim URL and add http:// if it contains no
protocol identifier */

sWorkingUrl.TrimLeft();
sWorkingUrl.TrimRight();
if (sWorkingUrl.Find(":") == -1)
{
if (sWorkingUrl.Left(1) == "/")
sWorkingUrl = "http:" + sWorkingUrl;
else
sWorkingUrl = "http://" + sWorkingUrl;
} // End if

/* Check the URL - must be valid and of the 'http:'
service type */
DWORD dwServiceType;
CString sServer, sObject;
unsigned short nPort;
if (AfxParseURL(sWorkingUrl,
dwServiceType,
sServer,
sObject,
nPort))
{
// URL is valid. Now check service type.
if (dwServiceType == AFX_INET_SERVICE_HTTP)
{
// Service type is valid (HTTP). Now make connection.
pSession = new CInternetSession(
m_sUserAgent,
1,
INTERNET_OPEN_TYPE_PRECONFIG);
pConnection = pSession->GetHttpConnection(sServer,
nPort,
NULL,
NULL);

pHttpFile = pConnection->OpenRequest(
CHttpConnection::HTTP_VERB_POST,
sObject,
//sServer,
//"http://bbs2.sina.com.cn/fbin/add.pl?forumid=71",
sUrl,
1,
NULL,
NULL,
INTERNET_FLAG_EXISTING_CONNECT
| INTERNET_FLAG_RELOAD
| INTERNET_FLAG_DONT_CACHE);
strcpy (sTemp, sData);
pHttpFile->SendRequest(sHeaders,
sTemp,
sData.GetLength());
if (pHttpFile) /* SendRequest worked */
{
// Check the http return code
if (!pHttpFile->QueryInfoStatusCode(dwHttpStatus))
dwHttpStatus = 200;

if (dwHttpStatus >= 400)
{
switch(dwHttpStatus)
{
case 404:
nResult = CROBOT_ERR_NOT_FOUND;
break;
case 403:
case 407:
nResult = CROBOT_ERR_NOT_AUTHORIZED;
break;
default:
nResult = CROBOT_ERR_CONNECTION_FAILED;
break;
} // End switch
} // End if dwHttpStatus
else /* No error - read response data */
{
nResult = CROBOT_ERR_SUCCESS;
do
{
nRead = pHttpFile->Read(pBuffer, 1023);
if (nRead != 0)
{
pBuffer[nRead] = 0;
sResult += pBuffer;
} // End if
} while (nRead != 0);
sResponse = sResult;
} // End else
} // End if pHttpFile
else /* SendRequest failed */
{
nResult = CROBOT_ERR_CONNECTION_FAILED;
} // End else
} // End if
else
// Wrong service
nResult = CROBOT_ERR_INVALID_URL;
} // End if
else
// Invalid URL
nResult = CROBOT_ERR_INVALID_URL;
} // End try

catch (CInternetException* e)
{
e->Delete();
sResponse = sResult;

// Exception occurred
nResult = CROBOT_ERR_CONNECTION_FAILED;
} // End catch
catch (...)
{
sResponse = sResult;

// Exception occurred
nResult = CROBOT_ERR_CONNECTION_FAILED;
} // End catch

// Clean up and exit function

if (pBuffer != NULL)
{
delete pBuffer;
pBuffer = NULL;
} // End if

if (pHttpFile != NULL)
{
pHttpFile->Close();
delete pHttpFile;
} // End if

if (pConnection != NULL)
{
pConnection->Close();
delete pConnection;
} // End if

if (pSession != NULL)
{
pSession->Close();
delete pSession;
} // End if

sErrMsg = ErrorMessage(nResult);
if (nResult == CROBOT_ERR_SUCCESS)
return true;
else
return false;
}

/*
版权所有:周田鼠
http://www.geocities.com/zhoutianshu
zhoutianshu@yahoo.com
感谢空心菜。
*/


// mfcapp.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "mfcapp.h"
#include "postdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMfcappApp

BEGIN_MESSAGE_MAP(CMfcappApp, CWinApp)
//{{AFX_MSG_MAP(CMfcappApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMfcappApp construction

CMfcappApp::CMfcappApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CMfcappApp object

CMfcappApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CMfcappApp initialization

BOOL CMfcappApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.

PostDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}

// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}


/*
版权所有:周田鼠
http://www.geocities.com/zhoutianshu
zhoutianshu@yahoo.com
感谢空心菜。
*/
#include "stdafx.h"
#include "mfcapp.h"
#include "PostDlg.h"
#include "crobotinternet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define TRYNUM 3
//#define SETMESSAGE

/////////////////////////////////////////////////////////////////////////////
// PostDlg dialog


PostDlg::PostDlg(CWnd* pParent /*=NULL*/)
: CDialog(PostDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(PostDlg)
m_author = _T("");
m_body = _T("");
m_subject = _T("");
m_urlname = _T("");
m_copyfrom = _T("");
m_pass = _T("");
m_refimg = _T("");
m_refurl = _T("");
m_newORreply = -1;
m_newORreply=0;
m_refid = _T("");
//}}AFX_DATA_INIT
}


void PostDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(PostDlg)
DDX_Text(pDX, IDC_AUTHOR, m_author);
DDX_Text(pDX, IDC_BODY, m_body);
DDX_Text(pDX, IDC_TITLE, m_subject);
DDX_Text(pDX, IDC_URLNAME, m_urlname);
DDX_Text(pDX, IDC_COPYFROM, m_copyfrom);
DDX_Text(pDX, IDC_PASS, m_pass);
DDX_Text(pDX, IDC_REFIMG, m_refimg);
DDX_Text(pDX, IDC_REFURL, m_refurl);
DDX_Radio(pDX, IDC_RADIO1, m_newORreply);
DDX_Text(pDX, IDC_REFID, m_refid);
//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(PostDlg, CDialog)
//{{AFX_MSG_MAP(PostDlg)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// PostDlg message handlers

void PostDlg::OnOK()
{
PostRichwin();
//CDialog::OnOK();
}

void PostDlg::PostRichwin()
{

UpdateData();

//convert abnormal characters
TransformString(m_author);
TransformString(m_body);
TransformString(m_copyfrom);
TransformString(m_pass);
TransformString(m_refimg);
TransformString(m_refurl);
TransformString(m_subject);
TransformString(m_urlname);

CRobotInternet internet;
CString sURL, sData, sResponse, sErrMsg;
int nResult;
int i = 0;
internet.m_sUserAgent = "Mozilla/4.0 (compatible; MSIE4.0; windows95)";

//首先进行登陆
sURL = "http://bbs2.sina.com.cn/newfbin/add.pl";
sData = "forumid=71&type=login&loginname="+m_author+"&password="+m_pass;
internet.httpPost(sURL,sData, sResponse, nResult, sErrMsg);

if(!m_newORreply) //加新帖
{
sURL = "http://bbs2.sina.com.cn/newfbin/post.pl?forumid=71";
sData = "post=new&forumid=71&subject=" + m_subject +
"©from=" + m_copyfrom +
"&body=" + m_body ;
"&urlname=" + m_urlname +
"&refurl=" + m_refurl +
"&refimg=" + m_refimg;
if(internet.httpPost(sURL,sData, sResponse, nResult, sErrMsg))
::MessageBox(NULL,sResponse,"返回信息",MB_OK);
}
else //回帖
{
sURL = "http://bbs2.sina.com.cn/newfbin/post.pl?forumid=71";
sData = "post=reply&forumid=71&subject=" + m_subject +
"&postid=" + m_refid +
"©from=" + m_copyfrom +
"&body=" + m_body ;
"&urlname=" + m_urlname +
"&refurl=" + m_refurl +
"&refimg=" + m_refimg;
if(internet.httpPost(sURL,sData, sResponse, nResult, sErrMsg))
::MessageBox(NULL,sResponse,"返回信息",MB_OK);
}
}
void PostDlg::TransformString(CString &s)
{
CString t = "";
int i;
for(i = 0; i < s.GetLength(); i++) {
switch (s.GetAt(i)) {
case '&':
t = t + "%26";
break;
case '%':
t = t + "%25";
break;
case '<':
t = t + "%3c";
break;
case '>':
t = t + "%3e";
break;
case '=':
t = t + "%3d";
break;
default:
t = t + s.GetAt(i);
break;
}
}
s = t;
}


void trash()
{
/*
//1LLFC
sURL = "http://www.bbsland.com/cgi-bin/post_rm.cgi";
sData = "name=" + sName +
"&usrpwd=" +
"&sender=" + sName +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle;
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "LLFC", MB_OK);
#endif
//2自助移名加拿大 not
sURL = "http://yangyang.virtualave.net/canada/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "自助移名加拿大", MB_OK);
#endif


//3海阔天空论坛
sURL = "http://www.toptoday.com/cgi-freebbs/freeforum.cgi?corydon";
sData = "name=" + sName +
"&password=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "海阔天空论坛", MB_OK);
#endif


//4统独论坛http://omniboard.hypermart.net/ui/mainpage.pl
sURL = "http://omniboard.hypermart.net/ui/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "统独论坛", MB_OK);
#endif


//5万维读者论坛 http://www.creaders.org/cgi-bin/mainpage.cgi
sURL = "http://www.creaders.org/cgi-bin/post_pol.cgi";
sData = "name=" + sName +
"&usrpwd=" +
"&sender=" + sName +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "万维读者论坛", MB_OK);
#endif


//6华岳政治时事论坛 http://www.washeng.com/HuaShan/BBS/shishi/gbcurrent.html
sURL = "http://washeng.com/cgi-bin/hbbs-add.cgi";
sData = "barcode=1909434&forum=shishi&lang=gb&action=add&shijian=20:22:59&username=" + sName +
"&password=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "华岳政治时事论坛", MB_OK);
#endif


//7外交与方略http://omniboard.hypermart.net/diplomacy/mainpage.pl
sURL = "http://omniboard.hypermart.net/diplomacy/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "外交与方略", MB_OK);
#endif


//8文学城论坛http://www.chinese-e.com/cgi-bin/life.pl
sURL = "http://www.chinese-e.com/cgi-bin/lifeboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "文学城论坛", MB_OK);
#endif


//9新华通论坛http://207.151.76.245/cgi-bin/mainpage.pl not
sURL = "http://207.151.76.245/cgi-bin/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "新华通论坛", MB_OK);
#endif

//10新大陆http://www.bbsland.com/cgi-bin/newland.cgi
sURL = "http://www.bbsland.com/cgi-bin/post_nl.cgi";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "新大陆", MB_OK);
#endif

//11世界军事论坛http://www.wforum.com/home/wmfmain.html
sURL = "http://www.wforum.com/cgi-bin/wmf/anyboard.cgi/wmf/";
sData = "abc=hV&cmd=sA&name=" + sName +
"&passwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "世界军事论坛", MB_OK);
#endif

//12战争风云http://omniboard.hypermart.net/military/mainpage.pl
sURL = "http://omniboard.hypermart.net/military/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "战争风云", MB_OK);
#endif

//13指点江山http://207.151.76.248/cgi-bin/mainpage.pl
sURL = "http://207.151.76.248/cgi-bin/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "指点江山", MB_OK);
#endif

//14风花雪月http://207.151.76.247/cgi-bin/mainpage.pl
sURL = "http://207.151.76.247/cgi-bin/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "风花雪月", MB_OK);
#endif


//15大家论坛http://www.duoweinews.com/BBS/Dajia/mainpage.cgi?encoding=gb
sURL = "http://www.duoweinews.com/BBS/Dajia/mainboard.cgi";
sData = "name=" + sName +
"&usrpwd=" +
"&email=&unidoc=gb2312" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "大家论坛", MB_OK);
#endif

//16你说我说论坛http://nsws.hypermart.net/forum/mainpage.pl
sURL = "http://nsws.hypermart.net/forum/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "你说我说论坛", MB_OK);
#endif

//17海阔天空论坛http://www.toptoday.com/freebbs/corydon/corydon1.shtml
sURL = "http://nsws.hypermart.net/forum/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "海阔天空论坛", MB_OK);
#endif

//18新闻论坛 http://www.jumperhome.com/forums/F-pltc.htm
sURL = "http://www.jumperhome.com/cgi-bin/pltc-mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&sort=[随便谈谈]" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "新闻论坛", MB_OK);
#endif

//19大中华强国论坛http://www.auch.com.au/greatchina/forum/mainpage.pl
sURL = "http://www.auch.com.au/greatchina/forum/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "大中华强国论坛", MB_OK);
#endif

//20校友论坛http://www.omnitalk.net/alumni/mainpage.pl
sURL = "http://www.omnitalk.net/alumni/mainboard.pl";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "校友论坛", MB_OK);
#endif

//21中 国 学 生 在 美 国http://www.cstudent.com/usabbs/usabbs1.shtml
sURL = "http://www.cstudent.com/cgi-usabbs/usabbs.cgi";
sData = "name=" + sName +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "中 国 学 生 在 美 国", MB_OK);
#endif

//22茗香茶语http://www.bbsland.com/cgi-bin/tea.cgi
sURL = "http://www.bbsland.com/cgi-bin/post_tea.cgi";
sData = "name=" + sName +
"&usrpwd=" +
"&email=" +
"&subject=" + sTitle +
"&body=" + sBody +
"&url=" + sUrl +
"&url_title=" + sUrlTitle +
"&img=";
for (i = 0; i < TRYNUM; i++)
if (internet.httpPost(sURL,sData, sFile, nResult, sErrMsg)) break;
#ifdef SETMESSAGE
if (i <= TRYNUM)
MessageBox(NULL, sFile, "茗香茶语", MB_OK);
#endif


//23新浪http://bbs2.sina.com.cn/fbin/list.pl?forumid=46&startfullpath=/939588307c25771&count=150

sName = "full123";
sURL = "http://bbs2.sina.com.cn/fbin/post.pl";
sData = "author=" + sName +
"&password=" + sName +
"&email=" +
"&subject=" + sTitle +
"©from=" +
"&body=" + sBody +
"&urlname" + sUrlTitle +
"&refurl=" + sUrl +
"&refimg=";
while(!internet.httpPost(sURL,sData, sFile, nResult, sErrMsg, "multipart/form-data")){
MessageBox(NULL, sErrMsg, "", MB_OK);
};
MessageBox(NULL, sFile, "中 国 学 生 在 美 国", MB_OK);
*/
}

void PostDlg::OnRadio1()
{
GetDlgItem(IDC_REFID)->EnableWindow(FALSE);
GetDlgItem(IDC_REPSTATIC)->EnableWindow(FALSE);
}

void PostDlg::OnRadio2()
{
GetDlgItem(IDC_REFID)->EnableWindow(TRUE);
GetDlgItem(IDC_REPSTATIC)->EnableWindow(TRUE);
}

BOOL PostDlg::OnInitDialog()
{
CDialog::OnInitDialog();

GetDlgItem(IDC_REFID)->EnableWindow(FALSE);
GetDlgItem(IDC_REPSTATIC)->EnableWindow(FALSE);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}


/*
版权所有:周田鼠
http://www.geocities.com/zhoutianshu
zhoutianshu@yahoo.com
感谢空心菜。
*/


// stdafx.cpp : source file that includes just the standard includes
// mfcapp.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

oldmonsterman 2001-07-11
  • 打赏
  • 举报
回复
请各位高人快点回复
wjyasd 2001-07-11
  • 打赏
  • 举报
回复
gz
oldmonsterman 2001-07-11
  • 打赏
  • 举报
回复
感谢coolstar,等结贴是一块给份,抱歉

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧