cvs: peardoc /ja/package/authentication/auth intro.xml /ja/package/authentication/auth/auth auth.xml getauth.xml getstatus.xml setexpire.xml
setsessionname.xml start.xml
| From: | Tadashi Jokagi | Date: | Sat, 01 Nov 2003 13:54:12 +0000 |
| Subject: | cvs: peardoc /ja/package/authentication/auth intro.xml /ja/package/authentication/auth/auth auth.xml getauth.xml getstatus.xml setexpire.xml setsessionname.xml start.xml |
||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-1856@lists.php.net to get a copy of this message | ||
elf Sat Nov 1 08:54:12 2003 EDT
Added files:
/peardoc/ja/package/authentication/auth intro.xml
/peardoc/ja/package/authentication/auth/auth auth.xml getauth.xml
getstatus.xml
setexpire.xml
setsessionname.xml
start.xml
Log:
o added japanese manual.
Index: peardoc/ja/package/authentication/auth/intro.xml +++ peardoc/ja/package/authentication/auth/intro.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.7 --> <refentry id="package.authentication.auth.intro"> <refnamediv> <refname>å°å ¥</refname> <refpurpose>使ç¨ä¾</refpurpose> </refnamediv> <refsect1 id="packages.authentication.auth.intro.example"> <title>èªè¨¼ãã¥ã¼ããªã¢ã«</title> <simpara> ãã®"ç°¡æãã¥ã¼ããªã¢ã«"ã®ç®çã¯ã ç°¡åã«ä½¿ããèªè¨¼æ©æ§ã«ããã»ãã¥ã¢ãªãµã¤ããæ§ç¯ããã·ã¹ãã ã è¨å®ãããã¨ã§ãã </simpara> <para> ã»ãã¥ã¢ã¨ãããµã¤ãã®æä¸ä½ã«ã以ä¸ã®çãã³ã¼ããç½®ãã¦ã¿ã¾ãããã </para> <example> <title><classname>PEAR::Auth</classname>ã®å ¸åçãªä½¿ç¨ä¾</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'] . "\">"; echo "<input type=\"text\" name=\"username\">"; echo "<input type=\"password\" name=\"password\">"; echo "<input type=\"submit\">"; echo "</form>"; } $dsn = "mysql://user:password@localhost/database"; $a = new Auth("DB", $dsn, "loginFunction"); $a->start(); if ($a->getAuth()) { /** * The output of your site goes here. */ } ]]> </programlisting> <para> ãã®çãã³ã¼ãã¯ãèªè¨¼ã·ã¹ãã ã®ã¤ã³ã¹ã¿ã³ã¹ã使ãããã®ã§ãã </para> <para> æåã®è¡ã§ã¯ãPEARãã£ã¬ã¯ããªãããã¡ã¤ã«ãèªã¿è¾¼ãã§ãã¾ãã The first line in the above script includes the file from your PEAR directory. ããã«ã¯ãPEAR::Authãå®è¡ããéã«å¿ è¦ãªã³ã¼ããå ¨ã¦å«ã¾ãã¦ãã¾ãã It contains all the necessary code to run <classname>PEAR::Auth</classname>. ãã®å¾ããã°ã¤ã³ç»é¢ã表示ãã颿°ã1ã¤å®ç¾©ãã¾ãã ãã®é¢æ°ã¯ã ãã®ãã¼ã¸ãé²è¦§ããè ããã°ã¤ã³ãã¼ã¿ãå ¥åããããã«ä½¿ç¨ããã¾ãã ãã®é¢æ°ã® <acronym>HTML</acronym> ãã©ã¼ãããã¯èªç±ã«å¤æ´ãããã¨ãåºæ¥ã¾ãã </para> <para> <warning> <simpara> ãã®é¢æ°ã®HTMLãã©ã¼ãããã¯èªç±ã«å¤æ´ã§ãã¾ããã inputããã¯ã¹ã®nameã¯å¤æ´ãã¦ã¯ããã¾ããã ããã㯠<literal>username</literal>ããã³<literal>password</literal> ã¨ããå¿ è¦ãããã¾ãã </simpara> </warning> </para> <para> ãã°ã¤ã³ãã¼ã¿ãæ¤è¨¼ããããã«ãã¼ã¿ãã¼ã¹ã使ç¨ããããã ããã§ã夿°<varname>$dsn</varname>ã使ãã¾ãã ãã®å¤æ°ã«ã¯ã <link linkend="package.database.db">PEAR::DB</link> ã«ãããã¼ã¿ãã¼ã¹ã¨æ¥ç¶ããéã«ä½¿ç¨ãããæå¹ãªDSNæååãæå®ãã¾ãã ãã®ä»ã®ã¹ãã¬ã¼ã¸ã³ã³ããã使ç¨ãããå ´åã¯ã å¾è¿°ãã詳細ãªèª¬æãåç §ä¸ããã </para> <para> After that we create the authentication object. The first parameter defines the name of the storage container. Because we want to use a database driven storage container, we pass "DB" here. The second parameter is the connection parameter for the container driver. We use the previously defined DSN string. The third parameter is the name of our function that we defined at the beginning of the script. It prints the login form. </para> <para> Now our authentication object is initialized and we need to check if the user is logged in. This is done via the method <function>getAuth</function>. If it returns &true;, we can pass the content of our page to the user. </para> <para> <warning> <para> For now one cannot use <programlisting role="php"> <![CDATA[ $auth = new Auth(...); ]]> </programlisting> with <literal>register_globals=on</literal>, because <varname>$auth</varname> is also the name of the session variable, that is internally used by <classname>PEAR::Auth</classname>. </para> </warning> </para> </example> <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 (isset($_GET['login']) && $_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> <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 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 form. If he successfully logs in, he can then see the text "Everybody can see this text!" and the text "One can only see this if he is logged in!". </para> </example> <example> <title>Logout functionality</title> <simpara> The following example performs a <quote>logout</quote> for the current user and displays the login form again. </simpara> <programlisting role="php"> $myauth->start(); if ($_GET['action'] == "logout") { $myauth->logout(); $myauth->start(); } </programlisting> </example> <para> In the following passages we cover more detailed information about the functions of <classname>PEAR::Auth</classname>. </para> <para> This SQL statement creates a table usable under the default database authentication scheme using MySQL: </para> <programlisting role="sql"> <![CDATA[ CREATE TABLE auth ( username VARCHAR(50) default '' NOT NULL, password VARCHAR(32) default '' NOT NULL, PRIMARY KEY (username), KEY (password) ); ]]> </programlisting> <para> These are the table and field names necessary for working authentication. The password column must be at least 32 characters long because we store passwords encrypted using md5() and that is the length of the values returned by md5(). </para> </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/ja/package/authentication/auth/auth/auth.xml +++ peardoc/ja/package/authentication/auth/auth/auth.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.6 --> <refentry id="package.authentication.auth.auth.auth"> <refnamediv> <refname>Auth::Auth()</refname> <refpurpose>ã³ã³ã¹ãã©ã¯ã¿</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef><function>Auth::Auth</function></funcdef> <paramdef>string <parameter>$storageDriver = "DB"</parameter></paramdef> <paramdef>mixed <parameter>$options = ""</parameter></paramdef> <paramdef>string <parameter>$loginFunction = ""</parameter></paramdef> <paramdef>boolean <parameter><optional>$showLogin = &true;</optional></parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.auth.desc"> &title.desc; <para> èªè¨¼ã·ã¹ãã ã³ã³ã¹ãã©ã¯ã¿ã§ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.auth.parameter"> &title.param; <para> <variablelist> <varlistentry> <term> &type.string; <parameter>$storageDriver</parameter> </term> <listitem> <para> 使ç¨ãã¹ãã¹ãã¬ã¼ã¸ãã©ã¤ãã¼ã®ååã§ãã </para> </listitem> </varlistentry> <varlistentry> <term> &type.mixed; <parameter>$options</parameter> </term> <listitem> <para> ã¹ãã¬ã¼ã¸ã³ã³ããã«æ¸¡ããããªãã·ã§ã³ã§ãã </para> </listitem> </varlistentry> <varlistentry> <term> &type.string; <parameter>$loginFunction</parameter> </term> <listitem> <para> ãã°ã¤ã³ç»é¢ã表示ããã¦ã¼ã¶å®ç¾©é¢æ°ã®ååã§ãã </para> </listitem> </varlistentry> <varlistentry> <term> &type.bool; <parameter>$showLogin</parameter> </term> <listitem> <para> ãã°ã¤ã³ããªãã·ã§ã³ãã©ããå®ç¾©ãã¾ãã </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 id="package.authentication.auth.auth.auth.note"> &title.note; ¬e.notstatic; </refsect1> <refsect1 id="package.authentication.auth.auth.auth.see"> &title.see; <para> <link linkend="package.authentication.auth.intro-storage"> Introduction - The storage drivers </link> </para> </refsect1> <refsect1 id="package.authentication.auth.auth.auth.example"> &title.example; <example> <title>ç°ãªãDBãã©ã¡ã¼ã¿ã®ä½¿ç¨æ³</title> <programlisting role="php"> <![CDATA[ require_once "Auth/Auth.php"; function myOutput($username, $status) { ... /** See example 1 for the full listing */ } $params = array( "dsn" => "mysql://martin:test@localhost/auth", "table" => "myAuth", "usernamecol" => "myUserColumn", "passwordcol" => "myPasswordColumn" ); $a = new Auth("DB", $params, "myOutput"); $a->start(); if ($a->getAuth()) { echo "You have been authenticated successfully."; } ]]>; </programlisting> </example> <para> ãã®ä¾ã¯ãããªããã©ã®ããã«ãã¼ã¿ãã¼ã¹ãã¼ãã«ã ããã³ã«ã©ã åã®ä»£æ¿åãæå®åºæ¥ãã示ãã¾ãã ãã®ä¾ã§ã¯ããã¼ãã«myAuthã使ç¨ãã¾ãã ãã£ã¼ã«ãmyUserColumnããã®ã¦ã¼ã¶ã¼åã ããã³ãã£ã¼ã«ãmyPasswordColumnããã®ãã¹ã¯ã¼ãã鏿ãã¾ãã ãã®ãã£ã¼ã«ãã®ããã©ã«ãauthã»usernameã¨passwordã§ãã </para> <para> This feature is necessary if you want to use PEAR::Auth with a database layout that is different from the one, PEAR::Auth uses by default. </para> </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/ja/package/authentication/auth/auth/getauth.xml +++ peardoc/ja/package/authentication/auth/auth/getauth.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.3 --> <refentry id="package.authentication.auth.auth.getauth"> <refnamediv> <refname>Auth::getAuth()</refname> <refpurpose>ã¦ã¼ã¶ãèªè¨¼æ¸ã¿ãã©ãã調ã¹ã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>boolean <function>Auth_HTTP::getAuth</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.getauth.desc"> &title.desc; <para> ã¦ã¼ã¶ãèªè¨¼æ¸ã¿ãã©ãã調ã¹ã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.getauth.return"> &title.returns; <para> <parameter>boolean</parameter> - ã¦ã¼ã¶ãæ¢ã«èªè¨¼æ¸ã¿ãªãã°ã颿°ã¯&true;ãè¿ãã¾ãã ããã§ãªããã°ã&false;ãè¿ãã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.getauth.note"> &title.note; ¬e.notstatic; </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/ja/package/authentication/auth/auth/getstatus.xml +++ peardoc/ja/package/authentication/auth/auth/getstatus.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.3 --> <refentry id="package.authentication.auth.auth.getstatus"> <refnamediv> <refname>Auth::getStatus()</refname> <refpurpose>ç¾å¨ã®èªè¨¼ç¶æ³ã®æ å ±ãè¿ã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>string <function>Auth::getStatus</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.getstatus.desc"> &title.desc; <para> ãã®é¢æ°ã¯ãPEAR::Authã®ç¾å¨ã®ã¹ãã¼ã¿ã¹ãè¿ãã¾ãã è¿ãå¤ã¯ãPEAR Authã«ããå®ç¾©ããã宿°ã§ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.getstatus.return"> &title.returns; <para> <parameter>string</parameter> - å¤ã¯ <constant>AUTH_IDLED</constant>, <constant>AUTH_EXPIRED</constant>, <constant>AUTH_EXPIRED</constant> ã«ãªãã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.getstatus.note"> &title.note; ¬e.notstatic; </refsect1> <refsect1 id="package.authentication.auth.auth.getstatus.see"> &title.see; <para> <link linkend="package.authentication.auth.constants"> PEAR::Auth constants overview</link> </para> </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/ja/package/authentication/auth/auth/setexpire.xml +++ peardoc/ja/package/authentication/auth/auth/setexpire.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.3 --> <refentry id="package.authentication.auth.auth.setexpire"> <refnamediv> <refname>Auth::setExpire()</refname> <refpurpose>èªè¨¼æå¹æéãè¨å®ãã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>void <function>Auth::setExpire</function></funcdef> <paramdef>integer <parameter>$time</parameter></paramdef> <paramdef>boolean <parameter><optional>$add = &false;</optional></parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.setexpire.desc"> &title.desc; <para> ãã®é¢æ°ã«ããã èªè¨¼ã§ä½¿ç¨ãããæå¤§æå¹æéãæ°ããå¤ã«è¨å®ãããã¨ãã§ãã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.setexpire.parameter"> &title.param; <para> <variablelist> <varlistentry> <term> &type.int; <parameter>$time</parameter> </term> <listitem> <para> ç§åä½ã®èªè¨¼æå¹æé </para> </listitem> </varlistentry> <varlistentry> <term> &type.bool; <parameter>$add</parameter> </term> <listitem> <para> ãã&true;<parameter>$time</parameter>ã®å ´åã æå¹æéæéã«è¿½å ãã¾ãã ãã&false;ã®å ´åã¯ãæ¢åã®å¤ã«ç½®ãæãããã¾ãã </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 id="package.authentication.auth.auth.setexpire.note"> &title.note; ¬e.notstatic; </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/ja/package/authentication/auth/auth/setsessionname.xml +++ peardoc/ja/package/authentication/auth/auth/setsessionname.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.2 --> <refentry id="package.authentication.auth.auth.setsessionname"> <refnamediv> <refname>Auth::setSessionname()</refname> <refpurpose>ã«ã¹ã¿ã ã»ãã·ã§ã³åãè¨å®ãã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>void <function>Auth::setSessionname</function></funcdef> <paramdef>string <parameter>name</parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.setsessionname.desc"> &title.desc; <para> ãã®é¢æ°ã¯ã ãã°ã¤ã³æã«ä½æãããã»ãã·ã§ã³åã ã«ã¹ã¿ãã¤ãºãã¦è¨å®ãããã¨ãã§ãã¾ãã ãã®ã»ãã·ã§ã³åã®ããã©ã«ãã¯ã"PHPSESSID"ã§ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.setsessionname.parameter"> &title.param; <para> <variablelist> <varlistentry> <term> &type.string; <parameter>$name</parameter> </term> <listitem> <para> 使ç¨ããã»ãã·ã§ã³å </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 id="package.authentication.auth.auth.setsessionname.note"> &title.note; ¬e.notstatic; <para> åããã¡ã¤ã³ã§Authãç¨ããã¢ããªã±ã¼ã·ã§ã³ãè¤æ°å®è¡ããå ´åã¯ã <function>setSessionname</function>ã使ç¨ããå¿ è¦ãããã¾ãã ãã®é¢æ°ã使ç¨ããªãå ´åã ã¢ããªã±ã¼ã·ã§ã³ã®ä¸ã¤ã«ä¸åº¦ãã°ã¤ã³ããã¦ã¼ã¶ã¯ã å度ãã°ã¤ã³ãããã¨ãªãã«ä»ã®ã¢ããªã±ã¼ã·ã§ã³ã 使ç¨ãããã¨ãã§ãã¦ãã¾ãã¾ã! </para> </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/ja/package/authentication/auth/auth/start.xml +++ peardoc/ja/package/authentication/auth/auth/start.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.2 --> <refentry id="package.authentication.auth.auth.start"> <refnamediv> <refname>Auth::start()</refname> <refpurpose>èªè¨¼ãéå§ãã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>void <function>Auth::start</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.start.desc"> &title.desc; <para> èªè¨¼ããã»ã¹ãéå§ãã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.start.note"> &title.note; ¬e.notstatic; </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/ja/package/authentication/auth/intro.xml +++ peardoc/ja/package/authentication/auth/intro.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.7 --> <refentry id="package.authentication.auth.intro"> <refnamediv> <refname>å°å ¥</refname> <refpurpose>使ç¨ä¾</refpurpose> </refnamediv> <refsect1 id="packages.authentication.auth.intro.example"> <title>èªè¨¼ãã¥ã¼ããªã¢ã«</title> <simpara> ãã®"ç°¡æãã¥ã¼ããªã¢ã«"ã®ç®çã¯ã ç°¡åã«ä½¿ããèªè¨¼æ©æ§ã«ããã»ãã¥ã¢ãªãµã¤ããæ§ç¯ããã·ã¹ãã ã è¨å®ãããã¨ã§ãã </simpara> <para> ã»ãã¥ã¢ã¨ãããµã¤ãã®æä¸ä½ã«ã以ä¸ã®çãã³ã¼ããç½®ãã¦ã¿ã¾ãããã </para> <example> <title><classname>PEAR::Auth</classname>ã®å ¸åçãªä½¿ç¨ä¾</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'] . "\">"; echo "<input type=\"text\" name=\"username\">"; echo "<input type=\"password\" name=\"password\">"; echo "<input type=\"submit\">"; echo "</form>"; } $dsn = "mysql://user:password@localhost/database"; $a = new Auth("DB", $dsn, "loginFunction"); $a->start(); if ($a->getAuth()) { /** * The output of your site goes here. */ } ]]> </programlisting> <para> ãã®çãã³ã¼ãã¯ãèªè¨¼ã·ã¹ãã ã®ã¤ã³ã¹ã¿ã³ã¹ã使ãããã®ã§ãã </para> <para> æåã®è¡ã§ã¯ãPEARãã£ã¬ã¯ããªãããã¡ã¤ã«ãèªã¿è¾¼ãã§ãã¾ãã The first line in the above script includes the file from your PEAR directory. ããã«ã¯ãPEAR::Authãå®è¡ããéã«å¿ è¦ãªã³ã¼ããå ¨ã¦å«ã¾ãã¦ãã¾ãã It contains all the necessary code to run <classname>PEAR::Auth</classname>. ãã®å¾ããã°ã¤ã³ç»é¢ã表示ãã颿°ã1ã¤å®ç¾©ãã¾ãã ãã®é¢æ°ã¯ã ãã®ãã¼ã¸ãé²è¦§ããè ããã°ã¤ã³ãã¼ã¿ãå ¥åããããã«ä½¿ç¨ããã¾ãã ãã®é¢æ°ã® <acronym>HTML</acronym> ãã©ã¼ãããã¯èªç±ã«å¤æ´ãããã¨ãåºæ¥ã¾ãã </para> <para> <warning> <simpara> ãã®é¢æ°ã®HTMLãã©ã¼ãããã¯èªç±ã«å¤æ´ã§ãã¾ããã inputããã¯ã¹ã®nameã¯å¤æ´ãã¦ã¯ããã¾ããã ããã㯠<literal>username</literal>ããã³<literal>password</literal> ã¨ããå¿ è¦ãããã¾ãã </simpara> </warning> </para> <para> ãã°ã¤ã³ãã¼ã¿ãæ¤è¨¼ããããã«ãã¼ã¿ãã¼ã¹ã使ç¨ããããã ããã§ã夿°<varname>$dsn</varname>ã使ãã¾ãã ãã®å¤æ°ã«ã¯ã <link linkend="package.database.db">PEAR::DB</link> ã«ãããã¼ã¿ãã¼ã¹ã¨æ¥ç¶ããéã«ä½¿ç¨ãããæå¹ãªDSNæååãæå®ãã¾ãã ãã®ä»ã®ã¹ãã¬ã¼ã¸ã³ã³ããã使ç¨ãããå ´åã¯ã å¾è¿°ãã詳細ãªèª¬æãåç §ä¸ããã </para> <para> After that we create the authentication object. The first parameter defines the name of the storage container. Because we want to use a database driven storage container, we pass "DB" here. The second parameter is the connection parameter for the container driver. We use the previously defined DSN string. The third parameter is the name of our function that we defined at the beginning of the script. It prints the login form. </para> <para> Now our authentication object is initialized and we need to check if the user is logged in. This is done via the method <function>getAuth</function>. If it returns &true;, we can pass the content of our page to the user. </para> <para> <warning> <para> For now one cannot use <programlisting role="php"> <![CDATA[ $auth = new Auth(...); ]]> </programlisting> with <literal>register_globals=on</literal>, because <varname>$auth</varname> is also the name of the session variable, that is internally used by <classname>PEAR::Auth</classname>. </para> </warning> </para> </example> <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 (isset($_GET['login']) && $_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> <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 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 form. If he successfully logs in, he can then see the text "Everybody can see this text!" and the text "One can only see this if he is logged in!". </para> </example> <example> <title>Logout functionality</title> <simpara> The following example performs a <quote>logout</quote> for the current user and displays the login form again. </simpara> <programlisting role="php"> $myauth->start(); if ($_GET['action'] == "logout") { $myauth->logout(); $myauth->start(); } </programlisting> </example> <para> In the following passages we cover more detailed information about the functions of <classname>PEAR::Auth</classname>. </para> <para> This SQL statement creates a table usable under the default database authentication scheme using MySQL: </para> <programlisting role="sql"> <![CDATA[ CREATE TABLE auth ( username VARCHAR(50) default '' NOT NULL, password VARCHAR(32) default '' NOT NULL, PRIMARY KEY (username), KEY (password) ); ]]> </programlisting> <para> These are the table and field names necessary for working authentication. The password column must be at least 32 characters long because we store passwords encrypted using md5() and that is the length of the values returned by md5(). </para> </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/ja/package/authentication/auth/auth/auth.xml +++ peardoc/ja/package/authentication/auth/auth/auth.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.6 --> <refentry id="package.authentication.auth.auth.auth"> <refnamediv> <refname>Auth::Auth()</refname> <refpurpose>ã³ã³ã¹ãã©ã¯ã¿</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef><function>Auth::Auth</function></funcdef> <paramdef>string <parameter>$storageDriver = "DB"</parameter></paramdef> <paramdef>mixed <parameter>$options = ""</parameter></paramdef> <paramdef>string <parameter>$loginFunction = ""</parameter></paramdef> <paramdef>boolean <parameter><optional>$showLogin = &true;</optional></parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.auth.desc"> &title.desc; <para> èªè¨¼ã·ã¹ãã ã³ã³ã¹ãã©ã¯ã¿ã§ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.auth.parameter"> &title.param; <para> <variablelist> <varlistentry> <term> &type.string; <parameter>$storageDriver</parameter> </term> <listitem> <para> 使ç¨ãã¹ãã¹ãã¬ã¼ã¸ãã©ã¤ãã¼ã®ååã§ãã </para> </listitem> </varlistentry> <varlistentry> <term> &type.mixed; <parameter>$options</parameter> </term> <listitem> <para> ã¹ãã¬ã¼ã¸ã³ã³ããã«æ¸¡ããããªãã·ã§ã³ã§ãã </para> </listitem> </varlistentry> <varlistentry> <term> &type.string; <parameter>$loginFunction</parameter> </term> <listitem> <para> ãã°ã¤ã³ç»é¢ã表示ããã¦ã¼ã¶å®ç¾©é¢æ°ã®ååã§ãã </para> </listitem> </varlistentry> <varlistentry> <term> &type.bool; <parameter>$showLogin</parameter> </term> <listitem> <para> ãã°ã¤ã³ããªãã·ã§ã³ãã©ããå®ç¾©ãã¾ãã </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 id="package.authentication.auth.auth.auth.note"> &title.note; ¬e.notstatic; </refsect1> <refsect1 id="package.authentication.auth.auth.auth.see"> &title.see; <para> <link linkend="package.authentication.auth.intro-storage"> Introduction - The storage drivers </link> </para> </refsect1> <refsect1 id="package.authentication.auth.auth.auth.example"> &title.example; <example> <title>ç°ãªãDBãã©ã¡ã¼ã¿ã®ä½¿ç¨æ³</title> <programlisting role="php"> <![CDATA[ require_once "Auth/Auth.php"; function myOutput($username, $status) { ... /** See example 1 for the full listing */ } $params = array( "dsn" => "mysql://martin:test@localhost/auth", "table" => "myAuth", "usernamecol" => "myUserColumn", "passwordcol" => "myPasswordColumn" ); $a = new Auth("DB", $params, "myOutput"); $a->start(); if ($a->getAuth()) { echo "You have been authenticated successfully."; } ]]>; </programlisting> </example> <para> ãã®ä¾ã¯ãããªããã©ã®ããã«ãã¼ã¿ãã¼ã¹ãã¼ãã«ã ããã³ã«ã©ã åã®ä»£æ¿åãæå®åºæ¥ãã示ãã¾ãã ãã®ä¾ã§ã¯ããã¼ãã«myAuthã使ç¨ãã¾ãã ãã£ã¼ã«ãmyUserColumnããã®ã¦ã¼ã¶ã¼åã ããã³ãã£ã¼ã«ãmyPasswordColumnããã®ãã¹ã¯ã¼ãã鏿ãã¾ãã ãã®ãã£ã¼ã«ãã®ããã©ã«ãauthã»usernameã¨passwordã§ãã </para> <para> This feature is necessary if you want to use PEAR::Auth with a database layout that is different from the one, PEAR::Auth uses by default. </para> </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/ja/package/authentication/auth/auth/getauth.xml +++ peardoc/ja/package/authentication/auth/auth/getauth.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.3 --> <refentry id="package.authentication.auth.auth.getauth"> <refnamediv> <refname>Auth::getAuth()</refname> <refpurpose>ã¦ã¼ã¶ãèªè¨¼æ¸ã¿ãã©ãã調ã¹ã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>boolean <function>Auth_HTTP::getAuth</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.getauth.desc"> &title.desc; <para> ã¦ã¼ã¶ãèªè¨¼æ¸ã¿ãã©ãã調ã¹ã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.getauth.return"> &title.returns; <para> <parameter>boolean</parameter> - ã¦ã¼ã¶ãæ¢ã«èªè¨¼æ¸ã¿ãªãã°ã颿°ã¯&true;ãè¿ãã¾ãã ããã§ãªããã°ã&false;ãè¿ãã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.getauth.note"> &title.note; ¬e.notstatic; </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/ja/package/authentication/auth/auth/getstatus.xml +++ peardoc/ja/package/authentication/auth/auth/getstatus.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.3 --> <refentry id="package.authentication.auth.auth.getstatus"> <refnamediv> <refname>Auth::getStatus()</refname> <refpurpose>ç¾å¨ã®èªè¨¼ç¶æ³ã®æ å ±ãè¿ã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>string <function>Auth::getStatus</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.getstatus.desc"> &title.desc; <para> ãã®é¢æ°ã¯ãPEAR::Authã®ç¾å¨ã®ã¹ãã¼ã¿ã¹ãè¿ãã¾ãã è¿ãå¤ã¯ãPEAR Authã«ããå®ç¾©ããã宿°ã§ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.getstatus.return"> &title.returns; <para> <parameter>string</parameter> - å¤ã¯ <constant>AUTH_IDLED</constant>, <constant>AUTH_EXPIRED</constant>, <constant>AUTH_EXPIRED</constant> ã«ãªãã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.getstatus.note"> &title.note; ¬e.notstatic; </refsect1> <refsect1 id="package.authentication.auth.auth.getstatus.see"> &title.see; <para> <link linkend="package.authentication.auth.constants"> PEAR::Auth constants overview</link> </para> </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/ja/package/authentication/auth/auth/setexpire.xml +++ peardoc/ja/package/authentication/auth/auth/setexpire.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.3 --> <refentry id="package.authentication.auth.auth.setexpire"> <refnamediv> <refname>Auth::setExpire()</refname> <refpurpose>èªè¨¼æå¹æéãè¨å®ãã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>void <function>Auth::setExpire</function></funcdef> <paramdef>integer <parameter>$time</parameter></paramdef> <paramdef>boolean <parameter><optional>$add = &false;</optional></parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.setexpire.desc"> &title.desc; <para> ãã®é¢æ°ã«ããã èªè¨¼ã§ä½¿ç¨ãããæå¤§æå¹æéãæ°ããå¤ã«è¨å®ãããã¨ãã§ãã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.setexpire.parameter"> &title.param; <para> <variablelist> <varlistentry> <term> &type.int; <parameter>$time</parameter> </term> <listitem> <para> ç§åä½ã®èªè¨¼æå¹æé </para> </listitem> </varlistentry> <varlistentry> <term> &type.bool; <parameter>$add</parameter> </term> <listitem> <para> ãã&true;<parameter>$time</parameter>ã®å ´åã æå¹æéæéã«è¿½å ãã¾ãã ãã&false;ã®å ´åã¯ãæ¢åã®å¤ã«ç½®ãæãããã¾ãã </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 id="package.authentication.auth.auth.setexpire.note"> &title.note; ¬e.notstatic; </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/ja/package/authentication/auth/auth/setsessionname.xml +++ peardoc/ja/package/authentication/auth/auth/setsessionname.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.2 --> <refentry id="package.authentication.auth.auth.setsessionname"> <refnamediv> <refname>Auth::setSessionname()</refname> <refpurpose>ã«ã¹ã¿ã ã»ãã·ã§ã³åãè¨å®ãã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>void <function>Auth::setSessionname</function></funcdef> <paramdef>string <parameter>name</parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.setsessionname.desc"> &title.desc; <para> ãã®é¢æ°ã¯ã ãã°ã¤ã³æã«ä½æãããã»ãã·ã§ã³åã ã«ã¹ã¿ãã¤ãºãã¦è¨å®ãããã¨ãã§ãã¾ãã ãã®ã»ãã·ã§ã³åã®ããã©ã«ãã¯ã"PHPSESSID"ã§ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.setsessionname.parameter"> &title.param; <para> <variablelist> <varlistentry> <term> &type.string; <parameter>$name</parameter> </term> <listitem> <para> 使ç¨ããã»ãã·ã§ã³å </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 id="package.authentication.auth.auth.setsessionname.note"> &title.note; ¬e.notstatic; <para> åããã¡ã¤ã³ã§Authãç¨ããã¢ããªã±ã¼ã·ã§ã³ãè¤æ°å®è¡ããå ´åã¯ã <function>setSessionname</function>ã使ç¨ããå¿ è¦ãããã¾ãã ãã®é¢æ°ã使ç¨ããªãå ´åã ã¢ããªã±ã¼ã·ã§ã³ã®ä¸ã¤ã«ä¸åº¦ãã°ã¤ã³ããã¦ã¼ã¶ã¯ã å度ãã°ã¤ã³ãããã¨ãªãã«ä»ã®ã¢ããªã±ã¼ã·ã§ã³ã 使ç¨ãããã¨ãã§ãã¦ãã¾ãã¾ã! </para> </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/ja/package/authentication/auth/auth/start.xml +++ peardoc/ja/package/authentication/auth/auth/start.xml <!-- $Revision: 1.1 $ --> <!-- Sync: 1.2 --> <refentry id="package.authentication.auth.auth.start"> <refnamediv> <refname>Auth::start()</refname> <refpurpose>èªè¨¼ãéå§ãã</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef>void <function>Auth::start</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.authentication.auth.auth.start.desc"> &title.desc; <para> èªè¨¼ããã»ã¹ãéå§ãã¾ãã </para> </refsect1> <refsect1 id="package.authentication.auth.auth.start.note"> &title.note; ¬e.notstatic; </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 -->