diff options
author | deva <deva> | 2011-02-08 09:29:16 +0000 |
---|---|---|
committer | deva <deva> | 2011-02-08 09:29:16 +0000 |
commit | 3ea735592f26616c35ecddd44cf1a54415df20ac (patch) | |
tree | 7dcc69d89f1b672b5072943458f0e0b31a2afd2f /server/src/admin_connection.cc | |
parent | a65a5d1594d09d575d9e835d684eb52675341054 (diff) |
Add URI in html title.
Diffstat (limited to 'server/src/admin_connection.cc')
-rw-r--r-- | server/src/admin_connection.cc | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/server/src/admin_connection.cc b/server/src/admin_connection.cc index ae427a3..e8c5b02 100644 --- a/server/src/admin_connection.cc +++ b/server/src/admin_connection.cc @@ -31,6 +31,8 @@ #include "debug.h" +#include "configuration.h" + static std::string admin_sessionunlock(Environment &env, std::string id) { Session *session = env.sessions.session(id); @@ -46,6 +48,31 @@ static std::string admin_sessionunlock(Environment &env, std::string id) return "Session " + id + " does not exist or has been committed."; } +static std::string admin_listactivesessions(Environment &env) +{ + std::string str; + + std::vector<std::string> act = env.sessions.activeSessions(); + std::vector<std::string>::iterator i = act.begin(); + while(i != act.end()) { + str += "Session " + *i + "\n"; + i++; + } + + return str; +} + +static std::string admin_header(std::string uri) +{ + return admin_rc("header1") + uri + admin_rc("header2"); +} + +static std::string admin_flush(Environment &env) +{ + env.sessions.store(); + return "All sessions flushed to disc in " + Conf::session_path + "."; +} + AdminConnection::AdminConnection(Environment &e, headers_t a, std::string u) : env(e), args(a), uri(u) {} @@ -57,15 +84,29 @@ bool AdminConnection::handle(const char *data, size_t size) DEBUG(admin, "URI: %s\n", uri.c_str()); if(uri == "/") { - reply = admin_rc("header") + + reply = admin_header(uri) + "Command list:\n" - "/sessionunlock?id=[ID] unlock session with [ID] as its session id.\n" + "<strong>/sessionunlock?id=<em>[ID]</em></strong> unlock session with [ID] as its session id.\n" + "<strong>/listactivesessions</strong> lists all active sessions on the server.\n" + "<strong>/flushsessions</strong> flushes all active sessions to disc.\n" + admin_rc("footer"); return true; } if(uri == "/sessionunlock" && args.find("id") != args.end()) { - reply = admin_rc("header") + admin_sessionunlock(env, args["id"]) + reply = admin_header(uri) + admin_sessionunlock(env, args["id"]) + + admin_rc("footer"); + return true; + } + + if(uri == "/listactivesessions") { + reply = admin_header(uri) + admin_listactivesessions(env) + + admin_rc("footer"); + return true; + } + + if(uri == "/flushsessions") { + reply = admin_header(uri) + admin_flush(env) + admin_rc("footer"); return true; } @@ -92,17 +133,3 @@ void AdminConnection::getReply(Httpd::Reply &r) r.headers = hdrs; r.status = 200; // http 'OK' } - -#ifdef TEST_ADMIN_CONNECTION -//deps: -//cflags: -//libs: -#include "test.h" - -TEST_BEGIN; - -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_ADMIN_CONNECTION*/ |