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


PHP idna_convert::set_parameter方法代码示例

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


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

示例1: checkValue_input_Eval

 /**
  * Evaluation of 'input'-type values based on 'eval' list
  *
  * @param string $value Value to evaluate
  * @param array $evalArray Array of evaluations to traverse.
  * @param string $is_in Is-in string for 'is_in' evaluation
  * @return array Modified $value in key 'value' or empty array
  * @todo Define visibility
  */
 public function checkValue_input_Eval($value, $evalArray, $is_in)
 {
     $res = array();
     $newValue = $value;
     $set = TRUE;
     foreach ($evalArray as $func) {
         switch ($func) {
             case 'int':
             case 'year':
             case 'time':
             case 'timesec':
                 $value = intval($value);
                 break;
             case 'date':
             case 'datetime':
                 $value = intval($value);
                 if ($value > 0 && !$this->dontProcessTransformations) {
                     $value -= date('Z', $value);
                 }
                 break;
             case 'double2':
                 $value = preg_replace('/[^0-9,\\.-]/', '', $value);
                 $negative = substr($value, 0, 1) == '-';
                 $value = strtr($value, array(',' => '.', '-' => ''));
                 if (strpos($value, '.') === FALSE) {
                     $value .= '.0';
                 }
                 $valueArray = explode('.', $value);
                 $dec = array_pop($valueArray);
                 $value = join('', $valueArray) . '.' . $dec;
                 if ($negative) {
                     $value *= -1;
                 }
                 $value = number_format($value, 2, '.', '');
                 break;
             case 'md5':
                 if (strlen($value) != 32) {
                     $set = FALSE;
                 }
                 break;
             case 'trim':
                 $value = trim($value);
                 break;
             case 'upper':
                 $value = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $value, 'toUpper');
                 break;
             case 'lower':
                 $value = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $value, 'toLower');
                 break;
             case 'required':
                 if (!isset($value) || $value === '') {
                     $set = FALSE;
                 }
                 break;
             case 'is_in':
                 $c = strlen($value);
                 if ($c) {
                     $newVal = '';
                     for ($a = 0; $a < $c; $a++) {
                         $char = substr($value, $a, 1);
                         if (strpos($is_in, $char) !== FALSE) {
                             $newVal .= $char;
                         }
                     }
                     $value = $newVal;
                 }
                 break;
             case 'nospace':
                 $value = str_replace(' ', '', $value);
                 break;
             case 'alpha':
                 $value = preg_replace('/[^a-zA-Z]/', '', $value);
                 break;
             case 'num':
                 $value = preg_replace('/[^0-9]/', '', $value);
                 break;
             case 'alphanum':
                 $value = preg_replace('/[^a-zA-Z0-9]/', '', $value);
                 break;
             case 'alphanum_x':
                 $value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value);
                 break;
             case 'domainname':
                 if (!preg_match('/^[a-z0-9\\.\\-]*$/i', $value)) {
                     \TYPO3\CMS\Core\Utility\GeneralUtility::requireOnce(PATH_typo3 . 'contrib/idna/idna_convert.class.php');
                     $idnaConvert = new \idna_convert();
                     $idnaConvert->set_parameter('idn_version', '2008');
                     $value = $idnaConvert->encode($value);
                     unset($idnaConvert);
                 }
                 break;
//.........这里部分代码省略.........
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:101,代码来源:DataHandler.php

