2010-11-21 9 views
2

죄송합니다! 나는 그것을 알아. 슬래시를 제거해야했습니다 ...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> 
+0

[magic_quotes] (http://www.php.net/manual/ko/security.magicquotes.whynot.php)를 확인하십시오. – frayser

답변

0

이것은 ISP에 여전히 Magic Quotes이 설정되어 있기 때문에 발생합니다. 이상적으로는 계정을 사용 중지하거나 계정 구성 방법을 찾아야합니다.

이 작업을 수행 할 수없는 경우 stripslashes 또는 이와 동등한 것을 사용해야합니다. 이 다른 질문을보십시오 : How to turn off magic quotes on shared hosting?

0

'magic quotes'이 켜져 있습니다. 그들은 마술이 아닙니다.

이 설정을 감지하고 get_magic_quotes_gpc 또는 get_magic_quotes_runtime으로 확인하여 마법을 취소 할 수 있습니다.

$value=get_magic_quotes_gpc()?stripslashes($_REQUEST['value']):_REQUEST['value'];