php将fileterms函数返回的结果变成可读的形式

yipeiwu_com5年前PHP代码库
复制代码 代码如下:

function perms_str($perms){
    if (($perms & 0xC000) == 0xC000) {
        // Socket
        $info = 's';
    } elseif (($perms & 0xA000) == 0xA000) {
        // Symbolic Link
        $info = 'l';
    } elseif (($perms & 0x8000) == 0x8000) {
        // Regular
        $info = '-';
    } elseif (($perms & 0x6000) == 0x6000) {
        // Block special
        $info = 'b';
    } elseif (($perms & 0x4000) == 0x4000) {
        // Directory
        $info = 'd';
    } elseif (($perms & 0x2000) == 0x2000) {
        // Character special
        $info = 'c';
    } elseif (($perms & 0x1000) == 0x1000) {
        // FIFO pipe
        $info = 'p';
    } else {
        // Unknown
        $info = 'u';
    }

    // Owner
    $info .= (($perms & 0x0100) ? 'r' : '-');
    $info .= (($perms & 0x0080) ? 'w' : '-');
    $info .= (($perms & 0x0040) ?
                (($perms & 0x0800) ? 's' : 'x' ) :
                (($perms & 0x0800) ? 'S' : '-'));

    // Group
    $info .= (($perms & 0x0020) ? 'r' : '-');
    $info .= (($perms & 0x0010) ? 'w' : '-');
    $info .= (($perms & 0x0008) ?
                (($perms & 0x0400) ? 's' : 'x' ) :
                (($perms & 0x0400) ? 'S' : '-'));

    // World
    $info .= (($perms & 0x0004) ? 'r' : '-');
    $info .= (($perms & 0x0002) ? 'w' : '-');
    $info .= (($perms & 0x0001) ?
                (($perms & 0x0200) ? 't' : 'x' ) :
                (($perms & 0x0200) ? 'T' : '-'));

    return $info;
}

相关文章

Zend Framework中的简单工厂模式 图文

Zend Framework中的简单工厂模式 图文

前段时间用来ZF,把他当黑盒感觉不是很好,一直有看其源码的冲动,但是。。。如果一点一点点看的话,挑战确实有些大了。某天又然后想到好久没复习设计模式了。综合一下,复习一个设计模式之后在ZF...

PHP扩展mcrypt实现的AES加密功能示例

PHP扩展mcrypt实现的AES加密功能示例

本文实例讲述了PHP扩展mcrypt实现的AES加密功能。分享给大家供大家参考,具体如下: AES(Advanced Encryption Standard,高级加密标准)是美国联邦政府...

PHP抽象类基本用法示例

本文实例讲述了PHP抽象类基本用法。分享给大家供大家参考,具体如下: <?php //抽象类像一个模板,供子类扩展(重写),抽象类里有普通方法(有方法体),也有抽象方法...

php xfocus防注入资料

这里没有太深的技术含量,我只是比较简单的谈了谈。(以下操作如无具体说 明,都是基于PHP+MySQL+Apache的情况) 在现在各种黑客横行的时候,如何实现自己ph...

PHP静态方法和静态属性及常量属性的区别与介绍

PHP中若使用static关键字来修饰属性、方法,称这些属性、方法为静态属性、静态方法。static关键字声明一个属性或方法是和类相关的,而不是和类的某个特定的实例相关,因此,这类属性或...