@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $test_dir .= '/'; |
| 82 | 82 | } |
| 83 | 83 | if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
| 84 | - $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 84 | + $GLOBALS['test_dirs'][] = _DIR_RACINE.$test_dir; |
|
| 85 | 85 | } |
| 86 | 86 | } else { |
| 87 | 87 | if (!_FILE_CONNECT) { |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
| 97 | 97 | $test = test_ecrire($my_dir); |
| 98 | 98 | if (!$test) { |
| 99 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 99 | + $m = preg_replace(',^'._DIR_RACINE.',', '', $my_dir); |
|
| 100 | 100 | if (@file_exists($my_dir)) { |
| 101 | - $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 101 | + $bad_dirs['<li>'.$m.'</li>'] = 1; |
|
| 102 | 102 | } else { |
| 103 | - $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 103 | + $absent_dirs['<li>'.$m.'</li>'] = 1; |
|
| 104 | 104 | } |
| 105 | 105 | } else { |
| 106 | 106 | $chmod = max($chmod, $test); |
@@ -110,21 +110,21 @@ discard block |
||
| 110 | 110 | if ($bad_dirs or $absent_dirs) { |
| 111 | 111 | if (!_FILE_CONNECT) { |
| 112 | 112 | $titre = _T('dirs_preliminaire'); |
| 113 | - $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 113 | + $continuer = ' '._T('dirs_commencer').'.'; |
|
| 114 | 114 | } else { |
| 115 | 115 | $titre = _T('dirs_probleme_droits'); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
| 119 | - $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 119 | + $res = "<div align='right'>".menu_langues('var_lang_ecrire')."</div>\n"; |
|
| 120 | 120 | |
| 121 | 121 | if ($bad_dirs) { |
| 122 | 122 | $res .= |
| 123 | 123 | _T( |
| 124 | 124 | 'dirs_repertoires_suivants', |
| 125 | 125 | ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
| 126 | - ) . |
|
| 127 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 126 | + ). |
|
| 127 | + '<b>'._T('login_recharger').'</b>.'; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | if ($absent_dirs) { |
@@ -132,22 +132,21 @@ discard block |
||
| 132 | 132 | _T( |
| 133 | 133 | 'dirs_repertoires_absents', |
| 134 | 134 | ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
| 135 | - ) . |
|
| 136 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 135 | + ). |
|
| 136 | + '<b>'._T('login_recharger').'</b>.'; |
|
| 137 | 137 | } |
| 138 | - $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 138 | + $res = '<p>'.$continuer.$res.aider('install0', true).'</p>'; |
|
| 139 | 139 | |
| 140 | 140 | $t = _T('login_recharger'); |
| 141 | - $t = (!$test_dir ? '' : |
|
| 142 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 141 | + $t = (!$test_dir ? '' : "<input type='hidden' name='test_dir' value='".spip_htmlspecialchars($test_dir, ENT_QUOTES)."' />") |
|
| 143 | 142 | . "<input type='hidden' name='etape' value='chmod' />" |
| 144 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 143 | + . "<div style='text-align: right'><input type='submit' value='".attribut_html($t)."' /></div>"; |
|
| 145 | 144 | |
| 146 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 145 | + echo minipres($titre, $res.generer_form_ecrire('install', $t)); |
|
| 147 | 146 | } else { |
| 148 | 147 | $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
| 149 | 148 | if (!$deja) { |
| 150 | - redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 149 | + redirige_url_ecrire('install', 'etape=1&chmod='.$chmod); |
|
| 151 | 150 | } else { |
| 152 | 151 | redirige_url_ecrire(); |
| 153 | 152 | } |
@@ -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 | |
@@ -27,42 +27,42 @@ discard block |
||
| 27 | 27 | // |
| 28 | 28 | // https://code.spip.net/@test_ecrire |
| 29 | 29 | function test_ecrire($my_dir) { |
| 30 | - static $chmod = 0; |
|
| 31 | - |
|
| 32 | - $ok = false; |
|
| 33 | - $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 34 | - $self = basename($script); |
|
| 35 | - $uid = @fileowner('.'); |
|
| 36 | - $uid2 = @fileowner($self); |
|
| 37 | - $gid = @filegroup('.'); |
|
| 38 | - $gid2 = @filegroup($self); |
|
| 39 | - $perms = @fileperms($self); |
|
| 40 | - |
|
| 41 | - // Comparer l'appartenance d'un fichier cree par PHP |
|
| 42 | - // avec celle du script et du repertoire courant |
|
| 43 | - if (!$chmod) { |
|
| 44 | - @rmdir('test'); |
|
| 45 | - spip_unlink('test'); // effacer au cas ou |
|
| 46 | - @touch('test'); |
|
| 47 | - if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 48 | - $chmod = 0700; |
|
| 49 | - } else { |
|
| 50 | - if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 51 | - $chmod = 0770; |
|
| 52 | - } else { |
|
| 53 | - $chmod = 0777; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - // Appliquer de plus les droits d'acces du script |
|
| 57 | - if ($perms > 0) { |
|
| 58 | - $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 59 | - $chmod |= $perms; |
|
| 60 | - } |
|
| 61 | - spip_unlink('test'); |
|
| 62 | - } |
|
| 63 | - $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 64 | - |
|
| 65 | - return $ok ? $chmod : false; |
|
| 30 | + static $chmod = 0; |
|
| 31 | + |
|
| 32 | + $ok = false; |
|
| 33 | + $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 34 | + $self = basename($script); |
|
| 35 | + $uid = @fileowner('.'); |
|
| 36 | + $uid2 = @fileowner($self); |
|
| 37 | + $gid = @filegroup('.'); |
|
| 38 | + $gid2 = @filegroup($self); |
|
| 39 | + $perms = @fileperms($self); |
|
| 40 | + |
|
| 41 | + // Comparer l'appartenance d'un fichier cree par PHP |
|
| 42 | + // avec celle du script et du repertoire courant |
|
| 43 | + if (!$chmod) { |
|
| 44 | + @rmdir('test'); |
|
| 45 | + spip_unlink('test'); // effacer au cas ou |
|
| 46 | + @touch('test'); |
|
| 47 | + if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 48 | + $chmod = 0700; |
|
| 49 | + } else { |
|
| 50 | + if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 51 | + $chmod = 0770; |
|
| 52 | + } else { |
|
| 53 | + $chmod = 0777; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + // Appliquer de plus les droits d'acces du script |
|
| 57 | + if ($perms > 0) { |
|
| 58 | + $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 59 | + $chmod |= $perms; |
|
| 60 | + } |
|
| 61 | + spip_unlink('test'); |
|
| 62 | + } |
|
| 63 | + $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 64 | + |
|
| 65 | + return $ok ? $chmod : false; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // |
@@ -73,84 +73,84 @@ discard block |
||
| 73 | 73 | // https://code.spip.net/@install_etape_chmod_dist |
| 74 | 74 | function install_etape_chmod_dist() { |
| 75 | 75 | |
| 76 | - $continuer = null; |
|
| 77 | - $test_dir = _request('test_dir'); |
|
| 78 | - $chmod = 0; |
|
| 79 | - |
|
| 80 | - if ($test_dir) { |
|
| 81 | - if (substr($test_dir, -1) !== '/') { |
|
| 82 | - $test_dir .= '/'; |
|
| 83 | - } |
|
| 84 | - if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 85 | - $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 86 | - } |
|
| 87 | - } else { |
|
| 88 | - if (!_FILE_CONNECT) { |
|
| 89 | - $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 90 | - $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - $bad_dirs = []; |
|
| 95 | - $absent_dirs = []; |
|
| 96 | - |
|
| 97 | - foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 98 | - $test = test_ecrire($my_dir); |
|
| 99 | - if (!$test) { |
|
| 100 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 101 | - if (@file_exists($my_dir)) { |
|
| 102 | - $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 103 | - } else { |
|
| 104 | - $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 105 | - } |
|
| 106 | - } else { |
|
| 107 | - $chmod = max($chmod, $test); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - if ($bad_dirs or $absent_dirs) { |
|
| 112 | - if (!_FILE_CONNECT) { |
|
| 113 | - $titre = _T('dirs_preliminaire'); |
|
| 114 | - $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 115 | - } else { |
|
| 116 | - $titre = _T('dirs_probleme_droits'); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 121 | - |
|
| 122 | - if ($bad_dirs) { |
|
| 123 | - $res .= |
|
| 124 | - _T( |
|
| 125 | - 'dirs_repertoires_suivants', |
|
| 126 | - ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
|
| 127 | - ) . |
|
| 128 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - if ($absent_dirs) { |
|
| 132 | - $res .= |
|
| 133 | - _T( |
|
| 134 | - 'dirs_repertoires_absents', |
|
| 135 | - ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
|
| 136 | - ) . |
|
| 137 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 138 | - } |
|
| 139 | - $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 140 | - |
|
| 141 | - $t = _T('login_recharger'); |
|
| 142 | - $t = (!$test_dir ? '' : |
|
| 143 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 144 | - . "<input type='hidden' name='etape' value='chmod' />" |
|
| 145 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 146 | - |
|
| 147 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 148 | - } else { |
|
| 149 | - $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 150 | - if (!$deja) { |
|
| 151 | - redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 152 | - } else { |
|
| 153 | - redirige_url_ecrire(); |
|
| 154 | - } |
|
| 155 | - } |
|
| 76 | + $continuer = null; |
|
| 77 | + $test_dir = _request('test_dir'); |
|
| 78 | + $chmod = 0; |
|
| 79 | + |
|
| 80 | + if ($test_dir) { |
|
| 81 | + if (substr($test_dir, -1) !== '/') { |
|
| 82 | + $test_dir .= '/'; |
|
| 83 | + } |
|
| 84 | + if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 85 | + $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 86 | + } |
|
| 87 | + } else { |
|
| 88 | + if (!_FILE_CONNECT) { |
|
| 89 | + $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 90 | + $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + $bad_dirs = []; |
|
| 95 | + $absent_dirs = []; |
|
| 96 | + |
|
| 97 | + foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 98 | + $test = test_ecrire($my_dir); |
|
| 99 | + if (!$test) { |
|
| 100 | + $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 101 | + if (@file_exists($my_dir)) { |
|
| 102 | + $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 103 | + } else { |
|
| 104 | + $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 105 | + } |
|
| 106 | + } else { |
|
| 107 | + $chmod = max($chmod, $test); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + if ($bad_dirs or $absent_dirs) { |
|
| 112 | + if (!_FILE_CONNECT) { |
|
| 113 | + $titre = _T('dirs_preliminaire'); |
|
| 114 | + $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 115 | + } else { |
|
| 116 | + $titre = _T('dirs_probleme_droits'); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 121 | + |
|
| 122 | + if ($bad_dirs) { |
|
| 123 | + $res .= |
|
| 124 | + _T( |
|
| 125 | + 'dirs_repertoires_suivants', |
|
| 126 | + ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
|
| 127 | + ) . |
|
| 128 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + if ($absent_dirs) { |
|
| 132 | + $res .= |
|
| 133 | + _T( |
|
| 134 | + 'dirs_repertoires_absents', |
|
| 135 | + ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
|
| 136 | + ) . |
|
| 137 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 138 | + } |
|
| 139 | + $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 140 | + |
|
| 141 | + $t = _T('login_recharger'); |
|
| 142 | + $t = (!$test_dir ? '' : |
|
| 143 | + "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 144 | + . "<input type='hidden' name='etape' value='chmod' />" |
|
| 145 | + . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 146 | + |
|
| 147 | + echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 148 | + } else { |
|
| 149 | + $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 150 | + if (!$deja) { |
|
| 151 | + redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 152 | + } else { |
|
| 153 | + redirige_url_ecrire(); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | 156 | } |
@@ -11,98 +11,98 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('auth/ldap'); |
| 18 | 18 | |
| 19 | 19 | // https://code.spip.net/@install_etape_ldap4_dist |
| 20 | 20 | function install_etape_ldap4_dist() { |
| 21 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 22 | - $login_ldap = _request('login_ldap'); |
|
| 23 | - $pass_ldap = _request('pass_ldap'); |
|
| 24 | - $port_ldap = _request('port_ldap'); |
|
| 25 | - $base_ldap = _request('base_ldap'); |
|
| 26 | - $base_ldap_text = _request('base_ldap_text'); |
|
| 27 | - if (!$base_ldap) { |
|
| 28 | - $base_ldap = $base_ldap_text; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 32 | - |
|
| 33 | - $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 34 | - @ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 35 | - |
|
| 36 | - // Essayer de verifier le chemin fourni |
|
| 37 | - $r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', ''); |
|
| 38 | - $fail = (ldap_errno($ldap_link) == 32); |
|
| 39 | - |
|
| 40 | - if ($fail) { |
|
| 41 | - echo info_etape(_T('info_chemin_acces_annuaire')), |
|
| 42 | - info_progression_etape(3, 'etape_ldap', 'install/', true), |
|
| 43 | - "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'), |
|
| 44 | - ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>'; |
|
| 45 | - } else { |
|
| 46 | - info_etape(_T('info_reglage_ldap')); |
|
| 47 | - echo info_progression_etape(4, 'etape_ldap', 'install/'); |
|
| 48 | - |
|
| 49 | - $statuts = liste_statuts_ldap(); |
|
| 50 | - $statut_ldap = defined('_INSTALL_STATUT_LDAP') |
|
| 51 | - ? _INSTALL_STATUT_LDAP |
|
| 52 | - : $GLOBALS['liste_des_statuts']['info_redacteurs']; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - $res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
|
| 56 | - . "<input type='hidden' name='etape' value='ldap5' />" |
|
| 57 | - . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />" |
|
| 58 | - . fieldset( |
|
| 59 | - _T('info_statut_utilisateurs_1'), |
|
| 60 | - [ |
|
| 61 | - 'statut_ldap' => [ |
|
| 62 | - 'label' => _T('info_statut_utilisateurs_2') . '<br />', |
|
| 63 | - 'valeur' => $statut_ldap, |
|
| 64 | - 'alternatives' => $statuts |
|
| 65 | - ] |
|
| 66 | - ] |
|
| 67 | - ) |
|
| 68 | - . install_ldap_correspondances() |
|
| 69 | - . bouton_suivant(); |
|
| 70 | - |
|
| 71 | - echo generer_form_ecrire('install', $res); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - echo install_fin_html(); |
|
| 21 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 22 | + $login_ldap = _request('login_ldap'); |
|
| 23 | + $pass_ldap = _request('pass_ldap'); |
|
| 24 | + $port_ldap = _request('port_ldap'); |
|
| 25 | + $base_ldap = _request('base_ldap'); |
|
| 26 | + $base_ldap_text = _request('base_ldap_text'); |
|
| 27 | + if (!$base_ldap) { |
|
| 28 | + $base_ldap = $base_ldap_text; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 32 | + |
|
| 33 | + $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 34 | + @ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 35 | + |
|
| 36 | + // Essayer de verifier le chemin fourni |
|
| 37 | + $r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', ''); |
|
| 38 | + $fail = (ldap_errno($ldap_link) == 32); |
|
| 39 | + |
|
| 40 | + if ($fail) { |
|
| 41 | + echo info_etape(_T('info_chemin_acces_annuaire')), |
|
| 42 | + info_progression_etape(3, 'etape_ldap', 'install/', true), |
|
| 43 | + "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'), |
|
| 44 | + ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>'; |
|
| 45 | + } else { |
|
| 46 | + info_etape(_T('info_reglage_ldap')); |
|
| 47 | + echo info_progression_etape(4, 'etape_ldap', 'install/'); |
|
| 48 | + |
|
| 49 | + $statuts = liste_statuts_ldap(); |
|
| 50 | + $statut_ldap = defined('_INSTALL_STATUT_LDAP') |
|
| 51 | + ? _INSTALL_STATUT_LDAP |
|
| 52 | + : $GLOBALS['liste_des_statuts']['info_redacteurs']; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + $res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
|
| 56 | + . "<input type='hidden' name='etape' value='ldap5' />" |
|
| 57 | + . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />" |
|
| 58 | + . fieldset( |
|
| 59 | + _T('info_statut_utilisateurs_1'), |
|
| 60 | + [ |
|
| 61 | + 'statut_ldap' => [ |
|
| 62 | + 'label' => _T('info_statut_utilisateurs_2') . '<br />', |
|
| 63 | + 'valeur' => $statut_ldap, |
|
| 64 | + 'alternatives' => $statuts |
|
| 65 | + ] |
|
| 66 | + ] |
|
| 67 | + ) |
|
| 68 | + . install_ldap_correspondances() |
|
| 69 | + . bouton_suivant(); |
|
| 70 | + |
|
| 71 | + echo generer_form_ecrire('install', $res); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + echo install_fin_html(); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // https://code.spip.net/@liste_statuts_ldap |
| 78 | 78 | function liste_statuts_ldap() { |
| 79 | - $recom = [ |
|
| 80 | - 'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'), |
|
| 81 | - 'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'), |
|
| 82 | - 'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />') |
|
| 83 | - ]; |
|
| 84 | - |
|
| 85 | - $res = []; |
|
| 86 | - foreach ($GLOBALS['liste_des_statuts'] as $k => $v) { |
|
| 87 | - if (isset($recom[$k])) { |
|
| 88 | - $res[$v] = $recom[$k]; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - return $res; |
|
| 79 | + $recom = [ |
|
| 80 | + 'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'), |
|
| 81 | + 'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'), |
|
| 82 | + 'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />') |
|
| 83 | + ]; |
|
| 84 | + |
|
| 85 | + $res = []; |
|
| 86 | + foreach ($GLOBALS['liste_des_statuts'] as $k => $v) { |
|
| 87 | + if (isset($recom[$k])) { |
|
| 88 | + $res[$v] = $recom[$k]; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + return $res; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | function install_ldap_correspondances() { |
| 96 | - $champs = []; |
|
| 97 | - foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) { |
|
| 98 | - $nom = 'ldap_' . $champ; |
|
| 99 | - $val = is_array($v) ? join(',', $v) : strval($v); |
|
| 100 | - $champs[$nom] = [ |
|
| 101 | - 'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />', |
|
| 102 | - 'valeur' => $val |
|
| 103 | - ]; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return !$champs ? |
|
| 107 | - '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />'); |
|
| 96 | + $champs = []; |
|
| 97 | + foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) { |
|
| 98 | + $nom = 'ldap_' . $champ; |
|
| 99 | + $val = is_array($v) ? join(',', $v) : strval($v); |
|
| 100 | + $champs[$nom] = [ |
|
| 101 | + 'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />', |
|
| 102 | + 'valeur' => $val |
|
| 103 | + ]; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return !$champs ? |
|
| 107 | + '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />'); |
|
| 108 | 108 | } |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | if ($fail) { |
| 41 | 41 | echo info_etape(_T('info_chemin_acces_annuaire')), |
| 42 | 42 | info_progression_etape(3, 'etape_ldap', 'install/', true), |
| 43 | - "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'), |
|
| 44 | - ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>'; |
|
| 43 | + "<div class='error'><p><b>"._T('avis_operation_echec').'</b></p><p>'._T('avis_chemin_invalide_1'), |
|
| 44 | + ' (<tt>'.spip_htmlspecialchars($base_ldap).'</tt>) '._T('avis_chemin_invalide_2').'</p></div>'; |
|
| 45 | 45 | } else { |
| 46 | 46 | info_etape(_T('info_reglage_ldap')); |
| 47 | 47 | echo info_progression_etape(4, 'etape_ldap', 'install/'); |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
| 56 | 56 | . "<input type='hidden' name='etape' value='ldap5' />" |
| 57 | - . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />" |
|
| 57 | + . "<input type='hidden' name='base_ldap' value='".spip_htmlentities($base_ldap)."' />" |
|
| 58 | 58 | . fieldset( |
| 59 | 59 | _T('info_statut_utilisateurs_1'), |
| 60 | 60 | [ |
| 61 | 61 | 'statut_ldap' => [ |
| 62 | - 'label' => _T('info_statut_utilisateurs_2') . '<br />', |
|
| 62 | + 'label' => _T('info_statut_utilisateurs_2').'<br />', |
|
| 63 | 63 | 'valeur' => $statut_ldap, |
| 64 | 64 | 'alternatives' => $statuts |
| 65 | 65 | ] |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | // https://code.spip.net/@liste_statuts_ldap |
| 78 | 78 | function liste_statuts_ldap() { |
| 79 | 79 | $recom = [ |
| 80 | - 'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'), |
|
| 81 | - 'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'), |
|
| 82 | - 'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />') |
|
| 80 | + 'info_administrateurs' => ('<b>'._T('info_administrateur_1').'</b> '._T('info_administrateur_2').'<br />'), |
|
| 81 | + 'info_redacteurs' => ('<b>'._T('info_redacteur_1').'</b> '._T('info_redacteur_2').'<br />'), |
|
| 82 | + 'info_visiteurs' => ('<b>'._T('info_visiteur_1').'</b> '._T('info_visiteur_2').'<br />') |
|
| 83 | 83 | ]; |
| 84 | 84 | |
| 85 | 85 | $res = []; |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | function install_ldap_correspondances() { |
| 96 | 96 | $champs = []; |
| 97 | 97 | foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) { |
| 98 | - $nom = 'ldap_' . $champ; |
|
| 98 | + $nom = 'ldap_'.$champ; |
|
| 99 | 99 | $val = is_array($v) ? join(',', $v) : strval($v); |
| 100 | 100 | $champs[$nom] = [ |
| 101 | - 'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />', |
|
| 101 | + 'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]).'<br />', |
|
| 102 | 102 | 'valeur' => $val |
| 103 | 103 | ]; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | return !$champs ? |
| 107 | - '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />'); |
|
| 107 | + '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2').'<br /><br />'); |
|
| 108 | 108 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
| 46 | 46 | |
| 47 | 47 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 48 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 48 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 49 | 49 | |
| 50 | 50 | $fquery = sql_serveur('query', $server_db); |
| 51 | 51 | if ($choix_db == 'new_spip') { |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | if (!$ok) { |
| 56 | 56 | $re = "Impossible de creer la base $re"; |
| 57 | 57 | spip_log($re); |
| 58 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 58 | + return '<p>'._T('avis_connexion_erreur_creer_base')."</p><!--\n$re\n-->"; |
|
| 59 | 59 | } |
| 60 | 60 | } else { |
| 61 | 61 | $re = "Le nom de la base doit correspondre a $re"; |
| 62 | 62 | spip_log($re); |
| 63 | 63 | |
| 64 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 64 | + return '<p>'._T('avis_connexion_erreur_nom_base')."</p><!--\n$re\n-->"; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
| 73 | 73 | |
| 74 | 74 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 75 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 75 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 76 | 76 | |
| 77 | 77 | // Completer le tableau decrivant la connexion |
| 78 | 78 | |
| 79 | 79 | $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
| 80 | 80 | $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
| 81 | 81 | |
| 82 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 82 | + $old = sql_showbase($table_prefix.'_meta', $server_db); |
|
| 83 | 83 | if ($old) { |
| 84 | 84 | $old = sql_fetch($old, $server_db); |
| 85 | 85 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $charset['charset']; |
| 99 | 99 | $charsetbase = $charset['charset']; |
| 100 | 100 | } else { |
| 101 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 101 | + spip_log(_DEFAULT_CHARSET.' inconnu du serveur SQL'); |
|
| 102 | 102 | $charsetbase = 'standard'; |
| 103 | 103 | } |
| 104 | 104 | spip_log("Creation des tables. Codage $charsetbase"); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | if ($r) { |
| 149 | 149 | $r = sql_fetch($r, $server_db); |
| 150 | 150 | } |
| 151 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 151 | + $version_installee = !$r ? 0 : (double) $r['valeur']; |
|
| 152 | 152 | if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
| 153 | 153 | $fupdateq( |
| 154 | 154 | 'spip_meta', |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | '', |
| 158 | 158 | $server_db |
| 159 | 159 | ); |
| 160 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 160 | + spip_log('nouvelle version installee: '.$GLOBALS['spip_version_base']); |
|
| 161 | 161 | } |
| 162 | 162 | // eliminer la derniere operation d'admin mal terminee |
| 163 | 163 | // notamment la mise a jour |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | if ($chmod_db) { |
| 185 | 185 | install_fichier_connexion( |
| 186 | 186 | _FILE_CHMOD_TMP, |
| 187 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 187 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', ".sprintf('0%3o', $chmod_db).");\n" |
|
| 188 | 188 | ); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -249,16 +249,16 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | // https://code.spip.net/@install_premier_auteur |
| 251 | 251 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 252 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 252 | + return info_progression_etape(3, 'etape_', 'install/'). |
|
| 253 | 253 | info_etape( |
| 254 | 254 | _T('info_informations_personnelles'), |
| 255 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | - aider('install5', true) . |
|
| 257 | - '<p>' . |
|
| 255 | + '<b>'._T('texte_informations_personnelles_1').'</b>'. |
|
| 256 | + aider('install5', true). |
|
| 257 | + '<p>'. |
|
| 258 | 258 | ($auteur_obligatoire ? |
| 259 | 259 | '' |
| 260 | 260 | : |
| 261 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 261 | + _T('texte_informations_personnelles_2').' '._T('info_laisser_champs_vides') |
|
| 262 | 262 | ) |
| 263 | 263 | ) |
| 264 | 264 | . generer_form_ecrire('install', ( |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | _T('info_identification_publique'), |
| 269 | 269 | [ |
| 270 | 270 | 'nom' => [ |
| 271 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 271 | + 'label' => '<b>'._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n", |
|
| 272 | 272 | 'valeur' => $nom, |
| 273 | 273 | 'required' => $auteur_obligatoire, |
| 274 | 274 | ], |
| 275 | 275 | 'email' => [ |
| 276 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 276 | + 'label' => '<b>'._T('entree_adresse_email')."</b>\n", |
|
| 277 | 277 | 'valeur' => $email, |
| 278 | 278 | ] |
| 279 | 279 | ] |
@@ -283,23 +283,23 @@ discard block |
||
| 283 | 283 | _T('entree_identifiants_connexion'), |
| 284 | 284 | [ |
| 285 | 285 | 'login' => [ |
| 286 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 286 | + 'label' => '<b>'._T('entree_login')."</b><br />\n"._T( |
|
| 287 | 287 | 'info_login_trop_court_car_pluriel', |
| 288 | 288 | ['nb' => _LOGIN_TROP_COURT] |
| 289 | - ) . "\n", |
|
| 289 | + )."\n", |
|
| 290 | 290 | 'valeur' => $login, |
| 291 | 291 | 'required' => $auteur_obligatoire, |
| 292 | 292 | ], |
| 293 | 293 | 'pass' => [ |
| 294 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 294 | + 'label' => '<b>'._T('entree_mot_passe')."</b><br />\n"._T( |
|
| 295 | 295 | 'info_passe_trop_court_car_pluriel', |
| 296 | 296 | ['nb' => _PASS_LONGUEUR_MINI] |
| 297 | - ) . "\n", |
|
| 297 | + )."\n", |
|
| 298 | 298 | 'valeur' => $pass, |
| 299 | 299 | 'required' => $auteur_obligatoire, |
| 300 | 300 | ], |
| 301 | 301 | 'pass_verif' => [ |
| 302 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 302 | + 'label' => '<b>'._T('info_confirmer_passe')."</b><br />\n", |
|
| 303 | 303 | 'valeur' => $pass, |
| 304 | 304 | 'required' => $auteur_obligatoire, |
| 305 | 305 | ] |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | if ($res) { |
| 346 | 346 | $res = info_progression_etape(2, 'etape_', 'install/', true) |
| 347 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 347 | + . "<div class='error'><h3>"._T('avis_operation_echec').'</h3>' |
|
| 348 | 348 | . $res |
| 349 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 349 | + . '<p>'._T('texte_operation_echec').'</p>' |
|
| 350 | 350 | . '</div>'; |
| 351 | 351 | } |
| 352 | 352 | } else { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -20,199 +20,199 @@ discard block |
||
| 20 | 20 | // https://code.spip.net/@install_bases |
| 21 | 21 | function install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db) { |
| 22 | 22 | |
| 23 | - // Prefix des tables : |
|
| 24 | - // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 25 | - // a partir de ce qui est envoye a l'installation |
|
| 26 | - if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 27 | - $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 28 | - ? $GLOBALS['table_prefix'] |
|
| 29 | - : preparer_prefixe_tables(_request('tprefix')); |
|
| 30 | - // S'il est vide on remet spip |
|
| 31 | - if (!$table_prefix) { |
|
| 32 | - $table_prefix = 'spip'; |
|
| 33 | - } |
|
| 34 | - } else { |
|
| 35 | - $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 39 | - [, $adresse_db, $port] = $r; |
|
| 40 | - } else { |
|
| 41 | - $port = ''; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - $GLOBALS['connexions'][$server_db] |
|
| 45 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 46 | - |
|
| 47 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 48 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 49 | - |
|
| 50 | - $fquery = sql_serveur('query', $server_db); |
|
| 51 | - if ($choix_db == 'new_spip') { |
|
| 52 | - $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 53 | - if (preg_match($re, $sel_db)) { |
|
| 54 | - $ok = sql_create_base($sel_db, $server_db); |
|
| 55 | - if (!$ok) { |
|
| 56 | - $re = "Impossible de creer la base $re"; |
|
| 57 | - spip_log($re); |
|
| 58 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 59 | - } |
|
| 60 | - } else { |
|
| 61 | - $re = "Le nom de la base doit correspondre a $re"; |
|
| 62 | - spip_log($re); |
|
| 63 | - |
|
| 64 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 69 | - // un sql_mode |
|
| 70 | - install_mode_appel($server_db, false); |
|
| 71 | - $GLOBALS['connexions'][$server_db] |
|
| 72 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 73 | - |
|
| 74 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 75 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 76 | - |
|
| 77 | - // Completer le tableau decrivant la connexion |
|
| 78 | - |
|
| 79 | - $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 80 | - $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 81 | - |
|
| 82 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 83 | - if ($old) { |
|
| 84 | - $old = sql_fetch($old, $server_db); |
|
| 85 | - } |
|
| 86 | - if (!$old) { |
|
| 87 | - // Si possible, demander au serveur d'envoyer les textes |
|
| 88 | - // dans le codage std de SPIP, |
|
| 89 | - $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 90 | - |
|
| 91 | - if ($charset) { |
|
| 92 | - sql_set_charset($charset['charset'], $server_db); |
|
| 93 | - $GLOBALS['meta']['charset_sql_base'] = |
|
| 94 | - $charset['charset']; |
|
| 95 | - $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 96 | - $charset['collation']; |
|
| 97 | - $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 98 | - $charset['charset']; |
|
| 99 | - $charsetbase = $charset['charset']; |
|
| 100 | - } else { |
|
| 101 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 102 | - $charsetbase = 'standard'; |
|
| 103 | - } |
|
| 104 | - spip_log("Creation des tables. Codage $charsetbase"); |
|
| 105 | - creer_base($server_db); // AT LAST |
|
| 106 | - // memoriser avec quel charset on l'a creee |
|
| 107 | - |
|
| 108 | - if ($charset) { |
|
| 109 | - $t = [ |
|
| 110 | - 'nom' => 'charset_sql_base', |
|
| 111 | - 'valeur' => $charset['charset'], |
|
| 112 | - 'impt' => 'non' |
|
| 113 | - ]; |
|
| 114 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 115 | - $t['nom'] = 'charset_collation_sql_base'; |
|
| 116 | - $t['valeur'] = $charset['collation']; |
|
| 117 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 118 | - $t['nom'] = 'charset_sql_connexion'; |
|
| 119 | - $t['valeur'] = $charset['charset']; |
|
| 120 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 121 | - } |
|
| 122 | - $t = [ |
|
| 123 | - 'nom' => 'version_installee', |
|
| 124 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 125 | - 'impt' => 'non' |
|
| 126 | - ]; |
|
| 127 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 128 | - $t['nom'] = 'nouvelle_install'; |
|
| 129 | - $t['valeur'] = 1; |
|
| 130 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 131 | - // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 132 | - if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 133 | - @sql_insertq( |
|
| 134 | - 'spip_meta', |
|
| 135 | - ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 136 | - '', |
|
| 137 | - $server_db |
|
| 138 | - ); |
|
| 139 | - } |
|
| 140 | - } else { |
|
| 141 | - // pour recreer les tables disparues au besoin |
|
| 142 | - spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 143 | - creer_base($server_db); |
|
| 144 | - $fupdateq = sql_serveur('updateq', $server_db); |
|
| 145 | - |
|
| 146 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 147 | - |
|
| 148 | - if ($r) { |
|
| 149 | - $r = sql_fetch($r, $server_db); |
|
| 150 | - } |
|
| 151 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 152 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 153 | - $fupdateq( |
|
| 154 | - 'spip_meta', |
|
| 155 | - ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 156 | - "nom='version_installee'", |
|
| 157 | - '', |
|
| 158 | - $server_db |
|
| 159 | - ); |
|
| 160 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 161 | - } |
|
| 162 | - // eliminer la derniere operation d'admin mal terminee |
|
| 163 | - // notamment la mise a jour |
|
| 164 | - @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // recuperer le charset de la connexion dans les meta |
|
| 168 | - $charset = ''; |
|
| 169 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 170 | - if ($r) { |
|
| 171 | - $r = sql_fetch($r, $server_db); |
|
| 172 | - } |
|
| 173 | - if ($r) { |
|
| 174 | - $charset = $r['valeur']; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $ligne_rappel = install_mode_appel($server_db); |
|
| 178 | - |
|
| 179 | - $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 180 | - if (!$result_ok) { |
|
| 181 | - return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if ($chmod_db) { |
|
| 185 | - install_fichier_connexion( |
|
| 186 | - _FILE_CHMOD_TMP, |
|
| 187 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 188 | - ); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - // si ce fichier existe a cette etape c'est qu'il provient |
|
| 192 | - // d'une installation qui ne l'a pas cree correctement. |
|
| 193 | - // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 194 | - |
|
| 195 | - if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 196 | - spip_unlink(_FILE_CONNECT); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - install_fichier_connexion( |
|
| 200 | - _FILE_CONNECT_TMP, |
|
| 201 | - $ligne_rappel |
|
| 202 | - . install_connexion( |
|
| 203 | - $adresse_db, |
|
| 204 | - $port, |
|
| 205 | - $login_db, |
|
| 206 | - $pass_db, |
|
| 207 | - $sel_db, |
|
| 208 | - $server_db, |
|
| 209 | - $table_prefix, |
|
| 210 | - '', |
|
| 211 | - $charset |
|
| 212 | - ) |
|
| 213 | - ); |
|
| 214 | - |
|
| 215 | - return ''; |
|
| 23 | + // Prefix des tables : |
|
| 24 | + // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 25 | + // a partir de ce qui est envoye a l'installation |
|
| 26 | + if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 27 | + $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 28 | + ? $GLOBALS['table_prefix'] |
|
| 29 | + : preparer_prefixe_tables(_request('tprefix')); |
|
| 30 | + // S'il est vide on remet spip |
|
| 31 | + if (!$table_prefix) { |
|
| 32 | + $table_prefix = 'spip'; |
|
| 33 | + } |
|
| 34 | + } else { |
|
| 35 | + $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 39 | + [, $adresse_db, $port] = $r; |
|
| 40 | + } else { |
|
| 41 | + $port = ''; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + $GLOBALS['connexions'][$server_db] |
|
| 45 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 46 | + |
|
| 47 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 48 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 49 | + |
|
| 50 | + $fquery = sql_serveur('query', $server_db); |
|
| 51 | + if ($choix_db == 'new_spip') { |
|
| 52 | + $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 53 | + if (preg_match($re, $sel_db)) { |
|
| 54 | + $ok = sql_create_base($sel_db, $server_db); |
|
| 55 | + if (!$ok) { |
|
| 56 | + $re = "Impossible de creer la base $re"; |
|
| 57 | + spip_log($re); |
|
| 58 | + return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 59 | + } |
|
| 60 | + } else { |
|
| 61 | + $re = "Le nom de la base doit correspondre a $re"; |
|
| 62 | + spip_log($re); |
|
| 63 | + |
|
| 64 | + return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 69 | + // un sql_mode |
|
| 70 | + install_mode_appel($server_db, false); |
|
| 71 | + $GLOBALS['connexions'][$server_db] |
|
| 72 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 73 | + |
|
| 74 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 75 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 76 | + |
|
| 77 | + // Completer le tableau decrivant la connexion |
|
| 78 | + |
|
| 79 | + $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 80 | + $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 81 | + |
|
| 82 | + $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 83 | + if ($old) { |
|
| 84 | + $old = sql_fetch($old, $server_db); |
|
| 85 | + } |
|
| 86 | + if (!$old) { |
|
| 87 | + // Si possible, demander au serveur d'envoyer les textes |
|
| 88 | + // dans le codage std de SPIP, |
|
| 89 | + $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 90 | + |
|
| 91 | + if ($charset) { |
|
| 92 | + sql_set_charset($charset['charset'], $server_db); |
|
| 93 | + $GLOBALS['meta']['charset_sql_base'] = |
|
| 94 | + $charset['charset']; |
|
| 95 | + $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 96 | + $charset['collation']; |
|
| 97 | + $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 98 | + $charset['charset']; |
|
| 99 | + $charsetbase = $charset['charset']; |
|
| 100 | + } else { |
|
| 101 | + spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 102 | + $charsetbase = 'standard'; |
|
| 103 | + } |
|
| 104 | + spip_log("Creation des tables. Codage $charsetbase"); |
|
| 105 | + creer_base($server_db); // AT LAST |
|
| 106 | + // memoriser avec quel charset on l'a creee |
|
| 107 | + |
|
| 108 | + if ($charset) { |
|
| 109 | + $t = [ |
|
| 110 | + 'nom' => 'charset_sql_base', |
|
| 111 | + 'valeur' => $charset['charset'], |
|
| 112 | + 'impt' => 'non' |
|
| 113 | + ]; |
|
| 114 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 115 | + $t['nom'] = 'charset_collation_sql_base'; |
|
| 116 | + $t['valeur'] = $charset['collation']; |
|
| 117 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 118 | + $t['nom'] = 'charset_sql_connexion'; |
|
| 119 | + $t['valeur'] = $charset['charset']; |
|
| 120 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 121 | + } |
|
| 122 | + $t = [ |
|
| 123 | + 'nom' => 'version_installee', |
|
| 124 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 125 | + 'impt' => 'non' |
|
| 126 | + ]; |
|
| 127 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 128 | + $t['nom'] = 'nouvelle_install'; |
|
| 129 | + $t['valeur'] = 1; |
|
| 130 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 131 | + // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 132 | + if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 133 | + @sql_insertq( |
|
| 134 | + 'spip_meta', |
|
| 135 | + ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 136 | + '', |
|
| 137 | + $server_db |
|
| 138 | + ); |
|
| 139 | + } |
|
| 140 | + } else { |
|
| 141 | + // pour recreer les tables disparues au besoin |
|
| 142 | + spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 143 | + creer_base($server_db); |
|
| 144 | + $fupdateq = sql_serveur('updateq', $server_db); |
|
| 145 | + |
|
| 146 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 147 | + |
|
| 148 | + if ($r) { |
|
| 149 | + $r = sql_fetch($r, $server_db); |
|
| 150 | + } |
|
| 151 | + $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 152 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 153 | + $fupdateq( |
|
| 154 | + 'spip_meta', |
|
| 155 | + ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 156 | + "nom='version_installee'", |
|
| 157 | + '', |
|
| 158 | + $server_db |
|
| 159 | + ); |
|
| 160 | + spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 161 | + } |
|
| 162 | + // eliminer la derniere operation d'admin mal terminee |
|
| 163 | + // notamment la mise a jour |
|
| 164 | + @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // recuperer le charset de la connexion dans les meta |
|
| 168 | + $charset = ''; |
|
| 169 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 170 | + if ($r) { |
|
| 171 | + $r = sql_fetch($r, $server_db); |
|
| 172 | + } |
|
| 173 | + if ($r) { |
|
| 174 | + $charset = $r['valeur']; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $ligne_rappel = install_mode_appel($server_db); |
|
| 178 | + |
|
| 179 | + $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 180 | + if (!$result_ok) { |
|
| 181 | + return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if ($chmod_db) { |
|
| 185 | + install_fichier_connexion( |
|
| 186 | + _FILE_CHMOD_TMP, |
|
| 187 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 188 | + ); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + // si ce fichier existe a cette etape c'est qu'il provient |
|
| 192 | + // d'une installation qui ne l'a pas cree correctement. |
|
| 193 | + // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 194 | + |
|
| 195 | + if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 196 | + spip_unlink(_FILE_CONNECT); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + install_fichier_connexion( |
|
| 200 | + _FILE_CONNECT_TMP, |
|
| 201 | + $ligne_rappel |
|
| 202 | + . install_connexion( |
|
| 203 | + $adresse_db, |
|
| 204 | + $port, |
|
| 205 | + $login_db, |
|
| 206 | + $pass_db, |
|
| 207 | + $sel_db, |
|
| 208 | + $server_db, |
|
| 209 | + $table_prefix, |
|
| 210 | + '', |
|
| 211 | + $charset |
|
| 212 | + ) |
|
| 213 | + ); |
|
| 214 | + |
|
| 215 | + return ''; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -227,169 +227,169 @@ discard block |
||
| 227 | 227 | * @return string Le préfixe corrigé |
| 228 | 228 | */ |
| 229 | 229 | function preparer_prefixe_tables($prefixe) { |
| 230 | - return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 230 | + return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // https://code.spip.net/@install_propose_ldap |
| 234 | 234 | function install_propose_ldap() { |
| 235 | - return generer_form_ecrire('install', ( |
|
| 236 | - fieldset( |
|
| 237 | - _T('info_authentification_externe'), |
|
| 238 | - [ |
|
| 239 | - 'etape' => [ |
|
| 240 | - 'label' => _T('texte_annuaire_ldap_1'), |
|
| 241 | - 'valeur' => 'ldap1', |
|
| 242 | - 'hidden' => true |
|
| 243 | - ] |
|
| 244 | - ], |
|
| 245 | - bouton_suivant(_T('bouton_acces_ldap')) |
|
| 246 | - ))); |
|
| 235 | + return generer_form_ecrire('install', ( |
|
| 236 | + fieldset( |
|
| 237 | + _T('info_authentification_externe'), |
|
| 238 | + [ |
|
| 239 | + 'etape' => [ |
|
| 240 | + 'label' => _T('texte_annuaire_ldap_1'), |
|
| 241 | + 'valeur' => 'ldap1', |
|
| 242 | + 'hidden' => true |
|
| 243 | + ] |
|
| 244 | + ], |
|
| 245 | + bouton_suivant(_T('bouton_acces_ldap')) |
|
| 246 | + ))); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | // https://code.spip.net/@install_premier_auteur |
| 251 | 251 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 252 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 253 | - info_etape( |
|
| 254 | - _T('info_informations_personnelles'), |
|
| 255 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | - aider('install5', true) . |
|
| 257 | - '<p>' . |
|
| 258 | - ($auteur_obligatoire ? |
|
| 259 | - '' |
|
| 260 | - : |
|
| 261 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 262 | - ) |
|
| 263 | - ) |
|
| 264 | - . generer_form_ecrire('install', ( |
|
| 265 | - "\n<input type='hidden' name='etape' value='3b' />" |
|
| 266 | - . $hidden |
|
| 267 | - . fieldset( |
|
| 268 | - _T('info_identification_publique'), |
|
| 269 | - [ |
|
| 270 | - 'nom' => [ |
|
| 271 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 272 | - 'valeur' => $nom, |
|
| 273 | - 'required' => $auteur_obligatoire, |
|
| 274 | - ], |
|
| 275 | - 'email' => [ |
|
| 276 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 277 | - 'valeur' => $email, |
|
| 278 | - ] |
|
| 279 | - ] |
|
| 280 | - ) |
|
| 281 | - |
|
| 282 | - . fieldset( |
|
| 283 | - _T('entree_identifiants_connexion'), |
|
| 284 | - [ |
|
| 285 | - 'login' => [ |
|
| 286 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 287 | - 'info_login_trop_court_car_pluriel', |
|
| 288 | - ['nb' => _LOGIN_TROP_COURT] |
|
| 289 | - ) . "\n", |
|
| 290 | - 'valeur' => $login, |
|
| 291 | - 'required' => $auteur_obligatoire, |
|
| 292 | - ], |
|
| 293 | - 'pass' => [ |
|
| 294 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 295 | - 'info_passe_trop_court_car_pluriel', |
|
| 296 | - ['nb' => _PASS_LONGUEUR_MINI] |
|
| 297 | - ) . "\n", |
|
| 298 | - 'valeur' => $pass, |
|
| 299 | - 'required' => $auteur_obligatoire, |
|
| 300 | - ], |
|
| 301 | - 'pass_verif' => [ |
|
| 302 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 303 | - 'valeur' => $pass, |
|
| 304 | - 'required' => $auteur_obligatoire, |
|
| 305 | - ] |
|
| 306 | - ] |
|
| 307 | - ) |
|
| 308 | - . bouton_suivant())); |
|
| 252 | + return info_progression_etape(3, 'etape_', 'install/') . |
|
| 253 | + info_etape( |
|
| 254 | + _T('info_informations_personnelles'), |
|
| 255 | + '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | + aider('install5', true) . |
|
| 257 | + '<p>' . |
|
| 258 | + ($auteur_obligatoire ? |
|
| 259 | + '' |
|
| 260 | + : |
|
| 261 | + _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 262 | + ) |
|
| 263 | + ) |
|
| 264 | + . generer_form_ecrire('install', ( |
|
| 265 | + "\n<input type='hidden' name='etape' value='3b' />" |
|
| 266 | + . $hidden |
|
| 267 | + . fieldset( |
|
| 268 | + _T('info_identification_publique'), |
|
| 269 | + [ |
|
| 270 | + 'nom' => [ |
|
| 271 | + 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 272 | + 'valeur' => $nom, |
|
| 273 | + 'required' => $auteur_obligatoire, |
|
| 274 | + ], |
|
| 275 | + 'email' => [ |
|
| 276 | + 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 277 | + 'valeur' => $email, |
|
| 278 | + ] |
|
| 279 | + ] |
|
| 280 | + ) |
|
| 281 | + |
|
| 282 | + . fieldset( |
|
| 283 | + _T('entree_identifiants_connexion'), |
|
| 284 | + [ |
|
| 285 | + 'login' => [ |
|
| 286 | + 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 287 | + 'info_login_trop_court_car_pluriel', |
|
| 288 | + ['nb' => _LOGIN_TROP_COURT] |
|
| 289 | + ) . "\n", |
|
| 290 | + 'valeur' => $login, |
|
| 291 | + 'required' => $auteur_obligatoire, |
|
| 292 | + ], |
|
| 293 | + 'pass' => [ |
|
| 294 | + 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 295 | + 'info_passe_trop_court_car_pluriel', |
|
| 296 | + ['nb' => _PASS_LONGUEUR_MINI] |
|
| 297 | + ) . "\n", |
|
| 298 | + 'valeur' => $pass, |
|
| 299 | + 'required' => $auteur_obligatoire, |
|
| 300 | + ], |
|
| 301 | + 'pass_verif' => [ |
|
| 302 | + 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 303 | + 'valeur' => $pass, |
|
| 304 | + 'required' => $auteur_obligatoire, |
|
| 305 | + ] |
|
| 306 | + ] |
|
| 307 | + ) |
|
| 308 | + . bouton_suivant())); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // https://code.spip.net/@install_etape_3_dist |
| 312 | 312 | function install_etape_3_dist() { |
| 313 | - $ldap_present = _request('ldap_present'); |
|
| 314 | - |
|
| 315 | - if (!$ldap_present) { |
|
| 316 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 317 | - ? _INSTALL_HOST_DB |
|
| 318 | - : _request('adresse_db'); |
|
| 319 | - |
|
| 320 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 321 | - ? _INSTALL_USER_DB |
|
| 322 | - : _request('login_db'); |
|
| 323 | - |
|
| 324 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 325 | - ? _INSTALL_PASS_DB |
|
| 326 | - : _request('pass_db'); |
|
| 327 | - |
|
| 328 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 329 | - ? _INSTALL_SERVER_DB |
|
| 330 | - : _request('server_db'); |
|
| 331 | - |
|
| 332 | - $chmod_db = defined('_SPIP_CHMOD') |
|
| 333 | - ? _SPIP_CHMOD |
|
| 334 | - : _request('chmod'); |
|
| 335 | - |
|
| 336 | - $choix_db = defined('_INSTALL_NAME_DB') |
|
| 337 | - ? _INSTALL_NAME_DB |
|
| 338 | - : _request('choix_db'); |
|
| 339 | - |
|
| 340 | - $sel_db = ($choix_db == 'new_spip') |
|
| 341 | - ? _request('table_new') : $choix_db; |
|
| 342 | - |
|
| 343 | - $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 344 | - |
|
| 345 | - if ($res) { |
|
| 346 | - $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 347 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 348 | - . $res |
|
| 349 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 350 | - . '</div>'; |
|
| 351 | - } |
|
| 352 | - } else { |
|
| 353 | - $res = ''; |
|
| 354 | - [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 355 | - $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - if (!$res) { |
|
| 359 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 360 | - include(_FILE_CONNECT_TMP); |
|
| 361 | - } else { |
|
| 362 | - redirige_url_ecrire('install'); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 366 | - include(_FILE_CHMOD_TMP); |
|
| 367 | - } else { |
|
| 368 | - redirige_url_ecrire('install'); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 372 | - . (defined('_INSTALL_NAME_DB') ? '' |
|
| 373 | - : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 374 | - |
|
| 375 | - $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 376 | - |
|
| 377 | - $res = "<div class='success'><b>" |
|
| 378 | - . _T('info_base_installee') |
|
| 379 | - . '</b></div>' |
|
| 380 | - . install_premier_auteur( |
|
| 381 | - _request('email'), |
|
| 382 | - _request('login'), |
|
| 383 | - _request('nom'), |
|
| 384 | - _request('pass'), |
|
| 385 | - $hidden, |
|
| 386 | - $auteur_obligatoire |
|
| 387 | - ) |
|
| 388 | - . (($ldap_present or !function_exists('ldap_connect')) |
|
| 389 | - ? '' : install_propose_ldap()); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - echo install_debut_html(); |
|
| 393 | - echo $res; |
|
| 394 | - echo install_fin_html(); |
|
| 313 | + $ldap_present = _request('ldap_present'); |
|
| 314 | + |
|
| 315 | + if (!$ldap_present) { |
|
| 316 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 317 | + ? _INSTALL_HOST_DB |
|
| 318 | + : _request('adresse_db'); |
|
| 319 | + |
|
| 320 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 321 | + ? _INSTALL_USER_DB |
|
| 322 | + : _request('login_db'); |
|
| 323 | + |
|
| 324 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 325 | + ? _INSTALL_PASS_DB |
|
| 326 | + : _request('pass_db'); |
|
| 327 | + |
|
| 328 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 329 | + ? _INSTALL_SERVER_DB |
|
| 330 | + : _request('server_db'); |
|
| 331 | + |
|
| 332 | + $chmod_db = defined('_SPIP_CHMOD') |
|
| 333 | + ? _SPIP_CHMOD |
|
| 334 | + : _request('chmod'); |
|
| 335 | + |
|
| 336 | + $choix_db = defined('_INSTALL_NAME_DB') |
|
| 337 | + ? _INSTALL_NAME_DB |
|
| 338 | + : _request('choix_db'); |
|
| 339 | + |
|
| 340 | + $sel_db = ($choix_db == 'new_spip') |
|
| 341 | + ? _request('table_new') : $choix_db; |
|
| 342 | + |
|
| 343 | + $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 344 | + |
|
| 345 | + if ($res) { |
|
| 346 | + $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 347 | + . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 348 | + . $res |
|
| 349 | + . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 350 | + . '</div>'; |
|
| 351 | + } |
|
| 352 | + } else { |
|
| 353 | + $res = ''; |
|
| 354 | + [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 355 | + $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + if (!$res) { |
|
| 359 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 360 | + include(_FILE_CONNECT_TMP); |
|
| 361 | + } else { |
|
| 362 | + redirige_url_ecrire('install'); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 366 | + include(_FILE_CHMOD_TMP); |
|
| 367 | + } else { |
|
| 368 | + redirige_url_ecrire('install'); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 372 | + . (defined('_INSTALL_NAME_DB') ? '' |
|
| 373 | + : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 374 | + |
|
| 375 | + $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 376 | + |
|
| 377 | + $res = "<div class='success'><b>" |
|
| 378 | + . _T('info_base_installee') |
|
| 379 | + . '</b></div>' |
|
| 380 | + . install_premier_auteur( |
|
| 381 | + _request('email'), |
|
| 382 | + _request('login'), |
|
| 383 | + _request('nom'), |
|
| 384 | + _request('pass'), |
|
| 385 | + $hidden, |
|
| 386 | + $auteur_obligatoire |
|
| 387 | + ) |
|
| 388 | + . (($ldap_present or !function_exists('ldap_connect')) |
|
| 389 | + ? '' : install_propose_ldap()); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + echo install_debut_html(); |
|
| 393 | + echo $res; |
|
| 394 | + echo install_fin_html(); |
|
| 395 | 395 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -21,65 +21,65 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // https://code.spip.net/@install_etape_fin_dist |
| 23 | 23 | function install_etape_fin_dist() { |
| 24 | - ecrire_acces(); |
|
| 24 | + ecrire_acces(); |
|
| 25 | 25 | |
| 26 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 27 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 28 | - if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | - if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 30 | - spip_unlink(_FILE_CHMOD_TMP); |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - } |
|
| 26 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 27 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 28 | + if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | + if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 30 | + spip_unlink(_FILE_CHMOD_TMP); |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 36 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 37 | - spip_log("renomme $f"); |
|
| 38 | - if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | - if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 40 | - @spip_unlink(_FILE_CONNECT_TMP); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 35 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 36 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 37 | + spip_log("renomme $f"); |
|
| 38 | + if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | + if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 40 | + @spip_unlink(_FILE_CONNECT_TMP); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // creer le repertoire cache, qui sert partout ! |
|
| 46 | - // deja fait en etape 4 en principe, on garde au cas ou |
|
| 47 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 48 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 49 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 50 | - } |
|
| 45 | + // creer le repertoire cache, qui sert partout ! |
|
| 46 | + // deja fait en etape 4 en principe, on garde au cas ou |
|
| 47 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 48 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 49 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - // Verifier la securite des htaccess |
|
| 53 | - // Si elle ne fonctionne pas, prevenir |
|
| 54 | - $msg = install_verifier_htaccess(); |
|
| 55 | - if ($msg) { |
|
| 56 | - $cible = _T('public:accueil_site'); |
|
| 57 | - $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 58 | - echo minipres('AUTO', $msg . $cible); |
|
| 59 | - // ok, deboucher dans l'espace prive |
|
| 60 | - } else { |
|
| 61 | - redirige_url_ecrire('accueil'); |
|
| 62 | - } |
|
| 52 | + // Verifier la securite des htaccess |
|
| 53 | + // Si elle ne fonctionne pas, prevenir |
|
| 54 | + $msg = install_verifier_htaccess(); |
|
| 55 | + if ($msg) { |
|
| 56 | + $cible = _T('public:accueil_site'); |
|
| 57 | + $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 58 | + echo minipres('AUTO', $msg . $cible); |
|
| 59 | + // ok, deboucher dans l'espace prive |
|
| 60 | + } else { |
|
| 61 | + redirige_url_ecrire('accueil'); |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function install_verifier_htaccess() { |
| 66 | - if ( |
|
| 67 | - verifier_htaccess(_DIR_TMP, true) |
|
| 68 | - and verifier_htaccess(_DIR_CONNECT, true) |
|
| 69 | - ) { |
|
| 70 | - return ''; |
|
| 71 | - } |
|
| 66 | + if ( |
|
| 67 | + verifier_htaccess(_DIR_TMP, true) |
|
| 68 | + and verifier_htaccess(_DIR_CONNECT, true) |
|
| 69 | + ) { |
|
| 70 | + return ''; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - $titre = _T('htaccess_inoperant'); |
|
| 73 | + $titre = _T('htaccess_inoperant'); |
|
| 74 | 74 | |
| 75 | - $averti = _T( |
|
| 76 | - 'htaccess_a_simuler', |
|
| 77 | - [ |
|
| 78 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 79 | - 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 80 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 81 | - ] |
|
| 82 | - ); |
|
| 75 | + $averti = _T( |
|
| 76 | + 'htaccess_a_simuler', |
|
| 77 | + [ |
|
| 78 | + 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 79 | + 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 80 | + 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 81 | + ] |
|
| 82 | + ); |
|
| 83 | 83 | |
| 84 | - return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 84 | + return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 85 | 85 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | // creer le repertoire cache, qui sert partout ! |
| 46 | 46 | // deja fait en etape 4 en principe, on garde au cas ou |
| 47 | 47 | if (!@file_exists(_DIR_CACHE)) { |
| 48 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 48 | + $rep = preg_replace(','._DIR_TMP.',', '', _DIR_CACHE); |
|
| 49 | 49 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | if ($msg) { |
| 56 | 56 | $cible = _T('public:accueil_site'); |
| 57 | 57 | $cible = generer_form_ecrire('accueil', '', '', $cible); |
| 58 | - echo minipres('AUTO', $msg . $cible); |
|
| 58 | + echo minipres('AUTO', $msg.$cible); |
|
| 59 | 59 | // ok, deboucher dans l'espace prive |
| 60 | 60 | } else { |
| 61 | 61 | redirige_url_ecrire('accueil'); |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | $averti = _T( |
| 76 | 76 | 'htaccess_a_simuler', |
| 77 | 77 | [ |
| 78 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 78 | + 'htaccess' => '<tt>'._ACCESS_FILE_NAME.'</tt>', |
|
| 79 | 79 | 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
| 80 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 80 | + 'document_root' => '<tt>'.$_SERVER['DOCUMENT_ROOT'].'</tt>' |
|
| 81 | 81 | ] |
| 82 | 82 | ); |
| 83 | 83 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -19,62 +19,62 @@ discard block |
||
| 19 | 19 | // https://code.spip.net/@install_etape_4_dist |
| 20 | 20 | function install_etape_4_dist() { |
| 21 | 21 | |
| 22 | - // creer le repertoire cache, qui sert partout ! |
|
| 23 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 24 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 25 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 26 | - } |
|
| 22 | + // creer le repertoire cache, qui sert partout ! |
|
| 23 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 24 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 25 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 30 | - echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 29 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 30 | + echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 31 | 31 | |
| 32 | - echo "<div class='success'><b>" |
|
| 33 | - . _T('info_derniere_etape') |
|
| 34 | - . '</b><p>' |
|
| 35 | - . _T('info_utilisation_spip') |
|
| 36 | - . '</p></div>'; |
|
| 32 | + echo "<div class='success'><b>" |
|
| 33 | + . _T('info_derniere_etape') |
|
| 34 | + . '</b><p>' |
|
| 35 | + . _T('info_utilisation_spip') |
|
| 36 | + . '</p></div>'; |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - echo '<p>' |
|
| 40 | - . _T( |
|
| 41 | - 'plugin_info_plugins_dist_1', |
|
| 42 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 43 | - ) |
|
| 44 | - . '</p>'; |
|
| 39 | + echo '<p>' |
|
| 40 | + . _T( |
|
| 41 | + 'plugin_info_plugins_dist_1', |
|
| 42 | + ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 43 | + ) |
|
| 44 | + . '</p>'; |
|
| 45 | 45 | |
| 46 | - // installer les extensions |
|
| 47 | - include_spip('inc/plugin'); |
|
| 48 | - $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 49 | - echo $afficher( |
|
| 50 | - self(), |
|
| 51 | - liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 52 | - [], |
|
| 53 | - [], |
|
| 54 | - _DIR_PLUGINS_DIST, |
|
| 55 | - 'afficher_nom_plugin' |
|
| 56 | - ); |
|
| 46 | + // installer les extensions |
|
| 47 | + include_spip('inc/plugin'); |
|
| 48 | + $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 49 | + echo $afficher( |
|
| 50 | + self(), |
|
| 51 | + liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 52 | + [], |
|
| 53 | + [], |
|
| 54 | + _DIR_PLUGINS_DIST, |
|
| 55 | + 'afficher_nom_plugin' |
|
| 56 | + ); |
|
| 57 | 57 | |
| 58 | - // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 59 | - // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 60 | - // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 61 | - // et procede alors a l'installation |
|
| 62 | - if ( |
|
| 63 | - !isset($GLOBALS['meta']['version_installee']) |
|
| 64 | - or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 65 | - ) { |
|
| 66 | - plugin_installes_meta(); |
|
| 67 | - } |
|
| 58 | + // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 59 | + // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 60 | + // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 61 | + // et procede alors a l'installation |
|
| 62 | + if ( |
|
| 63 | + !isset($GLOBALS['meta']['version_installee']) |
|
| 64 | + or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 65 | + ) { |
|
| 66 | + plugin_installes_meta(); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - // mettre a jour si necessaire l'adresse du site |
|
| 70 | - // securite si on arrive plus a se loger |
|
| 71 | - include_spip('inc/config'); |
|
| 72 | - appliquer_adresse_site(''); |
|
| 69 | + // mettre a jour si necessaire l'adresse du site |
|
| 70 | + // securite si on arrive plus a se loger |
|
| 71 | + include_spip('inc/config'); |
|
| 72 | + appliquer_adresse_site(''); |
|
| 73 | 73 | |
| 74 | - // aller a la derniere etape qui clos l'install et redirige |
|
| 75 | - $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 76 | - . bouton_suivant(_T('login_espace_prive')); |
|
| 74 | + // aller a la derniere etape qui clos l'install et redirige |
|
| 75 | + $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 76 | + . bouton_suivant(_T('login_espace_prive')); |
|
| 77 | 77 | |
| 78 | - echo generer_form_ecrire('install', $suite); |
|
| 79 | - echo install_fin_html(); |
|
| 78 | + echo generer_form_ecrire('install', $suite); |
|
| 79 | + echo install_fin_html(); |
|
| 80 | 80 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // creer le repertoire cache, qui sert partout ! |
| 23 | 23 | if (!@file_exists(_DIR_CACHE)) { |
| 24 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 24 | + $rep = preg_replace(','._DIR_TMP.',', '', _DIR_CACHE); |
|
| 25 | 25 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | echo '<p>' |
| 40 | 40 | . _T( |
| 41 | 41 | 'plugin_info_plugins_dist_1', |
| 42 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 42 | + ['plugins_dist' => '<tt>'.joli_repertoire(_DIR_PLUGINS_DIST).'</tt>'] |
|
| 43 | 43 | ) |
| 44 | 44 | . '</p>'; |
| 45 | 45 | |
@@ -52,29 +52,28 @@ discard block |
||
| 52 | 52 | $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
| 53 | 53 | . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
| 54 | 54 | . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n" |
| 55 | - . (($tls_ldap != 'oui') ? '' : |
|
| 56 | - "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 55 | + . (($tls_ldap != 'oui') ? '' : "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 57 | 56 | . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
| 58 | 57 | |
| 59 | 58 | $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
| 60 | 59 | $res = ''; |
| 61 | 60 | foreach ($champs as $champ => $v) { |
| 62 | - $nom = 'ldap_' . $champ; |
|
| 61 | + $nom = 'ldap_'.$champ; |
|
| 63 | 62 | $val = trim(_request($nom)); |
| 64 | 63 | if (preg_match('/^\w*$/', $val)) { |
| 65 | 64 | if ($val) { |
| 66 | 65 | $val = _q($val); |
| 67 | 66 | } |
| 68 | 67 | } else { |
| 69 | - $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 68 | + $val = 'array('._q(preg_split('/\W+/', $val)).')'; |
|
| 70 | 69 | }; |
| 71 | 70 | if ($val) { |
| 72 | - $res .= "'$champ' => " . $val . ','; |
|
| 71 | + $res .= "'$champ' => ".$val.','; |
|
| 73 | 72 | } |
| 74 | 73 | } |
| 75 | 74 | $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
| 76 | 75 | |
| 77 | - install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 76 | + install_fichier_connexion(_DIR_CONNECT._FILE_LDAP, $conn); |
|
| 78 | 77 | } |
| 79 | 78 | |
| 80 | 79 | function etape_ldap5_suite() { |
@@ -87,7 +86,7 @@ discard block |
||
| 87 | 86 | ); |
| 88 | 87 | |
| 89 | 88 | echo generer_form_ecrire('install', ( |
| 90 | - "<input type='hidden' name='etape' value='3' />" . |
|
| 89 | + "<input type='hidden' name='etape' value='3' />". |
|
| 91 | 90 | "<input type='hidden' name='ldap_present' value='true' />" |
| 92 | 91 | . bouton_suivant())); |
| 93 | 92 | |
@@ -11,85 +11,85 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/headers'); |
| 17 | 17 | include_spip('auth/ldap'); |
| 18 | 18 | |
| 19 | 19 | // https://code.spip.net/@install_etape_ldap5_dist |
| 20 | 20 | function install_etape_ldap5_dist() { |
| 21 | - etape_ldap5_save(); |
|
| 22 | - etape_ldap5_suite(); |
|
| 21 | + etape_ldap5_save(); |
|
| 22 | + etape_ldap5_suite(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | function etape_ldap5_save() { |
| 26 | - $conn = null; |
|
| 27 | - if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 28 | - redirige_url_ecrire('install'); |
|
| 29 | - } |
|
| 26 | + $conn = null; |
|
| 27 | + if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 28 | + redirige_url_ecrire('install'); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - ecrire_meta('ldap_statut_import', _request('statut_ldap')); |
|
| 31 | + ecrire_meta('ldap_statut_import', _request('statut_ldap')); |
|
| 32 | 32 | |
| 33 | - lire_fichier(_FILE_CONNECT_TMP, $conn); |
|
| 33 | + lire_fichier(_FILE_CONNECT_TMP, $conn); |
|
| 34 | 34 | |
| 35 | - if ($p = strpos($conn, "'');")) { |
|
| 36 | - ecrire_fichier( |
|
| 37 | - _FILE_CONNECT_TMP, |
|
| 38 | - substr($conn, 0, $p + 1) |
|
| 39 | - . _FILE_LDAP |
|
| 40 | - . substr($conn, $p + 1) |
|
| 41 | - ); |
|
| 42 | - } |
|
| 35 | + if ($p = strpos($conn, "'');")) { |
|
| 36 | + ecrire_fichier( |
|
| 37 | + _FILE_CONNECT_TMP, |
|
| 38 | + substr($conn, 0, $p + 1) |
|
| 39 | + . _FILE_LDAP |
|
| 40 | + . substr($conn, $p + 1) |
|
| 41 | + ); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - $adresse_ldap = addcslashes(_request('adresse_ldap'), "'\\"); |
|
| 45 | - $login_ldap = addcslashes(_request('login_ldap'), "'\\"); |
|
| 46 | - $pass_ldap = addcslashes(_request('pass_ldap'), "'\\"); |
|
| 47 | - $port_ldap = addcslashes(_request('port_ldap'), "'\\"); |
|
| 48 | - $tls_ldap = addcslashes(_request('tls_ldap'), "'\\"); |
|
| 49 | - $protocole_ldap = addcslashes(_request('protocole_ldap'), "'\\"); |
|
| 50 | - $base_ldap = addcslashes(_request('base_ldap'), "'\\"); |
|
| 51 | - $base_ldap_text = addcslashes(_request('base_ldap_text'), "'\\"); |
|
| 44 | + $adresse_ldap = addcslashes(_request('adresse_ldap'), "'\\"); |
|
| 45 | + $login_ldap = addcslashes(_request('login_ldap'), "'\\"); |
|
| 46 | + $pass_ldap = addcslashes(_request('pass_ldap'), "'\\"); |
|
| 47 | + $port_ldap = addcslashes(_request('port_ldap'), "'\\"); |
|
| 48 | + $tls_ldap = addcslashes(_request('tls_ldap'), "'\\"); |
|
| 49 | + $protocole_ldap = addcslashes(_request('protocole_ldap'), "'\\"); |
|
| 50 | + $base_ldap = addcslashes(_request('base_ldap'), "'\\"); |
|
| 51 | + $base_ldap_text = addcslashes(_request('base_ldap_text'), "'\\"); |
|
| 52 | 52 | |
| 53 | - $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
|
| 54 | - . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
|
| 55 | - . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n" |
|
| 56 | - . (($tls_ldap != 'oui') ? '' : |
|
| 57 | - "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 58 | - . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
|
| 53 | + $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
|
| 54 | + . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
|
| 55 | + . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n" |
|
| 56 | + . (($tls_ldap != 'oui') ? '' : |
|
| 57 | + "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 58 | + . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
|
| 59 | 59 | |
| 60 | - $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
|
| 61 | - $res = ''; |
|
| 62 | - foreach ($champs as $champ => $v) { |
|
| 63 | - $nom = 'ldap_' . $champ; |
|
| 64 | - $val = trim(_request($nom)); |
|
| 65 | - if (preg_match('/^\w*$/', $val)) { |
|
| 66 | - if ($val) { |
|
| 67 | - $val = _q($val); |
|
| 68 | - } |
|
| 69 | - } else { |
|
| 70 | - $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 71 | - }; |
|
| 72 | - if ($val) { |
|
| 73 | - $res .= "'$champ' => " . $val . ','; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
|
| 60 | + $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
|
| 61 | + $res = ''; |
|
| 62 | + foreach ($champs as $champ => $v) { |
|
| 63 | + $nom = 'ldap_' . $champ; |
|
| 64 | + $val = trim(_request($nom)); |
|
| 65 | + if (preg_match('/^\w*$/', $val)) { |
|
| 66 | + if ($val) { |
|
| 67 | + $val = _q($val); |
|
| 68 | + } |
|
| 69 | + } else { |
|
| 70 | + $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 71 | + }; |
|
| 72 | + if ($val) { |
|
| 73 | + $res .= "'$champ' => " . $val . ','; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
|
| 77 | 77 | |
| 78 | - install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 78 | + install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | function etape_ldap5_suite() { |
| 82 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 82 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 83 | 83 | |
| 84 | - echo info_etape( |
|
| 85 | - _T('info_ldap_ok'), |
|
| 86 | - info_progression_etape(5, 'etape_ldap', 'install/') |
|
| 87 | - ); |
|
| 84 | + echo info_etape( |
|
| 85 | + _T('info_ldap_ok'), |
|
| 86 | + info_progression_etape(5, 'etape_ldap', 'install/') |
|
| 87 | + ); |
|
| 88 | 88 | |
| 89 | - echo generer_form_ecrire('install', ( |
|
| 90 | - "<input type='hidden' name='etape' value='3' />" . |
|
| 91 | - "<input type='hidden' name='ldap_present' value='true' />" |
|
| 92 | - . bouton_suivant())); |
|
| 89 | + echo generer_form_ecrire('install', ( |
|
| 90 | + "<input type='hidden' name='etape' value='3' />" . |
|
| 91 | + "<input type='hidden' name='ldap_present' value='true' />" |
|
| 92 | + . bouton_suivant())); |
|
| 93 | 93 | |
| 94 | - echo install_fin_html(); |
|
| 94 | + echo install_fin_html(); |
|
| 95 | 95 | } |
@@ -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 | /** |
@@ -35,18 +35,18 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function genie_maintenance_dist($t) { |
| 37 | 37 | |
| 38 | - // (re)mettre .htaccess avec deny from all |
|
| 39 | - // dans les deux repertoires dits inaccessibles par http |
|
| 40 | - include_spip('inc/acces'); |
|
| 41 | - verifier_htaccess(_DIR_ETC); |
|
| 42 | - verifier_htaccess(_DIR_TMP); |
|
| 38 | + // (re)mettre .htaccess avec deny from all |
|
| 39 | + // dans les deux repertoires dits inaccessibles par http |
|
| 40 | + include_spip('inc/acces'); |
|
| 41 | + verifier_htaccess(_DIR_ETC); |
|
| 42 | + verifier_htaccess(_DIR_TMP); |
|
| 43 | 43 | |
| 44 | - // Verifier qu'aucune table n'est crashee |
|
| 45 | - if (!_request('reinstall')) { |
|
| 46 | - verifier_crash_tables(); |
|
| 47 | - } |
|
| 44 | + // Verifier qu'aucune table n'est crashee |
|
| 45 | + if (!_request('reinstall')) { |
|
| 46 | + verifier_crash_tables(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return 1; |
|
| 49 | + return 1; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -63,33 +63,33 @@ discard block |
||
| 63 | 63 | * des tables qui ont crashé. |
| 64 | 64 | */ |
| 65 | 65 | function verifier_crash_tables() { |
| 66 | - if (spip_connect()) { |
|
| 67 | - include_spip('base/serial'); |
|
| 68 | - include_spip('base/auxiliaires'); |
|
| 69 | - $crash = []; |
|
| 70 | - foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 71 | - foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 72 | - if ( |
|
| 73 | - !sql_select('*', $table, '', '', '', 1) |
|
| 74 | - and !defined('spip_interdire_cache') |
|
| 75 | - ) { # cas "LOST CONNECTION" |
|
| 76 | - $crash[] = $table; |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - #$crash[] = 'test'; |
|
| 81 | - if ($crash) { |
|
| 82 | - ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 83 | - spip_log('crash des tables', 'err'); |
|
| 84 | - spip_log($crash, 'err'); |
|
| 85 | - } else { |
|
| 86 | - effacer_meta('message_crash_tables'); |
|
| 87 | - } |
|
| 66 | + if (spip_connect()) { |
|
| 67 | + include_spip('base/serial'); |
|
| 68 | + include_spip('base/auxiliaires'); |
|
| 69 | + $crash = []; |
|
| 70 | + foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 71 | + foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 72 | + if ( |
|
| 73 | + !sql_select('*', $table, '', '', '', 1) |
|
| 74 | + and !defined('spip_interdire_cache') |
|
| 75 | + ) { # cas "LOST CONNECTION" |
|
| 76 | + $crash[] = $table; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + #$crash[] = 'test'; |
|
| 81 | + if ($crash) { |
|
| 82 | + ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 83 | + spip_log('crash des tables', 'err'); |
|
| 84 | + spip_log($crash, 'err'); |
|
| 85 | + } else { |
|
| 86 | + effacer_meta('message_crash_tables'); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - return $crash; |
|
| 90 | - } |
|
| 89 | + return $crash; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return false; |
|
| 92 | + return false; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | function message_crash_tables() { |
| 108 | - if ($crash = verifier_crash_tables()) { |
|
| 109 | - return |
|
| 110 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | - . ' <tt>' . join(', ', $crash) . '</tt><br />' |
|
| 112 | - . generer_form_ecrire( |
|
| 113 | - 'base_repair', |
|
| 114 | - _T('texte_crash_base'), |
|
| 115 | - '', |
|
| 116 | - _T('bouton_tenter_recuperation') |
|
| 117 | - ); |
|
| 118 | - } |
|
| 108 | + if ($crash = verifier_crash_tables()) { |
|
| 109 | + return |
|
| 110 | + '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | + . ' <tt>' . join(', ', $crash) . '</tt><br />' |
|
| 112 | + . generer_form_ecrire( |
|
| 113 | + 'base_repair', |
|
| 114 | + _T('texte_crash_base'), |
|
| 115 | + '', |
|
| 116 | + _T('bouton_tenter_recuperation') |
|
| 117 | + ); |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -107,8 +107,8 @@ |
||
| 107 | 107 | function message_crash_tables() { |
| 108 | 108 | if ($crash = verifier_crash_tables()) { |
| 109 | 109 | return |
| 110 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | - . ' <tt>' . join(', ', $crash) . '</tt><br />' |
|
| 110 | + '<strong>'._T('texte_recuperer_base').'</strong><br />' |
|
| 111 | + . ' <tt>'.join(', ', $crash).'</tt><br />' |
|
| 112 | 112 | . generer_form_ecrire( |
| 113 | 113 | 'base_repair', |
| 114 | 114 | _T('texte_crash_base'), |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @package SPIP\Core\Drapeaux\Edition |
| 31 | 31 | **/ |
| 32 | 32 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 33 | - return; |
|
| 33 | + return; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
@@ -45,46 +45,46 @@ discard block |
||
| 45 | 45 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 46 | 46 | **/ |
| 47 | 47 | function lire_tableau_edition() { |
| 48 | - $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | - if (!$edition) { |
|
| 50 | - return []; |
|
| 51 | - } |
|
| 52 | - $changed = false; |
|
| 48 | + $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | + if (!$edition) { |
|
| 50 | + return []; |
|
| 51 | + } |
|
| 52 | + $changed = false; |
|
| 53 | 53 | |
| 54 | - $bon_pour_le_service = time() - 3600; |
|
| 55 | - // parcourir le tableau et virer les vieux |
|
| 56 | - foreach ($edition as $objet => $data) { |
|
| 57 | - if (!is_array($data)) { |
|
| 58 | - unset($edition[$objet]); |
|
| 59 | - } // vieille version |
|
| 60 | - else { |
|
| 61 | - foreach ($data as $id => $tab) { |
|
| 62 | - if (!is_array($tab)) { |
|
| 63 | - unset($edition[$objet][$tab]); |
|
| 64 | - } // vieille version |
|
| 65 | - else { |
|
| 66 | - foreach ($tab as $n => $duo) { |
|
| 67 | - if (current($duo) < $bon_pour_le_service) { |
|
| 68 | - unset($edition[$objet][$id][$n]); |
|
| 69 | - $changed = true; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - if (!$edition[$objet][$id]) { |
|
| 74 | - unset($edition[$objet][$id]); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - if (!$edition[$objet]) { |
|
| 79 | - unset($edition[$objet]); |
|
| 80 | - } |
|
| 81 | - } |
|
| 54 | + $bon_pour_le_service = time() - 3600; |
|
| 55 | + // parcourir le tableau et virer les vieux |
|
| 56 | + foreach ($edition as $objet => $data) { |
|
| 57 | + if (!is_array($data)) { |
|
| 58 | + unset($edition[$objet]); |
|
| 59 | + } // vieille version |
|
| 60 | + else { |
|
| 61 | + foreach ($data as $id => $tab) { |
|
| 62 | + if (!is_array($tab)) { |
|
| 63 | + unset($edition[$objet][$tab]); |
|
| 64 | + } // vieille version |
|
| 65 | + else { |
|
| 66 | + foreach ($tab as $n => $duo) { |
|
| 67 | + if (current($duo) < $bon_pour_le_service) { |
|
| 68 | + unset($edition[$objet][$id][$n]); |
|
| 69 | + $changed = true; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + if (!$edition[$objet][$id]) { |
|
| 74 | + unset($edition[$objet][$id]); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + if (!$edition[$objet]) { |
|
| 79 | + unset($edition[$objet]); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - if ($changed) { |
|
| 84 | - ecrire_tableau_edition($edition); |
|
| 85 | - } |
|
| 83 | + if ($changed) { |
|
| 84 | + ecrire_tableau_edition($edition); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return $edition; |
|
| 87 | + return $edition; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 98 | 98 | **/ |
| 99 | 99 | function ecrire_tableau_edition($edition) { |
| 100 | - ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 100 | + ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | * Type d'objet édité |
| 118 | 118 | */ |
| 119 | 119 | function signale_edition($id, $auteur, $type = 'article') { |
| 120 | - include_spip('base/objets'); |
|
| 121 | - include_spip('inc/filtres'); |
|
| 122 | - if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | - return; |
|
| 124 | - } |
|
| 120 | + include_spip('base/objets'); |
|
| 121 | + include_spip('inc/filtres'); |
|
| 122 | + if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | + return; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $edition = lire_tableau_edition(); |
|
| 127 | - if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | - $nom = $auteur['nom']; |
|
| 129 | - } else { |
|
| 130 | - $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | - } |
|
| 126 | + $edition = lire_tableau_edition(); |
|
| 127 | + if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | + $nom = $auteur['nom']; |
|
| 129 | + } else { |
|
| 130 | + $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | - $edition[$type][$id] = []; |
|
| 135 | - } |
|
| 136 | - $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | - ecrire_tableau_edition($edition); |
|
| 133 | + if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | + $edition[$type][$id] = []; |
|
| 135 | + } |
|
| 136 | + $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | + ecrire_tableau_edition($edition); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function qui_edite($id, $type = 'article') { |
| 153 | 153 | |
| 154 | - $edition = lire_tableau_edition(); |
|
| 154 | + $edition = lire_tableau_edition(); |
|
| 155 | 155 | |
| 156 | - return empty($edition[$type][$id]) ? [] : $edition[$type][$id]; |
|
| 156 | + return empty($edition[$type][$id]) ? [] : $edition[$type][$id]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -167,22 +167,22 @@ discard block |
||
| 167 | 167 | * Liste de tableaux `['nom_auteur_modif' => x|y|z, 'date_diff' => n]` |
| 168 | 168 | */ |
| 169 | 169 | function mention_qui_edite($id, $type = 'article') { |
| 170 | - $modif = qui_edite($id, $type); |
|
| 171 | - unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 170 | + $modif = qui_edite($id, $type); |
|
| 171 | + unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 172 | 172 | |
| 173 | - if ($modif) { |
|
| 174 | - $quand = 0; |
|
| 175 | - foreach ($modif as $duo) { |
|
| 176 | - $auteurs[] = typo(key($duo)); |
|
| 177 | - $quand = max($quand, current($duo)); |
|
| 178 | - } |
|
| 173 | + if ($modif) { |
|
| 174 | + $quand = 0; |
|
| 175 | + foreach ($modif as $duo) { |
|
| 176 | + $auteurs[] = typo(key($duo)); |
|
| 177 | + $quand = max($quand, current($duo)); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | - return [ |
|
| 182 | - 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | - 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | - ]; |
|
| 185 | - } |
|
| 180 | + // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | + return [ |
|
| 182 | + 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | + 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | + ]; |
|
| 185 | + } |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -196,25 +196,25 @@ discard block |
||
| 196 | 196 | * Liste de tableaux `['objet' => x, 'id_objet' => n]` |
| 197 | 197 | */ |
| 198 | 198 | function liste_drapeau_edition($id_auteur) { |
| 199 | - $edition = lire_tableau_edition(); |
|
| 200 | - $objets_ouverts = []; |
|
| 199 | + $edition = lire_tableau_edition(); |
|
| 200 | + $objets_ouverts = []; |
|
| 201 | 201 | |
| 202 | - foreach ($edition as $objet => $data) { |
|
| 203 | - foreach ($data as $id => $auteurs) { |
|
| 204 | - if ( |
|
| 205 | - isset($auteurs[$id_auteur]) |
|
| 206 | - and is_array($auteurs[$id_auteur]) // precaution |
|
| 207 | - and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 208 | - ) { |
|
| 209 | - $objets_ouverts[] = [ |
|
| 210 | - 'objet' => $objet, |
|
| 211 | - 'id_objet' => $id, |
|
| 212 | - ]; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 202 | + foreach ($edition as $objet => $data) { |
|
| 203 | + foreach ($data as $id => $auteurs) { |
|
| 204 | + if ( |
|
| 205 | + isset($auteurs[$id_auteur]) |
|
| 206 | + and is_array($auteurs[$id_auteur]) // precaution |
|
| 207 | + and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 208 | + ) { |
|
| 209 | + $objets_ouverts[] = [ |
|
| 210 | + 'objet' => $objet, |
|
| 211 | + 'id_objet' => $id, |
|
| 212 | + ]; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - return $objets_ouverts; |
|
| 217 | + return $objets_ouverts; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | * @return void |
| 228 | 228 | */ |
| 229 | 229 | function debloquer_tous($id_auteur) { |
| 230 | - $edition = lire_tableau_edition(); |
|
| 231 | - foreach ($edition as $objet => $data) { |
|
| 232 | - foreach ($data as $id => $auteurs) { |
|
| 233 | - if (isset($auteurs[$id_auteur])) { |
|
| 234 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 235 | - ecrire_tableau_edition($edition); |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 230 | + $edition = lire_tableau_edition(); |
|
| 231 | + foreach ($edition as $objet => $data) { |
|
| 232 | + foreach ($data as $id => $auteurs) { |
|
| 233 | + if (isset($auteurs[$id_auteur])) { |
|
| 234 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 235 | + ecrire_tableau_edition($edition); |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -253,19 +253,19 @@ discard block |
||
| 253 | 253 | * @return void |
| 254 | 254 | */ |
| 255 | 255 | function debloquer_edition($id_auteur, $id_objet, $type = 'article') { |
| 256 | - $edition = lire_tableau_edition(); |
|
| 256 | + $edition = lire_tableau_edition(); |
|
| 257 | 257 | |
| 258 | - foreach ($edition as $objet => $data) { |
|
| 259 | - if ($objet == $type) { |
|
| 260 | - foreach ($data as $id => $auteurs) { |
|
| 261 | - if ( |
|
| 262 | - $id == $id_objet |
|
| 263 | - and isset($auteurs[$id_auteur]) |
|
| 264 | - ) { |
|
| 265 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 266 | - ecrire_tableau_edition($edition); |
|
| 267 | - } |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - } |
|
| 258 | + foreach ($edition as $objet => $data) { |
|
| 259 | + if ($objet == $type) { |
|
| 260 | + foreach ($data as $id => $auteurs) { |
|
| 261 | + if ( |
|
| 262 | + $id == $id_objet |
|
| 263 | + and isset($auteurs[$id_auteur]) |
|
| 264 | + ) { |
|
| 265 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 266 | + ecrire_tableau_edition($edition); |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | 271 | } |
@@ -561,11 +561,9 @@ discard block |
||
| 561 | 561 | if (!isset($msg[$p])) { |
| 562 | 562 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 563 | 563 | $msg[$p] = [$resume['erreur']]; |
| 564 | - } |
|
| 565 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 564 | + } elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 566 | 565 | $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
| 567 | - } |
|
| 568 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 566 | + } elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 569 | 567 | $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
| 570 | 568 | } |
| 571 | 569 | } else { |
@@ -954,8 +952,7 @@ discard block |
||
| 954 | 952 | if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
| 955 | 953 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 956 | 954 | } |
| 957 | - } |
|
| 958 | - else { |
|
| 955 | + } else { |
|
| 959 | 956 | foreach ($info['chemin'] as $chemin) { |
| 960 | 957 | if ( |
| 961 | 958 | !isset($chemin['version']) or plugin_version_compatible( |
@@ -1425,8 +1422,7 @@ discard block |
||
| 1425 | 1422 | echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
| 1426 | 1423 | $trace, |
| 1427 | 1424 | "\n"; |
| 1428 | - } |
|
| 1429 | - else { |
|
| 1425 | + } else { |
|
| 1430 | 1426 | include_spip('inc/filtres_boites'); |
| 1431 | 1427 | echo "<div class='install-plugins svp_retour'>" |
| 1432 | 1428 | . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
@@ -1463,8 +1459,7 @@ discard block |
||
| 1463 | 1459 | if (file_exists($nom)) { |
| 1464 | 1460 | if (substr($nom, -4) == '.php') { |
| 1465 | 1461 | $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
| 1466 | - } |
|
| 1467 | - else { |
|
| 1462 | + } else { |
|
| 1468 | 1463 | $fichier_tmp = $nom . '.tmp'; |
| 1469 | 1464 | } |
| 1470 | 1465 | file_put_contents($fichier_tmp, $contenu); |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -47,27 +47,27 @@ discard block |
||
| 47 | 47 | * @return array |
| 48 | 48 | **/ |
| 49 | 49 | function liste_plugin_files($dir_plugins = null) { |
| 50 | - static $plugin_files = []; |
|
| 51 | - if (is_null($dir_plugins)) { |
|
| 52 | - $dir_plugins = _DIR_PLUGINS; |
|
| 53 | - } |
|
| 54 | - if ( |
|
| 55 | - !isset($plugin_files[$dir_plugins]) |
|
| 56 | - or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0 |
|
| 57 | - ) { |
|
| 58 | - $plugin_files[$dir_plugins] = []; |
|
| 59 | - foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | - $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - sort($plugin_files[$dir_plugins]); |
|
| 64 | - // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | - // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | - $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return $plugin_files[$dir_plugins]; |
|
| 50 | + static $plugin_files = []; |
|
| 51 | + if (is_null($dir_plugins)) { |
|
| 52 | + $dir_plugins = _DIR_PLUGINS; |
|
| 53 | + } |
|
| 54 | + if ( |
|
| 55 | + !isset($plugin_files[$dir_plugins]) |
|
| 56 | + or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0 |
|
| 57 | + ) { |
|
| 58 | + $plugin_files[$dir_plugins] = []; |
|
| 59 | + foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | + $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + sort($plugin_files[$dir_plugins]); |
|
| 64 | + // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | + // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | + $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return $plugin_files[$dir_plugins]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -83,45 +83,45 @@ discard block |
||
| 83 | 83 | * Liste complète des répeertoires |
| 84 | 84 | **/ |
| 85 | 85 | function fast_find_plugin_dirs($dir, $max_prof = 100) { |
| 86 | - $fichiers = []; |
|
| 87 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | - if ($dir == '') { |
|
| 91 | - $dir = '.'; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if (!is_dir($dir)) { |
|
| 95 | - return $fichiers; |
|
| 96 | - } |
|
| 97 | - if (is_plugin_dir($dir, '')) { |
|
| 98 | - $fichiers[] = $dir; |
|
| 99 | - |
|
| 100 | - return $fichiers; |
|
| 101 | - } |
|
| 102 | - if ($max_prof <= 0) { |
|
| 103 | - return $fichiers; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $subdirs = []; |
|
| 107 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | - while (($f = readdir($d)) !== false) { |
|
| 109 | - if ( |
|
| 110 | - $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | - and $f != 'CVS' |
|
| 112 | - and is_dir($f = "$dir/$f") |
|
| 113 | - ) { |
|
| 114 | - $subdirs[] = $f; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - closedir($d); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - foreach ($subdirs as $d) { |
|
| 121 | - $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $fichiers; |
|
| 86 | + $fichiers = []; |
|
| 87 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | + if ($dir == '') { |
|
| 91 | + $dir = '.'; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if (!is_dir($dir)) { |
|
| 95 | + return $fichiers; |
|
| 96 | + } |
|
| 97 | + if (is_plugin_dir($dir, '')) { |
|
| 98 | + $fichiers[] = $dir; |
|
| 99 | + |
|
| 100 | + return $fichiers; |
|
| 101 | + } |
|
| 102 | + if ($max_prof <= 0) { |
|
| 103 | + return $fichiers; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $subdirs = []; |
|
| 107 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | + while (($f = readdir($d)) !== false) { |
|
| 109 | + if ( |
|
| 110 | + $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | + and $f != 'CVS' |
|
| 112 | + and is_dir($f = "$dir/$f") |
|
| 113 | + ) { |
|
| 114 | + $subdirs[] = $f; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + closedir($d); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + foreach ($subdirs as $d) { |
|
| 121 | + $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $fichiers; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,27 +142,27 @@ discard block |
||
| 142 | 142 | **/ |
| 143 | 143 | function is_plugin_dir($dir, $dir_plugins = null) { |
| 144 | 144 | |
| 145 | - if (is_array($dir)) { |
|
| 146 | - foreach ($dir as $k => $d) { |
|
| 147 | - if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | - unset($dir[$k]); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $dir; |
|
| 153 | - } |
|
| 154 | - if (is_null($dir_plugins)) { |
|
| 155 | - $dir_plugins = _DIR_PLUGINS; |
|
| 156 | - } |
|
| 157 | - $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | - |
|
| 159 | - foreach ($search as $s) { |
|
| 160 | - if (file_exists($s)) { |
|
| 161 | - return $dir; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - return ''; |
|
| 145 | + if (is_array($dir)) { |
|
| 146 | + foreach ($dir as $k => $d) { |
|
| 147 | + if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | + unset($dir[$k]); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $dir; |
|
| 153 | + } |
|
| 154 | + if (is_null($dir_plugins)) { |
|
| 155 | + $dir_plugins = _DIR_PLUGINS; |
|
| 156 | + } |
|
| 157 | + $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | + |
|
| 159 | + foreach ($search as $s) { |
|
| 160 | + if (file_exists($s)) { |
|
| 161 | + return $dir; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + return ''; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** Regexp d'extraction des informations d'un intervalle de compatibilité */ |
@@ -189,51 +189,51 @@ discard block |
||
| 189 | 189 | **/ |
| 190 | 190 | function plugin_version_compatible($intervalle, $version, $avec_quoi = '') { |
| 191 | 191 | |
| 192 | - if (!strlen($intervalle)) { |
|
| 193 | - return true; |
|
| 194 | - } |
|
| 195 | - if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | - return false; |
|
| 197 | - } |
|
| 198 | - // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | - // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | - $minimum = $regs[1]; |
|
| 201 | - $maximum = $regs[2]; |
|
| 202 | - |
|
| 203 | - // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | - // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | - // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | - // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | - // entre plugins) |
|
| 208 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | - if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | - return true; |
|
| 211 | - } |
|
| 212 | - // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | - // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $minimum_inc = $intervalle[0] == '['; |
|
| 217 | - $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | - |
|
| 219 | - if (strlen($minimum)) { |
|
| 220 | - if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | - return false; |
|
| 222 | - } |
|
| 223 | - if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | - return false; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - if (strlen($maximum)) { |
|
| 228 | - if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 231 | - if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | - return false; |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - return true; |
|
| 192 | + if (!strlen($intervalle)) { |
|
| 193 | + return true; |
|
| 194 | + } |
|
| 195 | + if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 198 | + // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | + // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | + $minimum = $regs[1]; |
|
| 201 | + $maximum = $regs[2]; |
|
| 202 | + |
|
| 203 | + // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | + // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | + // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | + // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | + // entre plugins) |
|
| 208 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | + if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | + return true; |
|
| 211 | + } |
|
| 212 | + // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | + // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $minimum_inc = $intervalle[0] == '['; |
|
| 217 | + $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | + |
|
| 219 | + if (strlen($minimum)) { |
|
| 220 | + if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | + return false; |
|
| 222 | + } |
|
| 223 | + if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | + return false; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + if (strlen($maximum)) { |
|
| 228 | + if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | + if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | + return false; |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + return true; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -250,62 +250,62 @@ discard block |
||
| 250 | 250 | * @return array |
| 251 | 251 | */ |
| 252 | 252 | function liste_plugin_valides($liste_plug, $force = false) { |
| 253 | - $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | - $infos = [ |
|
| 256 | - // lister les extensions qui sont automatiquement actives |
|
| 257 | - '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | - '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | - ]; |
|
| 260 | - |
|
| 261 | - // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | - // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | - $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | - $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | - $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | - $liste_non_classee = [ |
|
| 267 | - 'SPIP' => [ |
|
| 268 | - 'nom' => 'SPIP', |
|
| 269 | - 'etat' => 'stable', |
|
| 270 | - 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | - 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | - 'dir' => '', |
|
| 273 | - ] |
|
| 274 | - ]; |
|
| 275 | - |
|
| 276 | - $invalides = []; |
|
| 277 | - foreach ($liste_ext as $plug) { |
|
| 278 | - if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - foreach ($liste_plug as $plug) { |
|
| 283 | - if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | - if (is_array($r)) { |
|
| 286 | - $invalides = array_merge($invalides, $r); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | - $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | - foreach ($liste_plug as $plug) { |
|
| 294 | - if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | - if (is_array($r)) { |
|
| 297 | - $invalides = array_merge($invalides, $r); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | - |
|
| 305 | - // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | - $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | - |
|
| 308 | - return [$infos, $liste_non_classee, $invalides]; |
|
| 253 | + $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | + $infos = [ |
|
| 256 | + // lister les extensions qui sont automatiquement actives |
|
| 257 | + '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | + '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | + ]; |
|
| 260 | + |
|
| 261 | + // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | + // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | + $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | + $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | + $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | + $liste_non_classee = [ |
|
| 267 | + 'SPIP' => [ |
|
| 268 | + 'nom' => 'SPIP', |
|
| 269 | + 'etat' => 'stable', |
|
| 270 | + 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | + 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | + 'dir' => '', |
|
| 273 | + ] |
|
| 274 | + ]; |
|
| 275 | + |
|
| 276 | + $invalides = []; |
|
| 277 | + foreach ($liste_ext as $plug) { |
|
| 278 | + if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + foreach ($liste_plug as $plug) { |
|
| 283 | + if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | + if (is_array($r)) { |
|
| 286 | + $invalides = array_merge($invalides, $r); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | + $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | + foreach ($liste_plug as $plug) { |
|
| 294 | + if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | + if (is_array($r)) { |
|
| 297 | + $invalides = array_merge($invalides, $r); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | + |
|
| 305 | + // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | + $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | + |
|
| 308 | + return [$infos, $liste_non_classee, $invalides]; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -325,30 +325,30 @@ discard block |
||
| 325 | 325 | * array description short si on ne le retient pas (pour memorisation dans une table des erreurs) |
| 326 | 326 | */ |
| 327 | 327 | function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) { |
| 328 | - $i = $infos[$dir_type][$plug]; |
|
| 329 | - $p = strtoupper($i['prefix']); |
|
| 330 | - $short_desc = [ |
|
| 331 | - 'nom' => $i['nom'], |
|
| 332 | - 'etat' => $i['etat'], |
|
| 333 | - 'version' => $i['version'], |
|
| 334 | - 'dir' => $plug, |
|
| 335 | - 'dir_type' => $dir_type |
|
| 336 | - ]; |
|
| 337 | - if (isset($i['erreur']) and $i['erreur']) { |
|
| 338 | - $short_desc['erreur'] = $i['erreur']; |
|
| 339 | - return [$p => $short_desc]; |
|
| 340 | - } |
|
| 341 | - if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 342 | - return [$p => $short_desc]; |
|
| 343 | - } |
|
| 344 | - if ( |
|
| 345 | - !isset($liste[$p]) |
|
| 346 | - or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 347 | - ) { |
|
| 348 | - $liste[$p] = $short_desc; |
|
| 349 | - } |
|
| 350 | - // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 351 | - return $p; |
|
| 328 | + $i = $infos[$dir_type][$plug]; |
|
| 329 | + $p = strtoupper($i['prefix']); |
|
| 330 | + $short_desc = [ |
|
| 331 | + 'nom' => $i['nom'], |
|
| 332 | + 'etat' => $i['etat'], |
|
| 333 | + 'version' => $i['version'], |
|
| 334 | + 'dir' => $plug, |
|
| 335 | + 'dir_type' => $dir_type |
|
| 336 | + ]; |
|
| 337 | + if (isset($i['erreur']) and $i['erreur']) { |
|
| 338 | + $short_desc['erreur'] = $i['erreur']; |
|
| 339 | + return [$p => $short_desc]; |
|
| 340 | + } |
|
| 341 | + if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 342 | + return [$p => $short_desc]; |
|
| 343 | + } |
|
| 344 | + if ( |
|
| 345 | + !isset($liste[$p]) |
|
| 346 | + or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 347 | + ) { |
|
| 348 | + $liste[$p] = $short_desc; |
|
| 349 | + } |
|
| 350 | + // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 351 | + return $p; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -364,47 +364,47 @@ discard block |
||
| 364 | 364 | * @param array $infos |
| 365 | 365 | */ |
| 366 | 366 | function plugin_fixer_procure(&$liste, &$infos) { |
| 367 | - foreach ($liste as $p => $resume) { |
|
| 368 | - $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 369 | - if (isset($i['procure']) and $i['procure']) { |
|
| 370 | - foreach ($i['procure'] as $procure) { |
|
| 371 | - $p = strtoupper($procure['nom']); |
|
| 372 | - $dir = $resume['dir']; |
|
| 373 | - if ($dir) { |
|
| 374 | - $dir .= '/'; |
|
| 375 | - } |
|
| 376 | - $dir .= 'procure:' . $procure['nom']; |
|
| 377 | - |
|
| 378 | - $procure['etat'] = '?'; |
|
| 379 | - $procure['dir_type'] = $resume['dir_type']; |
|
| 380 | - $procure['dir'] = $dir; |
|
| 381 | - |
|
| 382 | - // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 383 | - // on ajoute cette version a la liste |
|
| 384 | - if ( |
|
| 385 | - !isset($liste[$p]) |
|
| 386 | - or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 387 | - ) { |
|
| 388 | - $liste[$p] = $procure; |
|
| 389 | - |
|
| 390 | - // on fournit une information minimale pour ne pas perturber la compilation |
|
| 391 | - $infos[$resume['dir_type']][$dir] = [ |
|
| 392 | - 'prefix' => $procure['nom'], |
|
| 393 | - 'nom' => $procure['nom'], |
|
| 394 | - 'etat' => $procure['etat'], |
|
| 395 | - 'version' => $procure['version'], |
|
| 396 | - 'chemin' => [], |
|
| 397 | - 'necessite' => [], |
|
| 398 | - 'utilise' => [], |
|
| 399 | - 'lib' => [], |
|
| 400 | - 'menu' => [], |
|
| 401 | - 'onglet' => [], |
|
| 402 | - 'procure' => [], |
|
| 403 | - ]; |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - } |
|
| 367 | + foreach ($liste as $p => $resume) { |
|
| 368 | + $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 369 | + if (isset($i['procure']) and $i['procure']) { |
|
| 370 | + foreach ($i['procure'] as $procure) { |
|
| 371 | + $p = strtoupper($procure['nom']); |
|
| 372 | + $dir = $resume['dir']; |
|
| 373 | + if ($dir) { |
|
| 374 | + $dir .= '/'; |
|
| 375 | + } |
|
| 376 | + $dir .= 'procure:' . $procure['nom']; |
|
| 377 | + |
|
| 378 | + $procure['etat'] = '?'; |
|
| 379 | + $procure['dir_type'] = $resume['dir_type']; |
|
| 380 | + $procure['dir'] = $dir; |
|
| 381 | + |
|
| 382 | + // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 383 | + // on ajoute cette version a la liste |
|
| 384 | + if ( |
|
| 385 | + !isset($liste[$p]) |
|
| 386 | + or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 387 | + ) { |
|
| 388 | + $liste[$p] = $procure; |
|
| 389 | + |
|
| 390 | + // on fournit une information minimale pour ne pas perturber la compilation |
|
| 391 | + $infos[$resume['dir_type']][$dir] = [ |
|
| 392 | + 'prefix' => $procure['nom'], |
|
| 393 | + 'nom' => $procure['nom'], |
|
| 394 | + 'etat' => $procure['etat'], |
|
| 395 | + 'version' => $procure['version'], |
|
| 396 | + 'chemin' => [], |
|
| 397 | + 'necessite' => [], |
|
| 398 | + 'utilise' => [], |
|
| 399 | + 'lib' => [], |
|
| 400 | + 'menu' => [], |
|
| 401 | + 'onglet' => [], |
|
| 402 | + 'procure' => [], |
|
| 403 | + ]; |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -418,20 +418,20 @@ discard block |
||
| 418 | 418 | * @return array |
| 419 | 419 | */ |
| 420 | 420 | function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) { |
| 421 | - foreach ($liste as $prefix => $infos) { |
|
| 422 | - if ( |
|
| 423 | - !$dir_plugins |
|
| 424 | - or ( |
|
| 425 | - defined($infos['dir_type']) |
|
| 426 | - and constant($infos['dir_type']) == $dir_plugins) |
|
| 427 | - ) { |
|
| 428 | - $liste[$prefix] = $infos['dir']; |
|
| 429 | - } else { |
|
| 430 | - unset($liste[$prefix]); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - return $liste; |
|
| 421 | + foreach ($liste as $prefix => $infos) { |
|
| 422 | + if ( |
|
| 423 | + !$dir_plugins |
|
| 424 | + or ( |
|
| 425 | + defined($infos['dir_type']) |
|
| 426 | + and constant($infos['dir_type']) == $dir_plugins) |
|
| 427 | + ) { |
|
| 428 | + $liste[$prefix] = $infos['dir']; |
|
| 429 | + } else { |
|
| 430 | + unset($liste[$prefix]); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + return $liste; |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -446,9 +446,9 @@ discard block |
||
| 446 | 446 | * @return array |
| 447 | 447 | */ |
| 448 | 448 | function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) { |
| 449 | - include_spip('plugins/installer'); |
|
| 449 | + include_spip('plugins/installer'); |
|
| 450 | 450 | |
| 451 | - return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 451 | + return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -479,54 +479,54 @@ discard block |
||
| 479 | 479 | * qui n'ont pas satisfait leurs dépendances |
| 480 | 480 | **/ |
| 481 | 481 | function plugin_trier($infos, $liste_non_classee) { |
| 482 | - $toute_la_liste = $liste_non_classee; |
|
| 483 | - $liste = $ordre = []; |
|
| 484 | - $count = 0; |
|
| 485 | - |
|
| 486 | - while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 487 | - #echo "tour::";var_dump($liste_non_classee); |
|
| 488 | - $count = $c; |
|
| 489 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 490 | - $plug = $resume['dir']; |
|
| 491 | - $dir_type = $resume['dir_type']; |
|
| 492 | - $info1 = $infos[$dir_type][$plug]; |
|
| 493 | - // si des plugins sont necessaires, |
|
| 494 | - // on ne peut inserer qu'apres eux |
|
| 495 | - foreach ($info1['necessite'] as $need) { |
|
| 496 | - $nom = strtoupper($need['nom']); |
|
| 497 | - $compat = $need['compatibilite'] ?? ''; |
|
| 498 | - if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 499 | - $info1 = false; |
|
| 500 | - break; |
|
| 501 | - } |
|
| 502 | - } |
|
| 503 | - if (!$info1) { |
|
| 504 | - continue; |
|
| 505 | - } |
|
| 506 | - // idem si des plugins sont utiles, |
|
| 507 | - // sauf si ils sont de toute facon absents de la liste |
|
| 508 | - foreach ($info1['utilise'] as $need) { |
|
| 509 | - $nom = strtoupper($need['nom']); |
|
| 510 | - $compat = $need['compatibilite'] ?? ''; |
|
| 511 | - if (isset($toute_la_liste[$nom])) { |
|
| 512 | - if ( |
|
| 513 | - !isset($liste[$nom]) or |
|
| 514 | - !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 515 | - ) { |
|
| 516 | - $info1 = false; |
|
| 517 | - break; |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - } |
|
| 521 | - if ($info1) { |
|
| 522 | - $ordre[$p] = $info1; |
|
| 523 | - $liste[$p] = $liste_non_classee[$p]; |
|
| 524 | - unset($liste_non_classee[$p]); |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return [$liste, $ordre, $liste_non_classee]; |
|
| 482 | + $toute_la_liste = $liste_non_classee; |
|
| 483 | + $liste = $ordre = []; |
|
| 484 | + $count = 0; |
|
| 485 | + |
|
| 486 | + while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 487 | + #echo "tour::";var_dump($liste_non_classee); |
|
| 488 | + $count = $c; |
|
| 489 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 490 | + $plug = $resume['dir']; |
|
| 491 | + $dir_type = $resume['dir_type']; |
|
| 492 | + $info1 = $infos[$dir_type][$plug]; |
|
| 493 | + // si des plugins sont necessaires, |
|
| 494 | + // on ne peut inserer qu'apres eux |
|
| 495 | + foreach ($info1['necessite'] as $need) { |
|
| 496 | + $nom = strtoupper($need['nom']); |
|
| 497 | + $compat = $need['compatibilite'] ?? ''; |
|
| 498 | + if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 499 | + $info1 = false; |
|
| 500 | + break; |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | + if (!$info1) { |
|
| 504 | + continue; |
|
| 505 | + } |
|
| 506 | + // idem si des plugins sont utiles, |
|
| 507 | + // sauf si ils sont de toute facon absents de la liste |
|
| 508 | + foreach ($info1['utilise'] as $need) { |
|
| 509 | + $nom = strtoupper($need['nom']); |
|
| 510 | + $compat = $need['compatibilite'] ?? ''; |
|
| 511 | + if (isset($toute_la_liste[$nom])) { |
|
| 512 | + if ( |
|
| 513 | + !isset($liste[$nom]) or |
|
| 514 | + !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 515 | + ) { |
|
| 516 | + $info1 = false; |
|
| 517 | + break; |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + } |
|
| 521 | + if ($info1) { |
|
| 522 | + $ordre[$p] = $info1; |
|
| 523 | + $liste[$p] = $liste_non_classee[$p]; |
|
| 524 | + unset($liste_non_classee[$p]); |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return [$liste, $ordre, $liste_non_classee]; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -543,40 +543,40 @@ discard block |
||
| 543 | 543 | * Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent |
| 544 | 544 | **/ |
| 545 | 545 | function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = []) { |
| 546 | - static $erreurs = []; |
|
| 547 | - |
|
| 548 | - if (!is_array($liste)) { |
|
| 549 | - $liste = []; |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 553 | - $liste = array_diff_key($liste, $liste_non_classee); |
|
| 554 | - |
|
| 555 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 556 | - $dir_type = $resume['dir_type']; |
|
| 557 | - $plug = $resume['dir']; |
|
| 558 | - $k = $infos[$dir_type][$plug]; |
|
| 559 | - |
|
| 560 | - $plug = constant($dir_type) . $plug; |
|
| 561 | - if (!isset($msg[$p])) { |
|
| 562 | - if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 563 | - $msg[$p] = [$resume['erreur']]; |
|
| 564 | - } |
|
| 565 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 566 | - $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 567 | - } |
|
| 568 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 569 | - $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 570 | - } |
|
| 571 | - } else { |
|
| 572 | - foreach ($msg[$p] as $c => $l) { |
|
| 573 | - $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 574 | - } |
|
| 575 | - } |
|
| 576 | - $erreurs[$plug] = $msg[$p]; |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 546 | + static $erreurs = []; |
|
| 547 | + |
|
| 548 | + if (!is_array($liste)) { |
|
| 549 | + $liste = []; |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 553 | + $liste = array_diff_key($liste, $liste_non_classee); |
|
| 554 | + |
|
| 555 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 556 | + $dir_type = $resume['dir_type']; |
|
| 557 | + $plug = $resume['dir']; |
|
| 558 | + $k = $infos[$dir_type][$plug]; |
|
| 559 | + |
|
| 560 | + $plug = constant($dir_type) . $plug; |
|
| 561 | + if (!isset($msg[$p])) { |
|
| 562 | + if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 563 | + $msg[$p] = [$resume['erreur']]; |
|
| 564 | + } |
|
| 565 | + elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 566 | + $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 567 | + } |
|
| 568 | + elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 569 | + $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 570 | + } |
|
| 571 | + } else { |
|
| 572 | + foreach ($msg[$p] as $c => $l) { |
|
| 573 | + $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | + $erreurs[$plug] = $msg[$p]; |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -591,25 +591,25 @@ discard block |
||
| 591 | 591 | * - Liste des erreurs ou code HTML des erreurs |
| 592 | 592 | **/ |
| 593 | 593 | function plugin_donne_erreurs($raw = false, $raz = true) { |
| 594 | - if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 595 | - return $raw ? [] : ''; |
|
| 596 | - } |
|
| 597 | - $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 598 | - // Compat ancienne version |
|
| 599 | - if (!$list) { |
|
| 600 | - $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 601 | - } elseif (!$raw) { |
|
| 602 | - foreach ($list as $plug => $msg) { |
|
| 603 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 605 | - } |
|
| 606 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 607 | - } |
|
| 608 | - if ($raz) { |
|
| 609 | - effacer_meta('plugin_erreur_activation'); |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - return $list; |
|
| 594 | + if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 595 | + return $raw ? [] : ''; |
|
| 596 | + } |
|
| 597 | + $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 598 | + // Compat ancienne version |
|
| 599 | + if (!$list) { |
|
| 600 | + $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 601 | + } elseif (!$raw) { |
|
| 602 | + foreach ($list as $plug => $msg) { |
|
| 603 | + $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | + . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 605 | + } |
|
| 606 | + $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 607 | + } |
|
| 608 | + if ($raz) { |
|
| 609 | + effacer_meta('plugin_erreur_activation'); |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + return $list; |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -629,21 +629,21 @@ discard block |
||
| 629 | 629 | * |
| 630 | 630 | **/ |
| 631 | 631 | function plugin_necessite($n, $liste, $balise = 'necessite') { |
| 632 | - $msg = []; |
|
| 633 | - foreach ($n as $need) { |
|
| 634 | - $id = strtoupper($need['nom']); |
|
| 635 | - $r = plugin_controler_necessite( |
|
| 636 | - $liste, |
|
| 637 | - $id, |
|
| 638 | - $need['compatibilite'] ?? '', |
|
| 639 | - $balise |
|
| 640 | - ); |
|
| 641 | - if ($r) { |
|
| 642 | - $msg[] = $r; |
|
| 643 | - } |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - return $msg; |
|
| 632 | + $msg = []; |
|
| 633 | + foreach ($n as $need) { |
|
| 634 | + $id = strtoupper($need['nom']); |
|
| 635 | + $r = plugin_controler_necessite( |
|
| 636 | + $liste, |
|
| 637 | + $id, |
|
| 638 | + $need['compatibilite'] ?? '', |
|
| 639 | + $balise |
|
| 640 | + ); |
|
| 641 | + if ($r) { |
|
| 642 | + $msg[] = $r; |
|
| 643 | + } |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + return $msg; |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | /** |
@@ -665,19 +665,19 @@ discard block |
||
| 665 | 665 | * Message d'erreur lorsque la dépendance est absente. |
| 666 | 666 | **/ |
| 667 | 667 | function plugin_controler_necessite($liste, $nom, $intervalle, $balise) { |
| 668 | - if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 669 | - return ''; |
|
| 670 | - } |
|
| 671 | - // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 672 | - if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 673 | - return ''; |
|
| 674 | - } |
|
| 675 | - return plugin_message_incompatibilite( |
|
| 676 | - $intervalle, |
|
| 677 | - (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 678 | - $nom, |
|
| 679 | - $balise |
|
| 680 | - ); |
|
| 668 | + if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 669 | + return ''; |
|
| 670 | + } |
|
| 671 | + // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 672 | + if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 673 | + return ''; |
|
| 674 | + } |
|
| 675 | + return plugin_message_incompatibilite( |
|
| 676 | + $intervalle, |
|
| 677 | + (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 678 | + $nom, |
|
| 679 | + $balise |
|
| 680 | + ); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -694,70 +694,70 @@ discard block |
||
| 694 | 694 | */ |
| 695 | 695 | function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) { |
| 696 | 696 | |
| 697 | - // prendre en compte les erreurs de dépendances à PHP |
|
| 698 | - // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 699 | - $type = 'plugin'; |
|
| 700 | - if ($nom === 'SPIP') { |
|
| 701 | - $type = 'spip'; |
|
| 702 | - } elseif ($nom === 'PHP') { |
|
| 703 | - $type = 'php'; |
|
| 704 | - } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 705 | - $type = 'extension_php'; |
|
| 706 | - [, $nom] = explode(':', $nom, 2); |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 710 | - $minimum = $regs[1]; |
|
| 711 | - $maximum = $regs[2]; |
|
| 712 | - |
|
| 713 | - $minimum_inclus = $intervalle[0] == '['; |
|
| 714 | - $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 715 | - |
|
| 716 | - if (strlen($minimum)) { |
|
| 717 | - if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 718 | - return _T("plugin_${balise}_${type}", [ |
|
| 719 | - 'plugin' => $nom, |
|
| 720 | - 'version' => ' ≥ ' . $minimum |
|
| 721 | - ]); |
|
| 722 | - } |
|
| 723 | - if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 724 | - return _T("plugin_${balise}_${type}", [ |
|
| 725 | - 'plugin' => $nom, |
|
| 726 | - 'version' => ' > ' . $minimum |
|
| 727 | - ]); |
|
| 728 | - } |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - if (strlen($maximum)) { |
|
| 732 | - if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 733 | - return _T("plugin_${balise}_${type}", [ |
|
| 734 | - 'plugin' => $nom, |
|
| 735 | - 'version' => ' ≤ ' . $maximum |
|
| 736 | - ]); |
|
| 737 | - } |
|
| 738 | - if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 739 | - return _T("plugin_${balise}_plugin", [ |
|
| 740 | - 'plugin' => $nom, |
|
| 741 | - 'version' => ' < ' . $maximum |
|
| 742 | - ]); |
|
| 743 | - } |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - // note : il ne peut pas y avoir d'erreur sur |
|
| 748 | - // - un 'utilise' sans version. |
|
| 749 | - // - un 'php' sans version. |
|
| 750 | - return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]); |
|
| 697 | + // prendre en compte les erreurs de dépendances à PHP |
|
| 698 | + // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 699 | + $type = 'plugin'; |
|
| 700 | + if ($nom === 'SPIP') { |
|
| 701 | + $type = 'spip'; |
|
| 702 | + } elseif ($nom === 'PHP') { |
|
| 703 | + $type = 'php'; |
|
| 704 | + } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 705 | + $type = 'extension_php'; |
|
| 706 | + [, $nom] = explode(':', $nom, 2); |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 710 | + $minimum = $regs[1]; |
|
| 711 | + $maximum = $regs[2]; |
|
| 712 | + |
|
| 713 | + $minimum_inclus = $intervalle[0] == '['; |
|
| 714 | + $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 715 | + |
|
| 716 | + if (strlen($minimum)) { |
|
| 717 | + if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 718 | + return _T("plugin_${balise}_${type}", [ |
|
| 719 | + 'plugin' => $nom, |
|
| 720 | + 'version' => ' ≥ ' . $minimum |
|
| 721 | + ]); |
|
| 722 | + } |
|
| 723 | + if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 724 | + return _T("plugin_${balise}_${type}", [ |
|
| 725 | + 'plugin' => $nom, |
|
| 726 | + 'version' => ' > ' . $minimum |
|
| 727 | + ]); |
|
| 728 | + } |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + if (strlen($maximum)) { |
|
| 732 | + if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 733 | + return _T("plugin_${balise}_${type}", [ |
|
| 734 | + 'plugin' => $nom, |
|
| 735 | + 'version' => ' ≤ ' . $maximum |
|
| 736 | + ]); |
|
| 737 | + } |
|
| 738 | + if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 739 | + return _T("plugin_${balise}_plugin", [ |
|
| 740 | + 'plugin' => $nom, |
|
| 741 | + 'version' => ' < ' . $maximum |
|
| 742 | + ]); |
|
| 743 | + } |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + // note : il ne peut pas y avoir d'erreur sur |
|
| 748 | + // - un 'utilise' sans version. |
|
| 749 | + // - un 'php' sans version. |
|
| 750 | + return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]); |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | |
| 754 | 754 | function plugin_controler_lib($lib, $url) { |
| 755 | - /* Feature sortie du core, voir STP |
|
| 755 | + /* Feature sortie du core, voir STP |
|
| 756 | 756 | * if ($url) { |
| 757 | 757 | include_spip('inc/charger_plugin'); |
| 758 | 758 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 759 | 759 | }*/ |
| 760 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 760 | + return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | * true si il y a eu des modifications sur la liste des plugins actifs, false sinon |
| 773 | 773 | **/ |
| 774 | 774 | function actualise_plugins_actifs($pipe_recherche = false) { |
| 775 | - return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 775 | + return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | |
@@ -799,116 +799,116 @@ discard block |
||
| 799 | 799 | **/ |
| 800 | 800 | function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') { |
| 801 | 801 | |
| 802 | - // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 803 | - $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 804 | - |
|
| 805 | - // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 806 | - if (!$cache and !spip_connect()) { |
|
| 807 | - return false; |
|
| 808 | - } |
|
| 809 | - |
|
| 810 | - if ($operation != 'raz') { |
|
| 811 | - $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 812 | - $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 813 | - if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 814 | - $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 815 | - $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 816 | - $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 817 | - } |
|
| 818 | - // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 819 | - // on les reinjecte ici |
|
| 820 | - if ( |
|
| 821 | - isset($GLOBALS['meta']['plugin_attente']) |
|
| 822 | - and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 823 | - ) { |
|
| 824 | - $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 825 | - } |
|
| 826 | - |
|
| 827 | - if ($operation == 'ajoute') { |
|
| 828 | - $plugin = array_merge($plugin_valides, $plugin); |
|
| 829 | - } elseif ($operation == 'enleve') { |
|
| 830 | - $plugin = array_diff($plugin_valides, $plugin); |
|
| 831 | - } else { |
|
| 832 | - $plugin = $plugin_valides; |
|
| 833 | - } |
|
| 834 | - } |
|
| 835 | - $actifs_avant = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 836 | - |
|
| 837 | - // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 838 | - if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 839 | - $plugin = $ajouter_dependances($plugin); |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - // recharger le xml des plugins a activer |
|
| 843 | - // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 844 | - // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 845 | - // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 846 | - // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 847 | - [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true); |
|
| 848 | - // trouver l'ordre d'activation |
|
| 849 | - [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste); |
|
| 850 | - if ($invalides or $reste) { |
|
| 851 | - plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 852 | - } |
|
| 853 | - |
|
| 854 | - // Ignorer les plugins necessitant une lib absente |
|
| 855 | - // et preparer la meta d'entete Http |
|
| 856 | - $err = $msg = $header = []; |
|
| 857 | - foreach ($plugin_valides as $p => $resume) { |
|
| 858 | - // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 859 | - if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 860 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 861 | - } |
|
| 862 | - if ($resume['dir']) { |
|
| 863 | - foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 864 | - if (!find_in_path($l['nom'], 'lib/')) { |
|
| 865 | - $err[$p] = $resume; |
|
| 866 | - $msg[$p][] = $l; |
|
| 867 | - unset($plugin_valides[$p]); |
|
| 868 | - } |
|
| 869 | - } |
|
| 870 | - } |
|
| 871 | - } |
|
| 872 | - if ($err) { |
|
| 873 | - plugins_erreurs($err, '', $infos, $msg); |
|
| 874 | - } |
|
| 875 | - |
|
| 876 | - if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 877 | - effacer_meta('message_crash_plugins'); |
|
| 878 | - } |
|
| 879 | - ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 880 | - $liste = array_diff_key($liste, $plugin_valides); |
|
| 881 | - ecrire_meta('plugin_attente', serialize($liste)); |
|
| 882 | - $header = strtolower(implode(',', $header)); |
|
| 883 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 884 | - ecrire_fichier( |
|
| 885 | - _DIR_VAR . 'config.txt', |
|
| 886 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 887 | - ); |
|
| 888 | - } else { |
|
| 889 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 890 | - } |
|
| 891 | - // generer charger_plugins_chemin.php |
|
| 892 | - plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 893 | - // generer les fichiers |
|
| 894 | - // - charger_plugins_options.php |
|
| 895 | - // - charger_plugins_fonctions.php |
|
| 896 | - plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 897 | - // charger les chemins des plugins et les fichiers d'options |
|
| 898 | - // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 899 | - plugins_amorcer_plugins_actifs(); |
|
| 900 | - // mise a jour de la matrice des pipelines |
|
| 901 | - $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 902 | - // generer le fichier _CACHE_PIPELINE |
|
| 903 | - pipeline_precompile($prepend_code); |
|
| 904 | - |
|
| 905 | - if (spip_connect()) { |
|
| 906 | - // lancer et initialiser les nouveaux crons ! |
|
| 907 | - include_spip('inc/genie'); |
|
| 908 | - genie_queue_watch_dist(); |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 802 | + // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 803 | + $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 804 | + |
|
| 805 | + // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 806 | + if (!$cache and !spip_connect()) { |
|
| 807 | + return false; |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + if ($operation != 'raz') { |
|
| 811 | + $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 812 | + $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 813 | + if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 814 | + $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 815 | + $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 816 | + $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 817 | + } |
|
| 818 | + // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 819 | + // on les reinjecte ici |
|
| 820 | + if ( |
|
| 821 | + isset($GLOBALS['meta']['plugin_attente']) |
|
| 822 | + and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 823 | + ) { |
|
| 824 | + $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 825 | + } |
|
| 826 | + |
|
| 827 | + if ($operation == 'ajoute') { |
|
| 828 | + $plugin = array_merge($plugin_valides, $plugin); |
|
| 829 | + } elseif ($operation == 'enleve') { |
|
| 830 | + $plugin = array_diff($plugin_valides, $plugin); |
|
| 831 | + } else { |
|
| 832 | + $plugin = $plugin_valides; |
|
| 833 | + } |
|
| 834 | + } |
|
| 835 | + $actifs_avant = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 836 | + |
|
| 837 | + // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 838 | + if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 839 | + $plugin = $ajouter_dependances($plugin); |
|
| 840 | + } |
|
| 841 | + |
|
| 842 | + // recharger le xml des plugins a activer |
|
| 843 | + // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 844 | + // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 845 | + // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 846 | + // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 847 | + [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true); |
|
| 848 | + // trouver l'ordre d'activation |
|
| 849 | + [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste); |
|
| 850 | + if ($invalides or $reste) { |
|
| 851 | + plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 852 | + } |
|
| 853 | + |
|
| 854 | + // Ignorer les plugins necessitant une lib absente |
|
| 855 | + // et preparer la meta d'entete Http |
|
| 856 | + $err = $msg = $header = []; |
|
| 857 | + foreach ($plugin_valides as $p => $resume) { |
|
| 858 | + // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 859 | + if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 860 | + $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 861 | + } |
|
| 862 | + if ($resume['dir']) { |
|
| 863 | + foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 864 | + if (!find_in_path($l['nom'], 'lib/')) { |
|
| 865 | + $err[$p] = $resume; |
|
| 866 | + $msg[$p][] = $l; |
|
| 867 | + unset($plugin_valides[$p]); |
|
| 868 | + } |
|
| 869 | + } |
|
| 870 | + } |
|
| 871 | + } |
|
| 872 | + if ($err) { |
|
| 873 | + plugins_erreurs($err, '', $infos, $msg); |
|
| 874 | + } |
|
| 875 | + |
|
| 876 | + if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 877 | + effacer_meta('message_crash_plugins'); |
|
| 878 | + } |
|
| 879 | + ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 880 | + $liste = array_diff_key($liste, $plugin_valides); |
|
| 881 | + ecrire_meta('plugin_attente', serialize($liste)); |
|
| 882 | + $header = strtolower(implode(',', $header)); |
|
| 883 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 884 | + ecrire_fichier( |
|
| 885 | + _DIR_VAR . 'config.txt', |
|
| 886 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 887 | + ); |
|
| 888 | + } else { |
|
| 889 | + @unlink(_DIR_VAR . 'config.txt'); |
|
| 890 | + } |
|
| 891 | + // generer charger_plugins_chemin.php |
|
| 892 | + plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 893 | + // generer les fichiers |
|
| 894 | + // - charger_plugins_options.php |
|
| 895 | + // - charger_plugins_fonctions.php |
|
| 896 | + plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 897 | + // charger les chemins des plugins et les fichiers d'options |
|
| 898 | + // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 899 | + plugins_amorcer_plugins_actifs(); |
|
| 900 | + // mise a jour de la matrice des pipelines |
|
| 901 | + $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 902 | + // generer le fichier _CACHE_PIPELINE |
|
| 903 | + pipeline_precompile($prepend_code); |
|
| 904 | + |
|
| 905 | + if (spip_connect()) { |
|
| 906 | + // lancer et initialiser les nouveaux crons ! |
|
| 907 | + include_spip('inc/genie'); |
|
| 908 | + genie_queue_watch_dist(); |
|
| 909 | + } |
|
| 910 | + |
|
| 911 | + return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
@@ -927,74 +927,74 @@ discard block |
||
| 927 | 927 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 928 | 928 | **/ |
| 929 | 929 | function plugins_precompile_chemin($plugin_valides, $ordre) { |
| 930 | - $chemins = [ |
|
| 931 | - 'public' => [], |
|
| 932 | - 'prive' => [] |
|
| 933 | - ]; |
|
| 934 | - $contenu = ''; |
|
| 935 | - foreach ($ordre as $p => $info) { |
|
| 936 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 937 | - if (isset($plugin_valides[$p])) { |
|
| 938 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 939 | - $plug = $plugin_valides[$p]['dir']; |
|
| 940 | - // definir le plugin, donc le path avant l'include du fichier options |
|
| 941 | - // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 942 | - |
|
| 943 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 944 | - |
|
| 945 | - $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 946 | - if ( |
|
| 947 | - $prefix !== 'SPIP' |
|
| 948 | - and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 949 | - ) { |
|
| 950 | - $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 951 | - if (!$info['chemin']) { |
|
| 952 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 953 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 954 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 955 | - $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 956 | - } |
|
| 957 | - } |
|
| 958 | - else { |
|
| 959 | - foreach ($info['chemin'] as $chemin) { |
|
| 960 | - if ( |
|
| 961 | - !isset($chemin['version']) or plugin_version_compatible( |
|
| 962 | - $chemin['version'], |
|
| 963 | - $GLOBALS['spip_version_branche'], |
|
| 964 | - 'spip' |
|
| 965 | - ) |
|
| 966 | - ) { |
|
| 967 | - $dir = $chemin['path']; |
|
| 968 | - if (strlen($dir) and $dir[0] == '/') { |
|
| 969 | - $dir = substr($dir, 1); |
|
| 970 | - } |
|
| 971 | - if (strlen($dir) and $dir == './') { |
|
| 972 | - $dir = ''; |
|
| 973 | - } |
|
| 974 | - if (strlen($dir)) { |
|
| 975 | - $dir = rtrim($dir, '/') . '/'; |
|
| 976 | - } |
|
| 977 | - if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 978 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 979 | - } |
|
| 980 | - if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 981 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 982 | - } |
|
| 983 | - } |
|
| 984 | - } |
|
| 985 | - } |
|
| 986 | - } |
|
| 987 | - } |
|
| 988 | - } |
|
| 989 | - if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 990 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 991 | - ',', |
|
| 992 | - array_reverse($chemins['public']) |
|
| 993 | - ) . "]);\n" |
|
| 994 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 995 | - } |
|
| 996 | - |
|
| 997 | - ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 930 | + $chemins = [ |
|
| 931 | + 'public' => [], |
|
| 932 | + 'prive' => [] |
|
| 933 | + ]; |
|
| 934 | + $contenu = ''; |
|
| 935 | + foreach ($ordre as $p => $info) { |
|
| 936 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 937 | + if (isset($plugin_valides[$p])) { |
|
| 938 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 939 | + $plug = $plugin_valides[$p]['dir']; |
|
| 940 | + // definir le plugin, donc le path avant l'include du fichier options |
|
| 941 | + // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 942 | + |
|
| 943 | + $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 944 | + |
|
| 945 | + $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 946 | + if ( |
|
| 947 | + $prefix !== 'SPIP' |
|
| 948 | + and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 949 | + ) { |
|
| 950 | + $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 951 | + if (!$info['chemin']) { |
|
| 952 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 953 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 954 | + if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 955 | + $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 956 | + } |
|
| 957 | + } |
|
| 958 | + else { |
|
| 959 | + foreach ($info['chemin'] as $chemin) { |
|
| 960 | + if ( |
|
| 961 | + !isset($chemin['version']) or plugin_version_compatible( |
|
| 962 | + $chemin['version'], |
|
| 963 | + $GLOBALS['spip_version_branche'], |
|
| 964 | + 'spip' |
|
| 965 | + ) |
|
| 966 | + ) { |
|
| 967 | + $dir = $chemin['path']; |
|
| 968 | + if (strlen($dir) and $dir[0] == '/') { |
|
| 969 | + $dir = substr($dir, 1); |
|
| 970 | + } |
|
| 971 | + if (strlen($dir) and $dir == './') { |
|
| 972 | + $dir = ''; |
|
| 973 | + } |
|
| 974 | + if (strlen($dir)) { |
|
| 975 | + $dir = rtrim($dir, '/') . '/'; |
|
| 976 | + } |
|
| 977 | + if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 978 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 979 | + } |
|
| 980 | + if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 981 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 982 | + } |
|
| 983 | + } |
|
| 984 | + } |
|
| 985 | + } |
|
| 986 | + } |
|
| 987 | + } |
|
| 988 | + } |
|
| 989 | + if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 990 | + $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 991 | + ',', |
|
| 992 | + array_reverse($chemins['public']) |
|
| 993 | + ) . "]);\n" |
|
| 994 | + . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 995 | + } |
|
| 996 | + |
|
| 997 | + ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | /** |
@@ -1012,67 +1012,67 @@ discard block |
||
| 1012 | 1012 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 1013 | 1013 | **/ |
| 1014 | 1014 | function plugins_precompile_xxxtions($plugin_valides, $ordre) { |
| 1015 | - $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1016 | - $boutons = []; |
|
| 1017 | - $onglets = []; |
|
| 1018 | - $sign = ''; |
|
| 1019 | - |
|
| 1020 | - foreach ($ordre as $p => $info) { |
|
| 1021 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1022 | - if (isset($plugin_valides[$p])) { |
|
| 1023 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1024 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1025 | - $dir = constant($dir_type); |
|
| 1026 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1027 | - if ($info['menu']) { |
|
| 1028 | - $boutons = array_merge($boutons, $info['menu']); |
|
| 1029 | - } |
|
| 1030 | - if ($info['onglet']) { |
|
| 1031 | - $onglets = array_merge($onglets, $info['onglet']); |
|
| 1032 | - } |
|
| 1033 | - foreach ($contenu as $charge => $v) { |
|
| 1034 | - // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1035 | - // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1036 | - // donc ni sa relecture, ni sa detection |
|
| 1037 | - if ( |
|
| 1038 | - !isset($info[$charge]) |
|
| 1039 | - and $dir // exclure le cas du plugin "SPIP" |
|
| 1040 | - and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 1041 | - and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1042 | - ) { |
|
| 1043 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1044 | - $info[$charge] = [$file]; |
|
| 1045 | - } |
|
| 1046 | - } |
|
| 1047 | - if (isset($info[$charge])) { |
|
| 1048 | - $files = $info[$charge]; |
|
| 1049 | - foreach ($files as $k => $file) { |
|
| 1050 | - // on genere un if file_exists devant chaque include |
|
| 1051 | - // pour pouvoir garder le meme niveau d'erreur general |
|
| 1052 | - $file = trim($file); |
|
| 1053 | - if ( |
|
| 1054 | - !is_readable("$dir$plug/$file") |
|
| 1055 | - // uniquement pour les paquet.xml |
|
| 1056 | - and file_exists("$dir$plug/paquet.xml") |
|
| 1057 | - ) { |
|
| 1058 | - unset($info[$charge][$k]); |
|
| 1059 | - } else { |
|
| 1060 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1061 | - $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1062 | - } |
|
| 1063 | - } |
|
| 1064 | - } |
|
| 1065 | - } |
|
| 1066 | - $sign .= md5(serialize($info)); |
|
| 1067 | - } |
|
| 1068 | - } |
|
| 1069 | - |
|
| 1070 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1071 | - $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1072 | - . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1073 | - |
|
| 1074 | - ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1075 | - ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1015 | + $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1016 | + $boutons = []; |
|
| 1017 | + $onglets = []; |
|
| 1018 | + $sign = ''; |
|
| 1019 | + |
|
| 1020 | + foreach ($ordre as $p => $info) { |
|
| 1021 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1022 | + if (isset($plugin_valides[$p])) { |
|
| 1023 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1024 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1025 | + $dir = constant($dir_type); |
|
| 1026 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1027 | + if ($info['menu']) { |
|
| 1028 | + $boutons = array_merge($boutons, $info['menu']); |
|
| 1029 | + } |
|
| 1030 | + if ($info['onglet']) { |
|
| 1031 | + $onglets = array_merge($onglets, $info['onglet']); |
|
| 1032 | + } |
|
| 1033 | + foreach ($contenu as $charge => $v) { |
|
| 1034 | + // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1035 | + // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1036 | + // donc ni sa relecture, ni sa detection |
|
| 1037 | + if ( |
|
| 1038 | + !isset($info[$charge]) |
|
| 1039 | + and $dir // exclure le cas du plugin "SPIP" |
|
| 1040 | + and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 1041 | + and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1042 | + ) { |
|
| 1043 | + if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1044 | + $info[$charge] = [$file]; |
|
| 1045 | + } |
|
| 1046 | + } |
|
| 1047 | + if (isset($info[$charge])) { |
|
| 1048 | + $files = $info[$charge]; |
|
| 1049 | + foreach ($files as $k => $file) { |
|
| 1050 | + // on genere un if file_exists devant chaque include |
|
| 1051 | + // pour pouvoir garder le meme niveau d'erreur general |
|
| 1052 | + $file = trim($file); |
|
| 1053 | + if ( |
|
| 1054 | + !is_readable("$dir$plug/$file") |
|
| 1055 | + // uniquement pour les paquet.xml |
|
| 1056 | + and file_exists("$dir$plug/paquet.xml") |
|
| 1057 | + ) { |
|
| 1058 | + unset($info[$charge][$k]); |
|
| 1059 | + } else { |
|
| 1060 | + $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1061 | + $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1062 | + } |
|
| 1063 | + } |
|
| 1064 | + } |
|
| 1065 | + } |
|
| 1066 | + $sign .= md5(serialize($info)); |
|
| 1067 | + } |
|
| 1068 | + } |
|
| 1069 | + |
|
| 1070 | + $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1071 | + $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1072 | + . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1073 | + |
|
| 1074 | + ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1075 | + ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | /** |
@@ -1091,24 +1091,24 @@ discard block |
||
| 1091 | 1091 | * @return string Code php |
| 1092 | 1092 | */ |
| 1093 | 1093 | function plugin_ongletbouton($nom, $val) { |
| 1094 | - if (!$val) { |
|
| 1095 | - $val = []; |
|
| 1096 | - } |
|
| 1097 | - |
|
| 1098 | - $val = serialize($val); |
|
| 1099 | - $md5 = md5($val); |
|
| 1100 | - |
|
| 1101 | - if (!defined("_UPDATED_$nom")) { |
|
| 1102 | - define("_UPDATED_$nom", $val); |
|
| 1103 | - define("_UPDATED_md5_$nom", $md5); |
|
| 1104 | - } |
|
| 1105 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1106 | - |
|
| 1107 | - return |
|
| 1108 | - "if (!function_exists('$nom')) {\n" |
|
| 1109 | - . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1110 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1111 | - . "}\n"; |
|
| 1094 | + if (!$val) { |
|
| 1095 | + $val = []; |
|
| 1096 | + } |
|
| 1097 | + |
|
| 1098 | + $val = serialize($val); |
|
| 1099 | + $md5 = md5($val); |
|
| 1100 | + |
|
| 1101 | + if (!defined("_UPDATED_$nom")) { |
|
| 1102 | + define("_UPDATED_$nom", $val); |
|
| 1103 | + define("_UPDATED_md5_$nom", $md5); |
|
| 1104 | + } |
|
| 1105 | + $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1106 | + |
|
| 1107 | + return |
|
| 1108 | + "if (!function_exists('$nom')) {\n" |
|
| 1109 | + . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1110 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1111 | + . "}\n"; |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | /** |
@@ -1123,15 +1123,15 @@ discard block |
||
| 1123 | 1123 | **/ |
| 1124 | 1124 | function plugins_amorcer_plugins_actifs() { |
| 1125 | 1125 | |
| 1126 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1127 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1128 | - } |
|
| 1126 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1127 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1128 | + } |
|
| 1129 | 1129 | |
| 1130 | - if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1131 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 1132 | - } else { |
|
| 1133 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1134 | - } |
|
| 1130 | + if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1131 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 1132 | + } else { |
|
| 1133 | + spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1134 | + } |
|
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | 1137 | /** |
@@ -1154,140 +1154,140 @@ discard block |
||
| 1154 | 1154 | * Couples (nom du pipeline => Code PHP à insérer au début du pipeline) |
| 1155 | 1155 | **/ |
| 1156 | 1156 | function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) { |
| 1157 | - static $liste_pipe_manquants = []; |
|
| 1158 | - if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1159 | - $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1160 | - } |
|
| 1161 | - |
|
| 1162 | - $prepend_code = []; |
|
| 1163 | - |
|
| 1164 | - foreach ($ordre as $p => $info) { |
|
| 1165 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1166 | - if (isset($plugin_valides[$p])) { |
|
| 1167 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1168 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1169 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1170 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1171 | - if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1172 | - foreach ($info['pipeline'] as $pipe) { |
|
| 1173 | - $nom = $pipe['nom']; |
|
| 1174 | - if (isset($pipe['action'])) { |
|
| 1175 | - $action = $pipe['action']; |
|
| 1176 | - } else { |
|
| 1177 | - $action = $nom; |
|
| 1178 | - } |
|
| 1179 | - $nomlower = strtolower($nom); |
|
| 1180 | - if ( |
|
| 1181 | - $nomlower != $nom |
|
| 1182 | - and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1183 | - and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1184 | - ) { |
|
| 1185 | - $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1186 | - unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1187 | - } |
|
| 1188 | - $nom = $nomlower; |
|
| 1189 | - // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1190 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1191 | - $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1192 | - } |
|
| 1193 | - if ($action) { |
|
| 1194 | - if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) { |
|
| 1195 | - $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1196 | - ',(\|\||$),', |
|
| 1197 | - "|$prefix$action\\1", |
|
| 1198 | - $GLOBALS['spip_pipeline'][$nom], |
|
| 1199 | - 1 |
|
| 1200 | - ); |
|
| 1201 | - } |
|
| 1202 | - if (isset($pipe['inclure'])) { |
|
| 1203 | - $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1204 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1205 | - } |
|
| 1206 | - } |
|
| 1207 | - } |
|
| 1208 | - } |
|
| 1209 | - if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) { |
|
| 1210 | - if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1211 | - $prepend_code['taches_generales_cron'] = ''; |
|
| 1212 | - } |
|
| 1213 | - foreach ($info['genie'] as $genie) { |
|
| 1214 | - $nom = $prefix . $genie['nom']; |
|
| 1215 | - $periode = max(60, intval($genie['periode'])); |
|
| 1216 | - if (charger_fonction($nom, 'genie', true)) { |
|
| 1217 | - $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1218 | - } else { |
|
| 1219 | - spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1220 | - } |
|
| 1221 | - } |
|
| 1222 | - } |
|
| 1223 | - if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) { |
|
| 1224 | - if (!isset($prepend_code['insert_head_css'])) { |
|
| 1225 | - $prepend_code['insert_head_css'] = ''; |
|
| 1226 | - } |
|
| 1227 | - if (!isset($prepend_code['header_prive_css'])) { |
|
| 1228 | - $prepend_code['header_prive_css'] = ''; |
|
| 1229 | - } |
|
| 1230 | - foreach ($info['style'] as $style) { |
|
| 1231 | - if (isset($style['path']) and $style['path']) { |
|
| 1232 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1233 | - } else { |
|
| 1234 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1235 | - } |
|
| 1236 | - $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1237 | - if (isset($style['media']) and strlen($style['media'])) { |
|
| 1238 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1239 | - } |
|
| 1240 | - $code .= "/>';\n"; |
|
| 1241 | - if ($style['type'] != 'prive') { |
|
| 1242 | - $prepend_code['insert_head_css'] .= $code; |
|
| 1243 | - } |
|
| 1244 | - if ($style['type'] != 'public') { |
|
| 1245 | - $prepend_code['header_prive_css'] .= $code; |
|
| 1246 | - } |
|
| 1247 | - } |
|
| 1248 | - } |
|
| 1249 | - if (!isset($prepend_code['insert_head'])) { |
|
| 1250 | - $prepend_code['insert_head'] = ''; |
|
| 1251 | - } |
|
| 1252 | - if (!isset($prepend_code['header_prive'])) { |
|
| 1253 | - $prepend_code['header_prive'] = ''; |
|
| 1254 | - } |
|
| 1255 | - if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
|
| 1256 | - foreach ($info['script'] as $script) { |
|
| 1257 | - if (isset($script['path']) and $script['path']) { |
|
| 1258 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1259 | - } else { |
|
| 1260 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1261 | - } |
|
| 1262 | - $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1263 | - if ($script['type'] != 'prive') { |
|
| 1264 | - $prepend_code['insert_head'] .= $code; |
|
| 1265 | - } |
|
| 1266 | - if ($script['type'] != 'public') { |
|
| 1267 | - $prepend_code['header_prive'] .= $code; |
|
| 1268 | - } |
|
| 1269 | - } |
|
| 1270 | - } |
|
| 1271 | - } |
|
| 1272 | - } |
|
| 1273 | - |
|
| 1274 | - $prepend_code['insert_head'] = |
|
| 1275 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1276 | - . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1277 | - . $prepend_code['insert_head']; |
|
| 1278 | - $prepend_code['header_prive'] = |
|
| 1279 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1280 | - . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1281 | - . $prepend_code['header_prive']; |
|
| 1282 | - |
|
| 1283 | - // on ajoute les pipe qui ont ete recenses manquants |
|
| 1284 | - foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1285 | - if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1286 | - $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1287 | - } |
|
| 1288 | - } |
|
| 1289 | - |
|
| 1290 | - return $prepend_code; |
|
| 1157 | + static $liste_pipe_manquants = []; |
|
| 1158 | + if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1159 | + $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1160 | + } |
|
| 1161 | + |
|
| 1162 | + $prepend_code = []; |
|
| 1163 | + |
|
| 1164 | + foreach ($ordre as $p => $info) { |
|
| 1165 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1166 | + if (isset($plugin_valides[$p])) { |
|
| 1167 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1168 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1169 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1170 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1171 | + if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1172 | + foreach ($info['pipeline'] as $pipe) { |
|
| 1173 | + $nom = $pipe['nom']; |
|
| 1174 | + if (isset($pipe['action'])) { |
|
| 1175 | + $action = $pipe['action']; |
|
| 1176 | + } else { |
|
| 1177 | + $action = $nom; |
|
| 1178 | + } |
|
| 1179 | + $nomlower = strtolower($nom); |
|
| 1180 | + if ( |
|
| 1181 | + $nomlower != $nom |
|
| 1182 | + and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1183 | + and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1184 | + ) { |
|
| 1185 | + $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1186 | + unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1187 | + } |
|
| 1188 | + $nom = $nomlower; |
|
| 1189 | + // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1190 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1191 | + $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1192 | + } |
|
| 1193 | + if ($action) { |
|
| 1194 | + if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) { |
|
| 1195 | + $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1196 | + ',(\|\||$),', |
|
| 1197 | + "|$prefix$action\\1", |
|
| 1198 | + $GLOBALS['spip_pipeline'][$nom], |
|
| 1199 | + 1 |
|
| 1200 | + ); |
|
| 1201 | + } |
|
| 1202 | + if (isset($pipe['inclure'])) { |
|
| 1203 | + $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1204 | + "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1205 | + } |
|
| 1206 | + } |
|
| 1207 | + } |
|
| 1208 | + } |
|
| 1209 | + if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) { |
|
| 1210 | + if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1211 | + $prepend_code['taches_generales_cron'] = ''; |
|
| 1212 | + } |
|
| 1213 | + foreach ($info['genie'] as $genie) { |
|
| 1214 | + $nom = $prefix . $genie['nom']; |
|
| 1215 | + $periode = max(60, intval($genie['periode'])); |
|
| 1216 | + if (charger_fonction($nom, 'genie', true)) { |
|
| 1217 | + $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1218 | + } else { |
|
| 1219 | + spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1220 | + } |
|
| 1221 | + } |
|
| 1222 | + } |
|
| 1223 | + if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) { |
|
| 1224 | + if (!isset($prepend_code['insert_head_css'])) { |
|
| 1225 | + $prepend_code['insert_head_css'] = ''; |
|
| 1226 | + } |
|
| 1227 | + if (!isset($prepend_code['header_prive_css'])) { |
|
| 1228 | + $prepend_code['header_prive_css'] = ''; |
|
| 1229 | + } |
|
| 1230 | + foreach ($info['style'] as $style) { |
|
| 1231 | + if (isset($style['path']) and $style['path']) { |
|
| 1232 | + $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1233 | + } else { |
|
| 1234 | + $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1235 | + } |
|
| 1236 | + $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1237 | + if (isset($style['media']) and strlen($style['media'])) { |
|
| 1238 | + $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1239 | + } |
|
| 1240 | + $code .= "/>';\n"; |
|
| 1241 | + if ($style['type'] != 'prive') { |
|
| 1242 | + $prepend_code['insert_head_css'] .= $code; |
|
| 1243 | + } |
|
| 1244 | + if ($style['type'] != 'public') { |
|
| 1245 | + $prepend_code['header_prive_css'] .= $code; |
|
| 1246 | + } |
|
| 1247 | + } |
|
| 1248 | + } |
|
| 1249 | + if (!isset($prepend_code['insert_head'])) { |
|
| 1250 | + $prepend_code['insert_head'] = ''; |
|
| 1251 | + } |
|
| 1252 | + if (!isset($prepend_code['header_prive'])) { |
|
| 1253 | + $prepend_code['header_prive'] = ''; |
|
| 1254 | + } |
|
| 1255 | + if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
|
| 1256 | + foreach ($info['script'] as $script) { |
|
| 1257 | + if (isset($script['path']) and $script['path']) { |
|
| 1258 | + $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1259 | + } else { |
|
| 1260 | + $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1261 | + } |
|
| 1262 | + $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1263 | + if ($script['type'] != 'prive') { |
|
| 1264 | + $prepend_code['insert_head'] .= $code; |
|
| 1265 | + } |
|
| 1266 | + if ($script['type'] != 'public') { |
|
| 1267 | + $prepend_code['header_prive'] .= $code; |
|
| 1268 | + } |
|
| 1269 | + } |
|
| 1270 | + } |
|
| 1271 | + } |
|
| 1272 | + } |
|
| 1273 | + |
|
| 1274 | + $prepend_code['insert_head'] = |
|
| 1275 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1276 | + . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1277 | + . $prepend_code['insert_head']; |
|
| 1278 | + $prepend_code['header_prive'] = |
|
| 1279 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1280 | + . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1281 | + . $prepend_code['header_prive']; |
|
| 1282 | + |
|
| 1283 | + // on ajoute les pipe qui ont ete recenses manquants |
|
| 1284 | + foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1285 | + if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1286 | + $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1287 | + } |
|
| 1288 | + } |
|
| 1289 | + |
|
| 1290 | + return $prepend_code; |
|
| 1291 | 1291 | } |
| 1292 | 1292 | |
| 1293 | 1293 | /** |
@@ -1314,62 +1314,62 @@ discard block |
||
| 1314 | 1314 | **/ |
| 1315 | 1315 | function pipeline_precompile($prepend_code = []) { |
| 1316 | 1316 | |
| 1317 | - $all_pipes = $all_pipes_end = ''; |
|
| 1318 | - if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1319 | - $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1320 | - unset($GLOBALS['spip_pipeline']['all']); |
|
| 1321 | - $all_pipes = trim(array_shift($a)); |
|
| 1322 | - if ($all_pipes) { |
|
| 1323 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1324 | - } |
|
| 1325 | - if (count($a)) { |
|
| 1326 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1327 | - } |
|
| 1328 | - } |
|
| 1329 | - $content = ''; |
|
| 1330 | - foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1331 | - $s_inc = ''; |
|
| 1332 | - $s_call = ''; |
|
| 1333 | - if ($all_pipes) { |
|
| 1334 | - $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1335 | - } |
|
| 1336 | - if ($all_pipes_end) { |
|
| 1337 | - $pipeline .= $all_pipes_end; |
|
| 1338 | - } |
|
| 1339 | - $pipe = array_filter(explode('|', $pipeline)); |
|
| 1340 | - // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1341 | - foreach ($pipe as $fonc) { |
|
| 1342 | - $fonc = trim($fonc); |
|
| 1343 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1344 | - if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1345 | - $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1346 | - $file = "'$file'"; |
|
| 1347 | - // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1348 | - if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1349 | - $dir = $regs[1]; |
|
| 1350 | - $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1351 | - if (defined($root_dir)) { |
|
| 1352 | - $dir = $root_dir; |
|
| 1353 | - } |
|
| 1354 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1355 | - $file = str_replace("''.", '', $file); |
|
| 1356 | - $file = str_replace(constant($dir), '', $file); |
|
| 1357 | - } |
|
| 1358 | - $s_inc .= "include_once_check($file);\n"; |
|
| 1359 | - } |
|
| 1360 | - } |
|
| 1361 | - if (strlen($s_inc)) { |
|
| 1362 | - $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1363 | - } |
|
| 1364 | - $content .= "// Pipeline $action \n" |
|
| 1365 | - . "function execute_pipeline_$action(&\$val){\n" |
|
| 1366 | - . $s_inc |
|
| 1367 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1368 | - . $s_call |
|
| 1369 | - . "return \$val;\n}\n"; |
|
| 1370 | - } |
|
| 1371 | - ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1372 | - clear_path_cache(); |
|
| 1317 | + $all_pipes = $all_pipes_end = ''; |
|
| 1318 | + if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1319 | + $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1320 | + unset($GLOBALS['spip_pipeline']['all']); |
|
| 1321 | + $all_pipes = trim(array_shift($a)); |
|
| 1322 | + if ($all_pipes) { |
|
| 1323 | + $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1324 | + } |
|
| 1325 | + if (count($a)) { |
|
| 1326 | + $all_pipes_end = '||' . array_shift($a); |
|
| 1327 | + } |
|
| 1328 | + } |
|
| 1329 | + $content = ''; |
|
| 1330 | + foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1331 | + $s_inc = ''; |
|
| 1332 | + $s_call = ''; |
|
| 1333 | + if ($all_pipes) { |
|
| 1334 | + $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1335 | + } |
|
| 1336 | + if ($all_pipes_end) { |
|
| 1337 | + $pipeline .= $all_pipes_end; |
|
| 1338 | + } |
|
| 1339 | + $pipe = array_filter(explode('|', $pipeline)); |
|
| 1340 | + // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1341 | + foreach ($pipe as $fonc) { |
|
| 1342 | + $fonc = trim($fonc); |
|
| 1343 | + $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1344 | + if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1345 | + $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1346 | + $file = "'$file'"; |
|
| 1347 | + // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1348 | + if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1349 | + $dir = $regs[1]; |
|
| 1350 | + $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1351 | + if (defined($root_dir)) { |
|
| 1352 | + $dir = $root_dir; |
|
| 1353 | + } |
|
| 1354 | + $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1355 | + $file = str_replace("''.", '', $file); |
|
| 1356 | + $file = str_replace(constant($dir), '', $file); |
|
| 1357 | + } |
|
| 1358 | + $s_inc .= "include_once_check($file);\n"; |
|
| 1359 | + } |
|
| 1360 | + } |
|
| 1361 | + if (strlen($s_inc)) { |
|
| 1362 | + $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1363 | + } |
|
| 1364 | + $content .= "// Pipeline $action \n" |
|
| 1365 | + . "function execute_pipeline_$action(&\$val){\n" |
|
| 1366 | + . $s_inc |
|
| 1367 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1368 | + . $s_call |
|
| 1369 | + . "return \$val;\n}\n"; |
|
| 1370 | + } |
|
| 1371 | + ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1372 | + clear_path_cache(); |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | |
@@ -1382,12 +1382,12 @@ discard block |
||
| 1382 | 1382 | * true si le plugin est actif, false sinon |
| 1383 | 1383 | **/ |
| 1384 | 1384 | function plugin_est_installe($plug_path) { |
| 1385 | - $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1386 | - if (!$plugin_installes) { |
|
| 1387 | - return false; |
|
| 1388 | - } |
|
| 1385 | + $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1386 | + if (!$plugin_installes) { |
|
| 1387 | + return false; |
|
| 1388 | + } |
|
| 1389 | 1389 | |
| 1390 | - return in_array($plug_path, $plugin_installes); |
|
| 1390 | + return in_array($plug_path, $plugin_installes); |
|
| 1391 | 1391 | } |
| 1392 | 1392 | |
| 1393 | 1393 | |
@@ -1400,46 +1400,46 @@ discard block |
||
| 1400 | 1400 | * @uses plugins_installer_dist() |
| 1401 | 1401 | **/ |
| 1402 | 1402 | function plugin_installes_meta() { |
| 1403 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1404 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 1405 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1406 | - } |
|
| 1407 | - |
|
| 1408 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1409 | - $meta_plug_installes = []; |
|
| 1410 | - foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1411 | - if ($plug = $resume['dir']) { |
|
| 1412 | - $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1413 | - if ($infos) { |
|
| 1414 | - if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1415 | - $meta_plug_installes[] = $plug; |
|
| 1416 | - } |
|
| 1417 | - if (is_array($infos)) { |
|
| 1418 | - [$ok, $trace] = $infos['install_test']; |
|
| 1419 | - $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1420 | - $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1421 | - if (_IS_CLI) { |
|
| 1422 | - include_spip('inc/filtres'); |
|
| 1423 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1424 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1425 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1426 | - $trace, |
|
| 1427 | - "\n"; |
|
| 1428 | - } |
|
| 1429 | - else { |
|
| 1430 | - include_spip('inc/filtres_boites'); |
|
| 1431 | - echo "<div class='install-plugins svp_retour'>" |
|
| 1432 | - . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1433 | - . $trace |
|
| 1434 | - . "<div class='result'>$result</div>" |
|
| 1435 | - . boite_fermer() |
|
| 1436 | - . '</div>'; |
|
| 1437 | - } |
|
| 1438 | - } |
|
| 1439 | - } |
|
| 1440 | - } |
|
| 1441 | - } |
|
| 1442 | - ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1403 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1404 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 1405 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1406 | + } |
|
| 1407 | + |
|
| 1408 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1409 | + $meta_plug_installes = []; |
|
| 1410 | + foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1411 | + if ($plug = $resume['dir']) { |
|
| 1412 | + $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1413 | + if ($infos) { |
|
| 1414 | + if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1415 | + $meta_plug_installes[] = $plug; |
|
| 1416 | + } |
|
| 1417 | + if (is_array($infos)) { |
|
| 1418 | + [$ok, $trace] = $infos['install_test']; |
|
| 1419 | + $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1420 | + $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1421 | + if (_IS_CLI) { |
|
| 1422 | + include_spip('inc/filtres'); |
|
| 1423 | + $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1424 | + $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1425 | + echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1426 | + $trace, |
|
| 1427 | + "\n"; |
|
| 1428 | + } |
|
| 1429 | + else { |
|
| 1430 | + include_spip('inc/filtres_boites'); |
|
| 1431 | + echo "<div class='install-plugins svp_retour'>" |
|
| 1432 | + . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1433 | + . $trace |
|
| 1434 | + . "<div class='result'>$result</div>" |
|
| 1435 | + . boite_fermer() |
|
| 1436 | + . '</div>'; |
|
| 1437 | + } |
|
| 1438 | + } |
|
| 1439 | + } |
|
| 1440 | + } |
|
| 1441 | + } |
|
| 1442 | + ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | /** |
@@ -1453,29 +1453,29 @@ discard block |
||
| 1453 | 1453 | * Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante |
| 1454 | 1454 | **/ |
| 1455 | 1455 | function ecrire_fichier_php($nom, $contenu, $comment = '') { |
| 1456 | - if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1457 | - $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1458 | - } |
|
| 1459 | - |
|
| 1460 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1461 | - // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1462 | - // si pas de modif on ne touche pas au fichier initial |
|
| 1463 | - if (file_exists($nom)) { |
|
| 1464 | - if (substr($nom, -4) == '.php') { |
|
| 1465 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1466 | - } |
|
| 1467 | - else { |
|
| 1468 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1469 | - } |
|
| 1470 | - file_put_contents($fichier_tmp, $contenu); |
|
| 1471 | - if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1472 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1473 | - @unlink($fichier_tmp); |
|
| 1474 | - return; |
|
| 1475 | - } |
|
| 1476 | - @unlink($fichier_tmp); |
|
| 1477 | - } |
|
| 1478 | - ecrire_fichier($nom, $contenu); |
|
| 1479 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1480 | - spip_clear_opcode_cache(realpath($nom)); |
|
| 1456 | + if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1457 | + $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1458 | + } |
|
| 1459 | + |
|
| 1460 | + $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1461 | + // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1462 | + // si pas de modif on ne touche pas au fichier initial |
|
| 1463 | + if (file_exists($nom)) { |
|
| 1464 | + if (substr($nom, -4) == '.php') { |
|
| 1465 | + $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1466 | + } |
|
| 1467 | + else { |
|
| 1468 | + $fichier_tmp = $nom . '.tmp'; |
|
| 1469 | + } |
|
| 1470 | + file_put_contents($fichier_tmp, $contenu); |
|
| 1471 | + if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1472 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1473 | + @unlink($fichier_tmp); |
|
| 1474 | + return; |
|
| 1475 | + } |
|
| 1476 | + @unlink($fichier_tmp); |
|
| 1477 | + } |
|
| 1478 | + ecrire_fichier($nom, $contenu); |
|
| 1479 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1480 | + spip_clear_opcode_cache(realpath($nom)); |
|
| 1481 | 1481 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | if ($dir) { |
| 374 | 374 | $dir .= '/'; |
| 375 | 375 | } |
| 376 | - $dir .= 'procure:' . $procure['nom']; |
|
| 376 | + $dir .= 'procure:'.$procure['nom']; |
|
| 377 | 377 | |
| 378 | 378 | $procure['etat'] = '?'; |
| 379 | 379 | $procure['dir_type'] = $resume['dir_type']; |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | $plug = $resume['dir']; |
| 558 | 558 | $k = $infos[$dir_type][$plug]; |
| 559 | 559 | |
| 560 | - $plug = constant($dir_type) . $plug; |
|
| 560 | + $plug = constant($dir_type).$plug; |
|
| 561 | 561 | if (!isset($msg[$p])) { |
| 562 | 562 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 563 | 563 | $msg[$p] = [$resume['erreur']]; |
@@ -600,10 +600,10 @@ discard block |
||
| 600 | 600 | $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
| 601 | 601 | } elseif (!$raw) { |
| 602 | 602 | foreach ($list as $plug => $msg) { |
| 603 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 603 | + $list[$plug] = '<li>'._T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | + . '<ul><li>'.implode('</li><li>', $msg).'</li></ul></li>'; |
|
| 605 | 605 | } |
| 606 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 606 | + $list = '<ul>'.join("\n", $list).'</ul>'; |
|
| 607 | 607 | } |
| 608 | 608 | if ($raz) { |
| 609 | 609 | effacer_meta('plugin_erreur_activation'); |
@@ -717,13 +717,13 @@ discard block |
||
| 717 | 717 | if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
| 718 | 718 | return _T("plugin_${balise}_${type}", [ |
| 719 | 719 | 'plugin' => $nom, |
| 720 | - 'version' => ' ≥ ' . $minimum |
|
| 720 | + 'version' => ' ≥ '.$minimum |
|
| 721 | 721 | ]); |
| 722 | 722 | } |
| 723 | 723 | if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
| 724 | 724 | return _T("plugin_${balise}_${type}", [ |
| 725 | 725 | 'plugin' => $nom, |
| 726 | - 'version' => ' > ' . $minimum |
|
| 726 | + 'version' => ' > '.$minimum |
|
| 727 | 727 | ]); |
| 728 | 728 | } |
| 729 | 729 | } |
@@ -732,13 +732,13 @@ discard block |
||
| 732 | 732 | if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
| 733 | 733 | return _T("plugin_${balise}_${type}", [ |
| 734 | 734 | 'plugin' => $nom, |
| 735 | - 'version' => ' ≤ ' . $maximum |
|
| 735 | + 'version' => ' ≤ '.$maximum |
|
| 736 | 736 | ]); |
| 737 | 737 | } |
| 738 | 738 | if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
| 739 | 739 | return _T("plugin_${balise}_plugin", [ |
| 740 | 740 | 'plugin' => $nom, |
| 741 | - 'version' => ' < ' . $maximum |
|
| 741 | + 'version' => ' < '.$maximum |
|
| 742 | 742 | ]); |
| 743 | 743 | } |
| 744 | 744 | } |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | include_spip('inc/charger_plugin'); |
| 758 | 758 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 759 | 759 | }*/ |
| 760 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 760 | + return _T('plugin_necessite_lib', ['lib' => $lib])." <a href='$url'>$url</a>"; |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | foreach ($plugin_valides as $p => $resume) { |
| 858 | 858 | // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
| 859 | 859 | if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
| 860 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 860 | + $header[] = $p.($resume['version'] ? '('.$resume['version'].')' : ''); |
|
| 861 | 861 | } |
| 862 | 862 | if ($resume['dir']) { |
| 863 | 863 | foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
@@ -882,11 +882,11 @@ discard block |
||
| 882 | 882 | $header = strtolower(implode(',', $header)); |
| 883 | 883 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 884 | 884 | ecrire_fichier( |
| 885 | - _DIR_VAR . 'config.txt', |
|
| 886 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 885 | + _DIR_VAR.'config.txt', |
|
| 886 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP').' '.$GLOBALS['spip_version_affichee'].' @ www.spip.net + '.$header |
|
| 887 | 887 | ); |
| 888 | 888 | } else { |
| 889 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 889 | + @unlink(_DIR_VAR.'config.txt'); |
|
| 890 | 890 | } |
| 891 | 891 | // generer charger_plugins_chemin.php |
| 892 | 892 | plugins_precompile_chemin($plugin_valides, $ordre); |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | // definir le plugin, donc le path avant l'include du fichier options |
| 941 | 941 | // permet de faire des include_spip pour attraper un inc_ du plugin |
| 942 | 942 | |
| 943 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 943 | + $dir = $dir_type.".'".$plug."/'"; |
|
| 944 | 944 | |
| 945 | 945 | $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
| 946 | 946 | if ( |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | if (!$info['chemin']) { |
| 952 | 952 | $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
| 953 | 953 | $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
| 954 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 954 | + if (is_dir(constant($dir_type).$plug.'/squelettes/')) { |
|
| 955 | 955 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 956 | 956 | } |
| 957 | 957 | } |
@@ -972,13 +972,13 @@ discard block |
||
| 972 | 972 | $dir = ''; |
| 973 | 973 | } |
| 974 | 974 | if (strlen($dir)) { |
| 975 | - $dir = rtrim($dir, '/') . '/'; |
|
| 975 | + $dir = rtrim($dir, '/').'/'; |
|
| 976 | 976 | } |
| 977 | 977 | if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
| 978 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 978 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 979 | 979 | } |
| 980 | 980 | if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
| 981 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 981 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | } |
@@ -987,11 +987,11 @@ discard block |
||
| 987 | 987 | } |
| 988 | 988 | } |
| 989 | 989 | if (count($chemins['public']) or count($chemins['prive'])) { |
| 990 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 990 | + $contenu .= 'if (_DIR_RESTREINT) _chemin(['.implode( |
|
| 991 | 991 | ',', |
| 992 | 992 | array_reverse($chemins['public']) |
| 993 | - ) . "]);\n" |
|
| 994 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 993 | + )."]);\n" |
|
| 994 | + . 'else _chemin(['.implode(',', array_reverse($chemins['prive']))."]);\n"; |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | and strpos($dir, ':') === false // exclure le cas des procure: |
| 1041 | 1041 | and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
| 1042 | 1042 | ) { |
| 1043 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1043 | + if (is_readable("$dir$plug/".($file = $info['prefix'].'_'.$charge.'.php'))) { |
|
| 1044 | 1044 | $info[$charge] = [$file]; |
| 1045 | 1045 | } |
| 1046 | 1046 | } |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | ) { |
| 1058 | 1058 | unset($info[$charge][$k]); |
| 1059 | 1059 | } else { |
| 1060 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1060 | + $_file = $root_dir_type.".'$plug/$file'"; |
|
| 1061 | 1061 | $contenu[$charge] .= "include_once_check($_file);\n"; |
| 1062 | 1062 | } |
| 1063 | 1063 | } |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | } |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1070 | + $contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options']; |
|
| 1071 | 1071 | $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
| 1072 | 1072 | . plugin_ongletbouton('onglets_plugins', $onglets); |
| 1073 | 1073 | |
@@ -1102,12 +1102,12 @@ discard block |
||
| 1102 | 1102 | define("_UPDATED_$nom", $val); |
| 1103 | 1103 | define("_UPDATED_md5_$nom", $md5); |
| 1104 | 1104 | } |
| 1105 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1105 | + $val = "unserialize('".str_replace("'", "\'", $val)."')"; |
|
| 1106 | 1106 | |
| 1107 | 1107 | return |
| 1108 | 1108 | "if (!function_exists('$nom')) {\n" |
| 1109 | 1109 | . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
| 1110 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1110 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n" |
|
| 1111 | 1111 | . "}\n"; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | if (@is_readable(_CACHE_PLUGINS_OPT)) { |
| 1131 | 1131 | include_once(_CACHE_PLUGINS_OPT); |
| 1132 | 1132 | } else { |
| 1133 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1133 | + spip_log('pipelines desactives: impossible de produire '._CACHE_PLUGINS_OPT); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | 1136 | |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | $dir_type = $plugin_valides[$p]['dir_type']; |
| 1168 | 1168 | $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
| 1169 | 1169 | $plug = $plugin_valides[$p]['dir']; |
| 1170 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1170 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'].'_'); |
|
| 1171 | 1171 | if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
| 1172 | 1172 | foreach ($info['pipeline'] as $pipe) { |
| 1173 | 1173 | $nom = $pipe['nom']; |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | } |
| 1202 | 1202 | if (isset($pipe['inclure'])) { |
| 1203 | 1203 | $GLOBALS['spip_matrice']["$prefix$action"] = |
| 1204 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1204 | + "$root_dir_type:$plug/".$pipe['inclure']; |
|
| 1205 | 1205 | } |
| 1206 | 1206 | } |
| 1207 | 1207 | } |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | $prepend_code['taches_generales_cron'] = ''; |
| 1212 | 1212 | } |
| 1213 | 1213 | foreach ($info['genie'] as $genie) { |
| 1214 | - $nom = $prefix . $genie['nom']; |
|
| 1214 | + $nom = $prefix.$genie['nom']; |
|
| 1215 | 1215 | $periode = max(60, intval($genie['periode'])); |
| 1216 | 1216 | if (charger_fonction($nom, 'genie', true)) { |
| 1217 | 1217 | $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
@@ -1229,13 +1229,13 @@ discard block |
||
| 1229 | 1229 | } |
| 1230 | 1230 | foreach ($info['style'] as $style) { |
| 1231 | 1231 | if (isset($style['path']) and $style['path']) { |
| 1232 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1232 | + $code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) "; |
|
| 1233 | 1233 | } else { |
| 1234 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1234 | + $code = "if (\$f='".addslashes($style['url'])."') "; |
|
| 1235 | 1235 | } |
| 1236 | 1236 | $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
| 1237 | 1237 | if (isset($style['media']) and strlen($style['media'])) { |
| 1238 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1238 | + $code .= ' media="'.addslashes($style['media']).'"'; |
|
| 1239 | 1239 | } |
| 1240 | 1240 | $code .= "/>';\n"; |
| 1241 | 1241 | if ($style['type'] != 'prive') { |
@@ -1255,9 +1255,9 @@ discard block |
||
| 1255 | 1255 | if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
| 1256 | 1256 | foreach ($info['script'] as $script) { |
| 1257 | 1257 | if (isset($script['path']) and $script['path']) { |
| 1258 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1258 | + $code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) "; |
|
| 1259 | 1259 | } else { |
| 1260 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1260 | + $code = "if (\$f='".addslashes($script['url'])."') "; |
|
| 1261 | 1261 | } |
| 1262 | 1262 | $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
| 1263 | 1263 | if ($script['type'] != 'prive') { |
@@ -1320,10 +1320,10 @@ discard block |
||
| 1320 | 1320 | unset($GLOBALS['spip_pipeline']['all']); |
| 1321 | 1321 | $all_pipes = trim(array_shift($a)); |
| 1322 | 1322 | if ($all_pipes) { |
| 1323 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1323 | + $all_pipes = '|'.ltrim($all_pipes, '|'); |
|
| 1324 | 1324 | } |
| 1325 | 1325 | if (count($a)) { |
| 1326 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1326 | + $all_pipes_end = '||'.array_shift($a); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | } |
| 1329 | 1329 | $content = ''; |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | // Eclater le pipeline en filtres et appliquer chaque filtre |
| 1341 | 1341 | foreach ($pipe as $fonc) { |
| 1342 | 1342 | $fonc = trim($fonc); |
| 1343 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1343 | + $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; |
|
| 1344 | 1344 | if (isset($GLOBALS['spip_matrice'][$fonc])) { |
| 1345 | 1345 | $file = $GLOBALS['spip_matrice'][$fonc]; |
| 1346 | 1346 | $file = "'$file'"; |
@@ -1351,7 +1351,7 @@ discard block |
||
| 1351 | 1351 | if (defined($root_dir)) { |
| 1352 | 1352 | $dir = $root_dir; |
| 1353 | 1353 | } |
| 1354 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1354 | + $file = str_replace($regs[0], "'.".$dir.".'", $file); |
|
| 1355 | 1355 | $file = str_replace("''.", '', $file); |
| 1356 | 1356 | $file = str_replace(constant($dir), '', $file); |
| 1357 | 1357 | } |
@@ -1364,7 +1364,7 @@ discard block |
||
| 1364 | 1364 | $content .= "// Pipeline $action \n" |
| 1365 | 1365 | . "function execute_pipeline_$action(&\$val){\n" |
| 1366 | 1366 | . $s_inc |
| 1367 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1367 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '') |
|
| 1368 | 1368 | . $s_call |
| 1369 | 1369 | . "return \$val;\n}\n"; |
| 1370 | 1370 | } |
@@ -1420,9 +1420,9 @@ discard block |
||
| 1420 | 1420 | $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
| 1421 | 1421 | if (_IS_CLI) { |
| 1422 | 1422 | include_spip('inc/filtres'); |
| 1423 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1424 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1425 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1423 | + $trace = ltrim(textebrut($trace)."\n".$result); |
|
| 1424 | + $trace = ' '.str_replace("\n", "\n ", $trace); |
|
| 1425 | + echo "\n".($ok ? 'OK ' : '/!\ ').textebrut($titre)."\n", |
|
| 1426 | 1426 | $trace, |
| 1427 | 1427 | "\n"; |
| 1428 | 1428 | } |
@@ -1457,15 +1457,15 @@ discard block |
||
| 1457 | 1457 | $GLOBALS['fichier_php_compile_recent'] = 0; |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1460 | + $contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>'; |
|
| 1461 | 1461 | // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
| 1462 | 1462 | // si pas de modif on ne touche pas au fichier initial |
| 1463 | 1463 | if (file_exists($nom)) { |
| 1464 | 1464 | if (substr($nom, -4) == '.php') { |
| 1465 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1465 | + $fichier_tmp = substr($nom, 0, -4).'.tmp.php'; |
|
| 1466 | 1466 | } |
| 1467 | 1467 | else { |
| 1468 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1468 | + $fichier_tmp = $nom.'.tmp'; |
|
| 1469 | 1469 | } |
| 1470 | 1470 | file_put_contents($fichier_tmp, $contenu); |
| 1471 | 1471 | if (md5_file($nom) == md5_file($fichier_tmp)) { |