PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/application/core/Filter/Stripslashes.php

https://github.com/olekhy/SimpleSite
PHP | 58 lines | 18 code | 4 blank | 36 comment | 1 complexity | 7bcdf0152b40d7098b88e4f8a3ad1d1a MD5 | raw file
  1. <?php
  2. /**
  3. * Abstract generic Calss Filter
  4. *
  5. * This source file is part of the Webfact Framework.
  6. *
  7. * @category Filter
  8. * @package App_Absract_Filter
  9. * @subpackage App_Absract_Filter_Stripslashes
  10. * @copyright Copyright (c) 2010 Webfact GmbH (http://www.webfact.de)
  11. * @author Oleksandr Khutoretsky <olekhy@googlemail.com>
  12. * @author Sascha-Oliver Prolic <saschaprolic@googlemail.com>
  13. */
  14. /**
  15. * Strip backslashes from string all was matched.
  16. * Or remove backslashes in special case when we
  17. * could'n set off magic_quotes_gpc directive in php.ini
  18. *
  19. * @category Filter
  20. * @package App_Absract_Filter
  21. * @subpackage App_Absract_Filter_Stripslashes
  22. * @copyright Copyright (c) 2010 Webfact GmbH (http://www.webfact.de)
  23. * @author Oleksandr Khutoretsky <olekhy@googlemail.com>
  24. * @author Sascha-Oliver Prolic <saschaprolic@googlemail.com>
  25. */
  26. class App_Abstract_Filter_Stripslashes implements Zend_Filter_Interface
  27. {
  28. /**
  29. * @var bool
  30. */
  31. private $_filterMagicGpc = false;
  32. /**
  33. * @param $filterMagicGpc
  34. * @return void
  35. */
  36. public function __construct($filterMagicGpc = false)
  37. {
  38. $this->_filterMagicGpc = (bool) $filterMagicGpc;
  39. }
  40. /**
  41. * apply the filter
  42. * @param string $value
  43. * @return string
  44. */
  45. public function filter($value)
  46. {
  47. $v = (string) $value;
  48. if(true === $this->_filterMagicGpc)
  49. {
  50. return @preg_replace('!\\\((\')|(\")|(\\\)|(0)|(NULL))!i', "$1", $v);
  51. }
  52. return stripslashes($v);
  53. }
  54. }