- StringFunctions::Convert(portstr,port);\r
-\r
- // set template\r
- templatestr="<html><head></head><body><a href=\"home.htm\">Home</a><br><h1>Could not find template.htm! Place in program directory and restart!</h1><br>[CONTENT]</body></html>";\r
- FILE *infile=fopen("template.htm","r+b");\r
- if(infile)\r
- {\r
- fseek(infile,0,SEEK_END);\r
- long len=ftell(infile);\r
- std::vector<char> data(len,0);\r
- fseek(infile,0,SEEK_SET);\r
- fread(&data[0],1,len,infile);\r
- fclose(infile);\r
- templatestr.assign(data.begin(),data.end());\r
- }\r
- else\r
- {\r
- m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"HTTPThread::HTTPThread could not open template.htm");\r
- }\r
-\r
- // push back page handlers\r
- m_pagehandlers.push_back(new ShowCaptchaPage());\r
- m_pagehandlers.push_back(new OptionsPage(templatestr));\r
- m_pagehandlers.push_back(new LocalIdentitiesPage(templatestr));\r
- m_pagehandlers.push_back(new CreateIdentityPage(templatestr));\r
- m_pagehandlers.push_back(new AnnounceIdentityPage(templatestr));\r
- m_pagehandlers.push_back(new AddPeerPage(templatestr));\r
- m_pagehandlers.push_back(new PeerTrustPage(templatestr));\r
- m_pagehandlers.push_back(new ControlBoardPage(templatestr));\r
- m_pagehandlers.push_back(new PeerDetailsPage(templatestr));\r
- m_pagehandlers.push_back(new PeerMaintenancePage(templatestr));\r
- m_pagehandlers.push_back(new ExecQueryPage(templatestr));\r
- // homepage must be last - catch all page handler\r
- m_pagehandlers.push_back(new HomePage(templatestr));\r
-\r
- m_ctx=0;\r
- m_ctx=shttpd_init(NULL,"listen_ports",portstr.c_str(),NULL);\r
- shttpd_listen(m_ctx,port,false);\r
-\r
- shttpd_register_uri(m_ctx,"*",HTTPThread::PageCallback,this);\r
-\r
-}\r
-\r
-HTTPThread::~HTTPThread()\r
-{\r
- shttpd_fini(m_ctx);\r
-\r
- for(std::vector<IPageHandler *>::iterator i=m_pagehandlers.begin(); i!=m_pagehandlers.end(); i++)\r
- {\r
- delete (*i);\r
- }\r
-\r