SILENT KILLERPanel

Current Path: > home > codekrsu > > ameliagraphics.com > wp-content > plugins > > updraftplus > includes


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/codekrsu//ameliagraphics.com/wp-content/plugins//updraftplus/includes

NameTypeSizeLast ModifiedActions
Dropbox2 Directory - -
Google Directory - -
blockui Directory - -
checkout-embed Directory - -
cloudfiles Directory - -
handlebars Directory - -
images Directory - -
jquery-ui.dialog.extended Directory - -
jquery.serializeJSON Directory - -
jstree Directory - -
labelauty Directory - -
pcloud Directory - -
select2 Directory - -
tether Directory - -
tether-shepherd Directory - -
updraftclone Directory - -
S3.php File 78483 bytes March 21 2025 22:25:22.
S3compat.php File 31581 bytes December 23 2024 23:47:28.
cacert.pem File 221470 bytes November 23 2023 19:21:20.
class-backup-history.php File 40508 bytes April 17 2025 13:45:08.
class-commands.php File 49966 bytes April 17 2025 13:45:08.
class-database-utility.php File 37569 bytes April 17 2025 13:45:08.
class-filesystem-functions.php File 41259 bytes December 23 2024 23:47:28.
class-http-error-descriptions.php File 11669 bytes August 09 2023 18:48:00.
class-job-scheduler.php File 10552 bytes May 16 2023 19:44:38.
class-manipulation-functions.php File 17139 bytes July 06 2023 16:16:56.
class-partialfileservlet.php File 7558 bytes December 23 2024 23:47:28.
class-remote-send.php File 32760 bytes March 21 2025 22:25:22.
class-search-replace.php File 20570 bytes December 23 2024 23:47:28.
class-semaphore.php File 6424 bytes August 22 2022 22:55:02.
class-storage-methods-interface.php File 18664 bytes August 09 2023 18:48:00.
class-updraft-dashboard-news.php File 8242 bytes December 23 2024 23:47:28.
class-updraft-semaphore.php File 7693 bytes August 19 2021 15:58:16.
class-updraftcentral-updraftplus-commands.php File 1857 bytes December 15 2022 01:35:40.
class-updraftplus-encryption.php File 14031 bytes April 17 2025 13:45:08.
class-wpadmin-commands.php File 39447 bytes February 26 2025 16:29:18.
class-zip.php File 18336 bytes March 21 2025 22:25:22.
ftp.class.php File 6769 bytes April 17 2025 13:45:08.
get-cpanel-quota-usage.pl File 408 bytes October 18 2013 00:20:56.
google-extensions.php File 9497 bytes December 23 2024 23:47:28.
jquery-ui.custom-v1.11.4-1-25-6.min.css File 38751 bytes May 28 2025 00:56:22.
jquery-ui.custom-v1.11.4-1-25-6.min.css.map File 58374 bytes May 28 2025 00:56:22.
jquery-ui.custom-v1.11.4.css File 43193 bytes September 16 2022 16:41:44.
jquery-ui.custom-v1.12.1-1-25-6.min.css File 40497 bytes May 28 2025 00:56:22.
jquery-ui.custom-v1.12.1-1-25-6.min.css.map File 60839 bytes May 28 2025 00:56:22.
jquery-ui.custom-v1.12.1.css File 45090 bytes September 16 2022 16:41:44.
migrator-lite.php File 53735 bytes January 11 2025 21:36:56.
updraft-admin-common-1-25-6.min.js File 158895 bytes May 28 2025 00:56:22.
updraft-admin-common.js File 263234 bytes May 28 2025 00:56:22.
updraft-restorer-skin-compatibility.php File 452 bytes February 21 2020 14:44:26.
updraft-restorer-skin.php File 1723 bytes December 15 2022 01:35:40.
updraftcentral.php File 3464 bytes April 17 2025 13:45:08.
updraftplus-clone.php File 7237 bytes March 21 2025 22:25:22.
updraftplus-login.php File 4368 bytes March 11 2019 20:05:38.
updraftplus-notices.php File 22065 bytes March 21 2025 22:25:22.
updraftplus-tour.php File 13366 bytes April 17 2025 13:45:08.
updraftvault.php File 2040 bytes December 15 2022 01:35:40.

Reading File: /home/codekrsu//ameliagraphics.com/wp-content/plugins//updraftplus/includes/class-job-scheduler.php

<?php

if (!defined('UPDRAFTPLUS_DIR')) die('No access.');

/**
 * A class for scheduling-related code.
 * N.B. This class began life Nov 2018; it is not guaranteed to contain all scheduling-related code. The variables used have also generally remained in the UpdraftPlus class.
 */
class UpdraftPlus_Job_Scheduler {

