15#include <Wt/Http/Request.h>
16#include <Wt/Http/Response.h>
17#include <Wt/WDateTime.h>
18#include <Wt/WLayout.h>
19#include <Wt/WResource.h>
20#include <Wt/WServer.h>
27#define VAULT_ROOT std::string("/")
28#define CLIENT_FOLDERS "/"
32#ifdef __GRAB_DATE_STRING_FROM_PROGRAM_DATE__
34 stat( argv[0], &attr );
36 auto tm = localtime( &attr.st_mtime );
40 strftime( datestring,
sizeof(datestring), nl_langinfo(D_T_FMT), tm );
44 std::string datestring = __GNUCASHEW_VERSION__ +
" " + __GNUCASHEW_BUILD__;
46 std::cout << __DATETIMEPIDFILELINE__
85 std::cout << __FILE__ <<
":" << __LINE__
86 <<
"\n headers:" << request.
headers().size()
87 <<
"\n path:" << request.
path()
89 <<
"\n urlParams:" << request.
urlParams().size()
90 <<
"\n pathInfo:" << request.
pathInfo()
94 for(
auto header : request.
headers() )
96 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << header.name() <<
" " << header.value() << std::endl;
101 auto _blocked = [&]()
103 std::vector< std::string > allowed =
125 std::cout << __FILE__ <<
":" << __LINE__
126 <<
" HtmlResource::ipblocked: [" << request.
headerValue(
"X-Forwarded-For" ) <<
"]"
127 <<
" '" << request.
path() <<
"'"
130 response.
out() <<
"<html><body>oh oh, something went wrong.<br />Please contact the site administrator</body></html>";
133 file.open(
"HtmlResource.log", std::ios_base::app );
138 <<
" [" << request.
headerValue(
"x-Forwarded-For" ) <<
"]"
139 <<
" " << request.
path()
150 auto fileName =
"approot/html" + request.
pathInfo();
152 file.open( fileName );
154 if( !file.is_open() )
156 std::cout << __FILE__ <<
":" << __LINE__ <<
" NO FILE:" << fileName << std::endl;
157 response.
out() <<
"no file!";
160 std::cout << __FILE__ <<
":" << __LINE__
161 <<
" [" << request.
headerValue(
"X-Forwarded-For" ) <<
"]"
162 <<
" HtmlResource:" << fileName
165 response.
out() << file.rdbuf();
182 std::cout << __FILE__ <<
":" << __LINE__
183 <<
"\n headers:" << request. headers ().size()
184 <<
"\n path:" << request. path ()
185 <<
"\n queryString:" << request. queryString ()
186 <<
"\n urlParams:" << request. urlParams ().size()
187 <<
"\n pathInfo:" << request. pathInfo ()
188 <<
"\n clientAddress:" << request. clientAddress ()
191 for(
auto header : request.
headers() )
193 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << header.name() <<
" " << header.value() << std::endl;
199 auto _blocked = [&]()
201 std::vector< std::string > allowed =
224 std::cout << __FILE__ <<
":" << __LINE__
225 <<
" HtmlResource::ipblocked: [" << request.
headerValue(
"X-Forwarded-For" ) <<
"]"
226 <<
" '" << request.
path() <<
"'"
229 response.
out() <<
"<html><body>oh oh, something went wrong.<br />Please contact the site administrator</body></html>";
232 file.open(
"HtmlResource.log", std::ios_base::app );
237 <<
" [" << request.
headerValue(
"x-Forwarded-For" ) <<
"]"
238 <<
" " << request.
path()
246 response.
out() <<
"ok\n";
278 std::cout << __FILE__ <<
":" << __LINE__
279 <<
"\n headers:" << request. headers ().size()
280 <<
"\n path:" << request. path ()
281 <<
"\n queryString:" << request. queryString ()
282 <<
"\n urlParams:" << request. urlParams ().size()
283 <<
"\n pathInfo:" << request. pathInfo ()
284 <<
"\n clientAddress:" << request. clientAddress ()
287 for(
auto header : request.
headers() )
289 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << header.name() <<
" " << header.value() << std::endl;
294 auto _blocked = [&]()
296 std::vector< std::string > allowed =
319 std::cout << __FILE__ <<
":" << __LINE__
320 <<
" HtmlResource::ipblocked: [" << request.
headerValue(
"X-Forwarded-For" ) <<
"]"
321 <<
" '" << request.
path() <<
"'"
324 response.
out() <<
"<html><body>oh oh, something went wrong.<br />Please contact the site administrator</body></html>";
327 file.open(
"HtmlResource.log", std::ios_base::app );
332 <<
" [" << request.
headerValue(
"x-Forwarded-For" ) <<
"]"
333 <<
" " << request.
path()
342 for(
int i = 100000; i < 115000; i++ )
350 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << _path << std::endl;
357 response.
out() <<
"ok";
372 Wt::EntryPointType::Application,
375 return std::make_unique<C>(env);
381int main(
int argc,
char ** argv )
435 addEntryPoint< Redirector >(
"/" , server );
436 addEntryPoint< GCW::App >(
"/demo" , server );
437 addEntryPoint< GCW::App >(
"/gnucashew" , server );
445 std::cerr << e.
what() <<
" TERMINATING TERMINATING TERMINATING" << std::endl;
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response)
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response)
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response)
Redirector(const Wt::WEnvironment &env)
std::string headerValue(const std::string &field) const
std::vector< Message::Header > headers() const
std::string clientAddress() const
std::string queryString() const
std::string pathInfo() const
const std::vector< std::pair< std::string, std::string > > & urlParams() const
void redirect(const std::string &url)
WApplication(const WEnvironment &environment)
static WDateTime currentDateTime()
virtual const char * what() const override
static void setDefaultImplementation(LayoutImplementation implementation)
WTCONNECTOR_API void run()
WT_API void addEntryPoint(EntryPointType type, ApplicationCreator callback, const std::string &path=std::string(), const std::string &favicon=std::string())
std::string toUTF8() const
WString & arg(const std::wstring &value)
int main(int argc, char **argv)
void show_program_version(const std::string &message)
void addEntryPoint(const std::string &url, Wt::WServer &server)