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


PHP Net_IDNA2::decode方法代码示例

本文整理汇总了PHP中Net_IDNA2::decode方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_IDNA2::decode方法的具体用法?PHP Net_IDNA2::decode怎么用?PHP Net_IDNA2::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_IDNA2的用法示例。


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

示例1: decode

 /**
  * Decodes punycoded'd URL
  * @param  string $url URL
  * @return mixed  string with decoded URL on success, boolean false otherwise
  */
 public static function decode($url)
 {
     $url = self::fix($url);
     if ($url) {
         $components = parse_url($url);
         $host = $components['host'];
         if (strpos($host, self::PUNYCODE_PREFIX) !== false) {
             $idn = new \Net_IDNA2();
             $host = $idn->decode($host);
         }
         $path = !empty($components['path']) ? $components['path'] : '';
         return $host . rtrim($path, '/');
     }
     return false;
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:20,代码来源:Url.php

示例2: catch

 function idn_to_utf8($domain)
 {
     static $idn, $loaded;
     if (!$loaded) {
         $idn = new Net_IDNA2();
         $loaded = true;
     }
     if ($idn && $domain && preg_match('/(^|\\.)xn--/i', $domain)) {
         try {
             $domain = $idn->decode($domain);
         } catch (Exception $e) {
         }
     }
     return $domain;
 }
开发者ID:NathanAUS,项目名称:roundcubemail,代码行数:15,代码来源:bootstrap.php

示例3: decodeIDN

 /**
  * Converts given punycode to the IDN.
  * @param string $value punycode to be converted.
  * @return string resulting IDN.
  * @since 1.1.13
  */
 private function decodeIDN($value)
 {
     if (preg_match_all('/^(.*):\\/\\/([^\\/]+)(.*)$/', $value, $matches)) {
         if (function_exists('idn_to_utf8')) {
             $value = $matches[1][0] . '://' . idn_to_utf8($matches[2][0]) . $matches[3][0];
         } else {
             require_once Yii::getPathOfAlias('system.vendors.Net_IDNA2.Net') . DIRECTORY_SEPARATOR . 'IDNA2.php';
             $idna = new Net_IDNA2();
             $value = $matches[1][0] . '://' . @$idna->decode($matches[2][0]) . $matches[3][0];
         }
     }
     return $value;
 }
开发者ID:azizbekvahidov,项目名称:foods,代码行数:19,代码来源:CUrlValidator.php

示例4: decodePunycode

 /**
  * Retrieve decoding domain name from punycode
  *
  * @param string $url decode url from Punycode
  * @return string
  */
 public function decodePunycode($url)
 {
     $parsedUrl = parse_url($url);
     if ($this->_isPunycode($parsedUrl['host'])) {
         if (function_exists('idn_to_utf8')) {
             $host = idn_to_utf8($parsedUrl['host']);
         } else {
             $idn = new Net_IDNA2();
             $host = $idn->decode($parsedUrl['host']);
         }
         return str_replace($parsedUrl['host'], $host, $url);
     } else {
         return $url;
     }
 }
开发者ID:tesorogithub,项目名称:tesoroshop,代码行数:21,代码来源:__default.php

示例5: decode_host

/**
 * Decodes from punycode
 * @param string $host ONLY the host name, e.g. "XN----7SBCPNF2DL2EYA.XN--P1AI"
 * @return string
 */
function decode_host($host)
{
    if (stripos($host, "xn--") === false) {
        return $host;
    }
    require_once 'Net/IDNA2.php';
    // netcat/require/lib
    $decoder = new Net_IDNA2();
    try {
        $host = $decoder->decode(strtolower($host));
    } catch (Net_IDNA2_Exception $e) {
        trigger_error("Cannot convert host name '{$host}' from punycode: {$e->getMessage()}", E_USER_WARNING);
        return $host;
    }
    return $host;
}
开发者ID:Blu2z,项目名称:implsk,代码行数:21,代码来源:s_common.inc.php

示例6: decode_idna

/**
 * Decodes a String from IDNA format to UTF8
 *
 * @param  $input
 * @return string
 */
function decode_idna($input)
{
    if (function_exists('idn_to_utf8')) {
        // return idn_to_utf8($input, IDNA_USE_STD3_RULES);
        return idn_to_utf8($input);
    } else {
        $IDNA = new Net_IDNA2();
        $output = $IDNA->decode($input);
        return $output == false ? $input : $output;
    }
}
开发者ID:gOOvER,项目名称:EasySCP,代码行数:17,代码来源:easyscp-functions.php

示例7: decode

 /**
  * Decodes punycoded'd URL
  *
  * @param string $url URL
  *
  * @return mixed string with decoded URL on success, boolean false otherwise
  */
 public static function decode($url)
 {
     $url = self::fix($url);
     if ($url) {
         $components = parse_url($url);
         $host = $components['host'] . (empty($components['port']) ? '' : ':' . $components['port']);
         if (self::isPunycoded($host)) {
             try {
                 $idn = new \Net_IDNA2();
                 $host = $idn->decode($host);
             } catch (\InvalidArgumentException $e) {
             }
         }
         $path = !empty($components['path']) ? $components['path'] : '';
         return $host . rtrim($path, '/');
     }
     return false;
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:25,代码来源:Url.php

示例8: decodeIDN

 /**
  * Converts given punycode to the IDN.
  *
  * @param string $value punycode to be converted.
  *
  * @return string resulting IDN.
  * @since 1.1.13
  */
 private function decodeIDN($value)
 {
     if (preg_match_all('/^(.*):\\/\\/([^\\/]+)(.*)$/', $value, $matches)) {
         if (function_exists('idn_to_utf8')) {
             $value = $matches[1][0] . '://' . idn_to_utf8($matches[2][0]) . $matches[3][0];
         } else {
             require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Net_IDNA2' . DIRECTORY_SEPARATOR . 'IDNA2.php';
             $idna = new Net_IDNA2();
             $value = $matches[1][0] . '://' . @$idna->decode($matches[2][0]) . $matches[3][0];
         }
     }
     return $value;
 }
开发者ID:astar3086,项目名称:studio_logistic,代码行数:21,代码来源:UrlValidator.php


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