Zubrag.com
August 23, 2019, 09:11:46 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Use external text file to supply passwords for Password Protect  (Read 17334 times)
sundial2k
Newbie
*
Posts: 13


« on: June 03, 2010, 05:44:02 PM »

Hi - I'm wondering if it's possible to use an external text file (or ideally a Google Doc Spreadsheet) with a list of usernames/passwords for Password Protect.

Thanks,
John

Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #1 on: June 04, 2010, 02:42:43 AM »

Can be done for text file, but needs some changes. I'll post in a day
Logged
sundial2k
Newbie
*
Posts: 13


« Reply #2 on: June 04, 2010, 06:03:39 AM »

Thanks!!  I was wondering - is there a way to track the number of times one of these codes is used?

John
Logged
sundial2k
Newbie
*
Posts: 13


« Reply #3 on: June 04, 2010, 06:33:54 AM »

I was just looking at Advanced Password Protect and I think this might work even better.  Am I correct in understanding that I can give my admin access to MANAGER.PHP and he can log in and enter/change/add users?

John
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #4 on: June 04, 2010, 06:40:51 AM »

Yes, "advanced password protect" script provides better user management than "password protect" script. But remember to backup users file sometimes as somebody reported lose of users list (possibly there is a bug)

In case you decide to update regular password protect script to load users from external file than:
find this code

// Add login/password pairs below, like described above
// NOTE: all rows except last must have comma "," at the end of line
$LOGIN_INFORMATION = array(
  'zubrag' => 'root',
  'admin' => 'adminpass'
);

and relace with this code

// list of users
$users = file('/path/to/users/list/file/including/filename');
if (!$users) die('Cannot find users list!');

// prepare users list
$LOGIN_INFORMATION = array();
foreach ($users as $user) {
  $u = explode(',',$user);
  if (USE_USERNAME) {
    $LOGIN_INFORMATION[trim($u[0])] = trim($u[1]);
  }
  else {
    $LOGIN_INFORMATION[] = trim($u[0]);
  }
}


Note: remember to fix bolded path to the userlist file
Logged
sundial2k
Newbie
*
Posts: 13


« Reply #5 on: June 04, 2010, 06:54:31 AM »

That's awesome!  How do the passwords need to be formated in the external file, and I'm assuming that it should be a basic .txt file?
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #6 on: June 04, 2010, 07:26:20 AM »

yes, basic txt file. Name/extension does not matter, can be anything.

users file format:
username1,password1
username2,password2
...

username/password pair delimiter defined in following line. As you can see it is set to comma. Change it if you need something else as delimiter
$u = explode(',',$user);
Logged
sundial2k
Newbie
*
Posts: 13


« Reply #7 on: June 04, 2010, 01:32:12 PM »

Thanks - you made that super-easy!  I appreciate your help!!
Logged
Kimball342
Newbie
*
Posts: 11


« Reply #8 on: August 11, 2010, 12:31:38 AM »

What a tremendous article and helping comments, nice to see here, an amazing post, keep it Up. no doubt its a admirable post.
Logged
Uradelekcil
Newbie
*
Posts: 2


WWW
« Reply #9 on: September 23, 2011, 07:27:16 AM »

very interesting article ... I hope this will continue
Logged
jasper2012
Newbie
*
Posts: 2


« Reply #10 on: January 06, 2012, 02:27:29 AM »

we just would like to give a huge thumbs up for the great info you have here on this post. I will be coming back to your posr for
more soon.


__________________
Cost performance led 5050 online.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC