예제 #1
0
 /**
  * Execute the callback.
  */
 public function execute()
 {
     $action = ucfirst(Request::get('action'));
     $request_type = strtolower(Request::type());
     if ($action) {
         if (in_array($request_type . $action, get_class_methods($this))) {
             $this->{$request_type . $action}();
             $this->output();
         } else {
             Messenger::error('There was an error processing your submission.');
         }
     } else {
         if (in_array($request_type, get_class_methods($this))) {
             $this->{$request_type}();
             $this->output();
         } else {
             $this->output = array();
             // TODO: show 302
             echo 'Method not available';
             exit;
         }
     }
 }
예제 #2
0
 /**
  * Make sure a valid token has been received.
  *
  * @return boolean
  *   Whether the token is valid.
  */
 public function validateToken() {
     // If this is a post request, there must be a valid token.
     if (!$this->ignoreToken && strtolower(Request::type()) == 'post') {
         $token = Request::post('token', 'hex');
         return !empty($token) && $token == Session::getInstance()->getToken();
     } else {
         // This is not a POST request so it's not required.
         return true;
     }
 }