#if !defined(AFX_UPTIME_H__EF2FAE8C_C347_451E_89AE_100EBC61E4C8__INCLUDED_)
#define AFX_UPTIME_H__EF2FAE8C_C347_451E_89AE_100EBC61E4C8__INCLUDED_

// UPTIME.H - Header file for your Internet Server
//    Uptime Filter

#include "resource.h"

class LogInfo : public CObject
{
public:
	DWORD m_dwHits;
};

class CUptimeFilter : public CHttpFilter
{
public:
	CUptimeFilter();
	~CUptimeFilter();

// 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(CUptimeFilter)
	public:
	virtual BOOL GetFilterVersion(PHTTP_FILTER_VERSION pVer);
	virtual DWORD OnPreprocHeaders(CHttpFilterContext* pCtxt, PHTTP_FILTER_PREPROC_HEADERS pHeaderInfo);
	virtual DWORD OnEndOfNetSession(CHttpFilterContext* pCtxt);
	//}}AFX_VIRTUAL

protected:

	// Function to record a hit in a map (of hits to LogInfo objects)
	void RecordHit(CMapStringToOb& Map, const char *str);

	// Function to show the map that the above func has been recording hits into
	void ShowHitMap(CHttpFilterContext* pCtxt, CMapStringToOb& Map, const char *pszTitle, const char *pszHdr);

	// Time the web server was started
	time_t m_tStartup;

	// Total hits since the server started
	DWORD m_dwHits;

	// The last hour we had a hit recorded in
	int m_nLastHour;

	// 24 slots for the hourly stats
	DWORD m_dwHours[24];

	// Map of hits by URL
	CMapStringToOb m_mByPage;

	// Map of hits by IP address
	CMapStringToOb m_mByUser;

	// Map of hits by web browser
	CMapStringToOb m_mByBrowser;

	// Map of hits by Referer 
	CMapStringToOb m_mByReferer;

	// Mutex: protect these var from multiple threads corrupting each other
	CMutex m_mxStats;

	// The recent hits list (FIFO)
	CStringList m_slRecentHits;

	//{{AFX_MSG(CUptimeFilter)
	//}}AFX_MSG
};

const int nMaxRecentHits = 100;

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_UPTIME_H__EF2FAE8C_C347_451E_89AE_100EBC61E4C8__INCLUDED)

