GRAYBYTE WORDPRESS FILE MANAGER9069

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.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
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /usr/src/litespeed-wp-plugin/6.3.0.1/litespeed-cache/src/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /usr/src/litespeed-wp-plugin/6.3.0.1/litespeed-cache/src//preset.cls.php
<?php
/**
 * The preset class.
 *
 * @since  5.3.0
 */
namespace LiteSpeed;

defined('WPINC') || exit();

class Preset extends Import
{
	protected $_summary;

	const MAX_BACKUPS = 10;

	const TYPE_APPLY = 'apply';
	const TYPE_RESTORE = 'restore';

	const STANDARD_DIR = LSCWP_DIR . 'data/preset';
	const BACKUP_DIR = LITESPEED_STATIC_DIR . '/auto-backup';

	/**
	 * Returns sorted backup names
	 *
	 * @since  5.3.0
	 * @access public
	 */
	public static function get_backups()
	{
		self::init_filesystem();
		global $wp_filesystem;

		$backups = array_map(
			function ($path) {
				return self::basename($path['name']);
			},
			$wp_filesystem->dirlist(self::BACKUP_DIR) ?: array()
		);
		rsort($backups);

		return $backups;
	}

	/**
	 * Removes extra backup files
	 *
	 * @since  5.3.0
	 * @access public
	 */
	public static function prune_backups()
	{
		$backups = self::get_backups();
		global $wp_filesystem;

		foreach (array_slice($backups, self::MAX_BACKUPS) as $backup) {
			$path = self::get_backup($backup);
			$wp_filesystem->delete($path);
			Debug2::debug('[Preset] Deleted old backup from ' . $backup);
		}
	}

	/**
	 * Returns a settings file's extensionless basename given its filesystem path
	 *
	 * @since  5.3.0
	 * @access public
	 */
	public static function basename($path)
	{
		return basename($path, '.data');
	}

	/**
	 * Returns a standard preset's path given its extensionless basename
	 *
	 * @since  5.3.0
	 * @access public
	 */
	public static function get_standard($name)
	{
		return path_join(self::STANDARD_DIR, $name . '.data');
	}

	/**
	 * Returns a backup's path given its extensionless basename
	 *
	 * @since  5.3.0
	 * @access public
	 */
	public static function get_backup($name)
	{
		return path_join(self::BACKUP_DIR, $name . '.data');
	}

	/**
	 * Initializes the global $wp_filesystem object and clears stat cache
	 *
	 * @since  5.3.0
	 */
	static function init_filesystem()
	{
		require_once ABSPATH . '/wp-admin/includes/file.php';
		\WP_Filesystem();
		clearstatcache();
	}

	/**
	 * Init
	 *
	 * @since  5.3.0
	 */
	public function __construct()
	{
		Debug2::debug('[Preset] Init');
		$this->_summary = self::get_summary();
	}

	/**
	 * Applies a standard preset's settings given its extensionless basename
	 *
	 * @since  5.3.0
	 * @access public
	 */
	public function apply($preset)
	{
		$this->make_backup($preset);

		$path = self::get_standard($preset);
		$result = $this->import_file($path) ? $preset : 'error';

		$this->log($result);
	}

	/**
	 * Restores settings from the backup file with the given timestamp, then deletes the file
	 *
	 * @since  5.3.0
	 * @access public
	 */
	public function restore($timestamp)
	{
		$backups = array();
		foreach (self::get_backups() as $backup) {
			if (preg_match('/^backup-' . $timestamp . '(-|$)/', $backup) === 1) {
				$backups[] = $backup;
			}
		}

		if (empty($backups)) {
			$this->log('error');
			return;
		}

		$backup = $backups[0];
		$path = self::get_backup($backup);

		if (!$this->import_file($path)) {
			$this->log('error');
			return;
		}

		self::init_filesystem();
		global $wp_filesystem;

		$wp_filesystem->delete($path);
		Debug2::debug('[Preset] Deleted most recent backup from ' . $backup);

		$this->log('backup');
	}

	/**
	 * Saves current settings as a backup file, then prunes extra backup files
	 *
	 * @since  5.3.0
	 * @access public
	 */
	public function make_backup($preset)
	{
		$backup = 'backup-' . time() . '-before-' . $preset;
		$data = $this->export(true);

		$path = self::get_backup($backup);
		File::save($path, $data, true);
		Debug2::debug('[Preset] Backup saved to ' . $backup);

		self::prune_backups();
	}

	/**
	 * Tries to import from a given settings file
	 *
	 * @since  5.3.0
	 */
	function import_file($path)
	{
		$debug = function ($result, $name) {
			$action = $result ? 'Applied' : 'Failed to apply';
			Debug2::debug('[Preset] ' . $action . ' settings from ' . $name);
			return $result;
		};

		$name = self::basename($path);
		$contents = file_get_contents($path);

		if (false === $contents) {
			Debug2::debug('[Preset] ❌ Failed to get file contents');
			return $debug(false, $name);
		}

		$parsed = array();
		try {
			// Check if the data is v4+
			if (strpos($contents, '["_version",') === 0) {
				$contents = explode("\n", $contents);
				foreach ($contents as $line) {
					$line = trim($line);
					if (empty($line)) {
						continue;
					}
					list($key, $value) = \json_decode($line, true);
					$parsed[$key] = $value;
				}
			} else {
				$parsed = \json_decode(base64_decode($contents), true);
			}
		} catch (\Exception $ex) {
			Debug2::debug('[Preset] ❌ Failed to parse serialized data');
			return $debug(false, $name);
		}

		if (empty($parsed)) {
			Debug2::debug('[Preset] ❌ Nothing to apply');
			return $debug(false, $name);
		}

		$this->cls('Conf')->update_confs($parsed);

		return $debug(true, $name);
	}

