-- Begin auth. inc --
<? Php
$ Id = "xxxCOM ";
If (! Isset ($ PHP_AUTH_USER )){
Header ("WWW-Authenticate: Basic realm =" $ id "");
Header ("HTTP/1.0 401 Unauthorized ");
Require ('error. inc ');
Exit;
}
$ Name = $ PHP_AUTH_USER;
$ Pass = $ PHP_AUTH_PW;
Require ("connect. inc ");
$ Query = "select * from auth where username = '$ name' & realm =' $ id '";
$ Result = mysql_db_query ("admin", $ query );
If (mysql_num_rows ($ result) = 0 ){
Header ("WWW-Authenticate: Basic realm =" $ id "");
Header ("HTTP/1.0 401 Unauthorized ");
Require ('error. inc ');
Exit;
}
$ Active = mysql_result ($ result, 0, "active ");
If ($ active = 'no '){
?>
<HTML> <HEAD>
<TITLE> 404 Not Found </TITLE>
</HEAD> <BODY>
<H1> Not Found </H1>
The requested URL
<? Echo $ REQUEST_URI;?>
Was not found on this server. <P>
</BODY> </HTML>
<? Php
Exit;
}
?>
-- End auth. inc --
-- Begin connect. inc --
<? Php mysql_connect ("localhost", "user", "");?>
-- End connect. inc --
-- Begin error. inc --
This file stores error messages and returns!
-- End error. inc --
-- User library structure (self-adjusted )--
Create table auth (
Id smallint (6) DEFAULT '0' not null auto_increment,
Username varchar (16) DEFAULT ''not null,
Lastname tinyblob,
Firstname tinyblob,
Password varchar (16 ),
Realm varchar (16 ),
Active char (3 ),
Primary key (id ),
UNIQUE id (id ),
UNIQUE username (username)
);
-- The user library structure ends --
-- Add user example --
Insert into auth (username, lastname, firstname, password, realm, active) values ('admin', 'My ', 'love', 'Password', 'xxxcom ', 'Yes ');
-- End --
-- The user management program starts usermanage. php --
<? Php include ("auth. inc");?>
<? Php
If ($ PHP_AUTH_USER! = "Admin "){
Header ("WWW-Authenticate: Basic realm =" xxxCOM customer authentication "");
Header ("HTTP/1.0 401 Unauthorized ");
Echo "Access Denied! N ";
Exit;
};
If ($ PHP_AUTH_PW! = "Mypassword "){
Header ("WWW-Authenticate: Basic realm =" xxxCOM customer authentication "");
Header ("HTTP/1.0 401 Unauthorized ");
Echo "Access Denied! N ";
Exit;
};
If ($ activate ){
Include ("connect. inc ");
$ Query1 = "UPDATE auth SET active = 'yes' where id = '$ id '";
$ Result1 = mysql_db_query ("admin", $ query1 );
If ($ result1 ){
Echo "<font size =" + 1 "> n ";
Echo "$ user activatedn ";
Echo "<br> n <a href =" $ PHP_SELF "> return </a> \ n ";
Echo "</font> n ";
Exit;
} Else {
Echo "<font size =" + 1 "> n ";
Echo "Error: Unknown Errorn ";
Echo "<br> n <a href =" $ PHP_SELF "> return </a> \ n ";
Echo "</font> n ";
Exit;
}
}
If ($ deactivate ){
Include ("connect. inc ");
$ Query2 = "UPDATE auth SET active = 'no' where id = '$ id '";
$ Result2 = mysql_db_query ("admin", $ query2 );
If ($ result2 ){
Echo "<font size =" + 1 "> n ";
Echo "$ user deactivatedn ";
Echo "<br> n <a href =" $ PHP_SELF "> return </a> \ n ";
Echo "</font> n ";
Exit;
} Else {
Echo "<font size =" + 1 "> n ";
Echo "Error: Unknown Errorn ";
Echo "<br> n <a href =" $ PHP_SELF "> return </a> \ n ";
Echo "</font> n ";
Exit;
}
}
If ($ delete ){
Include ("connect. inc ");
$ Query3 = "delete from auth where id = '$ id '";
$ Result3 = mysql_db_query ("admin", $ query3 );
If ($ result3 ){
Echo "<font size =" + 1 "> n ";
Echo "$ user deleted! N ";
Echo "<br> n <a href =" $ PHP_SELF "> return </a> \ n ";
Echo "</font> n ";
Exit;
} Else {
Echo "<font size =" + 1 "> n ";
Echo "Error: Unknown Errorn ";
Echo "<br> n <a href =" $ PHP_SELF "> return </a> \ n ";
Echo "</font> n ";
Exit;
}
}
Echo "Echo "Echo "<title> User management </title> n ";
Echo "Echo "<body> n ";
Echo "<form method =" post "action =" $ PHP_SELF "> \ n ";
Echo "<table border =" 1 "> n ";
Echo "<tr> <th> <font size =" + 1 "> Username </font> </th> <font size =" + 1 "> Real Name </font> </th> <font size = "+ 1"> Activated </font> </th> </tr> n ";
Include ("connect. inc ");
$ Query = "SELECT * FROM auth ";
$ Result = mysql_db_query ("admin", $ query );
If ($ result ){
While ($ r = mysql_fetch_array ($ result )){
$ Id = $ r ["id"];
$ Username = $ r ["username"];
$ Lastname = $ r ["lastname"];
$ Firstname = $ r ["firstname"];
$ Activated = $ r ["active"];
If ($ activated = "yes "){
Echo "<tr> <td> <font size =" + 1 "> $ username </font> </td> <font size =" + 1 "> $ lastname, $ firstname </font> </td> <font size = "+ 1"> $ activated </font> </td> <a href =" $ PHP_SELF? Deactivate = yes & id = $ id & user = $ username "> Deactivate </a> </td> <a href =" $ PHP_SELF? Delete = yes & id = $ id "> Delete </a> </td> </tr> n ";
} Elseif ($ activated = "no "){
Echo "<tr> <td> <font size =" + 1 "> $ username </font> </td> <font size =" + 1 "> $ lastname, $ firstname </font> </td> <font size = "+ 1"> $ activated </font> </td> <a href =" $ PHP_SELF? Activate = yes & id = $ id "> Activate </a> </td> <a href =" $ PHP_SELF? Delete = yes & id = $ id "> Delete </a> </td> </tr> n ";
}
}
}
Mysql_free_result ($ result );
Echo "</table> \ n ";
Echo "</body> \ n ";
Echo "?>
-- Usermanage. php ended --