aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/utf/utf_tools.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/utf/utf_tools.php')
-rw-r--r--phpBB/includes/utf/utf_tools.php38
1 files changed, 33 insertions, 5 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php
index 8098176837..9ee87a5425 100644
--- a/phpBB/includes/utf/utf_tools.php
+++ b/phpBB/includes/utf/utf_tools.php
@@ -70,7 +70,7 @@ if (!extension_loaded('xml'))
$pos = 0;
$len = strlen($str);
$ret = '';
-
+
while ($pos < $len)
{
$ord = ord($str[$pos]) & 0xF0;
@@ -252,7 +252,7 @@ else
if (is_null($offset))
{
$ar = explode($needle, $str);
-
+
if (sizeof($ar) > 1)
{
// Pop off the end of the string where the last match was made
@@ -527,7 +527,7 @@ else
$op = '^(?:' . $op . '.{' . $oy . '})';
}
else
- {
+ {
// offset == 0; just anchor the pattern
$op = '^';
}
@@ -560,7 +560,7 @@ else
$lx = (int) ($length / 65535);
$ly = $length % 65535;
-
+
// negative length requires a captured group
// of length characters
if ($lx)
@@ -632,7 +632,7 @@ function utf8_str_split($str, $split_len = 1)
{
return array($str);
}
-
+
preg_match_all('/.{' . $split_len . '}|[^\x00]{1,' . $split_len . '}$/us', $str, $ar);
return $ar[0];
}
@@ -1917,4 +1917,32 @@ function utf8_wordwrap($string, $width = 75, $break = "\n", $cut = false)
return implode($break, $new_lines);
}
+/**
+* UTF8-safe basename() function
+*
+* basename() has some limitations and is dependent on the locale setting
+* according to the PHP manual. Therefore we provide our own locale independant
+* basename function.
+*
+* @param string $filename The filename basename() should be applied to
+* @return string The basenamed filename
+*/
+function utf8_basename($filename)
+{
+ // We always check for forward slash AND backward slash
+ // because they could be mixed or "sneaked" in. ;)
+ // You know, never trust user input...
+ if (strpos($filename, '/') !== false)
+ {
+ $filename = utf8_substr($filename, utf8_strrpos($filename, '/') + 1);
+ }
+
+ if (strpos($filename, '\\') !== false)
+ {
+ $filename = utf8_substr($filename, utf8_strrpos($filename, '\\') + 1);
+ }
+
+ return $filename;
+}
+
?> \ No newline at end of file