Example #1
0
 function decode($text, $type = 0)
 {
     if (empty($text)) {
         return '';
     } elseif (!is_string($text)) {
         return false;
     }
     return addslashes_deep_obj(json_decode(stripslashes($text), $type));
 }
Example #2
0
 function decode($text, $type = 0)
 {
     if (empty($text)) {
         return '';
     } elseif (!is_string($text)) {
         return false;
     }
     if (EC_CHARSET === 'utf-8' && function_exists('json_decode')) {
         return addslashes_deep_obj(json_decode(stripslashes($text), $type));
     }
     $this->at = 0;
     $this->ch = '';
     $this->text = strtr(stripslashes($text), array("\r" => '', "\n" => '', "\t" => '', "\\b" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "\v" => '', "\f" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => ''));
     $this->next();
     $return = $this->val();
     $result = empty($type) ? $return : $this->object_to_array($return);
     return addslashes_deep_obj($result);
 }
Example #3
0
    function decode($text,$type=0) // 默认type=0返回obj,type=1返回array
    {
        if (empty($text))
        {
            return '';
        }
        elseif (!is_string($text))
        {
            return false;
        }

        if (EC_CHARSET === 'utf-8' && function_exists('json_decode'))
        {
            return addslashes_deep_obj(json_decode(stripslashes($text),$type));
        }

        $this->at   = 0;
        $this->ch   = '';
        $this->text = strtr(stripslashes($text), array(
                "\r"   => '', "\n"   => '', "\t"   => '', "\b"   => '',
                "\x00" => '', "\x01" => '', "\x02" => '', "\x03" => '',
                "\x04" => '', "\x05" => '', "\x06" => '', "\x07" => '',
                "\x08" => '', "\x0b" => '', "\x0c" => '', "\x0e" => '',
                "\x0f" => '', "\x10" => '', "\x11" => '', "\x12" => '',
                "\x13" => '', "\x14" => '', "\x15" => '', "\x16" => '',
                "\x17" => '', "\x18" => '', "\x19" => '', "\x1a" => '',
                "\x1b" => '', "\x1c" => '', "\x1d" => '', "\x1e" => '',
                "\x1f" => ''
        ));

        $this->next();
        $return = $this->val();

        $result = empty($type) ? $return : $this->object_to_array($return);

        return addslashes_deep_obj($result);
    }
Example #4
0
/**
 * 将对象成员变量或者数组的特殊字符进行转义
 *
 * @access   public
 * @param    mix        $obj      对象或者数组
 * @author   Xuan Yan
 *
 * @return   mix                  对象或者数组
 */
function addslashes_deep_obj($obj)
{
    if (is_object($obj) == true) {
        foreach ($obj as $key => $val) {
            if ($val == true) {
                $obj->{$key} = addslashes_deep_obj($val);
            } else {
                $obj->{$key} = addslashes_deep($val);
            }
        }
    } else {
        $obj = addslashes_deep($obj);
    }
    return $obj;
}
Example #5
0
 function decode($text, $type = 0)
 {
     if (empty($text)) {
         return '';
     } elseif (!is_string($text)) {
         return false;
     }
     if (function_exists('json_decode')) {
         return addslashes_deep_obj(json_decode(stripslashes($text), $type));
     }
     $this->at = 0;
     $this->ch = '';
     $this->text = strtr(stripslashes($text), array("\r" => '', "\n" => '', "\t" => '', "\\b" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "\v" => '', "\f" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => '', "" => ''));
     $this->next();
     $return = $this->val();
     if (empty($type)) {
         $result = $return;
     } else {
         $result = $this->rec_get_object_vars($return);
         //print_r($result);
     }
     return addslashes_deep_obj($result);
 }