本文整理汇总了PHP中rcube_charset::clean方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_charset::clean方法的具体用法?PHP rcube_charset::clean怎么用?PHP rcube_charset::clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcube_charset
的用法示例。
在下文中一共展示了rcube_charset::clean方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse_input_value
/**
* Parse/validate input value. See self::get_input_value()
* Performs stripslashes() and charset conversion if necessary
*
* @param string Input value
* @param boolean Allow HTML tags in field value
* @param string Charset to convert into
*
* @return string Parsed value
*/
public static function parse_input_value($value, $allow_html = FALSE, $charset = NULL)
{
global $OUTPUT;
if (empty($value)) {
return $value;
}
if (is_array($value)) {
foreach ($value as $idx => $val) {
$value[$idx] = self::parse_input_value($val, $allow_html, $charset);
}
return $value;
}
// strip single quotes if magic_quotes_sybase is enabled
if (ini_get('magic_quotes_sybase')) {
$value = str_replace("''", "'", $value);
} else {
if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
$value = stripslashes($value);
}
}
// remove HTML tags if not allowed
if (!$allow_html) {
$value = strip_tags($value);
}
$output_charset = is_object($OUTPUT) ? $OUTPUT->get_charset() : null;
// remove invalid characters (#1488124)
if ($output_charset == 'UTF-8') {
$value = rcube_charset::clean($value);
}
// convert to internal charset
if ($charset && $output_charset) {
$value = rcube_charset::convert($value, $output_charset, $charset);
}
return $value;
}
示例2: get
/**
* Returns header value
*/
public function get($name, $decode = true)
{
$name = strtolower($name);
if (isset($this->obj_headers[$name])) {
$value = $this->{$this->obj_headers[$name]};
} else {
$value = $this->others[$name];
}
if ($decode) {
if (is_array($value)) {
foreach ($value as $key => $val) {
$value[$key] = rcube_mime::decode_header($val, $this->charset);
$value[$key] = rcube_charset::clean($val);
}
} else {
$value = rcube_mime::decode_header($value, $this->charset);
$value = rcube_charset::clean($value);
}
}
return $value;
}
示例3: fix_attachment_name
/**
* Fix attachment name encoding if needed/possible
*/
protected function fix_attachment_name($name, $part)
{
if ($name == rcube_charset::clean($name)) {
return $name;
}
// find charset from part or its parent(s)
if ($part->charset) {
$charsets[] = $part->charset;
} else {
// check first part (common case)
$n = strpos($part->mime_id, '.') ? preg_replace('/\\.[0-9]+$/', '', $part->mime_id) . '.1' : 1;
if (($_part = $this->mime_parts[$n]) && $_part->charset) {
$charsets[] = $_part->charset;
}
// check parents' charset
$items = explode('.', $part->mime_id);
for ($i = count($items) - 1; $i > 0; $i--) {
$last = array_pop($items);
$parent = $this->mime_parts[join('.', $items)];
if ($parent && $parent->charset) {
$charsets[] = $parent->charset;
}
}
}
if ($this->headers->charset) {
$charsets[] = $this->headers->charset;
}
if (empty($charsets)) {
$rcube = rcube::get_instance();
$charsets[] = rcube_charset::detect($name, $rcube->config->get('default_charset', RCUBE_CHARSET));
}
foreach (array_unique($charsets) as $charset) {
$_name = rcube_charset::convert($name, $charset);
if ($_name == rcube_charset::clean($_name)) {
if (!$part->charset) {
$part->charset = $charset;
}
return $_name;
}
}
return $name;
}
示例4: json_serialize
/**
* Convert a variable into a javascript object notation
*
* @param mixed $input Input value
* @param boolean $pretty Enable JSON formatting
*
* @return string Serialized JSON string
*/
public static function json_serialize($input, $pretty = false)
{
$input = rcube_charset::clean($input);
$options = 0;
if ($pretty) {
$options |= JSON_PRETTY_PRINT;
}
// sometimes even using rcube_charset::clean() the input contains invalid UTF-8 sequences
// that's why we have @ here
return @json_encode($input, $options);
}
示例5: rc_utf8_clean
function rc_utf8_clean($input)
{
return rcube_charset::clean($input);
}
示例6: json_serialize
/**
* Convert a variable into a javascript object notation
*
* @param mixed Input value
*
* @return string Serialized JSON string
*/
public static function json_serialize($input)
{
$input = rcube_charset::clean($input);
// sometimes even using rcube_charset::clean() the input contains invalid UTF-8 sequences
// that's why we have @ here
return @json_encode($input);
}
示例7: get
/**
* Returns header value
*/
public function get($name, $decode = true)
{
$name = strtolower($name);
if (isset($this->obj_headers[$name])) {
$value = $this->{$this->obj_headers[$name]};
} else {
$value = $this->others[$name];
}
if ($decode) {
$value = rcube_mime::decode_header($value, $this->charset);
$value = rcube_charset::clean($value);
}
return $value;
}
示例8: parse_input_value
/**
* Parse/validate input value. See self::get_input_value()
* Performs stripslashes() and charset conversion if necessary
*
* @param string Input value
* @param boolean Allow HTML tags in field value
* @param string Charset to convert into
*
* @return string Parsed value
*/
public static function parse_input_value($value, $allow_html = false, $charset = null)
{
global $OUTPUT;
if (empty($value)) {
return $value;
}
if (is_array($value)) {
foreach ($value as $idx => $val) {
$value[$idx] = self::parse_input_value($val, $allow_html, $charset);
}
return $value;
}
// remove HTML tags if not allowed
if (!$allow_html) {
$value = strip_tags($value);
}
$output_charset = is_object($OUTPUT) ? $OUTPUT->get_charset() : null;
// remove invalid characters (#1488124)
if ($output_charset == 'UTF-8') {
$value = rcube_charset::clean($value);
}
// convert to internal charset
if ($charset && $output_charset) {
$value = rcube_charset::convert($value, $output_charset, $charset);
}
return $value;
}
示例9: test_clean
/**
* @dataProvider data_clean
*/
function test_clean($input, $output)
{
$this->assertEquals($output, rcube_charset::clean($input));
}
示例10: rc_utf8_clean
function rc_utf8_clean($input)
{
_deprecation_warning(__FUNCTION__);
return rcube_charset::clean($input);
}