![]() |
|
[PHP] how to make a php page that edits and clears another PHP file - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183) +---- Thread: [PHP] how to make a php page that edits and clears another PHP file (/showthread.php?tid=2489017) |
how to make a php page that edits and clears another PHP file - Crazer - May 12, 2012 Ok so I would need /admin/logs.php to view and be able to edit ../logs/log.php but after lets say the 5th line of code. I would like to to clear it also and remove ALL text after line 5, But lines 1-5 should not be touched. also i need /admin/indexfile.php to view and edit ../index.php but the whole file. * - Novalty - May 12, 2012 Give this a go. I've not tested it at all so there a very good chance I've missed something. It's just the first one. PHP Code * - alphabot - May 12, 2012 Here is my version, you could put it into a function if you want. Code <?phpbenefit of my code is that it's dynamic. EDIT: Meh just reread what you wanted. Anyway, you could incorporate mine into his to make his dynamic. * - Crazer - May 12, 2012 (May 12, 2012 11:52 AM)alphabot Wrote: Here is my version, you could put it into a function if you want. Okay man, did not work for one. 1) deleted my first 5 lines of code, 2) as soon as i run code it deletes everything i only want it to delete when i hit delete and display code on load under line 5, and only want to remove underline 5 * - alphabot - May 12, 2012 Here we go, try this: (its based off of mine and his) Code <?php * - Novalty - May 13, 2012 Just wondering, did mine work okay? Since I never actually tested it I don't know for sure! * - YERANUK - May 13, 2012 $filepath = 'path/to/file' file_put_contents($filepath, implode(array_slice(file($filepath), 0, 5))); |