? File_HtAccess.diff Index: HtAccess.php =================================================================== RCS file: /repository/pear/File_HtAccess/HtAccess.php,v retrieving revision 1.12 diff -u -r1.12 HtAccess.php --- HtAccess.php 13 Jan 2005 22:02:55 -0000 1.12 +++ HtAccess.php 27 Apr 2006 20:06:31 -0000 @@ -424,8 +424,33 @@ $retval = true; - $str = 'AuthName ' . $this->getAuthName() . "\n"; - $str .= 'AuthType ' . $this->getAuthType() . "\n"; + $str = $this->getContent(); + + $fd = @fopen($this->getFile(), 'w'); + if ($fd) { + fwrite($fd, $str, strlen($str)); + } else { + $retval = PEAR::raiseError('Could not open ' . $this->getFile() . + ' for writing.'); + + } + + return($retval); + + } + + /** + * Returns the .htaccess File content + * + * @access public + * @return string + */ + + function getContent() { + + $str = ''; + if(''!=$this->getAuthName()) $str .= 'AuthName ' . $this->getAuthName() . "\n"; + if(''!=$this->getAuthType()) $str .= 'AuthType ' . $this->getAuthType() . "\n"; if ('basic' == strtolower($this->getAuthType())) { $str .= 'AuthUserFile ' . $this->getAuthUserFile() . "\n"; @@ -439,20 +464,10 @@ } } - $str .= 'Require ' . $this->getRequire('string') . "\n"; + if(''!=trim($this->getRequire('string'))) $str .= 'Require ' . $this->getRequire('string') . "\n"; $str .= $this->getAdditional('string') . "\n"; - $fd = @fopen($this->getFile(), 'w'); - if ($fd) { - fwrite($fd, $str, strlen($str)); - } else { - $retval = PEAR::raiseError('Could not open ' . $this->getFile() . - ' for writing.'); - - } - - return($retval); - + return($str); } }