コード例 #1
0
ファイル: function.php プロジェクト: batcom/DaoCloudPHPDemo
function charset_encode($_input_charset, $_output_charset, $input)
{
    $output = "";
    $string = $input;
    if (is_array($input)) {
        $key = array_keys($string);
        $size = sizeof($key);
        for ($i = 0; $i < $size; $i++) {
            $string[$key[$i]] = charset_encode($_input_charset, $_output_charset, $string[$key[$i]]);
        }
        return $string;
    } else {
        if (!isset($_output_charset)) {
            $_output_charset = $_input_charset;
        }
        if ($_input_charset == $_output_charset || $input == null) {
            $output = $input;
        } elseif (function_exists("mb_convert_encoding")) {
            $output = mb_convert_encoding($input, $_output_charset, $_input_charset);
        } elseif (function_exists("iconv")) {
            $output = iconv($_input_charset, $_output_charset, $input);
        } else {
            die("sorry, you have no libs support for charset change.");
        }
        return $output;
    }
}
コード例 #2
0
 function build_url()
 {
     $url = $this->gateway;
     $sort_array = array();
     $arg = "";
     $sort_array = arg_sort($this->parameter);
     while (list($key, $val) = each($sort_array)) {
         $arg .= $key . "=" . urlencode(charset_encode($val, $this->parameter['_input_charset'])) . "&";
     }
     $url .= $arg . "sign=" . $this->mysign . "&sign_type=" . $this->sign_type;
     return $url;
 }
コード例 #3
0
ファイル: i18n.php プロジェクト: jprice/EHCP
/**
 * Combined decoding and encoding functions
 *
 * If conversion is done to charset different that utf-8, unsupported symbols
 * will be replaced with question marks.
 * @since 1.4.4 and 1.5.1
 * @param string $in_charset initial charset
 * @param string $string string that has to be converted
 * @param string $out_charset final charset
 * @param boolean $htmlencode keep htmlspecialchars encoding
 * @return string converted string
 */
function charset_convert($in_charset, $string, $out_charset, $htmlencode = true)
{
    $string = charset_decode($in_charset, $string, true);
    $string = charset_encode($string, $out_charset, $htmlencode);
    return $string;
}
コード例 #4
0
    $filename = $header->disposition->getProperty('filename');
    if (!$filename) {
        $filename = $header->disposition->getProperty('name');
    }
    if (!$filename) {
        $filename = $header->getParameter('name');
    }
} else {
    $filename = $header->getParameter('name');
}
$filename = decodeHeader($filename, true, false);
$filename = charset_encode($filename, $default_charset, false);
// If name is not set, use subject of email
if (strlen($filename) < 1) {
    $filename = decodeHeader($subject, true, true);
    $filename = charset_encode($filename, $default_charset, false);
    if ($type1 == 'plain' && $type0 == 'text') {
        $suffix = 'txt';
    } else {
        if ($type1 == 'richtext' && $type0 == 'text') {
            $suffix = 'rtf';
        } else {
            if ($type1 == 'postscript' && $type0 == 'application') {
                $suffix = 'ps';
            } else {
                if ($type1 == 'rfc822' && $type0 == 'message') {
                    $suffix = 'msg';
                } else {
                    $suffix = $type1;
                }
            }
コード例 #5
0
function ip2city($ip = '', $ipdatafile = '')
{
    include ROOT_PATH . '/inc/curl.class.php';
    $curl = new curl();
    $ip = empty($ip) ? real_ip() : $ip;
    $api = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=text&ip=' . $ip;
    $result = $curl->get($api);
    $arr = explode("\t", $result);
    if (isset($arr[5])) {
        $city = charset_encode($arr[5], $GLOBALS['proverbcharset'], 'gbk');
        if (empty($city)) {
            $city = !empty($_REQUEST['city']) ? $_REQUEST['city'] : '全国';
        }
    } else {
        $city = '全国';
    }
    return $city;
}
コード例 #6
0
 function admin_delete_action()
 {
     $key = empty($_GET['key']) ? 'id' : $_GET['key'];
     if (empty($_GET['table'])) {
         echo '参数有误';
         exit;
     } elseif (empty($_GET['val'])) {
         echo '字段值为空';
         exit;
     } else {
         $val = charset_encode($_GET['val'], $GLOBALS['charset'], 'utf-8');
         $container = "and {$key}='" . trim($val) . "'";
         $obj = new common($_GET['table']);
         if (in_array($_GET['table'], array('site', 'city', 'sitecate'))) {
             deletef($_GET['table']);
         }
         if ($_GET['table'] == 'catelist') {
             deletef('cate');
         }
         $group = $obj->GetOne($container);
         if ($group && $obj->DeleteData('1 ' . $container)) {
             exit('1');
         } else {
             exit('failed');
         }
     }
 }
コード例 #7
0
function _U2_Utf8_Gb($_C)
{
    $_String = '';
    if ($_C < 0x80) {
        $_String .= $_C;
    } elseif ($_C < 0x800) {
        $_String .= chr(0xc0 | $_C >> 6);
        $_String .= chr(0x80 | $_C & 0x3f);
    } elseif ($_C < 0x10000) {
        $_String .= chr(0xe0 | $_C >> 12);
        $_String .= chr(0x80 | $_C >> 6 & 0x3f);
        $_String .= chr(0x80 | $_C & 0x3f);
    } elseif ($_C < 0x200000) {
        $_String .= chr(0xf0 | $_C >> 18);
        $_String .= chr(0x80 | $_C >> 12 & 0x3f);
        $_String .= chr(0x80 | $_C >> 6 & 0x3f);
        $_String .= chr(0x80 | $_C & 0x3f);
    }
    return charset_encode($_String, 'gbk');
}