Hongmu Notes
Home Summary of pitfalls PHP PaTa Warning: scandir(): open_basedir restriction is in effect. The file (/www/wwwrootyiyou/) is not within the allowed path(s): (/www/wwwroot/eyoucms.yanshi.4s5.cn/: /tmp/)
Summary of pitfalls

PHP PaTa Warning: scandir(): open_basedir restriction is in effect. The file (/www/wwwrootyiyou/) is not within the allowed path(s): (/www/wwwroot/eyoucms.yanshi.4s5.cn/: /tmp/)

PHP PaTa Warning: scandir(): open_basedir restriction is in effect. The file (/www/wwwrootyiyou/) is not within the allowed path(s): (/www/wwwroot/eyoucms.yanshi.4s5.cn/: /tmp/)

This warning message is due to server configuration settings.open_basedirThe restriction limits the file system access scope of the PHP script; since your script is attempting to access a directory outside this permitted range, a warning is raised.

There are several ways to solve this problem:

  1. Modify server configuration

You can contact the server administrator to request modifications to the server.open_basedirFor configuration purposes, add the directory you wish to access to the allowed list to resolve this issue.

  1. Use other functions

scandir()The function is affected.open_basedirThe impact of restrictions; however, PHP provides other functions that can be used to retrieve files and subdirectories from a directory, such asglob()readdir()Functions. You can try using these functions as an alternative.scandir()A function to solve this problem.

  1. Skip restricted directory

You can incorporate exception handling into your code; whenscandir()When the function throws a warning, it catches the exception and skips accessing directories with restricted access. The example code is as follows:

function getDirectories($dir) {
    $directories = array();

    if (is_dir($dir)) {
        try {
            $files = scandir($dir);

            foreach ($files as $file) {
                if ($file != "." && $file != ".." && is_dir($dir . "/" . $file)) {
                    $directories[] = $file;
                }
            }
        } catch (Exception $e) {
            // 忽略访问受限目录时的警告
        }
    }

    return $directories;
}

In this example code, we usetry-catchStructure for capturingscandir()Any exception thrown by the function – if an exception occurs (e.g., when attempting to access a restricted directory) – will cause the function to skip that operation directly. This allows us to ignore the warning when accessing a restricted directory without affecting the normal execution of the program.

Please note that this method may cause certain directories to be missed, as restricted directories are not scanned. Therefore, this approach is only suitable for less critical directories and is not recommended for scenarios where all directories must be scanned.

After all that, let me briefly share my solution!

BaoTa Panel Solution

Delete the website's root directory..user.iniThis document

https://www.4s5.cn/archives/1210.html

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Browser caching increases the speed of secondary visits to your website

Browser caching increases the speed of secondary visits to your website Summary of pitfalls

Use browser caching of official words: If users will visit your website multiple times, browser caching of static resources can save users time. Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images). Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.). Normally, HTML doesn’t…
👁 202

Recommended reading

Culinary and Food Service Training School Website Template 1213

Culinary and Food Service Training School Website Template 1213 Practical Collection Yiyou template

This EyouCMS template is ideal for culinary, food service, snack preparation, and training institutions. Its food-themed design is perfect for showcasing cooking courses, snack preparation training programs, faculty expertise, and student projects. It helps food service training organizations attract learners online and enhance their brand awareness. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 34
Responsive office supplies service company website template 0350

Responsive office supplies service company website template 0350 Practical Collection Yiyou template

An eyouCMS responsive website template designed for office supplies and service companies. Its professional and practical design effectively showcases office supply products, corporate services, solutions, and brand identity. This template helps office supply businesses showcase their products online and attract corporate clients. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for YouyouCMS...
👁 46
(Adaptive Mobile Version) HTML5 Responsive Brand Innovation Design Website – pbootCMS Template; Download Source Code for Marketing Planning Company Websites – 0687

(Adaptive Mobile Version) HTML5 Responsive Brand Innovation Design Website – pbootCMS Template; Download Source Code for Marketing Planning Company Websites – 0687 Practical Collection pbootcms Template

A responsive brand innovation design and marketing strategy PbootCMS website template, compatible with both PC and WAP devices. Its creative and modern design style is ideal for showcasing brand design works, marketing strategy cases, and innovative concepts. This template helps advertising or brand strategy agencies demonstrate their expertise online and attract corporate clients. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www...
👁 40
EmpireCMS 7.5 Batch Import Plugin for TXT-format articles – supports importing up to 2,000,000 articles per day.

EmpireCMS 7.5 Batch Import Plugin for TXT-format articles – supports importing up to 2,000,000 articles per day. Practical Collection empire plugin

It sounds simple – yet it's actually quite complex! Empire CMS boasts an astonishingly high article capacity – which means some users need to import articles in bulk into Empire CMS. That's how this plugin was born! Configuration PHP code: <?php // Directory where the TXT file is stored $AddNews['target'] = 'Physical Science 16–30,000'; // Category ID $AddNews['class'] =...
👁 341
Catering Franchising Industry Website Template 1214

Catering Franchising Industry Website Template 1214 Practical Collection Yiyou template

An EyouCMS website template designed specifically for the catering franchise industry. Its modern and visually appealing design effectively showcases catering brands, franchise policies, store imagery, and success stories. This template helps catering chain brands attract franchisees online and expand their market presence. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (Eyou...
👁 64
Network Software Technology Company Website Template 0351

Network Software Technology Company Website Template 0351 Practical Collection Yiyou template

This EYO CMS template is ideal for web, software, and technology companies. Its modern, tech-oriented design effectively showcases software products, web services, technical capabilities, and corporate image. It helps technology firms present their brand online and attract business clients. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EYO CMS | EYO CMS (Eyo...
👁 45