| [ Index ] |
WordPress Source Cross Reference |
[Summary view] [Print] [Text view]
1 <?php 2 require_once ('admin.php'); 3 $title = __('Template & File Editing'); 4 $parent_file = 'edit.php'; 5 6 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file')); 7 8 $recents = get_option('recently_edited'); 9 10 if (empty($file)) { 11 if ($recents) { 12 $file = $recents[0]; 13 } else { 14 $file = 'index.php'; 15 } 16 } 17 18 $file = validate_file_to_edit($file); 19 $real_file = get_real_file_to_edit($file); 20 21 switch($action) { 22 23 case 'update': 24 25 check_admin_referer('edit-file_' . $file); 26 27 if ( ! current_user_can('edit_files') ) 28 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>'); 29 30 $newcontent = stripslashes($_POST['newcontent']); 31 if (is_writeable($real_file)) { 32 $f = @ fopen($real_file, 'w+'); 33 if ( $f ) { 34 fwrite($f, $newcontent); 35 fclose($f); 36 wp_redirect("templates.php?file=$file&a=te"); 37 } else { 38 wp_redirect("templates.php?file=$file&a=err"); 39 } 40 } else { 41 wp_redirect("templates.php?file=$file&a=err"); 42 } 43 44 exit(); 45 46 break; 47 48 default: 49 50 require_once ('./admin-header.php'); 51 52 if ( ! current_user_can('edit_files') ) 53 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>'); 54 55 if ( strstr( $file, 'wp-config.php' ) ) 56 wp_die('<p>'.__('The config file cannot be edited or viewed through the web interface. Sorry!').'</p>'); 57 58 update_recently_edited($file); 59 60 if (!is_file($real_file)) 61 $error = true; 62 63 if (!$error) { 64 $f = @ fopen($real_file, 'r'); 65 if ( $f ) { 66 $content = fread($f, filesize($real_file)); 67 $content = htmlspecialchars($content); 68 } else { 69 $error = true; 70 } 71 } 72 73 ?> 74 <?php if (isset($_GET['a'])) : ?> 75 <?php if ( 'err' == $_GET['a'] ) : ?> 76 <div id="message" class="error"><p><?php _e('Could not save file.') ?></p></div> 77 <?php else: ?> 78 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div> 79 <?php endif; ?> 80 <?php endif; ?> 81 <div class="wrap"> 82 <?php 83 if (is_writeable($real_file)) { 84 echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), wp_specialchars($file) ) . '</h2>'; 85 } else { 86 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), wp_specialchars($file) ) . '</h2>'; 87 } 88 ?> 89 <div id="templateside"> 90 <?php 91 if ( $recents ) : 92 ?> 93 <h3><?php _e('Recent'); ?></h3> 94 <?php 95 echo '<ol>'; 96 foreach ($recents as $recent) : 97 echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a></li>"; 98 endforeach; 99 echo '</ol>'; 100 endif; 101 ?> 102 <h3><?php _e('Common'); ?></h3> 103 <?php $common_files = array('index.php', '.htaccess', 'my-hacks.php'); 104 $old_files = array('wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php'); 105 foreach ($old_files as $old_file) { 106 if (file_exists(ABSPATH . $old_file)) 107 $common_files[] = $old_file; 108 } ?> 109 <ul> 110 <?php foreach ($common_files as $common_file) : ?> 111 <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li> 112 <?php endforeach; ?> 113 </ul> 114 </div> 115 <?php if (!$error) { ?> 116 <form name="template" id="template" action="templates.php" method="post"> 117 <?php wp_nonce_field('edit-file_' . $file) ?> 118 <div><textarea cols="70" rows="25" name="newcontent" id='newcontent' tabindex="1"><?php echo $content ?></textarea> 119 <input type="hidden" name="action" value="update" /> 120 <input type="hidden" name="file" value="<?php echo $file ?>" /> 121 </div> 122 <?php if ( is_writeable($real_file) ) : ?> 123 <p class="submit"> 124 <?php 125 echo "<input type='submit' name='submit' value=' " . __('Update File »') . "' tabindex='2' />"; 126 ?> 127 </p> 128 <?php else : ?> 129 <p><em><?php _e('If this file were writable you could edit it.'); ?></em></p> 130 <?php endif; ?> 131 </form> 132 <?php 133 } else { 134 echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>'; 135 } 136 ?> 137 <div class="clear"> </div> 138 </div> 139 <div class="wrap"> 140 <h2><?php _e('Other Files') ?></h2> 141 142 <p><?php _e('To edit a file, type its name here. You can edit any file <a href="http://codex.wordpress.org/Changing_File_Permissions" title="Read more about making files writable">writable by the server</a>, e.g. CHMOD 666.') ?></p> 143 <form name="file" action="templates.php" method="get"> 144 <input type="text" name="file" /> 145 <input type="submit" name="submit" value="<?php _e('Edit file »') ?>" /> 146 </form> 147 148 <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> 149 </div> 150 <?php 151 152 break; 153 } 154 155 include ("admin-footer.php"); 156 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Jul 15 11:57:04 2006 | Courtesy of Taragana |