php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40288 how to check if a file is includable or not includable
Submitted: 2007-01-30 13:48 UTC Modified: 2012-08-14 11:57 UTC
Votes:10
Avg. Score:4.8 ± 0.4
Reproduced:8 of 8 (100.0%)
Same Version:0 (0.0%)
Same OS:3 (37.5%)
From: ironoxid at libero dot it Assigned: cweiske (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.0 OS: irrelevant
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ironoxid at libero dot it
New email:
PHP Version: OS:

 

 [2007-01-30 13:48 UTC] ironoxid at libero dot it
Description:
------------
Actually there is a difference between read and include authorization: I can't read a file, but, at the same time, I can include it (read about safe_mode_include_dir).
Unfortunately there is no way to check if I can include a file or not.
Actually the only way to do this is perform an include, and this is not always what we want to do.

Reproduce code:
---------------
function check_plugins($pluginsFromConfig) {
  foreach($pluginsFromConfig As $filepath) {
    if(is_includable($filepath)===false) {
      trigger_error('plugin not found',E_USER_ERROR);
      exit;
    }
    else echo 'plugin -bla- -bla- exists';
  }
}

Expected result:
----------------
We expect to know if a file can be included, without include it.

Actual result:
--------------
Function is_includable doesn't exist. We tried to use file_exists, etc. but are limited by safe_mode restrictions.
Documentation say that we can use is_readable for ignore safe_mode restriction but it doesn't work and if it will work it will be logically wrong.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-14 11:57 UTC] cweiske@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: cweiske
 [2012-08-14 11:57 UTC] cweiske@php.net
stream_resolve_include_path() does what you want (from PHP 5.3.2 on).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Sep 22 13:00:01 2025 UTC