SunQuest
 
       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  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
IBM® developerWorks
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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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! Accelerating Software Innovation on i on Power Systems

    Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, for an overview of Rational’s new software offerings and resources to help modernize and accelerate software innovation on i on Power Systems – while ensuring past application investments are protected and continue to grow. Learn how these solutions are helping customers extend their core i5/OS solutions toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time.
    FREE! Go There Now!


    Role of Integrated Requirements Management in Software Delivery

    As organizations integrate software into every aspect of business, they are constantly pressured to deliver faster, better, and cheaper results. Unfortunately, a “dis-integrated” software delivery approach reduces returns while increasing costs. This IBM Rational White Paper shows how Integrated Requirements Management aligns organizations around maximizing value and keeping pace with change.
    FREE! Go There Now!


    NEW! IBM Rational AppScan Standard Edition V7.7

    Secure your Web applications with IBM Rational AppScan Standard Edition V7.7, previously known as Watchfire AppScan. This Web application security testing tool automates vulnerability assessments and scans and tests for common Web application vulnerabilities. Visit IBM developerWorks to download a free trial of IBM Rational AppScan Standard Edition V7.7.
    FREE! Go There Now!


    NEW! Project and Portfolio Management Executive Resource Kit

    Portfolio Management is about effectively managing portfolio value by aligning portfolio investments with business goals. This complimentary e-kit provides a collection of materials that can help you understand how IBM Rational enables and automates best practices for improved governance and clear visibility into portfolio and project performance across the entire IT project lifecycle.
    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! Evaluate WebSphere Extended Deployment Compute Grid V6.1

    Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points.
    FREE! Go There Now!


    Build Forge Express demo: Enabling software delivery excellence for small and midsized businesses

    This demonstration gives you an overview of IBM® Rational® Build Forge Express Edition, a global offering that provides a framework to automate and execute software processes. Rational Build Forge provides a software assembly line that can support all of your tools, technologies, and platforms so you can achieve a repeatable, reliable, and traceable build and release process.
    FREE! Go There Now!


    NEW! Using IBM Rational Developer for System z and IBM Rational ClearCase together to manage application development

    Whether you are creating new applications or modifying existing ones, managing integration of new components with traditional z/OS elements is a critical part of building and deploying modern applications. Listen to this webcast to see how IBM can help you optimize your development process using an IDE like Rational Developer for System z that integrates with management tools, such as ClearCase to manage your application development on mainframes.
    FREE! Go There Now!


    NEW! Webcast: Calling All Testers! Find Application Vulnerabilities Early in the Development Process Where they are Easier to Fix and Less Risky to your Business

    In this webcast, IBM Rational will discuss the importance of Web application security and will share techniques and best practices to introduce application security testing into current QA processes including: understanding common security vulnerabilities and techniques to integrate security testing with defect tracking and remediation systems in an effort to safeguard sensitive online information.
    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-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway