[ Index ] |
|
Code source de WordPress 2.1.2 |
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 if ( filesize($real_file ) > 0 ) { 67 $content = fread($f, filesize($real_file)); 68 $content = htmlspecialchars($content); 69 } else { 70 $content = ''; 71 } 72 } else { 73 $error = true; 74 } 75 } 76 77 ?> 78 <?php if (isset($_GET['a'])) : ?> 79 <?php if ( 'err' == $_GET['a'] ) : ?> 80 <div id="message" class="error"><p><?php _e('Could not save file.') ?></p></div> 81 <?php else: ?> 82 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div> 83 <?php endif; ?> 84 <?php endif; ?> 85 <div class="wrap"> 86 <?php 87 if (is_writeable($real_file)) { 88 echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), wp_specialchars($file) ) . '</h2>'; 89 } else { 90 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), wp_specialchars($file) ) . '</h2>'; 91 } 92 ?> 93 <div id="templateside"> 94 <?php 95 if ( $recents ) : 96 ?> 97 <h3><?php _e('Recent'); ?></h3> 98 <?php 99 echo '<ol>'; 100 foreach ($recents as $recent) : 101 echo "<li><a href='templates.php?file=" . attribute_escape($recent) . "'>" . wp_specialchars(get_file_description(basename($recent))) . "</a></li>"; 102 endforeach; 103 echo '</ol>'; 104 endif; 105 ?> 106 <h3><?php _e('Common'); ?></h3> 107 <?php $common_files = array('index.php', '.htaccess', 'my-hacks.php'); 108 $old_files = array('wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php'); 109 foreach ($old_files as $old_file) { 110 if (file_exists(ABSPATH . $old_file)) 111 $common_files[] = $old_file; 112 } ?> 113 <ul> 114 <?php foreach ($common_files as $common_file) : ?> 115 <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li> 116 <?php endforeach; ?> 117 </ul> 118 </div> 119 <?php if (!$error) { ?> 120 <form name="template" id="template" action="templates.php" method="post"> 121 <?php wp_nonce_field('edit-file_' . $file) ?> 122 <div><textarea cols="70" rows="25" name="newcontent" id='newcontent' tabindex="1"><?php echo $content ?></textarea> 123 <input type="hidden" name="action" value="update" /> 124 <input type="hidden" name="file" value="<?php echo $file ?>" /> 125 </div> 126 <?php if ( is_writeable($real_file) ) : ?> 127 <p class="submit"> 128 <?php 129 echo "<input type='submit' name='submit' value=' " . __('Update File »') . "' tabindex='2' />"; 130 ?> 131 </p> 132 <?php else : ?> 133 <p><em><?php _e('If this file were writable you could edit it.'); ?></em></p> 134 <?php endif; ?> 135 </form> 136 <?php 137 } else { 138 echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>'; 139 } 140 ?> 141 <div class="clear"> </div> 142 </div> 143 <div class="wrap"> 144 <h2><?php _e('Other Files') ?></h2> 145 146 <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> 147 <form name="file" action="templates.php" method="get"> 148 <input type="text" name="file" /> 149 <input type="submit" name="submit" value="<?php _e('Edit file »') ?>" /> 150 </form> 151 152 <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> 153 </div> 154 <?php 155 156 break; 157 } 158 159 include ("admin-footer.php"); 160 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 19:41:27 2007 | par Balluche grâce à PHPXref 0.7 |