/**
 * stripslashes() string or nested array of strings
 *
 * @param  string|array  with slashes
 * @return string|array  without slashes
 */
function cbStripslashes( $value ) {
	$striped					=	'';
	if ( is_string( $value ) ) {
		$striped				=	stripslashes( $value );
	} else {
		if ( is_array( $value ) ) {
			$striped			=	array();
			foreach ( array_keys( $value ) as $k ) {
				$striped[$k]	=	cbStripslashes( $value[$k] );
			}
		} else {
			$striped			=	$value;
		}
	}
	return $striped;
}
Example #2
0
	/**
	 * gets cookie set by cbSetcookie ! WARNING: always unescaped
	 * //TBD: add domain info in cookie-name
	 *
	 * @param  string            $name
	 * @param  string|array      $defaultValue
	 * @return string|array|null
	 */
	function getcookie( $name, $defaultValue = null ) {
		global $_COOKIE;
	
		return cbStripslashes( cbGetParam( $_COOKIE, $name, $defaultValue ) );
	}
 /**
  * Copy the named array or object content into this object as vars
  * only existing vars of object are filled.
  * When undefined in array, object variables are kept.
  * 
  * WARNING: DOES addslashes / escape BY DEFAULT
  * 
  * Can be overridden or overloaded.
  *
  * @param  array|object  $array         The input array or object
  * @param  string        $ignore        Fields to ignore
  * @param  string        $prefix        Prefix for the array keys
  * @param  boolean       $checkSlashes  TRUE: if magic_quotes are ON, remove slashes (TRUE BY DEFAULT !)
  * @return boolean                      TRUE: ok, FALSE: error on array binding
  */
 function bind($array, $ignore = '', $prefix = null, $checkSlashes = true)
 {
     if (is_array($array) || is_object($array)) {
         $ignore = ' ' . $ignore . ' ';
         foreach (get_object_vars($this) as $k => $v) {
             if (substr($k, 0, 1) != '_') {
                 if (strpos($ignore, ' ' . $k . ' ') === false) {
                     $ak = $prefix . $k;
                     if (is_array($array) && isset($array[$ak])) {
                         $this->{$k} = $checkSlashes && get_magic_quotes_gpc() ? cbStripslashes($array[$ak]) : $array[$ak];
                     } elseif (isset($array->{$ak})) {
                         $this->{$k} = $checkSlashes && get_magic_quotes_gpc() ? cbStripslashes($array->{$ak}) : $array->{$ak};
                     }
                 }
             }
         }
     } else {
         $this->_error = get_class($this) . "::bind failed: not an array.";
         return false;
     }
     return true;
 }