/** * function makeExecutable * Try to make a file executable if it's not the case * On windows platform, this function always return true. * @param string $f, the full filename of the file or dir * @return boolean true on success, false on failure * @static */ function makeExecutable($f) { $f = realpath($f); if (!file_exists($f)) { return false; } if (APPLICATION_IS_WINDOWS || function_exists('is_executable') && @is_executable($f)) { return true; } elseif (!function_exists('is_executable')) { //assume we are on windows platform because this function does not exists before PHP5.0.0 (so files are always executable) return true; } else { @chmod($f, octdec(DIRS_CHMOD)); if (CMS_file::fileIsExecutable($f)) { return true; } else { @chmod($f, octdec('0775')); if (CMS_file::fileIsExecutable($f)) { return true; } else { @chmod($f, octdec('0777')); if (CMS_file::fileIsExecutable($f)) { return true; } else { return false; } } } } }