@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | if (defined('_TEST_DIRS')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | define('_TEST_DIRS', '1'); |
| 21 | 21 | |
@@ -26,42 +26,42 @@ discard block |
||
| 26 | 26 | // Tente d'ecrire |
| 27 | 27 | // |
| 28 | 28 | function test_ecrire($my_dir) { |
| 29 | - static $chmod = 0; |
|
| 30 | - |
|
| 31 | - $ok = false; |
|
| 32 | - $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 33 | - $self = basename($script); |
|
| 34 | - $uid = @fileowner('.'); |
|
| 35 | - $uid2 = @fileowner($self); |
|
| 36 | - $gid = @filegroup('.'); |
|
| 37 | - $gid2 = @filegroup($self); |
|
| 38 | - $perms = @fileperms($self); |
|
| 39 | - |
|
| 40 | - // Comparer l'appartenance d'un fichier cree par PHP |
|
| 41 | - // avec celle du script et du repertoire courant |
|
| 42 | - if (!$chmod) { |
|
| 43 | - @rmdir('test'); |
|
| 44 | - spip_unlink('test'); // effacer au cas ou |
|
| 45 | - @touch('test'); |
|
| 46 | - if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 47 | - $chmod = 0700; |
|
| 48 | - } else { |
|
| 49 | - if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 50 | - $chmod = 0770; |
|
| 51 | - } else { |
|
| 52 | - $chmod = 0777; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - // Appliquer de plus les droits d'acces du script |
|
| 56 | - if ($perms > 0) { |
|
| 57 | - $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 58 | - $chmod |= $perms; |
|
| 59 | - } |
|
| 60 | - spip_unlink('test'); |
|
| 61 | - } |
|
| 62 | - $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 63 | - |
|
| 64 | - return $ok ? $chmod : false; |
|
| 29 | + static $chmod = 0; |
|
| 30 | + |
|
| 31 | + $ok = false; |
|
| 32 | + $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 33 | + $self = basename($script); |
|
| 34 | + $uid = @fileowner('.'); |
|
| 35 | + $uid2 = @fileowner($self); |
|
| 36 | + $gid = @filegroup('.'); |
|
| 37 | + $gid2 = @filegroup($self); |
|
| 38 | + $perms = @fileperms($self); |
|
| 39 | + |
|
| 40 | + // Comparer l'appartenance d'un fichier cree par PHP |
|
| 41 | + // avec celle du script et du repertoire courant |
|
| 42 | + if (!$chmod) { |
|
| 43 | + @rmdir('test'); |
|
| 44 | + spip_unlink('test'); // effacer au cas ou |
|
| 45 | + @touch('test'); |
|
| 46 | + if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 47 | + $chmod = 0700; |
|
| 48 | + } else { |
|
| 49 | + if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 50 | + $chmod = 0770; |
|
| 51 | + } else { |
|
| 52 | + $chmod = 0777; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + // Appliquer de plus les droits d'acces du script |
|
| 56 | + if ($perms > 0) { |
|
| 57 | + $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 58 | + $chmod |= $perms; |
|
| 59 | + } |
|
| 60 | + spip_unlink('test'); |
|
| 61 | + } |
|
| 62 | + $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 63 | + |
|
| 64 | + return $ok ? $chmod : false; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // |
@@ -71,84 +71,84 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | function install_etape_chmod_dist() { |
| 73 | 73 | |
| 74 | - $continuer = null; |
|
| 75 | - $test_dir = _request('test_dir'); |
|
| 76 | - $chmod = 0; |
|
| 77 | - |
|
| 78 | - if ($test_dir and strpos($test_dir, '..') === false) { |
|
| 79 | - if (substr($test_dir, -1) !== '/') { |
|
| 80 | - $test_dir .= '/'; |
|
| 81 | - } |
|
| 82 | - if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 83 | - $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 84 | - } |
|
| 85 | - } else { |
|
| 86 | - if (!_FILE_CONNECT) { |
|
| 87 | - $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 88 | - $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - $bad_dirs = []; |
|
| 93 | - $absent_dirs = []; |
|
| 94 | - |
|
| 95 | - foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 96 | - $test = test_ecrire($my_dir); |
|
| 97 | - if (!$test) { |
|
| 98 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 99 | - if (@file_exists($my_dir)) { |
|
| 100 | - $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 101 | - } else { |
|
| 102 | - $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 103 | - } |
|
| 104 | - } else { |
|
| 105 | - $chmod = max($chmod, $test); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - if ($bad_dirs or $absent_dirs) { |
|
| 110 | - if (!_FILE_CONNECT) { |
|
| 111 | - $titre = _T('dirs_preliminaire'); |
|
| 112 | - $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 113 | - } else { |
|
| 114 | - $titre = _T('dirs_probleme_droits'); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 119 | - |
|
| 120 | - if ($bad_dirs) { |
|
| 121 | - $res .= |
|
| 122 | - _T( |
|
| 123 | - 'dirs_repertoires_suivants', |
|
| 124 | - ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
|
| 125 | - ) . |
|
| 126 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - if ($absent_dirs) { |
|
| 130 | - $res .= |
|
| 131 | - _T( |
|
| 132 | - 'dirs_repertoires_absents', |
|
| 133 | - ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
|
| 134 | - ) . |
|
| 135 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 136 | - } |
|
| 137 | - $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 138 | - |
|
| 139 | - $t = _T('login_recharger'); |
|
| 140 | - $t = (!$test_dir ? '' : |
|
| 141 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 142 | - . "<input type='hidden' name='etape' value='chmod' />" |
|
| 143 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 144 | - |
|
| 145 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 146 | - } else { |
|
| 147 | - $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 148 | - if (!$deja) { |
|
| 149 | - redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 150 | - } else { |
|
| 151 | - redirige_url_ecrire(); |
|
| 152 | - } |
|
| 153 | - } |
|
| 74 | + $continuer = null; |
|
| 75 | + $test_dir = _request('test_dir'); |
|
| 76 | + $chmod = 0; |
|
| 77 | + |
|
| 78 | + if ($test_dir and strpos($test_dir, '..') === false) { |
|
| 79 | + if (substr($test_dir, -1) !== '/') { |
|
| 80 | + $test_dir .= '/'; |
|
| 81 | + } |
|
| 82 | + if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 83 | + $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 84 | + } |
|
| 85 | + } else { |
|
| 86 | + if (!_FILE_CONNECT) { |
|
| 87 | + $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 88 | + $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + $bad_dirs = []; |
|
| 93 | + $absent_dirs = []; |
|
| 94 | + |
|
| 95 | + foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 96 | + $test = test_ecrire($my_dir); |
|
| 97 | + if (!$test) { |
|
| 98 | + $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 99 | + if (@file_exists($my_dir)) { |
|
| 100 | + $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 101 | + } else { |
|
| 102 | + $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 103 | + } |
|
| 104 | + } else { |
|
| 105 | + $chmod = max($chmod, $test); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + if ($bad_dirs or $absent_dirs) { |
|
| 110 | + if (!_FILE_CONNECT) { |
|
| 111 | + $titre = _T('dirs_preliminaire'); |
|
| 112 | + $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 113 | + } else { |
|
| 114 | + $titre = _T('dirs_probleme_droits'); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 119 | + |
|
| 120 | + if ($bad_dirs) { |
|
| 121 | + $res .= |
|
| 122 | + _T( |
|
| 123 | + 'dirs_repertoires_suivants', |
|
| 124 | + ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
|
| 125 | + ) . |
|
| 126 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + if ($absent_dirs) { |
|
| 130 | + $res .= |
|
| 131 | + _T( |
|
| 132 | + 'dirs_repertoires_absents', |
|
| 133 | + ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
|
| 134 | + ) . |
|
| 135 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 136 | + } |
|
| 137 | + $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 138 | + |
|
| 139 | + $t = _T('login_recharger'); |
|
| 140 | + $t = (!$test_dir ? '' : |
|
| 141 | + "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 142 | + . "<input type='hidden' name='etape' value='chmod' />" |
|
| 143 | + . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 144 | + |
|
| 145 | + echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 146 | + } else { |
|
| 147 | + $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 148 | + if (!$deja) { |
|
| 149 | + redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 150 | + } else { |
|
| 151 | + redirige_url_ecrire(); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | 154 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -52,68 +52,68 @@ discard block |
||
| 52 | 52 | * cookie sécurisé ou non ? |
| 53 | 53 | **/ |
| 54 | 54 | function spip_setcookie($name = '', $value = '', $options = []) { |
| 55 | - static $to_secure_list = ['spip_session']; |
|
| 56 | - if (defined('_COOKIE_SECURE_LIST') and is_array(_COOKIE_SECURE_LIST)) { |
|
| 57 | - $to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - if (!is_array($options)) { |
|
| 61 | - // anciens paramètres : |
|
| 62 | - # spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '') |
|
| 63 | - $opt = func_get_args(); |
|
| 64 | - $opt = array_slice($opt, 2); |
|
| 65 | - $options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !); |
|
| 66 | - if (isset($opt[0])) { |
|
| 67 | - $options['expires'] = $opt[0]; |
|
| 68 | - } |
|
| 69 | - if (isset($opt[1])) { |
|
| 70 | - $options['path'] = $opt[1]; |
|
| 71 | - } |
|
| 72 | - if (isset($opt[2])) { |
|
| 73 | - $options['domain'] = $opt[2]; |
|
| 74 | - } |
|
| 75 | - if (isset($opt[3])) { |
|
| 76 | - $options['secure'] = $opt[3]; |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // expires |
|
| 81 | - if (!isset($options['expires'])) { |
|
| 82 | - $options['expires'] = 0; |
|
| 83 | - } |
|
| 84 | - if (!isset($options['path']) or $options['path'] === 'AUTO') { |
|
| 85 | - if (defined('_COOKIE_PATH')) { |
|
| 86 | - $options['path'] = _COOKIE_PATH; |
|
| 87 | - } else { |
|
| 88 | - $options['path'] = preg_replace(',^\w+://[^/]*,', '', url_de_base()); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - if (empty($options['domain']) and defined('_COOKIE_DOMAIN') and _COOKIE_DOMAIN) { |
|
| 92 | - $options['domain'] = _COOKIE_DOMAIN; |
|
| 93 | - } |
|
| 94 | - if (in_array($name, $to_secure_list)) { |
|
| 95 | - if (empty($options['secure']) and defined('_COOKIE_SECURE') and _COOKIE_SECURE) { |
|
| 96 | - $options['secure'] = true; |
|
| 97 | - } |
|
| 98 | - if (empty($options['httponly'])) { |
|
| 99 | - $options['httponly'] = true; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - if (empty($options['samesite'])) { |
|
| 103 | - $options['samesite'] = 'Lax'; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // in fine renommer le prefixe si besoin |
|
| 107 | - if (strpos($name, 'spip_') === 0) { |
|
| 108 | - $name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies"); |
|
| 112 | - $a = @setcookie($name, $value, $options); |
|
| 113 | - |
|
| 114 | - spip_cookie_envoye(true); |
|
| 115 | - |
|
| 116 | - return $a; |
|
| 55 | + static $to_secure_list = ['spip_session']; |
|
| 56 | + if (defined('_COOKIE_SECURE_LIST') and is_array(_COOKIE_SECURE_LIST)) { |
|
| 57 | + $to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + if (!is_array($options)) { |
|
| 61 | + // anciens paramètres : |
|
| 62 | + # spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '') |
|
| 63 | + $opt = func_get_args(); |
|
| 64 | + $opt = array_slice($opt, 2); |
|
| 65 | + $options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !); |
|
| 66 | + if (isset($opt[0])) { |
|
| 67 | + $options['expires'] = $opt[0]; |
|
| 68 | + } |
|
| 69 | + if (isset($opt[1])) { |
|
| 70 | + $options['path'] = $opt[1]; |
|
| 71 | + } |
|
| 72 | + if (isset($opt[2])) { |
|
| 73 | + $options['domain'] = $opt[2]; |
|
| 74 | + } |
|
| 75 | + if (isset($opt[3])) { |
|
| 76 | + $options['secure'] = $opt[3]; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // expires |
|
| 81 | + if (!isset($options['expires'])) { |
|
| 82 | + $options['expires'] = 0; |
|
| 83 | + } |
|
| 84 | + if (!isset($options['path']) or $options['path'] === 'AUTO') { |
|
| 85 | + if (defined('_COOKIE_PATH')) { |
|
| 86 | + $options['path'] = _COOKIE_PATH; |
|
| 87 | + } else { |
|
| 88 | + $options['path'] = preg_replace(',^\w+://[^/]*,', '', url_de_base()); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + if (empty($options['domain']) and defined('_COOKIE_DOMAIN') and _COOKIE_DOMAIN) { |
|
| 92 | + $options['domain'] = _COOKIE_DOMAIN; |
|
| 93 | + } |
|
| 94 | + if (in_array($name, $to_secure_list)) { |
|
| 95 | + if (empty($options['secure']) and defined('_COOKIE_SECURE') and _COOKIE_SECURE) { |
|
| 96 | + $options['secure'] = true; |
|
| 97 | + } |
|
| 98 | + if (empty($options['httponly'])) { |
|
| 99 | + $options['httponly'] = true; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + if (empty($options['samesite'])) { |
|
| 103 | + $options['samesite'] = 'Lax'; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // in fine renommer le prefixe si besoin |
|
| 107 | + if (strpos($name, 'spip_') === 0) { |
|
| 108 | + $name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies"); |
|
| 112 | + $a = @setcookie($name, $value, $options); |
|
| 113 | + |
|
| 114 | + spip_cookie_envoye(true); |
|
| 115 | + |
|
| 116 | + return $a; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | * @return bool |
| 130 | 130 | **/ |
| 131 | 131 | function spip_cookie_envoye($set = '') { |
| 132 | - static $envoye = false; |
|
| 133 | - if ($set) { |
|
| 134 | - $envoye = true; |
|
| 135 | - } |
|
| 132 | + static $envoye = false; |
|
| 133 | + if ($set) { |
|
| 134 | + $envoye = true; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - return $envoye; |
|
| 137 | + return $envoye; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -153,21 +153,21 @@ discard block |
||
| 153 | 153 | * Préfixe des cookies de SPIP |
| 154 | 154 | **/ |
| 155 | 155 | function recuperer_cookies_spip($cookie_prefix) { |
| 156 | - $prefix_long = strlen($cookie_prefix); |
|
| 157 | - |
|
| 158 | - foreach ($_COOKIE as $name => $value) { |
|
| 159 | - if (substr($name, 0, 5) == 'spip_' && substr($name, 0, $prefix_long) != $cookie_prefix) { |
|
| 160 | - unset($_COOKIE[$name]); |
|
| 161 | - unset($GLOBALS[$name]); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - foreach ($_COOKIE as $name => $value) { |
|
| 165 | - if (substr($name, 0, $prefix_long) == $cookie_prefix) { |
|
| 166 | - $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name); |
|
| 167 | - $_COOKIE[$spipname] = $value; |
|
| 168 | - $GLOBALS[$spipname] = $value; |
|
| 169 | - } |
|
| 170 | - } |
|
| 156 | + $prefix_long = strlen($cookie_prefix); |
|
| 157 | + |
|
| 158 | + foreach ($_COOKIE as $name => $value) { |
|
| 159 | + if (substr($name, 0, 5) == 'spip_' && substr($name, 0, $prefix_long) != $cookie_prefix) { |
|
| 160 | + unset($_COOKIE[$name]); |
|
| 161 | + unset($GLOBALS[$name]); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + foreach ($_COOKIE as $name => $value) { |
|
| 165 | + if (substr($name, 0, $prefix_long) == $cookie_prefix) { |
|
| 166 | + $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name); |
|
| 167 | + $_COOKIE[$spipname] = $value; |
|
| 168 | + $GLOBALS[$spipname] = $value; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | |
@@ -186,18 +186,18 @@ discard block |
||
| 186 | 186 | * |
| 187 | 187 | **/ |
| 188 | 188 | function exec_test_ajax_dist() { |
| 189 | - switch (_request('js')) { |
|
| 190 | - // on est appele par <noscript> |
|
| 191 | - case -1: |
|
| 192 | - spip_setcookie('spip_accepte_ajax', -1); |
|
| 193 | - include_spip('inc/headers'); |
|
| 194 | - redirige_par_entete(chemin_image('erreur-xx.svg')); |
|
| 195 | - break; |
|
| 196 | - |
|
| 197 | - // ou par ajax |
|
| 198 | - case 1: |
|
| 199 | - default: |
|
| 200 | - spip_setcookie('spip_accepte_ajax', 1); |
|
| 201 | - break; |
|
| 202 | - } |
|
| 189 | + switch (_request('js')) { |
|
| 190 | + // on est appele par <noscript> |
|
| 191 | + case -1: |
|
| 192 | + spip_setcookie('spip_accepte_ajax', -1); |
|
| 193 | + include_spip('inc/headers'); |
|
| 194 | + redirige_par_entete(chemin_image('erreur-xx.svg')); |
|
| 195 | + break; |
|
| 196 | + |
|
| 197 | + // ou par ajax |
|
| 198 | + case 1: |
|
| 199 | + default: |
|
| 200 | + spip_setcookie('spip_accepte_ajax', 1); |
|
| 201 | + break; |
|
| 202 | + } |
|
| 203 | 203 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | */ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres_boites'); |
@@ -41,25 +41,25 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function parametres_css_prive() { |
| 43 | 43 | |
| 44 | - $args = []; |
|
| 45 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 44 | + $args = []; |
|
| 45 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 51 | 51 | |
| 52 | - $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 52 | + $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 53 | 53 | |
| 54 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | - parse_str($couleurs($c), $c); |
|
| 56 | - $args = array_merge($args, $c); |
|
| 54 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | + parse_str($couleurs($c), $c); |
|
| 56 | + $args = array_merge($args, $c); |
|
| 57 | 57 | |
| 58 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | - $args['var_mode'] = 'recalcul'; |
|
| 60 | - } |
|
| 58 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | + $args['var_mode'] = 'recalcul'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return http_build_query($args); |
|
| 62 | + return http_build_query($args); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -82,91 +82,91 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function chercher_rubrique( |
| 85 | - $titre, |
|
| 86 | - $id_objet, |
|
| 87 | - $id_parent, |
|
| 88 | - $objet, |
|
| 89 | - $id_secteur, |
|
| 90 | - $restreint, |
|
| 91 | - $actionable = false, |
|
| 92 | - $retour_sans_cadre = false |
|
| 85 | + $titre, |
|
| 86 | + $id_objet, |
|
| 87 | + $id_parent, |
|
| 88 | + $objet, |
|
| 89 | + $id_secteur, |
|
| 90 | + $restreint, |
|
| 91 | + $actionable = false, |
|
| 92 | + $retour_sans_cadre = false |
|
| 93 | 93 | ) { |
| 94 | 94 | |
| 95 | - include_spip('inc/autoriser'); |
|
| 96 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 99 | - if (!sql_countsel('spip_rubriques')) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | - |
|
| 105 | - if ($id_parent == 0) { |
|
| 106 | - $logo = 'racine-24.png'; |
|
| 107 | - } elseif ($id_secteur == $id_parent) { |
|
| 108 | - $logo = 'secteur-24.png'; |
|
| 109 | - } else { |
|
| 110 | - $logo = 'rubrique-24.png'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $confirm = ''; |
|
| 114 | - if ($objet == 'rubrique') { |
|
| 115 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | - // confirmation du deplacement |
|
| 117 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | - |
|
| 119 | - if ($contient_breves > 0) { |
|
| 120 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | - $scb = _T( |
|
| 122 | - 'avis_deplacement_rubrique', |
|
| 123 | - [ |
|
| 124 | - 'contient_breves' => $contient_breves, |
|
| 125 | - 'scb' => $scb |
|
| 126 | - ] |
|
| 127 | - ); |
|
| 128 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | - . $scb . |
|
| 131 | - "</label></div></div>\n"; |
|
| 132 | - } else { |
|
| 133 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $form .= $confirm; |
|
| 137 | - if ($actionable) { |
|
| 138 | - if (strpos($form, '<select') !== false) { |
|
| 139 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | - . '</div>'; |
|
| 142 | - } |
|
| 143 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | - $form = generer_action_auteur( |
|
| 146 | - "editer_$objet", |
|
| 147 | - $id_objet, |
|
| 148 | - self(), |
|
| 149 | - $form, |
|
| 150 | - " method='post' class='submit_plongeur'" |
|
| 151 | - ); |
|
| 152 | - } else { |
|
| 153 | - $form = generer_action_auteur( |
|
| 154 | - 'editer_objet', |
|
| 155 | - "$objet/$id_objet", |
|
| 156 | - self(), |
|
| 157 | - $form, |
|
| 158 | - " method='post' class='submit_plongeur'" |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if ($retour_sans_cadre) { |
|
| 164 | - return $form; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - include_spip('inc/presentation'); |
|
| 168 | - |
|
| 169 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 95 | + include_spip('inc/autoriser'); |
|
| 96 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | + if (!sql_countsel('spip_rubriques')) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | + |
|
| 105 | + if ($id_parent == 0) { |
|
| 106 | + $logo = 'racine-24.png'; |
|
| 107 | + } elseif ($id_secteur == $id_parent) { |
|
| 108 | + $logo = 'secteur-24.png'; |
|
| 109 | + } else { |
|
| 110 | + $logo = 'rubrique-24.png'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $confirm = ''; |
|
| 114 | + if ($objet == 'rubrique') { |
|
| 115 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | + // confirmation du deplacement |
|
| 117 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | + |
|
| 119 | + if ($contient_breves > 0) { |
|
| 120 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | + $scb = _T( |
|
| 122 | + 'avis_deplacement_rubrique', |
|
| 123 | + [ |
|
| 124 | + 'contient_breves' => $contient_breves, |
|
| 125 | + 'scb' => $scb |
|
| 126 | + ] |
|
| 127 | + ); |
|
| 128 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | + . $scb . |
|
| 131 | + "</label></div></div>\n"; |
|
| 132 | + } else { |
|
| 133 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $form .= $confirm; |
|
| 137 | + if ($actionable) { |
|
| 138 | + if (strpos($form, '<select') !== false) { |
|
| 139 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | + . '</div>'; |
|
| 142 | + } |
|
| 143 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | + $form = generer_action_auteur( |
|
| 146 | + "editer_$objet", |
|
| 147 | + $id_objet, |
|
| 148 | + self(), |
|
| 149 | + $form, |
|
| 150 | + " method='post' class='submit_plongeur'" |
|
| 151 | + ); |
|
| 152 | + } else { |
|
| 153 | + $form = generer_action_auteur( |
|
| 154 | + 'editer_objet', |
|
| 155 | + "$objet/$id_objet", |
|
| 156 | + self(), |
|
| 157 | + $form, |
|
| 158 | + " method='post' class='submit_plongeur'" |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if ($retour_sans_cadre) { |
|
| 164 | + return $form; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + include_spip('inc/presentation'); |
|
| 168 | + |
|
| 169 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | * @return bool |
| 181 | 181 | */ |
| 182 | 182 | function avoir_visiteurs($past = false, $accepter = true) { |
| 183 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | - return true; |
|
| 185 | - } |
|
| 186 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | - return true; |
|
| 188 | - } |
|
| 189 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | - return true; |
|
| 191 | - } |
|
| 192 | - if (!$past) { |
|
| 193 | - return false; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - return sql_countsel( |
|
| 197 | - 'spip_auteurs', |
|
| 198 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 183 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | + return true; |
|
| 185 | + } |
|
| 186 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 189 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | + return true; |
|
| 191 | + } |
|
| 192 | + if (!$past) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + return sql_countsel( |
|
| 197 | + 'spip_auteurs', |
|
| 198 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 199 | 199 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 200 | - ); |
|
| 200 | + ); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function statuts_articles_visibles($statut_auteur) { |
| 216 | - static $auth = []; |
|
| 217 | - if (!isset($auth[$statut_auteur])) { |
|
| 218 | - $auth[$statut_auteur] = []; |
|
| 219 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | - foreach ($statuts as $s) { |
|
| 221 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | - $auth[$statut_auteur][] = $s; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return $auth[$statut_auteur]; |
|
| 216 | + static $auth = []; |
|
| 217 | + if (!isset($auth[$statut_auteur])) { |
|
| 218 | + $auth[$statut_auteur] = []; |
|
| 219 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | + foreach ($statuts as $s) { |
|
| 221 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | + $auth[$statut_auteur][] = $s; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return $auth[$statut_auteur]; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -238,38 +238,38 @@ discard block |
||
| 238 | 238 | * @return string |
| 239 | 239 | */ |
| 240 | 240 | function traduire_statut_auteur($statut, $attente = '') { |
| 241 | - $plus = ''; |
|
| 242 | - if ($statut == 'nouveau') { |
|
| 243 | - if ($attente) { |
|
| 244 | - $statut = $attente; |
|
| 245 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | - } else { |
|
| 247 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - $recom = [ |
|
| 252 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | - ]; |
|
| 257 | - if (isset($recom[$statut])) { |
|
| 258 | - return $recom[$statut] . $plus; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // retrouver directement par le statut sinon |
|
| 262 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | - if (isset($recom[$t])) { |
|
| 264 | - return $recom[$t] . $plus; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return _T($t) . $plus; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | - // c'est toujours plus informatif que rien du tout |
|
| 272 | - return $statut; |
|
| 241 | + $plus = ''; |
|
| 242 | + if ($statut == 'nouveau') { |
|
| 243 | + if ($attente) { |
|
| 244 | + $statut = $attente; |
|
| 245 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | + } else { |
|
| 247 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + $recom = [ |
|
| 252 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | + ]; |
|
| 257 | + if (isset($recom[$statut])) { |
|
| 258 | + return $recom[$statut] . $plus; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // retrouver directement par le statut sinon |
|
| 262 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | + if (isset($recom[$t])) { |
|
| 264 | + return $recom[$t] . $plus; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return _T($t) . $plus; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | + // c'est toujours plus informatif que rien du tout |
|
| 272 | + return $statut; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -280,29 +280,29 @@ discard block |
||
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | 282 | function afficher_qui_edite($id_objet, $objet): string { |
| 283 | - static $qui = []; |
|
| 284 | - if (isset($qui[$objet][$id_objet])) { |
|
| 285 | - return $qui[$objet][$id_objet]; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - include_spip('inc/config'); |
|
| 289 | - if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | - return $qui[$objet][$id_objet] = ''; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - include_spip('inc/drapeau_edition'); |
|
| 294 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | - if (!$modif) { |
|
| 296 | - return $qui[$objet][$id_objet] = ''; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - include_spip('base/objets'); |
|
| 300 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | - if (isset($infos['texte_signale_edition'])) { |
|
| 302 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 283 | + static $qui = []; |
|
| 284 | + if (isset($qui[$objet][$id_objet])) { |
|
| 285 | + return $qui[$objet][$id_objet]; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + include_spip('inc/config'); |
|
| 289 | + if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | + return $qui[$objet][$id_objet] = ''; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + include_spip('inc/drapeau_edition'); |
|
| 294 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | + if (!$modif) { |
|
| 296 | + return $qui[$objet][$id_objet] = ''; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + include_spip('base/objets'); |
|
| 300 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | + if (isset($infos['texte_signale_edition'])) { |
|
| 302 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -320,53 +320,53 @@ discard block |
||
| 320 | 320 | * @return array |
| 321 | 321 | */ |
| 322 | 322 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 323 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - switch ($quoi) { |
|
| 328 | - case 'redacteurs': |
|
| 329 | - $statut = AUTEURS_MIN_REDAC; |
|
| 330 | - $statut = explode(',', $statut); |
|
| 331 | - if ($en_base) { |
|
| 332 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | - $retire = array_diff($statut, $check); |
|
| 334 | - $statut = array_diff($statut, $retire); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return array_unique($statut); |
|
| 338 | - |
|
| 339 | - case 'visiteurs': |
|
| 340 | - $statut = []; |
|
| 341 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | - $exclus = explode(',', $exclus); |
|
| 343 | - if (!$en_base) { |
|
| 344 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | - } |
|
| 347 | - $s_complement = array_column( |
|
| 348 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | - 'statut' |
|
| 350 | - ); |
|
| 351 | - |
|
| 352 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | - |
|
| 354 | - default: |
|
| 355 | - case 'tous': |
|
| 356 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | - $s_complement = array_column( |
|
| 358 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | - 'statut' |
|
| 360 | - ); |
|
| 361 | - $statut = array_merge($statut, $s_complement); |
|
| 362 | - if ($en_base) { |
|
| 363 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | - $retire = array_diff($statut, $check); |
|
| 365 | - $statut = array_diff($statut, $retire); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - return array_unique($statut); |
|
| 369 | - } |
|
| 323 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + switch ($quoi) { |
|
| 328 | + case 'redacteurs': |
|
| 329 | + $statut = AUTEURS_MIN_REDAC; |
|
| 330 | + $statut = explode(',', $statut); |
|
| 331 | + if ($en_base) { |
|
| 332 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | + $retire = array_diff($statut, $check); |
|
| 334 | + $statut = array_diff($statut, $retire); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return array_unique($statut); |
|
| 338 | + |
|
| 339 | + case 'visiteurs': |
|
| 340 | + $statut = []; |
|
| 341 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | + $exclus = explode(',', $exclus); |
|
| 343 | + if (!$en_base) { |
|
| 344 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | + } |
|
| 347 | + $s_complement = array_column( |
|
| 348 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | + 'statut' |
|
| 350 | + ); |
|
| 351 | + |
|
| 352 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | + |
|
| 354 | + default: |
|
| 355 | + case 'tous': |
|
| 356 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | + $s_complement = array_column( |
|
| 358 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | + 'statut' |
|
| 360 | + ); |
|
| 361 | + $statut = array_merge($statut, $s_complement); |
|
| 362 | + if ($en_base) { |
|
| 363 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | + $retire = array_diff($statut, $check); |
|
| 365 | + $statut = array_diff($statut, $retire); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + return array_unique($statut); |
|
| 369 | + } |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -382,28 +382,28 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 384 | 384 | |
| 385 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | - $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | - ? '' |
|
| 388 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | - |
|
| 390 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | - if ($objet == 'rubrique') { |
|
| 392 | - $id_rubrique = 0; |
|
| 393 | - } else { |
|
| 394 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - return $id_rubrique; |
|
| 385 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | + $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | + ? '' |
|
| 388 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | + |
|
| 390 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | + if ($objet == 'rubrique') { |
|
| 392 | + $id_rubrique = 0; |
|
| 393 | + } else { |
|
| 394 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + return $id_rubrique; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -414,12 +414,12 @@ discard block |
||
| 414 | 414 | * @return string |
| 415 | 415 | */ |
| 416 | 416 | function lien_article_virtuel($virtuel) { |
| 417 | - include_spip('inc/lien'); |
|
| 418 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | - return ''; |
|
| 420 | - } |
|
| 417 | + include_spip('inc/lien'); |
|
| 418 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | + return ''; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - return propre('[->' . $virtuel . ']'); |
|
| 422 | + return propre('[->' . $virtuel . ']'); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -442,11 +442,11 @@ discard block |
||
| 442 | 442 | * @filtre |
| 443 | 443 | */ |
| 444 | 444 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 445 | - include_spip('inc/acces'); |
|
| 446 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 445 | + include_spip('inc/acces'); |
|
| 446 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 447 | 447 | |
| 448 | - $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 448 | + $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | |
@@ -458,76 +458,76 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | function alertes_auteur($id_auteur): string { |
| 460 | 460 | |
| 461 | - $alertes = []; |
|
| 462 | - |
|
| 463 | - if ( |
|
| 464 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | - ) { |
|
| 467 | - include_spip('genie/maintenance'); |
|
| 468 | - if ($msg = message_crash_tables()) { |
|
| 469 | - $alertes[] = $msg; |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - if ( |
|
| 474 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | - ) { |
|
| 479 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | - if ( |
|
| 485 | - $a |
|
| 486 | - and is_array($a = unserialize($a)) |
|
| 487 | - and count($a) |
|
| 488 | - ) { |
|
| 489 | - $update = false; |
|
| 490 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | - $update = true; |
|
| 494 | - } |
|
| 495 | - if (isset($a[''])) { |
|
| 496 | - $alertes = array_merge($alertes, $a['']); |
|
| 497 | - unset($a['']); |
|
| 498 | - $update = true; |
|
| 499 | - } |
|
| 500 | - if ($update) { |
|
| 501 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | - } |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - if ( |
|
| 506 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | - ) { |
|
| 509 | - include_spip('inc/plugin'); |
|
| 510 | - $alertes[] = plugin_donne_erreurs(); |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - $alertes = pipeline( |
|
| 514 | - 'alertes_auteur', |
|
| 515 | - [ |
|
| 516 | - 'args' => [ |
|
| 517 | - 'id_auteur' => $id_auteur, |
|
| 518 | - 'exec' => _request('exec'), |
|
| 519 | - ], |
|
| 520 | - 'data' => $alertes |
|
| 521 | - ] |
|
| 522 | - ); |
|
| 523 | - |
|
| 524 | - if ($alertes = array_filter($alertes)) { |
|
| 525 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | - join(' | ', $alertes) |
|
| 527 | - . '</div></div>'; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return ''; |
|
| 461 | + $alertes = []; |
|
| 462 | + |
|
| 463 | + if ( |
|
| 464 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | + ) { |
|
| 467 | + include_spip('genie/maintenance'); |
|
| 468 | + if ($msg = message_crash_tables()) { |
|
| 469 | + $alertes[] = $msg; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + if ( |
|
| 474 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | + ) { |
|
| 479 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | + if ( |
|
| 485 | + $a |
|
| 486 | + and is_array($a = unserialize($a)) |
|
| 487 | + and count($a) |
|
| 488 | + ) { |
|
| 489 | + $update = false; |
|
| 490 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | + $update = true; |
|
| 494 | + } |
|
| 495 | + if (isset($a[''])) { |
|
| 496 | + $alertes = array_merge($alertes, $a['']); |
|
| 497 | + unset($a['']); |
|
| 498 | + $update = true; |
|
| 499 | + } |
|
| 500 | + if ($update) { |
|
| 501 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | + } |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + if ( |
|
| 506 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | + ) { |
|
| 509 | + include_spip('inc/plugin'); |
|
| 510 | + $alertes[] = plugin_donne_erreurs(); |
|
| 511 | + } |
|
| 512 | + |
|
| 513 | + $alertes = pipeline( |
|
| 514 | + 'alertes_auteur', |
|
| 515 | + [ |
|
| 516 | + 'args' => [ |
|
| 517 | + 'id_auteur' => $id_auteur, |
|
| 518 | + 'exec' => _request('exec'), |
|
| 519 | + ], |
|
| 520 | + 'data' => $alertes |
|
| 521 | + ] |
|
| 522 | + ); |
|
| 523 | + |
|
| 524 | + if ($alertes = array_filter($alertes)) { |
|
| 525 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | + join(' | ', $alertes) |
|
| 527 | + . '</div></div>'; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + return ''; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -537,9 +537,9 @@ discard block |
||
| 537 | 537 | * @return string |
| 538 | 538 | */ |
| 539 | 539 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 540 | - include_spip('inc/presenter_enfants'); |
|
| 540 | + include_spip('inc/presenter_enfants'); |
|
| 541 | 541 | |
| 542 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 542 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -557,15 +557,15 @@ discard block |
||
| 557 | 557 | * @return string |
| 558 | 558 | */ |
| 559 | 559 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 560 | - $titre = attribut_html($titre); |
|
| 561 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | - |
|
| 564 | - if (!$titre_lien) { |
|
| 565 | - return $icone; |
|
| 566 | - } else { |
|
| 567 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | - } |
|
| 560 | + $titre = attribut_html($titre); |
|
| 561 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | + |
|
| 564 | + if (!$titre_lien) { |
|
| 565 | + return $icone; |
|
| 566 | + } else { |
|
| 567 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | + } |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | |
@@ -584,22 +584,22 @@ discard block |
||
| 584 | 584 | * @return array |
| 585 | 585 | */ |
| 586 | 586 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 587 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | - return []; |
|
| 590 | - } |
|
| 591 | - $r = reset($res); |
|
| 592 | - if (isset($r['rang_lien'])) { |
|
| 593 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | - asort($l); |
|
| 595 | - $l = array_keys($l); |
|
| 596 | - } else { |
|
| 597 | - // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | - // Sinon c'est dans "id_objet" |
|
| 599 | - $l = array_column( |
|
| 600 | - $res, |
|
| 601 | - $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | - ); |
|
| 603 | - } |
|
| 604 | - return $l; |
|
| 587 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | + return []; |
|
| 590 | + } |
|
| 591 | + $r = reset($res); |
|
| 592 | + if (isset($r['rang_lien'])) { |
|
| 593 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | + asort($l); |
|
| 595 | + $l = array_keys($l); |
|
| 596 | + } else { |
|
| 597 | + // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | + // Sinon c'est dans "id_objet" |
|
| 599 | + $l = array_column( |
|
| 600 | + $res, |
|
| 601 | + $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | + ); |
|
| 603 | + } |
|
| 604 | + return $l; |
|
| 605 | 605 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Fichier |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -36,28 +36,28 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | function spip_livrer_fichier($fichier, $content_type = 'application/octet-stream', $options = []) { |
| 38 | 38 | |
| 39 | - $defaut = [ |
|
| 40 | - 'attachment' => false, |
|
| 41 | - 'expires' => 3600, |
|
| 42 | - 'range' => null |
|
| 43 | - ]; |
|
| 44 | - $options = array_merge($defaut, $options); |
|
| 45 | - if (is_numeric($options['expires']) and $options['expires'] > 0) { |
|
| 46 | - $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - if (is_null($options) and isset($_SERVER['HTTP_RANGE'])) { |
|
| 50 | - $options['range'] = $_SERVER['HTTP_RANGE']; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - spip_livrer_fichier_entetes($fichier, $content_type, $options['attachment'] && !$options['range'], $options['expires']); |
|
| 54 | - |
|
| 55 | - if (!is_null($options['range'])) { |
|
| 56 | - spip_livrer_fichier_partie($fichier, $options['range']); |
|
| 57 | - } |
|
| 58 | - else { |
|
| 59 | - spip_livrer_fichier_entier($fichier); |
|
| 60 | - } |
|
| 39 | + $defaut = [ |
|
| 40 | + 'attachment' => false, |
|
| 41 | + 'expires' => 3600, |
|
| 42 | + 'range' => null |
|
| 43 | + ]; |
|
| 44 | + $options = array_merge($defaut, $options); |
|
| 45 | + if (is_numeric($options['expires']) and $options['expires'] > 0) { |
|
| 46 | + $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + if (is_null($options) and isset($_SERVER['HTTP_RANGE'])) { |
|
| 50 | + $options['range'] = $_SERVER['HTTP_RANGE']; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + spip_livrer_fichier_entetes($fichier, $content_type, $options['attachment'] && !$options['range'], $options['expires']); |
|
| 54 | + |
|
| 55 | + if (!is_null($options['range'])) { |
|
| 56 | + spip_livrer_fichier_partie($fichier, $options['range']); |
|
| 57 | + } |
|
| 58 | + else { |
|
| 59 | + spip_livrer_fichier_entier($fichier); |
|
| 60 | + } |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -70,28 +70,28 @@ discard block |
||
| 70 | 70 | * @param int|string $expires |
| 71 | 71 | */ |
| 72 | 72 | function spip_livrer_fichier_entetes($fichier, $content_type = 'application/octet-stream', $attachment = false, $expires = 0) { |
| 73 | - // toujours envoyer un content type, meme vide ! |
|
| 74 | - header('Accept-Ranges: bytes'); |
|
| 75 | - header('Content-Type: ' . $content_type); |
|
| 76 | - |
|
| 77 | - if ($attachment) { |
|
| 78 | - $f = basename($fichier); |
|
| 79 | - // ce content-type est necessaire pour eviter des corruptions de zip dans ie6 |
|
| 80 | - header('Content-Type: application/octet-stream'); |
|
| 81 | - |
|
| 82 | - header("Content-Disposition: attachment; filename=\"$f\";"); |
|
| 83 | - header('Content-Transfer-Encoding: binary'); |
|
| 84 | - |
|
| 85 | - // fix for IE caching or PHP bug issue |
|
| 86 | - header('Expires: 0'); // set expiration time |
|
| 87 | - header('Pragma: public'); |
|
| 88 | - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
| 89 | - } |
|
| 90 | - else { |
|
| 91 | - $f = basename($fichier); |
|
| 92 | - header("Content-Disposition: inline; filename=\"$f\";"); |
|
| 93 | - header('Expires: ' . $expires); // set expiration time |
|
| 94 | - } |
|
| 73 | + // toujours envoyer un content type, meme vide ! |
|
| 74 | + header('Accept-Ranges: bytes'); |
|
| 75 | + header('Content-Type: ' . $content_type); |
|
| 76 | + |
|
| 77 | + if ($attachment) { |
|
| 78 | + $f = basename($fichier); |
|
| 79 | + // ce content-type est necessaire pour eviter des corruptions de zip dans ie6 |
|
| 80 | + header('Content-Type: application/octet-stream'); |
|
| 81 | + |
|
| 82 | + header("Content-Disposition: attachment; filename=\"$f\";"); |
|
| 83 | + header('Content-Transfer-Encoding: binary'); |
|
| 84 | + |
|
| 85 | + // fix for IE caching or PHP bug issue |
|
| 86 | + header('Expires: 0'); // set expiration time |
|
| 87 | + header('Pragma: public'); |
|
| 88 | + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
| 89 | + } |
|
| 90 | + else { |
|
| 91 | + $f = basename($fichier); |
|
| 92 | + header("Content-Disposition: inline; filename=\"$f\";"); |
|
| 93 | + header('Expires: ' . $expires); // set expiration time |
|
| 94 | + } |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -99,20 +99,20 @@ discard block |
||
| 99 | 99 | * @param string $fichier |
| 100 | 100 | */ |
| 101 | 101 | function spip_livrer_fichier_entier($fichier) { |
| 102 | - if (!file_exists($fichier)) { |
|
| 103 | - throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 104 | - } |
|
| 102 | + if (!file_exists($fichier)) { |
|
| 103 | + throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - if (!is_readable($fichier)) { |
|
| 107 | - throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 108 | - } |
|
| 106 | + if (!is_readable($fichier)) { |
|
| 107 | + throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - if ($size = filesize($fichier)) { |
|
| 111 | - header(sprintf('Content-Length: %d', $size)); |
|
| 112 | - } |
|
| 110 | + if ($size = filesize($fichier)) { |
|
| 111 | + header(sprintf('Content-Length: %d', $size)); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - readfile($fichier); |
|
| 115 | - exit(); |
|
| 114 | + readfile($fichier); |
|
| 115 | + exit(); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -125,98 +125,98 @@ discard block |
||
| 125 | 125 | * @throws Exception |
| 126 | 126 | */ |
| 127 | 127 | function spip_livrer_fichier_partie($fichier, $range = null) { |
| 128 | - if (!file_exists($fichier)) { |
|
| 129 | - throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 130 | - } |
|
| 128 | + if (!file_exists($fichier)) { |
|
| 129 | + throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - if (!is_readable($fichier)) { |
|
| 133 | - throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 134 | - } |
|
| 132 | + if (!is_readable($fichier)) { |
|
| 133 | + throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | |
| 137 | - // Par defaut on envoie tout |
|
| 138 | - $byteOffset = 0; |
|
| 139 | - $byteLength = $fileSize = filesize($fichier); |
|
| 137 | + // Par defaut on envoie tout |
|
| 138 | + $byteOffset = 0; |
|
| 139 | + $byteLength = $fileSize = filesize($fichier); |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | - // Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
|
| 143 | - if ($range and preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
|
| 144 | - ### Offset signifies where we should begin to read the file |
|
| 145 | - $byteOffset = (int)$match[1]; |
|
| 142 | + // Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
|
| 143 | + if ($range and preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
|
| 144 | + ### Offset signifies where we should begin to read the file |
|
| 145 | + $byteOffset = (int)$match[1]; |
|
| 146 | 146 | |
| 147 | 147 | |
| 148 | - ### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
|
| 149 | - if (isset($match[2])) { |
|
| 150 | - $finishBytes = (int)$match[2]; |
|
| 151 | - $byteLength = $finishBytes + 1; |
|
| 152 | - } else { |
|
| 153 | - $finishBytes = $fileSize - 1; |
|
| 154 | - } |
|
| 148 | + ### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
|
| 149 | + if (isset($match[2])) { |
|
| 150 | + $finishBytes = (int)$match[2]; |
|
| 151 | + $byteLength = $finishBytes + 1; |
|
| 152 | + } else { |
|
| 153 | + $finishBytes = $fileSize - 1; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
|
| 157 | - } |
|
| 158 | - else { |
|
| 159 | - // si pas de range valide, on delegue a la methode d'envoi complet |
|
| 160 | - spip_livrer_fichier_entier($fichier); |
|
| 161 | - // redondant, mais facilite la comprehension du code |
|
| 162 | - exit(); |
|
| 163 | - } |
|
| 156 | + $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
|
| 157 | + } |
|
| 158 | + else { |
|
| 159 | + // si pas de range valide, on delegue a la methode d'envoi complet |
|
| 160 | + spip_livrer_fichier_entier($fichier); |
|
| 161 | + // redondant, mais facilite la comprehension du code |
|
| 162 | + exit(); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - // Remove headers that might unnecessarily clutter up the output |
|
| 166 | - header_remove('Cache-Control'); |
|
| 167 | - header_remove('Pragma'); |
|
| 165 | + // Remove headers that might unnecessarily clutter up the output |
|
| 166 | + header_remove('Cache-Control'); |
|
| 167 | + header_remove('Pragma'); |
|
| 168 | 168 | |
| 169 | - // partial content |
|
| 170 | - header('HTTP/1.1 206 Partial content'); |
|
| 171 | - header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 169 | + // partial content |
|
| 170 | + header('HTTP/1.1 206 Partial content'); |
|
| 171 | + header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 172 | 172 | |
| 173 | 173 | |
| 174 | - $byteRange = $byteLength - $byteOffset; |
|
| 174 | + $byteRange = $byteLength - $byteOffset; |
|
| 175 | 175 | |
| 176 | - header(sprintf('Content-Length: %d', $byteRange)); |
|
| 176 | + header(sprintf('Content-Length: %d', $byteRange)); |
|
| 177 | 177 | |
| 178 | - // Variable containing the buffer |
|
| 179 | - $buffer = ''; |
|
| 180 | - // Just a reasonable buffer size |
|
| 181 | - $bufferSize = 512 * 16; |
|
| 182 | - // Contains how much is left to read of the byteRange |
|
| 183 | - $bytePool = $byteRange; |
|
| 178 | + // Variable containing the buffer |
|
| 179 | + $buffer = ''; |
|
| 180 | + // Just a reasonable buffer size |
|
| 181 | + $bufferSize = 512 * 16; |
|
| 182 | + // Contains how much is left to read of the byteRange |
|
| 183 | + $bytePool = $byteRange; |
|
| 184 | 184 | |
| 185 | - if (!$handle = fopen($fichier, 'r')) { |
|
| 186 | - throw new \Exception(sprintf('Could not get handle for file %s', $fichier)); |
|
| 187 | - } |
|
| 185 | + if (!$handle = fopen($fichier, 'r')) { |
|
| 186 | + throw new \Exception(sprintf('Could not get handle for file %s', $fichier)); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - if (fseek($handle, $byteOffset, SEEK_SET) == -1) { |
|
| 190 | - throw new \Exception(sprintf('Could not seek to byte offset %d', $byteOffset)); |
|
| 191 | - } |
|
| 189 | + if (fseek($handle, $byteOffset, SEEK_SET) == -1) { |
|
| 190 | + throw new \Exception(sprintf('Could not seek to byte offset %d', $byteOffset)); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | |
| 194 | - while ($bytePool > 0) { |
|
| 195 | - // How many bytes we request on this iteration |
|
| 196 | - $chunkSizeRequested = min($bufferSize, $bytePool); |
|
| 194 | + while ($bytePool > 0) { |
|
| 195 | + // How many bytes we request on this iteration |
|
| 196 | + $chunkSizeRequested = min($bufferSize, $bytePool); |
|
| 197 | 197 | |
| 198 | - // Try readin $chunkSizeRequested bytes from $handle and put data in $buffer |
|
| 199 | - $buffer = fread($handle, $chunkSizeRequested); |
|
| 198 | + // Try readin $chunkSizeRequested bytes from $handle and put data in $buffer |
|
| 199 | + $buffer = fread($handle, $chunkSizeRequested); |
|
| 200 | 200 | |
| 201 | - // Store how many bytes were actually read |
|
| 202 | - $chunkSizeActual = strlen($buffer); |
|
| 201 | + // Store how many bytes were actually read |
|
| 202 | + $chunkSizeActual = strlen($buffer); |
|
| 203 | 203 | |
| 204 | - // If we didn't get any bytes that means something unexpected has happened since $bytePool should be zero already |
|
| 205 | - if ($chunkSizeActual == 0) { |
|
| 206 | - // For production servers this should go in your php error log, since it will break the output |
|
| 207 | - trigger_error('Chunksize became 0', E_USER_WARNING); |
|
| 208 | - break; |
|
| 209 | - } |
|
| 204 | + // If we didn't get any bytes that means something unexpected has happened since $bytePool should be zero already |
|
| 205 | + if ($chunkSizeActual == 0) { |
|
| 206 | + // For production servers this should go in your php error log, since it will break the output |
|
| 207 | + trigger_error('Chunksize became 0', E_USER_WARNING); |
|
| 208 | + break; |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - // Decrease byte pool with amount of bytes that were read during this iteration |
|
| 212 | - $bytePool -= $chunkSizeActual; |
|
| 211 | + // Decrease byte pool with amount of bytes that were read during this iteration |
|
| 212 | + $bytePool -= $chunkSizeActual; |
|
| 213 | 213 | |
| 214 | - // Write the buffer to output |
|
| 215 | - print $buffer; |
|
| 214 | + // Write the buffer to output |
|
| 215 | + print $buffer; |
|
| 216 | 216 | |
| 217 | - // Try to output the data to the client immediately |
|
| 218 | - flush(); |
|
| 219 | - } |
|
| 217 | + // Try to output the data to the client immediately |
|
| 218 | + flush(); |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - exit(); |
|
| 221 | + exit(); |
|
| 222 | 222 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | * @return void |
| 44 | 44 | **/ |
| 45 | 45 | function install_fichier_connexion($nom, $texte) { |
| 46 | - $texte = '<' . "?php\n" |
|
| 47 | - . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 48 | - . $texte; |
|
| 46 | + $texte = '<' . "?php\n" |
|
| 47 | + . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 48 | + . $texte; |
|
| 49 | 49 | |
| 50 | - ecrire_fichier($nom, $texte); |
|
| 50 | + ecrire_fichier($nom, $texte); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -76,20 +76,20 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | **/ |
| 78 | 78 | function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') { |
| 79 | - $adr = addcslashes($adr, "'\\"); |
|
| 80 | - $port = addcslashes($port, "'\\"); |
|
| 81 | - $login = addcslashes($login, "'\\"); |
|
| 82 | - $pass = addcslashes($pass, "'\\"); |
|
| 83 | - $base = addcslashes($base, "'\\"); |
|
| 84 | - $type = addcslashes($type, "'\\"); |
|
| 85 | - $pref = addcslashes($pref, "'\\"); |
|
| 86 | - $ldap = addcslashes($ldap, "'\\"); |
|
| 87 | - $charset = addcslashes($charset, "'\\"); |
|
| 88 | - |
|
| 89 | - return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 90 | - . 'spip_connect_db(' |
|
| 91 | - . "'$adr','$port','$login','$pass','$base'" |
|
| 92 | - . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 79 | + $adr = addcslashes($adr, "'\\"); |
|
| 80 | + $port = addcslashes($port, "'\\"); |
|
| 81 | + $login = addcslashes($login, "'\\"); |
|
| 82 | + $pass = addcslashes($pass, "'\\"); |
|
| 83 | + $base = addcslashes($base, "'\\"); |
|
| 84 | + $type = addcslashes($type, "'\\"); |
|
| 85 | + $pref = addcslashes($pref, "'\\"); |
|
| 86 | + $ldap = addcslashes($ldap, "'\\"); |
|
| 87 | + $charset = addcslashes($charset, "'\\"); |
|
| 88 | + |
|
| 89 | + return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 90 | + . 'spip_connect_db(' |
|
| 91 | + . "'$adr','$port','$login','$pass','$base'" |
|
| 92 | + . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -105,29 +105,29 @@ discard block |
||
| 105 | 105 | * Tableau des informations sur la connexion |
| 106 | 106 | **/ |
| 107 | 107 | function analyse_fichier_connection(string $file): array { |
| 108 | - if (!file_exists($file)) { |
|
| 109 | - return []; |
|
| 110 | - } |
|
| 111 | - $s = file_get_contents($file); |
|
| 112 | - if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 113 | - array_shift($regs); |
|
| 114 | - |
|
| 115 | - return $regs; |
|
| 116 | - } else { |
|
| 117 | - $ar = '\s*\'([^\']*)\''; |
|
| 118 | - $r = '\s*,' . $ar; |
|
| 119 | - $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 120 | - if (preg_match($r, $s, $regs)) { |
|
| 121 | - $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';'); |
|
| 122 | - array_shift($regs); |
|
| 123 | - array_shift($regs); |
|
| 124 | - |
|
| 125 | - return $regs; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - spip_log("$file n'est pas un fichier de connexion"); |
|
| 129 | - |
|
| 130 | - return []; |
|
| 108 | + if (!file_exists($file)) { |
|
| 109 | + return []; |
|
| 110 | + } |
|
| 111 | + $s = file_get_contents($file); |
|
| 112 | + if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 113 | + array_shift($regs); |
|
| 114 | + |
|
| 115 | + return $regs; |
|
| 116 | + } else { |
|
| 117 | + $ar = '\s*\'([^\']*)\''; |
|
| 118 | + $r = '\s*,' . $ar; |
|
| 119 | + $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 120 | + if (preg_match($r, $s, $regs)) { |
|
| 121 | + $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';'); |
|
| 122 | + array_shift($regs); |
|
| 123 | + array_shift($regs); |
|
| 124 | + |
|
| 125 | + return $regs; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + spip_log("$file n'est pas un fichier de connexion"); |
|
| 129 | + |
|
| 130 | + return []; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -144,75 +144,75 @@ discard block |
||
| 144 | 144 | * Liste des noms de connecteurs |
| 145 | 145 | **/ |
| 146 | 146 | function bases_referencees($exclu = '') { |
| 147 | - $tables = []; |
|
| 148 | - foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 149 | - if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 150 | - $tables[] = basename($f, '.php'); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return $tables; |
|
| 147 | + $tables = []; |
|
| 148 | + foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 149 | + if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 150 | + $tables[] = basename($f, '.php'); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return $tables; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | function install_mode_appel($server_db, $tout = true) { |
| 159 | - return ($server_db != 'mysql') ? '' |
|
| 160 | - : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 161 | - . test_sql_mode_mysql($server_db)); |
|
| 159 | + return ($server_db != 'mysql') ? '' |
|
| 160 | + : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 161 | + . test_sql_mode_mysql($server_db)); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // |
| 165 | 165 | // Verifier que l'hebergement est compatible SPIP ... ou l'inverse :-) |
| 166 | 166 | // (sert a l'etape 1 de l'installation) |
| 167 | 167 | function tester_compatibilite_hebergement() { |
| 168 | - $err = []; |
|
| 169 | - |
|
| 170 | - $p = phpversion(); |
|
| 171 | - if (version_compare($p, _PHP_MIN, '<')) { |
|
| 172 | - $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]); |
|
| 173 | - } |
|
| 174 | - if (version_compare($p, _PHP_MAX, '>')) { |
|
| 175 | - $err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - $diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions()); |
|
| 179 | - if (!empty($diff)) { |
|
| 180 | - $err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 184 | - if ($err) { |
|
| 185 | - die("<div class='error'>" |
|
| 186 | - . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 187 | - . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // Il faut une base de donnees tout de meme ... |
|
| 191 | - $serveurs = install_select_serveur(); |
|
| 192 | - if (!$serveurs) { |
|
| 193 | - $err[] = _T('install_extension_php_obligatoire') |
|
| 194 | - . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 195 | - . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 196 | - . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0) |
|
| 200 | - if ($a = @ini_get('mbstring.func_overload')) { |
|
| 201 | - $err[] = _T('install_extension_mbstring') |
|
| 202 | - . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - if ($err) { |
|
| 206 | - echo "<div class='error'>" |
|
| 207 | - . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 208 | - foreach ($err as $e) { |
|
| 209 | - echo "<li><strong>$e</strong></li>\n"; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 213 | - # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 214 | - echo "</ul></div>\n"; |
|
| 215 | - } |
|
| 168 | + $err = []; |
|
| 169 | + |
|
| 170 | + $p = phpversion(); |
|
| 171 | + if (version_compare($p, _PHP_MIN, '<')) { |
|
| 172 | + $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]); |
|
| 173 | + } |
|
| 174 | + if (version_compare($p, _PHP_MAX, '>')) { |
|
| 175 | + $err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + $diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions()); |
|
| 179 | + if (!empty($diff)) { |
|
| 180 | + $err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 184 | + if ($err) { |
|
| 185 | + die("<div class='error'>" |
|
| 186 | + . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 187 | + . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // Il faut une base de donnees tout de meme ... |
|
| 191 | + $serveurs = install_select_serveur(); |
|
| 192 | + if (!$serveurs) { |
|
| 193 | + $err[] = _T('install_extension_php_obligatoire') |
|
| 194 | + . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 195 | + . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 196 | + . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0) |
|
| 200 | + if ($a = @ini_get('mbstring.func_overload')) { |
|
| 201 | + $err[] = _T('install_extension_mbstring') |
|
| 202 | + . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + if ($err) { |
|
| 206 | + echo "<div class='error'>" |
|
| 207 | + . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 208 | + foreach ($err as $e) { |
|
| 209 | + echo "<li><strong>$e</strong></li>\n"; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 213 | + # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 214 | + echo "</ul></div>\n"; |
|
| 215 | + } |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | |
@@ -222,23 +222,23 @@ discard block |
||
| 222 | 222 | * @note superflu ?? |
| 223 | 223 | */ |
| 224 | 224 | function login_hebergeur() { |
| 225 | - $base_hebergeur = 'localhost'; # par defaut |
|
| 225 | + $base_hebergeur = 'localhost'; # par defaut |
|
| 226 | 226 | |
| 227 | - // Free |
|
| 228 | - if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 229 | - $base_hebergeur = 'sql.free.fr'; |
|
| 230 | - $login_hebergeur = $regs[1]; |
|
| 231 | - } else { |
|
| 232 | - $login_hebergeur = ''; |
|
| 233 | - } |
|
| 227 | + // Free |
|
| 228 | + if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 229 | + $base_hebergeur = 'sql.free.fr'; |
|
| 230 | + $login_hebergeur = $regs[1]; |
|
| 231 | + } else { |
|
| 232 | + $login_hebergeur = ''; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - return [$base_hebergeur, $login_hebergeur]; |
|
| 235 | + return [$base_hebergeur, $login_hebergeur]; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | function info_etape($titre, $complement = '') { |
| 240 | - return '<h2>' . $titre . "</h2>\n" . |
|
| 241 | - ($complement ? '' . $complement . "\n" : ''); |
|
| 240 | + return '<h2>' . $titre . "</h2>\n" . |
|
| 241 | + ($complement ? '' . $complement . "\n" : ''); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -248,154 +248,154 @@ discard block |
||
| 248 | 248 | * @return string Code HTML du bouton |
| 249 | 249 | **/ |
| 250 | 250 | function bouton_suivant($code = '') { |
| 251 | - if ($code == '') { |
|
| 252 | - $code = _T('bouton_suivant'); |
|
| 253 | - } |
|
| 254 | - static $suivant = 0; |
|
| 255 | - $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 256 | - $suivant += 1; |
|
| 257 | - |
|
| 258 | - return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 259 | - $code . |
|
| 260 | - " >>\" /></p>\n"; |
|
| 251 | + if ($code == '') { |
|
| 252 | + $code = _T('bouton_suivant'); |
|
| 253 | + } |
|
| 254 | + static $suivant = 0; |
|
| 255 | + $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 256 | + $suivant += 1; |
|
| 257 | + |
|
| 258 | + return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 259 | + $code . |
|
| 260 | + " >>\" /></p>\n"; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | function info_progression_etape($en_cours, $phase, $dir, $erreur = false) { |
| 264 | - $intitule_etat = []; |
|
| 265 | - //$en_cours = _request('etape')?_request('etape'):""; |
|
| 266 | - $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 267 | - $debut = 1; |
|
| 268 | - $etat = 'ok'; |
|
| 269 | - $last = count($liste); |
|
| 264 | + $intitule_etat = []; |
|
| 265 | + //$en_cours = _request('etape')?_request('etape'):""; |
|
| 266 | + $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 267 | + $debut = 1; |
|
| 268 | + $etat = 'ok'; |
|
| 269 | + $last = count($liste); |
|
| 270 | 270 | // $texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo')); |
| 271 | 271 | |
| 272 | - $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee')); |
|
| 273 | - $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 274 | - $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles')); |
|
| 275 | - $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape')); |
|
| 272 | + $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee')); |
|
| 273 | + $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 274 | + $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles')); |
|
| 275 | + $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape')); |
|
| 276 | 276 | |
| 277 | - $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap')); |
|
| 278 | - $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap')); |
|
| 279 | - $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1')); |
|
| 280 | - $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap')); |
|
| 281 | - $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok')); |
|
| 277 | + $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap')); |
|
| 278 | + $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap')); |
|
| 279 | + $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1')); |
|
| 280 | + $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap')); |
|
| 281 | + $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok')); |
|
| 282 | 282 | |
| 283 | 283 | // $aff_etapes = "<span id='etapes'>"; |
| 284 | 284 | |
| 285 | - $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 286 | - |
|
| 287 | - foreach ($liste as $etape => $fichier) { |
|
| 288 | - if ($debut < $last) { |
|
| 289 | - if ($debut == $en_cours && $erreur) { |
|
| 290 | - $class = 'on erreur'; |
|
| 291 | - } else { |
|
| 292 | - if ($debut == $en_cours) { |
|
| 293 | - $class = 'on'; |
|
| 294 | - } else { |
|
| 295 | - if ($debut > $en_cours) { |
|
| 296 | - $class = 'prochains'; |
|
| 297 | - } else { |
|
| 298 | - $class = 'valides'; |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 304 | - $aff_etapes .= ($debut == $en_cours) ? '<strong>' : ''; |
|
| 305 | - $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 306 | - $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 307 | - $aff_etapes .= ($debut == $en_cours) ? '</strong>' : ''; |
|
| 308 | - $aff_etapes .= '</div></li>'; |
|
| 309 | - } |
|
| 310 | - $debut++; |
|
| 311 | - } |
|
| 312 | - $aff_etapes .= '</ul>'; |
|
| 313 | - $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 314 | - |
|
| 315 | - return $aff_etapes; |
|
| 285 | + $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 286 | + |
|
| 287 | + foreach ($liste as $etape => $fichier) { |
|
| 288 | + if ($debut < $last) { |
|
| 289 | + if ($debut == $en_cours && $erreur) { |
|
| 290 | + $class = 'on erreur'; |
|
| 291 | + } else { |
|
| 292 | + if ($debut == $en_cours) { |
|
| 293 | + $class = 'on'; |
|
| 294 | + } else { |
|
| 295 | + if ($debut > $en_cours) { |
|
| 296 | + $class = 'prochains'; |
|
| 297 | + } else { |
|
| 298 | + $class = 'valides'; |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 304 | + $aff_etapes .= ($debut == $en_cours) ? '<strong>' : ''; |
|
| 305 | + $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 306 | + $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 307 | + $aff_etapes .= ($debut == $en_cours) ? '</strong>' : ''; |
|
| 308 | + $aff_etapes .= '</div></li>'; |
|
| 309 | + } |
|
| 310 | + $debut++; |
|
| 311 | + } |
|
| 312 | + $aff_etapes .= '</ul>'; |
|
| 313 | + $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 314 | + |
|
| 315 | + return $aff_etapes; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | function fieldset($legend, $champs = [], $apres = '', $avant = '') { |
| 320 | - return "<fieldset>\n" . |
|
| 321 | - $avant . |
|
| 322 | - ($legend ? '<legend>' . $legend . "</legend>\n" : '') . |
|
| 323 | - fieldset_champs($champs) . |
|
| 324 | - $apres . |
|
| 325 | - "</fieldset>\n"; |
|
| 320 | + return "<fieldset>\n" . |
|
| 321 | + $avant . |
|
| 322 | + ($legend ? '<legend>' . $legend . "</legend>\n" : '') . |
|
| 323 | + fieldset_champs($champs) . |
|
| 324 | + $apres . |
|
| 325 | + "</fieldset>\n"; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | function fieldset_champs($champs = []) { |
| 329 | - $fieldset = ''; |
|
| 330 | - foreach ($champs as $nom => $contenu) { |
|
| 331 | - $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 332 | - $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 333 | - if (isset($contenu['alternatives'])) { |
|
| 334 | - $fieldset .= $contenu['label'] . "\n"; |
|
| 335 | - foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 336 | - $fieldset .= "<input type='radio' name='" . $nom . |
|
| 337 | - "' id='$nom-$valeur' value='$valeur'" |
|
| 338 | - . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 339 | - . "/>\n"; |
|
| 340 | - $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 341 | - } |
|
| 342 | - $fieldset .= "<br />\n"; |
|
| 343 | - } else { |
|
| 344 | - $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 345 | - $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 346 | - . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 347 | - . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '') |
|
| 348 | - . " />\n"; |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - return $fieldset; |
|
| 329 | + $fieldset = ''; |
|
| 330 | + foreach ($champs as $nom => $contenu) { |
|
| 331 | + $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 332 | + $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 333 | + if (isset($contenu['alternatives'])) { |
|
| 334 | + $fieldset .= $contenu['label'] . "\n"; |
|
| 335 | + foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 336 | + $fieldset .= "<input type='radio' name='" . $nom . |
|
| 337 | + "' id='$nom-$valeur' value='$valeur'" |
|
| 338 | + . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 339 | + . "/>\n"; |
|
| 340 | + $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 341 | + } |
|
| 342 | + $fieldset .= "<br />\n"; |
|
| 343 | + } else { |
|
| 344 | + $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 345 | + $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 346 | + . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 347 | + . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '') |
|
| 348 | + . " />\n"; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + return $fieldset; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | function install_select_serveur() { |
| 356 | - $options = []; |
|
| 357 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 358 | - $d = opendir($dir); |
|
| 359 | - if (!$d) { |
|
| 360 | - return []; |
|
| 361 | - } |
|
| 362 | - while (($f = readdir($d)) !== false) { |
|
| 363 | - if ( |
|
| 364 | - (preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 365 | - and is_readable($f = $dir . $f) |
|
| 366 | - ) { |
|
| 367 | - require_once($f); |
|
| 368 | - $s = $s[1]; |
|
| 369 | - $v = 'spip_versions_' . $s; |
|
| 370 | - if (function_exists($v) and $v()) { |
|
| 371 | - $titre = _T("install_select_type_$s"); |
|
| 372 | - // proposer mysql par defaut si dispo |
|
| 373 | - $checked = ($s == 'mysql' ? " checked='checked'" : ''); |
|
| 374 | - $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 375 | - . "<label for='$s'>" . ($titre ?: $s) . '</label></li>'; |
|
| 376 | - } else { |
|
| 377 | - spip_log("$s: portage indisponible"); |
|
| 378 | - } |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - sort($options); |
|
| 382 | - |
|
| 383 | - return $options; |
|
| 356 | + $options = []; |
|
| 357 | + $dir = _DIR_RESTREINT . 'req/'; |
|
| 358 | + $d = opendir($dir); |
|
| 359 | + if (!$d) { |
|
| 360 | + return []; |
|
| 361 | + } |
|
| 362 | + while (($f = readdir($d)) !== false) { |
|
| 363 | + if ( |
|
| 364 | + (preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 365 | + and is_readable($f = $dir . $f) |
|
| 366 | + ) { |
|
| 367 | + require_once($f); |
|
| 368 | + $s = $s[1]; |
|
| 369 | + $v = 'spip_versions_' . $s; |
|
| 370 | + if (function_exists($v) and $v()) { |
|
| 371 | + $titre = _T("install_select_type_$s"); |
|
| 372 | + // proposer mysql par defaut si dispo |
|
| 373 | + $checked = ($s == 'mysql' ? " checked='checked'" : ''); |
|
| 374 | + $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 375 | + . "<label for='$s'>" . ($titre ?: $s) . '</label></li>'; |
|
| 376 | + } else { |
|
| 377 | + spip_log("$s: portage indisponible"); |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + sort($options); |
|
| 382 | + |
|
| 383 | + return $options; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) { |
| 387 | - $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 388 | - |
|
| 389 | - return generer_form_ecrire('install', ( |
|
| 390 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 391 | - . $hidden |
|
| 392 | - . (_request('echec') ? |
|
| 393 | - ('<p><b>' . _T('avis_connexion_echec_1') . |
|
| 394 | - '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>') |
|
| 395 | - : '') |
|
| 396 | - |
|
| 397 | - . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 398 | - . http_script(' |
|
| 387 | + $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 388 | + |
|
| 389 | + return generer_form_ecrire('install', ( |
|
| 390 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 391 | + . $hidden |
|
| 392 | + . (_request('echec') ? |
|
| 393 | + ('<p><b>' . _T('avis_connexion_echec_1') . |
|
| 394 | + '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>') |
|
| 395 | + : '') |
|
| 396 | + |
|
| 397 | + . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 398 | + . http_script(' |
|
| 399 | 399 | jQuery(function($) { |
| 400 | 400 | $details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur"); |
| 401 | 401 | $("input[type=hidden][name=server_db]").each(function(){ |
@@ -428,145 +428,145 @@ discard block |
||
| 428 | 428 | }); |
| 429 | 429 | });') |
| 430 | 430 | |
| 431 | - . ($server_db |
|
| 432 | - ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 433 | - . (($predef[0]) |
|
| 434 | - ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 435 | - : '') |
|
| 436 | - : ('<fieldset><legend>' |
|
| 437 | - . _T('install_select_type_db') |
|
| 438 | - . '</legend>' |
|
| 439 | - . '<p class="explication">' |
|
| 440 | - . _T('install_types_db_connus') |
|
| 441 | - // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 442 | - // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 443 | - . '</p>' |
|
| 444 | - . "\n<div class='p'>\n<ul>\n" |
|
| 445 | - . join("\n", install_select_serveur()) |
|
| 446 | - . "\n</ul>\n</div></fieldset>") |
|
| 447 | - ) |
|
| 448 | - . '<div id="install_adresse_base_hebergeur">' |
|
| 449 | - . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 450 | - . ($predef[1] |
|
| 451 | - ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 452 | - : fieldset( |
|
| 453 | - _T('entree_base_donnee_1'), |
|
| 454 | - [ |
|
| 455 | - 'adresse_db' => [ |
|
| 456 | - 'label' => $db[1], |
|
| 457 | - 'valeur' => $db[0] |
|
| 458 | - ], |
|
| 459 | - ] |
|
| 460 | - ) |
|
| 461 | - ) |
|
| 462 | - . '</div>' |
|
| 463 | - |
|
| 464 | - . '<div id="install_login_base_hebergeur">' |
|
| 465 | - . ($predef[2] |
|
| 466 | - ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 467 | - : fieldset( |
|
| 468 | - _T('entree_login_connexion_1'), |
|
| 469 | - [ |
|
| 470 | - 'login_db' => [ |
|
| 471 | - 'label' => $login[1], |
|
| 472 | - 'valeur' => $login[0] |
|
| 473 | - ], |
|
| 474 | - ] |
|
| 475 | - ) |
|
| 476 | - ) |
|
| 477 | - . '</div>' |
|
| 478 | - |
|
| 479 | - . '<div id="install_pass_base_hebergeur">' |
|
| 480 | - . ($predef[3] |
|
| 481 | - ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 482 | - : fieldset( |
|
| 483 | - _T('entree_mot_passe_1'), |
|
| 484 | - [ |
|
| 485 | - 'pass_db' => [ |
|
| 486 | - 'label' => $pass[1], |
|
| 487 | - 'valeur' => $pass[0] |
|
| 488 | - ], |
|
| 489 | - ] |
|
| 490 | - ) |
|
| 491 | - ) |
|
| 492 | - . '</div>' |
|
| 493 | - |
|
| 494 | - . bouton_suivant())); |
|
| 431 | + . ($server_db |
|
| 432 | + ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 433 | + . (($predef[0]) |
|
| 434 | + ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 435 | + : '') |
|
| 436 | + : ('<fieldset><legend>' |
|
| 437 | + . _T('install_select_type_db') |
|
| 438 | + . '</legend>' |
|
| 439 | + . '<p class="explication">' |
|
| 440 | + . _T('install_types_db_connus') |
|
| 441 | + // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 442 | + // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 443 | + . '</p>' |
|
| 444 | + . "\n<div class='p'>\n<ul>\n" |
|
| 445 | + . join("\n", install_select_serveur()) |
|
| 446 | + . "\n</ul>\n</div></fieldset>") |
|
| 447 | + ) |
|
| 448 | + . '<div id="install_adresse_base_hebergeur">' |
|
| 449 | + . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 450 | + . ($predef[1] |
|
| 451 | + ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 452 | + : fieldset( |
|
| 453 | + _T('entree_base_donnee_1'), |
|
| 454 | + [ |
|
| 455 | + 'adresse_db' => [ |
|
| 456 | + 'label' => $db[1], |
|
| 457 | + 'valeur' => $db[0] |
|
| 458 | + ], |
|
| 459 | + ] |
|
| 460 | + ) |
|
| 461 | + ) |
|
| 462 | + . '</div>' |
|
| 463 | + |
|
| 464 | + . '<div id="install_login_base_hebergeur">' |
|
| 465 | + . ($predef[2] |
|
| 466 | + ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 467 | + : fieldset( |
|
| 468 | + _T('entree_login_connexion_1'), |
|
| 469 | + [ |
|
| 470 | + 'login_db' => [ |
|
| 471 | + 'label' => $login[1], |
|
| 472 | + 'valeur' => $login[0] |
|
| 473 | + ], |
|
| 474 | + ] |
|
| 475 | + ) |
|
| 476 | + ) |
|
| 477 | + . '</div>' |
|
| 478 | + |
|
| 479 | + . '<div id="install_pass_base_hebergeur">' |
|
| 480 | + . ($predef[3] |
|
| 481 | + ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 482 | + : fieldset( |
|
| 483 | + _T('entree_mot_passe_1'), |
|
| 484 | + [ |
|
| 485 | + 'pass_db' => [ |
|
| 486 | + 'label' => $pass[1], |
|
| 487 | + 'valeur' => $pass[0] |
|
| 488 | + ], |
|
| 489 | + ] |
|
| 490 | + ) |
|
| 491 | + ) |
|
| 492 | + . '</div>' |
|
| 493 | + |
|
| 494 | + . bouton_suivant())); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | // 4 valeurs qu'on reconduit d'un script a l'autre |
| 498 | 498 | // sauf s'ils sont predefinis. |
| 499 | 499 | |
| 500 | 500 | function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) { |
| 501 | - return ((defined('_INSTALL_HOST_DB')) |
|
| 502 | - ? '' |
|
| 503 | - : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . '" />' |
|
| 504 | - ) |
|
| 505 | - . ((defined('_INSTALL_USER_DB')) |
|
| 506 | - ? '' |
|
| 507 | - : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />' |
|
| 508 | - ) |
|
| 509 | - . ((defined('_INSTALL_PASS_DB')) |
|
| 510 | - ? '' |
|
| 511 | - : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />' |
|
| 512 | - ) |
|
| 513 | - |
|
| 514 | - . ((defined('_INSTALL_SERVER_DB')) |
|
| 515 | - ? '' |
|
| 516 | - : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />' |
|
| 517 | - ); |
|
| 501 | + return ((defined('_INSTALL_HOST_DB')) |
|
| 502 | + ? '' |
|
| 503 | + : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . '" />' |
|
| 504 | + ) |
|
| 505 | + . ((defined('_INSTALL_USER_DB')) |
|
| 506 | + ? '' |
|
| 507 | + : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />' |
|
| 508 | + ) |
|
| 509 | + . ((defined('_INSTALL_PASS_DB')) |
|
| 510 | + ? '' |
|
| 511 | + : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />' |
|
| 512 | + ) |
|
| 513 | + |
|
| 514 | + . ((defined('_INSTALL_SERVER_DB')) |
|
| 515 | + ? '' |
|
| 516 | + : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />' |
|
| 517 | + ); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | // presentation des bases existantes |
| 521 | 521 | |
| 522 | 522 | function install_etape_liste_bases($server_db, $login_db, $disabled = []) { |
| 523 | - $bases = $checked = []; |
|
| 524 | - $noms = sql_listdbs($server_db); |
|
| 525 | - if (!$noms) { |
|
| 526 | - return ''; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - foreach ($noms as $nom) { |
|
| 530 | - $id = spip_htmlspecialchars($nom); |
|
| 531 | - $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 532 | - $base = ' name="choix_db" value="' |
|
| 533 | - . $nom |
|
| 534 | - . '"' |
|
| 535 | - . $dis |
|
| 536 | - . " type='radio' id='$id'"; |
|
| 537 | - $label = "<label for='$id'>" |
|
| 538 | - . ($dis ? "<i>$nom</i>" : $nom) |
|
| 539 | - . '</label>'; |
|
| 540 | - |
|
| 541 | - if ( |
|
| 542 | - !$checked and !$dis and |
|
| 543 | - (($nom == $login_db) or |
|
| 544 | - ($GLOBALS['table_prefix'] == $nom)) |
|
| 545 | - ) { |
|
| 546 | - $checked = "<input$base checked='checked' />\n$label"; |
|
| 547 | - } else { |
|
| 548 | - $bases[] = "<input$base />\n$label"; |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - if (!$bases && !$checked) { |
|
| 553 | - return false; |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - if ($checked) { |
|
| 557 | - array_unshift($bases, $checked); |
|
| 558 | - $checked = true; |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - return [$checked, $bases]; |
|
| 523 | + $bases = $checked = []; |
|
| 524 | + $noms = sql_listdbs($server_db); |
|
| 525 | + if (!$noms) { |
|
| 526 | + return ''; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + foreach ($noms as $nom) { |
|
| 530 | + $id = spip_htmlspecialchars($nom); |
|
| 531 | + $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 532 | + $base = ' name="choix_db" value="' |
|
| 533 | + . $nom |
|
| 534 | + . '"' |
|
| 535 | + . $dis |
|
| 536 | + . " type='radio' id='$id'"; |
|
| 537 | + $label = "<label for='$id'>" |
|
| 538 | + . ($dis ? "<i>$nom</i>" : $nom) |
|
| 539 | + . '</label>'; |
|
| 540 | + |
|
| 541 | + if ( |
|
| 542 | + !$checked and !$dis and |
|
| 543 | + (($nom == $login_db) or |
|
| 544 | + ($GLOBALS['table_prefix'] == $nom)) |
|
| 545 | + ) { |
|
| 546 | + $checked = "<input$base checked='checked' />\n$label"; |
|
| 547 | + } else { |
|
| 548 | + $bases[] = "<input$base />\n$label"; |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + if (!$bases && !$checked) { |
|
| 553 | + return false; |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + if ($checked) { |
|
| 557 | + array_unshift($bases, $checked); |
|
| 558 | + $checked = true; |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + return [$checked, $bases]; |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | function install_propager($hidden) { |
| 565 | - $res = ''; |
|
| 566 | - foreach ($hidden as $k) { |
|
| 567 | - $v = spip_htmlentities(_request($k)); |
|
| 568 | - $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 569 | - } |
|
| 565 | + $res = ''; |
|
| 566 | + foreach ($hidden as $k) { |
|
| 567 | + $v = spip_htmlentities(_request($k)); |
|
| 568 | + $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | - return $res; |
|
| 571 | + return $res; |
|
| 572 | 572 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -46,33 +46,33 @@ discard block |
||
| 46 | 46 | * Environnement du formulaire |
| 47 | 47 | **/ |
| 48 | 48 | function formulaires_editer_article_charger_dist( |
| 49 | - $id_article = 'new', |
|
| 50 | - $id_rubrique = 0, |
|
| 51 | - $retour = '', |
|
| 52 | - $lier_trad = 0, |
|
| 53 | - $config_fonc = 'articles_edit_config', |
|
| 54 | - $row = [], |
|
| 55 | - $hidden = '' |
|
| 49 | + $id_article = 'new', |
|
| 50 | + $id_rubrique = 0, |
|
| 51 | + $retour = '', |
|
| 52 | + $lier_trad = 0, |
|
| 53 | + $config_fonc = 'articles_edit_config', |
|
| 54 | + $row = [], |
|
| 55 | + $hidden = '' |
|
| 56 | 56 | ) { |
| 57 | - $valeurs = formulaires_editer_objet_charger( |
|
| 58 | - 'article', |
|
| 59 | - $id_article, |
|
| 60 | - $id_rubrique, |
|
| 61 | - $lier_trad, |
|
| 62 | - $retour, |
|
| 63 | - $config_fonc, |
|
| 64 | - $row, |
|
| 65 | - $hidden |
|
| 66 | - ); |
|
| 57 | + $valeurs = formulaires_editer_objet_charger( |
|
| 58 | + 'article', |
|
| 59 | + $id_article, |
|
| 60 | + $id_rubrique, |
|
| 61 | + $lier_trad, |
|
| 62 | + $retour, |
|
| 63 | + $config_fonc, |
|
| 64 | + $row, |
|
| 65 | + $hidden |
|
| 66 | + ); |
|
| 67 | 67 | |
| 68 | - if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) { |
|
| 69 | - $valeurs['editable'] = ''; |
|
| 70 | - } |
|
| 68 | + if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) { |
|
| 69 | + $valeurs['editable'] = ''; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - // il faut enlever l'id_rubrique car la saisie se fait sur id_parent |
|
| 73 | - // et id_rubrique peut etre passe dans l'url comme rubrique parent initiale |
|
| 74 | - // et sera perdue si elle est supposee saisie |
|
| 75 | - return $valeurs; |
|
| 72 | + // il faut enlever l'id_rubrique car la saisie se fait sur id_parent |
|
| 73 | + // et id_rubrique peut etre passe dans l'url comme rubrique parent initiale |
|
| 74 | + // et sera perdue si elle est supposee saisie |
|
| 75 | + return $valeurs; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -97,15 +97,15 @@ discard block |
||
| 97 | 97 | * Hash du formulaire |
| 98 | 98 | */ |
| 99 | 99 | function formulaires_editer_article_identifier_dist( |
| 100 | - $id_article = 'new', |
|
| 101 | - $id_rubrique = 0, |
|
| 102 | - $retour = '', |
|
| 103 | - $lier_trad = 0, |
|
| 104 | - $config_fonc = 'articles_edit_config', |
|
| 105 | - $row = [], |
|
| 106 | - $hidden = '' |
|
| 100 | + $id_article = 'new', |
|
| 101 | + $id_rubrique = 0, |
|
| 102 | + $retour = '', |
|
| 103 | + $lier_trad = 0, |
|
| 104 | + $config_fonc = 'articles_edit_config', |
|
| 105 | + $row = [], |
|
| 106 | + $hidden = '' |
|
| 107 | 107 | ) { |
| 108 | - return serialize([intval($id_article), $lier_trad]); |
|
| 108 | + return serialize([intval($id_article), $lier_trad]); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | function articles_edit_config(array $row): array { |
| 120 | 120 | |
| 121 | - $config = []; |
|
| 122 | - $config['lignes'] = 8; |
|
| 123 | - $config['langue'] = $GLOBALS['spip_lang']; |
|
| 124 | - $config['restreint'] = ($row['statut'] === 'publie'); |
|
| 121 | + $config = []; |
|
| 122 | + $config['lignes'] = 8; |
|
| 123 | + $config['langue'] = $GLOBALS['spip_lang']; |
|
| 124 | + $config['restreint'] = ($row['statut'] === 'publie'); |
|
| 125 | 125 | |
| 126 | - return $config; |
|
| 126 | + return $config; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -149,43 +149,43 @@ discard block |
||
| 149 | 149 | * Erreurs du formulaire |
| 150 | 150 | **/ |
| 151 | 151 | function formulaires_editer_article_verifier_dist( |
| 152 | - $id_article = 'new', |
|
| 153 | - $id_rubrique = 0, |
|
| 154 | - $retour = '', |
|
| 155 | - $lier_trad = 0, |
|
| 156 | - $config_fonc = 'articles_edit_config', |
|
| 157 | - $row = [], |
|
| 158 | - $hidden = '' |
|
| 152 | + $id_article = 'new', |
|
| 153 | + $id_rubrique = 0, |
|
| 154 | + $retour = '', |
|
| 155 | + $lier_trad = 0, |
|
| 156 | + $config_fonc = 'articles_edit_config', |
|
| 157 | + $row = [], |
|
| 158 | + $hidden = '' |
|
| 159 | 159 | ) { |
| 160 | - // auto-renseigner le titre si il n'existe pas |
|
| 161 | - titre_automatique('titre', ['descriptif', 'chapo', 'texte']); |
|
| 162 | - if (!_request('id_parent') and !intval($id_article)) { |
|
| 163 | - $valeurs = formulaires_editer_objet_charger( |
|
| 164 | - 'article', |
|
| 165 | - $id_article, |
|
| 166 | - $id_rubrique, |
|
| 167 | - $lier_trad, |
|
| 168 | - $retour, |
|
| 169 | - $config_fonc, |
|
| 170 | - $row, |
|
| 171 | - $hidden |
|
| 172 | - ); |
|
| 173 | - set_request('id_parent', $valeurs['id_parent']); |
|
| 174 | - } |
|
| 175 | - // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide |
|
| 176 | - $erreurs = formulaires_editer_objet_verifier('article', $id_article, ['id_parent']); |
|
| 177 | - // si on utilise le formulaire dans le public |
|
| 178 | - if (!function_exists('autoriser')) { |
|
| 179 | - include_spip('inc/autoriser'); |
|
| 180 | - } |
|
| 181 | - if ( |
|
| 182 | - !isset($erreurs['id_parent']) |
|
| 183 | - and !autoriser('creerarticledans', 'rubrique', _request('id_parent')) |
|
| 184 | - ) { |
|
| 185 | - $erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise'); |
|
| 186 | - } |
|
| 160 | + // auto-renseigner le titre si il n'existe pas |
|
| 161 | + titre_automatique('titre', ['descriptif', 'chapo', 'texte']); |
|
| 162 | + if (!_request('id_parent') and !intval($id_article)) { |
|
| 163 | + $valeurs = formulaires_editer_objet_charger( |
|
| 164 | + 'article', |
|
| 165 | + $id_article, |
|
| 166 | + $id_rubrique, |
|
| 167 | + $lier_trad, |
|
| 168 | + $retour, |
|
| 169 | + $config_fonc, |
|
| 170 | + $row, |
|
| 171 | + $hidden |
|
| 172 | + ); |
|
| 173 | + set_request('id_parent', $valeurs['id_parent']); |
|
| 174 | + } |
|
| 175 | + // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide |
|
| 176 | + $erreurs = formulaires_editer_objet_verifier('article', $id_article, ['id_parent']); |
|
| 177 | + // si on utilise le formulaire dans le public |
|
| 178 | + if (!function_exists('autoriser')) { |
|
| 179 | + include_spip('inc/autoriser'); |
|
| 180 | + } |
|
| 181 | + if ( |
|
| 182 | + !isset($erreurs['id_parent']) |
|
| 183 | + and !autoriser('creerarticledans', 'rubrique', _request('id_parent')) |
|
| 184 | + ) { |
|
| 185 | + $erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise'); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - return $erreurs; |
|
| 188 | + return $erreurs; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -211,29 +211,29 @@ discard block |
||
| 211 | 211 | * Retours des traitements |
| 212 | 212 | **/ |
| 213 | 213 | function formulaires_editer_article_traiter_dist( |
| 214 | - $id_article = 'new', |
|
| 215 | - $id_rubrique = 0, |
|
| 216 | - $retour = '', |
|
| 217 | - $lier_trad = 0, |
|
| 218 | - $config_fonc = 'articles_edit_config', |
|
| 219 | - $row = [], |
|
| 220 | - $hidden = '' |
|
| 214 | + $id_article = 'new', |
|
| 215 | + $id_rubrique = 0, |
|
| 216 | + $retour = '', |
|
| 217 | + $lier_trad = 0, |
|
| 218 | + $config_fonc = 'articles_edit_config', |
|
| 219 | + $row = [], |
|
| 220 | + $hidden = '' |
|
| 221 | 221 | ) { |
| 222 | - // ici on ignore changer_lang qui est poste en cas de trad, |
|
| 223 | - // car l'heuristique du choix de la langue est pris en charge par article_inserer |
|
| 224 | - // en fonction de la config du site et de la rubrique choisie |
|
| 225 | - if (!$lier_trad) { |
|
| 226 | - set_request('changer_lang'); |
|
| 227 | - } |
|
| 222 | + // ici on ignore changer_lang qui est poste en cas de trad, |
|
| 223 | + // car l'heuristique du choix de la langue est pris en charge par article_inserer |
|
| 224 | + // en fonction de la config du site et de la rubrique choisie |
|
| 225 | + if (!$lier_trad) { |
|
| 226 | + set_request('changer_lang'); |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - return formulaires_editer_objet_traiter( |
|
| 230 | - 'article', |
|
| 231 | - $id_article, |
|
| 232 | - $id_rubrique, |
|
| 233 | - $lier_trad, |
|
| 234 | - $retour, |
|
| 235 | - $config_fonc, |
|
| 236 | - $row, |
|
| 237 | - $hidden |
|
| 238 | - ); |
|
| 229 | + return formulaires_editer_objet_traiter( |
|
| 230 | + 'article', |
|
| 231 | + $id_article, |
|
| 232 | + $id_rubrique, |
|
| 233 | + $lier_trad, |
|
| 234 | + $retour, |
|
| 235 | + $config_fonc, |
|
| 236 | + $row, |
|
| 237 | + $hidden |
|
| 238 | + ); |
|
| 239 | 239 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -47,30 +47,30 @@ discard block |
||
| 47 | 47 | * Environnement du formulaire |
| 48 | 48 | **/ |
| 49 | 49 | function formulaires_editer_rubrique_charger_dist( |
| 50 | - $id_rubrique = 'new', |
|
| 51 | - $id_parent = 0, |
|
| 52 | - $retour = '', |
|
| 53 | - $lier_trad = 0, |
|
| 54 | - $config_fonc = 'rubriques_edit_config', |
|
| 55 | - $row = [], |
|
| 56 | - $hidden = '' |
|
| 50 | + $id_rubrique = 'new', |
|
| 51 | + $id_parent = 0, |
|
| 52 | + $retour = '', |
|
| 53 | + $lier_trad = 0, |
|
| 54 | + $config_fonc = 'rubriques_edit_config', |
|
| 55 | + $row = [], |
|
| 56 | + $hidden = '' |
|
| 57 | 57 | ) { |
| 58 | - $valeurs = formulaires_editer_objet_charger( |
|
| 59 | - 'rubrique', |
|
| 60 | - $id_rubrique, |
|
| 61 | - $id_parent, |
|
| 62 | - $lier_trad, |
|
| 63 | - $retour, |
|
| 64 | - $config_fonc, |
|
| 65 | - $row, |
|
| 66 | - $hidden |
|
| 67 | - ); |
|
| 68 | - |
|
| 69 | - if (intval($id_rubrique) and !autoriser('modifier', 'rubrique', intval($id_rubrique))) { |
|
| 70 | - $valeurs['editable'] = ''; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - return $valeurs; |
|
| 58 | + $valeurs = formulaires_editer_objet_charger( |
|
| 59 | + 'rubrique', |
|
| 60 | + $id_rubrique, |
|
| 61 | + $id_parent, |
|
| 62 | + $lier_trad, |
|
| 63 | + $retour, |
|
| 64 | + $config_fonc, |
|
| 65 | + $row, |
|
| 66 | + $hidden |
|
| 67 | + ); |
|
| 68 | + |
|
| 69 | + if (intval($id_rubrique) and !autoriser('modifier', 'rubrique', intval($id_rubrique))) { |
|
| 70 | + $valeurs['editable'] = ''; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + return $valeurs; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | function rubriques_edit_config(array $row): array { |
| 85 | 85 | |
| 86 | - $config = []; |
|
| 87 | - $config['lignes'] = 8; |
|
| 88 | - $config['langue'] = $GLOBALS['spip_lang']; |
|
| 89 | - $config['restreint'] = (!$GLOBALS['connect_toutes_rubriques']); |
|
| 86 | + $config = []; |
|
| 87 | + $config['lignes'] = 8; |
|
| 88 | + $config['langue'] = $GLOBALS['spip_lang']; |
|
| 89 | + $config['restreint'] = (!$GLOBALS['connect_toutes_rubriques']); |
|
| 90 | 90 | |
| 91 | - return $config; |
|
| 91 | + return $config; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | * Hash du formulaire |
| 114 | 114 | */ |
| 115 | 115 | function formulaires_editer_rubrique_identifier_dist( |
| 116 | - $id_rubrique = 'new', |
|
| 117 | - $id_parent = 0, |
|
| 118 | - $retour = '', |
|
| 119 | - $lier_trad = 0, |
|
| 120 | - $config_fonc = 'rubriques_edit_config', |
|
| 121 | - $row = [], |
|
| 122 | - $hidden = '' |
|
| 116 | + $id_rubrique = 'new', |
|
| 117 | + $id_parent = 0, |
|
| 118 | + $retour = '', |
|
| 119 | + $lier_trad = 0, |
|
| 120 | + $config_fonc = 'rubriques_edit_config', |
|
| 121 | + $row = [], |
|
| 122 | + $hidden = '' |
|
| 123 | 123 | ) { |
| 124 | - return serialize([intval($id_rubrique), $lier_trad]); |
|
| 124 | + return serialize([intval($id_rubrique), $lier_trad]); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -147,34 +147,34 @@ discard block |
||
| 147 | 147 | * Erreurs du formulaire |
| 148 | 148 | **/ |
| 149 | 149 | function formulaires_editer_rubrique_verifier_dist( |
| 150 | - $id_rubrique = 'new', |
|
| 151 | - $id_parent = 0, |
|
| 152 | - $retour = '', |
|
| 153 | - $lier_trad = 0, |
|
| 154 | - $config_fonc = 'rubriques_edit_config', |
|
| 155 | - $row = [], |
|
| 156 | - $hidden = '' |
|
| 150 | + $id_rubrique = 'new', |
|
| 151 | + $id_parent = 0, |
|
| 152 | + $retour = '', |
|
| 153 | + $lier_trad = 0, |
|
| 154 | + $config_fonc = 'rubriques_edit_config', |
|
| 155 | + $row = [], |
|
| 156 | + $hidden = '' |
|
| 157 | 157 | ) { |
| 158 | - // auto-renseigner le titre si il n'existe pas |
|
| 159 | - titre_automatique('titre', ['descriptif', 'texte']); |
|
| 160 | - // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_rubrique si vide |
|
| 161 | - $erreurs = formulaires_editer_objet_verifier('rubrique', $id_rubrique, []); |
|
| 162 | - |
|
| 163 | - // s'assurer qu'on ne s'auto-designe pas comme parent ! |
|
| 164 | - if ( |
|
| 165 | - intval($id_rubrique) |
|
| 166 | - and empty($erreurs['id_parent']) |
|
| 167 | - and $id_parent = _request('id_parent') |
|
| 168 | - ) { |
|
| 169 | - include_spip('inc/rubriques'); |
|
| 170 | - $branche = calcul_branche_in($id_rubrique); |
|
| 171 | - $branche = explode(',', $branche); |
|
| 172 | - if (in_array($id_parent, $branche)) { |
|
| 173 | - $erreurs['id_parent'] = _L('Impossible de déplacer une rubrique dans sa propre branche, on tourne en rond !'); |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - return $erreurs; |
|
| 158 | + // auto-renseigner le titre si il n'existe pas |
|
| 159 | + titre_automatique('titre', ['descriptif', 'texte']); |
|
| 160 | + // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_rubrique si vide |
|
| 161 | + $erreurs = formulaires_editer_objet_verifier('rubrique', $id_rubrique, []); |
|
| 162 | + |
|
| 163 | + // s'assurer qu'on ne s'auto-designe pas comme parent ! |
|
| 164 | + if ( |
|
| 165 | + intval($id_rubrique) |
|
| 166 | + and empty($erreurs['id_parent']) |
|
| 167 | + and $id_parent = _request('id_parent') |
|
| 168 | + ) { |
|
| 169 | + include_spip('inc/rubriques'); |
|
| 170 | + $branche = calcul_branche_in($id_rubrique); |
|
| 171 | + $branche = explode(',', $branche); |
|
| 172 | + if (in_array($id_parent, $branche)) { |
|
| 173 | + $erreurs['id_parent'] = _L('Impossible de déplacer une rubrique dans sa propre branche, on tourne en rond !'); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + return $erreurs; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -200,22 +200,22 @@ discard block |
||
| 200 | 200 | * Retour des traitements |
| 201 | 201 | **/ |
| 202 | 202 | function formulaires_editer_rubrique_traiter_dist( |
| 203 | - $id_rubrique = 'new', |
|
| 204 | - $id_parent = 0, |
|
| 205 | - $retour = '', |
|
| 206 | - $lier_trad = 0, |
|
| 207 | - $config_fonc = 'rubriques_edit_config', |
|
| 208 | - $row = [], |
|
| 209 | - $hidden = '' |
|
| 203 | + $id_rubrique = 'new', |
|
| 204 | + $id_parent = 0, |
|
| 205 | + $retour = '', |
|
| 206 | + $lier_trad = 0, |
|
| 207 | + $config_fonc = 'rubriques_edit_config', |
|
| 208 | + $row = [], |
|
| 209 | + $hidden = '' |
|
| 210 | 210 | ) { |
| 211 | - return formulaires_editer_objet_traiter( |
|
| 212 | - 'rubrique', |
|
| 213 | - $id_rubrique, |
|
| 214 | - $id_parent, |
|
| 215 | - $lier_trad, |
|
| 216 | - $retour, |
|
| 217 | - $config_fonc, |
|
| 218 | - $row, |
|
| 219 | - $hidden |
|
| 220 | - ); |
|
| 211 | + return formulaires_editer_objet_traiter( |
|
| 212 | + 'rubrique', |
|
| 213 | + $id_rubrique, |
|
| 214 | + $id_parent, |
|
| 215 | + $lier_trad, |
|
| 216 | + $retour, |
|
| 217 | + $config_fonc, |
|
| 218 | + $row, |
|
| 219 | + $hidden |
|
| 220 | + ); |
|
| 221 | 221 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -31,46 +31,46 @@ discard block |
||
| 31 | 31 | * Mot de passe |
| 32 | 32 | **/ |
| 33 | 33 | function creer_pass_aleatoire($longueur = 16, $sel = '') { |
| 34 | - $seed = (int)round(((float)microtime() + 1) * time()); |
|
| 35 | - |
|
| 36 | - mt_srand($seed); |
|
| 37 | - $s = ''; |
|
| 38 | - $pass = ''; |
|
| 39 | - for ($i = 0; $i < $longueur; $i++) { |
|
| 40 | - if (!$s) { |
|
| 41 | - $s = random_int(0, mt_getrandmax()); |
|
| 42 | - if (!$s) { |
|
| 43 | - $s = random_int(0, mt_getrandmax()); |
|
| 44 | - } |
|
| 45 | - $s = substr(md5(uniqid($s) . $sel), 0, 16); |
|
| 46 | - } |
|
| 47 | - $r = unpack('Cr', pack('H2', $s . $s)); |
|
| 48 | - $x = $r['r'] & 63; |
|
| 49 | - if ($x < 10) { |
|
| 50 | - $x = chr($x + 48); |
|
| 51 | - } else { |
|
| 52 | - if ($x < 36) { |
|
| 53 | - $x = chr($x + 55); |
|
| 54 | - } else { |
|
| 55 | - if ($x < 62) { |
|
| 56 | - $x = chr($x + 61); |
|
| 57 | - } else { |
|
| 58 | - if ($x == 63) { |
|
| 59 | - $x = '/'; |
|
| 60 | - } else { |
|
| 61 | - $x = '.'; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - $pass .= $x; |
|
| 67 | - $s = substr($s, 2); |
|
| 68 | - } |
|
| 69 | - $pass = preg_replace('@[./]@', 'a', $pass); |
|
| 70 | - $pass = preg_replace('@[I1l]@', 'L', $pass); |
|
| 71 | - $pass = preg_replace('@[0O]@', 'o', $pass); |
|
| 72 | - |
|
| 73 | - return $pass; |
|
| 34 | + $seed = (int)round(((float)microtime() + 1) * time()); |
|
| 35 | + |
|
| 36 | + mt_srand($seed); |
|
| 37 | + $s = ''; |
|
| 38 | + $pass = ''; |
|
| 39 | + for ($i = 0; $i < $longueur; $i++) { |
|
| 40 | + if (!$s) { |
|
| 41 | + $s = random_int(0, mt_getrandmax()); |
|
| 42 | + if (!$s) { |
|
| 43 | + $s = random_int(0, mt_getrandmax()); |
|
| 44 | + } |
|
| 45 | + $s = substr(md5(uniqid($s) . $sel), 0, 16); |
|
| 46 | + } |
|
| 47 | + $r = unpack('Cr', pack('H2', $s . $s)); |
|
| 48 | + $x = $r['r'] & 63; |
|
| 49 | + if ($x < 10) { |
|
| 50 | + $x = chr($x + 48); |
|
| 51 | + } else { |
|
| 52 | + if ($x < 36) { |
|
| 53 | + $x = chr($x + 55); |
|
| 54 | + } else { |
|
| 55 | + if ($x < 62) { |
|
| 56 | + $x = chr($x + 61); |
|
| 57 | + } else { |
|
| 58 | + if ($x == 63) { |
|
| 59 | + $x = '/'; |
|
| 60 | + } else { |
|
| 61 | + $x = '.'; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + $pass .= $x; |
|
| 67 | + $s = substr($s, 2); |
|
| 68 | + } |
|
| 69 | + $pass = preg_replace('@[./]@', 'a', $pass); |
|
| 70 | + $pass = preg_replace('@[I1l]@', 'L', $pass); |
|
| 71 | + $pass = preg_replace('@[0O]@', 'o', $pass); |
|
| 72 | + |
|
| 73 | + return $pass; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -79,20 +79,20 @@ discard block |
||
| 79 | 79 | * @return string Identifiant |
| 80 | 80 | */ |
| 81 | 81 | function creer_uniqid() { |
| 82 | - static $seeded; |
|
| 82 | + static $seeded; |
|
| 83 | 83 | |
| 84 | - if (!$seeded) { |
|
| 85 | - $seed = (int)round(((float)microtime() + 1) * time()); |
|
| 86 | - mt_srand($seed); |
|
| 87 | - $seeded = true; |
|
| 88 | - } |
|
| 84 | + if (!$seeded) { |
|
| 85 | + $seed = (int)round(((float)microtime() + 1) * time()); |
|
| 86 | + mt_srand($seed); |
|
| 87 | + $seeded = true; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - $s = random_int(0, mt_getrandmax()); |
|
| 91 | - if (!$s) { |
|
| 92 | - $s = random_int(0, mt_getrandmax()); |
|
| 93 | - } |
|
| 90 | + $s = random_int(0, mt_getrandmax()); |
|
| 91 | + if (!$s) { |
|
| 92 | + $s = random_int(0, mt_getrandmax()); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - return uniqid($s, 1); |
|
| 95 | + return uniqid($s, 1); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -106,42 +106,42 @@ discard block |
||
| 106 | 106 | * @return string Retourne l'alea éphemère actuel au passage |
| 107 | 107 | */ |
| 108 | 108 | function charger_aleas() { |
| 109 | - if (!isset($GLOBALS['meta']['alea_ephemere'])) { |
|
| 110 | - include_spip('base/abstract_sql'); |
|
| 111 | - $aleas = sql_allfetsel( |
|
| 112 | - ['nom', 'valeur'], |
|
| 113 | - 'spip_meta', |
|
| 114 | - sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']), |
|
| 115 | - '', |
|
| 116 | - '', |
|
| 117 | - '', |
|
| 118 | - '', |
|
| 119 | - '', |
|
| 120 | - 'continue' |
|
| 121 | - ); |
|
| 122 | - if ($aleas) { |
|
| 123 | - foreach ($aleas as $a) { |
|
| 124 | - $GLOBALS['meta'][$a['nom']] = $a['valeur']; |
|
| 125 | - } |
|
| 126 | - return $GLOBALS['meta']['alea_ephemere']; |
|
| 127 | - } else { |
|
| 128 | - spip_log('aleas indisponibles', 'session'); |
|
| 129 | - return ''; |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - return $GLOBALS['meta']['alea_ephemere']; |
|
| 109 | + if (!isset($GLOBALS['meta']['alea_ephemere'])) { |
|
| 110 | + include_spip('base/abstract_sql'); |
|
| 111 | + $aleas = sql_allfetsel( |
|
| 112 | + ['nom', 'valeur'], |
|
| 113 | + 'spip_meta', |
|
| 114 | + sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']), |
|
| 115 | + '', |
|
| 116 | + '', |
|
| 117 | + '', |
|
| 118 | + '', |
|
| 119 | + '', |
|
| 120 | + 'continue' |
|
| 121 | + ); |
|
| 122 | + if ($aleas) { |
|
| 123 | + foreach ($aleas as $a) { |
|
| 124 | + $GLOBALS['meta'][$a['nom']] = $a['valeur']; |
|
| 125 | + } |
|
| 126 | + return $GLOBALS['meta']['alea_ephemere']; |
|
| 127 | + } else { |
|
| 128 | + spip_log('aleas indisponibles', 'session'); |
|
| 129 | + return ''; |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + return $GLOBALS['meta']['alea_ephemere']; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | 136 | * Renouveller l'alea (utilisé pour sécuriser les scripts du répertoire `action/`) |
| 137 | 137 | **/ |
| 138 | 138 | function renouvelle_alea() { |
| 139 | - charger_aleas(); |
|
| 140 | - ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non'); |
|
| 141 | - $GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid()); |
|
| 142 | - ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non'); |
|
| 143 | - ecrire_meta('alea_ephemere_date', time(), 'non'); |
|
| 144 | - spip_log("renouvellement de l'alea_ephemere"); |
|
| 139 | + charger_aleas(); |
|
| 140 | + ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non'); |
|
| 141 | + $GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid()); |
|
| 142 | + ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non'); |
|
| 143 | + ecrire_meta('alea_ephemere_date', time(), 'non'); |
|
| 144 | + spip_log("renouvellement de l'alea_ephemere"); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | |
@@ -161,21 +161,21 @@ discard block |
||
| 161 | 161 | * Clé de sécurité. |
| 162 | 162 | **/ |
| 163 | 163 | function low_sec($id_auteur) { |
| 164 | - // Pas d'id_auteur : low_sec |
|
| 165 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 166 | - include_spip('inc/config'); |
|
| 167 | - if (!$low_sec = lire_config('low_sec')) { |
|
| 168 | - ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire()); |
|
| 169 | - } |
|
| 170 | - } else { |
|
| 171 | - $low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . intval($id_auteur)); |
|
| 172 | - if (!$low_sec) { |
|
| 173 | - $low_sec = creer_pass_aleatoire(); |
|
| 174 | - sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . intval($id_auteur)); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - return $low_sec; |
|
| 164 | + // Pas d'id_auteur : low_sec |
|
| 165 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 166 | + include_spip('inc/config'); |
|
| 167 | + if (!$low_sec = lire_config('low_sec')) { |
|
| 168 | + ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire()); |
|
| 169 | + } |
|
| 170 | + } else { |
|
| 171 | + $low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . intval($id_auteur)); |
|
| 172 | + if (!$low_sec) { |
|
| 173 | + $low_sec = creer_pass_aleatoire(); |
|
| 174 | + sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . intval($id_auteur)); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + return $low_sec; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | |
@@ -208,11 +208,11 @@ discard block |
||
| 208 | 208 | * @filtre |
| 209 | 209 | */ |
| 210 | 210 | function securiser_acces_low_sec($id_auteur, $cle, $dir, $op = '', $args = '') { |
| 211 | - if ($op) { |
|
| 212 | - $dir .= " $op $args"; |
|
| 213 | - } |
|
| 211 | + if ($op) { |
|
| 212 | + $dir .= " $op $args"; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - return verifier_low_sec($id_auteur, $cle, $dir); |
|
| 215 | + return verifier_low_sec($id_auteur, $cle, $dir); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -227,11 +227,11 @@ discard block |
||
| 227 | 227 | * @return string |
| 228 | 228 | */ |
| 229 | 229 | function generer_url_api_low_sec(string $script, string $format, string $fond, string $path, string $args, bool $no_entities = false, ?bool $public = null) { |
| 230 | - $id_auteur = $GLOBALS['visiteur_session']['id_auteur'] ?? 0; |
|
| 231 | - $cle = afficher_low_sec($id_auteur, "$script/$format $fond $args"); |
|
| 232 | - $path = "$id_auteur/$cle/$format/$fond" . ($path ? "/$path" : ''); |
|
| 230 | + $id_auteur = $GLOBALS['visiteur_session']['id_auteur'] ?? 0; |
|
| 231 | + $cle = afficher_low_sec($id_auteur, "$script/$format $fond $args"); |
|
| 232 | + $path = "$id_auteur/$cle/$format/$fond" . ($path ? "/$path" : ''); |
|
| 233 | 233 | |
| 234 | - return generer_url_api($script, $path, $args, $no_entities = false, $public); |
|
| 234 | + return generer_url_api($script, $path, $args, $no_entities = false, $public); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
@@ -249,27 +249,27 @@ discard block |
||
| 249 | 249 | * @deprecated 4.1 |
| 250 | 250 | */ |
| 251 | 251 | function param_low_sec($op, $args = [], $lang = '', $mime = 'rss') { |
| 252 | - $a = $b = ''; |
|
| 253 | - foreach ($args as $val => $var) { |
|
| 254 | - if ($var) { |
|
| 255 | - if ($val <> 'statut') { |
|
| 256 | - $a .= ':' . $val . '-' . $var; |
|
| 257 | - } |
|
| 258 | - $b .= $val . '=' . $var . '&'; |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - $a = substr($a, 1); |
|
| 262 | - $id = intval(@$GLOBALS['connect_id_auteur']); |
|
| 263 | - |
|
| 264 | - return $b |
|
| 265 | - . 'op=' |
|
| 266 | - . $op |
|
| 267 | - . '&id=' |
|
| 268 | - . $id |
|
| 269 | - . '&cle=' |
|
| 270 | - . afficher_low_sec($id, "$mime $op $a") |
|
| 271 | - . (!$a ? '' : "&args=$a") |
|
| 272 | - . (!$lang ? '' : "&lang=$lang"); |
|
| 252 | + $a = $b = ''; |
|
| 253 | + foreach ($args as $val => $var) { |
|
| 254 | + if ($var) { |
|
| 255 | + if ($val <> 'statut') { |
|
| 256 | + $a .= ':' . $val . '-' . $var; |
|
| 257 | + } |
|
| 258 | + $b .= $val . '=' . $var . '&'; |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + $a = substr($a, 1); |
|
| 262 | + $id = intval(@$GLOBALS['connect_id_auteur']); |
|
| 263 | + |
|
| 264 | + return $b |
|
| 265 | + . 'op=' |
|
| 266 | + . $op |
|
| 267 | + . '&id=' |
|
| 268 | + . $id |
|
| 269 | + . '&cle=' |
|
| 270 | + . afficher_low_sec($id, "$mime $op $a") |
|
| 271 | + . (!$a ? '' : "&args=$a") |
|
| 272 | + . (!$lang ? '' : "&lang=$lang"); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * Clé |
| 286 | 286 | **/ |
| 287 | 287 | function afficher_low_sec($id_auteur, $action = '') { |
| 288 | - return substr(md5($action . low_sec($id_auteur)), 0, 8); |
|
| 288 | + return substr(md5($action . low_sec($id_auteur)), 0, 8); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * true si les clés corresponde, false sinon |
| 304 | 304 | **/ |
| 305 | 305 | function verifier_low_sec($id_auteur, $cle, $action = '') { |
| 306 | - return ($cle == afficher_low_sec($id_auteur, $action)); |
|
| 306 | + return ($cle == afficher_low_sec($id_auteur, $action)); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | * Identifiant de l'auteur |
| 314 | 314 | **/ |
| 315 | 315 | function effacer_low_sec($id_auteur) { |
| 316 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 317 | - return; |
|
| 318 | - } // jamais trop prudent ;) |
|
| 319 | - sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . intval($id_auteur)); |
|
| 316 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 317 | + return; |
|
| 318 | + } // jamais trop prudent ;) |
|
| 319 | + sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . intval($id_auteur)); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | |
@@ -334,31 +334,31 @@ discard block |
||
| 334 | 334 | * - void sinon. |
| 335 | 335 | **/ |
| 336 | 336 | function ecrire_acces() { |
| 337 | - $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 338 | - $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 339 | - |
|
| 340 | - // Cette variable de configuration peut etre posee par un plugin |
|
| 341 | - // par exemple acces_restreint ; |
|
| 342 | - // si .htaccess existe, outrepasser spip_meta |
|
| 343 | - if ( |
|
| 344 | - (!isset($GLOBALS['meta']['creer_htpasswd']) |
|
| 345 | - or ($GLOBALS['meta']['creer_htpasswd'] != 'oui')) |
|
| 346 | - and !@file_exists($htaccess) |
|
| 347 | - ) { |
|
| 348 | - spip_unlink($htpasswd); |
|
| 349 | - spip_unlink($htpasswd . '-admin'); |
|
| 350 | - return; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre |
|
| 354 | - # de devenir redacteur le cas echeant (auth http)... a nettoyer |
|
| 355 | - // attention, il faut au prealable se connecter a la base (necessaire car utilise par install) |
|
| 356 | - // TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test auth_ldap_connect() |
|
| 357 | - if (include_spip('auth/ldap') and auth_ldap_connect()) { |
|
| 358 | - return; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - generer_htpasswd_files($htpasswd, "$htpasswd-admin"); |
|
| 337 | + $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 338 | + $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 339 | + |
|
| 340 | + // Cette variable de configuration peut etre posee par un plugin |
|
| 341 | + // par exemple acces_restreint ; |
|
| 342 | + // si .htaccess existe, outrepasser spip_meta |
|
| 343 | + if ( |
|
| 344 | + (!isset($GLOBALS['meta']['creer_htpasswd']) |
|
| 345 | + or ($GLOBALS['meta']['creer_htpasswd'] != 'oui')) |
|
| 346 | + and !@file_exists($htaccess) |
|
| 347 | + ) { |
|
| 348 | + spip_unlink($htpasswd); |
|
| 349 | + spip_unlink($htpasswd . '-admin'); |
|
| 350 | + return; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre |
|
| 354 | + # de devenir redacteur le cas echeant (auth http)... a nettoyer |
|
| 355 | + // attention, il faut au prealable se connecter a la base (necessaire car utilise par install) |
|
| 356 | + // TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test auth_ldap_connect() |
|
| 357 | + if (include_spip('auth/ldap') and auth_ldap_connect()) { |
|
| 358 | + return; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + generer_htpasswd_files($htpasswd, "$htpasswd-admin"); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -367,29 +367,29 @@ discard block |
||
| 367 | 367 | * @param $htpasswd_admin |
| 368 | 368 | */ |
| 369 | 369 | function generer_htpasswd_files($htpasswd, $htpasswd_admin) { |
| 370 | - if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) { |
|
| 371 | - $generer_htpasswd($htpasswd, $htpasswd_admin); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - $pwd_all = ''; // login:htpass pour tous |
|
| 375 | - $pwd_admin = ''; // login:htpass pour les admins |
|
| 376 | - |
|
| 377 | - $res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau'])); |
|
| 378 | - while ($row = sql_fetch($res)) { |
|
| 379 | - if (strlen($row['login']) and strlen($row['htpass'])) { |
|
| 380 | - $ligne = $row['login'] . ':' . $row['htpass'] . "\n"; |
|
| 381 | - $pwd_all .= $ligne; |
|
| 382 | - if ($row['statut'] == '0minirezo') { |
|
| 383 | - $pwd_admin .= $ligne; |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - if ($pwd_all) { |
|
| 389 | - ecrire_fichier($htpasswd, $pwd_all); |
|
| 390 | - ecrire_fichier($htpasswd_admin, $pwd_admin); |
|
| 391 | - spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass'); |
|
| 392 | - } |
|
| 370 | + if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) { |
|
| 371 | + $generer_htpasswd($htpasswd, $htpasswd_admin); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + $pwd_all = ''; // login:htpass pour tous |
|
| 375 | + $pwd_admin = ''; // login:htpass pour les admins |
|
| 376 | + |
|
| 377 | + $res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau'])); |
|
| 378 | + while ($row = sql_fetch($res)) { |
|
| 379 | + if (strlen($row['login']) and strlen($row['htpass'])) { |
|
| 380 | + $ligne = $row['login'] . ':' . $row['htpass'] . "\n"; |
|
| 381 | + $pwd_all .= $ligne; |
|
| 382 | + if ($row['statut'] == '0minirezo') { |
|
| 383 | + $pwd_admin .= $ligne; |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + if ($pwd_all) { |
|
| 389 | + ecrire_fichier($htpasswd, $pwd_all); |
|
| 390 | + ecrire_fichier($htpasswd_admin, $pwd_admin); |
|
| 391 | + spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass'); |
|
| 392 | + } |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -403,11 +403,11 @@ discard block |
||
| 403 | 403 | * La chaîne hachée si fonction crypt présente, rien sinon. |
| 404 | 404 | */ |
| 405 | 405 | function generer_htpass($pass) { |
| 406 | - if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) { |
|
| 407 | - return $generer_htpass($pass); |
|
| 408 | - } |
|
| 406 | + if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) { |
|
| 407 | + return $generer_htpass($pass); |
|
| 408 | + } |
|
| 409 | 409 | |
| 410 | - return ''; |
|
| 410 | + return ''; |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -420,14 +420,14 @@ discard block |
||
| 420 | 420 | * @return boolean |
| 421 | 421 | */ |
| 422 | 422 | function verifier_htaccess($rep, $force = false) { |
| 423 | - $htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME; |
|
| 424 | - if (((@file_exists($htaccess)) or defined('_TEST_DIRS')) and !$force) { |
|
| 425 | - return true; |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - // directive deny compatible Apache 2.0+ |
|
| 429 | - $deny = |
|
| 430 | - '# Deny all requests from Apache 2.4+. |
|
| 423 | + $htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME; |
|
| 424 | + if (((@file_exists($htaccess)) or defined('_TEST_DIRS')) and !$force) { |
|
| 425 | + return true; |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + // directive deny compatible Apache 2.0+ |
|
| 429 | + $deny = |
|
| 430 | + '# Deny all requests from Apache 2.4+. |
|
| 431 | 431 | <IfModule mod_authz_core.c> |
| 432 | 432 | Require all denied |
| 433 | 433 | </IfModule> |
@@ -436,32 +436,32 @@ discard block |
||
| 436 | 436 | Deny from all |
| 437 | 437 | </IfModule> |
| 438 | 438 | '; |
| 439 | - // support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD) |
|
| 440 | - if ( |
|
| 441 | - function_exists('apache_get_version') |
|
| 442 | - and $v = apache_get_version() |
|
| 443 | - and strncmp($v, 'Apache/1.', 9) == 0 |
|
| 444 | - ) { |
|
| 445 | - $deny = "deny from all\n"; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - if ($ht = @fopen($htaccess, 'w')) { |
|
| 449 | - fputs($ht, $deny); |
|
| 450 | - fclose($ht); |
|
| 451 | - @chmod($htaccess, _SPIP_CHMOD & 0666); |
|
| 452 | - $t = rtrim($rep, '/') . '/.ok'; |
|
| 453 | - if ($ht = @fopen($t, 'w')) { |
|
| 454 | - @fclose($ht); |
|
| 455 | - include_spip('inc/distant'); |
|
| 456 | - $t = substr($t, strlen(_DIR_RACINE)); |
|
| 457 | - $t = url_de_base() . $t; |
|
| 458 | - $ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]); |
|
| 459 | - $ht = ($ht['status'] ?? null) === 403; |
|
| 460 | - } |
|
| 461 | - } |
|
| 462 | - spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee')); |
|
| 463 | - |
|
| 464 | - return $ht; |
|
| 439 | + // support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD) |
|
| 440 | + if ( |
|
| 441 | + function_exists('apache_get_version') |
|
| 442 | + and $v = apache_get_version() |
|
| 443 | + and strncmp($v, 'Apache/1.', 9) == 0 |
|
| 444 | + ) { |
|
| 445 | + $deny = "deny from all\n"; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + if ($ht = @fopen($htaccess, 'w')) { |
|
| 449 | + fputs($ht, $deny); |
|
| 450 | + fclose($ht); |
|
| 451 | + @chmod($htaccess, _SPIP_CHMOD & 0666); |
|
| 452 | + $t = rtrim($rep, '/') . '/.ok'; |
|
| 453 | + if ($ht = @fopen($t, 'w')) { |
|
| 454 | + @fclose($ht); |
|
| 455 | + include_spip('inc/distant'); |
|
| 456 | + $t = substr($t, strlen(_DIR_RACINE)); |
|
| 457 | + $t = url_de_base() . $t; |
|
| 458 | + $ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]); |
|
| 459 | + $ht = ($ht['status'] ?? null) === 403; |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | + spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee')); |
|
| 463 | + |
|
| 464 | + return $ht; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | /** |
@@ -479,20 +479,20 @@ discard block |
||
| 479 | 479 | * Valeur de la configuration `creer_htaccess` |
| 480 | 480 | */ |
| 481 | 481 | function gerer_htaccess() { |
| 482 | - // Cette variable de configuration peut etre posee par un plugin |
|
| 483 | - // par exemple acces_restreint |
|
| 484 | - $f = (isset($GLOBALS['meta']['creer_htaccess']) and ($GLOBALS['meta']['creer_htaccess'] === 'oui')); |
|
| 485 | - $dirs = sql_allfetsel('extension', 'spip_types_documents'); |
|
| 486 | - $dirs[] = ['extension' => 'distant']; |
|
| 487 | - foreach ($dirs as $e) { |
|
| 488 | - if (is_dir($dir = _DIR_IMG . $e['extension'])) { |
|
| 489 | - if ($f) { |
|
| 490 | - verifier_htaccess($dir); |
|
| 491 | - } else { |
|
| 492 | - spip_unlink($dir . '/' . _ACCESS_FILE_NAME); |
|
| 493 | - } |
|
| 494 | - } |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - return $GLOBALS['meta']['creer_htaccess'] ?? ''; |
|
| 482 | + // Cette variable de configuration peut etre posee par un plugin |
|
| 483 | + // par exemple acces_restreint |
|
| 484 | + $f = (isset($GLOBALS['meta']['creer_htaccess']) and ($GLOBALS['meta']['creer_htaccess'] === 'oui')); |
|
| 485 | + $dirs = sql_allfetsel('extension', 'spip_types_documents'); |
|
| 486 | + $dirs[] = ['extension' => 'distant']; |
|
| 487 | + foreach ($dirs as $e) { |
|
| 488 | + if (is_dir($dir = _DIR_IMG . $e['extension'])) { |
|
| 489 | + if ($f) { |
|
| 490 | + verifier_htaccess($dir); |
|
| 491 | + } else { |
|
| 492 | + spip_unlink($dir . '/' . _ACCESS_FILE_NAME); |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + return $GLOBALS['meta']['creer_htaccess'] ?? ''; |
|
| 498 | 498 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Fonctions |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -29,29 +29,29 @@ discard block |
||
| 29 | 29 | * @param bool $left |
| 30 | 30 | */ |
| 31 | 31 | function critere_compteur_articles_filtres_dist($idb, &$boucles, $crit, $left = false) { |
| 32 | - $boucle = &$boucles[$idb]; |
|
| 32 | + $boucle = &$boucles[$idb]; |
|
| 33 | 33 | |
| 34 | - $_statut = calculer_liste($crit->param[0], [], $boucles, $boucle->id_parent); |
|
| 34 | + $_statut = calculer_liste($crit->param[0], [], $boucles, $boucle->id_parent); |
|
| 35 | 35 | |
| 36 | - $not = ''; |
|
| 37 | - if ($crit->not) { |
|
| 38 | - $not = ", 'NOT'"; |
|
| 39 | - } |
|
| 40 | - $boucle->from['LAA'] = 'spip_auteurs_liens'; |
|
| 41 | - $boucle->from_type['LAA'] = 'left'; |
|
| 42 | - $boucle->join['LAA'] = ["'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''"]; |
|
| 36 | + $not = ''; |
|
| 37 | + if ($crit->not) { |
|
| 38 | + $not = ", 'NOT'"; |
|
| 39 | + } |
|
| 40 | + $boucle->from['LAA'] = 'spip_auteurs_liens'; |
|
| 41 | + $boucle->from_type['LAA'] = 'left'; |
|
| 42 | + $boucle->join['LAA'] = ["'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''"]; |
|
| 43 | 43 | |
| 44 | - $boucle->from['articles'] = 'spip_articles'; |
|
| 45 | - $boucle->from_type['articles'] = 'left'; |
|
| 46 | - $boucle->join['articles'] = [ |
|
| 47 | - "'LAA'", |
|
| 48 | - "'id_article'", |
|
| 49 | - "'id_objet'", |
|
| 50 | - "'(articles.statut IS NULL OR '.sql_in_quote('articles.statut',[$_statut]$not).')'" |
|
| 51 | - ]; |
|
| 44 | + $boucle->from['articles'] = 'spip_articles'; |
|
| 45 | + $boucle->from_type['articles'] = 'left'; |
|
| 46 | + $boucle->join['articles'] = [ |
|
| 47 | + "'LAA'", |
|
| 48 | + "'id_article'", |
|
| 49 | + "'id_objet'", |
|
| 50 | + "'(articles.statut IS NULL OR '.sql_in_quote('articles.statut',[$_statut]$not).')'" |
|
| 51 | + ]; |
|
| 52 | 52 | |
| 53 | - $boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles'; |
|
| 54 | - $boucle->group[] = 'auteurs.id_auteur'; |
|
| 53 | + $boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles'; |
|
| 54 | + $boucle->group[] = 'auteurs.id_auteur'; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * Pile complétée par le code à générer |
| 70 | 70 | */ |
| 71 | 71 | function balise_COMPTEUR_ARTICLES_dist($p) { |
| 72 | - return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres'); |
|
| 72 | + return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -85,44 +85,44 @@ discard block |
||
| 85 | 85 | * @return string |
| 86 | 86 | */ |
| 87 | 87 | function afficher_initiale($url, $initiale, $compteur, $debut, $pas) { |
| 88 | - static $memo = null; |
|
| 89 | - static $res = []; |
|
| 90 | - $out = ''; |
|
| 91 | - if ( |
|
| 92 | - !$memo |
|
| 93 | - or (!$initiale and !$url) |
|
| 94 | - or ($initiale !== $memo['initiale']) |
|
| 95 | - ) { |
|
| 96 | - $newcompt = intval(floor(($compteur - 1) / $pas) * $pas); |
|
| 97 | - // si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien |
|
| 98 | - if (!$initiale and !$url and !$memo['compteur']) { |
|
| 99 | - $memo = null; |
|
| 100 | - } |
|
| 101 | - if ($memo) { |
|
| 102 | - $on = (($memo['compteur'] <= $debut) |
|
| 103 | - and ( |
|
| 104 | - $newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur']) |
|
| 105 | - )); |
|
| 106 | - $res[] = "<li class='pagination-item'>" . lien_ou_expose($memo['url'], $memo['initiale'], $on ? 'span.pagination-item-label' : '', 'pagination-item-label lien_pagination') . '</li>'; |
|
| 107 | - } |
|
| 108 | - if ($initiale) { |
|
| 109 | - $memo = [ |
|
| 110 | - 'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0, |
|
| 111 | - 'initiale' => $initiale, |
|
| 112 | - 'url' => parametre_url($url, 'i', $initiale), |
|
| 113 | - 'compteur' => $newcompt |
|
| 114 | - ]; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - if (!$initiale and !$url) { |
|
| 118 | - if ((is_countable($res) ? count($res) : 0) > 1) { |
|
| 119 | - $out = "<ul class='pagination-items'>" . implode(' ', $res) . '</ul>'; |
|
| 120 | - } |
|
| 121 | - $memo = null; |
|
| 122 | - $res = []; |
|
| 123 | - } |
|
| 88 | + static $memo = null; |
|
| 89 | + static $res = []; |
|
| 90 | + $out = ''; |
|
| 91 | + if ( |
|
| 92 | + !$memo |
|
| 93 | + or (!$initiale and !$url) |
|
| 94 | + or ($initiale !== $memo['initiale']) |
|
| 95 | + ) { |
|
| 96 | + $newcompt = intval(floor(($compteur - 1) / $pas) * $pas); |
|
| 97 | + // si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien |
|
| 98 | + if (!$initiale and !$url and !$memo['compteur']) { |
|
| 99 | + $memo = null; |
|
| 100 | + } |
|
| 101 | + if ($memo) { |
|
| 102 | + $on = (($memo['compteur'] <= $debut) |
|
| 103 | + and ( |
|
| 104 | + $newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur']) |
|
| 105 | + )); |
|
| 106 | + $res[] = "<li class='pagination-item'>" . lien_ou_expose($memo['url'], $memo['initiale'], $on ? 'span.pagination-item-label' : '', 'pagination-item-label lien_pagination') . '</li>'; |
|
| 107 | + } |
|
| 108 | + if ($initiale) { |
|
| 109 | + $memo = [ |
|
| 110 | + 'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0, |
|
| 111 | + 'initiale' => $initiale, |
|
| 112 | + 'url' => parametre_url($url, 'i', $initiale), |
|
| 113 | + 'compteur' => $newcompt |
|
| 114 | + ]; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + if (!$initiale and !$url) { |
|
| 118 | + if ((is_countable($res) ? count($res) : 0) > 1) { |
|
| 119 | + $out = "<ul class='pagination-items'>" . implode(' ', $res) . '</ul>'; |
|
| 120 | + } |
|
| 121 | + $memo = null; |
|
| 122 | + $res = []; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - return $out; |
|
| 125 | + return $out; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -141,24 +141,24 @@ discard block |
||
| 141 | 141 | * @return string |
| 142 | 142 | */ |
| 143 | 143 | function auteur_lien_messagerie($id_auteur, $en_ligne, $statut, $imessage, $email = '') { |
| 144 | - static $time = null; |
|
| 145 | - if (!in_array($statut, ['0minirezo', '1comite'])) { |
|
| 146 | - return ''; |
|
| 147 | - } |
|
| 144 | + static $time = null; |
|
| 145 | + if (!in_array($statut, ['0minirezo', '1comite'])) { |
|
| 146 | + return ''; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - if (is_null($time)) { |
|
| 150 | - $time = time(); |
|
| 151 | - } |
|
| 152 | - $parti = (($time - strtotime($en_ligne)) > 15 * 60); |
|
| 149 | + if (is_null($time)) { |
|
| 150 | + $time = time(); |
|
| 151 | + } |
|
| 152 | + $parti = (($time - strtotime($en_ligne)) > 15 * 60); |
|
| 153 | 153 | |
| 154 | - if ( |
|
| 155 | - $imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ? |
|
| 156 | - and $GLOBALS['meta']['messagerie_agenda'] != 'non' |
|
| 157 | - ) { |
|
| 158 | - return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self()); |
|
| 159 | - } elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) { |
|
| 160 | - return 'mailto:' . $email; |
|
| 161 | - } else { |
|
| 162 | - return ''; |
|
| 163 | - } |
|
| 154 | + if ( |
|
| 155 | + $imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ? |
|
| 156 | + and $GLOBALS['meta']['messagerie_agenda'] != 'non' |
|
| 157 | + ) { |
|
| 158 | + return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self()); |
|
| 159 | + } elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) { |
|
| 160 | + return 'mailto:' . $email; |
|
| 161 | + } else { |
|
| 162 | + return ''; |
|
| 163 | + } |
|
| 164 | 164 | } |