gpt4 book ai didi

php - Joomla 无法连接到启用 SSL 的数据库

转载 作者:行者123 更新时间:2023-11-29 02:48:48 25 4
gpt4 key购买 nike

我使用的是最新版本的 Joomla v3.6,我很惊讶地发现不支持通过 SSL 连接到 MySQL 数据库。

看起来需要破解核心 Joomla 数据库驱动程序文件:/libraries/joomla/database/driver/mysqli.php

更令人沮丧的是,这个文件似乎使用了 mysqli_connect(),据我所知,它没有内置对 SSL 连接的支持,因此它不会像添加几个属性那样简单。

在我开始黑客攻击之前,有没有人使用 Joomla 成功连接到安全数据库?是否有我不知道的其他驱动程序?

我在这里包含了完整的 Joomla DB 连接功能以供引用:

public function connect()
{
if ($this->connection)
{
return;
}

/*
* Unlike mysql_connect(), mysqli_connect() takes the port and socket as separate arguments. Therefore, we
* have to extract them from the host string.
*/
$port = isset($this->options['port']) ? $this->options['port'] : 3306;
$regex = '/^(?P<host>((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:(?P<port>.+))?$/';

if (preg_match($regex, $this->options['host'], $matches))
{
// It's an IPv4 address with or without port
$this->options['host'] = $matches['host'];

if (!empty($matches['port']))
{
$port = $matches['port'];
}
}
elseif (preg_match('/^(?P<host>\[.*\])(:(?P<port>.+))?$/', $this->options['host'], $matches))
{
// We assume square-bracketed IPv6 address with or without port, e.g. [fe80:102::2%eth1]:3306
$this->options['host'] = $matches['host'];

if (!empty($matches['port']))
{
$port = $matches['port'];
}
}
elseif (preg_match('/^(?P<host>(\w+:\/{2,3})?[a-z0-9\.\-]+)(:(?P<port>[^:]+))?$/i', $this->options['host'], $matches))
{
// Named host (e.g example.com or localhost) with or without port
$this->options['host'] = $matches['host'];

if (!empty($matches['port']))
{
$port = $matches['port'];
}
}
elseif (preg_match('/^:(?P<port>[^:]+)$/', $this->options['host'], $matches))
{
// Empty host, just port, e.g. ':3306'
$this->options['host'] = 'localhost';
$port = $matches['port'];
}
// ... else we assume normal (naked) IPv6 address, so host and port stay as they are or default

// Get the port number or socket name
if (is_numeric($port))
{
$this->options['port'] = (int) $port;
}
else
{
$this->options['socket'] = $port;
}

// Make sure the MySQLi extension for PHP is installed and enabled.
if (!self::isSupported())
{
throw new JDatabaseExceptionUnsupported('The MySQL adapter mysqli is not available');
}

$this->connection = @mysqli_connect(
$this->options['host'], $this->options['user'], $this->options['password'], null, $this->options['port'], $this->options['socket']
);

// Attempt to connect to the server.
if (!$this->connection)
{
throw new JDatabaseExceptionConnecting('Could not connect to MySQL.');
}

// Set sql_mode to non_strict mode
mysqli_query($this->connection, "SET @@SESSION.sql_mode = '';");

// If auto-select is enabled select the given database.
if ($this->options['select'] && !empty($this->options['database']))
{
$this->select($this->options['database']);
}

// Pre-populate the UTF-8 Multibyte compatibility flag based on server version
$this->utf8mb4 = $this->serverClaimsUtf8mb4Support();

// Set the character set (needed for MySQL 4.1.2+).
$this->utf = $this->setUtf();

// Turn MySQL profiling ON in debug mode:
if ($this->debug && $this->hasProfiling())
{
mysqli_query($this->connection, "SET profiling_history_size = 100;");
mysqli_query($this->connection, "SET profiling = 1;");
}
}

最佳答案

您的问题的解决方案是 MySQL ssh 隧道。如果您这样做,那么您将不必修改 Joomla 核心中的任何内容。请参阅:http://chxo.com/be2/20040511_5667.html

关于php - Joomla 无法连接到启用 SSL 的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38443333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com