Skip to content

Commit

Permalink
Show link to http://znc.in from web
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthGandalf committed Mar 21, 2012
1 parent 7beb717 commit fb2b519
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/znc/znc.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CZNC {
bool RehashConfig(CString& sError); bool RehashConfig(CString& sError);
void BackupConfigOnce(const CString& sSuffix); void BackupConfigOnce(const CString& sSuffix);
static CString GetVersion(); static CString GetVersion();
static CString GetTag(bool bIncludeVersion = true); static CString GetTag(bool bIncludeVersion = true, bool bHTML = false);
static CString GetCompileOptionsString(); static CString GetCompileOptionsString();
CString GetUptime() const; CString GetUptime() const;
void ClearBindHosts(); void ClearBindHosts();
Expand Down
22 changes: 16 additions & 6 deletions src/HTTPSock.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -432,12 +432,22 @@ bool CHTTPSock::PrintErrorPage(unsigned int uStatusId, const CString& sStatusMsg
} }


CString sPage = CString sPage =
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n" "<!DOCTYPE HTML>\r\n"
"<html><head>\r\n<title>" + CString(uStatusId) + " " + sStatusMsg.Escape_n(CString::EHTML) + "</title>\r\n" "<html>\r\n"
"</head><body>\r\n<h1>" + sStatusMsg.Escape_n(CString::EHTML) + "</h1>\r\n" "<head>\r\n"
"<p>" + sMessage.Escape_n(CString::EHTML) + "</p>\r\n" "<meta charset=\"utf-8\"/>\r\n"
"<hr />\r\n<address>" + CZNC::GetTag(false).Escape_n(CString::EHTML) + " at " + GetLocalIP().Escape_n(CString::EHTML) + " Port " + CString(GetLocalPort()) + "</address>\r\n" "<title>" + CString(uStatusId) + " " + sStatusMsg.Escape_n(CString::EHTML) + "</title>\r\n"
"</body></html>\r\n"; "</head>\r\n"
"<body>\r\n"
"<h1>" + sStatusMsg.Escape_n(CString::EHTML) + "</h1>\r\n"
"<p>" + sMessage.Escape_n(CString::EHTML) + "</p>\r\n"
"<hr/>\r\n"
"<address>" +
CZNC::GetTag(false, /* bHTML = */ true) +
" at " + GetLocalIP().Escape_n(CString::EHTML) + " Port " + CString(GetLocalPort()) +
"</address>\r\n"
"</body>\r\n"
"</html>\r\n";


PrintHeader(sPage.length(), "text/html", uStatusId, sStatusMsg); PrintHeader(sPage.length(), "text/html", uStatusId, sStatusMsg);
Write(sPage); Write(sPage);
Expand Down
2 changes: 1 addition & 1 deletion src/WebModules.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void CWebSock::SetPaths(CModule* pModule, bool bIsTemplate) {
void CWebSock::SetVars() { void CWebSock::SetVars() {
m_Template["SessionUser"] = GetUser(); m_Template["SessionUser"] = GetUser();
m_Template["SessionIP"] = GetRemoteIP(); m_Template["SessionIP"] = GetRemoteIP();
m_Template["Tag"] = CZNC::GetTag(GetSession()->GetUser() != NULL); m_Template["Tag"] = CZNC::GetTag(GetSession()->GetUser() != NULL, true);
m_Template["SkinName"] = GetSkinName(); m_Template["SkinName"] = GetSkinName();
m_Template["_CSRF_Check"] = GetCSRFCheck(); m_Template["_CSRF_Check"] = GetCSRFCheck();


Expand Down
10 changes: 6 additions & 4 deletions src/znc.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -79,17 +79,19 @@ CString CZNC::GetVersion() {
return szBuf; return szBuf;
} }


CString CZNC::GetTag(bool bIncludeVersion) { CString CZNC::GetTag(bool bIncludeVersion, bool bHTML) {
CString sAddress = bHTML ? "<a href=\"http://znc.in\">http://znc.in</a>" : "http://znc.in";

if (!bIncludeVersion) { if (!bIncludeVersion) {
return "ZNC - http://znc.in"; return "ZNC - " + sAddress;
} }


char szBuf[128]; char szBuf[128];
snprintf(szBuf, sizeof(szBuf), "ZNC %1.3f"VERSION_EXTRA" - http://znc.in", VERSION); snprintf(szBuf, sizeof(szBuf), "ZNC %1.3f"VERSION_EXTRA" - ", VERSION);
// If snprintf overflows (which I doubt), we want to be on the safe side // If snprintf overflows (which I doubt), we want to be on the safe side
szBuf[sizeof(szBuf) - 1] = '\0'; szBuf[sizeof(szBuf) - 1] = '\0';


return szBuf; return szBuf + sAddress;
} }


CString CZNC::GetCompileOptionsString() { CString CZNC::GetCompileOptionsString() {
Expand Down
2 changes: 1 addition & 1 deletion webskins/_default_/tmpl/LowerBanner.tmpl
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
<div id="tag"><p><? VAR Tag ?></p></div> <div id="tag"><p><? VAR Tag ESC=ASCII ?></p></div>
2 changes: 1 addition & 1 deletion webskins/dark-clouds/tmpl/Banner.tmpl
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
<div id="banner"><p><? VAR Tag ?></p></div> <div id="banner"><p><? VAR Tag ESC=ASCII ?></p></div>
2 changes: 1 addition & 1 deletion webskins/forest/tmpl/Banner.tmpl
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
<div id="banner"><p><? VAR Tag ?></p></div> <div id="banner"><p><? VAR Tag ESC=ASCII ?></p></div>

0 comments on commit fb2b519

Please sign in to comment.