Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

how to make a php page that edits and clears another PHP file

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.
(May 12, 2012 11:52 AM)alphabot Wrote:  Here is my version, you could put it into a function if you want.

Code
<?php
    $log = fopen("logs/log.php", "r");
    $t = array();
    for($i=0; $i<5; $i++) {
        $t[] =fgets($log);
    }
    fclose($log);

    $log = fopen("logs/log.php", "w");
    foreach($t as $v) {
        fwrite($log, $v);
    }

    //Write your stuff
    fwrite($log, "Test");

    fclose($log);
?>

benefit of my code is that it's dynamic.

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


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by t0pemieFeb 20, 2018 12:04 PM 4 176 Feb 20, 2018 12:04 PM
Last Post: V3t3r4n
[PHP] by jamesgates1Jul 20, 2014 04:33 PM 8 303 Jul 20, 2014 04:33 PM
Last Post: jamesgates1
[PHP] by MilitiaSep 14, 2012 07:11 PM 0 63 Sep 14, 2012 07:11 PM
Last Post: Militia