How can I write file without overwrite |
Those new settings will overwrite pre-existing values, however, to actually replace the lines is a bit more complex, as I wasn't sure exactly what you were trying to do. If you're trying to add and update, I would basically do an array merge, then completely overwrite the file. See: https://www.php.net/manual/en/function.array-merge.php
Obviously, my solution was just to get you started. Again, I think what you're doing here is very bad practice from a security concept, so I don't feel very comfortable giving a full on solution to someone who probably does not have the grasp of the language necessary to deal with it in a safe fashion. The link I gave you should be enough to give you some ideas, and help you figure out how to do it if you really just want to do this without too much trouble. I would highly suggest you re-think your strategy for storing and updating settings in the long run to a method that isn't directly executable, and can give you some way of filtering to ensure you're not just writing a back door into whatever your project is for some malicious party to take advantage of, as this particular setup would be trivial to compromise in the best of situations. |
Messages In This Thread |
How can I write file without overwrite - by bomi - 06-17-2019, 01:41 PM
RE: How can I write file without overwrite - by mladoux - 06-17-2019, 04:36 PM
RE: How can I write file without overwrite - by bomi - 06-18-2019, 02:29 PM
RE: How can I write file without overwrite - by mladoux - 06-18-2019, 06:33 PM
RE: How can I write file without overwrite - by mladoux - 06-18-2019, 06:37 PM
RE: How can I write file without overwrite - by bomi - 06-18-2019, 10:46 PM
|