• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP utf8_check函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: entities_to_7bit

function entities_to_7bit($str)
{
    require_once LEPTON_PATH . '/framework/summary.utf8.php';
    // convert to UTF-8
    $str = charset_to_utf8($str);
    if (!utf8_check($str)) {
        return $str;
    }
    // replace some specials
    $str = utf8_stripspecials($str, '_');
    // translate non-ASCII characters to ASCII
    $str = utf8_romanize($str);
    // missed some? - Many UTF-8-chars can't be romanized
    // convert to HTML-entities, and replace entites by hex-numbers
    $str = utf8_fast_umlauts_to_entities($str, false);
    $str = str_replace(''', ''', $str);
    //    $str = preg_replace_callback('/&#([0-9]+);/', function($matches) {return "dechex($matches[1])";}, $str);
    //    $str = preg_replace_callback('/&#([0-9]+);/', function($matches) {return dechex($matches[1]);}, $str);
    if (version_compare(PHP_VERSION, '5.3', '<')) {
        $str = preg_replace('/&#([0-9]+);/e', "dechex('\$1')", $str);
    } else {
        $str = preg_replace_callback('/&#([0-9]+);/', create_function('$aMatches', 'return dechex($aMatches[1]);'), $str);
    }
    // maybe there are some &gt; &lt; &apos; &quot; &amp; &nbsp; left, replace them too
    $str = str_replace(array('&gt;', '&lt;', '&apos;', '\'', '&quot;', '&amp;'), '', $str);
    $str = str_replace('&amp;', '', $str);
    return $str;
}
开发者ID:pixelhulk,项目名称:LEPTON,代码行数:28,代码来源:function.entities_to_7bit.php


示例2: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     global $INPUT;
     parent::__construct();
     // ldap extension is needed
     if (!function_exists('ldap_connect')) {
         $this->_debug("LDAP err: PHP LDAP extension not found.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     // Prepare SSO
     if (!empty($_SERVER['REMOTE_USER'])) {
         // make sure the right encoding is used
         if ($this->getConf('sso_charset')) {
             $_SERVER['REMOTE_USER'] = iconv($this->getConf('sso_charset'), 'UTF-8', $_SERVER['REMOTE_USER']);
         } elseif (!utf8_check($_SERVER['REMOTE_USER'])) {
             $_SERVER['REMOTE_USER'] = utf8_encode($_SERVER['REMOTE_USER']);
         }
         // trust the incoming user
         if ($this->conf['sso']) {
             $_SERVER['REMOTE_USER'] = $this->cleanUser($_SERVER['REMOTE_USER']);
             // we need to simulate a login
             if (empty($_COOKIE[DOKU_COOKIE])) {
                 $INPUT->set('u', $_SERVER['REMOTE_USER']);
                 $INPUT->set('p', 'sso_only');
             }
         }
     }
     // Add the capabilities to change the password
     $this->cando['modPass'] = $this->getConf('modPass');
 }
开发者ID:numas,项目名称:dokuwiki,代码行数:34,代码来源:auth.php


示例3: __construct

 /**
  * Constructor
  */
 function __construct()
 {
     global $conf;
     $this->cnf = $conf['auth']['ad'];
     // additional information fields
     if (isset($this->cnf['additional'])) {
         $this->cnf['additional'] = str_replace(' ', '', $this->cnf['additional']);
         $this->cnf['additional'] = explode(',', $this->cnf['additional']);
     } else {
         $this->cnf['additional'] = array();
     }
     // ldap extension is needed
     if (!function_exists('ldap_connect')) {
         if ($this->cnf['debug']) {
             msg("AD Auth: PHP LDAP extension not found.", -1);
         }
         $this->success = false;
         return;
     }
     // Prepare SSO
     if (!utf8_check($_SERVER['REMOTE_USER'])) {
         $_SERVER['REMOTE_USER'] = utf8_encode($_SERVER['REMOTE_USER']);
     }
     if ($_SERVER['REMOTE_USER'] && $this->cnf['sso']) {
         // remove possible NTLM domain
         list($dom, $usr) = explode('\\', $_SERVER['REMOTE_USER'], 2);
         if (!$usr) {
             $usr = $dom;
         }
         // remove possible Kerberos domain
         list($usr, $dom) = explode('@', $usr);
         $dom = strtolower($dom);
         $_SERVER['REMOTE_USER'] = $usr;
         // we need to simulate a login
         if (empty($_COOKIE[DOKU_COOKIE])) {
             $_REQUEST['u'] = $_SERVER['REMOTE_USER'];
             $_REQUEST['p'] = 'sso_only';
         }
     }
     // prepare adLDAP standard configuration
     $this->opts = $this->cnf;
     // add possible domain specific configuration
     if ($dom && is_array($this->cnf[$dom])) {
         foreach ($this->cnf[$dom] as $key => $val) {
             $this->opts[$key] = $val;
         }
     }
     // handle multiple AD servers
     $this->opts['domain_controllers'] = explode(',', $this->opts['domain_controllers']);
     $this->opts['domain_controllers'] = array_map('trim', $this->opts['domain_controllers']);
     $this->opts['domain_controllers'] = array_filter($this->opts['domain_controllers']);
     // we can change the password if SSL is set
     if ($this->opts['use_ssl'] || $this->opts['use_tls']) {
         $this->cando['modPass'] = true;
     }
     $this->cando['modName'] = true;
     $this->cando['modMail'] = true;
 }
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:61,代码来源:ad.class.php


示例4: dol_print_file

/**
 *  Output content of a file $filename in version of current language (otherwise may use an alternate language)
 *  @param      langs           Object language to use for output
 *  @param      filename        Relative filename to output
 *  @param      searchalt       1=Search also in alternative languages
 *	@return		boolean
 */
function dol_print_file($langs,$filename,$searchalt=0)
{
    global $conf;

    // Test if file is in lang directory
    foreach($langs->dir as $searchdir)
    {
        $htmlfile=($searchdir."/langs/".$langs->defaultlang."/".$filename);
        dol_syslog('functions2::dol_print_file search file '.$htmlfile, LOG_DEBUG);
        if (is_readable($htmlfile))
        {
            $content=file_get_contents($htmlfile);
            $isutf8=utf8_check($content);
            if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content);
            elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content);
            else print $content;
            return true;
        }
        else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);

        if ($searchalt) {
            // Test si fichier dans repertoire de la langue alternative
            if ($langs->defaultlang != "en_US") $htmlfilealt = $searchdir."/langs/en_US/".$filename;
            else $htmlfilealt = $searchdir."/langs/fr_FR/".$filename;
            dol_syslog('functions2::dol_print_file search alt file '.$htmlfilealt, LOG_DEBUG);
            //print 'getcwd='.getcwd().' htmlfilealt='.$htmlfilealt.' X '.file_exists(getcwd().'/'.$htmlfilealt);
            if (is_readable($htmlfilealt))
            {
                $content=file_get_contents($htmlfilealt);
                $isutf8=utf8_check($content);
                if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content);
                elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content);
                else print $content;
                return true;
            }
            else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);
        }
    }

    return false;
}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:48,代码来源:functions2.lib.php


示例5: processTagUrl

 public function processTagUrl(array $tag, array $rendererStates)
 {
     if (!empty($tag['option'])) {
         $url = $tag['option'];
         $text = $this->renderSubTree($tag['children'], $rendererStates);
     } else {
         $url = $this->stringifyTree($tag['children']);
         $text = urldecode($url);
         if (!utf8_check($text)) {
             $text = $url;
         }
     }
     $validUrl = $this->_getValidUrl($url);
     if (!empty($validUrl)) {
         $this->_urls[$url] = $validUrl;
     }
     if (!empty($tag['option'])) {
         return "[URL={$this->_urlPrefix}{$url}{$this->_urlSuffix}]{$text}[/URL]";
     } else {
         return "[URL]{$this->_urlPrefix}{$url}{$this->_urlSuffix}[/URL]";
     }
 }
开发者ID:ThemeHouse-XF,项目名称:ImageRestrict,代码行数:22,代码来源:Reverse.php


示例6: sanitize

 /**
  * Sanitize a variable.
  * 
  * @param string $input
  * @param string $type
  * @return string|false
  */
 public static function sanitize($input, $type)
 {
     switch ($type) {
         // Escape HTML special characters.
         case 'escape':
             if (!utf8_check($input)) {
                 return false;
             }
             return escape($input);
             // Strip all HTML tags.
         // Strip all HTML tags.
         case 'strip':
             if (!utf8_check($input)) {
                 return false;
             }
             return escape(strip_tags($input));
             // Clean up HTML content to prevent XSS attacks.
         // Clean up HTML content to prevent XSS attacks.
         case 'html':
             if (!utf8_check($input)) {
                 return false;
             }
             return Filters\HTMLFilter::clean($input);
             // Clean up the input to be used as a safe filename.
         // Clean up the input to be used as a safe filename.
         case 'filename':
             if (!utf8_check($input)) {
                 return false;
             }
             return Filters\FilenameFilter::clean($input);
             // Unknown filters return false.
         // Unknown filters return false.
         default:
             return false;
     }
 }
开发者ID:rhymix,项目名称:rhymix,代码行数:43,代码来源:security.php


示例7: show_elem

/**
 * Function to put the movable box of a source field
 *
 * @param	array	$fieldssource	List of source fields
 * @param	int		$pos			Pos
 * @param	string	$key			Key
 * @param	boolean	$var			Line style (odd or not)
 * @param	int		$nostyle		Hide style
 * @return	void
 */
function show_elem($fieldssource, $pos, $key, $var, $nostyle = '')
{
    global $langs, $bc;
    print "\n\n<!-- Box " . $pos . " start -->\n";
    print '<div class="box" style="padding: 0px 0px 0px 0px;" id="boxto_' . $pos . '">' . "\n";
    print '<table summary="boxtable' . $pos . '" width="100%" class="nobordernopadding">' . "\n";
    if ($pos && $pos > count($fieldssource)) {
        print '<tr ' . ($nostyle ? '' : $bc[$var]) . ' height="20">';
        print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
        print img_picto($pos > 0 ? $langs->trans("MoveField", $pos) : '', 'uparrow', 'class="boxhandle" style="cursor:move;"');
        print '</td>';
        print '<td style="font-weight: normal">';
        print $langs->trans("NoFields");
        print '</td>';
        print '</tr>';
    } elseif ($key == 'none') {
        print '<tr ' . ($nostyle ? '' : $bc[$var]) . ' height="20">';
        print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
        print '&nbsp;';
        print '</td>';
        print '<td style="font-weight: normal">';
        print '&nbsp;';
        print '</td>';
        print '</tr>';
    } else {
        print '<tr ' . ($nostyle ? '' : $bc[$var]) . ' height="20">';
        print '<td class="nocellnopadding" width="16" style="font-weight: normal">';
        // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object
        print img_picto($langs->trans("MoveField", $pos), 'uparrow', 'class="boxhandle" style="cursor:move;"');
        print '</td>';
        print '<td style="font-weight: normal">';
        print $langs->trans("Field") . ' ' . $pos;
        $example = $fieldssource[$pos]['example1'];
        if ($example) {
            if (!utf8_check($example)) {
                $example = utf8_encode($example);
            }
            print ' (<i>' . $example . '</i>)';
        }
        print '</td>';
        print '</tr>';
    }
    print "</table>\n";
    print "</div>\n";
    print "<!-- Box end -->\n\n";
}
开发者ID:nrjacker4,项目名称:crm-php,代码行数:56,代码来源:import.php


