当前位置: 首页>>代码示例>>PHP>>正文


PHP idn_to_utf8函数代码示例

本文整理汇总了PHP中idn_to_utf8函数的典型用法代码示例。如果您正苦于以下问题:PHP idn_to_utf8函数的具体用法?PHP idn_to_utf8怎么用?PHP idn_to_utf8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了idn_to_utf8函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: decode

 /**
  * Decode a Punycode domain name to its Unicode counterpart
  *
  * @param string $input Domain name in Punycode
  *
  * @return string Unicode domain name
  */
 public function decode($input)
 {
     if ($this->idnSupport === true) {
         return idn_to_utf8($input);
     }
     return self::$punycode->decode($input);
 }
开发者ID:voku,项目名称:php-domain-parser,代码行数:14,代码来源:PunycodeWrapper.php

示例2: getIdn

 /**
  * Get internationalized domain name
  *
  * @return null|false|string
  */
 public function getIdn()
 {
     if (empty($this->domain)) {
         return null;
     }
     return @idn_to_utf8($this->domain);
 }
开发者ID:gridguyz,项目名称:multisite,代码行数:12,代码来源:Structure.php

示例3: isValidDomain

 /**
  * Return true if a domain is a valid domain.
  * @link https://url.spec.whatwg.org/#valid-domain URL Standard
  * @param string $domain A UTF-8 string.
  * @return boolean
  */
 public static function isValidDomain($domain)
 {
     $valid = mb_strlen($domain, 'UTF-8') <= self::PHP_IDN_HANDLEABLE_LENGTH;
     if ($valid) {
         $result = idn_to_ascii($domain, IDNA_USE_STD3_RULES | IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
         if (!is_string($result)) {
             $valid = false;
         }
     }
     if ($valid) {
         $domainNameLength = strlen($result);
         if ($domainNameLength < 1 || $domainNameLength > 253) {
             $valid = false;
         }
     }
     if ($valid) {
         foreach (explode('.', $result) as $label) {
             $labelLength = strlen($label);
             if ($labelLength < 1 || $labelLength > 63) {
                 $valid = false;
                 break;
             }
         }
     }
     if ($valid) {
         $result = idn_to_utf8($result, IDNA_USE_STD3_RULES, INTL_IDNA_VARIANT_UTS46, $idna_info);
         if ($idna_info['errors'] !== 0) {
             $valid = false;
         }
     }
     return $valid;
 }
开发者ID:esperecyan,项目名称:url,代码行数:38,代码来源:HostProcessing.php

示例4: filter

 public function filter(string $host) : string
 {
     $host = $this->validateHost($host);
     if ($this->isIdn) {
         $host = idn_to_utf8($host);
     }
     return $this->lower($host);
 }
开发者ID:narrowspark,项目名称:framework,代码行数:8,代码来源:Host.php

示例5: create_identity

 public function create_identity($p)
 {
     $rcmail = rcmail::get_instance();
     // prefs are set in create_user()
     if ($this->prefs) {
         if ($this->prefs['full_name']) {
             $p['record']['name'] = $this->prefs['full_name'];
         }
         if (($this->identities_level == 0 || $this->identities_level == 2) && $this->prefs['email_address']) {
             $p['record']['email'] = $this->prefs['email_address'];
         }
         if ($this->prefs['___signature___']) {
             $p['record']['signature'] = $this->prefs['___signature___'];
         }
         if ($this->prefs['reply_to']) {
             $p['record']['reply-to'] = $this->prefs['reply_to'];
         }
         if (($this->identities_level == 0 || $this->identities_level == 1) && isset($this->prefs['identities']) && $this->prefs['identities'] > 1) {
             for ($i = 1; $i < $this->prefs['identities']; $i++) {
                 unset($ident_data);
                 $ident_data = array('name' => '', 'email' => '');
                 // required data
                 if ($this->prefs['full_name' . $i]) {
                     $ident_data['name'] = $this->prefs['full_name' . $i];
                 }
                 if ($this->identities_level == 0 && $this->prefs['email_address' . $i]) {
                     $ident_data['email'] = $this->prefs['email_address' . $i];
                 } else {
                     $ident_data['email'] = $p['record']['email'];
                 }
                 if ($this->prefs['reply_to' . $i]) {
                     $ident_data['reply-to'] = $this->prefs['reply_to' . $i];
                 }
                 if ($this->prefs['___sig' . $i . '___']) {
                     $ident_data['signature'] = $this->prefs['___sig' . $i . '___'];
                 }
                 // insert identity
                 $identid = $rcmail->user->insert_identity($ident_data);
             }
         }
         // copy address book
         $contacts = $rcmail->get_address_book(null, true);
         if ($contacts && count($this->abook)) {
             foreach ($this->abook as $rec) {
                 // #1487096 handle multi-address and/or too long items
                 $rec['email'] = array_shift(explode(';', $rec['email']));
                 if (check_email(idn_to_ascii($rec['email']))) {
                     $rec['email'] = idn_to_utf8($rec['email']);
                     $contacts->insert($rec, true);
                 }
             }
         }
         // mark identity as complete for following hooks
         $p['complete'] = true;
     }
     return $p;
 }
开发者ID:shishenkov,项目名称:zpanel,代码行数:57,代码来源:squirrelmail_usercopy.php

示例6: findBy

 /**
  * @param array|null $options
  * @return Domain[]
  */
 public function findBy(array $options = null)
 {
     $domainObjects = [];
     $domainsList = $this->api->getList($options);
     foreach ($domainsList as $domainName) {
         $domain = idn_to_utf8($domainName->getFqdn());
         $domainObjects[] = $this->factory->build($domain);
     }
     return $domainObjects;
 }
开发者ID:EDSI-Tech,项目名称:GandiBundle,代码行数:14,代码来源:DomainRepository.php

示例7: checkDomain

 /**
  * Check email's domain
  *
  * @param $value
  *
  * @return bool
  */
 public static function checkDomain($value)
 {
     static $regexData = ['pattern' => '/^(?:[0-9a-zA-Z](?:[\\-\\+\\_]*[0-9a-zA-Z])*\\.)+[0-9a-zA-Z](?:[\\-\\+\\_]*[0-9a-zA-Z])*$/u'];
     $explodedEmail = explode('@', $value);
     if (!isset($explodedEmail[1])) {
         return false;
     }
     $preparedDomain = idn_to_utf8($explodedEmail[1]);
     return stringValidator::byRegex($preparedDomain, $regexData);
 }
开发者ID:mpcmf,项目名称:mpcmf-core,代码行数:17,代码来源:emailValidator.php

示例8: convertIdnToUtf8Format

 /**
  * Convert idn to utf8 format
  * 
  * @param string $name
  * 
  * @return string
  */
 public static function convertIdnToUtf8Format($name)
 {
     if (empty($name)) {
         return;
     }
     if (!function_exists('idn_to_utf8')) {
         \DBG::msg('Idn is not supported in this system.');
     } else {
         $name = idn_to_utf8($name);
     }
     return $name;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:19,代码来源:ComponentController.class.php

示例9: __set

 /**
  */
 public function __set($name, $value)
 {
     switch ($name) {
         case 'host':
             $value = ltrim($value, '@');
             $this->_host = function_exists('idn_to_utf8') ? strtolower(idn_to_utf8($value)) : strtolower($value);
             break;
         case 'personal':
             $this->_personal = strlen($value) ? Horde_Mime::decode($value) : null;
             break;
     }
 }
开发者ID:netcon-source,项目名称:apps,代码行数:14,代码来源:Address.php

示例10: test_invalidTld

 public function test_invalidTld()
 {
     $tlds = [strval(bin2hex(openssl_random_pseudo_bytes(64))), '-tld-cannot-start-from-hypen', 'ąęśćżźł-there-is-no-such-idn', 'xn--fd67as67fdsa', '!@#-inavlid-chars-in-tld', 'no spaces in tld allowed', 'no--double--hypens--allowed'];
     if (count($tlds) === 0) {
         $this->markTestSkipped("Couldn't get TLD list");
     }
     foreach ($tlds as $key => $tld) {
         if (strpos(mb_strtolower($tld), 'xn--') !== 0) {
             $tld = mb_strtolower($tld);
         }
         $this->assertFalse($this->isValid('test@example.' . idn_to_utf8($tld)));
     }
 }
开发者ID:andrzejewsky,项目名称:piwik,代码行数:13,代码来源:EmailValidatorTest.php

示例11: listIPDomains

/**
 * Generate List of Domains assigned to IPs
 *
 * @param  iMSCP_pTemplate $tpl Template engine
 * @return void
 */
function listIPDomains($tpl)
{
    $resellerId = $_SESSION['user_id'];
    $stmt = exec_query('SELECT reseller_ips FROM reseller_props WHERE reseller_id = ?', $resellerId);
    $data = $stmt->fetchRow();
    $resellerIps = explode(';', substr($data['reseller_ips'], 0, -1));
    $stmt = execute_query('SELECT ip_id, ip_number FROM server_ips WHERE ip_id IN (' . implode(',', $resellerIps) . ')');
    while ($ip = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
        $stmt2 = exec_query('
				SELECT
					domain_name
				FROM
					domain
				INNER JOIN
					admin ON(admin_id = domain_admin_id)
				WHERE
					domain_ip_id = :ip_id
				AND
					created_by = :reseller_id
				UNION
				SELECT
					alias_name AS domain_name
				FROM
					domain_aliasses
				INNER JOIN
					domain USING(domain_id)
				INNER JOIN
					admin ON(admin_id = domain_admin_id)
				WHERE
					alias_ip_id = :ip_id
				AND
					created_by = :reseller_id
			', array('ip_id' => $ip['ip_id'], 'reseller_id' => $resellerId));
        $domainsCount = $stmt2->rowCount();
        $tpl->assign(array('IP' => tohtml($ip['ip_number']), 'RECORD_COUNT' => tr('Total Domains') . ': ' . $domainsCount));
        if ($domainsCount) {
            while ($data = $stmt2->fetchRow(PDO::FETCH_ASSOC)) {
                $tpl->assign('DOMAIN_NAME', tohtml(idn_to_utf8($data['domain_name'])));
                $tpl->parse('DOMAIN_ROW', '.domain_row');
            }
        } else {
            $tpl->assign('DOMAIN_NAME', tr('No used yet'));
            $tpl->parse('DOMAIN_ROW', 'domain_row');
        }
        $tpl->parse('IP_ROW', '.ip_row');
        $tpl->assign('DOMAIN_ROW', '');
    }
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:54,代码来源:ip_usage.php

示例12: validateStringHost

 /**
  * Validate a string only host
  *
  * @param string $str
  *
  * @return array
  */
 protected function validateStringHost($str)
 {
     if (empty($str)) {
         return [];
     }
     $host = $this->lower($this->setIsAbsolute($str));
     $raw_labels = explode('.', $host);
     $labels = array_map(function ($value) {
         return idn_to_ascii($value);
     }, $raw_labels);
     $this->assertValidHost($labels);
     $this->isIdn = $raw_labels !== $labels;
     return array_reverse(array_map(function ($label) {
         return idn_to_utf8($label);
     }, $labels));
 }
开发者ID:Zeichen32,项目名称:uri,代码行数:23,代码来源:HostnameTrait.php

示例13: setPattern

 public function setPattern($arr, $page)
 {
     list(, $alias, $toname, $host) = $this->splice($arr);
     $name = $orginalname = $toname . $host;
     if (extension_loaded('intl')) {
         // 国際化ドメイン対応
         if (preg_match('/[^A-Za-z0-9.-]/', $host)) {
             $name = $toname . idn_to_ascii($host);
         } else {
             if (!$alias && strtolower(substr($host, 0, 4)) === 'xn--') {
                 $orginalname = $toname . idn_to_utf8($host);
             }
         }
     }
     return parent::setParam($page, $name, '', 'mailto', $alias === '' ? $orginalname : $alias);
 }
开发者ID:logue,项目名称:pukiwiki_adv,代码行数:16,代码来源:Mailto.php

示例14: convert_idn_domain

/**
 * @return string
 */
function convert_idn_domain($domain)
{
    // Get domain length
    $domain_length = strlen($domain);
    // Perform two idn operations, convert to ascii and convert to utf8
    $idn_ascii_domain = idn_to_ascii($domain);
    // IDN utf8 domain detected, return converted domain.
    if ($domain_length != strlen($idn_ascii_domain)) {
        return $idn_ascii_domain;
    }
    $idn_utf8_domain = idn_to_utf8($domain);
    // IDN ascii domain detected, return converted domain.
    if ($domain_length != strlen($idn_utf8_domain)) {
        return $idn_utf8_domain;
    }
    return $domain;
}
开发者ID:sjparkinson,项目名称:isitup.org,代码行数:20,代码来源:functions.php

示例15: init

 function init()
 {
     if (!empty(App::$primary->config['site']['domain'])) {
         $domain = App::$primary->config['site']['domain'];
     } else {
         $domain = implode('.', array_slice(explode('.', idn_to_utf8(INJI_DOMAIN_NAME)), -2));
     }
     $alias = str_replace($domain, '', idn_to_utf8(INJI_DOMAIN_NAME));
     $city = null;
     if ($alias) {
         $alias = str_replace('.', '', $alias);
         $city = Geography\City::get($alias, 'alias');
     }
     if (!$city) {
         $city = Geography\City::get(1, 'default');
     }
     Geography\City::$cur = $city;
 }
开发者ID:krvd,项目名称:cms-Inji,代码行数:18,代码来源:Geography.php


注:本文中的idn_to_utf8函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。