• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP fileperms函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中fileperms函数的典型用法代码示例。如果您正苦于以下问题:PHP fileperms函数的具体用法?PHP fileperms怎么用?PHP fileperms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fileperms函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testChmod

 /**
  *
  */
 public function testChmod()
 {
     $cache = new FileAdapter(self::$dir, new NoneSerializer(), 0777);
     $cache->set('item', 'content');
     $perms = fileperms(self::$dir . '/' . md5('item'));
     $this->assertEquals('0777', substr(sprintf('%o', $perms), -4));
 }
开发者ID:genkgo,项目名称:cache,代码行数:10,代码来源:FileAdapterTest.php


示例2: writeFile

 /**
  * Записать файл
  * @param $name
  * @param $content
  * @throws \Exception
  */
 public function writeFile($name, $content)
 {
     // Проыеряем, что название не пустое
     if (empty($name)) {
         return;
     }
     // Проверяем существование файла
     $file_path = $this->get('kernel')->getRootDir() . $this->web_dir . $name;
     if (!file_exists($file_path)) {
         try {
             touch($file_path);
         } catch (\Exception $e) {
             throw new \Exception('Не удалось создать файл ' . $name);
         }
     }
     // Проверяем права
     $file_perms = fileperms($file_path);
     if ($file_perms & 0777 !== 0666) {
         try {
             chmod($file_path, '0666');
         } catch (\Exception $e) {
             throw new \Exception('Не удалось отредактировать права на файл ' . $name);
         }
     }
     // Записываем содержимое
     try {
         file_put_contents($file_path, $content, LOCK_EX);
     } catch (\Exception $e) {
         throw new \Exception('Не удалось отредактировать файл ' . $name);
     }
 }
开发者ID:it-blaster,项目名称:seo-bundle,代码行数:37,代码来源:SeoFileAdminController.php


