Changeset 3219647
- Timestamp:
- 01/09/2025 01:02:44 PM (15 months ago)
- Location:
- htaccess-file-editor
- Files:
-
- 10 edited
-
tags/1.0.20/assets/js/htaccess-file-editor.min.js (modified) (1 diff)
-
tags/1.0.20/includes/class-htaccess-file-editor-hooks.php (modified) (2 diffs)
-
tags/1.0.20/includes/functions.php (modified) (9 diffs)
-
tags/1.0.20/templates/backup-form.php (modified) (1 diff)
-
tags/1.0.20/templates/dashboard.php (modified) (1 diff)
-
trunk/assets/js/htaccess-file-editor.min.js (modified) (1 diff)
-
trunk/includes/class-htaccess-file-editor-hooks.php (modified) (2 diffs)
-
trunk/includes/functions.php (modified) (9 diffs)
-
trunk/templates/backup-form.php (modified) (1 diff)
-
trunk/templates/dashboard.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
htaccess-file-editor/tags/1.0.20/assets/js/htaccess-file-editor.min.js
r3140218 r3219647 1 jQuery(document).ready( (function(e){wp.codeEditor.initialize(e("#htaccess-file-editor-textarea"),htaccess_file_editor_settings)}));1 jQuery(document).ready(function(e){wp.codeEditor.initialize(e("#htaccess-file-editor-textarea"),htaccess_file_editor_settings)}); -
htaccess-file-editor/tags/1.0.20/includes/class-htaccess-file-editor-hooks.php
r3210305 r3219647 64 64 public function migrate_backup_name() { 65 65 $old_name = 'htaccess.backup'; 66 $new_name = '.htaccess-file-editor-bkup'; 66 $hash = sanitize_file_name( substr( wp_generate_password( 10, false ), 0, 5 ) ); 67 $new_name = '.htaccess-file-editor-bkup-' . $hash; 67 68 $path = WP_CONTENT_DIR; 68 // If the new backup file exists, then we don't need to migrate 69 if ( file_exists( $path . '/' . $new_name ) ) { 69 // Retrieve the saved backup name 70 $saved_name = get_option( 'htaccess_file_editor_backup_name' ); 71 // If the backup file is saved in the options and exists, then we don't need to migrate 72 if ( $saved_name && file_exists( $path . '/' . $saved_name ) ) { 70 73 return; 71 74 } 75 72 76 // If the old file doesn't exist, then we don't need to migrate 73 77 if ( ! file_exists( $path . '/' . $old_name ) ) { … … 80 84 WP_Filesystem(); 81 85 $wp_filesystem->move( $path . '/' . $old_name, $path . '/' . $new_name ); 86 update_option( 'htaccess_file_editor_backup_name', $new_name ); 82 87 } 83 88 } -
htaccess-file-editor/tags/1.0.20/includes/functions.php
r3210305 r3219647 9 9 require_once ABSPATH . '/wp-admin/includes/file.php'; 10 10 WP_Filesystem(); 11 $WPHE_backup_path = ABSPATH . 'wp-content/.htaccess-file-editor-bkup'; 11 $saved_name = get_option( 'htaccess_file_editor_backup_name' ); 12 // Check if the backup file is saved in the options 13 if ( $saved_name ) { 14 $file_name = $saved_name; 15 } else { 16 $hash = sanitize_file_name( substr( wp_generate_password( 10, false ), 0, 5 ) ); 17 $file_name = '.htaccess-file-editor-bkup-' . $hash; 18 } 19 $WPHE_backup_path = ABSPATH . 'wp-content/' . $file_name; 12 20 $WPHE_orig_path = ABSPATH . '.htaccess'; 13 21 @clearstatcache(); 14 22 15 htaccess_file_editor_create_secure_wpcontent( );23 htaccess_file_editor_create_secure_wpcontent( $file_name ); 16 24 if ( file_exists( $WPHE_backup_path ) ) { 17 htaccess_file_editor_delete_backup( );25 htaccess_file_editor_delete_backup( $file_name ); 18 26 19 27 if ( file_exists( ABSPATH . '.htaccess' ) ) { … … 35 43 unset( $htaccess_content_orig ); 36 44 unset( $WPHE_success ); 45 update_option( 'htaccess_file_editor_backup_name', $file_name ); 37 46 return true; 38 47 } … … 64 73 unset( $htaccess_content_orig ); 65 74 unset( $WPHE_success ); 75 update_option( 'htaccess_file_editor_backup_name', $file_name ); 66 76 return true; 67 77 } … … 75 85 76 86 77 function htaccess_file_editor_create_secure_wpcontent() { 87 function htaccess_file_editor_create_secure_wpcontent( $file_name = false ) { 88 if ( ! $file_name ) { 89 return false; 90 } 78 91 $htaccess_file_editor_secure_path = ABSPATH . 'wp-content/.htaccess'; 79 92 $htaccess_file_editor_secure_text = ' 80 93 # Htaccess File Editor - Secure backups 81 <files .htaccess-file-editor-bkup>94 <files ' . $file_name . '> 82 95 order allow,deny 83 96 deny from all … … 91 104 92 105 if ( $htaccess_file_editor_secure_content !== false ) { 93 if ( strpos( $htaccess_file_editor_secure_content, '<files .htaccess-file-editor-bkup>' ) === false ) {106 if ( strpos( $htaccess_file_editor_secure_content, '<files ' . $file_name . '>' ) === false ) { 94 107 unset( $htaccess_file_editor_secure_content ); 95 108 $htaccess_file_editor_create_sec = $wp_filesystem->put_contents( ABSPATH . 'wp-content/.htaccess', $htaccess_file_editor_secure_text ); … … 125 138 126 139 function htaccess_file_editor_restore_backup() { 127 $htaccess_file_editor_backup_path = ABSPATH . 'wp-content/.htaccess-file-editor-bkup'; 140 $file_name = get_option( 'htaccess_file_editor_backup_name' ); 141 if ( ! $file_name ) { 142 return false; 143 } 144 $htaccess_file_editor_backup_path = ABSPATH . 'wp-content/' . $file_name; 128 145 $WPHE_orig_path = ABSPATH . '.htaccess'; 129 146 @clearstatcache(); … … 152 169 return $htaccess_file_editor_htaccess_content_backup; 153 170 } else { 154 htaccess_file_editor_delete_backup( );171 htaccess_file_editor_delete_backup( $file_name ); 155 172 unset( $htaccess_file_editor_success ); 156 173 unset( $htaccess_file_editor_htaccess_content_backup ); … … 163 180 164 181 165 function htaccess_file_editor_delete_backup() { 166 $htaccess_file_editor_backup_path = ABSPATH . 'wp-content/.htaccess-file-editor-bkup'; 182 function htaccess_file_editor_delete_backup( $file_name = false ) { 183 184 if ( ! $file_name ) { 185 $file_name = get_option( 'htaccess_file_editor_backup_name' ); 186 if ( ! $file_name ) { 187 return false; 188 } 189 } 190 $htaccess_file_editor_backup_path = ABSPATH . 'wp-content/' . $file_name; 167 191 @clearstatcache(); 168 192 … … 184 208 return false; 185 209 } else { 186 unset( $htaccess_file_editor_backup_path ); 187 return true; 188 } 189 } else { 210 delete_option( 'htaccess_file_editor_backup_name' ); 211 unset( $htaccess_file_editor_backup_path ); 212 return true; 213 } 214 } else { 215 delete_option( 'htaccess_file_editor_backup_name' ); 190 216 unset( $htaccess_file_editor_backup_path ); 191 217 return true; -
htaccess-file-editor/tags/1.0.20/templates/backup-form.php
r3210305 r3219647 1 1 <?php 2 if (file_exists(ABSPATH . 'wp-content/.htaccess-file-editor-bkup')) { 2 $file_name = get_option('htaccess_file_editor_backup_name'); 3 4 if ($file_name && file_exists(ABSPATH . 'wp-content/' . $file_name)) { 3 5 echo '<div class="postbox htaccess-file-editor-box" style="background: #FFEECE;">'; 4 6 ?> -
htaccess-file-editor/tags/1.0.20/templates/dashboard.php
r3210305 r3219647 9 9 require_once ABSPATH . '/wp-admin/includes/file.php'; 10 10 WP_Filesystem(); 11 $htaccess_file_editor_backup_path = WP_CONTENT_URL . '/.htaccess-file-editor-bkup'; 11 $file_name = get_option( 'htaccess_file_editor_backup_name' ); 12 $htaccess_file_editor_backup_path = WP_CONTENT_URL . '/' . $file_name; 12 13 $htaccess_file_editor_origin_path = ABSPATH . '.htaccess'; 13 14 ?> -
htaccess-file-editor/trunk/assets/js/htaccess-file-editor.min.js
r3140218 r3219647 1 jQuery(document).ready( (function(e){wp.codeEditor.initialize(e("#htaccess-file-editor-textarea"),htaccess_file_editor_settings)}));1 jQuery(document).ready(function(e){wp.codeEditor.initialize(e("#htaccess-file-editor-textarea"),htaccess_file_editor_settings)}); -
htaccess-file-editor/trunk/includes/class-htaccess-file-editor-hooks.php
r3210305 r3219647 64 64 public function migrate_backup_name() { 65 65 $old_name = 'htaccess.backup'; 66 $new_name = '.htaccess-file-editor-bkup'; 66 $hash = sanitize_file_name( substr( wp_generate_password( 10, false ), 0, 5 ) ); 67 $new_name = '.htaccess-file-editor-bkup-' . $hash; 67 68 $path = WP_CONTENT_DIR; 68 // If the new backup file exists, then we don't need to migrate 69 if ( file_exists( $path . '/' . $new_name ) ) { 69 // Retrieve the saved backup name 70 $saved_name = get_option( 'htaccess_file_editor_backup_name' ); 71 // If the backup file is saved in the options and exists, then we don't need to migrate 72 if ( $saved_name && file_exists( $path . '/' . $saved_name ) ) { 70 73 return; 71 74 } 75 72 76 // If the old file doesn't exist, then we don't need to migrate 73 77 if ( ! file_exists( $path . '/' . $old_name ) ) { … … 80 84 WP_Filesystem(); 81 85 $wp_filesystem->move( $path . '/' . $old_name, $path . '/' . $new_name ); 86 update_option( 'htaccess_file_editor_backup_name', $new_name ); 82 87 } 83 88 } -
htaccess-file-editor/trunk/includes/functions.php
r3210305 r3219647 9 9 require_once ABSPATH . '/wp-admin/includes/file.php'; 10 10 WP_Filesystem(); 11 $WPHE_backup_path = ABSPATH . 'wp-content/.htaccess-file-editor-bkup'; 11 $saved_name = get_option( 'htaccess_file_editor_backup_name' ); 12 // Check if the backup file is saved in the options 13 if ( $saved_name ) { 14 $file_name = $saved_name; 15 } else { 16 $hash = sanitize_file_name( substr( wp_generate_password( 10, false ), 0, 5 ) ); 17 $file_name = '.htaccess-file-editor-bkup-' . $hash; 18 } 19 $WPHE_backup_path = ABSPATH . 'wp-content/' . $file_name; 12 20 $WPHE_orig_path = ABSPATH . '.htaccess'; 13 21 @clearstatcache(); 14 22 15 htaccess_file_editor_create_secure_wpcontent( );23 htaccess_file_editor_create_secure_wpcontent( $file_name ); 16 24 if ( file_exists( $WPHE_backup_path ) ) { 17 htaccess_file_editor_delete_backup( );25 htaccess_file_editor_delete_backup( $file_name ); 18 26 19 27 if ( file_exists( ABSPATH . '.htaccess' ) ) { … … 35 43 unset( $htaccess_content_orig ); 36 44 unset( $WPHE_success ); 45 update_option( 'htaccess_file_editor_backup_name', $file_name ); 37 46 return true; 38 47 } … … 64 73 unset( $htaccess_content_orig ); 65 74 unset( $WPHE_success ); 75 update_option( 'htaccess_file_editor_backup_name', $file_name ); 66 76 return true; 67 77 } … … 75 85 76 86 77 function htaccess_file_editor_create_secure_wpcontent() { 87 function htaccess_file_editor_create_secure_wpcontent( $file_name = false ) { 88 if ( ! $file_name ) { 89 return false; 90 } 78 91 $htaccess_file_editor_secure_path = ABSPATH . 'wp-content/.htaccess'; 79 92 $htaccess_file_editor_secure_text = ' 80 93 # Htaccess File Editor - Secure backups 81 <files .htaccess-file-editor-bkup>94 <files ' . $file_name . '> 82 95 order allow,deny 83 96 deny from all … … 91 104 92 105 if ( $htaccess_file_editor_secure_content !== false ) { 93 if ( strpos( $htaccess_file_editor_secure_content, '<files .htaccess-file-editor-bkup>' ) === false ) {106 if ( strpos( $htaccess_file_editor_secure_content, '<files ' . $file_name . '>' ) === false ) { 94 107 unset( $htaccess_file_editor_secure_content ); 95 108 $htaccess_file_editor_create_sec = $wp_filesystem->put_contents( ABSPATH . 'wp-content/.htaccess', $htaccess_file_editor_secure_text ); … … 125 138 126 139 function htaccess_file_editor_restore_backup() { 127 $htaccess_file_editor_backup_path = ABSPATH . 'wp-content/.htaccess-file-editor-bkup'; 140 $file_name = get_option( 'htaccess_file_editor_backup_name' ); 141 if ( ! $file_name ) { 142 return false; 143 } 144 $htaccess_file_editor_backup_path = ABSPATH . 'wp-content/' . $file_name; 128 145 $WPHE_orig_path = ABSPATH . '.htaccess'; 129 146 @clearstatcache(); … … 152 169 return $htaccess_file_editor_htaccess_content_backup; 153 170 } else { 154 htaccess_file_editor_delete_backup( );171 htaccess_file_editor_delete_backup( $file_name ); 155 172 unset( $htaccess_file_editor_success ); 156 173 unset( $htaccess_file_editor_htaccess_content_backup ); … … 163 180 164 181 165 function htaccess_file_editor_delete_backup() { 166 $htaccess_file_editor_backup_path = ABSPATH . 'wp-content/.htaccess-file-editor-bkup'; 182 function htaccess_file_editor_delete_backup( $file_name = false ) { 183 184 if ( ! $file_name ) { 185 $file_name = get_option( 'htaccess_file_editor_backup_name' ); 186 if ( ! $file_name ) { 187 return false; 188 } 189 } 190 $htaccess_file_editor_backup_path = ABSPATH . 'wp-content/' . $file_name; 167 191 @clearstatcache(); 168 192 … … 184 208 return false; 185 209 } else { 186 unset( $htaccess_file_editor_backup_path ); 187 return true; 188 } 189 } else { 210 delete_option( 'htaccess_file_editor_backup_name' ); 211 unset( $htaccess_file_editor_backup_path ); 212 return true; 213 } 214 } else { 215 delete_option( 'htaccess_file_editor_backup_name' ); 190 216 unset( $htaccess_file_editor_backup_path ); 191 217 return true; -
htaccess-file-editor/trunk/templates/backup-form.php
r3210305 r3219647 1 1 <?php 2 if (file_exists(ABSPATH . 'wp-content/.htaccess-file-editor-bkup')) { 2 $file_name = get_option('htaccess_file_editor_backup_name'); 3 4 if ($file_name && file_exists(ABSPATH . 'wp-content/' . $file_name)) { 3 5 echo '<div class="postbox htaccess-file-editor-box" style="background: #FFEECE;">'; 4 6 ?> -
htaccess-file-editor/trunk/templates/dashboard.php
r3210305 r3219647 9 9 require_once ABSPATH . '/wp-admin/includes/file.php'; 10 10 WP_Filesystem(); 11 $htaccess_file_editor_backup_path = WP_CONTENT_URL . '/.htaccess-file-editor-bkup'; 11 $file_name = get_option( 'htaccess_file_editor_backup_name' ); 12 $htaccess_file_editor_backup_path = WP_CONTENT_URL . '/' . $file_name; 12 13 $htaccess_file_editor_origin_path = ABSPATH . '.htaccess'; 13 14 ?>
Note: See TracChangeset
for help on using the changeset viewer.