cvs: peardoc /en/packages/authentication auth.xml
| From: | Martin Jansen | Date: | Sun, 10 Feb 2002 11:06:44 +0000 |
| Subject: | cvs: peardoc /en/packages/authentication auth.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2357@lists.php.net to get a copy of this message | ||
mj Sun Feb 10 06:06:44 2002 EDT
Modified files:
/peardoc/en/packages/authentication auth.xml
Log:
* Add another usage example
* Add documentation for setSessionname() and setExpire()
Index: peardoc/en/packages/authentication/auth.xml
diff -u peardoc/en/packages/authentication/auth.xml:1.3
peardoc/en/packages/authentication/auth.xml:1.4
--- peardoc/en/packages/authentication/auth.xml:1.3 Sat Jan 26 08:00:55 2002
+++ peardoc/en/packages/authentication/auth.xml Sun Feb 10 06:06:43 2002
@@ -107,10 +107,73 @@
</para>
</warning>
<para>
+ <example>
+ <title>Using optional authentication</title>
+ <programlisting role="php">
+ <![CDATA[
+require_once "Auth/Auth.php";
+
+function loginFunction()
+{
+ /**
+ * Change the HTML output so that it fits to your
+ * application.
+ */
+ echo "<form method=\"post\" action=\"" .
$_SERVER['PHP_SELF'] . "?login=1\">";
+ echo "<input type=\"text\" name=\"username\">";
+ echo "<input type=\"password\" name=\"password\">";
+ echo "<input type=\"submit\">";
+ echo "</form>";
+}
+
+if ($_GET['login'] == 1) {
+ $optional = true;
+} else {
+ $optional = false;
+}
+
+$dsn = "mysql://user:password@localhost/database";
+
+$a = new Auth("DB", $dsn, "loginFunction", $optional);
+
+$a->start();
+
+echo "Everybody can see this text!<br />";
+
+if (!isset($_GET['login'])) {
+ echo "<a href=\"test.php?login=1\">Click here to log in</a>\n";
+}
+
+if ($a->getAuth()) {
+ echo "One can only see this if he is logged in!";
+}
+ ]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ This is a pretty nice example for the optional login feature: The
+ last parameter <parameter>$optional</parameter> can be either
+ true or false. If it is false, the login form is not shown and
+ the user, who visits the page, only sees the text "Everybody can
+ see this text!". If he clicks on the link above this text, he
+ gets the same page but with the GET parameter "login=1". Now he
+ can enter his login information in the login formular. If he has
+ been successfully logged in, he can then see the text "Everbody
+ can see this text!" and the text "One can only see this if he is
+ logged in!".
+ </para>
+ <para>
In the following passages you get to know some detailed
information about the functions of PEAR::Auth.
</para>
+ <para>
+ This feature is useful e.g. for portal sites which provide some
+ services to all users that visit the sites and some services only
+ to users that are logged in.
+ </para>
</refsect1>
+
<refsect1 id="packages.Auth.Auth.Auth">
<title>Auth::Auth</title>
@@ -121,17 +184,19 @@
<paramdef>string <parameter>storageDriver</parameter></paramdef>
<paramdef>mixed <parameter>options</parameter></paramdef>
<paramdef>string <parameter>loginFunction</parameter></paramdef>
+ <paramdef>bool
<parameter><optional>showLogin</optional></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Constructor for the authencation system. The first parameter is
- the name of the storage driver, that should be used. The second
+ the name of the storage driver that should be used. The second
parameter can either be a string containing some login information
or an array containing a bunch of options for the storage driver.
</para>
<para>
- The third parameter is the name of user-defined function, that
- prints the login screen.
+ The third parameter is the name of user-defined function that
+ prints the login screen. The last parameter can be either true
+ or false and defines if the login is optional or not.
</para>
<example>
@@ -210,4 +275,46 @@
For usage example, see <function>Auth::Auth</function>.
</para>
</refsect1>
+
+ <refsect1 id="packages.Auth.Auth.setSessionname">
+ <title>Auth::setSessionname</title>
+
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>void <function>setSessionname</function></funcdef>
+ <paramdef>string <parameter>name</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <simpara>
+ This function can set a customized name for the session that is
+ created during the login process. The default for this session
+ name is "PHPSESSID". You have to use <function>setSessionname</function>,
+ if you are running two or more different applications with Auth
+ on the same domain. If you don't use this function, a user who has
+ once logged in at one of the applications can also use the other
+ applications without logging in again!
+ </simpara>
+ </refsect1>
+
+ <refsect1 id="packages.Auth.Auth.setExpire">
+ <title>Auth::setExpire</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>void <function>setExpire</function></funcdef>
+ <paramdef>int <parameter>time</parameter></paramdef>
+ <paramdef>bool
<parameter><optional>add</optional></parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+
+ <simpara>
+ With this function you can set the maximum expire time that is
+ used by auth to a new value. The first parameter <parameter>$time
+ </parameter> defines the number of seconds. If the second
+ parameter <parameter>$add</parameter> is true, the first parameter
+ is added on the existing expire time. If it is false (which is
+ also the default value), the first parameter replaces the existing
+ time.
+ </simpara>
+ </refsect1>
+
</refentry>