cvs: peardoc /peardoc2/en/package/filesystem file-htaccess.xml /peardoc2/en/package/filesystem/file-htaccess addrequire.xml delrequire.xml
file-htaccess.xml intro.xml load.xml save.xml setrequire.xml

From: Date: Sat, 11 Jan 2003 20:42:10 +0000
Subject: cvs: peardoc /peardoc2/en/package/filesystem file-htaccess.xml /peardoc2/en/package/filesystem/file-htaccess addrequire.xml delrequire.xml
file-htaccess.xml intro.xml load.xml save.xml setrequire.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-249@lists.php.net to get a copy of this message
tuupola Sat Jan 11 15:42:10 2003 EDT Added files: /peardoc/peardoc2/en/package/filesystem/file-htaccess addrequire.xml delrequire.xml Modified files: /peardoc/peardoc2/en/package/filesystem file-htaccess.xml /peardoc/peardoc2/en/package/filesystem/file-htaccess file-htaccess.xml intro.xml load.xml save.xml setrequire.xml Log: * todays roundup for File_HtAccess docs

Index: peardoc/peardoc2/en/package/filesystem/file-htaccess.xml diff -u peardoc/peardoc2/en/package/filesystem/file-htaccess.xml:1.3 peardoc/peardoc2/en/package/filesystem/file-htaccess.xml:1.4 --- peardoc/peardoc2/en/package/filesystem/file-htaccess.xml:1.3 Sat Jan 11 04:52:30 2003 +++ peardoc/peardoc2/en/package/filesystem/file-htaccess.xml Sat Jan 11 15:42:09 2003 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <sect1 id="package.filesystem.file-htaccess"> <title>File_HtAccess</title> @@ -19,10 +19,9 @@ --> &package.filesystem.file-htaccess.setrequire; - - <!-- &package.filesystem.file-htaccess.addrequire; &package.filesystem.file-htaccess.delrequire; + <!-- &package.filesystem.file-htaccess.getrequire; &package.filesystem.file-htaccess.setadditional; &package.filesystem.file-htaccess.addadditional; Index: peardoc/peardoc2/en/package/filesystem/file-htaccess/file-htaccess.xml diff -u peardoc/peardoc2/en/package/filesystem/file-htaccess/file-htaccess.xml:1.3 peardoc/peardoc2/en/package/filesystem/file-htaccess/file-htaccess.xml:1.4 --- peardoc/peardoc2/en/package/filesystem/file-htaccess/file-htaccess.xml:1.3 Sat Jan 11 04:52:31 2003 +++ peardoc/peardoc2/en/package/filesystem/file-htaccess/file-htaccess.xml Sat Jan 11 15:42:09 2003 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="package.filesystem.file-htaccess.file-htaccess"> <refnamediv> @@ -8,9 +8,11 @@ <refsynopsisdiv> <funcsynopsis> +<!-- <funcsynopsisinfo> require_once 'File/HtAccess.php'; </funcsynopsisinfo> +--> <funcprototype> <funcdef>object <function>new File_HtAccess</function></funcdef> <paramdef> @@ -26,7 +28,7 @@ <refsect1 id="package.filesystem.file-htaccess.file-htaccess.desc"> &title.desc; <para> - Creates a instance of a File_HtAccess object. + Creates an instance of a <classname>File_HtAccess</classname> object. </para> </refsect1> @@ -85,7 +87,7 @@ <refsect1 id="package.filesystem.file-htaccess.file-htaccess.return"> &title.returns; <para> - <parameter>object</parameter> - instance of File_HtAccess + <parameter>object</parameter> - instance of <classname>File_HtAccess</classname> </para> </refsect1> @@ -110,13 +112,12 @@ <refsect1 id="package.filesystem.file-htaccess.setproperties.example"> &title.example; <example> - <title>Using <function>File_HtAccess::setProperties</function></title> + <title>How to create new instance of <classname>File_HtAccess</classname></title> <programlisting role="php"> <![CDATA[ <?php -require_once 'File_HtAccess.php'; - - +require_once('File_HtAccess.php'); +$fh = new File_HtAccess('.htaccess'); ?> ]]> </programlisting> Index: peardoc/peardoc2/en/package/filesystem/file-htaccess/intro.xml diff -u peardoc/peardoc2/en/package/filesystem/file-htaccess/intro.xml:1.3 peardoc/peardoc2/en/package/filesystem/file-htaccess/intro.xml:1.4 --- peardoc/peardoc2/en/package/filesystem/file-htaccess/intro.xml:1.3 Sat Jan 11 04:52:31 2003 +++ peardoc/peardoc2/en/package/filesystem/file-htaccess/intro.xml Sat Jan 11 15:42:09 2003 @@ -1,11 +1,11 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="package.filesystem.file-htaccess.intro"> <refnamediv> <refname>Introduction</refname> - <refpurpose>Create and manipulate .htaccess files</refpurpose> + <refpurpose>what are .htaccess files</refpurpose> </refnamediv> - <refsect1 id="package.filesystem.file-htaccess.intro.whatis"> + <refsect1 id="package.filesystem.file-htaccess.intro.whatis-file-htaccess"> <title>What is File_HtAccess?</title> <para> <classname>File_HtAccess</classname> provides common methods @@ -19,7 +19,129 @@ </para> </refsect1> - <refsect1 id="package.filesystem.file-htaccess.intro.usage"> + <refsect1 id="package.filesystem.file-htaccess.intro.whatis-htaccess"> + <title>What are .htaccess files?</title> + <para> + The most common and the original purpose of .htaccess files is + to create per-directory password protection of resources. With + modern webservers there is vast amount of other things .htaccess + files can do. These include: custom error pages, ip based access + control, redirecting users automatically, denying directory listing + and using different files as an index file. + </para> + <para> + <classname>File_HtAccess</classname> concentrates only + to password protection of directories, although it is possible to use + it to control other things mentioned above too. + </para> + <para> + A .htaccess file is built from the following basic directives. They + differ a bit whether youre using Basic or Digest authentication. + <table> + <title>Directives</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Directive</entry> + <entry>Purpose</entry> + </row> + </thead> + <tbody> + + <row> + <entry>AuthType</entry> + <entry> + Authentication type being used, "Basic" or "Digest". + </entry> + </row> + + <row> + <entry>AuthName</entry> + <entry> + Authentication realm or name. + </entry> + </row> + + <row> + <entry>AuthUserFile</entry> + <entry> + Full path to password file if using Basic authentication. + </entry> + </row> + + <row> + <entry>AuthGroupFile</entry> + <entry> + Full path to group file if using Basic authentication. + </entry> + </row> + + <row> + <entry>AuthDigestFile</entry> + <entry> + Full path to password file if using Digest authentication. + </entry> + </row> + + <row> + <entry>AuthDigestGroupFile</entry> + <entry> + Full path to group file if using Digest authentication. + </entry> + </row> + + <row> + <entry>Require</entry> + <entry> + Requirements which must be met to grant access. + </entry> + </row> + + </tbody> + </tgroup> + </table> + </para> + <para> + File_HtAccess provides method accessor methods with corresponding names + for each of these directives, such as getAuthType() and setAuthType(). + </para> + <para> + A typical .htaccess file looks like this: + <programlisting> +<![CDATA[ +AuthName "Protected" +AuthType Basic +AuthUserFile /usr/local/apache/conf/users.dat +require valid-user +]]> + </programlisting> + </para> + </refsect1> + + <refsect1 id="package.filesystem.file-htaccess.intro.whatis-basic"> + <title>What is Basic authentication</title> + <para> + When a client requests resource protected with basic authentication + webserver responds with a 401 Authentication Required header. When + client receives 401 header it asks the user for username and password. + If authentication succeeds, the protected resource will be sent to + the client. Otherwise the access will be denied. + </para> + </refsect1> + + <refsect1 id="package.filesystem.file-htaccess.intro.whatis-digest"> + <title>What is Digest authentication</title> + <para> + Even though the passwords are stored encrypted on serverside they are + sent cleartext between client and server when using Basic authentication. + With Digest authentication the passwords are never sent cleartext but as + a MD5 digest instead. The caveat is, most browsers do not support Digest + authentication. + </para> + </refsect1> + +<!-- + <refsect1 id="package.filesystem.file-htaccess.intro.usage"> <title>Example usage</title> <refsect2 id="package.filesystem.file-htaccess.intro.usage.example1"> @@ -79,8 +201,8 @@ </para> </refsect2> - </refsect1> +--> </refentry> <!-- Keep this comment at the end of the file Index: peardoc/peardoc2/en/package/filesystem/file-htaccess/load.xml diff -u peardoc/peardoc2/en/package/filesystem/file-htaccess/load.xml:1.4 peardoc/peardoc2/en/package/filesystem/file-htaccess/load.xml:1.5 --- peardoc/peardoc2/en/package/filesystem/file-htaccess/load.xml:1.4 Sat Jan 11 04:52:31 2003 +++ peardoc/peardoc2/en/package/filesystem/file-htaccess/load.xml Sat Jan 11 15:42:09 2003 @@ -1,16 +1,18 @@ -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <refentry id="package.filesystem.file-htaccess.load"> <refnamediv> <refname>File_HtAccess::load()</refname> - <refpurpose>load the .htaccess file</refpurpose> + <refpurpose>load the contents of existing .htaccess file</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> +<!-- <funcsynopsisinfo> require_once 'File/HtAccess.php'; </funcsynopsisinfo> +--> <funcprototype> <funcdef>mixed <function>File_HtAccess::load</function></funcdef> <paramdef> @@ -53,7 +55,16 @@ <programlisting role="php"> <![CDATA[ <?php -require_once 'File_HtAccess.php'; +require_once('File_HtAccess.php'); + +$fh = new File_HtAccess('.htaccess'); +$status = $fh->load(); + +if (PEAR::isError($fh)) { + // handle errors +} else { + // continue processing +} ?> ]]> Index: peardoc/peardoc2/en/package/filesystem/file-htaccess/save.xml diff -u peardoc/peardoc2/en/package/filesystem/file-htaccess/save.xml:1.2 peardoc/peardoc2/en/package/filesystem/file-htaccess/save.xml:1.3 --- peardoc/peardoc2/en/package/filesystem/file-htaccess/save.xml:1.2 Fri Jan 10 12:51:37 2003 +++ peardoc/peardoc2/en/package/filesystem/file-htaccess/save.xml Sat Jan 11 15:42:09 2003 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.filesystem.file-htaccess.save"> <refnamediv> @@ -8,9 +8,11 @@ <refsynopsisdiv> <funcsynopsis> +<!-- <funcsynopsisinfo> require_once 'File/HtAccess.php'; </funcsynopsisinfo> +--> <funcprototype> <funcdef>mixed <function>File_HtAccesss:save</function></funcdef> <paramdef> @@ -54,10 +56,25 @@ <programlisting role="php"> <![CDATA[ <?php -require_once 'File_HtAccess.php'; - - -?> +require_once('File_HtAccess.php'); + +/* create a new .htaccess file with given parameters */ +$params['authname']      = 'Private'; +$params['authtype']      = 'Basic'; +$params['authuserfile']  = '/path/to/.htpasswd'; +$params['authgroupfile'] = '/path/to/.htgroup'; +$params['require']       = array('group', 'admins'); + +$fh = new File_HtAccess('.htaccess', $params); +$status = $fh->save(); + +if (PEAR::isError($status)) { + // handle errors +} else { + // continue processing +} + +?> ]]> </programlisting> </example> Index: peardoc/peardoc2/en/package/filesystem/file-htaccess/setrequire.xml diff -u peardoc/peardoc2/en/package/filesystem/file-htaccess/setrequire.xml:1.2 peardoc/peardoc2/en/package/filesystem/file-htaccess/setrequire.xml:1.3 --- peardoc/peardoc2/en/package/filesystem/file-htaccess/setrequire.xml:1.2 Sat Jan 11 04:52:31 2003 +++ peardoc/peardoc2/en/package/filesystem/file-htaccess/setrequire.xml Sat Jan 11 15:42:09 2003 @@ -7,9 +7,11 @@ <refsynopsisdiv> <funcsynopsis> +<!-- <funcsynopsisinfo> require_once 'File_HtAccess.php'; </funcsynopsisinfo> +--> <funcprototype> <funcdef>void <function>File_HtAccess::setRequire</function></funcdef> <paramdef> @@ -26,7 +28,7 @@ value. If you need to add a value (user) to require use <function>File_HtAccess::addRequire</function> instead. Using this method you can control which users will be able to access - the protected folders. + the protected resources. </para> </refsect1> <refsect1 id="package.filesystem.file-htaccess.setrequire.parameter"> @@ -89,8 +91,25 @@ <programlisting role="php"> <![CDATA[ <?php -require_once 'File_HtAccess.php'; +require_once('File_HtAccess.php'); + +/* let any valid user access the resource */ +$fh = new File_HtAccess('.htaccess'); +$fh->load(); +$fh->setRequire('valid-user'); +$fh->save(); + +/* let user tuupola or panula access the resource */ +$fh = new File_HtAccess('.htaccess'); +$fh->load(); +$fh->setRequire(array('user', 'tuupola', 'panula');); +$fh->save(); +/* let anyone from group admins to access the resource */ +$fh = new File_HtAccess('.htaccess'); +$fh->load(); +$fh->setRequire(array('group', 'admins');); +$fh->save(); ?> ]]> Index: peardoc/peardoc2/en/package/filesystem/file-htaccess/addrequire.xml +++ peardoc/peardoc2/en/package/filesystem/file-htaccess/addrequire.xml <refentry id="package.filesystem.file-htaccess.addrequire"> <refnamediv> <refname>File_HtAccess::addRequire()</refname> <refpurpose>add a value into require property</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <!-- <funcsynopsisinfo> require_once 'File_HtAccess.php'; </funcsynopsisinfo> --> <funcprototype> <funcdef>void <function>File_HtAccess::addRequire</function></funcdef> <paramdef> string <parameter>$require</parameter> </paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.filesystem.file-htaccess.addrequire.desc"> &title.desc; <para> Adds a value (user) into require property. Using this method you can control which users will be able to access the protected resources. </para> </refsect1> <refsect1 id="package.filesystem.file-htaccess.addrequire.parameter"> &title.param; <para> <itemizedlist> <listitem> <para> <parameter>string $require</parameter> - value (user) to be added to require property. </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1 id="package.filesystem.file-htaccess.addrequire.return"> &title.returns; <para> void </para> </refsect1> <refsect1 id="package.filesystem.file.file-htaccess.addrequire.note"> &title.note; &note.notstatic; </refsect1> <refsect1 id="package.filesystem.file.file-htaccess.addrequire.see"> &title.see; <para> <simplelist> <member> <link linkend="package.filesystem.file-htaccess.setrequire"> <function>File_HtAccess::setRequire</function> </link>< </member> <member> <link linkend="package.filesystem.file-htaccess.delrequire"> <function>File_HtAccess::delRequire</function> </link>< </member> <member> <link linkend="package.filesystem.file-htaccess.getrequire"> <function>File_HtAccess::getRequire</function> </link>< </member> </simplelist> </para> </refsect1> <refsect1 id="package.filesystem.file-htaccess.addrequire.example"> &title.example; <example> <title>Using <function>File_HtAccess::addRequire</function></title> <programlisting role="php"> <![CDATA[ <?php require_once('File_HtAccess.php'); /* add user tuupola to list of users to be granted access */ $fh = new File_HtAccess('.htaccess'); $fh->load(); $fh->addRequire('tuupola'); $fh->save(); ?> ]]> </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/peardoc2/en/package/filesystem/file-htaccess/delrequire.xml +++ peardoc/peardoc2/en/package/filesystem/file-htaccess/delrequire.xml <refentry id="package.filesystem.file-htaccess.delrequire"> <refnamediv> <refname>File_HtAccess::delrequire()</refname> <refpurpose>remove a value from require property</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <!-- <funcsynopsisinfo> require_once 'File_HtAccess.php'; </funcsynopsisinfo> --> <funcprototype> <funcdef>void <function>File_HtAccess::delRequire</function></funcdef> <paramdef> string <parameter>$require</parameter> </paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.filesystem.file-htaccess.delrequire.desc"> &title.desc; <para> Remove a value (user) from require property. Using this method you can control which users will be able to access the protected resources. </para> </refsect1> <refsect1 id="package.filesystem.file-htaccess.delrequire.parameter"> &title.param; <para> <itemizedlist> <listitem> <para> <parameter>string $require</parameter> - value (user) to be added to require property. </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1 id="package.filesystem.file-htaccess.delrequire.return"> &title.returns; <para> void </para> </refsect1> <refsect1 id="package.filesystem.file.file-htaccess.delrequire.note"> &title.note; &note.notstatic; </refsect1> <refsect1 id="package.filesystem.file.file-htaccess.delrequire.see"> &title.see; <para> <simplelist> <member> <link linkend="package.filesystem.file-htaccess.setrequire"> <function>File_HtAccess::setRequire</function> </link>< </member> <member> <link linkend="package.filesystem.file-htaccess.addrequire"> <function>File_HtAccess::addRequire</function> </link>< </member> <member> <link linkend="package.filesystem.file-htaccess.getrequire"> <function>File_HtAccess::getRequire</function> </link>< </member> </simplelist> </para> </refsect1> <refsect1 id="package.filesystem.file-htaccess.delrequire.example"> &title.example; <example> <title>Using <function>File_HtAccess::delRequire</function></title> <programlisting role="php"> <![CDATA[ <?php require_once('File_HtAccess.php'); /* remove user viemero from list of users to be granted access */ $fh = new File_HtAccess('.htaccess'); $fh->load(); $fh->delRequire('viemero'); $fh->save(); ?> ]]> </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.pear.doc (#249) next »