示例#1
0
文件: Request.php 项目: Roewe/encoder
 public function punyencode($inputtext, $inputenc)
 {
     require_once 'assets/php/vendors/idna_convert_060/idna_convert.class.php';
     require_once 'assets/php/vendors/idna_convert_060/transcode_wrapper.php';
     $IDN = new idna_convert();
     return $IDN->encode(encode_utf8($inputtext, $inputenc));
 }
示例#2
0
function listLastVisit()
{
    global $xml_database_comname;
    global $userfolder;
    global $lastvisit_config_file;
    $lastvisitfile = $userfolder . $lastvisit_config_file;
    $lastvisitfile = encode_utf8($lastvisitfile);
    $xml = new COM($xml_database_comname, NULL, CP_UTF8) or die("create com instance error");
    $xml->ReadDB($lastvisitfile);
    $xml->ResetPos();
    if (!$xml->FindElem("database")) {
        return false;
    }
    $xml->IntoElem();
    if (!$xml->FindElem("lastvisit")) {
        return false;
    }
    $lastvisit = array();
    while ($xml->FindElem("item")) {
        $info = array();
        $xml->ResetChildPos();
        while ($xml->FindChildElem("")) {
            $name = $xml->GetChildTagName();
            $value = $xml->GetChildData();
            $info[strtolower($name)] = $value;
        }
        $lastvisit[] = $info;
    }
    return true;
}
示例#3
0
function encode_punycode_item($name, $useutf8 = true)
{
    if (substr($name, 0, 4) != "xn--") {
        if (!$useutf8) {
            $name = encode_utf8($name);
        }
        $punycode = new Punycode();
        $name = $punycode->encode($name);
    }
    return $name;
}
 /**
  * Convert a string to UTF-8
  *
  * Return the encoded string or false on failure
  *
  * @param string $strValue
  * @param string $strEncoding
  * @param bool   $booSafemode
  *
  * @return string string|false on failure
  *
  * @see encode_utf8
  */
 public static function encodeUtf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false)
 {
     return encode_utf8($strValue = '', $strEncoding = 'iso-8859-1', $booSafemode = false);
 }
示例#5
0
 /**
  * Convert an internationalized domain name or URL to ASCII-compatible encoding.
  * 
  * @param string $url Either a domain name or a complete URL. 
  * @param string $charset The character encoding of the $url parameter. Defaults to the encoding set in Settings -> Reading.
  * @return string
  */
 static function idn_to_ascii($url, $charset = '')
 {
     $idn = blcUtility::get_idna_converter();
     if ($idn != null) {
         if (empty($charset)) {
             $charset = get_bloginfo('charset');
         }
         //Encode only the host
         if (preg_match('@(\\w+:/*)?([^/:]+)(.*$)?@s', $url, $matches)) {
             $host = $matches[2];
             if (strtoupper($charset) != 'UTF-8' && strtoupper($charset) != 'UTF8') {
                 $host = encode_utf8($host, $charset, true);
             }
             $host = $idn->encode($host);
             $url = $matches[1] . $host . $matches[3];
         }
     }
     return $url;
 }
示例#6
0
文件: lib.php 项目: honj51/taobaocrm
function have_external_pop3()
{
    global $userfolder;
    global $userinfo_config_file;
    global $xml_database_comname;
    $pref_file = $userfolder . $userinfo_config_file;
    if (!file_exists($pref_file)) {
        return;
    }
    $pref_file = encode_utf8($pref_file);
    $xml = simplexml_load_file($pref_file);
    if (isset($xml->pop3mail) && $xml->pop3mail) {
        if (isset($xml->pop3mail->item) && $xml->pop3mail->item) {
            return true;
        }
    }
    return false;
}
示例#7
0
/**
 * Encodes an ISO-8859-1 string or array to UTF-8.
 *
 * @param mixed $data String or array to convert.
 * @return mixed Encoded data.
 */
function encode_utf8($data)
{
    if ($data === null || $data === '') {
        return $data;
    }
    if (is_array($data)) {
        foreach ($data as $strKey => $mixVal) {
            $data[$strKey] = encode_utf8($mixVal);
        }
        return $data;
    } else {
        if (!mb_check_encoding($data, 'UTF-8')) {
            return mb_convert_encoding($data, 'UTF-8');
        } else {
            return $data;
        }
    }
}
示例#8
0
function getDomainInfo($domain)
{
    global $domain_config_file;
    global $xml_database_comname;
    $filename = encode_utf8($domain_config_file);
    /*
    $xml = new COM($xml_database_comname, NULL, CP_UTF8) or die ("create com instance error");
    $xml->ReadDB($filename);
    $xml->ResetPos();
    
    $xml->FindElem("database");
    $xml->IntoElem();
    
    if ($xml->FindElem("domain")){
    	$xml->IntoElem();
    
    	while($xml->FindElem("item")) {
    		$strDomain = "";
    		$iDomainType = 0;
    		 
    		$xml->ResetChildPos();	
    		while($xml->FindChildElem("")) {
    			$strTagName = strtolower($xml->GetChildTagName());
    			$strTagValue = $xml->GetChildData();
    			
    			switch($strTagName){
    				case "domain":
    					$strDomain = $strTagValue;
    					break;
    				case "type":
    					$iDomainType = intval($strTagValue);
    					break;
    			}
    		}
    		
    		if (strcasecmp($strDomain, $domain) == 0
    			|| (empty($domain) && $iDomainType == 1)){
    			$domainInfo = array();
    			
    			$xml->ResetChildPos();	
    			while($xml->FindChildElem("")) {
    				$strTagName = strtolower($xml->GetChildTagName());
    				$strTagValue = $xml->GetChildData();
    				
    				$domainInfo[$strTagName] = $strTagValue;
    				
    			}
    			
    			return $domainInfo;
    		}
    	}
    }
    */
    $xml = simplexml_load_file($filename);
    foreach ($xml->domain->item as $item) {
        $strDomain = "";
        $iDomainType = 0;
        foreach ($item as $key => $value) {
            $key = (string) $key;
            $value = (string) $value;
            switch ($key) {
                case "domain":
                    $strDomain = $value;
                    break;
                case "type":
                    $iDomainType = intval($value);
                    break;
            }
        }
        if (strcasecmp($strDomain, $domain) == 0 || empty($domain) && $iDomainType == 1) {
            $domainInfo = array();
            foreach ($item as $key => $value) {
                $key = strtolower((string) $key);
                $value = (string) $value;
                $domainInfo[$key] = $value;
            }
            return $domainInfo;
        }
    }
    return false;
}