summaryrefslogtreecommitdiff
path: root/server/src/admin_connection.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-12-06 14:15:52 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2011-12-06 14:15:52 +0100
commit8f00317567dab4c825a0eca76a9cae7951edd11f (patch)
treecb0d052e81e1fa9608eb7c3dc539dcc1d65e5043 /server/src/admin_connection.cc
parentfbeee6710e4132a921ea3c7de15799a8eb681e97 (diff)
Clean up the way connections are handled.
Diffstat (limited to 'server/src/admin_connection.cc')
-rw-r--r--server/src/admin_connection.cc110
1 files changed, 54 insertions, 56 deletions
diff --git a/server/src/admin_connection.cc b/server/src/admin_connection.cc
index fac52a1..5a15a34 100644
--- a/server/src/admin_connection.cc
+++ b/server/src/admin_connection.cc
@@ -90,70 +90,68 @@ AdminConnection::AdminConnection(Environment &e, headers_t a, std::string u)
AdminConnection::~AdminConnection() {}
-bool AdminConnection::handle(const char *data, size_t size)
+bool AdminConnection::data(const char *, size_t) { return true; }
+
+bool AdminConnection::handle()
{
status = 200; // OK
- if(data == NULL && size == 0) {
- DEBUG(admin, "URI: %s\n", uri.c_str());
-
- if(uri == "/") {
- reply = admin_header(uri) +
- "Command list:\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"
- "<strong>/export?template=<em>[TEMPLATE]</em></strong> export template with name [TEMPLATE] to a\n csf file (comma seperated file, that can be opened in OOCalc or Excel).\n"
- + admin_rc("footer");
- return true;
- }
-
- if(uri == "/sessionunlock" && args.find("id") != args.end()) {
- reply = admin_header(uri) + admin_sessionunlock(env, args["id"])
- + admin_rc("footer");
- return true;
- }
+ DEBUG(admin, "URI: %s\n", uri.c_str());
- 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;
- }
-
- if(uri == "/export" && args.find("template") != args.end()) {
- time_t from = 0;
- if(args.find("from") != args.end()) from = atoi(args["from"].c_str());
-
- time_t to = time(NULL);
- if(args.find("to") != args.end()) to = atoi(args["to"].c_str());
- bool ok;
- std::string res = admin_export(env, args["template"], &ok, from, to);
- if(!ok) reply = admin_header(uri) + res + admin_rc("footer");
- else {
- reply = res;
- hdrs["Content-Type"] = "text/csv; charset=UTF-8";
- hdrs["Content-Disposition"] = "attachment; filename=\""+args["template"]+".csv\"";
- }
- return true;
- }
-
- if(uri == "/favicon.ico") {
- hdrs["Content-Type"] = "image/ico";
- reply = admin_rc("favicon");
- return true;
- }
-
- reply = admin_header(uri) +
- "'" + uri + "' not recognised as a valid command."
+ if(uri == "/") {
+ reply = admin_header(uri) +
+ "Command list:\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"
+ "<strong>/export?template=<em>[TEMPLATE]</em></strong> export template with name [TEMPLATE] to a\n csf file (comma seperated file, that can be opened in OOCalc or Excel).\n"
+ admin_rc("footer");
return true;
}
+
+ if(uri == "/sessionunlock" && args.find("id") != args.end()) {
+ 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;
+ }
+
+ if(uri == "/export" && args.find("template") != args.end()) {
+ time_t from = 0;
+ if(args.find("from") != args.end()) from = atoi(args["from"].c_str());
+
+ time_t to = time(NULL);
+ if(args.find("to") != args.end()) to = atoi(args["to"].c_str());
+ bool ok;
+ std::string res = admin_export(env, args["template"], &ok, from, to);
+ if(!ok) reply = admin_header(uri) + res + admin_rc("footer");
+ else {
+ reply = res;
+ hdrs["Content-Type"] = "text/csv; charset=UTF-8";
+ hdrs["Content-Disposition"] = "attachment; filename=\""+args["template"]+".csv\"";
+ }
+ return true;
+ }
+ if(uri == "/favicon.ico") {
+ hdrs["Content-Type"] = "image/ico";
+ reply = admin_rc("favicon");
+ return true;
+ }
+
+ reply = admin_header(uri) +
+ "'" + uri + "' not recognised as a valid command."
+ + admin_rc("footer");
return true;
}