• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question PHP Warning: file_exists(): open_basedir restriction in effect.

Anders Johansson

New Pleskian
PHP Warning: file_exists(): open_basedir restriction in effect. File(//?#) is not within the allowed path(s): (/var/www/vhosts/mydomain.com/:/tmp/:/var/www/vhosts/mydomain.com/:/tmp:/tmp/:/var/www/vhosts/staging1.mydomain.com/:/tmp) in /var/www/vhosts/mydomain.com/staging1.mydomain.com/wp-content/plugins/wp-job-manager/wp-job-manager-template.php on line 835

So I found some threads here and elsewhere but cant seem to solve it.
I am on the staging1 environment and trying to solve this.
Changed open base dir and added the last 2 paths .
How to add "File(//?#)" path correctly? please help
 
The errors from line 835:

```

/**
* Displays the company logo.
*
* @since 1.0.0
* @param string $size (default: 'full').
* @param mixed $default (default: null).1
* @param int|WP_Post $post (default: null).
*/
function the_company_logo( $size = 'thumbnail', $default = null, $post = null ) {
$logo = get_the_company_logo( $post, $size );

if ( has_post_thumbnail( $post ) ) {
echo '<img class="company_logo" src="' . esc_url( $logo ) . '" alt="' . esc_attr( get_the_company_name( $post ) ) . '" />';

// Before 1.24.0, logo URLs were stored in post meta.
} elseif ( ! empty( $logo ) && ( strstr( $logo, 'http' ) || file_exists( $logo ) ) ) {
if ( 'full' !== $size ) {
$logo = job_manager_get_resized_image( $logo, $size );
}
echo '<img class="company_logo" src="' . esc_url( $logo ) . '" alt="' . esc_attr( get_the_company_name( $post ) ) . '" />';
} elseif ( $default ) {
echo '<img class="company_logo" src="' . esc_url( $default ) . '" alt="' . esc_attr( get_the_company_name( $post ) ) . '" />';
} else {
echo '<img class="company_logo" src="' . esc_url( apply_filters( 'job_manager_default_company_logo', JOB_MANAGER_PLUGIN_URL . '/assets/images/company.png' ) ) . '" alt="' . esc_attr( get_the_company_name( $post ) ) . '" />';
}
}

```

also error from log

19-Aug-2021 15:42:16 UTC] PHP Fatal error: Uncaught ValueError: Path cannot be empty in /var/www/vhosts/mydomain.com/httpdocs/wp-content/plugins/wp-job-manager/wp-job-manager-template.php:27
Stack trace:
#0 /var/www/vhosts/mydomain.com/httpdocs/wp-content/plugins/wp-job-manager-resumes/includes/class-wp-resume-manager-apply.php(110): get_job_manager_template()
#1 /var/www/vhosts/mydomain.com/httpdocs/wp-includes/class-wp-hook.php(303): WP_Resume_Manager_Apply->apply_with_resume()
#2 /var/www/vhosts/mydomain.com/httpdocs/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
#3 /var/www/vhosts/mydomain.com/httpdocs/wp-includes/plugin.php(470): WP_Hook->do_action()
#4 /var/www/vhosts/mydomain.com/httpdocs/wp-content/plugins/wp-job-manager/templates/job-application.php(31): do_action()
#5 /var/www/vhosts/mydomain.com/httpdocs/wp-content/plugins/wp-job-manager/wp-job-manager-template.php(27): include('...')
#6 /var/www/vhosts/mydomain.com/httpdocs/wp-content/themes/whereuare/single-job_listing.php(69): get_job_manager_template()
#7 /var/www/vhosts/mydomain.com/httpdocs/wp-includes/template-loader.php(106): include('...')
#8 /var/www/vhosts/mydomain.com/httpdocs/wp-blog-header.php(19): require_once('...')
#9 /var/www/vhosts/mydomain.com/httpdocs/index.php(17): require('...')
#10 {main}
thrown in /var/www/vhosts/mydomain.com/httpdocs/wp-content/plugins/wp-job-manager/wp-job-manager-template.php on line 27

which is following code:

```

/**
* Gets and includes template files.
*
* @since 1.0.0
* @param mixed $template_name
* @param array $args (default: array()).
* @param string $template_path (default: '').
* @param string $default_path (default: '').
*/
function get_job_manager_template( $template_name, $args = [], $template_path = 'job_manager', $default_path = '' ) {
if ( $args && is_array( $args ) ) {
// phpcs:ignore WordPress.PHP.DontExtract.extract_extract -- Please, forgive us.
extract( $args );
}
include locate_job_manager_template( $template_name, $template_path, $default_path );
}

```
 
reseted to default open_basedir
error [19-Aug-2021 15:42:19 UTC] PHP Warning: file_exists(): open_basedir restriction in effect. File(//?#) is not within the allowed path(s): (/var/www/vhosts/mydomain.com/:/tmp/) in /var/www/vhosts/mydomain.com/httpdocs/wp-content/plugins/wp-job-manager/wp-job-manager-template.php on line 835
 
The file must be located inside the webspace subscription path. Your template or script tries to access a file that is outside your own webspace subscription path (outside /var/www/vhosts/mydomain.com). This won't work. The solution is not to extend the open_base_dir setting, but to correct the path configuration of the website, so that it only uses files that are inside the subscription.
 
Back
Top