Changeset 1028 for trunk/wp-admin/templates.php
- Timestamp:
- 03/29/2004 10:43:07 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/templates.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/templates.php
r1020 r1028 12 12 return $array; 13 13 } 14 15 function validate_file($file) { 16 if ('..' == substr($file,0,2)) 17 die ('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'); 18 19 if (':' == substr($file,1,1)) 20 die ('Sorry, can’t call files with their real path.'); 21 22 if ('/' == substr($file,0,1)) 23 $file = '.' . $file; 24 25 $file = stripslashes($file); 26 $file = str_replace('../', '', $file); 27 28 return $file; 29 } 14 30 15 31 if (!get_magic_quotes_gpc()) { … … 48 64 $newcontent = stripslashes($HTTP_POST_VARS['newcontent']); 49 65 $file = $HTTP_POST_VARS['file']; 50 $f = fopen($file, 'w+'); 51 fwrite($f, $newcontent); 52 fclose($f); 66 $file = validate_file($file); 67 $real_file = '../' . $file; 68 if (is_writeable($real_file)) { 69 $f = fopen($real_file, 'w+'); 70 fwrite($f, $newcontent); 71 fclose($f); 72 header("Location: templates.php?file=$file&a=te"); 73 } else { 74 header("Location: templates.php?file=$file"); 75 } 53 76 54 $file = str_replace('../', '', $file);55 header("Location: templates.php?file=$file&a=te");56 77 exit(); 57 78 … … 73 94 } 74 95 } 96 97 $file = validate_file($file); 98 $real_file = '../' . $file; 75 99 76 if ('..' == substr($file,0,2)) 77 die ('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'); 78 79 if (':' == substr($file,1,1)) 80 die ('Sorry, can’t call files with their real path.'); 81 82 if ('/' == substr($file,0,1)) 83 $file = '.' . $file; 84 85 $file = stripslashes($file); 86 $file = str_replace('../', '', $file); 87 $file = '../' . $file; 88 89 if (!is_file($file)) 100 if (!is_file($real_file)) 90 101 $error = 1; 91 102 … … 94 105 95 106 if (!$error) { 96 $f = fopen($ file, 'r');97 $content = fread($f, filesize($ file));107 $f = fopen($real_file, 'r'); 108 $content = fread($f, filesize($real_file)); 98 109 $content = htmlspecialchars($content); 99 110 // $content = str_replace("</textarea","</textarea",$content); … … 115 126 <br /> 116 127 <?php 117 if (is_writeable($ file)) {128 if (is_writeable($real_file)) { 118 129 echo "<input type='submit' name='submit' value='Update File' tabindex='2' />"; 119 130 } else {
Note: See TracChangeset
for help on using the changeset viewer.