本文整理汇总了PHP中utf8_recode函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_recode函数的具体用法?PHP utf8_recode怎么用?PHP utf8_recode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_recode函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: cleanup
/**
* Clean up a text to remove non-alphanumeric characters
*
* This method receives a UTF-8 string, normalizes and validates it, replaces all
* non-alphanumeric characters with strings then returns the result.
*
* Any number of "allowed chars" can be passed as a UTF-8 string in NFC.
*
* @param string $text Text to split, in UTF-8 (not normalized or sanitized)
* @param string $allowed_chars String of special chars to allow
* @param string $encoding Text encoding
* @return string Cleaned up text, only alphanumeric chars are left
*
* @todo normalizer::cleanup being able to be used?
*/
function cleanup($text, $allowed_chars = null, $encoding = 'utf-8')
{
global $phpbb_root_path, $phpEx;
static $conv = array(), $conv_loaded = array();
$words = $allow = array();
// Convert the text to UTF-8
$encoding = strtolower($encoding);
if ($encoding != 'utf-8') {
$text = utf8_recode($text, $encoding);
}
$utf_len_mask = array("À" => 2, "Ð" => 2, "à" => 3, "ð" => 4);
/**
* Replace HTML entities and NCRs
*/
$text = htmlspecialchars_decode(utf8_decode_ncr($text), ENT_QUOTES);
/**
* Load the UTF-8 normalizer
*
* If we use it more widely, an instance of that class should be held in a
* a global variable instead
*/
utf_normalizer::nfc($text);
/**
* The first thing we do is:
*
* - convert ASCII-7 letters to lowercase
* - remove the ASCII-7 non-alpha characters
* - remove the bytes that should not appear in a valid UTF-8 string: 0xC0,
* 0xC1 and 0xF5-0xFF
*
* @todo in theory, the third one is already taken care of during normalization and those chars should have been replaced by Unicode replacement chars
*/
$sb_match = "ISTCPAMELRDOJBNHFGVWUQKYXZ\r\n\t!\"#\$%&'()*+,-./:;<=>?@[\\]^_`{|}~\v\fÀÁõö÷øùúûüýþÿ";
$sb_replace = 'istcpamelrdojbnhfgvwuqkyxz ';
/**
* This is the list of legal ASCII chars, it is automatically extended
* with ASCII chars from $allowed_chars
*/
$legal_ascii = ' eaisntroludcpmghbfvq10xy2j9kw354867z';
/**
* Prepare an array containing the extra chars to allow
*/
if (isset($allowed_chars[0])) {
$pos = 0;
$len = strlen($allowed_chars);
do {
$c = $allowed_chars[$pos];
if ($c < "€") {
/**
* ASCII char
*/
$sb_pos = strpos($sb_match, $c);
if (is_int($sb_pos)) {
/**
* Remove the char from $sb_match and its corresponding
* replacement in $sb_replace
*/
$sb_match = substr($sb_match, 0, $sb_pos) . substr($sb_match, $sb_pos + 1);
$sb_replace = substr($sb_replace, 0, $sb_pos) . substr($sb_replace, $sb_pos + 1);
$legal_ascii .= $c;
}
++$pos;
} else {
/**
* UTF-8 char
*/
$utf_len = $utf_len_mask[$c & "ð"];
$allow[substr($allowed_chars, $pos, $utf_len)] = 1;
$pos += $utf_len;
}
} while ($pos < $len);
}
$text = strtr($text, $sb_match, $sb_replace);
$ret = '';
$pos = 0;
$len = strlen($text);
do {
/**
* Do all consecutive ASCII chars at once
*/
if ($spn = strspn($text, $legal_ascii, $pos)) {
$ret .= substr($text, $pos, $spn);
$pos += $spn;
}
if ($pos >= $len) {
//.........这里部分代码省略.........
开发者ID:jverkoey,项目名称:Three20-Scope,代码行数:101,代码来源:fulltext_native.php
示例2: my_preg_match
function my_preg_match($pattern, $subject)
{
// start regullar expression
preg_match($pattern, $subject, $out);
// if there is some result... process it and return it
if (isset($out[1])) {
// cdata
$out[1] = strtr($out[1], array('<![CDATA[' => '', ']]>' => ''));
if (isset($this->rsscp) && $this->rsscp != 'UTF-8') {
// recode with phpBB´s functions
$out[1] = utf8_recode($out[1], $this->rsscp);
}
// Return result
return trim($out[1]);
} else {
// if there is NO result, return empty string
return '';
}
}
开发者ID:phpbbireland,项目名称:stargate-portal,代码行数:19,代码来源:sgp_lastrss.php
示例3: phpbb_set_encoding
//.........这里部分代码省略.........
global $convert, $phpEx;
/*static $lang_enc_array = array(
'korean' => 'euc-kr',
'serbian' => 'windows-1250',
'polish' => 'iso-8859-2',
'kurdish' => 'windows-1254',
'slovak' => 'Windows-1250',
'russian' => 'windows-1251',
'estonian' => 'iso-8859-4',
'chinese_simplified' => 'gb2312',
'macedonian' => 'windows-1251',
'azerbaijani' => 'UTF-8',
'romanian' => 'iso-8859-2',
'romanian_diacritice' => 'iso-8859-2',
'lithuanian' => 'windows-1257',
'turkish' => 'iso-8859-9',
'ukrainian' => 'windows-1251',
'japanese' => 'shift_jis',
'hungarian' => 'ISO-8859-2',
'romanian_no_diacritics' => 'iso-8859-2',
'mongolian' => 'UTF-8',
'slovenian' => 'windows-1250',
'bosnian' => 'windows-1250',
'czech' => 'Windows-1250',
'farsi' => 'Windows-1256',
'croatian' => 'windows-1250',
'greek' => 'iso-8859-7',
'russian_tu' => 'windows-1251',
'sakha' => 'UTF-8',
'serbian_cyrillic' => 'windows-1251',
'bulgarian' => 'windows-1251',
'chinese_traditional_taiwan' => 'big5',
'chinese_traditional' => 'big5',
'arabic' => 'windows-1256',
'hebrew' => 'WINDOWS-1255',
'thai' => 'windows-874',
//'chinese_traditional_taiwan' => 'utf-8' // custom modified, we may have to do an include :-(
);*/
if (empty($lang_enc_array))
{
$lang_enc_array = array();
}
$get_lang = trim(get_config_value('default_lang'));
// Do we need the users language encoding?
if ($grab_user_lang && !empty($convert_row))
{
if (!empty($convert_row['user_lang']))
{
$get_lang = trim($convert_row['user_lang']);
}
else if (!empty($convert_row['poster_id']))
{
global $src_db, $same_db;
if ($convert->mysql_convert && $same_db)
{
$src_db->sql_query("SET NAMES 'binary'");
}
$sql = 'SELECT user_lang
FROM ' . $convert->src_table_prefix . 'users
WHERE user_id = ' . (int) $convert_row['poster_id'];
$result = $src_db->sql_query($sql);
$get_lang = (string) $src_db->sql_fetchfield('user_lang');
$src_db->sql_freeresult($result);
if ($convert->mysql_convert && $same_db)
{
$src_db->sql_query("SET NAMES 'utf8'");
}
$get_lang = (!trim($get_lang)) ? trim(get_config_value('default_lang')) : trim($get_lang);
}
}
if (!isset($lang_enc_array[$get_lang]))
{
$filename = $convert->options['forum_path'] . '/language/lang_' . $get_lang . '/lang_main.' . $phpEx;
if (!file_exists($filename))
{
$get_lang = trim(get_config_value('default_lang'));
}
if (!isset($lang_enc_array[$get_lang]))
{
include($convert->options['forum_path'] . '/language/lang_' . $get_lang . '/lang_main.' . $phpEx);
$lang_enc_array[$get_lang] = $lang['ENCODING'];
unset($lang);
}
}
$encoding = $lang_enc_array[$get_lang];
return utf8_recode($text, $lang_enc_array[$get_lang]);
}
开发者ID:BackupTheBerlios,项目名称:phpbb-hu-svn,代码行数:101,代码来源:functions_phpbb20.php
示例4: utf8_convert_message
/**
* Trying to convert returned system message to utf8
*
* PHP assumes such messages are ISO-8859-1 so we'll do that too
* and if it breaks messages we'll blame it on them ;-)
*/
function utf8_convert_message($message)
{
// First of all check if conversion is neded at all, as there is no point
// in converting ASCII messages from ISO-8859-1 to UTF-8
if (!preg_match('/[\x80-\xFF]/', $message))
{
return utf8_htmlspecialchars($message);
}
// else we need to convert some part of the message
return utf8_htmlspecialchars(utf8_recode($message, 'ISO-8859-1'));
}
开发者ID:ALTUN69,项目名称:icy_phoenix,代码行数:18,代码来源:utf_tools.php
示例5: define
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = defined('PHPBB_ROOT_PATH') ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include $phpbb_root_path . 'common.' . $phpEx;
include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup(array('memberlist', 'groups'));
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
if (!empty($_REQUEST['un'])) {
$_REQUEST['un'] = rawurldecode($_REQUEST['un']);
if (!$phpbb_seo->is_utf8($_REQUEST['un'])) {
$_REQUEST['un'] = utf8_normalize_nfc(utf8_recode($_REQUEST['un'], 'ISO-8859-1'));
}
}
// www.phpBB-SEO.com SEO TOOLKIT END
// Grab data
$mode = request_var('mode', '');
$action = request_var('action', '');
$user_id = request_var('u', ANONYMOUS);
$username = request_var('un', '', true);
$group_id = request_var('g', 0);
$topic_id = request_var('t', 0);
// Check our mode...
if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders'))) {
trigger_error('NO_MODE');
}
switch ($mode) {
开发者ID:jverkoey,项目名称:Three20-Scope,代码行数:31,代码来源:memberlist.php
示例6: seo_req_uri
/**
* Returns the full REQUEST_URI
*/
public function seo_req_uri()
{
$this->seo_path['uri'] = $this->request->server('HTTP_X_REWRITE_URL');
// IIS isapi_rewrite
if (empty($this->seo_path['uri'])) {
// Apache mod_rewrite
$this->seo_path['uri'] = $this->request->server('REQUEST_URI');
}
if (empty($this->seo_path['uri'])) {
$this->seo_path['uri'] = $this->request->server('SCRIPT_NAME') . (($qs = $this->request->server('QUERY_STRING')) != '' ? "?{$qs}" : '');
}
$this->seo_path['uri'] = str_replace('%26', '&', rawurldecode(ltrim($this->seo_path['uri'], '/')));
// workaround for FF default iso encoding
if (!$this->is_utf8($this->seo_path['uri'])) {
$this->seo_path['uri'] = \utf8_normalize_nfc(\utf8_recode($this->seo_path['uri'], 'iso-8859-1'));
}
$this->seo_path['uri'] = $this->seo_path['root_url'] . $this->seo_path['uri'];
return $this->seo_path['uri'];
}
开发者ID:kinecto,项目名称:usu,代码行数:22,代码来源:core.php
示例7: seo_req_uri
/**
* Returns the full REQUEST_URI
*/
function seo_req_uri()
{
if (!empty($_SERVER['HTTP_X_REWRITE_URL'])) {
// IIS isapi_rewrite
$this->seo_path['uri'] = ltrim($_SERVER['HTTP_X_REWRITE_URL'], '/');
} elseif (!empty($_SERVER['REQUEST_URI'])) {
// Apache mod_rewrite
$this->seo_path['uri'] = ltrim($_SERVER['REQUEST_URI'], '/');
} else {
// no mod rewrite
$this->seo_path['uri'] = ltrim($_SERVER['SCRIPT_NAME'], '/') . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
}
$this->seo_path['uri'] = str_replace('%26', '&', rawurldecode($this->seo_path['uri']));
// workaround for FF default iso encoding
if (!$this->is_utf8($this->seo_path['uri'])) {
$this->seo_path['uri'] = utf8_normalize_nfc(utf8_recode($this->seo_path['uri'], 'iso-8859-1'));
}
$this->seo_path['uri'] = $this->seo_path['root_url'] . $this->seo_path['uri'];
return $this->seo_path['uri'];
}
开发者ID:jverkoey,项目名称:Three20-Scope,代码行数:23,代码来源:phpbb_seo_class_light.php
示例8: final_stage
/**
* Sends an email to the board administrator with their password and some useful links
*/
function final_stage($mode, $sub)
{
global $auth, $config, $db, $user, $template, $user, $phpbb_root_path, $phpEx, $phpbb_seo, $cache;
$update_info = '';
if (!sizeof($this->errors)) {
if ($mode != 'uninstall_gym_sitemaps') {
set_gym_config('gym_version', $this->version, 'main', $this->old_config);
$this->config_report[] = "SET <b>gym_version</b> to {$this->version}";
set_config('gym_installed', 1);
} else {
set_config('gym_installed', 0);
}
add_log('admin', 'SEO_LOG_' . strtoupper($mode), $this->version);
} else {
set_config('gym_installed', 0);
add_log('admin', 'SEO_LOG_' . strtoupper($mode) . '_FAIL', $this->errors);
$cache->purge();
$this->p_master->error($user->lang['SEO_ERROR_INSTALL'] . '<br/><pre>' . implode('<br/>', $this->errors) . '</pre>', __LINE__, __FILE__);
}
$cache->purge();
$this->page_title = $user->lang['STAGE_FINAL'];
if ($mode != 'uninstall_gym_sitemaps') {
if ($mode == 'update_gym_sitemaps') {
$key = 'UPDATE';
$lang_key = strpos($user->lang_name, 'fr') !== false ? 'FR' : '';
if ($update_infos = @file("./docs/update_from_last{$lang_key}.txt")) {
foreach ($update_infos as $line) {
$line = str_replace(array("\r", "\n"), '', utf8_htmlspecialchars(is_utf8($line) ? $line : utf8_recode($line, 'iso-8859-1')));
$update_info .= (preg_match('`^#`', $line) ? "<b style=\"color:blue;\">{$line}</b>" : $line) . '<br/>';
}
}
} else {
$key = 'INSTALL';
}
$submit_action = append_sid($phpbb_root_path . 'adm/index.' . $phpEx . '?sid=' . $user->session_id);
$title = $user->lang['SEO_INSTALL_CONGRATS'];
$body = sprintf($user->lang["SEO_{$key}_CONGRATS_EXPLAIN"], $this->modrtype_lang['link'], $this->version) . '<br/>' . implode('<br/>', $this->config_report) . "<br/><br/><hr/><pre>{$update_info}</pre>";
} else {
$submit_action = append_sid($phpbb_root_path . 'index.' . $phpEx);
$title = $user->lang['UN_SEO_INSTALL_CONGRATS'];
$body = sprintf($user->lang['UN_SEO_INSTALL_CONGRATS_EXPLAIN'], $this->modrtype_lang['link'], $this->version);
}
$template->assign_vars(array('TITLE' => $title, 'BODY' => $body, 'L_SUBMIT' => $user->lang['SEO_FINAL_' . strtoupper($mode)], 'U_ACTION' => $submit_action));
}
开发者ID:Ibrahim-Abdelkader,项目名称:phpbb3,代码行数:47,代码来源:gym_install.php
示例9: utf8_normalize_nfc
}
$post_text = utf8_normalize_nfc(request_var('contents', '', true));
$uid = $bitfield = $options = '';
// will be modified by generate_text_for_storage
$allow_bbcode = $allow_urls = $allow_smilies = true;
generate_text_for_storage($post_text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
// let's try something else here in order to get the bbcode_uid and bbcode_bitfield
$message_parser = new parse_message();
$message_parser->message = $post_text;
if (!isset($uid)) {
$uid = $message_parser->bbcode_uid;
}
if (!isset($bitfield)) {
$bitfield = $message_parser->bbcode_bitfield;
}
$sql_ary = array('post_text' => utf8_recode($post_text, 'utf-8'), 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'post_edit_time' => $edit_time, 'post_edit_count' => $edit_count, 'post_edit_user' => $edit_user);
$sql = 'UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE post_id = {$post_id}";
$db->sql_query($sql);
$text = generate_text_for_display($sql_ary['post_text'], $sql_ary['bbcode_uid'], $sql_ary['bbcode_bitfield'], 7);
$template->assign_vars(array('SEND_TEXT' => true, 'TEXT' => $text, 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST')));
} elseif ($post_id) {
$sql = 'SELECT p.*, f.*, t.*
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f\n\tWHERE p.post_id = {$post_id} AND p.topic_id = t.topic_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// HTML, BBCode, Smilies, Images and Flash status
$bbcode_status = $config['allow_bbcode'] && ($auth->acl_get('f_bbcode', $row['forum_id']) || $row['forum_id'] == 0) ? true : false;
$smilies_status = $bbcode_status && $config['allow_smilies'] && $auth->acl_get('f_smilies', $row['forum_id']) ? true : false;
$img_status = $bbcode_status && $auth->acl_get('f_img', $row['forum_id']) ? true : false;
$url_status = $config['allow_post_links'] ? true : false;
开发者ID:jverkoey,项目名称:Three20-Scope,代码行数:31,代码来源:quickedit.php
示例10: parse_atom
/**
* Main parsing function for ATOM format
*/
private function parse_atom()
{
// get root
$root = $this->data->children('http://www.w3.org/2005/Atom');
// get feed data
foreach ($root as $ak => $av) {
if ($ak != 'entry') {
$this->check_feed_attributes($ak);
}
}
// do we have some data ?
if (isset($root->entry)) {
$i = 0;
foreach ($root->entry as $entry) {
$details = $entry->children('http://www.w3.org/2005/Atom');
foreach ($details as $k => $v) {
$this->items[$i][utf8_recode($k, $this->encoding)] = (string) utf8_recode($v, $this->encoding);
$this->check_item_attributes($k);
}
$i++;
}
}
}
开发者ID:royalterra,项目名称:SFNC,代码行数:26,代码来源:sfnc.class.php
示例11: defined
$phpbb_root_path = defined('PHPBB_ROOT_PATH') ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include $phpbb_root_path . 'common.' . $phpEx;
include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
include $phpbb_root_path . 'includes/bbcode.' . $phpEx;
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
if (empty($_REQUEST['f'])) {
$phpbb_seo->get_forum_id($session_forum_id);
if ($session_forum_id > 0) {
$_REQUEST['f'] = (int) $session_forum_id;
}
}
if (!empty($_REQUEST['hilit'])) {
$_REQUEST['hilit'] = rawurldecode($_REQUEST['hilit']);
if (!$phpbb_seo->is_utf8($_REQUEST['hilit'])) {
$_REQUEST['hilit'] = utf8_normalize_nfc(utf8_recode($_REQUEST['hilit'], 'iso-8859-1'));
}
}
// www.phpBB-SEO.com SEO TOOLKIT END
// Start session management
$user->session_begin();
$auth->acl($user->data);
// Initial var setup
$forum_id = request_var('f', 0);
$topic_id = request_var('t', 0);
$post_id = request_var('p', 0);
$voted_id = request_var('vote_id', array('' => 0));
// BEGIN Topic solved
$solved_id = request_var('ys', 0);
$unsolved = request_var('ns', 0);
// END Topic solved
开发者ID:jverkoey,项目名称:Three20-Scope,代码行数:31,代码来源:viewtopic.php
示例12: GGs_rss
//.........这里部分代码省略.........
$auth_msg = '';
if ($this->actions['auth_checked']) {
$auth_msg = '<br/><br/>' . (is_numeric($this->actions['list_id']) && $this->actions['list_id'] > 0 ? sprintf($lang['rss_auth_this'], $userdata['username']) : sprintf($lang['rss_auth_some'], $userdata['username']));
$auth_msg = htmlspecialchars($auth_msg);
}
// XSLT styling
$rss_xslt = '';
if ($this->rss_config['rss_xslt']) {
// Isn't this a bit stupid, we need to trick browsers to allow xlst usage
// We do it by adding some space chars at the beginning of the xml code
// FF 2 and IE7 only look for the first 500 chars to decide it's rss or not
// and impose their private handling
$blanc_fix = '';
if ($this->rss_config['rss_force_xslt']) {
for ($i = 0; $i < 650; $i++) {
$blanc_fix .= ' ';
}
$blanc_fix = "\n" . '<!-- Some spaces ' . $blanc_fix . ' to force xlst -->';
}
$rss_xslt = $this->rss_config['rss_xslt'] ? '<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="' . $this->path_config['rss_url'] . 'ggs_style/mxrss2.xsl"?>' . $blanc_fix : '';
}
$this->output_data['data'] = '<?xml version="1.0" encoding="utf-8"?>' . $rss_xslt . "\n" . '<!-- Generated by Google Yahoo MSN Sitemaps and RSS ' . $this->ggsitemaps_config['ggs_ver'] . ' - ' . $this->ggsitemaps_config['ggs_c_info'] . ' -->' . "\n" . '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">';
$this->style_config['rsschan_img_tpl'] = '<image>' . "\n\t\t\t" . '<title>%s</title>' . "\n\t\t\t" . '<url>%s</url>' . "\n\t\t\t" . '<link>%s</link>' . "\n\t\t" . '</image>';
$this->style_config['rsschan_tpl'] = "\n\t" . '<channel>' . "\n\t\t" . '<title>%s</title>' . "\n\t\t" . '<link>%s</link>' . "\n\t\t" . '<description>%s</description>' . $this->rss_config['rss_lang'] . $this->rss_config['c_info'] . "\n\t\t" . '<lastBuildDate>%s</lastBuildDate>' . "\n\t\t" . '%s' . "\n\t\t" . '<docs>http://blogs.law.harvard.edu/tech/rss</docs>' . "\n\t\t" . '<generator>Ultimate Google Sitemaps and RSS ' . $this->ggsitemaps_config['ggs_ver'] . ' www.phpBB-SEO.com</generator>' . "\n\t\t" . '<ttl>' . intval(($this->cache_config['rss_cache_max_age'] - ($this->output_data['time'] - $this->output_data['last_mod_time'])) / 60) . '</ttl>';
if (in_array($this->actions['action'], $this->actions['actions'])) {
include $this->path_config['module_path'] . 'includes/rss_' . $this->actions['action'] . '.' . $phpEx;
if ($this->output_data['showstats']) {
$this->output_data['gen_data'] = sprintf('%.5f', $phpbb_seo->microtime_float() - $this->output_data['microtime']);
$mem_stats = $this->ggs_mem_usage();
$this->output_data['data'] .= "\n\t" . '</channel>' . "\n" . '</rss>' . sprintf($this->style_config['stats_genlist'], $this->output_data['gen_data'], $mem_stats, $db->num_queries, $this->output_data['url_sofar']);
} else {
$this->output_data['data'] .= "\n\t" . '</channel>' . "\n" . '</rss>';
}
} else {
// We are working on all available files
$rss_gen_url = $this->path_config['rss_url'] . ($this->mod_r_config['mod_rewrite'] ? "rss" . $this->mod_r_config['extra_params'] . ".xml" . $this->ext_config['gzip_ext_out'] : "rss.{$phpEx}" . (substr($this->mod_r_config['extra_params'], 0, 5) === "&" ? "?" . substr($this->mod_r_config['extra_params'], 5) : ''));
$chan_title_gen = htmlspecialchars($this->rss_config['sitename'] . $this->rss_config['extra_title']);
$chan_desc_gen = htmlspecialchars($this->rss_config['site_desc']);
$rss_link_url = $this->actions['action'] === 'rss' || $this->actions['action'] === 'channels' ? $this->path_config['root_url'] : $this->path_config['phpbb_url'];
$board_image = sprintf($this->style_config['rsschan_img_tpl'], $chan_title_gen, $this->rss_config['rss_image'], $rss_link_url);
$chan_time = gmdate('D, d M Y H:i:s \\G\\M\\T', $this->output_data['last_mod_time']);
if ($this->actions['action'] === 'channels') {
$rss_list_url = $this->path_config['rss_url'] . ($this->mod_r_config['mod_rewrite'] ? 'channels-rss' . $this->mod_r_config['extra_params'] . '.xml' . $this->ext_config['gzip_ext_out'] : 'rss.' . $phpEx . '?channels' . $this->mod_r_config['extra_params']);
$this->seo_kill_dupes($rss_list_url);
$chan_title = htmlspecialchars($this->rss_config['sitename'] . $lang['rss_chan_list'] . $this->rss_config['extra_title']);
$chan_desc = htmlspecialchars($this->rss_config['site_desc'] . $lang['rss_chan_list']);
$this->output_data['data'] .= sprintf($this->style_config['rsschan_tpl'], $chan_title, $rss_link_url, $chan_desc . $auth_msg, $chan_time, $board_image);
$this->output_data['url_sofar']++;
$this->output_data['data'] .= sprintf($this->style_config['rss_tpl'], $chan_title, $this->path_config['root_url'], $chan_time, $chan_desc, $rss_list_url, htmlspecialchars($this->rss_config['sitename']), $this->path_config['root_url']);
$this->output_data['url_sofar']++;
} else {
$this->seo_kill_dupes($rss_gen_url);
$this->output_data['data'] .= sprintf($this->style_config['rsschan_tpl'], $chan_title_gen, $rss_link_url, $chan_desc_gen . $auth_msg, $chan_time, $board_image);
$this->output_data['url_sofar']++;
}
$this->output_data['data'] .= sprintf($this->style_config['rss_tpl'], $chan_title_gen, $this->path_config['root_url'], $chan_time, $chan_desc_gen, $rss_gen_url, htmlspecialchars($this->rss_config['sitename']), $this->path_config['root_url']);
$this->output_data['url_sofar']++;
// URL limit, we take the last xx items from each feed
// where xx is the URL limit divided by the number of feeds
$this->rss_config['rss_url_limit'] = intval($this->rss_config['rss_url_limit'] / $this->actions['file_count']);
$url_sofar_total = 0;
$dir = @opendir($this->path_config['module_path'] . 'includes');
while (($file = @readdir($dir)) !== FALSE) {
if (preg_match("/^rss_[a-zA-Z0-9_-]+\\." . $phpEx . "\$/", $file)) {
include_once $this->path_config['module_path'] . 'includes/' . $file;
// Keep total
$url_sofar_total = $url_sofar_total + $this->output_data['url_sofar'];
// Reset current
$this->output_data['url_sofar'] = 0;
}
}
@closedir($dir);
$this->output_data['url_sofar'] = $url_sofar_total;
$this->output_data['data'] .= "\n\t" . '</channel>';
if ($this->output_data['showstats']) {
$this->output_data['gen_data'] = sprintf('%.5f', $phpbb_seo->microtime_float() - $this->output_data['microtime']);
$mem_stats = $this->ggs_mem_usage();
$this->output_data['data'] .= "\n" . '</rss>' . sprintf($this->style_config['stats_genlist'], $this->output_data['gen_data'], $mem_stats, $db->num_queries, $this->output_data['url_sofar']);
} else {
$this->output_data['data'] .= "\n" . '</rss>';
}
}
if ($this->rss_config['non_utf8']) {
$encoding = trim($this->rss_config['rss_charset']);
if ($encoding === 'auto' && @extension_loaded('mbstring')) {
$encoding = trim(@mb_strtolower(@mb_internal_encoding()));
}
if ($encoding == '' || $encoding === 'auto' || $encoding == 'no value') {
$encoding = 'iso-8859-1';
}
if (!$this->rss_config['use_native_utf8_encode']) {
// Only inlcude the file if required 15ko is not much but still
require_once $this->path_config['module_path'] . "includes/utf/utf_tools.{$phpEx}";
$this->output_data['data'] = utf8_recode($this->output_data['data'], $encoding, $this);
} else {
$this->output_data['data'] = utf8_encode($this->output_data['data']);
}
}
return;
}
开发者ID:Nekrofage,项目名称:FJR,代码行数:101,代码来源:ggs_functions.php
示例13: get_match
/**
* get_match($pattern, $string, $encoding)
* returns properly encoded match from feed
*/
function get_match($pattern, $string, $encoding = 'utf-8')
{
static $filters = array('<![CDATA[' => '', ']]>' => '');
$string = strtr($string, $filters);
preg_match($pattern, $string, $out);
if (!empty($out[1])) {
// cdata
$out[1] = strtr($out[1], $filters);
if (strtolower($encoding) != 'utf-8') {
$out[1] = utf8_recode($out[1], $encoding);
}
return @html_entity_decode(trim($out[1]), ENT_COMPAT, 'UTF-8');
} else {
return '';
}
}
开发者ID:Ibrahim-Abdelkader,项目名称:phpbb3,代码行数:20,代码来源:gym_rss_functions.php
示例14: define
*/
define('IN_PHPBB', true);
$phpbb_root_path = defined('PHPBB_ROOT_PATH') ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include $phpbb_root_path . 'common.' . $phpEx;
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('search');
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$clean_request = array('keywords', 'author', 'add_keywords');
foreach ($clean_request as $request) {
if (!empty($_REQUEST[$request])) {
$_REQUEST[$request] = rawurldecode($_REQUEST[$request]);
if (!$phpbb_seo->is_utf8($_REQUEST[$request])) {
$_REQUEST[$request] = utf8_normalize_nfc(utf8_recode($_REQUEST[$request], 'iso-8859-1'));
}
}
}
// www.phpBB-SEO.com SEO TOOLKIT END
// Define initial vars
$mode = request_var('mode', '');
$search_id = request_var('search_id', '');
$start = max(request_var('start', 0), 0);
$post_id = request_var('p', 0);
$topic_id = request_var('t', 0);
$view = request_var('view', '');
$submit = request_var('submit', false);
$keywords = utf8_normalize_nfc(request_var('keywords', '', true));
$add_keywords = utf8_normalize_nfc(request_var('add_keywords', '', true));
$author = request_var('author', '', true);
开发者ID:Ibrahim-Abdelkader,项目名称:phpbb3,代码行数:31,代码来源:search.php
示例15: phpbb_set_encoding
/**
* Function for recoding text with the default language
*
* @param string $text text to recode to utf8
*/
function phpbb_set_encoding($text)
{
$encoding = 'utf8';
return utf8_recode($text, $encoding);
}
开发者ID:phimax,项目名称:zoroak,代码行数:11,代码来源:functions_mybb16.php
示例16: core_common
public function core_common($event)
{
if (empty($this->core->seo_opt['url_rewrite'])) {
return;
}
// this helps fixing several cases of relative links
define('PHPBB_USE_BOARD_URL_PATH', true);
$this->start = max(0, $this->request->variable('start', 0));
switch ($this->core->seo_opt['req_file']) {
case 'viewforum':
$this->forum_id = max(0, $this->request->variable('f', 0));
if (!$this->forum_id) {
$this->core->get_forum_id($this->forum_id);
if (!$this->forum_id) {
// here we need to find out if the uri really was a forum one
if (!preg_match('`^.+?\\.' . $this->php_ext . '(\\?.*)?$`', $this->core->seo_path['uri'])) {
// request url is rewriten
// re-route request to app.php
global $phpbb_container;
// god save the hax
$phpbb_root_path = $this->phpbb_root_path;
$phpEx = $this->php_ext;
include $phpbb_root_path . 'includes/functions_url_matcher.' . $phpEx;
// we need to overwrite couple SERVER variable to simulate direct app.php call
// start with scripts
$script_fix_list = array('SCRIPT_FILENAME', 'SCRIPT_NAME', 'PHP_SELF');
foreach ($script_fix_list as $varname) {
if ($this->request->is_set($varname, \phpbb\request\request_interface::SERVER)) {
$value = $this->request->server($varname);
if ($value) {
$value = preg_replace('`^(.*?)viewforum\\.' . $this->php_ext . '((\\?|/).*)?$`', '\\1app.' . $this->php_ext . '\\2', $value);
$this->request->overwrite($varname, $value, \phpbb\request\request_interface::SERVER);
}
}
}
// then fix query strings
$qs_fix_list = array('QUERY_STRING', 'REDIRECT_QUERY_STRING');
foreach ($qs_fix_list as $varname) {
if ($this->request->is_set($varname, \phpbb\request\request_interface::SERVER)) {
$value = $this->request->server($varname);
if ($value) {
$value = preg_replace('`^forum_uri=[^&]*(&|&)start=((&|&).*)?$`i', '', $value);
$this->request->overwrite($varname, $value, \phpbb\request\request_interface::SERVER);
}
}
}
// Start session management
$this->user->session_begin();
$this->auth->acl($this->user->data);
$this->user->setup('app');
$http_kernel = $phpbb_container->get('http_kernel');
$symfony_request = $phpbb_container->get('symfony_request');
$response = $http_kernel->handle($symfony_request);
$response->send();
$http_kernel->terminate($symfony_request, $response);
exit;
}
if ($this->core->seo_opt['redirect_404_forum']) {
$this->core->seo_redirect($this->core->seo_path['phpbb_url']);
} else {
send_status_line(404, 'Not Found');
}
} else {
$this->request->overwrite('f', (int) $this->forum_id);
}
}
break;
case 'viewtopic':
$this->forum_id = max(0, $this->request->variable('f', 0));
$this->topic_id = max(0, $this->request->variable('t', 0));
$this->post_id = max(0, $this->request->variable('p', 0));
if (!$this->forum_id) {
$this->core->get_forum_id($this->forum_id);
if ($this->forum_id > 0) {
$this->request->overwrite('f', (int) $this->forum_id);
}
}
$this->hilit_words = $this->request->variable('hilit', '', true);
if ($this->hilit_words) {
$this->hilit_words = rawurldecode($this->hilit_words);
if (!$this->core->is_utf8($this->hilit_words)) {
$this->hilit_words = utf8_normalize_nfc(utf8_recode($this->hilit_words, 'iso-8859-1'));
}
$this->request->overwrite('hilit', $this->hilit_words);
}
if (!$this->topic_id && !$this->post_id) {
if ($this->core->seo_opt['redirect_404_forum']) {
if ($this->forum_id && !empty($this->core->seo_url['forum'][$this->forum_id])) {
$this->core->seo_redirect(append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $this->forum_id));
} else {
$this->core->seo_redirect($this->core->seo_path['phpbb_url']);
}
} else {
send_status_line(404, 'Not Found');
}
}
break;
}
}
开发者ID:kinecto,项目名称:usu,代码行数:99,代码来源:listener.php
注:本文中的utf8_recode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论