Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Online HTML/PHP Editor: Edit File In Browser!
Nqon
post May 17 2005, 03:08 PM
Post #1


Member [ Level 1 ]
Group Icon

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
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post May 17 2005, 03:30 PM
Post #2


PsYcheDeLiC dR3aMeR
Group Icon

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 smile.gif
Go to the top of the page
 
+Quote Post
Nqon
post May 17 2005, 03:38 PM
Post #3


Member [ Level 1 ]
Group Icon

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?
Go to the top of the page
 
+Quote Post
jipman
post May 17 2005, 05:18 PM
Post #4


Pretty please?
Group Icon

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 &lt; , &gt;, 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 wink.gif

[brag]
Mine works so nicely that I use that instead of SSH'ing to the server.
[/brag]
Go to the top of the page
 
+Quote Post
Nqon
post May 18 2005, 08:14 AM
Post #5


Member [ Level 1 ]
Group Icon

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.
Go to the top of the page
 
+Quote Post
jipman
post May 18 2005, 02:45 PM
Post #6


Pretty please?
Group Icon

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?
&lt; 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.
Go to the top of the page
 
+Quote Post
manymanymuch
post Jun 29 2005, 06:28 PM
Post #7


Newbie [ Level 2 ]
Group Icon

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.
Go to the top of the page
 
+Quote Post
CrazyPensil
post Mar 18 2006, 09:06 AM
Post #8


Member [ Level 1 ]
Group Icon

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 smile.gif

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
Go to the top of the page
 
+Quote Post
Opethian
post Apr 30 2006, 01:37 AM
Post #9


Member [ Level 1 ]
Group Icon

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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php Script To Download File From Another Site(9)
  2. Script To Calculate/report Html Document Filesize(7)
  3. Php Reading And Writing To File(4)
  4. Counter With Img In Flat File(0)
  5. PHP File Upload Works... But Stupid IE(3)
  6. Display Text If Line Not Empty In Config File(8)
  7. PHP Script To Upload A File(13)
  8. Generating A Table Into A File In CSV Format(6)
  9. How Can I Write PHP Code By This Formmail Html(5)
  10. How To Create An Online Timed Test With PHP?(17)
  11. How To Embed Ram File Produced By Http Header(2)
  12. Xgrid With Php(0)
  13. Updating An Rss File Using A Php Form(1)
  14. How To Edit Php Files?(16)
  15. File Self Secure?(6)
  1. OpenWYSIWYG Instead Of RichTextEditor(3)
  2. How To Delete File Using PHP Shell Script(3)
  3. Backing Up User Forms As Static HTML(5)
  4. How To Force A Zip File To Be Downloaded(11)
  5. Online Multiplayer Chess Script(2)
  6. Automated File Structure Creation Script(3)
  7. Php - Browser Based Editor(3)
  8. Php File Upload(3)
  9. Windows Explorer Impersonator - The Online Explorer(13)
  10. Extplorer(7)
  11. Make A Script Run Even If No User Is Online(6)
  12. How To Create/edit/delete Ftp Accounts With Php(1)


 



- Lo-Fi Version Time is now: 8th September 2008 - 06:49 AM