	/**
	 * Updates the log
	 *
	 * @since  5.3.0
	 */
	function log($preset)
	{
		$this->_summary['preset'] = $preset;
		$this->_summary['preset_timestamp'] = time();
		self::save_summary();
	}

	/**
	 * Handles all request actions from main cls
	 *
	 * @since  5.3.0
	 * @access public
	 */
	public function handler()
	{
		$type = Router::verify_type();

		switch ($type) {
			case self::TYPE_APPLY:
				$this->apply(!empty($_GET['preset']) ? $_GET['preset'] : false);
				break;

			case self::TYPE_RESTORE:
				$this->restore(!empty($_GET['timestamp']) ? $_GET['timestamp'] : false);
				break;

			default:
				break;
		}

		Admin::redirect();
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
January 01 1970 00:00:00
root / root
0
cdn
--
July 29 2024 22:31:56
root / root
0755
data_structure
--
July 29 2024 22:31:56
root / root
0755
activation.cls.php
14.991 KB
July 29 2024 22:31:56
root / root
0644
admin-display.cls.php
33.202 KB
July 29 2024 22:31:56
root / root
0644
admin-settings.cls.php
9.521 KB
July 29 2024 22:31:56
root / root
0644
admin.cls.php
4.441 KB
July 29 2024 22:31:56
root / root
0644
api.cls.php
11.076 KB
July 29 2024 22:31:56
root / root
0644
avatar.cls.php
6.063 KB
July 29 2024 22:31:56
root / root
0644
base.cls.php
30.246 KB
July 29 2024 22:31:56
root / root
0644
cdn-setup.cls.php
9.874 KB
July 29 2024 22:31:56
root / root
0644
cdn.cls.php
13.132 KB
July 29 2024 22:31:56
root / root
0644
cloud.cls.php
41.797 KB
July 29 2024 22:31:56
root / root
0644
conf.cls.php
18.579 KB
July 29 2024 22:31:56
root / root
0644
control.cls.php
21.746 KB
July 29 2024 22:31:56
root / root
0644
core.cls.php
20.05 KB
July 29 2024 22:31:56
root / root
0644
crawler-map.cls.php
13.999 KB
July 29 2024 22:31:56
root / root
0644
crawler.cls.php
35.222 KB
July 29 2024 22:31:56
root / root
0644
css.cls.php
13.104 KB
July 29 2024 22:31:56
root / root
0644
data.cls.php
17.406 KB
July 29 2024 22:31:56
root / root
0644
data.upgrade.func.php
21.372 KB
July 29 2024 22:31:56
root / root
0644
db-optm.cls.php
9.585 KB
July 29 2024 22:31:56
root / root
0644
debug2.cls.php
12.044 KB
July 29 2024 22:31:56
root / root
0644
doc.cls.php
4.737 KB
July 29 2024 22:31:56
root / root
0644
error.cls.php
6.438 KB
July 29 2024 22:31:56
root / root
0644
esi.cls.php
26.766 KB
July 29 2024 22:31:56
root / root
0644
file.cls.php
10.135 KB
July 29 2024 22:31:56
root / root
0644
gui.cls.php
27.449 KB
July 29 2024 22:31:56
root / root
0644
health.cls.php
2.893 KB
July 29 2024 22:31:56
root / root
0644
htaccess.cls.php
23.919 KB
July 29 2024 22:31:56
root / root
0644
img-optm.cls.php
60.243 KB
July 29 2024 22:31:56
root / root
0644
import.cls.php
4.15 KB
July 29 2024 22:31:56
root / root
0644
instance.cls.php
0.15 KB
July 29 2024 22:31:56
root / root
0644
lang.cls.php
15.536 KB
July 29 2024 22:31:56
root / root
0644
localization.cls.php
3.383 KB
July 29 2024 22:31:56
root / root
0644
media.cls.php
31.01 KB
July 29 2024 22:31:56
root / root
0644
metabox.cls.php
4.205 KB
July 29 2024 22:31:56
root / root
0644
object-cache.cls.php
15.547 KB
July 29 2024 22:31:56
root / root
0644
object.lib.php
33.969 KB
July 29 2024 22:31:56
root / root
0644
optimize.cls.php
36.492 KB
July 29 2024 22:31:56
root / root
0644
optimizer.cls.php
8.827 KB
July 29 2024 22:31:56
root / root
0644
placeholder.cls.php
14.076 KB
July 29 2024 22:31:56
root / root
0644
preset.cls.php
5.43 KB
July 29 2024 22:31:56
root / root
0644
purge.cls.php
29.785 KB
July 29 2024 22:31:56
root / root
0644
report.cls.php
5.328 KB
July 29 2024 22:31:56
root / root
0644
rest.cls.php
7.865 KB
July 29 2024 22:31:56
root / root
0644
root.cls.php
12.596 KB
July 29 2024 22:31:56
root / root
0644
router.cls.php
17.357 KB
July 29 2024 22:31:56
root / root
0644
str.cls.php
1.17 KB
July 29 2024 22:31:56
root / root
0644
tag.cls.php
8.619 KB
July 29 2024 22:31:56
root / root
0644
task.cls.php
5.292 KB
July 29 2024 22:31:56
root / root
0644
tool.cls.php
3.291 KB
July 29 2024 22:31:56
root / root
0644
ucss.cls.php
14.39 KB
July 29 2024 22:31:56
root / root
0644
utility.cls.php
20.634 KB
July 29 2024 22:31:56
root / root
0644
vary.cls.php
19.171 KB
July 29 2024 22:31:56
root / root
0644
vpi.cls.php
7.408 KB
July 29 2024 22:31:56
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF