|
|
(Next) Auth::addUser() |
||||
| |
|||||
|
|||||
Auth::Auth (
mixed $storageDriver
, mixed $options = ""
, string $loginFunction = ""
, boolean $showLogin
= = true
)
認証システムのコンストラクタです。
コンストラクタによって、session_start() で PHP のセッション管理が開始されることが保証されます。 Auth が正しく動作するためには、セッションが有効になっている必要があるからです。
使用すべきストレージドライバーの名前、 もしくは独自の Auth_Container オブジェクト
Auth 自身およびストレージドライバの両方についてのオプションを含む配列。 グローバルなオプションについては Auth のオプション 、 各ドライバ固有のオプションについては個々のストレージドライバのドキュメントを参照ください。
ログイン画面を表示するユーザ定義関数の名前。 この関数には三つのパラメータ $username、$status、&$auth を渡します。これらは、 直近に試みられたユーザ名、直近の試みが失敗した際の状態コード そして Auth オブジェクト自身への参照となります。
ログインがオプションかどうかの定義
This function can not be called statically.
DB パラメータ
<?php
require_once "Auth/Auth.php";
function myOutput($username, $status, $auth)
{
... /* See first example in introduction 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.";
}
?>
<?php
;
?>
データベーステーブル、 およびカラム名の代替名を指定する方法について示します。 この例では、テーブル myAuth を使用します。 フィールド myUserColumn からユーザー名、 フィールド myPasswordColumn からパスワードを選択します。 デフォルトでは、テーブル名およびフィールド名は それぞれ、auth および username、password となります。 また、DSN の代わりに、DSN 引数を保持した DB のオブジェクトを 渡すこともできます。
この機能は、 デフォルトと異なるデータベースレイアウトで、 PEAR::Auth を使用したい場合に必要となります。
独自ストレージコンテナ
<?php
require_once "Auth/Auth.php";
function myOutput($username, $status)
{
... /* See first example in introduction for the full listing */
}
$a = new Auth(new CustomAuthContainer($options), null, "myOutput");
$a->start();
if ($a->getAuth()) {
echo "You have been authenticated successfully.";
}
?>
この例は、独自のストレージコンテナを Auth に渡す方法について示しています。
Auth パッケージが提供するストレージコンテナが、 自らの要求に合致しない場合は、独自のストレージコンテナを 作成することができます。 ストレージコンテナの詳細な情報については、 ストレージドライバ のセクションを参照してください。
|
|
(Next) Auth::addUser() |
||||||||
| |
|||||||||
|
|||||||||