示例2:

     }
 }
 //$forum_page['user_contact']['forum-mail'] = '<li><span>'.$lang_profile['Escrow'].': <a href="'.forum_link($forum_url['escrow'], $id).'">'.$lang_profile['Start new escrow'].'</a></span></li>';
 /*
 //else if ($forum_user['id'] == $id || ($forum_user['is_admmod'] && $user['email_setting'] == '2'))
 //	$forum_page['user_private']['forum-mail'] = '<li><span>'.$lang_profile['E-mail'].': <a href="'.forum_link($forum_url['email'], $id).'">'.$lang_profile['Send forum e-mail'].'</a></span></li>';
 */
 // Website
 if ($user['url'] != '') {
     $url_source = $user['url'];
     // IDNA url handling
     if (defined('FORUM_SUPPORT_PCRE_UNICODE') && defined('FORUM_ENABLE_IDNA')) {
         // Load the IDNA class for international url handling
         require_once FORUM_ROOT . 'include/idna/idna_convert.class.php';
         $idn = new idna_convert();
         $idn->set_parameter('encoding', 'utf8');
         $idn->set_parameter('strict', false);
         if (preg_match('!^(https?|ftp|news){1}' . preg_quote('://xn--', '!') . '!', $url_source)) {
             $user['url'] = $idn->decode($url_source);
         } else {
             $url_source = $idn->encode($url_source);
         }
     }
     if ($forum_config['o_censoring'] == '1') {
         $user['url'] = censor_words($user['url']);
     }
     $url_source = forum_htmlencode($url_source);
     $user['url'] = forum_htmlencode($user['url']);
     $forum_page['url'] = '<a href="' . $url_source . '" class="external url" rel="me">' . $user['url'] . '</a>';
     $forum_page['user_contact']['website'] = '<li><span>' . $lang_profile['Website'] . ': ' . $forum_page['url'] . '</span></li>';
 }
开发者ID:torepublicStartpageCode,项目名称:torepublic2,代码行数:31,代码来源:profile.php

示例3: handle_url_tag

function handle_url_tag($url, $link = '', $bbcode = false)
{
    $return = ($hook = get_hook('ps_handle_url_tag_start')) ? eval($hook) : null;
    if ($return != null) {
        return $return;
    }
    $full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url);
    if (strpos($url, 'www.') === 0) {
        // If it starts with www, we add http://
        $full_url = 'http://' . $full_url;
    } else {
        if (strpos($url, 'ftp.') === 0) {
            // Else if it starts with ftp, we add ftp://
            $full_url = 'ftp://' . $full_url;
        } else {
            if (!preg_match('#^([a-z0-9]{3,6})://#', $url)) {
                // Else if it doesn't start with abcdef://, we add http://
                $full_url = 'http://' . $full_url;
            }
        }
    }
    if (defined('FORUM_SUPPORT_PCRE_UNICODE') && defined('FORUM_ENABLE_IDNA')) {
        static $idn;
        static $cached_encoded_urls = null;
        if (is_null($cached_encoded_urls)) {
            $cached_encoded_urls = array();
        }
        // Check in cache
        $cache_key = md5($full_url);
        if (isset($cached_encoded_urls[$cache_key])) {
            $full_url = $cached_encoded_urls[$cache_key];
        } else {
            if (!isset($idn)) {
                $idn = new idna_convert();
                $idn->set_parameter('encoding', 'utf8');
                $idn->set_parameter('strict', false);
            }
            $full_url = $idn->encode($full_url);
            $cached_encoded_urls[$cache_key] = $full_url;
        }
    }
    // Ok, not very pretty :-)
    if (!$bbcode) {
        if (defined('FORUM_SUPPORT_PCRE_UNICODE') && defined('FORUM_ENABLE_IDNA')) {
            $link_name = $link == '' || $link == $url ? $url : $link;
            if (preg_match('!^(https?|ftp|news){1}' . preg_quote('://xn--', '!') . '!', $link_name)) {
                $link = $idn->decode($link_name);
            }
        }
        $link = $link == '' || $link == $url ? utf8_strlen($url) > 55 ? utf8_substr($url, 0, 39) . ' … ' . utf8_substr($url, -10) : $url : stripslashes($link);
    }
    $return = ($hook = get_hook('ps_handle_url_tag_end')) ? eval($hook) : null;
    if ($return != null) {
        return $return;
    }
    if ($bbcode) {
        if (defined('FORUM_SUPPORT_PCRE_UNICODE') && defined('FORUM_ENABLE_IDNA')) {
            if (preg_match('!^(https?|ftp|news){1}' . preg_quote('://xn--', '!') . '!', $link)) {
                $link = $idn->decode($link);
            }
        }
        if ($full_url == $link) {
            return '[url]' . $link . '[/url]';
        } else {
            return '[url=' . $full_url . ']' . $link . '[/url]';
        }
    } else {
        return '<a href="' . $full_url . '">' . $link . '</a>';
    }
}
开发者ID:ZerGabriel,项目名称:punbb,代码行数:70,代码来源:parser.php


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