[SPIP] ~v3.2.4-->v3.2.5
[lhc/web/www.git] / www / ecrire / inc / utils.php
index 1e5375f..22c0c32 100644 (file)
@@ -3,7 +3,7 @@
 /***************************************************************************\
  *  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.     *
@@ -687,7 +687,7 @@ function self($amp = '&', $root = false) {
        include_spip('inc/filtres_mini');
        $url = spip_htmlspecialchars($url);
        
-       $url = str_replace(array("'", '"', '<', '[', ']'), array('%27', '%22', '%3C', '%5B', '%5D'), $url);
+       $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url);
 
        // &amp; ?
        if ($amp != '&amp;') {
@@ -836,7 +836,7 @@ function _L($text, $args = array(), $options = array()) {
                $options = $defaut_options;
        }
 
-       if (is_array($args)) {
+       if (is_array($args) and count($args)) {
                if (!function_exists('interdire_scripts')) {
                        include_spip('inc/texte');
                }
@@ -1641,14 +1641,24 @@ function find_all_in_path($dir, $pattern, $recurs = false) {
 
 /**
  * PrĂ©dicat sur les scripts de ecrire qui n'authentifient pas par cookie
+ * et beneficient d'une exception
+ *
  * @param string $nom
+ * @param bool $strict
  * @return bool
  */
-function autoriser_sans_cookie($nom) {
+function autoriser_sans_cookie($nom, $strict = false) {
        static $autsanscookie = array('install', 'base_repair');
-       $nom = preg_replace('/.php[3]?$/', '', basename($nom));
 
-       return in_array($nom, $autsanscookie);
+       if (in_array($nom, $autsanscookie)) {
+               if (test_espace_prive()){
+                       include_spip('base/connect_sql');
+                       if (!$strict or !spip_connect()){
+                               return true;
+                       }
+               }
+       }
+       return false;
 }
 
 /**
@@ -2567,7 +2577,7 @@ function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null
 
                        if (isset($GLOBALS['meta']['adresse_site'])) {
                                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
-                               $uri_ref = $uri_ref['path'] . '/';
+                               $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
                        } else {
                                $uri_ref = "";
                        }
@@ -2812,8 +2822,8 @@ function init_var_mode() {
                                } elseif (in_array('calcul', $var_mode)) {
                                        define('_VAR_MODE', 'calcul');
                                }
-                               $var_mode = array_diff($var_mode, array('calcul', 'recalcul'));
                        }
+                       $var_mode = array_diff($var_mode, array('calcul', 'recalcul'));
                        if ($var_mode) {
                                include_spip('inc/autoriser');
                                // autoriser preview si preview seulement, et sinon autoriser debug