Source for file Slashes.class.php

Documentation is available at Slashes.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package Converter
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * Add/Strip Slashes Converter Class
  22.  *
  23.  * @category Gumbo
  24.  * @package Converter
  25.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  26.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  27.  * @author Michael Luster <mluster79@yahoo.com>
  28.  * @link http://sourceforge.net/projects/phpgumbo
  29.  * @desc Add/Strip Slashes Converter Class
  30.  * @version 0.0.1
  31.  */
  32.  
  33. gumbo_load ("Converter_Abstract");
  34.  
  35.     
  36.     /** ACTION METHODS **/
  37.     /**
  38.      * Returns added slashes to data
  39.      * @param string $data 
  40.      * @return string 
  41.      */
  42.     public function toAdd ($data{
  43.         try {
  44.             // verify precondition
  45.             if (!is_string ($data)) {
  46.                 throw new Gumbo_Exception ("Invalid Argument 'data:str' => {$data}:gettype ($data));
  47.             }
  48.             
  49.             if (get_magic_quotes_gpc ()) {
  50.                 return $data;
  51.             }
  52.             return addslashes ($data);
  53.         catch (Gumbo_Exception $e{
  54.             $e->setFunction (__METHOD__);
  55.             gumbo_trigger ($e);
  56.         }
  57.         return null;
  58.     }
  59.     
  60.     /**
  61.      * Returns as slashes stripped
  62.      * @param string $data 
  63.      * @return string 
  64.      */
  65.     public function toStrip ($data{
  66.         try {
  67.             // verify precondition
  68.             if (!is_string ($data)) {
  69.                 throw new Gumbo_Exception ("Invalid Argument 'data:str' => {$data}:gettype ($data));
  70.             }
  71.             
  72.             return stripslashes ($data);
  73.         catch (Gumbo_Exception $e{
  74.             $e->setFunction (__METHOD__);
  75.             gumbo_trigger ($e);
  76.         }
  77.         return null;
  78.     }
  79.     
  80. }
  81.  
  82. ?>