Login   Register  
PHP Classes
elePHPant
Icontem

File: function.http.auth.eg.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Md. Shahadat Hossain Khan Razon  >  Basic Realm Authentication Controller  >  function.http.auth.eg.php  >  Download  
File: function.http.auth.eg.php
Role: Example script
Content type: text/plain
Description: Example: Authentication by Customized Function
Class: Basic Realm Authentication Controller
Authenticate users with HTTP basic mechanism
Author: By
Last change: fix session hijacking & fixation
Date: 1 year ago
Size: 1,132 bytes
 

Contents

Class file image Download
<?php

session_start
();
include_once 
'http.auth.cls.php';

function 
chk_my_user_simple($p_user$p_pass){
    
$users=array('demo'=>'demo''admin'=>'admin1''user'=>'admin2');
    if(isset(
$users[$p_user]) && $users[$p_user]==$p_pass) return true;
}
$httpauth=new HTTPBasicRealmAuth('authentication by function''chk_my_user_simple');
/**/
/*
class myWebsiteUsers{

    var $users;
    function __construct(){
        $this->users['admin']=$this->encrypt('admin1');
        $this->users['demo']=$this->encrypt('admin2');
        $this->users['user']=$this->encrypt('admin3');
        $this->users['client']=$this->encrypt('admin4');
    }

    function encrypt($p_subject){ return md5($p_subject); }

}
function chk_my_user($p_user, $p_pass){
    $usr=new myWebsiteUsers();
    if(isset($usr->users[$p_user]) && $usr->users[$p_user]==$p_pass) return true;
}
$user=new myWebsiteUsers();
$httpauth=new HTTPBasicRealmAuth('authentication by function', NULL, 'chk_my_user', true, false);
$httpauth->setPasswordEncryptMethod(array($user, 'encrypt'));
$httpauth->setEncryptedPasswordFlag(true);
$httpauth->check();
*/

include 'secure.file.eg.php';