Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * This file is part of the symfony package.
5
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
 
11
/**
12
 * sfValidatorCSRFToken checks that the token is valid.
13
 *
14
 * @package    symfony
15
 * @subpackage validator
16
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17
 * @version    SVN: $Id: sfValidatorCSRFToken.class.php 7902 2008-03-15 13:17:33Z fabien $
18
 */
19
class sfValidatorCSRFToken extends sfValidatorBase
20
{
21
  /**
22
   * @see sfValidatorBase
23
   */
24
  protected function configure($options = array(), $messages = array())
25
  {
26
    $this->addRequiredOption('token');
27
 
28
    $this->setOption('required', true);
29
 
30
    $this->addMessage('csrf_attack', 'CSRF attack detected.');
31
  }
32
 
33
  /**
34
   * @see sfValidatorBase
35
   */
36
  protected function doClean($value)
37
  {
38
    if ($value != $this->getOption('token'))
39
    {
40
      throw new sfValidatorError($this, 'csrf_attack');
41
    }
42
 
43
    return $value;
44
  }
45
}