	/**
	 * This function is purely for timing - we just want to know the maximum run-time; not whether we have achieved anything during it. It will also run a check on whether the resumption interval is being approached.
	 */
	public static function record_still_alive() {
	
		global $updraftplus;
	
		// Update the record of maximum detected runtime on each run
		$time_passed = $updraftplus->jobdata_get('run_times');
		if (!is_array($time_passed)) $time_passed = array();

		$time_this_run = microtime(true)-$updraftplus->opened_log_time;
		$time_passed[$updraftplus->current_resumption] = $time_this_run;
		$updraftplus->jobdata_set('run_times', $time_passed);

		$resume_interval = $updraftplus->jobdata_get('resume_interval');
		if ($time_this_run + 30 > $resume_interval) {
			$new_interval = ceil($time_this_run + 30);
			set_site_transient('updraft_initial_resume_interval', (int) $new_interval, 8*86400);
			$updraftplus->log("The time we have been running (".round($time_this_run, 1).") is approaching the resumption interval ($resume_interval) - increasing resumption interval to $new_interval");
			$updraftplus->jobdata_set('resume_interval', $new_interval);
		}

	}
	
	/**
	 * This method helps with efficient scheduling
	 */
	public static function reschedule_if_needed() {
	
		global $updraftplus;
	
		// If nothing is scheduled, then no re-scheduling is needed, so return
		if (empty($updraftplus->newresumption_scheduled)) return;
		
		$time_away = $updraftplus->newresumption_scheduled - time();
		
		// 45 is chosen because it is 15 seconds more than what is used to detect recent activity on files (file mod times). (If we use exactly the same, then it's more possible to slightly miss each other)
		if ($time_away > 1 && $time_away <= 45) {
			$updraftplus->log('The scheduled resumption is within 45 seconds - will reschedule');
			// Increase interval generally by 45 seconds, on the assumption that our prior estimates were innaccurate (i.e. not just 45 seconds *this* time)
			self::increase_resume_and_reschedule(45);
		}
	}
	
	/**
	 * Indicate that something useful happened. Calling this at appropriate times is an important part of scheduling decisions.
	 */
	public static function something_useful_happened() {

		global $updraftplus;
	
		self::record_still_alive();

		if (!$updraftplus->something_useful_happened) {
		
			// Update the record of when something useful happened
			$useful_checkins = $updraftplus->jobdata_get('useful_checkins');
			if (!is_array($useful_checkins)) $useful_checkins = array();
			if (!in_array($updraftplus->current_resumption, $useful_checkins)) {
				$useful_checkins[] = $updraftplus->current_resumption;
				$updraftplus->jobdata_set('useful_checkins', $useful_checkins);
			}
			
		}

		$updraftplus->something_useful_happened = true;

		$clone_job = $updraftplus->jobdata_get('clone_job');

		if (!empty($clone_job)) {
			static $last_call = false;

			// Check we haven't yet made a call or that 15 minutes has passed before we make another call
			if (!$last_call || time() - $last_call > 900) {
				$last_call = time();
				$clone_id = $updraftplus->jobdata_get('clone_id');
				$secret_token = $updraftplus->jobdata_get('secret_token');
				$log_data = $updraftplus->get_last_log_chunk($updraftplus->file_nonce);
				$log_contents = isset($log_data['log_contents']) ? $log_data['log_contents'] : '';
				$first_byte = isset($log_data['first_byte']) ? $log_data['first_byte'] : 0;
				$response = $updraftplus->get_updraftplus_clone()->backup_checkin(array('clone_id' => $clone_id, 'secret_token' => $secret_token, 'first_byte' => $first_byte, 'log_contents' => $log_contents));
				if (!isset($response['status']) || 'success' != $response['status']) {
					$updraftplus->log("UpdraftClone backup check-in failed.");
				} else {
					$updraftplus->log("UpdraftClone backup check-in made successfully.");
				}
			}
		}

		$updraft_dir = $updraftplus->backups_dir_location();
		if (file_exists($updraft_dir.'/deleteflag-'.$updraftplus->nonce.'.txt')) {
			$updraftplus->log("User request for abort: backup job will be immediately halted");
			@unlink($updraft_dir.'/deleteflag-'.$updraftplus->nonce.'.txt');// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the method.
			$updraftplus->backup_finish(true, true, true);
			die;
		}
		
		if ($updraftplus->current_resumption >= 9 && false == $updraftplus->newresumption_scheduled) {
			$updraftplus->log("This is resumption ".$updraftplus->current_resumption.", but meaningful activity is still taking place; so a new one will be scheduled");
			// We just use max here to make sure we get a number at all
			$resume_interval = max($updraftplus->jobdata_get('resume_interval'), 75);
			// Don't consult the minimum here
			// if (!is_numeric($resume_interval) || $resume_interval<300) { $resume_interval = 300; }
			$schedule_for = time()+$resume_interval;
			$updraftplus->newresumption_scheduled = $schedule_for;
			wp_schedule_single_event($schedule_for, 'updraft_backup_resume', array($updraftplus->current_resumption + 1, $updraftplus->nonce));
		} else {
			self::reschedule_if_needed();
		}
	}
	
