Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Вопросы КЭПу » Сайт на основе phptravels, проблемы с русскими символами в URL?

Сайт на основе phptravels, проблемы с русскими символами в URL?


     12.09.2016    Вопросы КЭПу    932

вопрос

/**
* Filter segments for malicious characters
*
* access    private
* @param    string
* return    string
*/
function _filter_uri($str)
{
if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
{
// preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
// compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str))
{
show_error('The URI you submitted has disallowed characters.', 400);
}
}

// Convert programatic characters to entities
$bad    = array('$',    '(',    ')',    '%28',    '%29');
$good    = array('$',    '(',    ')',    '(',    ')');

return str_replace($bad, $good, $str);
}

// --------------------------------------------------------------------

/**
* Remove the suffix from the URL if needed
*
* access    private
* return    void
*/
function _remove_url_suffix()
{
if ($this->config->item('url_suffix') != "")
{
$this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
}
}

// --------------------------------------------------------------------

/**
* Explode the URI Segments. The individual segments will
* be stored in the $this->segments array.
*
* access    private
* return    void
*/
function _explode_segments()
{
foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
{
// Filter segments for security
$val = trim($this->_filter_uri($val));

if ($val != '')
{
$this->segments[] = $val;
}
}
}
Не могу разобраться в коде, не выходит русское название отеля лишь на англ в ссылке.

Ответил: КЭП


Сайт на основе phptravels, проблемы с русскими символами в URL?

— Тогда мы идём к вам!
Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы

наверх