--- /media/data/diffs/www.gukit.ru/modules/filefield_sources/filefield_sources.module	2017-06-15 11:56:16.494582806 +0300
+++ /var/www/www.gukit.ru/sites/all/modules/filefield_sources/filefield_sources.module	2017-06-15 11:59:02.146579469 +0300
@@ -456,7 +456,7 @@
   $file = new stdClass();
   $file->uid      = $user->uid;
   $file->status   = 0;
-  $file->filename = trim(basename($filepath), '.');
+  $file->filename = trim(drupal_basename($filepath), '.');
   $file->uri      = $filepath;
   $file->filemime = file_get_mimetype($file->filename);
   $file->filesize = filesize($filepath);
@@ -492,7 +492,7 @@
   // rename filename.php.foo and filename.php to filename.php.foo.txt and
   // filename.php.txt, respectively). Don't rename if 'allow_insecure_uploads'
   // evaluates to TRUE.
-  if (!variable_get('allow_insecure_uploads', 0) && preg_match('/\.(php|pl|py|cgi|asp|js)(\.|$)/i', $file->filename) && (substr($file->filename, -4) != '.txt')) {
+  if (!variable_get('allow_insecure_uploads', 0) && preg_match('/\.(php|pl|py|cgi|asp|js)(\.|$)/i', $file->filename) && (mb_substr($file->filename, -4) != '.txt')) {
     $file->filemime = 'text/plain';
     $file->uri .= '.txt';
     $file->filename .= '.txt';
@@ -517,7 +517,7 @@
   }
 
   // A URI may already have a trailing slash or look like "public://".
-  if (substr($destination, -1) != '/') {
+  if (mb_substr($destination, -1) != '/') {
     $destination .= '/';
   }
 
@@ -596,7 +596,7 @@
 function filefield_sources_clean_filename($filepath, $extensions) {
   global $user;
 
-  $filename = basename($filepath);
+  $filename = drupal_basename($filepath);
 
   if (module_exists('transliteration')) {
     module_load_include('inc', 'transliteration');
@@ -710,8 +710,8 @@
  */
 function _filefield_sources_form_include($module, $filepath, &$form_state) {
   $last_dot = strrpos($filepath, '.');
-  $path = substr($filepath, 0, $last_dot);
-  $extension = substr($filepath, $last_dot + 1);
+  $path = mb_substr($filepath, 0, $last_dot);
+  $extension = mb_substr($filepath, $last_dot + 1);
   form_load_include($form_state, $extension, $module, $path);
 }
 
