Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Security.h

Go to the documentation of this file.
00001 //
00002 // Security.h
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 // Construction
00034 public:
00035         CSecurity();
00036         virtual ~CSecurity();
00037 
00038 // Attributes
00039 public:
00040         BOOL            m_bDenyPolicy;
00041 protected:
00042         CPtrList        m_pRules;
00043 public:
00044         static LPCTSTR xmlns;
00045 
00046 // Operations
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 // Construction
00083 public:
00084         CSecureRule(BOOL bCreate = TRUE);
00085         virtual ~CSecureRule();
00086 
00087 // Attributes
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 // Operations
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 // An adult filter class, used in searches, chat, etc
00125 class CAdultFilter
00126 {
00127 // Construction
00128 public:
00129         CAdultFilter();
00130         virtual ~CAdultFilter();
00131 
00132 // Attributes
00133 private:
00134         LPTSTR          m_pszBlockedWords;                      // Definitely adult content
00135         LPTSTR          m_pszDubiousWords;                      // Possibly adult content
00136 
00137 // Operations
00138 public:
00139         void            Load();
00140         BOOL            IsHitAdult( LPCTSTR );          // Does this search result have adult content?
00141         BOOL            IsSearchFiltered( LPCTSTR );// Check if search is filtered
00142         BOOL            IsChatFiltered( LPCTSTR );      // Check filter for chat
00143         BOOL            Censor( TCHAR* );                       // Censor (remove) bad words from a string
00144 private:
00145         BOOL            IsFiltered( LPCTSTR );
00146 };
00147 
00148 // A message filter class for chat messages. (Spam protection)
00149 class CMessageFilter
00150 {
00151 // Construction
00152 public:
00153         CMessageFilter();
00154         virtual ~CMessageFilter();
00155 
00156 // Attributes
00157 private:
00158         LPTSTR          m_pszED2KSpam;                          // Known ED2K spam phrases
00159         LPTSTR          m_pszFilteredPhrases;           // Known spam phrases
00160 
00161 // Operations
00162 public:
00163         void            Load();
00164         BOOL            IsED2KSpam( LPCTSTR );          // ED2K message spam filter (ED2K only, always on)
00165         BOOL            IsFiltered( LPCTSTR );          // Chat message spam filter
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_)

Generated on Thu Dec 15 10:39:48 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2