1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Using a .txt file for login/password

Discussion in 'PHP' started by Bulldog-Designs, Sep 19, 2006.

  1. #1
    Is there a way to create a Username/password login and the information stored in a .txt file?
    Can you please share the code :)
     
    Bulldog-Designs, Sep 19, 2006 IP
  2. matthewk

    matthewk Guest

    Messages:
    265
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yes, its pretty easy, but not very secure, i wouldnt recommend it. even encrypting the data or using a hash still isnt very safe.
     
    matthewk, Sep 19, 2006 IP
  3. Bulldog-Designs

    Bulldog-Designs Active Member

    Messages:
    912
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    60
    #3
    it doesnt have to be rediculously safe. I just need it so clients can check the progress of the work.
     
    Bulldog-Designs, Sep 19, 2006 IP
  4. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can store it in files with fopen, fwrite, fread and fclose. However an attacker just needs to know the address to that file and can gain access. So if anything you should put that file above the document root.
     
    Icheb, Sep 19, 2006 IP
  5. Bulldog-Designs

    Bulldog-Designs Active Member

    Messages:
    912
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Can you share the codes with me please?
     
    Bulldog-Designs, Sep 19, 2006 IP
  6. Pat Gael

    Pat Gael Banned

    Messages:
    1,331
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Pat Gael, Sep 19, 2006 IP
  7. phd

    phd Active Member

    Messages:
    496
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #7
    According to me, One should not use .txt for authentication login!! use database with encryption!! :)
     
    phd, Sep 20, 2006 IP
  8. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #8
    you can put the file outside the www directory, use crypt() php functions, also could use passwd format.
    what is securable - database or file putted this way - we could argue.
    Also you can use password protected directories and check for php authenticated username to detect, who was authenticated
     
    intoex, Sep 20, 2006 IP
  9. vinxxv

    vinxxv Well-Known Member

    Messages:
    506
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    118
    #9
    what about this? (taken from http://www.zend.com/zend/tut/authentication.php)

    
    <?php
    
    if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW)) 
         || ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'open' ) ) {
    
        header( 'WWW-Authenticate: Basic realm="Private"' );
        header( 'HTTP/1.0 401 Unauthorized' );
        echo 'Authorization Required.';
        exit;
    
    } else {
    
        echo 'Success!';
    
    }
    ?> 
    
    Code (markup):
    No more text file needed.. just have this on top of your script or have it included using the include function ( include "filename.php"; ). there are better approach to do this but this one seems to be the simplest.
     
    vinxxv, Sep 20, 2006 IP
  10. thuonghieu

    thuonghieu Peon

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    It is never safe for you if store your username and password in "TEXT" file such as: .txt .inc .dat ... because hackers can search it and it will be hacked.
    If you use php you can insert this code into file you need protect, after first <?php:

    For above:
    21232f297a57a5a743894a0e4a801fc3 --->admin
    1a1dc91c907325c69271ddf0c944bc72 --->pass
    Meaning you can login with: User=admin | Password=pass
    You can make your own username and password encrypted: http://gdataonline.com/makehash.php and input your username & password and submit. Replace it!
    It is very security
     
    thuonghieu, Sep 22, 2006 IP
  11. matthewk

    matthewk Guest

    Messages:
    265
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #11
    ya, like i said, you could use a hash, but you can still decrypt them with a script if you get the text file, but its better then just plain text.

    ...thats assuming you are still usinga text file, if you are just storing it in the php, it will work fine
     
    matthewk, Sep 22, 2006 IP
  12. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Uhm, no, you can't.
     
    Icheb, Sep 23, 2006 IP
  13. melol2

    melol2 Active Member

    Messages:
    511
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #13
    Not very secure at all! Imagine if I could find all the passwords to this site by going to forum.digitalpoint.com/passwords.txt . And all encryptions and hashes and be decrypted or brute forced...
     
    melol2, Sep 23, 2006 IP
  14. thuonghieu

    thuonghieu Peon

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    :D You cannot and never decrypted if I set password like: a@bGj7%$hKh!%)&t (meaning password >15 characters long, include digists/alphabets/speacial characters. To decrypted it you must wait about 100000000000 years LOLz
     
    thuonghieu, Sep 23, 2006 IP