Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IIS: No download links #671

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions classes/class-path.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public static function get_instance() {

/**
* Get the path to the directory where backups will be stored
*
* @return string $path
*/
public function get_path() {

Expand All @@ -82,7 +84,7 @@ public function get_path() {
// Ensure the backup directory is protected
$this->protect_path();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused as to why you removed the conform_dir call here? Isn't this exactly what we want it to do?


return Backup::conform_dir( $this->path );
return $this->path;

}

Expand Down Expand Up @@ -146,13 +148,13 @@ public function get_custom_path() {
*/
public function get_existing_paths() {

if ( false === $default = glob( WP_CONTENT_DIR . '/backupwordpress-*-backups', GLOB_ONLYDIR ) ) {
if ( false === $default = glob( WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backupwordpress-*-backups', GLOB_ONLYDIR ) ) {
$default = array();
}

$upload_dir = wp_upload_dir();

if ( false === $fallback = glob( $upload_dir['basedir'] . '/backupwordpress-*-backups', GLOB_ONLYDIR ) ) {
if ( false === $fallback = glob( $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'backupwordpress-*-backups', GLOB_ONLYDIR ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for DIRECTORY_SEPARATOR as Windows supports / fine.

$fallback = array();
}

Expand Down Expand Up @@ -214,7 +216,7 @@ public function calculate_path() {
}

if ( isset( $path ) ) {
$this->path = $path;
$this->path = Backup::conform_dir( $path );
}

}
Expand All @@ -227,7 +229,7 @@ public function protect_path( $reset = 'no' ) {
global $is_apache;

// Protect against directory browsing by including an index.html file
$index = $this->path . '/index.html';
$index = $this->path . DIRECTORY_SEPARATOR . 'index.html';

if ( ( 'reset' === $reset ) && file_exists( $index ) ) {
@unlink( $index );
Expand All @@ -237,7 +239,7 @@ public function protect_path( $reset = 'no' ) {
file_put_contents( $index, '' );
}

$htaccess = $this->path . '/.htaccess';
$htaccess = $this->path . DIRECTORY_SEPARATOR . '.htaccess';

if ( ( 'reset' === $reset ) && file_exists( $htaccess ) ) {
@unlink( $htaccess );
Expand Down
2 changes: 1 addition & 1 deletion functions/interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function hmbkp_get_backup_row( $file, HM\BackUpWordPress\Scheduled_Backup $sched

<td>

<?php if ( hmbkp_is_path_accessible( hmbkp_path() ) ) : ?>
<?php if ( hmbkp_is_path_accessible( hmbkp_path() ) ) : ?>
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'hmbkp_backup_archive' => $encoded_file, 'hmbkp_schedule_id' => $schedule->get_id(), 'action' => 'hmbkp_request_download_backup' ), admin_url( 'admin-post.php' ) ), 'hmbkp_download_backup', 'hmbkp_download_backup_nonce' ) ); ?>" class="download-action"><?php _e( 'Download', 'backupwordpress' ); ?></a> |
<?php endif; ?>

Expand Down