Add error checking to file save. fixes #2109
git-svn-id: http://svn.automattic.com/wordpress/trunk@3335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ebf2f33207
commit
f33dda4dd2
|
@ -41,12 +41,16 @@ case 'update':
|
||||||
|
|
||||||
$newcontent = stripslashes($_POST['newcontent']);
|
$newcontent = stripslashes($_POST['newcontent']);
|
||||||
if (is_writeable($real_file)) {
|
if (is_writeable($real_file)) {
|
||||||
$f = fopen($real_file, 'w+');
|
$f = @ fopen($real_file, 'w+');
|
||||||
fwrite($f, $newcontent);
|
if ( $f ) {
|
||||||
fclose($f);
|
fwrite($f, $newcontent);
|
||||||
header("Location: templates.php?file=$file&a=te");
|
fclose($f);
|
||||||
|
header("Location: templates.php?file=$file&a=te");
|
||||||
|
} else {
|
||||||
|
header("Location: templates.php?file=$file&a=err");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
header("Location: templates.php?file=$file");
|
header("Location: templates.php?file=$file&a=err");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
|
@ -66,17 +70,25 @@ default:
|
||||||
update_recently_edited($file);
|
update_recently_edited($file);
|
||||||
|
|
||||||
if (!is_file($real_file))
|
if (!is_file($real_file))
|
||||||
$error = 1;
|
$error = true;
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$f = fopen($real_file, 'r');
|
$f = @ fopen($real_file, 'r');
|
||||||
$content = fread($f, filesize($real_file));
|
if ( $f ) {
|
||||||
$content = htmlspecialchars($content);
|
$content = fread($f, filesize($real_file));
|
||||||
|
$content = htmlspecialchars($content);
|
||||||
|
} else {
|
||||||
|
$error = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<?php if (isset($_GET['a'])) : ?>
|
<?php if (isset($_GET['a'])) : ?>
|
||||||
|
<?php if ( 'err' == $_GET['a'] ) : ?>
|
||||||
|
<div id="message" class="error"><p><?php _e('Could not save file.') ?></p></div>
|
||||||
|
<? else: ?>
|
||||||
<div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
|
<div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
|
||||||
|
<?endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in New Issue