note 1106 deleted from function.is-writeable by jimw
| From: | jimw@php.net | Date: | Thu, 20 Dec 2001 22:39:37 +0000 |
| Subject: | note 1106 deleted from function.is-writeable by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-23516@lists.php.net to get a copy of this message | ||
<PRE>
<?php
/*
\\
\\ -mat- filid brandy, brandy@ecrc.de, Cable&Wireless ECRC GmbH
\\ Wed Jul 7 14:47:43 CEST 1999
\\
\\ my_is_writeable.inc
\\ checks whether a file is writeable or not. PHP3 function is_writeable() is broken.
\\
*/
Function my_is_writeable( $filename ) {
clearstatcache();
$perms = @Fileperms( $filename );
$owner = @FileOwner( $filename );
eregi( "^uid=([0-9]*)", exec( "id"), $regs );
$apacheuid = $regs[1];
/* Hint: integers starting with '0' are octal */
$perms = 0777 & $perms;
if ( $apacheuid != $owner ) {
if ( 06 == ( 07 & $perms ) ) { return 1; } else { return 0; }
} else {
if ( 0600 == ( 0700 & $perms ) ) { return 1; } else { return 0; }
}
}
?>
</PRE>