WordPress – Файл(/) находится вне допустимого пути(ов)

У меня есть что-то действительно странное после переноса WordPress на мой сервер:

Wed Aug 27 18:10:43 2014] [warn] [client 77.21.106.179] mod_fcgid: stderr: PHP Warning: is_dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/vhosts/xyz/:/tmp/:/usr/share/pear/) in /var/www/vhosts/xyz/xyz/wp-includes/functions.php on line 1425 

Зачем пытаться использовать WordPress для доступа к /? Любые идеи?

При вызове WordPress будет сгенерирован журнал ошибок объемом 1 ГБ ^^

Я размещаю около 100 экземпляров WP, все работают очень хорошо, ни одна установка не пытается получить доступ к «/».

РЕДАКТИРОВАТЬ

Это функция, которая терпит неудачу:

function wp_mkdir_p( $target ) {
    $wrapper = null;

    // strip the protocol
    if( wp_is_stream( $target ) ) {
        list( $wrapper, $target ) = explode( '://', $target, 2 );
    }

    // from php.net/mkdir user contributed notes
    $target = str_replace( '//', '/', $target );

    // put the wrapper back on the target
    if( $wrapper !== null ) {
        $target = $wrapper . '://' . $target;
    }

    // safe mode fails with a trailing slash under certain PHP versions.
    $target = rtrim($target, '/'); // Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
    if ( empty($target) )
        $target = '/';

    if ( file_exists( $target ) )
        return @is_dir( $target );


    // We need to find the permissions of the parent folder that exists and inherit that.
    $target_parent = dirname( $target );

    // MY MODIFICATION
    if ($target_parent = '/') {
        var_dump($target, $target_parent);
        die(debug_print_backtrace());
    }
    // MY MODIFICATION END

    while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
        $target_parent = dirname( $target_parent );
    }

    // Get the permission bits.
    $dir_perms = false;
    if ( $stat = @stat( $target_parent ) ) {
        $dir_perms = $stat['mode'] & 0007777;
    } else {
        $dir_perms = 0777;
    }

    if ( @mkdir( $target, $dir_perms, true ) ) {

        // If a umask is set that modifies $dir_perms, we'll have to re-set the $dir_perms correctly with chmod()
        if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
            $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
            for ( $i = 1; $i <= count( $folder_parts ); $i++ ) {
                @chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
            }
        }

        return true;
    }

    return false;
}

Я добавил некоторую модификацию, прочитайте комментарии, чтобы найти ее, я получаю следующий вывод:

string(95) "/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/uploads/2014/09"
string(1) "/" 
#0 wp_mkdir_p(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/uploads/2014/09) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/functions.php:1743] 
#1 wp_upload_dir() called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/other.php:360] 
#2 require(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/other.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/template.php:503] 
#3 load_template(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/other.php, ) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/template.php:477] 
#4 locate_template(Array ([0] => functions/other.php), 1, ) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/general-template.php:179] 
#5 get_template_part(functions/other) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/init.php:9] 
#6 require(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/init.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/template.php:503] 
#7 load_template(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions/init.php, ) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/template.php:477] 
#8 locate_template(Array ([0] => functions/init.php), 1, ) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-includes/general-template.php:179] 
#9 get_template_part(functions/init) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions.php:32] 
#10 include(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/themes/legatus-theme/functions.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-settings.php:328] 
#11 require_once(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-settings.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-config.php:111] 
#12 require_once(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-config.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-load.php:29] 
#13 require_once(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-load.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/wp-blog-header.php:12] 
#14 require(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-blog-header.php) called at [/var/www/vhosts/xyz/xyz.kunden.xyz/index.php:17] 

Что неверно, потому что имя_каталога(/var/www/vhosts/xyz/xyz.kunden.xyz/wp-content/uploads/2014/09) должно возвращать /var/www/vhosts/xyz/xyz.kunden.xyz/wp -content/uploads/2014 и не только /...

Любые идеи?


person lippoliv    schedule 27.08.2014    source источник
comment
Привет. Вам нужно предоставить код, который вызывается :)   -  person Mez    schedule 27.08.2014
comment
какой код? Я звоню в WordPress, неважно, главная это страница или wp-login.php ^^   -  person lippoliv    schedule 27.08.2014
comment
Я отредактировал свой код, пожалуйста, посмотрите   -  person lippoliv    schedule 03.09.2014


Ответы (1)


Дважды проверьте, что путь в $target действительно существует. Эта ошибка произошла со мной после перемещения Wordpress с одного сервера на другой с другими настройками внутренних папок.

Если путь в $target не существует на вашем сервере, вам необходимо исправить каждое его вхождение в код и в базу данных.

Чтобы безопасно исправить значения в базе данных, используйте такой инструмент, как https://github.com/interconnectit/Search-Replace-DB, который заботится о подобных словарям структурах в базе данных.

person lutuh    schedule 14.07.2015