diff --git a/WebModules.cpp b/WebModules.cpp index d3d9b26a..3e30d586 100644 --- a/WebModules.cpp +++ b/WebModules.cpp @@ -276,7 +276,7 @@ void CWebSock::SetPaths(CModule* pModule, bool bIsTemplate) { // 3. ./modules// // - m_Template.AppendPath(GetModWebPath(sModName)); + m_Template.AppendPath(GetModWebPath(pModule)); // 4. ~/.znc/webskins//mods// // @@ -444,14 +444,17 @@ CWebSock::EPageReqResult CWebSock::PrintTemplate(const CString& sPageName, CStri } } -CString CWebSock::GetModWebPath(const CString& sModName) const { - CString sRet = CZNC::Get().GetCurPath() + "/modules/www/" + sModName; +CString CWebSock::GetModWebPath(const CModule* pModule) const { + // This is: /path/to/module.so + const CString& sModPath = pModule->GetModPath(); - if (!CFile::IsDir(sRet)) { - sRet = CString(_MODDIR_) + "/www/" + sModName; - } + // Find the last '/' in sModPath... + CString::size_type pos = sModPath.find_last_of('/'); - return sRet + "/"; + // ...and set sModDir to the dir in which sModPath resides + CString sModDir = sModPath.substr(0, pos); + + return sModDir + "/www/" + pModule->GetModName(); } CString CWebSock::GetSkinPath(const CString& sSkinName) const { @@ -640,7 +643,7 @@ CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CS if (sURI.Left(10) == "/modfiles/") { m_Template.AppendPath(GetSkinPath(GetSkinName()) + "/mods/" + m_sModName + "/files/"); - m_Template.AppendPath(GetModWebPath(m_sModName) + "/files/"); + m_Template.AppendPath(GetModWebPath(pModule) + "/files/"); std::cerr << "===================== fffffffffffffffffffff [" << m_sModName << "] [" << m_sPage << "]" << std::endl; if (PrintFile(m_Template.ExpandFile(m_sPage.TrimLeft_n("/")))) { diff --git a/WebModules.h b/WebModules.h index f34f4bec..d067dc32 100644 --- a/WebModules.h +++ b/WebModules.h @@ -150,7 +150,7 @@ public: CString GetCSRFCheck(); virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort); - CString GetModWebPath(const CString& sModName) const; + CString GetModWebPath(const CModule* pModule) const; CString GetSkinPath(const CString& sSkinName) const; CModule* GetModule() const { return (CModule*) m_pModule; } size_t GetAvailSkins(vector& vRet);