Exemplo n.º 1
0
 /**
  * If an array is the value of the given key, this method walks the array
  * recursively, applying $this->inspekt on any non-array values
  *
  * @param mixed $input
  * @return mixed
  * @throws Exception
  * @author Ed Finkler
  */
 protected function walkArray($input)
 {
     if (!Inspekt::isArrayOrArrayObject($input)) {
         throw new Exception('$input must be an array or ArrayObject');
     }
     foreach ($input as $key => $val) {
         if (Inspekt::isArrayOrArrayObject($val)) {
             $input[$key] = $this->walkArray($val);
         } else {
             $val = $this->inspekt($val);
             $input[$key] = $val;
         }
     }
     return $input;
 }
 /**
  * If an array is the value of the given key, this method walks the array
  * recursively, applying $this->inspekt on any non-array values
  *
  * @param mixed $input
  * @param 
  * @author Ed Finkler
  */
 protected function walkArray($input)
 {
     if (!isset($classname)) {
         $classname = __CLASS__;
     }
     if (!Inspekt::isArrayOrArrayObject($input)) {
         user_error('$input must be an array or ArrayObject', E_USER_ERROR);
         return FALSE;
     }
     foreach ($input as $key => $val) {
         if (Inspekt::isArrayOrArrayObject($val)) {
             $input[$key] = $this->walkArray($val);
         } else {
             $val = $this->inspekt($val);
             $input[$key] = $val;
         }
     }
     return $input;
 }
Exemplo n.º 3
0
    /**
     * This returns the value of the given key passed through the HTMLPurifer
     * object, if it is instantiated with Inspekt_Cage::loadHTMLPurifer
     *
     * @param string $key
     * @return mixed purified HTML version of input
     * @tag filter
     */
    public function getPurifiedHTML($key)
    {
        if (!isset($this->_purifier)) {
            Inspekt_Error::raiseError("HTMLPurifier was not loaded", E_USER_WARNING);
            return false;
        }

        if (!$this->keyExists($key)) {
            return false;
        }
        $val = $this->_getValue($key);
        if (Inspekt::isArrayOrArrayObject($val)) {
            return $this->_purifier->purifyArray($val);
        } else {
            return $this->_purifier->purify($val);
        }
    }
Exemplo n.º 4
0
 /**
  * Escapes the value given with pg_escape_bytea, so it should be safe for passing to a PostgreSQL BYTEA column
  * 
  * @param mixed $value
  * @param resource $conn the postgresql connection. If none is given, it will use the last link opened, per behavior of pg_escape_bytea
  * @return mixed
  * 
  * @link http://php.net/manual/en/function.pg-escape-bytea.php
  */
 public static function escPgSQLBytea($value, $conn = null)
 {
     static $connection;
     $connection = $conn;
     if (Inspekt::isArrayOrArrayObject($value)) {
         return Inspekt::_walkArray($value, 'escPgSQL');
     } else {
         if (isset($connection)) {
             return pg_escape_bytea($connection, $value);
         } else {
             return pg_escape_bytea($value);
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Escapes the value given with pg_escape_bytea
  *
  * @param mixed $value
  * @param resource $conn the postgresql connection. If none is given, it 
  *                       will use the last link opened, per behavior of pg_escape_bytea
  * @return mixed
  *
  * @link http://php.net/manual/en/function.pg-escape-bytea.php
  */
 static public function escPgSQLBytea($value, $conn = null)
 {
     if (Inspekt::isArrayOrArrayObject($value)) {
         return Inspekt::_walkArray($value, 'escPgSQL');
     } else {
         //might also check is_resource if pg_connection_status is too much
         if (isset($conn) && pg_connection_status($conn) === PGSQL_CONNECTION_OK) {
             return pg_escape_bytea($conn, $value);
         } else {
             return pg_escape_bytea($value);
         }
     }
 }
Exemplo n.º 6
0
 /**
  * This returns the value of the given key passed through the HTMLPurifer
  * object, if it is instantiated with Cage::loadHTMLPurifer
  *
  * @param string $key
  * @return mixed purified HTML version of input
  * @throws Exception
  * @tag filter
  */
 public function getPurifiedHTML($key)
 {
     if (!isset($this->purifier)) {
         throw new Exception("HTMLPurifier was not loaded");
     }
     $val = $this->getValue($key);
     if (Inspekt::isArrayOrArrayObject($val)) {
         return $this->purifier->purifyArray($val);
     } else {
         return $this->purifier->purify($val);
     }
 }