Make WordPress Core

Ticket #11032: 11032.diff

File 11032.diff, 3.4 KB (added by dd32, 14 years ago)
  • wp-admin/includes/file.php

     
    206206                case 1 :
    207207                        wp_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.' ));
    208208
    209                 case 2 :
    210                         wp_die( __('Sorry, can’t call files with their real path.' ));
     209                //case 2 :
     210                //      wp_die( __('Sorry, can’t call files with their real path.' ));
    211211
    212212                case 3 :
    213213                        wp_die( __('Sorry, that file cannot be edited.' ));
  • wp-admin/theme-editor.php

     
    3333$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
    3434
    3535if (empty($file)) {
    36         $file = $allowed_files[0];
     36        $file = addslashes($allowed_files[0]);
    3737} else {
    3838        if ( 'theme' == $dir ) {
    3939                $file = dirname(dirname($themes[$theme]['Template Dir'])) . $file ;
     
    4242        }
    4343}
    4444
    45 $real_file = validate_file_to_edit($file, $allowed_files);
     45validate_file_to_edit($file, $allowed_files);
    4646$scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0;
    47 
    4847$file_show = basename( $file );
    4948
    5049switch($action) {
     
    5554
    5655        $newcontent = stripslashes($_POST['newcontent']);
    5756        $theme = urlencode($theme);
    58         if (is_writeable($real_file)) {
     57        if (is_writeable($file)) {
    5958                //is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
    60                 $f = fopen($real_file, 'w+');
     59                $f = fopen($file, 'w+');
    6160                if ($f !== FALSE) {
    6261                        fwrite($f, $newcontent);
    6362                        fclose($f);
     
    8382
    8483        update_recently_edited($file);
    8584
    86         if ( !is_file($real_file) )
     85        if ( !is_file($file) )
    8786                $error = 1;
    8887
    89         if ( !$error && filesize($real_file) > 0 ) {
    90                 $f = fopen($real_file, 'r');
    91                 $content = fread($f, filesize($real_file));
     88        if ( !$error && filesize($file) > 0 ) {
     89                $f = fopen($file, 'r');
     90                $content = fread($f, filesize($file));
    9291
    93                 if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) {
     92                if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) {
    9493                        $functions = wp_doc_link_parse( $content );
    9594
    9695                        $docs_select = '<select name="docs-list" id="docs-list">';
     
    102101                }
    103102
    104103                $content = htmlspecialchars( $content );
    105                 $codepress_lang = codepress_get_lang($real_file);
     104                $codepress_lang = codepress_get_lang($file);
    106105        }
    107106
    108107        ?>
     
    212211        <?php } ?>
    213212
    214213                <div>
    215 <?php if ( is_writeable($real_file) ) : ?>
     214<?php if ( is_writeable($file) ) : ?>
    216215                        <p class="submit">
    217216<?php
    218217        echo "<input type='submit' name='submit' class='button-primary' value='" . esc_attr__('Update File') . "' tabindex='2' />";
  • wp-includes/functions.php

     
    30683068        if ( false !== strpos( $file, './' ))
    30693069                return 1;
    30703070
     3071        if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
     3072                return 3;
     3073
    30713074        if (':' == substr( $file, 1, 1 ))
    30723075                return 2;
    30733076
    3074         if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
    3075                 return 3;
    3076 
    30773077        return 0;
    30783078}
    30793079