00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(AFX_SECURITY_H__85BE0E66_93D0_44B1_BEE1_E2C3C81CB8AF__INCLUDED_)
00023 #define AFX_SECURITY_H__85BE0E66_93D0_44B1_BEE1_E2C3C81CB8AF__INCLUDED_
00024
00025 #pragma once
00026
00027 class CSecureRule;
00028 class CXMLElement;
00029
00030
00031 class CSecurity
00032 {
00033
00034 public:
00035 CSecurity();
00036 virtual ~CSecurity();
00037
00038
00039 public:
00040 BOOL m_bDenyPolicy;
00041 protected:
00042 CPtrList m_pRules;
00043 public:
00044 static LPCTSTR xmlns;
00045
00046
00047 public:
00048 POSITION GetIterator() const;
00049 CSecureRule* GetNext(POSITION& pos) const;
00050 int GetCount();
00051 BOOL Check(CSecureRule* pRule) const;
00052 CSecureRule* GetGUID(const GUID& pGUID) const;
00053 public:
00054 void Add(CSecureRule* pRule);
00055 void Remove(CSecureRule* pRule);
00056 void MoveUp(CSecureRule* pRule);
00057 void MoveDown(CSecureRule* pRule);
00058 void Ban(IN_ADDR* pAddress, int nBanLength, BOOL bMessage = TRUE);
00059 public:
00060 void Clear();
00061 BOOL IsDenied(IN_ADDR* pAddress, LPCTSTR pszContent = NULL);
00062 BOOL IsAccepted(IN_ADDR* pAddress, LPCTSTR pszContent = NULL);
00063 void Expire();
00064 public:
00065 BOOL Load();
00066 BOOL Save(BOOL bLock = FALSE);
00067 BOOL Import(LPCTSTR pszFile);
00068 CXMLElement* ToXML(BOOL bRules = TRUE);
00069 BOOL FromXML(CXMLElement* pXML);
00070 protected:
00071 void Serialize(CArchive& ar);
00072
00073 };
00074
00075 enum
00076 {
00077 banSession, ban5Mins, ban30Mins, ban2Hours, banWeek, banForever
00078 };
00079
00080 class CSecureRule
00081 {
00082
00083 public:
00084 CSecureRule(BOOL bCreate = TRUE);
00085 virtual ~CSecureRule();
00086
00087
00088 public:
00089 int m_nType;
00090 BYTE m_nAction;
00091 CString m_sComment;
00092 GUID m_pGUID;
00093 public:
00094 DWORD m_nExpire;
00095 DWORD m_nToday;
00096 DWORD m_nEver;
00097 public:
00098 BYTE m_nIP[4];
00099 BYTE m_nMask[4];
00100 TCHAR* m_pContent;
00101
00102 enum { srAddress, srContent };
00103 enum { srNull, srAccept, srDeny };
00104 enum { srIndefinite = 0, srSession = 1 };
00105
00106
00107 public:
00108 void Remove();
00109 void Reset();
00110 void MaskFix();
00111 BOOL IsExpired(DWORD nNow, BOOL bSession = FALSE);
00112 BOOL Match(IN_ADDR* pAddress, LPCTSTR pszContent = NULL);
00113 void SetContentWords(const CString& strContent);
00114 CString GetContentWords();
00115 public:
00116 void Serialize(CArchive& ar, int nVersion);
00117 CXMLElement* ToXML();
00118 BOOL FromXML(CXMLElement* pXML);
00119 CString ToGnucleusString();
00120 BOOL FromGnucleusString(CString& str);
00121
00122 };
00123
00124
00125 class CAdultFilter
00126 {
00127
00128 public:
00129 CAdultFilter();
00130 virtual ~CAdultFilter();
00131
00132
00133 private:
00134 LPTSTR m_pszBlockedWords;
00135 LPTSTR m_pszDubiousWords;
00136
00137
00138 public:
00139 void Load();
00140 BOOL IsHitAdult( LPCTSTR );
00141 BOOL IsSearchFiltered( LPCTSTR );
00142 BOOL IsChatFiltered( LPCTSTR );
00143 BOOL Censor( TCHAR* );
00144 private:
00145 BOOL IsFiltered( LPCTSTR );
00146 };
00147
00148
00149 class CMessageFilter
00150 {
00151
00152 public:
00153 CMessageFilter();
00154 virtual ~CMessageFilter();
00155
00156
00157 private:
00158 LPTSTR m_pszED2KSpam;
00159 LPTSTR m_pszFilteredPhrases;
00160
00161
00162 public:
00163 void Load();
00164 BOOL IsED2KSpam( LPCTSTR );
00165 BOOL IsFiltered( LPCTSTR );
00166 };
00167
00168 extern CMessageFilter MessageFilter;
00169 extern CAdultFilter AdultFilter;
00170 extern CSecurity Security;
00171
00172 #endif // !defined(AFX_SECURITY_H__85BE0E66_93D0_44B1_BEE1_E2C3C81CB8AF__INCLUDED_)