Last Update:2016-06-01
Source: Internet
Author: User
Keywords
Full
source
management
authentication
user
Echo
--Begin Auth.inc--
$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 ') {
?>
<title>404 Not Found</title>
Not Found
The requested URL
Was wasn't found on the this server.
Exit } ?> --End Auth.inc-- --Begin Connect.inc-- --End Connect.inc-- --Begin Error.inc-- This file holds the error message and returns! --End Error.inc-- --User library structure (self-tuning)-- CREATE TABLE Auth ( ID smallint (6) DEFAULT ' 0 ' not NULL auto_increment, Username varchar (+) 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) ); --end of user library structure-- --Add User example-- Insert into auth (username, lastname, firstname, password, realms, Active) values (' admin ', ' my ', ' love ', ' Password ', ' Xxxcom ', ' yes '); --End-- --User Management program started usermanage.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"); $query 1 = "UPDATE auth SET active= ' yes ' where id= ' $id '"; $result 1 = mysql_db_query ("admin", $query 1); if ($result 1) { echo "n"; echo "$user Activatedn"; echo " n returns n "; echo "n"; Exit } else { echo "n"; echo "Error:unknown Errorn"; echo " n returns n "; echo "n"; Exit } } if ($deactivate) { Include ("Connect.inc"); $query 2 = "UPDATE auth SET active= ' no ' where id= ' $id '"; $result 2 = mysql_db_query ("admin", $query 2); if ($result 2) { echo "n"; echo "$user Deactivatedn"; echo " n returns n "; echo "n"; Exit } else { echo "n"; echo "Error:unknown Errorn"; echo " n returns n "; echo "n"; Exit } } if ($delete) { Include ("Connect.inc"); $query 3 = "Delete from auth where id= ' $id '"; $result 3 = mysql_db_query ("admin", $query 3); if ($result 3) { echo "n"; echo "$user deleted!n"; echo " n returns n "; echo "n"; Exit } else { echo "n"; echo "Error:unknown Errorn"; echo " n returns n "; echo "n"; Exit } } echo "n "; echo "n "; echo "<title>User Management</title>n "; echo "n "; echo "n "; echo "
n ";
echo "
n "; echo "
Username
Real Name
Activated
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 ["Lastn Ame "]; $firstname = $r ["FirstName"]; $activated = $r ["Active"]; if ($activated = = "Yes") {echo '
$username
$lastname, $firstname
$activated
Deactivate
Delete
n "; } elseif ($activated = = "No") {echo]
$username
$lastname, $firstname
$activated
Activate
Delete
n "; }}} mysql_free_result ($result); echo "
n ";
echo "n ";
echo "n ";
?>
--usermanage.php End--