示例3: ETCoreStart

 /**
  *	声明模板用法
  */
 function ETCoreStart($set = array('ID' => '1', 'TplType' => 'htm', 'CacheDir' => 'cache', 'TemplateDir' => 'template', 'AutoImage' => 'on', 'LangDir' => 'language', 'Language' => 'default', 'Copyright' => 'off', 'MemCache' => ''))
 {
     $this->TplID = (defined('TemplateID') ? TemplateID : ((int) @$set['ID'] <= 1 ? 1 : (int) $set['ID'])) . '_';
     $this->CacheDir = (defined('NewCache') ? NewCache : (trim($set['CacheDir']) != '' ? $set['CacheDir'] : 'cache')) . '/';
     $this->TemplateDir = (defined('NewTemplate') ? NewTemplate : (trim($set['TemplateDir']) != '' ? $set['TemplateDir'] : 'template')) . '/';
     $this->Ext = @$set['TplType'] != '' ? $set['TplType'] : 'htm';
     $this->AutoImage = @$set['AutoImage'] == 'off' ? 0 : 1;
     $this->Copyright = @$set['Copyright'] == 'off' ? 0 : 1;
     $this->Server = is_array($GLOBALS['_SERVER']) ? $GLOBALS['_SERVER'] : $_SERVER;
     $this->version = trim($_GET['EaseTemplateVer']) ? die('Ease Templae E3!') : '';
     //载入语言文件
     $this->LangDir = (defined('LangDir') ? LangDir : (@$set['LangDir'] != 'language' && @$set['LangDir'] ? $set['LangDir'] : 'language')) . '/';
     if (is_dir($this->LangDir)) {
         $this->Language = defined('Language') ? Language : ($set['Language'] != 'default' && $set['Language'] ? $set['Language'] : 'default');
         if (@is_file($this->LangDir . $this->Language . '.php')) {
             $lang = array();
             @(include_once $this->LangDir . $this->Language . '.php');
             $this->LangData = $lang;
         }
     } else {
         $this->Language = 'default';
     }
     //缓存目录检测以及运行模式
     if (@ereg(':', $set['MemCache'])) {
         $this->RunType = 'MemCache';
         $memset = explode(":", $set['MemCache']);
         $this->Emc = memcache_connect($memset[0], $memset[1]) or die("Could not connect!");
     } else {
         $this->RunType = @substr(@sprintf('%o', @fileperms($this->CacheDir)), -3) == 777 && is_dir($this->CacheDir) ? 'Cache' : 'Replace';
     }
     $CompileBasic = array('/(\\{\\s*|<!--\\s*)inc_php:([a-zA-Z0-9_\\[\\]\\.\\,\\/\\?\\=\\#\\:\\;\\-\\|\\^]{5,200})(\\s*\\}|\\s*-->)/eis', '/<!--\\s*DEL\\s*-->/is', '/<!--\\s*IF(\\[|\\()(.+?)(\\]|\\))\\s*-->/is', '/<!--\\s*ELSEIF(\\[|\\()(.+?)(\\]|\\))\\s*-->/is', '/<!--\\s*ELSE\\s*-->/is', '/<!--\\s*END\\s*-->/is', '/<!--\\s*([a-zA-Z0-9_\\$\\[\\]\'\\"]{2,60})\\s*(AS|as)\\s*(.+?)\\s*-->/', '/<!--\\s*while\\:\\s*(.+?)\\s*-->/is', '/(\\{\\s*|<!--\\s*)lang\\:(.+?)(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)row\\:(.+?)(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)color\\:\\s*([\\#0-9A-Za-z]+\\,[\\#0-9A-Za-z]+)(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)dir\\:([^\\{\\}]{1,100})(\\s*\\}|\\s*-->)/eis', '/(\\{\\s*|<!--\\s*)run\\:(\\}|\\s*-->)\\s*(.+?)\\s*(\\{|<!--\\s*)\\/run(\\s*\\}|\\s*-->)/is', '/(\\{\\s*|<!--\\s*)run\\:(.+?)(\\s*\\}|\\s*-->)/is', '/\\{([a-zA-Z0-9_\'\\"\\[\\]\\$]{1,100})\\}/');
     $this->Compile = is_array($this->Compile) ? array_merge($this->Compile, $CompileBasic) : $CompileBasic;
     $AnalysisBasic = array('$this->inc_php("\\2")', '";if($ET_Del==true){echo"', '";if(\\2){echo"', '";}elseif(\\2){echo"', '";}else{echo"', '";}echo"', '";\\$_i=0;foreach((array)\\1 AS \\3){\\$_i++;echo"', '";\\$_i=0;while(\\1){\\$_i++;echo"', '$this->lang("\\2")', '$this->Row("\\2")', '$this->Color("\\2")', '$this->Dirs("\\2")', '";\\3;echo"', '";\\2;echo"', '";echo \\$\\1;echo"');
     $this->Analysis = is_array($this->Analysis) ? array_merge($this->Analysis, $AnalysisBasic) : $AnalysisBasic;
 }
开发者ID:anLl,项目名称:Apply2,代码行数:38,代码来源:template.core.php


示例4: copy

 /**
  * Copies a file.
  *
  * If the target file is older than the origin file, it's always overwritten.
  * If the target file is newer, it is overwritten only when the
  * $overwriteNewerFiles option is set to true.
  *
  * @param string $originFile          The original filename
  * @param string $targetFile          The target filename
  * @param bool   $overwriteNewerFiles If true, target files newer than origin files are overwritten
  *
  * @throws FileNotFoundException When originFile doesn't exist
  * @throws IOException           When copy fails
  */
 public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
 {
     if (stream_is_local($originFile) && !is_file($originFile)) {
         throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
     }
     $this->mkdir(dirname($targetFile));
     $doCopy = true;
     if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
         $doCopy = filemtime($originFile) > filemtime($targetFile);
     }
     if ($doCopy) {
         // https://bugs.php.net/bug.php?id=64634
         if (false === ($source = @fopen($originFile, 'r'))) {
             throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
         }
         // Stream context created to allow files overwrite when using FTP stream wrapper - disabled by default
         if (false === ($target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true)))))) {
             throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
         }
         $bytesCopied = stream_copy_to_stream($source, $target);
         fclose($source);
         fclose($target);
         unset($source, $target);
         if (!is_file($targetFile)) {
             throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
         }
         // Like `cp`, preserve executable permission bits
         @chmod($targetFile, fileperms($targetFile) | fileperms($originFile) & 0111);
         if (stream_is_local($originFile) && $bytesCopied !== ($bytesOrigin = filesize($originFile))) {
             throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile);
         }
     }
 }
