Skip to content

Commit

Permalink
Removed namespace backslashes of Exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
BKcore committed Oct 25, 2011
1 parent 3a19cf7 commit 758613c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion example/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// ...
$result = 'CSRF check passed. Form parsed.';
}
catch ( \Exception $e )
catch ( Exception $e )
{
// CSRF attack detected
$result = $e->getMessage() . ' Form ignored.';
Expand Down
8 changes: 4 additions & 4 deletions example/nocsrf.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public static function check( $key, $origin, $throwException=false, $timespan=nu
{
if ( !isset( $_SESSION[ 'csrf_' . $key ] ) )
if($throwException)
throw new \Exception( 'Missing CSRF session token.' );
throw new Exception( 'Missing CSRF session token.' );
else
return false;

if ( !isset( $origin[ $key ] ) )
if($throwException)
throw new \Exception( 'Missing CSRF form token.' );
throw new Exception( 'Missing CSRF form token.' );
else
return false;

Expand All @@ -42,14 +42,14 @@ public static function check( $key, $origin, $throwException=false, $timespan=nu
// Check if session token matches form token
if ( $origin[ $key ] != $hash )
if($throwException)
throw new \Exception( 'Invalid CSRF token.' );
throw new Exception( 'Invalid CSRF token.' );
else
return false;

// Check for token expiration
if ( $timespan != null && is_int( $timespan ) && intval( substr( base64_decode( $hash ), 0, 10 ) ) + $timespan < time() )
if($throwException)
throw new \Exception( 'CSRF token has expired.' );
throw new Exception( 'CSRF token has expired.' );
else
return false;

Expand Down
8 changes: 4 additions & 4 deletions nocsrf.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public static function check( $key, $origin, $throwException=false, $timespan=nu
{
if ( !isset( $_SESSION[ 'csrf_' . $key ] ) )
if($throwException)
throw new \Exception( 'Missing CSRF session token.' );
throw new Exception( 'Missing CSRF session token.' );
else
return false;

if ( !isset( $origin[ $key ] ) )
if($throwException)
throw new \Exception( 'Missing CSRF form token.' );
throw new Exception( 'Missing CSRF form token.' );
else
return false;

Expand All @@ -42,14 +42,14 @@ public static function check( $key, $origin, $throwException=false, $timespan=nu
// Check if session token matches form token
if ( $origin[ $key ] != $hash )
if($throwException)
throw new \Exception( 'Invalid CSRF token.' );
throw new Exception( 'Invalid CSRF token.' );
else
return false;

// Check for token expiration
if ( $timespan != null && is_int( $timespan ) && intval( substr( base64_decode( $hash ), 0, 10 ) ) + $timespan < time() )
if($throwException)
throw new \Exception( 'CSRF token has expired.' );
throw new Exception( 'CSRF token has expired.' );
else
return false;

Expand Down

0 comments on commit 758613c

Please sign in to comment.