本文整理匯總了PHP中XenForo_Helper_File::_chmodFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP XenForo_Helper_File::_chmodFile方法的具體用法?PHP XenForo_Helper_File::_chmodFile怎麽用?PHP XenForo_Helper_File::_chmodFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XenForo_Helper_File
的用法示例。
在下文中一共展示了XenForo_Helper_File::_chmodFile方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: makeWritableByFtpUser
/**
* Ensures that the specified file can be written to by the FTP user.
* This generally doesn't need to do anything if PHP is running via
* some form of suexec. It's primarily needed when running as apache.
*
* @param string $file
* @return boolean
*/
public static function makeWritableByFtpUser($file)
{
if (self::$_chmodDirectory === null) {
if (XenForo_Application::isRegistered('config')) {
$chmod = XenForo_Application::get('config')->chmodWritableValue;
if ($chmod) {
self::$_chmodDirectory = XenForo_Application::get('config')->chmodWritableValue | 0111;
self::$_chmodFile = XenForo_Application::get('config')->chmodWritableValue;
}
}
if (!self::$_chmodFile) {
$selfWritable = null;
if (PHP_SAPI == 'cli') {
$uid = false;
if (function_exists('posix_getuid')) {
$uid = @posix_getuid();
} else {
$tempFile = tempnam(self::getTempDir(), 'xf');
if ($tempFile) {
$uid = fileowner($tempFile);
@unlink($tempFile);
}
}
if ($uid !== false) {
$lock = self::getInternalDataPath() . '/install-lock.php';
if (file_exists($lock)) {
// if we're running as who created the lock file,
// then the web access is likely running with the same user
$selfWritable = $uid == fileowner($lock);
} else {
if ($uid == 0) {
// if we're root, just force w+w
$selfWritable = false;
}
}
}
}
if ($selfWritable === null) {
$selfWritable = @is_writable(__FILE__);
}
if ($selfWritable) {
// writable - probably owned by ftp user already
self::$_chmodDirectory = 0755;
self::$_chmodFile = 0644;
} else {
// not writable, so file is probably owned by "nobody", need to w+w it
self::$_chmodDirectory = 0777;
self::$_chmodFile = 0666;
}
}
}
if (@is_readable($file)) {
return @chmod($file, @is_file($file) ? self::$_chmodFile : self::$_chmodDirectory);
} else {
return false;
}
}