Esempio n. 1
0
			<td>

				<?php 
if (defined('HMBKP_PATH')) {
    ?>
					<p><?php 
    printf(__('You\'ve set it to: %s', 'hmbkp'), '<code>' . HMBKP_PATH . '</code>');
    ?>
</p>
				<?php 
}
?>

				<p><?php 
printf(__('The path to folder you would like to store your backup files in, defaults to %s.', 'hmbkp'), '<code>' . esc_html(hmbkp_path_default()) . '</code>');
?>
 <?php 
_e('e.g.', 'hmbkp');
?>
 <code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p>

			</td>

		</tr>

		<tr<?php 
if (defined('HMBKP_MYSQLDUMP_PATH')) {
    ?>
 class="hmbkp_active"<?php 
}
 /**
  * If the HMBKP_PATH constant is defined and the new directory is writable then everything should be moved there
  *
  * @access public
  * @return void
  */
 public function testUnWritableDefinedBackupPath()
 {
     $this->assertEquals(hmbkp_path(), HMBKP_PATH);
     $this->backup->backup();
     $this->assertFileExists($this->backup->get_archive_filepath());
     chmod($this->custom_path, 0555);
     if (is_writable($this->custom_path)) {
         $this->markTestSkipped('The custom path was still writable');
     }
     hmbkp_constant_changes();
     $this->assertEquals(hmbkp_path(), hmbkp_path_default());
     $this->assertFileExists(str_replace($this->backup->get_path(), hmbkp_path_default(), $this->backup->get_archive_filepath()));
     // They should both exist because we didn't have permission to remove the old file
     $this->assertFileExists($this->backup->get_archive_filepath());
 }
Esempio n. 3
0
/**
 * Handles changes in the defined Constants
 * that users can define to control advanced
 * settings
 */
function hmbkp_constant_changes()
{
    // If a custom backup path has been set or changed
    if (defined('HMBKP_PATH') && HMBKP_PATH && HM_Backup::conform_dir(HMBKP_PATH) !== ($from = HM_Backup::conform_dir(get_option('hmbkp_path')))) {
        hmbkp_path_move($from, HMBKP_PATH);
    }
    // If a custom backup path has been removed
    if (defined('HMBKP_PATH') && !HMBKP_PATH || !defined('HMBKP_PATH') && hmbkp_path_default() !== ($from = HM_Backup::conform_dir(get_option('hmbkp_path')))) {
        hmbkp_path_move($from, hmbkp_path_default());
    }
    // If the custom path has changed and the new directory isn't writable
    if (defined('HMBKP_PATH') && HMBKP_PATH && !is_writable(HMBKP_PATH) && get_option('hmbkp_path') === HMBKP_PATH && is_dir(HMBKP_PATH)) {
        hmbkp_path_move(HMBKP_PATH, hmbkp_path_default());
    }
}
Esempio n. 4
0
 /**
  * Get the directory backups are saved to
  *
  * @access public
  * @return string
  */
 public function get_path()
 {
     if (empty($this->path)) {
         $this->set_path(self::conform_dir(hmbkp_path_default()));
     }
     return $this->path;
 }
Esempio n. 5
0
/**
 * Handles changes in the defined Constants
 * that users can define to control advanced
 * settings
 *
 * @return null
 */
function hmbkp_constant_changes()
{
    // Check whether we need to disable the cron
    if (hmbkp_get_disable_automatic_backup() && wp_next_scheduled('hmbkp_schedule_backup_hook')) {
        wp_clear_scheduled_hook('hmbkp_schedule_backup_hook');
    }
    // Or whether we need to re-enable it
    if (!hmbkp_get_disable_automatic_backup() && !wp_next_scheduled('hmbkp_schedule_backup_hook')) {
        hmbkp_setup_schedule();
    }
    // Allow the time of the daily backup to be changed
    if (wp_get_schedule('hmbkp_schedule_backup_hook') != get_option('hmbkp_schedule_frequency')) {
        hmbkp_setup_schedule();
    }
    // Reset if custom time is removed
    if ((defined('HMBKP_DAILY_SCHEDULE_TIME') && !HMBKP_DAILY_SCHEDULE_TIME || !defined('HMBKP_DAILY_SCHEDULE_TIME')) && get_option('hmbkp_schedule_frequency') == 'daily' && date('H:i', wp_next_scheduled('hmbkp_schedule_backup_hook')) != '23:00' && !hmbkp_get_disable_automatic_backup()) {
        hmbkp_setup_schedule();
    }
    // If a custom backup path has been set or changed
    if (defined('HMBKP_PATH') && HMBKP_PATH && hmbkp_conform_dir(HMBKP_PATH) != ($from = hmbkp_conform_dir(get_option('hmbkp_path')))) {
        hmbkp_path_move($from, HMBKP_PATH);
    }
    // If a custom backup path has been removed
    if (defined('HMBKP_PATH') && !HMBKP_PATH || !defined('HMBKP_PATH') && hmbkp_conform_dir(hmbkp_path_default()) != ($from = hmbkp_conform_dir(get_option('hmbkp_path')))) {
        hmbkp_path_move($from, hmbkp_path_default());
    }
    // If the custom path has changed and the new directory isn't writable
    if (defined('HMBKP_PATH') && HMBKP_PATH && hmbkp_conform_dir(HMBKP_PATH) != ($from = hmbkp_conform_dir(get_option('hmbkp_path'))) && $from != hmbkp_path_default() && !is_writable(HMBKP_PATH) && is_dir($from)) {
        hmbkp_path_move($from, hmbkp_path_default());
    }
}