/* *************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
- * Copyright (c) 2001-2017 *
+ * Copyright (c) 2001-2019 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
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);
}
* Expression SQL
**/
function spip_mysql_date_proche($champ, $interval, $unite) {
+ $use_now = ( ($champ === 'maj' or strpos($champ, '.maj')) ? true : false );
return '('
. $champ
. (($interval <= 0) ? '>' : '<')
. (($interval <= 0) ? 'DATE_SUB' : 'DATE_ADD')
. '('
- . sql_quote(date('Y-m-d H:i:s'))
+ . ($use_now ? 'NOW()' : sql_quote(date('Y-m-d H:i:s')))
. ', INTERVAL '
. (($interval > 0) ? $interval : (0 - $interval))
. ' '