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-semaphore.php

<?php
/**
 * Semaphore Lock Management
 * Adapted from WP Social under the GPL - thanks to Alex King (https://github.com/crowdfavorite/wp-social)
 */
class UpdraftPlus_Semaphore {

	/**
	 * Initializes the semaphore object.
	 *
	 * @static
	 * @return UpdraftPlus_Semaphore
	 */
	public static function factory() {
		return new self;
	}

	/**
	 * Lock Broke
	 *
	 * @var boolean
	 */
	protected $lock_broke = false;

	public $lock_name = 'lock';

	/**
	 * Attempts to start the lock. If the rename works, the lock is started.
	 *
	 * @return bool
	 */
	public function lock() {
		global $wpdb, $updraftplus;

		// Attempt to set the lock
		$affected = $wpdb->query("
			UPDATE $wpdb->options
			   SET option_name = 'updraftplus_locked_".$this->lock_name."'
			 WHERE option_name = 'updraftplus_unlocked_".$this->lock_name."'
		");

		if ('0' == $affected && !$this->stuck_check()) {
			$updraftplus->log('Semaphore lock ('.$this->lock_name.', '.$wpdb->options.') failed (line '.__LINE__.')');
			return false;
		}

		// Check to see if all processes are complete
		$affected = $wpdb->query("
			UPDATE $wpdb->options
			   SET option_value = CAST(option_value AS UNSIGNED) + 1
			 WHERE option_name = 'updraftplus_semaphore_".$this->lock_name."'
			   AND option_value = '0'
		");
		if ('1' != $affected) {
			if (!$this->stuck_check()) {
				$updraftplus->log('Semaphore lock ('.$this->lock_name.', '.$wpdb->options.') failed (line '.__LINE__.')');
				return false;
			}

			// Reset the semaphore to 1
			$wpdb->query("
				UPDATE $wpdb->options
				   SET option_value = '1'
				 WHERE option_name = 'updraftplus_semaphore_".$this->lock_name."'
			");

			$updraftplus->log('Semaphore ('.$this->lock_name.', '.$wpdb->options.') reset to 1');
		}

		// Set the lock time
		$wpdb->query($wpdb->prepare("
			UPDATE $wpdb->options
			   SET option_value = %s
			 WHERE option_name = 'updraftplus_last_lock_time_".$this->lock_name."'
		", current_time('mysql', 1)));
		$updraftplus->log('Set semaphore last lock ('.$this->lock_name.') time to '.current_time('mysql', 1));

		$updraftplus->log('Semaphore lock ('.$this->lock_name.') complete');
		return true;
	}

	public static function ensure_semaphore_exists($semaphore) {
		// Make sure the options for semaphores exist
		global $wpdb, $updraftplus;
		$results = $wpdb->get_results("
			SELECT option_id
				FROM $wpdb->options
				WHERE option_name IN ('updraftplus_locked_$semaphore', 'updraftplus_unlocked_$semaphore', 'updraftplus_last_lock_time_$semaphore', 'updraftplus_semaphore_$semaphore')
		");

		if (!is_array($results) || count($results) < 3) {
		
			if (is_array($results) && count($results) > 0) {
				$updraftplus->log("Semaphore ($semaphore, ".$wpdb->options.") in an impossible/broken state - fixing (".count($results).")");
			} else {
				$updraftplus->log("Semaphore ($semaphore, ".$wpdb->options.") being initialised");
			}
			
			$wpdb->query("
				DELETE FROM $wpdb->options
				WHERE option_name IN ('updraftplus_locked_$semaphore', 'updraftplus_unlocked_$semaphore', 'updraftplus_last_lock_time_$semaphore', 'updraftplus_semaphore_$semaphore')
			");
			
			$wpdb->query($wpdb->prepare("
				INSERT INTO $wpdb->options (option_name, option_value, autoload)
				VALUES
				('updraftplus_unlocked_$semaphore', '1', 'no'),
				('updraftplus_last_lock_time_$semaphore', '%s', 'no'),
				('updraftplus_semaphore_$semaphore', '0', 'no')
			", current_time('mysql', 1)));
		}
	}
	
	/**
	 * Increment the semaphore.
	 *
	 * @param  array $filters
	 * @return Updraft_Semaphore
	 */
	public function increment(array $filters = array()) {
		global $wpdb, $updraftplus;

		if (count($filters)) {
			// Loop through all of the filters and increment the semaphore
			foreach ($filters as $priority) {
				for ($i = 0, $j = count($priority); $i < $j; ++$i) {
					$this->increment();
				}
			}
		} else {
			$wpdb->query("
				UPDATE $wpdb->options
				   SET option_value = CAST(option_value AS UNSIGNED) + 1
				 WHERE option_name = 'updraftplus_semaphore_".$this->lock_name."'
			");
			$updraftplus->log('Incremented the semaphore ('.$this->lock_name.') by 1');
		}

		return $this;
	}

	/**
	 * Decrements the semaphore.
	 *
	 * @return void
	 */
	public function decrement() {
		global $wpdb, $updraftplus;

		$wpdb->query("
			UPDATE $wpdb->options
			   SET option_value = CAST(option_value AS UNSIGNED) - 1
			 WHERE option_name = 'updraftplus_semaphore_".$this->lock_name."'
			   AND CAST(option_value AS UNSIGNED) > 0
		");
		$updraftplus->log('Decremented the semaphore ('.$this->lock_name.') by 1');
	}

	/**
	 * Unlocks the process.
	 *
	 * @return bool
	 */
	public function unlock() {
		global $wpdb, $updraftplus;

		// Decrement for the master process.
		$this->decrement();

		$result = $wpdb->query("
			UPDATE $wpdb->options
			   SET option_name = 'updraftplus_unlocked_".$this->lock_name."'
			 WHERE option_name = 'updraftplus_locked_".$this->lock_name."'
		");

		if ('1' == $result) {
			$updraftplus->log('Semaphore ('.$this->lock_name.') unlocked');
			return true;
		}

		$updraftplus->log('Semaphore ('.$this->lock_name.', '.$wpdb->options.') still locked ('.$result.')');
		return false;
	}

	/**
	 * Attempts to jiggle the stuck lock loose.
	 *
	 * @return bool
	 */
	private function stuck_check() {
		global $wpdb, $updraftplus;

		// Check to see if we already broke the lock.
		if ($this->lock_broke) {
			return true;
		}

		$current_time = current_time('mysql', 1);
		$three_minutes_before = gmdate('Y-m-d H:i:s', time()-(defined('UPDRAFTPLUS_SEMAPHORE_LOCK_WAIT') ? UPDRAFTPLUS_SEMAPHORE_LOCK_WAIT : 180));

		$affected = $wpdb->query($wpdb->prepare("
			UPDATE $wpdb->options
			   SET option_value = %s
			 WHERE option_name = 'updraftplus_last_lock_time_".$this->lock_name."'
			   AND option_value <= %s
		", $current_time, $three_minutes_before));

		if ('1' == $affected) {
			$updraftplus->log('Semaphore ('.$this->lock_name.', '.$wpdb->options.') was stuck, set lock time to '.$current_time);
			$this->lock_broke = true;
			return true;
		}

		// Check if lock is greater that 24 hours
		$last_lock_time = strtotime(UpdraftPlus_Options::get_updraft_option('updraftplus_last_lock_time_'.$this->lock_name, $current_time));
		$next_day = strtotime($current_time.' +1 day');
		if ($last_lock_time > $next_day) {
			$this->lock_broke = true;
			return true;
		}

		return false;
	}
} // End UpdraftPlus_Semaphore

SILENT KILLER Tool