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! |
Hear how IBM Rational Project and Portfolio Management integrated solutions help teams put the right tools and processes in place to maximize the effectiveness and efficiency of project teams and ensure that the business vision is being executed correctly. Learn how to automate and integrate requirements prioritization, top-down project planning, communications and controls, and methodology deployment to keep your scope, costs, and schedules under control. Tackle with an end-to-end approach the management of scope and scope changes, usage of methodology to control and empower project teams, and optimization of resources to align activity costs with the overall project plan. FREE! Go There Now!
|
|
|
|
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!
|
|
|
|
Learn field-tested SOA principles, methodology, technology and implementation from the global SOA market leader - in a new e-book by an IBM SOA expert. Written by IBM Certified SOA Solution Designer Bobby Woolf, "Exploring IBM SOA Technology & Practice" is the ultimate insider's guide to SOA - a PDF e-book packed cover to cover with IBM's specific advice on how to make your SOA implementation a success. FREE! Go There Now!
|
|
|
|
Learn to enable users to both rate existing animations and to combine existing animations into new snippets. This is the third in a series of three tutorials that chronicle the building of a site that enables collaborative discussion and animation building using Domino and OpenLaszlo. 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!
|
|
|
|
Join this webcast to see how IBM Data Studio Developer and pureQuery can take the pain out of Java data access. uApplications developed using both Java and SQL have become a common requirement. Database connectivity using Java Database Connectivity (JDBC) to create an application is a multi-step tedious process, and tooling that covers both SQL and Java has been unavailable, until now. IBM Data Studio introduces the pureQuery platform: a high-performance, Java data access platform focused on simplifying the tasks of developing, managing, and optimizing database applications and services. FREE! Go There Now!
|
|
|
|
Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available. FREE! Go There Now!
|
|
|
|
Learn how to do more with your reusable assets with the free Rational Asset Manager eKit. The eKit includes demos on how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse. Plus you’ll find white papers and a Webcast that discuss the challenges of a Service Oriented Architecture and how Rational Asset Manager can provide quick and effective solutions. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on December 6 at 1:00 pm ET to participate in an agile application development discussion and get your questions answered on using IBM Rational Method Composer in a distributed environment.Get your questions answered! FREE! Go There Now!
|
|
|
|
You can now evaluate IBM Rational Asset Manager V7.0 online without installing or configuring it on your own system! Rational Asset Manager helps create, modify, govern, find, and reuse any type of development assets, including SOA and systems development assets. Rational Asset Manager helps you reduce software development costs and improve quality by facilitating the reuse of all types of software development-related assets. Visit developerWorks to learn more about this product and register to explore its capabilities online. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |