- if ($handler) {
- if ($handler->before()) {
- if ($method && method_exists($handler, $method)) {
- $handler->$method();
- } else if (method_exists($handler, 'index')) {
- $handler->index();
+ if ($handler && implements_interface($handler, 'IHandler')) {
+ if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) {
+ if ($handler->before($method)) {
+ if ($method && method_exists($handler, $method)) {
+ $handler->$method();
+ } else {
+ if (method_exists($handler, "catchall")) {
+ $handler->catchall($method);
+ }
+ }
+ $handler->after();
+ return;
+ } else {
+ header("Content-Type: text/json");
+ print error_json(6);
+ return;