Return Type | Function name | Arguments |
---|---|---|
hzTcpCode | hdsApp::ProcHTTP | (hzHttpEvent*,) |
Declared in file: hzDissemino.h
Defined in file : hdsSystem.cpp
Function Logic:
Function body:
hzTcpCode hdsApp::ProcHTTP (hzHttpEvent* pE) { _hzfunc("hdsApp::ProcHTTP") ; hzChain Z ; hzChain err ; hzIpConnex* pConnex ; hdsProfile* pVP ; hzAtom sv ; hdsInfo* pInfo = 0; hdsLang* pLang ; hdsResource* pResource ; hdsFile* pFix ; hdsPage* pPage ; hdsCIFunc* pCIF ; hdsFormref* pFormref ; hdsFormhdl* pFhdl ; hdsNavtree* pAG = 0; hdsArticle* pArt = 0; hdsArticleStd* pArtStd = 0; hdsArticleCIF* pArtCIF = 0; const char* pReq ; const char* i ; hzIpinfo ipi ; hzSysID cookie ; hzString iplocn ; hzString currRef ; hzString reqPath ; hzString argA ; hzString argB ; hzString hname ; uint32_t n ; uint32_t nAgt ; hzIpaddr ipa ; hzEcode rc ; hzTcpCode trc ; char argbuf[100]; if (!this) Fatal("No Dissemino Application") ; pConnex = pE->GetConnex() ; if (!pConnex) Fatal("No Client Connection") ; rc = E_FORMAT ; switch (pE->Method()) { case HTTP_GET: rc = E_OK ; break ; case HTTP_HEAD: rc = E_OK ; break ; case HTTP_POST: rc = E_OK ; break ; case HTTP_OPTIONS: err.Printf("START ProcHTTP (OPTIONS) %s\n", pE->Hostname()) ; break ; case HTTP_PUT: err.Printf("START ProcHTTP (PUT) %s\n", pE->Hostname()) ; break ; case HTTP_DELETE: err.Printf("START ProcHTTP (DELETE) %s\n", pE->Hostname()) ; break ; case HTTP_TRACE: err.Printf("START ProcHTTP (TRACE) %s\n", pE->Hostname()) ; break ; case HTTP_CONNECT: err.Printf("START ProcHTTP (CONNECT) %s\n", pE->Hostname()) ; break ; case HTTP_INVALID: err.Printf("START ProcHTTP (INVALID) %s\n", pE->Hostname()) ; break ; default: err.Printf("START ProcHTTP (INVALID) %s\n", pE->Hostname()) ; break ; } ipa = pE->ClientIP() ; if (ipa == IPADDR_NULL || ipa == IPADDR_BAD) { err.Printf("IP Address of %s\n", *ipa) ; threadLog(err) ; SendErrorPage(pE, HTTPMSG_INTERNAL_SERVER_ERROR, __func__, "Could not dechiper IP address\n") ; pConnex->SendKill() ; return TCP_TERMINATE ; } if (_hzGlobal_StatusIP.Exists(ipa)) { ipi = _hzGlobal_StatusIP[ipa] ; if (ipi.m_bInfo & HZ_IPSTATUS_BLACK_HTTP) { err.Printf("BLOCKED IP ADDRESS %s - Killing Connection\n", *ipa) ; threadLog(err) ; pConnex->SendKill() ; return TCP_TERMINATE ; } } if (rc != E_OK) { err.Printf("BLOCKING IP ADDRESS %s - Killing Connection\n", *ipa) ; threadLog(err) ; SetStatusIP(ipa, HZ_IPSTATUS_BLACK_PROT, 9000); pConnex->SendKill() ; return TCP_TERMINATE ; } iplocn = GetIpLocation(ipa) ; pE->m_pContextLang = pLang = m_pDfltLang ; trc = pE->Connection() ? TCP_KEEPALIVE : TCP_TERMINATE ; pReq = pE->GetResource() ; currRef = pE->Referer() ; if (!pE->Cookie()) pE->m_Report.Printf("Supplied Cookie: [0] info 0\n") ; else { pInfo = m_SessCookie[pE->Cookie()] ; if (!pInfo) { pE->m_Report.Printf("Supplied Cookie: [%016X] is dead\n", pE->Cookie()) ; pE->DelSessCookie(pE->Cookie()) ; } else { pE->m_Report.Printf("Supplied Cookie: [%016X] info %p\n", pE->Cookie(), pInfo) ; pE->SetSession(pInfo) ; pE->m_Report.Printf("Access: %d\n", pInfo->m_Access) ; pE->m_Report.Printf("Subscriber ID: %d\n", pInfo->m_SubId) ; pE->m_Report.Printf("User ID: %d\n", pInfo->m_UserId) ; pE->m_Report.Printf("Curr Object: %d\n", pInfo->m_CurrObj) ; for (n = 0; n < pInfo->m_Sessvals.Count() ; n++) { pE->m_Report.Printf("Sesion var: %s=%s\n", *pInfo->m_Sessvals.GetKey(n), *pInfo->m_Sessvals.GetObj(n).Str()) ; } } threadLog(pE->m_Report) ; pE->m_Report.Clear() ; } if (pE->UserAgent()) { if (m_UserAgents.Exists(pE->UserAgent())) nAgt = m_UserAgents[pE->UserAgent()] ; else { nAgt = m_UserAgents.Count() + 1; m_UserAgents.Insert(pE->UserAgent(), nAgt) ; } } pVP = m_Visitors[ipa] ; if (!pVP) { pVP = new hdsProfile() ; pVP->m_addr = ipa ; m_Visitors.Insert(ipa, pVP) ; } if (pE->Method() == HTTP_POST) { reqPath = pReq ; if (!pInfo) { if (reqPath == m_LoginPost) { rc = _SubscriberAuthenticate(pE) ; if (rc == E_OK) reqPath = m_LoginAuth ; else reqPath = m_LoginFail ; goto proc_std_request ; } } if (pInfo && pInfo->m_Access & ACCESS_ADMIN) { if (reqPath == preset_masterFileEdit_hdl) { _masterFileEditHdl(pE) ; return trc ; } if (reqPath == preset_masterCfgEdit_hdl1) { _masterCfgEditHdl(pE) ; return trc ; } } if (reqPath == preset_master_proc_auth && !pInfo) { rc = _masterProcAuth(pE) ; return trc ; } if (reqPath == preset_usr_proc_auth && !pInfo) { rc = _SubscriberAuthenticate(pE) ; return trc ; } pFormref = m_FormUrl2Ref[reqPath] ; hname = m_FormUrl2Hdl[reqPath] ; pFhdl = m_FormHdls[hname] ; if (!pFhdl) { pVP->m_P404++ ; SendErrorPage(pE, HTTPMSG_NOTFOUND, __func__, "No such form handler as %s", *reqPath) ; if (pVP->m_P404 > 20) { pE->m_Report.Printf("Note: Blocking IP %s for illegal POST requests\n", *ipa) ; SetStatusIP(ipa, HZ_IPSTATUS_BLACK_PROT, 0); } } else { pVP->m_post++ ; ProcForm(pE, pFormref, pFhdl) ; } pE->m_Report.Printf("\n%s POST: %s (%s, %s) ", *pE->m_Occur, *ipa, *iplocn, *m_pDfltLang->m_Code) ; pE->m_Report.Printf("[cook=%016X info=%p] (%s) %s\n", pE->Cookie(), pInfo, *currRef, pE->GetResource()) ; pE->m_Report.Printf("<rbot=%d fav=%d art=%d, pg=%d scr=%d img=%d sp=%d fix=%d post=%d G404=%d P404=%d>\n", pVP->m_robot, pVP->m_favicon, pVP->m_art, pVP->m_page, pVP->m_scr, pVP->m_img, pVP->m_spec, pVP->m_fix, pVP->m_post, pVP->m_G404, pVP->m_P404) ; threadLog(pE->m_Report) ; pE->m_Report.Clear() ; return trc ; } /* ** ** Deal with GET and HEAD method requests: All mainstrean resource requests. ** */ if (pE->Method() != HTTP_GET && pE->Method() != HTTP_HEAD) { SendErrorPage(pE, HTTPMSG_METHOD_NOT_ALLOWED, __func__, "Method not supported") ; return TCP_TERMINATE ; } if (preset_robots == pE->GetResource()) { rc = pE->SendRawString(HTTPMSG_OK, HMTYPE_TXT_PLAIN, m_Robot, 0/* ** 43200 */ , false) ; if (rc != E_OK) pE->m_Report << pE->m_Error ; pVP->m_robot++ ; goto get_end ; } if (preset_favicon == pE->GetResource()) { rc = pE->SendPageE(*m_Images, pReq + 1,86400,false); if (rc != E_OK) pE->m_Report << pE->m_Error ; pVP->m_favicon++ ; goto get_end ; } if (preset_sitemap_txt == pE->GetResource()) { pVP->m_spec++ ; if (!m_rawSitemapTxt.Size()) SendErrorPage(pE, HTTPMSG_NOTFOUND, __func__, "No such page as %s", pE->GetResource()) ; else { if (pE->Zipped() && m_zipSitemapTxt.Size()) rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_PLAIN, m_zipSitemapTxt, 0,true) ; else rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_PLAIN, m_rawSitemapTxt, 0,false) ; } goto get_end ; } if (preset_sitemap_xml == pE->GetResource()) { pVP->m_spec++ ; if (!m_rawSitemapTxt.Size()) SendErrorPage(pE, HTTPMSG_NOTFOUND, __func__, "No such page as %s", pE->GetResource()) ; else { if (pE->Zipped() && m_zipSitemapXml.Size()) rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_APP_XML, m_zipSitemapXml, 0/* ** 43200 */ , true) ; else rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_APP_XML, m_rawSitemapXml, 0/* ** 43200 */ , false) ; } goto get_end ; } if (preset_siteguide == pE->GetResource()) { pVP->m_spec++ ; if (!m_rawSiteguide.Size()) SendErrorPage(pE, HTTPMSG_NOTFOUND, __func__, "No such page as %s", pE->GetResource()) ; else { if (pE->Zipped() && m_zipSiteguide.Size()) rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, m_zipSiteguide, 0/* ** 43200 */ , true) ; else rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, m_rawSiteguide, 0/* ** 43200 */ , false) ; } goto get_end ; } if (pInfo && pInfo->m_Access & ACCESS_ADMIN) { if (reqPath == "/masterLogout") { rc = _masterLogout(pE) ; goto get_end ; } if (!memcmp(pReq, "/masterAction", 13)) { MasterArticle(pE) ; goto get_end ; } } /* ** if (pInfo && pInfo->m_Access & ACCESS_ADMIN) ** { ** if (pReq[1] == 'm' && pReq[2] == 'a' && pReq[3] == 's' && pReq[4] == 't' && pReq[5] == 'e' && pReq[6] == 'r') ** { ** reqPath = pReq ; //+ 1 ; ** ** if (reqPath == "/masterMainMenu") { rc = _masterMainMenu(pE) ; goto get_end ; } ** if (reqPath == "/masterCfgList") { rc = _masterCfgList(pE) ; goto get_end ; } ** if (reqPath == "/masterCfgEdit") { rc = _masterCfgEdit(pE) ; goto get_end ; } ** if (reqPath == "/masterResList") { rc = _masterResList(pE) ; goto get_end ; } ** if (reqPath == "/masterVisList") { rc = _masterVisList(pE) ; goto get_end ; } ** if (reqPath == "/masterDomain") { rc = _masterDomain(pE) ; goto get_end ; } ** if (reqPath == "/masterEmaddr") { rc = _masterEmaddr(pE) ; goto get_end ; } ** if (reqPath == "/masterStrFix") { rc = _masterStrFix(pE) ; goto get_end ; } ** if (reqPath == "/masterStrGen") { rc = _masterStrGen(pE) ; goto get_end ; } ** if (reqPath == "/masterBanned") { rc = _masterBanned(pE) ; goto get_end ; } ** if (reqPath == "/masterMemstat") { rc = _masterMemstat(pE) ; goto get_end ; } ** if (reqPath == "/masterUSL") { rc = _masterUSL(pE) ; goto get_end ; } ** if (reqPath == "/masterFileList") { rc = _masterFileList(pE) ; goto get_end ; } ** if (reqPath == "/masterFileEdit") { rc = _masterFileEdit(pE) ; goto get_end ; } ** if (reqPath == "/masterDataModel") { rc = _masterDataModel(pE) ; goto get_end ; } ** if (reqPath == "/masterCfgRestart") { rc = _masterCfgRestart(pE) ; goto get_end ; } ** if (reqPath == "/masterLogout") { rc = _masterLogout(pE) ; goto get_end ; } ** } ** ** // Master article - should this not simply be get article??? ** if (!memcmp(pReq, "/master_", 8)) ** { MasterArticle(pE) ; goto get_end ; } ** } ** */ /* ** ** Check for AJAX requests. These will not be the only source of requests in which there is one name-value pair submitted in the query part of the request URL, but requests to ** ** check a member value for availabilty (e.g. email address) and requests for articles are of this form. If the request is not for any of these, then drop through. ** */ if (pE->QueryLen() && pE->m_mapStrings.Count() == 1) { if (!memcmp(pReq, "/ck-", 4)) { InPageQuery(pE) ; goto get_end ; } argA = pE->m_mapStrings.GetKey(0); argB = pE->m_mapStrings.GetObj(0); pAG = m_ArticleGroups[argA] ; if (!pAG) { if (pInfo && pInfo->m_pTree && pInfo->m_pTree->m_Groupname == argA) pAG = pInfo->m_pTree ; if (!pAG) { threadLog("No Article Group Found\n") ; pE->SendAjaxResult(HTTPMSG_NOTFOUND, "Out of Range") ; goto get_end ; } } threadLog("Located Article Group %s\n", *pAG->m_Groupname) ; pArt = (hdsArticle*) pAG->GetItem(argB) ; if (!pArt) { if (pAG->m_pFunc) pAG->m_pFunc(pE, argB) ; else pE->SendAjaxResult(HTTPMSG_NOTFOUND, "Out of Range") ; goto get_end ; } if (!(pArt->m_resAccess == ACCESS_PUBLIC || (pArt->m_resAccess == ACCESS_NOBODY && (!pInfo || !(pInfo->m_Access & ACCESS_MASK))) || (pInfo && (pInfo->m_Access & ACCESS_ADMIN || (pInfo->m_Access & ACCESS_MASK) & pArt->m_resAccess)))) { threadLog("No Access\n") ; pE->SendAjaxResult(HTTPMSG_FORBIDDEN, "No Access") ; goto get_end ; } pVP->m_art++ ; pArtStd = dynamic_cast<hdsArticleStd*>(pArt) ; if (pArtStd) { pE->SetHdr(s_articleTitle, pArt->m_Title) ; /* ** NOT SURE ??? ** if (!pArtStd->m_USL) ** { ** // No USL assigned ** if (!pArtStd->m_Content) ** pE->SendAjaxResult(HTTPMSG_NOCONTENT, "Article is a heading only") ; ** else ** { ** Z = pArtStd->m_Content ; ** rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, Z, 0, false) ; ** } ** goto get_end ; ** } ** */ if (pArtStd->m_flagVE & VE_ACTIVE) { pArtStd->Display(Z, pE) ; if (!Z.Size()) { pE->m_Error.Printf("AJAX case 2\n") ; pE->SendAjaxResult(HTTPMSG_NOCONTENT, "Article is a heading only") ; } else { if (pE->Zipped()) rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, Z, 0,true) ; else rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, Z, 0,false) ; } goto get_end ; } if (pE->Zipped()) { Z = pArtStd->m_zipHTML ; if (Z.Size()) rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, Z, 0/* ** 43200 */ , true) ; else { pE->m_Error.Printf("Cmd: Could not locate article zip data %s\n", *pArtStd->m_Title) ; pE->SendAjaxResult(HTTPMSG_NOCONTENT, "Article is a heading only") ; } goto get_end ; } Z = pArtStd->m_rawHTML ; if (Z.Size()) rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, Z, 0/* ** 43200 */ , false) ; else { pE->m_Error.Printf("Cmd: Could not locate article raw data %s\n", *pArtStd->m_Title) ; pE->SendAjaxResult(HTTPMSG_NOCONTENT, "Article is a heading only") ; } goto get_end ; } pArtCIF = dynamic_cast<hdsArticleCIF*>(pArt) ; if (pArtCIF) { rc = pArtCIF->Run(pE) ; goto get_end ; } /* ** if (rc != E_OK || pE->m_Error.Size()) ** { ** if (pE->m_Error.Size()) ** pE->m_Report << pE->m_Error ; ** trc = TCP_TERMINATE ; ** } ** */ goto get_end ; } if (pReq[1]) { for (n = 0,i = pReq + 1; *i && n < 8; i++, n++) { argbuf[n] = *i ; if (*i == CHAR_FWSLASH) { argbuf[n] = 0; argA = argbuf ; if (!m_Languages.Exists(argA)) break ; pReq = i ; pE->m_pContextLang = pLang = m_Languages[argA] ; argA = (char*)0; n = -1; } } if (argA) { if (argA == preset_jsc || argA == preset_js) { if (argA == preset_jsc) reqPath = pReq + preset_jsc.Length() + 2; else reqPath = pReq + preset_js.Length() + 2; pE->m_Report.Printf("Serving script [%s]\n", *reqPath) ; if (m_rawScripts.Exists(reqPath)) { pVP->m_scr++ ; if (pE->Method() == HTTP_HEAD) pE->SendHttpHead(m_rawScripts[reqPath], HMTYPE_TXT_JS, 86400); else { if (pE->Zipped()) { Z = m_zipScripts[reqPath] ; rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_JS, Z, 86400,true); if (rc != E_OK) pE->m_Report << pE->m_Error ; } else { Z = m_rawScripts[reqPath] ; rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_JS, Z, 86400,false); if (rc != E_OK) { pE->m_Report << pE->m_Error ; } } } goto get_end ; } if (m_rawScripts.Exists(reqPath)) { pVP->m_scr++ ; if (pE->Method() == HTTP_HEAD) pE->SendHttpHead(m_rawScripts[reqPath], HMTYPE_TXT_JS, 86400); else { if (pE->Zipped()) { Z = m_zipScripts[reqPath] ; rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_JS, Z, 86400,true); if (rc != E_OK) pE->m_Report << pE->m_Error ; } else { Z = m_rawScripts[reqPath] ; rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_JS, Z, 86400,false); if (rc != E_OK) pE->m_Report << pE->m_Error ; } } goto get_end ; } SendErrorPage(pE, HTTPMSG_NOTFOUND, __func__, "No such script as %s (%s)", *reqPath, pE->GetResource()) ; goto get_end ; } if (argA == preset_sysimg) { pVP->m_img++ ; pE->m_Report.Printf("Serving image [%s]\n", pReq + 8); if (pE->Method() == HTTP_HEAD) pE->SendFileHead(*_hzGlobal_SysImages, pReq + 8); else pE->SendPageE(*_hzGlobal_SysImages, pReq + 8,86400,false); goto get_end ; } if (argA == preset_img) { pVP->m_img++ ; pE->m_Report.Printf("Serving image [%s]\n", pReq + 5); if (pE->Method() == HTTP_HEAD) pE->SendFileHead(*m_Images, pReq + 5); else pE->SendPageE(*m_Images, pReq + 5,86400,false); goto get_end ; } if (argA == preset_textpg) { pVP->m_spec++ ; reqPath = pReq + preset_textpg.Length() + 1; pE->m_Report.Printf("Serving textpg [%s]\n", *reqPath) ; pE->SendPageE(*m_Docroot, pReq, 0/* ** 43200 */ , false) ; goto get_end ; } /* ** if (argA == preset_docs) ** { ** pVP->m_spec++ ; ** SendDocument(pE) ; ** goto get_end ; ** } ** */ } if (m_namCSS == pReq+1) { pVP->m_scr++ ; if (pE->Method() == HTTP_HEAD) pE->SendHttpHead(m_txtCSS, HMTYPE_TXT_CSS, 86400); else { if (pE->Zipped()) rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_CSS, m_zipCSS, 86400,true); else rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_CSS, m_txtCSS, 86400,false); if (rc != E_OK) pE->m_Report << pE->m_Error ; } goto get_end ; } if (pReq[1]== ''u''&&!memcmp(pReq, "/userdir", 8)) { if (!pInfo) { SendErrorPage(pE, HTTPMSG_NOTFOUND, __func__, "No such page as %s (no-session-info)", pE->GetResource()) ; goto get_end ; } sv = pInfo->m_Sessvals[preset_userdir] ; if (sv.IsNull()) SendErrorPage(pE, HTTPMSG_NOTFOUND, __func__, "No such page as %s", pE->GetResource()) ; pVP->m_spec++ ; reqPath = m_Docroot + sv.Str() ; reqPath = ConvertText(reqPath, pE) ; pE->m_Report.Printf("Serving userfile [%s/%s]\n", *reqPath, pReq + preset_userdir.Length() + 2); rc = pE->SendFilePage(*reqPath, pReq + preset_userdir.Length() + 2,0,false) ; if (rc != E_OK) SendErrorPage(pE, HTTPMSG_NOTFOUND, __func__, "No such page as %s", pE->GetResource()) ; goto get_end ; } if (pReq[1]== ''m'') { if (!memcmp(pReq, "/memstats", 10)) { Z << "<html>\n<head>\n<style>\n.main { text-decoration:none; font-family:verdana; font-size:11px; font-weight:normal; color:#000000; }\n.stdpg { height:600px; border:0px; margin-left:5px; overflow-x:auto; overflow-y:auto; }\n</style>\n</head>\n<body>\n" ; ReportMemoryUsage(Z, true) ; Z << "</body>\n</html>\n" ; pE->SendAjaxResult(HTTPMSG_OK, Z) ; goto get_end ; } if (!memcmp(pReq, "/mutexes", 8)) { ReportMutexContention(Z, true) ; pE->SendAjaxResult(HTTPMSG_OK, Z) ; goto get_end ; } } } reqPath = pReq ; if (pReq[0]== CHAR_PERCENT) { reqPath = ConvertText(reqPath, pE) ; } if (!reqPath) reqPath = "/" ; if (reqPath.Length() > 1) { if (reqPath[reqPath.Length()-1]== CHAR_FWSLASH) reqPath.Truncate(reqPath.Length()-1); } if (reqPath == m_LogoutURL) { pVP->m_spec++ ; if (pInfo) { pE->m_Report.Printf("Deleting cookie %016x\n", pE->Cookie()) ; m_SessCookie.Delete(pE->Cookie()) ; pE->SetSession(0); pE->m_Report.Printf("Deleting cookie %016x\n", pE->Cookie()) ; } } /* ** pCIF = m_AltFuncs[reqPath] ; ** if (pCIF) ** { ** pE->m_Report.Printf("Serving C-Interface function %s\n", *reqPath) ; ** rc = pCIF->m_pFunc(pE) ; ** pE->m_Report.Printf("Done C-Interface returned %s\n", Err2Txt(rc)) ; ** goto get_end ; ** } ** ** pFix = m_Fixed[reqPath] ; ** if (pFix) ** { ** pE->m_Report.Printf("Serving fixed page [%s]\n", *reqPath) ; ** pVP->m_fix++ ; ** if (pE->Zipped() && pFix->m_zipValue.Size()) ** rc = pE->SendRawChain(HTTPMSG_OK, pFix->m_Mimetype, pFix->m_zipValue, 86400, true) ; ** else ** rc = pE->SendRawChain(HTTPMSG_OK, pFix->m_Mimetype, pFix->m_rawValue, 86400, false) ; ** ** if (rc != E_OK) ** pE->m_Report << pE->m_Error ; ** goto get_end ; ** } ** */ proc_std_request: pResource = m_ResourcesPath[reqPath] ; pE->m_Report.Printf("Got resource %p from request %s\n", pResource, *reqPath) ; if (!pResource) { if (reqPath == "/") pResource = m_ResourcesPath[preset_index] ; } if (!pResource) { if (reqPath.Contains(CHAR_EQUAL)) { reqPath.TruncateUpto("=") ; pResource = m_ResourcesPath[reqPath] ; } } if (!pResource) { pE->m_Report.Printf("No page case 2: Serving page with arg [%s]\n", *reqPath) ; if (!pInfo && m_MasterPath == pReq) { rc = _masterLoginPage(pE) ; goto get_end ; } if (m_OpFlags & DS_APP_NORMFILE) { argB = m_Docroot + reqPath ; rc = TestFile(*argB) ; if (rc != E_OK) pE->m_Report.Printf("Cannot find normal page [%s]\n", *argB) ; else { pE->m_Report.Printf("Serving normal page [%s]\n", *argB) ; pE->SendFilePage(*m_Docroot, *reqPath, 0,false) ; goto get_end ; } } pE->m_Report.Printf("Non-exist page [%s]\n", *reqPath) ; pVP->m_G404++ ; if (pVP->m_G404 > 1000||(!pVP->m_art&&pVP->m_page && pVP->m_G404 > 20)) { pE->m_Report.Printf("Note: Blocking IP %s for invalid GET requests\n", *ipa) ; SetStatusIP(ipa, HZ_IPSTATUS_BLACK_PROT, 9000); } if (pVP->m_robot) SendErrorPage(pE, HTTPMSG_GONE, __func__, "Page %s no longer exists", pE->GetResource()) ; else SendErrorPage(pE, HTTPMSG_NOTFOUND, __func__, "No such page as %s (info %p)", pE->GetResource(), pInfo) ; pE->m_Report.Printf("Served non-exist page [%s]\n", *reqPath) ; } else { pVP->m_page++ ; if (pResource->m_resAccess == ACCESS_PUBLIC || (pResource->m_resAccess == ACCESS_NOBODY && (!pInfo || !(pInfo->m_Access & ACCESS_MASK))) || (pInfo && (pInfo->m_Access & ACCESS_ADMIN || (pInfo->m_Access & ACCESS_MASK) & pResource->m_resAccess))) { if ((pPage = dynamic_cast<hdsPage*>(pResource))) { pE->m_Report.Printf("Serving page [%s] (%s)\n", *reqPath, *pPage->m_Title) ; if (pE->Method() == HTTP_HEAD) pPage->Head(pE) ; else { pPage->m_HitCount++ ; if (pE->m_Resarg || pPage->m_flagVE & VE_ACTIVE) { pPage->Display(pE) ; } else { if (pE->Zipped()) { Z = pPage->m_zipHTML ; if (Z.Size()) rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, Z, 0/* ** 43200 */ , true) ; else pE->m_Report.Printf("Cmd: Could not locate page zip data %s\n", *pPage->m_Title) ; } else { Z = pPage->m_rawHTML ; if (Z.Size()) rc = pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, Z, 0/* ** 43200 */ , false) ; else pE->m_Report.Printf("Cmd: Could not locate page raw data %s\n", *pPage->m_Title) ; } } } } if ((pFix = dynamic_cast<hdsFile*>(pResource))) { pE->m_Report.Printf("Serving fixed page [%s]\n", *reqPath) ; pVP->m_fix++ ; if (pE->Zipped() && pFix->m_zipValue.Size()) rc = pE->SendRawChain(HTTPMSG_OK, pFix->m_Mimetype, pFix->m_zipValue, 86400,true); else rc = pE->SendRawChain(HTTPMSG_OK, pFix->m_Mimetype, pFix->m_rawValue, 86400,false); if (rc != E_OK) pE->m_Report << pE->m_Error ; } if ((pCIF = dynamic_cast<hdsCIFunc*>(pResource))) { pCIF = dynamic_cast<hdsCIFunc*>(pResource) ; if (pCIF) { pE->m_Report.Printf("Serving C-Interface Function [%s]\n", *reqPath) ; pCIF->m_pFunc(pE) ; } else pE->m_Report.Printf("NOT Serving C-Interface Function [%s]\n", *reqPath) ; } } else SendErrorPage(pE, HTTPMSG_FORBIDDEN, __func__, "No access to page %s", pE->GetResource()) ; } get_end: if (rc != E_OK || pE->m_Error.Size()) { if (pE->m_Error.Size()) pE->m_Report << pE->m_Error ; trc = TCP_TERMINATE ; } if (pE->m_Report.Size()) { threadLog(pE->m_Report) ; pE->m_Report.Clear() ; } pE->m_Report.Printf("ev=%d sk=%d ", pE->EventNo(), pE->CliSocket()) ; if (pE->Connection()) pE->m_Report << "ka " ; else pE->m_Report << "cl " ; pE->m_Report.Printf("<bot=%d art=%d pg=%d scr=%d img=%d sp=%d fix=%d post=%d G404=%d P404=%d> ", pVP->m_robot, pVP->m_art, pVP->m_page, pVP->m_scr, pVP->m_img, pVP->m_spec, pVP->m_fix, pVP->m_post, pVP->m_G404, pVP->m_P404) ; if (pE->Method() == HTTP_HEAD) pE->m_Report << "HED: " ; else pE->m_Report << "GET: " ; pE->m_Report.Printf("%s lang %s %s vtotal=%u ", *iplocn, *pLang->m_Code, *ipa, m_Visitors.Count()) ; if (pInfo) pE->m_Report.Printf("[cook=%016X info=%p] (%s) %s\n", pE->Cookie(), pInfo, *currRef, pE->GetResource()) ; else pE->m_Report.Printf("[cook=%016X info=0] (%s) %s\n", pE->Cookie(), *currRef, pE->GetResource()) ; threadLog(pE->m_Report) ; pE->m_Report.Clear() ; return trc ; }