Check fopen return value. Props Otto42 and pishmishy. fixes #4448

git-svn-id: http://svn.automattic.com/wordpress/trunk@8208 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-06-27 20:14:50 +00:00
parent 6ae5dbab86
commit 216cdeedea
1 changed files with 8 additions and 3 deletions

View File

@ -43,13 +43,18 @@ case 'update':
$newcontent = stripslashes($_POST['newcontent']); $newcontent = stripslashes($_POST['newcontent']);
$theme = urlencode($theme); $theme = urlencode($theme);
if (is_writeable($real_file)) { if (is_writeable($real_file)) {
//is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
$f = fopen($real_file, 'w+'); $f = fopen($real_file, 'w+');
if ($f !== FALSE) {
fwrite($f, $newcontent); fwrite($f, $newcontent);
fclose($f); fclose($f);
$location = "theme-editor.php?file=$file&theme=$theme&a=te"; $location = "theme-editor.php?file=$file&theme=$theme&a=te";
} else { } else {
$location = "theme-editor.php?file=$file&theme=$theme"; $location = "theme-editor.php?file=$file&theme=$theme";
} }
} else {
$location = "theme-editor.php?file=$file&theme=$theme";
}
$location = wp_kses_no_null($location); $location = wp_kses_no_null($location);
$strip = array('%0d', '%0a'); $strip = array('%0d', '%0a');