|
|
|
|
![]() ![]() |
May 17 2005, 03:08 PM
Post
#1
|
|
|
Member [ Level 1 ] Group: Members Posts: 45 Joined: 5-May 05 Member No.: 4,758 |
Im wondering how you can load a file into a text area and edit it. Lets say i have a php file called test.php and id like this file to be loaded into a textarea and the user should be able to edit this file and store it.
Is this posible? Im also wondering how you make it so the html dosnt get encoded by the browser, lets say i need to explain on my website how you use html. CODE Just testing something, maybe i can get this from the source. <b></b>
This post has been edited by microscopic^earthling: Jun 29 2005, 06:50 PM |
|
|
|
May 17 2005, 03:30 PM
Post
#2
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 |
Why don't you google for HTMLArea Text Editor - that does the exact same job - i.e. creates an online text editor. Combine the code of that with some file saving/uploading routines in PHP and you'll get your desired results
|
|
|
|
May 17 2005, 03:38 PM
Post
#3
|
|
|
Member [ Level 1 ] Group: Members Posts: 45 Joined: 5-May 05 Member No.: 4,758 |
Thanks, but how do I get the php into the textarea without it being executed?
|
|
|
|
May 17 2005, 05:18 PM
Post
#4
|
|
|
Pretty please? Group: Members Posts: 733 Joined: 28-November 04 From: Holland Member No.: 1,552 |
easy
I made a editor by myself, let me enlighten you. If you encode all HTML like characters like < > to < , >, the < and > will show up correctly in the textarea but won't be executed. And posting is just posting the contents of the textarea and have a php file write it to a file. You also might want to wacht out for CHMODDING issues [brag] Mine works so nicely that I use that instead of SSH'ing to the server. [/brag] |
|
|
|
May 18 2005, 08:14 AM
Post
#5
|
|
|
Member [ Level 1 ] Group: Members Posts: 45 Joined: 5-May 05 Member No.: 4,758 |
Yes yes, I found out how you did that pritty quickly, but my problem is that the PHP file gets executed into the editing textarea, is there a way to avoid that?
The point of editing the php file is that it needs to be executed at some point! I know about the chmodding issues. But is there a way to bring the php file into the textarea without it being executed, i know i can use special characters that will stop it from being executed, but that would stop it from being executet all the time. I want it to be executed when it is included in the site. |
|
|
|
May 18 2005, 02:45 PM
Post
#6
|
|
|
Pretty please? Group: Members Posts: 733 Joined: 28-November 04 From: Holland Member No.: 1,552 |
What do you see when you open a file with : <?php echo 'test'; ?> in it?
exactly, you'll see <?php echo 'test'; ?> in the textarea, but what was in the source? < and all those other html characters. But when you POST it up to the server, it will just post <?php echo 'test'; ?>, because you will post up what up SEE in the textarea. |
|
|
|
Jun 29 2005, 06:28 PM
Post
#7
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 13 Joined: 29-June 05 Member No.: 6,692 |
I use PHP's htmlspecialchars() to show HTML coding.
There's a function which can be used to decode what has been encoded. It's htmlspecialchars_decode(). Unfortunately, this decoder is available only in PHP5. |
|
|
|
Mar 18 2006, 09:06 AM
Post
#8
|
|
|
Member [ Level 1 ] Group: Members Posts: 42 Joined: 17-March 06 From: Russia, St.Petersburg Member No.: 12,058 |
Simply.
A file with textarea, value of which would be written to the file chosen. CODE <?php if($file&&$script) { $fp=fopen($file, "w"); fwrite($fp,$script); fclose($fp); } ?> <form action="index.php" method=post> Name of file: <input type=text name=file><br> Code of file:<br> <textarea colls=400 rows=200 name=script></textarea> <input type=submit> </form> I hope, you'll be able to complete it yourself As for editing, CODE <?php
if($file&&$script) { $fp=fopen($file, "w"); fwrite($fp,$script); fclose($fp); } ?> <form action="index.php" method=post> Name of file: <input type=text name=file><br> Code of file:<br> <?php if($file) { ?> <textarea colls=400 rows=200 name=script> <?php $fp=fopen($file,"r"); $t=""; while(!feof($fp)) { $t.=fread($fp,1024); } fclose($fp); print $t; } </textarea> <input type=hidden name=file value="<?=$file;?>"> <?php } ?> <input type=submit> </form> This post has been edited by CrazyPensil: Mar 18 2006, 09:07 AM |
|
|
|
Apr 30 2006, 01:37 AM
Post
#9
|
|
|
Member [ Level 1 ] Group: Members Posts: 48 Joined: 30-April 06 From: Salisbury Member No.: 13,107 |
Try using one of those frameworks, script.acolo.us or MooScript I think, they have some examples that I'm unsure of, but just might be exactly what you were looking for.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 8th September 2008 - 06:49 AM |