injitools /
cms-Inji
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Inji; |
||
| 4 | /** |
||
| 5 | * Server module |
||
| 6 | * |
||
| 7 | * @author Alexey Krupskiy <[email protected]> |
||
| 8 | * @link http://inji.ru/ |
||
| 9 | * @copyright 2015 Alexey Krupskiy |
||
| 10 | * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
||
| 11 | */ |
||
| 12 | class Server extends Module { |
||
| 13 | public $name = 'Server'; |
||
| 14 | |||
| 15 | function checkCsrf($key, $token) { |
||
| 16 | return !empty($_SESSION['csrf'][$key]) && $_SESSION['csrf'][$key] == $token; |
||
| 17 | } |
||
| 18 | |||
| 19 | function checkCsrfForm($formData) { |
||
|
0 ignored issues
–
show
|
|||
| 20 | if (empty($formData['csrfKey']) || empty($formData['csrfToken'])) { |
||
| 21 | return false; |
||
| 22 | } |
||
| 23 | return $this->checkCsrf($formData['csrfKey'], $formData['csrfToken']); |
||
| 24 | } |
||
| 25 | } |
||
| 26 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.