Return Type | Function name | Arguments |
---|---|---|
hzEcode | hdsApp::ReadWebapp | (hzXmlNode*,) |
Declared in file: hzDissemino.h
Defined in file : hdsConfig.cpp
Function Logic:
Function body:
hzEcode hdsApp::ReadWebapp (hzXmlNode* pRoot) { _hzfunc("hdsApp::ReadWebapp") ; hzDocXml X ; hzChain Z ; hzAttrset ai ; hzXmlNode* pN ; hdbClass* pClass ; hzPair p ; hzString S ; hzString appname ; hzString cookieBase ; hzString basedir ; hzDomain domain ; hzDomain subdom ; hzEcode rc = E_OK ; if (!pRoot->NameEQ("webappCfg")) { m_pLog->Log("Expected root tag of <webappCfg>. Tag <%s> disallowed\n", pRoot->txtName()) ; return E_SYNTAX ; } m_pLog->Log("Obtained project's XML root %s\n", pRoot->txtName()) ; for (ai = pRoot ; ai.Valid() ; ai.Advance()) { if (ai.NameEQ("name")) appname = ai.Value() ; else if (ai.NameEQ("sslPvtKey")) m_SSL_PvtKey = ai.Value() ; else if (ai.NameEQ("sslCert")) m_SSL_Cert = ai.Value() ; else if (ai.NameEQ("sslCertCA")) m_SSL_CertCA = ai.Value() ; else if (ai.NameEQ("domain")) domain = ai.Value() ; else if (ai.NameEQ("subdom")) subdom = ai.Value() ; else if (ai.NameEQ("basedir")) basedir = ai.Value() ; else if (ai.NameEQ("docroot")) m_Docroot = ai.Value() ; else if (ai.NameEQ("configs")) m_Configdir = ai.Value() ; else if (ai.NameEQ("datadir")) m_Datadir = ai.Value() ; else if (ai.NameEQ("logroot")) m_Logroot = ai.Value() ; else if (ai.NameEQ("cookieName")) cookieBase = ai.Value() ; else if (ai.NameEQ("masterpath")) m_MasterPath = ai.Value() ; else if (ai.NameEQ("masteruser")) m_MasterUser = ai.Value() ; else if (ai.NameEQ("masterpass")) m_MasterPass = ai.Value() ; else if (ai.NameEQ("smtpAddr")) m_SmtpAddr = ai.Value() ; else if (ai.NameEQ("smtpUser")) m_SmtpUser = ai.Value() ; else if (ai.NameEQ("smtpPass")) m_SmtpPass = ai.Value() ; else if (ai.NameEQ("usernameFld")) m_UsernameFld = ai.Value() ; else if (ai.NameEQ("userpassFld")) m_UserpassFld = ai.Value() ; else if (ai.NameEQ("loghits")) m_AllHits = ai.Value() ; else if (ai.NameEQ("language")) m_DefaultLang = ai.Value() ; else if (ai.NameEQ("login")) m_OpFlags |= ai.ValEQ("true") ? DS_APP_SUBSCRIBERS : 0; else if (ai.NameEQ("robot")) m_OpFlags |= ai.ValEQ("true") ? DS_APP_ROBOT : 0; else if (ai.NameEQ("siteGuide")) m_OpFlags |= ai.ValEQ("true") ? DS_APP_GUIDE : 0; else if (ai.NameEQ("portSTD")) m_nPortSTD = ai.Value() ? atoi(ai.Value()) : 0; else if (ai.NameEQ("portSSL")) m_nPortSSL = ai.Value() ? atoi(ai.Value()) : 0; else { rc = E_SYNTAX ; m_pLog->Log("File %s Line %d <webappCfg> tag: Invalid param (%s=%s)\n", pRoot->Fname(), pRoot->Line(), ai.Name(), ai.Value()) ; } } if (basedir) { m_pLog->Log("Have basedir of %s\n", *basedir) ; if (basedir[basedir.Length()-1]!= CHAR_FWSLASH) basedir += "/" ; m_pLog->Log("Have basedir of %s\n", *basedir) ; m_Docroot = basedir + "docroot" ; m_Datadir = basedir + "data" ; m_Logroot = basedir + "logs" ; m_Configdir = basedir + "config" ; } if (cookieBase) SetCookieName(cookieBase) ; else m_CookieName = "_hz_dissemino_" ; if (rc == E_OK) { if (!m_Appname) { rc = E_NOINIT ; m_pLog->Log("No Project/Application name\n") ; } if (!m_Domain) { rc = E_NOINIT ; m_pLog->Log("No Project Domain\n") ; } if (!m_Docroot) { rc = E_NOINIT ; m_pLog->Log("No document root directory\n") ; } if (!m_Datadir) { rc = E_NOINIT ; m_pLog->Log("No data repos directory\n") ; } if (!m_Logroot) { rc = E_NOINIT ; m_pLog->Log("No logs root directory\n") ; } if (!m_MasterUser) { rc = E_NOINIT ; m_pLog->Log("No admin usename\n") ; } if (!m_MasterPass) { rc = E_NOINIT ; m_pLog->Log("No admin password\n") ; } if (!m_DefaultLang) { rc = E_NOINIT ; m_pLog->Log("No default language\n") ; } } if (rc != E_OK) return rc ; if (!m_Configdir) m_Configdir = m_Docroot ; if (m_AllHits) { pClass = new hdbClass(m_ADP, HDB_CLASS_DESIG_SYS) ; pClass->InitStart(m_AllHits) ; pClass->InitMember("tdstamp", datatype_XDATE, HDB_MBR_POP_SINGLE_COMPULSORY) ; pClass->InitMember("ipaddr", datatype_IPADDR, HDB_MBR_POP_SINGLE_COMPULSORY) ; pClass->InitMember("url", datatype_STRING, HDB_MBR_POP_SINGLE_COMPULSORY) ; pClass->InitDone() ; rc = m_ADP.RegisterDataClass(pClass) ; } if (!m_pDfltLang) { m_DefaultLang = "en-US" ; m_pDfltLang = new hdsLang() ; m_pDfltLang->m_Code = m_DefaultLang ; m_Languages.Insert(m_pDfltLang->m_Code, m_pDfltLang) ; } if (m_OpFlags & DS_APP_SUBSCRIBERS) { rc = m_ADP.InitSubscribers(m_Datadir) ; if (rc != E_OK) { m_pLog->Log("The subscriber cache is not found in the ADP\n") ; return E_NOINIT ; } } rc = InitResources() ; if (rc != E_OK) return hzerr(rc, "Resource Initialization Failed") ; m_Images = m_Docroot + "/img" ; for (pN = pRoot->GetFirstChild() ; rc == E_OK && pN ; pN = pN->Sibling()) { if (pN->NameEQ("fldspec")) rc = _readFldspec(pN) ; else if (pN->NameEQ("rgxtype")) rc = _readRgxType(pN) ; else if (pN->NameEQ("enum")) rc = _readDataEnum(pN) ; else if (pN->NameEQ("user")) rc = _readUser(pN) ; else if (pN->NameEQ("class")) rc = _readClass(pN) ; else if (pN->NameEQ("repos")) rc = _readRepos(pN) ; else if (pN->NameEQ("login")) rc = _readStdLogin(pN) ; else if (pN->NameEQ("logout")) rc = _readLogout(pN) ; else if (pN->NameEQ("xpage")) rc = _readPage(pN) ; else if (pN->NameEQ("xstyle")) rc = _readCSS(pN) ; else if (pN->NameEQ("xinclude")) rc = _readInclude(pN, 0,0); else if (pN->NameEQ("xscript")) rc = _readScript(pN) ; else if (pN->NameEQ("xtreeDcl")) rc = _readXtreeDcl(pN, 0); else if (pN->NameEQ("xfixfile")) rc = _readFixFile(pN) ; else if (pN->NameEQ("xfixdir")) rc = _readFixDir(pN) ; else if (pN->NameEQ("xmiscdir")) rc = _readMiscDir(pN) ; else if (pN->NameEQ("siteLanguages")) rc = _readSiteLangs(pN) ; else if (pN->NameEQ("navigation")) rc = _readNav(pN) ; else if (pN->NameEQ("xformHdl")) rc = _readFormHdl(pN) ; else if (pN->NameEQ("xformDef")) rc = _readFormDef(pN) ; else if (pN->NameEQ("includeCfg")) { p.Clear() ; for (ai = pN ; ai.Valid() ; ai.Advance()) { if (ai.NameEQ("dir")) p.name = ai.Value() ; else if (ai.NameEQ("fname")) p.value = ai.Value() ; else { rc = E_SYNTAX ; m_pLog->Log("File %s Line %d Reading <include> tag: Invalid param (%s=%s)\n", pN->Fname(), pN->Line(), ai.Name(), ai.Value()) ; } } rc = _loadInclFile(p.name, p.value) ; } else if (pN->NameEQ("passive")) { p.Clear() ; for (ai = pN ; ai.Valid() ; ai.Advance()) { if (ai.NameEQ("files")) p.name = ai.Value() ; else if (ai.NameEQ("htype")) p.value = ai.Value() ; else { rc = E_SYNTAX ; m_pLog->Log("File %s Line %d Reading <passive> tag: Invalid param (%s=%s)\n", pN->Fname(), pN->Line(), ai.Name(), ai.Value()) ; } } if (!p.name) { rc = E_SYNTAX ; m_pLog->Log("File %s Line %d <passive> No files specified\n", pN->Fname(), pN->Line()) ; } if (!p.value) { rc = E_SYNTAX ; m_pLog->Log("File %s Line %d <passive> No HTML type specified\n", pN->Fname(), pN->Line()) ; } if (rc == E_OK) m_Passives.Add(p) ; } else if (pN->NameEQ("recaptcha")) { for (ai = pN ; ai.Valid() ; ai.Advance()) { if (ai.NameEQ("public")) m_KeyPublic = ai.Value() ; else if (ai.NameEQ("private")) m_KeyPrivate = ai.Value() ; else { rc = E_SYNTAX ; m_pLog->Log("File %s Line %d Reading <recaptcha> tag: Invalid param (%s=%s)\n", pN->Fname(), pN->Line(), ai.Name(), ai.Value()) ; } } m_pLog->Log("File %s Line %d Set Google Recaptcha keys to public %s private %s\n", pN->Fname(), pN->Line(), *m_KeyPublic, *m_KeyPrivate) ; } else { rc = E_SYNTAX ; m_pLog->Log("File %s Line %d tag <%s> unexpected. Only the following are allowed\n", pN->Fname(), pN->Line(), pN->txtName()) ; m_pLog->Out("\tfldspec|rgxtype|enum|user|class|repos|login|logout|xpage|xstyle|xinclude|xscript|xtreeDcl|xfixfile|xfixdir|xmiscdir OR\n") ; m_pLog->Out("\tsiteLanguages|navigation|initstate|xformHdl|xformDef|includeCfg|passive|recaptcha\n") ; } } if (rc != E_OK) { m_pLog->Log("Aborted in config. Err=%s\n", Err2Txt(rc)) ; return rc ; } /* ** ** Set up the subscriber class and repository ** */ if (!m_DefaultLang) m_DefaultLang = "en-US" ; rc = AssertDir(m_Docroot, 0777); if (rc != E_OK) { m_pLog->Log("Cannot assert document root %s\n", *m_Docroot) ; return E_WRITEFAIL ; } rc = AssertDir(m_Datadir, 0777); if (rc != E_OK) { m_pLog->Log("Cannot assert data directory %s\n", *m_Datadir) ; return E_WRITEFAIL ; } if (chdir(*m_Docroot) < 0) { m_pLog->Log("Cannot CD to docroot [%s]\n", *m_Docroot) ; rc = E_NOINIT ; } else m_pLog->Log("Now operating in docroot [%s]\n", *m_Docroot) ; m_pLog->Log("Status=%s\n", Err2Txt(rc)) ; return rc ; }