// ISAPI_Test.h 헤더파일
class CISAPI_TestFilter : public CHttpFilter
{
public:
CISAPI_TestFilter();
~CISAPI_TestFilter();
// Overrides
// ClassWizard generated virtual function overrides
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//{{AFX_VIRTUAL(CISAPI_TestFilter)
public:
virtual BOOL GetFilterVersion(PHTTP_FILTER_VERSION pVer);
virtual DWORD HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD dwNotificationType, LPVOID pvNotification);
//}}AFX_VIRTUAL
//{{AFX_MSG(CISAPI_TestFilter)
//}}AFX_MSG
};
// ISAPI_Test.cpp 모듈
#include "ISAPI_Test.h"
CWinApp theApp;
CISAPI_TestFilter theFilter;
CISAPI_TestFilter::CISAPI_TestFilter()
{
}
CISAPI_TestFilter::~CISAPI_TestFilter()
{
}
BOOL CISAPI_TestFilter::GetFilterVersion(PHTTP_FILTER_VERSION pVer)
{
// Call default implementation for initialization
CHttpFilter::GetFilterVersion(pVer);
//pVer->dwFilterVersion = HTTP_FILTER_REVISION;
//기본적으로 위 값이 세팅된다.
// Clear the flags set by base class
pVer->dwFlags &= ~SF_NOTIFY_ORDER_MASK;
// Set the flags we are interested in
pVer->dwFlags |= SF_NOTIFY_ORDER_DEFAULT | SF_NOTIFY_SECURE_PORT | SF_NOTIFY_NONSECURE_PORT
| SF_NOTIFY_URL_MAP;
// Load description string
TCHAR sz[SF_MAX_FILTER_DESC_LEN+1];
ISAPIVERIFY(::LoadString(AfxGetResourceHandle(),
IDS_FILTER, sz, SF_MAX_FILTER_DESC_LEN));
_tcscpy(pVer->lpszFilterDesc, sz);
return TRUE;
}
DWORD CISAPI_TestFilter::HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD dwNotificationType, LPVOID pvNotification)
{
// TODO: Add your specialized code here and/or call the base class
if (dwNotificationType == SF_NOTIFY_URL_MAP )
return ::OnUrlMap(pfc, (PHTTP_FILTER_URL_MAP) pvNotification );
else
return CHttpFilter::HttpFilterProc(pfc, dwNotificationType, pvNotification);
}
DWORD onUrlMap(HTTP_FILTER_CONTEXT *pfc, HTTP_FILTER_URL_MAP *pvData) {
{
// TODO: React to this notification accordingly and
// return the appropriate status code
char szTemp[1000];
if (strstr(strlwr((char*) pMapInfo->pszURL), "thermidor"))
{
CHAR* pszNewURL = "Location: http://user.chollian.net/~thermidor";
wsprintf(szTemp, "%s\r\n\r\n", pszNewURL);
pCtxt->ServerSupportFunction(SF_REQ_SEND_RESPONSE_HEADER, (LPVOID) "302 Redirect",
(LPDWORD) szTemp, 0);
return SF_STATUS_REQ_FINISHED;
}
char* pszFileName = "D:\\ISAPI.Log";
char Temp[1000];
CHAR szServer[500];
DWORD dwSize;
FILE *pFile;
pFile = fopen(pszFileName, "a+");
pCtxt->GetServerVariable("SERVER_NAME", (LPVOID) szServer, &dwSize);
wsprintf(Temp, "http://%s - %s\r\n", szServer, pMapInfo->pszURL);
fprintf(pFile, Temp);
//fflush(pFile);
fclose(pFile);
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
#if 0
BEGIN_MESSAGE_MAP(CISAPI_TestFilter, CHttpFilter)
//{{AFX_MSG_MAP(CISAPI_TestFilter)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
'Tech: > C·C++' 카테고리의 다른 글
[펌] Win32 API FAQ (1) | 2008.06.26 |
---|---|
VC++2005 배포 (0) | 2008.06.26 |
C++ 동기화 객체(Critical Section, Mutex, Semaphore, Event) (0) | 2008.06.26 |
ISAPI Filter 예제 1 (MFC) (0) | 2008.06.26 |
ISAPI Filter에 대해... (1) (0) | 2008.06.26 |