Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/MWP/Incremen.../Database
File: Configuration.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* This file is part of the ManageWP Worker plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* (c) ManageWP LLC <contact@managewp.com>
[4] Fix | Delete
*
[5] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[6] Fix | Delete
* file that was distributed with this source code.
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
class MWP_IncrementalBackup_Database_Configuration
[10] Fix | Delete
{
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* @var string
[14] Fix | Delete
*/
[15] Fix | Delete
private $username;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* @var string
[19] Fix | Delete
*/
[20] Fix | Delete
private $password;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* @var string
[24] Fix | Delete
*/
[25] Fix | Delete
private $database;
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* @var bool
[29] Fix | Delete
*/
[30] Fix | Delete
private $socket;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* @var string|null
[34] Fix | Delete
*/
[35] Fix | Delete
private $host;
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* @var string|null
[39] Fix | Delete
*/
[40] Fix | Delete
private $socketPath;
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* @var string
[44] Fix | Delete
*/
[45] Fix | Delete
private $charset = 'utf8';
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* @var int
[49] Fix | Delete
*/
[50] Fix | Delete
private $port;
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* @param array $parameters
[54] Fix | Delete
*/
[55] Fix | Delete
public function __construct(array $parameters = array())
[56] Fix | Delete
{
[57] Fix | Delete
if (isset($parameters['username'])) {
[58] Fix | Delete
$this->username = $parameters['username'];
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
if (isset($parameters['password'])) {
[62] Fix | Delete
$this->password = $parameters['password'];
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
if (isset($parameters['socket'])) {
[66] Fix | Delete
$this->socket = true;
[67] Fix | Delete
$this->socketPath = $parameters['socket'];
[68] Fix | Delete
} elseif (isset($parameters['host'])) {
[69] Fix | Delete
$this->socket = false;
[70] Fix | Delete
$this->host = $parameters['host'];
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
if (isset($parameters['port'])) {
[74] Fix | Delete
$this->port = $parameters['port'];
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
if (isset($parameters['database'])) {
[78] Fix | Delete
$this->database = $parameters['database'];
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
if (isset($parameters['charset'])) {
[82] Fix | Delete
$this->charset = $parameters['charset'];
[83] Fix | Delete
}
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* @return string|null
[88] Fix | Delete
*/
[89] Fix | Delete
public function getHost()
[90] Fix | Delete
{
[91] Fix | Delete
return $this->host;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* @return string|null
[96] Fix | Delete
*/
[97] Fix | Delete
public function getSocketPath()
[98] Fix | Delete
{
[99] Fix | Delete
return $this->socketPath;
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* @return int
[104] Fix | Delete
*/
[105] Fix | Delete
public function getPort()
[106] Fix | Delete
{
[107] Fix | Delete
return $this->port;
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* @return boolean
[112] Fix | Delete
*/
[113] Fix | Delete
public function isSocket()
[114] Fix | Delete
{
[115] Fix | Delete
return $this->socket;
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* @return string
[120] Fix | Delete
*/
[121] Fix | Delete
public function getUsername()
[122] Fix | Delete
{
[123] Fix | Delete
return $this->username;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* @return string
[128] Fix | Delete
*/
[129] Fix | Delete
public function getPassword()
[130] Fix | Delete
{
[131] Fix | Delete
return $this->password;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
/**
[135] Fix | Delete
* @return string
[136] Fix | Delete
*/
[137] Fix | Delete
public function getDatabase()
[138] Fix | Delete
{
[139] Fix | Delete
return $this->database;
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
/**
[143] Fix | Delete
* @return string
[144] Fix | Delete
*/
[145] Fix | Delete
public function getCharset()
[146] Fix | Delete
{
[147] Fix | Delete
return $this->charset;
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
public static function createFromWordPressContext(MWP_WordPress_Context $context)
[151] Fix | Delete
{
[152] Fix | Delete
return self::createFromArray(array(
[153] Fix | Delete
'username' => $context->getConstant('DB_USER'),
[154] Fix | Delete
'password' => $context->getConstant('DB_PASSWORD'),
[155] Fix | Delete
'database' => $context->getConstant('DB_NAME'),
[156] Fix | Delete
'host' => $context->getConstant('DB_HOST'),
[157] Fix | Delete
'charset' => $context->hasConstant('DB_CHARSET') ? $context->getConstant('DB_CHARSET') : 'utf8',
[158] Fix | Delete
));
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
/**
[162] Fix | Delete
* $parameters array should contain:
[163] Fix | Delete
* - username: mysql username
[164] Fix | Delete
* - password: mysql password
[165] Fix | Delete
* - database: database name
[166] Fix | Delete
* - host: host - can contain port or be a mysql socket
[167] Fix | Delete
*/
[168] Fix | Delete
public static function createFromArray(array $parameters = array())
[169] Fix | Delete
{
[170] Fix | Delete
$configuration = array(
[171] Fix | Delete
'username' => isset($parameters['username']) ? $parameters['username'] : null,
[172] Fix | Delete
'password' => isset($parameters['password']) ? $parameters['password'] : null,
[173] Fix | Delete
'database' => $parameters['database'],
[174] Fix | Delete
);
[175] Fix | Delete
[176] Fix | Delete
$databaseHost = $parameters['host'];
[177] Fix | Delete
[178] Fix | Delete
$port = 0;
[179] Fix | Delete
$host = $databaseHost;
[180] Fix | Delete
[181] Fix | Delete
// Handle localhost:3306 cases
[182] Fix | Delete
if (strpos($databaseHost, ':') !== false) {
[183] Fix | Delete
list($host, $port) = explode(':', $databaseHost);
[184] Fix | Delete
$port = (int) $port;
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
// Database host can be a path to mysql socket
[188] Fix | Delete
if (strpos($databaseHost, '/') !== false || strpos($databaseHost, '\\') !== false) {
[189] Fix | Delete
$socket = end(explode(':', $databaseHost));
[190] Fix | Delete
[191] Fix | Delete
$configuration['socket'] = $socket;
[192] Fix | Delete
} else {
[193] Fix | Delete
$configuration['host'] = $host;
[194] Fix | Delete
if (!empty($port)) {
[195] Fix | Delete
$configuration['port'] = $port;
[196] Fix | Delete
}
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
if (isset($parameters['charset'])) {
[200] Fix | Delete
$configuration['charset'] = $parameters['charset'];
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
return new MWP_IncrementalBackup_Database_Configuration($configuration);
[204] Fix | Delete
}
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function