|
Poniższa funkcja sprawdza prawa chmod danego pliku i wyświetla je w formie np. -rw-rw-rw-
001<?php
002
003 # Pobiera prawa dostępu pliku
004
005 function Uprawnienia ($plik) {
006 $perms = @fileperms($plik);
007
008 if (($perms & 0xC000) == 0xC000) {
009
010 $info = 's';
011 } elseif (($perms & 0xA000) == 0xA000) {
012
013 $info = 'l';
014 } elseif (($perms & 0x8000) == 0x8000) {
015
016 $info = '-';
017 } elseif (($perms & 0x6000) == 0x6000) {
018
019 $info = 'b';
020 } elseif (($perms & 0x4000) == 0x4000) {
021
022 $info = 'd';
023 } elseif (($perms & 0x2000) == 0x2000) {
024
025 $info = 'c';
026 } elseif (($perms & 0x1000) == 0x1000) {
027
028 $info = 'p';
029 } else {
030
031 $info = 'u';
032 }
033
034
035 $info .= (($perms & 0x0100) ? 'r' : '-');
036 $info .= (($perms & 0x0080) ? 'w' : '-');
037 $info .= (($perms & 0x0040) ?
038 (($perms & 0x0800) ? 's' : 'x' ) :
039 (($perms & 0x0800) ? 'S' : '-'));
040
041
042 $info .= (($perms & 0x0020) ? 'r' : '-');
043 $info .= (($perms & 0x0010) ? 'w' : '-');
044 $info .= (($perms & 0x0008) ?
045 (($perms & 0x0400) ? 's' : 'x' ) :
046 (($perms & 0x0400) ? 'S' : '-'));
047
048
049 $info .= (($perms & 0x0004) ? 'r' : '-');
050 $info .= (($perms & 0x0002) ? 'w' : '-');
051 $info .= (($perms & 0x0001) ?
052 (($perms & 0x0200) ? 't' : 'x' ) :
053 (($perms & 0x0200) ? 'T' : '-'));
054
055 return $info;
056 }
057
058 echo Uprawnienia('plik.php');
059
060 ?>
Pobierz Skrypt
Autor: As Prawa autorskie © . Wszelkie Prawa Zastrzeżone.
Opublikowane: 2005-11-22 (334 odsłon)  [ Wróć ] Biblioteka index |