phpbar.de logo

Mailinglisten-Archive

[php] Apache user?

[php] Apache user?

-mat- filid brandy brandy_(at)_klammeraffe.org
Wed, 7 Jul 1999 14:51:34 +0200


Slan,

Hier ist meine Loesung: (danke fuer den `id` Tip)

<?php
/*
\\
\\  -mat- filid brandy, brandy_(at)_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  = _(at)_Fileperms( $filename );
  $owner  = _(at)_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; }
  }
}
?>

Slainte agus saol agat,
	-mat-

--
-mat- filid brandy   brandy_(at)_klammeraffe.org   MB210-RIPE
http://www.klammeraffe.org/~brandy/info/
PGP PUBLIC KEY CODE NUMBER E4118785
PGP fingerprint = D8102D77AA40514A6F610671297C5AB4


php::bar PHP Wiki   -   Listenarchive