开发者ID:WilBenShu,项目名称:digital_pilot,代码行数:47,代码来源:Filesystem.php


示例5: loadFromFile

 /**
  * Load properties from a given file properties
  * 
  * @param $file string The filename to scan
  * @param $contents boolean Load the contents
  * @param $loadId boolean Load id from database
  * @return boolean result
  */
 function loadFromFile($file, $contents = false, $loadId = false)
 {
     if (!JFile::exists($file) && !JFolder::exists($file . DS)) {
         return false;
     }
     $info = @stat($file);
     $this->scandate = $this->_db->getNullDate();
     $this->filename = basename($file);
     $this->fullpath = $file;
     $this->permission = fileperms($file) & 0777;
     $this->size = filesize($file);
     $ctime =& JFactory::getDate($info['ctime']);
     $mtime =& JFactory::getDate($info['mtime']);
     $this->ctime = $ctime->toMySQL();
     $this->mtime = $mtime->toMySQL();
     $this->uid = $info['uid'];
     $this->gid = $info['gid'];
     $this->type = '';
     if (is_file($file)) {
         $this->type = 'file';
         $this->hash_md = md5_file($file);
         if ($contents) {
             $f = new JD_File($file);
             $this->contents = $f->read();
         }
     } elseif (is_dir($file)) {
         $this->type = 'dir';
     }
     if ($loadId) {
         $this->_db->setQuery('SELECT id FROM #__jdefender_filesystem WHERE fullpath = ' . $this->fullpath . ' LIMIT 1');
         $this->id = $this->_db->loadResult();
     }
     return true;
 }
开发者ID:alphashuro,项目名称:audeprac,代码行数:42,代码来源:filesystem.php


示例6: setFileInformations

 /**
  * collect all fileinformations of given file and
  * save them to the global fileinformation array
  *
  * @param string $file
  * @return boolean is valid file?
  */
 protected function setFileInformations($file)
 {
     $this->fileInfo = array();
     // reset previously information to have a cleaned object
     $this->file = $file instanceof \TYPO3\CMS\Core\Resource\File ? $file : NULL;
     if (is_string($file) && !empty($file)) {
         $this->fileInfo = TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
         $this->fileInfo['mtime'] = filemtime($file);
         $this->fileInfo['atime'] = fileatime($file);
         $this->fileInfo['owner'] = fileowner($file);
         $this->fileInfo['group'] = filegroup($file);
         $this->fileInfo['size'] = filesize($file);
         $this->fileInfo['type'] = filetype($file);
         $this->fileInfo['perms'] = fileperms($file);
         $this->fileInfo['is_dir'] = is_dir($file);
         $this->fileInfo['is_file'] = is_file($file);
         $this->fileInfo['is_link'] = is_link($file);
         $this->fileInfo['is_readable'] = is_readable($file);
         $this->fileInfo['is_uploaded'] = is_uploaded_file($file);
         $this->fileInfo['is_writeable'] = is_writeable($file);
     }
     if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
         $pathInfo = \TYPO3\CMS\Core\Utility\PathUtility::pathinfo($file->getName());
         $this->fileInfo = array('file' => $file->getName(), 'filebody' => $file->getNameWithoutExtension(), 'fileext' => $file->getExtension(), 'realFileext' => $pathInfo['extension'], 'atime' => $file->getCreationTime(), 'mtime' => $file->getModificationTime(), 'owner' => '', 'group' => '', 'size' => $file->getSize(), 'type' => 'file', 'perms' => '', 'is_dir' => FALSE, 'is_file' => $file->getStorage()->getDriverType() === 'Local' ? is_file($file->getForLocalProcessing(FALSE)) : TRUE, 'is_link' => $file->getStorage()->getDriverType() === 'Local' ? is_link($file->getForLocalProcessing(FALSE)) : FALSE, 'is_readable' => TRUE, 'is_uploaded' => FALSE, 'is_writeable' => FALSE);
     }
     return $this->fileInfo !== array();
 }
