From c078e2dbca485fd1ca83cd3d5bafa535f329d3f3 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 18 Nov 2005 23:32:40 +0000 Subject: [PATCH] Randomize the directory a little bit. git-svn-id: http://svn.automattic.com/wordpress/trunk@3157 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/plugins/wp-db-backup.php | 32 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/wp-content/plugins/wp-db-backup.php b/wp-content/plugins/wp-db-backup.php index c5a9e3b9d..8fb78c6ae 100644 --- a/wp-content/plugins/wp-db-backup.php +++ b/wp-content/plugins/wp-db-backup.php @@ -16,7 +16,10 @@ Many thanks to Owen (http://asymptomatic.net/wp/) for his patch // CHANGE THIS IF YOU WANT TO USE A // DIFFERENT BACKUP LOCATION -define('WP_BACKUP_DIR', 'wp-content/backup'); + +$rand = substr( md5( md5( DB_PASSWORD ) ), -5 ); + +define('WP_BACKUP_DIR', 'wp-content/backup-' . $rand); define('ROWS_PER_SEGMENT', 100); @@ -209,6 +212,7 @@ class wpdbBackup { nextStep(); //--> + '; } @@ -726,14 +730,28 @@ class wpdbBackup { if ('' != $feedback) { echo $feedback; } - - if (! is_dir(ABSPATH . $this->backup_dir)) { - echo '

' . __('WARNING: Your backup directory does not exist!', 'wp-db-backup') . '
' . ABSPATH . $this->backup_dir . "

"; - $WHOOPS = TRUE; - }elseif (! is_writable(ABSPATH . $this->backup_dir)) { - echo '

' . __('WARNING: Your backup directory is NOT writable!', 'wp-db-backup') . '
' . ABSPATH . $this->backup_dir . "

"; + + // Give the new dirs the same perms as wp-content. + $stat = stat( ABSPATH . 'wp-content' ); + $dir_perms = $stat['mode'] & 0000777; // Get the permission bits. + + if ( !file_exists( ABSPATH . $this->backup_dir) ) { + if ( @ mkdir( ABSPATH . $this->backup_dir) ) { + @ chmod( ABSPATH . $this->backup_dir, $dir_perms); + } else { + echo '

' . __('WARNING: Your wp-content directory is NOT writable! We can not create the backup directory.', 'wp-db-backup') . '
' . ABSPATH . "

"; $WHOOPS = TRUE; + } } + + if ( !is_writable( ABSPATH . $this->backup_dir) ) { + echo '

' . __('WARNING: Your backup directory is NOT writable! We can not create the backup directory.', 'wp-db-backup') . '
' . ABSPATH . "

"; + } + + if ( !file_exists( ABSPATH . $this->backup_dir . 'index.php') ) { + @ touch( ABSPATH . $this->backup_dir . "index.php"); + } + echo "
"; echo '

' . __('Backup', 'wp-db-backup') . '

'; echo '
' . __('Tables', 'wp-db-backup') . '';