From 1fa9187be6ac854df0649887a07489a1949046ae Mon Sep 17 00:00:00 2001 From: psychon Date: Wed, 16 May 2007 22:29:39 +0000 Subject: [PATCH] Revs 945-948;952-953: - add timezone offset if server is in another timezone than the client - add prependTimestamp - add version number to configure.in - write connect delay back into znc.conf git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@801 726aef4b-f618-498e-8847-2d620e286838 --- User.cpp | 22 ++++++++++++++++------ User.h | 6 ++++++ configure.in | 2 +- modules/webadmin.cpp | 26 ++++++++++++++++---------- znc.cpp | 15 ++++++++++++++- 5 files changed, 53 insertions(+), 18 deletions(-) diff --git a/User.cpp b/User.cpp index dc784b23..d97f6b42 100644 --- a/User.cpp +++ b/User.cpp @@ -12,6 +12,7 @@ #include "Timers.h" CUser::CUser(const CString& sUserName) { + m_fTimezoneOffset = 0; m_uConnectTime = 0; SetUserName(sUserName); m_sNick = m_sCleanUserName; @@ -39,6 +40,7 @@ CUser::CUser(const CString& sUserName) { m_bBeingDeleted = false; m_sTimestampFormat = "[%H:%M:%S]"; m_bAppendTimestamp = false; + m_bPrependTimestamp = true; m_pKeepNickTimer = new CKeepNickTimer(this); m_pJoinTimer = new CJoinTimer(this); m_pMiscTimer = new CMiscTimer(this); @@ -136,18 +138,22 @@ CString& CUser::AddTimestamp(const CString& sStr, CString& sRet) const { char szTimestamp[1024]; time_t tm; - if(GetTimestampFormat().empty()) { + if(GetTimestampFormat().empty() || (!m_bAppendTimestamp && !m_bPrependTimestamp)) { sRet = sStr; } else { time(&tm); + tm += (time_t)(m_fTimezoneOffset * 60 * 60); // offset is in hours strftime(szTimestamp, sizeof(szTimestamp) / sizeof(char), GetTimestampFormat().c_str(), localtime(&tm)); - if(m_bAppendTimestamp) { - sRet = sStr + " "; - sRet += szTimestamp; - } else { + + sRet = sStr; + if (m_bPrependTimestamp) { sRet = szTimestamp; sRet += " " + sStr; } + if (m_bAppendTimestamp) { + sRet += " "; + sRet += szTimestamp; + } } return sRet; } @@ -387,6 +393,7 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet) { SetDenyLoadMod(User.DenyLoadMod()); SetAdmin(User.IsAdmin()); SetTimestampAppend(User.GetTimestampAppend()); + SetTimestampPrepend(User.GetTimestampPrepend()); SetTimestampFormat(User.GetTimestampFormat()); // !Flags @@ -419,6 +426,7 @@ bool CUser::IsHostAllowed(const CString& sHostMask) { const CString& CUser::GetTimestampFormat() const { return m_sTimestampFormat; } bool CUser::GetTimestampAppend() const { return m_bAppendTimestamp; } +bool CUser::GetTimestampPrepend() const { return m_bPrependTimestamp; } bool CUser::IsValidUserName(const CString& sUserName) { const char* p = sUserName.c_str(); @@ -530,7 +538,9 @@ bool CUser::WriteConfig(CFile& File) { PrintLine(File, "Admin", CString((IsAdmin()) ? "true" : "false")); PrintLine(File, "DCCLookupMethod", CString((UseClientIP()) ? "client" : "default")); PrintLine(File, "TimestampFormat", GetTimestampFormat()); - PrintLine(File, "AppendTimestamp", CString((GetTimestampAppend()) ? "yes" : "no")); + PrintLine(File, "AppendTimestamp", CString((GetTimestampAppend()) ? "true" : "false")); + PrintLine(File, "PrependTimestamp", CString((GetTimestampPrepend()) ? "true" : "false")); + PrintLine(File, "TimezoneOffset", CString(m_fTimezoneOffset)); File.Write("\r\n"); // Allow Hosts diff --git a/User.h b/User.h index 85590829..da7b883c 100644 --- a/User.h +++ b/User.h @@ -133,6 +133,8 @@ public: void SetBeingDeleted(bool b) { m_bBeingDeleted = b; } void SetTimestampFormat(const CString& s) { m_sTimestampFormat = s; } void SetTimestampAppend(bool b) { m_bAppendTimestamp = b; } + void SetTimestampPrepend(bool b) { m_bPrependTimestamp = b; } + void SetTimezoneOffset(float b) { m_fTimezoneOffset = b; } // !Setters // Getters @@ -151,6 +153,7 @@ public: const set& GetAllowedHosts() const; const CString& GetTimestampFormat() const; bool GetTimestampAppend() const; + bool GetTimestampPrepend() const; const CString& GetChanPrefixes() const { return m_sChanPrefixes; } bool IsChan(const CString& sChan) const { return (sChan.size() && GetChanPrefixes().find(sChan[0]) != CString::npos); } @@ -177,6 +180,7 @@ public: bool AutoCycle() const; bool IsBeingDeleted() const { return m_bBeingDeleted; } bool HasServers() const { return m_vServers.size() > 0; } + float GetTimezoneOffset() const { return m_fTimezoneOffset; } // !Getters private: protected: @@ -197,6 +201,7 @@ protected: CString m_sQuitMsg; MCString m_mssCTCPReplies; CString m_sTimestampFormat; + float m_fTimezoneOffset; // Paths CString m_sUserPath; @@ -218,6 +223,7 @@ protected: bool m_bAutoCycle; bool m_bBeingDeleted; bool m_bAppendTimestamp; + bool m_bPrependTimestamp; CKeepNickTimer* m_pKeepNickTimer; CJoinTimer* m_pJoinTimer; diff --git a/configure.in b/configure.in index 561e4d32..8f4d292f 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -AC_INIT +AC_INIT([znc], [0.048]) AC_PROG_CXX AC_CANONICAL_HOST CXXFLAGS="-D_GNU_SOURCE" diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index 29b54d39..fcce7b11 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -920,20 +920,25 @@ bool CWebAdminSock::UserPage(CString& sPageRet, CUser* pUser) { CTemplate& o7 = m_Template.AddRow("OptionLoop"); o7["Name"] = "appendtimestamp"; - o7["DisplayName"] = "Append Timestamp"; + o7["DisplayName"] = "Append Timestamps"; if (pUser && pUser->GetTimestampAppend()) { o7["Checked"] = "true"; } - if (IsAdmin()) { - CTemplate& o8 = m_Template.AddRow("OptionLoop"); - o8["Name"] = "denyloadmod"; - o8["DisplayName"] = "Deny LoadMod"; - if (pUser && pUser->DenyLoadMod()) { o8["Checked"] = "true"; } + CTemplate& o8 = m_Template.AddRow("OptionLoop"); + o8["Name"] = "prependtimestamp"; + o8["DisplayName"] = "Prepend Timestamps"; + if (pUser && pUser->GetTimestampPrepend()) { o8["Checked"] = "true"; } + if (IsAdmin()) { CTemplate& o9 = m_Template.AddRow("OptionLoop"); - o9["Name"] = "isadmin"; - o9["DisplayName"] = "Admin"; - if (pUser && pUser->IsAdmin()) { o9["Checked"] = "true"; } - if (pUser && pUser == CZNC::Get().FindUser(GetUser())) { o9["Disabled"] = "true"; } + o9["Name"] = "denyloadmod"; + o9["DisplayName"] = "Deny LoadMod"; + if (pUser && pUser->DenyLoadMod()) { o9["Checked"] = "true"; } + + CTemplate& o10 = m_Template.AddRow("OptionLoop"); + o10["Name"] = "isadmin"; + o10["DisplayName"] = "Admin"; + if (pUser && pUser->IsAdmin()) { o10["Checked"] = "true"; } + if (pUser && pUser == CZNC::Get().FindUser(GetUser())) { o10["Disabled"] = "true"; } } PrintPage(sPageRet, "UserPage.tmpl"); @@ -1096,6 +1101,7 @@ CUser* CWebAdminSock::GetNewUser(CString& sPageRet, CUser* pUser) { pNewUser->SetKeepNick(GetParam("keepnick").ToBool()); pNewUser->SetUseClientIP(GetParam("useclientip").ToBool()); pNewUser->SetTimestampAppend(GetParam("appendtimestamp").ToBool()); + pNewUser->SetTimestampPrepend(GetParam("prependtimestamp").ToBool()); if (IsAdmin()) { pNewUser->SetDenyLoadMod(GetParam("denyloadmod").ToBool()); diff --git a/znc.cpp b/znc.cpp index 962b9a7d..179bb66a 100644 --- a/znc.cpp +++ b/znc.cpp @@ -395,6 +395,8 @@ bool CZNC::WriteConfig() { File.Write("Listen" + s6 + " = " + sHostPortion + CString((pListener->IsSSL()) ? "+" : "") + CString(pListener->GetPort()) + "\r\n"); } + File.Write("ConnectDelay = " + CString(m_uiConnectDelay) + "\r\n"); + if (!m_sISpoofFile.empty()) { File.Write("ISpoofFile = " + m_sISpoofFile + "\r\n"); if (!m_sISpoofFormat.empty()) { File.Write("ISpoofFormat = " + m_sISpoofFormat + "\r\n"); } @@ -1000,17 +1002,28 @@ bool CZNC::ParseConfig(const CString& sConfig) { } else if (sName.CaseCmp("AppendTimestamp") == 0) { pUser->SetTimestampAppend(sValue.ToBool()); continue; + } else if (sName.CaseCmp("PrependTimestamp") == 0) { + pUser->SetTimestampPrepend(sValue.ToBool()); + continue; } else if (sName.CaseCmp("Timestamp") == 0) { if(sValue.Trim_n().CaseCmp("true") != 0) { if(sValue.Trim_n().CaseCmp("append") == 0) { pUser->SetTimestampAppend(true); + pUser->SetTimestampPrepend(false); + } else if(sValue.Trim_n().CaseCmp("prepend") == 0) { + pUser->SetTimestampAppend(false); + pUser->SetTimestampPrepend(true); } else if(sValue.Trim_n().CaseCmp("false") == 0) { - pUser->SetTimestampFormat(""); + pUser->SetTimestampAppend(false); + pUser->SetTimestampPrepend(false); } else { pUser->SetTimestampFormat(sValue); } } continue; + } else if (sName.CaseCmp("TimezoneOffset") == 0) { + pUser->SetTimezoneOffset(sValue.ToDouble()); // there is no ToFloat() + continue; } else if (sName.CaseCmp("LoadModule") == 0) { CString sModName = sValue.Token(0); CUtils::PrintAction("Loading Module [" + sModName + "]");