开发者ID:mneuhaus,项目名称:ke_search,代码行数:34,代码来源:class.tx_kesearch_lib_fileinfo.php


示例7: setFolderPermissions

 /**
  * Set globally writable permissions on the "tmp" and "logs" directory.
  *
  * This is not the most secure default, but it gets people up and running quickly.
  *
  * @param string $dir The application's root directory.
  * @param \Composer\IO\IOInterface $io IO interface to write to console.
  *
  * @return void
  */
 public static function setFolderPermissions($dir, $io)
 {
     // Change the permissions on a path and output the results.
     $changePerms = function ($path, $perms, $io) {
         // Get current permissions in decimal format so we can bitmask it.
         $currentPerms = octdec(substr(sprintf('%o', fileperms($path)), -4));
         if (($currentPerms & $perms) == $perms) {
             return;
         }
         $res = chmod($path, $currentPerms | $perms);
         if ($res) {
             $io->write('Permissions set on ' . $path);
         } else {
             $io->write('Failed to set permissions on ' . $path);
         }
     };
     $walker = function ($dir, $perms, $io) use(&$walker, $changePerms) {
         $files = array_diff(scandir($dir), ['.', '..']);
         foreach ($files as $file) {
             $path = $dir . '/' . $file;
             if (!is_dir($path)) {
                 continue;
             }
             $changePerms($path, $perms, $io);
             $walker($path, $perms, $io);
         }
     };
     $worldWritable = bindec('0000000111');
     $walker($dir . '/tmp', $worldWritable, $io);
     $changePerms($dir . '/tmp', $worldWritable, $io);
     $changePerms($dir . '/logs', $worldWritable, $io);
 }
开发者ID:Adnan0703,项目名称:Xeta,代码行数:42,代码来源:Installer.php


示例8: relocateShortcut

 private static function relocateShortcut()
 {
     $WshShell = new COM('WScript.Shell');
     $desktop = $WshShell->SpecialFolders('Desktop');
     $startmenu = $WshShell->SpecialFolders('Programs');
     $startmenu .= DIRECTORY_SEPARATOR . 'XAMPP for Windows';
     $links = array();
     $links[realpath($desktop . DIRECTORY_SEPARATOR . 'XAMPP Control Panel.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'Description' => 'XAMPP Control Panel');
     $links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Control Panel.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'Description' => 'XAMPP Control Panel');
     $links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Setup.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_setup.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Setup');
     $links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Shell.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_shell.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Shell');
     $links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Uninstall.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'uninstall_xampp.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Uninstall');
     foreach ($links as $shortcut => $value) {
         if (is_int($shortcut)) {
             continue;
         }
         $oldfileperm = fileperms($shortcut);
         if (!chmod($shortcut, 0666) && !is_writable($shortcut)) {
             throw new XAMPPException('File \'' . $shortcut . '\' is not writable.');
         }
         $ShellLink = $WshShell->CreateShortcut($shortcut);
         $ShellLink->TargetPath = $value['TargetPath'];
         $ShellLink->WorkingDirectory = $value['WorkingDirectory'];
         $ShellLink->WindowStyle = $value['WindowStyle'];
         $ShellLink->IconLocation = $value['IconLocation'];
         $ShellLink->Description = $value['Description'];
         $ShellLink->Save();
         $ShellLink = null;
         chmod($shortcut, $oldfileperm);
     }
     $WshShell = null;
     return;
 }
开发者ID:TheSkyNet,项目名称:railoapacheportable,代码行数:33,代码来源:package__xampp.php


