kratsg Posted October 27, 2007 Share Posted October 27, 2007 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 :-) Quote Link to comment https://forums.phpfreaks.com/topic/75046-solved-flat-file-writing-skills-required-question-about-this/ Share on other sites More sharing options...
GingerRobot Posted October 27, 2007 Share Posted October 27, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/75046-solved-flat-file-writing-skills-required-question-about-this/#findComment-379496 Share on other sites More sharing options...
kratsg Posted October 27, 2007 Author Share Posted October 27, 2007 Umm, maybe you didn't understand? I can do this, I know how to write to files and such, but I don't know how to do this level of file writing, in taking part of the file, shifting it up, etc... Quote Link to comment https://forums.phpfreaks.com/topic/75046-solved-flat-file-writing-skills-required-question-about-this/#findComment-379498 Share on other sites More sharing options...
kratsg Posted October 27, 2007 Author Share Posted October 27, 2007 Bump Quote Link to comment https://forums.phpfreaks.com/topic/75046-solved-flat-file-writing-skills-required-question-about-this/#findComment-379527 Share on other sites More sharing options...
cooldude832 Posted October 28, 2007 Share Posted October 28, 2007 exactly, this si a very specific answer that isn't straightforward which means someone isn't going to waste their time doing it for free. Quote Link to comment https://forums.phpfreaks.com/topic/75046-solved-flat-file-writing-skills-required-question-about-this/#findComment-379537 Share on other sites More sharing options...
Barand Posted October 28, 2007 Share Posted October 28, 2007 use file() to read the file contents in to arrays. Add/remove the user from the arrays. rewrite the arrays back to the files Quote Link to comment https://forums.phpfreaks.com/topic/75046-solved-flat-file-writing-skills-required-question-about-this/#findComment-379731 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.