Massive refactoring of panel return code

Abstracted panel return code to a separate function, moved post data in
an assoc. array, enabled HTTPS support, and more.