From: Ludovic CHEVALIER Date: Fri, 29 Jun 2018 10:03:43 +0000 (+0200) Subject: [SPIP] ~connexion mysql par socket X-Git-Tag: v3.3.0~41 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=d558cda864e3f858792fd87c23580e9c82df9711;hp=0f3ef482e6020c572ea3221db6ab5165772c22e9;p=lhc%2Fweb%2Fwww.git [SPIP] ~connexion mysql par socket https://core.spip.net/projects/spip/repository/revisions/24013 --- diff --git a/www/ecrire/req/mysql.php b/www/ecrire/req/mysql.php index 593b9e78..490dcf73 100644 --- a/www/ecrire/req/mysql.php +++ b/www/ecrire/req/mysql.php @@ -3,7 +3,7 @@ /* *************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2017 * + * Copyright (c) 2001-2018 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -44,9 +44,17 @@ function req_mysql_dist($host, $port, $login, $pass, $db = '', $prefixe = '') { if (!charger_php_extension('mysqli')) { return false; } - if ($port) { + + // si port est fourni mais pas host, c'est un socket -> compat avec vieille syntaxe de mysql_connect() et anciens fichiers connect.php + if ( + $port and !is_numeric($socket = $port) + and (!$host or $host=='localhost')) { + $link = @mysqli_connect($host, $login, $pass, '', null, $socket); + } + elseif ($port) { $link = @mysqli_connect($host, $login, $pass, '', $port); - } else { + } + else { $link = @mysqli_connect($host, $login, $pass); }