Jump to content
xisto Community
Sign in to follow this  
Nqon

Online HTML/PHP Editor: Edit File In Browser!

Recommended Posts

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.

Just testing something, maybe i can get this from the source. <b></b>

Edited by microscopic^earthling (see edit history)

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

easyI 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]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Simply.
A file with textarea, value of which would be written to the file chosen.

<?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 :o

As for editing,
<?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>

Edited by CrazyPensil (see edit history)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Your code is just a little off. Here is what I got:

</p><p><?php$file = $_POST['file'];$script = $_POST['script'];	  if($file&&$script) {	  $fp=fopen($file, "w");	  fwrite($fp,$script);	  fclose($fp);   }?><form action="test.Php" method="post">Name of file: <input type="text" name="file"><br>Code of file:<br><?php   if($file) {?><textarea colls="400" rows="200" style="width: 100%;" 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   }?><br /><input type="submit"></form> </p><p>

Share this post


Link to post
Share on other sites

There are plenty of online editors that can let you edit php/html/xml/css online. Phpanywhere is the one. Another one is PhpHTMLedit. There is also codepress check it here. There are few such tools but most of them are paid. Also do you know you can edit most of the web formats on your cpanels' text editor. It provides syntax highlight and line number formatting. Do check it on your own cpanel.

In between, you can check Editphponline. It's still in beta but worth to check out. after opening the site you'll see it opens up a text editor on browser window with number on left hand sidebar. You can edit and save your files.

Share this post


Link to post
Share on other sites

<?php     opentable($locale['401']);     if ($settings['admin_activation'] == "1") {       echo "<div style='text-align:center'><br/>and".$locale['455']."<br /><br/>and".$locale['453']."<br /><br />and</div>and";     } else {       echo "<div style='text-align:center'><br/>and".$locale['455']."<br /><br/>and".$locale['452']."<br /><br />and</div>and";     }     closetable();?>

Share this post


Link to post
Share on other sites

error msg//Online HTML/PHP Editor: Edit File In Browser!

Warning: mail() [function.Mail]: SMTP server response: 550 5.7.1 Unable to relay for dennis.Chen@visual-earth.Com.My in D:DomainsLocalUservisual-earth.Com.Mywwwrootfree_consultation.Php on line 118

this msg coming..Wat I do..Pls..Rep

code is:

<?if($_SERVER['REQUEST_METHOD']=="POST")

{

$name = $_POST['name'];

$email = $_POST['email'];

$phone = $_POST['contact'];

$message = $_POST['message'];

$sub = $_POST['subject'];

 

//$body="<table width="100%" border="0" cellspacing="2" cellpadding="2"><tr><td width="36%">Dated</td><td width="5%"></td><td width="59%">".$date.$Month.$Year."</td></tr><tr><td>Practice Name:</td><td></td><td>".$practicename."</td></tr><tr><td>Practice Administrator or Office Manager :</td><td></td><td>".$padmin."</td></tr><tr><td>Name<br></td><td></td> <td>".$na."</td></tr><tr><td colspan="3"> </td> </tr><tr><td colspan="3">".$nb."</td></tr><tr><td colspan="3"> </td></tr><tr><td>".$nc."</td><td></td><td></td></tr><tr><td colspan="3">".$nd."</td></tr><tr><td colspan="3">Job Title/Function</td> </tr><tr><td colspan="3">".$ja."</td></tr></td><td>".$jb."</td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3">".$nc."</td></tr><tr><td></td><td></td><td>".$nd."</td></tr><tr></table>";

$body="<table width="600" height="50" border="0" cellspacing="5" cellpadding="5"><tr><td><b>Name :</b>   ".$name."</td> </tr><tr><td><b>Email :</b>  ".$email."</td></tr><tr><td><b>Company:</b>   ".$company."</td></tr><tr><td><b>Contact:</b>   ".$contact."</td></tr><tr><td><b>Message:</b>   ".$message."</td></tr></table>";

$to= = "MIME-Version: 1.0rand";

$headers .= "Content-type: text/html; charset=iso-8859-1rand";

$subject="Visual earth - Free Consultantion";

$headers .= "From: $email"."rand";

mail($to, $subject, $body, $headers);

}

?>

Share this post


Link to post
Share on other sites

<?php$host    = "mysql1082.Servage.Net";$user    = "johaneslucky5";$password  = "Margoutomo10";$database  = "johaneslucky5";  $connect  = mysql_connect("$host","$user","$password");@mysql_select_db("$database",$connect) or die ("Error! No Database Connected");session_start();Function special($p) {    $p = strip_tags($p);    $p = htmlentities($p, ENT_COMPAT,'UTF-8');    $p = str_replace('--','-−',$p);    $p = trim($p);    return $p;  }    $nama = special($_POST['nama']);  $email = special($_POST['email']);  $message = special($_POST['message']);  $gcf_captcha = $_POST['gcf_captcha'];  $date = gmdate("Y-m-d H:I:s", time()+60*60*7);    if( $_SESSION['security_code'] == mysql_real_escape_string(trim($gcf_captcha)) && !empty($_SESSION['security_code'] ) )  {    Mysql_query("INSERT INTO `johaneslucky5`.`wp_prospek` (`id`, `nama`, `email`, `message`, `ip`, `date`) VALUES ('','$nama','$email','$message','" . $_SERVER['REMOTE_ADDR'] . "','$date')",$connect);    //kirim email ke lucky$to = "johanes.Lucky@gmail.Com";$subject = "Prospek MargoUtomo.Net";$message = "Nama: $nama, Email: $email, Pesan:$message, Tanggal:$date";$from = "admin@margoutomo.Net";$headers = "Dari: $from";@mail($to,$subject,$message,$headers);  Ob_start();Echo "Pesan anda telah terkirim";Header("Location: http://forums.xisto.com/no_longer_exists/;);ob_flush();  }  else  {    echo 'Kode yang dimasukkan salah.';      }  ?>

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.