当前位置: 首页>>代码示例>>PHP>>正文


PHP XenForo_Helper_File::_chmodFile方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:65,代码来源:File.php


注:本文中的XenForo_Helper_File::_chmodFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。