Make WordPress Core

Changeset 3157


Ignore:
Timestamp:
11/18/2005 11:32:40 PM (20 years ago)
Author:
matt
Message:

Randomize the directory a little bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/plugins/wp-db-backup.php

    r3154 r3157  
    1717// CHANGE THIS IF YOU WANT TO USE A
    1818// DIFFERENT BACKUP LOCATION
    19 define('WP_BACKUP_DIR', 'wp-content/backup');
     19
     20$rand = substr( md5( md5( DB_PASSWORD ) ), -5 );
     21
     22define('WP_BACKUP_DIR', 'wp-content/backup-' . $rand);
    2023
    2124define('ROWS_PER_SEGMENT', 100);
     
    210213            nextStep();
    211214            //--></script>
     215            </div>
    212216        ';
    213217    }
     
    727731            echo $feedback;
    728732        }
    729        
    730         if (! is_dir(ABSPATH . $this->backup_dir)) {
    731             echo '<div class="updated error"><p align="center">' . __('WARNING: Your backup directory does not exist!', 'wp-db-backup') . '<br />' . ABSPATH . $this->backup_dir . "</p></div>";
     733
     734        // Give the new dirs the same perms as wp-content.
     735        $stat = stat( ABSPATH . 'wp-content' );
     736        $dir_perms = $stat['mode'] & 0000777; // Get the permission bits.
     737
     738        if ( !file_exists( ABSPATH . $this->backup_dir) ) {
     739            if ( @ mkdir( ABSPATH . $this->backup_dir) ) {
     740                @ chmod( ABSPATH . $this->backup_dir, $dir_perms);
     741            } else {
     742                echo '<div class="updated error"><p align="center">' . __('WARNING: Your wp-content directory is <strong>NOT</strong> writable! We can not create the backup directory.', 'wp-db-backup') . '<br />' . ABSPATH . "</p></div>";
    732743            $WHOOPS = TRUE;
    733         }elseif (! is_writable(ABSPATH . $this->backup_dir)) {
    734             echo '<div class="updated error"><p align="center">' . __('WARNING: Your backup directory is <strong>NOT</strong> writable!', 'wp-db-backup') . '<br />' . ABSPATH . $this->backup_dir . "</p></div>";
    735             $WHOOPS = TRUE;
    736         }
     744            }
     745        }
     746       
     747        if ( !is_writable( ABSPATH . $this->backup_dir) ) {
     748            echo '<div class="updated error"><p align="center">' . __('WARNING: Your backup directory is <strong>NOT</strong> writable! We can not create the backup directory.', 'wp-db-backup') . '<br />' . ABSPATH . "</p></div>";
     749        }
     750
     751        if ( !file_exists( ABSPATH . $this->backup_dir . 'index.php') ) {
     752            @ touch( ABSPATH . $this->backup_dir . "index.php");
     753        }
     754
    737755        echo "<div class='wrap'>";
    738756        echo '<h2>' . __('Backup', 'wp-db-backup') . '</h2>';
Note: See TracChangeset for help on using the changeset viewer.