示例8: is_photo_available

 function is_photo_available($sdir)
 {
     include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     $pdir = get_exdir($this->id, 2) . $this->id . "/photos/";
     $dir = $sdir . '/' . $pdir;
     $nbphoto = 0;
     $dir_osencoded = dol_osencode($dir);
     if (file_exists($dir_osencoded)) {
         $handle = opendir($dir_osencoded);
         if (is_resource($handle)) {
             while (($file = readdir($handle)) != false) {
                 if (!utf8_check($file)) {
                     $file = utf8_encode($file);
                 }
                 // To be sure data is stored in UTF8 in memory
                 if (dol_is_file($dir . $file)) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:abbenbouchta,项目名称:immobilier,代码行数:23,代码来源:local.class.php


示例9: dol_string_unaccent

/**
 *	Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName
 *
 *	@param	string	$str			String to clean
 *	@return string   	       		Cleaned string
 *
 * 	@see    		dol_sanitizeFilename, dol_string_nospecial
 */
function dol_string_unaccent($str)
{
    if (utf8_check($str)) {
        // See http://www.utf8-chartable.de/
        $string = rawurlencode($str);
        $replacements = array('%C3%80' => 'A', '%C3%81' => 'A', '%C3%82' => 'A', '%C3%83' => 'A', '%C3%84' => 'A', '%C3%85' => 'A', '%C3%88' => 'E', '%C3%89' => 'E', '%C3%8A' => 'E', '%C3%8B' => 'E', '%C3%8C' => 'I', '%C3%8D' => 'I', '%C3%8E' => 'I', '%C3%8F' => 'I', '%C3%92' => 'O', '%C3%93' => 'O', '%C3%94' => 'O', '%C3%95' => 'O', '%C3%96' => 'O', '%C3%99' => 'U', '%C3%9A' => 'U', '%C3%9B' => 'U', '%C3%9C' => 'U', '%C3%A0' => 'a', '%C3%A1' => 'a', '%C3%A2' => 'a', '%C3%A3' => 'a', '%C3%A4' => 'a', '%C3%A5' => 'a', '%C3%A7' => 'c', '%C3%A8' => 'e', '%C3%A9' => 'e', '%C3%AA' => 'e', '%C3%AB' => 'e', '%C3%AC' => 'i', '%C3%AD' => 'i', '%C3%AE' => 'i', '%C3%AF' => 'i', '%C3%B1' => 'n', '%C3%B2' => 'o', '%C3%B3' => 'o', '%C3%B4' => 'o', '%C3%B5' => 'o', '%C3%B6' => 'o', '%C3%B9' => 'u', '%C3%BA' => 'u', '%C3%BB' => 'u', '%C3%BC' => 'u', '%C3%BF' => 'y');
        $string = strtr($string, $replacements);
        return rawurldecode($string);
    } else {
        // See http://www.ascii-code.com/
        $string = strtr($str, "ÀÁÂÃÄÅÇ\n\t\t\tÈÉÊËÌÍÎÏÐÑ\n\t\t\tÒÓÔÕØÙÚÛÝ\n\t\t\tàáâãäåçèéêë\n\t\t\tìíîïðñòóôõø\n\t\t\tùúûüýÿ", "AAAAAAC\n\t\t\tEEEEIIIIDN\n\t\t\tOOOOOUUUY\n\t\t\taaaaaaceeee\n\t\t\tiiiidnooooo\n\t\t\tuuuuyy");
        $string = strtr($string, array("Ä" => "Ae", "Æ" => "AE", "Ö" => "Oe", "Ü" => "Ue", "Þ" => "TH", "ß" => "ss", "ä" => "ae", "æ" => "ae", "ö" => "oe", "ü" => "ue", "þ" => "th"));
        return $string;
    }
}
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:23,代码来源:functions.lib.php


示例10: _getCookie

 /**
  * Returns one random cookie
  *
  * @author Andreas Gohr <[email protected]>
  */
 function _getCookie($cookie)
 {
     $file = mediaFN($cookie);
     if (!@file_exists($file)) {
         return 'ERROR: cookie file not found';
     }
     $dim = filesize($file);
     if ($dim < 2) {
         return "ERROR: invalid cookie file {$file}";
     }
     mt_srand((double) microtime() * 1000000);
     $rnd = mt_rand(0, $dim);
     $fd = fopen($file, 'r');
     if (!$fd) {
         return "ERROR: reading cookie file {$file} failed";
     }
     // jump to random place in file
     fseek($fd, $rnd);
     $text = '';
     $line = '';
     $cookie = false;
     $test = 0;
     while (true) {
         $seek = ftell($fd);
         $line = fgets($fd, 1024);
         if ($seek == 0) {
             // start of file always starts a cookie
             $cookie = true;
             if ($line == "%\n") {
                 // ignore delimiter if exists
                 continue;
             } else {
                 // part of the cookie
                 $text .= htmlspecialchars($line) . '<br />';
                 continue;
             }
         }
         if (feof($fd)) {
             if ($cookie) {
                 // we had a cookie already, stop here
                 break;
             } else {
                 // no cookie yet, wrap around
                 fseek($fd, 0);
                 continue;
             }
         }
         if ($line == "%\n") {
             if ($cookie) {
                 // we had a cookie already, stop here
                 break;
             } elseif ($seek == $dim - 2) {
                 // it's the end of file delimiter, wrap around
                 fseek($fd, 0);
                 continue;
             } else {
                 // start of the cookie
                 $cookie = true;
                 continue;
             }
         }
         // part of the cookie?
         if ($cookie) {
             $text .= htmlspecialchars($line) . '<br />';
         }
     }
     fclose($fd);
     // if it is not valid UTF-8 assume it's latin1
     if (!utf8_check($text)) {
         return utf8_encode($text);
     }
     return $text;
 }
开发者ID:splitbrain,项目名称:dokuwiki-plugin-xfortune,代码行数:78,代码来源:syntax.php


示例11: convert

 /**
  * 进行转换
  *
  * 说明:
  *   - iconv 下会忽略在目标字符集中不存在的字符
  *   - 查表方法使用 UTF-16BE 作为中间编码进行转换
  *   - 非 mbstring 方式由 HTML-ENTITIES(NCR) 转换到非 UTF-8 编码使用 UTF-8 作中间编码
  *   - 转换到 pinyin 使用 GBK 作中间编码
  *
  *
  * @param string $str 要转换的字符串
  * @param string $from 不填写将直接使用属性 from_encoding
  * @param string $to 不填写将直接使用属性 to_encoding
  * @return string 转换后的字符串
  */
 function convert($str, $from = '', $to = '')
 {
     if ($this->set($from, $to) && !empty($str) && $this->from_encoding != $this->to_encoding) {
         if (in_array($this->from_encoding, array('traditional', 'simplified')) || in_array($this->to_encoding, array('traditional', 'simplified'))) {
             if (utf8_check($str)) {
                 if ($this->from_encoding == 'simplified' && $this->to_encoding == 'traditional') {
                     return utf8_traditional_zh($str);
                 } else {
                     if ($this->from_encoding == 'traditional' && $this->to_encoding == 'simplified') {
                         return utf8_simplified_zh($str);
                     }
                 }
             }
             return $str;
         }
         if ($this->to_encoding == 'pinyin') {
             if ($this->from_encoding != 'gbk') {
                 $from_encoding = $this->from_encoding;
                 $str = $this->convert($str, $this->from_encoding, 'gbk');
                 $this->from_encoding = $from_encoding;
                 $this->to_encoding = 'pinyin';
             }
             return $this->gbk2pin($str);
         }
         switch ($this->type) {
             case 'mbstring':
                 return mb_convert_encoding($str, $this->to_encoding, $this->from_encoding);
             case 'iconv':
                 if ($this->to_encoding == 'html-entities') {
                     $str = iconv($this->from_encoding, 'utf-16be', $str);
                     return $this->unicode2htm($str);
                 } else {
                     if ($this->from_encoding != 'html-entities') {
                         return iconv($this->from_encoding, $this->to_encoding . '//IGNORE', $str);
                     }
                 }
             default:
                 if ($this->from_encoding == 'utf-8' && $this->to_encoding == 'html-entities') {
                     return utf8_to_ncr($str);
                 } else {
                     if ($this->from_encoding == 'html-entities') {
                         $str = utf8_from_ncr($str);
                         if ($this->to_encoding != 'utf-8') {
                             $str = $this->convert($str, 'utf-8', $this->to_encoding);
                             $this->from_encoding = 'html-entities';
                         }
                         return $str;
                     } else {
                         $space = array("\n", "\r", "\t");
                         $tag = array('<|n|>', '<|r|>', '<|t|>');
                         $str = str_replace($space, $tag, $str);
                         $method_name = substr($this->from_encoding, 0, 3);
                         $to_unicode = $method_name . '2unicode';
                         if ($this->from_encoding == 'utf-16le') {
                             $str = $this->change_byte($str);
                         } else {
                             if ($this->from_encoding != 'utf-16be' && method_exists($this, $to_unicode)) {
                                 $str = $this->{$to_unicode}($str);
                             }
                         }
                         $from_unicode = 'unicode2' . $method_name;
                         if ($this->to_encoding == 'utf-16le') {
                             $str = $this->change_byte($str);
                         } else {
                             if ($this->to_encoding != 'utf-16be' && method_exists($this, $from_unicode)) {
                                 $str = $this->{$from_unicode}($str);
                             }
                         }
                         return str_replace($tag, $space, $str);
                     }
                 }
         }
     } else {
         return $str;
     }
 }
开发者ID:h3len,项目名称:Project,代码行数:91,代码来源:encoding.class.php


示例12: cleanText

/**
 * convert line ending to unix format
 *
 * also makes sure the given text is valid UTF-8
 *
 * @see    formText() for 2crlf conversion
 * @author Andreas Gohr <[email protected]>
 *
 * @param string $text
 * @return string
 */
function cleanText($text)
{
    $text = preg_replace("/(\r\n)|(\r)/", "\n", $text);
    // if the text is not valid UTF-8 we simply assume latin1
    // this won't break any worse than it breaks with the wrong encoding
    // but might actually fix the problem in many cases
    if (!utf8_check($text)) {
        $text = utf8_encode($text);
    }
    return $text;
}
开发者ID:splitbrain,项目名称:dokuwiki,代码行数:22,代码来源:common.php


示例13: utf8_clean

/**
 * Remove BOM and invalid UTF-8 sequences from file content.
 * 
 * @param string $str
 * @return string
 */
function utf8_clean($str)
{
    if (strlen($str) >= 3 && substr($str, 0, 3) === "") {
        $str = substr($str, 3);
    }
    if (!utf8_check($str)) {
        $str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
    }
    return $str;
}
开发者ID:rhymix,项目名称:rhymix,代码行数:16,代码来源:functions.php


示例14: check_server_port

 /**
  * Try to create a socket connection
  *
  * @param 	string		$host		Add ssl:// for SSL/TLS.
  * @param 	int			$port		Example: 25, 465
  * @return	int						Socket id if ok, 0 if KO
  */
 function check_server_port($host, $port)
 {
     $_retVal = 0;
     $timeout = 5;
     // Timeout in seconds
     if (function_exists('fsockopen')) {
         dol_syslog("Try socket connection to host=" . $host . " port=" . $port);
         //See if we can connect to the SMTP server
         if ($socket = @fsockopen($host, $port, $errno, $errstr, $timeout)) {
             // Windows still does not have support for this timeout function
             if (function_exists('stream_set_timeout')) {
                 stream_set_timeout($socket, $timeout, 0);
             }
             dol_syslog("Now we wait for answer 220");
             // Check response from Server
             if ($_retVal = $this->server_parse($socket, "220")) {
                 $_retVal = $socket;
             }
         } else {
             $this->error = utf8_check('Error ' . $errno . ' - ' . $errstr) ? 'Error ' . $errno . ' - ' . $errstr : utf8_encode('Error ' . $errno . ' - ' . $errstr);
         }
     }
     return $_retVal;
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:31,代码来源:CMailFile.class.php


示例15: html_hilight

/**
 * Highlights searchqueries in HTML code
 *
 * @author Andreas Gohr <[email protected]>
 * @author Harry Fuecks <[email protected]>
 */
function html_hilight($html, $phrases)
{
    $phrases = array_filter((array) $phrases);
    $regex = join('|', array_map('ft_snippet_re_preprocess', array_map('preg_quote_cb', $phrases)));
    if ($regex === '') {
        return $html;
    }
    if (!utf8_check($regex)) {
        return $html;
    }
    $html = @preg_replace_callback("/((<[^>]*)|{$regex})/ui", 'html_hilight_callback', $html);
    return $html;
}
开发者ID:nefercheprure,项目名称:dokuwiki,代码行数:19,代码来源:html.php


示例16: convertEncodingStr

 /**
  * Convert strings into UTF-8
  *
  * @param string $str String to convert
  * @return string converted string
  */
 public static function convertEncodingStr($str)
 {
     if (!$str || utf8_check($str)) {
         return $str;
     }
     $obj = new stdClass();
     $obj->str = $str;
     $obj = self::convertEncoding($obj);
     return $obj->str;
 }
开发者ID:rhymix,项目名称:rhymix,代码行数:16,代码来源:Context.class.php


示例17: dol_delete_dir_recursive

/**
 *  Remove a directory $dir and its subdirectories (or only files and subdirectories)
 *
 *  @param	string	$dir            Dir to delete
 *  @param  int		$count          Counter to count nb of deleted elements
 *  @param  int		$nophperrors    Disable all PHP output errors
 *  @param	int		$onlysub		Delete only files and subdir, not main directory
 *  @return int             		Number of files and directory removed
 */
function dol_delete_dir_recursive($dir, $count = 0, $nophperrors = 0, $onlysub = 0)
{
    dol_syslog("functions.lib:dol_delete_dir_recursive " . $dir, LOG_DEBUG);
    if (dol_is_dir($dir)) {
        $dir_osencoded = dol_osencode($dir);
        if ($handle = opendir("{$dir_osencoded}")) {
            while (false !== ($item = readdir($handle))) {
                if (!utf8_check($item)) {
                    $item = utf8_encode($item);
                }
                // should be useless
                if ($item != "." && $item != "..") {
                    if (is_dir(dol_osencode("{$dir}/{$item}"))) {
                        $count = dol_delete_dir_recursive("{$dir}/{$item}", $count, $nophperrors);
                    } else {
                        dol_delete_file("{$dir}/{$item}", 1, $nophperrors);
                        $count++;
                        //echo " removing $dir/$item<br>\n";
                    }
                }
            }
            closedir($handle);
            if (empty($onlysub)) {
                dol_delete_dir($dir, $nophperrors);
                $count++;
                //echo "removing $dir<br>\n";
            }
        }
    }
    //echo "return=".$count;
    return $count;
}
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:41,代码来源:files.lib.php


示例18: render

 /**
  * Create output
  */
 function render($mode, Doku_Renderer &$renderer, $opt)
 {
     if ($mode == 'metadata') {
         return false;
     }
     // load file data
     if ($opt['file']) {
         if (preg_match('/^https?:\\/\\//i', $opt['file'])) {
             require_once DOKU_INC . 'inc/HTTPClient.php';
             $http = new DokuHTTPClient();
             $opt['content'] = $http->get($opt['file']);
             if ($opt['content'] === false) {
                 $renderer->cdata('Failed to fetch remote CSV data');
                 return true;
             }
         } else {
             $renderer->info['cache'] = false;
             if (auth_quickaclcheck(getNS($opt['file']) . ':*') < AUTH_READ) {
                 $renderer->cdata('Access denied to CSV data');
                 return true;
             } else {
                 $file = mediaFN($opt['file']);
                 $opt['content'] = io_readFile($file);
             }
         }
         // if not valid UTF-8 is given we assume ISO-8859-1
         if (!utf8_check($opt['content'])) {
             $opt['content'] = utf8_encode($opt['content']);
         }
     }
     // check if there is content
     $content =& $opt['content'];
     $content = trim($content);
     if ($content === '') {
         $renderer->cdata('No csv data found');
         return true;
     }
     // Export the csv file
     $targetfile = '';
     $export = $opt['export'];
     if ($export != '') {
         $targetfile = htmlspecialchars(trim($export));
         if (auth_quickaclcheck(getNS($targetfile . ':*')) < AUTH_EDIT) {
             $renderer->cdata('Access denied: Could not create download link.');
             $targetfile = '';
             return true;
         } else {
             $file = mediaFN($targetfile);
             if (file_put_contents($file, $content, LOCK_EX) > 0) {
                 $linkname = $opt['linkname'];
                 if ($linkname == '') {
                     $linkname = 'Download CSV file';
                 }
             } else {
                 $targetfile = '';
                 $renderer->cdata('Failed to write ' . $file . ': Could not create download link.');
                 return true;
             }
         }
     }
     // get the first row - it will define the structure
     $row = $this->csv_explode_row($content, $opt['delim'], $opt['enclosure'], $opt['escape']);
     $maxcol = count($row);
     $line = 0;
     // create the table and start rendering
     $renderer->table_open($maxcol);
     while ($row !== false) {
         // make sure we have enough columns
         $row = array_pad($row, $maxcol, '');
         // render
         $renderer->tablerow_open();
         for ($i = 0; $i < $maxcol;) {
             $span = 1;
             // lookahead to find spanning cells
             if ($opt['span_empty_cols']) {
                 for ($j = $i + 1; $j < $maxcol; $j++) {
                     if ($row[$j] === '') {
                         $span++;
                     } else {
                         break;
                     }
                 }
             }
             // open cell
             if ($line < $opt['hdr_rows'] || $i < $opt['hdr_cols']) {
                 $renderer->tableheader_open($span);
             } else {
                 $renderer->tablecell_open($span);
             }
             // print cell content, call linebreak() for newlines
             $lines = explode("\n", $row[$i]);
             $cnt = count($lines);
             for ($k = 0; $k < $cnt; $k++) {
                 $renderer->cdata($lines[$k]);
                 if ($k < $cnt - 1) {
                     $renderer->linebreak();
                 }
//.........这里部分代码省略.........
开发者ID:bzfwunde,项目名称:csv,代码行数:101,代码来源:syntax.php


示例19: loadBox

    /**
     *  Charge les donnees en memoire pour affichage ulterieur
     *  @param      $max        Nombre maximum d'enregistrements a charger
     */
    function loadBox($max=5)
    {
        global $user, $langs, $conf;
        $langs->load("boxes");

		$this->max=$max;

		// On recupere numero de param de la boite
		preg_match('/^([0-9]+) /',$this->param,$reg);
		$site=$reg[1];

		// Creation rep (pas besoin, on le cree apres recup flux)
		// documents/rss is created by module activation
		// documents/rss/tmp is created by magpie
		//$result=create_exdir($conf->externalrss->dir_temp);

		// Recupere flux RSS definie dans EXTERNAL_RSS_URLRSS_$site
        $url=@constant("EXTERNAL_RSS_URLRSS_".$site);
        //define('MAGPIE_DEBUG',1);
        $rss=fetch_rss($url);
        if (! is_object($rss))
        {
        	dol_syslog("FETCH_RSS site=".$site);
        	dol_syslog("FETCH_RSS url=".$url);
        	return -1;
        }

		// INFO sur le channel
		$description=$rss->channel['tagline'];
		$link=$rss->channel['link'];

        $title=$langs->trans("BoxTitleLastRssInfos",$max, @constant("EXTERNAL_RSS_TITLE_". $site));
        if ($rss->ERROR)
        {
            // Affiche warning car il y a eu une erreur
            $title.=" ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate",(isset($rss->date)?dol_print_date($rss->date,"dayhourtext"):$langs->trans("Unknown"))));
            $this->info_box_head = array('text' => $title,'limit' => 0);
        }
        else
        {
        	$this->info_box_head = array('text' => $title,
        		'sublink' => $link, 'subtext'=>$langs->trans("LastRefreshDate").': '.(isset($rss->date)?dol_print_date($rss->date,"dayhourtext"):$langs->trans("Unknown")), 'subpicto'=>'object_bookmark');
		}

		// INFO sur le elements
        for($i = 0; $i < $max && $i < sizeof($rss->items); $i++)
        {
            $item = $rss->items[$i];

			// Magpierss common fields
            $href  = $item['link'];
        	$title = urldecode($item['title']);
			$date  = $item['date_timestamp'];	// date will be empty if conversion into timestamp failed
			if ($rss->is_rss())		// If RSS
			{
				if (! $date && isset($item['pubdate']))    $date=$item['pubdate'];
				if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date'];
				//$item['dc']['language']
				//$item['dc']['publisher']
			}
			if ($rss->is_atom())	// If Atom
			{
				if (! $date && isset($item['issued']))    $date=$item['issued'];
				if (! $date && isset($item['modified']))  $date=$item['modified'];
				//$item['issued']
				//$item['modified']
				//$item['atom_content']
			}
			if (is_numeric($date)) $date=dol_print_date($date,"dayhour");

			$isutf8 = utf8_check($title);
	        if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $title=utf8_encode($title);
	        elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title=utf8_decode($title);

	        $title=preg_replace("/([[:alnum:]])\?([[:alnum:]])/","\\1'\\2",$title);   // Gere probleme des apostrophes mal codee/decodee par utf8
            $title=preg_replace("/^\s+/","",$title);                                  // Supprime espaces de debut
            $this->info_box_contents["$href"]="$title";

            $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
            'logo' => $this->boximg,
            'url' => $href,
            'target' => 'newrss');

            $this->info_box_contents[$i][1] = array('td' => 'align="left"',
            'text' => $title,
            'url' => $href,
            'maxlength' => 64,
            'target' => 'newrss');

            $this->info_box_contents[$i][2] = array('td' => 'align="right" nowrap="1"',
            'text' => $date);
        }
    }
开发者ID:remyyounes,项目名称:dolibarr,代码行数:97,代码来源:box_external_rss.php


示例20: testDolUtf8Check

    /**
     * testDolTextIsHtml
     *
     * @return void
     */
    public function testDolUtf8Check()
    {
        // True
        $result=utf8_check('azerty');
        $this->assertTrue($result);

        $file=dirname(__FILE__).'/textutf8.txt';
        $filecontent=file_get_contents($file);
        $result=utf8_check($filecontent);
        $this->assertTrue($result);

        $file=dirname(__FILE__).'/textiso.txt';
        $filecontent=file_get_contents($file);
        $result=utf8_check($filecontent);
        $this->assertFalse($result);
    }
开发者ID:nrjacker4,项目名称:crm-php,代码行数:21,代码来源:FunctionsTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP utf8_clean_string函数代码示例发布时间:2022-05-23
下一篇:
PHP utf8_basename函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap