@@ -11,76 +11,76 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function install_etape_ldap3_dist() { |
| 18 | - $info = []; |
|
| 19 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 20 | - $login_ldap = _request('login_ldap'); |
|
| 21 | - $pass_ldap = _request('pass_ldap'); |
|
| 22 | - $port_ldap = _request('port_ldap'); |
|
| 18 | + $info = []; |
|
| 19 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 20 | + $login_ldap = _request('login_ldap'); |
|
| 21 | + $pass_ldap = _request('pass_ldap'); |
|
| 22 | + $port_ldap = _request('port_ldap'); |
|
| 23 | 23 | |
| 24 | - $base_ldap_text = defined('_INSTALL_BASE_LDAP') |
|
| 25 | - ? _INSTALL_BASE_LDAP |
|
| 26 | - : 'ou=users, dc=mon-domaine, dc=com'; |
|
| 24 | + $base_ldap_text = defined('_INSTALL_BASE_LDAP') |
|
| 25 | + ? _INSTALL_BASE_LDAP |
|
| 26 | + : 'ou=users, dc=mon-domaine, dc=com'; |
|
| 27 | 27 | |
| 28 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 28 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 29 | 29 | |
| 30 | - echo info_etape( |
|
| 31 | - _T('info_chemin_acces_1'), |
|
| 32 | - info_progression_etape(3, 'etape_ldap', 'install/') |
|
| 33 | - ), |
|
| 34 | - _T('info_chemin_acces_2'); |
|
| 30 | + echo info_etape( |
|
| 31 | + _T('info_chemin_acces_1'), |
|
| 32 | + info_progression_etape(3, 'etape_ldap', 'install/') |
|
| 33 | + ), |
|
| 34 | + _T('info_chemin_acces_2'); |
|
| 35 | 35 | |
| 36 | - $ldap_link = @ldap_connect("$adresse_ldap", "$port_ldap"); |
|
| 37 | - if ($ldap_link) { |
|
| 38 | - @ldap_bind($ldap_link, "$login_ldap", "$pass_ldap"); |
|
| 39 | - $result = @ldap_read($ldap_link, '', 'objectclass=*', ['namingContexts']); |
|
| 40 | - $info = @ldap_get_entries($ldap_link, $result); |
|
| 41 | - @ldap_close($ldap_link); |
|
| 42 | - } |
|
| 36 | + $ldap_link = @ldap_connect("$adresse_ldap", "$port_ldap"); |
|
| 37 | + if ($ldap_link) { |
|
| 38 | + @ldap_bind($ldap_link, "$login_ldap", "$pass_ldap"); |
|
| 39 | + $result = @ldap_read($ldap_link, '', 'objectclass=*', ['namingContexts']); |
|
| 40 | + $info = @ldap_get_entries($ldap_link, $result); |
|
| 41 | + @ldap_close($ldap_link); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - $checked = false; |
|
| 45 | - $res = ''; |
|
| 46 | - if (is_array($info) and $info['count'] > 0) { |
|
| 47 | - $res .= '<p>' . _T('info_selection_chemin_acces') . '</p>'; |
|
| 48 | - $res .= '<ul>'; |
|
| 49 | - $n = 0; |
|
| 50 | - for ($i = 0; $i < $info['count']; $i++) { |
|
| 51 | - $names = $info[$i]['namingcontexts']; |
|
| 52 | - if (is_array($names)) { |
|
| 53 | - for ($j = 0; $j < $names['count']; $j++) { |
|
| 54 | - $n++; |
|
| 55 | - $res .= '<li><input name="base_ldap" value="' . spip_htmlspecialchars($names[$j]) . "\" type='radio' id='tab$n'"; |
|
| 56 | - if (!$checked) { |
|
| 57 | - $res .= ' checked="checked"'; |
|
| 58 | - $checked = true; |
|
| 59 | - } |
|
| 60 | - $res .= ' />'; |
|
| 61 | - $res .= "<label for='tab$n'>" . spip_htmlspecialchars($names[$j]) . "</label></li>\n"; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - $res .= '</ul>'; |
|
| 66 | - $res .= _T('info_ou') . ' '; |
|
| 67 | - } |
|
| 68 | - $res .= "<br />\n<input name=\"base_ldap\" value=\"\" type='radio' id='manuel'"; |
|
| 69 | - if (!$checked) { |
|
| 70 | - $res .= ' checked="checked"'; |
|
| 71 | - $checked = true; |
|
| 72 | - } |
|
| 44 | + $checked = false; |
|
| 45 | + $res = ''; |
|
| 46 | + if (is_array($info) and $info['count'] > 0) { |
|
| 47 | + $res .= '<p>' . _T('info_selection_chemin_acces') . '</p>'; |
|
| 48 | + $res .= '<ul>'; |
|
| 49 | + $n = 0; |
|
| 50 | + for ($i = 0; $i < $info['count']; $i++) { |
|
| 51 | + $names = $info[$i]['namingcontexts']; |
|
| 52 | + if (is_array($names)) { |
|
| 53 | + for ($j = 0; $j < $names['count']; $j++) { |
|
| 54 | + $n++; |
|
| 55 | + $res .= '<li><input name="base_ldap" value="' . spip_htmlspecialchars($names[$j]) . "\" type='radio' id='tab$n'"; |
|
| 56 | + if (!$checked) { |
|
| 57 | + $res .= ' checked="checked"'; |
|
| 58 | + $checked = true; |
|
| 59 | + } |
|
| 60 | + $res .= ' />'; |
|
| 61 | + $res .= "<label for='tab$n'>" . spip_htmlspecialchars($names[$j]) . "</label></li>\n"; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + $res .= '</ul>'; |
|
| 66 | + $res .= _T('info_ou') . ' '; |
|
| 67 | + } |
|
| 68 | + $res .= "<br />\n<input name=\"base_ldap\" value=\"\" type='radio' id='manuel'"; |
|
| 69 | + if (!$checked) { |
|
| 70 | + $res .= ' checked="checked"'; |
|
| 71 | + $checked = true; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $res .= ' />' |
|
| 75 | - . "\n<label for='manuel'>" . _T('entree_chemin_acces') . '</label> ' |
|
| 76 | - . "\n<fieldset>" |
|
| 77 | - . "<input type='text' name='base_ldap_text' class='text' value=\"$base_ldap_text\" size='40' />" |
|
| 78 | - . "\n</fieldset>" |
|
| 79 | - . "\n<input type='hidden' name='etape' value='ldap4' />" |
|
| 80 | - . install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
|
| 81 | - . bouton_suivant(); |
|
| 74 | + $res .= ' />' |
|
| 75 | + . "\n<label for='manuel'>" . _T('entree_chemin_acces') . '</label> ' |
|
| 76 | + . "\n<fieldset>" |
|
| 77 | + . "<input type='text' name='base_ldap_text' class='text' value=\"$base_ldap_text\" size='40' />" |
|
| 78 | + . "\n</fieldset>" |
|
| 79 | + . "\n<input type='hidden' name='etape' value='ldap4' />" |
|
| 80 | + . install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
|
| 81 | + . bouton_suivant(); |
|
| 82 | 82 | |
| 83 | - echo generer_form_ecrire('install', $res); |
|
| 83 | + echo generer_form_ecrire('install', $res); |
|
| 84 | 84 | |
| 85 | - echo install_fin_html(); |
|
| 85 | + echo install_fin_html(); |
|
| 86 | 86 | } |
@@ -11,88 +11,88 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function install_etape_ldap1_dist() { |
| 18 | - $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 19 | - ? _INSTALL_HOST_LDAP |
|
| 20 | - : 'localhost'; |
|
| 18 | + $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 19 | + ? _INSTALL_HOST_LDAP |
|
| 20 | + : 'localhost'; |
|
| 21 | 21 | |
| 22 | - $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 23 | - ? _INSTALL_PORT_LDAP |
|
| 24 | - : 389; |
|
| 22 | + $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 23 | + ? _INSTALL_PORT_LDAP |
|
| 24 | + : 389; |
|
| 25 | 25 | |
| 26 | - $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 27 | - ? _INSTALL_TLS_LDAP |
|
| 28 | - : 'non'; |
|
| 26 | + $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 27 | + ? _INSTALL_TLS_LDAP |
|
| 28 | + : 'non'; |
|
| 29 | 29 | |
| 30 | - $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 31 | - ? _INSTALL_PROTOCOLE_LDAP |
|
| 32 | - : 3; // on essaie 2 en cas d'echec |
|
| 30 | + $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 31 | + ? _INSTALL_PROTOCOLE_LDAP |
|
| 32 | + : 3; // on essaie 2 en cas d'echec |
|
| 33 | 33 | |
| 34 | - $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 35 | - ? _INSTALL_USER_LDAP |
|
| 36 | - : ''; |
|
| 34 | + $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 35 | + ? _INSTALL_USER_LDAP |
|
| 36 | + : ''; |
|
| 37 | 37 | |
| 38 | - $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 39 | - ? _INSTALL_PASS_LDAP |
|
| 40 | - : ''; |
|
| 38 | + $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 39 | + ? _INSTALL_PASS_LDAP |
|
| 40 | + : ''; |
|
| 41 | 41 | |
| 42 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 42 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 43 | 43 | |
| 44 | - echo info_etape( |
|
| 45 | - _T('titre_connexion_ldap'), |
|
| 46 | - info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 47 | - ); |
|
| 44 | + echo info_etape( |
|
| 45 | + _T('titre_connexion_ldap'), |
|
| 46 | + info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 47 | + ); |
|
| 48 | 48 | |
| 49 | - echo generer_form_ecrire('install', ( |
|
| 50 | - "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 51 | - . fieldset( |
|
| 52 | - _T('entree_adresse_annuaire'), |
|
| 53 | - [ |
|
| 54 | - 'adresse_ldap' => [ |
|
| 55 | - 'label' => _T('texte_adresse_annuaire_1'), |
|
| 56 | - 'valeur' => $adresse_ldap |
|
| 57 | - ], |
|
| 58 | - 'port_ldap' => [ |
|
| 59 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 60 | - 'valeur' => $port_ldap |
|
| 61 | - ], |
|
| 62 | - 'tls_ldap' => [ |
|
| 63 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 64 | - 'valeur' => $tls_ldap, |
|
| 65 | - 'alternatives' => [ |
|
| 66 | - 'non' => _T('item_non'), |
|
| 67 | - 'oui' => _T('item_oui') |
|
| 68 | - ] |
|
| 69 | - ], |
|
| 70 | - 'protocole_ldap' => [ |
|
| 71 | - 'label' => _T('protocole_ldap'), |
|
| 72 | - 'valeur' => $protocole_ldap, |
|
| 73 | - 'alternatives' => [ |
|
| 74 | - '3' => '3', |
|
| 75 | - '2' => '2' |
|
| 76 | - ] |
|
| 77 | - ] |
|
| 78 | - ] |
|
| 79 | - ) |
|
| 49 | + echo generer_form_ecrire('install', ( |
|
| 50 | + "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 51 | + . fieldset( |
|
| 52 | + _T('entree_adresse_annuaire'), |
|
| 53 | + [ |
|
| 54 | + 'adresse_ldap' => [ |
|
| 55 | + 'label' => _T('texte_adresse_annuaire_1'), |
|
| 56 | + 'valeur' => $adresse_ldap |
|
| 57 | + ], |
|
| 58 | + 'port_ldap' => [ |
|
| 59 | + 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 60 | + 'valeur' => $port_ldap |
|
| 61 | + ], |
|
| 62 | + 'tls_ldap' => [ |
|
| 63 | + 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 64 | + 'valeur' => $tls_ldap, |
|
| 65 | + 'alternatives' => [ |
|
| 66 | + 'non' => _T('item_non'), |
|
| 67 | + 'oui' => _T('item_oui') |
|
| 68 | + ] |
|
| 69 | + ], |
|
| 70 | + 'protocole_ldap' => [ |
|
| 71 | + 'label' => _T('protocole_ldap'), |
|
| 72 | + 'valeur' => $protocole_ldap, |
|
| 73 | + 'alternatives' => [ |
|
| 74 | + '3' => '3', |
|
| 75 | + '2' => '2' |
|
| 76 | + ] |
|
| 77 | + ] |
|
| 78 | + ] |
|
| 79 | + ) |
|
| 80 | 80 | |
| 81 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 82 | - . fieldset( |
|
| 83 | - _T('connexion_ldap'), |
|
| 84 | - [ |
|
| 85 | - 'login_ldap' => [ |
|
| 86 | - 'label' => _T('texte_login_ldap_1'), |
|
| 87 | - 'valeur' => $login_ldap |
|
| 88 | - ], |
|
| 89 | - 'pass_ldap' => [ |
|
| 90 | - 'label' => _T('entree_passe_ldap'), |
|
| 91 | - 'valeur' => $pass_ldap |
|
| 92 | - ] |
|
| 93 | - ] |
|
| 94 | - ) |
|
| 95 | - . bouton_suivant())); |
|
| 81 | + . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 82 | + . fieldset( |
|
| 83 | + _T('connexion_ldap'), |
|
| 84 | + [ |
|
| 85 | + 'login_ldap' => [ |
|
| 86 | + 'label' => _T('texte_login_ldap_1'), |
|
| 87 | + 'valeur' => $login_ldap |
|
| 88 | + ], |
|
| 89 | + 'pass_ldap' => [ |
|
| 90 | + 'label' => _T('entree_passe_ldap'), |
|
| 91 | + 'valeur' => $pass_ldap |
|
| 92 | + ] |
|
| 93 | + ] |
|
| 94 | + ) |
|
| 95 | + . bouton_suivant())); |
|
| 96 | 96 | |
| 97 | - echo install_fin_html(); |
|
| 97 | + echo install_fin_html(); |
|
| 98 | 98 | } |
@@ -11,166 +11,166 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('base/abstract_sql'); |
| 18 | 18 | |
| 19 | 19 | function install_etape_2_dist() { |
| 20 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 21 | - ? _INSTALL_HOST_DB |
|
| 22 | - : _request('adresse_db'); |
|
| 20 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 21 | + ? _INSTALL_HOST_DB |
|
| 22 | + : _request('adresse_db'); |
|
| 23 | 23 | |
| 24 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 25 | - [, $adresse_db, $port] = $r; |
|
| 26 | - } else { |
|
| 27 | - $port = ''; |
|
| 28 | - } |
|
| 24 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 25 | + [, $adresse_db, $port] = $r; |
|
| 26 | + } else { |
|
| 27 | + $port = ''; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 31 | - ? _INSTALL_USER_DB |
|
| 32 | - : _request('login_db'); |
|
| 30 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 31 | + ? _INSTALL_USER_DB |
|
| 32 | + : _request('login_db'); |
|
| 33 | 33 | |
| 34 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 35 | - ? _INSTALL_PASS_DB |
|
| 36 | - : _request('pass_db'); |
|
| 34 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 35 | + ? _INSTALL_PASS_DB |
|
| 36 | + : _request('pass_db'); |
|
| 37 | 37 | |
| 38 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 39 | - ? _INSTALL_SERVER_DB |
|
| 40 | - : _request('server_db'); |
|
| 38 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 39 | + ? _INSTALL_SERVER_DB |
|
| 40 | + : _request('server_db'); |
|
| 41 | 41 | |
| 42 | - $name_db = defined('_INSTALL_NAME_DB') |
|
| 43 | - ? _INSTALL_NAME_DB |
|
| 44 | - : ''; |
|
| 42 | + $name_db = defined('_INSTALL_NAME_DB') |
|
| 43 | + ? _INSTALL_NAME_DB |
|
| 44 | + : ''; |
|
| 45 | 45 | |
| 46 | - $chmod = _request('chmod'); |
|
| 46 | + $chmod = _request('chmod'); |
|
| 47 | 47 | |
| 48 | - $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 49 | - $GLOBALS['connexions'][$server_db] = $link; |
|
| 48 | + $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 49 | + $GLOBALS['connexions'][$server_db] = $link; |
|
| 50 | 50 | |
| 51 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 52 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 51 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 52 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 53 | 53 | |
| 54 | - echo install_debut_html(); |
|
| 54 | + echo install_debut_html(); |
|
| 55 | 55 | |
| 56 | 56 | // prenons toutes les dispositions possibles pour que rien ne s'affiche ! |
| 57 | 57 | |
| 58 | - /* |
|
| 58 | + /* |
|
| 59 | 59 | * /!\ sqlite3/PDO : erreur sur join(', ', $link) |
| 60 | 60 | * L'objet PDO ne peut pas etre transformee en chaine |
| 61 | 61 | * Un echo $link ne fonctionne pas non plus |
| 62 | 62 | * Il faut utiliser par exemple print_r($link) |
| 63 | 63 | */ |
| 64 | - //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 65 | - $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 66 | - //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 67 | - //echo "\n-->\n"; |
|
| 64 | + //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 65 | + $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 66 | + //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 67 | + //echo "\n-->\n"; |
|
| 68 | 68 | |
| 69 | - if (($db_connect == '0') && $link) { |
|
| 70 | - echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 71 | - echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 69 | + if (($db_connect == '0') && $link) { |
|
| 70 | + echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 71 | + echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 72 | 72 | |
| 73 | - echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 73 | + echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 74 | 74 | |
| 75 | - echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 76 | - [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 75 | + echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 76 | + [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 77 | 77 | |
| 78 | - $hidden = (defined('_SPIP_CHMOD') |
|
| 79 | - ? '' |
|
| 80 | - : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 81 | - . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 78 | + $hidden = (defined('_SPIP_CHMOD') |
|
| 79 | + ? '' |
|
| 80 | + : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 81 | + . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 82 | 82 | |
| 83 | - echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 84 | - } else { |
|
| 85 | - echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 83 | + echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 84 | + } else { |
|
| 85 | + echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 86 | 86 | |
| 87 | - echo "<div class='error'>"; |
|
| 88 | - echo info_etape(_T('info_connexion_base')); |
|
| 89 | - echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 90 | - echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 87 | + echo "<div class='error'>"; |
|
| 88 | + echo info_etape(_T('info_connexion_base')); |
|
| 89 | + echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 90 | + echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 91 | 91 | |
| 92 | - echo "<p style='font-size: small;'>", |
|
| 93 | - _T('avis_connexion_echec_3'), |
|
| 94 | - '</p></div>'; |
|
| 95 | - } |
|
| 92 | + echo "<p style='font-size: small;'>", |
|
| 93 | + _T('avis_connexion_echec_3'), |
|
| 94 | + '</p></div>'; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - echo install_fin_html(); |
|
| 97 | + echo install_fin_html(); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Liste les bases accessibles, |
| 101 | 101 | // avec une heuristique pour preselectionner la plus probable |
| 102 | 102 | |
| 103 | 103 | function install_etape_2_bases($login_db, $server_db) { |
| 104 | - $res = install_etape_liste_bases($server_db, $login_db); |
|
| 105 | - if ($res) { |
|
| 106 | - [$checked, $bases] = $res; |
|
| 107 | - |
|
| 108 | - return [ |
|
| 109 | - $checked, |
|
| 110 | - "<label for='choix_db'><b>" |
|
| 111 | - . _T('texte_choix_base_2') |
|
| 112 | - . '</b><br />' |
|
| 113 | - . _T('texte_choix_base_3') |
|
| 114 | - . '</label>' |
|
| 115 | - . "<ul>\n<li>" |
|
| 116 | - . join("</li>\n<li>", $bases) |
|
| 117 | - . "</li>\n</ul><p>" |
|
| 118 | - . _T('info_ou') |
|
| 119 | - . ' ' |
|
| 120 | - ]; |
|
| 121 | - } |
|
| 122 | - $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 104 | + $res = install_etape_liste_bases($server_db, $login_db); |
|
| 105 | + if ($res) { |
|
| 106 | + [$checked, $bases] = $res; |
|
| 107 | + |
|
| 108 | + return [ |
|
| 109 | + $checked, |
|
| 110 | + "<label for='choix_db'><b>" |
|
| 111 | + . _T('texte_choix_base_2') |
|
| 112 | + . '</b><br />' |
|
| 113 | + . _T('texte_choix_base_3') |
|
| 114 | + . '</label>' |
|
| 115 | + . "<ul>\n<li>" |
|
| 116 | + . join("</li>\n<li>", $bases) |
|
| 117 | + . "</li>\n</ul><p>" |
|
| 118 | + . _T('info_ou') |
|
| 119 | + . ' ' |
|
| 120 | + ]; |
|
| 121 | + } |
|
| 122 | + $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 123 | 123 | ' . _T('avis_lecture_noms_bases_2') . '<p>'; |
| 124 | 124 | |
| 125 | - $checked = false; |
|
| 126 | - if ($login_db) { |
|
| 127 | - // Si un login comporte un point, le nom de la base est plus |
|
| 128 | - // probablement le login sans le point -- testons pour savoir |
|
| 129 | - $test_base = $login_db; |
|
| 130 | - $ok = sql_selectdb($test_base, $server_db); |
|
| 131 | - $test_base2 = str_replace('.', '_', $test_base); |
|
| 132 | - if (sql_selectdb($test_base2, $server_db)) { |
|
| 133 | - $test_base = $test_base2; |
|
| 134 | - $ok = true; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - if ($ok) { |
|
| 138 | - $res .= _T('avis_lecture_noms_bases_3') |
|
| 139 | - . '<ul>' |
|
| 140 | - . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 141 | - . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 142 | - . '</ul>' |
|
| 143 | - . '<p>' . _T('info_ou') . ' '; |
|
| 144 | - $checked = true; |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return [$checked, $res]; |
|
| 125 | + $checked = false; |
|
| 126 | + if ($login_db) { |
|
| 127 | + // Si un login comporte un point, le nom de la base est plus |
|
| 128 | + // probablement le login sans le point -- testons pour savoir |
|
| 129 | + $test_base = $login_db; |
|
| 130 | + $ok = sql_selectdb($test_base, $server_db); |
|
| 131 | + $test_base2 = str_replace('.', '_', $test_base); |
|
| 132 | + if (sql_selectdb($test_base2, $server_db)) { |
|
| 133 | + $test_base = $test_base2; |
|
| 134 | + $ok = true; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + if ($ok) { |
|
| 138 | + $res .= _T('avis_lecture_noms_bases_3') |
|
| 139 | + . '<ul>' |
|
| 140 | + . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 141 | + . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 142 | + . '</ul>' |
|
| 143 | + . '<p>' . _T('info_ou') . ' '; |
|
| 144 | + $checked = true; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return [$checked, $res]; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | function install_etape_2_form($hidden, $checked, $res, $etape) { |
| 152 | - return generer_form_ecrire('install', ( |
|
| 153 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 154 | - . $hidden |
|
| 155 | - . (defined('_INSTALL_NAME_DB') |
|
| 156 | - ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 157 | - : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 158 | - . $res |
|
| 159 | - . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 160 | - . ($checked ? '' : " checked='checked'") |
|
| 161 | - . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 162 | - . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 163 | - ) |
|
| 164 | - |
|
| 165 | - . ((defined('_INSTALL_TABLE_PREFIX') |
|
| 166 | - or $GLOBALS['table_prefix'] != 'spip') |
|
| 167 | - ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 168 | - : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 169 | - . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 170 | - . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 171 | - . 'spip' # valeur par defaut |
|
| 172 | - . "' size='20' /></p></fieldset>" |
|
| 173 | - ) |
|
| 174 | - |
|
| 175 | - . bouton_suivant())); |
|
| 152 | + return generer_form_ecrire('install', ( |
|
| 153 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 154 | + . $hidden |
|
| 155 | + . (defined('_INSTALL_NAME_DB') |
|
| 156 | + ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 157 | + : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 158 | + . $res |
|
| 159 | + . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 160 | + . ($checked ? '' : " checked='checked'") |
|
| 161 | + . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 162 | + . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 163 | + ) |
|
| 164 | + |
|
| 165 | + . ((defined('_INSTALL_TABLE_PREFIX') |
|
| 166 | + or $GLOBALS['table_prefix'] != 'spip') |
|
| 167 | + ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 168 | + : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 169 | + . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 170 | + . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 171 | + . 'spip' # valeur par defaut |
|
| 172 | + . "' size='20' /></p></fieldset>" |
|
| 173 | + ) |
|
| 174 | + |
|
| 175 | + . bouton_suivant())); |
|
| 176 | 176 | } |
@@ -11,69 +11,69 @@ |
||
| 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'); |
| 18 | 18 | |
| 19 | 19 | function install_etape_4_dist() { |
| 20 | 20 | |
| 21 | - // creer le repertoire cache, qui sert partout ! |
|
| 22 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 23 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 24 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 25 | - } |
|
| 21 | + // creer le repertoire cache, qui sert partout ! |
|
| 22 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 23 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 24 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 29 | - echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 28 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 29 | + echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 30 | 30 | |
| 31 | - echo "<div class='success'><b>" |
|
| 32 | - . _T('info_derniere_etape') |
|
| 33 | - . '</b><p>' |
|
| 34 | - . _T('info_utilisation_spip') |
|
| 35 | - . '</p></div>'; |
|
| 31 | + echo "<div class='success'><b>" |
|
| 32 | + . _T('info_derniere_etape') |
|
| 33 | + . '</b><p>' |
|
| 34 | + . _T('info_utilisation_spip') |
|
| 35 | + . '</p></div>'; |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - echo '<p>' |
|
| 39 | - . _T( |
|
| 40 | - 'plugin_info_plugins_dist_1', |
|
| 41 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 42 | - ) |
|
| 43 | - . '</p>'; |
|
| 38 | + echo '<p>' |
|
| 39 | + . _T( |
|
| 40 | + 'plugin_info_plugins_dist_1', |
|
| 41 | + ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 42 | + ) |
|
| 43 | + . '</p>'; |
|
| 44 | 44 | |
| 45 | - // installer les extensions |
|
| 46 | - include_spip('inc/plugin'); |
|
| 47 | - $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 48 | - echo $afficher( |
|
| 49 | - self(), |
|
| 50 | - liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 51 | - [], |
|
| 52 | - [], |
|
| 53 | - _DIR_PLUGINS_DIST, |
|
| 54 | - 'afficher_nom_plugin' |
|
| 55 | - ); |
|
| 45 | + // installer les extensions |
|
| 46 | + include_spip('inc/plugin'); |
|
| 47 | + $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 48 | + echo $afficher( |
|
| 49 | + self(), |
|
| 50 | + liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 51 | + [], |
|
| 52 | + [], |
|
| 53 | + _DIR_PLUGINS_DIST, |
|
| 54 | + 'afficher_nom_plugin' |
|
| 55 | + ); |
|
| 56 | 56 | |
| 57 | - // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 58 | - // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 59 | - // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 60 | - // et procede alors a l'installation |
|
| 61 | - if ( |
|
| 62 | - !isset($GLOBALS['meta']['version_installee']) |
|
| 63 | - or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 64 | - ) { |
|
| 65 | - plugin_installes_meta(); |
|
| 66 | - } |
|
| 57 | + // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 58 | + // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 59 | + // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 60 | + // et procede alors a l'installation |
|
| 61 | + if ( |
|
| 62 | + !isset($GLOBALS['meta']['version_installee']) |
|
| 63 | + or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 64 | + ) { |
|
| 65 | + plugin_installes_meta(); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - // mettre a jour si necessaire l'adresse du site |
|
| 69 | - // securite si on arrive plus a se loger |
|
| 70 | - include_spip('inc/config'); |
|
| 71 | - appliquer_adresse_site(''); |
|
| 68 | + // mettre a jour si necessaire l'adresse du site |
|
| 69 | + // securite si on arrive plus a se loger |
|
| 70 | + include_spip('inc/config'); |
|
| 71 | + appliquer_adresse_site(''); |
|
| 72 | 72 | |
| 73 | - // aller a la derniere etape qui clos l'install et redirige |
|
| 74 | - $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 75 | - . bouton_suivant(_T('login_espace_prive')); |
|
| 73 | + // aller a la derniere etape qui clos l'install et redirige |
|
| 74 | + $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 75 | + . bouton_suivant(_T('login_espace_prive')); |
|
| 76 | 76 | |
| 77 | - echo generer_form_ecrire('install', $suite); |
|
| 78 | - echo install_fin_html(); |
|
| 77 | + echo generer_form_ecrire('install', $suite); |
|
| 78 | + echo install_fin_html(); |
|
| 79 | 79 | } |
@@ -11,84 +11,84 @@ |
||
| 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 | function install_etape_ldap5_dist() { |
| 20 | - etape_ldap5_save(); |
|
| 21 | - etape_ldap5_suite(); |
|
| 20 | + etape_ldap5_save(); |
|
| 21 | + etape_ldap5_suite(); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | function etape_ldap5_save() { |
| 25 | - $conn = null; |
|
| 26 | - if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 27 | - redirige_url_ecrire('install'); |
|
| 28 | - } |
|
| 25 | + $conn = null; |
|
| 26 | + if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 27 | + redirige_url_ecrire('install'); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - ecrire_meta('ldap_statut_import', _request('statut_ldap')); |
|
| 30 | + ecrire_meta('ldap_statut_import', _request('statut_ldap')); |
|
| 31 | 31 | |
| 32 | - lire_fichier(_FILE_CONNECT_TMP, $conn); |
|
| 32 | + lire_fichier(_FILE_CONNECT_TMP, $conn); |
|
| 33 | 33 | |
| 34 | - if ($p = strpos($conn, "'');")) { |
|
| 35 | - ecrire_fichier( |
|
| 36 | - _FILE_CONNECT_TMP, |
|
| 37 | - substr($conn, 0, $p + 1) |
|
| 38 | - . _FILE_LDAP |
|
| 39 | - . substr($conn, $p + 1) |
|
| 40 | - ); |
|
| 41 | - } |
|
| 34 | + if ($p = strpos($conn, "'');")) { |
|
| 35 | + ecrire_fichier( |
|
| 36 | + _FILE_CONNECT_TMP, |
|
| 37 | + substr($conn, 0, $p + 1) |
|
| 38 | + . _FILE_LDAP |
|
| 39 | + . substr($conn, $p + 1) |
|
| 40 | + ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $adresse_ldap = addcslashes(_request('adresse_ldap'), "'\\"); |
|
| 44 | - $login_ldap = addcslashes(_request('login_ldap'), "'\\"); |
|
| 45 | - $pass_ldap = addcslashes(_request('pass_ldap'), "'\\"); |
|
| 46 | - $port_ldap = addcslashes(_request('port_ldap'), "'\\"); |
|
| 47 | - $tls_ldap = addcslashes(_request('tls_ldap'), "'\\"); |
|
| 48 | - $protocole_ldap = addcslashes(_request('protocole_ldap'), "'\\"); |
|
| 49 | - $base_ldap = addcslashes(_request('base_ldap'), "'\\"); |
|
| 50 | - $base_ldap_text = addcslashes(_request('base_ldap_text'), "'\\"); |
|
| 43 | + $adresse_ldap = addcslashes(_request('adresse_ldap'), "'\\"); |
|
| 44 | + $login_ldap = addcslashes(_request('login_ldap'), "'\\"); |
|
| 45 | + $pass_ldap = addcslashes(_request('pass_ldap'), "'\\"); |
|
| 46 | + $port_ldap = addcslashes(_request('port_ldap'), "'\\"); |
|
| 47 | + $tls_ldap = addcslashes(_request('tls_ldap'), "'\\"); |
|
| 48 | + $protocole_ldap = addcslashes(_request('protocole_ldap'), "'\\"); |
|
| 49 | + $base_ldap = addcslashes(_request('base_ldap'), "'\\"); |
|
| 50 | + $base_ldap_text = addcslashes(_request('base_ldap_text'), "'\\"); |
|
| 51 | 51 | |
| 52 | - $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
|
| 53 | - . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
|
| 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") |
|
| 57 | - . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
|
| 52 | + $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
|
| 53 | + . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
|
| 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") |
|
| 57 | + . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
|
| 58 | 58 | |
| 59 | - $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
|
| 60 | - $res = ''; |
|
| 61 | - foreach ($champs as $champ => $v) { |
|
| 62 | - $nom = 'ldap_' . $champ; |
|
| 63 | - $val = trim(_request($nom)); |
|
| 64 | - if (preg_match('/^\w*$/', $val)) { |
|
| 65 | - if ($val) { |
|
| 66 | - $val = _q($val); |
|
| 67 | - } |
|
| 68 | - } else { |
|
| 69 | - $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 70 | - }; |
|
| 71 | - if ($val) { |
|
| 72 | - $res .= "'$champ' => " . $val . ','; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
|
| 59 | + $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
|
| 60 | + $res = ''; |
|
| 61 | + foreach ($champs as $champ => $v) { |
|
| 62 | + $nom = 'ldap_' . $champ; |
|
| 63 | + $val = trim(_request($nom)); |
|
| 64 | + if (preg_match('/^\w*$/', $val)) { |
|
| 65 | + if ($val) { |
|
| 66 | + $val = _q($val); |
|
| 67 | + } |
|
| 68 | + } else { |
|
| 69 | + $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 70 | + }; |
|
| 71 | + if ($val) { |
|
| 72 | + $res .= "'$champ' => " . $val . ','; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
|
| 76 | 76 | |
| 77 | - install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 77 | + install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | function etape_ldap5_suite() { |
| 81 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 81 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 82 | 82 | |
| 83 | - echo info_etape( |
|
| 84 | - _T('info_ldap_ok'), |
|
| 85 | - info_progression_etape(5, 'etape_ldap', 'install/') |
|
| 86 | - ); |
|
| 83 | + echo info_etape( |
|
| 84 | + _T('info_ldap_ok'), |
|
| 85 | + info_progression_etape(5, 'etape_ldap', 'install/') |
|
| 86 | + ); |
|
| 87 | 87 | |
| 88 | - echo generer_form_ecrire('install', ( |
|
| 89 | - "<input type='hidden' name='etape' value='3' />" . |
|
| 90 | - "<input type='hidden' name='ldap_present' value='true' />" |
|
| 91 | - . bouton_suivant())); |
|
| 88 | + echo generer_form_ecrire('install', ( |
|
| 89 | + "<input type='hidden' name='etape' value='3' />" . |
|
| 90 | + "<input type='hidden' name='ldap_present' value='true' />" |
|
| 91 | + . bouton_suivant())); |
|
| 92 | 92 | |
| 93 | - echo install_fin_html(); |
|
| 93 | + echo install_fin_html(); |
|
| 94 | 94 | } |
@@ -11,140 +11,140 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/presentation'); |
| 17 | 17 | include_spip('inc/config'); |
| 18 | 18 | |
| 19 | 19 | function formulaires_configurer_relayeur_charger_dist() { |
| 20 | - $valeurs = [ |
|
| 21 | - 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 22 | - 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 23 | - 'test_proxy' => 'https://www.spip.net/', |
|
| 24 | - ]; |
|
| 20 | + $valeurs = [ |
|
| 21 | + 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 22 | + 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 23 | + 'test_proxy' => 'https://www.spip.net/', |
|
| 24 | + ]; |
|
| 25 | 25 | |
| 26 | - return $valeurs; |
|
| 26 | + return $valeurs; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | function formulaires_configurer_relayeur_verifier_dist() { |
| 30 | - $erreurs = []; |
|
| 31 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 32 | - $http_noproxy = _request('http_noproxy'); |
|
| 33 | - |
|
| 34 | - if ($http_proxy and !tester_url_absolue($http_proxy)) { |
|
| 35 | - $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) { |
|
| 39 | - if (!$http_proxy) { |
|
| 40 | - $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 41 | - } else { |
|
| 42 | - include_spip('inc/distant'); |
|
| 43 | - $test_proxy = _request('test_proxy'); |
|
| 44 | - $t = parse_url($test_proxy); |
|
| 45 | - if (!@$t['host']) { |
|
| 46 | - $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 47 | - } else { |
|
| 48 | - include_spip('inc/texte'); // pour aide, couper, lang |
|
| 49 | - $info = ''; |
|
| 50 | - if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 51 | - $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // il faut fausser le proxy actuel pour faire le test ! |
|
| 55 | - $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 56 | - $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 57 | - $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 58 | - $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 59 | - $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 60 | - $page = $page['page'] ?? ''; |
|
| 61 | - $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 62 | - $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 63 | - if ($page) { |
|
| 64 | - $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 65 | - $erreurs['message_erreur'] = ''; |
|
| 66 | - } else { |
|
| 67 | - $erreurs['message_erreur'] = $info . _T( |
|
| 68 | - 'info_impossible_lire_page', |
|
| 69 | - ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 70 | - ) |
|
| 71 | - . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 72 | - . aider('confhttpproxy'); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - return $erreurs; |
|
| 30 | + $erreurs = []; |
|
| 31 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 32 | + $http_noproxy = _request('http_noproxy'); |
|
| 33 | + |
|
| 34 | + if ($http_proxy and !tester_url_absolue($http_proxy)) { |
|
| 35 | + $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) { |
|
| 39 | + if (!$http_proxy) { |
|
| 40 | + $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 41 | + } else { |
|
| 42 | + include_spip('inc/distant'); |
|
| 43 | + $test_proxy = _request('test_proxy'); |
|
| 44 | + $t = parse_url($test_proxy); |
|
| 45 | + if (!@$t['host']) { |
|
| 46 | + $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 47 | + } else { |
|
| 48 | + include_spip('inc/texte'); // pour aide, couper, lang |
|
| 49 | + $info = ''; |
|
| 50 | + if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 51 | + $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // il faut fausser le proxy actuel pour faire le test ! |
|
| 55 | + $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 56 | + $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 57 | + $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 58 | + $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 59 | + $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 60 | + $page = $page['page'] ?? ''; |
|
| 61 | + $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 62 | + $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 63 | + if ($page) { |
|
| 64 | + $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 65 | + $erreurs['message_erreur'] = ''; |
|
| 66 | + } else { |
|
| 67 | + $erreurs['message_erreur'] = $info . _T( |
|
| 68 | + 'info_impossible_lire_page', |
|
| 69 | + ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 70 | + ) |
|
| 71 | + . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 72 | + . aider('confhttpproxy'); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + return $erreurs; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | function formulaires_configurer_relayeur_traiter_dist() { |
| 82 | - $res = ['editable' => true]; |
|
| 82 | + $res = ['editable' => true]; |
|
| 83 | 83 | |
| 84 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 85 | - $http_noproxy = _request('http_noproxy'); |
|
| 86 | - if ($http_proxy !== null) { |
|
| 87 | - ecrire_meta('http_proxy', $http_proxy); |
|
| 88 | - } |
|
| 84 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 85 | + $http_noproxy = _request('http_noproxy'); |
|
| 86 | + if ($http_proxy !== null) { |
|
| 87 | + ecrire_meta('http_proxy', $http_proxy); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - if ($http_noproxy !== null) { |
|
| 91 | - ecrire_meta('http_noproxy', $http_noproxy); |
|
| 92 | - } |
|
| 90 | + if ($http_noproxy !== null) { |
|
| 91 | + ecrire_meta('http_noproxy', $http_noproxy); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 94 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 95 | 95 | |
| 96 | - return $res; |
|
| 96 | + return $res; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | function relayeur_saisie_ou_config($http_proxy, $default) { |
| 100 | - // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 101 | - if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 102 | - $http_proxy = $default; |
|
| 103 | - } |
|
| 100 | + // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 101 | + if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 102 | + $http_proxy = $default; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $http_proxy; |
|
| 105 | + return $http_proxy; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Function glue_url : le pendant de parse_url |
| 109 | 109 | function glue_url($url) { |
| 110 | - if (!is_array($url)) { |
|
| 111 | - return false; |
|
| 112 | - } |
|
| 113 | - // scheme |
|
| 114 | - $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 115 | - // user & pass |
|
| 116 | - if (!empty($url['user'])) { |
|
| 117 | - $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 118 | - } |
|
| 119 | - // host |
|
| 120 | - $uri .= $url['host']; |
|
| 121 | - // port |
|
| 122 | - $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 123 | - $uri .= $port; |
|
| 124 | - // path |
|
| 125 | - $uri .= $url['path']; |
|
| 110 | + if (!is_array($url)) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | + // scheme |
|
| 114 | + $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 115 | + // user & pass |
|
| 116 | + if (!empty($url['user'])) { |
|
| 117 | + $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 118 | + } |
|
| 119 | + // host |
|
| 120 | + $uri .= $url['host']; |
|
| 121 | + // port |
|
| 122 | + $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 123 | + $uri .= $port; |
|
| 124 | + // path |
|
| 125 | + $uri .= $url['path']; |
|
| 126 | 126 | // fragment or query |
| 127 | - if (isset($url['fragment'])) { |
|
| 128 | - $uri .= '#' . $url['fragment']; |
|
| 129 | - } elseif (isset($url['query'])) { |
|
| 130 | - $uri .= '?' . $url['query']; |
|
| 131 | - } |
|
| 127 | + if (isset($url['fragment'])) { |
|
| 128 | + $uri .= '#' . $url['fragment']; |
|
| 129 | + } elseif (isset($url['query'])) { |
|
| 130 | + $uri .= '?' . $url['query']; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return $uri; |
|
| 133 | + return $uri; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | // Ne pas afficher la partie 'password' du proxy |
| 138 | 138 | function no_password_proxy_url($http_proxy) { |
| 139 | - if ( |
|
| 140 | - $http_proxy |
|
| 141 | - and $p = @parse_url($http_proxy) |
|
| 142 | - and isset($p['pass']) |
|
| 143 | - and $p['pass'] |
|
| 144 | - ) { |
|
| 145 | - $p['pass'] = '****'; |
|
| 146 | - $http_proxy = glue_url($p); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - return $http_proxy; |
|
| 139 | + if ( |
|
| 140 | + $http_proxy |
|
| 141 | + and $p = @parse_url($http_proxy) |
|
| 142 | + and isset($p['pass']) |
|
| 143 | + and $p['pass'] |
|
| 144 | + ) { |
|
| 145 | + $p['pass'] = '****'; |
|
| 146 | + $http_proxy = glue_url($p); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + return $http_proxy; |
|
| 150 | 150 | } |
@@ -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 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * Pile complétée du code compilé |
| 43 | 43 | **/ |
| 44 | 44 | function balise_FORMULAIRE_ADMIN($p) { |
| 45 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []); |
|
| 45 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * - chaîne vide sinon. |
| 60 | 60 | */ |
| 61 | 61 | function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) { |
| 62 | - return $args; |
|
| 62 | + return $args; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -84,66 +84,66 @@ discard block |
||
| 84 | 84 | **/ |
| 85 | 85 | function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') { |
| 86 | 86 | |
| 87 | - static $dejafait = false; |
|
| 87 | + static $dejafait = false; |
|
| 88 | 88 | |
| 89 | - if (empty($_COOKIE['spip_admin'])) { |
|
| 90 | - return ''; |
|
| 91 | - } |
|
| 89 | + if (empty($_COOKIE['spip_admin'])) { |
|
| 90 | + return ''; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if (!is_array($debug)) { |
|
| 94 | - if ($dejafait) { |
|
| 95 | - return ''; |
|
| 96 | - } |
|
| 97 | - } else { |
|
| 98 | - if ($dejafait) { |
|
| 99 | - if (empty($debug['sourcefile'])) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - foreach ($debug['sourcefile'] as $k => $v) { |
|
| 103 | - if (strpos($v, 'administration.') !== false) { |
|
| 104 | - if (isset($debug['resultat'][$k . 'tout'])) { |
|
| 105 | - return $debug['resultat'][$k . 'tout']; |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 93 | + if (!is_array($debug)) { |
|
| 94 | + if ($dejafait) { |
|
| 95 | + return ''; |
|
| 96 | + } |
|
| 97 | + } else { |
|
| 98 | + if ($dejafait) { |
|
| 99 | + if (empty($debug['sourcefile'])) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + foreach ($debug['sourcefile'] as $k => $v) { |
|
| 103 | + if (strpos($v, 'administration.') !== false) { |
|
| 104 | + if (isset($debug['resultat'][$k . 'tout'])) { |
|
| 105 | + return $debug['resultat'][$k . 'tout']; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - return ''; |
|
| 111 | - } |
|
| 112 | - } |
|
| 110 | + return ''; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - include_spip('inc/autoriser'); |
|
| 115 | - include_spip('base/abstract_sql'); |
|
| 114 | + include_spip('inc/autoriser'); |
|
| 115 | + include_spip('base/abstract_sql'); |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | - $dejafait = true; |
|
| 118 | + $dejafait = true; |
|
| 119 | 119 | |
| 120 | - // Preparer le #ENV des boutons |
|
| 120 | + // Preparer le #ENV des boutons |
|
| 121 | 121 | |
| 122 | - $env = admin_objet(); |
|
| 122 | + $env = admin_objet(); |
|
| 123 | 123 | |
| 124 | - // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" |
|
| 125 | - if (!$env) { |
|
| 126 | - $env['ecrire'] = _DIR_RESTREINT_ABS; |
|
| 127 | - } |
|
| 124 | + // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" |
|
| 125 | + if (!$env) { |
|
| 126 | + $env['ecrire'] = _DIR_RESTREINT_ABS; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - $env['divclass'] = $float; |
|
| 130 | - $env['lang'] = admin_lang(); |
|
| 131 | - $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul'); |
|
| 132 | - $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug()); |
|
| 133 | - $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider(); |
|
| 134 | - $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : ''); |
|
| 129 | + $env['divclass'] = $float; |
|
| 130 | + $env['lang'] = admin_lang(); |
|
| 131 | + $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul'); |
|
| 132 | + $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug()); |
|
| 133 | + $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider(); |
|
| 134 | + $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : ''); |
|
| 135 | 135 | |
| 136 | - if (empty($GLOBALS['use_cache'])) { |
|
| 137 | - $env['use_cache'] = ' *'; |
|
| 138 | - } |
|
| 136 | + if (empty($GLOBALS['use_cache'])) { |
|
| 137 | + $env['use_cache'] = ' *'; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - if (isset($debug['validation'])) { |
|
| 141 | - $env['xhtml_error'] = $debug['validation']; |
|
| 142 | - } |
|
| 140 | + if (isset($debug['validation'])) { |
|
| 141 | + $env['xhtml_error'] = $debug['validation']; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - $env['_pipelines']['formulaire_admin'] = []; |
|
| 144 | + $env['_pipelines']['formulaire_admin'] = []; |
|
| 145 | 145 | |
| 146 | - return ['formulaires/administration', 0, $env]; |
|
| 146 | + return ['formulaires/administration', 0, $env]; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -161,47 +161,47 @@ discard block |
||
| 161 | 161 | * Tableau de l'environnement calculé |
| 162 | 162 | **/ |
| 163 | 163 | function admin_objet() { |
| 164 | - include_spip('inc/urls'); |
|
| 165 | - $env = []; |
|
| 166 | - |
|
| 167 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 168 | - $objets = urls_liste_objets(false); |
|
| 169 | - $objets = array_diff($objets, ['rubrique']); |
|
| 170 | - $objets = array_reverse($objets); |
|
| 171 | - array_unshift($objets, 'rubrique'); |
|
| 172 | - foreach ($objets as $obj) { |
|
| 173 | - $type = $obj; |
|
| 174 | - if ( |
|
| 175 | - $type == objet_type($type, false) |
|
| 176 | - and $_id_type = id_table_objet($type) |
|
| 177 | - and isset($GLOBALS['contexte'][$_id_type]) |
|
| 178 | - and $id = $GLOBALS['contexte'][$_id_type] |
|
| 179 | - and !is_array($id) |
|
| 180 | - and $id = intval($id) |
|
| 181 | - and $desc = $trouver_table(table_objet_sql($type)) |
|
| 182 | - ) { |
|
| 183 | - $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id)); |
|
| 184 | - if ($id) { |
|
| 185 | - $env[$_id_type] = $id; |
|
| 186 | - $env['objet'] = $type; |
|
| 187 | - $env['id_objet'] = $id; |
|
| 188 | - $env['voir_' . $obj] = |
|
| 189 | - str_replace('&', '&', generer_objet_url($id, $obj, '', '', false)); |
|
| 190 | - if ( |
|
| 191 | - isset($desc['field']['id_rubrique']) |
|
| 192 | - and $type != 'rubrique' |
|
| 193 | - ) { |
|
| 194 | - unset($env['id_rubrique']); |
|
| 195 | - unset($env['voir_rubrique']); |
|
| 196 | - if (admin_preview($type, $id, $desc)) { |
|
| 197 | - $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&'); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - return $env; |
|
| 164 | + include_spip('inc/urls'); |
|
| 165 | + $env = []; |
|
| 166 | + |
|
| 167 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 168 | + $objets = urls_liste_objets(false); |
|
| 169 | + $objets = array_diff($objets, ['rubrique']); |
|
| 170 | + $objets = array_reverse($objets); |
|
| 171 | + array_unshift($objets, 'rubrique'); |
|
| 172 | + foreach ($objets as $obj) { |
|
| 173 | + $type = $obj; |
|
| 174 | + if ( |
|
| 175 | + $type == objet_type($type, false) |
|
| 176 | + and $_id_type = id_table_objet($type) |
|
| 177 | + and isset($GLOBALS['contexte'][$_id_type]) |
|
| 178 | + and $id = $GLOBALS['contexte'][$_id_type] |
|
| 179 | + and !is_array($id) |
|
| 180 | + and $id = intval($id) |
|
| 181 | + and $desc = $trouver_table(table_objet_sql($type)) |
|
| 182 | + ) { |
|
| 183 | + $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id)); |
|
| 184 | + if ($id) { |
|
| 185 | + $env[$_id_type] = $id; |
|
| 186 | + $env['objet'] = $type; |
|
| 187 | + $env['id_objet'] = $id; |
|
| 188 | + $env['voir_' . $obj] = |
|
| 189 | + str_replace('&', '&', generer_objet_url($id, $obj, '', '', false)); |
|
| 190 | + if ( |
|
| 191 | + isset($desc['field']['id_rubrique']) |
|
| 192 | + and $type != 'rubrique' |
|
| 193 | + ) { |
|
| 194 | + unset($env['id_rubrique']); |
|
| 195 | + unset($env['voir_rubrique']); |
|
| 196 | + if (admin_preview($type, $id, $desc)) { |
|
| 197 | + $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&'); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + return $env; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | |
@@ -219,30 +219,30 @@ discard block |
||
| 219 | 219 | * - Tableau d'un élément sinon. |
| 220 | 220 | **/ |
| 221 | 221 | function admin_preview($type, $id, $desc = null) { |
| 222 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) { |
|
| 223 | - return ''; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - if (!$desc) { |
|
| 227 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 228 | - $desc = $trouver_table(table_objet_sql($type)); |
|
| 229 | - } |
|
| 230 | - if (!$desc or !isset($desc['field']['statut'])) { |
|
| 231 | - return ''; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - include_spip('inc/autoriser'); |
|
| 235 | - if (!autoriser('previsualiser')) { |
|
| 236 | - return ''; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $notpub = sql_in('statut', ['prop', 'prive']); |
|
| 240 | - |
|
| 241 | - if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') { |
|
| 242 | - $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 222 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) { |
|
| 223 | + return ''; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + if (!$desc) { |
|
| 227 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 228 | + $desc = $trouver_table(table_objet_sql($type)); |
|
| 229 | + } |
|
| 230 | + if (!$desc or !isset($desc['field']['statut'])) { |
|
| 231 | + return ''; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + include_spip('inc/autoriser'); |
|
| 235 | + if (!autoriser('previsualiser')) { |
|
| 236 | + return ''; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $notpub = sql_in('statut', ['prop', 'prive']); |
|
| 240 | + |
|
| 241 | + if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') { |
|
| 242 | + $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -253,25 +253,25 @@ discard block |
||
| 253 | 253 | * Code de langue |
| 254 | 254 | **/ |
| 255 | 255 | function admin_lang() { |
| 256 | - $alang = ''; |
|
| 257 | - if (!empty($_COOKIE['spip_admin'])) { |
|
| 258 | - $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']); |
|
| 259 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 260 | - if (!$alang) { |
|
| 261 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - if (!$alang) { |
|
| 265 | - return ''; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - $l = lang_select($alang); |
|
| 269 | - $alang = $GLOBALS['spip_lang']; |
|
| 270 | - if ($l) { |
|
| 271 | - lang_select(); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - return $alang; |
|
| 256 | + $alang = ''; |
|
| 257 | + if (!empty($_COOKIE['spip_admin'])) { |
|
| 258 | + $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']); |
|
| 259 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 260 | + if (!$alang) { |
|
| 261 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + if (!$alang) { |
|
| 265 | + return ''; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + $l = lang_select($alang); |
|
| 269 | + $alang = $GLOBALS['spip_lang']; |
|
| 270 | + if ($l) { |
|
| 271 | + lang_select(); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + return $alang; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -281,11 +281,11 @@ discard block |
||
| 281 | 281 | **/ |
| 282 | 282 | function admin_valider() { |
| 283 | 283 | |
| 284 | - return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ? |
|
| 285 | - (parametre_url(self(), 'var_mode', 'debug', '&') |
|
| 286 | - . '&var_mode_affiche=validation') : |
|
| 287 | - ('http://validator.w3.org/check?uri=' |
|
| 288 | - . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 284 | + return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ? |
|
| 285 | + (parametre_url(self(), 'var_mode', 'debug', '&') |
|
| 286 | + . '&var_mode_affiche=validation') : |
|
| 287 | + ('http://validator.w3.org/check?uri=' |
|
| 288 | + . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | * @return string |
| 295 | 295 | **/ |
| 296 | 296 | function admin_debug() { |
| 297 | - return (( |
|
| 298 | - (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug']) |
|
| 299 | - or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug']) |
|
| 300 | - or ( |
|
| 301 | - defined('_VAR_MODE') and _VAR_MODE == 'debug' |
|
| 302 | - and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug'] |
|
| 303 | - ) |
|
| 304 | - ) and autoriser('debug') |
|
| 305 | - ) |
|
| 306 | - ? parametre_url(self(), 'var_mode', 'debug', '&') : ''; |
|
| 297 | + return (( |
|
| 298 | + (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug']) |
|
| 299 | + or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug']) |
|
| 300 | + or ( |
|
| 301 | + defined('_VAR_MODE') and _VAR_MODE == 'debug' |
|
| 302 | + and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug'] |
|
| 303 | + ) |
|
| 304 | + ) and autoriser('debug') |
|
| 305 | + ) |
|
| 306 | + ? parametre_url(self(), 'var_mode', 'debug', '&') : ''; |
|
| 307 | 307 | } |
@@ -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 | /** |
@@ -40,29 +40,29 @@ discard block |
||
| 40 | 40 | * Pile complétée par le code à générer |
| 41 | 41 | */ |
| 42 | 42 | function balise_INFO__dist($p) { |
| 43 | - $info = $p->nom_champ; |
|
| 44 | - $type_objet = interprete_argument_balise(1, $p); |
|
| 45 | - $id_objet = interprete_argument_balise(2, $p); |
|
| 46 | - if ($info === 'INFO_' or !$type_objet or !$id_objet) { |
|
| 47 | - $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 48 | - erreur_squelette($msg, $p); |
|
| 49 | - $p->interdire_scripts = true; |
|
| 43 | + $info = $p->nom_champ; |
|
| 44 | + $type_objet = interprete_argument_balise(1, $p); |
|
| 45 | + $id_objet = interprete_argument_balise(2, $p); |
|
| 46 | + if ($info === 'INFO_' or !$type_objet or !$id_objet) { |
|
| 47 | + $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 48 | + erreur_squelette($msg, $p); |
|
| 49 | + $p->interdire_scripts = true; |
|
| 50 | 50 | |
| 51 | - return $p; |
|
| 52 | - } else { |
|
| 53 | - // Récupérer tous les params à la suite de objet et id_objet |
|
| 54 | - $_params = '['; |
|
| 55 | - $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 56 | - for ($i = 3; $i < $nb_params; $i++) { |
|
| 57 | - $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 58 | - } |
|
| 59 | - $_params .= ']'; |
|
| 51 | + return $p; |
|
| 52 | + } else { |
|
| 53 | + // Récupérer tous les params à la suite de objet et id_objet |
|
| 54 | + $_params = '['; |
|
| 55 | + $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 56 | + for ($i = 3; $i < $nb_params; $i++) { |
|
| 57 | + $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 58 | + } |
|
| 59 | + $_params .= ']'; |
|
| 60 | 60 | |
| 61 | - $info_sql = strtolower(substr($info, 5)); |
|
| 62 | - $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 63 | - $p->code = champ_sql($info, $p, $code); |
|
| 64 | - $p->interdire_scripts = true; |
|
| 61 | + $info_sql = strtolower(substr($info, 5)); |
|
| 62 | + $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 63 | + $p->code = champ_sql($info, $p, $code); |
|
| 64 | + $p->interdire_scripts = true; |
|
| 65 | 65 | |
| 66 | - return $p; |
|
| 67 | - } |
|
| 66 | + return $p; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/autoriser'); |
@@ -35,42 +35,42 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function action_menu_rubriques_dist() { |
| 37 | 37 | |
| 38 | - // si pas acces a ecrire, pas acces au menu |
|
| 39 | - // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | - if (!autoriser('ecrire')) { |
|
| 41 | - $retour = |
|
| 42 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | - '</a>' . |
|
| 47 | - '</li>' . |
|
| 48 | - '</ul>'; |
|
| 49 | - include_spip('inc/actions'); |
|
| 50 | - ajax_retour($retour); |
|
| 51 | - exit; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if ($date = intval(_request('date'))) { |
|
| 55 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - $r = gen_liste_rubriques(); |
|
| 59 | - if ( |
|
| 60 | - !$r |
|
| 61 | - and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | - and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | - ) { |
|
| 64 | - include_spip('inc/headers'); |
|
| 65 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | - http_response_code(304); |
|
| 67 | - exit; |
|
| 68 | - } else { |
|
| 69 | - include_spip('inc/actions'); |
|
| 70 | - $ret = menu_rubriques(); |
|
| 71 | - ajax_retour($ret); |
|
| 72 | - exit; |
|
| 73 | - } |
|
| 38 | + // si pas acces a ecrire, pas acces au menu |
|
| 39 | + // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | + if (!autoriser('ecrire')) { |
|
| 41 | + $retour = |
|
| 42 | + '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | + '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | + '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | + '</a>' . |
|
| 47 | + '</li>' . |
|
| 48 | + '</ul>'; |
|
| 49 | + include_spip('inc/actions'); |
|
| 50 | + ajax_retour($retour); |
|
| 51 | + exit; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if ($date = intval(_request('date'))) { |
|
| 55 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + $r = gen_liste_rubriques(); |
|
| 59 | + if ( |
|
| 60 | + !$r |
|
| 61 | + and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | + and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | + ) { |
|
| 64 | + include_spip('inc/headers'); |
|
| 65 | + header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | + http_response_code(304); |
|
| 67 | + exit; |
|
| 68 | + } else { |
|
| 69 | + include_spip('inc/actions'); |
|
| 70 | + $ret = menu_rubriques(); |
|
| 71 | + ajax_retour($ret); |
|
| 72 | + exit; |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -84,44 +84,44 @@ discard block |
||
| 84 | 84 | * Code HTML présentant la liste des rubriques |
| 85 | 85 | **/ |
| 86 | 86 | function menu_rubriques($complet = true) { |
| 87 | - $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | - . '</a>' |
|
| 91 | - . '</li>'; |
|
| 92 | - |
|
| 93 | - if (!$complet) { |
|
| 94 | - return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | - gen_liste_rubriques(); |
|
| 99 | - } |
|
| 100 | - $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | - |
|
| 102 | - $total_lignes = $i = sizeof($arr_low); |
|
| 103 | - |
|
| 104 | - if ($i > 0) { |
|
| 105 | - $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | - if ($nb_col <= 1) { |
|
| 107 | - $nb_col = ceil($total_lignes / 10); |
|
| 108 | - } |
|
| 109 | - foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | - $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | - $i++; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | - $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | - . $ret |
|
| 119 | - . "\n</ul>\n"; |
|
| 120 | - } else { |
|
| 121 | - $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $ret; |
|
| 87 | + $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | + . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | + . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | + . '</a>' |
|
| 91 | + . '</li>'; |
|
| 92 | + |
|
| 93 | + if (!$complet) { |
|
| 94 | + return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | + gen_liste_rubriques(); |
|
| 99 | + } |
|
| 100 | + $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | + |
|
| 102 | + $total_lignes = $i = sizeof($arr_low); |
|
| 103 | + |
|
| 104 | + if ($i > 0) { |
|
| 105 | + $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | + if ($nb_col <= 1) { |
|
| 107 | + $nb_col = ceil($total_lignes / 10); |
|
| 108 | + } |
|
| 109 | + foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | + $i++; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | + $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | + . $ret |
|
| 119 | + . "\n</ul>\n"; |
|
| 120 | + } else { |
|
| 121 | + $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $ret; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,48 +142,48 @@ discard block |
||
| 142 | 142 | * Code HTML présentant la liste des rubriques |
| 143 | 143 | **/ |
| 144 | 144 | function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) { |
| 145 | - static $zmax = 6; |
|
| 146 | - $profondeur_next = $profondeur + 1; |
|
| 147 | - |
|
| 148 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | - . "</a>\n"; |
|
| 151 | - |
|
| 152 | - // Limiter volontairement le nombre de sous-menus |
|
| 153 | - if (!(--$zmax)) { |
|
| 154 | - $zmax++; |
|
| 155 | - |
|
| 156 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | - $i = sizeof($arr_rub); |
|
| 161 | - if (!$i) { |
|
| 162 | - $zmax++; |
|
| 163 | - |
|
| 164 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - $nb_col = 1; |
|
| 169 | - if ($nb_rub = count($arr_rub)) { |
|
| 170 | - $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | - } |
|
| 172 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | - $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | - . $nav |
|
| 175 | - . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | - foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | - if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | - $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | - $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | - $i++; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $ret .= "</ul></li>\n"; |
|
| 184 | - $zmax++; |
|
| 185 | - |
|
| 186 | - return $ret; |
|
| 145 | + static $zmax = 6; |
|
| 146 | + $profondeur_next = $profondeur + 1; |
|
| 147 | + |
|
| 148 | + $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | + . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | + . "</a>\n"; |
|
| 151 | + |
|
| 152 | + // Limiter volontairement le nombre de sous-menus |
|
| 153 | + if (!(--$zmax)) { |
|
| 154 | + $zmax++; |
|
| 155 | + |
|
| 156 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | + $i = sizeof($arr_rub); |
|
| 161 | + if (!$i) { |
|
| 162 | + $zmax++; |
|
| 163 | + |
|
| 164 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + $nb_col = 1; |
|
| 169 | + if ($nb_rub = count($arr_rub)) { |
|
| 170 | + $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | + } |
|
| 172 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | + $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | + . $nav |
|
| 175 | + . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | + foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | + if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | + $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | + $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | + $i++; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $ret .= "</ul></li>\n"; |
|
| 184 | + $zmax++; |
|
| 185 | + |
|
| 186 | + return $ret; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * Liste des rubriques enfants de la rubrique (et leur titre) |
| 202 | 202 | **/ |
| 203 | 203 | function extraire_article($id_p, $t) { |
| 204 | - return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 204 | + return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -217,42 +217,42 @@ discard block |
||
| 217 | 217 | **/ |
| 218 | 218 | function gen_liste_rubriques() { |
| 219 | 219 | |
| 220 | - $cache = null; |
|
| 221 | - include_spip('inc/config'); |
|
| 222 | - // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | - $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | - if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | - [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | - if ($date == $last) { |
|
| 227 | - return false; |
|
| 228 | - } // c'etait en cache :-) |
|
| 229 | - } |
|
| 230 | - // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | - |
|
| 232 | - $where = sql_in_select( |
|
| 233 | - 'id_rubrique', |
|
| 234 | - 'id_rubrique', |
|
| 235 | - 'spip_rubriques', |
|
| 236 | - '', |
|
| 237 | - '', |
|
| 238 | - 'id_parent=0 DESC, date DESC', |
|
| 239 | - _CACHE_RUBRIQUES_MAX |
|
| 240 | - ); |
|
| 241 | - |
|
| 242 | - // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | - |
|
| 244 | - $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | - |
|
| 246 | - // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | - // car on met le resultat en cache, commun a tout le monde |
|
| 248 | - $GLOBALS['db_art_cache'] = []; |
|
| 249 | - while ($r = sql_fetch($res)) { |
|
| 250 | - $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | - $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | - ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | - |
|
| 257 | - return true; |
|
| 220 | + $cache = null; |
|
| 221 | + include_spip('inc/config'); |
|
| 222 | + // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | + $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | + if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | + [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | + if ($date == $last) { |
|
| 227 | + return false; |
|
| 228 | + } // c'etait en cache :-) |
|
| 229 | + } |
|
| 230 | + // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | + |
|
| 232 | + $where = sql_in_select( |
|
| 233 | + 'id_rubrique', |
|
| 234 | + 'id_rubrique', |
|
| 235 | + 'spip_rubriques', |
|
| 236 | + '', |
|
| 237 | + '', |
|
| 238 | + 'id_parent=0 DESC, date DESC', |
|
| 239 | + _CACHE_RUBRIQUES_MAX |
|
| 240 | + ); |
|
| 241 | + |
|
| 242 | + // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | + |
|
| 244 | + $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | + |
|
| 246 | + // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | + // car on met le resultat en cache, commun a tout le monde |
|
| 248 | + $GLOBALS['db_art_cache'] = []; |
|
| 249 | + while ($r = sql_fetch($res)) { |
|
| 250 | + $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | + $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | + ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | + |
|
| 257 | + return true; |
|
| 258 | 258 | } |