previousAuth_HTTP::Auth_HTTP() (Previous) (Next) Auth_HTTP 例2next

View this page in Last updated: Sun, 21 Jun 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Auth_HTTP 例

Auth_HTTP 例 – シンプルなパスワード保護の例

Example

<?php

// Auth_HTTP を使った基本的な実装の例

require_once("Auth/HTTP.php");

// データベース接続オプションの設定
$AuthOptions = array(
'dsn'=>"pgsql://test:test@localhost/testdb",
'table'=>"testable",                            // テーブル名 
'usernamecol'=>"username",            // ユーザ名のコラム
'passwordcol'=>"password",            // パスワードのコラム
'cryptType'=>"none",                // データベース中でのパスワードの暗号化形式
);


$a = new Auth_HTTP("DB"$AuthOptions);

$a->setRealm('yourrealm');            // 領域 (realm) 名
$a->setCancelText('<h2>Error 401</h2>');        // 認証が失敗した際に表示されるメッセージ
$a->start();                    // 認証プロセスの開始


if($a->getAuth())                // 認証すべきユーザかどうかの確認
{
    echo 
"Hello $a->username welcome to my secret page";
    
};

?>
previousAuth_HTTP::Auth_HTTP() (Previous) (Next) Auth_HTTP 例2next

Download Documentation Last updated: Sun, 21 Jun 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.