	/**
	 * Reschedule the next resumption for the specified amount of time in the future
	 *
	 * @uses wp_schedule_single_event()
	 *
	 * @param Integer $how_far_ahead - a number of seconds
	 */
	public static function reschedule($how_far_ahead) {
	
		global $updraftplus;
		
		// Reschedule - remove presently scheduled event
		$next_resumption = $updraftplus->current_resumption + 1;
		wp_clear_scheduled_hook('updraft_backup_resume', array($next_resumption, $updraftplus->nonce));
		// Add new event
		// This next line may be too cautious; but until 14-Aug-2014, it was 300.
		// Update 20-Mar-2015 - lowered from 180 to 120
		// Update 03-Aug-2018 - lowered from 120 to 100
		// Update 09-Oct-2020 - lowered from 100 to 60
		if ($how_far_ahead < 60) $how_far_ahead = 60;
		$schedule_for = time() + $how_far_ahead;
		$updraftplus->log("Rescheduling resumption $next_resumption: moving to $how_far_ahead seconds from now ($schedule_for)");
		wp_schedule_single_event($schedule_for, 'updraft_backup_resume', array($next_resumption, $updraftplus->nonce));
		$updraftplus->newresumption_scheduled = $schedule_for;
	}
	
	/**
	 * Terminate a backup run because other activity on the backup has been detected
	 *
	 * @uses die()
	 *
	 * @param String  $file				   - Indicate the file whose recent modification is indicative of activity
	 * @param Integer $time_now			   - The epoch time at which the detection took place
	 * @param Integer $time_mod			   - The epoch time at which the file was modified
	 * @param Boolean $increase_resumption - Whether or not to increase the resumption interval
	 */
	public static function terminate_due_to_activity($file, $time_now, $time_mod, $increase_resumption = true) {
	
		global $updraftplus;
		
		// We check-in, to avoid 'no check in last time!' detectors firing.
		self::record_still_alive();
		
		// Log
		$file_size = file_exists($file) ? round(filesize($file)/1024, 1). 'KB' : 'n/a';
		$updraftplus->log("Terminate: ".basename($file)." exists with activity within the last 30 seconds (time_mod=$time_mod, time_now=$time_now, diff=".(floor($time_now-$time_mod)).", size=$file_size). This likely means that another UpdraftPlus run is at work; so we will exit.");
		
		$increase_by = $increase_resumption ? 120 : 0;
		self::increase_resume_and_reschedule($increase_by, true);
		
		// Die, unless there was a deliberate over-ride (for development purposes)
		if (!defined('UPDRAFTPLUS_ALLOW_RECENT_ACTIVITY') || !UPDRAFTPLUS_ALLOW_RECENT_ACTIVITY) die;
	}
	
	/**
	 * Increase the resumption interval and reschedule the next resumption
	 *
	 * @uses self::reschedule()
	 *
	 * @param Integer $howmuch		  - how much to add to the existing resumption interval
	 * @param Boolean $due_to_overlap - setting this changes the strategy for calculating the next resumption; it indicates that the reason for an increase is because of recent activity detection
	 */
	private static function increase_resume_and_reschedule($howmuch = 120, $due_to_overlap = false) {

		global $updraftplus;
	
		$resume_interval = max((int) $updraftplus->jobdata_get('resume_interval'), (0 === $howmuch) ? 120 : 300);

		if (empty($updraftplus->newresumption_scheduled) && $due_to_overlap) {
			$updraftplus->log('A new resumption will be scheduled to prevent the job ending');
		}

		$new_resume = $resume_interval + $howmuch;
		// It may be that we're increasing for the second (or more) time during a run, and that we already know that the new value will be insufficient, and can be increased
		if ($updraftplus->opened_log_time > 100 && microtime(true)-$updraftplus->opened_log_time > $new_resume) {
			$new_resume = ceil(microtime(true)-$updraftplus->opened_log_time)+45;
			$howmuch = $new_resume-$resume_interval;
		}

		// This used to be always $new_resume, until 14-Aug-2014. However, people who have very long-running processes can end up with very long times between resumptions as a result.
		// Actually, let's not try this yet. I think it is safe, but think there is a more conservative solution available.
		// $how_far_ahead = min($new_resume, 600);
		// Nov 2018 - scheduling the next resumption unnecessarily-far-in-the-future after an overlap is still occurring, so, we're adjusting this to have a maximum value in that particular case
		$how_far_ahead = $due_to_overlap ? min($new_resume, 900) : $new_resume;
		
		// If it is very long-running, then that would normally be known soon.
		// If the interval is already 12 minutes or more, then try the next resumption 10 minutes from now (i.e. sooner than it would have been). Thus, we are guaranteed to get at least 24 minutes of processing in the first 34.
		if ($updraftplus->current_resumption <= 1 && $new_resume > 720) $how_far_ahead = 600;

		if (!empty($updraftplus->newresumption_scheduled) || $due_to_overlap) self::reschedule($how_far_ahead);
		
		$updraftplus->jobdata_set('resume_interval', $new_resume);

		$updraftplus->log("To decrease the likelihood of overlaps, increasing resumption interval to: $resume_interval + $howmuch = $new_resume");
	}
}

SILENT KILLER Tool