@@ -12,76 +12,76 @@ |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // http://code.spip.net/@install_etape_ldap3_dist |
| 19 | 19 | function install_etape_ldap3_dist() { |
| 20 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 21 | - $login_ldap = _request('login_ldap'); |
|
| 22 | - $pass_ldap = _request('pass_ldap'); |
|
| 23 | - $port_ldap = _request('port_ldap'); |
|
| 20 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 21 | + $login_ldap = _request('login_ldap'); |
|
| 22 | + $pass_ldap = _request('pass_ldap'); |
|
| 23 | + $port_ldap = _request('port_ldap'); |
|
| 24 | 24 | |
| 25 | - $base_ldap_text = defined('_INSTALL_BASE_LDAP') |
|
| 26 | - ? _INSTALL_BASE_LDAP |
|
| 27 | - : 'ou=users, dc=mon-domaine, dc=com'; |
|
| 25 | + $base_ldap_text = defined('_INSTALL_BASE_LDAP') |
|
| 26 | + ? _INSTALL_BASE_LDAP |
|
| 27 | + : 'ou=users, dc=mon-domaine, dc=com'; |
|
| 28 | 28 | |
| 29 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 29 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 30 | 30 | |
| 31 | - echo info_etape( |
|
| 32 | - _T('info_chemin_acces_1'), |
|
| 33 | - info_progression_etape(3, 'etape_ldap', 'install/') |
|
| 34 | - ), |
|
| 35 | - _T('info_chemin_acces_2'); |
|
| 31 | + echo info_etape( |
|
| 32 | + _T('info_chemin_acces_1'), |
|
| 33 | + info_progression_etape(3, 'etape_ldap', 'install/') |
|
| 34 | + ), |
|
| 35 | + _T('info_chemin_acces_2'); |
|
| 36 | 36 | |
| 37 | - $ldap_link = @ldap_connect("$adresse_ldap", "$port_ldap"); |
|
| 38 | - if ($ldap_link) { |
|
| 39 | - @ldap_bind($ldap_link, "$login_ldap", "$pass_ldap"); |
|
| 40 | - $result = @ldap_read($ldap_link, '', 'objectclass=*', array('namingContexts')); |
|
| 41 | - $info = @ldap_get_entries($ldap_link, $result); |
|
| 42 | - @ldap_close($ldap_link); |
|
| 43 | - } |
|
| 37 | + $ldap_link = @ldap_connect("$adresse_ldap", "$port_ldap"); |
|
| 38 | + if ($ldap_link) { |
|
| 39 | + @ldap_bind($ldap_link, "$login_ldap", "$pass_ldap"); |
|
| 40 | + $result = @ldap_read($ldap_link, '', 'objectclass=*', array('namingContexts')); |
|
| 41 | + $info = @ldap_get_entries($ldap_link, $result); |
|
| 42 | + @ldap_close($ldap_link); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $checked = false; |
|
| 46 | - $res = ''; |
|
| 47 | - if (is_array($info) and $info['count'] > 0) { |
|
| 48 | - $res .= '<p>' . _T('info_selection_chemin_acces') . '</p>'; |
|
| 49 | - $res .= '<ul>'; |
|
| 50 | - $n = 0; |
|
| 51 | - for ($i = 0; $i < $info['count']; $i++) { |
|
| 52 | - $names = $info[$i]['namingcontexts']; |
|
| 53 | - if (is_array($names)) { |
|
| 54 | - for ($j = 0; $j < $names['count']; $j++) { |
|
| 55 | - $n++; |
|
| 56 | - $res .= '<li><input name="base_ldap" value="' . spip_htmlspecialchars($names[$j]) . "\" type='radio' id='tab$n'"; |
|
| 57 | - if (!$checked) { |
|
| 58 | - $res .= ' checked="checked"'; |
|
| 59 | - $checked = true; |
|
| 60 | - } |
|
| 61 | - $res .= ' />'; |
|
| 62 | - $res .= "<label for='tab$n'>" . spip_htmlspecialchars($names[$j]) . "</label></li>\n"; |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - $res .= '</ul>'; |
|
| 67 | - $res .= _T('info_ou') . ' '; |
|
| 68 | - } |
|
| 69 | - $res .= "<br />\n<input name=\"base_ldap\" value=\"\" type='radio' id='manuel'"; |
|
| 70 | - if (!$checked) { |
|
| 71 | - $res .= ' checked="checked"'; |
|
| 72 | - $checked = true; |
|
| 73 | - } |
|
| 45 | + $checked = false; |
|
| 46 | + $res = ''; |
|
| 47 | + if (is_array($info) and $info['count'] > 0) { |
|
| 48 | + $res .= '<p>' . _T('info_selection_chemin_acces') . '</p>'; |
|
| 49 | + $res .= '<ul>'; |
|
| 50 | + $n = 0; |
|
| 51 | + for ($i = 0; $i < $info['count']; $i++) { |
|
| 52 | + $names = $info[$i]['namingcontexts']; |
|
| 53 | + if (is_array($names)) { |
|
| 54 | + for ($j = 0; $j < $names['count']; $j++) { |
|
| 55 | + $n++; |
|
| 56 | + $res .= '<li><input name="base_ldap" value="' . spip_htmlspecialchars($names[$j]) . "\" type='radio' id='tab$n'"; |
|
| 57 | + if (!$checked) { |
|
| 58 | + $res .= ' checked="checked"'; |
|
| 59 | + $checked = true; |
|
| 60 | + } |
|
| 61 | + $res .= ' />'; |
|
| 62 | + $res .= "<label for='tab$n'>" . spip_htmlspecialchars($names[$j]) . "</label></li>\n"; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + $res .= '</ul>'; |
|
| 67 | + $res .= _T('info_ou') . ' '; |
|
| 68 | + } |
|
| 69 | + $res .= "<br />\n<input name=\"base_ldap\" value=\"\" type='radio' id='manuel'"; |
|
| 70 | + if (!$checked) { |
|
| 71 | + $res .= ' checked="checked"'; |
|
| 72 | + $checked = true; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - $res .= ' />' |
|
| 76 | - . "\n<label for='manuel'>" . _T('entree_chemin_acces') . '</label> ' |
|
| 77 | - . "\n<fieldset>" |
|
| 78 | - . "<input type='text' name='base_ldap_text' class='text' value=\"$base_ldap_text\" size='40' />" |
|
| 79 | - . "\n</fieldset>" |
|
| 80 | - . "\n<input type='hidden' name='etape' value='ldap4' />" |
|
| 81 | - . install_propager(array('adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap')) |
|
| 82 | - . bouton_suivant(); |
|
| 75 | + $res .= ' />' |
|
| 76 | + . "\n<label for='manuel'>" . _T('entree_chemin_acces') . '</label> ' |
|
| 77 | + . "\n<fieldset>" |
|
| 78 | + . "<input type='text' name='base_ldap_text' class='text' value=\"$base_ldap_text\" size='40' />" |
|
| 79 | + . "\n</fieldset>" |
|
| 80 | + . "\n<input type='hidden' name='etape' value='ldap4' />" |
|
| 81 | + . install_propager(array('adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap')) |
|
| 82 | + . bouton_suivant(); |
|
| 83 | 83 | |
| 84 | - echo generer_form_ecrire('install', $res); |
|
| 84 | + echo generer_form_ecrire('install', $res); |
|
| 85 | 85 | |
| 86 | - echo install_fin_html(); |
|
| 86 | + echo install_fin_html(); |
|
| 87 | 87 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $checked = false; |
| 46 | 46 | $res = ''; |
| 47 | 47 | if (is_array($info) and $info['count'] > 0) { |
| 48 | - $res .= '<p>' . _T('info_selection_chemin_acces') . '</p>'; |
|
| 48 | + $res .= '<p>'._T('info_selection_chemin_acces').'</p>'; |
|
| 49 | 49 | $res .= '<ul>'; |
| 50 | 50 | $n = 0; |
| 51 | 51 | for ($i = 0; $i < $info['count']; $i++) { |
@@ -53,18 +53,18 @@ discard block |
||
| 53 | 53 | if (is_array($names)) { |
| 54 | 54 | for ($j = 0; $j < $names['count']; $j++) { |
| 55 | 55 | $n++; |
| 56 | - $res .= '<li><input name="base_ldap" value="' . spip_htmlspecialchars($names[$j]) . "\" type='radio' id='tab$n'"; |
|
| 56 | + $res .= '<li><input name="base_ldap" value="'.spip_htmlspecialchars($names[$j])."\" type='radio' id='tab$n'"; |
|
| 57 | 57 | if (!$checked) { |
| 58 | 58 | $res .= ' checked="checked"'; |
| 59 | 59 | $checked = true; |
| 60 | 60 | } |
| 61 | 61 | $res .= ' />'; |
| 62 | - $res .= "<label for='tab$n'>" . spip_htmlspecialchars($names[$j]) . "</label></li>\n"; |
|
| 62 | + $res .= "<label for='tab$n'>".spip_htmlspecialchars($names[$j])."</label></li>\n"; |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | $res .= '</ul>'; |
| 67 | - $res .= _T('info_ou') . ' '; |
|
| 67 | + $res .= _T('info_ou').' '; |
|
| 68 | 68 | } |
| 69 | 69 | $res .= "<br />\n<input name=\"base_ldap\" value=\"\" type='radio' id='manuel'"; |
| 70 | 70 | if (!$checked) { |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $res .= ' />' |
| 76 | - . "\n<label for='manuel'>" . _T('entree_chemin_acces') . '</label> ' |
|
| 76 | + . "\n<label for='manuel'>"._T('entree_chemin_acces').'</label> ' |
|
| 77 | 77 | . "\n<fieldset>" |
| 78 | 78 | . "<input type='text' name='base_ldap_text' class='text' value=\"$base_ldap_text\" size='40' />" |
| 79 | 79 | . "\n</fieldset>" |
@@ -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 | // http://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 | - if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 27 | - redirige_url_ecrire('install'); |
|
| 28 | - } |
|
| 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'] : array(); |
|
| 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'] : array(); |
|
| 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 | - _T('info_terminer_installation') |
|
| 87 | - ); |
|
| 83 | + echo info_etape( |
|
| 84 | + _T('info_ldap_ok'), |
|
| 85 | + info_progression_etape(5, 'etape_ldap', 'install/'), |
|
| 86 | + _T('info_terminer_installation') |
|
| 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 | } |
@@ -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'] : array(); |
| 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 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -27,18 +27,18 @@ discard block |
||
| 27 | 27 | * @uses info_copyright() |
| 28 | 28 | **/ |
| 29 | 29 | function install_etape__dist() { |
| 30 | - utiliser_langue_visiteur(); |
|
| 31 | - $menu_langues = menu_langues('var_lang_ecrire'); |
|
| 32 | - if (!$menu_langues) { |
|
| 33 | - redirige_url_ecrire('install', 'etape=chmod'); |
|
| 34 | - } else { |
|
| 35 | - include_spip('inc/presentation'); // pour info_copyright |
|
| 30 | + utiliser_langue_visiteur(); |
|
| 31 | + $menu_langues = menu_langues('var_lang_ecrire'); |
|
| 32 | + if (!$menu_langues) { |
|
| 33 | + redirige_url_ecrire('install', 'etape=chmod'); |
|
| 34 | + } else { |
|
| 35 | + include_spip('inc/presentation'); // pour info_copyright |
|
| 36 | 36 | |
| 37 | - $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 38 | - "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 39 | - '<p>' . _T('install_select_langue') . '</p>' . |
|
| 40 | - '<div>' . $menu_langues . "</div>\n" . |
|
| 41 | - generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 42 | - echo minipres('AUTO', $res); |
|
| 43 | - } |
|
| 37 | + $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 38 | + "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 39 | + '<p>' . _T('install_select_langue') . '</p>' . |
|
| 40 | + '<div>' . $menu_langues . "</div>\n" . |
|
| 41 | + generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 42 | + echo minipres('AUTO', $res); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -34,11 +34,11 @@ |
||
| 34 | 34 | } else { |
| 35 | 35 | include_spip('inc/presentation'); // pour info_copyright |
| 36 | 36 | |
| 37 | - $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 38 | - "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 39 | - '<p>' . _T('install_select_langue') . '</p>' . |
|
| 40 | - '<div>' . $menu_langues . "</div>\n" . |
|
| 41 | - generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 37 | + $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='".chemin_image('logo-spip.png')."' />\n". |
|
| 38 | + "<p class='small'>".info_copyright()."</p></div>\n". |
|
| 39 | + '<p>'._T('install_select_langue').'</p>'. |
|
| 40 | + '<div>'.$menu_langues."</div>\n". |
|
| 41 | + generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />".bouton_suivant()); |
|
| 42 | 42 | echo minipres('AUTO', $res); |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -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 | // http://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(array('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 | - array( |
|
| 61 | - 'statut_ldap' => array( |
|
| 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(array('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 | + array( |
|
| 61 | + 'statut_ldap' => array( |
|
| 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 | // http://code.spip.net/@liste_statuts_ldap |
| 78 | 78 | function liste_statuts_ldap() { |
| 79 | - $recom = array( |
|
| 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 = array(); |
|
| 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 = array( |
|
| 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 = array(); |
|
| 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 = array(); |
|
| 97 | - foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : array() as $champ => $v) { |
|
| 98 | - $nom = 'ldap_' . $champ; |
|
| 99 | - $val = is_array($v) ? join(',', $v) : strval($v); |
|
| 100 | - $champs[$nom] = array( |
|
| 101 | - 'label' => _T('ldap_correspondance', array('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 = array(); |
|
| 97 | + foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : array() as $champ => $v) { |
|
| 98 | + $nom = 'ldap_' . $champ; |
|
| 99 | + $val = is_array($v) ? join(',', $v) : strval($v); |
|
| 100 | + $champs[$nom] = array( |
|
| 101 | + 'label' => _T('ldap_correspondance', array('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(array('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 | array( |
| 61 | 61 | 'statut_ldap' => array( |
| 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 | // http://code.spip.net/@liste_statuts_ldap |
| 78 | 78 | function liste_statuts_ldap() { |
| 79 | 79 | $recom = array( |
| 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 = array(); |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | function install_ldap_correspondances() { |
| 96 | 96 | $champs = array(); |
| 97 | 97 | foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : array() 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] = array( |
| 101 | - 'label' => _T('ldap_correspondance', array('champ' => "<tt>$champ</tt>")) . '<br />', |
|
| 101 | + 'label' => _T('ldap_correspondance', array('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 | } |
@@ -22,192 +22,192 @@ |
||
| 22 | 22 | |
| 23 | 23 | if (isset($GLOBALS['_INC_PUBLIC']) and $GLOBALS['_INC_PUBLIC']) { |
| 24 | 24 | |
| 25 | - echo recuperer_fond($fond, $contexte_inclus, array(), _request('connect')); |
|
| 25 | + echo recuperer_fond($fond, $contexte_inclus, array(), _request('connect')); |
|
| 26 | 26 | |
| 27 | 27 | } else { |
| 28 | 28 | |
| 29 | - $GLOBALS['_INC_PUBLIC'] = 1; |
|
| 30 | - define('_PIPELINE_SUFFIX', test_espace_prive() ? '_prive' : ''); |
|
| 31 | - |
|
| 32 | - // Faut-il initialiser SPIP ? (oui dans le cas general) |
|
| 33 | - if (!defined('_DIR_RESTREINT_ABS')) { |
|
| 34 | - if (defined('_DIR_RESTREINT') |
|
| 35 | - and @file_exists(_ROOT_RESTREINT . 'inc_version.php') |
|
| 36 | - ) { |
|
| 37 | - include_once _ROOT_RESTREINT . 'inc_version.php'; |
|
| 38 | - } else { |
|
| 39 | - die('inc_version absent ?'); |
|
| 40 | - } |
|
| 41 | - } // $fond defini dans le fichier d'appel ? |
|
| 42 | - |
|
| 43 | - else { |
|
| 44 | - if (isset($fond) and !_request('fond')) { |
|
| 45 | - } // fond demande dans l'url par page=xxxx ? |
|
| 46 | - else { |
|
| 47 | - if (isset($_GET[_SPIP_PAGE])) { |
|
| 48 | - $fond = (string)$_GET[_SPIP_PAGE]; |
|
| 49 | - |
|
| 50 | - // Securite |
|
| 51 | - if (strstr($fond, '/') |
|
| 52 | - and !( |
|
| 53 | - isset($GLOBALS['visiteur_session']) // pour eviter d'evaluer la suite pour les anonymes |
|
| 54 | - and include_spip('inc/autoriser') |
|
| 55 | - and autoriser('webmestre')) |
|
| 56 | - ) { |
|
| 57 | - include_spip('inc/minipres'); |
|
| 58 | - echo minipres(); |
|
| 59 | - exit; |
|
| 60 | - } |
|
| 61 | - // l'argument Page a priorite sur l'argument action |
|
| 62 | - // le cas se presente a cause des RewriteRule d'Apache |
|
| 63 | - // qui permettent d'ajouter un argument dans la QueryString |
|
| 64 | - // mais pas d'en retirer un en conservant les autres. |
|
| 65 | - if (isset($_GET['action']) and $_GET['action'] === $fond) { |
|
| 66 | - unset($_GET['action']); |
|
| 67 | - } |
|
| 68 | - # sinon, fond par defaut |
|
| 69 | - } else { |
|
| 70 | - // sinon fond par defaut (cf. assembler.php) |
|
| 71 | - $fond = pipeline('detecter_fond_par_defaut', ''); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $tableau_des_temps = array(); |
|
| 77 | - |
|
| 78 | - // Particularites de certains squelettes |
|
| 79 | - if ($fond == 'login') { |
|
| 80 | - $forcer_lang = true; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - if (isset($forcer_lang) and $forcer_lang and ($forcer_lang !== 'non') |
|
| 84 | - and !_request('action') |
|
| 85 | - and $_SERVER['REQUEST_METHOD'] != 'POST' |
|
| 86 | - ) { |
|
| 87 | - include_spip('inc/lang'); |
|
| 88 | - verifier_lang_url(); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $lang = !isset($_GET['lang']) ? '' : lang_select($_GET['lang']); |
|
| 92 | - |
|
| 93 | - // Charger l'aiguilleur des traitements derogatoires |
|
| 94 | - // (action en base SQL, formulaires CVT, AJax) |
|
| 95 | - if (_request('action') or _request('var_ajax') or _request('formulaire_action')) { |
|
| 96 | - include_spip('public/aiguiller'); |
|
| 97 | - if ( |
|
| 98 | - // cas des appels actions ?action=xxx |
|
| 99 | - traiter_appels_actions() |
|
| 100 | - or |
|
| 101 | - // cas des hits ajax sur les inclusions ajax |
|
| 102 | - traiter_appels_inclusions_ajax() |
|
| 103 | - or |
|
| 104 | - // cas des formulaires charger/verifier/traiter |
|
| 105 | - traiter_formulaires_dynamiques() |
|
| 106 | - ) { |
|
| 107 | - // lancer les taches sur affichage final, comme le cron |
|
| 108 | - // mais sans rien afficher |
|
| 109 | - $GLOBALS['html'] = false; // ne rien afficher |
|
| 110 | - pipeline('affichage_final' . _PIPELINE_SUFFIX, ''); |
|
| 111 | - exit; // le hit est fini ! |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - // Il y a du texte a produire, charger le metteur en page |
|
| 116 | - include_spip('public/assembler'); |
|
| 117 | - $page = assembler($fond, _request('connect')); |
|
| 118 | - |
|
| 119 | - if (isset($page['status'])) { |
|
| 120 | - include_spip('inc/headers'); |
|
| 121 | - http_status($page['status']); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // Content-Type ? |
|
| 125 | - if (!isset($page['entetes']['Content-Type'])) { |
|
| 126 | - $charset = isset($GLOBALS['meta']['charset']) ? $GLOBALS['meta']['charset'] : "utf-8"; |
|
| 127 | - $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; |
|
| 128 | - $html = true; |
|
| 129 | - } else { |
|
| 130 | - $html = preg_match(',^\s*text/html,', $page['entetes']['Content-Type']); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // Tester si on est admin et il y a des choses supplementaires a dire |
|
| 134 | - // type tableau pour y mettre des choses au besoin. |
|
| 135 | - $debug = ((_request('var_mode') == 'debug') or $tableau_des_temps) ? array(1) : array(); |
|
| 136 | - |
|
| 137 | - // affiche-t-on les boutons d'administration ? voir f_admin() |
|
| 138 | - $affiche_boutons_admin = ($html and ( |
|
| 139 | - (isset($_COOKIE['spip_admin']) and (!isset($flag_preserver) or !$flag_preserver)) |
|
| 140 | - or ($debug and include_spip('inc/autoriser') and autoriser('debug')) |
|
| 141 | - or (defined('_VAR_PREVIEW') and _VAR_PREVIEW) |
|
| 142 | - )); |
|
| 143 | - |
|
| 144 | - if ($affiche_boutons_admin) { |
|
| 145 | - include_spip('balise/formulaire_admin'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - // Execution de la page calculee |
|
| 150 | - |
|
| 151 | - // traitements sur les entetes avant envoi |
|
| 152 | - // peut servir pour le plugin de stats |
|
| 153 | - $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']); |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - // eval $page et affecte $res |
|
| 157 | - include _ROOT_RESTREINT . "public/evaluer_page.php"; |
|
| 158 | - envoyer_entetes($page['entetes']); |
|
| 159 | - if ($res === false) { |
|
| 160 | - include_spip('inc/autoriser'); |
|
| 161 | - $err = _T('zbug_erreur_execution_page'); |
|
| 162 | - if (autoriser('webmestre')) { |
|
| 163 | - $err .= "\n<hr />\n" |
|
| 164 | - . highlight_string($page['codephp'], true) |
|
| 165 | - . "\n<hr />\n"; |
|
| 166 | - } |
|
| 167 | - $msg = array($err); |
|
| 168 | - erreur_squelette($msg); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - // |
|
| 172 | - // Envoyer le resultat apres post-traitements |
|
| 173 | - // |
|
| 174 | - // (c'est ici qu'on fait var_recherche, validation, boutons d'admin, |
|
| 175 | - // cf. public/assembler.php) |
|
| 176 | - echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); |
|
| 177 | - |
|
| 178 | - if ($lang) { |
|
| 179 | - lang_select(); |
|
| 180 | - } |
|
| 181 | - // l'affichage de la page a pu lever des erreurs (inclusion manquante) |
|
| 182 | - // il faut tester a nouveau |
|
| 183 | - $debug = ((_request('var_mode') == 'debug') or $tableau_des_temps) ? array(1) : array(); |
|
| 184 | - |
|
| 185 | - // Appel au debusqueur en cas d'erreurs ou de demande de trace |
|
| 186 | - // at last |
|
| 187 | - if ($debug) { |
|
| 188 | - // en cas d'erreur, retester l'affichage |
|
| 189 | - if ($html and ($affiche_boutons_admin or $debug)) { |
|
| 190 | - $var_mode_affiche = _request('var_mode_affiche'); |
|
| 191 | - $var_mode_objet = _request('var_mode_objet'); |
|
| 192 | - $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ""); |
|
| 193 | - echo erreur_squelette(false); |
|
| 194 | - } |
|
| 195 | - } else { |
|
| 196 | - |
|
| 197 | - if (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 198 | - and $GLOBALS['meta']['date_prochain_postdate'] <= time() |
|
| 199 | - ) { |
|
| 200 | - include_spip('inc/rubriques'); |
|
| 201 | - calculer_prochain_postdate(true); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - // Effectuer une tache de fond ? |
|
| 205 | - // si _DIRECT_CRON_FORCE est present, on force l'appel |
|
| 206 | - if (defined('_DIRECT_CRON_FORCE')) { |
|
| 207 | - cron(); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // sauver le cache chemin si necessaire |
|
| 211 | - save_path_cache(); |
|
| 212 | - } |
|
| 29 | + $GLOBALS['_INC_PUBLIC'] = 1; |
|
| 30 | + define('_PIPELINE_SUFFIX', test_espace_prive() ? '_prive' : ''); |
|
| 31 | + |
|
| 32 | + // Faut-il initialiser SPIP ? (oui dans le cas general) |
|
| 33 | + if (!defined('_DIR_RESTREINT_ABS')) { |
|
| 34 | + if (defined('_DIR_RESTREINT') |
|
| 35 | + and @file_exists(_ROOT_RESTREINT . 'inc_version.php') |
|
| 36 | + ) { |
|
| 37 | + include_once _ROOT_RESTREINT . 'inc_version.php'; |
|
| 38 | + } else { |
|
| 39 | + die('inc_version absent ?'); |
|
| 40 | + } |
|
| 41 | + } // $fond defini dans le fichier d'appel ? |
|
| 42 | + |
|
| 43 | + else { |
|
| 44 | + if (isset($fond) and !_request('fond')) { |
|
| 45 | + } // fond demande dans l'url par page=xxxx ? |
|
| 46 | + else { |
|
| 47 | + if (isset($_GET[_SPIP_PAGE])) { |
|
| 48 | + $fond = (string)$_GET[_SPIP_PAGE]; |
|
| 49 | + |
|
| 50 | + // Securite |
|
| 51 | + if (strstr($fond, '/') |
|
| 52 | + and !( |
|
| 53 | + isset($GLOBALS['visiteur_session']) // pour eviter d'evaluer la suite pour les anonymes |
|
| 54 | + and include_spip('inc/autoriser') |
|
| 55 | + and autoriser('webmestre')) |
|
| 56 | + ) { |
|
| 57 | + include_spip('inc/minipres'); |
|
| 58 | + echo minipres(); |
|
| 59 | + exit; |
|
| 60 | + } |
|
| 61 | + // l'argument Page a priorite sur l'argument action |
|
| 62 | + // le cas se presente a cause des RewriteRule d'Apache |
|
| 63 | + // qui permettent d'ajouter un argument dans la QueryString |
|
| 64 | + // mais pas d'en retirer un en conservant les autres. |
|
| 65 | + if (isset($_GET['action']) and $_GET['action'] === $fond) { |
|
| 66 | + unset($_GET['action']); |
|
| 67 | + } |
|
| 68 | + # sinon, fond par defaut |
|
| 69 | + } else { |
|
| 70 | + // sinon fond par defaut (cf. assembler.php) |
|
| 71 | + $fond = pipeline('detecter_fond_par_defaut', ''); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $tableau_des_temps = array(); |
|
| 77 | + |
|
| 78 | + // Particularites de certains squelettes |
|
| 79 | + if ($fond == 'login') { |
|
| 80 | + $forcer_lang = true; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + if (isset($forcer_lang) and $forcer_lang and ($forcer_lang !== 'non') |
|
| 84 | + and !_request('action') |
|
| 85 | + and $_SERVER['REQUEST_METHOD'] != 'POST' |
|
| 86 | + ) { |
|
| 87 | + include_spip('inc/lang'); |
|
| 88 | + verifier_lang_url(); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $lang = !isset($_GET['lang']) ? '' : lang_select($_GET['lang']); |
|
| 92 | + |
|
| 93 | + // Charger l'aiguilleur des traitements derogatoires |
|
| 94 | + // (action en base SQL, formulaires CVT, AJax) |
|
| 95 | + if (_request('action') or _request('var_ajax') or _request('formulaire_action')) { |
|
| 96 | + include_spip('public/aiguiller'); |
|
| 97 | + if ( |
|
| 98 | + // cas des appels actions ?action=xxx |
|
| 99 | + traiter_appels_actions() |
|
| 100 | + or |
|
| 101 | + // cas des hits ajax sur les inclusions ajax |
|
| 102 | + traiter_appels_inclusions_ajax() |
|
| 103 | + or |
|
| 104 | + // cas des formulaires charger/verifier/traiter |
|
| 105 | + traiter_formulaires_dynamiques() |
|
| 106 | + ) { |
|
| 107 | + // lancer les taches sur affichage final, comme le cron |
|
| 108 | + // mais sans rien afficher |
|
| 109 | + $GLOBALS['html'] = false; // ne rien afficher |
|
| 110 | + pipeline('affichage_final' . _PIPELINE_SUFFIX, ''); |
|
| 111 | + exit; // le hit est fini ! |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + // Il y a du texte a produire, charger le metteur en page |
|
| 116 | + include_spip('public/assembler'); |
|
| 117 | + $page = assembler($fond, _request('connect')); |
|
| 118 | + |
|
| 119 | + if (isset($page['status'])) { |
|
| 120 | + include_spip('inc/headers'); |
|
| 121 | + http_status($page['status']); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // Content-Type ? |
|
| 125 | + if (!isset($page['entetes']['Content-Type'])) { |
|
| 126 | + $charset = isset($GLOBALS['meta']['charset']) ? $GLOBALS['meta']['charset'] : "utf-8"; |
|
| 127 | + $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; |
|
| 128 | + $html = true; |
|
| 129 | + } else { |
|
| 130 | + $html = preg_match(',^\s*text/html,', $page['entetes']['Content-Type']); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // Tester si on est admin et il y a des choses supplementaires a dire |
|
| 134 | + // type tableau pour y mettre des choses au besoin. |
|
| 135 | + $debug = ((_request('var_mode') == 'debug') or $tableau_des_temps) ? array(1) : array(); |
|
| 136 | + |
|
| 137 | + // affiche-t-on les boutons d'administration ? voir f_admin() |
|
| 138 | + $affiche_boutons_admin = ($html and ( |
|
| 139 | + (isset($_COOKIE['spip_admin']) and (!isset($flag_preserver) or !$flag_preserver)) |
|
| 140 | + or ($debug and include_spip('inc/autoriser') and autoriser('debug')) |
|
| 141 | + or (defined('_VAR_PREVIEW') and _VAR_PREVIEW) |
|
| 142 | + )); |
|
| 143 | + |
|
| 144 | + if ($affiche_boutons_admin) { |
|
| 145 | + include_spip('balise/formulaire_admin'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + // Execution de la page calculee |
|
| 150 | + |
|
| 151 | + // traitements sur les entetes avant envoi |
|
| 152 | + // peut servir pour le plugin de stats |
|
| 153 | + $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']); |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + // eval $page et affecte $res |
|
| 157 | + include _ROOT_RESTREINT . "public/evaluer_page.php"; |
|
| 158 | + envoyer_entetes($page['entetes']); |
|
| 159 | + if ($res === false) { |
|
| 160 | + include_spip('inc/autoriser'); |
|
| 161 | + $err = _T('zbug_erreur_execution_page'); |
|
| 162 | + if (autoriser('webmestre')) { |
|
| 163 | + $err .= "\n<hr />\n" |
|
| 164 | + . highlight_string($page['codephp'], true) |
|
| 165 | + . "\n<hr />\n"; |
|
| 166 | + } |
|
| 167 | + $msg = array($err); |
|
| 168 | + erreur_squelette($msg); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + // |
|
| 172 | + // Envoyer le resultat apres post-traitements |
|
| 173 | + // |
|
| 174 | + // (c'est ici qu'on fait var_recherche, validation, boutons d'admin, |
|
| 175 | + // cf. public/assembler.php) |
|
| 176 | + echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); |
|
| 177 | + |
|
| 178 | + if ($lang) { |
|
| 179 | + lang_select(); |
|
| 180 | + } |
|
| 181 | + // l'affichage de la page a pu lever des erreurs (inclusion manquante) |
|
| 182 | + // il faut tester a nouveau |
|
| 183 | + $debug = ((_request('var_mode') == 'debug') or $tableau_des_temps) ? array(1) : array(); |
|
| 184 | + |
|
| 185 | + // Appel au debusqueur en cas d'erreurs ou de demande de trace |
|
| 186 | + // at last |
|
| 187 | + if ($debug) { |
|
| 188 | + // en cas d'erreur, retester l'affichage |
|
| 189 | + if ($html and ($affiche_boutons_admin or $debug)) { |
|
| 190 | + $var_mode_affiche = _request('var_mode_affiche'); |
|
| 191 | + $var_mode_objet = _request('var_mode_objet'); |
|
| 192 | + $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ""); |
|
| 193 | + echo erreur_squelette(false); |
|
| 194 | + } |
|
| 195 | + } else { |
|
| 196 | + |
|
| 197 | + if (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 198 | + and $GLOBALS['meta']['date_prochain_postdate'] <= time() |
|
| 199 | + ) { |
|
| 200 | + include_spip('inc/rubriques'); |
|
| 201 | + calculer_prochain_postdate(true); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + // Effectuer une tache de fond ? |
|
| 205 | + // si _DIRECT_CRON_FORCE est present, on force l'appel |
|
| 206 | + if (defined('_DIRECT_CRON_FORCE')) { |
|
| 207 | + cron(); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // sauver le cache chemin si necessaire |
|
| 211 | + save_path_cache(); |
|
| 212 | + } |
|
| 213 | 213 | } |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | // Faut-il initialiser SPIP ? (oui dans le cas general) |
| 33 | 33 | if (!defined('_DIR_RESTREINT_ABS')) { |
| 34 | 34 | if (defined('_DIR_RESTREINT') |
| 35 | - and @file_exists(_ROOT_RESTREINT . 'inc_version.php') |
|
| 35 | + and @file_exists(_ROOT_RESTREINT.'inc_version.php') |
|
| 36 | 36 | ) { |
| 37 | - include_once _ROOT_RESTREINT . 'inc_version.php'; |
|
| 37 | + include_once _ROOT_RESTREINT.'inc_version.php'; |
|
| 38 | 38 | } else { |
| 39 | 39 | die('inc_version absent ?'); |
| 40 | 40 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | } // fond demande dans l'url par page=xxxx ? |
| 46 | 46 | else { |
| 47 | 47 | if (isset($_GET[_SPIP_PAGE])) { |
| 48 | - $fond = (string)$_GET[_SPIP_PAGE]; |
|
| 48 | + $fond = (string) $_GET[_SPIP_PAGE]; |
|
| 49 | 49 | |
| 50 | 50 | // Securite |
| 51 | 51 | if (strstr($fond, '/') |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | // lancer les taches sur affichage final, comme le cron |
| 108 | 108 | // mais sans rien afficher |
| 109 | 109 | $GLOBALS['html'] = false; // ne rien afficher |
| 110 | - pipeline('affichage_final' . _PIPELINE_SUFFIX, ''); |
|
| 110 | + pipeline('affichage_final'._PIPELINE_SUFFIX, ''); |
|
| 111 | 111 | exit; // le hit est fini ! |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | // Content-Type ? |
| 125 | 125 | if (!isset($page['entetes']['Content-Type'])) { |
| 126 | 126 | $charset = isset($GLOBALS['meta']['charset']) ? $GLOBALS['meta']['charset'] : "utf-8"; |
| 127 | - $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; |
|
| 127 | + $page['entetes']['Content-Type'] = 'text/html; charset='.$charset; |
|
| 128 | 128 | $html = true; |
| 129 | 129 | } else { |
| 130 | 130 | $html = preg_match(',^\s*text/html,', $page['entetes']['Content-Type']); |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | // traitements sur les entetes avant envoi |
| 152 | 152 | // peut servir pour le plugin de stats |
| 153 | - $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']); |
|
| 153 | + $page['entetes'] = pipeline('affichage_entetes_final'._PIPELINE_SUFFIX, $page['entetes']); |
|
| 154 | 154 | |
| 155 | 155 | |
| 156 | 156 | // eval $page et affecte $res |
| 157 | - include _ROOT_RESTREINT . "public/evaluer_page.php"; |
|
| 157 | + include _ROOT_RESTREINT."public/evaluer_page.php"; |
|
| 158 | 158 | envoyer_entetes($page['entetes']); |
| 159 | 159 | if ($res === false) { |
| 160 | 160 | include_spip('inc/autoriser'); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | // |
| 174 | 174 | // (c'est ici qu'on fait var_recherche, validation, boutons d'admin, |
| 175 | 175 | // cf. public/assembler.php) |
| 176 | - echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); |
|
| 176 | + echo pipeline('affichage_final'._PIPELINE_SUFFIX, $page['texte']); |
|
| 177 | 177 | |
| 178 | 178 | if ($lang) { |
| 179 | 179 | lang_select(); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | if ($html and ($affiche_boutons_admin or $debug)) { |
| 190 | 190 | $var_mode_affiche = _request('var_mode_affiche'); |
| 191 | 191 | $var_mode_objet = _request('var_mode_objet'); |
| 192 | - $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ""); |
|
| 192 | + $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet.'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ""); |
|
| 193 | 193 | echo erreur_squelette(false); |
| 194 | 194 | } |
| 195 | 195 | } else { |
@@ -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 | /** |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | * @return int |
| 28 | 28 | */ |
| 29 | 29 | function genie_mise_a_jour_dist($t) { |
| 30 | - include_spip('inc/meta'); |
|
| 31 | - $maj = info_maj('spip', 'SPIP', $GLOBALS['spip_version_branche']); |
|
| 32 | - ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : "", 'non'); |
|
| 30 | + include_spip('inc/meta'); |
|
| 31 | + $maj = info_maj('spip', 'SPIP', $GLOBALS['spip_version_branche']); |
|
| 32 | + ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : "", 'non'); |
|
| 33 | 33 | |
| 34 | - mise_a_jour_ecran_securite(); |
|
| 34 | + mise_a_jour_ecran_securite(); |
|
| 35 | 35 | |
| 36 | - spip_log("Verification version SPIP : " . ($maj ? $maj : "version a jour"), "verifie_maj"); |
|
| 36 | + spip_log("Verification version SPIP : " . ($maj ? $maj : "version a jour"), "verifie_maj"); |
|
| 37 | 37 | |
| 38 | - return 1; |
|
| 38 | + return 1; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // TODO : fournir une URL sur spip.net pour maitriser la diffusion d'une nouvelle version de l'ecran via l'update auto |
@@ -52,45 +52,45 @@ discard block |
||
| 52 | 52 | * ou de ne repondre une 304 que si le md5 est bon |
| 53 | 53 | */ |
| 54 | 54 | function mise_a_jour_ecran_securite() { |
| 55 | - // TODO : url https avec verification du certificat |
|
| 56 | - return; |
|
| 57 | - |
|
| 58 | - // si l'ecran n'est pas deja present ou pas updatable, sortir |
|
| 59 | - if (!_URL_ECRAN_SECURITE |
|
| 60 | - or !file_exists($filename = _DIR_ETC . "ecran_securite.php") |
|
| 61 | - or !is_writable($filename) |
|
| 62 | - or !$last_modified = filemtime($filename) |
|
| 63 | - or !$md5 = md5_file($filename) |
|
| 64 | - ) { |
|
| 65 | - return false; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - include_spip('inc/distant'); |
|
| 69 | - $tmp_file = _DIR_TMP . "ecran_securite.php"; |
|
| 70 | - $url = parametre_url(_URL_ECRAN_SECURITE, "md5", $md5); |
|
| 71 | - $url = parametre_url($url, "vspip", $GLOBALS['spip_version_branche']); |
|
| 72 | - $res = recuperer_url($url, array( |
|
| 73 | - 'if_modified_since' => $last_modified, |
|
| 74 | - 'file' => $tmp_file |
|
| 75 | - )); |
|
| 76 | - |
|
| 77 | - // si il y a une version plus recente que l'on a recu correctement |
|
| 78 | - if ($res['status'] == 200 |
|
| 79 | - and $res['length'] |
|
| 80 | - and $tmp_file = $res['file'] |
|
| 81 | - ) { |
|
| 82 | - |
|
| 83 | - if ($md5 !== md5_file($tmp_file)) { |
|
| 84 | - // on essaye de l'inclure pour verifier que ca ne fait pas erreur fatale |
|
| 85 | - include_once $tmp_file; |
|
| 86 | - // ok, on le copie a la place de l'ecran existant |
|
| 87 | - // en backupant l'ecran avant, au cas ou |
|
| 88 | - @copy($filename, $filename . "-bck-" . date('Y-m-d-His', $last_modified)); |
|
| 89 | - @rename($tmp_file, $filename); |
|
| 90 | - } else { |
|
| 91 | - @unlink($tmp_file); |
|
| 92 | - } |
|
| 93 | - } |
|
| 55 | + // TODO : url https avec verification du certificat |
|
| 56 | + return; |
|
| 57 | + |
|
| 58 | + // si l'ecran n'est pas deja present ou pas updatable, sortir |
|
| 59 | + if (!_URL_ECRAN_SECURITE |
|
| 60 | + or !file_exists($filename = _DIR_ETC . "ecran_securite.php") |
|
| 61 | + or !is_writable($filename) |
|
| 62 | + or !$last_modified = filemtime($filename) |
|
| 63 | + or !$md5 = md5_file($filename) |
|
| 64 | + ) { |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + include_spip('inc/distant'); |
|
| 69 | + $tmp_file = _DIR_TMP . "ecran_securite.php"; |
|
| 70 | + $url = parametre_url(_URL_ECRAN_SECURITE, "md5", $md5); |
|
| 71 | + $url = parametre_url($url, "vspip", $GLOBALS['spip_version_branche']); |
|
| 72 | + $res = recuperer_url($url, array( |
|
| 73 | + 'if_modified_since' => $last_modified, |
|
| 74 | + 'file' => $tmp_file |
|
| 75 | + )); |
|
| 76 | + |
|
| 77 | + // si il y a une version plus recente que l'on a recu correctement |
|
| 78 | + if ($res['status'] == 200 |
|
| 79 | + and $res['length'] |
|
| 80 | + and $tmp_file = $res['file'] |
|
| 81 | + ) { |
|
| 82 | + |
|
| 83 | + if ($md5 !== md5_file($tmp_file)) { |
|
| 84 | + // on essaye de l'inclure pour verifier que ca ne fait pas erreur fatale |
|
| 85 | + include_once $tmp_file; |
|
| 86 | + // ok, on le copie a la place de l'ecran existant |
|
| 87 | + // en backupant l'ecran avant, au cas ou |
|
| 88 | + @copy($filename, $filename . "-bck-" . date('Y-m-d-His', $last_modified)); |
|
| 89 | + @rename($tmp_file, $filename); |
|
| 90 | + } else { |
|
| 91 | + @unlink($tmp_file); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -108,52 +108,52 @@ discard block |
||
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | 110 | function info_maj($dir, $file, $version) { |
| 111 | - include_spip('inc/plugin'); |
|
| 112 | - |
|
| 113 | - list($maj, $min, $rev) = preg_split('/\D+/', $version); |
|
| 114 | - |
|
| 115 | - $nom = _DIR_CACHE_XML . _VERSIONS_LISTE; |
|
| 116 | - $page = !file_exists($nom) ? '' : file_get_contents($nom); |
|
| 117 | - $page = info_maj_cache($nom, $dir, $page); |
|
| 118 | - |
|
| 119 | - // reperer toutes les versions de numero majeur superieur ou egal |
|
| 120 | - // (a revoir quand on arrivera a SPIP V10 ...) |
|
| 121 | - $p = substr("0123456789", intval($maj)); |
|
| 122 | - $p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i'; |
|
| 123 | - preg_match_all($p, $page, $m, PREG_SET_ORDER); |
|
| 124 | - $page = $page_majeure = ''; |
|
| 125 | - |
|
| 126 | - // branche en cours d'utilisation |
|
| 127 | - $branche = implode('.', array_slice(explode('.', $version, 3), 0, 2)); |
|
| 128 | - |
|
| 129 | - foreach ($m as $v) { |
|
| 130 | - $v = array_pad($v, 5, 0); |
|
| 131 | - list(, $maj2, $min2, , $rev2) = $v; |
|
| 132 | - $branche_maj = $maj2 . '.' . $min2; |
|
| 133 | - $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 134 | - // d'abord les mises à jour de la même branche |
|
| 135 | - if ((spip_version_compare($version, $version_maj, '<')) |
|
| 136 | - and (spip_version_compare($page, $version_maj, '<')) |
|
| 137 | - and spip_version_compare($branche, $branche_maj, '=') |
|
| 138 | - ) { |
|
| 139 | - $page = $version_maj; |
|
| 140 | - } |
|
| 141 | - // puis les mises à jours majeures |
|
| 142 | - if ((spip_version_compare($version, $version_maj, '<')) |
|
| 143 | - and (spip_version_compare($page, $version_maj, '<')) |
|
| 144 | - and spip_version_compare($branche, $branche_maj, '<') |
|
| 145 | - ) { |
|
| 146 | - $page_majeure = $version_maj; |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - if (!$page and !$page_majeure) { |
|
| 150 | - return ""; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - $message = $page ? _T('nouvelle_version_spip', array('version' => $page)) . ($page_majeure ? ' | ' : '') : ''; |
|
| 154 | - $message .= $page_majeure ? _T('nouvelle_version_spip_majeure', array('version' => $page_majeure)) : ''; |
|
| 155 | - |
|
| 156 | - return "<a class='info_maj_spip' href='https://www.spip.net/fr_update' title='$page'>" . $message . '</a>'; |
|
| 111 | + include_spip('inc/plugin'); |
|
| 112 | + |
|
| 113 | + list($maj, $min, $rev) = preg_split('/\D+/', $version); |
|
| 114 | + |
|
| 115 | + $nom = _DIR_CACHE_XML . _VERSIONS_LISTE; |
|
| 116 | + $page = !file_exists($nom) ? '' : file_get_contents($nom); |
|
| 117 | + $page = info_maj_cache($nom, $dir, $page); |
|
| 118 | + |
|
| 119 | + // reperer toutes les versions de numero majeur superieur ou egal |
|
| 120 | + // (a revoir quand on arrivera a SPIP V10 ...) |
|
| 121 | + $p = substr("0123456789", intval($maj)); |
|
| 122 | + $p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i'; |
|
| 123 | + preg_match_all($p, $page, $m, PREG_SET_ORDER); |
|
| 124 | + $page = $page_majeure = ''; |
|
| 125 | + |
|
| 126 | + // branche en cours d'utilisation |
|
| 127 | + $branche = implode('.', array_slice(explode('.', $version, 3), 0, 2)); |
|
| 128 | + |
|
| 129 | + foreach ($m as $v) { |
|
| 130 | + $v = array_pad($v, 5, 0); |
|
| 131 | + list(, $maj2, $min2, , $rev2) = $v; |
|
| 132 | + $branche_maj = $maj2 . '.' . $min2; |
|
| 133 | + $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 134 | + // d'abord les mises à jour de la même branche |
|
| 135 | + if ((spip_version_compare($version, $version_maj, '<')) |
|
| 136 | + and (spip_version_compare($page, $version_maj, '<')) |
|
| 137 | + and spip_version_compare($branche, $branche_maj, '=') |
|
| 138 | + ) { |
|
| 139 | + $page = $version_maj; |
|
| 140 | + } |
|
| 141 | + // puis les mises à jours majeures |
|
| 142 | + if ((spip_version_compare($version, $version_maj, '<')) |
|
| 143 | + and (spip_version_compare($page, $version_maj, '<')) |
|
| 144 | + and spip_version_compare($branche, $branche_maj, '<') |
|
| 145 | + ) { |
|
| 146 | + $page_majeure = $version_maj; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + if (!$page and !$page_majeure) { |
|
| 150 | + return ""; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + $message = $page ? _T('nouvelle_version_spip', array('version' => $page)) . ($page_majeure ? ' | ' : '') : ''; |
|
| 154 | + $message .= $page_majeure ? _T('nouvelle_version_spip_majeure', array('version' => $page_majeure)) : ''; |
|
| 155 | + |
|
| 156 | + return "<a class='info_maj_spip' href='https://www.spip.net/fr_update' title='$page'>" . $message . '</a>'; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -174,25 +174,25 @@ discard block |
||
| 174 | 174 | * Contenu du fichier de cache de l'info de maj de SPIP. |
| 175 | 175 | */ |
| 176 | 176 | function info_maj_cache($nom, $dir, $page = '') { |
| 177 | - include_spip('inc/acces'); |
|
| 178 | - $alea_ephemere = charger_aleas(); |
|
| 179 | - $re = '<archives id="a' . $alea_ephemere . '">'; |
|
| 180 | - if (preg_match("/$re/", $page)) { |
|
| 181 | - return $page; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE; |
|
| 185 | - $a = file_exists($nom) ? filemtime($nom) : ''; |
|
| 186 | - include_spip('inc/distant'); |
|
| 187 | - $res = recuperer_url_cache($url, array('if_modified_since' => $a)); |
|
| 188 | - // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 189 | - if ($res) { |
|
| 190 | - $page = $res['page'] ? $res['page'] : $page; |
|
| 191 | - } |
|
| 192 | - // Placer l'indicateur de fraicheur |
|
| 193 | - $page = preg_replace('/^<archives.*?>/', $re, $page); |
|
| 194 | - sous_repertoire(_DIR_CACHE_XML); |
|
| 195 | - ecrire_fichier($nom, $page); |
|
| 196 | - |
|
| 197 | - return $page; |
|
| 177 | + include_spip('inc/acces'); |
|
| 178 | + $alea_ephemere = charger_aleas(); |
|
| 179 | + $re = '<archives id="a' . $alea_ephemere . '">'; |
|
| 180 | + if (preg_match("/$re/", $page)) { |
|
| 181 | + return $page; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE; |
|
| 185 | + $a = file_exists($nom) ? filemtime($nom) : ''; |
|
| 186 | + include_spip('inc/distant'); |
|
| 187 | + $res = recuperer_url_cache($url, array('if_modified_since' => $a)); |
|
| 188 | + // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 189 | + if ($res) { |
|
| 190 | + $page = $res['page'] ? $res['page'] : $page; |
|
| 191 | + } |
|
| 192 | + // Placer l'indicateur de fraicheur |
|
| 193 | + $page = preg_replace('/^<archives.*?>/', $re, $page); |
|
| 194 | + sous_repertoire(_DIR_CACHE_XML); |
|
| 195 | + ecrire_fichier($nom, $page); |
|
| 196 | + |
|
| 197 | + return $page; |
|
| 198 | 198 | } |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | function genie_mise_a_jour_dist($t) { |
| 30 | 30 | include_spip('inc/meta'); |
| 31 | 31 | $maj = info_maj('spip', 'SPIP', $GLOBALS['spip_version_branche']); |
| 32 | - ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : "", 'non'); |
|
| 32 | + ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche']."|$maj") : "", 'non'); |
|
| 33 | 33 | |
| 34 | 34 | mise_a_jour_ecran_securite(); |
| 35 | 35 | |
| 36 | - spip_log("Verification version SPIP : " . ($maj ? $maj : "version a jour"), "verifie_maj"); |
|
| 36 | + spip_log("Verification version SPIP : ".($maj ? $maj : "version a jour"), "verifie_maj"); |
|
| 37 | 37 | |
| 38 | 38 | return 1; |
| 39 | 39 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // si l'ecran n'est pas deja present ou pas updatable, sortir |
| 59 | 59 | if (!_URL_ECRAN_SECURITE |
| 60 | - or !file_exists($filename = _DIR_ETC . "ecran_securite.php") |
|
| 60 | + or !file_exists($filename = _DIR_ETC."ecran_securite.php") |
|
| 61 | 61 | or !is_writable($filename) |
| 62 | 62 | or !$last_modified = filemtime($filename) |
| 63 | 63 | or !$md5 = md5_file($filename) |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | include_spip('inc/distant'); |
| 69 | - $tmp_file = _DIR_TMP . "ecran_securite.php"; |
|
| 69 | + $tmp_file = _DIR_TMP."ecran_securite.php"; |
|
| 70 | 70 | $url = parametre_url(_URL_ECRAN_SECURITE, "md5", $md5); |
| 71 | 71 | $url = parametre_url($url, "vspip", $GLOBALS['spip_version_branche']); |
| 72 | 72 | $res = recuperer_url($url, array( |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | include_once $tmp_file; |
| 86 | 86 | // ok, on le copie a la place de l'ecran existant |
| 87 | 87 | // en backupant l'ecran avant, au cas ou |
| 88 | - @copy($filename, $filename . "-bck-" . date('Y-m-d-His', $last_modified)); |
|
| 88 | + @copy($filename, $filename."-bck-".date('Y-m-d-His', $last_modified)); |
|
| 89 | 89 | @rename($tmp_file, $filename); |
| 90 | 90 | } else { |
| 91 | 91 | @unlink($tmp_file); |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | list($maj, $min, $rev) = preg_split('/\D+/', $version); |
| 114 | 114 | |
| 115 | - $nom = _DIR_CACHE_XML . _VERSIONS_LISTE; |
|
| 115 | + $nom = _DIR_CACHE_XML._VERSIONS_LISTE; |
|
| 116 | 116 | $page = !file_exists($nom) ? '' : file_get_contents($nom); |
| 117 | 117 | $page = info_maj_cache($nom, $dir, $page); |
| 118 | 118 | |
| 119 | 119 | // reperer toutes les versions de numero majeur superieur ou egal |
| 120 | 120 | // (a revoir quand on arrivera a SPIP V10 ...) |
| 121 | 121 | $p = substr("0123456789", intval($maj)); |
| 122 | - $p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i'; |
|
| 122 | + $p = ',/'.$file.'\D+(['.$p.']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i'; |
|
| 123 | 123 | preg_match_all($p, $page, $m, PREG_SET_ORDER); |
| 124 | 124 | $page = $page_majeure = ''; |
| 125 | 125 | |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | foreach ($m as $v) { |
| 130 | 130 | $v = array_pad($v, 5, 0); |
| 131 | - list(, $maj2, $min2, , $rev2) = $v; |
|
| 132 | - $branche_maj = $maj2 . '.' . $min2; |
|
| 133 | - $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 131 | + list(, $maj2, $min2,, $rev2) = $v; |
|
| 132 | + $branche_maj = $maj2.'.'.$min2; |
|
| 133 | + $version_maj = $maj2.'.'.$min2.'.'.$rev2; |
|
| 134 | 134 | // d'abord les mises à jour de la même branche |
| 135 | 135 | if ((spip_version_compare($version, $version_maj, '<')) |
| 136 | 136 | and (spip_version_compare($page, $version_maj, '<')) |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | return ""; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $message = $page ? _T('nouvelle_version_spip', array('version' => $page)) . ($page_majeure ? ' | ' : '') : ''; |
|
| 153 | + $message = $page ? _T('nouvelle_version_spip', array('version' => $page)).($page_majeure ? ' | ' : '') : ''; |
|
| 154 | 154 | $message .= $page_majeure ? _T('nouvelle_version_spip_majeure', array('version' => $page_majeure)) : ''; |
| 155 | 155 | |
| 156 | - return "<a class='info_maj_spip' href='https://www.spip.net/fr_update' title='$page'>" . $message . '</a>'; |
|
| 156 | + return "<a class='info_maj_spip' href='https://www.spip.net/fr_update' title='$page'>".$message.'</a>'; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | function info_maj_cache($nom, $dir, $page = '') { |
| 177 | 177 | include_spip('inc/acces'); |
| 178 | 178 | $alea_ephemere = charger_aleas(); |
| 179 | - $re = '<archives id="a' . $alea_ephemere . '">'; |
|
| 179 | + $re = '<archives id="a'.$alea_ephemere.'">'; |
|
| 180 | 180 | if (preg_match("/$re/", $page)) { |
| 181 | 181 | return $page; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - $url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE; |
|
| 184 | + $url = _VERSIONS_SERVEUR.$dir.'/'._VERSIONS_LISTE; |
|
| 185 | 185 | $a = file_exists($nom) ? filemtime($nom) : ''; |
| 186 | 186 | include_spip('inc/distant'); |
| 187 | 187 | $res = recuperer_url_cache($url, array('if_modified_since' => $a)); |
@@ -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('base/abstract_sql'); |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function genie_optimiser_dist($t) { |
| 37 | 37 | |
| 38 | - optimiser_base_une_table(); |
|
| 39 | - optimiser_base(); |
|
| 38 | + optimiser_base_une_table(); |
|
| 39 | + optimiser_base(); |
|
| 40 | 40 | |
| 41 | - // la date souhaitee pour le tour suivant = apres-demain a 4h du mat ; |
|
| 42 | - // sachant qu'on a un delai de 48h, on renvoie aujourd'hui a 4h du mat |
|
| 43 | - // avec une periode de flou entre 2h et 6h pour ne pas saturer un hebergeur |
|
| 44 | - // qui aurait beaucoup de sites SPIP |
|
| 45 | - return -(mktime(2, 0, 0) + rand(0, 3600 * 4)); |
|
| 41 | + // la date souhaitee pour le tour suivant = apres-demain a 4h du mat ; |
|
| 42 | + // sachant qu'on a un delai de 48h, on renvoie aujourd'hui a 4h du mat |
|
| 43 | + // avec une periode de flou entre 2h et 6h pour ne pas saturer un hebergeur |
|
| 44 | + // qui aurait beaucoup de sites SPIP |
|
| 45 | + return -(mktime(2, 0, 0) + rand(0, 3600 * 4)); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @return void |
| 58 | 58 | **/ |
| 59 | 59 | function optimiser_base($attente = 86400) { |
| 60 | - optimiser_base_disparus($attente); |
|
| 60 | + optimiser_base_disparus($attente); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -74,27 +74,27 @@ discard block |
||
| 74 | 74 | **/ |
| 75 | 75 | function optimiser_base_une_table() { |
| 76 | 76 | |
| 77 | - $tables = array(); |
|
| 78 | - $result = sql_showbase(); |
|
| 79 | - |
|
| 80 | - // on n'optimise qu'une seule table a chaque fois, |
|
| 81 | - // pour ne pas vautrer le systeme |
|
| 82 | - // lire http://dev.mysql.com/doc/refman/5.0/fr/optimize-table.html |
|
| 83 | - while ($row = sql_fetch($result)) { |
|
| 84 | - $tables[] = array_shift($row); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - if ($tables) { |
|
| 88 | - $table_op = intval(lire_config('optimiser_table', 0) + 1) % sizeof($tables); |
|
| 89 | - ecrire_config('optimiser_table', $table_op); |
|
| 90 | - $q = $tables[$table_op]; |
|
| 91 | - spip_log("debut d'optimisation de la table $q"); |
|
| 92 | - if (sql_optimize($q)) { |
|
| 93 | - spip_log("fin d'optimisation de la table $q"); |
|
| 94 | - } else { |
|
| 95 | - spip_log("Pas d'optimiseur necessaire"); |
|
| 96 | - } |
|
| 97 | - } |
|
| 77 | + $tables = array(); |
|
| 78 | + $result = sql_showbase(); |
|
| 79 | + |
|
| 80 | + // on n'optimise qu'une seule table a chaque fois, |
|
| 81 | + // pour ne pas vautrer le systeme |
|
| 82 | + // lire http://dev.mysql.com/doc/refman/5.0/fr/optimize-table.html |
|
| 83 | + while ($row = sql_fetch($result)) { |
|
| 84 | + $tables[] = array_shift($row); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + if ($tables) { |
|
| 88 | + $table_op = intval(lire_config('optimiser_table', 0) + 1) % sizeof($tables); |
|
| 89 | + ecrire_config('optimiser_table', $table_op); |
|
| 90 | + $q = $tables[$table_op]; |
|
| 91 | + spip_log("debut d'optimisation de la table $q"); |
|
| 92 | + if (sql_optimize($q)) { |
|
| 93 | + spip_log("fin d'optimisation de la table $q"); |
|
| 94 | + } else { |
|
| 95 | + spip_log("Pas d'optimiseur necessaire"); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -120,18 +120,18 @@ discard block |
||
| 120 | 120 | * Nombre de suppressions |
| 121 | 121 | **/ |
| 122 | 122 | function optimiser_sansref($table, $id, $sel, $and = '') { |
| 123 | - $in = array(); |
|
| 124 | - while ($row = sql_fetch($sel)) { |
|
| 125 | - $in[$row['id']] = true; |
|
| 126 | - } |
|
| 127 | - sql_free($sel); |
|
| 128 | - |
|
| 129 | - if ($in) { |
|
| 130 | - sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 131 | - spip_log("Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in))); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - return count($in); |
|
| 123 | + $in = array(); |
|
| 124 | + while ($row = sql_fetch($sel)) { |
|
| 125 | + $in[$row['id']] = true; |
|
| 126 | + } |
|
| 127 | + sql_free($sel); |
|
| 128 | + |
|
| 129 | + if ($in) { |
|
| 130 | + sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 131 | + spip_log("Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in))); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + return count($in); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
@@ -153,74 +153,74 @@ discard block |
||
| 153 | 153 | **/ |
| 154 | 154 | function optimiser_base_disparus($attente = 86400) { |
| 155 | 155 | |
| 156 | - # format = 20060610110141, si on veut forcer une optimisation tout de suite |
|
| 157 | - $mydate = sql_quote(date("Y-m-d H:i:s", time() - $attente)); |
|
| 156 | + # format = 20060610110141, si on veut forcer une optimisation tout de suite |
|
| 157 | + $mydate = sql_quote(date("Y-m-d H:i:s", time() - $attente)); |
|
| 158 | 158 | |
| 159 | - $n = 0; |
|
| 159 | + $n = 0; |
|
| 160 | 160 | |
| 161 | - // |
|
| 162 | - // Rubriques |
|
| 163 | - // |
|
| 161 | + // |
|
| 162 | + // Rubriques |
|
| 163 | + // |
|
| 164 | 164 | |
| 165 | - # les articles qui sont dans une id_rubrique inexistante |
|
| 166 | - # attention on controle id_rubrique>0 pour ne pas tuer les articles |
|
| 167 | - # specialement affectes a une rubrique non-existante (plugin, |
|
| 168 | - # cf. https://core.spip.net/issues/1549 ) |
|
| 169 | - $res = sql_select("A.id_article AS id", |
|
| 170 | - "spip_articles AS A |
|
| 165 | + # les articles qui sont dans une id_rubrique inexistante |
|
| 166 | + # attention on controle id_rubrique>0 pour ne pas tuer les articles |
|
| 167 | + # specialement affectes a une rubrique non-existante (plugin, |
|
| 168 | + # cf. https://core.spip.net/issues/1549 ) |
|
| 169 | + $res = sql_select("A.id_article AS id", |
|
| 170 | + "spip_articles AS A |
|
| 171 | 171 | LEFT JOIN spip_rubriques AS R |
| 172 | 172 | ON A.id_rubrique=R.id_rubrique", |
| 173 | - "A.id_rubrique > 0 |
|
| 173 | + "A.id_rubrique > 0 |
|
| 174 | 174 | AND R.id_rubrique IS NULL |
| 175 | 175 | AND A.maj < $mydate"); |
| 176 | 176 | |
| 177 | - $n += optimiser_sansref('spip_articles', 'id_article', $res); |
|
| 177 | + $n += optimiser_sansref('spip_articles', 'id_article', $res); |
|
| 178 | 178 | |
| 179 | - // les articles a la poubelle |
|
| 180 | - sql_delete("spip_articles", "statut='poubelle' AND maj < $mydate"); |
|
| 179 | + // les articles a la poubelle |
|
| 180 | + sql_delete("spip_articles", "statut='poubelle' AND maj < $mydate"); |
|
| 181 | 181 | |
| 182 | - // |
|
| 183 | - // Auteurs |
|
| 184 | - // |
|
| 182 | + // |
|
| 183 | + // Auteurs |
|
| 184 | + // |
|
| 185 | 185 | |
| 186 | - include_spip('action/editer_liens'); |
|
| 187 | - // optimiser les liens de tous les auteurs vers des objets effaces |
|
| 188 | - // et depuis des auteurs effaces |
|
| 189 | - $n += objet_optimiser_liens(array('auteur' => '*'), '*'); |
|
| 186 | + include_spip('action/editer_liens'); |
|
| 187 | + // optimiser les liens de tous les auteurs vers des objets effaces |
|
| 188 | + // et depuis des auteurs effaces |
|
| 189 | + $n += objet_optimiser_liens(array('auteur' => '*'), '*'); |
|
| 190 | 190 | |
| 191 | - # effacer les auteurs poubelle qui ne sont lies a rien |
|
| 192 | - $res = sql_select("A.id_auteur AS id", |
|
| 193 | - "spip_auteurs AS A |
|
| 191 | + # effacer les auteurs poubelle qui ne sont lies a rien |
|
| 192 | + $res = sql_select("A.id_auteur AS id", |
|
| 193 | + "spip_auteurs AS A |
|
| 194 | 194 | LEFT JOIN spip_auteurs_liens AS L |
| 195 | 195 | ON L.id_auteur=A.id_auteur", |
| 196 | - "L.id_auteur IS NULL |
|
| 196 | + "L.id_auteur IS NULL |
|
| 197 | 197 | AND A.statut='5poubelle' AND A.maj < $mydate"); |
| 198 | 198 | |
| 199 | - $n += optimiser_sansref('spip_auteurs', 'id_auteur', $res); |
|
| 200 | - |
|
| 201 | - # supprimer les auteurs 'nouveau' qui n'ont jamais donne suite |
|
| 202 | - # au mail de confirmation (45 jours pour repondre, ca devrait suffire) |
|
| 203 | - sql_delete("spip_auteurs", "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - 45 * 24 * 3600))); |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
|
| 207 | - * |
|
| 208 | - * L'index 'data' est un entier indiquant le nombre d'optimisations |
|
| 209 | - * qui ont été réalisées (par exemple le nombre de suppressions faites) |
|
| 210 | - * et qui doit être incrémenté par les fonctions |
|
| 211 | - * utilisant ce pipeline si elles suppriment des éléments. |
|
| 212 | - * |
|
| 213 | - * @pipeline_appel optimiser_base_disparus |
|
| 214 | - */ |
|
| 215 | - $n = pipeline('optimiser_base_disparus', array( |
|
| 216 | - 'args' => array( |
|
| 217 | - 'attente' => $attente, |
|
| 218 | - 'date' => $mydate |
|
| 219 | - ), |
|
| 220 | - 'data' => $n |
|
| 221 | - )); |
|
| 222 | - |
|
| 223 | - if (!$n) { |
|
| 224 | - spip_log("Optimisation des tables: aucun lien mort"); |
|
| 225 | - } |
|
| 199 | + $n += optimiser_sansref('spip_auteurs', 'id_auteur', $res); |
|
| 200 | + |
|
| 201 | + # supprimer les auteurs 'nouveau' qui n'ont jamais donne suite |
|
| 202 | + # au mail de confirmation (45 jours pour repondre, ca devrait suffire) |
|
| 203 | + sql_delete("spip_auteurs", "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - 45 * 24 * 3600))); |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
|
| 207 | + * |
|
| 208 | + * L'index 'data' est un entier indiquant le nombre d'optimisations |
|
| 209 | + * qui ont été réalisées (par exemple le nombre de suppressions faites) |
|
| 210 | + * et qui doit être incrémenté par les fonctions |
|
| 211 | + * utilisant ce pipeline si elles suppriment des éléments. |
|
| 212 | + * |
|
| 213 | + * @pipeline_appel optimiser_base_disparus |
|
| 214 | + */ |
|
| 215 | + $n = pipeline('optimiser_base_disparus', array( |
|
| 216 | + 'args' => array( |
|
| 217 | + 'attente' => $attente, |
|
| 218 | + 'date' => $mydate |
|
| 219 | + ), |
|
| 220 | + 'data' => $n |
|
| 221 | + )); |
|
| 222 | + |
|
| 223 | + if (!$n) { |
|
| 224 | + spip_log("Optimisation des tables: aucun lien mort"); |
|
| 225 | + } |
|
| 226 | 226 | } |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | sql_free($sel); |
| 128 | 128 | |
| 129 | 129 | if ($in) { |
| 130 | - sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 131 | - spip_log("Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in))); |
|
| 130 | + sql_delete($table, sql_in($id, array_keys($in)).($and ? " AND $and" : '')); |
|
| 131 | + spip_log("Numeros des entrees $id supprimees dans la table $table: ".implode(', ', array_keys($in))); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | return count($in); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | # supprimer les auteurs 'nouveau' qui n'ont jamais donne suite |
| 202 | 202 | # au mail de confirmation (45 jours pour repondre, ca devrait suffire) |
| 203 | - sql_delete("spip_auteurs", "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - 45 * 24 * 3600))); |
|
| 203 | + sql_delete("spip_auteurs", "statut='nouveau' AND maj < ".sql_quote(date('Y-m-d', time() - 45 * 24 * 3600))); |
|
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
@@ -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 | /** |
@@ -32,32 +32,32 @@ discard block |
||
| 32 | 32 | * @return int |
| 33 | 33 | */ |
| 34 | 34 | function genie_mail_dist($t) { |
| 35 | - $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 36 | - $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 37 | - |
|
| 38 | - $now = time(); |
|
| 39 | - if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) { |
|
| 40 | - ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now - (3600 * 24 * $jours_neuf))); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - $page = recuperer_fond('nouveautes', |
|
| 44 | - array('date' => $GLOBALS['meta']['dernier_envoi_neuf'], 'jours_neuf' => $jours_neuf), array('raw' => true)); |
|
| 45 | - |
|
| 46 | - if (strlen(trim($page['texte']))) { |
|
| 47 | - // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 48 | - $headers = ""; |
|
| 49 | - if (isset($page['entetes']) and count($page['entetes'])) { |
|
| 50 | - foreach ($page['entetes'] as $k => $v) { |
|
| 51 | - $headers .= (strlen($v) ? "$k: $v" : $k) . "\n"; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - include_spip("inc/notifications"); |
|
| 56 | - notifications_envoyer_mails($adresse_neuf, $page['texte'], "", "", $headers); |
|
| 57 | - ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now)); |
|
| 58 | - } else { |
|
| 59 | - spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - return 1; |
|
| 35 | + $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 36 | + $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 37 | + |
|
| 38 | + $now = time(); |
|
| 39 | + if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) { |
|
| 40 | + ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now - (3600 * 24 * $jours_neuf))); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + $page = recuperer_fond('nouveautes', |
|
| 44 | + array('date' => $GLOBALS['meta']['dernier_envoi_neuf'], 'jours_neuf' => $jours_neuf), array('raw' => true)); |
|
| 45 | + |
|
| 46 | + if (strlen(trim($page['texte']))) { |
|
| 47 | + // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 48 | + $headers = ""; |
|
| 49 | + if (isset($page['entetes']) and count($page['entetes'])) { |
|
| 50 | + foreach ($page['entetes'] as $k => $v) { |
|
| 51 | + $headers .= (strlen($v) ? "$k: $v" : $k) . "\n"; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + include_spip("inc/notifications"); |
|
| 56 | + notifications_envoyer_mails($adresse_neuf, $page['texte'], "", "", $headers); |
|
| 57 | + ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now)); |
|
| 58 | + } else { |
|
| 59 | + spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + return 1; |
|
| 63 | 63 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | $headers = ""; |
| 49 | 49 | if (isset($page['entetes']) and count($page['entetes'])) { |
| 50 | 50 | foreach ($page['entetes'] as $k => $v) { |
| 51 | - $headers .= (strlen($v) ? "$k: $v" : $k) . "\n"; |
|
| 51 | + $headers .= (strlen($v) ? "$k: $v" : $k)."\n"; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -11,74 +11,74 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Correction typographique francaise |
| 18 | 18 | |
| 19 | 19 | function typographie_fr_dist($letexte) { |
| 20 | 20 | |
| 21 | - static $trans; |
|
| 21 | + static $trans; |
|
| 22 | 22 | |
| 23 | - // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ; |
|
| 24 | - // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe |
|
| 25 | - if (!$trans) { |
|
| 26 | - $trans = array( |
|
| 27 | - "'" => '’', |
|
| 28 | - ' ' => '~', |
|
| 29 | - '»' => '»', |
|
| 30 | - '«' => '«', |
|
| 31 | - '”' => '”', |
|
| 32 | - '“' => '“', |
|
| 33 | - '°' => '°' |
|
| 34 | - ); |
|
| 35 | - $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°'); |
|
| 36 | - $chars_trans = array_keys($chars); |
|
| 37 | - $chars = array_values($chars); |
|
| 38 | - $chars_trans = implode(' ', array_map('chr', $chars_trans)); |
|
| 39 | - $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer')); |
|
| 40 | - $chars_trans = explode(' ', $chars_trans); |
|
| 41 | - foreach ($chars as $k => $r) { |
|
| 42 | - $trans[$chars_trans[$k]] = $r; |
|
| 43 | - } |
|
| 44 | - } |
|
| 23 | + // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ; |
|
| 24 | + // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe |
|
| 25 | + if (!$trans) { |
|
| 26 | + $trans = array( |
|
| 27 | + "'" => '’', |
|
| 28 | + ' ' => '~', |
|
| 29 | + '»' => '»', |
|
| 30 | + '«' => '«', |
|
| 31 | + '”' => '”', |
|
| 32 | + '“' => '“', |
|
| 33 | + '°' => '°' |
|
| 34 | + ); |
|
| 35 | + $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°'); |
|
| 36 | + $chars_trans = array_keys($chars); |
|
| 37 | + $chars = array_values($chars); |
|
| 38 | + $chars_trans = implode(' ', array_map('chr', $chars_trans)); |
|
| 39 | + $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer')); |
|
| 40 | + $chars_trans = explode(' ', $chars_trans); |
|
| 41 | + foreach ($chars as $k => $r) { |
|
| 42 | + $trans[$chars_trans[$k]] = $r; |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - $letexte = strtr($letexte, $trans); |
|
| 46 | + $letexte = strtr($letexte, $trans); |
|
| 47 | 47 | |
| 48 | - $cherche1 = array( |
|
| 49 | - /* 1 */ |
|
| 50 | - '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S', |
|
| 51 | - /* 2 */ |
|
| 52 | - '/»| --?,|(?::(?!:)| %)(?:\W|$)/S', |
|
| 53 | - /* 3 */ |
|
| 54 | - '/([^[<(!?.])([!?][!?\.]*)/iS', |
|
| 55 | - /* 4 */ |
|
| 56 | - '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S' |
|
| 57 | - ); |
|
| 58 | - $remplace1 = array( |
|
| 59 | - /* 1 */ |
|
| 60 | - '\1~;', |
|
| 61 | - /* 2 */ |
|
| 62 | - '~\0', |
|
| 63 | - /* 3 */ |
|
| 64 | - '\1~\2', |
|
| 65 | - /* 4 */ |
|
| 66 | - '\0~' |
|
| 67 | - ); |
|
| 68 | - $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 69 | - $letexte = preg_replace('/ *~+ */S', '~', $letexte); |
|
| 48 | + $cherche1 = array( |
|
| 49 | + /* 1 */ |
|
| 50 | + '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S', |
|
| 51 | + /* 2 */ |
|
| 52 | + '/»| --?,|(?::(?!:)| %)(?:\W|$)/S', |
|
| 53 | + /* 3 */ |
|
| 54 | + '/([^[<(!?.])([!?][!?\.]*)/iS', |
|
| 55 | + /* 4 */ |
|
| 56 | + '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S' |
|
| 57 | + ); |
|
| 58 | + $remplace1 = array( |
|
| 59 | + /* 1 */ |
|
| 60 | + '\1~;', |
|
| 61 | + /* 2 */ |
|
| 62 | + '~\0', |
|
| 63 | + /* 3 */ |
|
| 64 | + '\1~\2', |
|
| 65 | + /* 4 */ |
|
| 66 | + '\0~' |
|
| 67 | + ); |
|
| 68 | + $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 69 | + $letexte = preg_replace('/ *~+ */S', '~', $letexte); |
|
| 70 | 70 | |
| 71 | - $cherche2 = array( |
|
| 72 | - '/([^-\n]|^)--([^-]|$)/S', |
|
| 73 | - ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 74 | - '/~/' |
|
| 75 | - ); |
|
| 76 | - $remplace2 = array( |
|
| 77 | - '\1—\2', |
|
| 78 | - '\1\3\4', |
|
| 79 | - ' ' |
|
| 80 | - ); |
|
| 81 | - $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 71 | + $cherche2 = array( |
|
| 72 | + '/([^-\n]|^)--([^-]|$)/S', |
|
| 73 | + ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 74 | + '/~/' |
|
| 75 | + ); |
|
| 76 | + $remplace2 = array( |
|
| 77 | + '\1—\2', |
|
| 78 | + '\1\3\4', |
|
| 79 | + ' ' |
|
| 80 | + ); |
|
| 81 | + $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 82 | 82 | |
| 83 | - return $letexte; |
|
| 83 | + return $letexte; |
|
| 84 | 84 | } |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | |
| 71 | 71 | $cherche2 = array( |
| 72 | 72 | '/([^-\n]|^)--([^-]|$)/S', |
| 73 | - ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 73 | + ',('._PROTOCOLES_STD.')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 74 | 74 | '/~/' |
| 75 | 75 | ); |
| 76 | 76 | $remplace2 = array( |