first commit

This commit is contained in:
2025-02-24 22:33:42 +01:00
commit 737c037e85
18358 changed files with 5392983 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<?php
/**
* cloudways custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\HOST
* @link http://www.php-fig.org/psr/psr-2/
*/
use Duplicator\Libs\Snap\SnapUtil;
class DUP_PRO_Cloudways_Host implements DUP_PRO_Host_interface
{
public static function getIdentifier()
{
return DUP_PRO_Custom_Host_Manager::HOST_CLOUDWAYS;
}
public function isHosting()
{
ob_start();
SnapUtil::phpinfo();
$serverinfo = ob_get_clean();
return (strpos($serverinfo, "cloudwaysapps") !== false);
}
public function init()
{
}
}

View File

@@ -0,0 +1,167 @@
<?php
/**
* custom hosting manager
* singleton class
*
* Standard: PSR-2
*
* @package SC\DUPX\HOST
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
require_once(DUPLICATOR____PATH . '/classes/host/interface.host.php');
require_once(DUPLICATOR____PATH . '/classes/host/class.godaddy.host.php');
require_once(DUPLICATOR____PATH . '/classes/host/class.wpengine.host.php');
require_once(DUPLICATOR____PATH . '/classes/host/class.cloudways.host.php');
require_once(DUPLICATOR____PATH . '/classes/host/class.wordpresscom.host.php');
require_once(DUPLICATOR____PATH . '/classes/host/class.liquidweb.host.php');
require_once(DUPLICATOR____PATH . '/classes/host/class.pantheon.host.php');
require_once(DUPLICATOR____PATH . '/classes/host/class.flywheel.host.php');
class DUP_PRO_Custom_Host_Manager
{
const HOST_GODADDY = 'godaddy';
const HOST_WPENGINE = 'wpengine';
const HOST_CLOUDWAYS = 'cloudways';
const HOST_WORDPRESSCOM = 'wordpresscom';
const HOST_LIQUIDWEB = 'liquidweb';
const HOST_PANTHEON = 'pantheon';
const HOST_FLYWHEEL = 'flywheel';
/** @var ?self */
protected static $instance = null;
/** @var bool */
private $initialized = false;
/** @var DUP_PRO_Host_interface[] */
private $customHostings = array();
/** @var string[] */
private $activeHostings = array();
/**
*
* @return self
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Class constructor
*/
private function __construct()
{
$this->customHostings[DUP_PRO_WPEngine_Host::getIdentifier()] = new DUP_PRO_WPEngine_Host();
$this->customHostings[DUP_PRO_Cloudways_Host::getIdentifier()] = new DUP_PRO_Cloudways_Host();
$this->customHostings[DUP_PRO_GoDaddy_Host::getIdentifier()] = new DUP_PRO_GoDaddy_Host();
$this->customHostings[DUP_PRO_WordpressCom_Host::getIdentifier()] = new DUP_PRO_WordpressCom_Host();
$this->customHostings[DUP_PRO_Liquidweb_Host::getIdentifier()] = new DUP_PRO_Liquidweb_Host();
$this->customHostings[DUP_PRO_Pantheon_Host::getIdentifier()] = new DUP_PRO_Pantheon_Host();
$this->customHostings[DUP_PRO_Flywheel_Host::getIdentifier()] = new DUP_PRO_Flywheel_Host();
}
/**
* Initialize custom hostings
*
* @return bool
*/
public function init()
{
if ($this->initialized) {
return true;
}
foreach ($this->customHostings as $cHost) {
if (!($cHost instanceof DUP_PRO_Host_interface)) {
throw new Exception('Host must implement DUP_PRO_Host_interface');
}
if ($cHost->isHosting()) {
$this->activeHostings[] = $cHost->getIdentifier();
$cHost->init();
}
}
$this->initialized = true;
return true;
}
/**
* Return active hostings
*
* @return string[]
*/
public function getActiveHostings()
{
return $this->activeHostings;
}
/**
* Returns true if the current site is hosted on identified host
*
* @param string $identifier Host identifier
*
* @return bool
*/
public function isHosting($identifier)
{
return in_array($identifier, $this->activeHostings);
}
/**
* Returns true if the current site is hosted on a managed host
*
* @return bool
*/
public function isManaged()
{
if ($this->isHosting(self::HOST_WORDPRESSCOM)) {
return true;
}
if ($this->isHosting(self::HOST_GODADDY)) {
return true;
}
if ($this->isHosting(self::HOST_WPENGINE)) {
return true;
}
if ($this->isHosting(self::HOST_CLOUDWAYS)) {
return true;
}
if ($this->isHosting(self::HOST_LIQUIDWEB)) {
return true;
}
if ($this->isHosting(self::HOST_PANTHEON)) {
return true;
}
if ($this->isHosting(self::HOST_FLYWHEEL)) {
return true;
}
return false;
}
/**
* Get hostg object
*
* @param string $identifier Host identifier
*
* @return DUP_PRO_Host_interface|false
*/
public function getHosting($identifier)
{
if ($this->isHosting($identifier)) {
return $this->customHostings[$identifier];
} else {
return false;
}
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Flywheel custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\HOST
* @link http://www.php-fig.org/psr/psr-2/
*/
use Duplicator\Libs\Snap\SnapWP;
class DUP_PRO_Flywheel_Host implements DUP_PRO_Host_interface
{
public static function getIdentifier()
{
return DUP_PRO_Custom_Host_Manager::HOST_FLYWHEEL;
}
public function isHosting()
{
return apply_filters('duplicator_pro_host_check', file_exists(self::getFlywheelMainPluginPaht()), self::getIdentifier());
}
public function init()
{
add_filter('duplicator_pro_overwrite_params_data', array(__CLASS__, 'installerParams'));
add_filter('duplicator_pro_global_file_filters', array(__CLASS__, 'filterPluginFile'));
}
/**
* Get the path to the main plugin file
*
* @return string
*/
public static function getFlywheelMainPluginPaht()
{
return trailingslashit(SnapWP::getHomePath()) . '.fw-config.php';
}
/**
* Filter plugin file
*
* @param array<string> $globalsFileFilters Global file filters
*
* @return array<string>
*/
public static function filterPluginFile($globalsFileFilters)
{
$globalsFileFilters[] = self::getFlywheelMainPluginPaht();
return $globalsFileFilters;
}
/**
* Add installer params
*
* @param array<string,array{formStatus?:string,value:mixed}> $data Data
*
* @return array<string,array{formStatus?:string,value:mixed}>
*/
public static function installerParams($data)
{
// generare new wp-config.php file
$data['wp_config'] = array(
'value' => 'new',
'formStatus' => 'st_infoonly',
);
return $data;
}
}

View File

@@ -0,0 +1,69 @@
<?php
/**
* godaddy custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\HOST
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUP_PRO_GoDaddy_Host implements DUP_PRO_Host_interface
{
public static function getIdentifier()
{
return DUP_PRO_Custom_Host_Manager::HOST_GODADDY;
}
public function isHosting()
{
return apply_filters('duplicator_pro_godaddy_host_check', file_exists(WPMU_PLUGIN_DIR . '/gd-system-plugin.php'));
}
public function init()
{
add_filter('duplicator_pro_default_archive_build_mode', array(__CLASS__, 'defaultArchiveBuildMode'), 20, 1);
add_filter('duplicator_pro_overwrite_params_data', array(__CLASS__, 'installerParams'));
}
/**
* In godaddy the packag build mode must be Dup archive
*
* @param int $archiveBuildMode archive build mode
*
* @return int
*/
public static function defaultArchiveBuildMode($archiveBuildMode)
{
return DUP_PRO_Archive_Build_Mode::DupArchive;
}
/**
* Add installer params
*
* @param array<string,array{formStatus?:string,value:mixed}> $data Data
*
* @return array<string,array{formStatus?:string,value:mixed}>
*/
public static function installerParams($data)
{
// disable wp engine plugins
$data['fd_plugins'] = array(
'value' => array(
'gd-system-plugin.php',
'object-cache.php',
),
);
// generate new wp-config.php file
$data['wp_config'] = array(
'value' => 'new',
'formStatus' => 'st_infoonly',
);
return $data;
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* wpengine custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\HOST
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUP_PRO_Liquidweb_Host implements DUP_PRO_Host_interface
{
public static function getIdentifier()
{
return DUP_PRO_Custom_Host_Manager::HOST_LIQUIDWEB;
}
public function isHosting()
{
return apply_filters('duplicator_pro_liquidweb_host_check', file_exists(WPMU_PLUGIN_DIR . '/liquid-web.php'));
}
public function init()
{
add_filter('duplicator_pro_overwrite_params_data', array(__CLASS__, 'installerParams'));
}
/**
* Add installer params
*
* @param array<string,array{formStatus?:string,value:mixed}> $data Data
*
* @return array<string,array{formStatus?:string,value:mixed}>
*/
public static function installerParams($data)
{
$data['fd_plugins'] = array(
'value' => array(
'liquidweb_mwp.php',
'000-liquidweb-config.php',
'liquid-web.php',
'lw_disable_nags.php',
),
);
return $data;
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* godaddy custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\HOST
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUP_PRO_Pantheon_Host implements DUP_PRO_Host_interface
{
public static function getIdentifier()
{
return DUP_PRO_Custom_Host_Manager::HOST_PANTHEON;
}
public function isHosting()
{
return apply_filters('duplicator_pro_pantheon_host_check', file_exists(WPMU_PLUGIN_DIR . '/pantheon.php'));
}
public function init()
{
add_filter('duplicator_pro_overwrite_params_data', array(__CLASS__, 'installerParams'));
}
/**
* Add installer params
*
* @param array<string,array{formStatus?:string,value:mixed}> $data Data
*
* @return array<string,array{formStatus?:string,value:mixed}>
*/
public static function installerParams($data)
{
// disable wp engine plugins
$data['fd_plugins'] = array(
'value' => array('pantheon.php'),
);
// generare new wp-config.php file
$data['wp_config'] = array(
'value' => 'new',
'formStatus' => 'st_infoonly',
);
return $data;
}
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* godaddy custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\HOST
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUP_PRO_WordpressCom_Host implements DUP_PRO_Host_interface
{
/**
* Get the identifier for this host
*
* @return string
*/
public static function getIdentifier()
{
return DUP_PRO_Custom_Host_Manager::HOST_WORDPRESSCOM;
}
/**
* @return bool
*/
public function isHosting()
{
return apply_filters('duplicator_pro_wordpress_host_check', file_exists(WPMU_PLUGIN_DIR . '/wpcomsh-loader.php'));
}
public function init()
{
add_filter('duplicator_pro_is_shellzip_available', '__return_false');
add_filter('duplicator_pro_overwrite_params_data', array(__CLASS__, 'installerParams'));
}
/**
* Add installer params
*
* @param array<string,array{formStatus?:string,value:mixed}> $data Data
*
* @return array<string,array{formStatus?:string,value:mixed}>
*/
public static function installerParams($data)
{
// disable plugins
$data['fd_plugins'] = array(
'value' => array(
'wpcomsh-loader.php',
'advanced-cache.php',
'object-cache.php',
),
);
// generare new wp-config.php file
$data['wp_config'] = array(
'value' => 'new',
'formStatus' => 'st_infoonly',
);
// disable WP_CACHE
$data['wpc_WP_CACHE'] = array(
'value' => array(
'value' => false,
'inWpConfig' => false,
),
'formStatus' => 'st_infoonly',
);
return $data;
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* wpengine custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\HOST
* @link http://www.php-fig.org/psr/psr-2/
*/
use Duplicator\Libs\Snap\SnapUtil;
class DUP_PRO_WPEngine_Host implements DUP_PRO_Host_interface
{
public static function getIdentifier()
{
return DUP_PRO_Custom_Host_Manager::HOST_WPENGINE;
}
public function isHosting()
{
ob_start();
SnapUtil::phpinfo(INFO_ENVIRONMENT);
$serverinfo = ob_get_clean();
return apply_filters('duplicator_pro_wp_engine_host_check', (strpos($serverinfo, "WPENGINE_ACCOUNT") !== false));
}
public function init()
{
add_filter('duplicator_pro_overwrite_params_data', array(__CLASS__, 'installerParams'));
}
/**
* Add installer params
*
* @param array<string,array{formStatus?:string,value:mixed}> $data Data
*
* @return array<string,array{formStatus?:string,value:mixed}>
*/
public static function installerParams($data)
{
// disable wp engine plugins
$data['fd_plugins'] = array(
'value' => array(
'mu-plugin.php',
'advanced-cache.php',
'wpengine-security-auditor.php',
'stop-long-comments.php',
'slt-force-strong-passwords.php',
'wpe-wp-sign-on-plugin.php',
),
);
// generare new wp-config.php file
$data['wp_config'] = array(
'value' => 'new',
'formStatus' => 'st_infoonly',
);
// disable WP_CACHE
$data['wpc_WP_CACHE'] = array(
'value' => array(
'value' => false,
'inWpConfig' => false,
),
'formStatus' => 'st_infoonly',
);
return $data;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* interface for specific hostings class
*
* Standard: PSR-2
*
* @package SC\DUPX\HOST
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
interface DUP_PRO_Host_interface
{
/**
* return the current host itentifier
*
* @return string
*/
public static function getIdentifier();
/**
* @return bool true if is current host
*/
public function isHosting();
/**
* the init function.
* is called only if isHosting is true
*
* @return void
*/
public function init();
}