Show link to http://znc.in from web

This commit is contained in:
Alexey Sokolov
2012-03-22 04:27:26 +07:00
parent 7beb7172d6
commit fb2b5193bc
7 changed files with 27 additions and 15 deletions

View File

@@ -55,7 +55,7 @@ public:
bool RehashConfig(CString& sError);
void BackupConfigOnce(const CString& sSuffix);
static CString GetVersion();
static CString GetTag(bool bIncludeVersion = true);
static CString GetTag(bool bIncludeVersion = true, bool bHTML = false);
static CString GetCompileOptionsString();
CString GetUptime() const;
void ClearBindHosts();

View File

@@ -432,12 +432,22 @@ bool CHTTPSock::PrintErrorPage(unsigned int uStatusId, const CString& sStatusMsg
}
CString sPage =
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
"<html><head>\r\n<title>" + CString(uStatusId) + " " + sStatusMsg.Escape_n(CString::EHTML) + "</title>\r\n"
"</head><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).Escape_n(CString::EHTML) + " at " + GetLocalIP().Escape_n(CString::EHTML) + " Port " + CString(GetLocalPort()) + "</address>\r\n"
"</body></html>\r\n";
"<!DOCTYPE HTML>\r\n"
"<html>\r\n"
"<head>\r\n"
"<meta charset=\"utf-8\"/>\r\n"
"<title>" + CString(uStatusId) + " " + sStatusMsg.Escape_n(CString::EHTML) + "</title>\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);
Write(sPage);

View File

@@ -304,7 +304,7 @@ void CWebSock::SetPaths(CModule* pModule, bool bIsTemplate) {
void CWebSock::SetVars() {
m_Template["SessionUser"] = GetUser();
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["_CSRF_Check"] = GetCSRFCheck();

View File

@@ -79,17 +79,19 @@ CString CZNC::GetVersion() {
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) {
return "ZNC - http://znc.in";
return "ZNC - " + sAddress;
}
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
szBuf[sizeof(szBuf) - 1] = '\0';
return szBuf;
return szBuf + sAddress;
}
CString CZNC::GetCompileOptionsString() {

View File

@@ -1 +1 @@
<div id="tag"><p><? VAR Tag ?></p></div>
<div id="tag"><p><? VAR Tag ESC=ASCII ?></p></div>

View File

@@ -1 +1 @@
<div id="banner"><p><? VAR Tag ?></p></div>
<div id="banner"><p><? VAR Tag ESC=ASCII ?></p></div>

View File

@@ -1 +1 @@
<div id="banner"><p><? VAR Tag ?></p></div>
<div id="banner"><p><? VAR Tag ESC=ASCII ?></p></div>