Created
March 20, 2012 22:22
-
-
Save panbanda/2141902 to your computer and use it in GitHub Desktop.
Form Submission Handler for Base Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check for form submission with a csrf check | |
*/ | |
private function __form_submission() | |
{ | |
if ($post = Input::post()) | |
{ | |
$token = Arr::get($post, 'csrf'); | |
$action = Arr::get($post, 'action'); | |
if (! Security::check($token) OR $action === NULL) return FALSE; | |
$method = preg_replace('/[^a-zA-Z0-9_]+/', '', 'do_'.$action); | |
if (method_exists($this, $method)) | |
{ | |
call_user_func(array($this, $method)); | |
} | |
} | |
} | |
// This will call function do_{$action}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment