User Management Code
  Home arrow User Management Code arrow Simple and Easy Security
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
USER MANAGEMENT CODE

Simple and Easy Security
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2002-11-06

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Simple and Easy Security, with txt file as user list and password. Easy to manage and adapt to your website. It cost free.

    By : hermawan

    <?php
    /************************************************\
    * Function Name : Security Made Easy *
    * Creator : Hermawan Haryanto *
    * Email : hermawan@codewalkers.com *
    * Website : http://hermawan.com *
    * License : GPL (General Public License) *
    \***********************************************/
    session_start();
    class security {
    var $usernames = Array ();
    var $passwords = Array ();
    var $error;
    function security () {
    $this->setAccountFile ("security.txt");
    }
    function setAccountFile ($file) {
    $fp = fopen ($file,"r");
    $content = fread ($fp,filesize ($file));
    $contents = explode("\n", $content);
    for ($i=0;$i<count($contents);$i++) {
    if (!$this->isempty($contents[$i])) {
    $accounts = explode("|", $contents[$i]);
    if (!$this->isempty($accounts[0])) {
    $this->usernames[] = $this->decode($accounts[0]);
    $this->passwords[] = $this->decode($accounts[1]);
    }
    }
    }
    }
    function secureme () {
    global $_POST;
    $forms = $_POST;
    if (count($forms)<1) {
    if (!$_SESSION || trim($_SESSION["loggedin"])=="") {
    $this->showloginform();
    exit();
    }
    } else {
    if ($this->isempty($forms["username"])) $this->seterror("<li>Username is empty!</li>");
    if ($this->isempty($forms["password"])) $this->seterror("<li>Password is empty!</li>");
    if ($this->isempty($this->error)) {
    if (in_array($forms["username"], $this->usernames)) {
    for ($i=0;$i<count($this->usernames);$i++) {
    if ($forms["username"]==$this->usernames[$i]) {
    if ($forms["password"]!=$this->passwords[$i]) $this->seterror("<li>Username seems right but the password is wrong!</li>");
    }
    }
    } else {
    $this->seterror("<li>Username is not known!</li>");
    }
    }
    if ($this->isempty($this->error)) {
    $_SESSION["loggedin"] = "true";
    Header("Location:".$forms["ref"]);
    exit();
    } else {
    $this->showerror();
    $this->showloginform();
    exit();
    }
    }
    }
    function seterror($str) {
    $this->error .= $str;
    }
    function showerror() {
    print "<center><b>Error:</b><font color=#FF0000>$this->error</font></center>";
    }
    function isempty ($str) {
    if (trim($str)=="") return true;
    else return false;
    }
    function showloginform () {
    print "<body><table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr><td align=center valign=middle><table width=250 border=0 cellpadding=4 cellspacing=1 bgcolor=#EEEEEE><tr><td align=center valign=middle><font size=-1 face=Tahoma, Verdana, Arial><strong>User Authentication</strong></font></td></tr><tr><td bgcolor=#FFFFFF><table width=100% border=0 cellspacing=0 cellpadding=2><form method=post><input type=hidden name=ref value=".$_SERVER["PHP_SELF"]."><tr><td width=75 align=right valign=middle><font size=-2 face=Tahoma, Verdana, Arial><strong>Username</strong></font></td><td width=5 align=center valign=middle><font size=-2 face=Tahoma, Verdana, Arial>:</font></td><td align=left valign=middle><font size=-2 face=Tahoma, Verdana, Arial>&nbsp; <input name=username type=text size=22></font></td></tr><tr><td width=75 align=right valign=middle><font size=-2 face=Tahoma, Verdana, Arial><strong>Password</strong></font></td><td width=5 align=center valign=middle><font size=-2 face=Tahoma, Verdana, Arial>:</font></td><td align=left valign=middle><font size=-2 face=Tahoma, Verdana, Arial>&nbsp; <input name=password type=password size=22></font></td></tr><tr><td width=75 align=right valign=middle><font size=-2 face=Tahoma, Verdana, Arial>&nbsp;</font></td><td width=5 align=center valign=middle><font size=-2 face=Tahoma, Verdana, Arial>&nbsp;</font></td><td align=left valign=middle><font size=-2 face=Tahoma, Verdana, Arial>&nbsp; <input name=action type=submit id=action value=LOGIN></font></td></tr></form></table></td></tr></table></td></tr></table></body>";
    }
    function encode ($str) {
    return base64_encode ($str);
    }
    function decode ($str) {
    return base64_decode ($str);
    }
    };
    if (eregi("security.php", $_SERVER["PHP_SELF"])) {
    $act = $_GET["act"];
    switch ($act) {
    case "encode" :
    if ($_GET["str"]) {
    $s = new security;
    print $s->encode($str);
    break;
    } else {
    Header("Location: http://www.dekap.com");
    break;
    }
    case "logout" :
    session_destroy();
    Header("Location:".$_SERVER["HTTP_REFERER"]);
    break;
    default :
    Header("Location: http://www.dekap.com");
    break;
    }
    }
    ?>

    Click to Download File



    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

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Applying lean thinking to the governance of software development

    Effective governance for lean development isn’t about command and control. Instead, the focus is on enabling the right behaviors and practices through collaborative and supportive techniques. Hear from Scott Ambler on how it is far more effective to motivate people to do the right thing than it is to force them to do so. Learn how to form a lightweight, collaboration-based framework that reflects the realities of modern IT organizations.
    FREE! Go There Now!


    NEW! Discovering the value of WebSphere Process Server

    WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies.
    FREE! Go There Now!


    NEW! Download IBM Rational Developer for System z

    Download a free trial version of IBM Rational Developer for System z, software that can help you deliver core development capabilities; the power of Java Platform, Enterprise Edition (Java EE); and rapid application development support to diverse enterprise application development teams. With comprehensive development tools to help create, deploy and maintain traditional enterprise and composite applications, Rational Developer for System z enables developers with different technical backgrounds to easily participate in important technology projects.
    FREE! Go There Now!


    NEW! Hacking 101

    Join us for this web seminar to learn how you can defend your web applications from attack. Learn about the 3 most common web application attacks, including how they occur and what can be done to prevent them. We’ll also discuss manual versus automated approaches for scanning and identifying web application vulnerabilities and how IBM Rational AppScan, an automated vulnerability scanner, can help you automate more of what you are doing manually today.
    FREE! Go There Now!


    NEW! IBM Rational ClearCase Innovator's Series

    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!


    NEW! Rational 'Talks to You' Teleconference Series

    This Fall, IBM Rational talks to you directly through a special teleconference series giving you access to the best minds in IBM Rational - product experts and market thought leaders who will answer your questions during these pre-scheduled telephone conference calls. Register today!
    FREE! Go There Now!


    NEW! Rational Talks to You: Scott Ambler on being agile in a global development environment

    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!


    NEW! The dirty dozen: preventing common application-level hack attacks

    As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications.
    FREE! Go There Now!


    NEW! The role of integrated requirements management in software delivery

    This paper is about the critical role that a discipline called integrated require­ments management can play in helping to ensure that your business goals and IT investments are continuously aligned—whether you are sourcing, integrat­ing, building or maintaining software. It also looks at ways that automated IBM Rational® products can work together to help you use requirements in the very best way.
    FREE! Go There Now!


    NEW! Try IBM Rational Asset Manager V7.0 online!

    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!

    USER MANAGEMENT CODE ARTICLES

    - XCRYPT v1.0b
    - DB_eSession class stores sessions in a MySQL...
    - Ever Changing Dynamic Passcode Code
    - phpAutoMembersArea - create own members area
    - Azura Signup 2.5
    - Azura Signup 2.0
    - Azura Signup
    - Flexcustomer
    - PHP Quicksite 2.0
    - PHP Quicksite 1.0
    - random string generator (key generator)
    - Example Login system
    - Simple and Easy Security
    - Basic Security
    - UMA - User Management and Authentication





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek