죄송합니다! 나는 그것을 알아. 슬래시를 제거해야했습니다 ...PHP 쓰기 파일 쓰기
안녕하세요, 브라우저에서 설정 파일을 편집 할 수있는 다음 코드가 있습니다. 파일 내용이 검색되어 텍스트 상자에 표시됩니다. 그런 다음 편집 내용이 다시 파일에 저장됩니다. 내 개발 컴퓨터에서 모든 것이 잘 작동하지만 호스팅 계정에서는 작동하지 않습니다.
파일을 저장할 때 모든 작은 따옴표 앞에 백 슬래시가 추가되어 쓰여집니다.
어떻게하면 내 코드를 변경하여이를 방지 할 수 있습니까? 고맙습니다!
<?php
// button javascript
$save_changes_js = "return confirm('Do you want to SAVE the CHANGE(S)?');";
// open web config
$filename = ROOT_PATH.'web.config.php';
$contents = file_get_contents($filename);
if(isset($_POST['txbConfig']) && !empty($_POST['txbConfig']))
{
// save changes to file
$changes = $_POST['txbConfig'];
file_put_contents($filename,$changes);
// refresh page
$destination_url = SITE_URL.'admin/edit-config.php';
header('Location:'.$destination_url);
}
?>
<form action="" method="post" name="editConfig" class="htmlForm">
<div class="editConfigWrap">
<textarea name="txbConfig"><?php echo $contents ?></textarea>
</div>
<input name="submit" type="submit" value="Save Changes" class="gvbtn" onclick="<?php echo $save_changes_js; ?>">
</form>
[magic_quotes] (http://www.php.net/manual/ko/security.magicquotes.whynot.php)를 확인하십시오. – frayser