Skip to content

Instantly share code, notes, and snippets.

@koshiaaaaan
Created December 8, 2009 18:31
Show Gist options
  • Save koshiaaaaan/251877 to your computer and use it in GitHub Desktop.
Save koshiaaaaan/251877 to your computer and use it in GitHub Desktop.
<?php
require_once 'Zend/Filter/Interface.php';
class My_Filter_NormalizeMagicQuotesGpc implements Zend_Filter_Interface
{
protected $_flag ;
public function __construct( $flag = false )
{
$this->_flag = ( boolean ) $flag ;
}
public function getMagicQuotesGpc()
{
return $this->_flag ;
}
public function setMagicQuotesGpc( $flag )
{
$this->_flag = ( boolean ) $flag ;
return $this ;
}
public function filter( $value )
{
if( ( ! $this->_flag ) && ( get_magic_quotes_gpc() ) ) {
$value = stripslashes( $value ) ;
} else if( ( $this->_flag ) && ( ! get_magic_quotes_gpc() ) ) {
$value = addslashes( $value ) ;
}
return $value ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment