Jump to content

[SOLVED] Flat File Writing Skills required (question about this)


Recommended Posts

Two files: htpasswd and htgroup (yes, it's not a coincidence). I'm creating an ACP that will control the data in these two files. I've got a php script that will force authenticate and keep logged in if details are correct.

 

htpasswd

user1:password1
user2:password2
user3:password3
user4:password4
user5:password5
user6:password6
user7:password7
user8:password8
user9:password9

 

htgroup

group1:user1 user2 user6 user8
group2:user3 user7
group3:user5
group4:user4 user9

 

I want to be able to do the following:

  • Add New User (writes a user:password combo to htpasswd and adds them to a group in htgroup)
  • Delete User (removes them from htpasswd and htgroup)

 

Here's what I want accomplished (based on the two code as examples).

 

When we add a new user, it will APPEND to the file correctly (with the \r\n line breaks) and the correct adding to the group.

 

When we delete a user, it will delete the line in htpasswd (shifts all lines below upwards so there's no gap) and removes that user from the corresponding group (shifts all users left to fill in gap).

 

For example: if I want to delete user6, it should go from the above, to this:

 

htpasswd

user1:password1
user2:password2
user3:password3
user4:password4
user5:password5
user7:password7
user8:password8
user9:password9

 

htgroup

group1:user1 user2 user8
group2:user3 user7
group3:user5
group4:user4 user9

 

If I want to re-add user6 (also into group1), it will go from the above, to this:

 

user1:password1
user2:password2
user3:password3
user4:password4
user5:password5
user7:password7
user8:password8
user9:password9
user6:password6

 

htgroup

group1:user1 user2 user8 user6
group2:user3 user7
group3:user5
group4:user4 user9

 

Thanks :-)

Entirely possible. If you want somone to do it for you, head over to the freelance forum. This isn't the place for people to just do stuff for you. If you have a go yourself, and get stuck, then come back and we'll help you out.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.