示例9: addHeader

 public function addHeader($size, $name)
 {
     $size = decoct($size);
     $info = stat($this->path);
     $uid = sprintf('%6s ', decoct($info[4]));
     $gid = sprintf('%6s ', decoct($info[5]));
     $mode = sprintf('%6s ', decoct(fileperms($this->path)));
     $mtime = sprintf('%11s', decoct(filemtime($this->path)));
     // Compute the "before" & "after" checksum chunks.
     $before = pack('a100a8a8a8a12A12', $name, $mode, $uid, $gid, $size, $mtime);
     $after = pack('a1a100a6a2a32a32a8a8a155a12', '', '', '', '', '', '', '', '', '', '');
     // Compute checksum
     $checksum = 0;
     for ($i = 0; $i < 148; $i++) {
         $checksum += ord(substr($before, $i, 1));
     }
     for ($i = 148; $i < 156; $i++) {
         $checksum += ord(' ');
     }
     for ($i = 156, $j = 0; $i < 512; $i++, $j++) {
         $checksum += ord(substr($after, $j, 1));
     }
     $checksum = sprintf('%6s ', decoct($checksum));
     $checksum = pack('a8', $checksum);
     $this->write($before . $checksum . $after);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:26,代码来源:tar.php


示例10: addFileInfo

 private function addFileInfo($filename)
 {
     $this->total[] = "#name:" . $filename . "\n";
     $this->total[] = "#perm:" . fileperms($filename) . "\n";
     $this->total[] = "#size:" . filesize($filename) . "\n";
     $this->total[] = "\n!#start#!\n";
 }
开发者ID:rgantt,项目名称:japha,代码行数:7,代码来源:Inflate.php


示例11: permission

function permission($filename)
{
    $perms = fileperms($filename);
    if (($perms & 0xc000) == 0xc000) {
        $info = 's';
    } elseif (($perms & 0xa000) == 0xa000) {
        $info = 'l';
    } elseif (($perms & 0x8000) == 0x8000) {
        $info = '-';
    } elseif (($perms & 0x6000) == 0x6000) {
        $info = 'b';
    } elseif (($perms & 0x4000) == 0x4000) {
        $info = 'd';
    } elseif (($perms & 0x2000) == 0x2000) {
        $info = 'c';
    } elseif (($perms & 0x1000) == 0x1000) {
        $info = 'p';
    } else {
        $info = 'u';
    }
    $info .= $perms & 0x100 ? 'r' : '-';
    $info .= $perms & 0x80 ? 'w' : '-';
    $info .= $perms & 0x40 ? $perms & 0x800 ? 's' : 'x' : ($perms & 0x800 ? 'S' : '-');
    $info .= $perms & 0x20 ? 'r' : '-';
    $info .= $perms & 0x10 ? 'w' : '-';
    $info .= $perms & 0x8 ? $perms & 0x400 ? 's' : 'x' : ($perms & 0x400 ? 'S' : '-');
    $info .= $perms & 0x4 ? 'r' : '-';
    $info .= $perms & 0x2 ? 'w' : '-';
    $info .= $perms & 0x1 ? $perms & 0x200 ? 't' : 'x' : ($perms & 0x200 ? 'T' : '-');
    return $info;
}
开发者ID:royalswe,项目名称:yas26,代码行数:31,代码来源:filelist.inc.php


示例12: birth_setSave

function birth_setSave($arr, $modId)
{
    global $DMC, $DBPrefix;
    for ($i = 1; $i <= count($arr) / 3; $i++) {
        setPlugSet($modId, "birthTitle{$i}", $arr["birthTitle{$i}"]);
        setPlugSet($modId, "birthDate{$i}", $arr["birthDate{$i}"]);
        setPlugSet($modId, "textColor{$i}", $arr["textColor{$i}"]);
    }
    //Check file visit access
    $xmlFile = "../plugins/birth/birth.xml";
    $os = strtoupper(substr(PHP_OS, 0, 3));
    $fileAccess = intval(substr(sprintf('%o', fileperms($xmlFile)), -4));
    if ($fileAccess < 777 and $os != "WIN") {
        $ActionMessage = "<b><font color='red'>birth.xml => Please change the CHMOD as 777.</font></b>";
    } else {
        $filecontent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
        $filecontent .= "<birth>\n";
        for ($i = 0; $i < count($arr) / 3; $i++) {
            $num = $i + 1;
            if ($arr["birthTitle{$num}"]) {
                $filecontent .= "\t<item>\n";
                $filecontent .= "\t\t<birthTitle>" . $arr["birthTitle{$num}"] . "</birthTitle>\n";
                $filecontent .= "\t\t<birthDate>" . $arr["birthDate{$num}"] . "</birthDate>\n";
                $filecontent .= "\t\t<textColor>" . $arr["textColor{$num}"] . "</textColor>\n";
                $filecontent .= "\t</item>\n";
            }
        }
        $filecontent .= "</birth>\n";
        $fp = fopen($xmlFile, "wb");
        @fwrite($fp, $filecontent);
        @fclose($fp);
        $ActionMessage = "";
    }
    return $ActionMessage;
}
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:35,代码来源:setting.php


示例13: get

 /**
  * @param string $type
  * @return KalturaTypeReflector
  */
 static function get($type)
 {
     if (!self::$_enabled) {
         return new KalturaTypeReflector($type);
     }
     if (!array_key_exists($type, self::$_loadedTypeReflectors)) {
         $cachedDir = KAutoloader::buildPath(kConf::get("cache_root_path"), "api_v3", "typeReflector");
         if (!is_dir($cachedDir)) {
             mkdir($cachedDir);
             chmod($cachedDir, 0755);
         }
         $cachedFilePath = $cachedDir . DIRECTORY_SEPARATOR . $type . ".cache";
         $typeReflector = null;
         if (file_exists($cachedFilePath)) {
             $cachedData = file_get_contents($cachedFilePath);
             $typeReflector = unserialize($cachedData);
         }
         if (!$typeReflector) {
             $typeReflector = new KalturaTypeReflector($type);
             $cachedData = serialize($typeReflector);
             $bytesWritten = kFile::safeFilePutContents($cachedFilePath, $cachedData);
             if (!$bytesWritten) {
                 $folderPermission = substr(decoct(fileperms(dirname($cachedFilePath))), 2);
                 error_log("Kaltura type reflector could not be saved to path [{$cachedFilePath}] type [{$type}] folder permisisons [{$folderPermission}]");
             }
         }
         self::$_loadedTypeReflectors[$type] = $typeReflector;
     }
     return self::$_loadedTypeReflectors[$type];
 }
开发者ID:DBezemer,项目名称:server,代码行数:34,代码来源:KalturaTypeReflectorCacher.php


示例14: nfo_setSave

function nfo_setSave($arr, $modId)
{
    global $DMC, $DBPrefix;
    $fieldList = array("bgcolor", "txtcolor", "imgtype");
    for ($i = 0; $i < count($fieldList); $i++) {
        $name = $fieldList[$i];
        setPlugSet($modId, $name, $arr[$name]);
    }
    //Check file visit access
    $configFile = "../plugins/nfo/nfo_config.php";
    $os = strtoupper(substr(PHP_OS, 0, 3));
    $fileAccess = intval(substr(sprintf('%o', fileperms($configFile)), -4));
    if ($fileAccess < 777 and $os != "WIN") {
        $ActionMessage = "<b><font color='red'>nfo_config.php => Please change the CHMOD as 777.</font></b>";
    } else {
        $fp = @fopen($configFile, 'r');
        $filecontent = @fread($fp, @filesize($configFile));
        @fclose($fp);
        $filecontent = preg_replace("/[\$]imgtype\\s*\\=\\s*[\"'].*?[\"']/is", "\$imgtype = \"" . $arr['imgtype'] . "\"", $filecontent);
        $filecontent = preg_replace("/[\$]bgcolor\\s*\\=\\s*[\"'].*?[\"']/is", "\$bgcolor = \"" . $arr['bgcolor'] . "\"", $filecontent);
        $filecontent = preg_replace("/[\$]txtcolor\\s*\\=\\s*[\"'].*?[\"']/is", "\$txtcolor = \"" . $arr['txtcolor'] . "\"", $filecontent);
        $fp = @fopen($configFile, 'wbt');
        @fwrite($fp, trim($filecontent));
        @fclose($fp);
        $ActionMessage = "";
    }
    return $ActionMessage;
}
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:28,代码来源:setting.php


示例15: testRecursiveChmod

 /**
  * Tests the recursively changing of filemodes.
  */
 public function testRecursiveChmod()
 {
     # Compile a directory name
     $dir = sys_get_temp_dir() . '/wadelib';
     # Delete directory from earlier runs:
     FileSystemManager::rrmdir($dir);
     # Create a directory
     $rc = mkdir($dir);
     # Create a bunch of subfiles
     $files = array();
     for ($i = 0; $i < 3; $i++) {
         $files[] = tempnam($dir, 'wl');
     }
     # Switch modes
     $newperm = 0777;
     $rc = WadeLib::changeFilemode($dir, $newperm, true);
     $this->assertEquals(true, $rc);
     # Clear file status cache.
     # Otherwise, during some testruns
     # problems may occur with invalid
     # file-permissions cached by PHP:
     clearstatcache();
     # Loop through created files to check filemode
     foreach ($files as $f) {
         $rc = fileperms($f);
         echo $f, PHP_EOL;
         printf('Expecting %s, got %s' . PHP_EOL, substr(sprintf('%o', $newperm), -4), substr(sprintf('%o', $rc), -4));
         $this->assertEquals(substr(sprintf('%o', $newperm), -4), substr(sprintf('%o', $rc), -4));
         # Unlink files
         unlink($f);
     }
 }
开发者ID:codeless,项目名称:wadelib,代码行数:35,代码来源:WadeLibTest.php


示例16: checkPermissions

/**
 * Checks permissions of files and directories.
 * @param sFileName - file's name.
 */
function checkPermissions($sFileName)
{
    $sPermissions = "";
    $sFilePath = trim($sFileName);
    clearstatcache();
    if (!file_exists($sFilePath)) {
        $sResult = "";
    } else {
        clearstatcache();
        $iPermissions = fileperms($sFilePath);
        for ($i = 0, $offset = 0; $i < 3; $i++, $offset += 3) {
            $iPerm = 0;
            for ($j = 0; $j < 3; $j++) {
                $iPermissions >> $j + $offset & 1 ? $iPerm += pow(2, $j) : "";
            }
            $sPermissions = $iPerm . $sPermissions;
        }
        $sResult = $sPermissions;
    }
    $sResult = "";
    $bDir = is_dir($sFilePath);
    if (is_readable($sFilePath)) {
        $sResult = $bDir ? "755" : "644";
    }
    if (is_writable($sFilePath)) {
        $sResult = $bDir ? "777" : "666";
    }
    if (!$bDir && is_executable($sFilePath)) {
        $sResult = "777";
    }
    return $sResult;
}
开发者ID:Gotgot59,项目名称:dolphin.pro,代码行数:36,代码来源:functions.inc.php


示例17: read

 public function read($absolutePath, $relativePath, $sortName = 'filename', $sortOrder = SORT_ASC)
 {
     for ($list = array(), $handle = opendir($absolutePath); FALSE !== ($file = readdir($handle));) {
         if ($file != '.' && $file != '..' && $file != 'webint' && file_exists($path = $absolutePath . DIRECTORY_SEPARATOR . $file)) {
             $entry = array('filename' => $file, 'permission' => substr(sprintf('%o', fileperms($path)), -4));
             $entry['modtime'] = filemtime($path);
             do {
                 if (!is_dir($path)) {
                     $entry['size'] = filesize($path);
                     $entry['mode'] = 'file';
                     $entry['dirpath'] = $relativePath . DIRECTORY_SEPARATOR . $file;
                     break;
                 } else {
                     $entry['size'] = '';
                     $entry['mode'] = 'folder';
                     $entry['dirpath'] = urlencode($relativePath . DIRECTORY_SEPARATOR . $file);
                     break;
                 }
             } while (FALSE);
             $list[] = $entry;
         }
     }
     closedir($handle);
     $list = $this->sortArray($list, 'mode', 'desc', $sortName, $sortOrder);
     return $list;
 }
开发者ID:zinzia,项目名称:kapalonline,代码行数:26,代码来源:Filesystem.php


示例18: show_perms

function show_perms($file)
{
    $in_Perms = fileperms($file);
    $sP = "<b>";
    if ($in_Perms & 0x1000) {
        $sP .= 'p';
    } elseif ($in_Perms & 0x2000) {
        $sP .= 'c';
    } elseif ($in_Perms & 0x4000) {
        $sP .= 'd';
    } elseif ($in_Perms & 0x6000) {
        $sP .= 'b';
    } elseif ($in_Perms & 0x8000) {
        $sP .= '&minus;';
    } elseif ($in_Perms & 0xa000) {
        $sP .= 'l';
    } elseif ($in_Perms & 0xc000) {
        $sP .= 's';
    } else {
        $sP .= 'u';
    }
    // UNKNOWN
    $sP .= "</b>";
    // owner - group - others
    $sP .= ($in_Perms & 0x100 ? 'r' : '&minus;') . ($in_Perms & 0x80 ? 'w' : '&minus;') . ($in_Perms & 0x40 ? $in_Perms & 0x800 ? 's' : 'x' : ($in_Perms & 0x800 ? 'S' : '&minus;'));
    $sP .= ($in_Perms & 0x20 ? 'r' : '&minus;') . ($in_Perms & 0x10 ? 'w' : '&minus;') . ($in_Perms & 0x8 ? $in_Perms & 0x400 ? 's' : 'x' : ($in_Perms & 0x400 ? 'S' : '&minus;'));
    $sP .= ($in_Perms & 0x4 ? 'r' : '&minus;') . ($in_Perms & 0x2 ? 'w' : '&minus;') . ($in_Perms & 0x1 ? $in_Perms & 0x200 ? 't' : 'x' : ($in_Perms & 0x200 ? 'T' : '&minus;'));
    return $sP;
}
开发者ID:Parashutik,项目名称:ReloadCMS,代码行数:29,代码来源:rights_test.php


示例19: testSetUnixPermissions

 /**
  * Verify that the Unix permissions can be set.
  *
  * @covers \KHerGe\File\permissions
  */
 public function testSetUnixPermissions()
 {
     $file = tempnam(sys_get_temp_dir(), 'fm-');
     $permissions = 0777;
     self::assertEquals($permissions, permissions(__FILE__, $permissions), 'The Unix permissions were not returned.');
     self::assertNotEquals($permissions, fileperms($file) & $permissions, 'The Unix permissions were not set.');
 }
开发者ID:kherge,项目名称:file-manager,代码行数:12,代码来源:functionsTest.php


示例20: copy

 /**
  * Wraps copy and is able to copy directories
  * @param string $from Source location
  * @param string $to   Target location
  * @throws \Exception
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @return bool
  */
 public function copy($from, $to)
 {
     if ($this->isFile($from)) {
         if (@copy($from, $to)) {
             return true;
         }
         throw new \Exception("Could not copy file '{$from}' to '{$to}'");
     }
     if ($this->isDirectory($from)) {
         $returnValue = true;
         // Does the "to" directory need to be created
         $makingDirectory = !$this->isDirectory($to);
         if ($makingDirectory) {
             if (!$this->makeDirectory($to, 0777, true)) {
                 throw new \Exception("Could not create directory '{$to}'");
             }
         }
         // Step through the directory
         $fromDirectory = opendir($from);
         while (false !== ($file = readdir($fromDirectory))) {
             if ($file != '.' && $file != '..') {
                 $returnValue = $returnValue && $this->copy("{$from}/{$file}", "{$to}/{$file}");
             }
         }
         closedir($fromDirectory);
         // Fix permissions
         if ($makingDirectory) {
             $returnValue = $returnValue && $this->changeMode($to, fileperms($from));
         }
         return $returnValue;
     }
     throw new \Exception("'{$from}' does not exist or is not accessible");
 }
开发者ID:TheFoundryVisionmongers,项目名称:Masonry-Module-FileSystem,代码行数:41,代码来源:FileSystem.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP files函数代码示例发布时间:2022-05-15
下一篇:
PHP filepath_is_safe函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap