Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

328 lines
11 KiB

  1. // LogExtPg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include <iadmw.h>
  5. #include "logui.h"
  6. #include "LogExtPg.h"
  7. #include "wrapmb.h"
  8. #include "metatool.h"
  9. #include <iiscnfg.h>
  10. #include <logconst.h>
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CLogExtended property page
  18. IMPLEMENT_DYNCREATE(CLogExtended, CPropertyPage)
  19. CLogExtended::CLogExtended() : CPropertyPage(CLogExtended::IDD),
  20. m_fInitialized( FALSE )
  21. {
  22. //{{AFX_DATA_INIT(CLogExtended)
  23. m_bool_bytesreceived = FALSE;
  24. m_bool_bytessent = FALSE;
  25. m_bool_clientip = FALSE;
  26. m_bool_cookie = FALSE;
  27. m_bool_date = FALSE;
  28. m_bool_httpstatus = FALSE;
  29. m_bool_referer = FALSE;
  30. m_bool_serverip = FALSE;
  31. m_bool_servername = FALSE;
  32. m_bool_servicename = FALSE;
  33. m_bool_time = FALSE;
  34. m_bool_timetaken = FALSE;
  35. m_bool_uriquery = FALSE;
  36. m_bool_uristem = FALSE;
  37. m_bool_useragent = FALSE;
  38. m_bool_username = FALSE;
  39. m_bool_win32status = FALSE;
  40. m_bool_method = FALSE;
  41. m_bool_serverport = FALSE;
  42. m_bool_version = FALSE;
  43. //}}AFX_DATA_INIT
  44. }
  45. CLogExtended::~CLogExtended()
  46. {
  47. }
  48. void CLogExtended::DoDataExchange(CDataExchange* pDX)
  49. {
  50. CPropertyPage::DoDataExchange(pDX);
  51. //{{AFX_DATA_MAP(CLogExtended)
  52. DDX_Check(pDX, IDC_CHK_BYTESRECEIVED, m_bool_bytesreceived);
  53. DDX_Check(pDX, IDC_CHK_BYTESSENT, m_bool_bytessent);
  54. DDX_Check(pDX, IDC_CHK_CLIENTIP, m_bool_clientip);
  55. DDX_Check(pDX, IDC_CHK_COOKIE, m_bool_cookie);
  56. DDX_Check(pDX, IDC_CHK_DATE, m_bool_date);
  57. DDX_Check(pDX, IDC_CHK_HTTPSTATUS, m_bool_httpstatus);
  58. DDX_Check(pDX, IDC_CHK_REFERER, m_bool_referer);
  59. DDX_Check(pDX, IDC_CHK_SERVERIP, m_bool_serverip);
  60. DDX_Check(pDX, IDC_CHK_SERVERNAME, m_bool_servername);
  61. DDX_Check(pDX, IDC_CHK_SERVICENAME, m_bool_servicename);
  62. DDX_Check(pDX, IDC_CHK_TIME, m_bool_time);
  63. DDX_Check(pDX, IDC_CHK_TIMETAKEN, m_bool_timetaken);
  64. DDX_Check(pDX, IDC_CHK_URI_QUERY, m_bool_uriquery);
  65. DDX_Check(pDX, IDC_CHK_URISTEM, m_bool_uristem);
  66. DDX_Check(pDX, IDC_CHK_USERAGENT, m_bool_useragent);
  67. DDX_Check(pDX, IDC_CHK_USERNAME, m_bool_username);
  68. DDX_Check(pDX, IDC_CHK_WIN32STATUS, m_bool_win32status);
  69. DDX_Check(pDX, IDC_METHOD, m_bool_method);
  70. DDX_Check(pDX, IDC_CHK_SERVERPORT, m_bool_serverport);
  71. DDX_Check(pDX, IDC_CHK_VERSION, m_bool_version);
  72. //}}AFX_DATA_MAP
  73. }
  74. //--------------------------------------------------------------------------
  75. BEGIN_MESSAGE_MAP(CLogExtended, CPropertyPage)
  76. //{{AFX_MSG_MAP(CLogExtended)
  77. ON_BN_CLICKED(IDC_CHK_BYTESRECEIVED, OnChkBytesreceived)
  78. ON_BN_CLICKED(IDC_CHK_BYTESSENT, OnChkBytessent)
  79. ON_BN_CLICKED(IDC_CHK_CLIENTIP, OnChkClientip)
  80. ON_BN_CLICKED(IDC_CHK_COOKIE, OnChkCookie)
  81. ON_BN_CLICKED(IDC_CHK_DATE, OnChkDate)
  82. ON_BN_CLICKED(IDC_CHK_HTTPSTATUS, OnChkHttpstatus)
  83. ON_BN_CLICKED(IDC_CHK_REFERER, OnChkReferer)
  84. ON_BN_CLICKED(IDC_CHK_SERVERIP, OnChkServerip)
  85. ON_BN_CLICKED(IDC_CHK_SERVERNAME, OnChkServername)
  86. ON_BN_CLICKED(IDC_CHK_SERVICENAME, OnChkServicename)
  87. ON_BN_CLICKED(IDC_CHK_TIME, OnChkTime)
  88. ON_BN_CLICKED(IDC_CHK_TIMETAKEN, OnChkTimetaken)
  89. ON_BN_CLICKED(IDC_CHK_URI_QUERY, OnChkUriQuery)
  90. ON_BN_CLICKED(IDC_CHK_URISTEM, OnChkUristem)
  91. ON_BN_CLICKED(IDC_CHK_USERAGENT, OnChkUseragent)
  92. ON_BN_CLICKED(IDC_CHK_USERNAME, OnChkUsername)
  93. ON_BN_CLICKED(IDC_CHK_WIN32STATUS, OnChkWin32status)
  94. ON_BN_CLICKED(IDC_METHOD, OnMethod)
  95. //}}AFX_MSG_MAP
  96. ON_COMMAND(ID_HELP_FINDER, DoHelp)
  97. ON_COMMAND(ID_HELP, DoHelp)
  98. ON_COMMAND(ID_CONTEXT_HELP, DoHelp)
  99. ON_COMMAND(ID_DEFAULT_HELP, DoHelp)
  100. END_MESSAGE_MAP()
  101. //---------------------------------------------------------------------------
  102. void CLogExtended::DoHelp()
  103. {
  104. WinHelp( HIDD_LOGUI_EXTENDED );
  105. }
  106. //--------------------------------------------------------------------------
  107. void CLogExtended::Init()
  108. {
  109. DWORD dwFlags;
  110. BOOL fGotIt = FALSE;
  111. // we will be pulling stuff out of the metabase here
  112. // prepare the metabase wrapper
  113. CWrapMetaBase mbWrap;
  114. if ( !mbWrap.FInit(m_pMB) ) return;
  115. // open the target
  116. if ( mbWrap.Open( m_szMeta, METADATA_PERMISSION_READ ) )
  117. {
  118. // start with the logging period
  119. fGotIt = mbWrap.GetDword( _T(""), MD_LOGEXT_FIELD_MASK, IIS_MD_UT_SERVER, &dwFlags, METADATA_INHERIT );
  120. // close the metabase
  121. mbWrap.Close();
  122. }
  123. // if we didn't get it, use the default values
  124. if ( !fGotIt )
  125. dwFlags = DEFAULT_EXTLOG_FIELDS;
  126. // seperate out all the fields
  127. UpdateData( TRUE );
  128. if ( dwFlags & EXTLOG_BYTES_RECV ) m_bool_bytesreceived = TRUE;
  129. if ( dwFlags & EXTLOG_BYTES_SENT ) m_bool_bytessent = TRUE;
  130. if ( dwFlags & EXTLOG_CLIENT_IP ) m_bool_clientip = TRUE;
  131. if ( dwFlags & EXTLOG_COOKIE ) m_bool_cookie = TRUE;
  132. if ( dwFlags & EXTLOG_DATE ) m_bool_date = TRUE;
  133. if ( dwFlags & EXTLOG_HTTP_STATUS ) m_bool_httpstatus = TRUE;
  134. if ( dwFlags & EXTLOG_REFERER ) m_bool_referer = TRUE;
  135. if ( dwFlags & EXTLOG_SERVER_IP ) m_bool_serverip = TRUE;
  136. if ( dwFlags & EXTLOG_SERVER_PORT ) m_bool_serverport = TRUE;
  137. if ( dwFlags & EXTLOG_COMPUTER_NAME ) m_bool_servername = TRUE;
  138. if ( dwFlags & EXTLOG_SITE_NAME ) m_bool_servicename = TRUE;
  139. if ( dwFlags & EXTLOG_TIME ) m_bool_time = TRUE;
  140. if ( dwFlags & EXTLOG_TIME_TAKEN ) m_bool_timetaken = TRUE;
  141. if ( dwFlags & EXTLOG_URI_QUERY ) m_bool_uriquery = TRUE;
  142. if ( dwFlags & EXTLOG_URI_STEM ) m_bool_uristem = TRUE;
  143. if ( dwFlags & EXTLOG_USER_AGENT ) m_bool_useragent = TRUE;
  144. if ( dwFlags & EXTLOG_USERNAME ) m_bool_username = TRUE;
  145. if ( dwFlags & EXTLOG_WIN32_STATUS ) m_bool_win32status = TRUE;
  146. if ( dwFlags & EXTLOG_METHOD ) m_bool_method = TRUE;
  147. if ( dwFlags & EXTLOG_PROTOCOL_VERSION ) m_bool_version = TRUE;
  148. // set the data back
  149. UpdateData( FALSE );
  150. }
  151. /////////////////////////////////////////////////////////////////////////////
  152. // CLogExtended message handlers
  153. //--------------------------------------------------------------------------
  154. BOOL CLogExtended::OnSetActive()
  155. {
  156. // if we haven't been initialized yet, do so
  157. if ( !m_fInitialized )
  158. {
  159. Init();
  160. m_fInitialized = TRUE;
  161. }
  162. return CPropertyPage::OnSetActive();
  163. }
  164. //--------------------------------------------------------------------------
  165. BOOL CLogExtended::OnApply()
  166. {
  167. DWORD dwFlags = 0;
  168. BOOL f;
  169. // prepare the extended logging flag
  170. if ( m_bool_bytesreceived ) dwFlags |= EXTLOG_BYTES_RECV;
  171. if ( m_bool_bytessent ) dwFlags |= EXTLOG_BYTES_SENT;
  172. if ( m_bool_clientip ) dwFlags |= EXTLOG_CLIENT_IP;
  173. if ( m_bool_cookie ) dwFlags |= EXTLOG_COOKIE;
  174. if ( m_bool_date ) dwFlags |= EXTLOG_DATE;
  175. if ( m_bool_httpstatus ) dwFlags |= EXTLOG_HTTP_STATUS;
  176. if ( m_bool_referer ) dwFlags |= EXTLOG_REFERER;
  177. if ( m_bool_serverport ) dwFlags |= EXTLOG_SERVER_PORT;
  178. if ( m_bool_serverip ) dwFlags |= EXTLOG_SERVER_IP;
  179. if ( m_bool_servername ) dwFlags |= EXTLOG_COMPUTER_NAME;
  180. if ( m_bool_servicename ) dwFlags |= EXTLOG_SITE_NAME;
  181. if ( m_bool_time ) dwFlags |= EXTLOG_TIME;
  182. if ( m_bool_timetaken ) dwFlags |= EXTLOG_TIME_TAKEN;
  183. if ( m_bool_uriquery ) dwFlags |= EXTLOG_URI_QUERY;
  184. if ( m_bool_uristem ) dwFlags |= EXTLOG_URI_STEM;
  185. if ( m_bool_useragent ) dwFlags |= EXTLOG_USER_AGENT;
  186. if ( m_bool_username ) dwFlags |= EXTLOG_USERNAME;
  187. if ( m_bool_win32status ) dwFlags |= EXTLOG_WIN32_STATUS;
  188. if ( m_bool_method ) dwFlags |= EXTLOG_METHOD;
  189. if ( m_bool_version ) dwFlags |= EXTLOG_PROTOCOL_VERSION;
  190. // set the extended logging logging field mask
  191. f = SetMetaDword( m_pMB, m_szServer, m_szMeta, _T(""), MD_LOGEXT_FIELD_MASK,
  192. IIS_MD_UT_SERVER, dwFlags, TRUE );
  193. SetModified( FALSE );
  194. return CPropertyPage::OnApply();
  195. }
  196. //--------------------------------------------------------------------------
  197. void CLogExtended::OnChkBytesreceived()
  198. {
  199. SetModified();
  200. }
  201. //--------------------------------------------------------------------------
  202. void CLogExtended::OnChkBytessent()
  203. {
  204. SetModified();
  205. }
  206. //--------------------------------------------------------------------------
  207. void CLogExtended::OnChkClientip()
  208. {
  209. SetModified();
  210. }
  211. //--------------------------------------------------------------------------
  212. void CLogExtended::OnChkCookie()
  213. {
  214. SetModified();
  215. }
  216. //--------------------------------------------------------------------------
  217. void CLogExtended::OnChkDate()
  218. {
  219. SetModified();
  220. }
  221. //--------------------------------------------------------------------------
  222. void CLogExtended::OnChkHttpstatus()
  223. {
  224. SetModified();
  225. }
  226. //--------------------------------------------------------------------------
  227. void CLogExtended::OnChkReferer()
  228. {
  229. SetModified();
  230. }
  231. //--------------------------------------------------------------------------
  232. void CLogExtended::OnChkServerip()
  233. {
  234. SetModified();
  235. }
  236. //--------------------------------------------------------------------------
  237. void CLogExtended::OnChkServername()
  238. {
  239. SetModified();
  240. }
  241. //--------------------------------------------------------------------------
  242. void CLogExtended::OnChkServicename()
  243. {
  244. SetModified();
  245. }
  246. //--------------------------------------------------------------------------
  247. void CLogExtended::OnChkTime()
  248. {
  249. SetModified();
  250. }
  251. //--------------------------------------------------------------------------
  252. void CLogExtended::OnChkTimetaken()
  253. {
  254. SetModified();
  255. }
  256. //--------------------------------------------------------------------------
  257. void CLogExtended::OnChkUriQuery()
  258. {
  259. SetModified();
  260. }
  261. //--------------------------------------------------------------------------
  262. void CLogExtended::OnChkUristem()
  263. {
  264. SetModified();
  265. }
  266. //--------------------------------------------------------------------------
  267. void CLogExtended::OnChkUseragent()
  268. {
  269. SetModified();
  270. }
  271. //--------------------------------------------------------------------------
  272. void CLogExtended::OnChkUsername()
  273. {
  274. SetModified();
  275. }
  276. //--------------------------------------------------------------------------
  277. void CLogExtended::OnChkWin32status()
  278. {
  279. SetModified();
  280. }
  281. //--------------------------------------------------------------------------
  282. void CLogExtended::OnMethod()
  283. {
  284. SetModified();
  285. }