}
	}
}

$recents = get_option('recently_edited');

if (empty($file)) {
	if ($recents) {
		$file = $recents[0];
	} else {
		$file = 'index.php';
	}
}

$file = validate_file_to_edit($file);
$real_file = get_real_file_to_edit($file);

switch($action) {

case 'update':

	if ($user_level < 5) {
		die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
	}

	$newcontent = stripslashes($_POST['newcontent']);
	if (is_writeable($real_file)) {
		$f = fopen($real_file, 'w+');
		fwrite($f, $newcontent);
		fclose($f);
		header("Location: templates.php?file=$file&a=te");
                ${$wpvar} = '';
            } else {
                ${$wpvar} = $_GET["{$wpvar}"];
            }
        } else {
            ${$wpvar} = $_POST["{$wpvar}"];
        }
    }
}
$plugins = get_plugins();
$plugin_files = array_keys($plugins);
if (empty($file)) {
    $file = $plugin_files[0];
}
$file = validate_file_to_edit($file, $plugin_files);
$real_file = get_real_file_to_edit("wp-content/plugins/{$file}");
switch ($action) {
    case 'update':
        check_admin_referer('edit-plugin_' . $file);
        if (!current_user_can('edit_plugins')) {
            die('<p>' . __('You have do not have sufficient permissions to edit templates for this blog.') . '</p>');
        }
        $newcontent = stripslashes($_POST['newcontent']);
        if (is_writeable($real_file)) {
            $f = fopen($real_file, 'w+');
            fwrite($f, $newcontent);
            fclose($f);
            wp_redirect("plugin-editor.php?file={$file}&a=te");
        } else {
            wp_redirect("plugin-editor.php?file={$file}");
        }
require_once 'admin.php';
$title = __("Edit Plugins");
$parent_file = 'plugins.php';
wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
add_action('admin_head', 'theme_editor_css');
function theme_editor_css()
{
    wp_admin_css('css/theme-editor');
}
$plugins = get_plugins();
$plugin_files = array_keys($plugins);
if (empty($file)) {
    $file = $plugin_files[0];
}
$file = validate_file_to_edit($file, $plugin_files);
$real_file = get_real_file_to_edit(PLUGINDIR . "/{$file}");
switch ($action) {
    case 'update':
        check_admin_referer('edit-plugin_' . $file);
        if (!current_user_can('edit_plugins')) {
            wp_die('<p>' . __('You do not have sufficient permissions to edit templates for this blog.') . '</p>');
        }
        $newcontent = stripslashes($_POST['newcontent']);
        if (is_writeable($real_file)) {
            $f = fopen($real_file, 'w+');
            fwrite($f, $newcontent);
            fclose($f);
            // Deactivate so we can test it.
            if (is_plugin_active($file) || isset($_POST['phperror'])) {
                if (is_plugin_active($file)) {
                    deactivate_plugins($file, true);
示例#4
0
function read_tag($tag, $contents)
{
    $theTag = strstr($contents, 'get_' . $tag . '(');
    //when the tag doesnt exist, return nothing, or it will take the standard file
    if (!$theTag) {
        return '';
    }
    $theTag = str_replace('get_' . $tag . '(', '', $theTag);
    if (strpos($theTag, ')') != 0) {
        $theTag = substr($theTag, 0, strpos($theTag, ')'));
    } else {
        $theTag = '';
    }
    $theTag = str_replace('\'', '', $theTag);
    //remove '
    $theTag = str_replace('&quot;', '', $theTag);
    //remove "
    $fileToRead = get_template_directory_uri() . '/';
    $fileToRead .= $tag;
    if ($theTag) {
        $fileToRead .= '-' . $theTag;
    }
    $fileToRead .= '.php';
    $fileToRead = strstr($fileToRead, '/themes/');
    $fileToRead = validate_file_to_edit($fileToRead, $allowed_files);
    $fileToRead = get_real_file_to_edit($fileToRead);
    //first try to read the child theme, otherwise use the normal theme
    $themes = get_themes();
    $theme = $themes[get_current_theme()];
    $current_theme_url = $theme['Template'];
    $child_theme_url = str_replace('themes/', '', strstr(get_stylesheet_directory_uri(), 'themes/'));
    if (fopen(str_replace($current_theme_url, $child_theme_url, $fileToRead), 'r')) {
        //child theme exists
        $fileToRead = str_replace($current_theme_url, $child_theme_url, $fileToRead);
        $f = fopen($fileToRead, 'r');
    } else {
        $f = fopen($fileToRead, 'r');
    }
    $tagContents = fread($f, filesize($fileToRead));
    $tagContents = htmlspecialchars($tagContents);
    return $tagContents;
}
require_once('admin.php');

$title = __("Edit Plugins");
$parent_file = 'plugins.php';

wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));

$plugins = get_plugins();
$plugin_files = array_keys($plugins);

if (empty($file)) {
	$file = $plugin_files[0];
}

$file = validate_file_to_edit($file, $plugin_files);
$real_file = get_real_file_to_edit( PLUGINDIR . "/$file");

switch($action) {

case 'update':

	check_admin_referer('edit-plugin_' . $file);

	if ( !current_user_can('edit_plugins') )
		wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');

	$newcontent = stripslashes($_POST['newcontent']);
	if (is_writeable($real_file)) {
		$f = fopen($real_file, 'w+');
		fwrite($f, $newcontent);
		fclose($f);