/** * In this scenario, WordPress is installed in a subdirectory with index.php in root and wp-config.php in the subdirectory. */ function test_standard_install_in_subdirectory_2() { $abspath = $this->test_data . '/exclude'; $this->wp_config_in($abspath); $this->index_in(dirname($abspath)); $path = Path::get_home_path($abspath); $this->assertEquals(dirname($abspath), $path); }
/** * Send the download file to the browser and then redirect back to the backups page */ function request_download_backup() { check_admin_referer('hmbkp_download_backup', 'hmbkp_download_backup_nonce'); if (!file_exists(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])))) { return; } $url = str_replace(wp_normalize_path(Path::get_home_path()), home_url('/'), trailingslashit(dirname(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive']))))) . urlencode(pathinfo(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])), PATHINFO_BASENAME)); global $is_apache; if ($is_apache) { Path::get_instance()->protect_path('reset'); $url = add_query_arg('key', HMBKP_SECURE_KEY, $url); } wp_safe_redirect($url, 303); die; }
/** * In this scenario, WordPress is installed in a subdirectory with index.php and wp-config both in root. */ function test_standard_install_in_subdirectory() { $home = get_option('home'); $siteurl = get_option('siteurl'); $sfn = $_SERVER['SCRIPT_FILENAME']; $this->assertEquals(wp_normalize_path(untrailingslashit(ABSPATH)), Path::get_home_path()); update_option('home', 'http://localhost'); update_option('siteurl', 'http://localhost/wp'); $_SERVER['SCRIPT_FILENAME'] = 'D:\\root\\vhosts\\site\\httpdocs\\wp\\wp-admin\\options-permalink.php'; $this->assertEquals('D:/root/vhosts/site/httpdocs/', trailingslashit(Path::get_home_path())); $_SERVER['SCRIPT_FILENAME'] = '/Users/foo/public_html/trunk/wp/wp-admin/options-permalink.php'; $this->assertEquals('/Users/foo/public_html/trunk/', trailingslashit(Path::get_home_path())); $_SERVER['SCRIPT_FILENAME'] = 'S:/home/wordpress/trunk/wp/wp-admin/options-permalink.php'; $this->assertEquals('S:/home/wordpress/trunk/', trailingslashit(Path::get_home_path())); update_option('home', $home); update_option('siteurl', $siteurl); $_SERVER['SCRIPT_FILENAME'] = $sfn; }
<td> <?php if (defined('HMBKP_ROOT')) { ?> <p><?php printf(__('You\'ve set it to: %s', 'backupwordpress'), '<code>' . esc_html(HMBKP_ROOT) . '</code>'); ?> </p> <?php } ?> <p><?php printf(__('The root directory that is backed up. Defaults to %s.', 'backupwordpress'), '<code>' . Path::get_home_path() . '</code>'); ?> <?php _e('e.g.', 'backupwordpress'); ?> <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p> </td> </tr> <tr<?php if (defined('HMBKP_SCHEDULE_TIME') && HMBKP_SCHEDULE_TIME !== '11pm') { ?> class="hmbkp_active"<?php }
$reoccurrence = sprintf(__('weekly on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html($day) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>'); break; case 'fortnightly': $reoccurrence = sprintf(__('every two weeks on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>'); break; case 'monthly': $reoccurrence = sprintf(__('on the %1$s of each month at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(date_i18n('jS', $schedule->get_next_occurrence(false))) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>'); break; case 'manually': $reoccurrence = __('manually', 'backupwordpress'); break; default: $reoccurrence = __('manually', 'backupwordpress'); $schedule->set_reoccurrence('manually'); } $server = '<code title="' . __('Check the help tab to learn how to change where your backups are stored.', 'backupwordpress') . '">' . esc_attr(str_replace(Path::get_home_path(), '', Path::get_path())) . '</code>'; // Backup to keep switch ($schedule->get_max_backups()) { case 1: $backup_to_keep = sprintf(__('store the most recent backup in %s', 'backupwordpress'), $server); break; case 0: $backup_to_keep = sprintf(__('don\'t store any backups in on this server', 'backupwordpress'), Path::get_path()); break; default: $backup_to_keep = sprintf(__('store the last %1$s backups in %2$s', 'backupwordpress'), esc_html($schedule->get_max_backups()), $server); } $email_msg = ''; $services = array(); foreach (Services::get_services($schedule) as $file => $service) { if (is_wp_error($service)) {
function is_path_accessible($dir) { // Path is inaccessible if (strpos($dir, Path::get_home_path()) === false) { return false; } return true; }
break; case 'fortnightly': $reoccurrence = sprintf(__('every two weeks on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>'); break; case 'monthly': $reoccurrence = sprintf(__('on the %1$s of each month at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(date_i18n('jS', $schedule->get_next_occurrence(false))) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>'); break; case 'manually': $reoccurrence = __('manually', 'backupwordpress'); break; default: $reoccurrence = __('manually', 'backupwordpress'); $schedule->set_reoccurrence('manually'); } $server = '<span title="' . esc_attr(Path::get_path()) . '">' . __('this server', 'backupwordpress') . '</span>'; $server = '<code>' . esc_attr(str_replace(Path::get_home_path(), '', Path::get_path())) . '</code>'; // Backup to keep switch ($schedule->get_max_backups()) { case 1: $backup_to_keep = sprintf(__('store the most recent backup in %s', 'backupwordpress'), $server); break; case 0: $backup_to_keep = sprintf(__('don\'t store any backups in on this server', 'backupwordpress'), Path::get_path()); break; default: $backup_to_keep = sprintf(__('store the last %1$s backups in %2$s', 'backupwordpress'), esc_html($schedule->get_max_backups()), $server); } $email_msg = ''; $services = array(); foreach (Services::get_services($schedule) as $file => $service) { if (is_wp_error($service)) {