first commit

This commit is contained in:
Roman Pyrih
2026-04-21 15:48:41 +02:00
commit 7483681901
10216 changed files with 3236626 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
<Files *.php>
Order Deny,Allow
Deny from all
</Files>
<Files index.php>
Order Allow,Deny
Allow from all
</Files>

View File

@@ -0,0 +1,3 @@
<?php
// silent

View File

@@ -0,0 +1,379 @@
<?php
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Libs\Snap\SnapURL;
/**
* A stub for returning an object
*/
class DUPX_API_REQUEST
{
/** @var array{operation:string,process_time:string} */
public $report = ['operation' => '', 'process_time' => ''];
/** @var mixed */
public $result;
}
/**
* A stub for returning an object error response from a failed request
*/
class DUPX_API_ERROR
{
/** @var string */
public $request = '';
/** @var string */
public $message = '';
/** @var string */
public $exception = '';
}
/**
* The DUPX_API_ROUTE object is a routable object that the DUPX_API_SERVER
* uses to help convert methods to routable service calls.
*
* In order for a classes method to become routeable the following route
* tag must be delcated in the comments section of the method in the format
* below with {} brackets around that name of the actual paramter.
*
* <route template="/category/example_method/{param1}/{param2}/{list*}/" type="request">
*
* TEMPLATE ATTRIBUTE:
* When called via an http request the paramter name should be substituted
* with the actual value for the parameter such as
*
* /category/example_method/1/test/a,b,c/
*
* Supported parameter types:
* {param1} = string type
* example: /test/ or /1/
*
* {list*} = array type
* example: /1,2,3/ or /a,b,c/
*
* TYPE ATTRIBUTE:
* The attribute type="request" is used to determine where the request values
* are retrived from. The default is "request" meaning it looks for:
* PATH, GET, POST in that order. If you want the request to only look
* for GET requets then set the attribute to type="get"
*/
class DUPX_API_ROUTE
{
/** @var string */
public $template = '';
/** @var string */
public $type = '';
/** @var string */
public $operation = '';
/** @var array<string,mixed> */
public $params = [];
/** @var string */
public $class_method = '';
/** @var string */
public $class_name = '';
/** @var ?object */
public $class_instance;
}
/**
* The DUPX_API_SERVER object is used to listen for and process
* routable template calls. The root for this api stack starts with
* https://website.com/dup-installer/api/router.php/cpnl/create_token/
*
* This will display the GUI for the api and is the starting point
* for processing api requets.
*
* <code>
* //Register API Engine
* $API_SERVER = new DUPX_API_SERVER();
* $API_SERVER->add_controller(new MyClass());
* $API_SERVER->process_request();
* </code>
*/
class DUPX_API_Server
{
/** @var object[] */
public $controllers = [];
public $uri_found;
public $uri_match;
public $args_in = [];
public $args_map = [];
public $exe_route;
public $api_enabled = false;
/**
* Called to begin listening to all requests made through the router.php request.
* If the inbound request is found it will process the service request.
*
* @param bool $debug Turn debugging on/off
*
* An example of a request URL is:
* //localhost/dup-installer/api/router.php/cpnl/create_token/{host}/{user}/{pass}/
*/
public function process_request($debug = false): void
{
$url_route = $this->get_active_url_route();
$this->exe_route = $this->find_controller($url_route);
//API process: Invalid route requested
if (!$this->exe_route) {
/* TODO: Find clean way to provide validation message
$url = urldecode($url_route);
$log = "WARNING: Unable to find a matching controller at this route:<br/>\n {$url}<br/>\n";
$log .= "Be sure that all controllers are properly using a &lt;route&gt; directive";
echo $log; */
return;
}
$this->uri_found = $url_route;
$this->uri_match = $this->exe_route->operation;
$this->args_map = $this->process_args();
if ($debug) {
$this->debug_info();
}
$api_request = new DUPX_API_REQUEST();
try {
$time_start = microtime(true);
$rfl_method = new ReflectionMethod($this->exe_route->class_name, $this->exe_route->class_method);
$result = $rfl_method->invokeArgs($this->exe_route->class_instance, $this->args_map);
$result = (DUPX_U::isJSON($result)) ? json_decode($result) : $result;
//Return results as JSON
$api_request->report['process_time'] = microtime(true) - $time_start;
$api_request->report['operation'] = $this->exe_route->operation;
$api_request->result = $result;
if (!headers_sent()) {
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: application/json');
}
echo json_encode($api_request);
exit;
}
catch (Exception $ex) {
$err = new DUPX_API_ERROR();
$err->request = $this->exe_route->class_method;
$err->message = $ex->getMessage();
$err->exception = $ex->__toString();
echo json_encode($err);
exit;
}
}
/**
* Display debug info about an inbound service request
*/
public function debug_info(): void
{
echo '<pre>';
echo 'FOUND: '.$this->uri_found.'<br/>';
echo 'MATCHED: '.$this->uri_match.'<br/>';
echo 'INPUTS:';
DUPX_U::dump($this->args_in);
echo 'INPUT MAP:';
DUPX_U::dump($this->args_map);
DUPX_U::dump($this->exe_route, true);
echo '<br/> RESULT: <br/>';
echo '</pre>';
}
/**
* Controller classes are the heart of the web services. Add a controller
* to allow service methods to be exposed via the /api/router.php
* Example of controller class is: class.cpnl.ctrl.php
*/
public function add_controller($class): bool
{
$rfl = new ReflectionClass($class);
$cls_name = $rfl->getName();
$cls_methods = $rfl->getMethods();
if (in_array($cls_name, $this->controllers)) {
return false;
}
foreach ($cls_methods as $m) {
$comments = $m->getDocComment();
$route_elm = $this->get_tag_attributes('route', $comments);
if ($route_elm != null) {
$route = new DUPX_API_ROUTE();
$route->type = $route_elm['type'] ?? 'request';
$route->template = $route_elm['template'] ?? '';
//Check for duplicate operation
if ($this->find_controller($route->operation)) {
throw new Exception("Duplicate route tag operation '{$route->operation}'! See tag <route tempalte='{$route->template}' > in class {$cls_name}");
}
$route->operation = $this->get_operation($route_elm['template']);
$route->params = $this->get_params($route->template, $route->operation);
$route->class_method = $m->getName();
$route->class_instance = $class;
$route->class_name = $cls_name;
$this->controllers[] = $route;
}
}
return true;
}
/**
* Matches the uri defined template args
* with the inbound args, PATH, GET, POST
*/
private function process_args()
{
$args_map = [];
$params = empty($this->exe_route->params) ? null : $this->exe_route->params;
if ($params == null) {
return $args_map;
}
$args_map = $params;
$args_map = array_map(fn($n) => null, $args_map);
// <route template="/cpnl/is_active/{cpnl-host}/{arg1}/{list*}" type="request">
//REQUEST: Post, Get, Path
//PATH: Path
//GET: Get
//POST: Post
$uri_params = substr($this->uri_found, strlen($this->uri_match));
$this->args_in['PATH'] = array_filter(explode("/", preg_replace('/\?.*/', '', $uri_params)));
$this->args_in['GET'] = $_GET;
$this->args_in['POST'] = $_POST;
switch (strtoupper($this->exe_route->type)) {
case 'POST' : $args_map = array_merge($args_map, $this->args_in['POST']);
break;
case 'GET' : $args_map = array_merge($args_map, $this->args_in['GET']);
break;
case 'PATH' : $args_map = $this->args_map_merge($args_map);
break;
default :
$args_map = array_merge($args_map, $this->args_in['POST']);
$args_map = array_merge($args_map, $this->args_in['GET']);
$args_map = $this->args_map_merge($args_map);
}
//Only returned the params defined
$length = count($this->exe_route->params);
$args_map = array_slice($args_map, 0, $length);
return array_map('urldecode', $args_map);
}
/**
* Creats the args map needed for the final args results
*/
private function args_map_merge(array $args_map): array
{
$keys = array_keys($args_map);
foreach ($this->args_in['PATH'] as $k => $v) {
$args_map[$keys[$k]] = $v;
}
return $args_map;
}
/**
* Will look through all of the registerd controllers
* and find the correct controller based on the request
*/
private function find_controller($template)
{
if (empty($this->controllers)) {
return;
}
foreach ($this->controllers as $controller) {
if (strstr($template, (string) $controller->operation)) {
return $controller;
}
}
}
/**
* Returns the parameters from a uri template
* example: "/cpnl/is_active/{host}?s=1"
* returns: array('host' => '', 's' => 1);
* @return 'list'[]|'string'[]
*/
private function get_params($template, ?string $operation): array
{
$paths = str_replace($operation, '', $template);
$paths = array_filter(explode("/", $paths));
$params = [];
foreach ($paths as $p) {
$type = strpos($p, '*') ? 'list' : 'string';
$name = $type == 'list' ? trim($p, '{*}') : trim($p, '{}');
$params[$name] = $type;
}
return $params;
}
/**
* Returns the base operation portion of a template
* example: "http://site.com/instatller.php/cpnl/is_active/1/category/a,b,c"
* returns: "/cpnl/is_active/host?s=1"
*/
private function get_active_url_route(): string
{
$file = 'router.php';
$url_path = strstr(SnapURL::getCurrentUrl(true, true), $file);
return str_replace($file, '', $url_path);
}
/**
* Returns the base operation portion of a template
* example: "/cpnl/is_active/host?s=1"
* returns: "/cpnl/is_active/"
*/
private function get_operation($template): ?string
{
$routes = explode("/", $template);
$ops = [];
if ($routes == false) {
return null;
}
//remove parameters
foreach ($routes as $r) {
if (preg_match("/^[a-zA-Z0-9_\-]+$/", $r)) {
$ops[] = $r;
}
}
return '/'.implode('/', $ops).'/';
}
/**
* Finds a tag element in a string and parses its attributes
* example: Finds <route> element and returns its attributes
*/
private function get_tag_attributes(string $element_name, $string)
{
if ($string == false) {
return;
}
// Grab the string of attr inside an element tag.
$found = preg_match('#<'.$element_name.'\s+([^>]+(?:"|\'))\s?/?>#', $string, $matches);
if ($found == 1) {
// Match attr-name attribute-value pairs.
$attr_array = [];
$attr_string = $matches[1];
$found = preg_match_all('#([^\s=]+)\s*=\s*(\'[^<\']*\'|"[^<"]*")#', $attr_string, $matches, PREG_SET_ORDER);
if ($found != 0) {
// Create an associative array that matches attr names to attr values.
foreach ($matches as $att) {
$attr_array[$att[1]] = substr($att[2], 1, -1);
}
return $attr_array;
}
}
return;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,441 @@
<?php
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
//This class is called through both the router.php and main.installer.php
//Full Path: {DUPX_INIT}/api/
require_once("class.cpnl.base.php");
/**
* Class used to store cPanel host information
* */
class DUPX_cPanelHost
{
/** @var string */
public $url = '';
/** @var string */
public $host = '';
/** @var string */
public $scheme = '';
/** @var int */
public $port = 0;
/** @var string */
public $user = '';
/** @var string */
public $pass = '';
}
/**
* Wrapper Class for cPanel API
*
* <routable> */
class DUPX_cPanel_Controller
{
/** @var ?CPNL_API */
private $api;
/**
* Creates a security token to access the cPanel calls
* @param string $host The cPanel host name can be full url or just domain name
* https://mysite.com:2083, https://mysite.com, mysite.com
* @param string $user A valid cPanel user name
* @param string $pass A valid cPanel user password
* @return string A base64 encoded string of the input params
*
* <route template="/cpnl/create_token/{host}/{user}/{pass}/">
*/
public function create_token($host, $user, $pass): string
{
if (substr($host, 0, 4) !== 'http') {
$host = 'https://' . $host;
}
$url = parse_url($host);
$host = $url['host'] ?? null;
if (is_null($host)) {
throw new Exception('The create_token operation requires a valid host parameter');
}
if (!$user) {
throw new Exception('The create_token operation requires a valid user parameter');
}
if (!$pass) {
throw new Exception('The create_token operation requires a valid password parameter');
}
$scheme = $url['scheme'] ?? 'https';
$port = $url['port'] ?? '2083';
return base64_encode("{$scheme},{$host},{$port},{$user},{$pass}");
}
/**
* Get the host information about this cpanel server
* @param string $token The authtoken used to access cpanel
* @return DUPX_cPanelHost A DUPX_cPanelHost object
*
* <route template="/cpnl/get_host/{token}/">
*/
public function get_host($token): \DUPX_cPanelHost
{
$host = new DUPX_cPanelHost();
$creds = explode(",", base64_decode($token));
if (!isset($creds[1])) {
throw new Exception("Invalid hostname detected for get_host with token: $token");
}
$host->scheme = $creds[0];
$host->host = $creds[1];
$host->port = (int) $creds[2];
$host->user = $creds[3];
$host->pass = $creds[4];
$host->url = "{$host->scheme}://{$host->host}:{$host->port}";
return $host;
}
/**
* Get the setup data needed for validating and show DB information
* @param string $token The authtoken used to access cpanel
* @return array $data['valid_host'] Is the url a valid cpanel URL
* $data['valid_user'] Is the user a valid cpanel user
* $data['is_prefix_on'] Does the cpanel use a DB prefix
* $data['dbinfo'] A list of databases and info
* $data['dbusers'] A list of database users
*
* <route template="/cpnl/get_setup_data/{token}/">
*/
public function get_setup_data($token): array
{
$data = [];
$host = $this->connect($token);
$data['valid_host'] = false;
$data['valid_user'] = false;
$data['is_prefix_on'] = false;
$data['dbinfo'] = null;
$data['dbusers'] = null;
try {
$data = [];
$host = $this->connect($token);
$data['valid_host'] = $this->is_host_active($host->url);
$data['is_prefix_on'] = $this->is_prefix_on($token);
//Try two calls just in case
$obj = json_decode($this->api->api2_query($host->user, "Contactus", "isenabled"));
if (isset($obj->cpanelresult->func)) {
$data['valid_user'] = true;
} else {
$obj = json_decode($this->api->api2_query($host->user, "Email", "accountname"));
if (isset($obj->cpanelresult->func)) {
$data['valid_user'] = true;
}
}
//DB NAMES/USRERS
$obj = json_decode($this->api->api2_query($host->user, "MysqlFE", "getalldbsinfo"));
$obj_dbs = $obj->cpanelresult->data ?? null;
$data['dbinfo'] = ($obj_dbs != null && count($obj_dbs) >= 1) ? $obj_dbs : null;
$obj = json_decode($this->api->api2_query($host->user, "MysqlFE", "listusers"));
$obj_dbusers = $obj->cpanelresult->data ?? null;
$data['dbusers'] = ($obj_dbusers != null && count($obj_dbusers) >= 1) ? $obj_dbusers : null;
return $data;
} catch (Exception $ex) {
return $data;
}
}
/**
* Lists the databases for the specified cpanel account
* @param string $token The authtoken used to access cpanel
* @return array $data['status'] True/False or an error message.
* $data['cpnl_api'] The cpanel API result
*
* <route template="/cpnl/list_dbs/{token}/">
*/
public function list_dbs($token)
{
// Returns true/false or message on error
$data['status'] = "Error listing databases. See the log for more details.";
$data['cpnl_api'] = null;
$host = $this->connect($token);
$json = $this->api->api2_query($host->user, "MysqlFE", "listdbs");
if ($json !== false) {
$obj = json_decode($json);
$data['cpnl_api'] = $obj;
$data['status'] = isset($obj->cpanelresult->event->result) && $obj->cpanelresult->event->result == 1;
if (property_exists($obj->cpanelresult, 'error')) {
$data['status'] = $obj->cpanelresult->error;
}
}
return $data;
}
/**
* Creates a database via the cPanel API
*
* @param string $token The authtoken used to access cpanel
* @param string $dbname The name of database to create
* @return array $data['status'] True/False or an error message.
* $data['cpnl_api'] The cpanel API result
*
* <route template="/cpnl/create_db/{token}/{dbname}">
*/
public function create_db($token, $dbname)
{
// Returns true/false or message on error
$data['status'] = "Error creating database '{$dbname}'. See the log for more details.";
$data['cpnl_api'] = null;
$host = $this->connect($token);
$args = [];
$args['db'] = $dbname;
$json = $this->api->api2_query($host->user, "MysqlFE", "createdb", $args);
if ($json !== false) {
$obj = json_decode($json);
$data['cpnl_api'] = $obj;
$data['status'] = isset($obj->cpanelresult->event->result) && $obj->cpanelresult->event->result == 1;
if (property_exists($obj->cpanelresult, 'error')) {
$data['status'] = $obj->cpanelresult->error;
}
}
return $data;
}
/**
* Deletes a database via the cPanel API
*
* @param string $token The authtoken used to access cpanel
* @param string $dbname The name of database to delete
* @return array $data['status'] True/False or an error message.
* $data['cpnl_api'] The cpanel API result
*
* <route template="/cpnl/delete_db/{token}/{dbname}">
*/
public function delete_db($token, $dbname)
{
// Returns true/false or message on error
$data['status'] = "Error deleting database '{$dbname}'. See the log for more details.";
$data['cpnl_api'] = null;
$host = $this->connect($token);
$args = [];
$args['db'] = $dbname;
$json = $this->api->api2_query($host->user, "MysqlFE", "deletedb", $args);
if ($json !== false) {
$obj = json_decode($json);
$data['cpnl_api'] = $obj;
$data['status'] = isset($obj->cpanelresult->event->result) && $obj->cpanelresult->event->result == 1;
if (property_exists($obj->cpanelresult, 'error')) {
$data['status'] = $obj->cpanelresult->error;
}
}
return $data;
}
/**
* Creates a database user via the cPanel API
*
* @param string $token The authtoken used to access cpanel
* @param string $dbuser The name of database user to create
* @param string $dbpass The database password to create for the user
*
* @return array<string,mixed> $data['status'] True/False or an error message.
* $data['cpnl_api'] The cpanel API result
*
* <route template="/cpnl/create_db_user/{token}/{dbuser}/{dbpass}">
*/
public function create_db_user($token, $dbuser, $dbpass)
{
// Returns true/false or message on error
$data['status'] = "Error creating database user '{$dbuser}'. See the log for more details.";
$data['cpnl_api'] = null;
$host = $this->connect($token);
$args = [];
$args['dbuser'] = $dbuser;
$args['password'] = $dbpass;
$json = $this->api->api2_query($host->user, "MysqlFE", "createdbuser", $args);
if ($json !== false) {
$obj = json_decode($json);
$data['cpnl_api'] = $obj;
if (isset($obj->cpanelresult->event->result) && $obj->cpanelresult->event->result == 1) {
$data['status'] = true;
}
if (property_exists($obj->cpanelresult, 'error')) {
$data['status'] = $obj->cpanelresult->error;
}
}
return $data;
}
/**
* Deletes a database user via the cPanel API
*
* @param string $token The authtoken used to access cpanel
* @param string $dbuser The name of database user to delete
* @return array $data['status'] True/False or an error message.
* $data['cpnl_api'] The cpanel API result
*
* <route template="/cpnl/delete_db_user/{token}/{dbuser}">
*/
public function delete_db_user($token, $dbuser)
{
// Returns true/false or message on error
$data['status'] = "Error deleting database user '{$dbuser}'. See the log for more details.";
$data['cpnl_api'] = null;
$host = $this->connect($token);
$args = [];
$args['dbuser'] = $dbuser;
$json = $this->api->api2_query($host->user, "MysqlFE", "deletedbuser", $args);
if ($json !== false) {
$obj = json_decode($json);
$data['cpnl_api'] = $obj;
if (isset($obj->cpanelresult->event->result) && $obj->cpanelresult->event->result == 1) {
$data['status'] = true;
}
if (property_exists($obj->cpanelresult, 'error')) {
$data['status'] = $obj->cpanelresult->error;
}
}
return $data;
}
/**
* Assigns a user to a database via the cPanel API with ALL privileges
*
* @param string $token The authtoken used to access cpanel
* @param string $dbname The name of a valid database
* @param string $dbuser The user to add to the database
* @return array $data['status'] True/False or an error message.
* $data['cpnl_api'] The cpanel API result
*
* <route template="/cpnl/assign_db_user/{token}/{dbname}/{dbuser}">
*/
public function assign_db_user($token, $dbname, $dbuser)
{
// Returns true/false or message on error
$data['status'] = "Unable to retrieve error status from cPanel API'. See the log for more details.";
$data['cpnl_api'] = null;
$host = $this->connect($token);
$args = [];
$args['privileges'] = 'ALL PRIVILEGES';
$args['db'] = $dbname;
$args['dbuser'] = $dbuser;
$json = $this->api->api2_query($host->user, "MysqlFE", "setdbuserprivileges", $args);
if ($json !== false) {
$obj = json_decode($json);
$data['cpnl_api'] = $obj;
//On some APIs this method returns error = 1 even when result = 1. It seems that the result = 1 is more
//accurate for success detection so that will be the primary driver for success
if (isset($obj->cpanelresult->event->result) && $obj->cpanelresult->event->result == 1) {
$data['status'] = true;
} elseif (property_exists($obj->cpanelresult, 'error')) {
$data['status'] = $obj->cpanelresult->error;
}
}
return $data;
}
/**
* Is the user in the database specified
* @param string $token The authtoken used to access cpanel
* @param string $dbname The name of a valid database
* @param string $dbuser A database user
* @return array $data['status'] True/False or an error message.
* $data['cpnl_api'] The cpanel API result
*
* <route template="/cpnl/is_user_in_db/{token}/{dbname}/{dbuser}">
*/
public function is_user_in_db($token, $dbname, $dbuser)
{
// Returns true/false or message on error
$data['status'] = "Error determining if '{$dbuser}' can access database '{$dbname}'. See the log for more details.";
$data['cpnl_api'] = null;
$host = $this->connect($token);
$args = [];
$args['db'] = $dbname;
$json = $this->api->api2_query($host->user, "MysqlFE", "listusersindb", $args);
if ($json !== false) {
$obj = json_decode($json);
$data['cpnl_api'] = $obj;
$data['status'] = false;
foreach ($obj->cpanelresult->data as $database_pair) {
if ($database_pair->user == $dbuser) {
$data['status'] = true;
break;
}
}
} else {
$data['status'] = 'Could not retrieve list of users in database.';
}
return $data;
}
/**
* Does cpanel require the database to have a prefix
* <route template="/cpnl/is_prefix_on/{token}">
* Return
* $data['status'] True/False or an error message.
* $data['cpnl_api'] The cpanel API result
*
* @param string $token The authtoken used to access cpanel
*
* @return array{status:bool|string,cpnl_api:object}
*/
public function is_prefix_on($token): array
{
// Returns true/false or message on error
$data = [];
$data['status'] = "Error determining if database prefix name is enabled. See the log for more details.";
$data['cpnl_api'] = null;
$host = $this->connect($token);
$json = $this->api->api2_query($host->user, "DBmap", "status");
if ($json !== false) {
$obj = json_decode($json);
$data['cpnl_api'] = $obj;
$data['status'] = isset($obj->cpanelresult->data) ? "Error calling DBmap" : $obj->cpanelresult->data[0]->prefix == 1;
}
return $data;
}
/**
* Connect to the cPanel API
*
* @param string $token A valid token
* @return DUPX_cPanelHost A DUPX_cPanelHost object
*/
public function connect($token)
{
$host = $this->get_host($token);
if (!$host->host || !$host->user || !$host->pass) {
throw new Exception('DUPX_cPanel->connect invalid token provided.');
}
//Call to cPanel XMLAPI Client Class see /classes/_libs.php
$this->api = new CPNL_API($host->host);
$this->api->password_auth($host->user, $host->pass);
$this->api->set_protocol($host->scheme);
$this->api->set_port($host->port);
$this->api->set_output("json");
$this->api->set_debug(false);
return $host;
}
/**
* Check to see if the cPanel API is availble for use
*
* @param string $url
*
* @return bool True if this host supports the json api
*
* //https://mysite.com:2083/json-api/
*/
private function is_host_active($url): bool
{
$route = '/json-api/';
$url = (!strpos($url, $route)) ? "{$url}/json-api/" : $url;
$response = DUPX_HTTP::get($url);
$json = json_decode($response);
if (isset($json->cpanelresult)) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,4 @@
<?php
//Start at router for all api requets
header('Location: router.php') ;

View File

@@ -0,0 +1,32 @@
<?php
if (!defined('DUPXABSPATH')) {
define('DUPXABSPATH', __DIR__);
}
use Duplicator\Installer\Core\Bootstrap;
define('DUPX_VERSION', '4.5.25.2');
define('DUPX_INIT', str_replace('\\', '/', dirname(__DIR__)));
define('DUPX_ROOT', preg_match('/^[\\\\\/]?$/', dirname(DUPX_INIT)) ? '/' : dirname(DUPX_INIT));
require_once(DUPX_INIT . '/src/Utils/Autoloader.php');
Duplicator\Installer\Utils\Autoloader::register();
/**
* init constants and include
*/
Bootstrap::init(2);
require_once('class.api.php');
require_once('class.cpnl.base.php');
require_once('class.cpnl.ctrl.php');
//Register API Engine - If it processes the current route it spits out JSON and exits the process
$API_Server = new DUPX_API_Server();
$API_Server->add_controller(new DUPX_cPanel_Controller());
$API_Server->process_request(false);
dupxTplRender('api/front', [
'apiControllers' => $API_Server->controllers,
'dupVersion' => DUPX_ArchiveConfig::getInstance()->version_dup
]);

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@@ -0,0 +1,91 @@
/*! ================================================
* DUPLICATOR TIPPY STYLE
* Copyright:Snap Creek LLC 2015-2021
* ================================================ */
.tippy-box[data-theme~='duplicator'],
.tippy-box[data-theme~='duplicator-filled'] {
background-color: white;
color: black;
font-size: 12px;
border-width: 1px;
border-style: solid;
border-radius: 0;
padding: 0;
max-width: 250px;
}
.tippy-box[data-theme~='duplicator'] .tippy-content,
.tippy-box[data-theme~='duplicator-filled'] .tippy-content {
padding: 0;
}
.tippy-box[data-theme~='duplicator'] h3,
.tippy-box[data-theme~='duplicator-filled'] h3 {
display: block;
box-sizing: border-box;
margin: 0;
width: 100%;
padding: 5px;
font-weight: bold;
font-size: 12px;
}
.tippy-box[data-theme~='duplicator'] .dup-tippy-content,
.tippy-box[data-theme~='duplicator-filled'] .dup-tippy-content {
padding: 5px;
}
.tippy-box[data-theme~='duplicator'] .dup-tippy-content *:first-child,
.tippy-box[data-theme~='duplicator-filled'] .dup-tippy-content *:first-child {
margin-top: 0;
}
.tippy-box[data-theme~='duplicator'] .dup-tippy-content *:last-child,
.tippy-box[data-theme~='duplicator-filled'] .dup-tippy-content *:last-child {
margin-bottom: 0;
}
.tippy-box[data-placement^='top']>.tippy-arrow::before {
bottom: -9px;
}
.tippy-box[data-placement^='bottom']>.tippy-arrow::before {
top: -9px;
}
.tippy-box[data-theme~='duplicator'],
.tippy-box[data-theme~='duplicator-filled'] {
border-color: #13659C;
}
.tippy-box[data-theme~='duplicator'] h3,
.tippy-box[data-theme~='duplicato-filled'] h3 {
background-color: #13659C;
color: white;
}
.tippy-box[data-theme~='duplicator-filled'] .tippy-content {
background-color: #13659C;
color: white;
}
.tippy-box[data-theme~='duplicator'][data-placement^='top']>.tippy-arrow::before,
.tippy-box[data-theme~='duplicator-filled'][data-placement^='top']>.tippy-arrow::before {
border-top-color: #13659C;
}
.tippy-box[data-theme~='duplicator'][data-placement^='bottom']>.tippy-arrow::before,
.tippy-box[data-theme~='duplicator-filled'][data-placement^='bottom']>.tippy-arrow::before {
border-bottom-color: #13659C;
}
.tippy-box[data-theme~='duplicator'][data-placement^='left']>.tippy-arrow::before,
.tippy-box[data-theme~='duplicator-filled'][data-placement^='left']>.tippy-arrow::before {
border-left-color: #13659C;
}
.tippy-box[data-theme~='duplicator'][data-placement^='right']>.tippy-arrow::before,
.tippy-box[data-theme~='duplicator-filled'][data-placement^='right']>.tippy-arrow::before {
border-right-color: #13659C;
}

View File

@@ -0,0 +1,8 @@
@font-face {
font-family: 'dotsfont';
src: url('dotsfont.eot');
src: url('dotsfont.eot?#iefix') format('embedded-opentype'),
url('dotsfont.woff') format('woff'),
url('dotsfont.ttf') format('truetype'),
url('dotsfont.svg#dotsfontregular') format('svg');
}

View File

@@ -0,0 +1,225 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata></metadata>
<defs>
<font id="dotsfontregular" horiz-adv-x="1200" >
<font-face units-per-em="1000" ascent="750" descent="-250" />
<missing-glyph horiz-adv-x="500" />
<glyph horiz-adv-x="0" />
<glyph horiz-adv-x="333" />
<glyph unicode=" " />
<glyph unicode="!" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x22;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="#" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="$" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="%" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x26;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="'" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="(" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode=")" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="*" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="+" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="," d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="-" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="." d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="/" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="0" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="1" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="2" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="3" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="4" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="5" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="6" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="7" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="8" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="9" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode=":" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode=";" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x3c;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="=" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x3e;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="?" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="@" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="A" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="B" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="C" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="D" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="E" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="F" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="G" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="H" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="I" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="J" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="K" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="L" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="M" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="N" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="O" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="P" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="Q" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="R" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="S" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="T" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="U" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="V" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="W" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="X" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="Y" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="Z" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="[" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="\" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="]" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="^" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="_" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="`" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="a" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="b" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="c" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="d" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="e" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="f" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="g" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="h" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="i" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="j" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="k" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="l" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="m" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="n" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="o" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="p" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="q" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="r" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="s" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="t" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="u" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="v" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="w" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="x" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="y" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="z" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="{" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="|" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="}" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="~" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xa0;" />
<glyph unicode="&#xa1;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xa2;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xa3;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xa4;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xa5;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xa6;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xa7;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xa8;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xa9;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xaa;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xab;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xac;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xad;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xae;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xaf;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xb0;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xb1;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xb2;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xb3;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xb4;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xb6;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xb7;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xb8;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xb9;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xba;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xbb;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xbc;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xbd;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xbe;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xbf;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc0;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc1;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc2;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc3;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc4;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc5;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc6;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc7;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc8;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xc9;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xca;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xcb;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xcc;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xcd;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xce;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xcf;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd0;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd1;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd2;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd3;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd4;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd5;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd6;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd7;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd8;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xd9;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xda;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xdb;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xdc;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xdd;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xde;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xdf;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe0;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe1;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe2;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe3;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe4;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe5;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe6;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe7;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe8;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xe9;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xea;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xeb;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xec;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xed;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xee;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xef;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf0;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf1;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf2;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf3;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf4;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf5;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf6;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf7;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf8;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xf9;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xfa;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xfb;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xfc;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xfd;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xfe;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#xff;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x2c6;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x2dc;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x2000;" horiz-adv-x="345" />
<glyph unicode="&#x2001;" horiz-adv-x="690" />
<glyph unicode="&#x2002;" horiz-adv-x="345" />
<glyph unicode="&#x2003;" horiz-adv-x="690" />
<glyph unicode="&#x2004;" horiz-adv-x="230" />
<glyph unicode="&#x2005;" horiz-adv-x="172" />
<glyph unicode="&#x2006;" horiz-adv-x="115" />
<glyph unicode="&#x2007;" horiz-adv-x="115" />
<glyph unicode="&#x2008;" horiz-adv-x="86" />
<glyph unicode="&#x2009;" horiz-adv-x="138" />
<glyph unicode="&#x200a;" horiz-adv-x="38" />
<glyph unicode="&#x2010;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x2011;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x2012;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x2013;" horiz-adv-x="987" d="M730 350q0 145 -70.5 241.5t-177.5 96.5t-179.5 -99.5t-72.5 -245.5q0 -145 70 -241t178 -96t180 98.5t72 245.5z" />
<glyph unicode="&#x2014;" horiz-adv-x="1487" d="M1230 350q0 145 -141 241.5t-354 96.5q-215 0 -360 -99.5t-145 -245.5q0 -145 140.5 -241t356 -96t359.5 98.5t144 245.5z" />
<glyph unicode="&#x2018;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x2019;" d="M943 350q0 145 -100.5 241.5t-252.5 96.5q-153 0 -256.5 -99.5t-103.5 -245.5q0 -145 100 -241t254 -96t256.5 98.5t102.5 245.5z" />
<glyph unicode="&#x202f;" horiz-adv-x="138" />
<glyph unicode="&#x205f;" horiz-adv-x="172" />
<glyph unicode="&#x25fc;" horiz-adv-x="690" d="M0 690h690v-690h-690v690z" />
</font>
</defs></svg>

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,3 @@
<?php
//silent

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,133 @@
<?php
/**
* validation css
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
?>
<style>
#validate-area .status-badge {
margin: 1px 2px 0 0;
line-height: 18px;
height: 18px;
}
#validate-area.show-all .header .status-badge,
#validate-area.show-warnings .header .status-badge.warn,
#validate-area.show-warnings .header .status-badge.hwarn,
#validate-area.show-warnings .header .status-badge.fail {
display: none;
}
#validate-area.show-warnings .test-wrapper.good,
#validate-area.show-warnings .test-wrapper.pass {
display: none;
}
#validation-result .category-wrapper {
background-color: #efefef;
border: 1px solid silver;
border-radius:2px;
margin-bottom: 10px;
overflow: hidden;
}
#validation-result .category-wrapper > .header {
background-color: #E0E0E0;
color: #000;
padding: 3px 3px 3px 5px;
font-weight: bold;
border-bottom: 1px solid silver;
}
#validation-result .category-wrapper > .header .status-badge {
margin-top: 2px;
}
#validation-result .category-title {
font-size: 14px;
}
#validation-result .category-content {
background-color: #FFF;
}
#validation-result .test-title {
background-color: #efefef;
padding: 3px 3px 3px 5px;
font-size: 13px;
line-height: 20px;
}
#validation-result .test-title:hover {
background-color: #dfdfdf;
}
#validation-result .test-content {
padding: 10px;
line-height: 18px;
font-size: 12px;
cursor: default;
}
#validation-result .test-content pre {
overflow: auto;
}
#validation-result .test-content *:first-child {
margin-top: 0;
}
#validation-result .test-content *:last-child {
margin-bottom: 0;
}
#validation-result .test-content .sub-title {
border-bottom: 1px solid #d3d3d3;
font-weight: bold;
margin: 7px 0 3px 0;
}
#validation-result .test-content a {
color:#485AA3;
}
#validation-result .test-content ul {
padding-left:25px
}
#validation-result .test-content ul li {
padding:2px
}
#validation-result .test-content ul.vids {
list-style-type: none;
}
#validation-result .validation-iswritable-failes-objects {
padding: 10px 0 10px 10px;
background: #EDEDED;
}
#validation-result .validation-iswritable-failes-objects pre {
min-height: 60px;
max-height: 400px;
max-width: 100%;
overflow: auto;
}
#validation-result .test-content .desc-sol {
padding: 10px;
display: block;
background: #efefef;
margin-top: 10px;
border-radius: 5px;
}
</style>

View File

@@ -0,0 +1,534 @@
<?php
defined("DUPXABSPATH") or die("");
use Duplicator\Installer\Core\Security;
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Installer\Utils\SecureCsrf;
use Duplicator\Libs\Snap\SnapURL;
use VendorDuplicator\Amk\JsonSerialize\JsonSerialize;
$paramsManager = PrmMng::getInstance();
?>
<script>
//Unique namespace
DUPX = new Object();
DUPX.Util = new Object();
DUPX.UI = new Object();
DUPX.Const = new Object();
DUPX.GLB_DEBUG = <?php echo $paramsManager->getValue(PrmMng::PARAM_DEBUG) ? 'true' : 'false'; ?>;
DUPX.dupInstallerUrl = <?php echo JsonSerialize::serialize(SnapURL::getCurrentUrl(false, true)); ?>;
DUPX.dupSourceUrlData = <?php echo JsonSerialize::serialize($_REQUEST); ?>;
DUPX.beforeUnloadListener = (event) => {
event.preventDefault();
return event.returnValue = "Are you sure you want to exit?";
};
DUPX.beforeUnloadCheck = function (enable) {
if (enable) {
window.addEventListener("beforeunload", DUPX.beforeUnloadListener);
} else {
window.removeEventListener("beforeunload", DUPX.beforeUnloadListener);
}
};
DUPX.redirect = function (url, method, params) {
var form = $('<form>', {
method: method,
action: url
});
$.each(params, function (key, value) {
form.append($('<input>', {
'type': 'hidden',
'name': key,
'value': value
}));
});
$("body").append(form);
DUPX.beforeUnloadCheck(false);
form.submit();
};
DUPX.redirectMainInstaller = function(method, params) {
fullParams = $.extend(true, {}, DUPX.dupSourceUrlData, params);
DUPX.redirect(DUPX.dupInstallerUrl, method, fullParams);
};
DUPX.parseJSON = function (mixData) {
// if mixData is already a object, Then don't parse it
if (typeof mixData === 'object' && mixData !== null) {
return mixData;
}
try {
var parsed = JSON.parse(mixData);
return parsed;
} catch (e) {
console.log("JSON parse failed - 1");
console.log(mixData);
}
if (mixData.indexOf('[') > -1 && mixData.indexOf('{') > -1) {
if (mixData.indexOf('{') < mixData.indexOf('[')) {
var startBracket = '{';
var endBracket = '}';
} else {
var startBracket = '[';
var endBracket = ']';
}
} else if (mixData.indexOf('[') > -1 && mixData.indexOf('{') === -1) {
var startBracket = '[';
var endBracket = ']';
} else {
var startBracket = '{';
var endBracket = '}';
}
var jsonStartPos = mixData.indexOf(startBracket);
var jsonLastPos = mixData.lastIndexOf(endBracket);
if (jsonStartPos > -1 && jsonLastPos > -1) {
var expectedJsonStr = mixData.slice(jsonStartPos, jsonLastPos + 1);
try {
var parsed = JSON.parse(expectedJsonStr);
return parsed;
} catch (e) {
console.log("JSON parse failed - 2");
console.log(mixData);
throw e;
return false;
}
}
throw "could not parse the JSON";
return false;
}
DUPX.StandarJsonAjaxWrapper = function (action, token, ajaxData, callbackSuccess, callbackFail, options) {
var ajax_url = document.location.href;
var currentOptions = jQuery.extend({}, DUPX.standarJsonAjaxOptions, options);
var ajaxData = $.extend(true, {}, DUPX.dupSourceUrlData, {
"ctrl_action": 'ajax',
"ajax_action": action,
"ajax_csrf_token": token
}, ajaxData);
function retryOnFailure(result, textStatus, jqXHR) {
var retryOptions = Object.assign({}, options);
retryOptions.numberOfAttempts--;
if (typeof currentOptions.callbackOnRetry === "function") {
currentOptions.callbackOnRetry(result, textStatus, jqXHR, retryOptions);
}
if (currentOptions.delayRetryOnFailure > 0) {
setTimeout(function () {
DUPX.StandarJsonAjaxWrapper(action, token, ajaxData, callbackSuccess, callbackFail, retryOptions);
}, currentOptions.delayRetryOnFailure);
} else {
DUPX.StandarJsonAjaxWrapper(action, token, ajaxData, callbackSuccess, callbackFail, retryOptions);
}
}
jQuery.ajax({
type: "POST",
url: ajax_url,
dataType: "json",
timeout: currentOptions.timeOut,
data: ajaxData,
beforeSend: currentOptions.beforeSend,
success: function (result, textStatus, jqXHR) {
var message = '';
if (result.success) {
if (typeof callbackSuccess === "function") {
callbackSuccess(result, textStatus, jqXHR);
} else {
alert('SUCCESS: ' + result.message);
}
} else {
if (currentOptions.retryOnFailure && currentOptions.numberOfAttempts > 0) {
retryOnFailure(result, textStatus, jqXHR);
} else {
if (typeof callbackFail === "function") {
callbackFail(result, textStatus, jqXHR);
} else {
alert('RESPONSE ERROR! ' + result.message);
}
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
var statusText = Boolean(jqXHR.statusText) ? jqXHR.statusText : "Server error";
const result = {
'success': false,
'message': 'AJAX ERROR! STATUS: ' + jqXHR.status + ' ' + statusText,
'errorContent': {
'pre': '',
'html': '',
'iframe': ''
},
'actionData': null
};
if (currentOptions.retryOnFailure && currentOptions.numberOfAttempts > 0) {
retryOnFailure(result, statusText, jqXHR);
return;
}
switch(jqXHR.status) {
case 200:
result.message = 'AJAX ERROR! STATUS: ' + statusText;
result.errorContent.html = jqXHR.responseText;
break;
default:
break;
}
if (jqXHR.status >= 500 && jqXHR.status < 600) {
result.errorContent.iframe = jqXHR.responseText;
}
if (typeof callbackFail === "function") {
callbackFail(result, statusText, jqXHR);
} else {
alert(result.message);
}
}
});
};
DUPX.standarJsonAjaxOptions = {
timeOut: 1800000,
beforeSend: null,
retryOnFailure: false,
numberOfAttempts: 3,
delayRetryOnFailure: 5000,
callbackOnRetry: null
};
DUPX.showProgressBar = function ()
{
DUPX.animateProgressBar('progress-bar');
$('#ajaxerr-area').hide();
$('#progress-area').show();
};
DUPX.hideProgressBar = function ()
{
$('#progress-area').hide(100);
$('#ajaxerr-area').fadeIn(400);
};
DUPX.getFormDataObject = function (formObj) {
var formArray = $(formObj).serializeArray();
var returnObj = {};
for (var i = 0; i < formArray.length; i++) {
returnObj[formArray[i]['name']] = formArray[i]['value'];
}
return returnObj;
};
DUPX.animateProgressBar = function (id) {
//Create Progress Bar
var $mainbar = $("#" + id);
$mainbar.progressbar({value: 100});
$mainbar.height(25);
runAnimation($mainbar);
function runAnimation($pb) {
$pb.css({"padding-left": "0%", "padding-right": "90%"});
$pb.progressbar("option", "value", 100);
$pb.animate({paddingLeft: "90%", paddingRight: "0%"}, 3500, "linear", function () {
runAnimation($pb);
});
}
};
DUPX.stringifyNumber = function (n) {
const special = [
'zeroth', 'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelvth', 'thirteenth', 'fourteenth',
'fifteenth', 'sixteenth', 'seventeenth', 'eighteenth', 'nineteenth'
];
const deca = ['twent', 'thirt', 'fourt', 'fift', 'sixt', 'sevent', 'eight', 'ninet'];
if (n < 20) {
return special[n];
}
if (n % 10 === 0) {
return deca[Math.floor(n / 10) - 2] + 'ieth';
}
return deca[Math.floor(n / 10) - 2] + 'y-' + special[n % 10];
};
/**
* Returns the windows active url */
DUPX.getNewURL = function (id)
{
var filename = window.location.pathname.split('/').pop() || 'main.installer.php';
var newVal = window.location.href.split("?")[0];
newVal = newVal.replace("/" + filename, '');
var last_slash = newVal.lastIndexOf("/");
newVal = newVal.substring(0, last_slash);
$("#" + id).val(newVal).keyup();
};
DUPX.getNewUrlByDomObj = function (button) {
var inputId = $(button).parent().find('input').attr('id');
DUPX.getNewURL(inputId);
};
DUPX.editActivate = function (button, msg)
{
var buttonObj = $(button);
var inputObj = buttonObj.parent().find('input');
if (confirm(msg)) {
inputObj.removeAttr('readonly').removeClass('readonly');
buttonObj.hide();
}
};
DUPX.autoUpdateToggle = function (button, msg)
{
var buttonObj = $(button);
var wrapperObj = $(button).closest('.param-wrapper');
var inputObj = buttonObj.parent().find('input');
var fromInputObj = $('#' + wrapperObj.data('auto-update-from-input'));
if (wrapperObj.hasClass('autoupdate-enabled')) {
if (confirm(msg)) {
wrapperObj.removeClass('autoupdate-enabled').addClass('autoupdate-disabled');
buttonObj.text('Manual');
inputObj.prop('readonly', false);
}
} else {
wrapperObj.removeClass('autoupdate-disabled').addClass('autoupdate-enabled');
buttonObj.text('Auto');
inputObj.prop('readonly', true);
fromInputObj.trigger("change");
}
/*
if (confirm(msg)) {
inputObj.removeAttr('readonly').removeClass('readonly');
buttonObj.hide();
}*/
};
/*
* DUPX.requestAPI({
* operation : '/cpnl/create_token/',
* data : params,
* callback : function(){});
*/
DUPX.requestAPI = function (obj)
{
var timeout = obj.timeout || 120000; //default to 120 seconds
var apiPath = (obj.operation.substr(-1) !== '/') ? apiPath += '/' : obj.operation;
var urlPath = window.location.pathname;
var pathName = urlPath.substring(0, urlPath.lastIndexOf("/") + 1);
var requestURI = window.location.origin + pathName + 'api/router.php' + apiPath + window.location.search
for (var key in obj.params)
{
if (obj.params.hasOwnProperty(key) && typeof (obj.params[key]) != 'undefined')
{
obj.params[key] = encodeURIComponent(obj.params[key].replace(/&amp;/g, "&"));
}
}
var tokenData = <?php
$paramManager = PrmMng::getInstance();
echo JsonSerialize::serialize([
PrmMng::PARAM_ROUTER_ACTION => $paramManager->getValue(PrmMng::PARAM_ROUTER_ACTION),
Security::ROUTER_TOKEN => SecureCsrf::generate($paramManager->getValue(PrmMng::PARAM_ROUTER_ACTION)),
]);
?>;
var ajaxData = $.extend({}, tokenData, obj.params);
if (DUPX.GLB_DEBUG) {
console.log('==============================================================');
console.log('API REQUEST: ' + obj.operation);
console.log(obj.params);
}
//Requests to API are capped at 2 minutes
$.ajax({
type: "POST",
cache: false,
timeout: timeout,
url: requestURI,
data: ajaxData,
success: function (respData) {
if (DUPX.GLB_DEBUG)
console.log(respData);
try {
var data = DUPX.parseJSON(respData);
} catch (err) {
console.error(err);
console.error('JSON parse failed for response data: ' + respData);
var data = respData;
}
obj.callback(data);
},
error: function (data) {
if (DUPX.GLB_DEBUG)
console.log(data);
obj.callback(data);
}
});
}
DUPX.toggleAll = function (id) {
$(id + " *[data-type='toggle']").each(function () {
$(this).trigger('click');
});
}
DUPX.toggleClick = function ()
{
var button = $(this);
var src = 0;
var id = button.attr('data-target');
var text = button.text().replace(/\+|\-/, "");
var icon = button.find('i.fa');
var target = $(id);
var list = new Array();
var style = [
{open: "fa-minus-square",
close: "fa-plus-square"
},
{open: "fa-caret-down",
close: "fa-caret-right"
}];
//Create src
for (i = 0; i < style.length; i++) {
if ($(icon).hasClass(style[i].open) || $(icon).hasClass(style[i].close)) {
src = i;
break;
}
}
//Build remove list
for (i = 0; i < style.length; i++) {
list.push(style[i].open);
list.push(style[i].close);
}
$(icon).removeClass(list.join(" "));
if (target.is(':hidden')) {
(icon.length)
? $(icon).addClass(style[src].open)
: button.html("- " + text);
button.removeClass('open').addClass('close');
target.show().removeClass('no-display');
} else {
(icon.length)
? $(icon).addClass(style[src].close)
: button.html("+ " + text);
button.removeClass('close').addClass('open');
target.hide().addClass('no-display');
}
}
DUPX.WpItemSwitchInit = function () {
$('.wpinconf-check-wrapper input').change(function () {
var paramWrapper = $(this).closest('.param-wrapper');
if (this.checked) {
paramWrapper.find('.input-container').show().find('.input-item').prop('disabled', false);
} else {
paramWrapper.find('.input-container').hide().find('.input-item').prop('disabled', true);
}
});
}
DUPX.Util.formatBytes = function (bytes, decimals)
{
if (bytes == 0)
return '0 Bytes';
var k = 1000;
var dm = decimals + 1 || 3;
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = Math.floor(Math.log(bytes) / Math.log(k));
return (bytes / Math.pow(k, i)).toPrecision(dm) + ' ' + sizes[i];
}
DUPX.initJsSelect = function (selector) {
$(selector).select2({
'width': '100%',
'dropdownAutoWidth': true,
'minimumResultsForSearch': 10
});
};
$(document).ready(function ()
{
DuplicatorTooltip.load();
DUPX.initJsSelect('select.js-select');
$('body').on( "click", ".copy-to-clipboard-block button", function(e) {
e.preventDefault();
var button = $(this);
var buttonText = button.html();
var textarea = button.parent().find("textarea")[0];
textarea.select();
try {
message = document.execCommand('copy') ? "Copied to Clipboard" : 'Unable to copy';
} catch (err) {
console.log(err);
}
button.html(message);
setTimeout(function () {
button.text(buttonText);
}, 2000);
});
DUPX.WpItemSwitchInit();
});
</script>
<script>
/**
* Fatal error messages shown at top of installer.
* Used to control the [show more] and [show all] links
*/
$(document).ready(function ()
{
function moreCheck(moreCont, moreWrap) {
if (moreWrap.height() > moreCont.height()) {
moreCont.addClass('more');
} else {
moreCont.removeClass('more');
}
}
$('.more-content').each(function () {
var moreCont = $(this);
var step = moreCont.data('more-step');
var moreWrap = $(this).find('.more-wrapper');
moreCont.find('.more-button').click(function () {
moreCont.css('max-height', "+=" + step + "px");
moreCheck(moreCont, moreWrap);
});
moreCont.find('.all-button').click(function () {
moreCont.css('max-height', "none");
moreCheck(moreCont, moreWrap);
});
moreCheck(moreCont, moreWrap);
});
});
</script>
<?php
DUPX_U_Html::js();

View File

@@ -0,0 +1,3 @@
<?php
//silent

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html dir='ltr'>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width">
<title>Maintenance</title>
<style>
#message {
text-align: center;
margin: 40px 0;
}
</style>
</head>
<!-- DUPLICATOR INSTALLER MAINTENANCE -->
<!-- Remove this file in case you are not running an installation but it was not removed from the installer due to some error. -->
<!-- This file is "index.html" located in home path -->
<body id="error-page">
<div id="message">
<h2>
Briefly unavailable for scheduled maintenance. Check back in a minute.
</h2>
</div>
</body>
</html>

View File

@@ -0,0 +1,349 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input { /* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the website, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
*
* @package WordPress
*/
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** Database username */
define( 'DB_USER', 'username_here' );
/** Database password */
define( 'DB_PASSWORD', 'password_here' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**#@+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* @since 2.6.0
*/
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
/**#@-*/
/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*
* At the installation time, database tables are created with the specified prefix.
* Changing this value after WordPress is installed will make your site think
* it has not been installed.
*
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
*/
define( 'WP_DEBUG', false );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

View File

@@ -0,0 +1,9 @@
<Files *.php>
Order Deny,Allow
Deny from all
</Files>
<Files index.php>
Order Allow,Deny
Allow from all
</Files>

View File

@@ -0,0 +1,87 @@
<?php
defined("DUPXABSPATH") or die("");
/**
* Http Class Utility
*/
class DUPX_HTTP
{
/**
* Do an http post request with curl or php code
*
* @param string $url A URL to get. If $params is not null then all query strings will be removed.
* @param string[] $params A valid key/pair combo $data = array('key1' => 'value1', 'key2' => 'value2');
* @param ?string[] $headers Optional header elements
*
* @return string|bool a string or FALSE on failure.
*/
public static function get($url, $params = [], $headers = null)
{
//PHP GET
if (!function_exists('curl_init')) {
return self::php_get_post($url, $params, $headers = null, 'GET');
}
//Remove query string if $params are passed
$full_url = $url;
if (count($params)) {
$url = preg_replace('/\?.*/', '', $url);
$full_url = $url . '?' . http_build_query($params);
}
$headers_on = isset($headers) && array_count_values($headers);
$ch = curl_init();
// Return contents of transfer on curl_exec
// Allow self-signed certs
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_URL, $full_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, $headers_on);
if ($headers_on) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
/**
* Do an http post request with curl or php code
*
* @param string $url A URL to get. If $params is not null then all query strings will be removed.
* @param string[] $params A valid key/pair combo $data = array('key1' => 'value1', 'key2' => 'value2');
* @param ?string[] $headers Optional header elements
* @param string $method The method to use
*
* @return string
*/
private static function php_get_post($url, $params, $headers = null, string $method = 'POST'): string
{
$full_url = $url;
if ($method == 'GET' && count($params)) {
$url = preg_replace('/\?.*/', '', $url);
$full_url = $url . '?' . http_build_query($params);
}
$data = [
'http' => [
'method' => $method,
'content' => http_build_query($params),
],
];
if ($headers !== null) {
$data['http']['header'] = $headers;
}
$ctx = stream_context_create($data);
$fp = @fopen($full_url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $full_url");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $full_url");
}
return $response;
}
}

View File

@@ -0,0 +1,162 @@
<?php
/**
* Class used to update and edit web server configuration files
* for .htaccess, web.config and user.ini
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\Crypt
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Libs\Index\FileIndexManager;
use Duplicator\Installer\Core\Security;
use Duplicator\Installer\Core\Bootstrap;
use Duplicator\Installer\Core\Deploy\ServerConfigs;
use Duplicator\Installer\Utils\InstallerOrigFileMng;
use Duplicator\Installer\Utils\InstDescMng;
/**
* Package related functions
*/
final class DUPX_Package
{
/**
*
* @return bool|string false if fail
*/
public static function getPackageHash()
{
static $packageHash = null;
if (is_null($packageHash)) {
if (($packageHash = Bootstrap::getPackageHash()) === false) {
throw new Exception('PACKAGE ERROR: can\'t find package hash');
}
}
return $packageHash;
}
/**
*
* @return string
*/
public static function getArchiveFileHash()
{
static $fileHash = null;
if (is_null($fileHash)) {
$fileHash = preg_replace('/^.+_([a-z0-9]+)_[0-9]{14}_archive\.(?:daf|zip)$/', '$1', Security::getInstance()->getArchivePath());
}
return $fileHash;
}
/**
*
* @return bool|string false if fail
*/
public static function getPackageArchivePath()
{
static $archivePath = null;
if (is_null($archivePath)) {
$path = DUPX_INIT . '/' . InstDescMng::getInstance()->getName(InstDescMng::TYPE_ARCHIVE_CONFIG);
if (!file_exists($path)) {
throw new Exception('PACKAGE ERROR: can\'t read package path: ' . $path);
} else {
$archivePath = $path;
}
}
return $archivePath;
}
/**
* Returns a save-to-edit wp-config file
*
* @return string
*/
public static function getWpconfigArkPath()
{
return InstallerOrigFileMng::getInstance()->getEntryStoredPath(ServerConfigs::CONFIG_ORIG_FILE_WPCONFIG_ID);
}
/**
*
* @return string
*/
public static function getManualExtractFile(): string
{
return DUPX_INIT . '/' . InstDescMng::getInstance()->getName(InstDescMng::TYPE_MANUAL_EXTRACT);
}
/**
*
* @return string
*/
public static function getWpconfigSamplePath()
{
static $path = null;
if (is_null($path)) {
$path = DUPX_INIT . '/assets/wp-config-sample.php';
}
return $path;
}
/**
* Get path to directory with SQL dump files
*
* @return string
*/
public static function getSqlDumpDirPath()
{
static $path = null;
if (is_null($path)) {
$path = DUPX_INIT . '/' . dirname(InstDescMng::getInstance()->getName(InstDescMng::TYPE_DB_DUMP));
}
return $path;
}
/**
*
* @return string
*/
public static function getIndexPath()
{
static $path = null;
if (is_null($path)) {
$path = DUPX_INIT . '/' . InstDescMng::getInstance()->getName(InstDescMng::TYPE_INDEX);
}
return $path;
}
/**
*
* @return string
*/
public static function getScanJsonPath()
{
static $path = null;
if (is_null($path)) {
$path = DUPX_INIT . '/' . InstDescMng::getInstance()->getName(InstDescMng::TYPE_SCAN);
}
return $path;
}
/**
* Returns the index manager
*
* @return FileIndexManager
*/
public static function getIndexManager()
{
static $indexManager = null;
if (is_null($indexManager)) {
$indexManager = new FileIndexManager(self::getIndexPath());
}
return $indexManager;
}
}

View File

@@ -0,0 +1,109 @@
<?php
defined("DUPXABSPATH") or die("");
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Libs\Shell\Shell;
use Duplicator\Libs\Snap\SnapIO;
use Duplicator\Libs\Snap\SnapWP;
/**
* DUPX_cPanel
* Wrapper Class for cPanel API */
class DUPX_Server
{
/** @var string[] A list of the core WordPress directories */
public static $wpCoreDirsList = [
'wp-admin',
'wp-includes',
];
/**
* Return PHP safe nome, on PHP 5.4 is always false
*
* @return bool
*/
public static function phpSafeModeOn(): bool
{
// safe_mode has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.
return false;
}
/**
* Returns the path this this server where the zip command can be called
*
* @return null|string // null if can't find unzip
*/
public static function get_unzip_filepath(): ?string
{
$filepath = null;
if (Shell::test() !== false) {
$shellOutput = Shell::runCommandBuffered('hash unzip 2>&1');
if ($shellOutput->getCode() >= 0 && $shellOutput->isEmpty()) {
$filepath = 'unzip';
} else {
$possible_paths = [
'/usr/bin/unzip',
'/opt/local/bin/unzip',
];
foreach ($possible_paths as $path) {
if (file_exists($path)) {
$filepath = $path;
break;
}
}
}
}
return $filepath;
}
/**
*
* @return string[]
*/
public static function getWpAddonsSiteLists(): array
{
$addonsSites = [];
$pathsToCheck = DUPX_ArchiveConfig::getInstance()->getPathsMapping();
if (is_scalar($pathsToCheck)) {
$pathsToCheck = [$pathsToCheck];
}
foreach ($pathsToCheck as $mainPath) {
SnapIO::regexGlobCallback($mainPath, function ($path) use (&$addonsSites): void {
if (SnapWP::isWpHomeFolder($path)) {
$addonsSites[] = $path;
}
}, [
'regexFile' => false,
'recursive' => true,
]);
}
return $addonsSites;
}
/**
* Does the site look to be a WordPress site
*
* @return bool Returns true if the site looks like a WP site
*/
public static function isWordPress()
{
$absPathNew = PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_WP_CORE_NEW);
if (!is_dir($absPathNew)) {
return false;
}
if (($root_files = scandir($absPathNew)) === false) {
return false;
}
$file_count = 0;
foreach ($root_files as $file) {
if (in_array($file, self::$wpCoreDirsList)) {
$file_count++;
}
}
return (count(self::$wpCoreDirsList) == $file_count);
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX
*/
use Duplicator\Installer\Core\Security;
use Duplicator\Libs\Snap\FunctionalityCheck;
use Duplicator\Libs\Snap\SnapUtil;
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
/**
* In this class all the utility functions related to the wordpress configuration and the package are defined.
*/
class DUPX_Conf_Utils
{
/**
*
* @staticvar bool $present
* @return bool
*/
public static function isManualExtractFilePresent()
{
static $present = null;
if (is_null($present)) {
$present = file_exists(DUPX_Package::getManualExtractFile());
}
return $present;
}
/**
*
* @staticvar null|bool $enable
* @return bool
*/
public static function isShellZipAvailable()
{
static $enable = null;
if (is_null($enable)) {
$enable = DUPX_Server::get_unzip_filepath() != null;
}
return $enable;
}
/**
*
* @return bool
*/
public static function isPhpZipAvailable()
{
return SnapUtil::classExists(ZipArchive::class);
}
/**
*
* @staticvar bool $exists
* @return bool
*/
public static function archiveExists()
{
static $exists = null;
if (is_null($exists)) {
$exists = file_exists(Security::getInstance()->getArchivePath());
}
return $exists;
}
/**
* Get archive size
*
* @return int
*/
public static function archiveSize()
{
static $arcSize = null;
if (is_null($arcSize)) {
$archivePath = Security::getInstance()->getArchivePath();
$arcSize = file_exists($archivePath) ? (int) @filesize($archivePath) : 0;
}
return $arcSize;
}
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* Class used to update and edit web server configuration files
* for both Apache and IIS files .htaccess and web.config
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\WPConfig
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Deploy\ServerConfigs;
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Installer\Utils\InstallerOrigFileMng;
use Duplicator\Installer\Utils\Log\Log;
use Duplicator\Libs\Snap\SnapIO;
use Duplicator\Libs\WpConfig\WPConfigTransformer;
class DUPX_WPConfig
{
const ADMIN_SERIALIZED_SECURITY_STRING = 'a:1:{s:13:"administrator";b:1;}';
const ADMIN_LEVEL = 10;
/**
* get wp-config default path (not relative to orig file manger)
*
* @return string
*/
public static function getWpConfigDeafultPath(): string
{
return PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_NEW) . '/wp-config.php';
}
/**
*
* @return bool|string false if fail
*/
public static function getWpConfigPath()
{
$origWpConfTarget = InstallerOrigFileMng::getInstance()->getEntryTargetPath(ServerConfigs::CONFIG_ORIG_FILE_WPCONFIG_ID, self::getWpConfigDeafultPath());
$origWpDir = SnapIO::safePath(dirname($origWpConfTarget));
if ($origWpDir === PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_NEW)) {
return $origWpConfTarget;
} else {
return PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_WP_CORE_NEW) . "/wp-config.php";
}
}
/**
*
*
* @return boolean|WPConfigTransformer
*/
public static function getLocalConfigTransformer()
{
static $confTransformer = null;
if (is_null($confTransformer)) {
try {
if (($wpConfigPath = ServerConfigs::getWpConfigLocalStoredPath()) === false) {
$wpConfigPath = DUPX_WPConfig::getWpConfigPath();
}
if (is_readable($wpConfigPath)) {
$confTransformer = new WPConfigTransformer($wpConfigPath);
} else {
$confTransformer = false;
}
} catch (Exception $e) {
$confTransformer = false;
}
}
return $confTransformer;
}
/**
*
* @param string $name constant name
* @param string $type constant | variable
* @param mixed $default default value
*
* @return mixed
*/
public static function getValueFromLocalWpConfig($name, $type = 'constant', $default = '')
{
if (($confTransformer = self::getLocalConfigTransformer()) !== false) {
return $confTransformer->exists($type, $name) ? $confTransformer->getValue($type, $name) : $default;
} else {
return null;
}
}
/**
* Check if the wp-config of the source site is valid.
*
* @return bool true on success, false on failure
*/
public static function isSourceWpConfigValid()
{
static $wpConfigValid = null;
if (is_null($wpConfigValid)) {
try {
if (($wpConfigPath = ServerConfigs::getSourceWpConfigPath()) == false) {
throw new Exception('Source wp-config.php don\'t exists');
}
$configTransformer = new WPConfigTransformer($wpConfigPath);
$requiredConst = [
'DB_NAME',
'DB_USER',
'DB_PASSWORD',
'DB_HOST',
];
foreach ($requiredConst as $constName) {
if (!$configTransformer->exists('constant', $constName)) {
throw new Exception($constName . ' don\'t exist');
}
}
$wpConfigValid = true;
} catch (Exception | Error $e) {
Log::info('CHECK WP CONFIG FAIL msg: ' . $e->getMessage());
$wpConfigValid = false;
}
}
return $wpConfigValid;
}
}

View File

@@ -0,0 +1,88 @@
<?php
/**
* Class used to group all global constants
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\Constants
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Utils\InstDescMng;
use Duplicator\Libs\Shell\Shell;
class DUPX_Constants
{
const CHUNK_EXTRACTION_TIMEOUT_TIME_ZIP = 5;
const CHUNK_EXTRACTION_TIMEOUT_TIME_DUP = 5;
const CHUNK_DBINSTALL_TIMEOUT_TIME = 5;
const CHUNK_MAX_TIMEOUT_TIME = 5;
const DEFAULT_MAX_STRLEN_SERIALIZED_CHECK_IN_M = 4; // 0 no limit
const DUP_SITE_URL = 'https://duplicator.com/';
const FAQ_URL = 'https://duplicator.com/knowledge-base/';
const MIN_NEW_PASSWORD_LEN = 6;
const BACKUP_RENAME_PREFIX = 'dp___bk_';
const DEBUG_MODE = false;
/**
* Init method used to auto initialize the global params
* This function init all params before read from request
*
* @return void
*/
public static function init(): void
{
//DATABASE SETUP: all time in seconds
//max_allowed_packet: max value 1073741824 (1268MB) see my.ini
$GLOBALS['DB_MAX_TIME'] = 5000;
$GLOBALS['DATABASE_PAGE_SIZE'] = 3500;
$GLOBALS['DB_MAX_PACKETS'] = 268435456;
$GLOBALS['DBCHARSET_DEFAULT'] = 'utf8';
$GLOBALS['DBCOLLATE_DEFAULT'] = 'utf8_general_ci';
$GLOBALS['DB_RENAME_PREFIX'] = self::BACKUP_RENAME_PREFIX . date("dHi") . '_';
$GLOBALS['DB_INSTALL_MULTI_THREADED_MAX_RETRIES'] = 3;
if (!defined('MAX_SITES_TO_DEFAULT_ENABLE_CORSS_SEARCH')) {
define('MAX_SITES_TO_DEFAULT_ENABLE_CORSS_SEARCH', 10);
}
//GLOBALS
$GLOBALS["NOTICES_FILE_PATH"] = DUPX_INIT . '/' . InstDescMng::getInstance()->getName(InstDescMng::TYPE_INST_NOTICES);
$GLOBALS["CHUNK_DATA_FILE_PATH"] = DUPX_INIT . '/' . InstDescMng::getInstance()->getName(InstDescMng::TYPE_INST_CHUNK_DATA);
$GLOBALS['PHP_MEMORY_LIMIT'] = ini_get('memory_limit') === false ? 'n/a' : ini_get('memory_limit');
$GLOBALS['PHP_SUHOSIN_ON'] = Shell::isSuhosinEnabled() ? 'enabled' : 'disabled';
$GLOBALS['DISPLAY_MAX_OBJECTS_FAILED_TO_SET_PERM'] = 5;
// Displaying notice for slow zip chunk extraction
$GLOBALS['ZIP_ARC_CHUNK_EXTRACT_DISP_NOTICE_AFTER'] = 5 * 60 * 60; // 5 minutes
$GLOBALS['ZIP_ARC_CHUNK_EXTRACT_DISP_NOTICE_MIN_EXPECTED_EXTRACT_TIME'] = 10 * 60 * 60; // 10 minutes
$GLOBALS['ZIP_ARC_CHUNK_EXTRACT_DISP_NEXT_NOTICE_INTERVAL'] = 5 * 60 * 60; // 5 minutes
$additional_msg = ' for additional details <a href="' . self::FAQ_URL . 'how-to-handle-various-install-scenarios/" target="_blank">click here</a>.';
$GLOBALS['ZIP_ARC_CHUNK_EXTRACT_NOTICES'] = [
'This server looks to be under load or throttled, the extraction process may take some time',
'This host is currently experiencing very slow I/O. You can continue to wait or try a manual extraction.',
'This host I/O is currently having issues. It is recommended to try a manual extraction.',
];
foreach ($GLOBALS['ZIP_ARC_CHUNK_EXTRACT_NOTICES'] as $key => $val) {
$GLOBALS['ZIP_ARC_CHUNK_EXTRACT_NOTICES'][$key] = $val . $additional_msg;
}
$GLOBALS['FW_USECDN'] = false;
$GLOBALS['NOW_TIME'] = @date("His");
}
/**
* Is debug mode enabled
*
* @return bool
*/
public static function isDebugMode(): bool
{
return self::DEBUG_MODE;
}
}

View File

@@ -0,0 +1,3 @@
<?php
//silent

View File

@@ -0,0 +1,928 @@
<?php
/**
* Database functions
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Utils\Log\Log;
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Installer\Core\Params\Descriptors\ParamDescUsers;
use Duplicator\Libs\Snap\SnapDB;
class DUPX_DB_Functions
{
const TABLE_NAME_DUPLICATOR_PACKAGES = 'duplicator_backups';
const TABLE_NAME_DUPLICAT_ENTITIES = 'duplicator_entities';
const TABLE_NAME_DUPLICATOR_ACTIVITY_LOGS = 'duplicator_activity_logs';
const TABLE_NAME_WP_USERS = 'users';
const TABLE_NAME_WP_USERMETA = 'usermeta';
/** @var ?self */
protected static $instance;
/** @var ?mysqli */
private $dbh;
protected float $timeStart;
/** @var ?array<string, string> current data connection */
private $dataConnection;
/** @var ?array<int,array{name:string,isDefault:bool}> list of supported engine types */
private $engineData;
/** @var ?array<string,array{defCollation:false|string,collations:string[]}> supported charset and collation data */
private $charsetData;
/** @var ?array<string,string> default charset in dwtabase connection */
private $defaultCharset;
/** @var int */
private $rename_tbl_log = 0;
/**
* Class constructor
*/
private function __construct()
{
$this->timeStart = DUPX_U::getMicrotime();
}
/**
*
* @return self
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Returns mysqli handle
*
* @param ?array<string,?string> $customConnection custom connection data
*
* @return ?mysqli
*/
public function dbConnection($customConnection = null)
{
if (!is_null($this->dbh)) {
return $this->dbh;
}
$paramsManager = PrmMng::getInstance();
if (is_null($customConnection)) {
if (!DUPX_Validation_manager::isValidated()) {
throw new Exception('Installer isn\'t validated');
}
$dbhost = $paramsManager->getValue(PrmMng::PARAM_DB_HOST);
$dbname = $paramsManager->getValue(PrmMng::PARAM_DB_NAME);
$dbuser = $paramsManager->getValue(PrmMng::PARAM_DB_USER);
$dbpass = $paramsManager->getValue(PrmMng::PARAM_DB_PASS);
} else {
$dbhost = $customConnection['dbhost'];
$dbname = $customConnection['dbname'];
$dbuser = $customConnection['dbuser'];
$dbpass = $customConnection['dbpass'];
}
$dbflag = $paramsManager->getValue(PrmMng::PARAM_DB_FLAG);
if ($dbflag === DUPX_DB::DB_CONNECTION_FLAG_NOT_SET) {
$dbh = self::checkFlagsDbConnection($dbhost, $dbuser, $dbpass, $dbname);
$dbflag = $paramsManager->getValue(PrmMng::PARAM_DB_FLAG);
} else {
$dbh = DUPX_DB::connect($dbhost, $dbuser, $dbpass, $dbname, $dbflag);
}
if ($dbh != false) {
$this->dbh = $dbh;
$this->dataConnection = [
'dbhost' => $dbhost,
'dbname' => $dbname,
'dbuser' => $dbuser,
'dbpass' => $dbpass,
'dbflag' => $dbflag,
];
} else {
$dbConnError = (mysqli_connect_error()) ? 'Error: ' . mysqli_connect_error() : 'Unable to Connect';
$msg = "Unable to connect with the following parameters:<br/>"
. "HOST: " . Log::v2str($dbhost) . "\n"
. "DBUSER: " . Log::v2str($dbuser) . "\n"
. "DATABASE: " . Log::v2str($dbname) . "\n"
. "MESSAGE: " . $dbConnError;
Log::error($msg);
}
if (is_null($customConnection)) {
$db_max_time = mysqli_real_escape_string($this->dbh, $GLOBALS['DB_MAX_TIME']);
DUPX_DB::mysqli_query($this->dbh, "SET wait_timeout = " . mysqli_real_escape_string($this->dbh, $db_max_time));
DUPX_DB::setCharset($this->dbh, $paramsManager->getValue(PrmMng::PARAM_DB_CHARSET), $paramsManager->getValue(PrmMng::PARAM_DB_COLLATE));
}
return $this->dbh;
}
/**
* Check flags dbconnection
*
* @param string $dbhost host
* @param string $dbuser user
* @param string $dbpass password
* @param string $dbname database name
*
* @return bool|mysqli
*/
protected static function checkFlagsDbConnection($dbhost, $dbuser, $dbpass, $dbname = null)
{
$paramsManager = PrmMng::getInstance();
$wpConfigFalgsVal = $paramsManager->getValue(PrmMng::PARAM_WP_CONF_MYSQL_CLIENT_FLAGS);
$isLocalhost = $dbhost == "localhost";
if (($dbh = DUPX_DB::connect($dbhost, $dbuser, $dbpass, $dbname)) != false) {
$dbflag = DUPX_DB::MYSQLI_CLIENT_NO_FLAGS;
$wpConfigFalgsVal['inWpConfig'] = false;
$wpConfigFalgsVal['value'] = [];
} elseif (!$isLocalhost && ($dbh = DUPX_DB::connect($dbhost, $dbuser, $dbpass, $dbname, MYSQLI_CLIENT_SSL)) != false) {
$dbflag = MYSQLI_CLIENT_SSL;
$wpConfigFalgsVal['inWpConfig'] = true;
$wpConfigFalgsVal['value'] = [MYSQLI_CLIENT_SSL];
} elseif (
!$isLocalhost &&
defined("MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT") &&
(
$dbh = DUPX_DB::connect(
$dbhost,
$dbuser,
$dbpass,
$dbname,
MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT // phpcs:ignore PHPCompatibility.Constants.NewConstants.mysqli_client_ssl_dont_verify_server_certFound
)
) != false
) {
// phpcs:ignore PHPCompatibility.Constants.NewConstants.mysqli_client_ssl_dont_verify_server_certFound
$dbflag = MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
$wpConfigFalgsVal['inWpConfig'] = true;
$wpConfigFalgsVal['value'] = [$dbflag];
} else {
$dbflag = DUPX_DB::MYSQLI_CLIENT_NO_FLAGS;
}
$paramsManager->setValue(PrmMng::PARAM_DB_FLAG, $dbflag);
$paramsManager->setValue(PrmMng::PARAM_WP_CONF_MYSQL_CLIENT_FLAGS, $wpConfigFalgsVal);
$paramsManager->save();
return $dbh;
}
/**
* close db connection if is open
*
* @return void
*/
public function closeDbConnection(): void
{
if (!is_null($this->dbh)) {
mysqli_close($this->dbh);
$this->dbh = null;
$this->dataConnection = null;
$this->charsetData = null;
$this->defaultCharset = null;
}
}
/**
* get default charset
*
* @return string
*/
public function getDefaultCharset()
{
if (is_null($this->defaultCharset)) {
$this->dbConnection();
// SHOW VARIABLES LIKE "character_set_database"
if (($result = DUPX_DB::mysqli_query($this->dbh, "SHOW VARIABLES LIKE 'character_set_database'")) === false) {
throw new Exception('SQL ERROR:' . mysqli_error($this->dbh));
}
if ($result->num_rows != 1) {
throw new Exception('DEFAULT CHARSET NUMBER NOT VALID NUM ' . $result->num_rows);
}
while ($row = $result->fetch_array()) {
$this->defaultCharset = $row[1];
}
$result->free();
}
return $this->defaultCharset;
}
/**
*
* @param string $charset charset
*
* @return string|false false if charset don't exists
*/
public function getDefaultCollateOfCharset($charset)
{
$this->getCharsetAndCollationData();
return isset($this->charsetData[$charset]) ? $this->charsetData[$charset]['defCollation'] : false;
}
/**
* Get list of supported MySQL engine
*
* @return array<int,array{name:string,isDefault:bool}>
*/
public function getEngineData()
{
if (is_null($this->engineData)) {
$this->dbConnection();
if (($result = DUPX_DB::mysqli_query($this->dbh, "SHOW ENGINES")) === false) {
throw new Exception('SQL ERROR:' . mysqli_error($this->dbh));
}
$this->engineData = [];
while ($row = $result->fetch_array()) {
if ($row[1] !== "YES" && $row[1] !== "DEFAULT") {
continue;
}
$this->engineData[] = [
"name" => $row[0],
"isDefault" => $row[1] === "DEFAULT",
];
}
}
return $this->engineData;
}
/**
* @return string[] list of supported MySQL engine names
*/
public function getSupportedEngineList(): array
{
return array_map(fn($engine): string => $engine["name"], $this->getEngineData());
}
/**
* Returns default MySQL engine of the database
*
* @return string
*/
public function getDefaultEngine()
{
foreach ($this->engineData as $engine) {
if ($engine["isDefault"]) {
return $engine["name"];
}
}
return $this->engineData[0]["name"];
}
/**
* Get charset and collation data
*
* @return array<string,array{defCollation:bool,collations:string[]}>
*/
public function getCharsetAndCollationData(): array
{
if (is_null($this->charsetData)) {
$this->dbConnection();
if (($result = DUPX_DB::mysqli_query($this->dbh, "SHOW COLLATION")) === false) {
throw new Exception('SQL ERROR:' . mysqli_error($this->dbh));
}
$this->charsetData = [];
while ($row = $result->fetch_array()) {
$collation = $row[0];
$charset = $row[1];
$default = filter_var($row[3], FILTER_VALIDATE_BOOLEAN);
$compiled = filter_var($row[4], FILTER_VALIDATE_BOOLEAN);
if (!$compiled) {
continue;
}
if (!isset($this->charsetData[$charset])) {
$this->charsetData[$charset] = [
'defCollation' => false,
'collations' => [],
];
}
$this->charsetData[$charset]['collations'][] = $collation;
if ($default) {
$this->charsetData[$charset]['defCollation'] = $collation;
}
}
$result->free();
ksort($this->charsetData);
foreach (array_keys($this->charsetData) as $charset) {
sort($this->charsetData[$charset]['collations']);
}
}
return $this->charsetData;
}
/**
*
* @return string[]
*/
public function getCharsetsList()
{
return array_keys($this->getCharsetAndCollationData());
}
/**
*
* @return string[]
*/
public function getCollationsList(): array
{
$result = [];
foreach ($this->getCharsetAndCollationData() as $charsetInfo) {
$result = array_merge($result, $charsetInfo['collations']);
}
return array_unique($result);
}
/**
* Get real charset by param
*
* @return string
*/
public function getRealCharsetByParam()
{
$this->getCharsetAndCollationData();
//$sourceCharset = DUPX_ArchiveConfig::getInstance()->getWpConfigDefineValue('DB_CHARSET', '');
$sourceCharset = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_CHARSET);
return (array_key_exists($sourceCharset, $this->charsetData) ? $sourceCharset : $this->getDefaultCharset());
}
/**
* Get real collate by param
*
* @return string
*/
public function getRealCollateByParam()
{
$this->getCharsetAndCollationData();
$charset = $this->getRealCharsetByParam();
//$sourceCollate = DUPX_ArchiveConfig::getInstance()->getWpConfigDefineValue('DB_COLLATE', '');
$sourceCollate = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_COLLATE);
return (strlen($sourceCollate) == 0 || !in_array($sourceCollate, $this->charsetData[$charset]['collations'])) ?
$this->getDefaultCollateOfCharset($charset) :
$sourceCollate;
}
/**
* Return option name table.
*
* @param ?string $prefix table prefix, if null take wp table prefix by default
*
* @return string
*/
public static function getOptionsTableName($prefix = null): string
{
if (is_null($prefix)) {
$prefix = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLE_PREFIX);
}
return $prefix . 'options';
}
/**
* Return activity logs table name.
*
* @param ?string $prefix table prefix, if null take wp table prefix by default
*
* @return string
*/
public static function getActivityLogsTableName($prefix = null): string
{
if (is_null($prefix)) {
$prefix = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLE_PREFIX);
}
return $prefix . self::TABLE_NAME_DUPLICATOR_ACTIVITY_LOGS;
}
/**
*
* @param null|string $prefix table prefix, if null take wp table prefix by default
*
* @return string
*/
public static function getPostsTableName($prefix = null): string
{
if (is_null($prefix)) {
$prefix = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLE_PREFIX);
}
return $prefix . 'posts';
}
/**
*
* @param null|string $prefix table prefix, if null take wp table prefix by default
*
* @return string
*/
public static function getUserTableName($prefix = null): string
{
if (is_null($prefix)) {
$prefix = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLE_PREFIX);
}
return $prefix . self::TABLE_NAME_WP_USERS;
}
/**
*
* @param null|string $prefix table prefix, if null take wp table prefix by default
*
* @return string
*/
public static function getUserMetaTableName($prefix = null): string
{
if (is_null($prefix)) {
$prefix = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLE_PREFIX);
}
return $prefix . self::TABLE_NAME_WP_USERMETA;
}
/**
*
* @param null|string $prefix table prefix, if null take wp table prefix by default
*
* @return string
*/
public static function getPackagesTableName($prefix = null): string
{
if (is_null($prefix)) {
$prefix = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLE_PREFIX);
}
return $prefix . self::TABLE_NAME_DUPLICATOR_PACKAGES;
}
/**
*
* @param null|string $prefix table prefix, if null take wp table prefix by default
*
* @return string
*/
public static function getEntitiesTableName($prefix = null): string
{
if (is_null($prefix)) {
$prefix = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLE_PREFIX);
}
return $prefix . self::TABLE_NAME_DUPLICAT_ENTITIES;
}
/**
* Get Duplicator tables names
*
* @param string $prefix table prefix
*
* @return string[]
*/
public static function getDuplicatorTablesNames($prefix): array
{
return [
self::getEntitiesTableName($prefix),
self::getPackagesTableName($prefix),
self::getActivityLogsTableName($prefix),
];
}
/**
*
* @param string $userLogin user login
*
* @return boolean return true if user login name exists in users table
*/
public function checkIfUserNameExists($userLogin)
{
if (!$this->tablesExist(self::getUserTableName())) {
return false;
}
$query = 'SELECT ID FROM `' . mysqli_real_escape_string($this->dbh, self::getUserTableName()) . '` '
. 'WHERE user_login="' . mysqli_real_escape_string($this->dbh, $userLogin) . '"';
if (($result = DUPX_DB::mysqli_query($this->dbh, $query)) === false) {
throw new Exception('SQL ERROR:' . mysqli_error($this->dbh));
}
return ($result->num_rows > 0);
}
/**
* User password reset
*
* @param int $userId user id
* @param string $newPassword new password
*
* @return bool
*/
public function userPwdReset($userId, $newPassword): bool
{
$tableName = mysqli_real_escape_string($this->dbh, self::getUserTableName());
$query = 'UPDATE `' . $tableName . '` '
. 'SET `user_pass` = MD5("' . mysqli_real_escape_string($this->dbh, $newPassword) . '") '
. 'WHERE `' . $tableName . '`.`ID` = ' . $userId;
if (($result = DUPX_DB::mysqli_query($this->dbh, $query)) === false) {
throw new Exception('SQL ERROR:' . mysqli_error($this->dbh));
} else {
return true;
}
}
/**
* return true if all tables passed in list exists
*
* @param string|string[] $tables list of table names
*
* @return bool
*/
public function tablesExist($tables)
{
//SHOW TABLES FROM c1_temptest WHERE Tables_in_c1_temptest IN ('i5tr4_users','i5tr4_usermeta')
$this->dbConnection();
if (empty($this->dataConnection['dbname'])) {
return false;
}
if (is_scalar($tables)) {
$tables = [$tables];
}
$dbName = mysqli_real_escape_string($this->dbh, $this->dataConnection['dbname']);
$dbh = $this->dbh;
$escapedTables = array_map(fn($table): string => "'" . mysqli_real_escape_string($dbh, $table) . "'", $tables);
$sql = 'SHOW TABLES FROM `' . $dbName . '` WHERE `Tables_in_' . $dbName . '` IN (' . implode(',', $escapedTables) . ')';
if (($result = DUPX_DB::mysqli_query($this->dbh, $sql)) === false) {
return false;
}
return $result->num_rows === count($tables);
}
/**
* Get table replace names from regex pattern
*
* @param string[] $tableList list of table names
* @param string $pattern regex search string
* @param string $replacement regex replace string
*
* @return array<array{old:string,new:string}> list of table names
*/
protected static function getTablesReplaceList($tableList, $pattern, $replacement): array
{
$result = [];
if (count($tableList) == 0) {
return $result;
}
sort($tableList);
$newNames = $tableList;
foreach ($tableList as $index => $oldName) {
$newName = substr(preg_replace($pattern, $replacement, $oldName), 0, 64); // Truncate too long table names
$nSuffix = 1;
while (in_array($newName, $newNames)) {
$suffix = '_' . base_convert((string) $nSuffix, 10, 36);
$newName = substr($newName, 0, -strlen($suffix)) . $suffix;
$nSuffix++;
}
$newNames[$index] = $newName;
$result[] = [
'old' => $oldName,
'new' => $newName,
];
}
return $result;
}
/**
* Replace table name with regex
*
* @param string $pattern regex pattern
* @param string $replacement regex replacement
* @param array<string,mixed> $options options
*
* @return void
*/
public function pregReplaceTableName($pattern, $replacement, $options = []): void
{
$this->dbConnection();
$options = array_merge([
'exclude' => [], // exclude table list,
'prefixFilter' => false,
'regexFilter' => false, // filter tables with regexp
'notRegexFilter' => false, // filter tables with not regexp
'regexTablesDropFkeys' => false,
'copyTables' => [], // tables that needs to be copied instead of renamed
], $options);
$escapedDbName = mysqli_real_escape_string($this->dbh, PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME));
$tablesIn = 'Tables_in_' . $escapedDbName;
$where = ' WHERE TRUE';
if ($options['prefixFilter'] !== false) {
$where .= ' AND `' . $tablesIn . '` NOT REGEXP "^' . mysqli_real_escape_string($this->dbh, SnapDB::quoteRegex($options['prefixFilter'])) . '.+"';
}
if ($options['regexFilter'] !== false) {
$where .= ' AND `' . $tablesIn . '` REGEXP "' . mysqli_real_escape_string($this->dbh, $options['regexFilter']) . '"';
}
if ($options['notRegexFilter'] !== false) {
$where .= ' AND `' . $tablesIn . '` NOT REGEXP "' . mysqli_real_escape_string($this->dbh, $options['notRegexFilter']) . '"';
}
$tablesList = DUPX_DB::queryColumnToArray($this->dbh, 'SHOW TABLES FROM `' . $escapedDbName . '`' . $where);
if (is_array($options['exclude'])) {
$tablesList = array_diff($tablesList, $options['exclude']);
}
$this->rename_tbl_log = 0;
if (count($tablesList) == 0) {
return;
}
$replaceList = self::getTablesReplaceList($tablesList, $pattern, $replacement);
DUPX_DB::mysqli_query($this->dbh, "SET FOREIGN_KEY_CHECKS = 0;");
foreach ($replaceList as $replace) {
$table = $replace['old'];
$newName = $replace['new'];
if (in_array($table, $options['copyTables'])) {
$this->copyTable($table, $newName, true);
} else {
$this->renameTable($table, $newName, true);
}
$this->rename_tbl_log++;
}
if ($options['regexTablesDropFkeys'] !== false) {
Log::info('DROP FOREING KEYS');
$this->dropForeignKeys($options['regexTablesDropFkeys']);
}
DUPX_DB::mysqli_query($this->dbh, "SET FOREIGN_KEY_CHECKS = 1;");
}
/**
*
* @param false|string $tableNamePatten table name pattern
*
* @return array<array{tableName:string, fKeyName:string}>
*/
public function getForeinKeysData($tableNamePatten = false)
{
$this->dbConnection();
//SELECT CONSTRAINT_NAME FROM information_schema.table_constraints WHERE `CONSTRAINT_TYPE` = 'FOREIGN KEY AND constraint_schema = 'temp_db_test_1234' AND `TABLE_NAME` = 'renamed''
$escapedDbName = mysqli_real_escape_string($this->dbh, PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME));
$escapePattenr = mysqli_real_escape_string($this->dbh, $tableNamePatten);
$where = " WHERE `CONSTRAINT_TYPE` = 'FOREIGN KEY' AND constraint_schema = '" . $escapedDbName . "'";
if ($tableNamePatten !== false) {
$where .= " AND `TABLE_NAME` REGEXP '" . $escapePattenr . "'";
}
if (($result = DUPX_DB::mysqli_query($this->dbh, "SELECT TABLE_NAME as tableName, CONSTRAINT_NAME as fKeyName FROM information_schema.table_constraints " . $where)) === false) {
Log::error('SQL ERROR:' . mysqli_error($this->dbh));
}
return $result->fetch_all(MYSQLI_ASSOC);
}
/**
*
* @param false|string $tableNamePatten table name pattern
*
* @return boolean
*/
public function dropForeignKeys($tableNamePatten = false): bool
{
foreach ($this->getForeinKeysData($tableNamePatten) as $fKeyData) {
$escapedTableName = mysqli_real_escape_string($this->dbh, $fKeyData['tableName']);
$escapedFKeyName = mysqli_real_escape_string($this->dbh, $fKeyData['fKeyName']);
if (DUPX_DB::mysqli_query($this->dbh, 'ALTER TABLE `' . $escapedTableName . '` DROP CONSTRAINT `' . $escapedFKeyName . '`') === false) {
Log::error('SQL ERROR:' . mysqli_error($this->dbh));
}
}
return true;
}
/**
* Copy table
*
* @param string $existing_name existing table name
* @param string $new_name new table name
* @param bool $delete_if_conflict delete table if conflict
*
* @return void
*/
public function copyTable($existing_name, $new_name, $delete_if_conflict = false): void
{
$this->dbConnection();
DUPX_DB::copyTable($this->dbh, $existing_name, $new_name, $delete_if_conflict);
}
/**
* Rename table
*
* @param string $existing_name existing table name
* @param string $new_name new table name
* @param bool $delete_if_conflict delete table if conflict
*
* @return void
*/
public function renameTable($existing_name, $new_name, $delete_if_conflict = false): void
{
$this->dbConnection();
DUPX_DB::renameTable($this->dbh, $existing_name, $new_name, $delete_if_conflict);
}
/**
* Drop table
*
* @param string $name table name
*
* @return void
*/
public function dropTable($name): void
{
$this->dbConnection();
DUPX_DB::dropTable($this->dbh, $name);
}
/**
*
* @param string $prefix table prefix
*
* @return false|array<array{id:int,user_login:string}>
*/
public function getAdminUsers($prefix)
{
$escapedPrefix = mysqli_real_escape_string($this->dbh, $prefix);
$userTable = mysqli_real_escape_string($this->dbh, static::getUserTableName($prefix));
$userMetaTable = mysqli_real_escape_string($this->dbh, static::getUserMetaTableName($prefix));
$sql = 'SELECT `' . $userTable . '`.`id` AS id, `' . $userTable . '`.`user_login` AS user_login FROM `' . $userTable . '` '
. 'INNER JOIN `' . $userMetaTable . '` ON ( `' . $userTable . '`.`id` = `' . $userMetaTable . '`.`user_id` ) '
. 'WHERE `' . $userMetaTable . '`.`meta_key` = "' . $escapedPrefix . 'capabilities" AND `' . $userMetaTable . '`.`meta_value` LIKE "%\"administrator\"%" '
. 'ORDER BY user_login ASC';
if (($queryResult = DUPX_DB::mysqli_query($this->dbh, $sql)) === false) {
return false;
}
$result = [];
while ($row = $queryResult->fetch_assoc()) {
$result[] = [
'id' => (int) $row['id'],
'user_login' => $row['user_login'],
];
}
return $result;
}
/**
* Returns the Duplicator Pro version if it exists, otherwise false
*
* @param string $prefix table prefix
*
* @return false|string Duplicator Pro version
*/
public function getDuplicatorVersion($prefix)
{
$optionsTable = self::getOptionsTableName($prefix);
$sql = "SELECT `option_value` FROM `{$optionsTable}` WHERE `option_name` = 'dupli_opt_version'";
if (($queryResult = DUPX_DB::mysqli_query($this->dbh, $sql)) === false || $queryResult->num_rows === 0) {
return false;
}
$row = $queryResult->fetch_row();
return $row[0];
}
/**
* Return unique identifier identifier of current overwrite site if exists
*
* @param string $prefix table prefix
*
* @return string Unique Identifier
*/
public function getUniqueId($prefix): string
{
$optionsTable = self::getOptionsTableName($prefix);
// Get from UniqueId option
$sql = "SELECT `option_value` FROM `{$optionsTable}` WHERE `option_name` = 'dupli_opt_unique_id'";
if (($queryResult = DUPX_DB::mysqli_query($this->dbh, $sql)) !== false && $queryResult->num_rows > 0) {
$identifier = $queryResult->fetch_row();
if (!empty($identifier[0])) {
return $identifier[0];
}
}
// Fallback to plugin data stats (for migrations from older sites)
$sql = "SELECT `option_value` FROM `{$optionsTable}` WHERE `option_name` = 'dupli_opt_plugin_data_stats'";
if (($queryResult = DUPX_DB::mysqli_query($this->dbh, $sql)) === false || $queryResult->num_rows === 0) {
return '';
}
$dataStat = $queryResult->fetch_row();
$dataStat = json_decode($dataStat[0], true);
return $dataStat['identifier'] ?? '';
}
/**
*
* @param int $userId user id
* @param null|string $prefix table prefix, if null take wp table prefix by default
*
* @return boolean
*/
public function updatePostsAuthor($userId, $prefix = null): bool
{
$this->dbConnection();
//UPDATE `i5tr4_posts` SET `post_author` = 7 WHERE TRUE
$postsTable = mysqli_real_escape_string($this->dbh, static::getPostsTableName($prefix));
$sql = 'UPDATE `' . $postsTable . '` SET `post_author` = ' . ((int) $userId) . ' WHERE TRUE';
Log::info('EXECUTE QUERY ' . $sql);
if (($result = DUPX_DB::mysqli_query($this->dbh, $sql)) === false) {
return false;
}
return true;
}
/**
*
* @return string[] Array of tables to be excluded
*/
public static function getExcludedTables(): array
{
$excludedTables = [];
if (ParamDescUsers::getUsersMode() !== ParamDescUsers::USER_MODE_OVERWRITE) {
$overwriteData = PrmMng::getInstance()->getValue(PrmMng::PARAM_OVERWRITE_SITE_DATA);
$excludedTables[] = self::getUserTableName($overwriteData['table_prefix']);
$excludedTables[] = self::getUserMetaTableName($overwriteData['table_prefix']);
}
return $excludedTables;
}
/**
* Get list of staging table prefixes from database
*
* Staging tables follow the pattern: dstg{id}_{prefix}
* For example: dstg1_wp_, dstg2_wp_
*
* @param string[] $tables Array of table names to filter
*
* @return string[] Array of unique staging prefixes found
*/
public static function getStagingTablePrefixes(array $tables): array
{
$stagingPrefixes = [];
foreach ($tables as $tableName) {
// Match tables starting with dstg followed by digits and underscore
if (preg_match('/^(dstg\d+_)/', $tableName, $matches)) {
$prefix = $matches[1];
if (!in_array($prefix, $stagingPrefixes)) {
$stagingPrefixes[] = $prefix;
}
}
}
return $stagingPrefixes;
}
}

View File

@@ -0,0 +1,746 @@
<?php
/**
* Lightweight abstraction layer for common simple database routines
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Utils\Log\Log;
class DUPX_DB
{
const DELETE_CHUNK_SIZE = 500;
const MYSQLI_CLIENT_NO_FLAGS = 0;
const DB_CONNECTION_FLAG_NOT_SET = -1;
/**
* Modified version of https://developer.wordpress.org/reference/classes/wpdb/db_connect/
*
* @param string $host The server host name
* @param string $username The server DB user name
* @param string $password The server DB password
* @param string $dbname The server DB name
* @param int $flag Extra flags for connection
*
* @return mysqli|null Database connection handle
*/
public static function connect($host, $username, $password, $dbname = null, $flag = self::MYSQLI_CLIENT_NO_FLAGS)
{
try {
$port = null;
$socket = null;
$is_ipv6 = false;
$host_data = self::parseDBHost($host);
if ($host_data) {
[
$host,
$port,
$socket,
$is_ipv6,
] = $host_data;
}
/*
* If using the `mysqlnd` library, the IPv6 address needs to be
* enclosed in square brackets, whereas it doesn't while using the
* `libmysqlclient` library.
* @see https://bugs.php.net/bug.php?id=67563
*/
if ($is_ipv6 && extension_loaded('mysqlnd')) {
$host = "[$host]";
}
$dbh = mysqli_init();
@mysqli_real_connect($dbh, $host, $username, $password, null, $port, $socket, $flag);
if ($dbh->connect_errno) {
$dbh = null;
Log::info('DATABASE CONNECTION ERROR: ' . mysqli_connect_error() . '[ERRNO:' . mysqli_connect_errno() . ']');
} else {
if (method_exists($dbh, 'options')) {
$dbh->options(MYSQLI_OPT_LOCAL_INFILE, 'disable');
}
}
if (!empty($dbname)) {
if (mysqli_select_db($dbh, mysqli_real_escape_string($dbh, $dbname)) == false) {
Log::info('DATABASE SELECT DB ERROR: ' . $dbname . ' BUT IS CONNECTED SO CONTINUE');
}
}
} catch (Exception $e) {
Log::info('DATABASE CONNECTION EXCEPTION ERROR: ' . $e->getMessage());
return null;
}
return $dbh;
}
/**
* Modified version of https://developer.wordpress.org/reference/classes/wpdb/parse_db_host/
* Return Array containing the host, the port, the socket and whether it is an IPv6 address, in that order. If $host couldn't be parsed, returns false
*
* @param string $host The DB_HOST setting to parse
*
* @return false|array{0:string,1:?int,2:?string,3:bool}
*/
public static function parseDBHost($host)
{
$port = null;
$socket = null;
$is_ipv6 = false;
// First peel off the socket parameter from the right, if it exists.
$socket_pos = strpos($host, ':/');
if (false !== $socket_pos) {
$socket = substr($host, $socket_pos + 1);
$host = substr($host, 0, $socket_pos);
}
// We need to check for an IPv6 address first.
// An IPv6 address will always contain at least two colons.
if (substr_count($host, ':') > 1) {
$pattern = '#^(?:\[)?(?P<host>[0-9a-fA-F:]+)(?:\]:(?P<port>[\d]+))?#';
$is_ipv6 = true;
} else {
// We seem to be dealing with an IPv4 address.
$pattern = '#^(?P<host>[^:/]*)(?::(?P<port>[\d]+))?#';
}
$matches = [];
$result = preg_match($pattern, $host, $matches);
if (1 !== $result) {
// Couldn't parse the address, bail.
return false;
}
$host = '';
foreach (['host', 'port'] as $component) {
if (!empty($matches[$component])) {
${$component} = $matches[$component];
}
}
return [
$host,
$port,
$socket,
$is_ipv6,
];
}
/**
*
* @param string $host The server host name
* @param string $username The server DB user name
* @param string $password The server DB password
* @param string $dbname The server DB name
*
* @return boolean
*/
public static function testConnection($host, $username, $password, $dbname = ''): bool
{
if (($dbh = DUPX_DB::connect($host, $username, $password, $dbname))) {
mysqli_close($dbh);
return true;
} else {
return false;
}
}
/**
* Count the tables in a given database
*
* @param mysqli $dbh A valid database link handle
* @param string $dbname Database to count tables in
*
* @return int The number of tables in the database
*/
public static function countTables(\mysqli $dbh, string $dbname): int
{
$res = self::mysqli_query($dbh, "SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '" . mysqli_real_escape_string($dbh, $dbname) . "' ");
$row = mysqli_fetch_row($res);
return is_null($row) ? 0 : $row[0];
}
/**
* Returns the number of rows in a table
*
* @param mysqli $dbh A valid database link handle
* @param string $name A valid table name
*
* @return int The number of rows in the table
*/
public static function countTableRows(\mysqli $dbh, string $name): int
{
$total = self::mysqli_query($dbh, "SELECT COUNT(*) FROM `" . mysqli_real_escape_string($dbh, $name) . "`");
if ($total) {
$total = @mysqli_fetch_array($total);
return $total[0];
} else {
return 0;
}
}
/**
* Get default character set
*
* @param mysqli $dbh A valid database link handle
*
* @return string Default charset
*/
public static function getDefaultCharSet($dbh)
{
static $defaultCharset = null;
if (is_null($defaultCharset)) {
$query = 'SHOW VARIABLES LIKE "character_set_database"';
if (($result = self::mysqli_query($dbh, $query))) {
if (($row = $result->fetch_assoc())) {
$defaultCharset = $row["Value"];
}
$result->free();
} else {
$defaultCharset = '';
}
}
return $defaultCharset;
}
/**
* Get Supported charset list
*
* @param mysqli $dbh A valid database link handle
*
* @return string[] Supported charset list
*/
public static function getSupportedCharSetList($dbh)
{
static $charsetList = null;
if (is_null($charsetList)) {
$charsetList = [];
$query = "SHOW CHARACTER SET;";
if (($result = self::mysqli_query($dbh, $query))) {
while ($row = $result->fetch_assoc()) {
$charsetList[] = $row["Charset"];
}
$result->free();
}
sort($charsetList);
}
return $charsetList;
}
/**
* Get Supported collations along with character set
*
* @param mysqli $dbh A valid database link handle
*
* @return array<array{Collation:string,Charset:string,Id:int,Default:string,Sortlen:int}>
*/
public static function getSupportedCollates($dbh)
{
static $collations = null;
if (is_null($collations)) {
$collations = [];
$query = "SHOW COLLATION";
if (($result = self::mysqli_query($dbh, $query))) {
while ($row = $result->fetch_assoc()) {
$collations[] = $row;
}
$result->free();
}
usort($collations, fn($a, $b): int => strcmp($a['Collation'], $b['Collation']));
}
return $collations;
}
/**
* Get Supported collations along with character set
*
* @param mysqli $dbh A valid database link handle
*
* @return string[] Supported collation
*/
public static function getSupportedCollateList($dbh)
{
static $collates = null;
if (is_null($collates)) {
$collates = [];
$query = "SHOW COLLATION";
if (($result = self::mysqli_query($dbh, $query))) {
while ($row = $result->fetch_assoc()) {
$collates[] = $row['Collation'];
}
$result->free();
}
sort($collates);
}
return $collates;
}
/**
* Returns the database names as an array
*
* @param mysqli $dbh A valid database link handle
* @param string $dbuser An optional dbuser name to search by
*
* @return string[] A list of all database names
*/
public static function getDatabases($dbh, $dbuser = ''): array
{
$result = [];
$sql = strlen($dbuser) ? "SHOW DATABASES LIKE '%" . mysqli_real_escape_string($dbh, $dbuser) . "%'" : 'SHOW DATABASES';
$query = self::mysqli_query($dbh, $sql);
if ($query) {
while ($db = @mysqli_fetch_array($query)) {
$result[] = $db[0];
}
}
return $result;
}
/**
* Check if database exists
*
* @param mysqli $dbh DB connection
* @param string $dbname database name
*
* @return bool
*/
public static function databaseExists(\mysqli $dbh, string $dbname): bool
{
$sql = 'SELECT COUNT(SCHEMA_NAME) AS databaseExists ' .
'FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = "' . mysqli_real_escape_string($dbh, $dbname) . '"';
$res = self::mysqli_query($dbh, $sql);
$row = mysqli_fetch_row($res);
return (!is_null($row) && $row[0] >= 1);
}
/**
* Check if table exists
*
* @param mysqli $dbh A valid database link handle
* @param string $tablename Table name to check for
*
* @return bool Whether or not if given table exists
*/
public static function tableExists(\mysqli $dbh, string $tablename): bool
{
$query = self::mysqli_query($dbh, "SHOW TABLES LIKE '" . mysqli_real_escape_string($dbh, $tablename) . "'");
return $query && mysqli_num_rows($query) == 1;
}
/**
* Select database if exists
*
* @param mysqli $dbh DB connection
* @param string $dbname database name
*
* @return bool false on failure
*/
public static function selectDB($dbh, $dbname)
{
if (!self::databaseExists($dbh, $dbname)) {
return false;
}
return mysqli_select_db($dbh, $dbname);
}
/**
* Returns the tables for a database as an array
*
* @param mysqli $dbh A valid database link handle
*
* @return string[] A list of all table names
*/
public static function getTables(mysqli $dbh): array
{
$query = self::mysqli_query($dbh, 'SHOW TABLES');
if ($query) {
$all_tables = [];
while ($table = @mysqli_fetch_array($query)) {
$all_tables[] = $table[0];
}
return $all_tables;
}
return [];
}
/**
* Get the requested MySQL system variable
*
* @param mysqli $dbh A valid database link handle
* @param string $name The database variable name to lookup
* @param mixed $default default value if query fail
*
* @return mixed the server variable to query for
*/
public static function getVariable($dbh, $name, $default = null)
{
if (($result = self::mysqli_query($dbh, "SHOW VARIABLES LIKE '" . mysqli_real_escape_string($dbh, $name) . "'")) == false) {
return $default;
}
$row = @mysqli_fetch_array($result);
@mysqli_free_result($result);
return $row[1] ?? $default;
}
/**
* Gets the MySQL database version number
*
* @param mysqli $dbh A valid database link handle
* @param bool $full True: Gets the full version
* False: Gets only the numeric
* portion i.e. 5.5.6 or 10.1.2
* (for MariaDB)
*
* @return string '0' on failure, version number on success
*/
public static function getVersion($dbh, $full = false)
{
if ($full) {
$version = self::getVariable($dbh, 'version', '');
} else {
$version = preg_replace('/[^0-9.].*/', '', self::getVariable($dbh, 'version', ''));
}
//Fall-back for servers that have restricted SQL for SHOW statement
//Note: For MariaDB this will report something like 5.5.5 when it is really 10.2.1.
//This mainly is due to mysqli_get_server_info method which gets the version comment
//and uses a regex vs getting just the int version of the value. So while the former
//code above is much more accurate it may fail in rare situations
if (empty($version)) {
$version = mysqli_get_server_info($dbh);
$version = preg_replace('/[^0-9.].*/', '', $version);
}
return empty($version) ? '0' : $version;
}
/**
* Determine if a MySQL database supports a particular feature
*
* @param mysqli $dbh Database connection handle
* @param string $feature the feature to check for
*
* @return bool
*/
public static function hasAbility($dbh, $feature)
{
$version = self::getVersion($dbh);
switch (strtolower($feature)) {
case 'collation':
case 'group_concat':
case 'subqueries':
return version_compare($version, '4.1', '>=');
case 'set_charset':
return version_compare($version, '5.0.7', '>=');
};
return false;
}
/**
* Runs a query and returns the results as an array with the column names
*
* @param mysqli $dbh A valid database link handle
* @param string $sql The sql to run
* @param int $column_index The column index to use as the key
*
* @return scalar[] The result of the query as an array with the column name as the key
*/
public static function queryColumnToArray(\mysqli $dbh, string $sql, $column_index = 0): array
{
$result_array = [];
$full_result_array = self::queryToArray($dbh, $sql);
for ($i = 0; $i < count($full_result_array); $i++) {
$result_array[] = $full_result_array[$i][$column_index];
}
return $result_array;
}
/**
* Runs a query with no result
*
* @param mysqli $dbh A valid database link handle
* @param string $sql The sql to run
*
* @return scalar[][] The result of the query as an array
*/
public static function queryToArray(\mysqli $dbh, string $sql): array
{
$result = [];
$query_result = self::mysqli_query($dbh, $sql);
if ($query_result !== false) {
if (mysqli_num_rows($query_result) > 0) {
while ($row = mysqli_fetch_row($query_result)) {
$result[] = $row;
}
}
} else {
$error = mysqli_error($dbh);
throw new Exception("Error executing query {$sql}.<br/>{$error}");
}
return $result;
}
/**
* Runs a query with no result
*
* @param mysqli $dbh A valid database link handle
* @param string $sql The sql to run
*
* @return void
*/
public static function queryNoReturn($dbh, $sql): void
{
if (self::mysqli_query($dbh, $sql) === false) {
$error = mysqli_error($dbh);
throw new Exception("Error executing query {$sql}.<br/>{$error}");
}
}
/**
* Drops the table given
*
* @param mysqli $dbh A valid database link handle
* @param string $name A valid table name to remove
*
* @return void
*/
public static function dropTable($dbh, $name): void
{
Log::info('DROP TABLE ' . $name, Log::LV_DETAILED);
$escapedName = mysqli_real_escape_string($dbh, $name);
self::queryNoReturn($dbh, 'DROP TABLE IF EXISTS `' . $escapedName . '`');
}
/**
* Empty the table given
*
* @param mysqli $dbh A valid database link handle
* @param string $name A valid table name to remove
*
* @return void
*/
public static function emptyTable($dbh, $name): void
{
Log::info('TRUNCATE TABLE ' . $name, Log::LV_DETAILED);
$escapedName = mysqli_real_escape_string($dbh, $name);
self::queryNoReturn($dbh, 'TRUNCATE TABLE `' . $escapedName . '`');
}
/**
* Renames an existing table
*
* @param mysqli $dbh A valid database link handle
* @param string $existing_name The current tables name
* @param string $new_name The new table name to replace the existing name
* @param bool $delete_if_conflict Delete the table name if there is a conflict
*
* @return void
*/
public static function renameTable($dbh, $existing_name, $new_name, $delete_if_conflict = false): void
{
if ($delete_if_conflict) {
self::dropTable($dbh, $new_name);
}
Log::info('RENAME TABLE ' . $existing_name . ' TO ' . $new_name);
$escapedOldName = mysqli_real_escape_string($dbh, $existing_name);
$escapedNewName = mysqli_real_escape_string($dbh, $new_name);
self::queryNoReturn($dbh, 'RENAME TABLE `' . $escapedOldName . '` TO `' . $escapedNewName . '`');
}
/**
* Renames an existing table
*
* @param mysqli $dbh A valid database link handle
* @param string $existing_name The current tables name
* @param string $new_name The new table name to replace the existing name
* @param bool $delete_if_conflict Delete the table name if there is a conflict
*
* @return void
*/
public static function copyTable($dbh, $existing_name, $new_name, $delete_if_conflict = false): void
{
if ($delete_if_conflict) {
self::dropTable($dbh, $new_name);
}
Log::info('COPY TABLE ' . $existing_name . ' TO ' . $new_name);
$escapedOldName = mysqli_real_escape_string($dbh, $existing_name);
$escapedNewName = mysqli_real_escape_string($dbh, $new_name);
self::queryNoReturn($dbh, 'CREATE TABLE `' . $escapedNewName . '` LIKE `' . $escapedOldName . '`');
self::queryNoReturn($dbh, 'INSERT INTO `' . $escapedNewName . '` SELECT * FROM `' . $escapedOldName . '`');
}
/**
* Sets the MySQL connection's character set.
*
* @param mysqli $dbh The resource given by mysqli_connect
* @param ?string $charset The character set, null default value
* @param ?string $collate The collation, null default value
*
* @return bool
*/
public static function setCharset($dbh, $charset = null, $collate = null)
{
if (!self::hasAbility($dbh, 'collation')) {
return false;
}
$charset = (!isset($charset)) ? $GLOBALS['DBCHARSET_DEFAULT'] : $charset;
$collate = (!isset($collate)) ? '' : $collate;
if (empty($charset)) {
return true;
}
if (function_exists('mysqli_set_charset') && self::hasAbility($dbh, 'set_charset')) {
try {
if (($result1 = mysqli_set_charset($dbh, $charset)) === false) {
$errMsg = mysqli_error($dbh);
Log::info('DATABASE ERROR: mysqli_set_charset ' . Log::v2str($charset) . ' MSG: ' . $errMsg);
} else {
Log::info('DATABASE: mysqli_set_charset ' . Log::v2str($charset), Log::LV_DETAILED);
}
} catch (Exception $e) {
Log::info('DATABASE ERROR: mysqli_set_charset ' . Log::v2str($charset) . ' MSG: ' . $e->getMessage());
$result1 = false;
}
if (!empty($collate)) {
$sql = "SET collation_connection = " . mysqli_real_escape_string($dbh, $collate);
if (($result2 = self::mysqli_query($dbh, $sql)) === false) {
$errMsg = mysqli_error($dbh);
Log::info('DATABASE ERROR: SET collation_connection ' . Log::v2str($collate) . ' MSG: ' . $errMsg);
} else {
Log::info('DATABASE: SET collation_connection ' . Log::v2str($collate), Log::LV_DETAILED);
}
} else {
$result2 = true;
}
return $result1 && $result2;
} else {
$sql = " SET NAMES " . mysqli_real_escape_string($dbh, $charset);
if (!empty($collate)) {
$sql .= " COLLATE " . mysqli_real_escape_string($dbh, $collate);
}
if (($result = self::mysqli_query($dbh, $sql)) === false) {
$errMsg = mysqli_error($dbh);
Log::info('DATABASE SQL ERROR: ' . Log::v2str($sql) . ' MSG: ' . $errMsg);
} else {
Log::info('DATABASE SQL: ' . Log::v2str($sql), Log::LV_DETAILED);
}
return $result;
}
}
/**
*
* @param mysqli $dbh The resource given by mysqli_connect\
*
* @return bool|string return false if current database isent selected or the string name
*/
public static function getCurrentDatabase($dbh)
{
// SELECT DATABASE() as db;
if (($result = self::mysqli_query($dbh, 'SELECT DATABASE() as db')) === false) {
return false;
}
$assoc = $result->fetch_assoc();
return $assoc['db'] ?? false;
}
/**
* mysqli_query wrapper with logging
*
* @param mysqli $link db connection
* @param string $query query string
* @param int $logFailLevel Write in the log only if the log level is equal to or greater than level
* @param int $resultmode The result mode can be one of 3 constants indicating how the result will be returned from the MySQL server.
*
* @return mysqli_result|bool For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries, mysqli_query() will return a mysqli_result object.
* For other successful queries mysqli_query() will return TRUE. Returns FALSE on failure
*/
public static function mysqli_query(
mysqli $link,
$query,
$logFailLevel = Log::LV_DEFAULT,
$resultmode = MYSQLI_STORE_RESULT
) {
try {
$result = mysqli_query($link, $query, $resultmode);
} catch (Exception $e) {
$result = false;
}
self::query_log_callback($link, $result, $query, $logFailLevel);
return $result;
}
/**
* Query log callback
*
* @param mysqli $link db connection
* @param mysqli_result|bool $result mysqli_result object or false on failure
* @param string $query query string
* @param int $logFailLevel ENUM Log::LV_*
*
* @return void
*/
public static function query_log_callback(mysqli $link, $result, $query, $logFailLevel = Log::LV_DEFAULT): void
{
if ($result === false) {
if (Log::isLevel($logFailLevel)) {
$callers = debug_backtrace(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
$file = $callers[0]['file'];
$line = $callers[0]['line'];
$queryLog = substr($query, 0, Log::isLevel(Log::LV_DEBUG) ? 10000 : 500);
Log::info('DB QUERY [ERROR][' . $file . ':' . $line . '] MSG: ' . mysqli_error($link) . "\n\tSQL: " . $queryLog);
Log::info(Log::traceToString($callers, 1));
}
} else {
if (Log::isLevel(Log::LV_HARD_DEBUG)) {
$callers = debug_backtrace(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
$file = $callers[0]['file'];
$line = $callers[0]['line'];
Log::info('DB QUERY [' . $file . ':' . $line . ']: ' . Log::v2str(substr($query, 0, 2000)), Log::LV_HARD_DEBUG);
}
}
}
/**
* Chunks delete
*
* @param mysqli $dbh database connection
* @param string $table table name
* @param string $where where contidions
*
* @return int affected rows
*/
public static function chunksDelete($dbh, $table, $where)
{
$sql = 'DELETE FROM ' . mysqli_real_escape_string($dbh, $table) . ' WHERE ' . $where . ' LIMIT ' . self::DELETE_CHUNK_SIZE;
$totalAffectedRows = 0;
do {
DUPX_DB::queryNoReturn($dbh, $sql);
$affectRows = mysqli_affected_rows($dbh);
$totalAffectedRows += $affectRows;
} while ($affectRows >= self::DELETE_CHUNK_SIZE);
return $totalAffectedRows;
}
}

View File

@@ -0,0 +1,464 @@
<?php
/**
* database table item descriptor
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\InstState;
use Duplicator\Installer\Core\Params\Descriptors\ParamDescMultisite;
use Duplicator\Installer\Core\Params\Descriptors\ParamDescUsers;
use Duplicator\Installer\Core\Params\Models\SiteOwrMap;
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Libs\Snap\SnapWP;
/**
* Database Table Item Class
*
* This class manages individual database table information during WordPress site migrations.
* It handles:
* - Table name management
* - Table operations (create, drop, rename)
* - Multisite support
* - Data integrity checks
*
* Note: The users and usermeta tables are handled separately from core tables.
*
* @see DUPX_DB_Functions::TABLE_NAME_WP_USERS
* @see DUPX_DB_Functions::TABLE_NAME_WP_USERMETA
* @see Duplicator\Installer\Core\Deploy\Database\DbUserMode
*/
class DUPX_DB_Table_item
{
/** @var string */
protected $originalName = '';
/** @var string */
protected $tableWithoutPrefix = '';
protected int $rows;
protected int $size;
protected bool $havePrefix;
/** @var int */
protected $subsiteId = -1;
/** @var string */
protected $subsitePrefix = '';
/**
*
* @param string $name table name
* @param int $rows number of rows
* @param int $size size in bytes
*/
public function __construct($name, $rows = 0, $size = 0)
{
if (strlen($this->originalName = $name) == 0) {
throw new Exception('The table name can\'t be empty.');
}
$this->rows = max(0, (int) $rows);
$this->size = max(0, (int) $size);
$oldPrefix = DUPX_ArchiveConfig::getInstance()->wp_tableprefix;
if (strlen($oldPrefix) === 0) {
$this->havePrefix = true;
$this->tableWithoutPrefix = $this->originalName;
}
if (strpos($this->originalName, $oldPrefix) === 0) {
$this->havePrefix = true;
$this->tableWithoutPrefix = substr($this->originalName, strlen($oldPrefix));
} else {
$this->havePrefix = false;
$this->tableWithoutPrefix = $this->originalName;
}
if (DUPX_ArchiveConfig::getInstance()->isNetwork() && $this->havePrefix) {
$matches = null;
if (preg_match('/^(' . preg_quote($oldPrefix, '/') . '(\d+)_)(.+)/', $this->originalName, $matches)) {
$this->subsitePrefix = $matches[1];
$this->subsiteId = (int) $matches[2];
$this->tableWithoutPrefix = $matches[3]; // update table without prefix without subsite prefix
} elseif (in_array($this->tableWithoutPrefix, SnapWP::getMultisiteTables())) {
$this->subsiteId = -1;
} else {
$this->subsiteId = 1;
$this->subsitePrefix = $oldPrefix;
}
} else {
$this->subsiteId = 1;
$this->subsitePrefix = $oldPrefix;
}
}
/**
* return the original talbe name in source site
*
* @return string
*/
public function getOriginalName()
{
return $this->originalName;
}
/**
* return table name without prefix, if the table has no prefix then the original name returns.
*
* @param bool $includeSubsiteId if true then the subsite id is included in the name
*
* @return string
*/
public function getNameWithoutPrefix($includeSubsiteId = false): string
{
return (($includeSubsiteId && $this->subsiteId > 1) ? $this->subsiteId . '_' : '') . $this->tableWithoutPrefix;
}
/**
*
* @param array{oldPrefix:string,newPrefix:string,commonPart:string} $diffData output
*
* @return boolean
*/
public function isDiffPrefix(&$diffData): bool
{
$oldPos = strlen(($oldName = $this->getOriginalName()));
$newPos = strlen(($newName = $this->getNewName()));
if ($oldName == $newName) {
$diffData = [
'oldPrefix' => '',
'newPrefix' => '',
'commonPart' => $oldName,
];
return false;
}
while ($oldPos > 0 && $newPos > 0) {
if ($oldName[$oldPos - 1] != $newName[$newPos - 1]) {
break;
}
$oldPos--;
$newPos--;
}
$diffData = [
'oldPrefix' => substr($oldName, 0, $oldPos),
'newPrefix' => substr($newName, 0, $newPos),
'commonPart' => substr($oldName, $oldPos),
];
return true;
}
/**
*
* @return bool
*/
public function havePrefix(): bool
{
return $this->havePrefix;
}
/**
* return new name extracted on target site
*
* @return string
*/
public function getNewName()
{
if (!$this->canBeExctracted()) {
return '';
}
if (!$this->havePrefix) {
return $this->originalName;
}
$paramsManager = PrmMng::getInstance();
switch (InstState::getInstType()) {
case InstState::TYPE_SINGLE:
case InstState::TYPE_MSUBDOMAIN:
case InstState::TYPE_MSUBFOLDER:
case InstState::TYPE_RBACKUP_SINGLE:
case InstState::TYPE_RBACKUP_MSUBDOMAIN:
case InstState::TYPE_RBACKUP_MSUBFOLDER:
case InstState::TYPE_RECOVERY_SINGLE:
case InstState::TYPE_RECOVERY_MSUBDOMAIN:
case InstState::TYPE_RECOVERY_MSUBFOLDER:
return $paramsManager->getValue(PrmMng::PARAM_DB_TABLE_PREFIX) . $this->getNameWithoutPrefix(true);
case InstState::TYPE_STANDALONE:
if (
$this->subsiteId === $paramsManager->getValue(PrmMng::PARAM_SUBSITE_ID) &&
$this->subsiteId > 1
) {
// convert standalon subsite prefix
return $paramsManager->getValue(PrmMng::PARAM_DB_TABLE_PREFIX) . $this->getNameWithoutPrefix(false);
} else {
return $paramsManager->getValue(PrmMng::PARAM_DB_TABLE_PREFIX) . $this->getNameWithoutPrefix(true);
}
case InstState::TYPE_SINGLE_ON_SUBDOMAIN:
case InstState::TYPE_SINGLE_ON_SUBFOLDER:
case InstState::TYPE_SUBSITE_ON_SUBDOMAIN:
case InstState::TYPE_SUBSITE_ON_SUBFOLDER:
if ($this->isUserTable()) {
return $paramsManager->getValue(PrmMng::PARAM_DB_TABLE_PREFIX) . $this->getNameWithoutPrefix(false);
}
if ($this->subsiteId <= 0) {
throw new Exception('Curretn talbe site id isn\'t defined');
}
if (($map = ParamDescMultisite::getOwrMapBySourceId($this->subsiteId)) == false) {
throw new Exception('Map by id ' . $this->subsiteId . ' don\'t exists');
}
switch ($map->getTargetId()) {
case SiteOwrMap::NEW_SUBSITE_WITH_SLUG:
case SiteOwrMap::NEW_SUBSITE_WITH_FULL_DOMAIN:
// Site must be created
return '';
default:
break;
}
if (($targetInfo = $map->getTargetSiteInfo()) == false) {
throw new Exception('Target site info ' . $map->getTargetId() . ' don\'t exists');
}
return $targetInfo['blog_prefix'] . $this->getNameWithoutPrefix(false);
case InstState::TYPE_NOT_SET:
throw new Exception('Cannot change setup with current installation type [' . InstState::getInstType() . ']');
default:
throw new Exception('Unknown mode');
}
}
/**
*
* @return int
*/
public function getRows(): int
{
return $this->rows;
}
/**
* Return table size
*
* @param bool $formatted if true then return size in human readable format
*
* @return int|string
*/
public function getSize($formatted = false)
{
return $formatted ? DUPX_U::readableByteSize($this->size) : $this->size;
}
/**
* Get table subsite id
*
* @return int if -1 isn't a subsite sable
*/
public function getSubsisteId()
{
return $this->subsiteId;
}
/**
* Check if table can be extracted
*
* @return bool
*/
public function canBeExctracted()
{
if (InstState::isInstType(InstState::TYPE_STANDALONE)) {
return $this->standAloneExtractCheck();
}
if (InstState::isAddSiteOnMultisite()) {
return $this->addSiteOnMultisiteCheck();
}
if (InstState::isRestoreBackup()) {
return $this->restoreBackupCheck();
}
return true;
}
/**
* If false the current table create query is skipped
*
* @return bool
*/
public function createTable(): bool
{
if ($this->usersTablesCreateCheck() === false) {
return false;
}
return true;
}
/**
* Check if create users table
*
* @return bool
*/
protected function usersTablesCreateCheck()
{
if (!$this->isUserTable()) {
return true;
}
return (ParamDescUsers::getUsersMode() !== ParamDescUsers::USER_MODE_IMPORT_USERS);
}
/**
* Return true if current table is user or usermeta table
*
* @return boolean
*/
public function isUserTable(): bool
{
return (
$this->havePrefix &&
in_array(
$this->tableWithoutPrefix,
[
DUPX_DB_Functions::TABLE_NAME_WP_USERS,
DUPX_DB_Functions::TABLE_NAME_WP_USERMETA,
]
)
);
}
/**
*
* @return boolean
*/
protected function standAloneExtractCheck(): bool
{
if ($this->isUserTable()) {
return true;
}
// extract tables without prefix
if (!$this->havePrefix) {
return true;
}
$standaloneId = PrmMng::getInstance()->getValue(PrmMng::PARAM_SUBSITE_ID);
// exclude multisite tables
if ($this->subsiteId < 0) {
return false;
}
if ($standaloneId == 1) {
// exclude all subsites tables
if ($this->subsiteId > 1) {
return false;
}
} else {
if ($this->subsiteId > 1) {
// exclude all subsite tables except tables with id 1
if ($this->subsiteId != $standaloneId) {
return false;
}
} else {
if (in_array($this->tableWithoutPrefix, SnapWP::getSiteCoreTables())) {
// exclude wordpress common main tables
return false;
}
if (in_array($this->tableWithoutPrefix, DUPX_DB_Tables::getInstance()->getStandaoneTablesWithoutPrefix())) {
// I exclude the tables of the standalone site that will be converted into main tables
return false;
}
}
}
return true;
}
/**
* returns true if the table is to be extracted
*
* @return boolean
*/
protected function addSiteOnMultisiteCheck()
{
if ($this->isUserTable()) {
return true;
}
$originalPrefix = DUPX_ArchiveConfig::getInstance()->wp_tableprefix;
if (in_array($this->originalName, DUPX_DB_Functions::getDuplicatorTablesNames($originalPrefix))) {
return false;
}
return (ParamDescMultisite::getOwrMapBySourceId($this->subsiteId) !== false);
}
/**
* Returns true if the table is to be extracted
*
* @return boolean
*/
protected function restoreBackupCheck()
{
if (!$this->havePrefix || $this->tableWithoutPrefix != DUPX_DB_Functions::TABLE_NAME_DUPLICATOR_PACKAGES) {
return true;
}
$overwriteData = PrmMng::getInstance()->getValue(PrmMng::PARAM_OVERWRITE_SITE_DATA);
// Extract table only if don't exists on restore backup mode
return (!$overwriteData['packagesTableExists']);
}
/**
* returns true if the table is to be extracted
*
* @return boolean
*/
public function extract()
{
if (!$this->canBeExctracted()) {
return false;
}
$tablesVals = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLES);
if (!isset($tablesVals[$this->originalName])) {
throw new Exception('Table ' . $this->originalName . ' not in table vals');
}
return $tablesVals[$this->originalName]['extract'];
}
/**
* returns true if a search and replace is to be performed
*
* @return boolean
*/
public function replaceEngine()
{
if (!$this->extract()) {
return false;
}
$tablesVals = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLES);
if (!isset($tablesVals[$this->originalName])) {
throw new Exception('Table ' . $this->originalName . ' not in table vals');
}
return $tablesVals[$this->originalName]['replace'];
}
}

View File

@@ -0,0 +1,377 @@
<?php
/**
* Original installer files manager
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Utils\Log\Log;
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Installer\Core\Params\Items\ParamFormTables;
/**
* Original installer files manager
* singleton class
*/
final class DUPX_DB_Tables
{
/** @var ?self */
private static $instance;
/** @var DUPX_DB_Table_item[] */
private $tables = [];
/**
*
* @return self
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Class constructor
*/
private function __construct()
{
$confTables = (array) DUPX_ArchiveConfig::getInstance()->dbInfo->tablesList;
foreach ($confTables as $tableName => $tableInfo) {
$rows = ($tableInfo->insertedRows === false ? $tableInfo->inaccurateRows : $tableInfo->insertedRows);
$this->tables[$tableName] = new DUPX_DB_Table_item($tableName, $rows, $tableInfo->size);
}
Log::info('CONSTRUCT TABLES: ' . Log::v2str($this->tables), Log::LV_HARD_DEBUG);
}
/**
*
* @return DUPX_DB_Table_item[]
*/
public function getTables()
{
return $this->tables;
}
/**
*
* @return string[]
*/
public function getTablesNames()
{
return array_keys($this->tables);
}
/**
* get the list of extracted tables names
*
* @return string[]
*/
public function getNewTablesNames(): array
{
$result = [];
foreach ($this->tables as $tableObj) {
if (!$tableObj->extract()) {
continue;
}
$newName = $tableObj->getNewName();
if (strlen($newName) == 0) {
continue;
}
$result[] = $newName;
}
return $result;
}
/**
*
* @return string[]
*/
public function getReplaceTablesNames(): array
{
$result = [];
foreach ($this->tables as $tableObj) {
if (!$tableObj->replaceEngine()) {
continue;
}
$newName = $tableObj->getNewName();
if (strlen($newName) == 0) {
continue;
}
$result[] = $newName;
}
return $result;
}
/**
* Get tables new subsite table names
*
* @param int $subsiteId susbsit ID
*
* @return string[]
*/
public function getSubsiteTablesNewNames($subsiteId): array
{
$result = [];
foreach ($this->tables as $tableObj) {
if (!$tableObj->extract()) {
continue;
}
if ($tableObj->getSubsisteId() != $subsiteId) {
continue;
}
$newName = $tableObj->getNewName();
if (strlen($newName) == 0) {
continue;
}
$result[] = $newName;
}
return $result;
}
/**
* Returns all tables that have a given name without prefix.
* for example all posts tables of a multisite if filter is equal to posts
*
* @param string $filter filter name
*
* @return string[]
*/
public function getTablesByNameWithoutPrefix($filter): array
{
$result = [];
foreach ($this->tables as $tableObj) {
$newName = $tableObj->getNewName();
if (strlen($newName) == 0) {
continue;
}
if (
$tableObj->extract() &&
$tableObj->havePrefix() &&
$tableObj->getNameWithoutPrefix() == $filter
) {
$result[] = $newName;
}
}
return $result;
}
/**
* return list of current standalone site tables without prefix
*
* @return string[]
*/
public function getStandaoneTablesWithoutPrefix()
{
static $standaloneTables = null;
if (is_null($standaloneTables)) {
$standaloneTables = [];
$standaloneId = PrmMng::getInstance()->getValue(PrmMng::PARAM_SUBSITE_ID);
foreach ($this->tables as $tableObj) {
if ($tableObj->getSubsisteId() === $standaloneId) {
$standaloneTables[] = $tableObj->getNameWithoutPrefix();
}
}
}
return $standaloneTables;
}
/**
* Retust tables to skip
*
* @return string[]
*/
public function getTablesToSkip(): array
{
$result = [];
foreach ($this->tables as $tableObj) {
if (!$tableObj->extract()) {
$result[] = $tableObj->getOriginalName();
}
}
return $result;
}
/**
* Restun lsit of tables where skip create but not insert
*
* @return string[]
*/
public function getTablesCreateSkip(): array
{
$result = [];
foreach ($this->tables as $tableObj) {
if ($tableObj->extract() && !$tableObj->createTable()) {
$result[] = $tableObj->getOriginalName();
}
}
return $result;
}
/**
* Get table object by table name
*
* @param string $table table name
*
* @return DUPX_DB_Table_item false if table don't exists
*/
public function getTableObjByName($table)
{
if (!isset($this->tables[$table])) {
throw new Exception('TABLE ' . $table . ' Isn\'t in list');
}
return $this->tables[$table];
}
/**
* Retrun rename tables mapping
*
* @return array<string,array<string,array<int, string>>>
*/
public function getRenameTablesMapping(): array
{
$mapping = [];
$diffData = [];
foreach ($this->tables as $tableObj) {
if (!$tableObj->extract()) {
// skip stable not extracted
continue;
}
if (!$tableObj->isDiffPrefix($diffData)) {
continue;
}
if (!isset($mapping[$diffData['oldPrefix']])) {
$mapping[$diffData['oldPrefix']] = [];
}
if (!isset($mapping[$diffData['oldPrefix']][$diffData['newPrefix']])) {
$mapping[$diffData['oldPrefix']][$diffData['newPrefix']] = [];
}
$mapping[$diffData['oldPrefix']][$diffData['newPrefix']][] = $diffData['commonPart'];
}
uksort($mapping, function ($a, $b): int {
$lenA = strlen($a);
$lenB = strlen($b);
if ($lenA == $lenB) {
return 0;
} elseif ($lenA > $lenB) {
return -1;
} else {
return 1;
}
});
// maximise prefix length
$optimizedMapping = [];
$char = '';
foreach ($mapping as $oldPrefix => $newMapping) {
foreach ($newMapping as $newPrefix => $commons) {
for ($pos = 0; /* break inside */; $pos++) {
for ($current = 0; $current < count($commons); $current++) {
if (strlen($commons[$current]) <= $pos) {
break 2;
}
if ($current == 0) {
$char = $commons[$current][$pos];
continue;
}
if ($commons[$current][$pos] != $char) {
break 2;
}
}
}
$optOldPrefix = $oldPrefix . substr($commons[0], 0, $pos);
$optNewPrefix = $newPrefix . substr($commons[0], 0, $pos);
if (!isset($optimizedMapping[$optOldPrefix])) {
$optimizedMapping[$optOldPrefix] = [];
}
$optimizedMapping[$optOldPrefix][$optNewPrefix] = array_map(fn($val): string => substr($val, $pos), $commons);
}
}
return $optimizedMapping;
}
/**
* return param table default
*
* @return array<array{name: string, extract: bool, replace: bool}>
*/
public function getDefaultParamValue(): array
{
$result = [];
foreach ($this->tables as $table) {
$result[$table->getOriginalName()] = ParamFormTables::getParamItemValueFromData(
$table->getOriginalName(),
$table->canBeExctracted(),
$table->canBeExctracted()
);
}
return $result;
}
/**
* return param table default filtered
*
* @param string[] $filterTables Table names to filter
*
* @return array<string, array{name: string, extract: bool, replace: bool}>
*/
public function getFilteredParamValue($filterTables): array
{
$result = [];
foreach ($this->tables as $table) {
$extract = !in_array($table->getOriginalName(), $filterTables) && $table->canBeExctracted();
$result[$table->getOriginalName()] = ParamFormTables::getParamItemValueFromData(
$table->getOriginalName(),
$extract,
$extract
);
}
return $result;
}
}

View File

@@ -0,0 +1,239 @@
<?php
/**
* custom hosting manager
* singleton class
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Deploy\Plugins\PluginsManager;
use Duplicator\Installer\Core\InstState;
use Duplicator\Installer\Core\Params\Items\ParamForm;
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Libs\Snap\SnapWP;
require_once(DUPX_INIT . '/classes/host/interface.host.php');
require_once(DUPX_INIT . '/classes/host/class.godaddy.host.php');
require_once(DUPX_INIT . '/classes/host/class.wpengine.host.php');
require_once(DUPX_INIT . '/classes/host/class.wordpresscom.host.php');
require_once(DUPX_INIT . '/classes/host/class.liquidweb.host.php');
require_once(DUPX_INIT . '/classes/host/class.pantheon.host.php');
require_once(DUPX_INIT . '/classes/host/class.flywheel.host.php');
require_once(DUPX_INIT . '/classes/host/class.siteground.host.php');
class DUPX_Custom_Host_Manager
{
const HOST_GODADDY = 'godaddy';
const HOST_WPENGINE = 'wpengine';
const HOST_WORDPRESSCOM = 'wordpresscom';
const HOST_LIQUIDWEB = 'liquidweb';
const HOST_PANTHEON = 'pantheon';
const HOST_FLYWHEEL = 'flywheel';
const HOST_SITEGROUND = 'siteground';
/** @var ?self */
protected static $instance;
/**
* this var prevent multiple params inizialization.
* it's useful on development to prevent an infinite loop in class constructor
*
* @var bool
*/
private $initialized = false;
/**
* custom hostings list
*
* @var DUPX_Host_interface[]
*/
private $customHostings = [];
/**
*
* @return self
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* init custom histings
*/
private function __construct()
{
$this->customHostings[DUPX_WPEngine_Host::getIdentifier()] = new DUPX_WPEngine_Host();
$this->customHostings[DUPX_GoDaddy_Host::getIdentifier()] = new DUPX_GoDaddy_Host();
$this->customHostings[DUPX_WordpressCom_Host::getIdentifier()] = new DUPX_WordpressCom_Host();
$this->customHostings[DUPX_Liquidweb_Host::getIdentifier()] = new DUPX_Liquidweb_Host();
$this->customHostings[DUPX_Pantheon_Host::getIdentifier()] = new DUPX_Pantheon_Host();
$this->customHostings[DUPX_Flywheel_Host::getIdentifier()] = new DUPX_Flywheel_Host();
$this->customHostings[DUPX_Siteground_Host::getIdentifier()] = new DUPX_Siteground_Host();
}
/**
* execute the active custom hostings inizialization only one time.
*
* @return boolean
* @throws Exception
*/
public function init(): bool
{
if ($this->initialized) {
return true;
}
foreach ($this->customHostings as $cHost) {
if (!($cHost instanceof DUPX_Host_interface)) {
throw new Exception('Host must implemnete DUPX_Host_interface');
}
if ($cHost->isHosting()) {
$cHost->init();
}
}
$this->initialized = true;
return true;
}
/**
* return the lisst of current custom active hostings
*
* @return string[]
*/
public function getActiveHostings(): array
{
$result = [];
foreach ($this->customHostings as $cHost) {
if ($cHost->isHosting()) {
$result[] = $cHost->getIdentifier();
}
}
return $result;
}
/**
* return true if current identifier hostoing is active
*
* @param string $identifier hosting identifier
*
* @return bool
*/
public function isHosting($identifier): bool
{
return isset($this->customHostings[$identifier]) && $this->customHostings[$identifier]->isHosting();
}
/**
*
* @return boolean|string return false if isn't managed manage hosting of manager hosting
*/
public function isManaged()
{
if ($this->isHosting(self::HOST_WPENGINE)) {
return self::HOST_WPENGINE;
} elseif ($this->isHosting(self::HOST_LIQUIDWEB)) {
return self::HOST_LIQUIDWEB;
} elseif ($this->isHosting(self::HOST_GODADDY)) {
return self::HOST_GODADDY;
} elseif ($this->isHosting(self::HOST_WORDPRESSCOM)) {
return self::HOST_WORDPRESSCOM;
} elseif ($this->isHosting(self::HOST_PANTHEON)) {
return self::HOST_PANTHEON;
} elseif ($this->isHosting(self::HOST_FLYWHEEL)) {
return self::HOST_FLYWHEEL;
} else {
return false;
}
}
/**
* @param string $identifier hosting identifier
*
* @return bool|DUPX_Host_interface
*/
public function getHosting($identifier)
{
if ($this->isHosting($identifier)) {
return $this->customHostings[$identifier];
} else {
return false;
}
}
/**
* @todo temp function fot prevent the warnings on managed hosting.
* This function must be removed in favor of right extraction mode will'be implemented
*
* @param string $extract_filename filename
*
* @return boolean
*/
public function skipWarningExtractionForManaged($extract_filename): bool
{
if (!$this->isManaged()) {
return false;
} elseif (SnapWP::isWpCore($extract_filename, SnapWP::PATH_RELATIVE)) {
return true;
} elseif (DUPX_ArchiveConfig::getInstance()->isChildOfArchivePath($extract_filename, ['abs', 'plugins', 'muplugins', 'themes'])) {
return true;
} elseif (in_array($extract_filename, PluginsManager::getInstance()->getDropInsPaths())) {
return true;
} else {
return false;
}
}
/**
* Set default params for manage hosting
*
* @return void
*/
public function setManagedHostParams(): void
{
if (($managedSlug = $this->isManaged()) === false) {
return;
}
$paramsManager = PrmMng::getInstance();
$paramsManager->setValue(PrmMng::PARAM_WP_CONFIG, 'nothing');
$paramsManager->setFormStatus(PrmMng::PARAM_WP_CONFIG, ParamForm::STATUS_INFO_ONLY);
$paramsManager->setValue(PrmMng::PARAM_HTACCESS_CONFIG, 'nothing');
$paramsManager->setFormStatus(PrmMng::PARAM_HTACCESS_CONFIG, ParamForm::STATUS_INFO_ONLY);
$paramsManager->setValue(PrmMng::PARAM_OTHER_CONFIG, 'nothing');
$paramsManager->setFormStatus(PrmMng::PARAM_OTHER_CONFIG, ParamForm::STATUS_INFO_ONLY);
if (InstState::getInstance()->getMode() === InstState::MODE_OVR_INSTALL) {
$overwriteData = $paramsManager->getValue(PrmMng::PARAM_OVERWRITE_SITE_DATA);
$paramsManager->setValue(PrmMng::PARAM_VALIDATION_ACTION_ON_START, DUPX_Validation_manager::ACTION_ON_START_AUTO);
$paramsManager->setValue(PrmMng::PARAM_DB_DISPLAY_OVERWIRE_WARNING, false);
$paramsManager->setValue(PrmMng::PARAM_CPNL_CAN_SELECTED, false);
$paramsManager->setValue(PrmMng::PARAM_DB_HOST, $overwriteData['dbhost']);
$paramsManager->setValue(PrmMng::PARAM_DB_NAME, $overwriteData['dbname']);
$paramsManager->setValue(PrmMng::PARAM_DB_USER, $overwriteData['dbuser']);
$paramsManager->setValue(PrmMng::PARAM_DB_PASS, $overwriteData['dbpass']);
$paramsManager->setValue(PrmMng::PARAM_DB_TABLE_PREFIX, $overwriteData['table_prefix']);
$paramsManager->setFormStatus(PrmMng::PARAM_DB_ACTION, ParamForm::STATUS_INFO_ONLY);
$paramsManager->setFormStatus(PrmMng::PARAM_DB_HOST, ParamForm::STATUS_INFO_ONLY);
$paramsManager->setFormStatus(PrmMng::PARAM_DB_NAME, ParamForm::STATUS_INFO_ONLY);
$paramsManager->setFormStatus(PrmMng::PARAM_DB_USER, ParamForm::STATUS_INFO_ONLY);
$paramsManager->setFormStatus(PrmMng::PARAM_DB_PASS, ParamForm::STATUS_INFO_ONLY);
$paramsManager->setFormStatus(PrmMng::PARAM_DB_TABLE_PREFIX, ParamForm::STATUS_INFO_ONLY);
}
$paramsManager->setFormStatus(PrmMng::PARAM_URL_NEW, ParamForm::STATUS_INFO_ONLY);
$paramsManager->setFormStatus(PrmMng::PARAM_SITE_URL, ParamForm::STATUS_INFO_ONLY);
$paramsManager->setFormStatus(PrmMng::PARAM_PATH_NEW, ParamForm::STATUS_INFO_ONLY);
$this->getHosting($managedSlug)->setCustomParams();
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* Flywheel custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
/**
* class for wordpress.com managed hosting
*
* @todo not yet implemneted
*/
class DUPX_Flywheel_Host implements DUPX_Host_interface
{
/**
* return the current host itentifier
*
* @return string
*/
public static function getIdentifier(): string
{
return DUPX_Custom_Host_Manager::HOST_FLYWHEEL;
}
/**
* @return bool true if is current host
*/
public function isHosting(): bool
{
// check only mu plugin file exists
$testFile = PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_NEW) . '/.fw-config.php';
return file_exists($testFile);
}
/**
* the init function.
* is called only if isHosting is true
*
* @return void
*/
public function init(): void
{
}
/**
*
* @return string
*/
public function getLabel(): string
{
return 'Flywheel';
}
/**
* this function is called if current hosting is this
*
* @return void
*/
public function setCustomParams(): void
{
$paramsManager = PrmMng::getInstance();
$paramsManager->setValue(PrmMng::PARAM_ARCHIVE_ENGINE_SKIP_WP_FILES, DUPX_Extraction::FILTER_SKIP_WP_CORE);
}
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* godaddy custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
/**
* class for GoDaddy managed hosting
*
* @todo not yet implemneted
*/
class DUPX_GoDaddy_Host implements DUPX_Host_interface
{
/**
* return the current host itentifier
*
* @return string
*/
public static function getIdentifier(): string
{
return DUPX_Custom_Host_Manager::HOST_GODADDY;
}
/**
* @return bool true if is current host
*/
public function isHosting(): bool
{
// check only mu plugin file exists
$file = PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_MUPLUGINS_NEW) . '/gd-system-plugin.php';
return file_exists($file);
}
/**
* the init function.
* is called only if isHosting is true
*
* @return void
*/
public function init(): void
{
}
/**
*
* @return string
*/
public function getLabel(): string
{
return 'GoDaddy';
}
/**
* this function is called if current hosting is this
*
* @return void
*/
public function setCustomParams(): void
{
PrmMng::getInstance()->setValue(PrmMng::PARAM_IGNORE_PLUGINS, [
'gd-system-plugin.php',
'object-cache.php',
]);
}
}

View File

@@ -0,0 +1,73 @@
<?php
/**
* liquidweb custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Liquidweb_Host implements DUPX_Host_interface
{
/**
* return the current host itentifier
*
* @return string
*/
public static function getIdentifier(): string
{
return DUPX_Custom_Host_Manager::HOST_LIQUIDWEB;
}
/**
* @return bool true if is current host
*/
public function isHosting(): bool
{
// check only mu plugin file exists
$testFile = PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_MUPLUGINS_NEW) . '/liquid-web.php';
return file_exists($testFile);
}
/**
* the init function.
* is called only if isHosting is true
*
* @return void
*/
public function init(): void
{
}
/**
* return the label of current hosting
*
* @return string
*/
public function getLabel(): string
{
return 'Liquid Web';
}
/**
* this function is called if current hosting is this
*
* @return void
*/
public function setCustomParams(): void
{
PrmMng::getInstance()->setValue(PrmMng::PARAM_IGNORE_PLUGINS, [
'liquidweb_mwp.php',
'000-liquidweb-config.php',
'liquid-web.php',
'lw_disable_nags.php',
]);
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* godaddy custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
/**
* class for GoDaddy managed hosting
*
* @todo not yet implemneted
*/
class DUPX_Pantheon_Host implements DUPX_Host_interface
{
/**
* return the current host itentifier
*
* @return string
*/
public static function getIdentifier(): string
{
return DUPX_Custom_Host_Manager::HOST_PANTHEON;
}
/**
* @return bool true if is current host
* @throws Exception
*/
public function isHosting(): bool
{
// check only mu plugin file exists
$testFile = PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_MUPLUGINS_NEW) . '/pantheon.php';
return file_exists($testFile);
}
/**
* the init function.
* is called only if isHosting is true
*
* @return void
*/
public function init(): void
{
}
/**
*
* @return string
*/
public function getLabel(): string
{
return 'Pantheon';
}
/**
* this function is called if current hosting is this
*
* @return void
*/
public function setCustomParams(): void
{
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* Siteground custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
use Duplicator\Libs\Snap\SnapUtil;
class DUPX_Siteground_Host implements DUPX_Host_interface
{
/**
* return the current host identifier
*
* @return string
*/
public static function getIdentifier(): string
{
return DUPX_Custom_Host_Manager::HOST_SITEGROUND;
}
/**
* @return bool true if is current host
*/
public function isHosting(): bool
{
ob_start();
SnapUtil::phpinfo(INFO_GENERAL);
$serverinfo = ob_get_clean();
return (strpos($serverinfo, "siteground") !== false);
}
/**
* the init function.
* is called only if isHosting is true
*
* @return void
*/
public function init(): void
{
}
/**
*
* @return string
*/
public function getLabel(): string
{
return 'SiteGround';
}
/**
* this function is called if current hosting is this
*
* @return void
*/
public function setCustomParams(): void
{
}
}

View File

@@ -0,0 +1,81 @@
<?php
/**
* godaddy custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\InstState;
use Duplicator\Installer\Core\Params\Descriptors\ParamDescUsers;
use Duplicator\Installer\Utils\Log\Log;
use Duplicator\Installer\Core\Params\PrmMng;
/**
* class for wordpress.com managed hosting
*
* @todo not yet implemneted
*/
class DUPX_WordpressCom_Host implements DUPX_Host_interface
{
/**
* return the current host itentifier
*
* @return string
*/
public static function getIdentifier(): string
{
return DUPX_Custom_Host_Manager::HOST_WORDPRESSCOM;
}
/**
* @return bool true if is current host
*/
public function isHosting(): bool
{
// check only mu plugin file exists
$testFile = PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_MUPLUGINS_NEW) . '/wpcomsh-loader.php';
return file_exists($testFile);
}
/**
* the init function.
* is called only if isHosting is true
*
* @return void
*/
public function init(): void
{
}
/**
*
* @return string
*/
public function getLabel(): string
{
return 'Wordpress.com';
}
/**
* this function is called if current hosting is this
*
* @return void
*/
public function setCustomParams(): void
{
$paramsManager = PrmMng::getInstance();
$paramsManager->setValue(PrmMng::PARAM_ARCHIVE_ENGINE_SKIP_WP_FILES, DUPX_Extraction::FILTER_SKIP_WP_CORE);
if (!InstState::isRecoveryMode()) {
$paramsManager->setValue(PrmMng::PARAM_USERS_MODE, ParamDescUsers::USER_MODE_IMPORT_USERS);
}
}
}

View File

@@ -0,0 +1,160 @@
<?php
/**
* wpengine custom hosting class
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Libs\Snap\SnapUtil;
/**
* class for wpengine managed hosting
*
* @todo not yet implemneted
*/
class DUPX_WPEngine_Host implements DUPX_Host_interface
{
/**
* return the current host itentifier
*
* @return string
*/
public static function getIdentifier(): string
{
return DUPX_Custom_Host_Manager::HOST_WPENGINE;
}
/**
* @return bool true if is current host
*/
public function isHosting(): bool
{
ob_start();
SnapUtil::phpinfo(INFO_ENVIRONMENT);
$serverinfo = ob_get_clean();
return (strpos($serverinfo, "WPENGINE_ACCOUNT") !== false);
}
/**
* the init function.
* is called only if isHosting is true
*
* @return void
*/
public function init(): void
{
}
/**
*
* @return string
*/
public function getLabel(): string
{
return 'WP Engine';
}
/**
* this function is called if current hosting is this
*
* @return void
*/
public function setCustomParams(): void
{
PrmMng::getInstance()->setValue(PrmMng::PARAM_IGNORE_PLUGINS, [
'mu-plugin.php',
'advanced-cache.php',
'wpengine-security-auditor.php',
'stop-long-comments.php',
'slt-force-strong-passwords.php',
]);
$this->force_disable_plugins();
}
/**
* force disable disallowed plugins
*
* @link https://wpengine.com/support/disallowed-plugins/
*
* @return void
*/
private function force_disable_plugins(): void
{
$fdPlugins = PrmMng::getInstance()->getValue(PrmMng::PARAM_FORCE_DIABLE_PLUGINS);
if (!is_array($fdPlugins)) {
$fdPlugins = [];
}
$fdPlugins = array_merge($fdPlugins, [
'gd-system-plugin.php',
'hcs.php',
'hello.php',
'adminer/adminer.php',
'async-google-analytics/asyncgoogleanalytics.php',
'backup/backup.php',
'backup-scheduler/backup-scheduler.php',
'backupwordpress/backupwordpress.php',
'backwpup/backwpup.php',
'bad-behavior/bad-behavior-wordpress.php',
'broken-link-checker/broken-link-checker.php',
'content-molecules/emc2_content_molecules.php',
'contextual-related-posts/contextual-related-posts.php',
'dynamic-related-posts/drpp.php',
'ewww-image-optimizer/ewww-image-optimizer.php',
'ezpz-one-click-backup/ezpz-ocb.php',
'file-commander/wp-plugin-file-commander.php',
'fuzzy-seo-booster/seoqueries.php',
'google-xml-sitemaps-with-multisite-support/sitemap.php',
'hc-custom-wp-admin-url/hc-custom-wp-admin-url.php',
'jr-referrer/jr-referrer.php',
'jumpple/sweetcaptcha.php',
'missed-schedule/missed-schedule.php',
'no-revisions/norevisions.php',
'ozh-who-sees-ads/wp_ozh_whoseesads.php',
'pipdig-power-pack/p3.php',
'portable-phpmyadmin/wp-phpmyadmin.php',
'quick-cache/quick-cache.php',
'quick-cache-pro/quick-cache-pro.php',
'recommend-a-friend/recommend-to-a-friend.php',
'seo-alrp/seo-alrp.php',
'si-captcha-for-wordpress/si-captcha.php',
'similar-posts/similar-posts.php',
'spamreferrerblock/spam_referrer_block.php',
'super-post/super-post.php',
'superslider/superslider.php',
'sweetcaptcha-revolutionary-free-captcha-service/sweetcaptcha.php',
'the-codetree-backup/codetree-backup.php',
'ToolsPack/ToolsPack.php',
'tweet-blender/tweet-blender.php',
'versionpress/versionpress.php',
'w3-total-cache/w3-total-cache.php',
'wordpress-gzip-compression/ezgz.php',
'wp-cache/wp-cache.php',
'wp-database-optimizer/wp_database_optimizer.php',
'wp-db-backup/wp-db-backup.php',
'wp-dbmanager/wp-dbmanager.php',
'wp-engine-snapshot/plugin.php',
'wp-file-cache/file-cache.php',
'wp-mailinglist/wp-mailinglist.php',
'wp-phpmyadmin/wp-phpmyadmin.php',
'wp-postviews/wp-postviews.php',
'wp-slimstat/wp-slimstat.php',
'wp-super-cache/wp-cache.php',
'wp-symposium-alerts/wp-symposium-alerts.php',
'wponlinebackup/wponlinebackup.php',
'yet-another-featured-posts-plugin/yafpp.php',
'yet-another-related-posts-plugin/yarpp.php',
]);
PrmMng::getInstance()->setValue(PrmMng::PARAM_FORCE_DIABLE_PLUGINS, $fdPlugins);
}
}

View File

@@ -0,0 +1,52 @@
<?php
/**
* interface for specific hostings class
*
* Standard: PSR-2
*
* @package SC\DUPX\DB
* @link http://www.php-fig.org/psr/psr-2/
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
/**
* instaler custom host interface for cusotm hosting classes
*/
interface DUPX_Host_interface
{
/**
* return the current host itentifier
*
* @return string
*/
public static function getIdentifier(): string;
/**
* @return bool true if is current host
*/
public function isHosting(): bool;
/**
* the init function.
* is called only if isHosting is true
*
* @return void
*/
public function init(): void;
/**
* return the label of current hosting
*
* @return string
*/
public function getLabel(): string;
/**
* this function is called if current hosting is this
*
* @return void
*/
public function setCustomParams(): void;
}

View File

@@ -0,0 +1,3 @@
<?php
//silent

View File

@@ -0,0 +1,3 @@
<?php
//silent

View File

@@ -0,0 +1,107 @@
<?php
/**
* Search and reaplace manager
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Libs\Snap\SnapIO;
class DUPX_TemplateItem
{
/** @var string */
protected $name;
protected string $mainFolder;
/** @var null|DUPX_TemplateItem */
protected $parent;
/**
* Class contructor
*
* @param string $name Template name
* @param string $mainFolder Main folder
* @param ?DUPX_TemplateItem $parent Parent template
*/
public function __construct($name, $mainFolder, $parent = null)
{
if (empty($name)) {
throw new Exception('The name of template can\'t be empty');
}
if (!is_dir($mainFolder) || !is_readable($mainFolder)) {
throw new Exception('The main main folder doesn\'t exist');
}
if (!is_null($parent) && !$parent instanceof self) {
throw new Exception('the parent must be a instance of ' . self::class);
}
$this->name = $name;
$this->mainFolder = SnapIO::safePathUntrailingslashit($mainFolder);
$this->parent = $parent;
}
/**
* Render template
*
* @param string $fileTpl Template file is a relative path from root template folder
* @param array<string, mixed> $args Array key / val where key is the var name in template
* @param bool $echo If false return template in string
*
* @return string
*/
public function render($fileTpl, $args = [], $echo = true)
{
ob_start();
if (($renderFile = $this->getFileTemplate($fileTpl)) !== false) {
foreach ($args as $var => $value) {
${$var} = $value;
}
require($renderFile);
} else {
echo '<p>FILE TPL NOT FOUND: ' . $fileTpl . '</p>';
}
if ($echo) {
ob_end_flush();
return '';
} else {
return ob_get_clean();
}
}
/**
* Acctept html of php extensions. if the file have unknown extension automatic add the php extension
*
* @param string $fileTpl File template
*
* @return boolean|string return false if don\'t find the template file
*/
protected function getFileTemplate($fileTpl)
{
$fileExtension = strtolower(pathinfo($fileTpl, PATHINFO_EXTENSION));
switch ($fileExtension) {
case 'php':
case 'html':
$fileName = $fileTpl;
break;
default:
$fileName = $fileTpl . '.php';
}
$fullPath = $this->mainFolder . '/' . $fileName;
if (file_exists($fullPath)) {
return $fullPath;
} elseif (!is_null($this->parent)) {
return $this->parent->getFileTemplate($fileName);
} else {
return false;
}
}
}

View File

@@ -0,0 +1,133 @@
<?php
/**
* Search and reaplace manager
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
require_once(DUPX_INIT . '/classes/utilities/template/class.u.template.item.php');
/**
* DUPX_Template
*/
final class DUPX_Template
{
const TEMPLATE_ADVANCED = 'default';
const TEMPLATE_BASE = 'base';
const TEMPLATE_IMPORT_BASE = 'import-base';
const TEMPLATE_IMPORT_ADVANCED = 'import-advanced';
const TEMPLATE_RECOVERY = 'recovery';
/** @var ?self */
private static $instance;
/** @var DUPX_TemplateItem[] */
private $templates = [];
/** @var string */
private $currentTemplate;
/**
* Get instance
*
* @return DUPX_Template
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Class constructor
*/
private function __construct()
{
// ADD DEFAULT TEMPLATE
$this->addTemplate(DUPX_Template::TEMPLATE_ADVANCED, DUPX_INIT . '/templates/default');
$this->setTemplate(DUPX_Template::TEMPLATE_ADVANCED);
}
/**
* Set template
*
* @param string $name Template name
*
* @return boolean
*/
public function setTemplate($name): bool
{
if (!isset($this->templates[$name])) {
throw new Exception('The template ' . $name . ' doesn\'t exist');
}
$this->currentTemplate = $name;
return true;
}
/**
* Add template
*
* @param string $name Template name
* @param string $mainFolder Main folder
* @param ?string $parentName Parent template name
*
* @return boolean
*/
public function addTemplate($name, $mainFolder, $parentName = null): bool
{
if (isset($this->templates[$name])) {
throw new Exception('The template "' . $name . '" already exists');
}
if (is_null($parentName)) {
$parent = null;
} elseif (isset($this->templates[$parentName])) {
$parent = $this->templates[$parentName];
} else {
throw new Exception('The parent template "' . $parentName . '" doesn\'t exist');
}
$this->templates[$name] = new DUPX_TemplateItem($name, $mainFolder, $parent);
return true;
}
/**
* Render template
*
* @param string $fileTpl Template file is a relative path from root template folder
* @param array<string, mixed> $args Array key / val where key is the var name in template
* @param bool $echo If false return template in string
*
* @return string
*/
public function render($fileTpl, $args = [], $echo = true)
{
return $this->templates[$this->currentTemplate]->render($fileTpl, $args, $echo);
}
}
/**
* Render template
*
* @param string $fileTpl Template file is a relative path from root template folder
* @param array<string, mixed> $args Array key / val where key is the var name in template
* @param bool $echo If false return template in string
*
* @return string
*/
function dupxTplRender($fileTpl, $args = [], $echo = true)
{
static $tplMng = null;
if (is_null($tplMng)) {
$tplMng = DUPX_Template::getInstance();
}
return $tplMng->render($fileTpl, $args, $echo);
}

View File

@@ -0,0 +1,291 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Utils\Log\Log;
/**
* Validation abstract item
*/
abstract class DUPX_Validation_abstract_item
{
const LV_FAIL = 0;
const LV_HARD_WARNING = 1;
const LV_SOFT_WARNING = 2;
const LV_GOOD = 3;
const LV_PASS = 4;
const LV_SKIP = 1000;
/** @var string */
protected $category = '';
/** @var ?int Enum LV_* */
protected $testResult;
/**
* Class Constructor
*
* @param string $category Category
*/
public function __construct($category = '')
{
$this->category = $category;
}
/**
*
* @param bool $reset Reset test result
*
* @return int test result level
*/
public function test($reset = false)
{
if ($reset || is_null($this->testResult)) {
try {
Log::resetTime(Log::LV_DEBUG);
Log::info('START TEST "' . $this->getTitle() . '" [CLASS: ' . static::class . ']');
$this->testResult = $this->runTest();
} catch (Exception | Error $e) {
Log::logException($e, Log::LV_DEFAULT, ' TEST "' . $this->getTitle() . '" EXCEPTION:');
$this->testResult = self::LV_FAIL;
}
Log::logTime('TEST "' . $this->getTitle() . '" RESULT: ' . $this->resultString() . "\n", Log::LV_DEFAULT, false);
}
return $this->testResult;
}
/**
* Run the test
*
* @return int Enum LV_* result
*/
abstract protected function runTest();
/**
* If true the test will be displayed in the validation section else will be skipped
*
* @return bool
*/
public function display()
{
if ($this->testResult === self::LV_SKIP) {
return false;
} else {
return true;
}
}
/**
* Get test category
*
* @return string
*/
public function getCategory()
{
return $this->category;
}
/**
* Get test title
*
* @return string
*/
public function getTitle()
{
return 'Test class ' . static::class;
}
/**
* Get test content
*
* @return string
*/
public function getContent()
{
try {
switch ($this->test(false)) {
case self::LV_SKIP:
return $this->skipContent();
case self::LV_GOOD:
return $this->goodContent();
case self::LV_PASS:
return $this->passContent();
case self::LV_SOFT_WARNING:
return $this->swarnContent();
case self::LV_HARD_WARNING:
return $this->hwarnContent();
case self::LV_FAIL:
default:
return $this->failContent();
}
} catch (Exception $e) {
Log::logException($e, Log::LV_DEFAULT, 'VALIDATION DISPLAY CONTENT ' . static::class . ' RESULT: ' . $this->resultString() . ' EXCEPTION:');
return 'DISPLAY CONTENT PROBLEM <br>'
. 'MESSAGE: ' . $e->getMessage() . '<br>'
. 'TRACE:'
. '<pre>' . $e->getTraceAsString() . '</pre>';
} catch (Error $e) {
Log::logException($e, Log::LV_DEFAULT, 'VALIDATION DISPLAY CONTENT ' . static::class . ' ERROR:');
return 'DISPLAY CONTENT PROBLEM <br>'
. 'MESSAGE: ' . $e->getMessage() . '<br>'
. 'TRACE:'
. '<pre>' . $e->getTraceAsString() . '</pre>';
}
}
/**
* Get badge class for result level
*
* @return string
*/
public function getBadgeClass()
{
return self::resultLevelToBadgeClass($this->test(false));
}
/**
* Get unique selector
*
* @return string
*/
public function getUniqueSelector()
{
return strtolower(str_replace("_", "-", static::class));
}
/**
* Get level label
*
* @return string
*/
public function resultString()
{
return self::resultLevelToString($this->test(false));
}
/**
* Level to string
*
* @param int $level Enum LV_*
*
* @return string
*/
public static function resultLevelToString($level)
{
switch ($level) {
case self::LV_SKIP:
return 'skip';
case self::LV_GOOD:
return 'good';
case self::LV_PASS:
return 'passed';
case self::LV_SOFT_WARNING:
return 'soft warning';
case self::LV_HARD_WARNING:
return 'hard warning';
case self::LV_FAIL:
default:
return 'failed';
}
}
/**
* Get badge class for result level
*
* @param int $level Enum LV_*
*
* @return string
*/
public static function resultLevelToBadgeClass($level)
{
switch ($level) {
case self::LV_SKIP:
return '';
case self::LV_GOOD:
return 'good';
case self::LV_PASS:
return 'pass';
case self::LV_SOFT_WARNING:
return 'warn';
case self::LV_HARD_WARNING:
return 'hwarn';
case self::LV_FAIL:
default:
return 'fail';
}
}
/**
* Return content for test status: fail warning
*
* @return string
*/
protected function failContent()
{
return 'test result: fail';
}
/**
* Return content for test status: hard warning
*
* @return string
*/
protected function hwarnContent()
{
return 'test result: hard warning';
}
/**
* Return content for test status: soft warning
*
* @return string
*/
protected function swarnContent()
{
return 'test result: soft warning';
}
/**
* Return content for test status: good
*
* @return string
*/
protected function goodContent()
{
return 'test result: good';
}
/**
* Return content for test status: pass
*
* @return string
*/
protected function passContent()
{
return 'test result: pass';
}
/**
* Return content for test status: skip
*
* @return string
*/
protected function skipContent()
{
return 'test result: skipped';
}
}

View File

@@ -0,0 +1,344 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Bootstrap;
use Duplicator\Installer\Core\Params\PrmMng;
require_once(DUPX_INIT . '/classes/validation/class.validation.database.service.php');
require_once(DUPX_INIT . '/classes/validation/class.validation.abstract.item.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.owrinstall.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.addon.sites.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.staging.sites.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.manual.extraction.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.dbonly.iswordpress.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.package.age.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.php.version.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.open.basedir.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.memory.limit.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.php.extensions.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.timeout.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.wordfence.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.disk.space.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.importer.version.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.importable.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.rest.api.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.managed.tprefix.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.iswritable.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.iswritable.configs.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.mysql.connect.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.php.functionalities.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.replace.paths.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.managed.supported.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.siteground.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.multisite.subfolder.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.archive.check.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.recovery.link.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.excluded.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.cpnl.connection.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.cpnl.new.user.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.host.name.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.connection.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.version.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.create.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.user.cleanup.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.cleanup.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.affected.tables.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.prefix.too.long.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.visibility.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.manual.tables.count.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.multiple.wp.installs.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.user.perms.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.user.resources.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.triggers.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.show.variables.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.supported.charset.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.supported.engine.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.gtid.mode.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.case.sentivie.tables.php');
require_once(DUPX_INIT . '/classes/validation/database-tests/class.validation.test.db.supported.default.charset.php');
require_once(DUPX_INIT . '/classes/validation/tests/class.validation.test.wp.config.php');
class DUPX_Validation_manager
{
const CAT_GENERAL = 'general';
const CAT_FILESYSTEM = 'filesystem';
const CAT_PHP = 'php';
const CAT_DATABASE = 'database';
const ACTION_ON_START_NORMAL = 'normal';
const ACTION_ON_START_AUTO = 'auto';
const MIN_LEVEL_VALID = DUPX_Validation_abstract_item::LV_HARD_WARNING;
/** @var ?self */
private static $instance;
/** @var DUPX_Validation_abstract_item[] */
private $tests = [];
/** @var array<string, mixed> */
private $extraData = [];
/**
*
* @return self
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Class constructor
*/
private function __construct()
{
// GENERAL
$this->tests[] = new DUPX_Validation_test_archive_check(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_importer_version(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_owrinstall(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_recovery(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_importable(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_rest_api(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_manual_extraction(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_dbonly_iswordpress(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_package_age(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_replace_paths(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_managed_supported(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_siteground(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_multisite_subfolder(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_staging_sites(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_addon_sites(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_wordfence(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_managed_tprefix(self::CAT_GENERAL);
$this->tests[] = new DUPX_Validation_test_wp_config(self::CAT_GENERAL);
// PHP
$this->tests[] = new DUPX_Validation_test_php_version(self::CAT_PHP);
$this->tests[] = new DUPX_Validation_test_open_basedir(self::CAT_PHP);
$this->tests[] = new DUPX_Validation_test_memory_limit(self::CAT_PHP);
$this->tests[] = new DUPX_Validation_test_extensions(self::CAT_PHP);
$this->tests[] = new DUPX_Validation_test_mysql_connect(self::CAT_PHP);
$this->tests[] = new DUPX_Validation_test_php_functionalities(self::CAT_PHP);
$this->tests[] = new DUPX_Validation_test_timeout(self::CAT_PHP);
// FILESYSTEM
$this->tests[] = new DUPX_Validation_test_disk_space(self::CAT_FILESYSTEM);
$this->tests[] = new DUPX_Validation_test_iswritable(self::CAT_FILESYSTEM);
$this->tests[] = new DUPX_Validation_test_iswritable_configs(self::CAT_FILESYSTEM);
// DATABASE
$this->tests[] = new DUPX_Validation_test_db_excluded(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_cpnl_connection(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_cpnl_new_user(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_host_name(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_connection(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_version(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_create(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_supported_engine(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_gtid_mode(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_visibility(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_manual_tables_count(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_multiple_wp_installs(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_user_resources(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_user_perms(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_custom_queries(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_triggers(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_supported_default_charset(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_supported_charset(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_case_sensitive_tables(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_affected_tables(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_prefix_too_long(self::CAT_DATABASE);
// after all database tests
$this->tests[] = new DUPX_Validation_test_db_cleanup(self::CAT_DATABASE);
$this->tests[] = new DUPX_Validation_test_db_user_cleanup(self::CAT_DATABASE);
}
/**
* True if the validation is valid
*
* @return bool
*/
public static function isValidated(): bool
{
$paramsManager = PrmMng::getInstance();
return $paramsManager->getValue(PrmMng::PARAM_VALIDATION_LEVEL) >= self::MIN_LEVEL_VALID;
}
/**
* True if start is validated on load
*
* @return bool
*/
public static function isFirstValidationOnLoad(): bool
{
return (
Bootstrap::isInit() &&
PrmMng::getInstance()->getValue(PrmMng::PARAM_VALIDATION_ACTION_ON_START) === DUPX_Validation_manager::ACTION_ON_START_AUTO
);
}
/**
* True if start validation is set to auto
*
* @return bool
*/
public static function validateOnLoad(): bool
{
$paramsManager = PrmMng::getInstance();
if ($paramsManager->getValue(PrmMng::PARAM_VALIDATION_ACTION_ON_START) === DUPX_Validation_manager::ACTION_ON_START_AUTO) {
return true;
}
if ($paramsManager->getValue(PrmMng::PARAM_STEP_ACTION) === DUPX_CTRL::ACTION_STEP_ON_VALIDATE) {
return true;
}
return false;
}
/**
* Get validation data
*
* @return array<string, mixed>
*/
public function getValidateData(): array
{
$this->runTests();
$mainResult = $this->getMainResult();
$paramsManager = PrmMng::getInstance();
$paramsManager->setValue(PrmMng::PARAM_VALIDATION_LEVEL, $mainResult);
$paramsManager->save();
return [
'mainLevel' => $mainResult,
'mainBagedClass' => DUPX_Validation_abstract_item::resultLevelToBadgeClass($mainResult),
'mainText' => DUPX_Validation_abstract_item::resultLevelToString($mainResult),
'categoriesLevels' => [
'database' => $this->getCagegoryResult(self::CAT_DATABASE),
'php' => $this->getCagegoryResult(self::CAT_PHP),
'general' => $this->getCagegoryResult(self::CAT_GENERAL),
'filesystem' => $this->getCagegoryResult(self::CAT_FILESYSTEM),
],
'htmlResult' => DUPX_CTRL::renderPostProcessings($this->getValidationHtmlResult()),
'extraData' => $this->extraData,
];
}
/**
* Run all tests
*
* @return void
*/
protected function runTests()
{
$this->extraData = [];
foreach ($this->tests as $test) {
$test->test(true);
}
}
/**
* Gte validation main result
*
* @return string
*/
protected function getValidationHtmlResult()
{
return dupxTplRender('parts/validation/validation-result', ['validationManager' => $this], false);
}
/**
* Add extra data
*
* @param string $key data key
* @param mixed $value data value
*
* @return void
*/
public function addExtraData($key, $value): void
{
$this->extraData[$key] = $value;
}
/**
* Get category result
*
* @param string $category category
*
* @return DUPX_Validation_abstract_item[]
*/
public function getTestsCategory($category): array
{
$result = [];
foreach ($this->tests as $test) {
if ($test->getCategory() === $category) {
$result[] = $test;
}
}
return $result;
}
/**
* Get category result
*
* @param string $category category
*
* @return int result level enum LV_*
*/
public function getCagegoryResult($category)
{
$result = PHP_INT_MAX;
foreach ($this->tests as $test) {
if ($test->getCategory() === $category && $test->test() < $result) {
$result = $test->test();
}
}
if ($result === DUPX_Validation_abstract_item::LV_GOOD) {
$result = DUPX_Validation_abstract_item::LV_PASS;
}
return $result;
}
/**
* Get category badge
*
* @param string $category category
*
* @return string
*/
public function getCagegoryBadge($category)
{
return DUPX_Validation_abstract_item::resultLevelToBadgeClass($this->getCagegoryResult($category));
}
/**
* Get main result
*
* @return int result level enum LV_*
*/
public function getMainResult()
{
$result = PHP_INT_MAX;
foreach ($this->tests as $test) {
if ($test->test() < $result) {
$result = $test->test();
}
}
if ($result === DUPX_Validation_abstract_item::LV_GOOD) {
$result = DUPX_Validation_abstract_item::LV_PASS;
}
return $result;
}
}

View File

@@ -0,0 +1,62 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_cpnl_connection extends DUPX_Validation_abstract_item
{
protected function runTest(): int
{
if (
DUPX_Validation_database_service::getInstance()->skipDatabaseTests() ||
PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_VIEW_MODE) !== 'cpnl'
) {
return self::LV_SKIP;
}
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(true);
if (DUPX_Validation_database_service::getInstance()->getCpnlConnection() === false) {
return self::LV_FAIL;
} else {
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(false);
return self::LV_PASS;
}
}
public function getTitle(): string
{
return 'Cpanel connection';
}
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/cpnl-connection', [
'isOk' => false,
'cpnlHost' => PrmMng::getInstance()->getValue(PrmMng::PARAM_CPNL_HOST),
'cpnlUser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_CPNL_USER),
'cpnlPass' => PrmMng::getInstance()->getValue(PrmMng::PARAM_CPNL_PASS),
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/cpnl-connection', [
'isOk' => true,
'cpnlHost' => PrmMng::getInstance()->getValue(PrmMng::PARAM_CPNL_HOST),
'cpnlUser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_CPNL_USER),
'cpnlPass' => '*****',
], false);
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_cpnl_new_user extends DUPX_Validation_abstract_item
{
/** @var ?mixed[] */
private $user;
protected function runTest(): int
{
if (
DUPX_Validation_database_service::getInstance()->skipDatabaseTests() ||
PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_VIEW_MODE) !== 'cpnl' ||
PrmMng::getInstance()->getValue(PrmMng::PARAM_CPNL_DB_USER_CHK) != true
) {
return self::LV_SKIP;
}
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(true);
if ((DUPX_Validation_database_service::getInstance()->cpnlCreateDbUser($this->user)) === false) {
return self::LV_FAIL;
} else {
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(false);
return self::LV_PASS;
}
}
public function getTitle(): string
{
return 'Create Database User';
}
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/cpnl-create-user', [
'isOk' => false,
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'dbpass' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_PASS),
'errorMessage' => $this->user['status'],
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/cpnl-create-user', [
'isOk' => true,
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'dbpass' => '*****',
'errorMessage' => '',
], false);
}
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\InstState;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_db_affected_tables extends DUPX_Validation_abstract_item
{
const MAX_DISPLAY_TABLE_COUNT = 1000;
/** @var int */
private $affectedTableCount = 0;
/** @var string[] */
private $affectedTables = [];
/** @var string */
private $message = "";
/**
* @return int
* @throws Exception
*/
protected function runTest(): int
{
$dbAction = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_ACTION);
if (
DUPX_Validation_database_service::getInstance()->skipDatabaseTests()
|| $dbAction === DUPX_DBInstall::DBACTION_MANUAL
|| $dbAction === DUPX_DBInstall::DBACTION_CREATE
) {
return self::LV_SKIP;
}
if (DUPX_Validation_database_service::getInstance()->dbTablesCount() === 0) {
return self::LV_PASS;
}
$this->affectedTables = DUPX_Validation_database_service::getInstance()->getDBActionAffectedTables($dbAction);
$this->affectedTableCount = count($this->affectedTables);
$partialText = $this->affectedTableCount > self::MAX_DISPLAY_TABLE_COUNT ? self::MAX_DISPLAY_TABLE_COUNT . " of " . $this->affectedTableCount : "All";
if ($dbAction === DUPX_DBInstall::DBACTION_REMOVE_ONLY_TABLES || $dbAction === DUPX_DBInstall::DBACTION_EMPTY) {
$this->message = "{$partialText} tables flagged for <b>removal</b> are list below:";
} else {
$this->message = "{$partialText} tables flagged for <b>back-up and rename</b> are list below:";
}
if (
$this->affectedTableCount > 0 &&
!InstState::isRestoreBackup()
) {
return self::LV_SOFT_WARNING;
}
return self::LV_PASS;
}
/**
* @return string
*/
public function getTitle(): string
{
return 'Tables Flagged for Removal or Backup';
}
/**
* @return string
*/
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-affected-tables', [
'isOk' => true,
'message' => $this->message,
'affectedTableCount' => $this->affectedTableCount,
'affectedTables' => array_slice($this->affectedTables, 0, self::MAX_DISPLAY_TABLE_COUNT),
], false);
}
/**
* @return string
*/
protected function swarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-affected-tables', [
'isOk' => false,
'message' => $this->message,
'affectedTableCount' => $this->affectedTableCount,
'affectedTables' => array_slice($this->affectedTables, 0, self::MAX_DISPLAY_TABLE_COUNT),
], false);
}
}

View File

@@ -0,0 +1,89 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUPX_Validation_test_db_case_sensitive_tables extends DUPX_Validation_abstract_item
{
/** @var string */
protected $errorMessage = '';
/** @var int<-1, max> */
protected $lowerCaseTableNames = -1;
/** @var int<0, max> */
protected $lowerCaseTableNamesSource = 0;
/** @var array<string[]> */
protected $duplicateTables = [];
/** @var string[] */
protected $redundantTables = [];
protected function runTest(): int
{
$archiveConfig = DUPX_ArchiveConfig::getInstance();
$caseSensitiveTablePresent = $archiveConfig->isTablesCaseSensitive();
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests() || !$caseSensitiveTablePresent) {
return self::LV_SKIP;
}
$this->duplicateTables = DUPX_ArchiveConfig::getInstance()->getDuplicateTableNames();
$this->redundantTables = DUPX_ArchiveConfig::getInstance()->getRedundantDuplicateTableNames();
$this->lowerCaseTableNames = DUPX_Validation_database_service::getInstance()->caseSensitiveTablesValue();
$this->lowerCaseTableNamesSource = $archiveConfig->dbInfo->lowerCaseTableNames;
$destIsCaseInsensitive = $this->lowerCaseTableNames !== 0;
$sourceIsCaseSensitive = $this->lowerCaseTableNamesSource === 0;
if ($destIsCaseInsensitive && $sourceIsCaseSensitive && count($this->duplicateTables) > 0) {
return self::LV_HARD_WARNING;
}
if ($destIsCaseInsensitive) {
return self::LV_SOFT_WARNING;
}
return self::LV_PASS;
}
public function getTitle(): string
{
return 'Tables Case Sensitivity';
}
protected function swarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-case-sensitive-tables', [
'isOk' => false,
'errorMessage' => $this->errorMessage,
'lowerCaseTableNames' => $this->lowerCaseTableNames,
], false);
}
protected function hwarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-case-sensitive-duplicates', [
'lowerCaseTableNames' => $this->lowerCaseTableNames,
'duplicateTableNames' => $this->duplicateTables,
'reduntantTableNames' => $this->redundantTables,
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-case-sensitive-tables', [
'isOk' => true,
'errorMessage' => $this->errorMessage,
'lowerCaseTableNames' => $this->lowerCaseTableNames,
], false);
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_db_cleanup extends DUPX_Validation_abstract_item
{
/** @var string */
protected $errorMessage = '';
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->isDatabaseCreated() === false) {
return self::LV_SKIP;
}
if (DUPX_Validation_database_service::getInstance()->cleanUpDatabase($this->errorMessage)) {
return self::LV_PASS;
} else {
return self::LV_HARD_WARNING;
}
}
public function getTitle(): string
{
return 'Database cleanup';
}
protected function hwarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-cleanup', [
'isOk' => false,
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'isCpanel' => (PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_VIEW_MODE) === 'cpnl'),
'errorMessage' => $this->errorMessage,
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-cleanup', [
'isOk' => true,
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'isCpanel' => (PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_VIEW_MODE) === 'cpnl'),
'errorMessage' => $this->errorMessage,
], false);
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_db_connection extends DUPX_Validation_abstract_item
{
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(true);
if (DUPX_Validation_database_service::getInstance()->getDbConnection() === false) {
return self::LV_FAIL;
} else {
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(false);
return self::LV_PASS;
}
}
public function getTitle(): string
{
return 'Host Connection';
}
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/db-connection', [
'isOk' => false,
'dbhost' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_HOST),
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'dbpass' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_PASS),
'mysqlConnErr' => mysqli_connect_error(),
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-connection', [
'isOk' => true,
'dbhost' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_HOST),
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'dbpass' => '*****',
'mysqlConnErr' => '',
], false);
}
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_db_create extends DUPX_Validation_abstract_item
{
/**
*
* @var bool
*/
protected $alreadyExists = false;
/**
*
* @var string
*/
protected $errorMessage = '';
protected function runTest(): int
{
if (
DUPX_Validation_database_service::getInstance()->skipDatabaseTests() ||
PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_ACTION) !== DUPX_DBInstall::DBACTION_CREATE
) {
return self::LV_SKIP;
}
// already exists test
if (DUPX_Validation_database_service::getInstance()->databaseExists()) {
$this->errorMessage = 'Database already exists';
$this->alreadyExists = true;
return self::LV_FAIL;
}
if (DUPX_Validation_database_service::getInstance()->createDatabase($this->errorMessage) === false) {
return self::LV_FAIL;
}
return self::LV_PASS;
}
public function getTitle(): string
{
return 'Create New Database';
}
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/db-create', [
'isOk' => false,
'alreadyExists' => $this->alreadyExists,
'errorMessage' => $this->errorMessage,
'isCpanel' => (PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_VIEW_MODE) === 'cpnl'),
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-create', [
'isOk' => true,
'alreadyExists' => $this->alreadyExists,
'errorMessage' => $this->errorMessage,
'isCpanel' => (PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_VIEW_MODE) === 'cpnl'),
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
], false);
}
}

View File

@@ -0,0 +1,62 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\InstState;
class DUPX_Validation_test_db_excluded extends DUPX_Validation_abstract_item
{
/**
* @return int
*/
protected function runTest(): int
{
if (!InstState::dbDoNothing()) {
return self::LV_PASS;
}
DUPX_Validation_database_service::getInstance()->setSkipOtherTests();
return self::LV_SOFT_WARNING;
}
/**
* @return string
*/
public function getTitle(): string
{
return 'Extract only files';
}
/**
* @return string
*/
protected function swarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-excluded', [
'dbExcluded' => DUPX_ArchiveConfig::getInstance()->isDBExcluded(),
'isOk' => false,
], false);
}
/**
* @return string
*/
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-excluded', [
'dbExcluded' => false,
'isOk' => true,
], false);
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUPX_Validation_test_db_gtid_mode extends DUPX_Validation_abstract_item
{
/** @var string[] */
protected $errorMessage = [];
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
if (DUPX_Validation_database_service::getInstance()->dbGtidModeEnabled($this->errorMessage)) {
return self::LV_SOFT_WARNING;
} else {
return self::LV_PASS;
}
}
public function getTitle(): string
{
return 'Database GTID Mode';
}
protected function swarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-gtid-mode', [
'isOk' => false,
'errorMessage' => $this->errorMessage,
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-gtid-mode', [
'isOk' => true,
'errorMessage' => $this->errorMessage,
], false);
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Libs\Snap\SnapIO;
class DUPX_Validation_test_db_host_name extends DUPX_Validation_abstract_item
{
/** @var string */
protected $fixedHost = '';
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(true);
$host = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_HOST);
//Host check
$parsed_host_info = DUPX_DB::parseDBHost($host);
$parsed_host = $parsed_host_info[0];
$isInvalidHost = $parsed_host == 'http' || $parsed_host == "https";
if ($isInvalidHost) {
$this->fixedHost = SnapIO::untrailingslashit(str_replace($parsed_host . "://", "", $host));
return self::LV_FAIL;
} else {
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(false);
return self::LV_PASS;
}
}
public function getTitle(): string
{
return 'Host Name';
}
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/db-host-name', [
'isOk' => false,
'host' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_HOST),
'fixedHost' => $this->fixedHost,
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-host-name', [
'isOk' => true,
'host' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_HOST),
'fixedHost' => '',
], false);
}
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_db_manual_tables_count extends DUPX_Validation_abstract_item
{
const MIN_TABLES_NUM = 10;
/** @var string */
protected $errorMessage = '';
/** @var int<0, max> */
protected $numTables = 0;
protected function runTest(): int
{
if (
DUPX_Validation_database_service::getInstance()->skipDatabaseTests() ||
PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_ACTION) !== DUPX_DBInstall::DBACTION_MANUAL
) {
return self::LV_SKIP;
}
$this->numTables = DUPX_Validation_database_service::getInstance()->dbTablesCount($this->errorMessage);
if ($this->numTables >= self::MIN_TABLES_NUM) {
return self::LV_PASS;
} else {
return self::LV_HARD_WARNING;
}
}
public function getTitle(): string
{
return 'Manual Table Check';
}
protected function hwarnContent()
{
return dupxTplRender(
'parts/validation/database-tests/db-manual-tables-count',
[
'isOk' => false,
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'numTables' => $this->numTables,
'errorMessage' => $this->errorMessage,
],
false
);
}
protected function passContent()
{
return dupxTplRender(
'parts/validation/database-tests/db-manual-tables-count',
[
'isOk' => true,
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'numTables' => $this->numTables,
'errorMessage' => $this->errorMessage,
],
false
);
}
}

View File

@@ -0,0 +1,91 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\InstState;
use Duplicator\Installer\Core\Params\PrmMng;
use Duplicator\Libs\Snap\SnapWP;
class DUPX_Validation_test_db_multiple_wp_installs extends DUPX_Validation_abstract_item
{
/**
* @var string[] unique wp prefixes in the DB
*/
protected $uniquePrefixes = [];
/**
* Check mutiple db install in database
*
* @return int
*/
protected function runTest(): int
{
$dbAction = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_ACTION);
if (
DUPX_Validation_database_service::getInstance()->skipDatabaseTests()
|| $dbAction === DUPX_DBInstall::DBACTION_MANUAL
|| $dbAction === DUPX_DBInstall::DBACTION_CREATE
) {
return self::LV_SKIP;
}
if (DUPX_Validation_database_service::getInstance()->dbTablesCount() === 0 || InstState::isAddSiteOnMultisite()) {
return self::LV_PASS;
}
$affectedTables = DUPX_Validation_database_service::getInstance()->getDBActionAffectedTables($dbAction);
$this->uniquePrefixes = SnapWP::getUniqueWPTablePrefixes($affectedTables);
if (count($this->uniquePrefixes) > 1) {
return self::LV_SOFT_WARNING;
}
return self::LV_PASS;
}
/**
* Get test title
*
* @return string
*/
public function getTitle(): string
{
return 'Multiple WP Installs';
}
/**
* Return content for test status: soft warning
*
* @return string
*/
protected function swarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-multiple-wp-installs', [
'isOk' => false,
'uniquePrefixes' => $this->uniquePrefixes,
], false);
}
/**
* Return content for test status: pass
*
* @return string
*/
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-multiple-wp-installs', [
'isOk' => true,
'uniquePrefixes' => $this->uniquePrefixes,
], false);
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_db_prefix_too_long extends DUPX_Validation_abstract_item
{
/** @var string */
protected $errorMessage = '';
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(true);
if (DUPX_Validation_database_service::getInstance()->checkDbPrefixTooLong($this->errorMessage)) {
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(false);
return self::LV_PASS;
} else {
return self::LV_FAIL;
}
}
public function getTitle(): string
{
return 'Prefix too long';
}
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/db-prefix-too-long', [
'isOk' => false,
'errorMessage' => $this->errorMessage,
'tooLongNewTableNames' => DUPX_Validation_database_service::getInstance()->getTooLongNewTableNames(),
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-prefix-too-long', [
'isOk' => true,
'errorMessage' => $this->errorMessage,
'tooLongNewTableNames' => DUPX_Validation_database_service::getInstance()->getTooLongNewTableNames(),
], false);
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUPX_Validation_test_db_custom_queries extends DUPX_Validation_abstract_item
{
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
if (!DUPX_Validation_database_service::getInstance()->isQueryWorking('SHOW VARIABLES LIKE "version"')) {
return self::LV_FAIL;
}
return self::LV_PASS;
}
public function getTitle(): string
{
return "Privileges: 'Show Variables' Query";
}
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/db-show-variables', ['pass' => false], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-show-variables', ['pass' => true], false);
}
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUPX_Validation_test_db_supported_charset extends DUPX_Validation_abstract_item
{
/** @var string */
protected $errorMessage = '';
/** @var string[] */
protected $charsetsList = [];
/** @var string[] */
protected $collationsList = [];
/** @var string[] */
protected $invalidCharsets = [];
/** @var string[] */
protected $invalidCollations = [];
/** @var mixed[] */
protected $extraData = [];
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
try {
$archiveConfig = DUPX_ArchiveConfig::getInstance();
$this->charsetsList = $archiveConfig->dbInfo->charSetList;
$this->collationsList = $archiveConfig->dbInfo->collationList;
$this->invalidCharsets = $archiveConfig->invalidCharsets();
$this->invalidCollations = $archiveConfig->invalidCollations();
if (empty($this->invalidCharsets) && empty($this->invalidCollations)) {
return self::LV_PASS;
} else {
return self::LV_HARD_WARNING;
}
} catch (Exception $e) {
$this->errorMessage = $e->getMessage();
return self::LV_FAIL;
}
}
public function getTitle(): string
{
return 'Character Set and Collation Capability';
}
protected function failContent()
{
$dbFuncs = DUPX_DB_Functions::getInstance();
return dupxTplRender('parts/validation/database-tests/db-supported-charset', [
'testResult' => $this->testResult,
'extraData' => $this->extraData,
'charsetsList' => $this->charsetsList,
'collationsList' => $this->collationsList,
'invalidCharsets' => $this->invalidCharsets,
'invalidCollations' => $this->invalidCollations,
'usedCharset' => $dbFuncs->getRealCharsetByParam(),
'usedCollate' => $dbFuncs->getRealCollateByParam(),
'errorMessage' => $this->errorMessage,
], false);
}
protected function hwarnContent()
{
return $this->failContent();
}
protected function passContent()
{
return $this->failContent();
}
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUPX_Validation_test_db_supported_default_charset extends DUPX_Validation_abstract_item
{
/** @var string */
protected $errorMessage = '';
/** @var bool */
protected $charsetOk = true;
/** @var bool */
protected $collateOk = true;
/** @var string */
protected $sourceCharset = '';
/** @var string */
protected $sourceCollate = '';
/**
* Run the test
*
* @return int Enum LV_* result
*/
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
try {
$archiveConfig = DUPX_ArchiveConfig::getInstance();
$dbFuncs = DUPX_DB_Functions::getInstance();
$this->sourceCharset = $archiveConfig->getWpConfigDefineValue('DB_CHARSET', '');
$this->sourceCollate = $archiveConfig->getWpConfigDefineValue('DB_COLLATE', '');
$data = $dbFuncs->getCharsetAndCollationData();
if (!array_key_exists($this->sourceCharset, $data)) {
$this->charsetOk = false;
} elseif (strlen($this->sourceCollate) > 0 && !in_array($this->sourceCollate, $data[$this->sourceCharset]['collations'])) {
$this->collateOk = false;
}
if ($this->charsetOk && $this->collateOk) {
return self::LV_PASS;
} else {
return self::LV_SOFT_WARNING;
}
} catch (Exception $e) {
$this->errorMessage = $e->getMessage();
return self::LV_FAIL;
}
}
/**
* @return string
*/
public function getTitle(): string
{
return 'Character Set and Collation Support';
}
/**
* @return string
*/
protected function failContent()
{
$dbFuncs = DUPX_DB_Functions::getInstance();
return dupxTplRender('parts/validation/database-tests/db-supported-default-charset', [
'testResult' => $this->testResult,
'charsetOk' => $this->charsetOk,
'collateOk' => $this->collateOk,
'sourceCharset' => $this->sourceCharset,
'sourceCollate' => $this->sourceCollate,
'usedCharset' => $dbFuncs->getRealCharsetByParam(),
'usedCollate' => $dbFuncs->getRealCollateByParam(),
'errorMessage' => $this->errorMessage,
], false);
}
/**
* @return string
*/
protected function swarnContent()
{
return $this->failContent();
}
/**
* @return string
*/
protected function passContent()
{
return $this->failContent();
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUPX_Validation_test_db_supported_engine extends DUPX_Validation_abstract_item
{
/** @var string */
protected $errorMessage = '';
/** @var string[] */
protected $invalidEngines = [];
/** @var string */
protected $defaultEngine = "";
/** @var bool */
protected $engineListRead = false;
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
try {
$this->invalidEngines = DUPX_ArchiveConfig::getInstance()->invalidEngines();
$this->defaultEngine = DUPX_DB_Functions::getInstance()->getDefaultEngine();
$this->engineListRead = true;
if (empty($this->invalidEngines)) {
return self::LV_PASS;
} else {
return self::LV_HARD_WARNING;
}
} catch (Exception $e) {
$this->errorMessage = $e->getMessage();
$this->engineListRead = false;
return self::LV_HARD_WARNING;
}
}
public function getTitle(): string
{
return 'Database Engine Support';
}
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/db-supported-engine', [
'testResult' => $this->testResult,
'invalidEngines' => $this->invalidEngines,
'defaultEngine' => $this->defaultEngine,
'errorMessage' => $this->errorMessage,
'engineListRead' => $this->engineListRead,
], false);
}
protected function hwarnContent()
{
return $this->failContent();
}
protected function passContent()
{
return $this->failContent();
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUPX_Validation_test_db_triggers extends DUPX_Validation_abstract_item
{
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
if (count(DUPX_ArchiveConfig::getInstance()->dbInfo->triggerList) > 0) {
return self::LV_SOFT_WARNING;
}
return self::LV_PASS;
}
public function getTitle(): string
{
return 'Source Database Triggers';
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-triggers', [
'isOk' => true,
'triggers' => DUPX_ArchiveConfig::getInstance()->dbInfo->triggerList,
], false);
}
protected function swarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-triggers', [
'isOk' => false,
'triggers' => DUPX_ArchiveConfig::getInstance()->dbInfo->triggerList,
], false);
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_db_user_cleanup extends DUPX_Validation_abstract_item
{
/** @var string */
protected $errorMessage = '';
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->isUserCreated() === false) {
return self::LV_SKIP;
}
if (DUPX_Validation_database_service::getInstance()->cleanUpUser($this->errorMessage)) {
return self::LV_PASS;
} else {
return self::LV_HARD_WARNING;
}
}
public function getTitle(): string
{
return 'User created cleanup';
}
protected function hwarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-user-cleanup', [
'isOk' => false,
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'errorMessage' => $this->errorMessage,
], false);
}
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-user-cleanup', [
'isOk' => true,
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'errorMessage' => $this->errorMessage,
], false);
}
}

View File

@@ -0,0 +1,94 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_db_user_perms extends DUPX_Validation_abstract_item
{
/** @var array<string,int> */
protected $perms = [];
/** @var string[] */
protected $errorMessages = [];
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
return DUPX_Validation_database_service::getInstance()->dbCheckUserPerms($this->perms, $this->errorMessages);
}
public function getTitle(): string
{
return 'Privileges: User Table Access';
}
/**
* @return string
*/
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/db-user-perms', [
'testResult' => self::LV_FAIL,
'perms' => $this->perms,
'failedPerms' => array_keys($this->perms, false, true),
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'errorMessages' => $this->errorMessages,
], false);
}
/**
* @return string
*/
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-user-perms', [
'testResult' => self::LV_PASS,
'perms' => $this->perms,
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'errorMessages' => $this->errorMessages,
], false);
}
/**
* @return string
*/
protected function swarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-user-perms', [
'testResult' => self::LV_HARD_WARNING,
'perms' => $this->perms,
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'errorMessages' => $this->errorMessages,
], false);
}
/**
* @return string
*/
protected function hwarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-user-perms', [
'testResult' => self::LV_HARD_WARNING,
'perms' => $this->perms,
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'errorMessages' => $this->errorMessages,
], false);
}
}

View File

@@ -0,0 +1,70 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Libs\Snap\SnapUtil;
class DUPX_Validation_test_db_user_resources extends DUPX_Validation_abstract_item
{
/** @var array<string, int|string> */
private $userResources = [];
/** @var bool */
private $userHasRestrictedResource = false;
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
if (($this->userResources = DUPX_Validation_database_service::getInstance()->getUserResources()) !== false) {
$this->userHasRestrictedResource = SnapUtil::inArrayExtended($this->userResources, fn($value): bool => $value > 0);
}
if ($this->userHasRestrictedResource) {
return self::LV_SOFT_WARNING;
}
return self::LV_PASS;
}
/**
* @return string
*/
public function getTitle(): string
{
return 'Privileges: User Resources';
}
/**
* @return string
*/
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-user-resources', [
'isOk' => !$this->userHasRestrictedResource,
'userResources' => $this->userResources,
], false);
}
/**
* @return string
*/
protected function swarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-user-resources', [
'isOk' => !$this->userHasRestrictedResource,
'userResources' => $this->userResources,
], false);
}
}

View File

@@ -0,0 +1,110 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Utils\Log\Log;
use Duplicator\Libs\Snap\SnapDB;
class DUPX_Validation_test_db_version extends DUPX_Validation_abstract_item
{
/** @var string */
protected $sourceDBVersion = '';
/** @var string */
protected $hostDBVersion = '';
/** @var string */
protected $hostDBEngine = '';
/** @var string */
protected $sourceDBEngine = '';
/** @var bool */
protected $dbsOfSameType = true;
/**
* Run the test
*
* @return int Enum LV_* result
*/
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(true);
$this->hostDBVersion = DUPX_DB::getVersion(DUPX_Validation_database_service::getInstance()->getDbConnection());
$this->sourceDBVersion = DUPX_ArchiveConfig::getInstance()->version_db;
Log::info('Current DB version: ' . Log::v2str($this->hostDBVersion) . ' Source DB version: ' . Log::v2str($this->sourceDBVersion), Log::LV_DETAILED);
if (version_compare($this->hostDBVersion, '5.0.0', '<')) {
return self::LV_FAIL;
}
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(false);
$this->hostDBEngine = SnapDB::getDBEngine(DUPX_Validation_database_service::getInstance()->getDbConnection());
$this->sourceDBEngine = DUPX_ArchiveConfig::getInstance()->dbInfo->dbEngine;
$this->dbsOfSameType = $this->sourceDBEngine === $this->hostDBEngine;
if (!$this->dbsOfSameType || intval($this->hostDBVersion) < intval($this->sourceDBVersion)) {
return self::LV_SOFT_WARNING;
}
return self::LV_PASS;
}
/**
* Get the title of the test
*
* @return string
*/
public function getTitle(): string
{
return 'Database Version';
}
/**
* @return string
*/
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/db-version', [
'isOk' => false,
'hostDBVersion' => $this->hostDBVersion,
], false);
}
/**
* @return string
*/
protected function swarnContent()
{
return dupxTplRender('parts/validation/database-tests/db-version-swarn', [
'hostDBVersion' => $this->hostDBVersion,
'sourceDBVersion' => $this->sourceDBVersion,
'hostDBEngine' => $this->hostDBEngine,
'sourceDBEngine' => $this->sourceDBEngine,
'dbsOfSameType' => $this->dbsOfSameType,
], false);
}
/**
* @return string
*/
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-version', [
'isOk' => true,
'hostDBVersion' => $this->hostDBVersion,
], false);
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_db_visibility extends DUPX_Validation_abstract_item
{
/** @var string */
protected $errorMessage = '';
protected function runTest(): int
{
if (DUPX_Validation_database_service::getInstance()->skipDatabaseTests()) {
return self::LV_SKIP;
}
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(true);
if (DUPX_Validation_database_service::getInstance()->checkDbVisibility($this->errorMessage)) {
DUPX_Validation_database_service::getInstance()->setSkipOtherTests(false);
return self::LV_PASS;
} else {
return self::LV_FAIL;
}
}
/**
* @return string
*/
public function getTitle(): string
{
return 'Privileges: User Visibility';
}
/**
* @return string
*/
protected function failContent()
{
return dupxTplRender('parts/validation/database-tests/db-visibility', [
'isOk' => false,
'databases' => DUPX_Validation_database_service::getInstance()->getDatabases(),
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'errorMessage' => $this->errorMessage,
], false);
}
/**
* @return string
*/
protected function passContent()
{
return dupxTplRender('parts/validation/database-tests/db-visibility', [
'isOk' => true,
'databases' => DUPX_Validation_database_service::getInstance()->getDatabases(),
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
'errorMessage' => $this->errorMessage,
], false);
}
}

View File

@@ -0,0 +1,70 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
use Duplicator\Installer\Core\Params\PrmMng;
class DUPX_Validation_test_addon_sites extends DUPX_Validation_abstract_item
{
/**
*
* @return int
*/
protected function runTest(): int
{
$list = self::getAddonsListsFolders();
if (PrmMng::getInstance()->getValue(PrmMng::PARAM_ARCHIVE_ACTION) === DUPX_Extraction::ACTION_DO_NOTHING) {
return self::LV_GOOD;
}
if (count($list) > 0) {
return self::LV_SOFT_WARNING;
} else {
return self::LV_GOOD;
}
}
/**
*
* @staticvar string[] $addonListFolder
*
* @return string[]
*/
public static function getAddonsListsFolders()
{
static $addonListFolder = null;
if (is_null($addonListFolder)) {
$addonListFolder = DUPX_Server::getWpAddonsSiteLists();
}
return $addonListFolder;
}
public function getTitle(): string
{
return 'Addon Sites';
}
protected function swarnContent()
{
return dupxTplRender('parts/validation/tests/addon-sites', [
'testResult' => $this->testResult,
'pathsList' => self::getAddonsListsFolders(),
], false);
}
protected function goodContent()
{
return $this->swarnContent();
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUPX_Validation_test_archive_check extends DUPX_Validation_abstract_item
{
protected function runTest(): int
{
if (DUPX_Conf_Utils::archiveExists()) {
return self::LV_PASS;
} else {
return self::LV_SOFT_WARNING;
}
}
public function getTitle(): string
{
return 'Archive Check';
}
protected function failContent()
{
return dupxTplRender('parts/validation/tests/archive-check', [
'testResult' => $this->testResult,
], false);
}
protected function swarnContent()
{
return $this->failContent();
}
protected function passContent()
{
return $this->failContent();
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Validation object
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
*
* @package SC\DUPX\U
*/
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
class DUPX_Validation_test_dbonly_iswordpress extends DUPX_Validation_abstract_item
{
protected function runTest(): int
{
if (!DUPX_ArchiveConfig::getInstance()->isDBOnly()) {
return self::LV_SKIP;
}
if (DUPX_Server::isWordPress()) {
return self::LV_GOOD;
} else {
return self::LV_SOFT_WARNING;
}
}
public function getTitle(): string
{
return 'Database Only';
}
protected function swarnContent()
{
return dupxTplRender('parts/validation/tests/dbonly-iswordpress', [], false);
}
protected function goodContent()
{
return dupxTplRender('parts/validation/tests/dbonly-iswordpress', [], false);
}
}

Some files were not shown because too many files have changed in this diff Show More