first commit
@@ -0,0 +1,9 @@
|
||||
<Files *.php>
|
||||
Order Deny,Allow
|
||||
Deny from all
|
||||
</Files>
|
||||
|
||||
<Files index.php>
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
</Files>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
// silent
|
||||
@@ -0,0 +1,382 @@
|
||||
<?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 = array('operation' => '', 'process_time' => '');
|
||||
/** @var mixed */
|
||||
public $result = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = array();
|
||||
/** @var string */
|
||||
public $class_method = '';
|
||||
/** @var string */
|
||||
public $class_name = '';
|
||||
/** @var ?object */
|
||||
public $class_instance = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = array();
|
||||
public $uri_found;
|
||||
public $uri_match;
|
||||
public $args_in = array();
|
||||
public $args_map = array();
|
||||
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)
|
||||
{
|
||||
$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 <route> 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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
$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 = isset($route_elm['type']) ? $route_elm['type'] : 'request';
|
||||
$route->template = isset($route_elm['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 = array();
|
||||
$params = empty($this->exe_route->params) ? null : $this->exe_route->params;
|
||||
if ($params == null) {
|
||||
return $args_map;
|
||||
}
|
||||
$args_map = $params;
|
||||
$args_map = array_map(function($n) {
|
||||
return 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);
|
||||
$args_map = array_map('urldecode', $args_map);
|
||||
|
||||
return $args_map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creats the args map needed for the final args results
|
||||
*/
|
||||
private function args_map_merge($args_map)
|
||||
{
|
||||
$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, $controller->operation)) {
|
||||
return $controller;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameters from a uri template
|
||||
* example: "/cpnl/is_active/{host}?s=1"
|
||||
* returns: array('host' => '', 's' => 1);
|
||||
*/
|
||||
private function get_params($template, $operation)
|
||||
{
|
||||
$paths = str_replace($operation, '', $template);
|
||||
$paths = array_filter(explode("/", $paths));
|
||||
$params = array();
|
||||
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()
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
$operation = '/'.implode('/', $ops).'/';
|
||||
return $operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a tag element in a string and parses its attributes
|
||||
* example: Finds <route> element and returns its attributes
|
||||
*/
|
||||
private function get_tag_attributes($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 = 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
<?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 = null;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if (substr($host, 0, 4) !== 'http') {
|
||||
$host = 'https://' . $host;
|
||||
}
|
||||
|
||||
$url = parse_url($host);
|
||||
$host = isset($url['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 = isset($url['scheme']) ? $url['scheme'] : 'https';
|
||||
$port = isset($url['port']) ? $url['port'] : '2083';
|
||||
$token = base64_encode("{$scheme},{$host},{$port},{$user},{$pass}");
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$data = array();
|
||||
$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 = array();
|
||||
$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 = isset($obj->cpanelresult->data) ? $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 = isset($obj->cpanelresult->data) ? $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 ? true : false;
|
||||
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 = array();
|
||||
$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 ? true : false;
|
||||
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 = array();
|
||||
$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 ? true : false;
|
||||
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 $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 = array();
|
||||
$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 = array();
|
||||
$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 = array();
|
||||
$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 = array();
|
||||
$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)
|
||||
{
|
||||
// Returns true/false or message on error
|
||||
$data = array();
|
||||
$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;
|
||||
if (isset($obj->cpanelresult->data)) {
|
||||
$data['status'] = "Error calling DBmap";
|
||||
} else {
|
||||
$data['status'] = ($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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
//Start at router for all api requets
|
||||
header('Location: router.php') ;
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
if (!defined('DUPXABSPATH')) {
|
||||
define('DUPXABSPATH', dirname(__FILE__));
|
||||
}
|
||||
|
||||
use Duplicator\Installer\Core\Bootstrap;
|
||||
|
||||
define('DUPX_VERSION', '4.5.16.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', array(
|
||||
'apiControllers' => $API_Server->controllers,
|
||||
'dupVersion' => DUPX_ArchiveConfig::getInstance()->version_dup
|
||||
));
|
||||
@@ -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');
|
||||
}
|
||||
@@ -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=""" 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="," 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="<" 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="_" 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=" " />
|
||||
<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="ª" 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="´" 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="¿" 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="É" 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="Ó" 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="Ý" 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="ç" 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="ñ" 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="û" 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=" " horiz-adv-x="345" />
|
||||
<glyph unicode=" " horiz-adv-x="690" />
|
||||
<glyph unicode=" " horiz-adv-x="345" />
|
||||
<glyph unicode=" " horiz-adv-x="690" />
|
||||
<glyph unicode=" " horiz-adv-x="230" />
|
||||
<glyph unicode=" " horiz-adv-x="172" />
|
||||
<glyph unicode=" " horiz-adv-x="115" />
|
||||
<glyph unicode=" " horiz-adv-x="115" />
|
||||
<glyph unicode=" " horiz-adv-x="86" />
|
||||
<glyph unicode=" " horiz-adv-x="138" />
|
||||
<glyph unicode=" " horiz-adv-x="38" />
|
||||
<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="–" 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="—" 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="‘" 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=" " horiz-adv-x="138" />
|
||||
<glyph unicode=" " horiz-adv-x="172" />
|
||||
<glyph unicode="◼" horiz-adv-x="690" d="M0 690h690v-690h-690v690z" />
|
||||
</font>
|
||||
</defs></svg>
|
||||
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
//silent
|
||||
|
After Width: | Height: | Size: 335 B |
|
After Width: | Height: | Size: 207 B |
|
After Width: | Height: | Size: 262 B |
|
After Width: | Height: | Size: 262 B |
|
After Width: | Height: | Size: 332 B |
|
After Width: | Height: | Size: 280 B |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
@@ -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>
|
||||
@@ -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(/&/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();
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
//silent
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,175 @@
|
||||
Password Strength Meter plugin for jQuery
|
||||
=========================================
|
||||
|
||||
[![Build status][build svg]][build status]
|
||||
[![Code coverage][coverage svg]][coverage]
|
||||
[![License][license svg]][license]
|
||||
[![Latest stable version][releases svg]][releases]
|
||||
[![Total downloads][downloads svg]][downloads]
|
||||
[![Code climate][climate svg]][climate]
|
||||
[![jsDelivr CDN][jsdelivr svg]][jsdelivr]
|
||||
|
||||
A password strength meter for jQuery. [Give it a try!][web]
|
||||
|
||||
![password example][example]
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Using npm
|
||||
|
||||
~~~bash
|
||||
npm install --save password-strength-meter
|
||||
~~~
|
||||
|
||||
Using bower
|
||||
|
||||
~~~bash
|
||||
bower install --save password-strength-meter
|
||||
~~~
|
||||
|
||||
Or much better, using yarn
|
||||
|
||||
~~~bash
|
||||
yarn add password-strength-meter
|
||||
~~~
|
||||
|
||||
For manual installations check out the [releases][releases] section for tarballs.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Import the required scripts:
|
||||
|
||||
~~~html
|
||||
<script src="./js/password-strength-meter/password.min.js"></script>
|
||||
<script src="./js/password-strength-meter/password.min.css"></script>
|
||||
~~~
|
||||
|
||||
Ensure your password field has a wrapper div, like in Bootstrap:
|
||||
|
||||
~~~html
|
||||
<div class="form-group">
|
||||
<label for="password">
|
||||
Password
|
||||
</label>
|
||||
<input id="password" type="password" class="form-control" />
|
||||
</div>
|
||||
~~~
|
||||
|
||||
And call the plugin when you wanna enable it:
|
||||
|
||||
~~~javascript
|
||||
$('#password').password({ /* options */ });
|
||||
~~~
|
||||
|
||||
### Available options
|
||||
|
||||
Here's the list of available options you can pass to the `password` plugin:
|
||||
|
||||
~~~javascript
|
||||
$('#password').password({
|
||||
enterPass: 'Type your password',
|
||||
shortPass: 'The password is too short',
|
||||
containsField: 'The password contains your username',
|
||||
steps: {
|
||||
// Easily change the steps' expected score here
|
||||
13: 'Really insecure password',
|
||||
33: 'Weak; try combining letters & numbers',
|
||||
67: 'Medium; try using special characters',
|
||||
94: 'Strong password',
|
||||
},
|
||||
showPercent: false,
|
||||
showText: true, // shows the text tips
|
||||
animate: true, // whether or not to animate the progress bar on input blur/focus
|
||||
animateSpeed: 'fast', // the above animation speed
|
||||
field: false, // select the match field (selector or jQuery instance) for better password checks
|
||||
fieldPartialMatch: true, // whether to check for partials in field
|
||||
minimumLength: 4, // minimum password length (below this threshold, the score is 0)
|
||||
useColorBarImage: true, // use the (old) colorbar image
|
||||
customColorBarRGB: {
|
||||
red: [0, 240],
|
||||
green: [0, 240],
|
||||
blue: 10,
|
||||
} // set custom rgb color ranges for colorbar.
|
||||
});
|
||||
~~~
|
||||
|
||||
### Events
|
||||
|
||||
There are two events fired by the `password` plugin:
|
||||
|
||||
~~~javascript
|
||||
$('#password').on('password.score', (e, score) => {
|
||||
console.log('Called every time a new score is calculated (this means on every keyup)')
|
||||
console.log('Current score is %d', score)
|
||||
})
|
||||
|
||||
$('#password').on('password.text', (e, text, score) => {
|
||||
console.log('Called every time the text is changed (less updated than password.score)')
|
||||
console.log('Current message is %s with a score of %d', text, score)
|
||||
})
|
||||
~~~
|
||||
|
||||
Compatiblity
|
||||
------------
|
||||
|
||||
This plugin was originally created in 2010 for jQuery 1.14, and the current release
|
||||
has been tested under jQuery 1, 2 & 3.
|
||||
|
||||
It should work in all browsers (even IE 666).
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
First you'll need to grab the code, as the npm version does not come with the
|
||||
source files:
|
||||
|
||||
~~~bash
|
||||
git clone https://github.com/elboletaire/password-strength-meter.git
|
||||
cd password-strength-meter
|
||||
npm install
|
||||
npm test
|
||||
~~~
|
||||
|
||||
> Note: tests are just run using jQuery 3.
|
||||
|
||||
Why?
|
||||
----
|
||||
|
||||
Why another library? Well, I found this on March 11th (of 2017) cleaning up my
|
||||
documents folder and noticed I made it in 2010 and never published it, so I
|
||||
decided to refactor it "a bit" (simply remade it from the ground-up) and publish
|
||||
it, so others can use it.
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
||||
Created by Òscar Casajuana <elboletaire at underave dot net>.
|
||||
|
||||
Based on unlicensed work by [Firas Kassem][firas], published in 2007 and modified
|
||||
by Amin Rajaee in 2009.
|
||||
|
||||
This code is licensed under a [GPL 3.0 license][license].
|
||||
|
||||
[example]: src/example.png
|
||||
[firas]: https://phiras.wordpress.com/2009/07/29/password-strength-meter-v-2/
|
||||
[license]: LICENSE.md
|
||||
[web]: https://elboletaire.github.io/password-strength-meter/
|
||||
|
||||
[build status]: https://gitlab.com/elboletaire/password-strength-meter/pipelines
|
||||
[coverage]: https://gitlab.com/elboletaire/password-strength-meter/-/jobs
|
||||
[license]: https://github.com/elboletaire/password-strength-meter/blob/master/LICENSE.md
|
||||
[releases]: https://github.com/elboletaire/password-strength-meter/releases
|
||||
[downloads]: https://www.npmjs.com/package/password-strength-meter
|
||||
[climate]: https://codeclimate.com/github/elboletaire/password-strength-meter
|
||||
[jsdelivr]: https://www.jsdelivr.com/package/npm/password-strength-meter
|
||||
|
||||
[build svg]: https://gitlab.com/elboletaire/password-strength-meter/badges/master/pipeline.svg
|
||||
[coverage svg]: https://gitlab.com/elboletaire/password-strength-meter/badges/master/coverage.svg
|
||||
[license svg]: https://img.shields.io/github/license/elboletaire/password-strength-meter.svg
|
||||
[releases svg]: https://img.shields.io/npm/v/password-strength-meter.svg
|
||||
[downloads svg]: https://img.shields.io/npm/dt/password-strength-meter.svg
|
||||
[climate svg]: https://img.shields.io/codeclimate/maintainability/elboletaire/password-strength-meter.svg
|
||||
[jsdelivr svg]: https://data.jsdelivr.com/v1/package/npm/password-strength-meter/badge?style=rounded
|
||||
@@ -0,0 +1,22 @@
|
||||
.pass-graybar {
|
||||
height: 3px;
|
||||
background-color: #CCC;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pass-colorbar {
|
||||
height: 3px;
|
||||
background-image: url(passwordstrength.jpg);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.pass-percent, .pass-text {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.pass-percent {
|
||||
margin-right: 5px;
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
/**
|
||||
* @author Òscar Casajuana a.k.a. elboletaire <elboletaire at underave dot net>
|
||||
* @link https://github.com/elboletaire/password-strength-meter
|
||||
* @license GPL-3.0
|
||||
*/
|
||||
// eslint-disable-next-line
|
||||
;(function ($) {
|
||||
'use strict';
|
||||
|
||||
var Password = function ($object, options) {
|
||||
var defaults = {
|
||||
enterPass: 'Type your password',
|
||||
shortPass: 'The password is too short',
|
||||
containsField: 'The password contains your username',
|
||||
steps: {
|
||||
13: 'Really insecure password',
|
||||
33: 'Weak; try combining letters & numbers',
|
||||
67: 'Medium; try using special characters',
|
||||
94: 'Strong password',
|
||||
},
|
||||
showPercent: false,
|
||||
showText: true,
|
||||
animate: true,
|
||||
animateSpeed: 'fast',
|
||||
field: false,
|
||||
fieldPartialMatch: true,
|
||||
minimumLength: 4,
|
||||
closestSelector: 'div',
|
||||
useColorBarImage: false,
|
||||
customColorBarRGB: {
|
||||
red: [0, 240],
|
||||
green: [0, 240],
|
||||
blue: 10
|
||||
},
|
||||
};
|
||||
|
||||
options = $.extend({}, defaults, options);
|
||||
|
||||
/**
|
||||
* Returns strings based on the score given.
|
||||
*
|
||||
* @param {int} score Score base.
|
||||
* @return {string}
|
||||
*/
|
||||
function scoreText(score)
|
||||
{
|
||||
if (score === -1) {
|
||||
return options.shortPass;
|
||||
}
|
||||
if (score === -2) {
|
||||
return options.containsField;
|
||||
}
|
||||
|
||||
score = score < 0 ? 0 : score;
|
||||
|
||||
var text = options.shortPass;
|
||||
var sortedStepKeys = Object.keys(options.steps).sort();
|
||||
for (var step in sortedStepKeys) {
|
||||
var stepVal = sortedStepKeys[step];
|
||||
if (stepVal < score) {
|
||||
text = options.steps[stepVal];
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value between -2 and 100 to score
|
||||
* the user's password.
|
||||
*
|
||||
* @param {string} password The password to be checked.
|
||||
* @param {string} field The field set (if options.field).
|
||||
* @return {int}
|
||||
*/
|
||||
function calculateScore(password, field)
|
||||
{
|
||||
var score = 0;
|
||||
|
||||
// password < options.minimumLength
|
||||
if (password.length < options.minimumLength) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (options.field) {
|
||||
// password === field
|
||||
if (password.toLowerCase() === field.toLowerCase()) {
|
||||
return -2;
|
||||
}
|
||||
// password contains field (and fieldPartialMatch is set to true)
|
||||
if (options.fieldPartialMatch && field.length) {
|
||||
var user = new RegExp(field.toLowerCase());
|
||||
if (password.toLowerCase().match(user)) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// password length
|
||||
score += password.length * 4;
|
||||
score += checkRepetition(1, password).length - password.length;
|
||||
score += checkRepetition(2, password).length - password.length;
|
||||
score += checkRepetition(3, password).length - password.length;
|
||||
score += checkRepetition(4, password).length - password.length;
|
||||
|
||||
// password has 3 numbers
|
||||
if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) {
|
||||
score += 5;
|
||||
}
|
||||
|
||||
// password has at least 2 symbols
|
||||
var symbols = '.*[!,@,#,$,%,^,&,*,?,_,~]';
|
||||
symbols = new RegExp('(' + symbols + symbols + ')');
|
||||
if (password.match(symbols)) {
|
||||
score += 5;
|
||||
}
|
||||
|
||||
// password has Upper and Lower chars
|
||||
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) {
|
||||
score += 10;
|
||||
}
|
||||
|
||||
// password has number and chars
|
||||
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) {
|
||||
score += 15;
|
||||
}
|
||||
|
||||
// password has number and symbol
|
||||
if (password.match(/([!@#$%^&*?_~])/) && password.match(/([0-9])/)) {
|
||||
score += 15;
|
||||
}
|
||||
|
||||
// password has char and symbol
|
||||
if (password.match(/([!@#$%^&*?_~])/) && password.match(/([a-zA-Z])/)) {
|
||||
score += 15;
|
||||
}
|
||||
|
||||
// password is just numbers or chars
|
||||
if (password.match(/^\w+$/) || password.match(/^\d+$/)) {
|
||||
score -= 10;
|
||||
}
|
||||
|
||||
if (score > 100) {
|
||||
score = 100;
|
||||
}
|
||||
|
||||
if (score < 0) {
|
||||
score = 0;
|
||||
}
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for repetition of characters in
|
||||
* a string
|
||||
*
|
||||
* @param {int} length Repetition length.
|
||||
* @param {string} str The string to be checked.
|
||||
* @return {string}
|
||||
*/
|
||||
function checkRepetition(length, str)
|
||||
{
|
||||
var res = "", repeated = false;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
repeated = true;
|
||||
for (var j = 0; j < length && (j + i + length) < str.length; j++) {
|
||||
repeated = repeated && (str.charAt(j + i) === str.charAt(j + i + length));
|
||||
}
|
||||
if (j < length) {
|
||||
repeated = false;
|
||||
}
|
||||
if (repeated) {
|
||||
i += length - 1;
|
||||
repeated = false;
|
||||
} else {
|
||||
res += str.charAt(i);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates background colors from percentage value.
|
||||
*
|
||||
* @param {int} perc The percentage strength of the password.
|
||||
* @return {object} Object with colors as keys
|
||||
*/
|
||||
function calculateColorFromPercentage(perc)
|
||||
{
|
||||
var minRed = 0;
|
||||
var maxRed = 240;
|
||||
var minGreen = 0;
|
||||
var maxGreen = 240;
|
||||
var blue = 10;
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(options.customColorBarRGB, 'red')) {
|
||||
minRed = options.customColorBarRGB.red[0];
|
||||
maxRed = options.customColorBarRGB.red[1];
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(options.customColorBarRGB, 'green')) {
|
||||
minGreen = options.customColorBarRGB.green[0];
|
||||
maxGreen = options.customColorBarRGB.green[1];
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(options.customColorBarRGB, 'blue')) {
|
||||
blue = options.customColorBarRGB.blue;
|
||||
}
|
||||
|
||||
var green = (perc * maxGreen / 50);
|
||||
var red = (2 * maxRed) - (perc * maxRed / 50);
|
||||
|
||||
return {
|
||||
red: Math.min(Math.max(red, minRed), maxRed),
|
||||
green: Math.min(Math.max(green, minGreen), maxGreen),
|
||||
blue: blue
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds color styles to colorbar jQuery object.
|
||||
*
|
||||
* @param {jQuery} $colorbar The colorbar jquery object.
|
||||
* @param {int} perc The percentage strength of the password.
|
||||
* @return {jQuery}
|
||||
*/
|
||||
function addColorBarStyle($colorbar, perc)
|
||||
{
|
||||
if (options.useColorBarImage) {
|
||||
$colorbar.css({
|
||||
backgroundPosition: "0px -" + perc + "px",
|
||||
width: perc + '%'
|
||||
});
|
||||
} else {
|
||||
var colors = calculateColorFromPercentage(perc);
|
||||
|
||||
$colorbar.css({
|
||||
'background-image': 'none',
|
||||
'background-color': 'rgb(' + colors.red.toString() + ', ' + colors.green.toString() + ', ' + colors.blue.toString() + ')',
|
||||
width: perc + '%'
|
||||
});
|
||||
}
|
||||
|
||||
return $colorbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the plugin creating and binding the
|
||||
* required layers and events.
|
||||
*
|
||||
* @return {Password} Returns the Password instance.
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
var shown = true;
|
||||
var $text = options.showText;
|
||||
var $percentage = options.showPercent;
|
||||
var $graybar = $('<div>').addClass('pass-graybar');
|
||||
var $colorbar = $('<div>').addClass('pass-colorbar');
|
||||
var $insert = $('<div>').addClass('pass-wrapper').append(
|
||||
$graybar.append($colorbar)
|
||||
);
|
||||
|
||||
$object.closest(options.closestSelector).addClass('pass-strength-visible');
|
||||
if (options.animate) {
|
||||
$insert.css('display', 'none');
|
||||
shown = false;
|
||||
$object.closest(options.closestSelector).removeClass('pass-strength-visible');
|
||||
}
|
||||
|
||||
if (options.showPercent) {
|
||||
$percentage = $('<span>').addClass('pass-percent').text('0%');
|
||||
$insert.append($percentage);
|
||||
}
|
||||
|
||||
if (options.showText) {
|
||||
$text = $('<span>').addClass('pass-text').html(options.enterPass);
|
||||
$insert.append($text);
|
||||
}
|
||||
|
||||
$object.closest(options.closestSelector).append($insert);
|
||||
|
||||
$object.keyup(function () {
|
||||
var field = options.field || '';
|
||||
if (field) {
|
||||
field = $(field).val();
|
||||
}
|
||||
|
||||
var score = calculateScore($object.val(), field);
|
||||
$object.trigger('password.score', [score]);
|
||||
var perc = score < 0 ? 0 : score;
|
||||
|
||||
$colorbar = addColorBarStyle($colorbar, perc);
|
||||
|
||||
if (options.showPercent) {
|
||||
$percentage.html(perc + '%');
|
||||
}
|
||||
|
||||
if (options.showText) {
|
||||
var text = scoreText(score);
|
||||
if (!$object.val().length && score <= 0) {
|
||||
text = options.enterPass;
|
||||
}
|
||||
|
||||
if ($text.html() !== $('<div>').html(text).html()) {
|
||||
$text.html(text);
|
||||
$object.trigger('password.text', [text, score]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (options.animate) {
|
||||
$object.focus(function () {
|
||||
if (!shown) {
|
||||
$insert.slideDown(options.animateSpeed, function () {
|
||||
shown = true;
|
||||
$object.closest(options.closestSelector).addClass('pass-strength-visible');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$object.blur(function () {
|
||||
if (!$object.val().length && shown) {
|
||||
$insert.slideUp(options.animateSpeed, function () {
|
||||
shown = false;
|
||||
$object.closest(options.closestSelector).removeClass('pass-strength-visible')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
return init.call(this);
|
||||
};
|
||||
|
||||
// Bind to jquery
|
||||
$.fn.password = function (options) {
|
||||
return this.each(function () {
|
||||
new Password($(this), options);
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
|
After Width: | Height: | Size: 9.7 KiB |
@@ -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>
|
||||
349
wp-content/plugins/duplicator-pro-v4.5.16.2/installer/dup-installer/assets/normalize.css
vendored
Normal 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;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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 web site, you can
|
||||
* copy this file to "wp-config.php" and fill in the values.
|
||||
*
|
||||
* This file contains the following configurations:
|
||||
*
|
||||
* * MySQL settings
|
||||
* * Secret keys
|
||||
* * Database table prefix
|
||||
* * ABSPATH
|
||||
*
|
||||
* @link https://codex.wordpress.org/Editing_wp-config.php
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
// ** MySQL settings - You can get this info from your web host ** //
|
||||
/** The name of the database for WordPress */
|
||||
define('DB_NAME', 'database_name_here');
|
||||
/** MySQL database username */
|
||||
define('DB_USER', 'username_here');
|
||||
/** MySQL database password */
|
||||
define('DB_PASSWORD', 'password_here');
|
||||
/** MySQL 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!
|
||||
*/
|
||||
$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 Codex.
|
||||
*
|
||||
* @link https://codex.wordpress.org/Debugging_in_WordPress
|
||||
*/
|
||||
define('WP_DEBUG', false);
|
||||
/* That's all, stop editing! Happy publishing. */
|
||||
|
||||
/** Absolute path to the WordPress directory. */
|
||||
if (! defined('ABSPATH')) {
|
||||
define('ABSPATH', dirname(__FILE__) . '/');
|
||||
}
|
||||
|
||||
/** Sets up WordPress vars and included files. */
|
||||
require_once(ABSPATH . 'wp-settings.php');
|
||||
@@ -0,0 +1,9 @@
|
||||
<Files *.php>
|
||||
Order Deny,Allow
|
||||
Deny from all
|
||||
</Files>
|
||||
|
||||
<Files index.php>
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
</Files>
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
defined("DUPXABSPATH") or die("");
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
class DUPX_Crypt
|
||||
{
|
||||
/**
|
||||
* Encrypt a string
|
||||
*
|
||||
* @param string $key The key to use for encryption
|
||||
* @param string $string The string to encrypt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function encrypt($key, $string)
|
||||
{
|
||||
$result = '';
|
||||
for ($i = 0; $i < strlen($string); $i++) {
|
||||
$char = substr($string, $i, 1);
|
||||
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
|
||||
$char = chr(ord($char) + ord($keychar));
|
||||
$result .= $char;
|
||||
}
|
||||
|
||||
return urlencode(base64_encode($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt a string
|
||||
*
|
||||
* @param string $key The key to use for decryption
|
||||
* @param string $string The string to decrypt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function decrypt($key, $string)
|
||||
{
|
||||
$result = '';
|
||||
$string = urldecode($string);
|
||||
$string = base64_decode($string);
|
||||
|
||||
for ($i = 0; $i < strlen($string); $i++) {
|
||||
$char = substr($string, $i, 1);
|
||||
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
|
||||
$char = chr(ord($char) - ord($keychar));
|
||||
$result .= $char;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scramble a string
|
||||
*
|
||||
* @param string $string The string to scramble
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function scramble($string)
|
||||
{
|
||||
return self::encrypt(self::sk1() . self::sk2(), $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unscramble a string
|
||||
*
|
||||
* @param string $string The string to unscramble
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function unscramble($string)
|
||||
{
|
||||
return self::decrypt(self::sk1() . self::sk2(), $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function sk1()
|
||||
{
|
||||
return 'fdas' . self::encrypt('abx', 'v1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the second key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function sk2()
|
||||
{
|
||||
return 'fres' . self::encrypt('ad3x', 'v2');
|
||||
}
|
||||
}
|
||||
@@ -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 = array(), $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, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
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, $method = 'POST')
|
||||
{
|
||||
$full_url = $url;
|
||||
if ($method == 'GET' && count($params)) {
|
||||
$url = preg_replace('/\?.*/', '', $url);
|
||||
$full_url = $url . '?' . http_build_query($params);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'http' => array(
|
||||
'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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
<?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\Installer\Core\Security;
|
||||
use Duplicator\Installer\Core\Bootstrap;
|
||||
use Duplicator\Installer\Core\Deploy\ServerConfigs;
|
||||
use Duplicator\Installer\Utils\InstallerOrigFileMng;
|
||||
|
||||
/**
|
||||
* 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 . '/' . Bootstrap::ARCHIVE_PREFIX . self::getPackageHash() . Bootstrap::ARCHIVE_EXTENSION;
|
||||
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()
|
||||
{
|
||||
return DUPX_INIT . '/dup-manual-extract__' . self::getPackageHash();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getWpconfigSamplePath()
|
||||
{
|
||||
static $path = null;
|
||||
if (is_null($path)) {
|
||||
$path = DUPX_INIT . '/assets/wp-config-sample.php';
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sql file relative path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSqlFilePathInArchive()
|
||||
{
|
||||
return 'dup-installer/dup-database__' . self::getPackageHash() . '.sql';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSqlFilePath()
|
||||
{
|
||||
static $path = null;
|
||||
if (is_null($path)) {
|
||||
$path = DUPX_INIT . '/dup-database__' . self::getPackageHash() . '.sql';
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDirsListPath()
|
||||
{
|
||||
static $path = null;
|
||||
if (is_null($path)) {
|
||||
$path = DUPX_INIT . '/dup-scanned-dirs__' . self::getPackageHash() . '.txt';
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getFilesListPath()
|
||||
{
|
||||
static $path = null;
|
||||
if (is_null($path)) {
|
||||
$path = DUPX_INIT . '/dup-scanned-files__' . self::getPackageHash() . '.txt';
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getScanJsonPath()
|
||||
{
|
||||
static $path = null;
|
||||
if (is_null($path)) {
|
||||
$path = DUPX_INIT . '/dup-scan__' . self::getPackageHash() . '.json';
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getSqlFileSize()
|
||||
{
|
||||
return (is_readable(self::getSqlFilePath())) ? (int) filesize(self::getSqlFilePath()) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param callable $callback callback function
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function foreachDirCallback($callback)
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
throw new Exception('Not valid callback');
|
||||
}
|
||||
|
||||
$dirFiles = DUPX_Package::getDirsListPath();
|
||||
|
||||
if (($handle = fopen($dirFiles, "r")) === false) {
|
||||
throw new Exception('Can\'t open dirs file list');
|
||||
}
|
||||
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if (($info = json_decode($line)) === null) {
|
||||
throw new Exception('Invalid json line in dirs file: ' . $line);
|
||||
}
|
||||
|
||||
call_user_func($callback, $info);
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param callable $callback callback
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function foreachFileCallback($callback)
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
throw new Exception('Not valid callback');
|
||||
}
|
||||
|
||||
$filesPath = DUPX_Package::getFilesListPath();
|
||||
|
||||
if (($handle = fopen($filesPath, "r")) === false) {
|
||||
throw new Exception('Can\'t open files file list');
|
||||
}
|
||||
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if (($info = json_decode($line)) === null) {
|
||||
throw new Exception('Invalid json line in files file: ' . $line);
|
||||
}
|
||||
|
||||
call_user_func($callback, $info);
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -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 = array(
|
||||
'wp-admin',
|
||||
'wp-includes',
|
||||
);
|
||||
|
||||
/**
|
||||
* Return PHP safe nome, on PHP 5.4 is always false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function phpSafeModeOn()
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
$filepath = null;
|
||||
if (Shell::runCommand('echo duplicator', Shell::AVAILABLE_COMMANDS) !== false) {
|
||||
$shellOutput = Shell::runCommand('hash unzip 2>&1', Shell::AVAILABLE_COMMANDS);
|
||||
if ($shellOutput !== false && $shellOutput->isEmpty()) {
|
||||
$filepath = 'unzip';
|
||||
} else {
|
||||
$possible_paths = array(
|
||||
'/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()
|
||||
{
|
||||
$addonsSites = array();
|
||||
$pathsToCheck = DUPX_ArchiveConfig::getInstance()->getPathsMapping();
|
||||
|
||||
if (is_scalar($pathsToCheck)) {
|
||||
$pathsToCheck = array($pathsToCheck);
|
||||
}
|
||||
|
||||
foreach ($pathsToCheck as $mainPath) {
|
||||
SnapIO::regexGlobCallback($mainPath, function ($path) use (&$addonsSites) {
|
||||
if (SnapWP::isWpHomeFolder($path)) {
|
||||
$addonsSites[] = $path;
|
||||
}
|
||||
}, array(
|
||||
'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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?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()
|
||||
{
|
||||
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 = array(
|
||||
'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 $e) {
|
||||
Log::info('CHECK WP CONFIG FAIL msg: ' . $e->getMessage());
|
||||
$wpConfigValid = false;
|
||||
} catch (Error $e) {
|
||||
Log::info('CHECK WP CONFIG FAIL msg: ' . $e->getMessage());
|
||||
$wpConfigValid = false;
|
||||
}
|
||||
}
|
||||
return $wpConfigValid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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\Core\Bootstrap;
|
||||
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_';
|
||||
|
||||
/**
|
||||
* Init method used to auto initialize the global params
|
||||
* This function init all params before read from request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function init()
|
||||
{
|
||||
//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);
|
||||
}
|
||||
|
||||
//UPDATE TABLE SETTINGS
|
||||
$GLOBALS['REPLACE_LIST'] = array();
|
||||
$GLOBALS['DEBUG_JS'] = false;
|
||||
|
||||
//CONSTANTS
|
||||
if (!defined("DUPLICATOR_PRO_SSDIR_NAME")) {
|
||||
define("DUPLICATOR_PRO_SSDIR_NAME", 'wp-snapshots-dup-pro'); //This should match DUPLICATOR_PRO_SSDIR_NAME in duplicator.php
|
||||
}
|
||||
|
||||
//GLOBALS
|
||||
$GLOBALS["NOTICES_FILE_PATH"] = DUPX_INIT . '/' . "dup-installer-notices__" . Bootstrap::getPackageHash() . ".json";
|
||||
$GLOBALS["CHUNK_DATA_FILE_PATH"] = DUPX_INIT . '/' . "dup-installer-chunk__" . Bootstrap::getPackageHash() . ".json";
|
||||
$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'] = array(
|
||||
'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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
//silent
|
||||
@@ -0,0 +1,862 @@
|
||||
<?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_WP_USERS = 'users';
|
||||
const TABLE_NAME_WP_USERMETA = 'usermeta';
|
||||
|
||||
/** @var ?self */
|
||||
protected static $instance = null;
|
||||
/** @var ?mysqli */
|
||||
private $dbh = null;
|
||||
/** @var float */
|
||||
protected $timeStart = 0;
|
||||
/** @var ?array<string, string> current data connection */
|
||||
private $dataConnection = null;
|
||||
/** @var ?array<int,array{name:string,isDefault:bool}> list of supported engine types */
|
||||
private $engineData = null;
|
||||
/** @var ?array<string,array{defCollation:bool,collations:string[]}> supported charset and collation data */
|
||||
private $charsetData = null;
|
||||
/** @var ?array<string,string> default charset in dwtabase connection */
|
||||
private $defaultCharset = null;
|
||||
/** @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 = array(
|
||||
'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'] = array();
|
||||
} elseif (!$isLocalhost && ($dbh = DUPX_DB::connect($dbhost, $dbuser, $dbpass, $dbname, MYSQLI_CLIENT_SSL)) != false) {
|
||||
$dbflag = MYSQLI_CLIENT_SSL;
|
||||
$wpConfigFalgsVal['inWpConfig'] = true;
|
||||
$wpConfigFalgsVal['value'] = array(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'] = array($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()
|
||||
{
|
||||
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|bool 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 = array();
|
||||
while ($row = $result->fetch_array()) {
|
||||
if ($row[1] !== "YES" && $row[1] !== "DEFAULT") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->engineData[] = array(
|
||||
"name" => $row[0],
|
||||
"isDefault" => $row[1] === "DEFAULT",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->engineData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] list of supported MySQL engine names
|
||||
*/
|
||||
public function getSupportedEngineList()
|
||||
{
|
||||
return array_map(function ($engine) {
|
||||
return $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()
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
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] = array(
|
||||
'defCollation' => false,
|
||||
'collations' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
$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()
|
||||
{
|
||||
$result = array();
|
||||
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)
|
||||
{
|
||||
if (is_null($prefix)) {
|
||||
$prefix = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLE_PREFIX);
|
||||
}
|
||||
return $prefix . 'options';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param null|string $prefix table prefix, if null take wp table prefix by default
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getPostsTableName($prefix = null)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (is_null($prefix)) {
|
||||
$prefix = PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_TABLE_PREFIX);
|
||||
}
|
||||
return $prefix . self::TABLE_NAME_DUPLICAT_ENTITIES;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
$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 = array($tables);
|
||||
}
|
||||
$dbName = mysqli_real_escape_string($this->dbh, $this->dataConnection['dbname']);
|
||||
$dbh = $this->dbh;
|
||||
|
||||
$escapedTables = array_map(function ($table) use ($dbh) {
|
||||
return "'" . 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)
|
||||
{
|
||||
$result = array();
|
||||
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[] = array(
|
||||
'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 = array())
|
||||
{
|
||||
$this->dbConnection();
|
||||
|
||||
$options = array_merge(array(
|
||||
'exclude' => array(), // exclude table list,
|
||||
'prefixFilter' => false,
|
||||
'regexFilter' => false, // filter tables with regexp
|
||||
'notRegexFilter' => false, // filter tables with not regexp
|
||||
'regexTablesDropFkeys' => false,
|
||||
'copyTables' => array(),// 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$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, $this->getUserTableName($prefix));
|
||||
$userMetaTable = mysqli_real_escape_string($this->dbh, $this->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 = array();
|
||||
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` = 'duplicator_pro_plugin_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 ustat identifier
|
||||
*
|
||||
* @param string $prefix table prefix
|
||||
*
|
||||
* @return string ustat identifier
|
||||
*/
|
||||
public function getUstatIdentifier($prefix)
|
||||
{
|
||||
$optionsTable = self::getOptionsTableName($prefix);
|
||||
$sql = "SELECT `option_value` FROM `{$optionsTable}` WHERE `option_name` = 'duplicator_pro_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 isset($dataStat['identifier']) ? $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)
|
||||
{
|
||||
$this->dbConnection();
|
||||
//UPDATE `i5tr4_posts` SET `post_author` = 7 WHERE TRUE
|
||||
$postsTable = mysqli_real_escape_string($this->dbh, $this->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()
|
||||
{
|
||||
$excludedTables = array();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,743 @@
|
||||
<?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) {
|
||||
list($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 = array();
|
||||
$result = preg_match($pattern, $host, $matches);
|
||||
if (1 !== $result) {
|
||||
// Couldn't parse the address, bail.
|
||||
return false;
|
||||
}
|
||||
|
||||
$host = '';
|
||||
foreach (array('host', 'port') as $component) {
|
||||
if (!empty($matches[$component])) {
|
||||
$$component = $matches[$component];
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
$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 = '')
|
||||
{
|
||||
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($dbh, $dbname)
|
||||
{
|
||||
$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($dbh, $name)
|
||||
{
|
||||
$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 = array();
|
||||
$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 = array();
|
||||
$query = "SHOW COLLATION";
|
||||
if (($result = self::mysqli_query($dbh, $query))) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$collations[] = $row;
|
||||
}
|
||||
$result->free();
|
||||
}
|
||||
|
||||
usort($collations, function ($a, $b) {
|
||||
return 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 = array();
|
||||
$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 = '')
|
||||
{
|
||||
$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)) {
|
||||
$all_dbs[] = $db[0];
|
||||
}
|
||||
if (isset($all_dbs) && is_array($all_dbs)) {
|
||||
return $all_dbs;
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if database exists
|
||||
*
|
||||
* @param mysqli $dbh DB connection
|
||||
* @param string $dbname database name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function databaseExists($dbh, $dbname)
|
||||
{
|
||||
$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($dbh, $tablename)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$query = self::mysqli_query($dbh, 'SHOW TABLES');
|
||||
if ($query) {
|
||||
$all_tables = array();
|
||||
while ($table = @mysqli_fetch_array($query)) {
|
||||
$all_tables[] = $table[0];
|
||||
}
|
||||
return $all_tables;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 isset($row[1]) ? $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($dbh, $sql, $column_index = 0)
|
||||
{
|
||||
$result_array = 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($dbh, $sql)
|
||||
{
|
||||
$result = array();
|
||||
$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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 isset($assoc['db']) ? $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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,457 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* This class manages the installer table, all table management refers to the table name in the original site.
|
||||
*/
|
||||
class DUPX_DB_Table_item
|
||||
{
|
||||
/** @var string */
|
||||
protected $originalName = '';
|
||||
/** @var string */
|
||||
protected $tableWithoutPrefix = '';
|
||||
/** @var int */
|
||||
protected $rows = 0;
|
||||
/** @var int */
|
||||
protected $size = 0;
|
||||
/** @var bool */
|
||||
protected $havePrefix = false;
|
||||
/** @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 tabel 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
$oldPos = strlen(($oldName = $this->getOriginalName()));
|
||||
$newPos = strlen(($newName = $this->getNewName()));
|
||||
|
||||
if ($oldName == $newName) {
|
||||
$diffData = array(
|
||||
'oldPrefix' => '',
|
||||
'newPrefix' => '',
|
||||
'commonPart' => $oldName,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($oldPos > 0 && $newPos > 0) {
|
||||
if ($oldName[$oldPos - 1] != $newName[$newPos - 1]) {
|
||||
break;
|
||||
}
|
||||
|
||||
$oldPos--;
|
||||
$newPos--;
|
||||
}
|
||||
|
||||
$diffData = array(
|
||||
'oldPrefix' => substr($oldName, 0, $oldPos),
|
||||
'newPrefix' => substr($newName, 0, $newPos),
|
||||
'commonPart' => substr($oldName, $oldPos),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function havePrefix()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return (
|
||||
$this->havePrefix &&
|
||||
in_array(
|
||||
$this->tableWithoutPrefix,
|
||||
array(
|
||||
DUPX_DB_Functions::TABLE_NAME_WP_USERS,
|
||||
DUPX_DB_Functions::TABLE_NAME_WP_USERMETA,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function standAloneExtractCheck()
|
||||
{
|
||||
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 ($this->originalName == DUPX_DB_Functions::getEntitiesTableName($originalPrefix)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->originalName == DUPX_DB_Functions::getPackagesTableName($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'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
<?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 = null;
|
||||
/** @var DUPX_DB_Table_item[] */
|
||||
private $tables = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @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()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
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()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
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)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
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)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
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()
|
||||
{
|
||||
$standaloneTables = null;
|
||||
|
||||
if (is_null($standaloneTables)) {
|
||||
$standaloneTables = array();
|
||||
$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()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
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()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
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()
|
||||
{
|
||||
$mapping = array();
|
||||
$diffData = array();
|
||||
|
||||
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']] = array();
|
||||
}
|
||||
|
||||
if (!isset($mapping[$diffData['oldPrefix']][$diffData['newPrefix']])) {
|
||||
$mapping[$diffData['oldPrefix']][$diffData['newPrefix']] = array();
|
||||
}
|
||||
|
||||
$mapping[$diffData['oldPrefix']][$diffData['newPrefix']][] = $diffData['commonPart'];
|
||||
}
|
||||
|
||||
uksort($mapping, function ($a, $b) {
|
||||
$lenA = strlen($a);
|
||||
$lenB = strlen($b);
|
||||
|
||||
if ($lenA == $lenB) {
|
||||
return 0;
|
||||
} elseif ($lenA > $lenB) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
// maximise prefix length
|
||||
$optimizedMapping = array();
|
||||
$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] = array();
|
||||
}
|
||||
|
||||
$optimizedMapping[$optOldPrefix][$optNewPrefix] = array_map(function ($val) use ($pos) {
|
||||
return substr($val, $pos);
|
||||
}, $commons);
|
||||
}
|
||||
}
|
||||
|
||||
return $optimizedMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* return param table default
|
||||
*
|
||||
* @return array<array{name: string, extract: bool, replace: bool}>
|
||||
*/
|
||||
public function getDefaultParamValue()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
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)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($this->tables as $table) {
|
||||
$extract = !in_array($table->getOriginalName(), $filterTables) ? $table->canBeExctracted() : false;
|
||||
|
||||
$result[$table->getOriginalName()] = ParamFormTables::getParamItemValueFromData(
|
||||
$table->getOriginalName(),
|
||||
$extract,
|
||||
$extract
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -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 = null;
|
||||
|
||||
/**
|
||||
* 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 = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
$result = array();
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!$this->isManaged()) {
|
||||
return false;
|
||||
} elseif (SnapWP::isWpCore($extract_filename, SnapWP::PATH_RELATIVE)) {
|
||||
return true;
|
||||
} elseif (DUPX_ArchiveConfig::getInstance()->isChildOfArchivePath($extract_filename, array('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()
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
return DUPX_Custom_Host_Manager::HOST_FLYWHEEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if is current host
|
||||
*/
|
||||
public function isHosting()
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return 'Flywheel';
|
||||
}
|
||||
|
||||
/**
|
||||
* this function is called if current hosting is this
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomParams()
|
||||
{
|
||||
$paramsManager = PrmMng::getInstance();
|
||||
|
||||
$paramsManager->setValue(PrmMng::PARAM_ARCHIVE_ENGINE_SKIP_WP_FILES, DUP_PRO_Extraction::FILTER_SKIP_WP_CORE);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
return DUPX_Custom_Host_Manager::HOST_GODADDY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if is current host
|
||||
*/
|
||||
public function isHosting()
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return 'GoDaddy';
|
||||
}
|
||||
|
||||
/**
|
||||
* this function is called if current hosting is this
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomParams()
|
||||
{
|
||||
PrmMng::getInstance()->setValue(PrmMng::PARAM_IGNORE_PLUGINS, array(
|
||||
'gd-system-plugin.php',
|
||||
'object-cache.php',
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
return DUPX_Custom_Host_Manager::HOST_LIQUIDWEB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if is current host
|
||||
*/
|
||||
public function isHosting()
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* return the label of current hosting
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return 'Liquid Web';
|
||||
}
|
||||
|
||||
/**
|
||||
* this function is called if current hosting is this
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomParams()
|
||||
{
|
||||
PrmMng::getInstance()->setValue(PrmMng::PARAM_IGNORE_PLUGINS, array(
|
||||
'liquidweb_mwp.php',
|
||||
'000-liquidweb-config.php',
|
||||
'liquid-web.php',
|
||||
'lw_disable_nags.php',
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
return DUPX_Custom_Host_Manager::HOST_PANTHEON;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if is current host
|
||||
* @throws Exception
|
||||
*/
|
||||
public function isHosting()
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return 'Pantheon';
|
||||
}
|
||||
|
||||
/**
|
||||
* this function is called if current hosting is this
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomParams()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
return DUPX_Custom_Host_Manager::HOST_SITEGROUND;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if is current host
|
||||
*/
|
||||
public function isHosting()
|
||||
{
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return 'SiteGround';
|
||||
}
|
||||
|
||||
/**
|
||||
* this function is called if current hosting is this
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomParams()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
return DUPX_Custom_Host_Manager::HOST_WORDPRESSCOM;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if is current host
|
||||
*/
|
||||
public function isHosting()
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return 'Wordpress.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* this function is called if current hosting is this
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomParams()
|
||||
{
|
||||
$paramsManager = PrmMng::getInstance();
|
||||
|
||||
$paramsManager->setValue(PrmMng::PARAM_ARCHIVE_ENGINE_SKIP_WP_FILES, DUP_PRO_Extraction::FILTER_SKIP_WP_CORE);
|
||||
|
||||
if (!InstState::isRecoveryMode()) {
|
||||
$paramsManager->setValue(PrmMng::PARAM_USERS_MODE, ParamDescUsers::USER_MODE_IMPORT_USERS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
return DUPX_Custom_Host_Manager::HOST_WPENGINE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if is current host
|
||||
*/
|
||||
public function isHosting()
|
||||
{
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return 'WP Engine';
|
||||
}
|
||||
|
||||
/**
|
||||
* this function is called if current hosting is this
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomParams()
|
||||
{
|
||||
PrmMng::getInstance()->setValue(PrmMng::PARAM_IGNORE_PLUGINS, array(
|
||||
'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()
|
||||
{
|
||||
$fdPlugins = PrmMng::getInstance()->getValue(PrmMng::PARAM_FORCE_DIABLE_PLUGINS);
|
||||
|
||||
if (!is_array($fdPlugins)) {
|
||||
$fdPlugins = array();
|
||||
}
|
||||
|
||||
$fdPlugins = array_merge($fdPlugins, array(
|
||||
'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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
/**
|
||||
* @return bool true if is current host
|
||||
*/
|
||||
public function isHosting();
|
||||
|
||||
/**
|
||||
* the init function.
|
||||
* is called only if isHosting is true
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init();
|
||||
|
||||
/**
|
||||
* return the label of current hosting
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel();
|
||||
|
||||
/**
|
||||
* this function is called if current hosting is this
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCustomParams();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
//silent
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Custom exceptions
|
||||
*
|
||||
* Standard: PSR-2
|
||||
*
|
||||
* @link http://www.php-fig.org/psr/psr-2 Full Documentation
|
||||
*
|
||||
* @package SC\DUPX\U
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Dup installer custom exception
|
||||
*/
|
||||
class DupxException extends Exception
|
||||
{
|
||||
/** @var string formatted html string */
|
||||
protected $longMsg = '';
|
||||
/** @var false|array{url: string, label: string} */
|
||||
protected $faqLink = false;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $shortMsg Short message
|
||||
* @param string $longMsg Long message
|
||||
* @param string $faqLinkUrl FAQ link URL
|
||||
* @param string $faqLinkLabel FAQ link label
|
||||
* @param int $code Exception code
|
||||
* @param Exception $previous Previous exception
|
||||
*/
|
||||
public function __construct($shortMsg, $longMsg = '', $faqLinkUrl = '', $faqLinkLabel = '', $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($shortMsg, $code, $previous);
|
||||
$this->longMsg = (string) $longMsg;
|
||||
if (strlen($faqLinkUrl) > 0) {
|
||||
$this->faqLink = array(
|
||||
'url' => $faqLinkUrl,
|
||||
'label' => $faqLinkLabel,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the long message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLongMsg()
|
||||
{
|
||||
return $this->longMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is have faq link
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function haveFaqLink()
|
||||
{
|
||||
return $this->faqLink !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get FAQ URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFaqLinkUrl()
|
||||
{
|
||||
if ($this->haveFaqLink()) {
|
||||
return $this->faqLink['url'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get FAQ label
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFaqLinkLabel()
|
||||
{
|
||||
if ($this->haveFaqLink()) {
|
||||
return $this->faqLink['label'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom string representation of object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$result = __CLASS__ . ": [{$this->code}]: {$this->message}";
|
||||
if ($this->haveFaqLink()) {
|
||||
$result .= "\n\tSee FAQ " . $this->faqLink['label'] . ': ' . $this->faqLink['url'];
|
||||
}
|
||||
if (!empty($this->longMsg)) {
|
||||
$result .= "\n\t" . strip_tags($this->longMsg);
|
||||
}
|
||||
$result .= "\n";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
//silent
|
||||
@@ -0,0 +1,108 @@
|
||||
<?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 = null;
|
||||
/** @var string */
|
||||
protected $mainFolder = null;
|
||||
/** @var null|DUPX_TemplateItem */
|
||||
protected $parent = null;
|
||||
|
||||
/**
|
||||
* 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 ' . __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 = array(), $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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 = null;
|
||||
/** @var DUPX_TemplateItem[] */
|
||||
private $templates = array();
|
||||
/** @var string */
|
||||
private $currentTemplate = null;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 = array(), $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 = array(), $echo = true)
|
||||
{
|
||||
static $tplMng = null;
|
||||
if (is_null($tplMng)) {
|
||||
$tplMng = DUPX_Template::getInstance();
|
||||
}
|
||||
|
||||
return $tplMng->render($fileTpl, $args, $echo);
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
<?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 = null;
|
||||
|
||||
/**
|
||||
* 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: ' . get_called_class() . ']');
|
||||
$this->testResult = $this->runTest();
|
||||
} catch (Exception $e) {
|
||||
Log::logException($e, Log::LV_DEFAULT, ' TEST "' . $this->getTitle() . '" EXCEPTION:');
|
||||
$this->testResult = self::LV_FAIL;
|
||||
} catch (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 ' . get_called_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 ' . get_called_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 ' . get_called_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("_", "-", get_called_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';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
<?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.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 = null;
|
||||
/** @var DUPX_Validation_abstract_item[] */
|
||||
private $tests = array();
|
||||
/** @var array<string, mixed> */
|
||||
private $extraData = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @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_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_tabels_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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$this->runTests();
|
||||
$mainResult = $this->getMainResult();
|
||||
|
||||
$paramsManager = PrmMng::getInstance();
|
||||
$paramsManager->setValue(PrmMng::PARAM_VALIDATION_LEVEL, $mainResult);
|
||||
$paramsManager->save();
|
||||
|
||||
return array(
|
||||
'mainLevel' => $mainResult,
|
||||
'mainBagedClass' => DUPX_Validation_abstract_item::resultLevelToBadgeClass($mainResult),
|
||||
'mainText' => DUPX_Validation_abstract_item::resultLevelToString($mainResult),
|
||||
'categoriesLevels' => array(
|
||||
'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 = array();
|
||||
|
||||
foreach ($this->tests as $test) {
|
||||
$test->test(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gte validation main result
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getValidationHtmlResult()
|
||||
{
|
||||
return dupxTplRender('parts/validation/validation-result', array('validationManager' => $this), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add extra data
|
||||
*
|
||||
* @param string $key data key
|
||||
* @param mixed $value data value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addExtraData($key, $value)
|
||||
{
|
||||
$this->extraData[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category result
|
||||
*
|
||||
* @param string $category category
|
||||
*
|
||||
* @return DUPX_Validation_abstract_item[]
|
||||
*/
|
||||
public function getTestsCategory($category)
|
||||
{
|
||||
$result = array();
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Cpanel connection';
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/cpnl-connection', array(
|
||||
'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', array(
|
||||
'isOk' => true,
|
||||
'cpnlHost' => PrmMng::getInstance()->getValue(PrmMng::PARAM_CPNL_HOST),
|
||||
'cpnlUser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_CPNL_USER),
|
||||
'cpnlPass' => '*****',
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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 = null;
|
||||
|
||||
protected function runTest()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Create Database User';
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/cpnl-create-user', array(
|
||||
'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', array(
|
||||
'isOk' => true,
|
||||
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
|
||||
'dbpass' => '*****',
|
||||
'errorMessage' => '',
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
return 'Tables Flagged for Removal or Backup';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function passContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-affected-tables', array(
|
||||
'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', array(
|
||||
'isOk' => false,
|
||||
'message' => $this->message,
|
||||
'affectedTableCount' => $this->affectedTableCount,
|
||||
'affectedTables' => array_slice($this->affectedTables, 0, self::MAX_DISPLAY_TABLE_COUNT),
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
return 'Tables Case Sensitivity';
|
||||
}
|
||||
|
||||
protected function swarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-case-sensitive-tables', array(
|
||||
'isOk' => false,
|
||||
'errorMessage' => $this->errorMessage,
|
||||
'lowerCaseTableNames' => $this->lowerCaseTableNames,
|
||||
), false);
|
||||
}
|
||||
|
||||
protected function hwarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-case-sensitive-duplicates', array(
|
||||
'lowerCaseTableNames' => $this->lowerCaseTableNames,
|
||||
'duplicateTableNames' => $this->duplicateTables,
|
||||
'reduntantTableNames' => $this->redundantTables,
|
||||
), false);
|
||||
}
|
||||
|
||||
protected function passContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-case-sensitive-tables', array(
|
||||
'isOk' => true,
|
||||
'errorMessage' => $this->errorMessage,
|
||||
'lowerCaseTableNames' => $this->lowerCaseTableNames,
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Database cleanup';
|
||||
}
|
||||
|
||||
protected function hwarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-cleanup', array(
|
||||
'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', array(
|
||||
'isOk' => true,
|
||||
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
|
||||
'isCpanel' => (PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_VIEW_MODE) === 'cpnl'),
|
||||
'errorMessage' => $this->errorMessage,
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Host Connection';
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-connection', array(
|
||||
'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', array(
|
||||
'isOk' => true,
|
||||
'dbhost' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_HOST),
|
||||
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
|
||||
'dbpass' => '*****',
|
||||
'mysqlConnErr' => '',
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Create New Database';
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-create', array(
|
||||
'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', array(
|
||||
'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);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
if (!InstState::dbDoNothing()) {
|
||||
return self::LV_PASS;
|
||||
}
|
||||
|
||||
DUPX_Validation_database_service::getInstance()->setSkipOtherTests();
|
||||
|
||||
return self::LV_SOFT_WARNING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Extract only files';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function swarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-excluded', array(
|
||||
'dbExcluded' => DUPX_ArchiveConfig::getInstance()->isDBExcluded(),
|
||||
'isOk' => false,
|
||||
), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function passContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-excluded', array(
|
||||
'dbExcluded' => false,
|
||||
'isOk' => true,
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Database GTID Mode';
|
||||
}
|
||||
|
||||
protected function swarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-gtid-mode', array(
|
||||
'isOk' => false,
|
||||
'errorMessage' => $this->errorMessage,
|
||||
), false);
|
||||
}
|
||||
|
||||
protected function passContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-gtid-mode', array(
|
||||
'isOk' => true,
|
||||
'errorMessage' => $this->errorMessage,
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Host Name';
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-host-name', array(
|
||||
'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', array(
|
||||
'isOk' => true,
|
||||
'host' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_HOST),
|
||||
'fixedHost' => '',
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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_tabels_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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Manual Table Check';
|
||||
}
|
||||
|
||||
protected function hwarnContent()
|
||||
{
|
||||
return dupxTplRender(
|
||||
'parts/validation/database-tests/db-manual-tables-count',
|
||||
array(
|
||||
'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',
|
||||
array(
|
||||
'isOk' => true,
|
||||
'dbname' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_NAME),
|
||||
'numTables' => $this->numTables,
|
||||
'errorMessage' => $this->errorMessage,
|
||||
),
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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 = array();
|
||||
|
||||
/**
|
||||
* Check mutiple db install in database
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function runTest()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
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', array(
|
||||
'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', array(
|
||||
'isOk' => true,
|
||||
'uniquePrefixes' => $this->uniquePrefixes,
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Prefix too long';
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-prefix-too-long', array(
|
||||
'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', array(
|
||||
'isOk' => true,
|
||||
'errorMessage' => $this->errorMessage,
|
||||
'tooLongNewTableNames' => DUPX_Validation_database_service::getInstance()->getTooLongNewTableNames(),
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return "Privileges: 'Show Variables' Query";
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-show-variables', array('pass' => false), false);
|
||||
}
|
||||
|
||||
protected function passContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-show-variables', array('pass' => true), false);
|
||||
}
|
||||
}
|
||||
@@ -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 = array();
|
||||
/** @var string[] */
|
||||
protected $collationsList = array();
|
||||
/** @var string[] */
|
||||
protected $invalidCharsets = array();
|
||||
/** @var string[] */
|
||||
protected $invalidCollations = array();
|
||||
/** @var mixed[] */
|
||||
protected $extraData = array();
|
||||
|
||||
protected function runTest()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Character Set and Collation Capability';
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
$dbFuncs = DUPX_DB_Functions::getInstance();
|
||||
|
||||
return dupxTplRender('parts/validation/database-tests/db-supported-charset', array(
|
||||
'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();
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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', array(
|
||||
'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();
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Database Engine Support';
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-supported-engine', array(
|
||||
'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();
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Source Database Triggers';
|
||||
}
|
||||
|
||||
protected function passContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-triggers', array(
|
||||
'isOk' => true,
|
||||
'triggers' => DUPX_ArchiveConfig::getInstance()->dbInfo->triggerList,
|
||||
), false);
|
||||
}
|
||||
|
||||
protected function swarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-triggers', array(
|
||||
'isOk' => false,
|
||||
'triggers' => DUPX_ArchiveConfig::getInstance()->dbInfo->triggerList,
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'User created cleanup';
|
||||
}
|
||||
|
||||
protected function hwarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-user-cleanup', array(
|
||||
'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', array(
|
||||
'isOk' => true,
|
||||
'dbuser' => PrmMng::getInstance()->getValue(PrmMng::PARAM_DB_USER),
|
||||
'errorMessage' => $this->errorMessage,
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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, bool> */
|
||||
protected $perms = array();
|
||||
/** @var array<string, bool> */
|
||||
protected $errorMessages = array();
|
||||
|
||||
protected function runTest()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Privileges: User Table Access';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-user-perms', array(
|
||||
'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', array(
|
||||
'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', array(
|
||||
'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', array(
|
||||
'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);
|
||||
}
|
||||
}
|
||||
@@ -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\Libs\Snap\SnapUtil;
|
||||
|
||||
class DUPX_Validation_test_db_user_resources extends DUPX_Validation_abstract_item
|
||||
{
|
||||
/** @var array<string, int|string> */
|
||||
private $userResources = array();
|
||||
/** @var bool */
|
||||
private $userHasRestrictedResource = false;
|
||||
|
||||
protected function runTest()
|
||||
{
|
||||
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, function ($value) {
|
||||
return $value > 0;
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->userHasRestrictedResource) {
|
||||
return self::LV_SOFT_WARNING;
|
||||
}
|
||||
|
||||
return self::LV_PASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Privileges: User Resources';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function passContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-user-resources', array(
|
||||
'isOk' => !$this->userHasRestrictedResource,
|
||||
'userResources' => $this->userResources,
|
||||
), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function swarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-user-resources', array(
|
||||
'isOk' => !$this->userHasRestrictedResource,
|
||||
'userResources' => $this->userResources,
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Database Version';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-version', array(
|
||||
'isOk' => false,
|
||||
'hostDBVersion' => $this->hostDBVersion,
|
||||
), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function swarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-version-swarn', array(
|
||||
'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', array(
|
||||
'isOk' => true,
|
||||
'hostDBVersion' => $this->hostDBVersion,
|
||||
), false);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Privileges: User Visibility';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/database-tests/db-visibility', array(
|
||||
'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', array(
|
||||
'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);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
$list = self::getAddonsListsFolders();
|
||||
|
||||
if (PrmMng::getInstance()->getValue(PrmMng::PARAM_ARCHIVE_ACTION) === DUP_PRO_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()
|
||||
{
|
||||
return 'Addon Sites';
|
||||
}
|
||||
|
||||
protected function swarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/tests/addon-sites', array(
|
||||
'testResult' => $this->testResult,
|
||||
'pathsList' => self::getAddonsListsFolders(),
|
||||
), false);
|
||||
}
|
||||
|
||||
protected function goodContent()
|
||||
{
|
||||
return $this->swarnContent();
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
if (DUPX_Conf_Utils::archiveExists()) {
|
||||
return self::LV_PASS;
|
||||
} else {
|
||||
return self::LV_SOFT_WARNING;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Archive Check';
|
||||
}
|
||||
|
||||
protected function failContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/tests/archive-check', array(
|
||||
'testResult' => $this->testResult,
|
||||
), false);
|
||||
}
|
||||
|
||||
protected function swarnContent()
|
||||
{
|
||||
return $this->failContent();
|
||||
}
|
||||
|
||||
protected function passContent()
|
||||
{
|
||||
return $this->failContent();
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
return 'Database Only';
|
||||
}
|
||||
|
||||
protected function swarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/tests/dbonly-iswordpress', array(), false);
|
||||
}
|
||||
|
||||
protected function goodContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/tests/dbonly-iswordpress', array(), false);
|
||||
}
|
||||
}
|
||||
@@ -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\InstState;
|
||||
use Duplicator\Installer\Core\Params\PrmMng;
|
||||
use Duplicator\Installer\Models\ScanInfo;
|
||||
use Duplicator\Libs\Snap\SnapIO;
|
||||
|
||||
class DUPX_Validation_test_disk_space extends DUPX_Validation_abstract_item
|
||||
{
|
||||
/** @var int */
|
||||
private $freeSpace = 0;
|
||||
/** @var int */
|
||||
private $archiveSize = 0;
|
||||
/** @var int */
|
||||
private $extractedSize = 0;
|
||||
|
||||
protected function runTest()
|
||||
{
|
||||
if (!function_exists('disk_free_space') || InstState::isRecoveryMode()) {
|
||||
return self::LV_SKIP;
|
||||
}
|
||||
|
||||
// if home path is root path is necessary do a trailingslashit
|
||||
$realPath = SnapIO::safePathTrailingslashit(PrmMng::getInstance()->getValue(PrmMng::PARAM_PATH_NEW));
|
||||
$this->freeSpace = (int) @disk_free_space($realPath);
|
||||
$this->archiveSize = DUPX_Conf_Utils::archiveExists() ? DUPX_Conf_Utils::archiveSize() : 1;
|
||||
$this->extractedSize = ScanInfo::getInstance()->getUSize();
|
||||
|
||||
if ($this->freeSpace && $this->archiveSize > 0 && $this->freeSpace > ($this->extractedSize + $this->archiveSize)) {
|
||||
return self::LV_GOOD;
|
||||
} else {
|
||||
return self::LV_SOFT_WARNING;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Disk Space';
|
||||
}
|
||||
|
||||
protected function swarnContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/tests/diskspace', array(
|
||||
'freeSpace' => DUPX_U::readableByteSize($this->freeSpace),
|
||||
'requiredSpace' => DUPX_U::readableByteSize($this->archiveSize + $this->extractedSize),
|
||||
'isOk' => false,
|
||||
), false);
|
||||
}
|
||||
|
||||
protected function goodContent()
|
||||
{
|
||||
return dupxTplRender('parts/validation/tests/diskspace', array(
|
||||
'freeSpace' => DUPX_U::readableByteSize($this->freeSpace),
|
||||
'requiredSpace' => DUPX_U::readableByteSize($this->archiveSize + $this->extractedSize),
|
||||
'isOk' => true,
|
||||
), false);
|
||||
}
|
||||
}
|
||||