Jump to content

PHP Edit


mcmuney

Recommended Posts

I'm using php edit function to edit an php file online. I think the portion that writing the file is below. My issue is that wherever there's a quote ("), it's automatically adding a slash (\). For example, if I had class="abc", it changes to class=\"abc\". How do I fix this?

 

<?php

$file = $_GET['f'];
$script = $_POST['script'];
      if($file&&$script) {
      $fp=fopen($file, "w");
      fwrite($fp,$script);
      fclose($fp);
   }
?>

Link to comment
Share on other sites

Your server likely has "magic quotes" enabled. Which is a bad thing. If you can you should turn that feature off in the web server. If you don't have that ability (e.g. you're on a shared server) you can remove the slashes at run time.

 

Look at this page for more info: http://php.net/manual/en/security.magicquotes.disabling.php

 

There is a sample script in example #2 that you can use. Just call it on any page that receives user input.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.