This is a basic script to for a user management system. This is just a back end, and you will be required to program the front end. I reccomend experience with PHP and such. Don't be suprised for a few bugs, it is still in it's alpha stage.
By : ipzero
<?
function checkUser($user, $pass) {
$fp = fopen("filename", "r");
$auth = false;
while (!feof($fp)) {
$parts = explode("||:|:||", trim(fgets($fp, 1024)));
if ($parts[0] == substr(crypt($user, "mn"), 2)) {
if ($parts[1] == substr(crypt($pass, "jh"), 2)) {
$auth = true;
break;
}
}
}
fclose($fp);
return $auth;
}
function addUser($user, $pass, $email) {
$fp = fopen("filename", "r");
$user = substr(crypt(trim($user), "mn"), 2);
while (!feof($fp)) {
$parts = explode("||:|:||", trim(fgets($fp, 1024)));
if ($parts[0] == $user) {
return 0;
exit;
}
}
fclose($fp);
$fp = fopen("filename", "a");
$pass = substr(crypt(trim($pass), "jh"), 2);
$email = trim($email);
$string = $user."||:|:||".$pass."||:|:||".$email."\n";
fwrite ($fp, $string);
fclose($fp);
return 1;
}
function findUser($user) {
$fp = fopen("filename", "r");
$found = false;
$i = 0;
while (!feof($fp)) {
$parts = explode("||:|:||", trim(fgets($fp, 1024)));
if ($parts[0] == substr(crypt($user, "mn"), 2)) {
print ("User <b><i>$user</i></b> found at line <b>$i</b>:<br>$parts[0]<br>$parts[1]<br>$parts[2]");
break;
}
$i++;
}
}
function deleteUser($user) {
$user = substr(crypt(trim($user), "mn"), 2);
$newfile[0] = "";
$content = file("");
$i = 0;
for(; $i < count($content); $i++) {
$parts = explode("||:|:||", trim($content[$i]));
if (!$parts[0] == $user) {
$newfile[$i] = $content[$i];
}
}
$fp = fopen("filename", "w")
or die ("Could not open file for writing");
for ($i = 0; $i < count($newfile); $i++) {
fwrite($fp, $newfile[$i]."\n");
}
fclose ($fp);
}
?>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More User Management Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
Join this Rational Talks to You teleconference, featuring Paul Boustany and Mark Krasovich, to speak to the experts about becoming a Rational ClearCase power user. Get a chance to ask your questions and learn tips and tricks for using Rational ClearCase in Agile development FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial version of WebSphere Business Modeler Advanced V6.1.1, IBM’s premier business process modeling and analysis tool for business users that offers process modeling, simulation, and analysis capabilities. IBM WebSphere Business Modeler helps you visualize, understand, and document business processes for continuous improvement. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial of the Rational Host Access Transformation Services (HATS) Toolkit. The HATS toolkit provides a set of plug-ins for the IBM Rational Software Delivery Platform to help you easily extend your legacy applications. HATS makes your 3270 and 5250 applications available as HTML through the most popular Web browsers, while converting your host screens to a Web look and feel and it also enables you to develop new Web, portal, and rich-client applications. FREE! Go There Now!
|
|
|
|
Learn from the best! Find out how developers use Rational ClearCase to be more flexible, innovative and deliver higher quality code in the Rational ClearCase Power Users eKit. This complimentary eKit provides a collection of materials, like articles, whitepapers, and demos that can help you become a power user of Rational ClearCase. FREE! Go There Now!
|
|
|
|
Learn how to implement a build management system that uses and extends your existing automation technologies. This tutorial shows, step-by-step, how to install and configure IBM Rational Build Forge to manage builds for Jakarta Tomcat from source code. FREE! Go There Now!
|
|
|
|
Listen to this webcast to get an overview of Info 2.0 and a technical demo of how to quickly build an enterprise mashup. IBM's Info 2.0 technology leverages emerging Web 2.0 technologies such as mashups, feeds, AJAX, and JSON in order to simplify assembly of information using feeds and services. Come learn about the technical elements of Info 2.0 including the Feed Generation framework, Mashup Engine, and mashup assembly components. Learn how to pull information from databases, departmental information, and the Web to create mashups critical to your company’s success. We will also discuss best practices to help you get started. FREE! Go There Now!
|
|
|
|
Regression testing -- in which code is thoroughly tested to ensure that changes have not produced unexpected results -- is an important part of any development process. But many testing environments neglect the terminal-based applications that still form the backbone of many industries. In this tutorial, you'll learn how the Rational Functional Tester Extension for Terminal-Based Applications works with other Rational Functional Tester to help test terminal-based applications quickly and easily. FREE! Go There Now!
|
|
|
|
Get a free trial download of the latest version of IBM Rational Method Composer V7.2 which helps you deliver customized yet consistent process guidance to your project teams and IT organization, and includes the latest version of IBM Rational Unified Process (RUP), which has provided process guidance to teams since 1996. FREE! Go There Now!
|
|
|
|
Get a free trial download of the latest version of IBM Rational Tester for SOA Quality V7.0.1, a functional and regression testing tool that enables the creation, comprehension, modification and execution of testing GUI-less Web services. FREE! Go There Now!
|
|
|
|
As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |