[wp-cvs]
wordpress/wp-admin admin-functions.php, 1.53, 1.54 menu.php,
1.31, 1.32 templates.php, 1.27, 1.28 theme-editor.php, 1.4, 1.5
Ryan Boren
rboren at users.sourceforge.net
Wed Nov 17 03:15:26 UTC 2004
- Previous message: [wp-cvs] wordpress/wp-admin page-new.php, NONE,
1.1 edit-page-form.php, 1.8, 1.9 edit-pages.php, 1.6,
1.7 menu.php, 1.30, 1.31 post.php, 1.107, 1.108
- Next message: [wp-cvs] wordpress/wp-admin plugin-editor.php,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/cafelog/wordpress/wp-admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22504/wp-admin
Modified Files:
admin-functions.php menu.php templates.php theme-editor.php
Log Message:
Theme, plugin, and file editing cleanup. Work in progress.
Index: templates.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/templates.php,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** templates.php 19 Oct 2004 03:03:06 -0000 1.27
--- templates.php 17 Nov 2004 03:15:22 -0000 1.28
***************
*** 2,22 ****
require_once('admin.php');
$title = __('Template & file editing');
! $parent_file = 'themes.php';
!
! function validate_file($file) {
! if ('..' == substr($file,0,2))
! 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.'));
!
! if (':' == substr($file,1,1))
! die (__('Sorry, can’t call files with their real path.'));
!
! if ('/' == substr($file,0,1))
! $file = '.' . $file;
!
! $file = stripslashes($file);
! $file = str_replace('../', '', $file);
!
! return $file;
! }
$wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
--- 2,6 ----
require_once('admin.php');
$title = __('Template & file editing');
! $parent_file = 'edit.php';
$wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
***************
*** 36,39 ****
--- 20,30 ----
}
+ if (empty($file)) {
+ $file = 'index.php';
+ }
+
+ $file = validate_file_to_edit($file);
+ $real_file = get_real_file_to_edit($file);
+
switch($action) {
***************
*** 45,59 ****
$newcontent = stripslashes($_POST['newcontent']);
! $file = $_POST['file'];
! $file = validate_file($file);
! $real_file = '../' . $file;
! if (is_writeable($real_file)) {
! $f = fopen($real_file, 'w+');
! fwrite($f, $newcontent);
! fclose($f);
! header("Location: templates.php?file=$file&a=te");
! } else {
! header("Location: templates.php?file=$file");
! }
exit();
--- 36,47 ----
$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");
! } else {
! header("Location: templates.php?file=$file");
! }
exit();
***************
*** 68,102 ****
}
! if ('' == $file) {
! $file = 'index.php';
! } else {
! $oldfiles = (array) get_option('recently_edited');
! if ($oldfiles) {
! $oldfiles = array_reverse($oldfiles);
! $oldfiles[] = $file;
! $oldfiles = array_reverse($oldfiles);
! $oldfiles = array_unique($oldfiles);
! if ( 5 < count($oldfiles) )
! array_pop($oldfiles);
! } else {
! $oldfiles[] = $file;
! }
! update_option('recently_edited', $oldfiles);
! }
- $home = get_settings('home');
- if (($home != '' && $home != get_settings('siteurl')) &&
- ('index.php' == $file || get_settings('blogfilename') == $file ||
- '.htaccess' == $file)) {
- $home_root = parse_url($home);
- $home_root = $home_root['path'];
- $root = str_replace($_SERVER['PHP_SELF'], '', $_SERVER['PATH_TRANSLATED']);
- $home_root = $root . $home_root;
- $real_file = $home_root . '/' . $file;
- } else {
- $file = validate_file($file);
- $real_file = '../' . $file;
- }
-
if (!is_file($real_file))
$error = 1;
--- 56,61 ----
}
! update_recently_edited($file);
if (!is_file($real_file))
$error = 1;
***************
*** 128,133 ****
echo '<ol>';
foreach ($recents as $recent) :
! $display = preg_replace('|.*/(.*)$|', '$1', $recent);
! echo "<li><a href='templates.php?file=$recent'>$display</a>";
endforeach;
echo '</ol>';
--- 87,91 ----
echo '<ol>';
foreach ($recents as $recent) :
! echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a>";
endforeach;
echo '</ol>';
***************
*** 135,146 ****
?>
<h3><?php _e('Common'); ?></h3>
<ul>
! <li><a href="templates.php?file=index.php"><?php _e('Main Index') ?></a></li>
! <li><a href="templates.php?file=wp-layout.css"><?php _e('Main Stylesheet') ?></a></li>
! <li><a href="templates.php?file=wp-comments.php"><?php _e('Comments') ?></a></li>
! <li><a href="templates.php?file=wp-comments-popup.php"><?php _e('Popup comments') ?></a></li>
! <li><a href="templates.php?file=.htaccess"><?php _e('.htaccess (for rewrite rules)') ?></a></li>
! <li><a href="templates.php?file=my-hacks.php"><?php _e('my-hacks.php (legacy hacks support)') ?></a></li>
! </ul>
</div>
<?php if (!$error) { ?>
--- 93,102 ----
?>
<h3><?php _e('Common'); ?></h3>
+ <?php $common_files = array('index.php', 'wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php', '.htaccess', 'my-hacks.php'); ?>
<ul>
! <?php foreach ($common_files as $common_file) : ?>
! <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li>
! <? endforeach; ?>
! </ul>
</div>
<?php if (!$error) { ?>
***************
*** 175,195 ****
</form>
- <?php
- $plugins_dir = @ dir(ABSPATH . 'wp-content/plugins');
- if ($plugins_dir) {
- while(($file = $plugins_dir->read()) !== false) {
- if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
- $plugin_files[] = $file;
- }
- }
- if ($plugins_dir || $plugin_files) :
- ?>
- <p>Plugin files:</p>
- <ul>
- <?php foreach($plugin_files as $plugin_file) : ?>
- <li><a href="templates.php?file=wp-content/plugins/<?php echo $plugin_file; ?>"><?php echo $plugin_file; ?></a></li>
- <?php endforeach; ?>
- </ul>
- <?php endif; ?>
<p><?php _e('Note: of course, you can also edit the files/templates in your text editor of choice and upload them. This online editor is only meant to be used when you don’t have access to a text editor or FTP client.') ?></p>
</div>
--- 131,134 ----
Index: menu.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/menu.php,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** menu.php 16 Nov 2004 19:29:51 -0000 1.31
--- menu.php 17 Nov 2004 03:15:22 -0000 1.32
***************
*** 25,28 ****
--- 25,29 ----
$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiting_mod), 1, 'moderation.php');
+ $submenu['edit.php'][30] = array(__('Files'), 5, 'templates.php');
$submenu['link-manager.php'][5] = array(__('Manage Links'), 5, 'link-manager.php');
***************
*** 41,47 ****
$submenu['options-general.php'][30] = array(__('Miscellaneous'), 5, 'options-misc.php');
$submenu['themes.php'][5] = array(__('Themes'), 5, 'themes.php');
$submenu['themes.php'][10] = array(__('Theme Editor'), 5, 'theme-editor.php');
- $submenu['themes.php'][15] = array(__('Other Files'), 5, 'templates.php');
do_action('admin_menu', '');
--- 42,50 ----
$submenu['options-general.php'][30] = array(__('Miscellaneous'), 5, 'options-misc.php');
+ $submenu['plugins.php'][5] = array(__('Plugins'), 5, 'plugins.php');
+ $submenu['plugins.php'][10] = array(__('Plugin Editor'), 5, 'plugin-editor.php');
+
$submenu['themes.php'][5] = array(__('Themes'), 5, 'themes.php');
$submenu['themes.php'][10] = array(__('Theme Editor'), 5, 'theme-editor.php');
do_action('admin_menu', '');
Index: admin-functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/admin-functions.php,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** admin-functions.php 24 Oct 2004 23:48:51 -0000 1.53
--- admin-functions.php 17 Nov 2004 03:15:13 -0000 1.54
***************
*** 730,732 ****
--- 730,816 ----
}
+
+ function validate_file_to_edit($file, $allowed_files = '') {
+ if ('..' == substr($file,0,2))
+ 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.'));
+
+ if (':' == substr($file,1,1))
+ die (__('Sorry, can’t call files with their real path.'));
+
+ if ( !empty($allowed_files) && (! in_array($file, $allowed_files)) ) {
+ die (__('Sorry, that file cannot be edited.'));
+ }
+
+ $file = stripslashes($file);
+
+ return $file;
+ }
+
+ function get_real_file_to_edit($file) {
+ $home = get_settings('home');
+ if (($home != '')
+ && ($home != get_settings('siteurl')) &&
+ ('index.php' == $file || get_settings('blogfilename') == $file ||
+ '.htaccess' == $file)) {
+ $home_root = parse_url($home);
+ $home_root = $home_root['path'];
+ $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
+ $home_root = $root . $home_root;
+ $real_file = $home_root . '/' . $file;
+ } else {
+ $real_file = ABSPATH . $file;
+ }
+
+ return $real_file;
+ }
+
+ $wp_file_descriptions = array('index.php' => __('Main Template'),
+ 'wp-layout.css' => __('Stylesheet'),
+ 'style.css' => __('Stylesheet'),
+ 'wp-comments.php' => __('Comments Template'),
+ 'comments.php' => __('Comments Template'),
+ 'wp-comments-popup.php' => __('Popup Comments Template'),
+ 'comments-popup.php' => __('Popup Comments Template'),
+ 'wp-footer.php' => __('Footer Template'),
+ 'footer.php' => __('Footer Template'),
+ 'wp-header.php' => __('Header Template'),
+ 'header.php' => __('Header Template'),
+ 'wp-sidebar.php' => __('Sidebar Template'),
+ 'sidebar.php' => __('Sidebar Template'),
+ 'archive.php' => __('Archive Template'),
+ 'category.php' => __('Category Template'),
+ 'page.php' => __('Page Template'),
+ 'search.php' => __('Search Template'),
+ 'single.php' => __('Post Template'),
+ '404.php' => __('404 Template'),
+ 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'),
+
+ '.htaccess' => __('.htaccess (for rewrite rules)')
+ );
+
+ function get_file_description($file) {
+ global $wp_file_descriptions;
+
+ if (isset($wp_file_descriptions[$file])) {
+ return $wp_file_descriptions[$file];
+ }
+
+ return $file;
+ }
+
+ function update_recently_edited($file) {
+ $oldfiles = (array) get_option('recently_edited');
+ if ($oldfiles) {
+ $oldfiles = array_reverse($oldfiles);
+ $oldfiles[] = $file;
+ $oldfiles = array_reverse($oldfiles);
+ $oldfiles = array_unique($oldfiles);
+ if ( 5 < count($oldfiles) )
+ array_pop($oldfiles);
+ } else {
+ $oldfiles[] = $file;
+ }
+ update_option('recently_edited', $oldfiles);
+ }
+
?>
\ No newline at end of file
Index: theme-editor.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/theme-editor.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** theme-editor.php 19 Oct 2004 03:03:06 -0000 1.4
--- theme-editor.php 17 Nov 2004 03:15:22 -0000 1.5
***************
*** 2,24 ****
require_once('admin.php');
! $title = __("Template & file editing");
$parent_file = 'themes.php';
- function validate_file($file) {
- if ('..' == substr($file,0,2))
- 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.'));
-
- if (':' == substr($file,1,1))
- die (__('Sorry, can’t call files with their real path.'));
-
- if ('/' == substr($file,0,1))
- $file = '.' . $file;
-
- $file = stripslashes($file);
- $file = str_replace('../', '', $file);
-
- return $file;
- }
-
$wpvarstoreset = array('action','redirect','profile','error','warning','a','file', 'theme');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
--- 2,8 ----
require_once('admin.php');
! $title = __("Edit Themes");
$parent_file = 'themes.php';
$wpvarstoreset = array('action','redirect','profile','error','warning','a','file', 'theme');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
***************
*** 37,40 ****
--- 21,39 ----
}
+ $themes = get_themes();
+
+ if (empty($theme)) {
+ $theme = get_current_theme();
+ }
+
+ $allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $allowed_files, $themes[$theme]['Template Files']);
+
+ if (empty($file)) {
+ $file = $allowed_files[0];
+ }
+
+ $file = validate_file_to_edit($file, $allowed_files);
+ $real_file = get_real_file_to_edit($file);
+
switch($action) {
***************
*** 46,60 ****
$newcontent = stripslashes($_POST['newcontent']);
! $file = $_POST['file'];
! $file = validate_file($file);
! $real_file = '../' . $file;
! if (is_writeable($real_file)) {
! $f = fopen($real_file, 'w+');
! fwrite($f, $newcontent);
! fclose($f);
! header("Location: theme-editor.php?file=$file&a=te");
! } else {
! header("Location: theme-editor.php?file=$file");
! }
exit();
--- 45,56 ----
$newcontent = stripslashes($_POST['newcontent']);
! if (is_writeable($real_file)) {
! $f = fopen($real_file, 'w+');
! fwrite($f, $newcontent);
! fclose($f);
! header("Location: theme-editor.php?file=$file&a=te");
! } else {
! header("Location: theme-editor.php?file=$file");
! }
exit();
***************
*** 68,99 ****
die(__('<p>You have do not have sufficient permissions to edit themes for this blog.</p>'));
}
-
- $themes = get_themes();
! if (! isset($theme) || empty($theme)) {
! $theme = get_current_theme();
! }
!
! $stylesheet_files = $themes[$theme]['Stylesheet Files'];
! $template_files = $themes[$theme]['Template Files'];
!
! if ('' == $file) {
! $file = $stylesheet_files[0];
! }
!
! $home = get_settings('home');
! if (($home != '')
! && ($home != get_settings('siteurl')) &&
! ('index.php' == $file || get_settings('blogfilename') == $file ||
! '.htaccess' == $file)) {
! $home_root = parse_url($home);
! $home_root = $home_root['path'];
! $root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
! $home_root = $root . $home_root;
! $real_file = $home_root . '/' . $file;
! } else {
! $file = validate_file($file);
! $real_file = '../' . $file;
! }
if (!is_file($real_file))
--- 64,69 ----
die(__('<p>You have do not have sufficient permissions to edit themes for this blog.</p>'));
}
! update_recently_edited($file);
if (!is_file($real_file))
***************
*** 129,150 ****
<div class="wrap">
<?php
! echo "<p>" . sprintf(__('Editing <strong>%s</strong>'), $file) . "</p>";
!
if (!$error) {
?>
! <form name="template" action="theme-editor.php" method="post">
! <textarea cols="80" rows="21" style="width:95%; margin-right: 10em; font-family: 'Courier New', Courier, monopace; font-size:small;" name="newcontent" tabindex="1"><?php echo $content ?></textarea>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="file" value="<?php echo $file ?>" />
! <input type="hidden" name="theme" value="<?php echo $theme ?>" />
<p class="submit">
! <?php
! if (is_writeable($real_file)) {
! echo "<input type='submit' name='submit' value='Update File »' tabindex='2' />";
! } else {
! echo "<input type='button' name='oops' value='" . __('(You cannot update that file/template: must make it writable, e.g. CHMOD 666)') ."' tabindex='2' />";
! }
! ?>
</p>
</form>
<?php
--- 99,139 ----
<div class="wrap">
<?php
! if (is_writeable($real_file)) {
! echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>';
! } else {
! echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>';
! }
! ?>
! <div id="templateside">
! <h3><?php printf(__("<strong>'%s'</strong> theme files"), $theme) ?></h3>
!
! <?php
! if ($allowed_files) :
! ?>
! <ul>
! <?php foreach($allowed_files as $allowed_file) : ?>
! <li><a href="theme-editor.php?file=<?php echo "$allowed_file"; ?>&theme=<?php echo urlencode($theme) ?>"><?php echo get_file_description(basename($allowed_file)); ?></a></li>
! <?php endforeach; ?>
! </ul>
! <?php endif; ?>
! </div>
! <?php
if (!$error) {
?>
! <form name="template" id="template" action="theme-editor.php" method="post">a
! <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="file" value="<?php echo $file ?>" />
! <input type="hidden" name="theme" value="<?php echo $theme ?>" />
! </div>
! <?php if ( is_writeable($real_file) ) : ?>
<p class="submit">
! <?php
! echo "<input type='submit' name='submit' value=' " . __('Update File') . " »' tabindex='2' />";
! ?>
</p>
+ <?php else : ?>
+ <p><em><?php _e('If this file was writable you could edit it.'); ?></em></p>
+ <?php endif; ?>
</form>
<?php
***************
*** 154,176 ****
?>
</div>
- <div class="wrap">
<?php
-
- if ($template_files || $stylesheet_files) :
- ?>
- <p><?php printf(__('<strong>%s</strong> theme files:'), $theme) ?></p>
- <ul>
- <?php foreach($stylesheet_files as $stylesheet_file) : ?>
- <li><a href="theme-editor.php?file=<?php echo "$stylesheet_file"; ?>&theme=<?php echo $theme; ?>"><?php echo basename($stylesheet_file); ?></a></li>
- <?php endforeach; ?>
- <?php foreach($template_files as $template_file) : ?>
- <li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&theme=<?php echo $theme; ?>"><?php echo basename($template_file); ?></a></li>
- <?php endforeach; ?>
- </ul>
- <?php endif; ?>
- <p><?php _e('Note: of course, you can also edit the files/templates in your text editor of choice and upload them. This online editor is only meant to be used when you don’t have access to a text editor or FTP client.') ?></p>
- </div>
- <?php
-
break;
}
--- 143,147 ----
- Previous message: [wp-cvs] wordpress/wp-admin page-new.php, NONE,
1.1 edit-page-form.php, 1.8, 1.9 edit-pages.php, 1.6,
1.7 menu.php, 1.30, 1.31 post.php, 1.107, 1.108
- Next message: [wp-cvs] wordpress/wp-admin plugin-editor.php,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cvs
mailing list