<?php
//---------------------------
// 用户认证函数    auth.inc
// Author: Wilson Peng
//        Copyright (C) 1999
//---------------------------
$error401 = "/home/phpdocs/error/401.php";
if ($PHP_AUTH_PW=="") {
  Header("WWW-Authenticate: Basic realm=\"超金卡会员\"");
  Header("HTTP/1.0 401 Unauthorized");
  include($error401);
  exit;
} else {
 
  $db_id = mysql_pconnect("localhost", "myid", "mypw");
  $result = mysql_db_query("mymember","select password, enable from MemberAuth where username='$PHP_AUTH_USER'");

  $row = mysql_fetch_array($result);
  $MemberPasswd = $row[0];
  $MemberEnable = $row[1];
  if ($MemberEnable==0) {
    echo "您的帐号被停用了";
    exit;
  }
  
  if ($PHP_AUTH_PW!=$MemberPasswd) {
    Header("WWW-Authenticate: Basic realm=\"超金卡会员\"");
    Header("HTTP/1.0 401 Unauthorized");
    include($error401);
    exit;
  }
}
?>