All pastes #163373 Raw Edit

naderman

public php v1 · immutable
·published 2006-09-07 14:01 UTC
rendered paste body
/*** set_var** Set variable, used by {@link request_var the request_var function}** @access private*/function set_var(&$result, $var, $type, $multibyte = false){	settype($var, $type);	$result = $var;	if ($type == 'string')	{		$result = trim(htmlspecialchars(str_replace(array("\r\n", "\r"), array("\n", "\n"), $result), ENT_QUOTES, 'UTF-8'));		if (!empty($result))		{			// Make sure multibyte characters are wellformed			if ($multibyte)			{				if (!preg_match('/^./u', $result))				{					$result = '';				}			}			else			{				// no multibyte, allow only ASCII (0-127)				$result = preg_replace('/[\x80-\xFF]/', '?', $result);			}		}		$result = (STRIP) ? stripslashes($result) : $result;	}}