diff options
Diffstat (limited to '')
-rw-r--r-- | src/sledjchisl/sledjchisl.c | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 915459a..83a4774 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c | |||
@@ -467,6 +467,7 @@ int idleTimeOut = 24 * 60 * 60; | |||
467 | int newbieTimeOut = 30; | 467 | int newbieTimeOut = 30; |
468 | float loadAverageInc = 0.5; | 468 | float loadAverageInc = 0.5; |
469 | int simTimeOut = 45; | 469 | int simTimeOut = 45; |
470 | boolean DEBUG = TRUE; | ||
470 | qhashtbl_t *mimeTypes; | 471 | qhashtbl_t *mimeTypes; |
471 | qlist_t *dbRequests; | 472 | qlist_t *dbRequests; |
472 | 473 | ||
@@ -2141,7 +2142,12 @@ static void HTMLheader(qgrow_t *reply, char *title) | |||
2141 | " <title>%s</title>\n" | 2142 | " <title>%s</title>\n" |
2142 | " <meta charset=\"UTF-8\">\n" | 2143 | " <meta charset=\"UTF-8\">\n" |
2143 | " <link rel=\"shortcut icon\" href=\"/SledjHamrIconSmall.png\">\n" | 2144 | " <link rel=\"shortcut icon\" href=\"/SledjHamrIconSmall.png\">\n" |
2144 | " <link type='text/css' rel='stylesheet' href='/debugStyle.css' media='all' />\n" | 2145 | , title); |
2146 | |||
2147 | if (DEBUG) | ||
2148 | reply->addstrf(reply, " <link type='text/css' rel='stylesheet' href='/debugStyle.css' media='all' />\n"); | ||
2149 | |||
2150 | reply->addstrf(reply, | ||
2145 | " <style> \n" | 2151 | " <style> \n" |
2146 | " html, body {background-color: black; color: white; font-family: 'sans-serif'; margin: 0; padding: 0;}\n" | 2152 | " html, body {background-color: black; color: white; font-family: 'sans-serif'; margin: 0; padding: 0;}\n" |
2147 | " a:link {color: aqua;}\n" | 2153 | " a:link {color: aqua;}\n" |
@@ -2158,7 +2164,7 @@ static void HTMLheader(qgrow_t *reply, char *title) | |||
2158 | " </head>\n" | 2164 | " </head>\n" |
2159 | " <body bgcolor='black' text='white' link='aqua' vlink='fuchsia' alink='red'>\n" | 2165 | " <body bgcolor='black' text='white' link='aqua' vlink='fuchsia' alink='red'>\n" |
2160 | " <font face='sans-serif'>" | 2166 | " <font face='sans-serif'>" |
2161 | , title); | 2167 | ); |
2162 | } | 2168 | } |
2163 | 2169 | ||
2164 | static void HTMLdebug(qgrow_t *reply) | 2170 | static void HTMLdebug(qgrow_t *reply) |
@@ -2372,22 +2378,25 @@ void HTMLfill(reqData *Rd, enum fragmentType type, char *text, int length) | |||
2372 | { | 2378 | { |
2373 | if (strcmp("DEBUG", text) == 0) | 2379 | if (strcmp("DEBUG", text) == 0) |
2374 | { | 2380 | { |
2375 | Rd->reply->addstrf(Rd->reply, "<h1>FastCGI SledjChisl</h1>\n" | 2381 | if (DEBUG) |
2376 | "<p>Request number %d, Process ID: %d</p>\n", count++, getpid()); | 2382 | { |
2377 | Rd->reply->addstrf(Rd->reply, "<p>libfcgi version: %s</p>\n", FCGI_VERSION); | 2383 | Rd->reply->addstrf(Rd->reply, "<h1>FastCGI SledjChisl</h1>\n" |
2378 | Rd->reply->addstrf(Rd->reply, "<p>Lua version: %s</p>\n", LUA_RELEASE); | 2384 | "<p>Request number %d, Process ID: %d</p>\n", count++, getpid()); |
2379 | Rd->reply->addstrf(Rd->reply, "<p>LuaJIT version: %s</p>\n", LUAJIT_VERSION); | 2385 | Rd->reply->addstrf(Rd->reply, "<p>libfcgi version: %s</p>\n", FCGI_VERSION); |
2380 | Rd->reply->addstrf(Rd->reply, "<p>MySQL client version: %s</p>\n", mysql_get_client_info()); | 2386 | Rd->reply->addstrf(Rd->reply, "<p>Lua version: %s</p>\n", LUA_RELEASE); |
2381 | outize(Rd->reply, Rd->headers, "Environment"); | 2387 | Rd->reply->addstrf(Rd->reply, "<p>LuaJIT version: %s</p>\n", LUAJIT_VERSION); |
2382 | outize(Rd->reply, Rd->cookies, "Cookies"); | 2388 | Rd->reply->addstrf(Rd->reply, "<p>MySQL client version: %s</p>\n", mysql_get_client_info()); |
2383 | outize(Rd->reply, Rd->queries, "Query"); | 2389 | outize(Rd->reply, Rd->headers, "Environment"); |
2384 | outize(Rd->reply, Rd->body, "POST body"); | 2390 | outize(Rd->reply, Rd->cookies, "Cookies"); |
2385 | outize(Rd->reply, Rd->stuff, "Stuff"); | 2391 | outize(Rd->reply, Rd->queries, "Query"); |
2386 | showSesh(Rd->reply, &Rd->shs); | 2392 | outize(Rd->reply, Rd->body, "POST body"); |
2387 | if (Rd->lnk) showSesh(Rd->reply, Rd->lnk); | 2393 | outize(Rd->reply, Rd->stuff, "Stuff"); |
2388 | outize(Rd->reply, Rd->database, "Database"); | 2394 | showSesh(Rd->reply, &Rd->shs); |
2389 | outizeCookie(Rd->reply, Rd->Rcookies, "Reply Cookies"); | 2395 | if (Rd->lnk) showSesh(Rd->reply, Rd->lnk); |
2390 | outize(Rd->reply, Rd->Rheaders, "Reply HEADERS"); | 2396 | outize(Rd->reply, Rd->database, "Database"); |
2397 | outizeCookie(Rd->reply, Rd->Rcookies, "Reply Cookies"); | ||
2398 | outize(Rd->reply, Rd->Rheaders, "Reply HEADERS"); | ||
2399 | } | ||
2391 | } | 2400 | } |
2392 | else if (strcmp("URL", text) == 0) | 2401 | else if (strcmp("URL", text) == 0) |
2393 | Rd->reply->addstrf(Rd->reply, "%s://%s%s", Rd->Scheme, Rd->Host, Rd->Script); | 2402 | Rd->reply->addstrf(Rd->reply, "%s://%s%s", Rd->Scheme, Rd->Host, Rd->Script); |
@@ -4083,7 +4092,7 @@ void loginPage(reqData *Rd, char *message) | |||
4083 | 4092 | ||
4084 | Rd->stuff->remove(Rd->stuff, "UUID"); | 4093 | Rd->stuff->remove(Rd->stuff, "UUID"); |
4085 | HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager"); | 4094 | HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager"); |
4086 | HTMLdebug(Rd->reply); | 4095 | if (DEBUG) HTMLdebug(Rd->reply); |
4087 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n"); | 4096 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n"); |
4088 | Rd->reply->addstr(Rd->reply, linky); | 4097 | Rd->reply->addstr(Rd->reply, linky); |
4089 | free(linky); | 4098 | free(linky); |
@@ -4118,7 +4127,7 @@ void accountCreationPage(reqData *Rd, char *message) | |||
4118 | // TODO - eww lots of memory leaks here. | 4127 | // TODO - eww lots of memory leaks here. |
4119 | // TODO - need to check if qLibc does it's own free() calls, and fill in the gaps for when it doesn't. | 4128 | // TODO - need to check if qLibc does it's own free() calls, and fill in the gaps for when it doesn't. |
4120 | HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager"); | 4129 | HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager"); |
4121 | HTMLdebug(Rd->reply); | 4130 | if (DEBUG) HTMLdebug(Rd->reply); |
4122 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n"); | 4131 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n"); |
4123 | Rd->reply->addstrf(Rd->reply, "<h2>Creating <!--#echo var=\"grid\" --> account for %s</h2>\n", name); | 4132 | Rd->reply->addstrf(Rd->reply, "<h2>Creating <!--#echo var=\"grid\" --> account for %s</h2>\n", name); |
4124 | Rd->reply->addstr(Rd->reply, linky); | 4133 | Rd->reply->addstr(Rd->reply, linky); |
@@ -4193,7 +4202,7 @@ void loggedOnPage(reqData *Rd, char *message) | |||
4193 | char *toke_n_munchie = getCookie(Rd->Rcookies, "toke_n_munchie"); | 4202 | char *toke_n_munchie = getCookie(Rd->Rcookies, "toke_n_munchie"); |
4194 | 4203 | ||
4195 | HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager"); | 4204 | HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager"); |
4196 | HTMLdebug(Rd->reply); | 4205 | if (DEBUG) HTMLdebug(Rd->reply); |
4197 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n"); | 4206 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n"); |
4198 | Rd->reply->addstrf(Rd->reply, "<h2><!--#echo var=\"grid\" --> account for %s</h2>\n", name); | 4207 | Rd->reply->addstrf(Rd->reply, "<h2><!--#echo var=\"grid\" --> account for %s</h2>\n", name); |
4199 | Rd->reply->addstr(Rd->reply, linky); | 4208 | Rd->reply->addstr(Rd->reply, linky); |
@@ -4233,7 +4242,7 @@ void listPage(reqData *Rd, char *message) | |||
4233 | char *toke_n_munchie = getCookie(Rd->Rcookies, "toke_n_munchie"); | 4242 | char *toke_n_munchie = getCookie(Rd->Rcookies, "toke_n_munchie"); |
4234 | 4243 | ||
4235 | HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager"); | 4244 | HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager"); |
4236 | HTMLdebug(Rd->reply); | 4245 | if (DEBUG) HTMLdebug(Rd->reply); |
4237 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n"); | 4246 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n"); |
4238 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> member accounts</h1>\n"); | 4247 | Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> member accounts</h1>\n"); |
4239 | Rd->reply->addstr(Rd->reply, linky); | 4248 | Rd->reply->addstr(Rd->reply, linky); |
@@ -4594,6 +4603,11 @@ jit library is loaded or the JIT compiler will not be activated. | |||
4594 | } | 4603 | } |
4595 | else if (lua_isstring(L, -1)) | 4604 | else if (lua_isstring(L, -1)) |
4596 | configs->putstr(configs, n, (char *) lua_tostring(L, -1)); | 4605 | configs->putstr(configs, n, (char *) lua_tostring(L, -1)); |
4606 | else if (lua_isboolean(L, -1)) | ||
4607 | { | ||
4608 | int v = lua_toboolean(L, -1); | ||
4609 | configs->putint(configs, n, v); | ||
4610 | } | ||
4597 | else | 4611 | else |
4598 | { | 4612 | { |
4599 | char *v = (char *) lua_tostring(L, -1); | 4613 | char *v = (char *) lua_tostring(L, -1); |
@@ -4604,6 +4618,8 @@ jit library is loaded or the JIT compiler will not be activated. | |||
4604 | } | 4618 | } |
4605 | } | 4619 | } |
4606 | } | 4620 | } |
4621 | DEBUG = configs->getint(configs, "debug"); | ||
4622 | d("Setting DEBUG = %d", DEBUG); | ||
4607 | if ((vd = configs->get (configs, "loadAverageInc", NULL, false)) != NULL) {loadAverageInc = *((float *) vd); d("Setting loadAverageInc = %f", loadAverageInc);} | 4623 | if ((vd = configs->get (configs, "loadAverageInc", NULL, false)) != NULL) {loadAverageInc = *((float *) vd); d("Setting loadAverageInc = %f", loadAverageInc);} |
4608 | if ((vd = configs->get (configs, "simTimeOut", NULL, false)) != NULL) {simTimeOut = (int) *((float *) vd); d("Setting simTimeOut = %d", simTimeOut);} | 4624 | if ((vd = configs->get (configs, "simTimeOut", NULL, false)) != NULL) {simTimeOut = (int) *((float *) vd); d("Setting simTimeOut = %d", simTimeOut);} |
4609 | if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; d("Setting scRoot = %s", scRoot);} | 4625 | if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; d("Setting scRoot = %s", scRoot);} |