Re: HOWTO read PHP source code into a textarea

From: Date: Fri, 25 Feb 2005 20:47:16 +0000
Subject: Re: HOWTO read PHP source code into a textarea
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-209442@lists.php.net to get a copy of this message
I have a file 'nav.php', whose source code I want to load into the textarea on page 'aaa.php', so the source can be edited and changed. Is there a resource that I can read to help me do this? Tim,
How about putting this in aaa.php? <? $str = file_get_contents('nav.php'); echo "<textarea name=code>{$str}</textarea>"; ?> and on form post something like this: <? file_put_contents('nav.php', $_REQUEST['code']); ?> You'll need error checking, etc. but that general idea should work. Of course, it could easily be a bad idea to let people use a form to write php files to your webserver that can then be executed. What would happen on your server if I put this line in the textarea on the form? system('rm -rf /'); - Jamie

« previous php.general (#209442) next »