function _google_tag_is_executable in GoogleTagManager 7
Same name and namespace in other branches
- 8 google_tag.module \_google_tag_is_executable()
- 7.2 google_tag.module \_google_tag_is_executable()
Determines whether a directory is searchable.
Remove this if PHP is_executable() is changed to not return FALSE simply because the URI points to a directory (not a file) in a stream wrapper other than the local file wrapper provided by PHP.
Parameters
string $uri: A directory path or stream wrapper URI.
Return value
bool Whether the directory is searchable.
3 calls to _google_tag_is_executable()
- google_tag_requirements in ./
google_tag.install - Implements hook_requirements().
- _file_prepare_directory in includes/
admin.inc - Checks that the directory exists and is writable.
- _google_tag_directory_prepare in includes/
admin.inc - Prepares directory for base or realm specific snippet files.
File
- includes/
admin.inc, line 468 - Contains the administrative page and form callbacks.
Code
function _google_tag_is_executable($uri) {
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
if ($realpath = $wrapper
->realpath($uri)) {
// The URI is a local stream wrapper.
// Use local path since PHP only checks ACLs on its local file wrapper.
// Remove OS check if PHP is_executable() is changed to not return FALSE
// simply because the URI points to a directory (not a file) on Windows.
return _google_tag_is_windows() || is_executable($realpath);
}
// The URI is a remote stream wrapper.
if (!($stat = $wrapper
->url_stat($uri, 0))) {
return FALSE;
}
if (!function_exists('posix_getuid') || !function_exists('posix_getgid')) {
// These functions are never defined on Windows and the extension that
// provides them may not be included on a Linux distribution.
// If directory is not searchable, then fault the site deployment process.
// @todo Is it worse to return true or false at this point?
return TRUE;
}
// Determine the appropriate permissions bit mask as an octal.
// The stat array is likely to have uid=gid=0 so that the mask is octal 01.
// This is true for Amazon S3 and Google Cloud Storage.
$mask = 1;
if ($stat['uid'] == posix_getuid()) {
$mask = $mask << 6;
}
elseif ($stat['gid'] == posix_getgid()) {
$mask = $mask << 3;
}
return ($stat['mode'] & $mask) != 0;
}
else {
// The URI is a local path.
return is_executable($uri);
}
}